]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindetailsview.h
Move the pasteIntoFolder() method from the contextmenu into DolphinView. This allows...
[dolphin.git] / src / dolphindetailsview.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef DOLPHINDETAILSVIEW_H
22 #define DOLPHINDETAILSVIEW_H
23
24 #include <dolphinview.h>
25 #include <QTreeView>
26 #include <libdolphin_export.h>
27
28 class DolphinController;
29
30 /**
31 * @brief Represents the details view which shows the name, size,
32 * date, permissions, owner and group of an item.
33 *
34 * The width of the columns is automatically adjusted in a way
35 * that full available width of the view is used by stretching the width
36 * of the name column.
37 */
38 class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView : public QTreeView
39 {
40 Q_OBJECT
41
42 public:
43 explicit DolphinDetailsView(QWidget* parent, DolphinController* controller);
44 virtual ~DolphinDetailsView();
45
46 protected:
47 virtual bool event(QEvent* event);
48 virtual QStyleOptionViewItem viewOptions() const;
49 virtual void contextMenuEvent(QContextMenuEvent* event);
50 virtual void mousePressEvent(QMouseEvent* event);
51 virtual void mouseMoveEvent(QMouseEvent* event);
52 virtual void mouseReleaseEvent(QMouseEvent* event);
53 virtual void startDrag(Qt::DropActions supportedActions);
54 virtual void dragEnterEvent(QDragEnterEvent* event);
55 virtual void dragLeaveEvent(QDragLeaveEvent* event);
56 virtual void dragMoveEvent(QDragMoveEvent* event);
57 virtual void dropEvent(QDropEvent* event);
58 virtual void paintEvent(QPaintEvent* event);
59 virtual void keyPressEvent(QKeyEvent* event);
60 virtual void resizeEvent(QResizeEvent* event);
61 virtual void wheelEvent(QWheelEvent* event);
62 virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
63
64 private slots:
65 /**
66 * Sets the sort indicator section of the header view
67 * corresponding to \a sorting.
68 */
69 void setSortIndicatorSection(DolphinView::Sorting sorting);
70
71 /**
72 * Sets the sort indicator order of the header view
73 * corresponding to \a sortOrder.
74 */
75 void setSortIndicatorOrder(Qt::SortOrder sortOrder);
76
77 /**
78 * Synchronizes the sorting state of the Dolphin menu 'View -> Sort'
79 * with the current state of the details view.
80 * @param column Index of the current sorting column.
81 */
82 void synchronizeSortingState(int column);
83
84 /**
85 * Is invoked when the mouse cursor has entered an item. The controller
86 * gets informed to emit the itemEntered() signal if the mouse cursor
87 * is above the name column. Otherwise the controller gets informed
88 * to emit the itemViewportEntered() signal (all other columns should
89 * behave as viewport area).
90 */
91 void slotEntered(const QModelIndex& index);
92
93 /**
94 * Updates the destination \a m_elasticBandDestination from
95 * the elastic band to the current mouse position and triggers
96 * an update.
97 */
98 void updateElasticBand();
99
100 /**
101 * Returns the rectangle for the elastic band dependent from the
102 * origin \a m_elasticBandOrigin, the current destination
103 * \a m_elasticBandDestination and the viewport position.
104 */
105 QRect elasticBandRect() const;
106
107 void zoomIn();
108 void zoomOut();
109
110 /**
111 * Opens a context menu at the position \a pos and allows to
112 * configure the visibility of the header columns.
113 */
114 void configureColumns(const QPoint& pos);
115
116 void updateColumnVisibility();
117
118 /**
119 * Disables the automatical resizing of columns, if the user has resized the columns
120 * with the mouse.
121 */
122 void slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize);
123
124 /**
125 * Disables the automatical resizing of the columns. Per default all columns
126 * are resized to use the maximum available width of the view as good as possible.
127 */
128 void disableAutoResizing();
129
130 void requestActivation();
131
132 void updateFont();
133
134 private:
135 bool isZoomInPossible() const;
136 bool isZoomOutPossible() const;
137
138 /**
139 * Updates the size of the decoration dependent on the
140 * icon size of the DetailsModeSettings. The controller
141 * will get informed about possible zoom in/zoom out
142 * operations.
143 */
144 void updateDecorationSize();
145
146 /** Return the upper left position in pixels of the viewport content. */
147 QPoint contentsPos() const;
148
149 KFileItemDelegate::Information infoForColumn(int columnIndex) const;
150
151 /**
152 * Resizes all columns in a way to use the whole available width of the view.
153 */
154 void resizeColumns();
155
156 private:
157 bool m_autoResize; // if true, the columns are resized automatically to the available width
158
159 DolphinController* m_controller;
160
161 QFont m_font;
162 QSize m_decorationSize;
163
164 QRect m_dropRect;
165
166 bool m_showElasticBand;
167 QPoint m_elasticBandOrigin;
168 QPoint m_elasticBandDestination;
169 };
170
171 #endif