~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/tabbox/tabboxview.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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
*********************************************************************/
 
20
 
 
21
#ifndef TABBOXVIEW_H
 
22
#define TABBOXVIEW_H
 
23
 
 
24
#include <QTableView>
 
25
/**
 
26
* @file
 
27
* This file desfines the classes which build up the view of the TabBox.
 
28
*
 
29
* @author Martin Gräßlin <kde@martin-graesslin.com>
 
30
* @since 4.4
 
31
*/
 
32
 
 
33
class QPropertyAnimation;
 
34
class QModelIndex;
 
35
namespace Plasma
 
36
{
 
37
class FrameSvg;
 
38
}
 
39
 
 
40
namespace KWin
 
41
{
 
42
namespace TabBox
 
43
{
 
44
class DesktopItemDelegate;
 
45
class DesktopModel;
 
46
 
 
47
class ClientModel;
 
48
class ClientItemDelegate;
 
49
 
 
50
class TabBoxMainView;
 
51
class TabBoxAdditionalView;
 
52
 
 
53
/**
 
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.
 
58
*
 
59
* @author Martin Gräßlin <kde@martin-graesslin.com>
 
60
* @since 4.4
 
61
*/
 
62
class TabBoxView : public QWidget
 
63
{
 
64
    Q_OBJECT
 
65
    Q_PROPERTY(QRect selectedItem READ selectedItem WRITE setSelectedItem)
 
66
public:
 
67
    TabBoxView(QWidget* parent = 0);
 
68
    ~TabBoxView();
 
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();
 
74
 
 
75
    /**
 
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.
 
81
    */
 
82
    QModelIndex indexAt(QPoint pos);
 
83
 
 
84
    /**
 
85
    * @return The ClientModel used by TabBox.
 
86
    */
 
87
    ClientModel* clientModel() const {
 
88
        return m_clientModel;
 
89
    }
 
90
    /**
 
91
    * @return The DesktopModel used by TabBox.
 
92
    */
 
93
    DesktopModel* desktopModel() {
 
94
        return m_desktopModel;
 
95
    }
 
96
    ClientItemDelegate* clientDelegate() const {
 
97
        return m_delegate;
 
98
    }
 
99
    ClientItemDelegate* additionalClientDelegate() const {
 
100
        return m_additionalClientDelegate;
 
101
    }
 
102
    DesktopItemDelegate* desktopDelegate() const {
 
103
        return m_desktopItemDelegate;
 
104
    }
 
105
    DesktopItemDelegate* additionalDesktopDelegate() const {
 
106
        return m_additionalDesktopDelegate;
 
107
    }
 
108
 
 
109
    void setPreview(bool preview);
 
110
    bool preview() const {
 
111
        return m_preview;
 
112
    }
 
113
 
 
114
    QRect selectedItem() const {
 
115
        return m_selectedItem;
 
116
    }
 
117
    void setSelectedItem(const QRect& rect) {
 
118
        m_selectedItem = rect;
 
119
    }
 
120
 
 
121
public slots:
 
122
    /**
 
123
    * Sets the current index in the two views.
 
124
    * @param index The new index
 
125
    */
 
126
    void setCurrentIndex(QModelIndex index);
 
127
 
 
128
private slots:
 
129
    /**
 
130
    * This slot reacts on a changed TabBoxConfig. It changes the used
 
131
    * item model and delegate if the TabBoxMode changed.
 
132
    */
 
133
    void configChanged();
 
134
 
 
135
private:
 
136
    /**
 
137
    * The main widget used to show all items
 
138
    */
 
139
    TabBoxMainView* m_tableView;
 
140
    TabBoxAdditionalView* m_additionalView;
 
141
    /**
 
142
    * Model for client items
 
143
    */
 
144
    ClientModel* m_clientModel;
 
145
    /**
 
146
    * Model for desktop items
 
147
    */
 
148
    DesktopModel* m_desktopModel;
 
149
    /**
 
150
    * Item delegate for client items
 
151
    */
 
152
    ClientItemDelegate* m_delegate;
 
153
    ClientItemDelegate* m_additionalClientDelegate;
 
154
    /**
 
155
    * Item delegate for desktop items
 
156
    */
 
157
    DesktopItemDelegate* m_desktopItemDelegate;
 
158
    DesktopItemDelegate* m_additionalDesktopDelegate;
 
159
    /**
 
160
    * Background Frame
 
161
    */
 
162
    Plasma::FrameSvg* m_frame;
 
163
    /**
 
164
    * The FrameSvg to render selected items
 
165
    */
 
166
    Plasma::FrameSvg* m_selectionFrame;
 
167
    /**
 
168
    * TabBoxView is a preview
 
169
    */
 
170
    bool m_preview;
 
171
    QPropertyAnimation* m_animation;
 
172
    QRect m_selectedItem;
 
173
    bool m_previewUpdate;
 
174
 
 
175
};
 
176
 
 
177
/**
 
178
* This class is the main widget of the TabBoxView.
 
179
* It is the "switching area" for TabBox items.
 
180
*
 
181
* @author Martin Gräßlin <kde@martin-graesslin.com>
 
182
* @since 4.4
 
183
*/
 
184
class TabBoxMainView : public QTableView
 
185
{
 
186
public:
 
187
    TabBoxMainView(QWidget* parent = 0);
 
188
    ~TabBoxMainView();
 
189
 
 
190
    virtual QSize sizeHint() const;
 
191
    virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
 
192
};
 
193
/**
 
194
* This class is the additional widget of the TabBoxView.
 
195
* It just displays the current item and can be turned off.
 
196
*
 
197
* @author Martin Gräßlin <kde@martin-graesslin.com>
 
198
* @since 4.4
 
199
*/
 
200
class TabBoxAdditionalView : public QTableView
 
201
{
 
202
public:
 
203
    TabBoxAdditionalView(QWidget* parent = 0);
 
204
    ~TabBoxAdditionalView();
 
205
 
 
206
    virtual QSize sizeHint() const;
 
207
    virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
 
208
    virtual void wheelEvent(QWheelEvent* event);
 
209
};
 
210
 
 
211
} // namespace Tabbox
 
212
} // namespace KWin
 
213
 
 
214
#endif // TABBOXVIEW_H