~ubuntu-branches/ubuntu/trusty/hedgewars/trusty-proposed

« back to all changes in this revision

Viewing changes to QTfrontend/model/themesmodel.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-11-20 18:31:17 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20111120183117-pjhz1n2pvnmxa246
Tags: 0.9.17-1
* [Paul Wise]
 * Mention the homing bee in the package description (Closes: #577092)
 * Also install the hwengine desktop file (LP: #811770)
 * Depend on ttf-dejavu-core since it is smaller
 * Depend on ttf-wqy-zenhei instead of embedding a copy of it
* [Dmitry E. Oboukhov]
 * New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "themesmodel.h"
 
3
 
 
4
ThemesModel::ThemesModel(QStringList themes, QObject *parent) :
 
5
    QAbstractListModel(parent)
 
6
{
 
7
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
 
8
    m_data.reserve(themes.size());
 
9
#endif
 
10
 
 
11
    foreach(QString theme, themes)
 
12
    {
 
13
        m_data.append(QHash<int, QVariant>());
 
14
        m_data.last().insert(Qt::DisplayRole, theme);
 
15
    }
 
16
}
 
17
 
 
18
int ThemesModel::rowCount(const QModelIndex &parent) const
 
19
{
 
20
    if(parent.isValid())
 
21
        return 0;
 
22
    else
 
23
        return m_data.size();
 
24
}
 
25
 
 
26
QVariant ThemesModel::data(const QModelIndex &index, int role) const
 
27
{
 
28
    if(index.column() > 0 || index.row() >= m_data.size())
 
29
        return QVariant();
 
30
    else
 
31
        return m_data.at(index.row()).value(role);
 
32
}
 
33
 
 
34
bool ThemesModel::setData(const QModelIndex &index, const QVariant &value, int role)
 
35
{
 
36
    if(index.column() > 0 || index.row() >= m_data.size())
 
37
        return false;
 
38
    else
 
39
    {
 
40
        m_data[index.row()].insert(role, value);
 
41
 
 
42
        return true;
 
43
    }
 
44
 
 
45
}
 
46
 
 
47
 
 
48
 
 
49