1
/***************************************************************************
2
* Copyright (C) 2006-2010 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 DOLPHINDETAILSVIEW_H
21
#define DOLPHINDETAILSVIEW_H
23
#include "dolphintreeview.h"
25
#include <libdolphin_export.h>
26
#include <views/dolphinview.h>
28
class DolphinViewController;
29
class DolphinSortFilterProxyModel;
30
class ViewExtensionsFactory;
33
* @brief Represents the details view which shows the name, size,
34
* date, permissions, owner and group of an item.
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
40
class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView : public DolphinTreeView
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.
54
explicit DolphinDetailsView(QWidget* parent,
55
DolphinViewController* dolphinViewController,
56
const ViewModeController* viewModeController,
57
DolphinSortFilterProxyModel* model);
58
virtual ~DolphinDetailsView();
61
* Returns a set containing the URLs of all expanded items.
63
QSet<KUrl> expandedUrls() const;
66
virtual QRect visualRect(const QModelIndex& index) const;
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;
85
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
89
* Sets the sort indicator section of the header view
90
* corresponding to \a sorting.
92
void setSortIndicatorSection(DolphinView::Sorting sorting);
95
* Sets the sort indicator order of the header view
96
* corresponding to \a sortOrder.
98
void setSortIndicatorOrder(Qt::SortOrder sortOrder);
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.
105
void synchronizeSortingState(int column);
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).
114
void slotEntered(const QModelIndex& index);
116
void setZoomLevel(int level);
118
void slotShowPreviewChanged();
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.
125
void configureSettings(const QPoint& pos);
128
* Updates the visibilty state of columns and their order.
130
void updateColumnVisibility();
133
* Resizes all columns in a way to use the whole available width of the view.
135
void resizeColumns();
138
* Saves order of the columns as global setting.
140
void saveColumnPositions();
143
* Disables the automatical resizing of columns, if the user has resized the columns
146
void slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize);
149
* Changes the alternating row colors setting depending from
150
* the activation state \a active.
152
void slotActivationChanged(bool active);
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.
158
void disableAutoResizing();
160
void requestActivation();
162
void slotGlobalSettingsChanged(int category);
165
* If \a expandable is true, the details view acts as tree view.
166
* The current expandable state is remembered in the settings.
168
void setFoldersExpandable(bool expandable);
171
* These slots update the list of expanded items.
173
void slotExpanded(const QModelIndex& index);
174
void slotCollapsed(const QModelIndex& index);
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.
181
void removeExpandedIndexes(const QModelIndex& parent, int start, int end);
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
189
void updateDecorationSize(bool showPreview);
191
KFileItemDelegate::Information infoForColumn(int columnIndex) const;
194
* Sets the maximum size available for editing in the delegate.
196
void adjustMaximumSizeForEditing(const QModelIndex& index);
199
* Helper method for DolphinDetailsView::resizeColumns(): Returns the
200
* string representation of the size-value for the given index.
202
QString itemSizeString(const QModelIndex& index, const KFileItem& item) const;
205
bool m_autoResize; // if true, the columns are resized automatically to the available width
207
DolphinViewController* m_dolphinViewController;
208
ViewExtensionsFactory* m_extensionsFactory;
209
QAction* m_expandableFoldersAction;
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;
218
QSize m_decorationSize;
221
friend class DolphinDetailsViewTest;