UI/FindFileNameDialog.py

changeset 2754
2b3a46d8905b
parent 2701
7904fd3bc30d
child 2791
a9577f248f04
child 3012
d177226027e2
child 3163
9f50365a0870
equal deleted inserted replaced
2752:5d556f9040e3 2754:2b3a46d8905b
54 self.buttonBox.addButton(self.trUtf8("Stop"), QDialogButtonBox.ActionRole) 54 self.buttonBox.addButton(self.trUtf8("Stop"), QDialogButtonBox.ActionRole)
55 self.stopButton.setToolTip(self.trUtf8("Press to stop the search")) 55 self.stopButton.setToolTip(self.trUtf8("Press to stop the search"))
56 self.stopButton.setEnabled(False) 56 self.stopButton.setEnabled(False)
57 self.buttonBox.button(QDialogButtonBox.Open).setToolTip( 57 self.buttonBox.button(QDialogButtonBox.Open).setToolTip(
58 self.trUtf8("Opens the selected file")) 58 self.trUtf8("Opens the selected file"))
59 self.buttonBox.button(QDialogButtonBox.Open).setEnabled(False)
59 60
60 self.project = project 61 self.project = project
61 self.extsepLabel.setText(os.extsep) 62 self.extsepLabel.setText(os.extsep)
62 63
63 self.shouldStop = False 64 self.shouldStop = False
71 if button == self.stopButton: 72 if button == self.stopButton:
72 self.shouldStop = True 73 self.shouldStop = True
73 elif button == self.buttonBox.button(QDialogButtonBox.Open): 74 elif button == self.buttonBox.button(QDialogButtonBox.Open):
74 self.__openFile() 75 self.__openFile()
75 76
76 def __openFile(self): 77 def __openFile(self, itm=None):
77 """ 78 """
78 Private slot to open a file. 79 Private slot to open a file.
79 80
80 It emits the signal 81 It emits the signal sourceFile or designerFile depending on the
81 sourceFile or designerFile depending on the file extension. 82 file extension.
82 """ 83
83 itm = self.fileList.currentItem() 84 @param itm item to be opened (QTreeWidgetItem)
84 fileName = itm.text(0) 85 """
85 filePath = itm.text(1) 86 if itm is None:
86 87 itm = self.fileList.currentItem()
87 if fileName.endswith('.ui'): 88 if itm is not None:
88 self.designerFile.emit(os.path.join(filePath, fileName)) 89 fileName = itm.text(0)
89 else: 90 filePath = itm.text(1)
90 self.sourceFile.emit(os.path.join(filePath, fileName)) 91
92 if fileName.endswith('.ui'):
93 self.designerFile.emit(os.path.join(filePath, fileName))
94 else:
95 self.sourceFile.emit(os.path.join(filePath, fileName))
91 96
92 def __searchFile(self): 97 def __searchFile(self):
93 """ 98 """
94 Private slot to handle the search. 99 Private slot to handle the search.
95 """ 100 """
138 locations[fn] = [fp] 143 locations[fn] = [fp]
139 QTreeWidgetItem(self.fileList, [fn, fp]) 144 QTreeWidgetItem(self.fileList, [fn, fp])
140 QApplication.processEvents() 145 QApplication.processEvents()
141 146
142 del locations 147 del locations
143 self.buttonBox.button(QDialogButtonBox.Open).setEnabled(found)
144 self.stopButton.setEnabled(False) 148 self.stopButton.setEnabled(False)
145 self.fileList.header().resizeSections(QHeaderView.ResizeToContents) 149 self.fileList.header().resizeSections(QHeaderView.ResizeToContents)
146 self.fileList.header().setStretchLastSection(True) 150 self.fileList.header().setStretchLastSection(True)
151
152 if found:
153 self.fileList.setCurrentItem(self.fileList.topLevelItem(0))
147 154
148 def checkStop(self): 155 def checkStop(self):
149 """ 156 """
150 Public method to check, if the search should be stopped. 157 Public method to check, if the search should be stopped.
151 158
222 229
223 def on_fileList_itemActivated(self, itm, column): 230 def on_fileList_itemActivated(self, itm, column):
224 """ 231 """
225 Private slot to handle the double click on a file item. 232 Private slot to handle the double click on a file item.
226 233
227 It emits the signal 234 It emits the signal sourceFile or designerFile depending on the
228 sourceFile or designerFile depending on the file extension. 235 file extension.
229 236
230 @param itm the double clicked listview item (QTreeWidgetItem) 237 @param itm the double clicked listview item (QTreeWidgetItem)
231 @param column column that was double clicked (integer) (ignored) 238 @param column column that was double clicked (integer) (ignored)
232 """ 239 """
233 self.__openFile() 240 self.__openFile(itm)
241
242 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
243 def on_fileList_currentItemChanged(self, current, previous):
244 """
245 Private slot handling a change of the current item.
246
247 @param current current item (QTreeWidgetItem)
248 @param previous prevoius current item (QTreeWidgetItem)
249 """
250 self.buttonBox.button(QDialogButtonBox.Open).setEnabled(current is not None)
234 251
235 def show(self): 252 def show(self):
236 """ 253 """
237 Overwritten method to enable/disable the project checkbox. 254 Overwritten method to enable/disable the project checkbox.
238 """ 255 """

eric ide

mercurial