]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnview.h
fixed issue that turning off the preview during the preview job still was active...
[dolphin.git] / src / dolphincolumnview.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 DOLPHINCOLUMNVIEW_H
21 #define DOLPHINCOLUMNVIEW_H
22
23 #include <kurl.h>
24
25 #include <QAbstractItemView>
26 #include <QList>
27 #include <QString>
28 #include <QStyleOption>
29
30 class DolphinColumnWidget;
31 class DolphinController;
32 class DolphinModel;
33 class QAbstractProxyModel;
34 class QFrame;
35 class QTimeLine;
36
37 /**
38 * @brief Represents the view, where each directory is show as separate column.
39 *
40 * @see DolphinIconsView
41 * @see DolphinDetailsView
42 */
43 class DolphinColumnView : public QAbstractItemView
44 {
45 Q_OBJECT
46
47 public:
48 explicit DolphinColumnView(QWidget* parent, DolphinController* controller);
49 virtual ~DolphinColumnView();
50
51 virtual QModelIndex indexAt(const QPoint& point) const;
52 virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
53 virtual QRect visualRect(const QModelIndex& index) const;
54
55 /** Inverts the selection of the currently active column. */
56 void invertSelection();
57
58 /**
59 * Reloads the content of all columns. In opposite to non-hierarchical views
60 * it is not enough to reload the KDirLister, instead this method must be explicitly
61 * invoked.
62 */
63 void reload();
64
65 /**
66 * Adjusts the root URL of the first column and removes all
67 * other columns.
68 */
69 void setRootUrl(const KUrl& url);
70
71 /** Returns the URL of the first column. */
72 KUrl rootUrl() const;
73
74 /**
75 * Filters the currently shown items by \a nameFilter. All items
76 * which contain the given filter string will be shown.
77 */
78 void setNameFilter(const QString& nameFilter);
79
80 /**
81 * Returns the currently used name filter. All items
82 * which contain the name filter will be shown.
83 */
84 QString nameFilter() const;
85
86 /**
87 * Shows the column which represents the URL \a url. If the column
88 * is already shown, it gets activated, otherwise it will be created.
89 */
90 void showColumn(const KUrl& url);
91
92 public slots:
93 /** @see QAbstractItemView::selectAll() */
94 virtual void selectAll();
95
96 protected:
97 virtual bool isIndexHidden(const QModelIndex& index) const;
98 virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
99 virtual void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags);
100 virtual QRegion visualRegionForSelection(const QItemSelection& selection) const;
101 virtual int horizontalOffset() const;
102 virtual int verticalOffset() const;
103
104 virtual void mousePressEvent(QMouseEvent* event);
105 virtual void resizeEvent(QResizeEvent* event);
106
107 private slots:
108 void zoomIn();
109 void zoomOut();
110
111 /**
112 * Moves the content of the columns view to represent
113 * the scrollbar position \a x.
114 */
115 void moveContentHorizontally(int x);
116
117 /**
118 * Updates the size of the decoration dependent on the
119 * icon size of the ColumnModeSettings. The controller
120 * will get informed about possible zoom in/zoom out
121 * operations.
122 */
123 void updateDecorationSize();
124
125 /**
126 * Updates the background color of the columns to respect
127 * the current activation state \a active.
128 */
129 void updateColumnsBackground(bool active);
130
131 void slotShowHiddenFilesChanged();
132 void slotShowPreviewChanged();
133
134 private:
135 bool isZoomInPossible() const;
136 bool isZoomOutPossible() const;
137
138 DolphinColumnWidget* activeColumn() const;
139
140 /**
141 * Deactivates the currently active column and activates
142 * the new column indicated by \a index. m_index represents
143 * the active column afterwards. Also the URL of the navigator
144 * will be adjusted to reflect the column URL.
145 */
146 void setActiveColumnIndex(int index);
147
148 void layoutColumns();
149 void updateScrollBar();
150
151 /**
152 * Assures that the currently active column is fully visible
153 * by adjusting the horizontal position of the content.
154 */
155 void assureVisibleActiveColumn();
156
157 /**
158 * Request the activation for the column \a column. It is assured
159 * that the columns gets fully visible by adjusting the horizontal
160 * position of the content.
161 */
162 void requestActivation(DolphinColumnWidget* column);
163
164 /** Removes all columns except of the root column. */
165 void removeAllColumns();
166
167 private:
168 DolphinController* m_controller;
169 bool m_active;
170 int m_index;
171 int m_contentX;
172 QList<DolphinColumnWidget*> m_columns;
173 QFrame* m_emptyViewport;
174 QTimeLine* m_animation;
175 QString m_nameFilter;
176
177 friend class DolphinColumnWidget;
178 };
179
180 inline DolphinColumnWidget* DolphinColumnView::activeColumn() const
181 {
182 return m_columns[m_index];
183 }
184
185 #endif