1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef DOLPHINCOLUMNVIEW_H
21 #define DOLPHINCOLUMNVIEW_H
23 #include <QAbstractItemView>
25 #include <QStyleOption>
28 class DolphinController
;
31 class QAbstractProxyModel
;
35 * @brief Represents the view, where each directory is show as separate column.
37 * @see DolphinIconsView
38 * @see DolphinDetailsView
40 class DolphinColumnView
: public QAbstractItemView
45 explicit DolphinColumnView(QWidget
* parent
, DolphinController
* controller
);
46 virtual ~DolphinColumnView();
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
);
53 /** Inverts the selection of the currently active column. */
54 void invertSelection();
58 * Reloads the content of all columns. In opposite to non-hierarchical views
59 * it is not enough to reload the KDirLister, instead this method must be explicitly
65 * Shows the column which represents the URL \a url. If the column
66 * is already shown, it gets activated, otherwise it will be created.
68 void showColumn(const KUrl
& url
);
70 /** @see QAbstractItemView::selectAll() */
71 virtual void selectAll();
74 virtual bool isIndexHidden(const QModelIndex
& index
) const;
75 virtual QModelIndex
moveCursor(CursorAction cursorAction
, Qt::KeyboardModifiers modifiers
);
76 virtual void setSelection(const QRect
& rect
, QItemSelectionModel::SelectionFlags flags
);
77 virtual QRegion
visualRegionForSelection(const QItemSelection
& selection
) const;
78 virtual int horizontalOffset() const;
79 virtual int verticalOffset() const;
81 virtual void mousePressEvent(QMouseEvent
* event
);
82 virtual void resizeEvent(QResizeEvent
* event
);
89 * Moves the content of the columns view to represent
90 * the scrollbar position \a x.
92 void moveContentHorizontally(int x
);
95 * Updates the size of the decoration dependent on the
96 * icon size of the ColumnModeSettings. The controller
97 * will get informed about possible zoom in/zoom out
100 void updateDecorationSize();
103 * Expands the directory model the the currently active URL.
104 * Used by DolphinColumnView::reload() after the directory
105 * lister has been loaded.
107 void expandToActiveUrl();
110 * Triggers the reloading of columns after the model index
111 * \a index has been expanded. Used by DolphinModel::expandToActiveUrl().
113 void triggerReloadColumns(const QModelIndex
& index
);
116 * Adjusts the root index of all columns to represent the reloaded
117 * model. Used by DolphinModel::triggerReloadColumns().
119 void reloadColumns();
121 void triggerItem(const QModelIndex
& index
);
124 bool isZoomInPossible() const;
125 bool isZoomOutPossible() const;
127 inline ColumnWidget
* activeColumn() const;
130 * Deactivates the currently active column and activates
131 * the new column indicated by \a index. m_index represents
132 * the active column afterwards. Also the URL of the navigator
133 * will be adjusted to reflect the column URL.
135 void setActiveColumnIndex(int index
);
137 void layoutColumns();
138 void updateScrollBar();
141 * Assures that the currently active column is fully visible
142 * by adjusting the horizontal position of the content.
144 void assureVisibleActiveColumn();
147 * Request the activation for the column \a column. It is assured
148 * that the columns gets fully visible by adjusting the horizontal
149 * position of the content.
151 void requestActivation(ColumnWidget
* column
);
154 DolphinController
* m_controller
;
155 bool m_restoreActiveColumnFocus
;
156 bool m_initializedDirLister
;
159 QList
<ColumnWidget
*> m_columns
;
160 QTimeLine
* m_animation
;
162 DolphinModel
* m_dolphinModel
;
163 QAbstractProxyModel
* m_proxyModel
;
165 friend class ColumnWidget
;
168 ColumnWidget
* DolphinColumnView::activeColumn() const
170 return m_columns
[m_index
];