First pass fixes from discussions. Mostly linter fixes

This commit is contained in:
AdenKoperczak 2025-01-11 10:32:21 -05:00
parent 91b4d6c2c2
commit dc284974b3
14 changed files with 107 additions and 74 deletions

View file

@ -17,11 +17,7 @@
#include <QPushButton>
#include <QFileDialog>
namespace scwx
{
namespace qt
{
namespace ui
namespace scwx::qt::ui
{
static const std::string logPrefix_ = "scwx::qt::ui::edit_marker_dialog";
@ -71,9 +67,10 @@ EditMarkerDialog::EditMarkerDialog(QWidget* parent) :
for (auto& markerIcon : p->markerManager_->get_icons())
{
ui->iconComboBox->addItem(markerIcon.second.qIcon,
QString(""),
QString::fromStdString(markerIcon.second.name));
ui->iconComboBox->addItem(
markerIcon.second.qIcon,
QString::fromStdString(markerIcon.second.shortName),
QString::fromStdString(markerIcon.second.name));
}
p->deleteButton_ =
ui->buttonBox->addButton("Delete", QDialogButtonBox::DestructiveRole);
@ -154,7 +151,8 @@ types::MarkerInfo EditMarkerDialog::get_marker_info() const
void EditMarkerDialog::Impl::show_color_dialog()
{
// WA_DeleteOnClose manages memory
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
auto* dialog = new QColorDialog(self_);
dialog->setAttribute(Qt::WA_DeleteOnClose);
@ -184,7 +182,7 @@ void EditMarkerDialog::Impl::show_icon_file_dialog()
auto* dialog = new QFileDialog(self_);
dialog->setFileMode(QFileDialog::ExistingFile);
dialog->setNameFilters({"Icon (*.png *.svg)", "All (*)"});
dialog->setNameFilters({"Icon (*.png *.svg)", "All Files (*)"});
dialog->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(dialog,
@ -256,6 +254,11 @@ void EditMarkerDialog::Impl::connect_signals()
}
}
});
connect(self_->ui->buttonBox->button(QDialogButtonBox::Apply),
&QAbstractButton::clicked,
self_,
[this]() { handle_accepted(); });
}
void EditMarkerDialog::Impl::set_icon_color(const std::string& color)
@ -276,7 +279,9 @@ void EditMarkerDialog::Impl::set_icon_color(const std::string& color)
if (i < 0)
{
iconComboBox->addItem(
icon, QString(""), QString::fromStdString(markerIcon.second.name));
icon,
QString::fromStdString(markerIcon.second.shortName),
QString::fromStdString(markerIcon.second.name));
}
else
{
@ -306,6 +311,4 @@ void EditMarkerDialog::Impl::handle_rejected()
}
}
} // namespace ui
} // namespace qt
} // namespace scwx
} // namespace scwx::qt::ui

View file

@ -8,11 +8,7 @@ namespace Ui
class EditMarkerDialog;
}
namespace scwx
{
namespace qt
{
namespace ui
namespace scwx::qt::ui
{
class EditMarkerDialog : public QDialog
{
@ -35,6 +31,4 @@ private:
Ui::EditMarkerDialog* ui;
};
} // namespace ui
} // namespace qt
} // namespace scwx
} // namespace scwx::qt::ui

View file

@ -101,7 +101,7 @@
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>

View file

@ -23,15 +23,21 @@ class MarkerSettingsWidgetImpl
{
public:
explicit MarkerSettingsWidgetImpl(MarkerSettingsWidget* self) :
self_ {self},
markerModel_ {new model::MarkerModel(self_)}
self_ {self},
markerModel_ {new model::MarkerModel(self_)},
proxyModel_ {new QSortFilterProxyModel(self_)}
{
proxyModel_->setSourceModel(markerModel_);
proxyModel_->setSortRole(Qt::DisplayRole); // TODO types::SortRole
proxyModel_->setFilterCaseSensitivity(Qt::CaseInsensitive);
proxyModel_->setFilterKeyColumn(-1);
}
void ConnectSignals();
MarkerSettingsWidget* self_;
model::MarkerModel* markerModel_;
MarkerSettingsWidget* self_;
model::MarkerModel* markerModel_;
QSortFilterProxyModel* proxyModel_;
std::shared_ptr<manager::MarkerManager> markerManager_ {
manager::MarkerManager::Instance()};
std::shared_ptr<ui::EditMarkerDialog> editMarkerDialog_ {nullptr};
@ -46,7 +52,7 @@ MarkerSettingsWidget::MarkerSettingsWidget(QWidget* parent) :
ui->setupUi(this);
ui->removeButton->setEnabled(false);
ui->markerView->setModel(p->markerModel_);
ui->markerView->setModel(p->proxyModel_);
p->editMarkerDialog_ = std::make_shared<ui::EditMarkerDialog>(this);