delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / dolphin / src / dolphincolumnview.h
blob1fdd75850b0d61c01a94233f633b3e2d5fa5e2dd
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 ***************************************************************************/
20 #ifndef DOLPHINCOLUMNVIEW_H
21 #define DOLPHINCOLUMNVIEW_H
23 #include "dolphinview.h"
25 #include <kurl.h>
27 #include <QAbstractItemView>
28 #include <QList>
29 #include <QString>
30 #include <QStyleOption>
32 class DolphinColumnWidget;
33 class DolphinController;
34 class DolphinModel;
35 class QAbstractProxyModel;
36 class QFrame;
37 class QTimeLine;
39 /**
40 * @brief Represents the view, where each directory is show as separate column.
42 * @see DolphinIconsView
43 * @see DolphinDetailsView
45 class DolphinColumnView : public QAbstractItemView
47 Q_OBJECT
49 public:
50 explicit DolphinColumnView(QWidget* parent, DolphinController* controller);
51 virtual ~DolphinColumnView();
53 /** @see QAbstractItemView::indexAt() */
54 virtual QModelIndex indexAt(const QPoint& point) const;
56 /**
57 * Returns the item on the position \a pos. The KFileItem instance
58 * is null if no item is below the position.
60 KFileItem itemAt(const QPoint& point) const;
62 /** @see QAbstractItemView::scrollTo() */
63 virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
65 /** @see QAbstractItemView::visualRect() */
66 virtual QRect visualRect(const QModelIndex& index) const;
68 /** Inverts the selection of the currently active column. */
69 void invertSelection();
71 /**
72 * Reloads the content of all columns. In opposite to non-hierarchical views
73 * it is not enough to reload the KDirLister, instead this method must be explicitly
74 * invoked.
76 void reload();
78 /**
79 * Adjusts the root URL of the first column and removes all
80 * other columns.
82 void setRootUrl(const KUrl& url);
84 /** Returns the URL of the first column. */
85 KUrl rootUrl() const;
87 /**
88 * Filters the currently shown items by \a nameFilter. All items
89 * which contain the given filter string will be shown.
91 void setNameFilter(const QString& nameFilter);
93 /**
94 * Returns the currently used name filter. All items
95 * which contain the name filter will be shown.
97 QString nameFilter() const;
99 /**
100 * Shows the column which represents the URL \a url. If the column
101 * is already shown, it gets activated, otherwise it will be created.
103 void showColumn(const KUrl& url);
106 * Does an inline editing for the item \a item
107 * inside the active column.
109 void editItem(const KFileItem& item);
112 * Returns the selected items of the active column.
114 KFileItemList selectedItems() const;
117 * Returns the MIME data for the selected items
118 * of the active column.
120 QMimeData* selectionMimeData() const;
122 public slots:
123 /** @see QAbstractItemView::selectAll() */
124 virtual void selectAll();
126 protected:
127 virtual bool isIndexHidden(const QModelIndex& index) const;
128 virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
129 virtual void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags);
130 virtual QRegion visualRegionForSelection(const QItemSelection& selection) const;
131 virtual int horizontalOffset() const;
132 virtual int verticalOffset() const;
134 virtual void mousePressEvent(QMouseEvent* event);
135 virtual void resizeEvent(QResizeEvent* event);
136 virtual void wheelEvent(QWheelEvent* event);
138 private slots:
139 void setZoomLevel(int level);
142 * Moves the content of the columns view to represent
143 * the scrollbar position \a x.
145 void moveContentHorizontally(int x);
148 * Updates the size of the decoration dependent on the
149 * icon size of the ColumnModeSettings. The controller
150 * will get informed about possible zoom in/zoom out
151 * operations.
153 void updateDecorationSize(bool showPreview);
156 * Updates the background color of the columns to respect
157 * the current activation state \a active.
159 void updateColumnsBackground(bool active);
161 void slotSortingChanged(DolphinView::Sorting sorting);
162 void slotSortOrderChanged(Qt::SortOrder order);
163 void slotShowHiddenFilesChanged();
164 void slotShowPreviewChanged();
166 private:
167 DolphinColumnWidget* activeColumn() const;
170 * Deactivates the currently active column and activates
171 * the new column indicated by \a index. m_index represents
172 * the active column afterwards. Also the URL of the navigator
173 * will be adjusted to reflect the column URL.
175 void setActiveColumnIndex(int index);
177 void layoutColumns();
178 void updateScrollBar();
181 * Assures that the currently active column is fully visible
182 * by adjusting the horizontal position of the content.
184 void assureVisibleActiveColumn();
187 * Request the activation for the column \a column. It is assured
188 * that the columns gets fully visible by adjusting the horizontal
189 * position of the content.
191 void requestActivation(DolphinColumnWidget* column);
193 /** Removes all columns except of the root column. */
194 void removeAllColumns();
197 * Returns the position of the point \a point relative to the column
198 * \a column.
200 QPoint columnPosition(DolphinColumnWidget* column, const QPoint& point) const;
203 * Deletes the column. If the itemview of the controller is set to the column,
204 * the controllers itemview is set to 0.
206 void deleteColumn(DolphinColumnWidget* column);
208 private:
209 DolphinController* m_controller;
210 bool m_active;
211 int m_index;
212 int m_contentX;
213 QList<DolphinColumnWidget*> m_columns;
214 QFrame* m_emptyViewport;
215 QTimeLine* m_animation;
216 QString m_nameFilter;
218 friend class DolphinColumnWidget;
221 inline DolphinColumnWidget* DolphinColumnView::activeColumn() const
223 return m_columns[m_index];
226 #endif