This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
app/sources/sqlstoragemodel.cpp
2018-08-02 12:51:05 +02:00

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;
}