]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnwidget.h
renamed IconManager to KFilePreviewGenerator
[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 KDirLister;
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 protected:
116 virtual QStyleOptionViewItem viewOptions() const;
117 virtual void startDrag(Qt::DropActions supportedActions);
118 virtual void dragEnterEvent(QDragEnterEvent* event);
119 virtual void dragLeaveEvent(QDragLeaveEvent* event);
120 virtual void dragMoveEvent(QDragMoveEvent* event);
121 virtual void dropEvent(QDropEvent* event);
122 virtual void paintEvent(QPaintEvent* event);
123 virtual void mousePressEvent(QMouseEvent* event);
124 virtual void keyPressEvent(QKeyEvent* event);
125 virtual void contextMenuEvent(QContextMenuEvent* event);
126 virtual void wheelEvent(QWheelEvent* event);
127 virtual void leaveEvent(QEvent* event);
128 virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
129
130 private slots:
131 void slotEntered(const QModelIndex& index);
132 void requestActivation();
133 void updateFont();
134
135 private:
136 /** Used by DolphinColumnWidget::setActive(). */
137 void activate();
138
139 /** Used by DolphinColumnWidget::setActive(). */
140 void deactivate();
141
142 private:
143 bool m_active;
144 DolphinColumnView* m_view;
145 SelectionManager* m_selectionManager;
146 KUrl m_url; // URL of the directory that is shown
147 KUrl m_childUrl; // URL of the next column that is shown
148
149 QFont m_font;
150 QSize m_decorationSize;
151
152 KDirLister* m_dirLister;
153 DolphinModel* m_dolphinModel;
154 DolphinSortFilterProxyModel* m_proxyModel;
155
156 KFilePreviewGenerator* m_previewGenerator;
157
158 QRect m_dropRect;
159
160 friend class DolphinColumnView;
161 };
162
163 inline bool DolphinColumnWidget::isActive() const
164 {
165 return m_active;
166 }
167
168 inline void DolphinColumnWidget::setChildUrl(const KUrl& url)
169 {
170 m_childUrl = url;
171 }
172
173 inline const KUrl& DolphinColumnWidget::childUrl() const
174 {
175 return m_childUrl;
176 }
177
178 inline void DolphinColumnWidget::setUrl(const KUrl& url)
179 {
180 if (url != m_url) {
181 m_url = url;
182 reload();
183 }
184 }
185
186 inline const KUrl& DolphinColumnWidget::url() const
187 {
188 return m_url;
189 }
190
191 #endif