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