1 /******************************************************************************
2 * copyright: (c) 2007 Alexandre Pereira de Oliveira <aleprj@gmail.com> *
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"
17 #include <QSortFilterProxyModel>
21 class QSortFilterProxyModel
;
22 class CollectionSortFilterProxyModel
;
23 class CollectionTreeItemModel
;
25 class CollectionTreeView
: public QTreeView
{
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
; }
46 void slotSetFilterTimeout();
49 void mousePressEvent( QMouseEvent
*event
);
50 void mouseMoveEvent( QMouseEvent
*event
);
51 void mouseDoubleClickEvent( QMouseEvent
*event
);
55 virtual void selectionChanged ( const QItemSelection
& selected
, const QItemSelection
& deselected
);
56 void slotExpand( const QModelIndex
&index
);
57 void slotCollapsed( const QModelIndex
&index
);
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
;
67 QPoint m_dragStartPosition
;
68 bool m_showTrackNumbers
;
73 void itemSelected( CollectionTreeItem
* item
);