mirror of
				https://github.com/arsenetar/dupeguru.git
				synced 2025-09-11 17:58:17 +00:00 
			
		
		
		
	[#165 state:fixed] Don't collapse tree nodes on changing folder states. [Qt]
This commit is contained in:
		
							parent
							
								
									99e3c34060
								
							
						
					
					
						commit
						2ba3584b7e
					
				| @ -173,6 +173,11 @@ class PyDirectoryOutline(PyOutline): | ||||
|     def addDirectory_(self, path): | ||||
|         self.py.add_directory(path) | ||||
|      | ||||
|     # python --> cocoa | ||||
|     def refresh_states(self): | ||||
|         # Under cocoa, both refresh() and refresh_states() do the same thing. | ||||
|         self.cocoa.refresh() | ||||
|      | ||||
| 
 | ||||
| class PyResultTable(PyTable): | ||||
|     py_class = ResultTable | ||||
|  | ||||
| @ -34,6 +34,11 @@ class DirectoryNode(Node): | ||||
|             self.append(DirectoryNode(self._tree, path, path[-1])) | ||||
|         self._loaded = True | ||||
|      | ||||
|     def update_all_states(self): | ||||
|         self._state = STATE_ORDER.index(self._tree.app.directories.get_state(self._directory_path)) | ||||
|         for node in self: | ||||
|             node.update_all_states() | ||||
|      | ||||
|     # The state propery is an index to the combobox | ||||
|     @property | ||||
|     def state(self): | ||||
| @ -46,11 +51,14 @@ class DirectoryNode(Node): | ||||
|         self._state = value | ||||
|         state = STATE_ORDER[value] | ||||
|         self._tree.app.directories.set_state(self._directory_path, state) | ||||
|         self._tree._refresh() | ||||
|         self._tree.view.refresh() | ||||
|         self._tree.update_all_states() | ||||
|      | ||||
| 
 | ||||
| class DirectoryTree(GUIObject, Tree): | ||||
|     #--- model -> view calls: | ||||
|     # refresh() | ||||
|     # refresh_states() # when only states label need to be refreshed | ||||
|     # | ||||
|     def __init__(self, view, app): | ||||
|         GUIObject.__init__(self, view, app) | ||||
|         Tree.__init__(self) | ||||
| @ -68,6 +76,11 @@ class DirectoryTree(GUIObject, Tree): | ||||
|     def add_directory(self, path): | ||||
|         self.app.add_directory(path) | ||||
|      | ||||
|     def update_all_states(self): | ||||
|         for node in self: | ||||
|             node.update_all_states() | ||||
|         self.view.refresh_states() | ||||
|      | ||||
|     #--- Event Handlers | ||||
|     def directories_changed(self): | ||||
|         self._refresh() | ||||
|  | ||||
| @ -8,7 +8,7 @@ | ||||
| 
 | ||||
| import urllib.parse | ||||
| 
 | ||||
| from PyQt4.QtCore import pyqtSignal, Qt, QRect, QUrl | ||||
| from PyQt4.QtCore import pyqtSignal, Qt, QRect, QUrl, QModelIndex | ||||
| from PyQt4.QtGui import (QComboBox, QStyledItemDelegate, QApplication, QBrush, QStyle, | ||||
|     QStyleOptionComboBox, QStyleOptionViewItemV4) | ||||
| 
 | ||||
| @ -69,7 +69,7 @@ class DirectoriesModel(TreeModel): | ||||
|     def _getChildren(self): | ||||
|         return list(self.model) | ||||
|      | ||||
|     def columnCount(self, parent): | ||||
|     def columnCount(self, parent=QModelIndex()): | ||||
|         return 2 | ||||
|      | ||||
|     def data(self, index, role): | ||||
| @ -100,7 +100,7 @@ class DirectoriesModel(TreeModel): | ||||
|         data = bytes(mimeData.data('text/uri-list')).decode('ascii') | ||||
|         unquoted = urllib.parse.unquote(data) | ||||
|         urls = unquoted.split('\r\n') | ||||
|         paths = [str(QUrl(url).toLocalFile()) for url in urls if url] | ||||
|         paths = [QUrl(url).toLocalFile() for url in urls if url] | ||||
|         for path in paths: | ||||
|             self.model.add_directory(path) | ||||
|         self.foldersAdded.emit(paths) | ||||
| @ -143,3 +143,6 @@ class DirectoriesModel(TreeModel): | ||||
|     def refresh(self): | ||||
|         self.reset() | ||||
|      | ||||
|     def refresh_states(self): | ||||
|         self.refreshData() | ||||
|      | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user