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