mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 02:26:38 +00:00 
			
		
		
		
	added CellId role to RegionMap model
This commit is contained in:
		
							parent
							
								
									2f63eb7ca4
								
							
						
					
					
						commit
						decd4270d9
					
				
					 2 changed files with 15 additions and 5 deletions
				
			
		|  | @ -384,15 +384,22 @@ QVariant CSMWorld::RegionMap::data (const QModelIndex& index, int role) const | ||||||
|             return QString::fromUtf8 (Misc::StringUtils::lowerCase (cell->second.mRegion).c_str()); |             return QString::fromUtf8 (Misc::StringUtils::lowerCase (cell->second.mRegion).c_str()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (role==Role_CellId) | ||||||
|  |     { | ||||||
|  |         CellCoordinates cellIndex = getIndex (index); | ||||||
|  | 
 | ||||||
|  |         std::ostringstream stream; | ||||||
|  |         stream << "#" << cellIndex.getX() << " " << cellIndex.getY(); | ||||||
|  | 
 | ||||||
|  |         return QString::fromUtf8 (stream.str().c_str()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     return QVariant(); |     return QVariant(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Qt::ItemFlags CSMWorld::RegionMap::flags (const QModelIndex& index) const | Qt::ItemFlags CSMWorld::RegionMap::flags (const QModelIndex& index) const | ||||||
| { | { | ||||||
|     if (mMap.find (getIndex (index))!=mMap.end()) |  | ||||||
|     return Qt::ItemIsSelectable | Qt::ItemIsEnabled; |     return Qt::ItemIsSelectable | Qt::ItemIsEnabled; | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CSMWorld::RegionMap::regionsAboutToBeRemoved (const QModelIndex& parent, int start, int end) | void CSMWorld::RegionMap::regionsAboutToBeRemoved (const QModelIndex& parent, int start, int end) | ||||||
|  |  | ||||||
|  | @ -26,7 +26,8 @@ namespace CSMWorld | ||||||
| 
 | 
 | ||||||
|             enum Role |             enum Role | ||||||
|             { |             { | ||||||
|                 Role_Region = Qt::UserRole |                 Role_Region = Qt::UserRole, | ||||||
|  |                 Role_CellId = Qt::UserRole+1 | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|         private: |         private: | ||||||
|  | @ -93,6 +94,8 @@ namespace CSMWorld | ||||||
|             virtual int columnCount (const QModelIndex& parent = QModelIndex()) const; |             virtual int columnCount (const QModelIndex& parent = QModelIndex()) const; | ||||||
| 
 | 
 | ||||||
|             virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const; |             virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const; | ||||||
|  |             ///< \note Calling this function with role==Role_CellId may return the ID of a cell
 | ||||||
|  |             /// that does not exist.
 | ||||||
| 
 | 
 | ||||||
|             virtual Qt::ItemFlags flags (const QModelIndex& index) const; |             virtual Qt::ItemFlags flags (const QModelIndex& index) const; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue