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

« back to all changes in this revision

Viewing changes to kcontrol/desktoptheme/thememodel.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
 * ThemeModel
 
3
 * Copyright (C) 2002 Karol Szwed <gallium@kde.org>
 
4
 * Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org>
 
5
 * Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
 
6
 * Copyright (C) 2009 by Davide Bettio <davide.bettio@kdemail.net>
 
7
 
 
8
 * Portions Copyright (C) 2007 Paolo Capriotti <p.capriotti@gmail.com>
 
9
 * Portions Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
 
10
 * Portions Copyright (C) 2008 by Petri Damsten <damu@iki.fi>
 
11
 * Portions Copyright (C) 2000 TrollTech AS.
 
12
 *
 
13
 * This program is free software; you can redistribute it and/or
 
14
 * modify it under the terms of the GNU General Public
 
15
 * License version 2 as published by the Free Software Foundation.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
20
 * General Public License for more details.
 
21
 *
 
22
 * You should have received a copy of the GNU General Public License
 
23
 * along with this program; see the file COPYING.  If not, write to
 
24
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
25
 * Boston, MA 02110-1301, USA.
 
26
 */
 
27
 
 
28
#ifndef THEMEMODEL_H
 
29
#define THEMEMODEL_H
 
30
 
 
31
#include <QtGui/QAbstractItemView>
 
32
 
 
33
namespace Plasma
 
34
{
 
35
    class FrameSvg;
 
36
}
 
37
 
 
38
//Theme selector code by Andre Duffeck (modified to add package description)
 
39
class ThemeInfo
 
40
{
 
41
public:
 
42
    QString package;
 
43
    Plasma::FrameSvg *svg;
 
44
    QString description;
 
45
    QString author;
 
46
    QString version;
 
47
    QString themeRoot;
 
48
};
 
49
 
 
50
class ThemeModel : public QAbstractListModel
 
51
{
 
52
public:
 
53
    enum { PackageNameRole = Qt::UserRole,
 
54
           SvgRole = Qt::UserRole + 1,
 
55
           PackageDescriptionRole = Qt::UserRole + 2,
 
56
           PackageAuthorRole = Qt::UserRole + 3,
 
57
           PackageVersionRole = Qt::UserRole + 4
 
58
         };
 
59
 
 
60
    ThemeModel(QObject *parent = 0);
 
61
    virtual ~ThemeModel();
 
62
 
 
63
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
64
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
65
    QModelIndex indexOf(const QString &path) const;
 
66
    void reload();
 
67
    void clearThemeList();
 
68
private:
 
69
    QMap<QString, ThemeInfo> m_themes;
 
70
};
 
71
 
 
72
class ThemeDelegate : public QAbstractItemDelegate
 
73
{
 
74
public:
 
75
    ThemeDelegate(QObject * parent = 0);
 
76
 
 
77
    virtual void paint(QPainter *painter,
 
78
                       const QStyleOptionViewItem &option,
 
79
                       const QModelIndex &index) const;
 
80
    virtual QSize sizeHint(const QStyleOptionViewItem &option,
 
81
                           const QModelIndex &index) const;
 
82
private:
 
83
    static const int MARGIN = 10;
 
84
};
 
85
 
 
86
 
 
87
#endif