From 23840ce7c5157db573f411be0becb06a235bf1d2 Mon Sep 17 00:00:00 2001 From: eelke Date: Tue, 19 Dec 2017 19:55:12 +0100 Subject: [PATCH] Cosmetic improvements. --- pglab/ColumnTableModel.cpp | 45 ++++++++++++++++++++++++++++++++++++-- pglab/MainWindow.cpp | 7 ++---- pglab/TablesPage.cpp | 1 + 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/pglab/ColumnTableModel.cpp b/pglab/ColumnTableModel.cpp index 20bcfe1..92e8aa6 100644 --- a/pglab/ColumnTableModel.cpp +++ b/pglab/ColumnTableModel.cpp @@ -63,7 +63,7 @@ QVariant ColumnTableModel::headerData(int section, Qt::Orientation orientation, c = tr("Type"); break; case NullCol: - c = tr("Not null"); + c = tr("N"); break; case DefaultCol: c = tr("Default"); @@ -75,6 +75,38 @@ QVariant ColumnTableModel::headerData(int section, Qt::Orientation orientation, } v = c; } + else if (role == Qt::ToolTipRole) { + if (section >= colCount) { + const auto &tbl_idx = m_indexes[section - colCount]; + if (tbl_idx.isprimary) + v = tr("Primary key"); + else if (tbl_idx.isunique) + v = tr("Unique index"); + else + v = tr("Index"); + } + else { + switch (section) { +// case NameCol: +// c = tr("Name"); +// break; +// case TypeCol: +// c = tr("Type"); +// break; + case NullCol: + v = tr("N = Column is nullable"); + break; + case DefaultCol: + v = tr("Default value for the columns"); + break; +// case CollationCol: +// c = tr("Collation"); +// break; + } + } + + + } } return v; @@ -136,7 +168,7 @@ QVariant ColumnTableModel::getData(const QModelIndex &index) const s = getTypeDisplayString(*m_catalog, t.typid, t.typmod); break; case NullCol: - s = QString::fromStdU16String(t.notnull ? u"\u2713" : u""); + s = QString::fromStdU16String(t.notnull ? u"" : u"N"); break; case DefaultCol: s = t.defaultValue; @@ -186,5 +218,14 @@ QVariant ColumnTableModel::data(const QModelIndex &index, int role) const } return v; } + if (role == Qt::TextAlignmentRole) { + QVariant v; + int col = index.column(); + if (col == NullCol || col >= colCount) + v = Qt::AlignCenter + Qt::AlignVCenter; + else + v = Qt::AlignLeft + Qt::AlignVCenter; + return v; + } return BaseTableModel::data(index, role); } diff --git a/pglab/MainWindow.cpp b/pglab/MainWindow.cpp index 00cae59..47eb17c 100644 --- a/pglab/MainWindow.cpp +++ b/pglab/MainWindow.cpp @@ -145,14 +145,11 @@ void MainWindow::on_actionAbout_triggered() " INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS " "FOR A PARTICULAR PURPOSE.\n" "\n" - "This program is dynamically linked with Qt 5.8 Copyright (C) 2016 " + "This program is dynamically linked with Qt 5.9 Copyright (C) 2017 " "The Qt Company Ltd. https://www.qt.io/licensing/. \n" "\n" "Icons by fatcow http://www.fatcow.com/free-icons provided under Creative Commons " - "attribution 3.0 license\n" - "\n" - "More icons by https://icons8.com/ under Creative Commons Attribution-NoDerivs 3.0 Unported " - "license." + "attribution 3.0 license." )); } diff --git a/pglab/TablesPage.cpp b/pglab/TablesPage.cpp index f869d8a..0f24a2f 100644 --- a/pglab/TablesPage.cpp +++ b/pglab/TablesPage.cpp @@ -34,6 +34,7 @@ void TablesPage::setCatalog(std::shared_ptr cat) { m_catalog = cat; m_tablesModel->setCatalog(cat); + ui->tableListTable->resizeColumnsToContents(); } void TablesPage::on_tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)