Switched TablesTableModel to rely on the PgLabDelegate for formatting instead of the old model base class.

This commit is contained in:
eelke 2018-08-27 21:12:27 +02:00
parent a4054ed789
commit 7630723b69
3 changed files with 23 additions and 32 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();
}