From a4054ed7890e459c9d7f6cf598acc661883d5532 Mon Sep 17 00:00:00 2001 From: eelke Date: Sun, 26 Aug 2018 15:18:32 +0200 Subject: [PATCH] Introduced global enum to keep track of custom roles we want to use in our datamodels. --- pglab/CustomDataRole.h | 10 ++++++++++ pglab/IndexModel.cpp | 3 ++- pglab/TablesPage.cpp | 1 + pglab/pglab.pro | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 pglab/CustomDataRole.h diff --git a/pglab/CustomDataRole.h b/pglab/CustomDataRole.h new file mode 100644 index 0000000..dccd92e --- /dev/null +++ b/pglab/CustomDataRole.h @@ -0,0 +1,10 @@ +#ifndef CUSTOMDATAROLE_H +#define CUSTOMDATAROLE_H + +#include + +enum CustomDataRole { + CustomDataTypeRole = Qt::UserRole, +}; + +#endif // CUSTOMDATAROLE_H diff --git a/pglab/IndexModel.cpp b/pglab/IndexModel.cpp index 93adc16..4e41fa3 100644 --- a/pglab/IndexModel.cpp +++ b/pglab/IndexModel.cpp @@ -3,6 +3,7 @@ #include "PgIndexContainer.h" #include "Pgsql_oids.h" #include "ScopeGuard.h" +#include "CustomDataRole.h" void IndexModel::setData(std::shared_ptr cat, const PgClass &table) { @@ -96,7 +97,7 @@ QVariant IndexModel::data(const QModelIndex &index, int role) const QVariant v; if (role == Qt::DisplayRole) v = getData(index); - else if (role == Qt::UserRole) + else if (role == CustomDataTypeRole) v = getType(index.column()); return v; } diff --git a/pglab/TablesPage.cpp b/pglab/TablesPage.cpp index 9031612..fd0703a 100644 --- a/pglab/TablesPage.cpp +++ b/pglab/TablesPage.cpp @@ -55,6 +55,7 @@ TablesPage::TablesPage(MainWindow *parent) PropertyProxyModel* property_model = new PropertyProxyModel(this); property_model->setSourceModel(m_tablesModel); + SetTableViewDefault(ui->tablePropertiesTable); ui->tablePropertiesTable->setModel(property_model); connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentChanged, diff --git a/pglab/pglab.pro b/pglab/pglab.pro index c2d13f3..aac271b 100644 --- a/pglab/pglab.pro +++ b/pglab/pglab.pro @@ -121,7 +121,8 @@ HEADERS += \ CodeEditor.h \ PlgPage.h \ AbstractCommand.h \ - PropertyProxyModel.h + PropertyProxyModel.h \ + CustomDataRole.h FORMS += mainwindow.ui \ ConnectionManagerWindow.ui \