1 /***************************************************************************
2 * Copyright (C) 2007-2009 by Peter Penz <peter.penz19@gmail.com> *
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();
100 * Invoked when m_assureVisibleActiveColumnTimer has been exceeded.
101 * Assures that the currently active column is fully visible
102 * by adjusting the horizontal position of the content.
104 void slotAssureVisibleActiveColumn();
108 * Assures that the currently active column is fully visible
109 * by adjusting the horizontal position of the content. The
110 * adjustment is done with a small delay (see
111 * slotAssureVisibleActiveColumn();
113 void assureVisibleActiveColumn();
115 void layoutColumns();
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 * Deletes the column. If the itemview of the controller is set to the column,
129 * the controllers itemview is set to 0.
131 void deleteColumn(DolphinColumnView
* column
);
134 DolphinViewController
* m_dolphinViewController
;
135 const ViewModeController
* m_viewModeController
;
139 QList
<DolphinColumnView
*> m_columns
;
140 QFrame
* m_emptyViewport
;
141 QTimeLine
* m_animation
;
142 QAbstractItemView
* m_dragSource
;
144 QTimer
* m_activeUrlTimer
;
145 QTimer
* m_assureVisibleActiveColumnTimer
;
147 friend class DolphinColumnView
;