Skip to content
Permalink
Browse files

[pyqgis-console] fixes #7653 and #7646

- more minor fixes
  • Loading branch information
slarosa committed Apr 23, 2013
1 parent 2e6178c commit e22f0d162fdcced81b089611377ece8112ce6dd4
Showing with 28 additions and 16 deletions.
  1. +8 −3 python/console/console.py
  2. +14 −10 python/console/console_editor.py
  3. +6 −3 python/console/console_sci.py
@@ -130,7 +130,7 @@ def __init__(self, parent=None):
#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 @@ def __init__(self, parent=None):

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 @@ def qtGui(self):
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):
@@ -477,7 +477,7 @@ def __init__(self, parent, parentConsole, filename, *args):
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 @@ def __init__(self, parent):
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 @@ def closeCurrentWidget(self):

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 @@ def listObject(self, tab):
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 @@ def listObject(self, tab):
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"))
@@ -416,16 +416,16 @@ def dropEvent(self, e):
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 @@ def runCommand(self, cmd):
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)

0 comments on commit e22f0d1

Please sign in to comment.
You can’t perform that action at this time.