mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 15:00:04 +00:00
Use data role to get marker id for location marker dialog.
This commit is contained in:
parent
b2e4215ea8
commit
9c16a88b63
2 changed files with 13 additions and 13 deletions
|
|
@ -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<int>(Column::Name):
|
||||
|
|
|
|||
|
|
@ -85,13 +85,14 @@ void MarkerSettingsWidgetImpl::ConnectSignals()
|
|||
->selectedRows(static_cast<int>(
|
||||
model::MarkerModel::Column::Name))
|
||||
.first();
|
||||
std::optional<types::MarkerId> 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<types::MarkerId> id =
|
||||
markerModel_->getId(row);
|
||||
if (!id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
editMarkerDialog_->setup(*id);
|
||||
editMarkerDialog_->setup(id.toULongLong());
|
||||
editMarkerDialog_->show();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue