Warning, file /multimedia/amarok/src/browsers/CollectionTreeItem.h 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) 2007 Alexandre Pereira de Oliveira <aleprj@gmail.com> * 0003 * Copyright (c) 2007-2009 Maximilian Kossick <maximilian.kossick@googlemail.com> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 #ifndef COLLECTIONTREEITEM_H 0019 #define COLLECTIONTREEITEM_H 0020 0021 #include "amarok_export.h" 0022 #include "browsers/BrowserDefines.h" 0023 #include "core/collections/Collection.h" 0024 #include "core/meta/forward_declarations.h" 0025 0026 #include <QList> 0027 0028 class CollectionTreeItemModelBase; 0029 class QAction; 0030 0031 class AMAROK_EXPORT CollectionTreeItem : public QObject 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 enum Type 0037 { 0038 Root, 0039 Collection, 0040 VariousArtist, 0041 NoLabel, 0042 Data 0043 }; 0044 Q_ENUM( Type ) 0045 0046 explicit CollectionTreeItem( CollectionTreeItemModelBase *model ); //root node 0047 CollectionTreeItem( const Meta::DataPtr &data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //data node 0048 CollectionTreeItem( Collections::Collection *parentCollection, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //collection node 0049 //this ctor creates a "Various Artists" and "No Labels" nodes. do not use it for anything else 0050 CollectionTreeItem( Type type, const Meta::DataList &data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //various artist node 0051 0052 ~CollectionTreeItem() override; 0053 0054 CollectionTreeItem* parent() const { return m_parent; } 0055 0056 void appendChild( CollectionTreeItem *child ); 0057 void removeChild( int index ); 0058 0059 CollectionTreeItem* child( int row ); 0060 0061 int childCount() const { return m_childItems.count(); } 0062 int columnCount() const { return 1; } 0063 QList<CollectionTreeItem*> children() const; 0064 0065 QVariant data( int role ) const; 0066 0067 int row() const; 0068 0069 int level() const; 0070 0071 bool isDataItem() const; 0072 bool isAlbumItem() const; 0073 bool isTrackItem() const; 0074 bool isVariousArtistItem() const; 0075 bool isNoLabelItem() const; 0076 0077 Collections::QueryMaker* queryMaker() const; 0078 0079 /** 0080 * Call addMatch for this objects data and it's query maker. Handles VariousArtist 0081 * item and NoLabel item, too. 0082 * 0083 * @param qm QueryMaker to add match to 0084 * @param levelCategory category for level this item is in, one of the values from 0085 * CategoryId::CatMenuId enum. Used only for distinction between Artist and 0086 * AlbumArtist. 0087 */ 0088 void addMatch( Collections::QueryMaker *qm, CategoryId::CatMenuId levelCategory ) const; 0089 0090 bool operator<( const CollectionTreeItem &other ) const; 0091 0092 const Meta::DataPtr data() const; 0093 Collections::Collection* parentCollection() const { return m_parentCollection ? m_parentCollection : (m_parent ? m_parent->parentCollection() : nullptr); } 0094 0095 QList<QUrl> urls() const; 0096 Meta::TrackList descendentTracks(); 0097 0098 bool allDescendentTracksLoaded() const; 0099 0100 //required to mark a tree item as dirty if the model has to require its children 0101 0102 Type type() const; 0103 bool requiresUpdate() const; 0104 void setRequiresUpdate( bool updateRequired ); 0105 0106 Q_SIGNALS: 0107 void dataUpdated(); 0108 0109 private Q_SLOTS: 0110 void tracksCounted( QStringList res ); 0111 void collectionUpdated(); 0112 0113 private: 0114 /** Returns a list of collection actions. 0115 Collection actions are shown on top of the collection tree item as icons (decorations) 0116 */ 0117 QList<QAction *> decoratorActions() const; 0118 void prepareForRemoval(); 0119 0120 Meta::DataPtr m_data; 0121 CollectionTreeItem *m_parent; 0122 CollectionTreeItemModelBase *m_model; 0123 Collections::Collection *m_parentCollection; 0124 0125 QList<CollectionTreeItem*> m_childItems; 0126 bool m_updateRequired; 0127 int m_trackCount; 0128 Type m_type; 0129 //QString m_name; 0130 mutable bool m_isCounting; 0131 }; 0132 0133 Q_DECLARE_METATYPE( CollectionTreeItem* ) 0134 Q_DECLARE_METATYPE( QList<CollectionTreeItem*> ) 0135 0136 #endif