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

« back to all changes in this revision

Viewing changes to kwin/tabbox/desktopmodel.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 DESKTOPMODEL_H
 
22
#define DESKTOPMODEL_H
 
23
 
 
24
#include <QModelIndex>
 
25
/**
 
26
* @file
 
27
* This file defines the class DesktopModel, the model for desktops.
 
28
*
 
29
* @author Martin Gräßlin <kde@martin-graesslin.com>
 
30
* @since 4.4
 
31
*/
 
32
 
 
33
namespace KWin
 
34
{
 
35
namespace TabBox
 
36
{
 
37
class ClientModel;
 
38
 
 
39
/**
 
40
* The model for desktops used in TabBox.
 
41
*
 
42
* @author Martin Gräßlin <kde@martin-graesslin.com>
 
43
* @since 4.4
 
44
*/
 
45
class DesktopModel
 
46
    : public QAbstractItemModel
 
47
{
 
48
public:
 
49
    enum {
 
50
        DesktopRole = Qt::UserRole, ///< Desktop number
 
51
        DesktopNameRole = Qt::UserRole + 1, ///< Desktop name
 
52
        ClientModelRole = Qt::UserRole + 2 ///< Clients on this desktop
 
53
    };
 
54
    DesktopModel(QObject* parent = 0);
 
55
    ~DesktopModel();
 
56
 
 
57
    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
 
58
    virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
 
59
    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
 
60
    virtual QModelIndex parent(const QModelIndex& child) const;
 
61
    virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
 
62
 
 
63
    /**
 
64
    * Generates a new list of desktops based on the current config.
 
65
    * Calling this method will reset the model.
 
66
    */
 
67
    void createDesktopList();
 
68
    /**
 
69
    * @return The current list of desktops.
 
70
    */
 
71
    QList< int > desktopList() const {
 
72
        return m_desktopList;
 
73
    }
 
74
    /**
 
75
    * @param desktop The desktop whose ModelIndex should be retrieved
 
76
    * @return The ModelIndex of given desktop or an invalid ModelIndex if
 
77
    * the desktop is not in the model.
 
78
    */
 
79
    QModelIndex desktopIndex(int desktop) const;
 
80
 
 
81
private:
 
82
    QList< int > m_desktopList;
 
83
    QMap< int, ClientModel* > m_clientModels;
 
84
};
 
85
 
 
86
} // namespace Tabbox
 
87
} // namespace KWin
 
88
#endif // DESKTOPMODEL_H