Initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#include "halls_model.h"
|
||||
|
||||
#include <QSqlError>
|
||||
|
||||
HallsModel::HallsModel(QObject *parent, const QSqlDatabase &database)
|
||||
: BaseSqlTableModel(parent, database) {}
|
||||
|
||||
void HallsModel::initialize() {
|
||||
|
||||
setTable("halls");
|
||||
|
||||
setEditStrategy(QSqlTableModel::OnFieldChange);
|
||||
|
||||
bool success = select();
|
||||
if (!success) {
|
||||
qWarning() << "Error:" << lastError().text();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant HallsModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const {
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
switch (section) {
|
||||
case HallsColumns::Id:
|
||||
return tr("ID");
|
||||
case HallsColumns::Name:
|
||||
return tr("Name");
|
||||
case HallsColumns::Capacity:
|
||||
return tr("Capacity");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QSqlTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
Reference in New Issue
Block a user