]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnwidget.h
* clear the selection toggle when zooming in or out
[dolphin.git] / src / dolphincolumnwidget.h
1 /***************************************************************************
2 * Copyright (C) 2007 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 DOLPHINCOLUMNWIDGET_H
21 #define DOLPHINCOLUMNWIDGET_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 DolphinColumnView;
33 class DolphinModel;
34 class DolphinSortFilterProxyModel;
35 class IconManager;
36 class KDirLister;
37 class KJob;
38 class KFileItem;
39 class KFileItemList;
40 class SelectionManager;
41 class QPixmap;
42
43 /**
44 * Represents one column inside the DolphinColumnView and has been
45 * extended to respect view options and hovering information.
46 */
47 class DolphinColumnWidget : public QListView
48 {
49 Q_OBJECT
50
51 public:
52 DolphinColumnWidget(QWidget* parent,
53 DolphinColumnView* columnView,
54 const KUrl& url);
55 virtual ~DolphinColumnWidget();
56
57 /** Sets the size of the icons. */
58 void setDecorationSize(const QSize& size);
59
60 /**
61 * An active column is defined as column, which shows the same URL
62 * as indicated by the URL navigator. The active column is usually
63 * drawn in a lighter color. All operations are applied to this column.
64 */
65 void setActive(bool active);
66 bool isActive() const;
67
68 /**
69 * Sets the directory URL of the child column that is shown next to
70 * this column. This property is only used for a visual indication
71 * of the shown directory, it does not trigger a loading of the model.
72 */
73 void setChildUrl(const KUrl& url);
74 const KUrl& childUrl() const;
75
76 /** Sets the directory URL that is shown inside the column widget. */
77 void setUrl(const KUrl& url);
78
79 /** Returns the directory URL that is shown inside the column widget. */
80 const KUrl& url() const;
81
82 /** Reloads the directory DolphinColumnWidget::url(). */
83 void reload();
84
85 void setSorting(DolphinView::Sorting sorting);
86 void setSortOrder(Qt::SortOrder order);
87 void setShowHiddenFiles(bool show);
88 void setShowPreview(bool show);
89
90 /**
91 * Updates the background color dependent from the activation state
92 * \a isViewActive of the column view.
93 */
94 void updateBackground();
95
96 /**
97 * Filters the currently shown items by \a nameFilter. All items
98 * which contain the given filter string will be shown.
99 */
100 void setNameFilter(const QString& nameFilter);
101
102 /**
103 * Does an inline editing for the item \a item.
104 */
105 void editItem(const KFileItem& item);
106
107 protected:
108 virtual QStyleOptionViewItem viewOptions() const;
109 virtual void startDrag(Qt::DropActions supportedActions);
110 virtual void dragEnterEvent(QDragEnterEvent* event);
111 virtual void dragLeaveEvent(QDragLeaveEvent* event);
112 virtual void dragMoveEvent(QDragMoveEvent* event);
113 virtual void dropEvent(QDropEvent* event);
114 virtual void paintEvent(QPaintEvent* event);
115 virtual void mousePressEvent(QMouseEvent* event);
116 virtual void keyPressEvent(QKeyEvent* event);
117 virtual void contextMenuEvent(QContextMenuEvent* event);
118 virtual void wheelEvent(QWheelEvent* event);
119 virtual void leaveEvent(QEvent* event);
120 virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
121
122 private slots:
123 void slotEntered(const QModelIndex& index);
124 void requestActivation();
125 void updateFont();
126
127 private:
128 /** Used by DolphinColumnWidget::setActive(). */
129 void activate();
130
131 /** Used by DolphinColumnWidget::setActive(). */
132 void deactivate();
133
134 private:
135 bool m_active;
136 DolphinColumnView* m_view;
137 SelectionManager* m_selectionManager;
138 KUrl m_url; // URL of the directory that is shown
139 KUrl m_childUrl; // URL of the next column that is shown
140
141 QFont m_font;
142 QSize m_decorationSize;
143
144 KDirLister* m_dirLister;
145 DolphinModel* m_dolphinModel;
146 DolphinSortFilterProxyModel* m_proxyModel;
147
148 IconManager* m_iconManager;
149
150 QRect m_dropRect;
151
152 friend class DolphinColumnView;
153 };
154
155 inline bool DolphinColumnWidget::isActive() const
156 {
157 return m_active;
158 }
159
160 inline void DolphinColumnWidget::setChildUrl(const KUrl& url)
161 {
162 m_childUrl = url;
163 }
164
165 inline const KUrl& DolphinColumnWidget::childUrl() const
166 {
167 return m_childUrl;
168 }
169
170 inline void DolphinColumnWidget::setUrl(const KUrl& url)
171 {
172 if (url != m_url) {
173 m_url = url;
174 reload();
175 }
176 }
177
178 inline const KUrl& DolphinColumnWidget::url() const
179 {
180 return m_url;
181 }
182
183 #endif