1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@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 as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
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 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 ***************************************************************************/
20 #ifndef KFILEITEMLISTVIEW_H
21 #define KFILEITEMLISTVIEW_H
23 #include <libdolphin_export.h>
25 #include <kitemviews/kitemlistview.h>
27 class KFileItemModelRolesUpdater
;
30 class LIBDOLPHINPRIVATE_EXPORT KFileItemListView
: public KItemListView
42 KFileItemListView(QGraphicsWidget
* parent
= 0);
43 virtual ~KFileItemListView();
45 void setPreviewsShown(bool show
);
46 bool previewsShown() const;
48 void setItemLayout(Layout layout
);
49 Layout
itemLayout() const;
52 virtual QSizeF
itemSizeHint(int index
) const;
55 virtual QHash
<QByteArray
, QSizeF
> visibleRoleSizes() const;
58 virtual QPixmap
createDragPixmap(const QSet
<int>& indexes
) const;
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
);
73 virtual void slotItemsRemoved(const KItemRangeList
& itemRanges
);
76 void triggerVisibleIndexRangeUpdate();
77 void updateVisibleIndexRange();
79 void triggerIconSizeUpdate();
80 void updateIconSize();
83 QSizeF
visibleRoleSizeHint(int index
, const QByteArray
& role
) const;
84 void updateLayoutOfVisibleItems();
85 void updateTimersInterval();
86 void updateMinimumRolesWidths();
91 KFileItemModelRolesUpdater
* m_modelRolesUpdater
;
92 QTimer
* m_updateVisibleIndexRangeTimer
;
93 QTimer
* m_updateIconSizeTimer
;
95 // Cache for calculating visibleRoleSizes() in a fast way
96 QHash
<QByteArray
, int> m_minimumRolesWidths
;
98 friend class KFileItemListViewTest
; // For unit testing