Messy commit. Testing suff and some improvements to how data is shown.

This commit is contained in:
eelke 2017-12-09 10:45:13 +01:00
parent bebb3391c3
commit 3a13b7ffb4
59 changed files with 2045 additions and 716 deletions

View file

@ -2,7 +2,7 @@
#include "PgAuthIdContainer.h"
RolesTableModel::RolesTableModel(QObject *parent)
: QAbstractTableModel(parent)
: BaseTableModel(parent)
{
}
@ -74,50 +74,80 @@ int RolesTableModel::columnCount(const QModelIndex &parent) const
return result;
}
QVariant RolesTableModel::data(const QModelIndex &index, int role) const
Oid RolesTableModel::getType(int column) const
{
QVariant v;
//if (!index.isValid())
if (m_roles) {
const PgAuthId &authid = m_roles->getByIdx(index.row());
if (role == Qt::DisplayRole) {
switch (index.column()) {
case NameCol:
v = authid.name;
break;
case SuperCol:
// todo lookup role name
v = authid.super;
break;
case InheritCol:
// todo lookup encoding name
v = authid.inherit;
break;
case CreateRoleCol:
v = authid.createRole;
break;
case CreateDBCol:
v = authid.createDB;
break;
case CanLoginCol:
v = authid.canlogin;
break;
case ReplicationCol:
v = authid.replication;
break;
case BypassRlsCol:
v = authid.bypassRls;
break;
case ConnlimitCol:
// todo lookup tablespace name
v = authid.connLimit;
break;
case ValidUntilCol:
v = authid.validUntil;
break;
}
}
using namespace Pgsql;
Oid oid;
switch (column) {
case NameCol:
oid = VARCHAROID;
break;
case ReplicationCol:
case BypassRlsCol:
case CanLoginCol:
case CreateDBCol:
case CreateRoleCol:
case InheritCol:
case SuperCol:
oid = BOOLOID;
break;
case ConnlimitCol:
oid = INT4OID;
break;
case ValidUntilCol:
oid = TIMESTAMPOID;
break;
default:
oid = InvalidOid;
}
return oid;
}
QVariant RolesTableModel::getData(const QModelIndex &index) const
{
QVariant v;
if (m_roles) {
const PgAuthId &authid = m_roles->getByIdx(index.row());
switch (index.column()) {
case NameCol:
v = authid.name;
break;
case SuperCol:
// todo lookup role name
v = authid.super;
break;
case InheritCol:
// todo lookup encoding name
v = authid.inherit;
break;
case CreateRoleCol:
v = authid.createRole;
break;
case CreateDBCol:
v = authid.createDB;
break;
case CanLoginCol:
v = authid.canlogin;
break;
case ReplicationCol:
v = authid.replication;
break;
case BypassRlsCol:
v = authid.bypassRls;
break;
case ConnlimitCol:
// todo lookup tablespace name
v = authid.connLimit;
break;
case ValidUntilCol:
v = authid.validUntil;
break;
}
}
return v;
}