43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
/*
|
|
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/>.
|
|
*/
|
|
|
|
#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;
|
|
}
|