[pyqgis-console] fixes #7653 and #7646

- more minor fixes
This commit is contained in:
Salvatore Larosa 2013-04-22 22:43:43 +02:00
parent 2e6178c897
commit e22f0d162f
3 changed files with 28 additions and 16 deletions

View File

@ -130,7 +130,7 @@ class PythonConsoleWidget(QWidget):
#self.splitterObj.addWidget(self.widgetEditor)
# Hide side editor on start up
self.widgetEditor.hide()
self.splitterObj.hide()
self.listClassMethod.hide()
sizes = self.splitter.sizes()
@ -474,7 +474,12 @@ class PythonConsoleWidget(QWidget):
def onClickGoToLine(self, item, column):
linenr = int(item.text(1))
objName = item.text(0)
itemName = str(item.text(0))
charPos = itemName.find(' ')
if charPos != -1:
objName = itemName[0:charPos]
else:
objName = itemName
self.tabEditorWidget.currentWidget().newEditor.goToLine(objName, linenr)
def sextante(self):
@ -487,7 +492,7 @@ class PythonConsoleWidget(QWidget):
self.shell.commandConsole('qtGui')
def toggleEditor(self, checked):
self.widgetEditor.show() if checked else self.widgetEditor.hide()
self.splitterObj.show() if checked else self.splitterObj.hide()
self.tabEditorWidget.enableToolBarEditor(checked)
def toggleObjectListWidget(self, checked):

View File

@ -477,7 +477,7 @@ class EditorTab(QWidget):
self.newEditor.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.newEditor.modificationChanged.connect(self.modified)
if filename:
self.newEditor.setText(open(unicode(filename), "rt").read())
self.newEditor.setText(open(unicode(filename), "r").read())
self.newEditor.setModified(False)
self.path = filename
@ -605,8 +605,11 @@ class EditorTabWidget(QTabWidget):
self.topFrame.show()
else:
self.newTabEditor(filename=None)
## Fixes #7653
if sys.platform != 'darwin':
self.setDocumentMode(True)
self.setDocumentMode(True)
self.setMovable(True)
#self.setTabsClosable(True)
self.setTabPosition(QTabWidget.South)
@ -723,12 +726,13 @@ class EditorTabWidget(QTabWidget):
def restoreTabs(self):
for script in self.restoreTabList:
pathFile = unicode(script.toString())
if os.path.exists(pathFile):
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
else:
self.newTabEditor(filename=None)
if script != '':
pathFile = unicode(script.toString())
if os.path.exists(pathFile):
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
else:
self.newTabEditor(filename=None)
self.topFrame.close()
self.enableToolBarEditor(True)
@ -788,7 +792,7 @@ class EditorTabWidget(QTabWidget):
dictObject[name] = class_data.lineno
for meth, lineno in sorted(class_data.methods.items(), key=itemgetter(1)):
methodItem = QTreeWidgetItem()
methodItem.setText(0, meth)
methodItem.setText(0, meth + ' ')
methodItem.setText(1, str(lineno))
methodItem.setToolTip(0, meth)
methodItem.setIcon(0, QgsApplication.getThemeIcon("console/iconMethodTreeWidgetConsole.png"))
@ -798,7 +802,7 @@ class EditorTabWidget(QTabWidget):
for func_name, data in sorted(readModuleFunction.items(), key=lambda x:x[1].lineno):
if isinstance(data, pyclbr.Function) and data.file == tabWidget.path:
funcItem = QTreeWidgetItem()
funcItem.setText(0, func_name)
funcItem.setText(0, func_name + ' ')
funcItem.setText(1, str(data.lineno))
funcItem.setToolTip(0, func_name)
funcItem.setIcon(0, QgsApplication.getThemeIcon("console/iconFunctionTreeWidgetConsole.png"))

View File

@ -416,16 +416,16 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter):
stringDrag = e.mimeData().text()
self.insertFromDropPaste(stringDrag)
self.setFocus()
e.setDropAction(Qt.MoveAction)
e.setDropAction(Qt.CopyAction)
e.accept()
else:
QsciScintillaCompat.dropEvent(self, e)
def insertFromDropPaste(self, textDP):
pasteList = textDP.split("\n")
pasteList = str(textDP).splitlines()
for line in pasteList[:-1]:
line.replace(">>> ", "").replace("... ", "")
self.insert(line)
self.insert(unicode(line))
self.move_cursor_to_end()
self.runCommand(unicode(self.currentCommand()))
if pasteList[-1] != "":
@ -493,6 +493,9 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter):
more = self.runsource(src, "<input>")
if not more:
self.buffer = []
## prevents to commands with more lines to break the console
## in the case they have a eol different from '\n'
self.setText('')
self.move_cursor_to_end()
self.displayPrompt(more)