mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 08:40:06 +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(); |       return QVariant(); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    if (role == Qt::ItemDataRole::UserRole) | ||||||
|  |    { | ||||||
|  |       return qulonglong(id); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|    switch(index.column()) |    switch(index.column()) | ||||||
|    { |    { | ||||||
|    case static_cast<int>(Column::Name): |    case static_cast<int>(Column::Name): | ||||||
|  |  | ||||||
|  | @ -85,13 +85,14 @@ void MarkerSettingsWidgetImpl::ConnectSignals() | ||||||
|                                    ->selectedRows(static_cast<int>( |                                    ->selectedRows(static_cast<int>( | ||||||
|                                       model::MarkerModel::Column::Name)) |                                       model::MarkerModel::Column::Name)) | ||||||
|                                    .first(); |                                    .first(); | ||||||
|          std::optional<types::MarkerId> id = markerModel_->getId(selected.row()); | 
 | ||||||
|          if (!id) |          QVariant id = proxyModel_->data(selected, Qt::ItemDataRole::UserRole); | ||||||
|  |          if (!id.isValid()) | ||||||
|          { |          { | ||||||
|             return; |             return; | ||||||
|          } |          } | ||||||
| 
 | 
 | ||||||
|          markerManager_->remove_marker(*id); |          markerManager_->remove_marker(id.toULongLong()); | ||||||
|       }); |       }); | ||||||
|    QObject::connect( |    QObject::connect( | ||||||
|       self_->ui->markerView->selectionModel(), |       self_->ui->markerView->selectionModel(), | ||||||
|  | @ -116,20 +117,14 @@ void MarkerSettingsWidgetImpl::ConnectSignals() | ||||||
|                     self_, |                     self_, | ||||||
|                     [this](const QModelIndex& index) |                     [this](const QModelIndex& index) | ||||||
|                     { |                     { | ||||||
|                        const int row = index.row(); |                        QVariant id = | ||||||
|                        if (row < 0) |                           proxyModel_->data(index, Qt::ItemDataRole::UserRole); | ||||||
|  |                        if (!id.isValid()) | ||||||
|                        { |                        { | ||||||
|                           return; |                           return; | ||||||
|                        } |                        } | ||||||
| 
 | 
 | ||||||
|                        std::optional<types::MarkerId> id = |                        editMarkerDialog_->setup(id.toULongLong()); | ||||||
|                           markerModel_->getId(row); |  | ||||||
|                        if (!id) |  | ||||||
|                        { |  | ||||||
|                           return; |  | ||||||
|                        } |  | ||||||
| 
 |  | ||||||
|                        editMarkerDialog_->setup(*id); |  | ||||||
|                        editMarkerDialog_->show(); |                        editMarkerDialog_->show(); | ||||||
|                     }); |                     }); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak