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

« back to all changes in this revision

Viewing changes to dolphin/src/views/dolphindetailsview.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) 2006-2010 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 DOLPHINDETAILSVIEW_H
21
 
#define DOLPHINDETAILSVIEW_H
22
 
 
23
 
#include "dolphintreeview.h"
24
 
#include <QTreeView>
25
 
#include <libdolphin_export.h>
26
 
#include <views/dolphinview.h>
27
 
 
28
 
class DolphinViewController;
29
 
class DolphinSortFilterProxyModel;
30
 
class ViewExtensionsFactory;
31
 
 
32
 
/**
33
 
 * @brief Represents the details view which shows the name, size,
34
 
 *        date, permissions, owner and group of an item.
35
 
 *
36
 
 * The width of the columns is automatically adjusted in a way
37
 
 * that full available width of the view is used by stretching the width
38
 
 * of the name column.
39
 
 */
40
 
class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView : public DolphinTreeView
41
 
{
42
 
    Q_OBJECT
43
 
 
44
 
public:
45
 
    /**
46
 
     * @param parent                Parent widget.
47
 
     * @param dolphinViewController Allows the DolphinDetailsView to control the
48
 
     *                              DolphinView in a limited way.
49
 
     * @param viewModeController    Controller that is used by the DolphinView
50
 
     *                              to control the DolphinDetailsView. The DolphinDetailsView
51
 
     *                              only has read access to the controller.
52
 
     * @param model                 Directory that is shown.
53
 
     */
54
 
    explicit DolphinDetailsView(QWidget* parent,
55
 
                                DolphinViewController* dolphinViewController,
56
 
                                const ViewModeController* viewModeController,
57
 
                                DolphinSortFilterProxyModel* model);
58
 
    virtual ~DolphinDetailsView();
59
 
 
60
 
    /**
61
 
     * Returns a set containing the URLs of all expanded items.
62
 
     */
63
 
    QSet<KUrl> expandedUrls() const;
64
 
 
65
 
public:
66
 
    virtual QRect visualRect(const QModelIndex& index) const;
67
 
 
68
 
protected:
69
 
    virtual bool event(QEvent* event);
70
 
    virtual QStyleOptionViewItem viewOptions() const;
71
 
    virtual void contextMenuEvent(QContextMenuEvent* event);
72
 
    virtual void mousePressEvent(QMouseEvent* event);
73
 
    virtual void startDrag(Qt::DropActions supportedActions);
74
 
    virtual void dragEnterEvent(QDragEnterEvent* event);
75
 
    virtual void dragMoveEvent(QDragMoveEvent* event);
76
 
    virtual void dropEvent(QDropEvent* event);
77
 
    virtual void keyPressEvent(QKeyEvent* event);
78
 
    virtual void resizeEvent(QResizeEvent* event);
79
 
    virtual void wheelEvent(QWheelEvent* event);
80
 
    virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
81
 
    virtual bool eventFilter(QObject* watched, QEvent* event);
82
 
    virtual bool acceptsDrop(const QModelIndex& index) const;
83
 
 
84
 
protected slots:
85
 
    virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
86
 
 
87
 
private slots:
88
 
    /**
89
 
     * Sets the sort indicator section of the header view
90
 
     * corresponding to \a sorting.
91
 
     */
92
 
    void setSortIndicatorSection(DolphinView::Sorting sorting);
93
 
 
94
 
    /**
95
 
     * Sets the sort indicator order of the header view
96
 
     * corresponding to \a sortOrder.
97
 
     */
98
 
    void setSortIndicatorOrder(Qt::SortOrder sortOrder);
99
 
 
100
 
    /**
101
 
     * Synchronizes the sorting state of the Dolphin menu 'View -> Sort'
102
 
     * with the current state of the details view.
103
 
     * @param column Index of the current sorting column.
104
 
     */
105
 
    void synchronizeSortingState(int column);
106
 
 
107
 
    /**
108
 
     * Is invoked when the mouse cursor has entered an item. The controller
109
 
     * gets informed to emit the itemEntered() signal if the mouse cursor
110
 
     * is above the name column. Otherwise the controller gets informed
111
 
     * to emit the itemViewportEntered() signal (all other columns should
112
 
     * behave as viewport area).
113
 
     */
114
 
    void slotEntered(const QModelIndex& index);
115
 
 
116
 
    void setZoomLevel(int level);
117
 
 
118
 
    void slotShowPreviewChanged();
119
 
 
120
 
    /**
121
 
     * Opens a context menu at the position \a pos and allows to
122
 
     * configure the visibility of the header columns and whether
123
 
     * expandable folders should be shown.
124
 
     */
125
 
    void configureSettings(const QPoint& pos);
126
 
 
127
 
    /**
128
 
     * Updates the visibilty state of columns and their order.
129
 
     */
130
 
    void updateColumnVisibility();
131
 
 
132
 
    /**
133
 
     * Resizes all columns in a way to use the whole available width of the view.
134
 
     */
135
 
    void resizeColumns();
136
 
 
137
 
    /**
138
 
     * Saves order of the columns as global setting.
139
 
     */
140
 
    void saveColumnPositions();
141
 
 
142
 
    /**
143
 
     * Disables the automatical resizing of columns, if the user has resized the columns
144
 
     * with the mouse.
145
 
     */
146
 
    void slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize);
147
 
 
148
 
    /**
149
 
     * Changes the alternating row colors setting depending from
150
 
     * the activation state \a active.
151
 
     */
152
 
    void slotActivationChanged(bool active);
153
 
 
154
 
    /**
155
 
     * Disables the automatical resizing of the columns. Per default all columns
156
 
     * are resized to use the maximum available width of the view as good as possible.
157
 
     */
158
 
    void disableAutoResizing();
159
 
 
160
 
    void requestActivation();
161
 
 
162
 
    void slotGlobalSettingsChanged(int category);
163
 
 
164
 
    /**
165
 
     * If \a expandable is true, the details view acts as tree view.
166
 
     * The current expandable state is remembered in the settings.
167
 
     */
168
 
    void setFoldersExpandable(bool expandable);
169
 
 
170
 
    /**
171
 
     * These slots update the list of expanded items.
172
 
     */
173
 
    void slotExpanded(const QModelIndex& index);
174
 
    void slotCollapsed(const QModelIndex& index);
175
 
 
176
 
private:
177
 
    /**
178
 
     * Removes the URLs corresponding to the children of \a index in the rows
179
 
     * between \a start and \a end inclusive from the set of expanded URLs.
180
 
     */
181
 
    void removeExpandedIndexes(const QModelIndex& parent, int start, int end);
182
 
 
183
 
    /**
184
 
     * Updates the size of the decoration dependent on the
185
 
     * icon size of the DetailsModeSettings. The controller
186
 
     * will get informed about possible zoom in/zoom out
187
 
     * operations.
188
 
     */
189
 
    void updateDecorationSize(bool showPreview);
190
 
 
191
 
    KFileItemDelegate::Information infoForColumn(int columnIndex) const;
192
 
 
193
 
    /**
194
 
     * Sets the maximum size available for editing in the delegate.
195
 
     */
196
 
    void adjustMaximumSizeForEditing(const QModelIndex& index);
197
 
 
198
 
    /**
199
 
     * Helper method for DolphinDetailsView::resizeColumns(): Returns the
200
 
     * string representation of the size-value for the given index.
201
 
     */
202
 
    QString itemSizeString(const QModelIndex& index, const KFileItem& item) const;
203
 
 
204
 
private:
205
 
    bool m_autoResize; // if true, the columns are resized automatically to the available width
206
 
 
207
 
    DolphinViewController* m_dolphinViewController;
208
 
    ViewExtensionsFactory* m_extensionsFactory;
209
 
    QAction* m_expandableFoldersAction;
210
 
 
211
 
    // A set containing the URLs of all currently expanded folders.
212
 
    // We cannot use a QSet<QModelIndex> because a QModelIndex is not guaranteed to remain valid over time.
213
 
    // Also a QSet<QPersistentModelIndex> does not work as expected because it is not guaranteed that
214
 
    // subsequent expand/collapse events of the same file item will yield the same QPersistentModelIndex.
215
 
    QSet<KUrl> m_expandedUrls;
216
 
 
217
 
    QFont m_font;
218
 
    QSize m_decorationSize;
219
 
 
220
 
    // For unit tests
221
 
    friend class DolphinDetailsViewTest;
222
 
};
223
 
 
224
 
#endif