]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnwidget.h
SVN_SILENT: assure that the order of the methods match in the h + cpp file
[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 DolphinDirLister;
36 class KFilePreviewGenerator;
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 /**
108 * Returns the item on the position \a pos. The KFileItem instance
109 * is null if no item is below the position.
110 */
111 KFileItem itemAt(const QPoint& pos) const;
112
113 KFileItemList selectedItems() const;
114
115 /**
116 * Returns the MIME data for the selected items.
117 */
118 QMimeData* selectionMimeData() const;
119
120 protected:
121 virtual QStyleOptionViewItem viewOptions() const;
122 virtual void startDrag(Qt::DropActions supportedActions);
123 virtual void dragEnterEvent(QDragEnterEvent* event);
124 virtual void dragLeaveEvent(QDragLeaveEvent* event);
125 virtual void dragMoveEvent(QDragMoveEvent* event);
126 virtual void dropEvent(QDropEvent* event);
127 virtual void paintEvent(QPaintEvent* event);
128 virtual void mousePressEvent(QMouseEvent* event);
129 virtual void keyPressEvent(QKeyEvent* event);
130 virtual void contextMenuEvent(QContextMenuEvent* event);
131 virtual void wheelEvent(QWheelEvent* event);
132 virtual void leaveEvent(QEvent* event);
133 virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
134
135 private slots:
136 void slotEntered(const QModelIndex& index);
137 void requestActivation();
138 void updateFont();
139
140 private:
141 /** Used by DolphinColumnWidget::setActive(). */
142 void activate();
143
144 /** Used by DolphinColumnWidget::setActive(). */
145 void deactivate();
146
147 private:
148 bool m_active;
149 DolphinColumnView* m_view;
150 SelectionManager* m_selectionManager;
151 KUrl m_url; // URL of the directory that is shown
152 KUrl m_childUrl; // URL of the next column that is shown
153
154 QFont m_font;
155 QSize m_decorationSize;
156
157 DolphinDirLister* m_dirLister;
158 DolphinModel* m_dolphinModel;
159 DolphinSortFilterProxyModel* m_proxyModel;
160
161 KFilePreviewGenerator* m_previewGenerator;
162
163 QRect m_dropRect;
164
165 friend class DolphinColumnView;
166 };
167
168 inline bool DolphinColumnWidget::isActive() const
169 {
170 return m_active;
171 }
172
173 inline void DolphinColumnWidget::setChildUrl(const KUrl& url)
174 {
175 m_childUrl = url;
176 }
177
178 inline const KUrl& DolphinColumnWidget::childUrl() const
179 {
180 return m_childUrl;
181 }
182
183 inline void DolphinColumnWidget::setUrl(const KUrl& url)
184 {
185 if (url != m_url) {
186 m_url = url;
187 reload();
188 }
189 }
190
191 inline const KUrl& DolphinColumnWidget::url() const
192 {
193 return m_url;
194 }
195
196 #endif