]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindetailsview.h
Fix the reproducible problem after the fix:
[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 <QtGui/QStyleOption>
26 #include <QtGui/QTreeView>
27 #include <libdolphin_export.h>
28
29 class DolphinController;
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 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
61 private slots:
62 /**
63 * Sets the sort indicator section of the header view
64 * corresponding to \a sorting.
65 */
66 void setSortIndicatorSection(DolphinView::Sorting sorting);
67
68 /**
69 * Sets the sort indicator order of the header view
70 * corresponding to \a sortOrder.
71 */
72 void setSortIndicatorOrder(Qt::SortOrder sortOrder);
73
74 /**
75 * Synchronizes the sorting state of the Dolphin menu 'View -> Sort'
76 * with the current state of the details view.
77 * @param column Index of the current sorting column.
78 */
79 void synchronizeSortingState(int column);
80
81 /**
82 * Is invoked when the mouse cursor has entered an item. The controller
83 * gets informed to emit the itemEntered() signal if the mouse cursor
84 * is above the name column. Otherwise the controller gets informed
85 * to emit the itemViewportEntered() signal (all other columns should
86 * behave as viewport area).
87 */
88 void slotEntered(const QModelIndex& index);
89
90 /**
91 * Updates the destination \a m_elasticBandDestination from
92 * the elastic band to the current mouse position and triggers
93 * an update.
94 */
95 void updateElasticBand();
96
97 /**
98 * Returns the rectangle for the elastic band dependent from the
99 * origin \a m_elasticBandOrigin, the current destination
100 * \a m_elasticBandDestination and the viewport position.
101 */
102 QRect elasticBandRect() const;
103
104 void zoomIn();
105 void zoomOut();
106
107 /**
108 * Called by QTreeView when an item is activated (clicked or double-clicked)
109 */
110 void slotItemActivated(const QModelIndex& index);
111
112 private:
113 bool isZoomInPossible() const;
114 bool isZoomOutPossible() const;
115
116 /**
117 * Updates the size of the decoration dependent on the
118 * icon size of the DetailsModeSettings. The controller
119 * will get informed about possible zoom in/zoom out
120 * operations.
121 */
122 void updateDecorationSize();
123
124 /** Return the upper left position in pixels of the viewport content. */
125 QPoint contentsPos() const;
126
127 private:
128 DolphinController* m_controller;
129 QStyleOptionViewItem m_viewOptions;
130
131 bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
132 QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
133
134 bool m_showElasticBand;
135 QPoint m_elasticBandOrigin;
136 QPoint m_elasticBandDestination;
137 };
138
139 #endif