1 | /*************************************************************************** |
2 | * Copyright (C) 2012 by Peter Penz <peter.penz19@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 as published by * |
6 | * the Free Software Foundation; either version 2 of the License, or * |
7 | * (at your option) any later version. * |
8 | * * |
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. * |
13 | * * |
14 | * You should have received a copy of the GNU General Public License * |
15 | * 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 * |
18 | ***************************************************************************/ |
19 | |
20 | #ifndef KSTANDARDITEMLISTVIEW_H |
21 | #define KSTANDARDITEMLISTVIEW_H |
22 | |
23 | #include <libdolphin_export.h> |
24 | |
25 | #include <kitemviews/kitemlistview.h> |
26 | |
27 | /** |
28 | * @brief Provides layouts for icons-, compact- and details-view. |
29 | * |
30 | * Together with the KStandardItemModel lists for standard usecases |
31 | * can be created in a straight forward way. |
32 | * |
33 | * Example code: |
34 | * <code> |
35 | * KStandardItemListView* view = new KStandardItemListView(); |
36 | * KStandardItemModel* model = new KStandardItemModel(); |
37 | * model->appendItem(new KStandardItem("Item 1")); |
38 | * model->appendItem(new KStandardItem("Item 2")); |
39 | * KItemListController* controller = new KItemListController(model, view); |
40 | * KItemListContainer* container = new KItemListContainer(controller, parentWidget); |
41 | * </code> |
42 | */ |
43 | class LIBDOLPHINPRIVATE_EXPORT KStandardItemListView : public KItemListView |
44 | { |
45 | Q_OBJECT |
46 | |
47 | public: |
48 | enum ItemLayout |
49 | { |
50 | IconsLayout, |
51 | CompactLayout, |
52 | DetailsLayout |
53 | }; |
54 | |
55 | KStandardItemListView(QGraphicsWidget* parent = 0); |
56 | virtual ~KStandardItemListView(); |
57 | |
58 | void setItemLayout(ItemLayout layout); |
59 | ItemLayout itemLayout() const; |
60 | |
61 | protected: |
62 | virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const; |
63 | virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const; |
64 | virtual void initializeItemListWidget(KItemListWidget* item); |
65 | virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const; |
66 | virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const; |
67 | virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous); |
68 | virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous); |
69 | virtual void onSupportsItemExpandingChanged(bool supportsExpanding); |
70 | virtual void polishEvent(); |
71 | |
72 | private: |
73 | void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin); |
74 | void updateLayoutOfVisibleItems(); |
75 | |
76 | private: |
77 | ItemLayout m_itemLayout; |
78 | }; |
79 | |
80 | #endif |
81 | |
82 | |
83 | |