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
);
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
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.
65 void showColumn(const KUrl
& url
);
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;
75 virtual void mousePressEvent(QMouseEvent
* event
);
76 virtual void resizeEvent(QResizeEvent
* event
);
83 * Moves the content of the columns view to represent
84 * the scrollbar position \a x.
86 void moveContentHorizontally(int x
);
89 * Updates the size of the decoration dependent on the
90 * icon size of the ColumnModeSettings. The controller
91 * will get informed about possible zoom in/zoom out
94 void updateDecorationSize();
97 * Expands the directory model the the currently active URL.
98 * Used by DolphinColumnView::reload() after the directory
99 * lister has been loaded.
101 void expandToActiveUrl();
104 * Triggers the reloading of columns after the model index
105 * \a index has been expanded. Used by DolphinModel::expandToActiveUrl().
107 void triggerReloadColumns(const QModelIndex
& index
);
110 * Adjusts the root index of all columns to represent the reloaded
111 * model. Used by DolphinModel::triggerReloadColumns().
113 void reloadColumns();
116 bool isZoomInPossible() const;
117 bool isZoomOutPossible() const;
119 inline ColumnWidget
* activeColumn() const;
122 * Deactivates the currently active column and activates
123 * the new column indicated by \a index. m_index represents
124 * the active column afterwards. Also the URL of the navigator
125 * will be adjusted to reflect the column URL.
127 void setActiveColumnIndex(int index
);
129 void layoutColumns();
130 void updateScrollBar();
133 * Assures that the currently active column is fully visible
134 * by adjusting the horizontal position of the content.
136 void assureVisibleActiveColumn();
139 * Request the activation for the column \a column. It is assured
140 * that the columns gets fully visible by adjusting the horizontal
141 * position of the content.
143 void requestActivation(ColumnWidget
* column
);
146 * Deletes all inactive child columns, that are a child of
147 * the currently active column.
149 void deleteInactiveChildColumns();
152 DolphinController
* m_controller
;
153 bool m_restoreActiveColumnFocus
;
156 QList
<ColumnWidget
*> m_columns
;
157 QTimeLine
* m_animation
;
159 DolphinModel
* m_dolphinModel
;
160 QAbstractProxyModel
* m_proxyModel
;
162 friend class ColumnWidget
;
165 ColumnWidget
* DolphinColumnView::activeColumn() const
167 return m_columns
[m_index
];