PgAttribute loading + ColummnTableModel
Required enchancement to PgContainer to make multifield key work.
This commit is contained in:
parent
f9caadb59e
commit
e9d72d391d
32 changed files with 698 additions and 99 deletions
|
|
@ -2,7 +2,10 @@
|
|||
#include "PgDatabaseCatalog.h"
|
||||
#include "PgClass.h"
|
||||
#include "PgClassContainer.h"
|
||||
#include "PgNamespace.h"
|
||||
#include "PgNamespaceContainer.h"
|
||||
#include "Pgsql_declare.h"
|
||||
#include <QBrush>
|
||||
|
||||
TablesTableModel::TablesTableModel(QObject *parent)
|
||||
: BaseTableModel(parent)
|
||||
|
|
@ -44,6 +47,9 @@ QVariant TablesTableModel::headerData(int section, Qt::Orientation orientation,
|
|||
case NameCol:
|
||||
v = tr("Name");
|
||||
break;
|
||||
case NamespaceCol:
|
||||
v = tr("Schema");
|
||||
break;
|
||||
case OwnerCol:
|
||||
v = tr("Owner");
|
||||
break;
|
||||
|
|
@ -80,6 +86,7 @@ Oid TablesTableModel::getType(int column) const
|
|||
case TablespaceCol:
|
||||
case OwnerCol:
|
||||
case NameCol:
|
||||
case NamespaceCol:
|
||||
case OptionsCol:
|
||||
case AclCol:
|
||||
default:
|
||||
|
|
@ -94,7 +101,10 @@ QVariant TablesTableModel::getData(const QModelIndex &index) const
|
|||
const auto &t = m_tables[index.row()];
|
||||
switch (index.column()) {
|
||||
case NameCol:
|
||||
v = formatTableName(t);
|
||||
v = t.name; //formatTableName(t);
|
||||
break;
|
||||
case NamespaceCol:
|
||||
v = getNamespaceDisplayString(*m_catalog, t.relnamespace);
|
||||
break;
|
||||
case OwnerCol:
|
||||
v = getRoleDisplayString(*m_catalog, t.owner);
|
||||
|
|
@ -113,9 +123,33 @@ QVariant TablesTableModel::getData(const QModelIndex &index) const
|
|||
return v;
|
||||
}
|
||||
|
||||
Oid TablesTableModel::getTableOid(int row) const
|
||||
{
|
||||
return m_tables[row].oid;
|
||||
}
|
||||
|
||||
QString TablesTableModel::formatTableName(const PgClass &cls) const
|
||||
{
|
||||
const char * format = "%2 (%1)";
|
||||
QString ns_name = getNamespaceDisplayString(*m_catalog, cls.relnamespace);
|
||||
return QString(format).arg(ns_name).arg(cls.name);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue