-
Notifications
You must be signed in to change notification settings - Fork 0
/
channelmodel.cpp
33 lines (30 loc) · 1.02 KB
/
channelmodel.cpp
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
#include "channelmodel.h"
ChannelModel::ChannelModel(QObject *parent, QSqlDatabase db) : QSqlTableModel(parent,db) {}
bool ChannelModel::select() {
bool status = QSqlTableModel::select();
if (!status) {
return status;
}
while (canFetchMore()) {
fetchMore();
}
return status;
}
QVariant ChannelModel::data(const QModelIndex &idx, int role) const {
if (!idx.isValid()) { return QVariant(); }
if (idx.column()==2) {
if (role==Qt::DecorationRole) {
QString path=settings.value("cache").toString()+"/channels/";
if (QFile::exists(path+data(idx.siblingAtColumn(0)).toString()+".xcf")) {
return QImage(path+data(idx.siblingAtColumn(0)).toString()+".xcf");
} else {
//return QImage(":/gfx/rss-feed.png");
return QVariant();
}
}
if (role==Qt::ToolTipRole) {
return data(idx.siblingAtColumn(4));
}
} //title column
return QSqlTableModel::data(idx,role);
}