Axivion: Mark current selected issue kind

Change-Id: I2bb49a5fed6f71f3a0e2dfc1207a6d6f592e59c2
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Christian Stenger
2024-01-31 14:18:53 +01:00
parent d7bae47f8a
commit 41103666c5

View File

@@ -20,6 +20,7 @@
#include <utils/basetreeview.h> #include <utils/basetreeview.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <QButtonGroup>
#include <QComboBox> #include <QComboBox>
#include <QFormLayout> #include <QFormLayout>
#include <QGridLayout> #include <QGridLayout>
@@ -233,6 +234,7 @@ private:
QString m_currentProject; QString m_currentProject;
std::optional<Dto::TableInfoDto> m_currentTableInfo; std::optional<Dto::TableInfoDto> m_currentTableInfo;
QHBoxLayout *m_typesLayout = nullptr; QHBoxLayout *m_typesLayout = nullptr;
QButtonGroup *m_typesButtonGroup = nullptr;
QHBoxLayout *m_filtersLayout = nullptr; QHBoxLayout *m_filtersLayout = nullptr;
QPushButton *m_addedFilter = nullptr; QPushButton *m_addedFilter = nullptr;
QPushButton *m_removedFilter = nullptr; QPushButton *m_removedFilter = nullptr;
@@ -260,6 +262,8 @@ IssuesWidget::IssuesWidget(QWidget *parent)
// table, columns depend on chosen issue type // table, columns depend on chosen issue type
QHBoxLayout *top = new QHBoxLayout; QHBoxLayout *top = new QHBoxLayout;
layout->addLayout(top); layout->addLayout(top);
m_typesButtonGroup = new QButtonGroup(this);
m_typesButtonGroup->setExclusive(true);
m_typesLayout = new QHBoxLayout; m_typesLayout = new QHBoxLayout;
top->addLayout(m_typesLayout); top->addLayout(m_typesLayout);
top->addStretch(1); top->addStretch(1);
@@ -458,8 +462,11 @@ void IssuesWidget::onSearchParameterChanged()
void IssuesWidget::updateBasicProjectInfo(std::optional<Dto::ProjectInfoDto> info) void IssuesWidget::updateBasicProjectInfo(std::optional<Dto::ProjectInfoDto> info)
{ {
auto cleanOld = [this] { auto cleanOld = [this] {
const QList<QAbstractButton *> originalList = m_typesButtonGroup->buttons();
QLayoutItem *child; QLayoutItem *child;
while ((child = m_typesLayout->takeAt(0)) != nullptr) { while ((child = m_typesLayout->takeAt(0)) != nullptr) {
if (originalList.contains(child->widget()))
m_typesButtonGroup->removeButton(qobject_cast<QAbstractButton *>(child->widget()));
delete child->widget(); delete child->widget();
delete child; delete child;
} }
@@ -488,16 +495,21 @@ void IssuesWidget::updateBasicProjectInfo(std::optional<Dto::ProjectInfoDto> inf
cleanOld(); cleanOld();
const std::vector<Dto::IssueKindInfoDto> &issueKinds = info->issueKinds; const std::vector<Dto::IssueKindInfoDto> &issueKinds = info->issueKinds;
int buttonId = 0;
for (const Dto::IssueKindInfoDto &kind : issueKinds) { for (const Dto::IssueKindInfoDto &kind : issueKinds) {
auto button = new QToolButton(this); auto button = new QToolButton(this);
button->setIcon(iconForIssue(kind.prefix)); button->setIcon(iconForIssue(kind.prefix));
button->setToolTip(kind.nicePluralName); button->setToolTip(kind.nicePluralName);
button->setCheckable(true);
connect(button, &QToolButton::clicked, this, [this, prefix = kind.prefix]{ connect(button, &QToolButton::clicked, this, [this, prefix = kind.prefix]{
m_currentPrefix = prefix; m_currentPrefix = prefix;
updateTableView(); updateTableView();
}); });
m_typesButtonGroup->addButton(button, ++buttonId);
m_typesLayout->addWidget(button); m_typesLayout->addWidget(button);
} }
if (auto firstButton = m_typesButtonGroup->button(1))
firstButton->setChecked(true);
m_ownerFilter->clear(); m_ownerFilter->clear();
for (const Dto::UserRefDto &user : info->users) for (const Dto::UserRefDto &user : info->users)