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