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>
25 #include <QtGui/QStyleOption>
26 #include <QtGui/QTreeView>
27 #include <libdolphin_export.h>
29 class DolphinController
;
32 * @brief Represents the details view which shows the name, size,
33 * date, permissions, owner and group of an item.
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
39 class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView
: public QTreeView
44 explicit DolphinDetailsView(QWidget
* parent
, DolphinController
* controller
);
45 virtual ~DolphinDetailsView();
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 resizeEvent(QResizeEvent
* event
);
62 virtual void closeEvent(QCloseEvent
* event
);
66 * Sets the sort indicator section of the header view
67 * corresponding to \a sorting.
69 void setSortIndicatorSection(DolphinView::Sorting sorting
);
72 * Sets the sort indicator order of the header view
73 * corresponding to \a sortOrder.
75 void setSortIndicatorOrder(Qt::SortOrder sortOrder
);
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.
82 void synchronizeSortingState(int column
);
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).
91 void slotEntered(const QModelIndex
& index
);
94 * Updates the destination \a m_elasticBandDestination from
95 * the elastic band to the current mouse position and triggers
98 void updateElasticBand();
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.
105 QRect
elasticBandRect() const;
111 * Called by QTreeView when an item is activated (clicked or double-clicked)
113 void triggerItem(const QModelIndex
& index
);
116 * Opens a context menu at the position \a pos and allows to
117 * configure the visibility of the header columns.
119 void configureColumns(const QPoint
& pos
);
121 void updateColumnVisibility();
124 bool isZoomInPossible() const;
125 bool isZoomOutPossible() const;
128 * Updates the size of the decoration dependent on the
129 * icon size of the DetailsModeSettings. The controller
130 * will get informed about possible zoom in/zoom out
133 void updateDecorationSize();
135 /** Return the upper left position in pixels of the viewport content. */
136 QPoint
contentsPos() const;
138 KFileItem
itemForIndex(const QModelIndex
& index
) const;
140 KFileItemDelegate::Information
infoForColumn(int columnIndex
) const;
143 * Resizes all columns in a way to use the whole available width of the view.
145 void resizeColumns();
148 DolphinController
* m_controller
;
149 QStyleOptionViewItem m_viewOptions
;
151 bool m_clearAdditionalInfo
;
153 bool m_dragging
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
154 QRect m_dropRect
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
156 bool m_showElasticBand
;
157 QPoint m_elasticBandOrigin
;
158 QPoint m_elasticBandDestination
;