]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindetailsview.h
There are some extractable strings in subdirs too.
[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 class SelectionManager;
30
31 /**
32 * @brief Represents the details view which shows the name, size,
33 * date, permissions, owner and group of an item.
34 *
35 * The width of the columns is automatically adjusted in a way
36 * that full available width of the view is used by stretching the width
37 * of the name column.
38 */
39 class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView : public QTreeView
40 {
41 Q_OBJECT
42
43 public:
44 explicit DolphinDetailsView(QWidget* parent, DolphinController* controller);
45 virtual ~DolphinDetailsView();
46
47 protected:
48 virtual bool event(QEvent* event);
49 virtual QStyleOptionViewItem viewOptions() const;
50 virtual void contextMenuEvent(QContextMenuEvent* event);
51 virtual void mousePressEvent(QMouseEvent* event);
52 virtual void mouseMoveEvent(QMouseEvent* event);
53 virtual void mouseReleaseEvent(QMouseEvent* event);
54 virtual void startDrag(Qt::DropActions supportedActions);
55 virtual void dragEnterEvent(QDragEnterEvent* event);
56 virtual void dragLeaveEvent(QDragLeaveEvent* event);
57 virtual void dragMoveEvent(QDragMoveEvent* event);
58 virtual void dropEvent(QDropEvent* event);
59 virtual void paintEvent(QPaintEvent* event);
60 virtual void keyPressEvent(QKeyEvent* event);
61 virtual void keyReleaseEvent(QKeyEvent* event);
62 virtual void resizeEvent(QResizeEvent* event);
63 virtual void wheelEvent(QWheelEvent* event);
64 virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
65 virtual bool eventFilter(QObject* watched, QEvent* event);
66
67 private slots:
68 /**
69 * Sets the sort indicator section of the header view
70 * corresponding to \a sorting.
71 */
72 void setSortIndicatorSection(DolphinView::Sorting sorting);
73
74 /**
75 * Sets the sort indicator order of the header view
76 * corresponding to \a sortOrder.
77 */
78 void setSortIndicatorOrder(Qt::SortOrder sortOrder);
79
80 /**
81 * Synchronizes the sorting state of the Dolphin menu 'View -> Sort'
82 * with the current state of the details view.
83 * @param column Index of the current sorting column.
84 */
85 void synchronizeSortingState(int column);
86
87 /**
88 * Is invoked when the mouse cursor has entered an item. The controller
89 * gets informed to emit the itemEntered() signal if the mouse cursor
90 * is above the name column. Otherwise the controller gets informed
91 * to emit the itemViewportEntered() signal (all other columns should
92 * behave as viewport area).
93 */
94 void slotEntered(const QModelIndex& index);
95
96 /**
97 * Updates the destination \a m_elasticBandDestination from
98 * the elastic band to the current mouse position and triggers
99 * an update.
100 */
101 void updateElasticBand();
102
103 /**
104 * Returns the rectangle for the elastic band dependent from the
105 * origin \a m_elasticBandOrigin, the current destination
106 * \a m_elasticBandDestination and the viewport position.
107 */
108 QRect elasticBandRect() const;
109
110 void zoomIn();
111 void zoomOut();
112
113 /**
114 * Opens a context menu at the position \a pos and allows to
115 * configure the visibility of the header columns.
116 */
117 void configureColumns(const QPoint& pos);
118
119 void updateColumnVisibility();
120
121 /**
122 * Disables the automatical resizing of columns, if the user has resized the columns
123 * with the mouse.
124 */
125 void slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize);
126
127 /**
128 * Disables the automatical resizing of the columns. Per default all columns
129 * are resized to use the maximum available width of the view as good as possible.
130 */
131 void disableAutoResizing();
132
133 void requestActivation();
134
135 void updateFont();
136
137 private:
138 bool isZoomInPossible() const;
139 bool isZoomOutPossible() const;
140
141 /**
142 * Updates the size of the decoration dependent on the
143 * icon size of the DetailsModeSettings. The controller
144 * will get informed about possible zoom in/zoom out
145 * operations.
146 */
147 void updateDecorationSize();
148
149 /** Return the upper left position in pixels of the viewport content. */
150 QPoint contentsPos() const;
151
152 KFileItemDelegate::Information infoForColumn(int columnIndex) const;
153
154 /**
155 * Resizes all columns in a way to use the whole available width of the view.
156 */
157 void resizeColumns();
158
159 private:
160 bool m_autoResize; // if true, the columns are resized automatically to the available width
161 bool m_expandingTogglePressed;
162 bool m_keyPressed; // true if a key is pressed currently; info used by currentChanged()
163
164 DolphinController* m_controller;
165 SelectionManager* m_selectionManager;
166
167 QFont m_font;
168 QSize m_decorationSize;
169
170 QRect m_dropRect;
171
172 bool m_showElasticBand;
173 QPoint m_elasticBandOrigin;
174 QPoint m_elasticBandDestination;
175 };
176
177 #endif