]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnview.h
Restore the root URL when navigating through the history (this is important for views...
[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 <QAbstractItemView>
24 #include <QList>
25 #include <QStyleOption>
26
27 class ColumnWidget;
28 class DolphinController;
29 class DolphinModel;
30 class KUrl;
31 class QAbstractProxyModel;
32 class QTimeLine;
33
34 /**
35 * @brief Represents the view, where each directory is show as separate column.
36 *
37 * @see DolphinIconsView
38 * @see DolphinDetailsView
39 */
40 class DolphinColumnView : public QAbstractItemView
41 {
42 Q_OBJECT
43
44 public:
45 explicit DolphinColumnView(QWidget* parent, DolphinController* controller);
46 virtual ~DolphinColumnView();
47
48 virtual QModelIndex indexAt(const QPoint& point) const;
49 virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
50 virtual QRect visualRect(const QModelIndex& index) const;
51 virtual void setModel(QAbstractItemModel* model);
52
53 /**
54 * Reloads the content of all columns. In opposite to non-hierarchical views
55 * it is not enough to reload the KDirLister, instead this method must be explicitly
56 * invoked.
57 */
58 void reload();
59
60 public slots:
61 /**
62 * Shows the column which represents the URL \a url. If the column
63 * is already shown, it gets activated, otherwise it will be created.
64 */
65 void showColumn(const KUrl& url);
66
67 protected:
68 virtual bool isIndexHidden(const QModelIndex& index) const;
69 virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
70 virtual void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags);
71 virtual QRegion visualRegionForSelection(const QItemSelection& selection) const;
72 virtual int horizontalOffset() const;
73 virtual int verticalOffset() const;
74
75 virtual void mousePressEvent(QMouseEvent* event);
76 virtual void resizeEvent(QResizeEvent* event);
77
78 private slots:
79 void zoomIn();
80 void zoomOut();
81 void triggerItem(const QModelIndex& index);
82
83 /**
84 * Moves the content of the columns view to represent
85 * the scrollbar position \a x.
86 */
87 void moveContentHorizontally(int x);
88
89 /**
90 * Updates the size of the decoration dependent on the
91 * icon size of the ColumnModeSettings. The controller
92 * will get informed about possible zoom in/zoom out
93 * operations.
94 */
95 void updateDecorationSize();
96
97 /**
98 * Expands the directory model the the currently active URL.
99 * Used by DolphinColumnView::reload() after the directory
100 * lister has been loaded.
101 */
102 void expandToActiveUrl();
103
104 /**
105 * Triggers the reloading of columns after the model index
106 * \a index has been expanded. Used by DolphinModel::expandToActiveUrl().
107 */
108 void triggerReloadColumns(const QModelIndex& index);
109
110 /**
111 * Adjusts the root index of all columns to represent the reloaded
112 * model. Used by DolphinModel::triggerReloadColumns().
113 */
114 void reloadColumns();
115
116 private:
117 bool isZoomInPossible() const;
118 bool isZoomOutPossible() const;
119
120 inline ColumnWidget* activeColumn() const;
121
122 /**
123 * Deactivates the currently active column and activates
124 * the new column indicated by \a index. m_index represents
125 * the active column afterwards. Also the URL of the navigator
126 * will be adjusted to reflect the column URL.
127 */
128 void setActiveColumnIndex(int index);
129
130 void layoutColumns();
131 void updateScrollBar();
132
133 /**
134 * Assures that the currently active column is fully visible
135 * by adjusting the horizontal position of the content.
136 */
137 void assureVisibleActiveColumn();
138
139 /**
140 * Request the activation for the column \a column. It is assured
141 * that the columns gets fully visible by adjusting the horizontal
142 * position of the content.
143 */
144 void requestActivation(ColumnWidget* column);
145
146 /**
147 * Deletes all inactive child columns, that are a child of
148 * the currently active column.
149 */
150 void deleteInactiveChildColumns();
151
152 private:
153 DolphinController* m_controller;
154 bool m_restoreActiveColumnFocus;
155 int m_index;
156 int m_contentX;
157 QList<ColumnWidget*> m_columns;
158 QTimeLine* m_animation;
159
160 DolphinModel* m_dolphinModel;
161 QAbstractProxyModel* m_proxyModel;
162
163 friend class ColumnWidget;
164 };
165
166 ColumnWidget* DolphinColumnView::activeColumn() const
167 {
168 return m_columns[m_index];
169 }
170
171 #endif