1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
27
* This file desfines the classes which build up the view of the TabBox.
29
* @author Martin Gräßlin <kde@martin-graesslin.com>
33
class QPropertyAnimation;
44
class DesktopItemDelegate;
48
class ClientItemDelegate;
51
class TabBoxAdditionalView;
54
* This class is the main view of the TabBox. It is made up of two widgets:
55
* TabBoxMainView which is the "switching area" for TabBox items and
56
* TabBoxInfoView which is an optional second list view only displaying the
57
* current selected item.
59
* @author Martin Gräßlin <kde@martin-graesslin.com>
62
class TabBoxView : public QWidget
65
Q_PROPERTY(QRect selectedItem READ selectedItem WRITE setSelectedItem)
67
TabBoxView(QWidget* parent = 0);
69
virtual void paintEvent(QPaintEvent* e);
70
virtual bool event(QEvent* event);
71
virtual void resizeEvent(QResizeEvent* event);
72
virtual QSize sizeHint() const;
73
void updateGeometry();
76
* Returns the index at the given position of the main view widget.
77
* @param pos The widget position
78
* @return The model index at given position. If there is no item
79
* at the position or the position is not in the main widget an
80
* invalid item will be returned.
82
QModelIndex indexAt(QPoint pos);
85
* @return The ClientModel used by TabBox.
87
ClientModel* clientModel() const {
91
* @return The DesktopModel used by TabBox.
93
DesktopModel* desktopModel() {
94
return m_desktopModel;
96
ClientItemDelegate* clientDelegate() const {
99
ClientItemDelegate* additionalClientDelegate() const {
100
return m_additionalClientDelegate;
102
DesktopItemDelegate* desktopDelegate() const {
103
return m_desktopItemDelegate;
105
DesktopItemDelegate* additionalDesktopDelegate() const {
106
return m_additionalDesktopDelegate;
109
void setPreview(bool preview);
110
bool preview() const {
114
QRect selectedItem() const {
115
return m_selectedItem;
117
void setSelectedItem(const QRect& rect) {
118
m_selectedItem = rect;
123
* Sets the current index in the two views.
124
* @param index The new index
126
void setCurrentIndex(QModelIndex index);
130
* This slot reacts on a changed TabBoxConfig. It changes the used
131
* item model and delegate if the TabBoxMode changed.
133
void configChanged();
137
* The main widget used to show all items
139
TabBoxMainView* m_tableView;
140
TabBoxAdditionalView* m_additionalView;
142
* Model for client items
144
ClientModel* m_clientModel;
146
* Model for desktop items
148
DesktopModel* m_desktopModel;
150
* Item delegate for client items
152
ClientItemDelegate* m_delegate;
153
ClientItemDelegate* m_additionalClientDelegate;
155
* Item delegate for desktop items
157
DesktopItemDelegate* m_desktopItemDelegate;
158
DesktopItemDelegate* m_additionalDesktopDelegate;
162
Plasma::FrameSvg* m_frame;
164
* The FrameSvg to render selected items
166
Plasma::FrameSvg* m_selectionFrame;
168
* TabBoxView is a preview
171
QPropertyAnimation* m_animation;
172
QRect m_selectedItem;
173
bool m_previewUpdate;
178
* This class is the main widget of the TabBoxView.
179
* It is the "switching area" for TabBox items.
181
* @author Martin Gräßlin <kde@martin-graesslin.com>
184
class TabBoxMainView : public QTableView
187
TabBoxMainView(QWidget* parent = 0);
190
virtual QSize sizeHint() const;
191
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
194
* This class is the additional widget of the TabBoxView.
195
* It just displays the current item and can be turned off.
197
* @author Martin Gräßlin <kde@martin-graesslin.com>
200
class TabBoxAdditionalView : public QTableView
203
TabBoxAdditionalView(QWidget* parent = 0);
204
~TabBoxAdditionalView();
206
virtual QSize sizeHint() const;
207
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
208
virtual void wheelEvent(QWheelEvent* event);
211
} // namespace Tabbox
214
#endif // TABBOXVIEW_H