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

44 lines
1.4 KiB
C++
Raw Normal View History

2018-08-12 20:51:57 +02:00
/*
Speed Climbing Stopwatch - Simple Stopwatch for Climbers
Copyright (C) 2018 Itsblue Development - Dorian Zeder
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2018-07-28 23:05:26 +02:00
#include "headers/sqlstoragemodel.h"
2018-07-22 16:47:55 +02:00
2018-08-02 12:50:55 +02:00
SqlStorageModel::SqlStorageModel(QObject *parent) : QSqlTableModel(parent)
2018-07-22 16:47:55 +02:00
{
2018-08-02 12:50:55 +02:00
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";
2018-07-22 16:47:55 +02:00
2018-08-02 12:50:55 +02:00
return names;
2018-07-22 16:47:55 +02:00
}