Server window database tab tweaks
- Encoding as string instead of id - Tablespace name instead of id - Database list sorting enabled - Database size
This commit is contained in:
parent
11459e1e12
commit
2724586f4e
5 changed files with 28 additions and 9 deletions
|
|
@ -52,6 +52,9 @@ QVariant DatabasesTableModel::headerData(int section, Qt::Orientation orientatio
|
||||||
case TablespaceCol:
|
case TablespaceCol:
|
||||||
v = tr("Tablespace");
|
v = tr("Tablespace");
|
||||||
break;
|
break;
|
||||||
|
case SizeCol:
|
||||||
|
v = tr("Size");
|
||||||
|
break;
|
||||||
case AclCol:
|
case AclCol:
|
||||||
v = tr("ACL");
|
v = tr("ACL");
|
||||||
break;
|
break;
|
||||||
|
|
@ -89,6 +92,9 @@ Oid DatabasesTableModel::getType(int column) const
|
||||||
case ConnLimitCol:
|
case ConnLimitCol:
|
||||||
oid = int4_oid;
|
oid = int4_oid;
|
||||||
break;
|
break;
|
||||||
|
case SizeCol:
|
||||||
|
oid = int8_oid;
|
||||||
|
break;
|
||||||
case AclCol:
|
case AclCol:
|
||||||
case CollateCol:
|
case CollateCol:
|
||||||
case CTypeCol:
|
case CTypeCol:
|
||||||
|
|
@ -119,7 +125,7 @@ QVariant DatabasesTableModel::getData(const QModelIndex &index) const
|
||||||
break;
|
break;
|
||||||
case EncodingCol:
|
case EncodingCol:
|
||||||
// todo lookup encoding name
|
// todo lookup encoding name
|
||||||
v = db.encoding;
|
v = db.encodingString;
|
||||||
break;
|
break;
|
||||||
case CollateCol:
|
case CollateCol:
|
||||||
v = db.collate;
|
v = db.collate;
|
||||||
|
|
@ -138,7 +144,10 @@ QVariant DatabasesTableModel::getData(const QModelIndex &index) const
|
||||||
break;
|
break;
|
||||||
case TablespaceCol:
|
case TablespaceCol:
|
||||||
// todo lookup tablespace name
|
// todo lookup tablespace name
|
||||||
v = db.tablespace;
|
v = getTablespaceDisplayString(*m_catalog, db.tablespace);
|
||||||
|
break;
|
||||||
|
case SizeCol:
|
||||||
|
v = db.sizeBytes;
|
||||||
break;
|
break;
|
||||||
case AclCol:
|
case AclCol:
|
||||||
v = db.aclString();
|
v = db.aclString();
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class DatabasesTableModel : public BaseTableModel
|
||||||
public:
|
public:
|
||||||
enum e_Columns : int { NameCol, DbaCol, EncodingCol, CollateCol,
|
enum e_Columns : int { NameCol, DbaCol, EncodingCol, CollateCol,
|
||||||
CTypeCol, IsTemplateCol, AllowConnCol, ConnLimitCol,
|
CTypeCol, IsTemplateCol, AllowConnCol, ConnLimitCol,
|
||||||
TablespaceCol, AclCol, COL_COUNT };
|
TablespaceCol, SizeCol, AclCol, COL_COUNT };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "DatabasesTableModel.h"
|
#include "DatabasesTableModel.h"
|
||||||
#include "RolesTableModel.h"
|
#include "RolesTableModel.h"
|
||||||
#include "catalog/PgDatabaseCatalog.h"
|
#include "catalog/PgDatabaseCatalog.h"
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ServerWindow::ServerWindow(MasterController *master, QWidget *parent)
|
ServerWindow::ServerWindow(MasterController *master, QWidget *parent)
|
||||||
|
|
@ -14,7 +15,12 @@ ServerWindow::ServerWindow(MasterController *master, QWidget *parent)
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
m_databasesModel = new DatabasesTableModel(this);
|
m_databasesModel = new DatabasesTableModel(this);
|
||||||
ui->databasesTableView->setModel(m_databasesModel);
|
|
||||||
|
auto databasesSortFilter = new QSortFilterProxyModel(this);
|
||||||
|
databasesSortFilter->setSourceModel(m_databasesModel);
|
||||||
|
|
||||||
|
ui->databasesTableView->setModel(databasesSortFilter);
|
||||||
|
ui->databasesTableView->setSortingEnabled(true);
|
||||||
|
|
||||||
m_rolesModel = new RolesTableModel(this);
|
m_rolesModel = new RolesTableModel(this);
|
||||||
ui->rolesTableView->setModel(m_rolesModel);
|
ui->rolesTableView->setModel(m_rolesModel);
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,14 @@ public:
|
||||||
|
|
||||||
Oid dba; // owner?
|
Oid dba; // owner?
|
||||||
int encoding;
|
int encoding;
|
||||||
|
QString encodingString;
|
||||||
QString collate;
|
QString collate;
|
||||||
QString ctype;
|
QString ctype;
|
||||||
bool isTemplate;
|
bool isTemplate;
|
||||||
bool allowConn;
|
bool allowConn;
|
||||||
int connLimit;
|
int connLimit;
|
||||||
Oid tablespace;
|
Oid tablespace;
|
||||||
|
int64_t sizeBytes;
|
||||||
|
|
||||||
using PgServerObject::PgServerObject;
|
using PgServerObject::PgServerObject;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@
|
||||||
|
|
||||||
std::string PgDatabaseContainer::getLoadQuery() const
|
std::string PgDatabaseContainer::getLoadQuery() const
|
||||||
{
|
{
|
||||||
return "SELECT oid,datname,datdba,encoding,datcollate,datctype,datistemplate,datallowconn,"
|
return "SELECT oid,datname,datdba,encoding,pg_encoding_to_char(encoding),datcollate \n"
|
||||||
"datconnlimit,dattablespace,datacl FROM pg_database";
|
",datctype,datistemplate,datallowconn,"
|
||||||
|
"datconnlimit,dattablespace,pg_database_size(oid),datacl "
|
||||||
|
"FROM pg_database";
|
||||||
}
|
}
|
||||||
|
|
||||||
PgDatabase PgDatabaseContainer::loadElem(const Pgsql::Row &row)
|
PgDatabase PgDatabaseContainer::loadElem(const Pgsql::Row &row)
|
||||||
|
|
@ -14,8 +16,8 @@ PgDatabase PgDatabaseContainer::loadElem(const Pgsql::Row &row)
|
||||||
Oid oid = col.nextValue();
|
Oid oid = col.nextValue();
|
||||||
QString name = col.nextValue();
|
QString name = col.nextValue();
|
||||||
PgDatabase v(m_catalog, oid, name);
|
PgDatabase v(m_catalog, oid, name);
|
||||||
col >> v.dba >> v.encoding >> v.collate >> v.ctype >> v.isTemplate
|
col >> v.dba >> v.encoding >> v.encodingString >> v.collate >> v.ctype >> v.isTemplate
|
||||||
>> v.allowConn >> v.connLimit >> v.tablespace;
|
>> v.allowConn >> v.connLimit >> v.tablespace >> v.sizeBytes;
|
||||||
|
|
||||||
AclList acl_list;
|
AclList acl_list;
|
||||||
col >> acl_list;
|
col >> acl_list;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue