1 /***************************************************************************
2 * Copyright (C) 2007-2009 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 DOLPHINCOLUMNVIEWCONTAINER_H
21 #define DOLPHINCOLUMNVIEWCONTAINER_H
23 #include "dolphinview.h"
28 #include <QScrollArea>
31 class DolphinColumnView
;
32 class DolphinViewController
;
38 * @brief Represents a container for columns represented as instances
39 * of DolphinColumnView.
41 * @see DolphinColumnView
43 class DolphinColumnViewContainer
: public QScrollArea
49 * @param parent Parent widget.
50 * @param dolphinViewController Allows the DolphinColumnView to control the
51 * DolphinView in a limited way.
52 * @param viewModeController Controller that is used by the DolphinView
53 * to control the DolphinColumnView. The DolphinColumnView
54 * only has read access to the controller.
55 * @param model Directory that is shown.
57 explicit DolphinColumnViewContainer(QWidget
* parent
,
58 DolphinViewController
* dolphinViewController
,
59 const ViewModeController
* viewModeController
);
60 virtual ~DolphinColumnViewContainer();
64 QAbstractItemView
* activeColumn() const;
67 * Shows the column which represents the URL \a url. If the column
68 * is already shown, it gets activated, otherwise it will be created.
70 void showColumn(const KUrl
& url
);
73 virtual void mousePressEvent(QMouseEvent
* event
);
74 virtual void keyPressEvent(QKeyEvent
* event
);
75 virtual void resizeEvent(QResizeEvent
* event
);
76 virtual void wheelEvent(QWheelEvent
* event
);
80 * Moves the content of the columns view to represent
81 * the scrollbar position \a x.
83 void moveContentHorizontally(int x
);
86 * Updates the background color of the columns to respect
87 * the current activation state \a active.
89 void updateColumnsBackground(bool active
);
92 * Tells the Dolphin controller to update the active URL
93 * to m_activeUrl. The slot is called asynchronously with a
94 * small delay, as this prevents a flickering when a directory
95 * from an inactive column gets selected.
97 void updateActiveUrl();
101 * Deactivates the currently active column and activates
102 * the new column indicated by \a index. m_index represents
103 * the active column afterwards. Also the URL of the navigator
104 * will be adjusted to reflect the column URL.
106 void setActiveColumnIndex(int index
);
108 void layoutColumns();
109 void updateScrollBar();
112 * Assures that the currently active column is fully visible
113 * by adjusting the horizontal position of the content.
115 void assureVisibleActiveColumn();
118 * Request the activation for the column \a column. It is assured
119 * that the columns gets fully visible by adjusting the horizontal
120 * position of the content.
122 void requestActivation(DolphinColumnView
* column
);
124 /** Removes all columns except of the root column. */
125 void removeAllColumns();
128 * Returns the position of the point \a point relative to the column
131 QPoint
columnPosition(DolphinColumnView
* column
, const QPoint
& point
) const;
134 * Deletes the column. If the itemview of the controller is set to the column,
135 * the controllers itemview is set to 0.
137 void deleteColumn(DolphinColumnView
* column
);
140 DolphinViewController
* m_dolphinViewController
;
141 const ViewModeController
* m_viewModeController
;
145 QList
<DolphinColumnView
*> m_columns
;
146 QFrame
* m_emptyViewport
;
147 QTimeLine
* m_animation
;
148 QAbstractItemView
* m_dragSource
;
150 QTimer
* m_activeUrlTimer
;
152 friend class DolphinColumnView
;