-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcustommodel.cpp
More file actions
40 lines (31 loc) · 1.1 KB
/
Copy pathcustommodel.cpp
File metadata and controls
40 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "custommodel.h"
#include <QIcon>
CustomModel::CustomModel(QObject *parent)
: QStringListModel(parent)
{
}
//QVariant CustomModel::headerData(int section, Qt::Orientation orientation, int role) const
//{
// // FIXME: Implement me!
//}
//int CustomModel::rowCount(const QModelIndex &parent) const
//{
// // For list models only the root node (an invalid parent) should return the list's size. For all
// // other (valid) parents, rowCount() should return 0 so that it does not become a tree model.
// if (parent.isValid())
// return 0;
// // FIXME: Implement me!
//}
QVariant CustomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
static QStringList list= {":/new/prefix1/image/categories-new-white (1).png", ":/new/prefix1/image/categories-new-white (2).png", ":/new/prefix1/image/categories-new-white3.png"};
if (role == Qt::DecorationRole){
QIcon icon(list[index.row()]);
assert(!icon.isNull());
return icon;
}
// FIXME: Implement me!
return QStringListModel::data(index, role);
}