]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnview.h
Restore the "Edit->Selection" menu from Konqueror 3 for file
[dolphin.git] / src / dolphincolumnview.h
1 /***************************************************************************
2 * Copyright (C) 2007-2009 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef DOLPHINCOLUMNVIEW_H
21 #define DOLPHINCOLUMNVIEW_H
22
23 #include "dolphinview.h"
24
25 #include <QFont>
26 #include <QListView>
27 #include <QSize>
28 #include <QStyleOption>
29
30 #include <kurl.h>
31
32 class DolphinColumnViewContainer;
33 class DolphinModel;
34 class DolphinSortFilterProxyModel;
35 class DolphinDirLister;
36 class KFileItem;
37 class KFileItemList;
38 class SelectionManager;
39 class ViewExtensionsFactory;
40
41 /**
42 * Represents one column inside the DolphinColumnViewContainer.
43 */
44 class DolphinColumnView : public QListView
45 {
46 Q_OBJECT
47
48 public:
49 DolphinColumnView(QWidget* parent,
50 DolphinColumnViewContainer* container,
51 const KUrl& url);
52 virtual ~DolphinColumnView();
53
54 /**
55 * An active column is defined as column, which shows the same URL
56 * as indicated by the URL navigator. The active column is usually
57 * drawn in a lighter color. All operations are applied to this column.
58 */
59 void setActive(bool active);
60 bool isActive() const;
61
62 /**
63 * Sets the directory URL of the child column that is shown next to
64 * this column. This property is only used for a visual indication
65 * of the shown directory, it does not trigger a loading of the model.
66 */
67 void setChildUrl(const KUrl& url);
68 KUrl childUrl() const;
69
70 /** Sets the directory URL that is shown inside the column widget. */
71 void setUrl(const KUrl& url);
72
73 /** Returns the directory URL that is shown inside the column widget. */
74 KUrl url() const;
75
76 /**
77 * Updates the background color dependent from the activation state
78 * \a isViewActive of the column view.
79 */
80 void updateBackground();
81
82 /**
83 * Returns the item on the position \a pos. The KFileItem instance
84 * is null if no item is below the position.
85 */
86 KFileItem itemAt(const QPoint& pos) const;
87
88 protected:
89 virtual QStyleOptionViewItem viewOptions() const;
90 virtual void startDrag(Qt::DropActions supportedActions);
91 virtual void dragEnterEvent(QDragEnterEvent* event);
92 virtual void dragLeaveEvent(QDragLeaveEvent* event);
93 virtual void dragMoveEvent(QDragMoveEvent* event);
94 virtual void dropEvent(QDropEvent* event);
95 virtual void paintEvent(QPaintEvent* event);
96 virtual void mousePressEvent(QMouseEvent* event);
97 virtual void keyPressEvent(QKeyEvent* event);
98 virtual void contextMenuEvent(QContextMenuEvent* event);
99 virtual void wheelEvent(QWheelEvent* event);
100 virtual void leaveEvent(QEvent* event);
101 virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
102 virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
103
104 private slots:
105 void setZoomLevel(int level);
106
107 void slotEntered(const QModelIndex& index);
108 void requestActivation();
109 void updateFont();
110
111 void slotShowPreviewChanged();
112
113 private:
114 /** Used by DolphinColumnView::setActive(). */
115 void activate();
116
117 /** Used by DolphinColumnView::setActive(). */
118 void deactivate();
119
120 void updateDecorationSize(bool showPreview);
121
122 private:
123 bool m_active;
124 DolphinColumnViewContainer* m_container;
125 SelectionManager* m_selectionManager;
126 ViewExtensionsFactory* m_extensionsFactory;
127 KUrl m_url; // URL of the directory that is shown
128 KUrl m_childUrl; // URL of the next column that is shown
129
130 QFont m_font;
131 QSize m_decorationSize;
132
133 DolphinDirLister* m_dirLister;
134 DolphinModel* m_dolphinModel;
135 DolphinSortFilterProxyModel* m_proxyModel;
136
137 QRect m_dropRect;
138
139 friend class DolphinColumnViewContainer;
140 };
141
142 inline bool DolphinColumnView::isActive() const
143 {
144 return m_active;
145 }
146
147 inline void DolphinColumnView::setChildUrl(const KUrl& url)
148 {
149 m_childUrl = url;
150 }
151
152 inline KUrl DolphinColumnView::childUrl() const
153 {
154 return m_childUrl;
155 }
156
157 inline void DolphinColumnView::setUrl(const KUrl& url)
158 {
159 if (url != m_url) {
160 m_url = url;
161 //reload();
162 }
163 }
164
165 inline KUrl DolphinColumnView::url() const
166 {
167 return m_url;
168 }
169
170 #endif