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
);
81 void triggerItem(const QModelIndex
& index
);
84 * Moves the content of the columns view to represent
85 * the scrollbar position \a x.
87 void moveContentHorizontally(int x
);
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
95 void updateDecorationSize();
98 * Expands the directory model the the currently active URL.
99 * Used by DolphinColumnView::reload() after the directory
100 * lister has been loaded.
102 void expandToActiveUrl();
105 * Triggers the reloading of columns after the model index
106 * \a index has been expanded. Used by DolphinModel::expandToActiveUrl().
108 void triggerReloadColumns(const QModelIndex
& index
);
111 * Adjusts the root index of all columns to represent the reloaded
112 * model. Used by DolphinModel::triggerReloadColumns().
114 void reloadColumns();
117 bool isZoomInPossible() const;
118 bool isZoomOutPossible() const;
120 inline ColumnWidget
* activeColumn() const;
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.
128 void setActiveColumnIndex(int index
);
130 void layoutColumns();
131 void updateScrollBar();
134 * Assures that the currently active column is fully visible
135 * by adjusting the horizontal position of the content.
137 void assureVisibleActiveColumn();
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.
144 void requestActivation(ColumnWidget
* column
);
147 * Deletes all inactive child columns, that are a child of
148 * the currently active column.
150 void deleteInactiveChildColumns();
153 DolphinController
* m_controller
;
154 bool m_restoreActiveColumnFocus
;
157 QList
<ColumnWidget
*> m_columns
;
158 QTimeLine
* m_animation
;
160 DolphinModel
* m_dolphinModel
;
161 QAbstractProxyModel
* m_proxyModel
;
163 friend class ColumnWidget
;
166 ColumnWidget
* DolphinColumnView::activeColumn() const
168 return m_columns
[m_index
];