Skip to content

Commit

Permalink
Merge pull request #11 from qgis/master
Browse files Browse the repository at this point in the history
merge from qgis
  • Loading branch information
longhuan2018 committed Oct 13, 2020
2 parents baa90f2 + 8d3e028 commit 6d2b701
Show file tree
Hide file tree
Showing 441 changed files with 2,836 additions and 1,944 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ ADD_DEFINITIONS(-DQT_DEPRECATED_WARNINGS)
# Unfortunately Qwt uses deprecated QString::null in headers, preventing this being raised above 5.8
ADD_DEFINITIONS(-DQT_DISABLE_DEPRECATED_BEFORE=0x050800)

# For fast string concatenation
ADD_DEFINITIONS(-DQT_USE_QSTRINGBUILDER)

IF (WITH_GEOREFERENCER)
FIND_PACKAGE(GSL REQUIRED)
SET(HAVE_GEOREFERENCER TRUE)
Expand Down
1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@
<file>themes/default/mActionLabelAnchorStart.svg</file>
<file>themes/default/transformation.svg</file>
<file>themes/default/mIconCodeEditor.svg</file>
<file>themes/default/console/iconSyntaxErrorConsoleParams.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion python/console/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def _textFindChanged(self):
def onClickGoToLine(self, item, column):
tabEditor = self.tabEditorWidget.currentWidget().newEditor
if item.text(1) == 'syntaxError':
check = tabEditor.syntaxCheck(fromContextMenu=False)
check = tabEditor.syntaxCheck()
if check and not tabEditor.isReadOnly():
self.tabEditorWidget.currentWidget().save()
return
Expand Down
64 changes: 16 additions & 48 deletions python/console/console_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,18 @@ def eventFilter(self, obj, event):

class Editor(QgsCodeEditorPython):

MARKER_NUM = 6

def __init__(self, parent=None):
super().__init__(parent)
self.parent = parent
# recent modification time
self.lastModified = 0
self.opening = ['(', '{', '[', "'", '"']
self.closing = [')', '}', ']', "'", '"']

# List of marker line to be deleted from check syntax
self.bufferMarkerLine = []

self.settings = QgsSettings()

self.markerDefine(QgsApplication.getThemePixmap("console/iconSyntaxErrorConsole.svg"),
self.MARKER_NUM)

self.setMinimumHeight(120)

self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)

# Annotations
self.setAnnotationDisplay(QsciScintilla.ANNOTATION_BOXED)

# Disable command key
ctrl, shift = self.SCMOD_CTRL << 16, self.SCMOD_SHIFT << 16
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl)
Expand Down Expand Up @@ -160,9 +147,9 @@ def contextMenuEvent(self, e):
QCoreApplication.translate("PythonConsole", "Hide Editor"),
self.hideEditor)
menu.addSeparator() # ------------------------------
syntaxCheck = menu.addAction(QgsApplication.getThemeIcon("console/iconSyntaxErrorConsole.svg"),
QCoreApplication.translate("PythonConsole", "Check Syntax"),
self.syntaxCheck, 'Ctrl+4')
syntaxCheckAction = menu.addAction(QgsApplication.getThemeIcon("console/iconSyntaxErrorConsole.svg"),
QCoreApplication.translate("PythonConsole", "Check Syntax"),
self.syntaxCheck, 'Ctrl+4')
runSelected = menu.addAction(QgsApplication.getThemeIcon("console/mIconRunConsole.svg"), # spellok
QCoreApplication.translate("PythonConsole", "Run Selected"),
self.runSelectedCode, 'Ctrl+E') # spellok
Expand Down Expand Up @@ -218,7 +205,7 @@ def contextMenuEvent(self, e):
menu.addAction(QgsApplication.getThemeIcon("console/iconSettingsConsole.svg"),
QCoreApplication.translate("PythonConsole", "Options…"),
self.parent.pc.openSettings)
syntaxCheck.setEnabled(False)
syntaxCheckAction.setEnabled(False)
pasteAction.setEnabled(False)
pyQGISHelpAction.setEnabled(False)
gist_menu.setEnabled(False)
Expand All @@ -237,7 +224,7 @@ def contextMenuEvent(self, e):
pyQGISHelpAction.setEnabled(True)
if not self.text() == '':
selectAllAction.setEnabled(True)
syntaxCheck.setEnabled(True)
syntaxCheckAction.setEnabled(True)
if self.isUndoAvailable():
undoAction.setEnabled(True)
if self.isRedoAvailable():
Expand Down Expand Up @@ -461,7 +448,7 @@ def runScriptCode(self):
self.parent.pc.callWidgetMessageBarEditor(msgEditorBlank, 0, True)
return

if self.syntaxCheck(fromContextMenu=False):
if self.syntaxCheck():
if filename and self.isModified() and autoSave:
self.parent.save(filename)
elif not filename or self.isModified():
Expand Down Expand Up @@ -495,15 +482,14 @@ def goToLine(self, objName, linenr):
self.ensureLineVisible(linenr)
self.setFocus()

def syntaxCheck(self, filename=None, fromContextMenu=True):
eline = None
ecolumn = 0
edescr = ''
def syntaxCheck(self):
source = self.text()
self.clearWarnings()
try:
filename = self.parent.tw.currentWidget().path
if not filename:
filename = self.parent.tw.currentWidget().path
# source = open(filename, 'r').read() + '\n'
tmpFile = self.createTempFile()
filename = tmpFile
if isinstance(source, type("")):
source = source.encode('utf-8')
if isinstance(filename, type("")):
Expand All @@ -512,34 +498,16 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
compile(source, filename, 'exec')
except SyntaxError as detail:
eline = detail.lineno and detail.lineno or 1
eline -= 1
ecolumn = detail.offset and detail.offset or 1
edescr = detail.msg
if eline is not None:
eline -= 1
for markerLine in self.bufferMarkerLine:
self.markerDelete(markerLine)
self.clearAnnotations(markerLine)
self.bufferMarkerLine.remove(markerLine)
if (eline) not in self.bufferMarkerLine:
self.bufferMarkerLine.append(eline)
self.markerAdd(eline, self.MARKER_NUM)
loadFont = self.settings.value("pythonConsole/fontfamilytext",
"Monospace")
styleAnn = QsciStyle(-1, "Annotation",
QColor(255, 0, 0),
QColor(255, 200, 0),
QFont(loadFont, 8, -1, True),
True)
self.annotate(eline, edescr, styleAnn)

self.addWarning(eline, edescr)
self.setCursorPosition(eline, ecolumn - 1)
# self.setSelection(eline, ecolumn, eline, self.lineLength(eline)-1)
self.ensureLineVisible(eline)
# self.ensureCursorVisible()
return False
else:
self.markerDeleteAll()
self.clearAnnotations()
return True

return True

def keyPressEvent(self, e):
t = e.text()
Expand Down
8 changes: 5 additions & 3 deletions python/console/console_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,18 @@ def insertInitText(self):
else:
self.setText(txtInit + '\n')

def initializeLexer(self):
super().initializeLexer()
self.setFoldingVisible(False)
self.setEdgeMode(QsciScintilla.EdgeNone)

def refreshSettingsOutput(self):
# Set Python lexer
self.initializeLexer()
self.setReadOnly(True)

self.setCaretWidth(0) # NO (blinking) caret in the output

self.setFoldingVisible(False)
self.setEdgeMode(QsciScintilla.EdgeNone)

def clearConsole(self):
self.setText('')
self.insertInitText()
Expand Down
27 changes: 14 additions & 13 deletions python/console/console_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import traceback

from qgis.core import QgsApplication, QgsSettings, Qgis
from qgis.gui import QgsCodeEditor

from .ui_console_history_dlg import Ui_HistoryDialogPythonConsole

_init_commands = ["import sys", "import os", "import re", "import math", "from qgis.core import *",
Expand Down Expand Up @@ -105,6 +107,18 @@ def __init__(self, parent=None):
self.newShortcutCAS.activated.connect(self.autoComplete)
self.newShortcutCSS.activated.connect(self.showHistory)

def initializeLexer(self):
super().initializeLexer()
self.setCaretLineVisible(False)
self.setLineNumbersVisible(False) # NO linenumbers for the input line
self.setFoldingVisible(False)
# Margin 1 is used for the '>>>' prompt (console input)
self.setMarginLineNumbers(1, True)
self.setMarginWidth(1, "00000")
self.setMarginType(1, 5) # TextMarginRightJustified=5
self.setMarginsBackgroundColor(self.color(QgsCodeEditorColorScheme.ColorRole.Background))
self.setEdgeMode(QsciScintilla.EdgeNone)

def _setMinimumHeight(self):
font = self.lexer().defaultFont(0)
fm = QFontMetrics(font)
Expand All @@ -118,19 +132,6 @@ def refreshSettingsShell(self):
# Sets minimum height for input area based of font metric
self._setMinimumHeight()

self.setCaretLineVisible(False)
self.setMarginLineNumbers(0, False) # NO linenumbers for the input line
self.setMarginWidth(0, 0)
# margin 2 is the folding
self.setMarginWidth(2, 0)
# Margin 1 is used for the '>>>' prompt (console input)
self.setMarginLineNumbers(1, True)
self.setMarginWidth(1, "00000")
self.setMarginType(1, 5) # TextMarginRightJustified=5
self.setMarginsBackgroundColor(self.color(QgsCodeEditorColorScheme.ColorRole.Background))
self.setFoldingVisible(False)
self.setEdgeMode(QsciScintilla.EdgeNone)

def showHistory(self):
if not self.historyDlg.isVisible():
self.historyDlg.show()
Expand Down
8 changes: 4 additions & 4 deletions python/core/auto_generated/diagram/qgsdiagram.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Base class for all diagram types.
public:

%ConvertToSubClassCode
if ( sipCpp->diagramName() == QStringLiteral( "Pie" ) )
if ( sipCpp->diagramName() == QLatin1String( "Pie" ) )
sipType = sipType_QgsPieDiagram;
else if ( sipCpp->diagramName() == QStringLiteral( "Histogram" ) )
else if ( sipCpp->diagramName() == QLatin1String( "Histogram" ) )
sipType = sipType_QgsHistogramDiagram;
else if ( sipCpp->diagramName() == QStringLiteral( "Text" ) )
else if ( sipCpp->diagramName() == QLatin1String( "Text" ) )
sipType = sipType_QgsTextDiagram;
else if ( sipCpp->diagramName() == QStringLiteral( "Stacked" ) )
else if ( sipCpp->diagramName() == QLatin1String( "Stacked" ) )
sipType = sipType_QgsStackedBarDiagram;
else
sipType = NULL;
Expand Down
10 changes: 8 additions & 2 deletions python/core/auto_generated/qgsaction.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Create a new QgsAction
:param description: A human readable description string
:param command: The action text. Its interpretation depends on the type
:param capture: If this is set to ``True``, the output will be captured when an action is run
:param enabledOnlyWhenEditable: if ``True`` then action is only enable in editmode
:param enabledOnlyWhenEditable: if ``True`` then action is only enable in editmode. Not available in Python bindings.
%End

QgsAction( ActionType type, const QString &description, const QString &action, const QString &icon, bool capture, const QString &shortTitle = QString(), const QSet<QString> &actionScopes = QSet<QString>(), const QString &notificationMessage = QString() );
Expand All @@ -57,7 +57,7 @@ Create a new QgsAction
:param shortTitle: A short string used to label user interface elements like buttons
:param actionScopes: A set of scopes in which this action will be available
:param notificationMessage: A particular message which reception will trigger the action
:param enabledOnlyWhenEditable: if ``True`` then action is only enable in editmode
:param enabledOnlyWhenEditable: if ``True`` then action is only enable in editmode. Not available in Python bindings.
%End

QString name() const;
Expand Down Expand Up @@ -126,6 +126,12 @@ Whether to capture output for display when this action is run
Returns whether only enabled in editable mode
%End

void setEnabledOnlyWhenEditable( bool enable );
%Docstring
Set whether the action is only enabled in editable mode

.. versionadded:: 3.16
%End

bool runable() const;
%Docstring
Expand Down
6 changes: 5 additions & 1 deletion python/core/auto_generated/qgsapplication.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,14 @@ Cursors are automatically scaled to look like a 16px cursor on 96dpi
screens.
%End

static QPixmap getThemePixmap( const QString &name );
static QPixmap getThemePixmap( const QString &name, const QColor &foreColor = QColor(), const QColor &backColor = QColor(), int size = 16 );
%Docstring
Helper to get a theme icon as a pixmap. It will fall back to the
default theme if the active theme does not have the required icon.

If ``foreColor`` or ``backColor`` are specified, then these colors will
be used for parametrized colors in SVG files wherever available. If
colors are specified then the ``size`` argument also must be set.
%End

static QString userStylePath();
Expand Down
4 changes: 2 additions & 2 deletions python/core/auto_generated/qgsdiagramrenderer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,9 @@ Evaluates and returns the diagram settings relating to a diagram for a specific
#include "qgsdiagramrenderer.h"
%End
%ConvertToSubClassCode
if ( sipCpp->rendererName() == QStringLiteral( "SingleCategory" ) )
if ( sipCpp->rendererName() == QLatin1String( "SingleCategory" ) )
sipType = sipType_QgsSingleCategoryDiagramRenderer;
else if ( sipCpp->rendererName() == QStringLiteral( "LinearlyInterpolated" ) )
else if ( sipCpp->rendererName() == QLatin1String( "LinearlyInterpolated" ) )
sipType = sipType_QgsLinearlyInterpolatedDiagramRenderer;
else
sipType = NULL;
Expand Down
20 changes: 10 additions & 10 deletions python/core/auto_generated/symbology/qgsrenderer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ class QgsFeatureRenderer

const QString type = sipCpp->type();

if ( type == QStringLiteral( "singleSymbol" ) )
if ( type == QLatin1String( "singleSymbol" ) )
sipType = sipType_QgsSingleSymbolRenderer;
else if ( type == QStringLiteral( "categorizedSymbol" ) )
else if ( type == QLatin1String( "categorizedSymbol" ) )
sipType = sipType_QgsCategorizedSymbolRenderer;
else if ( type == QStringLiteral( "graduatedSymbol" ) )
else if ( type == QLatin1String( "graduatedSymbol" ) )
sipType = sipType_QgsGraduatedSymbolRenderer;
else if ( type == QStringLiteral( "RuleRenderer" ) )
else if ( type == QLatin1String( "RuleRenderer" ) )
sipType = sipType_QgsRuleBasedRenderer;
else if ( type == QStringLiteral( "heatmapRenderer" ) )
else if ( type == QLatin1String( "heatmapRenderer" ) )
sipType = sipType_QgsHeatmapRenderer;
else if ( type == QStringLiteral( "invertedPolygonRenderer" ) )
else if ( type == QLatin1String( "invertedPolygonRenderer" ) )
sipType = sipType_QgsInvertedPolygonRenderer;
else if ( type == QStringLiteral( "pointCluster" ) )
else if ( type == QLatin1String( "pointCluster" ) )
sipType = sipType_QgsPointClusterRenderer;
else if ( type == QStringLiteral( "pointDisplacement" ) )
else if ( type == QLatin1String( "pointDisplacement" ) )
sipType = sipType_QgsPointDisplacementRenderer;
else if ( type == QStringLiteral( "25dRenderer" ) )
else if ( type == QLatin1String( "25dRenderer" ) )
sipType = sipType_Qgs25DRenderer;
else if ( type == QStringLiteral( "nullSymbol" ) )
else if ( type == QLatin1String( "nullSymbol" ) )
sipType = sipType_QgsNullSymbolRenderer;
else
sipType = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Base class for labeling configuration classes for vector tile layers.

const QString type = sipCpp->type();

if ( type == QStringLiteral( "basic" ) )
if ( type == QLatin1String( "basic" ) )
sipType = sipType_QgsVectorTileBasicLabeling;
else
sipType = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ For rendering it is expected that client code calls:

const QString type = sipCpp->type();

if ( type == QStringLiteral( "basic" ) )
if ( type == QLatin1String( "basic" ) )
sipType = sipType_QgsVectorTileBasicRenderer;
else
sipType = 0;
Expand Down
Loading

0 comments on commit 6d2b701

Please sign in to comment.