~ubuntu-branches/debian/sid/kde-baseapps/sid

« back to all changes in this revision

Viewing changes to dolphin/src/kitemviews/kfileitemlistview.h

  • Committer: Package Import Robot
  • Author(s): Modestas Vainius, Eshat Cakar, Pino Toscano
  • Date: 2012-06-09 22:18:08 UTC
  • mfrom: (4.2.1) (6.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20120609221808-h1l0ekd5qmb8nefr
Tags: 4:4.8.4-1
* New upstream release.

[ Eshat Cakar ]
* Add watch file.
* Bump kde-sc-dev-latest build dependency to version 4:4.8.4.
* Update installed files.

[ Pino Toscano ]
* Move files of the konqueror documentation from kde-baseapps-data to
  konqueror itself.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/**
 
31
 * @brief View that allows to show the content of file-items.
 
32
 *
 
33
 * The corresponding model set by the controller must be an instance
 
34
 * of KFileItemModel. Per default KFileItemListWidget is set as widget creator
 
35
 * value and KItemListGroupHeader as group-header creator value. Use
 
36
 * KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator()
 
37
 * to apply customized generators.
 
38
 */
 
39
class LIBDOLPHINPRIVATE_EXPORT KFileItemListView : public KItemListView
 
40
{
 
41
    Q_OBJECT
 
42
 
 
43
public:
 
44
    enum Layout
 
45
    {
 
46
        IconsLayout,
 
47
        CompactLayout,
 
48
        DetailsLayout
 
49
    };
 
50
 
 
51
    KFileItemListView(QGraphicsWidget* parent = 0);
 
52
    virtual ~KFileItemListView();
 
53
 
 
54
    void setPreviewsShown(bool show);
 
55
    bool previewsShown() const;
 
56
 
 
57
    /**
 
58
     * If enabled a small preview gets upscaled to the icon size in case where
 
59
     * the icon size is larger than the preview. Per default enlarging is
 
60
     * enabled.
 
61
     */
 
62
    void setEnlargeSmallPreviews(bool enlarge);
 
63
    bool enlargeSmallPreviews() const;
 
64
 
 
65
    void setItemLayout(Layout layout);
 
66
    Layout itemLayout() const;
 
67
 
 
68
    /**
 
69
     * Sets the list of enabled thumbnail plugins that are used for previews.
 
70
     * Per default all plugins enabled in the KConfigGroup "PreviewSettings"
 
71
     * are used.
 
72
     *
 
73
     * For a list of available plugins, call KServiceTypeTrader::self()->query("ThumbCreator").
 
74
     *
 
75
     * @see enabledPlugins
 
76
     */
 
77
    void setEnabledPlugins(const QStringList& list);
 
78
 
 
79
    /**
 
80
     * Returns the list of enabled thumbnail plugins.
 
81
     * @see setEnabledPlugins
 
82
     */
 
83
    QStringList enabledPlugins() const;
 
84
 
 
85
    /** @reimp */
 
86
    virtual QSizeF itemSizeHint(int index) const;
 
87
 
 
88
    /** @reimp */
 
89
    virtual QHash<QByteArray, QSizeF> visibleRolesSizes(const KItemRangeList& itemRanges) const;
 
90
 
 
91
    /** @reimp */
 
92
    virtual QPixmap createDragPixmap(const QSet<int>& indexes) const;
 
93
 
 
94
protected:
 
95
    virtual void initializeItemListWidget(KItemListWidget* item);
 
96
    virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const;
 
97
    virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous);
 
98
    virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
 
99
    virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous);
 
100
    virtual void onScrollOffsetChanged(qreal current, qreal previous);
 
101
    virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
 
102
    virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
 
103
    virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
 
104
    virtual void onTransactionBegin();
 
105
    virtual void onTransactionEnd();
 
106
    virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
 
107
 
 
108
protected slots:
 
109
    virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
 
110
    virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous);
 
111
 
 
112
private slots:
 
113
    void triggerVisibleIndexRangeUpdate();
 
114
    void updateVisibleIndexRange();
 
115
 
 
116
    void triggerIconSizeUpdate();
 
117
    void updateIconSize();
 
118
 
 
119
private:
 
120
    QSizeF visibleRoleSizeHint(int index, const QByteArray& role) const;
 
121
    void updateLayoutOfVisibleItems();
 
122
    void updateTimersInterval();
 
123
    void updateMinimumRolesWidths();
 
124
 
 
125
    /**
 
126
     * Applies the roles defined by KItemListView::visibleRoles() to the
 
127
     * KFileItemModel and KFileItemModelRolesUpdater. As the model does not
 
128
     * distinct between visible and invisible roles also internal roles
 
129
     * are applied that are mandatory for having a working KFileItemModel.
 
130
     */
 
131
    void applyRolesToModel();
 
132
 
 
133
    /**
 
134
     * @return Size that is available for the icons. The size might be larger than specified by
 
135
     *         KItemListStyleOption::iconSize: With the IconsLayout also the empty left area left
 
136
     *         and right of an icon will be included.
 
137
     */
 
138
    QSize availableIconSize() const;
 
139
 
 
140
private:
 
141
    Layout m_itemLayout;
 
142
 
 
143
    KFileItemModelRolesUpdater* m_modelRolesUpdater;
 
144
    QTimer* m_updateVisibleIndexRangeTimer;
 
145
    QTimer* m_updateIconSizeTimer;
 
146
 
 
147
    // Cache for calculating visibleRoleSizes() in a fast way
 
148
    QHash<QByteArray, int> m_minimumRolesWidths;
 
149
 
 
150
    friend class KFileItemListViewTest; // For unit testing
 
151
};
 
152
 
 
153
#endif
 
154
 
 
155