From f21a59e0304f575426c01babbf07d9162e04ea2a Mon Sep 17 00:00:00 2001 From: eelke Date: Thu, 11 Mar 2021 06:59:31 +0100 Subject: [PATCH] Display comments in the list of databases --- pglab/DatabasesTableModel.cpp | 7 +++++++ pglab/DatabasesTableModel.h | 2 +- pglablib/catalog/PgDatabase.h | 1 + pglablib/catalog/PgDatabaseContainer.cpp | 12 +++++++----- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pglab/DatabasesTableModel.cpp b/pglab/DatabasesTableModel.cpp index 30bbe23..dc48ae4 100644 --- a/pglab/DatabasesTableModel.cpp +++ b/pglab/DatabasesTableModel.cpp @@ -52,6 +52,9 @@ QVariant DatabasesTableModel::headerData(int section, Qt::Orientation orientatio case TablespaceCol: v = tr("Tablespace"); break; + case CommentCol: + v = tr("Comment"); + break; case SizeCol: v = tr("Size"); break; @@ -102,6 +105,7 @@ Oid DatabasesTableModel::getType(int column) const case DbaCol: case NameCol: case TablespaceCol: + case CommentCol: oid = varchar_oid; break; default: @@ -146,6 +150,9 @@ QVariant DatabasesTableModel::getData(const QModelIndex &index) const // todo lookup tablespace name v = getTablespaceDisplayString(*m_catalog, db.tablespace); break; + case CommentCol: + v = db.description; + break; case SizeCol: v = db.sizeBytes; break; diff --git a/pglab/DatabasesTableModel.h b/pglab/DatabasesTableModel.h index b953048..5f44c66 100644 --- a/pglab/DatabasesTableModel.h +++ b/pglab/DatabasesTableModel.h @@ -17,7 +17,7 @@ class DatabasesTableModel : public BaseTableModel public: enum e_Columns : int { NameCol, DbaCol, EncodingCol, CollateCol, CTypeCol, IsTemplateCol, AllowConnCol, ConnLimitCol, - TablespaceCol, SizeCol, AclCol, COL_COUNT }; + TablespaceCol, CommentCol, SizeCol, AclCol, COL_COUNT }; diff --git a/pglablib/catalog/PgDatabase.h b/pglablib/catalog/PgDatabase.h index 81f4d24..5be23ae 100644 --- a/pglablib/catalog/PgDatabase.h +++ b/pglablib/catalog/PgDatabase.h @@ -18,6 +18,7 @@ public: int connLimit; Oid tablespace; int64_t sizeBytes; + QString description; using PgServerObject::PgServerObject; diff --git a/pglablib/catalog/PgDatabaseContainer.cpp b/pglablib/catalog/PgDatabaseContainer.cpp index b577d45..d3ddaa0 100644 --- a/pglablib/catalog/PgDatabaseContainer.cpp +++ b/pglablib/catalog/PgDatabaseContainer.cpp @@ -3,10 +3,12 @@ std::string PgDatabaseContainer::getLoadQuery() const { - return "SELECT oid,datname,datdba,encoding,pg_encoding_to_char(encoding),datcollate \n" - ",datctype,datistemplate,datallowconn," - "datconnlimit,dattablespace,pg_database_size(oid),datacl " - "FROM pg_database"; + return + "SELECT oid, datname, datdba, encoding, pg_encoding_to_char(encoding), datcollate,\n" + " datctype, datistemplate, datallowconn, datconnlimit, dattablespace, pg_database_size(oid),\n" + " d.description, datacl\n" + "FROM pg_database\n" + " LEFT JOIN pg_catalog.pg_shdescription AS d ON (objoid=pg_database.oid)"; } PgDatabase PgDatabaseContainer::loadElem(const Pgsql::Row &row) @@ -17,7 +19,7 @@ PgDatabase PgDatabaseContainer::loadElem(const Pgsql::Row &row) QString name = col.nextValue(); PgDatabase v(m_catalog, oid, name); col >> v.dba >> v.encoding >> v.encodingString >> v.collate >> v.ctype >> v.isTemplate - >> v.allowConn >> v.connLimit >> v.tablespace >> v.sizeBytes; + >> v.allowConn >> v.connLimit >> v.tablespace >> v.sizeBytes >> v.description; AclList acl_list; col >> acl_list;