From: <tit...@us...> - 2007-06-29 04:11:16
|
Revision: 6017 http://svn.sourceforge.net/translate/?rev=6017&view=rev Author: titvirak Date: 2007-06-28 21:11:18 -0700 (Thu, 28 Jun 2007) Log Message: ----------- Fix save when close file. Modified Paths: -------------- src/trunk/pootling/modules/FileAction.py src/trunk/pootling/modules/MainEditor.py src/trunk/pootling/modules/Operator.py Modified: src/trunk/pootling/modules/FileAction.py =================================================================== --- src/trunk/pootling/modules/FileAction.py 2007-06-29 02:16:01 UTC (rev 6016) +++ src/trunk/pootling/modules/FileAction.py 2007-06-29 04:11:18 UTC (rev 6017) @@ -129,7 +129,6 @@ @param filename: file's name as QString """ self.filename = filename - self.emitFileOpened() # remember last open file's directory. self.directory = os.path.dirname(unicode(filename)) Modified: src/trunk/pootling/modules/MainEditor.py =================================================================== --- src/trunk/pootling/modules/MainEditor.py 2007-06-29 02:16:01 UTC (rev 6016) +++ src/trunk/pootling/modules/MainEditor.py 2007-06-29 04:11:18 UTC (rev 6017) @@ -285,7 +285,6 @@ # set file status information to text label of status bar. self.connect(self.operator, QtCore.SIGNAL("currentStatus"), self.statuslabel.setText) self.connect(self.fileaction, QtCore.SIGNAL("fileOpened"), self.openFile) - self.connect(self.operator, QtCore.SIGNAL("fileIsOK"), self.setOpening) # progress bar self.progressBar = QtGui.QProgressBar() @@ -402,20 +401,12 @@ World.settings.setValue("recentFileList", QtCore.QVariant(files)) self.updateRecentAction() - def setOpening(self, fileName): - """ - Set status after open a file. - @param fileName string, the filename to open - """ - self.setStatusForFile(fileName) - self.prependOpenRecent(fileName) - self.clearBookmarks() - def startRecentAction(self): action = self.sender() if action: # TODO: remove filename from recent file if it doesn't exist. - self.fileaction.setFileName(action.data().toString()) + filename = unicode(action.data().toString()) + self.openFile(filename) def clearRecentAction(self): self.ui.menuOpen_Recent.clear() @@ -586,9 +577,17 @@ self.ui.statusbar.addWidget(self.statusfuzzy) def openFile(self, filename): + """ + Open filename and prepend it in recent list. + @param filename: file to open. + """ closed = self.closeFile() if (closed): - self.operator.getUnits(filename) + if (self.operator.getUnits(filename)): + self.fileaction.setFileName(filename) + self.setStatusForFile(filename) + self.prependOpenRecent(filename) + self.clearBookmarks() self.show() def closeFile(self, force = False): @@ -683,7 +682,7 @@ if (inputFile): if os.path.exists(inputFile): - editor.fileaction.setFileName(inputFile) + self.openFile(inputFile) else: msg = editor.tr("%1 file name doesn't exist").arg(inputFile) QtGui.QMessageBox.warning(editor, editor.tr("File not found") , msg) Modified: src/trunk/pootling/modules/Operator.py =================================================================== --- src/trunk/pootling/modules/Operator.py 2007-06-29 02:16:01 UTC (rev 6016) +++ src/trunk/pootling/modules/Operator.py 2007-06-29 04:11:18 UTC (rev 6017) @@ -63,18 +63,19 @@ """ Read a file into the internal datastructure. @param fileName: the file to open, either a string or a file object. + @return True of False indicates success open of file. """ if (not os.path.exists(fileName)): QtGui.QMessageBox.critical(None, 'Error', fileName + '\n' + 'The file doesn\'t exist.') - return + return False try: store = factory.getobject(fileName) except Exception, e: QtGui.QMessageBox.critical(None, 'Error', 'Error while trying to read file ' + fileName + '\n' + str(e)) - return + return False self.setNewStore(store) - self.emit(QtCore.SIGNAL("fileIsOK"), fileName) self.fileName = fileName + return True def setNewStore(self, store): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |