]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnviewcontainer.h
Restore the "Edit->Selection" menu from Konqueror 3 for file
[dolphin.git] / src / dolphincolumnviewcontainer.h
1 /***************************************************************************
2 * Copyright (C) 2007-2009 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 ***************************************************************************/
19
20 #ifndef DOLPHINCOLUMNVIEWCONTAINER_H
21 #define DOLPHINCOLUMNVIEWCONTAINER_H
22
23 #include "dolphinview.h"
24
25 #include <kurl.h>
26
27 #include <QList>
28 #include <QScrollArea>
29 #include <QString>
30
31 class DolphinColumnView;
32 class DolphinController;
33 class QFrame;
34 class QTimeLine;
35
36 /**
37 * @brief Represents a container for columns represented as instances
38 * of DolphinColumnView.
39 *
40 * @see DolphinColumnView
41 */
42 class DolphinColumnViewContainer : public QScrollArea
43 {
44 Q_OBJECT
45
46 public:
47 explicit DolphinColumnViewContainer(QWidget* parent,
48 DolphinController* controller);
49 virtual ~DolphinColumnViewContainer();
50
51 KUrl rootUrl() const;
52
53 QAbstractItemView* activeColumn() const;
54
55 /**
56 * Shows the column which represents the URL \a url. If the column
57 * is already shown, it gets activated, otherwise it will be created.
58 */
59 void showColumn(const KUrl& url);
60
61 protected:
62 virtual void mousePressEvent(QMouseEvent* event);
63 virtual void keyPressEvent(QKeyEvent* event);
64 virtual void resizeEvent(QResizeEvent* event);
65 virtual void wheelEvent(QWheelEvent* event);
66
67 private slots:
68 /**
69 * Moves the content of the columns view to represent
70 * the scrollbar position \a x.
71 */
72 void moveContentHorizontally(int x);
73
74 /**
75 * Updates the background color of the columns to respect
76 * the current activation state \a active.
77 */
78 void updateColumnsBackground(bool active);
79
80 private:
81 /**
82 * Deactivates the currently active column and activates
83 * the new column indicated by \a index. m_index represents
84 * the active column afterwards. Also the URL of the navigator
85 * will be adjusted to reflect the column URL.
86 */
87 void setActiveColumnIndex(int index);
88
89 void layoutColumns();
90 void updateScrollBar();
91
92 /**
93 * Assures that the currently active column is fully visible
94 * by adjusting the horizontal position of the content.
95 */
96 void assureVisibleActiveColumn();
97
98 /**
99 * Request the activation for the column \a column. It is assured
100 * that the columns gets fully visible by adjusting the horizontal
101 * position of the content.
102 */
103 void requestActivation(DolphinColumnView* column);
104
105 /** Removes all columns except of the root column. */
106 void removeAllColumns();
107
108 /**
109 * Returns the position of the point \a point relative to the column
110 * \a column.
111 */
112 QPoint columnPosition(DolphinColumnView* column, const QPoint& point) const;
113
114 /**
115 * Deletes the column. If the itemview of the controller is set to the column,
116 * the controllers itemview is set to 0.
117 */
118 void deleteColumn(DolphinColumnView* column);
119
120 private:
121 DolphinController* m_controller;
122 bool m_active;
123 int m_index;
124 int m_contentX;
125 QList<DolphinColumnView*> m_columns;
126 QFrame* m_emptyViewport;
127 QTimeLine* m_animation;
128 QAbstractItemView* m_dragSource;
129
130 friend class DolphinColumnView;
131 };
132
133 #endif