2
* Copyright © 2005-2007 Fredrik Höglund <fredrik@kde.org>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public
6
* License version 2 as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; see the file COPYING. If not, write to
15
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
* Boston, MA 02110-1301, USA.
22
#include <QAbstractTableModel>
23
#include <QStringList>
28
// The two TableView/TreeView columns provided by the model
29
enum Columns { NameColumn = 0, DescColumn };
33
* The CursorThemeModel class provides a model for all locally installed
34
* Xcursor themes, and the KDE/Qt legacy bitmap theme.
36
* This class automatically scans the locations in the file system from
37
* which Xcursor loads cursors, and creates an internal list of all
38
* available cursor themes.
40
* The model provides this theme list to item views in the form of a list
41
* of rows with two columns; the first column has the theme's descriptive
42
* name and its sample cursor as its icon, and the second column contains
43
* the theme's description.
45
* Additional Xcursor themes can be added to a model after it's been
46
* created, by calling addTheme(), which takes QDir as a parameter,
47
* with the themes location. The intention is for this function to be
48
* called when a new Xcursor theme has been installed, after the model
51
* The KDE legacy theme is a read-only entry, with the descriptive name
52
* "KDE Classic", and the internal name "#kde_legacy#".
54
* Calling defaultIndex() will return the index of the theme Xcursor
55
* will use if the user hasn't explicitly configured a cursor theme.
57
class CursorThemeModel : public QAbstractTableModel
62
CursorThemeModel(QObject *parent = 0);
63
inline int columnCount(const QModelIndex &parent = QModelIndex()) const;
64
inline int rowCount(const QModelIndex &parent = QModelIndex()) const;
65
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
66
QVariant data(const QModelIndex &index, int role) const;
67
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
69
/// Returns the CursorTheme at @p index.
70
const CursorTheme *theme(const QModelIndex &index);
72
/// Returns the index for the CursorTheme with the internal name @p name,
73
/// or an invalid index if no matching theme can be found.
74
QModelIndex findIndex(const QString &name);
76
/// Returns the index for the default theme.
77
QModelIndex defaultIndex();
79
/// Adds the theme in @p dir, and returns @a true if successful or @a false otherwise.
80
bool addTheme(const QDir &dir);
81
void removeTheme(const QModelIndex &index);
83
/// Returns the list of base dirs Xcursor looks for themes in.
84
const QStringList searchPaths();
87
bool handleDefault(const QDir &dir);
88
void processThemeDir(const QDir &dir);
90
bool hasTheme(const QString &theme) const;
91
bool isCursorTheme(const QString &theme, const int depth = 0);
94
QList<CursorTheme*> list;
99
int CursorThemeModel::rowCount(const QModelIndex &) const
104
int CursorThemeModel::columnCount(const QModelIndex &) const
109
#endif // THEMEMODEL_H