Revert previous commit, was incorrect
[amarok.git] / src / collectionbrowser / CollectionTreeView.h
blob7dd96d12fe5d64a0ff845e8b6d2dacf3f027b489
1 /******************************************************************************
2 * copyright: (c) 2007 Alexandre Pereira de Oliveira <aleprj@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License version 2 *
6 * as published by the Free Software Foundation. *
7 ******************************************************************************/
9 #ifndef COLLECTIONTREEVIEW_H
10 #define COLLECTIONTREEVIEW_H
12 #include "CollectionSortFilterProxyModel.h"
13 #include "CollectionTreeItem.h"
14 #include "playlist/PlaylistModel.h"
16 #include <QSet>
17 #include <QSortFilterProxyModel>
18 #include <QTimer>
19 #include <QTreeView>
21 class QSortFilterProxyModel;
22 class CollectionSortFilterProxyModel;
23 class CollectionTreeItemModel;
25 class CollectionTreeView: public QTreeView {
26 Q_OBJECT
27 public:
28 CollectionTreeView( QWidget *parent = 0 );
29 ~CollectionTreeView();
31 QSortFilterProxyModel* filterModel() const;
33 void setLevels( const QList<int> &levels );
34 void setLevel( int level, int type );
36 void setModel ( QAbstractItemModel * model );
37 void contextMenuEvent(QContextMenuEvent* event);
39 void setShowYears( bool show ) { m_showYears = show; }
40 const bool showYears() const { return m_showYears; }
42 void setShowTrackNumbers( bool show ) { m_showTrackNumbers = show; }
43 const bool showTrackNumbers() const { return m_showTrackNumbers; }
45 public slots:
46 void slotSetFilterTimeout();
48 protected:
49 void mousePressEvent( QMouseEvent *event );
50 void mouseMoveEvent( QMouseEvent *event );
51 void mouseDoubleClickEvent( QMouseEvent *event );
53 protected slots:
55 virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
56 void slotExpand( const QModelIndex &index );
57 void slotCollapsed( const QModelIndex &index );
59 private:
60 // Utility function to play all items
61 // that have this as a parent..
62 void playChildTracks( CollectionTreeItem *item, Playlist::AddOptions insertMode ) const;
63 void playChildTracks( const QSet<CollectionTreeItem*> &items, Playlist::AddOptions insertMode ) const;
64 CollectionSortFilterProxyModel *m_filterModel;
65 CollectionTreeItemModel *m_treeModel;
66 QTimer m_filterTimer;
67 QPoint m_dragStartPosition;
68 bool m_showTrackNumbers;
69 bool m_showYears;
71 signals:
73 void itemSelected( CollectionTreeItem * item );
76 #endif