Warning, file /multimedia/amarok/src/playlistgenerator/ConstraintNode.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /**************************************************************************************** 0002 * Copyright (c) 2008-2012 Soren Harward <stharward@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #define DEBUG_PREFIX "APG::ConstraintNode" 0018 0019 #include "ConstraintNode.h" 0020 0021 #include "core/support/Debug.h" 0022 0023 #include <QList> 0024 0025 ConstraintNode::ConstraintNode( ConstraintNode* p ) : QObject( p ) { 0026 debug() << "new constraint node at" << (void*)this << "with parent at" << (void*)p; 0027 } 0028 0029 ConstraintNode::~ConstraintNode() 0030 { 0031 debug() << "destroying constraint at" << (void*)this << "that has parent" << (void*)QObject::parent(); 0032 qDeleteAll( m_children ); 0033 } 0034 0035 int ConstraintNode::row() const 0036 { 0037 ConstraintNode* p = parent(); 0038 if ( !p ) { 0039 return 0; 0040 } else { 0041 return p->where_is( this ); 0042 } 0043 } 0044 0045 int ConstraintNode::getRowCount() const 0046 { 0047 return m_children.size(); 0048 } 0049 0050 ConstraintNode* 0051 ConstraintNode::parent() const 0052 { 0053 return static_cast<ConstraintNode*>( QObject::parent() ); 0054 } 0055 0056 bool ConstraintNode::addChild( ConstraintNode* nc, int idx ) 0057 { 0058 if ( !m_children.contains( nc ) ) { 0059 if ( idx <= m_children.size() ) { 0060 m_children.insert( idx, nc ); 0061 } else { 0062 m_children.append( nc ); 0063 } 0064 return true; 0065 } else { 0066 debug() << "Tried to add a node that's already a child"; 0067 return false; 0068 } 0069 } 0070 0071 ConstraintNode* 0072 ConstraintNode::getChild( int idx ) 0073 { 0074 if ( idx < 0 ) 0075 return nullptr; 0076 0077 if ( idx < m_children.size() ) 0078 return m_children.at( idx ); 0079 0080 return nullptr; 0081 } 0082 0083 ConstraintNode* 0084 ConstraintNode::pruneChild( int idx ) 0085 { 0086 if ( idx < 0 ) 0087 return nullptr; 0088 if ( idx < m_children.size() ) { 0089 return m_children.takeAt( idx ); 0090 } 0091 return nullptr; 0092 } 0093 0094 bool 0095 ConstraintNode::removeChild( int idx ) 0096 { 0097 if ( idx < 0 ) 0098 return false; 0099 if ( idx < m_children.size() ) { 0100 ConstraintNode* n = m_children.takeAt( idx ); 0101 n->deleteLater(); 0102 return true; 0103 } 0104 return false; 0105 } 0106 0107 int 0108 ConstraintNode::where_is( const ConstraintNode* n ) const 0109 { 0110 // some nasty juju because indexOf isn't treating n as const 0111 ConstraintNode* x = const_cast<ConstraintNode*>( n ); 0112 return m_children.indexOf( x ); 0113 } 0114 0115 quint32 0116 ConstraintNode::suggestPlaylistSize() const 0117 { 0118 return 0; 0119 }