]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindetailsview.h
commited initial version of Dolphin
[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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #ifndef DOLPHINDETAILSVIEW_H
22 #define DOLPHINDETAILSVIEW_H
23
24 #include <kfiledetailview.h>
25 #include <itemeffectsmanager.h>
26 //Added by qt3to4:
27 #include <QPixmap>
28 #include <QResizeEvent>
29 #include <QEvent>
30 #include <QDropEvent>
31 #include <QMouseEvent>
32 #include <QDragMoveEvent>
33 #include <QPaintEvent>
34
35 class QRect;
36 class QTimer;
37 class DolphinView;
38
39 /**
40 * @brief Represents the details view which shows the name, size,
41 * date, permissions, owner and group of an item.
42 *
43 * The width of the columns are automatically adjusted in a way
44 * that full available width of the view is used by stretching the width
45 * of the name column.
46 *
47 * @author Peter Penz
48 */
49 class DolphinDetailsView : public KFileDetailView, public ItemEffectsManager
50 {
51 Q_OBJECT
52
53 public:
54 /**
55 * Maps the column indices of KFileDetailView to a
56 * descriptive column name.
57 */
58 enum ColumnName {
59 NameColumn = 0,
60 SizeColumn = 1,
61 DateColumn = 2,
62 PermissionsColumn = 3,
63 OwnerColumn = 4,
64 GroupColumn = 5
65 };
66
67 DolphinDetailsView(DolphinView* parent);
68
69 virtual ~DolphinDetailsView();
70
71 /** @see ItemEffectsManager::updateItems */
72 virtual void beginItemUpdates();
73
74 /** @see ItemEffectsManager::updateItems */
75 virtual void endItemUpdates();
76
77 /** @see KFileView::insertItem */
78 virtual void insertItem(KFileItem* fileItem);
79
80 /**
81 * @return True, if the position \a pos is above the name of
82 * item \a item.
83 */
84 bool isOnFilename(const Q3ListViewItem* item, const QPoint& pos) const;
85
86 /**
87 * Reads out the dolphin settings for the details view and refreshs
88 * the details view.
89 */
90 // TODO: Other view implementations use a similar interface. When using
91 // Interview in Qt4 this method should be moved to a base class (currently
92 // not possible due to having different base classes for the views).
93 void refreshSettings();
94
95 /** @see ItemEffectsManager::zoomIn() */
96 virtual void zoomIn();
97
98 /** @see ItemEffectsManager::zoomOut() */
99 virtual void zoomOut();
100
101 /** @see ItemEffectsManager::isZoomInPossible() */
102 virtual bool isZoomInPossible() const;
103
104 /** @see ItemEffectsManager::isZoomOutPossible() */
105 virtual bool isZoomOutPossible() const;
106
107 signals:
108 /**
109 * Is send, if the details view should be activated. Usually an activation
110 * is triggered by a mouse click.
111 */
112 void signalRequestActivation();
113
114 public slots:
115 /** @see KFileDetailView::resizeContents */
116 virtual void resizeContents(int width, int height);
117
118 /** Is connected to the onItem-signal from KFileDetailView. */
119 void slotOnItem(Q3ListViewItem* item);
120
121 /** Is connected to the onViewport-signal from KFileDetailView. */
122 void slotOnViewport();
123
124 protected:
125 /** @see ItemEffectsManager::setContextPixmap() */
126 virtual void setContextPixmap(void* context,
127 const QPixmap& pixmap);
128
129 /** @see ItemEffectsManager::setContextPixmap() */
130 virtual const QPixmap* contextPixmap(void* context);
131
132 /** @see ItemEffectsManager::setContextPixmap() */
133 virtual void* firstContext();
134
135 /** @see ItemEffectsManager::setContextPixmap() */
136 virtual void* nextContext(void* context);
137
138 /** @see ItemEffectsManager::setContextPixmap() */
139 virtual KFileItem* contextFileInfo(void* context);
140
141 /** @see KFileDetailView::contentsDragMoveEvent() */
142 virtual void contentsDragMoveEvent(QDragMoveEvent* event);
143
144 /** @see KFileDetailView::resizeEvent() */
145 virtual void resizeEvent(QResizeEvent* event);
146
147 /** @see KFileDetailView::acceptDrag() */
148 virtual bool acceptDrag (QDropEvent* event) const;
149
150 /** @see KFileDetailView::contentsDropEvent() */
151 virtual void contentsDropEvent(QDropEvent* event);
152
153 /** @see KFileDetailView::contentsMousePressEvent() */
154 virtual void contentsMousePressEvent(QMouseEvent* event);
155
156 /** @see KFileDetailView::contentsMouseMoveEvent() */
157 virtual void contentsMouseMoveEvent(QMouseEvent* event);
158
159 /** @see KFileDetailView::contentsMouseReleaseEvent() */
160 virtual void contentsMouseReleaseEvent(QMouseEvent* event);
161
162 /** @see QListView::paintEmptyArea() */
163 virtual void paintEmptyArea(QPainter* painter, const QRect& rect);
164
165 /** Draws the selection rubber. */
166 void drawRubber();
167
168 /** @see QListView::viewportPaintEvent() */
169 virtual void viewportPaintEvent(QPaintEvent* paintEvent);
170
171 /** @see QWidget::leaveEvent() */
172 virtual void leaveEvent(QEvent* event);
173
174 private slots:
175 void slotActivationUpdate();
176 void slotContextMenuRequested(Q3ListViewItem* item,
177 const QPoint& pos,
178 int col);
179 void slotUpdateDisabledItems();
180 void slotAutoScroll();
181 void updateColumnsWidth();
182 void slotItemRenamed(Q3ListViewItem* item,
183 const QString& name,
184 int column);
185
186 /**
187 * Is invoked when a section from the header has
188 * been clicked and stores the sort column and sort
189 * order.
190 */
191 void slotHeaderClicked(int section);
192
193 private:
194 class DolphinListViewItem : public KFileListViewItem {
195 public:
196 DolphinListViewItem(Q3ListView* parent,
197 KFileItem* fileItem);
198 virtual ~DolphinListViewItem();
199 virtual void paintCell(QPainter* painter,
200 const QColorGroup& colorGroup,
201 int column,
202 int cellWidth,
203 int alignment);
204
205 virtual void paintFocus(QPainter* painter,
206 const QColorGroup& colorGroup,
207 const QRect& rect);
208 };
209
210 DolphinView* m_dolphinView;
211 QTimer* m_resizeTimer;
212 QTimer* m_scrollTimer;
213 QRect* m_rubber;
214
215 /**
216 * Returns the width of the filename in pixels including
217 * the icon. It is assured that the returned width is
218 * <= the width of the filename column.
219 */
220 int filenameWidth(const Q3ListViewItem* item) const;
221
222 };
223
224 #endif