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