From 9c16a88b639c1638f7dfb6ddfd413d7b943599cc Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Fri, 4 Apr 2025 19:46:05 -0400 Subject: [PATCH] Use data role to get marker id for location marker dialog. --- scwx-qt/source/scwx/qt/model/marker_model.cpp | 5 +++++ .../scwx/qt/ui/marker_settings_widget.cpp | 21 +++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scwx-qt/source/scwx/qt/model/marker_model.cpp b/scwx-qt/source/scwx/qt/model/marker_model.cpp index 77fb7ab7..6c232177 100644 --- a/scwx-qt/source/scwx/qt/model/marker_model.cpp +++ b/scwx-qt/source/scwx/qt/model/marker_model.cpp @@ -100,6 +100,11 @@ QVariant MarkerModel::data(const QModelIndex& index, int role) const return QVariant(); } + if (role == Qt::ItemDataRole::UserRole) + { + return qulonglong(id); + } + switch(index.column()) { case static_cast(Column::Name): diff --git a/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp b/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp index b3ba8440..f3e81098 100644 --- a/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp +++ b/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp @@ -85,13 +85,14 @@ void MarkerSettingsWidgetImpl::ConnectSignals() ->selectedRows(static_cast( model::MarkerModel::Column::Name)) .first(); - std::optional id = markerModel_->getId(selected.row()); - if (!id) + + QVariant id = proxyModel_->data(selected, Qt::ItemDataRole::UserRole); + if (!id.isValid()) { return; } - markerManager_->remove_marker(*id); + markerManager_->remove_marker(id.toULongLong()); }); QObject::connect( self_->ui->markerView->selectionModel(), @@ -116,20 +117,14 @@ void MarkerSettingsWidgetImpl::ConnectSignals() self_, [this](const QModelIndex& index) { - const int row = index.row(); - if (row < 0) + QVariant id = + proxyModel_->data(index, Qt::ItemDataRole::UserRole); + if (!id.isValid()) { return; } - std::optional id = - markerModel_->getId(row); - if (!id) - { - return; - } - - editMarkerDialog_->setup(*id); + editMarkerDialog_->setup(id.toULongLong()); editMarkerDialog_->show(); }); }