forked from quickshell/quickshell
		
	core/scriptmodel: update model data after objectProp eq
Updates the values list and sends dataChanged if objectProp compared equal but the new value is actually different.
This commit is contained in:
		
							parent
							
								
									2e33ef5b7f
								
							
						
					
					
						commit
						8b5b12b722
					
				
					 1 changed files with 16 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -131,6 +131,22 @@ void ScriptModel::updateValuesUnique(const QVariantList& newValues) {
 | 
			
		|||
				iter = std::copy(startNewIter, newIter, iter);
 | 
			
		||||
				this->endInsertRows();
 | 
			
		||||
			}
 | 
			
		||||
		} else if (*newIter != *iter) {
 | 
			
		||||
			auto first = static_cast<qint32>(std::distance(this->mValues.begin(), iter));
 | 
			
		||||
			auto index = first;
 | 
			
		||||
 | 
			
		||||
			do {
 | 
			
		||||
				this->mValues.replace(index, *newIter);
 | 
			
		||||
				++iter;
 | 
			
		||||
				++newIter;
 | 
			
		||||
				++index;
 | 
			
		||||
			} while (iter != this->mValues.end() && newIter != newValues.end() && *newIter != *iter);
 | 
			
		||||
 | 
			
		||||
			this->dataChanged(
 | 
			
		||||
			    this->index(first, 0, QModelIndex()),
 | 
			
		||||
			    this->index(index - 1, 0, QModelIndex()),
 | 
			
		||||
			    {Qt::UserRole}
 | 
			
		||||
			);
 | 
			
		||||
		} else {
 | 
			
		||||
			++iter;
 | 
			
		||||
			++newIter;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue