1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
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. *
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. *
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 ***************************************************************************/
21 #ifndef DOLPHINDETAILSVIEW_H
22 #define DOLPHINDETAILSVIEW_H
24 #include <dolphinview.h>
26 #include <libdolphin_export.h>
28 class DolphinController
;
31 * @brief Represents the details view which shows the name, size,
32 * date, permissions, owner and group of an item.
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
38 class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView
: public QTreeView
43 explicit DolphinDetailsView(QWidget
* parent
, DolphinController
* controller
);
44 virtual ~DolphinDetailsView();
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 closeEvent(QCloseEvent
* event
);
65 * Sets the sort indicator section of the header view
66 * corresponding to \a sorting.
68 void setSortIndicatorSection(DolphinView::Sorting sorting
);
71 * Sets the sort indicator order of the header view
72 * corresponding to \a sortOrder.
74 void setSortIndicatorOrder(Qt::SortOrder sortOrder
);
77 * Synchronizes the sorting state of the Dolphin menu 'View -> Sort'
78 * with the current state of the details view.
79 * @param column Index of the current sorting column.
81 void synchronizeSortingState(int column
);
84 * Is invoked when the mouse cursor has entered an item. The controller
85 * gets informed to emit the itemEntered() signal if the mouse cursor
86 * is above the name column. Otherwise the controller gets informed
87 * to emit the itemViewportEntered() signal (all other columns should
88 * behave as viewport area).
90 void slotEntered(const QModelIndex
& index
);
93 * Updates the destination \a m_elasticBandDestination from
94 * the elastic band to the current mouse position and triggers
97 void updateElasticBand();
100 * Returns the rectangle for the elastic band dependent from the
101 * origin \a m_elasticBandOrigin, the current destination
102 * \a m_elasticBandDestination and the viewport position.
104 QRect
elasticBandRect() const;
110 * Called by QTreeView when an item is activated (clicked or double-clicked)
112 void triggerItem(const QModelIndex
& index
);
115 * Opens a context menu at the position \a pos and allows to
116 * configure the visibility of the header columns.
118 void configureColumns(const QPoint
& pos
);
120 void updateColumnVisibility();
123 bool isZoomInPossible() const;
124 bool isZoomOutPossible() const;
127 * Updates the size of the decoration dependent on the
128 * icon size of the DetailsModeSettings. The controller
129 * will get informed about possible zoom in/zoom out
132 void updateDecorationSize();
134 /** Return the upper left position in pixels of the viewport content. */
135 QPoint
contentsPos() const;
137 KFileItem
itemForIndex(const QModelIndex
& index
) const;
139 KFileItemDelegate::Information
infoForColumn(int columnIndex
) const;
142 * Resizes all columns in a way to use the whole available width of the view.
144 void resizeColumns();
147 DolphinController
* m_controller
;
150 QSize m_decorationSize
;
152 bool m_clearAdditionalInfo
;
154 bool m_dragging
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
155 QRect m_dropRect
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
157 bool m_showElasticBand
;
158 QPoint m_elasticBandOrigin
;
159 QPoint m_elasticBandDestination
;