]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphincolumnviewcontainer.h
Fix height calculation of "Additional Information" label
[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 class QTimer;
36
37 /**
38 * @brief Represents a container for columns represented as instances
39 * of DolphinColumnView.
40 *
41 * @see DolphinColumnView
42 */
43 class DolphinColumnViewContainer : public QScrollArea
44 {
45 Q_OBJECT
46
47 public:
48 explicit DolphinColumnViewContainer(QWidget* parent,
49 DolphinController* controller);
50 virtual ~DolphinColumnViewContainer();
51
52 KUrl rootUrl() const;
53
54 QAbstractItemView* activeColumn() const;
55
56 /**
57 * Shows the column which represents the URL \a url. If the column
58 * is already shown, it gets activated, otherwise it will be created.
59 */
60 void showColumn(const KUrl& url);
61
62 protected:
63 virtual void mousePressEvent(QMouseEvent* event);
64 virtual void keyPressEvent(QKeyEvent* event);
65 virtual void resizeEvent(QResizeEvent* event);
66 virtual void wheelEvent(QWheelEvent* event);
67
68 private slots:
69 /**
70 * Moves the content of the columns view to represent
71 * the scrollbar position \a x.
72 */
73 void moveContentHorizontally(int x);
74
75 /**
76 * Updates the background color of the columns to respect
77 * the current activation state \a active.
78 */
79 void updateColumnsBackground(bool active);
80
81 /**
82 * Tells the Dolphin controller to update the active URL
83 * to m_activeUrl. The slot is called asynchronously with a
84 * small delay, as this prevents a flickering when a directory
85 * from an inactive column gets selected.
86 */
87 void updateActiveUrl();
88
89 private:
90 /**
91 * Deactivates the currently active column and activates
92 * the new column indicated by \a index. m_index represents
93 * the active column afterwards. Also the URL of the navigator
94 * will be adjusted to reflect the column URL.
95 */
96 void setActiveColumnIndex(int index);
97
98 void layoutColumns();
99 void updateScrollBar();
100
101 /**
102 * Assures that the currently active column is fully visible
103 * by adjusting the horizontal position of the content.
104 */
105 void assureVisibleActiveColumn();
106
107 /**
108 * Request the activation for the column \a column. It is assured
109 * that the columns gets fully visible by adjusting the horizontal
110 * position of the content.
111 */
112 void requestActivation(DolphinColumnView* column);
113
114 /** Removes all columns except of the root column. */
115 void removeAllColumns();
116
117 /**
118 * Returns the position of the point \a point relative to the column
119 * \a column.
120 */
121 QPoint columnPosition(DolphinColumnView* column, const QPoint& point) const;
122
123 /**
124 * Deletes the column. If the itemview of the controller is set to the column,
125 * the controllers itemview is set to 0.
126 */
127 void deleteColumn(DolphinColumnView* column);
128
129 private:
130 DolphinController* m_controller;
131 bool m_active;
132 int m_index;
133 int m_contentX;
134 QList<DolphinColumnView*> m_columns;
135 QFrame* m_emptyViewport;
136 QTimeLine* m_animation;
137 QAbstractItemView* m_dragSource;
138
139 QTimer* m_activeUrlTimer;
140
141 friend class DolphinColumnView;
142 };
143
144 #endif