-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitemsmodel.cpp
More file actions
27 lines (24 loc) · 789 Bytes
/
itemsmodel.cpp
File metadata and controls
27 lines (24 loc) · 789 Bytes
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
#include "itemsmodel.h"
ItemsModel::ItemsModel(QObject *parent, QSqlDatabase db) : QSqlTableModel(parent,db) {}
bool ItemsModel::select() {
bool status = QSqlTableModel::select();
if (!status) {
return status;
}
while (canFetchMore()) {
fetchMore();
}
return status;
}
QVariant ItemsModel::data(const QModelIndex &idx, int role) const {
if (!idx.isValid()) { return QVariant(); }
if ((idx.column()==4)&&(role==Qt::DisplayRole)) {
QTextDocument doc;
doc.setHtml(QSqlTableModel::data(idx,role).toString());
return doc.toPlainText().simplified();
}
if (role==Qt::FontRole) {
return QSqlTableModel::data(idx.siblingAtColumn(14),Qt::DisplayRole).toBool();
}
return QSqlTableModel::data(idx,role);
}