Skip to content

Commit

Permalink
Merge branch 'master' into delimited_text_bug_fixes_2
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrook committed Apr 29, 2013
2 parents 2232c3d + 1959182 commit 18786ad
Show file tree
Hide file tree
Showing 48 changed files with 12,940 additions and 8,950 deletions.
46 changes: 23 additions & 23 deletions doc/TRANSLATORS

Large diffs are not rendered by default.

6,874 changes: 3,916 additions & 2,958 deletions i18n/qgis_da_DK.ts

Large diffs are not rendered by default.

588 changes: 317 additions & 271 deletions i18n/qgis_de.ts

Large diffs are not rendered by default.

7,061 changes: 3,944 additions & 3,117 deletions i18n/qgis_fr.ts

Large diffs are not rendered by default.

5,176 changes: 3,053 additions & 2,123 deletions i18n/qgis_gl_ES.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ms-windows/osgeo4w/browser.bat.tmpl
@@ -1,7 +1,7 @@
@echo off
call "~dp0\o4w_env.bat
call "%~dp0\o4w_env.bat"
call "%OSGEO4W_ROOT%"\apps\grass\grass-@grassversion@\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\@package@\bin;%OSGEO4W_ROOT%\apps\grass\grass-@grassversion@\lib
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/@package@
start "Quantum GIS Browser" /B "%OSGEO4W_ROOT%"\bin\@package@-browser.exe %*
start "Quantum GIS Browser" /B "%OSGEO4W_ROOT%"\bin\@package@-browser-bin.exe %*
8 changes: 4 additions & 4 deletions ms-windows/osgeo4w/package-nightly.cmd
Expand Up @@ -174,14 +174,14 @@ REM del %OSGEO4W_ROOT%\apps\%PACKAGENAME%\python\qgis\qgisconfig.py

touch exclude

move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qgis.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%.exe
move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qbrowser.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-browser.exe
move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qgis.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-bin.exe
move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qbrowser.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-browser-bin.exe

tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 ^
--exclude-from exclude ^
apps/%PACKAGENAME% ^
bin/%PACKAGENAME%.exe ^
bin/%PACKAGENAME%-browser.exe ^
bin/%PACKAGENAME%-bin.exe ^
bin/%PACKAGENAME%-browser-bin.exe ^
bin/%PACKAGENAME%.bat.tmpl ^
bin/%PACKAGENAME%-browser.bat.tmpl ^
apps/qt4/plugins/sqldrivers/qsqlocispatial.dll ^
Expand Down
8 changes: 4 additions & 4 deletions ms-windows/osgeo4w/package.cmd
Expand Up @@ -224,13 +224,13 @@ tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-server-%VERSION%-%PACKAGE%.tar.bz2 ^
>>%LOG% 2>&1
if errorlevel 1 goto error

move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qgis.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%.exe
move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qbrowser.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-browser.exe
move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qgis.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-bin.exe
move %OSGEO4W_ROOT%\apps\%PACKAGENAME%\bin\qbrowser.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-browser-bin.exe
tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 ^
--exclude-from exclude ^
--exclude "*.pyc" ^
"bin/%PACKAGENAME%-browser.exe" ^
"bin/%PACKAGENAME%.exe" ^
"bin/%PACKAGENAME%-browser-bin.exe" ^
"bin/%PACKAGENAME%-bin.exe" ^
"apps/%PACKAGENAME%/bin/qgis.reg.tmpl" ^
"apps/%PACKAGENAME%/i18n/" ^
"apps/%PACKAGENAME%/icons/" ^
Expand Down
2 changes: 1 addition & 1 deletion ms-windows/osgeo4w/qgis.bat.tmpl
Expand Up @@ -4,4 +4,4 @@ call "%OSGEO4W_ROOT%"\apps\grass\grass-@grassversion@\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\@package@\bin;%OSGEO4W_ROOT%\apps\grass\grass-@grassversion@\lib
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/@package@
start "Quantum GIS" /B "%OSGEO4W_ROOT%"\bin\@package@.exe %*
start "Quantum GIS" /B "%OSGEO4W_ROOT%"\bin\@package@-bin.exe %*
4 changes: 2 additions & 2 deletions python/console/console.py
Expand Up @@ -606,9 +606,9 @@ def openSettings(self):
self.options.exec_()

def prefChanged(self):
self.shell.refreshLexerProperties()
self.shell.settingsShell()
self.shellOut.refreshLexerProperties()
self.tabEditorWidget.changeFont()
self.tabEditorWidget.refreshSettingsEditor()

def callWidgetMessageBar(self, text):
self.shellOut.widgetMessageBar(iface, text)
Expand Down
189 changes: 120 additions & 69 deletions python/console/console_editor.py
Expand Up @@ -77,6 +77,8 @@ def __init__(self, parent=None):
super(Editor,self).__init__(parent)
self.parent = parent

self.settings = QSettings()

# Enable non-ascii chars for editor
self.setUtf8(True)

Expand Down Expand Up @@ -113,9 +115,6 @@ def __init__(self, parent=None):

self.setMinimumHeight(120)
#self.setMinimumWidth(300)

self.setAutoCompletionThreshold(2)
self.setAutoCompletionSource(self.AcsAPIs)

# Folding
self.setFolding(QsciScintilla.PlainFoldStyle)
Expand All @@ -131,6 +130,8 @@ def __init__(self, parent=None):
self.setWhitespaceVisibility(QsciScintilla.WsVisibleAfterIndent)
#self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

self.settingsEditor()

# Annotations
#self.setAnnotationDisplay(QsciScintilla.ANNOTATION_BOXED)

Expand All @@ -155,7 +156,7 @@ def __init__(self, parent=None):
## New QShortcut = ctrl+space/ctrl+alt+space for Autocomplete
self.newShortcutCS = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Space), self)
self.newShortcutCS.setContext(Qt.WidgetShortcut)
self.newShortcutCS.activated.connect(self.autoComplete)
self.newShortcutCS.activated.connect(self.autoCompleteKeyBinding)
self.runScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
self.runScut.setContext(Qt.WidgetShortcut)
self.runScut.activated.connect(self.runSelectedCode)
Expand All @@ -169,9 +170,33 @@ def __init__(self, parent=None):
self.uncommentScut = QShortcut(QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_3), self)
self.uncommentScut.setContext(Qt.WidgetShortcut)
self.uncommentScut.activated.connect(self.parent.pc.uncommentCode)

def autoComplete(self):
self.autoCompleteFromAll()

def settingsEditor(self):
self.setLexers()
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':
self.setAutoCompletionSource(self.AcsDocument)
elif radioButtonSource == 'fromAPI':
self.setAutoCompletionSource(self.AcsAPIs)
elif radioButtonSource == 'fromDocAPI':
self.setAutoCompletionSource(self.AcsAll)
else:
self.setAutoCompletionSource(self.AcsNone)

def autoCompleteKeyBinding(self):
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor").toString()
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor").toBool()
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
self.autoCompleteFromDocument()
elif radioButtonSource == 'fromAPI':
self.autoCompleteFromAPIs()
elif radioButtonSource == 'fromDocAPI':
self.autoCompleteFromAll()

def on_margin_clicked(self, nmargin, nline, modifiers):
# Toggle marker for the line the margin was clicked on
Expand All @@ -180,16 +205,13 @@ def on_margin_clicked(self, nmargin, nline, modifiers):
else:
self.markerAdd(nline, self.ARROW_MARKER_NUM)

def refreshLexerProperties(self):
self.setLexers()

def setLexers(self):
from qgis.core import QgsApplication

self.lexer = QsciLexerPython()
settings = QSettings()
loadFont = settings.value("pythonConsole/fontfamilytext", "Monospace").toString()
fontSize = settings.value("pythonConsole/fontsize", 10).toInt()[0]

loadFont = self.settings.value("pythonConsole/fontfamilytextEditor", "Monospace").toString()
fontSize = self.settings.value("pythonConsole/fontsizeEditor", 10).toInt()[0]

font = QFont(loadFont)
font.setFixedPitch(True)
Expand All @@ -208,11 +230,11 @@ def setLexers(self):
self.lexer.setFont(font, 4)

self.api = QsciAPIs(self.lexer)
chekBoxAPI = settings.value("pythonConsole/preloadAPI", True).toBool()
chekBoxAPI = self.settings.value("pythonConsole/preloadAPI", True).toBool()
if chekBoxAPI:
self.api.loadPrepared( QgsApplication.pkgDataPath() + "/python/qsci_apis/pyqgis_master.pap" )
else:
apiPath = settings.value("pythonConsole/userAPI").toStringList()
apiPath = self.settings.value("pythonConsole/userAPI").toStringList()
for i in range(0, len(apiPath)):
self.api.load(QString(unicode(apiPath[i])))
self.api.prepare()
Expand All @@ -239,6 +261,7 @@ def contextMenuEvent(self, e):
iconNewEditor = QgsApplication.getThemeIcon("console/iconTabEditorConsole.png")
iconCommentEditor = QgsApplication.getThemeIcon("console/iconCommentEditorConsole.png")
iconUncommentEditor = QgsApplication.getThemeIcon("console/iconUncommentEditorConsole.png")
iconSettings = QgsApplication.getThemeIcon("console/iconSettingsConsole.png")
hideEditorAction = menu.addAction("Hide Editor",
self.hideEditor)
menu.addSeparator()
Expand Down Expand Up @@ -282,6 +305,10 @@ def contextMenuEvent(self, e):
selectAllAction = menu.addAction("Select All",
self.selectAll,
QKeySequence.SelectAll)
menu.addSeparator()
settingsDialog = menu.addAction(iconSettings,
"Settings",
self.parent.pc.openSettings)
pasteAction.setEnabled(False)
codePadAction.setEnabled(False)
cutAction.setEnabled(False)
Expand Down Expand Up @@ -352,15 +379,13 @@ def codepad(self):
self.parent.pc.callWidgetMessageBarEditor(msgText + str(e.args))

def hideEditor(self):
self.parent.pc.widgetEditor.hide()
self.parent.pc.listClassMethod.hide()
self.parent.pc.splitterObj.hide()
self.parent.pc.showEditorButton.setChecked(False)

def commentEditorCode(self, commentCheck):
self.beginUndoAction()
if self.hasSelectedText():
startLine, _, endLine, _ = self.getSelection()
self.beginUndoAction()
for line in range(startLine, endLine + 1):
selCmd = self.text(line)
self.setSelection(line, 0, line, selCmd.length())
Expand All @@ -370,12 +395,12 @@ def commentEditorCode(self, commentCheck):
self.setCursorPosition(endLine, selCmd.length())
else:
if selCmd.startsWith('#'):
self.insert(selCmd[1:])
self.insert(selCmd[1:])
else:
self.insert(selCmd)
self.setCursorPosition(endLine, self.text(line).length() - 1)
else:
line, pos = self.getCursorPosition()
self.beginUndoAction()
selCmd = self.text(line)
self.setSelection(line, 0, line, selCmd.length())
self.removeSelectedText()
Expand All @@ -384,61 +409,88 @@ def commentEditorCode(self, commentCheck):
self.setCursorPosition(line, selCmd.length())
else:
if selCmd.startsWith('#'):
self.insert(selCmd[1:])
self.insert(selCmd[1:])
else:
self.insert(selCmd)
self.setCursorPosition(line, self.text(line).length() - 1)
self.endUndoAction()

def createTempFile(self):
import tempfile
fd, path = tempfile.mkstemp()
tmpFileName = path + '.py'
with open(path, "w") as f:
f.write(self.text())
os.close(fd)
os.rename(path, tmpFileName)
return tmpFileName

def runScriptCode(self):
tabWidget = self.parent.mw.currentWidget()
filename = tabWidget.path
def _runSubProcess(self, filename, tmp=False):
dir, name = os.path.split(unicode(filename))
if dir not in sys.path:
sys.path.append(dir)
try:
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
out, _traceback = p.communicate()

## Fix interrupted system call on OSX
if sys.platform == 'darwin':
status = None
while status is None:
try:
status = p.wait()
except OSError, e:
if e.errno == 4:
pass
else:
raise e
if tmp:
name = name + ' [Temporary file saved in ' + dir + ']'
if _traceback:
print "## %s" % datetime.datetime.now()
print "## Script error: %s" % name
sys.stderr.write(_traceback)
p.stderr.close()
else:
print "## %s" % datetime.datetime.now()
print "## Script executed successfully: %s" % name
sys.stdout.write(out)
p.stdout.close()
del p
if tmp:
os.remove(filename)
except IOError, error:
print 'Cannot execute file %s. Error: %s' % (filename, error.strerror)
except:
s = traceback.format_exc()
print '## Error: '
sys.stderr.write(s)

def runScriptCode(self):
autoSave = self.settings.value("pythonConsole/autoSaveScript").toBool()

tabWidget = self.parent.mw.currentWidget()
filename = tabWidget.path

msgEditorBlank = QCoreApplication.translate('PythonConsole',
'Hey, type something for running !')
msgEditorUnsaved = QCoreApplication.translate('PythonConsole',
'You have to save the file before running.')
if filename is None:
if not self.isModified():
self.parent.pc.callWidgetMessageBarEditor(msgEditorBlank)
else:
'You have to save the file before running.')
if not autoSave:
if filename is None:
if not self.isModified():
self.parent.pc.callWidgetMessageBarEditor(msgEditorBlank)
else:
self.parent.pc.callWidgetMessageBarEditor(msgEditorUnsaved)
return
if self.isModified():
self.parent.pc.callWidgetMessageBarEditor(msgEditorUnsaved)
return
if self.isModified():
self.parent.pc.callWidgetMessageBarEditor(msgEditorUnsaved)
return
return
else:
self._runSubProcess(filename)
else:
try:
p = subprocess.Popen(['python', filename], shell=False, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
out, traceback = p.communicate()

## Fix interrupted system call on OSX
if sys.platform == 'darwin':
status = None
while status is None:
try:
status = p.wait()
except OSError, e:
if e.errno == 4:
pass
else:
raise e

if traceback:
print "## %s" % datetime.datetime.now()
print "## Script error: %s" % name
sys.stderr.write(traceback)
p.stderr.close()
else:
print "## %s" % datetime.datetime.now()
print "## Script executed successfully: %s" % name
sys.stdout.write(out)
p.stdout.close()
del p
#execfile(unicode(filename))
except IOError, error:
print 'Cannot execute file %s. Error: %s' % (filename, error.strerror)
tmpFile = self.createTempFile()
self._runSubProcess(tmpFile, True)

def runSelectedCode(self):
cmd = self.selectedText()
Expand Down Expand Up @@ -827,18 +879,17 @@ def listObject(self, tab):
s = traceback.format_exc()
print '## Error: '
sys.stderr.write(s)

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

def changeLastDirPath(self, tab):
tabWidget = self.widget(tab)
settings = QSettings()
settings.setValue("pythonConsole/lastDirPath", QVariant(tabWidget.path))
self.settings.setValue("pythonConsole/lastDirPath", QVariant(tabWidget.path))

def widgetMessageBar(self, iface, text):
timeout = iface.messageTimeout()
currWidget = self.currentWidget()
currWidget.infoBar.pushMessage('Editor', text, QgsMessageBar.INFO, timeout)
currWidget.infoBar.pushMessage(text, QgsMessageBar.INFO, timeout)

0 comments on commit 18786ad

Please sign in to comment.