Restructured locations of source.
This commit is contained in:
parent
78a4c6d730
commit
7c4e8e95e8
151 changed files with 1 additions and 0 deletions
123
src/pglab/RolesTableModel.cpp
Normal file
123
src/pglab/RolesTableModel.cpp
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#include "RolesTableModel.h"
|
||||
#include "PgAuthIdContainer.h"
|
||||
|
||||
RolesTableModel::RolesTableModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void RolesTableModel::setRoleList(const PgAuthIdContainer* roles)
|
||||
{
|
||||
beginResetModel();
|
||||
m_roles = roles;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QVariant RolesTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
QVariant v;
|
||||
if (orientation == Qt::Horizontal) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case NameCol:
|
||||
v = tr("Name");
|
||||
break;
|
||||
case SuperCol:
|
||||
v = tr("Super");
|
||||
break;
|
||||
case InheritCol:
|
||||
v = tr("Inherit");
|
||||
break;
|
||||
case CreateRoleCol:
|
||||
v = tr("Create role");
|
||||
break;
|
||||
case CreateDBCol:
|
||||
v = tr("Create DB");
|
||||
break;
|
||||
case CanLoginCol:
|
||||
v = tr("Can login");
|
||||
break;
|
||||
case ReplicationCol:
|
||||
v = tr("Replication");
|
||||
break;
|
||||
case BypassRlsCol:
|
||||
v = tr("Bypass RLS");
|
||||
break;
|
||||
case ConnlimitCol:
|
||||
v = tr("Connection limit");
|
||||
break;
|
||||
case ValidUntilCol:
|
||||
v = tr("Valid until");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
int RolesTableModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
int result = 0;
|
||||
if (m_roles) {
|
||||
result = m_roles->count();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int RolesTableModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
int result = 10;
|
||||
// if (parent.isValid())
|
||||
// return 10;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant RolesTableModel::data(const QModelIndex &index, int role) 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue