Skip to content
Permalink
Browse files

[pyqgis-console] allow to disable the object inspector from settings …

…(default it is disabled)

- fixes some translation string
  • Loading branch information
slarosa committed May 15, 2013
1 parent aa0c754 commit 256684134ccd24d275e14462b67fa16133b8cc82
@@ -122,7 +122,8 @@ def __init__(self, parent=None):

self.listClassMethod = QTreeWidget(self.splitterObj)
self.listClassMethod.setColumnCount(2)
self.listClassMethod.setHeaderLabels(['Object', 'Line'])
objInspLabel = QCoreApplication.translate("PythonConsole", "Object Inspector")
self.listClassMethod.setHeaderLabels([objInspLabel, ''])
self.listClassMethod.setColumnHidden(1, True)
self.listClassMethod.setAlternatingRowColors(True)

@@ -237,7 +238,7 @@ def __init__(self, parent=None):
self.uncommentEditorButton.setToolTip(uncommentEditorBt)
self.uncommentEditorButton.setText(uncommentEditorBt)
## Action for Object browser
objList = QCoreApplication.translate("PythonConsole", "Object browser")
objList = QCoreApplication.translate("PythonConsole", "Object Inspector")
self.objectListButton = QAction(self)
self.objectListButton.setCheckable(True)
self.objectListButton.setEnabled(True)
@@ -186,6 +186,7 @@ def settingsEditor(self):
threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2).toInt()[0]
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI').toString()
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True).toBool()

self.setAutoCompletionThreshold(threshold)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
@@ -693,6 +694,7 @@ def __init__(self, parent, parentConsole, filename, readOnly):
self.setEventFilter(self.keyFilter)

def loadFile(self, filename, modified):
self.newEditor.lastModified = QFileInfo(filename).lastModified()
fn = open(unicode(filename), "rb")
txt = fn.read()
fn.close()
@@ -702,7 +704,6 @@ def loadFile(self, filename, modified):
self.newEditor.setReadOnly(self.readOnly)
QApplication.restoreOverrideCursor()
self.newEditor.setModified(modified)
self.newEditor.lastModified = QFileInfo(filename).lastModified()
self.newEditor.recolor()

def save(self, fileName=None):
@@ -869,7 +870,9 @@ def __init__(self, parent):
self.connect(self.newTabButton, SIGNAL('clicked()'), self.newTabEditor)

def _currentWidgetChanged(self, tab):
self.listObject(tab)
if self.settings.value("pythonConsole/enableObjectInsp",
False).toBool():
self.listObject(tab)
self.changeLastDirPath(tab)
self.enableSaveIfModified(tab)

@@ -1021,6 +1024,7 @@ def closeCurrentWidget(self):
self.parent.updateTabListScript(currWidget.path, action='remove')

def restoreTabs(self):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
for script in self.restoreTabList:
pathFile = unicode(script.toString())
if os.path.exists(pathFile):
@@ -1034,6 +1038,7 @@ def restoreTabs(self):
s = errOnRestore
sys.stderr.write(s)
self.parent.updateTabListScript(pathFile, action='remove')
QApplication.restoreOverrideCursor()
if self.count() < 1:
self.newTabEditor(filename=None)
self.topFrame.close()
@@ -1074,11 +1079,11 @@ def listObject(self, tab):
try:
reload(pyclbr)
dictObject = {}
superClassName = []
readModule = pyclbr.readmodule(module)
readModuleFunction = pyclbr.readmodule_ex(module)
for name, class_data in sorted(readModule.items(), key=lambda x:x[1].lineno):
if os.path.normpath(str(class_data.file)) == os.path.normpath(str(tabWidget.path)):
superClassName = []
for superClass in class_data.super:
if superClass == 'object':
continue
@@ -1088,7 +1093,7 @@ def listObject(self, tab):
superClassName.append(superClass.name)
classItem = QTreeWidgetItem()
if superClassName:
for i in superClassName: super = i
super = ', '.join([i for i in superClassName])
classItem.setText(0, name + ' [' + super + ']')
classItem.setToolTip(0, name + ' [' + super + ']')
else:
@@ -1128,16 +1133,28 @@ def listObject(self, tab):
iconWarning = QgsApplication.getThemeIcon("console/iconSyntaxErrorConsole.png")
msgItem.setIcon(0, iconWarning)
self.parent.listClassMethod.addTopLevelItem(msgItem)
#s = traceback.format_exc()
#print '## Error: '
#sys.stderr.write(s)
#pass
# s = traceback.format_exc()
# print '## Error: '
# sys.stderr.write(s)
# pass

def refreshSettingsEditor(self):
countTab = self.count()
for i in range(countTab):
self.widget(i).newEditor.settingsEditor()

objInspectorEnabled = self.settings.value("pythonConsole/enableObjectInsp",
False).toBool()
listObj = self.parent.objectListButton
listObj.setChecked(objInspectorEnabled)
listObj.setEnabled(objInspectorEnabled)
if objInspectorEnabled:
cW = self.currentWidget()
if cW:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.listObject(cW)
QApplication.restoreOverrideCursor()

def changeLastDirPath(self, tab):
tabWidget = self.widget(tab)
if tabWidget:
@@ -175,6 +175,7 @@ def saveSettings(self):

settings.setValue("pythonConsole/autoCompleteEnabledEditor", QVariant(self.autoCompleteEnabledEditor.isChecked()))
settings.setValue("pythonConsole/autoCompleteEnabled", QVariant(self.autoCompleteEnabled.isChecked()))
settings.setValue("pythonConsole/enableObjectInsp", QVariant(self.enableObjectInspector.isChecked()))

def restoreSettings(self):
settings = QSettings()
@@ -196,6 +197,7 @@ def restoreSettings(self):

self.autoCompleteEnabledEditor.setChecked(settings.value("pythonConsole/autoCompleteEnabledEditor", True).toBool())
self.autoCompleteEnabled.setChecked(settings.value("pythonConsole/autoCompleteEnabled", True).toBool())
self.enableObjectInspector.setChecked(settings.value("pythonConsole/enableObjectInsp", False).toBool())

if settings.value("pythonConsole/autoCompleteSource") == 'fromDoc':
self.autoCompFromDoc.setChecked(True)

0 comments on commit 2566841

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