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 bool event(QEvent
* event
);
67 virtual QStyleOptionViewItem
viewOptions() const;
68 virtual void contextMenuEvent(QContextMenuEvent
* event
);
69 virtual void mousePressEvent(QMouseEvent
* event
);
70 virtual void startDrag(Qt::DropActions supportedActions
);
71 virtual void dragEnterEvent(QDragEnterEvent
* event
);
72 virtual void dragMoveEvent(QDragMoveEvent
* event
);
73 virtual void dropEvent(QDropEvent
* event
);
74 virtual void keyPressEvent(QKeyEvent
* event
);
75 virtual void resizeEvent(QResizeEvent
* event
);
76 virtual void wheelEvent(QWheelEvent
* event
);
77 virtual void currentChanged(const QModelIndex
& current
, const QModelIndex
& previous
);
78 virtual bool eventFilter(QObject
* watched
, QEvent
* event
);
79 virtual QRect
visualRect(const QModelIndex
& index
) const;
80 virtual bool acceptsDrop(const QModelIndex
& index
) const;
83 virtual void rowsAboutToBeRemoved(const QModelIndex
&parent
, int start
, int end
);
87 * Sets the sort indicator section of the header view
88 * corresponding to \a sorting.
90 void setSortIndicatorSection(DolphinView::Sorting sorting
);
93 * Sets the sort indicator order of the header view
94 * corresponding to \a sortOrder.
96 void setSortIndicatorOrder(Qt::SortOrder sortOrder
);
99 * Synchronizes the sorting state of the Dolphin menu 'View -> Sort'
100 * with the current state of the details view.
101 * @param column Index of the current sorting column.
103 void synchronizeSortingState(int column
);
106 * Is invoked when the mouse cursor has entered an item. The controller
107 * gets informed to emit the itemEntered() signal if the mouse cursor
108 * is above the name column. Otherwise the controller gets informed
109 * to emit the itemViewportEntered() signal (all other columns should
110 * behave as viewport area).
112 void slotEntered(const QModelIndex
& index
);
114 void setZoomLevel(int level
);
116 void slotShowPreviewChanged();
119 * Opens a context menu at the position \a pos and allows to
120 * configure the visibility of the header columns and whether
121 * expandable folders should be shown.
123 void configureSettings(const QPoint
& pos
);
126 * Updates the visibilty state of columns and their order.
128 void updateColumnVisibility();
131 * Resizes all columns in a way to use the whole available width of the view.
133 void resizeColumns();
136 * Saves order of the columns as global setting.
138 void saveColumnPositions();
141 * Disables the automatical resizing of columns, if the user has resized the columns
144 void slotHeaderSectionResized(int logicalIndex
, int oldSize
, int newSize
);
147 * Changes the alternating row colors setting depending from
148 * the activation state \a active.
150 void slotActivationChanged(bool active
);
153 * Disables the automatical resizing of the columns. Per default all columns
154 * are resized to use the maximum available width of the view as good as possible.
156 void disableAutoResizing();
158 void requestActivation();
160 void slotGlobalSettingsChanged(int category
);
163 * If \a expandable is true, the details view acts as tree view.
164 * The current expandable state is remembered in the settings.
166 void setFoldersExpandable(bool expandable
);
169 * These slots update the list of expanded items.
171 void slotExpanded(const QModelIndex
& index
);
172 void slotCollapsed(const QModelIndex
& index
);
176 * Removes the URLs corresponding to the children of \a index in the rows
177 * between \a start and \a end inclusive from the set of expanded URLs.
179 void removeExpandedIndexes(const QModelIndex
& parent
, int start
, int end
);
182 * Updates the size of the decoration dependent on the
183 * icon size of the DetailsModeSettings. The controller
184 * will get informed about possible zoom in/zoom out
187 void updateDecorationSize(bool showPreview
);
189 KFileItemDelegate::Information
infoForColumn(int columnIndex
) const;
192 * Sets the maximum size available for editing in the delegate.
194 void adjustMaximumSizeForEditing(const QModelIndex
& index
);
197 bool m_autoResize
; // if true, the columns are resized automatically to the available width
199 DolphinViewController
* m_dolphinViewController
;
200 const ViewModeController
* m_viewModeController
;
201 ViewExtensionsFactory
* m_extensionsFactory
;
202 QAction
* m_expandableFoldersAction
;
204 // A set containing the URLs of all currently expanded folders.
205 // We cannot use a QSet<QModelIndex> because a QModelIndex is not guaranteed to remain valid over time.
206 // Also a QSet<QPersistentModelIndex> does not work as expected because it is not guaranteed that
207 // subsequent expand/collapse events of the same file item will yield the same QPersistentModelIndex.
208 QSet
<KUrl
> m_expandedUrls
;
211 QSize m_decorationSize
;