mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Simplify model handling and crashes fixes
So, there's only one crash left (that I put a big TODO: on the maintab.cpp about) and I'll fix it tomorrow as it's quite late here and I'm almost sleeping at the keyboard. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									ee9746c622
								
							
						
					
					
						commit
						6cd85d9b73
					
				
					 6 changed files with 41 additions and 13 deletions
				
			
		|  | @ -39,16 +39,10 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons | |||
| 
 | ||||
| void LocationInformationModel::update() | ||||
| { | ||||
| 	if (rowCount()) { | ||||
| 		beginRemoveRows(QModelIndex(), 0, rowCount()-1); | ||||
| 		endRemoveRows(); | ||||
| 	} | ||||
| 	if (dive_site_table.nr) { | ||||
| 		beginInsertRows(QModelIndex(), 0, dive_site_table.nr); | ||||
| 		internalRowCount = dive_site_table.nr; | ||||
| 		std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than); | ||||
| 		endInsertRows(); | ||||
| 	} | ||||
| 	beginResetModel(); | ||||
| 	internalRowCount = dive_site_table.nr; | ||||
| 	std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than); | ||||
| 	endResetModel(); | ||||
| } | ||||
| 
 | ||||
| int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int lat) | ||||
|  | @ -76,3 +70,14 @@ bool LocationInformationModel::setData(const QModelIndex &index, const QVariant | |||
| 	emit dataChanged(index, index); | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| bool LocationInformationModel::removeRows(int row, int count, const QModelIndex & parent) { | ||||
| 	if(row >= rowCount()) | ||||
| 		return false; | ||||
| 
 | ||||
| 	beginRemoveRows(QModelIndex(), row, row); | ||||
| 	struct dive_site *ds = get_dive_site(row); | ||||
| 	delete_dive_site(ds->uuid); | ||||
| 	endRemoveRows(); | ||||
| 	return true; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue