Flexible models

This commit is contained in:
Eelke Klein 2018-09-02 10:30:30 +00:00
parent 50cb21b6f9
commit 8b7bbec807
24 changed files with 333 additions and 51 deletions

View file

@ -5,13 +5,12 @@
#include "PgNamespace.h"
#include "PgNamespaceContainer.h"
#include "Pgsql_declare.h"
#include "CustomDataRole.h"
#include <QBrush>
TablesTableModel::TablesTableModel(QObject *parent)
: BaseTableModel(parent)
{
}
: QAbstractTableModel(parent)
{}
void TablesTableModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
{
@ -166,11 +165,11 @@ QVariant TablesTableModel::getData(const QModelIndex &index) const
v = getTablespaceDisplayString(*m_catalog, t.tablespace);
break;
case OptionsCol:
v = t.options;
//v = t.options;
break;
// case AclCol:
// v = t.acl;
// break;
// case AclCol:
// v = t.acl;
// break;
}
return v;
@ -195,19 +194,9 @@ QString TablesTableModel::formatTableName(const PgClass &cls) const
QVariant TablesTableModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::ForegroundRole) {
const auto &t = m_tables[index.row()];
auto ns = m_catalog->namespaces()->getByKey(t.relnamespace);
if (ns.isSystemCatalog()) {
switch (index.column()) {
case NameCol:
case NamespaceCol:
return QBrush(Qt::blue);
break;
}
}
}
return BaseTableModel::data(index, role);
if (role == Qt::DisplayRole)
return getData(index);
else if (role == CustomDataTypeRole)
return getType(index.column());
return QVariant();
}