2 * Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library/Lesser General Public License
6 * version 2, or (at your option) any later version, as published by the
7 * Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library/Lesser General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef PLASMA_KCATEGORIZEDITEMSVIEW_P_H
21 #define PLASMA_KCATEGORIZEDITEMSVIEW_P_H
23 #include <QtGui/QtGui>
24 #include <QtCore/QtCore>
26 #include "kcategorizeditemsviewmodels_p.h"
28 #include "ui_kcategorizeditemsviewbase.h"
30 using namespace KCategorizedItemsViewModels
;
31 class KCategorizedItemsViewDelegate
;
34 * QT4 View Widget for displaying a list of categorized items with special
35 * filtering capabilities.
37 * To use it, you need to implement KCategorizedItemsView::AbstractItem
39 * For convenience, there are default implementations of category model
40 * (DefaultCategoryModel), filters model (DefaultFilterModel) and the
41 * default item mode (DefaultItemModel), but you do not need to use them.
43 * One constraint is that DefaultItemModel *must* hold the items that
44 * are subclassed from KCategorizedItemsView::AbstractItem
47 class KCategorizedItemsView
: public QWidget
, public Ui::KCategorizedItemsViewBase
52 explicit KCategorizedItemsView(QWidget
*parent
= 0, Qt::WindowFlags f
= 0);
53 virtual ~KCategorizedItemsView();
55 void setFilterModel(QStandardItemModel
*model
); ///< Sets the filters model
56 void setItemModel(QStandardItemModel
*model
); ///< Sets the item model, as mentioned items must implement AbstractItem class
58 void addEmblem(const QString
&title
, const QIcon
&icon
, const Filter
&filter
);
61 QList
< AbstractItem
* > selectedItems() const;
64 virtual void resizeEvent (QResizeEvent
*event
) ;
65 virtual bool event (QEvent
*event
);
68 void searchTermChanged(const QString
&text
);
69 void filterChanged(int index
);
72 void itemActivated(const QModelIndex
&index
);
73 void itemDoubleClicked(const QModelIndex
&index
);
74 void slotSearchTermChanged(const QString
&term
);
77 void activated(const QModelIndex
&index
);
78 void clicked(const QModelIndex
&index
);
79 void doubleClicked(const QModelIndex
&index
);
80 void entered(const QModelIndex
&index
);
81 void pressed(const QModelIndex
&index
);
84 void updateColumnsWidth(bool force
= false);
86 QStandardItemModel
*m_modelCategories
;
87 QStandardItemModel
*m_modelFilters
;
88 QStandardItemModel
*m_modelItems
;
90 DefaultItemFilterProxyModel
*m_modelFilterItems
;
91 KCategorizedItemsViewDelegate
*m_delegate
;
95 QMap
< QString
, QPair
< Filter
, QIcon
> > m_emblems
;
96 AbstractItem
*getItemByProxyIndex(const QModelIndex
&index
) const;
98 friend class KCategorizedItemsViewDelegate
;
99 friend class CustomDragTreeView
;
102 //Q_DECLARE_METATYPE(KCategorizedItemsView::Filter)