PageRenderTime 1215ms CodeModel.GetById 21ms RepoModel.GetById 1ms 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
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-3.0, GPL-2.0
  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. #ifndef TRACKPROXYMODEL_H
  19. #define TRACKPROXYMODEL_H
  20. #include <QtGui/QSortFilterProxyModel>
  21. #include "playlistinterface.h"
  22. #include "playlist/trackmodel.h"
  23. #include "dllmacro.h"
  24. class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel
  25. {
  26. Q_OBJECT
  27. public:
  28. explicit TrackProxyModel ( QObject* parent = 0 );
  29. virtual ~TrackProxyModel() {}
  30. virtual TrackModel* sourceModel() const { return m_model; }
  31. virtual void setSourceTrackModel( TrackModel* sourceModel );
  32. virtual void setSourceModel( QAbstractItemModel* model );
  33. virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
  34. virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
  35. virtual void remove( const QModelIndex& index );
  36. virtual void remove( const QModelIndexList& indexes );
  37. virtual void remove( const QList< QPersistentModelIndex >& indexes );
  38. virtual bool showOfflineResults() const { return m_showOfflineResults; }
  39. virtual void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
  40. virtual void emitFilterChanged( const QString &pattern ) { emit filterChanged( pattern ); }
  41. virtual TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
  42. virtual Tomahawk::playlistinterface_ptr playlistInterface();
  43. signals:
  44. void filterChanged( const QString& filter );
  45. protected:
  46. virtual bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const;
  47. virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
  48. TrackModel* m_model;
  49. bool m_showOfflineResults;
  50. Tomahawk::playlistinterface_ptr m_playlistInterface;
  51. };
  52. #endif // TRACKPROXYMODEL_H