From f7a00c58d2824f49ecaafc0152fc0b8213772e46 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 13 Dec 2024 16:22:33 +0100 Subject: refactor: using qt containers instead of std containers --- src/ui/widgets/KeyTable.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui/widgets/KeyTable.cpp') diff --git a/src/ui/widgets/KeyTable.cpp b/src/ui/widgets/KeyTable.cpp index bda294a4..9d3511cd 100644 --- a/src/ui/widgets/KeyTable.cpp +++ b/src/ui/widgets/KeyTable.cpp @@ -34,10 +34,10 @@ namespace GpgFrontend::UI { -auto KeyTable::GetChecked() const -> KeyIdArgsListPtr { - auto ret = std::make_unique(); +auto KeyTable::GetChecked() const -> KeyIdArgsList { + auto ret = KeyIdArgsList{}; for (decltype(GetRowCount()) i = 0; i < GetRowCount(); i++) { - if (IsRowChecked(i)) ret->push_back(GetKeyIdByRow(i)); + if (IsRowChecked(i)) ret.push_back(GetKeyIdByRow(i)); } return ret; } -- cgit v1.2.3 From ee3491860f86c65e6af1bc3549e6228c053e34f3 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 20 Dec 2024 20:44:31 +0100 Subject: fix: adjust the width of key list cell correctly --- src/ui/widgets/KeyTable.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ui/widgets/KeyTable.cpp') diff --git a/src/ui/widgets/KeyTable.cpp b/src/ui/widgets/KeyTable.cpp index bda294a4..6fe2d966 100644 --- a/src/ui/widgets/KeyTable.cpp +++ b/src/ui/widgets/KeyTable.cpp @@ -54,7 +54,7 @@ KeyTable::KeyTable(QWidget* parent, QSharedPointer model, verticalHeader()->hide(); horizontalHeader()->setStretchLastSection(false); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + horizontalHeader()->setResizeContentsPrecision(1000); setShowGrid(false); sortByColumn(2, Qt::AscendingOrder); @@ -68,6 +68,10 @@ KeyTable::KeyTable(QWidget* parent, QSharedPointer model, setAlternatingRowColors(true); setSortingEnabled(true); + for (int i = 1; i < proxy_model_.columnCount(); ++i) { + this->resizeColumnToContents(i); + } + connect(CommonUtils::GetInstance(), &CommonUtils::SignalFavoritesChanged, &proxy_model_, &GpgKeyTableProxyModel::SignalFavoritesChanged); connect(this, &KeyTable::SignalColumnTypeChange, this, @@ -146,4 +150,5 @@ void KeyTable::UncheckAll() { return selected_indexes.first().row(); } + } // namespace GpgFrontend::UI \ No newline at end of file -- cgit v1.2.3 From 78d76b454769e0dcbaaeb7bbe30ec9d315b7388c Mon Sep 17 00:00:00 2001 From: saturneric Date: Sat, 21 Dec 2024 03:36:30 +0100 Subject: fix: ResizeToContents behaviors of key list --- src/ui/widgets/KeyTable.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/ui/widgets/KeyTable.cpp') diff --git a/src/ui/widgets/KeyTable.cpp b/src/ui/widgets/KeyTable.cpp index 6fe2d966..542382cf 100644 --- a/src/ui/widgets/KeyTable.cpp +++ b/src/ui/widgets/KeyTable.cpp @@ -54,8 +54,7 @@ KeyTable::KeyTable(QWidget* parent, QSharedPointer model, verticalHeader()->hide(); horizontalHeader()->setStretchLastSection(false); - horizontalHeader()->setResizeContentsPrecision(1000); - + horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); setShowGrid(false); sortByColumn(2, Qt::AscendingOrder); setSelectionBehavior(QAbstractItemView::SelectRows); @@ -68,10 +67,6 @@ KeyTable::KeyTable(QWidget* parent, QSharedPointer model, setAlternatingRowColors(true); setSortingEnabled(true); - for (int i = 1; i < proxy_model_.columnCount(); ++i) { - this->resizeColumnToContents(i); - } - connect(CommonUtils::GetInstance(), &CommonUtils::SignalFavoritesChanged, &proxy_model_, &GpgKeyTableProxyModel::SignalFavoritesChanged); connect(this, &KeyTable::SignalColumnTypeChange, this, -- cgit v1.2.3 From 8ddcf78c103037ccd1e4b5f3115164583d410aef Mon Sep 17 00:00:00 2001 From: saturneric Date: Sat, 21 Dec 2024 04:12:07 +0100 Subject: fix: avoid check action triggering the show of key detail dialog --- src/ui/widgets/KeyTable.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ui/widgets/KeyTable.cpp') diff --git a/src/ui/widgets/KeyTable.cpp b/src/ui/widgets/KeyTable.cpp index 542382cf..a1f5db07 100644 --- a/src/ui/widgets/KeyTable.cpp +++ b/src/ui/widgets/KeyTable.cpp @@ -76,6 +76,8 @@ KeyTable::KeyTable(QWidget* parent, QSharedPointer model, }); connect(this, &QTableView::doubleClicked, this, [this](const QModelIndex& index) { + if (!index.isValid() || index.column() == 0) return; + auto key = GpgKeyGetter::GetInstance(model_->GetGpgContextChannel()) .GetKey(GetKeyIdByRow(index.row())); if (!key.IsGood()) { -- cgit v1.2.3