PageRenderTime 121ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 65ms app.codeStats 0ms

/src/libtomahawk/playlist/trackproxymodel.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 69 lines | 35 code | 17 blank | 17 comment | 0 complexity | edba32f8db87863891330d7e5a2fad12 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *
 5 *   Tomahawk is free software: you can redistribute it and/or modify
 6 *   it under the terms of the GNU General Public License as published by
 7 *   the Free Software Foundation, either version 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef TRACKPROXYMODEL_H
20#define TRACKPROXYMODEL_H
21
22#include <QtGui/QSortFilterProxyModel>
23
24#include "playlistinterface.h"
25#include "playlist/trackmodel.h"
26
27#include "dllmacro.h"
28
29class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel
30{
31Q_OBJECT
32
33public:
34    explicit TrackProxyModel ( QObject* parent = 0 );
35    virtual ~TrackProxyModel() {}
36
37    virtual TrackModel* sourceModel() const { return m_model; }
38    virtual void setSourceTrackModel( TrackModel* sourceModel );
39    virtual void setSourceModel( QAbstractItemModel* model );
40
41    virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
42    virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
43
44    virtual void remove( const QModelIndex& index );
45    virtual void remove( const QModelIndexList& indexes );
46    virtual void remove( const QList< QPersistentModelIndex >& indexes );
47
48    virtual bool showOfflineResults() const { return m_showOfflineResults; }
49    virtual void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
50
51    virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); }
52
53    virtual TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
54
55    virtual Tomahawk::playlistinterface_ptr playlistInterface();
56
57signals:
58    void filterChanged( const QString& filter );
59
60protected:
61    virtual bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
62    virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
63
64    TrackModel* m_model;
65    bool m_showOfflineResults;
66    Tomahawk::playlistinterface_ptr m_playlistInterface;
67};
68
69#endif // TRACKPROXYMODEL_H