]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnview.h
restore zooming functionality
[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 DolphinViewAutoScroller;
37 class KFilePreviewGenerator;
38 class KFileItem;
39 class KFileItemList;
40 class SelectionManager;
41 class ToolTipManager;
42
43 /**
44 * Represents one column inside the DolphinColumnViewContainer.
45 */
46 class DolphinColumnView : public QListView
47 {
48 Q_OBJECT
49
50 public:
51 DolphinColumnView(QWidget* parent,
52 DolphinColumnViewContainer* container,
53 const KUrl& url);
54 virtual ~DolphinColumnView();
55
56 /**
57 * An active column is defined as column, which shows the same URL
58 * as indicated by the URL navigator. The active column is usually
59 * drawn in a lighter color. All operations are applied to this column.
60 */
61 void setActive(bool active);
62 bool isActive() const;
63
64 /**
65 * Sets the directory URL of the child column that is shown next to
66 * this column. This property is only used for a visual indication
67 * of the shown directory, it does not trigger a loading of the model.
68 */
69 void setChildUrl(const KUrl& url);
70 const KUrl& childUrl() const;
71
72 /** Sets the directory URL that is shown inside the column widget. */
73 void setUrl(const KUrl& url);
74
75 /** Returns the directory URL that is shown inside the column widget. */
76 const KUrl& url() const;
77
78 /**
79 * Updates the background color dependent from the activation state
80 * \a isViewActive of the column view.
81 */
82 void updateBackground();
83
84 /**
85 * Returns the item on the position \a pos. The KFileItem instance
86 * is null if no item is below the position.
87 */
88 KFileItem itemAt(const QPoint& pos) const;
89
90 protected:
91 virtual QStyleOptionViewItem viewOptions() const;
92 virtual void startDrag(Qt::DropActions supportedActions);
93 virtual void dragEnterEvent(QDragEnterEvent* event);
94 virtual void dragLeaveEvent(QDragLeaveEvent* event);
95 virtual void dragMoveEvent(QDragMoveEvent* event);
96 virtual void dropEvent(QDropEvent* event);
97 virtual void paintEvent(QPaintEvent* event);
98 virtual void mousePressEvent(QMouseEvent* event);
99 virtual void keyPressEvent(QKeyEvent* event);
100 virtual void contextMenuEvent(QContextMenuEvent* event);
101 virtual void wheelEvent(QWheelEvent* event);
102 virtual void leaveEvent(QEvent* event);
103 virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
104 virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
105
106 private slots:
107 void setZoomLevel(int level);
108
109 void slotEntered(const QModelIndex& index);
110 void requestActivation();
111 void updateFont();
112
113 void slotShowPreviewChanged();
114
115 private:
116 /** Used by DolphinColumnView::setActive(). */
117 void activate();
118
119 /** Used by DolphinColumnView::setActive(). */
120 void deactivate();
121
122 void updateDecorationSize(bool showPreview);
123
124 private:
125 bool m_active;
126 DolphinColumnViewContainer* m_container;
127 SelectionManager* m_selectionManager;
128 DolphinViewAutoScroller* m_autoScroller;
129 KUrl m_url; // URL of the directory that is shown
130 KUrl m_childUrl; // URL of the next column that is shown
131
132 QFont m_font;
133 QSize m_decorationSize;
134
135 DolphinDirLister* m_dirLister;
136 DolphinModel* m_dolphinModel;
137 DolphinSortFilterProxyModel* m_proxyModel;
138
139 KFilePreviewGenerator* m_previewGenerator;
140
141 ToolTipManager* m_toolTipManager;
142
143 QRect m_dropRect;
144
145 friend class DolphinColumnViewContainer;
146 };
147
148 inline bool DolphinColumnView::isActive() const
149 {
150 return m_active;
151 }
152
153 inline void DolphinColumnView::setChildUrl(const KUrl& url)
154 {
155 m_childUrl = url;
156 }
157
158 inline const KUrl& DolphinColumnView::childUrl() const
159 {
160 return m_childUrl;
161 }
162
163 inline void DolphinColumnView::setUrl(const KUrl& url)
164 {
165 if (url != m_url) {
166 m_url = url;
167 //reload();
168 }
169 }
170
171 inline const KUrl& DolphinColumnView::url() const
172 {
173 return m_url;
174 }
175
176 #endif