Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/library/proxytrackmodel.h

Go to the documentation of this file.
00001 // proxytrackmodel.h
00002 // Created 10/22/2009 by RJ Ryan (rryan@mit.edu)
00003 
00004 #ifndef PROXYTRACKMODEL_H
00005 #define PROXYTRACKMODEL_H
00006 
00007 #include <QSortFilterProxyModel>
00008 #include <QAbstractItemModel>
00009 
00010 #include "library/trackmodel.h"
00011 
00012 // ProxyTrackModel composes a TrackModel inside of a QSortFilterProxyModel so
00013 // that the sorting and filtering of the QSortFilterProxyModel can be completely
00014 // transparent to the user of the TrackModel. The ProxyTrackModel will
00015 // automatically translate any QModelIndex's to their source index before
00016 // calling the composed TrackModel. If the bHandleSearches flag is set, the
00017 // TrackModel search calls will not be delivered to the composed TrackModel
00018 // because filtering is handled by the QSortFilterProxyModel.
00019 class ProxyTrackModel : public QSortFilterProxyModel, public virtual TrackModel {
00020   public:
00021     // Construct a new ProxyTrackModel with pTrackModel as the TrackModel it
00022     // composes. If bHandleSearches is true, then search signals will not be
00023     // delivered to pTrackModel -- instead the ProxyTrackModel will do its own
00024     // filtering.
00025     ProxyTrackModel(QAbstractItemModel* pTrackModel, bool bHandleSearches=true);
00026     virtual ~ProxyTrackModel();
00027 
00028     virtual TrackPointer getTrack(const QModelIndex& index) const;
00029     virtual QString getTrackLocation(const QModelIndex& index) const;
00030     virtual int getTrackId(const QModelIndex& index) const;
00031     virtual const QLinkedList<int> getTrackRows(int trackId) const;
00032     virtual void search(const QString& searchText);
00033     virtual const QString currentSearch() const;
00034     virtual bool isColumnInternal(int column);
00035     virtual bool isColumnHiddenByDefault(int column);
00036     virtual void removeTrack(const QModelIndex& index);
00037     virtual void removeTracks(const QModelIndexList& indices);
00038     virtual bool addTrack(const QModelIndex& index, QString location);
00039     virtual void moveTrack(const QModelIndex& sourceIndex,
00040                            const QModelIndex& destIndex);
00041     virtual QItemDelegate* delegateForColumn(const int i);
00042     virtual TrackModel::CapabilitiesFlags getCapabilities() const;
00043 
00044     bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
00045 
00046     virtual QString getModelSetting(QString name);
00047     virtual bool setModelSetting(QString name, QVariant value);
00048 
00049   private:
00050     TrackModel* m_pTrackModel;
00051     QString m_currentSearch;
00052     bool m_bHandleSearches;
00053 };
00054 
00055 #endif /* PROXYTRACKMODEL_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines