71,752 changes: 30,975 additions & 40,777 deletions i18n/qgis_ja.ts

Large diffs are not rendered by default.

2,950 changes: 1,526 additions & 1,424 deletions i18n/qgis_nl.ts

Large diffs are not rendered by default.

404 changes: 205 additions & 199 deletions i18n/qgis_pt_PT.ts

Large diffs are not rendered by default.

8,593 changes: 4,874 additions & 3,719 deletions i18n/qgis_sv.ts

Large diffs are not rendered by default.

Binary file added images/flags/bn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
6 changes: 2 additions & 4 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<file>flags/en_US.png</file>
<file>flags/es.png</file>
<file>flags/et_EE.png</file>
<file>flags/eu_ES.png</file>
<file>flags/fa.png</file>
<file>flags/fi.png</file>
<file>flags/fr.png</file>
Expand Down Expand Up @@ -64,13 +63,11 @@
<file>themes/default/cap_round.png</file>
<file>themes/default/cap_square.png</file>
<file>themes/default/clearInput.png</file>
<file>themes/default/console/iconAboutConsole.png</file>
<file>themes/default/console/iconClassConsole.png</file>
<file>themes/default/console/iconClearConsole.png</file>
<file>themes/default/console/iconCodepadConsole.png</file>
<file>themes/default/console/iconHelpConsole.png</file>
<file>themes/default/console/iconHideToolConsole.png</file>
<file>themes/default/console/iconIfaceConsole.png</file>
<file>themes/default/console/iconOpenConsole.png</file>
<file>themes/default/console/iconQtCoreConsole.png</file>
<file>themes/default/console/iconQtGuiConsole.png</file>
Expand All @@ -84,7 +81,6 @@
<file>themes/default/console/imgHelpMenu.png</file>
<file>themes/default/console/iconTabEditorConsole.png</file>
<file>themes/default/console/iconNewTabEditorConsole.png</file>
<file>themes/default/console/iconCloseTabEditorConsole.png</file>
<file>themes/default/console/iconRestoreTabsConsole.png</file>
<file>themes/default/console/iconFileTabsMenuConsole.png</file>
<file>themes/default/console/iconShowEditorConsole.png</file>
Expand Down Expand Up @@ -434,6 +430,8 @@
<file>themes/default/unlocked.png</file>
<file>themes/default/user.png</file>
<file>flags/bs_BA.png</file>
<file>flags/eu.png</file>
<file>flags/bn.png</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
Binary file removed images/themes/default/console/iconAboutConsole.png
Binary file not shown.
Binary file not shown.
Binary file modified images/themes/default/console/iconFileTabsMenuConsole.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/themes/default/console/iconIfaceConsole.png
Binary file not shown.
Binary file modified images/themes/default/console/iconNewTabEditorConsole.png
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 @@ -708,7 +708,7 @@ def saveSettingsConsole(self):
self.settings.setValue("pythonConsole/splitterObj", self.splitterObj.saveState())
self.settings.setValue("pythonConsole/splitterEditor", self.splitterEditor.saveState())

self.shell.writeHistoryFile()
self.shell.writeHistoryFile(True)

def restoreSettingsConsole(self):
storedTabScripts = self.settings.value("pythonConsole/tabScripts")
Expand Down
17 changes: 11 additions & 6 deletions python/console/console_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ 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':
Expand Down Expand Up @@ -272,6 +271,9 @@ def contextMenuEvent(self, e):
iconFind = QgsApplication.getThemeIcon("console/iconSearchEditorConsole.png")
iconSyntaxCk = QgsApplication.getThemeIcon("console/iconSyntaxErrorConsole.png")
iconObjInsp = QgsApplication.getThemeIcon("console/iconClassBrowserConsole.png")
iconCut = QgsApplication.getThemeIcon("console/iconCutEditorConsole.png")
iconCopy = QgsApplication.getThemeIcon("console/iconCopyEditorConsole.png")
iconPaste = QgsApplication.getThemeIcon("console/iconPasteEditorConsole.png")
hideEditorAction = menu.addAction(QCoreApplication.translate("PythonConsole", "Hide Editor"),
self.hideEditor)
menu.addSeparator()
Expand Down Expand Up @@ -301,15 +303,18 @@ def contextMenuEvent(self, e):
"Find Text"),
self.showFindWidget)
menu.addSeparator()
cutAction = menu.addAction(QCoreApplication.translate("PythonConsole",
cutAction = menu.addAction(iconCut,
QCoreApplication.translate("PythonConsole",
"Cut"),
self.cut,
QKeySequence.Cut)
copyAction = menu.addAction(QCoreApplication.translate("PythonConsole",
copyAction = menu.addAction(iconCopy,
QCoreApplication.translate("PythonConsole",
"Copy"),
self.copy,
QKeySequence.Copy)
pasteAction = menu.addAction(QCoreApplication.translate("PythonConsole",
pasteAction = menu.addAction(iconPaste,
QCoreApplication.translate("PythonConsole",
"Paste"),
self.paste, QKeySequence.Paste)
menu.addSeparator()
Expand Down Expand Up @@ -958,11 +963,11 @@ def closeAll(self):
self._removeTab(i)
self.newTabEditor(tabName='Untitled-0')
self._removeTab(0)

def saveAs(self):
idx = self.idx
self.parent.saveAsScriptFile(idx)

def enableSaveIfModified(self, tab):
tabWidget = self.widget(tab)
if tabWidget:
Expand Down
5 changes: 2 additions & 3 deletions python/console/console_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def settingsShell(self):
self.setAutoCompletionThreshold(threshold)
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource", 'fromAPI').toString()
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True).toBool()
self.setAutoCompletionThreshold(threshold)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
self.setAutoCompletionSource(self.AcsDocument)
Expand Down Expand Up @@ -272,7 +271,7 @@ def updateHistory(self, command):
self.history.append(command)
self.historyIndex = len(self.history)

def writeHistoryFile(self):
def writeHistoryFile(self, fromCloseConsole=False):
ok = False
try:
wH = open(_historyFile, 'w')
Expand All @@ -282,7 +281,7 @@ def writeHistoryFile(self):
except:
raise
wH.close()
if ok:
if ok and not fromCloseConsole:
msgText = QCoreApplication.translate('PythonConsole',
'History saved successfully.')
self.parent.callWidgetMessageBar(msgText)
Expand Down
34 changes: 3 additions & 31 deletions python/console/console_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __init__(self, parent):

self.restoreSettings()
self.initialCheck()
self.autoCompletionOptions()

self.addAPIpath.setIcon(QIcon(":/images/themes/default/symbologyAdd.png"))
self.addAPIpath.setToolTip(QCoreApplication.translate("PythonConsole", "Add API path"))
Expand All @@ -44,10 +43,6 @@ def __init__(self, parent):

self.connect( self.preloadAPI,
SIGNAL("stateChanged(int)"), self.initialCheck)
self.connect( self.autoCompleteEnabled,
SIGNAL("stateChanged(int)"), self.autoCompletionOptions)
self.connect( self.autoCompleteEnabledEditor,
SIGNAL("stateChanged(int)"), self.autoCompletionOptions)
self.connect(self.addAPIpath,
SIGNAL("clicked()"), self.loadAPIFile)
self.connect(self.removeAPIpath,
Expand All @@ -64,28 +59,6 @@ def enableDisable(self, value):
self.addAPIpath.setEnabled(value)
self.removeAPIpath.setEnabled(value)

def autoCompletionOptions(self):
if self.autoCompleteEnabled.isChecked():
self.enableDisableAutoCompleteOptions(True)
else:
self.enableDisableAutoCompleteOptions(False)
if self.autoCompleteEnabledEditor.isChecked():
self.enableDisableAutoCompleteOptions(True, editor='editor')
else:
self.enableDisableAutoCompleteOptions(False, editor='editor')

def enableDisableAutoCompleteOptions(self, value, editor=None):
if editor:
self.autoCompFromAPIEditor.setEnabled(value)
self.autoCompFromDocAPIEditor.setEnabled(value)
self.autoCompFromDocEditor.setEnabled(value)
self.autoCompThresholdEditor.setEnabled(value)
else:
self.autoCompFromAPI.setEnabled(value)
self.autoCompFromDocAPI.setEnabled(value)
self.autoCompFromDoc.setEnabled(value)
self.autoCompThreshold.setEnabled(value)

def loadAPIFile(self):
settings = QSettings()
lastDirPath = settings.value("pythonConsole/lastDirAPIPath").toString()
Expand Down Expand Up @@ -146,6 +119,9 @@ def saveSettings(self):
settings.setValue("pythonConsole/autoCompThreshold", QVariant(self.autoCompThreshold.value()))
settings.setValue("pythonConsole/autoCompThresholdEditor", QVariant(self.autoCompThresholdEditor.value()))

settings.setValue("pythonConsole/autoCompleteEnabledEditor", QVariant(self.groupBoxAutoCompletionEditor.isChecked()))
settings.setValue("pythonConsole/autoCompleteEnabled", QVariant(self.groupBoxAutoCompletion.isChecked()))

if self.autoCompFromAPIEditor.isChecked():
settings.setValue("pythonConsole/autoCompleteSourceEditor", QVariant('fromAPI'))
elif self.autoCompFromDocEditor.isChecked():
Expand All @@ -160,8 +136,6 @@ def saveSettings(self):
elif self.autoCompFromDocAPI.isChecked():
settings.setValue("pythonConsole/autoCompleteSource", QVariant('fromDocAPI'))

settings.setValue("pythonConsole/autoCompleteEnabledEditor", QVariant(self.autoCompleteEnabledEditor.isChecked()))
settings.setValue("pythonConsole/autoCompleteEnabled", QVariant(self.autoCompleteEnabled.isChecked()))
settings.setValue("pythonConsole/enableObjectInsp", QVariant(self.enableObjectInspector.isChecked()))
settings.setValue("pythonConsole/autoCloseBracket", QVariant(self.autoCloseBracket.isChecked()))
settings.setValue("pythonConsole/autoCloseBracketEditor", QVariant(self.autoCloseBracketEditor.isChecked()))
Expand All @@ -188,8 +162,6 @@ def restoreSettings(self):
self.autoCompThreshold.setValue(settings.value("pythonConsole/autoCompThreshold", 2).toInt()[0])
self.autoCompThresholdEditor.setValue(settings.value("pythonConsole/autoCompThresholdEditor", 2).toInt()[0])

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())
self.autoCloseBracketEditor.setChecked(settings.value("pythonConsole/autoCloseBracketEditor", True).toBool())
self.autoCloseBracket.setChecked(settings.value("pythonConsole/autoCloseBracket", True).toBool())
Expand Down
252 changes: 104 additions & 148 deletions python/console/console_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>543</width>
<height>674</height>
<width>554</width>
<height>642</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
Expand Down Expand Up @@ -137,59 +137,37 @@
<property name="title">
<string>Autocompletion</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="collapsed" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<property name="saveCheckedState" stdset="0">
<bool>true</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="autoCompleteEnabledEditor">
<property name="text">
<string>Autocompletion enabled</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Threshold</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="autoCompThresholdEditor">
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Autocompletion threshold</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="autoCompThresholdEditor">
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="layoutRadioButtonEditor">
<item row="0" column="0">
<widget class="QRadioButton" name="autoCompFromDocEditor">
Expand Down Expand Up @@ -255,103 +233,6 @@
<string>Console</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="3" column="0">
<widget class="QgsCollapsibleGroupBox" name="groupBoxAutoCompletion">
<property name="title">
<string>Autocompletion</string>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="autoCompleteEnabled">
<property name="text">
<string>Autocompletion enabled</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Threshold</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="autoCompThreshold">
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="layoutRadioButton">
<item row="0" column="0">
<widget class="QRadioButton" name="autoCompFromDoc">
<property name="toolTip">
<string>Get autocompletion from current document</string>
</property>
<property name="text">
<string>from Document</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="autoCompFromAPI">
<property name="toolTip">
<string>Get autocompletion from installed APIs</string>
</property>
<property name="text">
<string>from APIs files</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="autoCompFromDocAPI">
<property name="toolTip">
<string>Get autocompletion from current document and installed APIs</string>
</property>
<property name="text">
<string>from Doc and APIs</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
Expand Down Expand Up @@ -408,13 +289,88 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QCheckBox" name="autoCloseBracket">
<property name="text">
<string>Automatic parentheses insertion</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QgsCollapsibleGroupBox" name="groupBoxAutoCompletion">
<property name="title">
<string>Autocompletion</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCheckedState" stdset="0">
<bool>true</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Autocompletion threshold</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="autoCompThreshold">
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="layoutRadioButton">
<item row="0" column="2">
<widget class="QRadioButton" name="autoCompFromDocAPI">
<property name="toolTip">
<string>Get autocompletion from current document and installed APIs</string>
</property>
<property name="text">
<string>from Doc and APIs</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="autoCompFromAPI">
<property name="toolTip">
<string>Get autocompletion from installed APIs</string>
</property>
<property name="text">
<string>from APIs files</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="autoCompFromDoc">
<property name="toolTip">
<string>Get autocompletion from current document</string>
</property>
<property name="text">
<string>from Document</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
24 changes: 12 additions & 12 deletions python/core/qgsdiagramrendererv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct QgsDiagramLayerSettings
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
};

//diagram settings for rendering
Expand Down Expand Up @@ -88,8 +88,8 @@ class QgsDiagramSettings
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
};

//additional diagram settings for interpolated size rendering
Expand Down Expand Up @@ -134,8 +134,8 @@ class QgsDiagramRendererV2
/**Returns list with all diagram settings in the renderer*/
virtual QList<QgsDiagramSettings> diagramSettings() const = 0;

virtual void readXML( const QDomElement& elem ) = 0;
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc ) const = 0;
virtual void readXML( const QDomElement& elem, const QgsVectorLayer* layer ) = 0;
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const = 0;

protected:

Expand All @@ -156,8 +156,8 @@ class QgsDiagramRendererV2
static int dpiPaintDevice( const QPainter* );

//read / write diagram
void _readXML( const QDomElement& elem );
void _writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
void _readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void _writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
};

/**Renders the diagrams for all features with the same settings*/
Expand All @@ -179,8 +179,8 @@ class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2

QList<QgsDiagramSettings> diagramSettings() const;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;

protected:
bool diagramSettings( const QgsAttributes&, const QgsRenderContext& c, QgsDiagramSettings& s );
Expand Down Expand Up @@ -222,8 +222,8 @@ class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2
int classificationAttribute() const;
void setClassificationAttribute( int index );

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;

protected:
bool diagramSettings( const QgsAttributes&, const QgsRenderContext& c, QgsDiagramSettings& s );
Expand Down
5 changes: 3 additions & 2 deletions python/gui/qgisinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ class QgisInterface : QObject
*/

//! Menus
virtual QMenu *fileMenu() = 0;
virtual QMenu *fileMenu() = 0 /Deprecated/;
virtual QMenu *projectMenu() = 0;
virtual QMenu *editMenu() = 0;
virtual QMenu *viewMenu() = 0;
virtual QMenu *layerMenu() = 0;
Expand Down Expand Up @@ -366,7 +367,7 @@ class QgisInterface : QObject
*/
virtual QToolBar *webToolBar() = 0;

//! File menu actions
//! Project menu actions
virtual QAction *actionNewProject() = 0;
virtual QAction *actionOpenProject() = 0;
virtual QAction *actionSaveProject() = 0;
Expand Down
16 changes: 11 additions & 5 deletions python/plugins/db_manager/db_plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@
class BaseError(Exception):
"""Base class for exceptions in the plugin."""
def __init__(self, e):
msg = e if isinstance(e, (str,unicode,QString)) else e.message
if isinstance(e, Exception):
msg = e.args[0] if len(e.args) > 0 else ''
else:
msg = e

try:
msg = unicode( msg )
except UnicodeDecodeError:
msg = unicode( msg, 'utf-8' )

self.msg = msg
Exception.__init__(self, msg)

def __unicode__(self):
return self.message
return self.msg

def __str__(self):
return unicode(self).encode('utf-8')
Expand All @@ -55,7 +60,7 @@ def __init__(self, e, query=None):
self.query = unicode( query ) if query != None else None

def __unicode__(self):
if self.query == None:
if self.query is None:
return BaseError.__unicode__(self)

msg = u"Error:\n%s" % BaseError.__unicode__(self)
Expand Down Expand Up @@ -976,8 +981,8 @@ def update(self, new_name, new_type_str=None, new_not_null=None, new_default_str
class TableConstraint(TableSubItemObject):
""" class that represents a constraint of a table (relation) """

TypeCheck, TypeForeignKey, TypePrimaryKey, TypeUnique = range(4)
types = { "c" : TypeCheck, "f" : TypeForeignKey, "p" : TypePrimaryKey, "u" : TypeUnique }
TypeCheck, TypeForeignKey, TypePrimaryKey, TypeUnique, TypeExclusion, TypeUnknown = range(6)
types = { "c" : TypeCheck, "f" : TypeForeignKey, "p" : TypePrimaryKey, "u" : TypeUnique, "x" : TypeExclusion }

onAction = { "a" : "NO ACTION", "r" : "RESTRICT", "c" : "CASCADE", "n" : "SET NULL", "d" : "SET DEFAULT" }
matchTypes = { "u" : "UNSPECIFIED", "f" : "FULL", "p" : "PARTIAL" }
Expand All @@ -991,6 +996,7 @@ def type2String(self):
if self.type == TableConstraint.TypePrimaryKey: return "Primary key"
if self.type == TableConstraint.TypeForeignKey: return "Foreign key"
if self.type == TableConstraint.TypeUnique: return "Unique"
if self.type == TableConstraint.TypeExclusion: return "Exclusion"
return 'Unknown'

def fields(self):
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/db_manager/db_plugins/postgis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,13 @@ def __init__(self, row, table):
class PGTableConstraint(TableConstraint):
def __init__(self, row, table):
TableConstraint.__init__(self, table)
self.name, constr_type, self.isDefferable, self.isDeffered, columns = row[:5]
self.name, constr_type_str, self.isDefferable, self.isDeffered, columns = row[:5]
self.columns = map(int, columns.split(' '))
self.type = TableConstraint.types[constr_type] # convert to enum

if constr_type_str in TableConstraint.types:
self.type = TableConstraint.types[constr_type_str]
else:
self.type = TableConstraint.TypeUnknown

if self.type == TableConstraint.TypeCheck:
self.checkSource = row[5]
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/db_manager/dlg_db_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def __init__(self, e, parent=None):
def sanitize(txt):
return "" if txt == None else "<pre>" + txt.replace('<','&lt;') + "</pre>"

if isinstance(e, DbError) and hasattr(e, 'query'):
self.setQueryMessage( sanitize(e.message), sanitize(e.query) )
if isinstance(e, DbError):
self.setQueryMessage( sanitize(e.msg), sanitize(e.query) )
else:
self.setMessage( sanitize(e.message) )
self.setMessage( sanitize(e.msg) )

def setMessage(self, msg):
self.txtErrorMsg.setHtml(msg)
Expand Down
20 changes: 14 additions & 6 deletions python/plugins/db_manager/dlg_import_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ def __init__(self, inLayer, outDb, outUri, parent=None):

self.mode = self.ASK_FOR_INPUT_MODE if self.inLayer is None else self.HAS_INPUT_MODE

# updates of UI
self.setupWorkingMode( self.mode )
# used to delete the inlayer whether created inside this dialog
self.inLayerMustBeDestroyed = False

self.connect(self.cboSchema, SIGNAL("currentIndexChanged(int)"), self.populateTables)
self.populateSchemas()
self.populateTables()
self.populateLayers()
self.populateEncodings()

# updates of UI
self.setupWorkingMode( self.mode )
self.connect(self.cboSchema, SIGNAL("currentIndexChanged(int)"), self.populateTables)



def setupWorkingMode(self, mode):
""" hide the widget to select a layer/file if the input layer
Expand Down Expand Up @@ -106,19 +110,21 @@ def populateLayers(self):
self.cboInputLayer.addItem( layer.name(), index )

def deleteInputLayer(self):
""" destroy the input layer instance, but only if it was
""" unset the input layer, then destroy it but only if it was
created from this dialog """
if self.mode == self.ASK_FOR_INPUT_MODE and self.inLayer:
self.inLayer.deleteLater()
if self.inLayerMustBeDestroyed:
self.inLayer.deleteLater()
self.inLayer = None
self.inLayerMustBeDestroyed = False
return True
return False

def chooseInputFile(self):
vectorFormats = qgis.core.QgsProviderRegistry.instance().fileVectorFilters()
# get last used dir and format
settings = QSettings()
lastDir = settings.value("/db_manager/lastUsedDir", "").toString()
lastDir = settings.value("/db_manager/lastUsedDir", "").toString()
lastVectorFormat = settings.value("/UI/lastVectorFileFilter", "").toString()
# ask for a filename
filename = QFileDialog.getOpenFileName(self, "Choose the file to import", lastDir, vectorFormats, lastVectorFormat)
Expand Down Expand Up @@ -158,10 +164,12 @@ def updateInputLayer(self):
return False

self.inLayer = layer
self.inLayerMustBeDestroyed = True

else:
legendIndex = self.cboInputLayer.itemData( index ).toInt()[0]
self.inLayer = iface.legendInterface().layers()[ legendIndex ]
self.inLayerMustBeDestroyed = False

# update the output table name
self.cboTable.setEditText(self.inLayer.name())
Expand Down
4 changes: 1 addition & 3 deletions python/plugins/db_manager/dlg_sql_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ def __init__(self, iface, db, parent=None):
def showEvent(self, event):
QDialog.showEvent(self, event)
self.updatePresetsCombobox()



def updatePresetsCombobox(self):
entries = QgsProject.instance().subkeyList('DBManager','savedQueries')
Expand All @@ -108,7 +106,7 @@ def storePreset(self):
self.presetCombo.setCurrentIndex(self.presetCombo.count()-1)
else:
self.presetCombo.setCurrentIndex(index)

def deletePreset(self):
name = self.presetCombo.currentText()
QgsProject.instance().removeEntry('DBManager','savedQueries/q'+str(name.__hash__()) )
Expand Down
6 changes: 0 additions & 6 deletions python/plugins/fTools/fTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,12 @@ def initGui(self):

self.updateThemeIcons("theme")

self.tmpAct = QAction( self.iface.mainWindow() )
self.iface.addPluginToVectorMenu( "tmp", self.tmpAct )
self.menu = self.iface.vectorMenu()
self.menu.addMenu( self.analysisMenu )
self.menu.addMenu( self.researchMenu )
self.menu.addMenu( self.geoMenu )
self.menu.addMenu( self.conversionMenu )
self.menu.addMenu( self.dataManageMenu )
self.iface.removePluginVectorMenu( "tmp", self.tmpAct )

QObject.connect(self.distMatrix, SIGNAL("triggered()"), self.dodistMatrix)
QObject.connect(self.sumLines, SIGNAL("triggered()"), self.dosumLines)
Expand Down Expand Up @@ -246,14 +243,11 @@ def initGui(self):
QObject.connect(self.spatialIndex, SIGNAL("triggered()"), self.doSpatIndex)

def unload(self):
self.iface.addPluginToVectorMenu( "tmp", self.tmpAct )
self.menu.removeAction( self.analysisMenu.menuAction() )
self.menu.removeAction( self.researchMenu.menuAction() )
self.menu.removeAction( self.geoMenu.menuAction() )
self.menu.removeAction( self.conversionMenu.menuAction() )
self.menu.removeAction( self.dataManageMenu.menuAction() )
self.iface.removePluginVectorMenu( "tmp", self.tmpAct )


def doSimplify(self):
d = doSimplify.Dialog(self.iface, 1)
Expand Down
2 changes: 1 addition & 1 deletion python/pyspatialite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ENDIF (WIN32)
FOREACH(file lib/__init__.py lib/dbapi2.py lib/dump.py)
ADD_CUSTOM_COMMAND(TARGET pyspatialite
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite/${file}
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite/
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
ENDFOREACH(file)
Expand Down
20 changes: 18 additions & 2 deletions resources/context_help/QgsDelimitedTextSourceSelect-en_US
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,25 @@ describe points, lines, and polygons of arbitrary complexity. The file can also
only table, which can then be joined to other tables in QGIS.
</p>
<p>
In addition to the geometry definition the file can contain text, integer, and real number fields. QGIS
will choose the type of field based on its contents.
In addition to the geometry definition the file can contain text, integer, and real number fields. By default
QGIS will choose the type of field based on its the non blank values of the field. If all can be interpreted
as integer then the type will be integer, if all can be interpreted as real numbers then the type will
be double, otherwise the type will be text.
</p>
<p>
QGIS can also read the types from an OGR CSV driver compatible &quot;csvt&quot; file.
This is a file alongside the data file, but with a &quot;t&quot; appended to the file name.
The file should just contain one linewhich lists the type of each field.
Valid types are &quot;integer&quot;, &quot;real&quot;, &quot;string&quot;, &quot;date&quot;, &quot;time&quot;, and &quot;datetime&quot;. The date, time, and datetime types are treated as strings in QGIS.
Each type may be followed by a width and precision, for example &quot;real(10.4)&quot;.
The list of types are separated by commas, regardless of the delimiter used in the data file. An
example of a valid format file would be:
</p>

<pre>
&quot;integer&quot;,&quot;string&quot;,&quot;string(20)&quot;,&quot;real(20.4)&quot;
</pre>

<h4><a name="creating">Creating a delimited text layer</a></h4>
<p>Creating a delimited text layer involves choosing the data file, defining the format (how each record is to
be split into fields), and defining the geometry is represented.
Expand Down
1 change: 1 addition & 0 deletions scripts/spelling.dat
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,4 @@ specifed:specified
widht:width
heigth:height
heigh:height
delimted:delimited
6 changes: 3 additions & 3 deletions scripts/tsstat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
es => 'Carlos Dávila, Javier César Aldariz, Gabriela Awad, Edwin Amado, Mayeul Kauffmann, Diana Galindo',
el_GR => 'Evripidis Argyropoulos, Mike Pegnigiannis, Nikos Ves',
et_EE => 'Veiko Viil',
eu_ES => 'Irantzu Alvarez',
eu => 'Asier Sarasua Garmendia, Irantzu Alvarez',
fa => 'Mola Pahnadayan',
fi => 'Marko Järvenpää',
fr => 'Eve Rousseau, Marc Monnerat, Lionel Roubeyrie, Jean Roc Morreale, Benjamin Bohard, Jeremy Garniaux, Yves Jacolin, Benjamin Lerre, Stéphane Morel, Marie Silvestre, Tahir Tamba, Xavier M, Mayeul Kauffmann, Mehdi Semchaoui, Robin Cura, Etienne Tourigny, Mathieu Bossaert',
Expand All @@ -55,14 +55,14 @@
is => 'Thordur Ivarsson',
id => 'Januar V. Simarmata, I Made Anombawa',
it => 'Paolo Cavallini, Flavio Rigolon, Maurizio Napolitano, Roberto Angeletti, Alessandro Fanna, Michele Beneventi, Marco Braida, Luca Casagrande, Luca Delucchi, Anne Gishla',
ja => 'BABA Yoshihiko, Yoichi Kayama',
ja => 'BABA Yoshihiko, Yoichi Kayama, Minoru Akagi, Takayuki Nuimura, Takayuki Mizutani, Norihiro Yamate',
ka_GE => 'Shota Murtskhvaladze, George Machitidze',
km => 'Khoem Sokhem',
ko_KR => 'BJ Jang',
lo => 'Anousak Souphavanh, Soukanh Lathsavong',
lv => 'Maris Nartiss, Pēteris Brūns',
lt => 'Kestas M',
nl => 'Richard Duivenvoorde, Raymond Nijssen, Carlo van Rijswijk',
nl => 'Richard Duivenvoorde, Raymond Nijssen, Carlo van Rijswijk, Diethard Jansen',
ml_IN => 'Vinayan Parameswaran',
mn => 'Bayarmaa Enkhtur',
pl_PL => 'Robert Szczepanek, Milena Nowotarska, Borys Jurgiel, Mateusz Loskot, Tomasz Paul, Andrzej Swiader ',
Expand Down
64 changes: 60 additions & 4 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "qgsvectorlayer.h"
#include "qgsgenericprojectionselector.h"
#include "qgsclipboard.h"
#include "qgsmessagelog.h"

#include <QFont>
#include <QDomDocument>
Expand Down Expand Up @@ -1453,7 +1454,7 @@ void QgsLegend::setDrawingOrder( QList<QgsMapLayer *> layers )
updateMapCanvasLayerSet();
}

void QgsLegend::setDrawingOrder( const QList<DrawingOrderInfo>& order )
void QgsLegend::setDrawingOrder( const QList<DrawingOrderInfo> &order )
{
QList<QgsMapCanvasLayer> layers;

Expand Down Expand Up @@ -1680,7 +1681,7 @@ bool QgsLegend::writeXML( QDomNode &legendnode, QDomDocument &document )

bool QgsLegend::writeXML( QList<QTreeWidgetItem *> items, QDomNode &node, QDomDocument &document )
{
foreach ( QTreeWidgetItem * currentItem, items )
foreach ( QTreeWidgetItem *currentItem, items )
{
QgsLegendItem *item = dynamic_cast<QgsLegendItem *>( currentItem );
if ( !item )
Expand Down Expand Up @@ -1827,6 +1828,9 @@ bool QgsLegend::readXML( QgsLegendGroup *parent, const QDomNode &node )
bkMapExtent = mMapCanvas->extent();
}

QString activeLayerId = node.toElement().attribute( "activeLayer" );
QgsLegendLayer *activeLayer = 0;

const QDomNodeList &l = node.childNodes();
for ( int i = 0; i < l.count(); i++ )
{
Expand Down Expand Up @@ -1899,6 +1903,9 @@ bool QgsLegend::readXML( QgsLegendGroup *parent, const QDomNode &node )
continue;
}

if ( currentLayer->layer() && currentLayer->layer()->id() == activeLayerId )
activeLayer = currentLayer;

if ( currentLayer->layer() && !QgsProject::instance()->layerIsEmbedded( currentLayer->layer()->id() ).isEmpty() )
{
// start with already set font style
Expand Down Expand Up @@ -1959,22 +1966,40 @@ bool QgsLegend::readXML( QgsLegendGroup *parent, const QDomNode &node )
}
}

if ( activeLayer )
setCurrentItem( activeLayer );

//restore canvas extent (could be changed by addLayer calls)
if ( !bkMapExtent.isEmpty() )
{
mMapCanvas->setExtent( bkMapExtent );
}

return true;
}

bool QgsLegend::readXML( QDomNode& legendnode )
{
clear(); //remove all items first
mEmbeddedGroups.clear();
mUpdateDrawingOrder = legendnode.toElement().attribute( "updateDrawingOrder", "true" ) == "true";

mUpdateDrawingOrder = true;

if ( !readXML( 0, legendnode ) )
return false;

if ( legendnode.toElement().attribute( "updateDrawingOrder", "true" ) != "true" )
{
if ( !verifyDrawingOrder() )
QgsMessageLog::logMessage( tr( "Not fully defined drawing order set to legend order." ), tr( "Legend" ), QgsMessageLog::WARNING );

mUpdateDrawingOrder = false;
}

emit updateDrawingOrderChecked( mUpdateDrawingOrder );
emit updateDrawingOrderUnchecked( !mUpdateDrawingOrder );
return readXML( 0, legendnode );

return true;
}

QgsLegendLayer* QgsLegend::readLayerFromXML( QDomElement& childelem, bool& isOpen )
Expand Down Expand Up @@ -2794,6 +2819,8 @@ void QgsLegend::writeProject( QDomDocument & doc )

QDomElement mapcanvasNode = doc.createElement( "legend" );
mapcanvasNode.setAttribute( "updateDrawingOrder", mUpdateDrawingOrder ? "true" : "false" );
if ( currentLayer() )
mapcanvasNode.setAttribute( "activeLayer", currentLayer()->id() );
qgisNode.appendChild( mapcanvasNode );
writeXML( mapcanvasNode, doc );
}
Expand Down Expand Up @@ -2946,11 +2973,40 @@ bool QgsLegend::groupEmbedded( QTreeWidgetItem* item ) const
return mEmbeddedGroups.contains( gItem->text( 0 ) );
}

bool QgsLegend::verifyDrawingOrder()
{
Q_ASSERT( mUpdateDrawingOrder );

// check if the drawing order wasn't already initially set
bool hasUndefinedOrder = false;
for ( QTreeWidgetItemIterator it( this ); *it && !hasUndefinedOrder; it++ )
{
QgsLegendLayer *ll = dynamic_cast<QgsLegendLayer *>( *it );
hasUndefinedOrder |= ll && ll->drawingOrder() < 0;
}

if ( !hasUndefinedOrder )
return true;

int i = 0;
foreach ( QgsLegendLayer *ll, legendLayers() )
{
ll->setDrawingOrder( i++ );
}

return false;
}

void QgsLegend::setUpdateDrawingOrder( bool updateDrawingOrder )
{
if ( mUpdateDrawingOrder == updateDrawingOrder )
return;

if ( !updateDrawingOrder )
{
verifyDrawingOrder();
}

mUpdateDrawingOrder = updateDrawingOrder;

QgsProject::instance()->dirty( true );
Expand Down
4 changes: 3 additions & 1 deletion src/app/legend/qgslegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class QgsLegend : public QTreeWidget

} mPixmaps;

//! Widget that holds the indicator line //
//! Widget that holds the indicator line
QWidget *mInsertionLine;

QMap< QgsMapLayer::LayerType, QList< LegendLayerAction > > mLegendLayerActionMap;
Expand All @@ -588,6 +588,8 @@ class QgsLegend : public QTreeWidget

void updateGroupCheckStates( QTreeWidgetItem *item );

bool verifyDrawingOrder();

signals:
void itemAdded( QModelIndex index );
void itemMoved( QModelIndex oldIndex, QModelIndex newIndex );
Expand Down
10 changes: 5 additions & 5 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ typedef SInt32 SRefCon;
#endif

// (if Windows/Mac, use icon from resource)
#if ! defined(Q_WS_WIN) && ! defined(Q_WS_MAC)
#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
#include "../../images/themes/default/qgis.xpm" // Linux
#include <QIcon>
#endif
Expand Down Expand Up @@ -195,7 +195,7 @@ LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
}
#endif

#ifdef Q_OS_UNIX
#if defined(linux) && !defined(ANDROID)
void qgisCrash( int signal )
{
qFatal( "QGIS died on signal %d", signal );
Expand Down Expand Up @@ -232,7 +232,7 @@ void myMessageOutput( QtMsgType type, const char *msg )
|| 0 == strncmp( msg, "QPainter::", 10 ) )
{
#if 0
#if defined(linux) && ! defined(ANDROID)
#if defined(linux) && !defined(ANDROID)
fprintf( stderr, "Stacktrace (run through c++filt):\n" );
void *buffer[256];
int nptrs = backtrace( buffer, sizeof( buffer ) / sizeof( *buffer ) );
Expand Down Expand Up @@ -276,7 +276,7 @@ int main( int argc, char *argv[] )
#endif // _MSC_VER
#endif // WIN32

#if !defined(ANDROID) && !defined(_MSC_VER)
#if defined(linux) && !defined(ANDROID)
// Set up the custom qWarning/qDebug custom handler
qInstallMsgHandler( myMessageOutput );

Expand Down Expand Up @@ -593,7 +593,7 @@ int main( int argc, char *argv[] )
QgsApplication myApp( argc, argv, myUseGuiFlag, configpath );

// (if Windows/Mac, use icon from resource)
#if ! defined(Q_WS_WIN) && ! defined(Q_WS_MAC)
#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
myApp.setWindowIcon( QPixmap( qgis_xpm ) ); // Linux
#endif

Expand Down
5 changes: 2 additions & 3 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )

void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );

Expand Down Expand Up @@ -473,12 +473,11 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
}
}
}
QgsDebugMsg( "Leaving." );
}

void QgsMapToolNodeTool::selectedFeatureDestroyed()
{
QgsDebugMsg( "Entered." );
QgsDebugCall;
mSelectedFeature = 0;
}

Expand Down
12 changes: 6 additions & 6 deletions src/app/nodetool/qgsselectedfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ QgsSelectedFeature::QgsSelectedFeature( QgsFeatureId featureId,
, mRubberBand( 0 )
, mValidator( 0 )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;
setSelectedFeature( featureId, vlayer, canvas );
}

QgsSelectedFeature::~QgsSelectedFeature()
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

deleteVertexMap();

Expand All @@ -61,14 +61,14 @@ QgsSelectedFeature::~QgsSelectedFeature()

void QgsSelectedFeature::currentLayerChanged( QgsMapLayer *layer )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;
if ( layer == mVlayer )
deleteLater();
}

void QgsSelectedFeature::updateGeometry( QgsGeometry *geom )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

delete mGeometry;

Expand Down Expand Up @@ -149,7 +149,7 @@ void QgsSelectedFeature::featureDeleted( QgsFeatureId fid )

void QgsSelectedFeature::geometryChanged( QgsFeatureId fid, QgsGeometry &geom )
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

if ( !mVlayer || fid != mFeatureId )
return;
Expand Down Expand Up @@ -483,7 +483,7 @@ void QgsSelectedFeature::createVertexMapPoint()

void QgsSelectedFeature::createVertexMap()
{
QgsDebugMsg( "Entering." );
QgsDebugCall;

if ( !mGeometry )
{
Expand Down
23 changes: 12 additions & 11 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ void QgisApp::readSettings()
// 'gis' theme is new /themes/default directory (2013-04-15)
setTheme( settings.value( "/Themes", "default" ).toString() );

// Add the recently accessed project file paths to the File menu
// Add the recently accessed project file paths to the Project menu
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();

// this is a new session! reset enable macros value to "ask"
Expand All @@ -888,7 +888,8 @@ void QgisApp::createActions()
mActionPluginSeparator1 = NULL; // plugin list separator will be created when the first plugin is loaded
mActionPluginSeparator2 = NULL; // python separator will be created only if python is found
mActionRasterSeparator = NULL; // raster plugins list separator will be created when the first plugin is loaded
// File Menu Items

// Project Menu Items

connect( mActionNewProject, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
connect( mActionNewBlankProject, SIGNAL( triggered() ), this, SLOT( fileNewBlank() ) );
Expand Down Expand Up @@ -1226,8 +1227,8 @@ void QgisApp::createMenus()
* for the following items.
*
* Project Properties:
* Gnome, Mac - File menu above print commands
* Kde, Win - Settings menu (Win doesn't specify)
* Gnome, Mac, Win - File/Project menu above print commands (Win doesn't specify)
* Kde - Settings menu
*
* Custom CRS, Options:
* Gnome - bottom of Edit menu
Expand All @@ -1251,20 +1252,20 @@ void QgisApp::createMenus()
QDialogButtonBox::ButtonLayout layout =
QDialogButtonBox::ButtonLayout( style()->styleHint( QStyle::SH_DialogButtonLayout, 0, this ) );

// File Menu
// Project Menu

// Connect once for the entire submenu.
connect( mRecentProjectsMenu, SIGNAL( triggered( QAction * ) ),
this, SLOT( openProject( QAction * ) ) );
connect( mProjectFromTemplateMenu, SIGNAL( triggered( QAction * ) ),
this, SLOT( fileNewFromTemplateAction( QAction * ) ) );

if ( layout == QDialogButtonBox::GnomeLayout || layout == QDialogButtonBox::MacLayout )
if ( layout == QDialogButtonBox::GnomeLayout || layout == QDialogButtonBox::MacLayout || layout == QDialogButtonBox::WinLayout )
{
QAction* before = mActionNewPrintComposer;
mSettingsMenu->removeAction( mActionProjectProperties );
mFileMenu->insertAction( before, mActionProjectProperties );
mFileMenu->insertSeparator( before );
mProjectMenu->insertAction( before, mActionProjectProperties );
mProjectMenu->insertSeparator( before );
}

// View Menu
Expand Down Expand Up @@ -2238,7 +2239,7 @@ void QgisApp::projectReadDecorationItems()
}
}

// Update file menu with the current list of recently accessed projects
// Update project menu with the current list of recently accessed projects
void QgisApp::updateRecentProjectPaths()
{
// Remove existing paths from the recent projects menu
Expand Down Expand Up @@ -2293,7 +2294,7 @@ void QgisApp::saveRecentProjectPath( QString projectPath, QSettings & settings )

} // QgisApp::saveRecentProjectPath

// Update file menu with the project templates
// Update project menu with the project templates
void QgisApp::updateProjectFromTemplates()
{
// get list of project files in template dir
Expand Down Expand Up @@ -5281,7 +5282,7 @@ void QgisApp::deselectAll()
void QgisApp::selectByExpression()
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );
if( !vlayer )
if ( !vlayer )
{
messageBar()->pushMessage(
tr( "No active vector layer" ),
Expand Down
7 changes: 4 additions & 3 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionShowPinnedLabels() { return mActionShowPinnedLabels; }

//! Menus
QMenu *fileMenu() { return mFileMenu; }
Q_DECL_DEPRECATED QMenu *fileMenu() { return mProjectMenu; }
QMenu *projectMenu() { return mProjectMenu; }
QMenu *editMenu() { return mEditMenu; }
QMenu *viewMenu() { return mViewMenu; }
QMenu *layerMenu() { return mLayerMenu; }
Expand Down Expand Up @@ -587,7 +588,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

QgsMessageLogViewer *logViewer() { return mLogViewer; }

//! Update file menu with the project templates
//! Update project menu with the project templates
void updateProjectFromTemplates();

protected:
Expand Down Expand Up @@ -1166,7 +1167,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
* instance simultaneously results in data loss.
*/
void saveRecentProjectPath( QString projectPath, QSettings & settings );
//! Update file menu with the current list of recently accessed projects
//! Update project menu with the current list of recently accessed projects
void updateRecentProjectPaths();
//! Read Well Known Binary stream from PostGIS
//void readWKB(const char *, QStringList tables);
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ bool QgisAppInterface::unregisterMainWindowAction( QAction* action )
}

//! Menus
QMenu *QgisAppInterface::fileMenu() { return qgis->fileMenu(); }
Q_DECL_DEPRECATED QMenu *QgisAppInterface::fileMenu() { return qgis->projectMenu(); }
QMenu *QgisAppInterface::projectMenu() { return qgis->projectMenu(); }
QMenu *QgisAppInterface::editMenu() { return qgis->editMenu(); }
QMenu *QgisAppInterface::viewMenu() { return qgis->viewMenu(); }
QMenu *QgisAppInterface::layerMenu() { return qgis->layerMenu(); }
Expand Down Expand Up @@ -455,7 +456,7 @@ QToolBar *QgisAppInterface::vectorToolBar() { return qgis->vectorToolBar(); }
QToolBar *QgisAppInterface::databaseToolBar() { return qgis->databaseToolBar(); }
QToolBar *QgisAppInterface::webToolBar() { return qgis->webToolBar(); }

//! File menu actions
//! Project menu actions
QAction *QgisAppInterface::actionNewProject() { return qgis->actionNewProject(); }
QAction *QgisAppInterface::actionOpenProject() { return qgis->actionOpenProject(); }
QAction *QgisAppInterface::actionSaveProject() { return qgis->actionSaveProject(); }
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ class QgisAppInterface : public QgisInterface
*/

//! Menus
virtual QMenu *fileMenu();
Q_DECL_DEPRECATED virtual QMenu *fileMenu();
virtual QMenu *projectMenu();
virtual QMenu *editMenu();
virtual QMenu *viewMenu();
virtual QMenu *layerMenu();
Expand Down Expand Up @@ -309,7 +310,7 @@ class QgisAppInterface : public QgisInterface
virtual QToolBar *databaseToolBar();
virtual QToolBar *webToolBar();

//! File menu actions
//! Project menu actions
virtual QAction *actionNewProject();
virtual QAction *actionOpenProject();
virtual QAction *actionSaveProject();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsconfigureshortcutsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void QgsConfigureShortcutsDialog::keyReleaseEvent( QKeyEvent * event )
{
if ( !mGettingShortcut )
{
QDialog::keyPressEvent( event );
QDialog::keyReleaseEvent( event );
return;
}

Expand Down
165 changes: 105 additions & 60 deletions src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ QgsFieldsProperties::QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent
connect( mAttributesTree, SIGNAL( itemSelectionChanged() ), this, SLOT( onAttributeSelectionChanged() ) );
connect( mAttributesList, SIGNAL( itemSelectionChanged() ), this, SLOT( onAttributeSelectionChanged() ) );

mAttributesList->sortByColumn( 0, Qt::AscendingOrder );
mAttributesTree->setHeaderLabels( QStringList() << tr( "Label" ) );

leEditForm->setText( layer->editForm() );
Expand Down Expand Up @@ -315,7 +316,8 @@ void QgsFieldsProperties::loadRows()

void QgsFieldsProperties::setRow( int row, int idx, const QgsField &field )
{
mAttributesList->setItem( row, attrIdCol, new QTableWidgetItem( QString::number( idx ) ) );
mAttributesList->setItem( row, attrIdCol, new QTableWidgetItem( idx ) );
mIndexedWidgets.insert( idx, mAttributesList->item( row, 0 ) );
mAttributesList->setItem( row, attrNameCol, new QTableWidgetItem( field.name() ) );
mAttributesList->setItem( row, attrTypeCol, new QTableWidgetItem( field.typeName() ) );
mAttributesList->setItem( row, attrLengthCol, new QTableWidgetItem( QString::number( field.length() ) ) );
Expand All @@ -325,10 +327,14 @@ void QgsFieldsProperties::setRow( int row, int idx, const QgsField &field )
for ( int i = 0; i < attrEditTypeCol; i++ )
mAttributesList->item( row, i )->setFlags( mAttributesList->item( row, i )->flags() & ~Qt::ItemIsEditable );

QPushButton *pb = new QPushButton( editTypeButtonText( mLayer->editType( idx ) ) );
FieldConfig cfg( mLayer, idx );
cfg.mEditType = mLayer->editType( idx );
QPushButton *pb = new QPushButton( editTypeButtonText( cfg.mEditType ) );
mAttributesList->setCellWidget( row, attrEditTypeCol, pb );
connect( pb, SIGNAL( pressed() ), this, SLOT( attributeTypeDialog( ) ) );
mButtonMap.insert( idx, pb );

cfg.mButton = pb;
setConfigForRow( row, cfg );

//set the alias for the attribute
mAttributesList->setItem( row, attrAliasCol, new QTableWidgetItem( mLayer->attributeAlias( idx ) ) );
Expand Down Expand Up @@ -455,56 +461,66 @@ void QgsFieldsProperties::attributeTypeDialog()
if ( !pb )
return;

int index = mButtonMap.key( pb, -1 );
FieldConfig cfg;
int index = -1;
int row = -1;

foreach ( QTableWidgetItem* wdg, mIndexedWidgets )
{
cfg = wdg->data( Qt::UserRole ).value<FieldConfig>();
if ( cfg.mButton == pb )
{
index = mIndexedWidgets.indexOf( wdg );
row = wdg->row();
break;
}
}

if ( index == -1 )
return;

QgsAttributeTypeDialog attributeTypeDialog( mLayer );

attributeTypeDialog.setValueMap( mValueMaps.value( index, mLayer->valueMap( index ) ) );
attributeTypeDialog.setRange( mRanges.value( index, mLayer->range( index ) ) );
attributeTypeDialog.setValueRelation( mValueRelationData.value( index, mLayer->valueRelation( index ) ) );
attributeTypeDialog.setValueMap( cfg.mValueMap );
attributeTypeDialog.setRange( cfg.mRange );
attributeTypeDialog.setValueRelation( cfg.mValueRelationData );

QPair<QString, QString> checkStates = mCheckedStates.value( index, mLayer->checkedState( index ) );
QPair<QString, QString> checkStates = cfg.mCheckedState;
attributeTypeDialog.setCheckedState( checkStates.first, checkStates.second );

attributeTypeDialog.setDateFormat( mDateFormat.value( index, mLayer->dateFormat( index ) ) );
attributeTypeDialog.setWidgetSize( mWidgetSize.value( index, mLayer->widgetSize( index ) ) );
attributeTypeDialog.setFieldEditable( mFieldEditables.value( index, mLayer->fieldEditable( index ) ) );
attributeTypeDialog.setDateFormat( cfg.mDateFormat );
attributeTypeDialog.setWidgetSize( cfg.mWidgetSize );
attributeTypeDialog.setFieldEditable( cfg.mEditable );

attributeTypeDialog.setIndex( index, mEditTypeMap.value( index, mLayer->editType( index ) ) );
attributeTypeDialog.setIndex( index, cfg.mEditType );

if ( !attributeTypeDialog.exec() )
return;

QgsVectorLayer::EditType editType = attributeTypeDialog.editType();
mEditTypeMap.insert( index, editType );
cfg.mEditType = attributeTypeDialog.editType();
cfg.mEditable = attributeTypeDialog.fieldEditable();

bool isFieldEditable = attributeTypeDialog.fieldEditable();
mFieldEditables.insert( index, isFieldEditable );

QString buttonText;
switch ( editType )
switch ( cfg.mEditType )
{
case QgsVectorLayer::ValueMap:
mValueMaps.insert( index, attributeTypeDialog.valueMap() );
cfg.mValueMap = attributeTypeDialog.valueMap();
break;
case QgsVectorLayer::EditRange:
case QgsVectorLayer::SliderRange:
case QgsVectorLayer::DialRange:
mRanges.insert( index, attributeTypeDialog.rangeData() );
cfg.mRange = attributeTypeDialog.rangeData();
break;
case QgsVectorLayer::CheckBox:
mCheckedStates.insert( index, attributeTypeDialog.checkedState() );
cfg.mCheckedState = attributeTypeDialog.checkedState();
break;
case QgsVectorLayer::ValueRelation:
mValueRelationData.insert( index, attributeTypeDialog.valueRelationData() );
cfg.mValueRelationData = attributeTypeDialog.valueRelationData();
break;
case QgsVectorLayer::Calendar:
mDateFormat.insert( index, attributeTypeDialog.dateFormat() );
cfg.mDateFormat = attributeTypeDialog.dateFormat();
break;
case QgsVectorLayer::Photo:
mWidgetSize.insert( index, attributeTypeDialog.widgetSize() );
cfg.mWidgetSize = attributeTypeDialog.widgetSize();
break;
case QgsVectorLayer::LineEdit:
case QgsVectorLayer::TextEdit:
Expand All @@ -521,7 +537,9 @@ void QgsFieldsProperties::attributeTypeDialog()
break;
}

pb->setText( editTypeButtonText( editType ) );
setConfigForRow( row, cfg );

pb->setText( editTypeButtonText( cfg.mEditType ) );
}


Expand All @@ -533,11 +551,10 @@ void QgsFieldsProperties::attributeAdded( int idx )
int row = mAttributesList->rowCount();
mAttributesList->insertRow( row );
setRow( row, idx, fields[idx] );
mIndexedWidgets.insert( idx, mAttributesList->item( row, 0 ) );

for ( int i = idx; i < mIndexedWidgets.count(); i++ )
{
mIndexedWidgets[i]->setText( QString::number( i ) );
mIndexedWidgets[i]->setData( Qt::DisplayRole, i );
}

mAttributesList->setCurrentCell( row, idx );
Expand All @@ -551,7 +568,7 @@ void QgsFieldsProperties::attributeDeleted( int idx )
mIndexedWidgets.removeAt( idx );
for ( int i = idx; i < mIndexedWidgets.count(); i++ )
{
mIndexedWidgets[i]->setText( QString::number( i ) );
mIndexedWidgets[i]->setData( Qt::DisplayRole, i );
}
}

Expand Down Expand Up @@ -594,6 +611,36 @@ void QgsFieldsProperties::editingToggled()
updateButtons();
}

QgsFieldsProperties::FieldConfig QgsFieldsProperties::configForRow( int row )
{
foreach ( QTableWidgetItem* wdg , mIndexedWidgets )
{
if ( wdg->row() == row )
{
return wdg->data( Qt::UserRole ).value<FieldConfig>();
}
}

// Should never get here
Q_ASSERT( false );
return FieldConfig();
}

void QgsFieldsProperties::setConfigForRow( int row, QgsFieldsProperties::FieldConfig cfg )
{
foreach ( QTableWidgetItem* wdg , mIndexedWidgets )
{
if ( wdg->row() == row )
{
wdg->setData( Qt::UserRole, QVariant::fromValue<FieldConfig>( cfg ) );
return;
}
}

// Should never get here
Q_ASSERT( false );
}

void QgsFieldsProperties::on_mAddAttributeButton_clicked()
{
QgsAddAttrDialog dialog( mLayer, this );
Expand Down Expand Up @@ -790,63 +837,42 @@ void QgsFieldsProperties::apply()
for ( int i = 0; i < mAttributesList->rowCount(); i++ )
{
int idx = mAttributesList->item( i, attrIdCol )->text().toInt();
FieldConfig cfg = configForRow( i );

QPushButton *pb = qobject_cast<QPushButton *>( mAttributesList->cellWidget( i, attrEditTypeCol ) );
if ( !pb )
continue;

QgsVectorLayer::EditType editType = editTypeFromButtonText( pb->text() );
mLayer->setEditType( idx, editType );
mLayer->setEditType( idx, cfg.mEditType );

if ( mFieldEditables.contains( idx ) )
mLayer->setFieldEditable( idx, mFieldEditables[idx] );
mLayer->setFieldEditable( idx, cfg.mEditable );

switch ( editType )
switch ( cfg.mEditType )
{
case QgsVectorLayer::ValueMap:
if ( mValueMaps.contains( idx ) )
{
QMap<QString, QVariant> &map = mLayer->valueMap( idx );
map.clear();
map = mValueMaps[idx];
}
mLayer->valueMap( idx ) = cfg.mValueMap;
break;

case QgsVectorLayer::EditRange:
case QgsVectorLayer::SliderRange:
case QgsVectorLayer::DialRange:
if ( mRanges.contains( idx ) )
{
mLayer->range( idx ) = mRanges[idx];
}
mLayer->range( idx ) = cfg.mRange;
break;

case QgsVectorLayer::CheckBox:
if ( mCheckedStates.contains( idx ) )
{
mLayer->setCheckedState( idx, mCheckedStates[idx].first, mCheckedStates[idx].second );
}
mLayer->setCheckedState( idx, cfg.mCheckedState.first, cfg.mCheckedState.second );
break;

case QgsVectorLayer::ValueRelation:
if ( mValueRelationData.contains( idx ) )
{
mLayer->valueRelation( idx ) = mValueRelationData[idx];
}
mLayer->valueRelation( idx ) = cfg.mValueRelationData;
break;

case QgsVectorLayer::Calendar:
if ( mDateFormat.contains( idx ) )
{
mLayer->dateFormat( idx ) = mDateFormat[idx];
}
mLayer->dateFormat( idx ) = cfg.mDateFormat;
break;

case QgsVectorLayer::Photo:
if ( mWidgetSize.contains( idx ) )
{
mLayer->widgetSize( idx ) = mWidgetSize[idx];
}
mLayer->widgetSize( idx ) = cfg.mWidgetSize;
break;

case QgsVectorLayer::LineEdit:
Expand Down Expand Up @@ -890,3 +916,22 @@ void QgsFieldsProperties::apply()
mLayer->setExcludeAttributesWMS( excludeAttributesWMS );
mLayer->setExcludeAttributesWFS( excludeAttributesWFS );
}


QgsFieldsProperties::FieldConfig::FieldConfig()
: mButton( NULL )
{
}

QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer* layer, int idx )
: mButton( NULL )
{
mEditable = layer->fieldEditable( idx );
mValueRelationData = layer->valueRelation( idx );
mValueMap = layer->valueMap( idx );
mRange = layer->range( idx );
mCheckedState = layer->checkedState( idx );
mEditType = layer->editType( idx );
mDateFormat = layer->dateFormat( idx );
mWidgetSize = layer->widgetSize( idx );
}
32 changes: 23 additions & 9 deletions src/app/qgsfieldsproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
{
Q_OBJECT

public:
class FieldConfig
{
public:
FieldConfig();
FieldConfig( QgsVectorLayer* layer, int idx );

bool mEditable;
QgsVectorLayer::ValueRelationData mValueRelationData;
QMap<QString, QVariant> mValueMap;
QgsVectorLayer::RangeData mRange;
QPair<QString, QString> mCheckedState;
QgsVectorLayer::EditType mEditType;
QPushButton* mButton;
QString mDateFormat;
QSize mWidgetSize;
};

public:
QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent = 0 );

Expand Down Expand Up @@ -101,19 +119,13 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
void editingToggled();

protected:
FieldConfig configForRow( int row );
void setConfigForRow( int row, FieldConfig cfg );

QgsVectorLayer* mLayer;
QgsAttributesTree* mAttributesTree;
QTableWidget* mAttributesList;

QMap<int, bool> mFieldEditables;
QMap<int, QgsVectorLayer::ValueRelationData> mValueRelationData;
QMap<int, QMap<QString, QVariant> > mValueMaps;
QMap<int, QgsVectorLayer::RangeData> mRanges;
QMap<int, QPair<QString, QString> > mCheckedStates;
QMap<int, QgsVectorLayer::EditType> mEditTypeMap;
QMap<int, QPushButton*> mButtonMap;
QMap<int, QString> mDateFormat;
QMap<int, QSize> mWidgetSize;
// Holds all the first column items (header: id) of the table.
// The index in the list is the fieldIdx, and therefore acts as a mapping
// between fieldIdx and QTableWidgetItem->row()
Expand Down Expand Up @@ -141,4 +153,6 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase

};

Q_DECLARE_METATYPE( QgsFieldsProperties::FieldConfig )

#endif // QGSFIELDSPROPERTIES_H
2 changes: 2 additions & 0 deletions src/app/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ void QgsMapToolCapture::deactivate()
while ( !mSnappingMarkers.isEmpty() )
delete mSnappingMarkers.takeFirst();

stopCapturing();

QgsMapToolEdit::deactivate();
}

Expand Down
2 changes: 0 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#############################################################
# sources

Expand Down
112 changes: 64 additions & 48 deletions src/core/qgsdiagramrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* *
***************************************************************************/
#include "qgsdiagramrendererv2.h"
#include "qgsvectorlayer.h"
#include "diagram/qgstextdiagram.h"
#include "diagram/qgspiediagram.h"
#include "diagram/qgshistogramdiagram.h"
Expand All @@ -21,8 +22,10 @@
#include <QPainter>


void QgsDiagramLayerSettings::readXML( const QDomElement& elem )
void QgsDiagramLayerSettings::readXML( const QDomElement& elem, const QgsVectorLayer* layer )
{
Q_UNUSED( layer )

placement = ( Placement )elem.attribute( "placement" ).toInt();
placementFlags = ( LinePlacementFlags )elem.attribute( "linePlacementFlags" ).toInt();
priority = elem.attribute( "priority" ).toInt();
Expand All @@ -32,8 +35,10 @@ void QgsDiagramLayerSettings::readXML( const QDomElement& elem )
yPosColumn = elem.attribute( "yPosColumn" ).toInt();
}

void QgsDiagramLayerSettings::writeXML( QDomElement& layerElem, QDomDocument& doc ) const
void QgsDiagramLayerSettings::writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const
{
Q_UNUSED( layer )

QDomElement diagramLayerElem = doc.createElement( "DiagramLayerSettings" );
diagramLayerElem.setAttribute( "placement", placement );
diagramLayerElem.setAttribute( "linePlacementFlags", placementFlags );
Expand All @@ -45,7 +50,7 @@ void QgsDiagramLayerSettings::writeXML( QDomElement& layerElem, QDomDocument& do
layerElem.appendChild( diagramLayerElem );
}

void QgsDiagramSettings::readXML( const QDomElement& elem )
void QgsDiagramSettings::readXML( const QDomElement& elem, const QgsVectorLayer* layer )
{
font.fromString( elem.attribute( "font" ) );
backgroundColor.setNamedColor( elem.attribute( "backgroundColor" ) );
Expand Down Expand Up @@ -117,26 +122,44 @@ void QgsDiagramSettings::readXML( const QDomElement& elem )

//colors
categoryColors.clear();
QStringList colorList = elem.attribute( "colors" ).split( "/" );
QStringList::const_iterator colorIt = colorList.constBegin();
for ( ; colorIt != colorList.constEnd(); ++colorIt )
QDomNodeList attributes = elem.elementsByTagName( "attribute" );

if ( attributes.length() > 0 )
{
QColor newColor( *colorIt );
newColor.setAlpha( 255 - transparency );
categoryColors.append( QColor( newColor ) );
for ( uint i = 0; i < attributes.length(); i++ )
{
QDomElement attrElem = attributes.at( i ).toElement();
QColor newColor( attrElem.attribute( "color" ) );
newColor.setAlpha( 255 - transparency );
categoryColors.append( newColor );
categoryIndices.append( layer->fieldNameIndex( attrElem.attribute( "field" ) ) );
}
}

//attribute indices
categoryIndices.clear();
QStringList catList = elem.attribute( "categories" ).split( "/" );
QStringList::const_iterator catIt = catList.constBegin();
for ( ; catIt != catList.constEnd(); ++catIt )
else
{
categoryIndices.append( catIt->toInt() );
// Restore old format attributes and colors

QStringList colorList = elem.attribute( "colors" ).split( "/" );
QStringList::const_iterator colorIt = colorList.constBegin();
for ( ; colorIt != colorList.constEnd(); ++colorIt )
{
QColor newColor( *colorIt );
newColor.setAlpha( 255 - transparency );
categoryColors.append( QColor( newColor ) );
}

//attribute indices
categoryIndices.clear();
QStringList catList = elem.attribute( "categories" ).split( "/" );
QStringList::const_iterator catIt = catList.constBegin();
for ( ; catIt != catList.constEnd(); ++catIt )
{
categoryIndices.append( catIt->toInt() );
}
}
}

void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc ) const
void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const
{
QDomElement categoryElem = doc.createElement( "DiagramCategory" );
categoryElem.setAttribute( "font", font.toString() );
Expand Down Expand Up @@ -209,26 +232,15 @@ void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc
categoryElem.setAttribute( "angleOffset", QString::number( angleOffset ) );

QString colors;
for ( int i = 0; i < categoryColors.size(); ++i )
int nCats = qMin( categoryColors.size(), categoryIndices.size() );
for ( int i = 0; i < nCats; ++i )
{
if ( i > 0 )
{
colors.append( "/" );
}
colors.append( categoryColors.at( i ).name() );
}
categoryElem.setAttribute( "colors", colors );
QDomElement attributeElem = doc.createElement( "attribute" );

QString categories;
for ( int i = 0; i < categoryIndices.size(); ++i )
{
if ( i > 0 )
{
categories.append( "/" );
}
categories.append( QString::number( categoryIndices.at( i ) ) );
attributeElem.setAttribute( "field", layer->pendingFields().at( categoryIndices.at( i ) ).name() );
attributeElem.setAttribute( "color", categoryColors.at( i ).name() );
categoryElem.appendChild( attributeElem );
}
categoryElem.setAttribute( "categories", categories );

rendererElem.appendChild( categoryElem );
}
Expand Down Expand Up @@ -305,8 +317,10 @@ int QgsDiagramRendererV2::dpiPaintDevice( const QPainter* painter )
return -1;
}

void QgsDiagramRendererV2::_readXML( const QDomElement& elem )
void QgsDiagramRendererV2::_readXML( const QDomElement& elem, const QgsVectorLayer* layer )
{
Q_UNUSED( layer )

delete mDiagram;
QString diagramType = elem.attribute( "diagramType" );
if ( diagramType == "Pie" )
Expand All @@ -327,9 +341,11 @@ void QgsDiagramRendererV2::_readXML( const QDomElement& elem )
}
}

void QgsDiagramRendererV2::_writeXML( QDomElement& rendererElem, QDomDocument& doc ) const
void QgsDiagramRendererV2::_writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const
{
Q_UNUSED( doc );
Q_UNUSED( layer )

if ( mDiagram )
{
rendererElem.setAttribute( "diagramType", mDiagram->diagramName() );
Expand Down Expand Up @@ -363,23 +379,23 @@ QList<QgsDiagramSettings> QgsSingleCategoryDiagramRenderer::diagramSettings() co
return settingsList;
}

void QgsSingleCategoryDiagramRenderer::readXML( const QDomElement& elem )
void QgsSingleCategoryDiagramRenderer::readXML( const QDomElement& elem, const QgsVectorLayer* layer )
{
QDomElement categoryElem = elem.firstChildElement( "DiagramCategory" );
if ( categoryElem.isNull() )
{
return;
}

mSettings.readXML( categoryElem );
_readXML( elem );
mSettings.readXML( categoryElem, layer );
_readXML( elem, layer );
}

void QgsSingleCategoryDiagramRenderer::writeXML( QDomElement& layerElem, QDomDocument& doc ) const
void QgsSingleCategoryDiagramRenderer::writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const
{
QDomElement rendererElem = doc.createElement( "SingleCategoryDiagramRenderer" );
mSettings.writeXML( rendererElem, doc );
_writeXML( rendererElem, doc );
mSettings.writeXML( rendererElem, doc, layer );
_writeXML( rendererElem, doc , layer );
layerElem.appendChild( rendererElem );
}

Expand Down Expand Up @@ -421,7 +437,7 @@ QSizeF QgsLinearlyInterpolatedDiagramRenderer::diagramSize( const QgsAttributes&
return mDiagram->diagramSize( attributes, c, mSettings, mInterpolationSettings );
}

void QgsLinearlyInterpolatedDiagramRenderer::readXML( const QDomElement& elem )
void QgsLinearlyInterpolatedDiagramRenderer::readXML( const QDomElement& elem, const QgsVectorLayer* layer )
{
mInterpolationSettings.lowerValue = elem.attribute( "lowerValue" ).toDouble();
mInterpolationSettings.upperValue = elem.attribute( "upperValue" ).toDouble();
Expand All @@ -433,12 +449,12 @@ void QgsLinearlyInterpolatedDiagramRenderer::readXML( const QDomElement& elem )
QDomElement settingsElem = elem.firstChildElement( "DiagramCategory" );
if ( !settingsElem.isNull() )
{
mSettings.readXML( settingsElem );
mSettings.readXML( settingsElem, layer );
}
_readXML( elem );
_readXML( elem, layer );
}

void QgsLinearlyInterpolatedDiagramRenderer::writeXML( QDomElement& layerElem, QDomDocument& doc ) const
void QgsLinearlyInterpolatedDiagramRenderer::writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const
{
QDomElement rendererElem = doc.createElement( "LinearlyInterpolatedDiagramRenderer" );
rendererElem.setAttribute( "lowerValue", QString::number( mInterpolationSettings.lowerValue ) );
Expand All @@ -448,7 +464,7 @@ void QgsLinearlyInterpolatedDiagramRenderer::writeXML( QDomElement& layerElem, Q
rendererElem.setAttribute( "upperWidth", QString::number( mInterpolationSettings.upperSize.width() ) );
rendererElem.setAttribute( "upperHeight", QString::number( mInterpolationSettings.upperSize.height() ) );
rendererElem.setAttribute( "classificationAttribute", mInterpolationSettings.classificationAttribute );
mSettings.writeXML( rendererElem, doc );
_writeXML( rendererElem, doc );
mSettings.writeXML( rendererElem, doc, layer );
_writeXML( rendererElem, doc, layer );
layerElem.appendChild( rendererElem );
}
26 changes: 14 additions & 12 deletions src/core/qgsdiagramrendererv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class QDomElement;
class QgsPalGeometry;
class QgsCoordinateTransform;
class QgsMapToPixel;
class QgsVectorLayer;

namespace pal { class Layer; }

class CORE_EXPORT QgsDiagramLayerSettings
Expand Down Expand Up @@ -88,8 +90,8 @@ class CORE_EXPORT QgsDiagramLayerSettings
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
};

//diagram settings for rendering
Expand Down Expand Up @@ -141,8 +143,8 @@ class CORE_EXPORT QgsDiagramSettings
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;
};

//additional diagram settings for interpolated size rendering
Expand Down Expand Up @@ -181,8 +183,8 @@ class CORE_EXPORT QgsDiagramRendererV2
/**Returns list with all diagram settings in the renderer*/
virtual QList<QgsDiagramSettings> diagramSettings() const = 0;

virtual void readXML( const QDomElement& elem ) = 0;
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc ) const = 0;
virtual void readXML( const QDomElement& elem, const QgsVectorLayer* layer ) = 0;
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const = 0;

protected:

Expand All @@ -203,8 +205,8 @@ class CORE_EXPORT QgsDiagramRendererV2
static int dpiPaintDevice( const QPainter* );

//read / write diagram
void _readXML( const QDomElement& elem );
void _writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
void _readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void _writeXML( QDomElement& rendererElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;

/**Reference to the object that does the real diagram rendering*/
QgsDiagram* mDiagram;
Expand All @@ -225,8 +227,8 @@ class CORE_EXPORT QgsSingleCategoryDiagramRenderer : public QgsDiagramRendererV2

QList<QgsDiagramSettings> diagramSettings() const;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;

protected:
bool diagramSettings( const QgsAttributes&, const QgsRenderContext& c, QgsDiagramSettings& s );
Expand Down Expand Up @@ -267,8 +269,8 @@ class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRend
int classificationAttribute() const { return mInterpolationSettings.classificationAttribute; }
void setClassificationAttribute( int index ) { mInterpolationSettings.classificationAttribute = index; }

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QgsVectorLayer* layer );
void writeXML( QDomElement& layerElem, QDomDocument& doc, const QgsVectorLayer* layer ) const;

protected:
bool diagramSettings( const QgsAttributes&, const QgsRenderContext& c, QgsDiagramSettings& s );
Expand Down
18 changes: 18 additions & 0 deletions src/core/qgslogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class QFile;
if ( QgsLogger::debugLevel() >= (level) && (level) > 0 ) \
QgsLogger::debug(QString(str), (level), __FILE__, __FUNCTION__, __LINE__); \
}
#define QgsDebugCall QgsScopeLogger _qgsScopeLogger(__FILE__, __FUNCTION__, __LINE__)
#else
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif
Expand Down Expand Up @@ -130,4 +132,20 @@ class CORE_EXPORT QgsLogger
static int sPrefixLength;
};

class QgsScopeLogger {
public:
QgsScopeLogger(const char* file, const char* func, int line)
: _file(file), _func(func), _line(line)
{
QgsLogger::debug("Entering.", 1, _file, _func, _line);
}
~QgsScopeLogger() {
QgsLogger::debug("Leaving.", 1, _file, _func, _line);
}
private:
const char *_file;
const char *_func;
int _line;
};

#endif
28 changes: 14 additions & 14 deletions src/core/qgsmaplayerregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ QList<QgsMapLayer *> QgsMapLayerRegistry::mapLayersByName( QString layerName )
//introduced in 1.8
QList<QgsMapLayer *> QgsMapLayerRegistry::addMapLayers(
QList<QgsMapLayer *> theMapLayers,
bool addToLegend )
bool addToLegend,
bool takeOwnership )
{
QList<QgsMapLayer *> myResultList;
for ( int i = 0; i < theMapLayers.size(); ++i )
Expand All @@ -85,14 +86,12 @@ QList<QgsMapLayer *> QgsMapLayerRegistry::addMapLayers(
continue;
}
//check the layer is not already registered!
QMap<QString, QgsMapLayer*>::iterator myIterator =
mMapLayers.find( myLayer->id() );
//if myIterator returns mMapLayers.end() then it
//does not exist in registry and its safe to add it
if ( myIterator == mMapLayers.end() )
if ( !mMapLayers.contains( myLayer->id() ) )
{
mMapLayers[myLayer->id()] = myLayer;
myResultList << mMapLayers[myLayer->id()];
if ( takeOwnership )
mOwnedLayers << myLayer;
emit layerWasAdded( myLayer );
}
}
Expand All @@ -109,10 +108,11 @@ QList<QgsMapLayer *> QgsMapLayerRegistry::addMapLayers(
//this is just a thin wrapper for addMapLayers
QgsMapLayer *
QgsMapLayerRegistry::addMapLayer( QgsMapLayer* theMapLayer,
bool addToLegend )
bool addToLegend,
bool takeOwnership )
{
QList<QgsMapLayer *> addedLayers;
addedLayers = addMapLayers( QList<QgsMapLayer*>() << theMapLayer, addToLegend );
addedLayers = addMapLayers( QList<QgsMapLayer*>() << theMapLayer, addToLegend, takeOwnership );
return addedLayers.isEmpty() ? 0 : addedLayers[0];
}

Expand All @@ -124,17 +124,17 @@ void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds )

foreach ( const QString &myId, theLayerIds )
{
QgsMapLayer* lyr = mMapLayers[myId];
emit layerWillBeRemoved( myId );
delete mMapLayers[myId];
if ( mOwnedLayers.contains( lyr ) )
{
delete lyr;
mOwnedLayers.remove( lyr );
}
mMapLayers.remove( myId );
}
}

void QgsMapLayerRegistry::clearMapLayers()
{
mMapLayers.clear();
} // QgsMapLayerRegistry::clearMapLayers()

void QgsMapLayerRegistry::removeMapLayer( const QString& theLayerId )
{
removeMapLayers( QStringList( theLayerId ) );
Expand Down
31 changes: 15 additions & 16 deletions src/core/qgsmaplayerregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define QGSMAPLAYERREGISTRY_H

#include <QMap>
#include <QSet>
#include <QObject>
#include <QStringList>
class QString;
Expand Down Expand Up @@ -58,10 +59,13 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* The layersAdded() and layersWasAdded() signals will be emitted in any case.
* The legendLayersAdded() signal only if addToLegend is true.
*
* @param theMapLayers A list of layer which should be added to the registry
* @param addToLegend If true (by default), the layers will be added to the
* legend and to the main canvas. If you have a private
* layer, you can set this parameter to false to hide it.
* @param theMapLayers A list of layer which should be added to the registry
* @param addToLegend If true (by default), the layers will be added to the
* legend and to the main canvas. If you have a private
* layer, you can set this parameter to false to hide it.
* @param takeOwnership Ownership will be transferred to the layer registry.
* If you specify false here, you have take care of deleting
* the layers yourself. Not available in python.
*
* @return QList<QgsMapLayer *> - a list of the map layers that were added
* successfully. If a layer is invalid, or already exists in the registry,
Expand All @@ -71,7 +75,8 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* @note Added in QGIS 1.8
*/
QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
bool addToLegend = true );
bool addToLegend = true,
bool takeOwnership = true );

/**
* @brief
Expand All @@ -86,6 +91,9 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* @param addToLegend If true (by default), the layer will be added to the
* legend and to the main canvas. If you have a private
* you can set this parameter to false to hide it.
* @param takeOwnership Ownership will be transferred to the layer registry.
* If you specify false here, you have take care of deleting
* the layer yourself. Not available in python.
*
* @return NULL if unable to add layer, otherwise pointer to newly added layer
*
Expand All @@ -94,17 +102,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* @note As a side-effect QgsProject is made dirty.
* @note Use addMapLayers if adding more than one layer at a time
*/
QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer, bool addToLegend = true );

/**
* @brief
* Clears the map layer registry silently. No signals are emitted,
* no layer is deleted. Whatever this is suitable for... The WMS
* server makes use of this.
*
* Not available in python
*/
void clearMapLayers();
QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer, bool addToLegend = true, bool takeOwnership = true );

/**
* @brief
Expand Down Expand Up @@ -230,6 +228,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
static QgsMapLayerRegistry* mInstance;

QMap<QString, QgsMapLayer*> mMapLayers;
QSet<QgsMapLayer*> mOwnedLayers;

/** debugging member
invoked when a connect() is made to this object
Expand Down
58 changes: 35 additions & 23 deletions src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,12 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
}

QSettings mySettings;
bool useRenderCaching = false;
if ( ! split )//render caching does not yet cater for split extents
{
if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
{
useRenderCaching = true;
if ( !mySameAsLastFlag || ml->cacheImage() == 0 )
{
QgsDebugMsg( "Caching enabled but layer redraw forced by extent change or empty cache" );
Expand Down Expand Up @@ -522,10 +524,10 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
if (( mRenderContext.useAdvancedEffects() ) && ( ml->type() == QgsMapLayer::VectorLayer ) )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
if (( vl->blendMode() != QPainter::CompositionMode_SourceOver && ( split || !mySettings.value( "/qgis/enable_render_caching", false ).toBool() ) )
|| ( vl->featureBlendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->layerTransparency() != 0 ) )

if (( !useRenderCaching )
&& (( vl->blendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->featureBlendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->layerTransparency() != 0 ) ) )
{
flattenedLayer = true;
mypFlattenedImage = new QImage( mRenderContext.painter()->device()->width(),
Expand All @@ -538,9 +540,18 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
}
mypPainter->scale( rasterScaleFactor, rasterScaleFactor );
mRenderContext.setPainter( mypPainter );
}
}

// set the painter to the feature blend mode
mypPainter->setCompositionMode( vl->featureBlendMode() );
// Per feature blending mode
if (( mRenderContext.useAdvancedEffects() ) && ( ml->type() == QgsMapLayer::VectorLayer ) )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
if ( vl->featureBlendMode() != QPainter::CompositionMode_SourceOver )
{
// set the painter to the feature blend mode, so that features drawn
// on this layer will interact and blend with each other
mRenderContext.painter()->setCompositionMode( vl->featureBlendMode() );
}
}

Expand Down Expand Up @@ -579,22 +590,8 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
mRenderContext.painter()->restore();
}

if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
{
if ( !split )
{
// composite the cached image into our view and then clean up from caching
// by reinstating the painter as it was swapped out for caching renders
delete mRenderContext.painter();
mRenderContext.setPainter( mypContextPainter );
//draw from cached image that we created further up
if ( ml->cacheImage() )
mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
}
}

// If we flattened this layer for alternate blend modes, composite it now
if ( flattenedLayer )
//apply layer transparency for vector layers
if (( mRenderContext.useAdvancedEffects() ) && ( ml->type() == QgsMapLayer::VectorLayer ) )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
if ( vl->layerTransparency() != 0 )
Expand All @@ -604,9 +601,24 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
QColor transparentFillColor = QColor( 0, 0, 0, 255 - ( 255 * vl->layerTransparency() / 100 ) );
// use destination in composition mode to merge source's alpha with destination
mRenderContext.painter()->setCompositionMode( QPainter::CompositionMode_DestinationIn );
mRenderContext.painter()->fillRect( mypFlattenedImage->rect(), transparentFillColor );
mRenderContext.painter()->fillRect( 0, 0, mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), transparentFillColor );
}
}

if ( useRenderCaching )
{
// composite the cached image into our view and then clean up from caching
// by reinstating the painter as it was swapped out for caching renders
delete mRenderContext.painter();
mRenderContext.setPainter( mypContextPainter );
//draw from cached image that we created further up
if ( ml->cacheImage() )
mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
}
else if ( flattenedLayer )
{
// If we flattened this layer for alternate blend modes, composite it now
delete mRenderContext.painter();
mRenderContext.setPainter( mypContextPainter );
mypContextPainter->save();
Expand Down
73 changes: 50 additions & 23 deletions src/core/qgsofflineediting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <qgsofflineediting.h>
#include <qgsproject.h>
#include <qgsvectordataprovider.h>
#include <qgsvectorlayereditbuffer.h>

#include <QDir>
#include <QDomDocument>
Expand Down Expand Up @@ -522,8 +523,8 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
// NOTE: Spatialite provider ignores position of geometry column
// fill gap in QgsAttributeMap if geometry column is not last (WORKAROUND)
int column = 0;
QgsAttributes newAttrs;
QgsAttributes attrs = f.attributes();
QgsAttributes newAttrs( attrs.count() );
for ( int it = 0; it < attrs.count(); ++it )
{
newAttrs[column++] = attrs[it];
Expand Down Expand Up @@ -551,10 +552,10 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con

// NOTE: insert fids in this loop, as the db is locked during newLayer->nextFeature()
sqlExec( db, "BEGIN" );
for ( int i = 0; i < remoteFeatureIds.size(); i++ )
int remoteCount = remoteFeatureIds.size();
for ( int i = 0; i < remoteCount; i++ )
{
addFidLookup( db, layerId, offlineFeatureIds.at( i ), remoteFeatureIds.at( i ) );

addFidLookup( db, layerId, offlineFeatureIds.at( i ), remoteFeatureIds.at( remoteCount - ( i + 1 ) ) );
emit progressUpdated( featureCount++ );
}
sqlExec( db, "COMMIT" );
Expand Down Expand Up @@ -1024,25 +1025,6 @@ QgsOfflineEditing::GeometryChanges QgsOfflineEditing::sqlQueryGeometryChanges( s
return values;
}

void QgsOfflineEditing::layerAdded( QgsMapLayer* layer )
{
// detect offline layer
if ( layer->customProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, false ).toBool() )
{
// enable logging
connect( layer, SIGNAL( committedAttributesAdded( const QString&, const QList<QgsField>& ) ),
this, SLOT( committedAttributesAdded( const QString&, const QList<QgsField>& ) ) );
connect( layer, SIGNAL( committedFeaturesAdded( const QString&, const QgsFeatureList& ) ),
this, SLOT( committedFeaturesAdded( const QString&, const QgsFeatureList& ) ) );
connect( layer, SIGNAL( committedFeaturesRemoved( const QString&, const QgsFeatureIds& ) ),
this, SLOT( committedFeaturesRemoved( const QString&, const QgsFeatureIds& ) ) );
connect( layer, SIGNAL( committedAttributeValuesChanges( const QString&, const QgsChangedAttributesMap& ) ),
this, SLOT( committedAttributeValuesChanges( const QString&, const QgsChangedAttributesMap& ) ) );
connect( layer, SIGNAL( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ),
this, SLOT( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ) );
}
}

void QgsOfflineEditing::committedAttributesAdded( const QString& qgisLayerId, const QList<QgsField>& addedAttributes )
{
sqlite3* db = openLoggingDb();
Expand Down Expand Up @@ -1204,3 +1186,48 @@ void QgsOfflineEditing::committedGeometriesChanges( const QString& qgisLayerId,
increaseCommitNo( db );
sqlite3_close( db );
}

void QgsOfflineEditing::startListenFeatureChanges()
{
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer *>( sender() );
// enable logging
connect( vLayer->editBuffer(), SIGNAL( committedAttributesAdded( const QString&, const QList<QgsField>& ) ),
this, SLOT( committedAttributesAdded( const QString&, const QList<QgsField>& ) ) );
connect( vLayer, SIGNAL( committedFeaturesAdded( const QString&, const QgsFeatureList& ) ),
this, SLOT( committedFeaturesAdded( const QString&, const QgsFeatureList& ) ) );
connect( vLayer, SIGNAL( committedFeaturesRemoved( const QString&, const QgsFeatureIds& ) ),
this, SLOT( committedFeaturesRemoved( const QString&, const QgsFeatureIds& ) ) );
connect( vLayer->editBuffer(), SIGNAL( committedAttributeValuesChanges( const QString&, const QgsChangedAttributesMap& ) ),
this, SLOT( committedAttributeValuesChanges( const QString&, const QgsChangedAttributesMap& ) ) );
connect( vLayer->editBuffer(), SIGNAL( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ),
this, SLOT( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ) );
}

void QgsOfflineEditing::stopListenFeatureChanges()
{
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer *>( sender() );
// disable logging
disconnect( vLayer->editBuffer(), SIGNAL( committedAttributesAdded( const QString&, const QList<QgsField>& ) ),
this, SLOT( committedAttributesAdded( const QString&, const QList<QgsField>& ) ) );
disconnect( vLayer, SIGNAL( committedFeaturesAdded( const QString&, const QgsFeatureList& ) ),
this, SLOT( committedFeaturesAdded( const QString&, const QgsFeatureList& ) ) );
disconnect( vLayer, SIGNAL( committedFeaturesRemoved( const QString&, const QgsFeatureIds& ) ),
this, SLOT( committedFeaturesRemoved( const QString&, const QgsFeatureIds& ) ) );
disconnect( vLayer->editBuffer(), SIGNAL( committedAttributeValuesChanges( const QString&, const QgsChangedAttributesMap& ) ),
this, SLOT( committedAttributeValuesChanges( const QString&, const QgsChangedAttributesMap& ) ) );
disconnect( vLayer->editBuffer(), SIGNAL( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ),
this, SLOT( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ) );
}

void QgsOfflineEditing::layerAdded( QgsMapLayer* layer )
{
// detect offline layer
if ( layer->customProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, false ).toBool() )
{
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer *>( layer );
connect( vLayer, SIGNAL( editingStarted() ), this, SLOT( startListenFeatureChanges() ) );
connect( vLayer, SIGNAL( editingStopped() ), this, SLOT( stopListenFeatureChanges() ) );
}
}


2 changes: 2 additions & 0 deletions src/core/qgsofflineediting.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class CORE_EXPORT QgsOfflineEditing : public QObject
void committedFeaturesRemoved( const QString& qgisLayerId, const QgsFeatureIds& deletedFeatureIds );
void committedAttributeValuesChanges( const QString& qgisLayerId, const QgsChangedAttributesMap& changedAttrsMap );
void committedGeometriesChanges( const QString& qgisLayerId, const QgsGeometryMap& changedGeometries );
void startListenFeatureChanges();
void stopListenFeatureChanges();
};

#endif // QGS_OFFLINE_EDITING_H
28 changes: 13 additions & 15 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ QgsPalLayerSettings::QgsPalLayerSettings()

// text buffer
bufferDraw = false;
bufferDrawOld = false; // on when old style buffer triggered by just size is found
bufferSize = 1.0;
bufferSizeInMapUnits = false;
bufferColor = Qt::white;
Expand Down Expand Up @@ -755,6 +754,13 @@ void QgsPalLayerSettings::readDataDefinedProperty( QgsVectorLayer* layer,
{
//upgrade any existing property to field name-based
layer->setCustomProperty( newPropertyName, QVariant( updateDataDefinedString( ddString ) ) );

// fix for buffer drawing triggered off of just its data defined size in the past (<2.0)
if ( oldIndx == 7 ) // old bufferSize enum
{
bufferDraw = true;
layer->setCustomProperty( "labeling/bufferDraw", true );
}
}

// remove old-style field index-based property
Expand Down Expand Up @@ -849,7 +855,6 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )

// fix for buffer being keyed off of just its size in the past
QVariant drawBuffer = layer->customProperty( "labeling/bufferDraw", QVariant() );
bufferDrawOld = !drawBuffer.isValid();
if ( drawBuffer.isValid() )
{
bufferDraw = drawBuffer.toBool();
Expand Down Expand Up @@ -1401,7 +1406,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t

if ( wrapchr.isEmpty() )
{
wrapchr = QString( "\n" ); // default to new line delimeter
wrapchr = QString( "\n" ); // default to new line delimiter
}

//consider the space needed for the direction symbol
Expand Down Expand Up @@ -2511,25 +2516,18 @@ void QgsPalLayerSettings::parseTextBuffer()
drawBuffer = exprVal.toBool();
}

if ( !drawBuffer )
{
return;
}

// data defined buffer size?
double bufrSize = bufferSize;
if ( dataDefinedValEval( "doublepos", QgsPalLayerSettings::BufferSize, exprVal ) )
{
bufrSize = exprVal.toDouble();
}

// FIXME: find better solution for temporarily turning on buffer, when previously defined by size
// fix for buffer being keyed off of just its size in the past
// if ( bufrSize > 0.0 && bufferDrawOld )
// {
// drawBuffer = bufferDraw = true;
// }

if ( !drawBuffer )
{
return;
}

// data defined buffer transparency?
int bufTransp = bufferTransp;
if ( dataDefinedValEval( "transp", QgsPalLayerSettings::BufferTransp, exprVal ) )
Expand Down
1 change: 0 additions & 1 deletion src/core/qgspallabeling.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ class CORE_EXPORT QgsPalLayerSettings
//-- text buffer

bool bufferDraw;
bool bufferDrawOld; // on when old style buffer triggered by just size is found
double bufferSize; // buffer size
bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
QColor bufferColor;
Expand Down
30 changes: 15 additions & 15 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,19 +814,19 @@ void QgsVectorLayer::invertSelection()

void QgsVectorLayer::selectAll()
{
QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
.setFlags( QgsFeatureRequest::NoGeometry )
.setSubsetOfAttributes( QgsAttributeList() ) );
QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
.setFlags( QgsFeatureRequest::NoGeometry )
.setSubsetOfAttributes( QgsAttributeList() ) );

QgsFeatureIds ids;
QgsFeatureIds ids;

QgsFeature fet;
while ( fit.nextFeature( fet ) )
{
ids << fet.id();
}
QgsFeature fet;
while ( fit.nextFeature( fet ) )
{
ids << fet.id();
}

setSelectedFeatures( ids );
setSelectedFeatures( ids );
}

void QgsVectorLayer::invertSelectionInRectangle( QgsRectangle & rect )
Expand Down Expand Up @@ -1830,13 +1830,13 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
if ( !singleCatDiagramElem.isNull() )
{
mDiagramRenderer = new QgsSingleCategoryDiagramRenderer();
mDiagramRenderer->readXML( singleCatDiagramElem );
mDiagramRenderer->readXML( singleCatDiagramElem, this );
}
QDomElement linearDiagramElem = node.firstChildElement( "LinearlyInterpolatedDiagramRenderer" );
if ( !linearDiagramElem.isNull() )
{
mDiagramRenderer = new QgsLinearlyInterpolatedDiagramRenderer();
mDiagramRenderer->readXML( linearDiagramElem );
mDiagramRenderer->readXML( linearDiagramElem, this );
}

if ( mDiagramRenderer )
Expand All @@ -1845,7 +1845,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
if ( !diagramSettingsElem.isNull() )
{
mDiagramLayerSettings = new QgsDiagramLayerSettings();
mDiagramLayerSettings->readXML( diagramSettingsElem );
mDiagramLayerSettings->readXML( diagramSettingsElem, this );
}
}
}
Expand Down Expand Up @@ -2168,9 +2168,9 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&

if ( mDiagramRenderer )
{
mDiagramRenderer->writeXML( mapLayerNode, doc );
mDiagramRenderer->writeXML( mapLayerNode, doc, this );
if ( mDiagramLayerSettings )
mDiagramLayerSettings->writeXML( mapLayerNode, doc );
mDiagramLayerSettings->writeXML( mapLayerNode, doc, this );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterprojector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void QgsRasterProjector::calcSrcExtent()
// align extent to src resolution to avoid jumping of reprojected pixels
// when shifting resampled grid.
// Important especially if we are over mMaxSrcXRes, mMaxSrcYRes limits
// Note however, that preceeding filters (like resampler) may read data
// Note however, that preceding filters (like resampler) may read data
// on different resolution.

QgsDebugMsg( "mSrcExtent = " + mSrcExtent.toString() );
Expand Down
Loading