26 lines
645 B
C++
26 lines
645 B
C++
#include "headers/sqlstoragemodel.h"
|
|
|
|
SqlStorageModel::SqlStorageModel(QObject *parent) : QSqlTableModel(parent)
|
|
{
|
|
qDebug("ProfileModel constructor");
|
|
setTable("times");
|
|
select();
|
|
}
|
|
|
|
QVariant SqlStorageModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if (role < Qt::UserRole)
|
|
return QSqlTableModel::data(index, role);
|
|
|
|
const QSqlRecord sqlRecord = record(index.row());
|
|
return sqlRecord.value(role - Qt::UserRole);
|
|
}
|
|
|
|
QHash<int, QByteArray> SqlStorageModel::roleNames() const
|
|
{
|
|
QHash<int, QByteArray> names;
|
|
names[Qt::UserRole + 0] = "id";
|
|
names[Qt::UserRole + 1] = "name";
|
|
|
|
return names;
|
|
}
|