]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphincolumnview.h
Fix Dolphin session management regression
[dolphin.git] / src / views / dolphincolumnview.h
1 /***************************************************************************
2 * Copyright (C) 2007-2009 by Peter Penz <peter.penz19@gmail.com> *
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 #include "dolphintreeview.h"
25
26 #include <QFont>
27 #include <QSize>
28 #include <QStyleOption>
29
30 #include <KUrl>
31
32 class DolphinColumnViewContainer;
33 class DolphinModel;
34 class DolphinSortFilterProxyModel;
35 class DolphinDirLister;
36 class KFileItem;
37 class QLabel;
38 class SelectionManager;
39 class ViewExtensionsFactory;
40
41 /**
42 * Represents one column inside the DolphinColumnViewContainer.
43 */
44 class DolphinColumnView : public DolphinTreeView
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 used for a visual indication
65 * of the shown directory, it does not trigger a loading of the model.
66 * When no url is selected and the user presses right, then child
67 * url will be used as column.
68 */
69 void setChildUrl(const KUrl& url);
70 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 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 virtual void setSelectionModel(QItemSelectionModel* model);
91
92 protected:
93 virtual QStyleOptionViewItem viewOptions() const;
94 virtual bool event(QEvent* event);
95 virtual void startDrag(Qt::DropActions supportedActions);
96 virtual void dragEnterEvent(QDragEnterEvent* event);
97 virtual void dragMoveEvent(QDragMoveEvent* event);
98 virtual void dropEvent(QDropEvent* event);
99 virtual void paintEvent(QPaintEvent* event);
100 virtual void mousePressEvent(QMouseEvent* event);
101 virtual void keyPressEvent(QKeyEvent* event);
102 virtual void contextMenuEvent(QContextMenuEvent* event);
103 virtual void wheelEvent(QWheelEvent* event);
104 virtual void leaveEvent(QEvent* event);
105 virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
106 virtual QRect visualRect(const QModelIndex& index) const;
107 virtual bool acceptsDrop(const QModelIndex& index) const;
108 virtual bool eventFilter(QObject* watched, QEvent* event);
109
110 private slots:
111 void setZoomLevel(int level);
112
113 void slotEntered(const QModelIndex& index);
114 void requestActivation();
115 void updateFont();
116
117 void slotShowPreviewChanged();
118
119 void slotDirListerCompleted();
120
121 private:
122 /** Used by DolphinColumnView::setActive(). */
123 void activate();
124
125 /** Used by DolphinColumnView::setActive(). */
126 void deactivate();
127
128 void updateDecorationSize(bool showPreview);
129
130 private:
131 bool m_active;
132 DolphinColumnViewContainer* m_container;
133 SelectionManager* m_selectionManager;
134 ViewExtensionsFactory* m_extensionsFactory;
135 KUrl m_url; // URL of the directory that is shown
136 KUrl m_childUrl; // URL of the next column that is shown
137
138 QFont m_font;
139 QSize m_decorationSize;
140
141 DolphinDirLister* m_dirLister;
142 DolphinModel* m_dolphinModel;
143 DolphinSortFilterProxyModel* m_proxyModel;
144
145 QLabel* m_resizeWidget;
146 int m_resizeXOrigin;
147
148 friend class DolphinColumnViewContainer;
149 };
150
151 #endif