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
25 #include <QAbstractItemView>
27 #include <QStyleOption>
29 class DolphinColumnWidget
;
30 class DolphinController
;
32 class QAbstractProxyModel
;
36 * @brief Represents the view, where each directory is show as separate column.
38 * @see DolphinIconsView
39 * @see DolphinDetailsView
41 class DolphinColumnView
: public QAbstractItemView
46 explicit DolphinColumnView(QWidget
* parent
, DolphinController
* controller
);
47 virtual ~DolphinColumnView();
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;
53 /** Inverts the selection of the currently active column. */
54 void invertSelection();
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
64 * Adjusts the root URL of the first column and removes all
67 void setRootUrl(const KUrl
& url
);
69 /** Returns the URL of the first column. */
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.
77 void showColumn(const KUrl
& url
);
79 /** @see QAbstractItemView::selectAll() */
80 virtual void selectAll();
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;
90 virtual void mousePressEvent(QMouseEvent
* event
);
91 virtual void resizeEvent(QResizeEvent
* event
);
98 * Moves the content of the columns view to represent
99 * the scrollbar position \a x.
101 void moveContentHorizontally(int x
);
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
109 void updateDecorationSize();
112 * Updates the background color of the columns to respect
113 * the current activation state \a active.
115 void updateColumnsBackground(bool active
);
117 void slotShowHiddenFilesChanged(bool show
);
118 void slotShowPreviewChanged(bool show
);
121 bool isZoomInPossible() const;
122 bool isZoomOutPossible() const;
124 DolphinColumnWidget
* activeColumn() const;
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.
132 void setActiveColumnIndex(int index
);
134 void layoutColumns();
135 void updateScrollBar();
138 * Assures that the currently active column is fully visible
139 * by adjusting the horizontal position of the content.
141 void assureVisibleActiveColumn();
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.
148 void requestActivation(DolphinColumnWidget
* column
);
150 /** Removes all columns except of the root column. */
151 void removeAllColumns();
154 DolphinController
* m_controller
;
158 QList
<DolphinColumnWidget
*> m_columns
;
159 QTimeLine
* m_animation
;
161 friend class DolphinColumnWidget
;
164 inline DolphinColumnWidget
* DolphinColumnView::activeColumn() const
166 return m_columns
[m_index
];