]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphincolumnview.h
Update e-mail address from peter.penz@gmx.at to peter.penz19@gmail.com
[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 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 virtual void setSelectionModel(QItemSelectionModel* model);
89
90 protected:
91 virtual QStyleOptionViewItem viewOptions() const;
92 virtual bool event(QEvent* event);
93 virtual void startDrag(Qt::DropActions supportedActions);
94 virtual void dragEnterEvent(QDragEnterEvent* 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 currentChanged(const QModelIndex& current, const QModelIndex& previous);
104 virtual QRect visualRect(const QModelIndex& index) const;
105 virtual bool acceptsDrop(const QModelIndex& index) const;
106 virtual bool eventFilter(QObject* watched, QEvent* event);
107
108 private slots:
109 void setZoomLevel(int level);
110
111 void slotEntered(const QModelIndex& index);
112 void requestActivation();
113 void updateFont();
114
115 void slotShowPreviewChanged();
116
117 void slotDirListerCompleted();
118
119 private:
120 /** Used by DolphinColumnView::setActive(). */
121 void activate();
122
123 /** Used by DolphinColumnView::setActive(). */
124 void deactivate();
125
126 void updateDecorationSize(bool showPreview);
127
128 private:
129 bool m_active;
130 DolphinColumnViewContainer* m_container;
131 SelectionManager* m_selectionManager;
132 ViewExtensionsFactory* m_extensionsFactory;
133 KUrl m_url; // URL of the directory that is shown
134 KUrl m_childUrl; // URL of the next column that is shown
135
136 QFont m_font;
137 QSize m_decorationSize;
138
139 DolphinDirLister* m_dirLister;
140 DolphinModel* m_dolphinModel;
141 DolphinSortFilterProxyModel* m_proxyModel;
142
143 QLabel* m_resizeWidget;
144 int m_resizeXOrigin;
145
146 friend class DolphinColumnViewContainer;
147 };
148
149 #endif