]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kfileitemlistview.h
Interface cleanups for drag and drop support
[dolphin.git] / src / kitemviews / kfileitemlistview.h
1 /***************************************************************************
2 * Copyright (C) 2011 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 KFILEITEMLISTVIEW_H
21 #define KFILEITEMLISTVIEW_H
22
23 #include <libdolphin_export.h>
24
25 #include <kitemviews/kitemlistview.h>
26
27 class KFileItemModelRolesUpdater;
28 class QTimer;
29
30 class LIBDOLPHINPRIVATE_EXPORT KFileItemListView : public KItemListView
31 {
32 Q_OBJECT
33
34 public:
35 enum Layout
36 {
37 IconsLayout,
38 CompactLayout,
39 DetailsLayout
40 };
41
42 KFileItemListView(QGraphicsWidget* parent = 0);
43 virtual ~KFileItemListView();
44
45 void setPreviewsShown(bool show);
46 bool previewsShown() const;
47
48 void setItemLayout(Layout layout);
49 Layout itemLayout() const;
50
51 /** @reimp */
52 virtual QSizeF itemSizeHint(int index) const;
53
54 /** @reimp */
55 virtual QHash<QByteArray, QSizeF> visibleRoleSizes() const;
56
57 /** @reimp */
58 virtual QPixmap createDragPixmap(const QSet<int>& indexes) const;
59
60 protected:
61 virtual void initializeItemListWidget(KItemListWidget* item);
62 virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous);
63 virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
64 virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous);
65 virtual void onOffsetChanged(qreal current, qreal previous);
66 virtual void onVisibleRolesChanged(const QHash<QByteArray, int>& current, const QHash<QByteArray, int>& previous);
67 virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
68 virtual void onTransactionBegin();
69 virtual void onTransactionEnd();
70 virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
71
72 protected slots:
73 virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
74
75 private slots:
76 void triggerVisibleIndexRangeUpdate();
77 void updateVisibleIndexRange();
78
79 void triggerIconSizeUpdate();
80 void updateIconSize();
81
82 private:
83 QSizeF visibleRoleSizeHint(int index, const QByteArray& role) const;
84 void updateLayoutOfVisibleItems();
85 void updateTimersInterval();
86 void updateMinimumRolesWidths();
87
88 private:
89 Layout m_itemLayout;
90
91 KFileItemModelRolesUpdater* m_modelRolesUpdater;
92 QTimer* m_updateVisibleIndexRangeTimer;
93 QTimer* m_updateIconSizeTimer;
94
95 // Cache for calculating visibleRoleSizes() in a fast way
96 QHash<QByteArray, int> m_minimumRolesWidths;
97
98 friend class KFileItemListViewTest; // For unit testing
99 };
100
101 #endif
102
103