Move MarkerManager to using an ID system for markers, instead of index

This commit is contained in:
AdenKoperczak 2024-11-03 14:16:56 -05:00
parent 236d7c1e35
commit 7a070b3e7f
8 changed files with 233 additions and 74 deletions

View file

@ -65,21 +65,25 @@ void MarkerSettingsWidgetImpl::ConnectSignals()
{
markerManager_->add_marker(types::MarkerInfo("", 0, 0));
});
QObject::connect(self_->ui->removeButton,
&QPushButton::clicked,
self_,
[this]()
{
auto selectionModel =
self_->ui->markerView->selectionModel();
QModelIndex selected =
selectionModel
->selectedRows(static_cast<int>(
model::MarkerModel::Column::Name))
.first();
QObject::connect(
self_->ui->removeButton,
&QPushButton::clicked,
self_,
[this]()
{
auto selectionModel = self_->ui->markerView->selectionModel();
QModelIndex selected = selectionModel
->selectedRows(static_cast<int>(
model::MarkerModel::Column::Name))
.first();
std::optional<types::MarkerId> id = markerModel_->getId(selected.row());
if (!id)
{
return;
}
markerManager_->remove_marker(selected.row());
});
markerManager_->remove_marker(*id);
});
QObject::connect(
self_->ui->markerView->selectionModel(),
&QItemSelectionModel::selectionChanged,