diff -r 5d556f9040e3 -r 2b3a46d8905b UI/FindFileNameDialog.py --- a/UI/FindFileNameDialog.py Fri Jun 28 19:49:58 2013 +0200 +++ b/UI/FindFileNameDialog.py Sat Jun 29 12:48:13 2013 +0200 @@ -56,6 +56,7 @@ self.stopButton.setEnabled(False) self.buttonBox.button(QDialogButtonBox.Open).setToolTip( self.trUtf8("Opens the selected file")) + self.buttonBox.button(QDialogButtonBox.Open).setEnabled(False) self.project = project self.extsepLabel.setText(os.extsep) @@ -73,21 +74,25 @@ elif button == self.buttonBox.button(QDialogButtonBox.Open): self.__openFile() - def __openFile(self): + def __openFile(self, itm=None): """ Private slot to open a file. - It emits the signal - sourceFile or designerFile depending on the file extension. + It emits the signal sourceFile or designerFile depending on the + file extension. + + @param itm item to be opened (QTreeWidgetItem) """ - itm = self.fileList.currentItem() - fileName = itm.text(0) - filePath = itm.text(1) - - if fileName.endswith('.ui'): - self.designerFile.emit(os.path.join(filePath, fileName)) - else: - self.sourceFile.emit(os.path.join(filePath, fileName)) + if itm is None: + itm = self.fileList.currentItem() + if itm is not None: + fileName = itm.text(0) + filePath = itm.text(1) + + if fileName.endswith('.ui'): + self.designerFile.emit(os.path.join(filePath, fileName)) + else: + self.sourceFile.emit(os.path.join(filePath, fileName)) def __searchFile(self): """ @@ -140,10 +145,12 @@ QApplication.processEvents() del locations - self.buttonBox.button(QDialogButtonBox.Open).setEnabled(found) self.stopButton.setEnabled(False) self.fileList.header().resizeSections(QHeaderView.ResizeToContents) self.fileList.header().setStretchLastSection(True) + + if found: + self.fileList.setCurrentItem(self.fileList.topLevelItem(0)) def checkStop(self): """ @@ -224,13 +231,23 @@ """ Private slot to handle the double click on a file item. - It emits the signal - sourceFile or designerFile depending on the file extension. + It emits the signal sourceFile or designerFile depending on the + file extension. @param itm the double clicked listview item (QTreeWidgetItem) @param column column that was double clicked (integer) (ignored) """ - self.__openFile() + self.__openFile(itm) + + @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) + def on_fileList_currentItemChanged(self, current, previous): + """ + Private slot handling a change of the current item. + + @param current current item (QTreeWidgetItem) + @param previous prevoius current item (QTreeWidgetItem) + """ + self.buttonBox.button(QDialogButtonBox.Open).setEnabled(current is not None) def show(self): """