]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kstandarditemlistview.h
Fix selection rect after porting from QFontMetrics::width()
[dolphin.git] / src / kitemviews / kstandarditemlistview.h
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 "dolphin_export.h"
24 #include "kitemviews/kitemlistview.h"
25
26 /**
27 * @brief Provides layouts for icons-, compact- and details-view.
28 *
29 * Together with the KStandardItemModel lists for standard usecases
30 * can be created in a straight forward way.
31 *
32 * Example code:
33 * <code>
34 * KStandardItemListView* view = new KStandardItemListView();
35 * KStandardItemModel* model = new KStandardItemModel();
36 * model->appendItem(new KStandardItem("Item 1"));
37 * model->appendItem(new KStandardItem("Item 2"));
38 * KItemListController* controller = new KItemListController(model, view);
39 * KItemListContainer* container = new KItemListContainer(controller, parentWidget);
40 * </code>
41 */
42 class DOLPHIN_EXPORT KStandardItemListView : public KItemListView
43 {
44 Q_OBJECT
45
46 public:
47 enum ItemLayout
48 {
49 IconsLayout,
50 CompactLayout,
51 DetailsLayout
52 };
53
54 explicit KStandardItemListView(QGraphicsWidget* parent = nullptr);
55 ~KStandardItemListView() override;
56
57 void setItemLayout(ItemLayout layout);
58 ItemLayout itemLayout() const;
59
60 protected:
61 KItemListWidgetCreatorBase* defaultWidgetCreator() const override;
62 KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const override;
63 void initializeItemListWidget(KItemListWidget* item) override;
64 bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const override;
65 virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
66 virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
67 void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) override;
68 void onSupportsItemExpandingChanged(bool supportsExpanding) override;
69 void polishEvent() override;
70
71 private:
72 void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin);
73 void updateLayoutOfVisibleItems();
74
75 private:
76 ItemLayout m_itemLayout;
77 };
78
79 #endif
80
81