228 changes: 106 additions & 122 deletions python/plugins/fTools/tools/doEliminate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(self, iface):
self.setupUi(self)
QtCore.QObject.connect(self.toolOut, QtCore.SIGNAL("clicked()"), self.outFile)
QtCore.QObject.connect(self.inShape, QtCore.SIGNAL("currentIndexChanged(QString)"), self.update)
QtCore.QObject.connect(self.writeShapefileCheck, QtCore.SIGNAL("stateChanged(int)"), self.on_writeShapefileCheck_stateChanged)
self.setWindowTitle(self.tr("Eliminate sliver polygons"))
self.buttonOk = self.buttonBox_2.button(QtGui.QDialogButtonBox.Ok)
# populate layer list
Expand All @@ -53,43 +52,34 @@ def __init__(self, iface):
if len(layers) > 0:
self.update(layers[0])

self.on_writeShapefileCheck_stateChanged(self.writeShapefileCheck.checkState())

def update(self, inputLayer):
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
selFeatures = changedLayer.selectedFeatureCount()
self.selected.setText( self.tr("Selected features: %1").arg(selFeatures))

def on_writeShapefileCheck_stateChanged(self, newState):
doEnable = (newState == 2)
self.outShape.setEnabled(doEnable)
self.toolOut.setEnabled(doEnable)
self.addToCanvasCheck.setEnabled(doEnable)

def accept(self):
self.buttonOk.setEnabled(False)

if self.inShape.currentText() == "":
QtGui.QMessageBox.information(self, self.tr("Eliminate"), self.tr("No input shapefile specified"))
else:
outFileName = self.outShape.text()

if self.writeShapefileCheck.isChecked():
outFileName = self.outShape.text()

if outFileName == "":
QtGui.MessageBox.information(self, self.tr("Eliminate"), self.tr("Please specify output shapefile"))
else:
outFile = QtCore.QFile(outFileName)
if outFileName == "":
QtGui.QMessageBox.information(self, self.tr("Eliminate"), self.tr("Please specify output shapefile"))
self.buttonOk.setEnabled(True)
return None
else:
outFile = QtCore.QFile(outFileName)

if outFile.exists():
if not QgsVectorFileWriter.deleteShapeFile(outFileName):
QtGui.QMessageBox.warning(self, self.tr("Delete error"),
self.tr("Can't delete file %1").arg(outFileName))
return
if outFile.exists():
if not QgsVectorFileWriter.deleteShapeFile(outFileName):
QtGui.QMessageBox.warning(self, self.tr("Delete error"),
self.tr("Can't delete file %1").arg(outFileName))
self.buttonOk.setEnabled(True)
return None

outFileName = unicode(outFileName)
else:
outFileName = None
outFileName = unicode(outFileName)

inLayer = ftools_utils.getVectorLayerByName(unicode(self.inShape.currentText()))

Expand All @@ -109,13 +99,23 @@ def outFile(self):
self.outShape.clear()
(outFileName, self.encoding) = ftools_utils.saveDialog(self)
if outFileName is None or self.encoding is None:
return
return None
self.outShape.setText(outFileName)

def eliminate(self, inLayer, boundary, progressBar, outFileName = None):
def saveChanges(self, outLayer):
if outLayer.commitChanges():
return True
else:
msg = ""
for aStrm in outLayer.commitErrors():
msg = msg + "\n" + aStrm
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Commit error:\n %1").arg(msg))
outLayer.rollBack()
return False

def eliminate(self, inLayer, boundary, progressBar, outFileName):
# keep references to the features to eliminate
fidsToEliminate = inLayer.selectedFeaturesIds()
fidsToProcess = inLayer.selectedFeaturesIds()

if outFileName: # user wants a new shape file to be created as result
provider = inLayer.dataProvider()
Expand All @@ -128,12 +128,20 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName = None):
outLayer = QgsVectorLayer(outFileName, QtCore.QFileInfo(outFileName).completeBaseName(), "ogr")

else:
outLayer = inLayer
outLayer.removeSelection(False)
QtGui.QMessageBox.information(self, self.tr("Eliminate"), self.tr("Please specify output shapefile"))
return None

# delete features to be eliminated in outLayer
outLayer.setSelectedFeatures(fidsToEliminate)
outLayer.startEditing()
doCommit = True

if outLayer.deleteSelectedFeatures():
if self.saveChanges(outLayer):
outLayer.startEditing()
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Could not delete features"))
return None

# ANALYZE
start = 20.00
progressBar.setValue(start)
Expand All @@ -144,103 +152,92 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName = None):

# we go through the list and see if we find any polygons we can merge the selected with
# if we have no success with some we merge and then restart the whole story
while (lastLen != len(fidsToProcess)): #check if we made any progress
lastLen = len(fidsToProcess)
fidsNotEliminated = []
fidsToDelete = []
while (lastLen != inLayer.selectedFeatureCount()): #check if we made any progress
lastLen = inLayer.selectedFeatureCount()
fidsToDeselect = []

#iterate over the polygons to eliminate
for fid in fidsToProcess:
for fid2Eliminate in inLayer.selectedFeaturesIds():
feat = QgsFeature()

if outLayer.featureAtId(fid, feat, True, False):
geom = feat.geometry()
bbox = geom.boundingBox()
if inLayer.featureAtId(fid2Eliminate, feat, True, False):
geom2Eliminate = feat.geometry()
bbox = geom2Eliminate.boundingBox()
outLayer.select(bbox, False) # make a new selection
mergeWithFid = None
mergeWithGeom = None
max = 0

for selFid in outLayer.selectedFeaturesIds():
if fid != selFid:
#check if this feature is to be eliminated, too
try:
found = fidsToEliminate.index(selFid)
except ValueError: #selFid is not in fidsToEliminate
# check whether the geometry to eliminate and the other geometry intersect
selFeat = QgsFeature()

if outLayer.featureAtId(selFid, selFeat, True, False):
selGeom = selFeat.geometry()

if geom.intersects(selGeom): # we have a candidate
iGeom = geom.intersection(selGeom)

if boundary:
selValue = iGeom.length()
else:
# we need a common boundary
if 0 < iGeom.length():
selValue = selGeom.area()
else:
selValue = 0

if selValue > max:
max = selValue
mergeWithFid = selFid
mergeWithGeom = QgsGeometry(selGeom) # deep copy of the geometry

selFeat = QgsFeature()

if outLayer.featureAtId(selFid, selFeat, True, False):
selGeom = selFeat.geometry()

if geom2Eliminate.intersects(selGeom): # we have a candidate
iGeom = geom2Eliminate.intersection(selGeom)

if boundary:
selValue = iGeom.length()
else:
# we need a common boundary
if 0 < iGeom.length():
selValue = selGeom.area()
else:
selValue = 0

if selValue > max:
max = selValue
mergeWithFid = selFid
mergeWithGeom = QgsGeometry(selGeom) # deep copy of the geometry

if mergeWithFid != None: # a successful candidate
try:
geomList = geomsToMerge[mergeWithFid]
except KeyError:
geomList = [mergeWithGeom]
newGeom = mergeWithGeom.combine(geom2Eliminate)

geomList.append(QgsGeometry(geom)) # deep copy of the geom
geomsToMerge[mergeWithFid] = geomList
fidsToDelete.append(fid)
if outLayer.changeGeometry(mergeWithFid, newGeom):
# write change back to disc
if self.saveChanges(outLayer):
outLayer.startEditing()
else:
return None

# mark feature as eliminated in inLayer
fidsToDeselect.append(fid2Eliminate)
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"),
self.tr("Could not replace geometry of feature with id %1").arg( mergeWithFid ))
return None

start = start + add
progressBar.setValue(start)
else:
fidsNotEliminated.append(fid)
# end for fid2Eliminate

# PROCESS
for aFid in geomsToMerge.iterkeys():
geomList = geomsToMerge[aFid]
# deselect features that are already eliminated in inLayer
for aFid in fidsToDeselect:
inLayer.deselect(aFid, False)

#end while

if len(geomList) > 1:
for i in range(len(geomList)):
aGeom = geomList[i]
if inLayer.selectedFeatureCount() > 0:
# copy all features that could not be eliminated to outLayer
if outLayer.addFeatures(inLayer.selectedFeatures()):
# inform user
fidList = QtCore.QString()

if i == 0:
newGeom = aGeom
else:
newGeom = newGeom.combine(aGeom)

# replace geometry in outLayer
if not outLayer.changeGeometry(aFid, newGeom):
QtGui.QMessageBox.warning(self, self.tr("Eliminate"),
self.tr("Could not replace geometry of feature with id %1").arg( aFid ))
doCommit = False
break

# delete eliminated features
for aFid in fidsToDelete:
if not outLayer.deleteFeature(aFid):
QtGui.QMessageBox.warning(self, self.tr("Eliminate"),
self.tr("Could not delete feature with id %1").arg( aFid ))
doCommit = False
break
# prepare array for the next loop
fidsToProcess = fidsNotEliminated

# SAVE CHANGES
if doCommit:
if not outLayer.commitChanges():
QtGui.QMessageBox.warning(self, self.tr("Commit error"), self.tr("Commit error"))
else:
outLayer.rollBack()
for fid in inLayer.selectedFeaturesIds():
if not fidList.isEmpty():
fidList.append(", ")

fidList.append(str(fid))

QtGui.QMessageBox.information(self, self.tr("Eliminate"),
self.tr("Could not eliminate features with these ids:\n%1").arg(fidList))
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Could not add features"))

# stop editing outLayer and commit any pending changes
if not self.saveChanges(outLayer):
return None

if outFileName:
if self.addToCanvasCheck.isChecked():
Expand All @@ -249,17 +246,4 @@ def eliminate(self, inLayer, boundary, progressBar, outFileName = None):
QtGui.QMessageBox.information(self, self.tr("Eliminate"),
self.tr("Created output shapefile:\n%1").arg(outFileName))

# inform user
if len(fidsNotEliminated) > 0:
fidList = QtCore.QString()

for fid in fidsNotEliminated:
if not fidList.isEmpty():
fidList.append(", ")

fidList.append(str(fid))

QtGui.QMessageBox.information(self, self.tr("Eliminate"),
self.tr("Could not eliminate features with these ids:\n%1").arg(fidList))

self.iface.mapCanvas().refresh()
96 changes: 50 additions & 46 deletions python/plugins/fTools/tools/frmEliminate.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,30 @@
<rect>
<x>0</x>
<y>0</y>
<width>377</width>
<height>243</height>
<width>436</width>
<height>218</height>
</rect>
</property>
<property name="windowTitle">
<string>Eliminate sliver polygons</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<widget class="QRadioButton" name="area">
<property name="text">
<string>area</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="selected">
<property name="text">
<string>Selected features:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Input vector layer</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QRadioButton" name="boundary">
<property name="text">
<string>common boundary</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Merge selection with the neighbouring polygon with the largest</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="inShape"/>
</item>
<item row="6" column="0" colspan="3">
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="writeShapefileCheck">
<property name="text">
<string>Save to new file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="outShape">
<property name="readOnly">
Expand All @@ -77,14 +46,17 @@
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="addToCanvasCheck">
<property name="text">
<string>Add result to canvas</string>
<item row="7" column="1">
<widget class="QDialogButtonBox" name="buttonBox_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="7" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
Expand All @@ -94,13 +66,45 @@
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QDialogButtonBox" name="buttonBox_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Input vector layer</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="inShape">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="addToCanvasCheck">
<property name="text">
<string>Add result to canvas</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="selected">
<property name="text">
<string>Selected features:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="area">
<property name="text">
<string>area</string>
</property>
</widget>
</item>
Expand Down
14 changes: 12 additions & 2 deletions python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,29 @@
"""

from PyQt4.QtCore import QCoreApplication,QLocale, QString
from qgis.core import QGis, QgsExpression
from PyQt4.QtCore import QCoreApplication, QLocale, QString
from qgis.core import QGis, QgsExpression, QgsMessageLog
from string import Template
import sys
import traceback
import glob
import os.path
import re
import ConfigParser
import warnings

#######################
# ERROR HANDLING

warnings.simplefilter('default')

def showWarning(message, category, filename, lineno, file=None, line=None):
QgsMessageLog.logMessage(
warnings.formatwarning(message, category, filename, lineno),
QCoreApplication.translate( "Python", "Python" )
)
warnings.showwarning = showWarning

def showException(type, value, tb, msg):
lst = traceback.format_exception(type, value, tb)
if msg == None:
Expand Down
22 changes: 22 additions & 0 deletions src/app/composer/qgscomposerlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"
#include <QFontDialog>
#include <QColorDialog>

#include "qgsapplegendinterface.h"
#include "qgisapp.h"
Expand Down Expand Up @@ -337,6 +338,27 @@ void QgsComposerLegendWidget::on_mItemFontButton_clicked()
}
}

void QgsComposerLegendWidget::on_mFontColorPushButton_clicked()
{
if ( !mLegend )
{
return;
}

QColor oldColor = mLegend->fontColor();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mLegend->beginCommand( tr( "Legend font color changed" ) );
mLegend->setFontColor( newColor );
mLegend->update();
mLegend->endCommand();
}

void QgsComposerLegendWidget::on_mBoxSpaceSpinBox_valueChanged( double d )
{
if ( mLegend )
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposerlegendwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class QgsComposerLegendWidget: public QWidget, private Ui::QgsComposerLegendWidg
void on_mGroupFontButton_clicked();
void on_mLayerFontButton_clicked();
void on_mItemFontButton_clicked();
void on_mFontColorPushButton_clicked();
void on_mBoxSpaceSpinBox_valueChanged( double d );
void on_mColumnSpaceSpinBox_valueChanged( double d );
void on_mCheckBoxAutoUpdate_stateChanged( int state );
Expand Down
50 changes: 49 additions & 1 deletion src/app/composer/qgscomposerscalebarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void QgsComposerScaleBarWidget::on_mLineWidthSpinBox_valueChanged( double d )

mComposerScaleBar->beginCommand( tr( "Scalebar line width" ), QgsComposerMergeCommand::ScaleBarLineWidth );
disconnectUpdateSignal();
QPen newPen( QColor( 0, 0, 0 ) );
QPen newPen( mComposerScaleBar->pen().color() );
newPen.setWidthF( d );
mComposerScaleBar->setPen( newPen );
mComposerScaleBar->update();
Expand Down Expand Up @@ -297,6 +297,29 @@ void QgsComposerScaleBarWidget::on_mFontButton_clicked()
mComposerScaleBar->update();
}

void QgsComposerScaleBarWidget::on_mFontColorPushButton_clicked()
{
if ( !mComposerScaleBar )
{
return;
}

QColor oldColor = mComposerScaleBar->fontColor();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar font color changed" ) );
disconnectUpdateSignal();
mComposerScaleBar->setFontColor( newColor );
mComposerScaleBar->update();
connectUpdateSignal();
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mColorPushButton_clicked()
{
if ( !mComposerScaleBar )
Expand All @@ -321,6 +344,31 @@ void QgsComposerScaleBarWidget::on_mColorPushButton_clicked()
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mStrokeColorPushButton_clicked()
{
if ( !mComposerScaleBar )
{
return;
}

QColor oldColor = mComposerScaleBar->pen().color();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar stroke color changed" ) );
disconnectUpdateSignal();
QPen newPen = mComposerScaleBar->pen();
newPen.setColor( newColor );
mComposerScaleBar->setPen( newPen );
mComposerScaleBar->update();
connectUpdateSignal();
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mUnitLabelLineEdit_textChanged( const QString& text )
{
if ( !mComposerScaleBar )
Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgscomposerscalebarwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class QgsComposerScaleBarWidget: public QWidget, private Ui::QgsComposerScaleBar
void on_mUnitLabelLineEdit_textChanged( const QString& text );
void on_mMapUnitsPerBarUnitSpinBox_valueChanged( double d );
void on_mColorPushButton_clicked();
void on_mStrokeColorPushButton_clicked();
void on_mFontButton_clicked();
void on_mFontColorPushButton_clicked();
void on_mStyleComboBox_currentIndexChanged( const QString& text );
void on_mLabelBarSpaceSpinBox_valueChanged( double d );
void on_mBoxSizeSpinBox_valueChanged( double d );
Expand Down
54 changes: 51 additions & 3 deletions src/app/qgisappstylesheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
mDefaultFont = qApp->font(); // save before it is changed in any way

// the following default values, before insertion in opts, can be
// configured using the platform(s) and window server(s) defined in the
// configured using the platforms and window servers defined in the
// constructor to set reasonable non-Qt defaults for the app stylesheet
QSettings settings;
// handle move from old QSettings group (/) to new (/qgis/stylesheet)
Expand Down Expand Up @@ -130,7 +130,13 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
QgsDebugMsg( QString( "fontFamily: %1" ).arg( fontFamily ) );
opts.insert( "fontFamily", QVariant( fontFamily ) );

settings.endGroup();
bool gbxCustom = false;
opts.insert( "groupBoxCustom", settings.value( "groupBoxCustom", QVariant( gbxCustom ) ) );

bool gbxBoldTitle = false;
opts.insert( "groupBoxBoldTitle", settings.value( "groupBoxBoldTitle", QVariant( gbxBoldTitle ) ) );

settings.endGroup(); // "qgis/stylesheet"

return opts;
}
Expand All @@ -139,6 +145,8 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant>& opts )
{
QString ss = QString( "" );


// QgisApp-wide font
QString fontSize = opts.value( "fontPointSize" ).toString();
QgsDebugMsg( QString( "fontPointSize: %1" ).arg( fontSize ) );
if ( fontSize.isEmpty() ) { return; }
Expand All @@ -149,6 +157,46 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant>& opts )

ss += QString( "* { font: %1pt \"%2\"} " ).arg( fontSize ).arg( fontFamily );

// QGroupBox and QgsCollapsibleGroupBox, mostly for Ubuntu and Mac
// TODO: test on/adjust for Windows
bool gbxCustom = opts.value( "groupBoxCustom" ).toBool();
QgsDebugMsg( QString( "groupBoxCustom: %1" ).arg( gbxCustom ) );
bool gbxBoldTitle = opts.value( "groupBoxBoldTitle" ).toBool();
QgsDebugMsg( QString( "groupBoxBoldTitle: %1" ).arg( gbxBoldTitle ) );
if ( gbxCustom || gbxBoldTitle )
{
ss += "QGroupBox{";
if ( gbxBoldTitle )
{
// doesn't work for QGroupBox::title
ss += QString( "color: rgb(%1,%1,%1);" ).arg( mMacWS ? 25 : 60 );
ss += "font-weight: bold;";
}
if ( gbxCustom )
{
ss += QString( "background-color: rgba(%1,%1,%1,90%);" ).arg( mMacWS ? 225 : 235 );
ss += "border: 1px solid #c0c0c0;";
ss += "border-radius: 5px;";
ss += "margin-top: 2.5ex;";
ss += QString( "margin-bottom: %1ex;" ).arg( mMacWS ? 1.5 : 1 );
}
ss += "} ";
if ( gbxCustom )
{
ss += "QGroupBox:flat{";
ss += "background-color: rgba(0,0,0,0);";
ss += "border: rgba(0,0,0,0);";
ss += "} ";

ss += "QGroupBox::title{";
ss += "subcontrol-origin: margin;";
ss += "subcontrol-position: top left;";
ss += "margin-left: 6px;";
ss += "background-color: rgba(0,0,0,0);";
ss += "} ";
}
}

QgsDebugMsg( QString( "Stylesheet built: %1" ).arg( ss ) );

emit appStyleSheetChanged( ss );
Expand All @@ -165,5 +213,5 @@ void QgisAppStyleSheet::saveToSettings( const QMap<QString, QVariant>& opts )
settings.setValue( QString( opt.key() ), opt.value() );
++opt;
}
settings.endGroup();
settings.endGroup(); // "qgis/stylesheet"
}
28 changes: 22 additions & 6 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mFontFamilyRadioCustom->blockSignals( true );
mFontFamilyComboBox->blockSignals( true );

spinFontSize->setValue( mStyleSheetNewOpts.value( "fontPointSize" ).toInt() );
QString fontFamily = mStyleSheetNewOpts.value( "fontFamily" ).toString();
spinFontSize->setValue( mStyleSheetOldOpts.value( "fontPointSize" ).toInt() );
QString fontFamily = mStyleSheetOldOpts.value( "fontFamily" ).toString();
bool isQtDefault = ( fontFamily == mStyleSheetBuilder->defaultFont().family() );
mFontFamilyRadioQt->setChecked( isQtDefault );
mFontFamilyRadioCustom->setChecked( !isQtDefault );
Expand All @@ -477,6 +477,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mFontFamilyRadioCustom->blockSignals( false );
mFontFamilyComboBox->blockSignals( false );

// custom group boxes
mCustomGroupBoxChkBx->setChecked( mStyleSheetOldOpts.value( "groupBoxCustom" ).toBool() );
mBoldGroupBoxTitleChkBx->setChecked( mStyleSheetOldOpts.value( "groupBoxBoldTitle" ).toBool() );

mMessageTimeoutSpnBx->setValue( settings.value( "/qgis/messageTimeout", 5 ).toInt() );

QString name = QApplication::style()->objectName();
Expand Down Expand Up @@ -1247,15 +1251,15 @@ void QgsOptions::rejectOptions()

void QgsOptions::on_spinFontSize_valueChanged( int fontSize )
{
mStyleSheetNewOpts.insert( "fontPointSize", fontSize );
mStyleSheetNewOpts.insert( "fontPointSize", QVariant( fontSize ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}

void QgsOptions::on_mFontFamilyRadioQt_released()
{
if ( mStyleSheetNewOpts.value( "fontFamily" ).toString() != mStyleSheetBuilder->defaultFont().family() )
{
mStyleSheetNewOpts.insert( "fontFamily", mStyleSheetBuilder->defaultFont().family() );
mStyleSheetNewOpts.insert( "fontFamily", QVariant( mStyleSheetBuilder->defaultFont().family() ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}
}
Expand All @@ -1264,7 +1268,7 @@ void QgsOptions::on_mFontFamilyRadioCustom_released()
{
if ( mFontFamilyComboBox->currentFont().family() != mStyleSheetBuilder->defaultFont().family() )
{
mStyleSheetNewOpts.insert( "fontFamily", mFontFamilyComboBox->currentFont().family() );
mStyleSheetNewOpts.insert( "fontFamily", QVariant( mFontFamilyComboBox->currentFont().family() ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}
}
Expand All @@ -1274,11 +1278,23 @@ void QgsOptions::on_mFontFamilyComboBox_currentFontChanged( const QFont& font )
if ( mFontFamilyRadioCustom->isChecked()
&& mStyleSheetNewOpts.value( "fontFamily" ).toString() != font.family() )
{
mStyleSheetNewOpts.insert( "fontFamily", font.family() );
mStyleSheetNewOpts.insert( "fontFamily", QVariant( font.family() ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}
}

void QgsOptions::on_mCustomGroupBoxChkBx_clicked( bool chkd )
{
mStyleSheetNewOpts.insert( "groupBoxCustom", QVariant( chkd ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}

void QgsOptions::on_mBoldGroupBoxTitleChkBx_clicked( bool chkd )
{
mStyleSheetNewOpts.insert( "groupBoxBoldTitle", QVariant( chkd ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}

void QgsOptions::on_pbnSelectProjection_clicked()
{
QSettings settings;
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
*/
void on_mFontFamilyComboBox_currentFontChanged( const QFont& font );

/** Slot to set whether to use custom group boxes
* @note added in QGIS 1.9
*/
void on_mCustomGroupBoxChkBx_clicked( bool chkd );

/** Slot to set whether to bold group box titles
* @note added in QGIS 1.9
*/
void on_mBoldGroupBoxTitleChkBx_clicked( bool chkd );

/*!
* Slot to select the default map selection color
*/
Expand Down
1 change: 0 additions & 1 deletion src/core/composer/qgscomposeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ void QgsComposerItem::drawText( QPainter* p, double x, double y, const QString&

p->save();
p->setFont( textFont );
p->setPen( QColor( 0, 0, 0 ) ); //draw text always in black
double scaleFactor = 1.0 / FONT_WORKAROUND_SCALE;
p->scale( scaleFactor, scaleFactor );
p->drawText( QPointF( x * FONT_WORKAROUND_SCALE, y * FONT_WORKAROUND_SCALE ), text );
Expand Down
13 changes: 9 additions & 4 deletions src/core/composer/qgscomposerlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ QgsComposerLegend::QgsComposerLegend( QgsComposition* composition )
, mComposerMap( 0 )
, mSplitLayer( false )
, mEqualColumnWidth( false )
, mFontColor( QColor( 0, 0, 0 ) )
{
//QStringList idList = layerIdList();
//mLegendModel.setLayerSet( idList );
Expand Down Expand Up @@ -206,7 +207,7 @@ QSizeF QgsComposerLegend::drawTitle( QPainter* painter, QPointF point, Qt::Align

double y = point.y();

if ( painter ) painter->setPen( QColor( 0, 0, 0 ) );
if ( painter ) painter->setPen( mFontColor );

for ( QStringList::Iterator titlePart = lines.begin(); titlePart != lines.end(); ++titlePart )
{
Expand Down Expand Up @@ -241,7 +242,7 @@ QSizeF QgsComposerLegend::drawGroupItemTitle( QgsComposerGroupItem* groupItem, Q

double y = point.y();

if ( painter ) painter->setPen( QColor( 0, 0, 0 ) );
if ( painter ) painter->setPen( mFontColor );

QStringList lines = splitStringForWrapping( groupItem->text() );
for ( QStringList::Iterator groupPart = lines.begin(); groupPart != lines.end(); ++groupPart )
Expand Down Expand Up @@ -269,7 +270,7 @@ QSizeF QgsComposerLegend::drawLayerItemTitle( QgsComposerLayerItem* layerItem, Q

double y = point.y();

if ( painter ) painter->setPen( QColor( 0, 0, 0 ) );
if ( painter ) painter->setPen( mFontColor );

QStringList lines = splitStringForWrapping( layerItem->text() );
for ( QStringList::Iterator layerItemPart = lines.begin(); layerItemPart != lines.end(); ++layerItemPart )
Expand Down Expand Up @@ -377,7 +378,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
}
}

if ( painter ) painter->setPen( QColor( 0, 0, 0 ) );
if ( painter ) painter->setPen( mFontColor );

double labelX = point.x() + labelXOffset; // + mIconLabelSpace;

Expand Down Expand Up @@ -727,6 +728,7 @@ bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc ) const
composerLegendElem.setAttribute( "symbolWidth", QString::number( mSymbolWidth ) );
composerLegendElem.setAttribute( "symbolHeight", QString::number( mSymbolHeight ) );
composerLegendElem.setAttribute( "wrapChar", mWrapChar );
composerLegendElem.setAttribute( "fontColor", mFontColor.name() );

if ( mComposerMap )
{
Expand Down Expand Up @@ -779,6 +781,9 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument
mItemFont.fromString( itemFontString );
}

//font color
mFontColor.setNamedColor( itemElem.attribute( "fontColor", "#000000" ) );

//spaces
mBoxSpace = itemElem.attribute( "boxSpace", "2.0" ).toDouble();
mColumnSpace = itemElem.attribute( "columnSpace", "2.0" ).toDouble();
Expand Down
4 changes: 4 additions & 0 deletions src/core/composer/qgscomposerlegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
QFont itemFont() const;
void setItemFont( const QFont& f );

QColor fontColor() const {return mFontColor;}
void setFontColor( const QColor& c ) {mFontColor = c;}

double boxSpace() const {return mBoxSpace;}
void setBoxSpace( double s ) {mBoxSpace = s;}

Expand Down Expand Up @@ -141,6 +144,7 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
QFont mGroupFont;
QFont mLayerFont;
QFont mItemFont;
QColor mFontColor;

/**Space between item box and contents*/
double mBoxSpace;
Expand Down
20 changes: 12 additions & 8 deletions src/core/composer/qgscomposerscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ QgsComposerScaleBar::QgsComposerScaleBar( QgsComposition* composition )
: QgsComposerItem( composition )
, mComposerMap( 0 )
, mNumUnitsPerSegment( 0 )
, mFontColor( QColor( 0, 0, 0 ) )
, mStyle( 0 )
, mSegmentMillimeters( 0.0 )
, mAlignment( Left )
Expand All @@ -60,7 +61,6 @@ void QgsComposerScaleBar::paint( QPainter* painter, const QStyleOptionGraphicsIt
}

drawBackground( painter );
painter->setPen( QPen( QColor( 0, 0, 0 ) ) ); //draw all text black

//x-offset is half of first label width because labels are drawn centered
QString firstLabel = firstLabelString();
Expand Down Expand Up @@ -228,6 +228,7 @@ void QgsComposerScaleBar::applyDefaultSettings()
mBrush.setStyle( Qt::SolidPattern );

mFont.setPointSizeF( 12.0 );
mFontColor = QColor( 0, 0, 0 );

mLabelBarSpace = 3.0;
mBoxContentSpace = 1.0;
Expand Down Expand Up @@ -422,13 +423,10 @@ bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc ) cons
composerScaleBarElem.setAttribute( "mapId", mComposerMap->id() );
}

//fill color
QColor brushColor = mBrush.color();
QDomElement colorElem = doc.createElement( "BrushColor" );
colorElem.setAttribute( "red", brushColor.red() );
colorElem.setAttribute( "green", brushColor.green() );
colorElem.setAttribute( "blue", brushColor.blue() );
composerScaleBarElem.appendChild( colorElem );
//colors
composerScaleBarElem.setAttribute( "brushColor", mBrush.color().name() );
composerScaleBarElem.setAttribute( "penColor", mPen.color().name() );
composerScaleBarElem.setAttribute( "fontColor", mFontColor.name() );

//alignment
composerScaleBarElem.setAttribute( "alignment", QString::number(( int ) mAlignment ) );
Expand Down Expand Up @@ -460,6 +458,12 @@ bool QgsComposerScaleBar::readXML( const QDomElement& itemElem, const QDomDocume
mFont.fromString( fontString );
}

//colors
//fill color
mBrush.setColor( QColor( itemElem.attribute( "brushColor", "#000000" ) ) );
mPen.setColor( QColor( itemElem.attribute( "penColor", "#000000" ) ) );
mFontColor.setNamedColor( itemElem.attribute( "fontColor", "#000000" ) );

//style
delete mStyle;
mStyle = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/core/composer/qgscomposerscalebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "qgscomposeritem.h"
#include <QPen>
#include <QColor>

class QgsComposerMap;
class QgsScaleBarStyle;
Expand Down Expand Up @@ -74,6 +75,9 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem

QFont font() const;

QColor fontColor() const {return mFontColor;}
void setFontColor( const QColor& c ) {mFontColor = c;}

void setFont( const QFont& font );

QPen pen() const {return mPen;}
Expand Down Expand Up @@ -172,6 +176,7 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
QString mUnitLabeling;
/**Font*/
QFont mFont;
QColor mFontColor;
/**Outline*/
QPen mPen;
/**Fill*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgsdoubleboxscalebarstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void QgsDoubleBoxScaleBarStyle::draw( QPainter* p, double xOffset ) const
double segmentHeight = mScaleBar->height() / 2;

p->save();
p->setPen( p->pen() );
p->setPen( mScaleBar->pen() );

QList<QPair<double, double> > segmentInfo;
mScaleBar->segmentPositions( segmentInfo );
Expand Down
3 changes: 1 addition & 2 deletions src/core/composer/qgsscalebarstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void QgsScaleBarStyle::drawLabels( QPainter* p ) const
p->save();

p->setFont( mScaleBar->font() );
p->setPen( QPen(mScaleBar->fontColor()) );

QString firstLabel = mScaleBar->firstLabelString();
double xOffset = mScaleBar->textWidthMillimeters( mScaleBar->font(), firstLabel ) / 2;
Expand Down Expand Up @@ -78,7 +79,6 @@ void QgsScaleBarStyle::drawLabels( QPainter* p ) const

if ( segmentCounter == 0 || segmentCounter >= nSegmentsLeft ) //don't draw label for intermediate left segments
{
p->setPen( QColor( 0, 0, 0 ) );
mScaleBar->drawText( p, segmentIt->first - mScaleBar->textWidthMillimeters( mScaleBar->font(), currentNumericLabel ) / 2 + xOffset, mScaleBar->fontAscentMillimeters( mScaleBar->font() ) + mScaleBar->boxContentSpace(), currentNumericLabel, mScaleBar->font() );
}

Expand All @@ -93,7 +93,6 @@ void QgsScaleBarStyle::drawLabels( QPainter* p ) const
if ( !segmentInfo.isEmpty() )
{
currentNumericLabel = QString::number( currentLabelNumber / mScaleBar->numMapUnitsPerScaleBarUnit() );
p->setPen( QColor( 0, 0, 0 ) );
mScaleBar->drawText( p, segmentInfo.last().first + mScaleBar->segmentMillimeters() - mScaleBar->textWidthMillimeters( mScaleBar->font(), currentNumericLabel ) / 2 + xOffset, mScaleBar->fontAscentMillimeters( mScaleBar->font() ) + mScaleBar->boxContentSpace(), currentNumericLabel + " " + mScaleBar->unitLabeling(), mScaleBar->font() );
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/composer/qgssingleboxscalebarstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void QgsSingleBoxScaleBarStyle::draw( QPainter* p, double xOffset ) const
double barTopPosition = mScaleBar->fontAscentMillimeters( mScaleBar->font() ) + mScaleBar->labelBarSpace() + mScaleBar->boxContentSpace();

p->save();
p->setPen( p->pen() );
p->setPen( mScaleBar->pen() );


QList<QPair<double, double> > segmentInfo;
mScaleBar->segmentPositions( segmentInfo );
Expand Down
18 changes: 18 additions & 0 deletions src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,23 @@ static QVariant fcnLPad( const QVariantList& values, QgsFeature* , QgsExpression
return string.leftJustified( length, fill.at( 0 ), true );
}

static QVariant fcnFormatString( const QVariantList& values, QgsFeature* , QgsExpression *parent )
{
QString string = getStringValue( values.at( 0 ), parent );
for ( int n = 1; n <= values.length() - 1; n++ )
{
QString arg = getStringValue( values.at( n ), parent );
QString place = '%' + QString::number( n );
if ( string.indexOf( place ) == -1 )
{
continue;
}
string.replace( place, arg );
}
return string;
}


static QVariant fcnNow( const QVariantList&, QgsFeature* , QgsExpression * )
{
return QVariant( QDateTime::currentDateTime() );
Expand Down Expand Up @@ -1100,6 +1117,7 @@ const QList<QgsExpression::Function*> &QgsExpression::Functions()
<< new StaticFunction( "right", 2, fcnRight, QObject::tr( "String" ) )
<< new StaticFunction( "rpad", 3, fcnRPad, QObject::tr( "String" ) )
<< new StaticFunction( "lpad", 3, fcnLPad, QObject::tr( "String" ) )
<< new StaticFunction( "format", -1, fcnFormatString, QObject::tr( "String" ) )
<< new StaticFunction( "format_number", 2, fcnFormatNumber, QObject::tr( "String" ) )
<< new StaticFunction( "format_date", 2, fcnFormatDate, QObject::tr( "String" ) )
<< new StaticFunction( "xat", 1, fcnXat, QObject::tr( "Geometry" ), "", true )
Expand Down
7 changes: 2 additions & 5 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,12 +786,9 @@ QString QgsMapLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
"). Problems may occur." );

QgsProjectFileTransform styleFile( myDocument, fileVersion );

styleFile.dump();

// styleFile.dump();
styleFile.updateRevision( thisVersion );

styleFile.dump();
// styleFile.dump();
}

// now get the layer node out and pass it over to the layer
Expand Down
13 changes: 5 additions & 8 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2279,15 +2279,12 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe

if ( !rasterRendererElem.isNull() )
{
if ( !rasterRendererElem.isNull() )
QString rendererType = rasterRendererElem.attribute( "type" );
QgsRasterRendererRegistryEntry rendererEntry;
if ( QgsRasterRendererRegistry::instance()->rendererData( rendererType, rendererEntry ) )
{
QString rendererType = rasterRendererElem.attribute( "type" );
QgsRasterRendererRegistryEntry rendererEntry;
if ( QgsRasterRendererRegistry::instance()->rendererData( rendererType, rendererEntry ) )
{
QgsRasterRenderer *renderer = rendererEntry.rendererCreateFunction( rasterRendererElem, dataProvider() );
mPipe.set( renderer );
}
QgsRasterRenderer *renderer = rendererEntry.rendererCreateFunction( rasterRendererElem, dataProvider() );
mPipe.set( renderer );
}
}

Expand Down
1 change: 1 addition & 0 deletions src/core/raster/qgssinglebandgrayrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ QgsRasterInterface * QgsSingleBandGrayRenderer::clone() const
renderer->setOpacity( mOpacity );
renderer->setAlphaBand( mAlphaBand );
renderer->setRasterTransparency( mRasterTransparency );
renderer->setGradient( mGradient );
if ( mContrastEnhancement )
{
renderer->setContrastEnhancement( new QgsContrastEnhancement( *mContrastEnhancement ) );
Expand Down
10 changes: 9 additions & 1 deletion src/gui/qgscollapsiblegroupbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,15 @@ void QgsCollapsibleGroupBox::updateStyle()
int marginRight = 5; // a little bit of space on the right, to match space on the left
int offsetLeft = 0; // offset for oxygen theme
int offsetTop = 0;
int offsetTop2 = 0; // offset for triangle
// int offsetTop2 = 0; // offset for triangle

// starting top offset for custom groupboxes in app stylesheet
QStyleOptionGroupBox box;
initStyleOption( &box );
QRect rectCheckBox = style()->subControlRect( QStyle::CC_GroupBox, &box,
QStyle::SC_GroupBoxCheckBox, this );
int offsetTop2 = rectCheckBox.top(); // offset for triangle


// calculate offset if frame overlaps triangle (oxygen theme)
// using an offset of 6 pixels from frame border
Expand Down
53 changes: 47 additions & 6 deletions src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
throw QgsMapServiceException( "ParameterMissing", "The TEMPLATE parameter is required for the GetPrint request" );
}

QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> > bkVectorRenderers;
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > > bkRasterRenderers;
QList< QPair< QgsVectorLayer*, unsigned int> > bkVectorOld;
QList< QPair< QgsVectorLayer*, double > > labelTransparencies;
QList< QPair< QgsVectorLayer*, double > > labelBufferTransparencies;

applyOpacities( layersList, bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );


QgsComposition* c = mConfigParser->createPrintComposition( mParameterMap[ "TEMPLATE" ], mMapRenderer, QMap<QString, QString>( mParameterMap ) );
if ( !c )
{
Expand Down Expand Up @@ -575,6 +584,8 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
{
throw QgsMapServiceException( "InvalidFormat", "Output format '" + formatString + "' is not supported in the GetPrint request" );
}

restoreOpacities( bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
restoreLayerFilters( originalLayerFilters );
clearFeatureSelections( selectedLayerIdList );

Expand Down Expand Up @@ -616,8 +627,10 @@ QImage* QgsWMSServer::getMap()
QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> > bkVectorRenderers;
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > > bkRasterRenderers;
QList< QPair< QgsVectorLayer*, unsigned int> > bkVectorOld;
QList< QPair< QgsVectorLayer*, double > > labelTransparencies;
QList< QPair< QgsVectorLayer*, double > > labelBufferTransparencies;

applyOpacities( layersList, bkVectorRenderers, bkVectorOld, bkRasterRenderers );
applyOpacities( layersList, bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );

mMapRenderer->render( &thePainter );
if ( mConfigParser )
Expand All @@ -626,7 +639,7 @@ QImage* QgsWMSServer::getMap()
mConfigParser->drawOverlays( &thePainter, theImage->dotsPerMeterX() / 1000.0 * 25.4, theImage->width(), theImage->height() );
}

restoreOpacities( bkVectorRenderers, bkVectorOld, bkRasterRenderers );
restoreOpacities( bkVectorRenderers, bkVectorOld, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
restoreLayerFilters( originalLayerFilters );
clearFeatureSelections( selectedLayerIdList );

Expand Down Expand Up @@ -1986,7 +1999,9 @@ void QgsWMSServer::clearFeatureSelections( const QStringList& layerIds ) const

void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair< QgsVectorLayer*, unsigned int> >& vectorOld,
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers )
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelTransparencies,
QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies )
{
//get opacity list
QMap<QString, QString>::const_iterator opIt = mParameterMap.find( "OPACITIES" );
Expand Down Expand Up @@ -2022,6 +2037,8 @@ void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< Q
//vector or raster?
QgsMapLayer* ml = lOpIt->first;
int opacity = lOpIt->second;
double opacityRatio = opacity / 255.0; //opacity value between 0 and 1

if ( !ml || opacity == 255 )
{
continue;
Expand All @@ -2040,7 +2057,7 @@ void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< Q
QgsSymbolV2List::iterator symbolIt = symbolList.begin();
for ( ; symbolIt != symbolList.end(); ++symbolIt )
{
( *symbolIt )->setAlpha(( *symbolIt )->alpha() * opacity / 255.0 );
( *symbolIt )->setAlpha(( *symbolIt )->alpha() * opacityRatio );
}
}
else //old symbology
Expand All @@ -2049,6 +2066,16 @@ void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< Q
vl->setTransparency( opacity );
}

//labeling
if ( vl->customProperty( "labeling/enabled" ).toString() == "true" )
{
double labelTransparency = vl->customProperty( "labeling/textTransp" ).toDouble();
labelTransparencies.push_back( qMakePair( vl, labelTransparency ) );
vl->setCustomProperty( "labeling/textTransp", labelTransparency + ( 100 - labelTransparency ) * ( 1.0 - opacityRatio ) );
double bufferTransparency = vl->customProperty( "labeling/bufferTransp" ).toDouble();
labelBufferTransparencies.push_back( qMakePair( vl, bufferTransparency ) );
vl->setCustomProperty( "labeling/bufferTransp", bufferTransparency + ( 100 - bufferTransparency )* ( 1.0 - opacityRatio ) );
}
}
else if ( ml->type() == QgsMapLayer::RasterLayer )
{
Expand All @@ -2059,7 +2086,7 @@ void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< Q
if ( rasterRenderer )
{
rasterRenderers.push_back( qMakePair( rl, dynamic_cast<QgsRasterRenderer*>( rasterRenderer->clone() ) ) );
rasterRenderer->setOpacity( opacity / 255.0 );
rasterRenderer->setOpacity( rasterRenderer->opacity() * opacityRatio );
}
}
}
Expand All @@ -2068,7 +2095,9 @@ void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< Q

void QgsWMSServer::restoreOpacities( QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair< QgsVectorLayer*, unsigned int> >& vectorOld,
QList < QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers )
QList < QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelOpacities,
QList< QPair< QgsVectorLayer*, double > >& labelBufferOpacities )
{
if ( vectorRenderers.isEmpty() && vectorOld.isEmpty() && rasterRenderers.isEmpty() )
{
Expand All @@ -2092,6 +2121,18 @@ void QgsWMSServer::restoreOpacities( QList< QPair< QgsVectorLayer*, QgsFeatureRe
{
( *oIt ).first->setTransparency(( *oIt ).second );
}

QList< QPair< QgsVectorLayer*, double > >::iterator loIt = labelOpacities.begin();
for ( ; loIt != labelOpacities.end(); ++loIt )
{
( *loIt ).first->setCustomProperty( "labeling/textTransp", ( *loIt ).second );
}

QList< QPair< QgsVectorLayer*, double > >::iterator lboIt = labelBufferOpacities.begin();
for ( ; lboIt != labelBufferOpacities.end(); ++lboIt )
{
( *lboIt ).first->setCustomProperty( "labeling/bufferTransp", ( *lboIt ).second );
}
}

bool QgsWMSServer::checkMaximumWidthHeight() const
Expand Down
12 changes: 9 additions & 3 deletions src/mapserver/qgswmsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,17 @@ class QgsWMSServer
/**Applies opacity on layer/group level*/
void applyOpacities( const QStringList& layerList, QList< QPair< QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair< QgsVectorLayer*, unsigned int> >& vectorOld,
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers );
QList< QPair< QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelTransparencies,
QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies
);

/**Restore original opacities*/
void restoreOpacities( QList< QPair <QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers, QList< QPair <QgsVectorLayer*, unsigned int> >& vectorOld,
QList< QPair < QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers );
void restoreOpacities( QList< QPair <QgsVectorLayer*, QgsFeatureRendererV2*> >& vectorRenderers,
QList< QPair <QgsVectorLayer*, unsigned int> >& vectorOld,
QList< QPair < QgsRasterLayer*, QgsRasterRenderer* > >& rasterRenderers,
QList< QPair< QgsVectorLayer*, double > >& labelTransparencies,
QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies );

void appendFormats( QDomDocument &doc, QDomElement &elem, const QStringList &formats );

Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqldataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ bool QgsMssqlConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction

if ( srcLayer->isValid() )
{
QString uri = connInfo() + " table=" + u.name + " (qgs_geometry)";
QString uri = connInfo() + " table=" + u.name + " (geom)";

QgsVectorLayerImport::ImportError err;
QString importError;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ QgsVectorLayerImport::ImportError QgsMssqlProvider::createEmptyLayer(
schemaName = "dbo";

if ( geometryColumn.isEmpty() )
geometryColumn = "qgs_geometry";
geometryColumn = "geom";

if ( primaryKey.isEmpty() )
primaryKey = "qgs_fid";
Expand Down
2 changes: 1 addition & 1 deletion src/providers/oracle/qgsoracledataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction

if ( srcLayer->isValid() )
{
uri.setDataSource( QString(), u.name.left( 30 ).toUpper(), "QGS_GEOMETRY" );
uri.setDataSource( QString(), u.name.left( 30 ).toUpper(), "GEOM" );
uri.setWkbType( srcLayer->wkbType() );
QString authid = srcLayer->crs().authid();
if ( authid.startsWith( "EPSG:", Qt::CaseInsensitive ) )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction )

if ( srcLayer->isValid() )
{
uri.setDataSource( QString(), u.name, "qgs_geometry" );
uri.setDataSource( QString(), u.name, "geom" );
QgsDebugMsg( "URI " + uri.uri() );
QgsVectorLayerImport::ImportError err;
QString importError;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialitedataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ bool QgsSLConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction )

if ( srcLayer->isValid() )
{
destUri.setDataSource( QString(), u.name, "geomm" );
destUri.setDataSource( QString(), u.name, "geom" );
QgsDebugMsg( "URI " + destUri.uri() );
QgsVectorLayerImport::ImportError err;
QString importError;
Expand Down
46 changes: 25 additions & 21 deletions src/ui/qgscomposerlegendwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-115</y>
<width>370</width>
<height>562</height>
<y>0</y>
<width>362</width>
<height>647</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -93,7 +93,7 @@
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QDoubleSpinBox" name="mSymbolWidthSpinBox">
<property name="prefix">
<string>Symbol width </string>
Expand All @@ -103,7 +103,7 @@
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QDoubleSpinBox" name="mSymbolHeightSpinBox">
<property name="prefix">
<string>Symbol height </string>
Expand All @@ -113,7 +113,7 @@
</property>
</widget>
</item>
<item row="14" column="1">
<item row="15" column="1">
<widget class="QDoubleSpinBox" name="mLayerSpaceSpinBox">
<property name="prefix">
<string>Layer space </string>
Expand All @@ -123,7 +123,7 @@
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QDoubleSpinBox" name="mSymbolSpaceSpinBox">
<property name="prefix">
<string>Symbol space </string>
Expand All @@ -133,7 +133,7 @@
</property>
</widget>
</item>
<item row="17" column="1">
<item row="18" column="1">
<widget class="QDoubleSpinBox" name="mIconLabelSpaceSpinBox">
<property name="prefix">
<string>Icon label space </string>
Expand All @@ -143,7 +143,7 @@
</property>
</widget>
</item>
<item row="18" column="1">
<item row="19" column="1">
<widget class="QDoubleSpinBox" name="mBoxSpaceSpinBox">
<property name="prefix">
<string>Box space </string>
Expand All @@ -153,7 +153,7 @@
</property>
</widget>
</item>
<item row="25" column="1">
<item row="26" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -166,17 +166,17 @@
</property>
</spacer>
</item>
<item row="21" column="1">
<item row="22" column="1">
<widget class="QComboBox" name="mMapComboBox"/>
</item>
<item row="20" column="1">
<item row="21" column="1">
<widget class="QLabel" name="mMapLabel">
<property name="text">
<string>Map</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QDoubleSpinBox" name="mGroupSpaceSpinBox">
<property name="prefix">
<string>Group Space </string>
Expand All @@ -186,14 +186,14 @@
</property>
</widget>
</item>
<item row="23" column="1">
<item row="24" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Wrap text on</string>
</property>
</widget>
</item>
<item row="24" column="1">
<item row="25" column="1">
<widget class="QLineEdit" name="mWrapCharLineEdit">
<property name="frame">
<bool>true</bool>
Expand Down Expand Up @@ -247,7 +247,7 @@
</property>
</widget>
</item>
<item row="19" column="1">
<item row="20" column="1">
<widget class="QDoubleSpinBox" name="mColumnSpaceSpinBox">
<property name="prefix">
<string>Column space </string>
Expand All @@ -257,15 +257,22 @@
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QPushButton" name="mFontColorPushButton">
<property name="text">
<string>Font color...</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>139</height>
<width>429</width>
<height>385</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -308,9 +315,6 @@
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="2" column="0">
Expand Down
210 changes: 124 additions & 86 deletions src/ui/qgscomposerscalebarwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>325</width>
<height>537</height>
<width>436</width>
<height>499</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -19,100 +19,129 @@
<property name="windowTitle">
<string>Barscale Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<height>501</height>
<width>415</width>
<height>552</height>
</rect>
</property>
<attribute name="label">
<string>Scale bar</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="mSegmentSizeLabel">
<item row="1" column="0">
<widget class="QLabel" name="mUnitsLabel">
<property name="text">
<string>Segment size</string>
<string>Units</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="mUnitsComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mUnitLabelLabel">
<property name="text">
<string>Unit label</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>mSegmentSizeSpinBox</cstring>
<cstring>mUnitLabelLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="mSegmentSizeSpinBox">
<property name="decimals">
<number>4</number>
<item row="3" column="1">
<widget class="QLineEdit" name="mUnitLabelLineEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mMapUnitsPerBarUnitLabel">
<property name="text">
<string>Map units per bar unit</string>
</property>
<property name="maximum">
<double>9999999999999.000000000000000</double>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>mMapUnitsPerBarUnitSpinBox</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mUnitsLabel">
<property name="text">
<string>Units</string>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="mMapUnitsPerBarUnitSpinBox">
<property name="maximum">
<double>9999999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mMapUnitsPerBarUnitLabel">
<item row="5" column="0">
<widget class="QLabel" name="mSegmentSizeLabel">
<property name="text">
<string>Map units per bar unit</string>
<string>Segment size</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>mMapUnitsPerBarUnitSpinBox</cstring>
<cstring>mSegmentSizeSpinBox</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mMapUnitsPerBarUnitSpinBox">
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="mSegmentSizeSpinBox">
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>9999999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="6" column="0">
<widget class="QLabel" name="mSegmentLabel">
<property name="text">
<string>Segments</string>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="mSegmentsLeftSpinBox">
<property name="suffix">
<string> Left segments</string>
<string> left</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mNumberOfSegmentsSpinBox">
<property name="suffix">
<string> Right segments</string>
<string> right</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<item row="8" column="0">
<widget class="QLabel" name="mStyleLabel">
<property name="text">
<string>Style</string>
Expand All @@ -122,10 +151,10 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="8" column="1">
<widget class="QComboBox" name="mStyleComboBox"/>
</item>
<item row="5" column="0">
<item row="9" column="0">
<widget class="QLabel" name="mMapLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
Expand All @@ -144,7 +173,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="9" column="1">
<widget class="QComboBox" name="mMapComboBox">
<property name="enabled">
<bool>true</bool>
Expand All @@ -157,17 +186,17 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="10" column="0">
<widget class="QLabel" name="mAlignmentLabel">
<property name="text">
<string>Alignment</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="10" column="1">
<widget class="QComboBox" name="mAlignmentComboBox"/>
</item>
<item row="7" column="0" colspan="2">
<item row="14" column="0" colspan="2">
<widget class="QSpinBox" name="mHeightSpinBox">
<property name="suffix">
<string> mm</string>
Expand All @@ -177,7 +206,17 @@
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="15" column="0" colspan="2">
<widget class="QDoubleSpinBox" name="mLabelBarSpaceSpinBox">
<property name="prefix">
<string>Label space </string>
</property>
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="16" column="0" colspan="2">
<widget class="QDoubleSpinBox" name="mLineWidthSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
Expand All @@ -202,17 +241,7 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QDoubleSpinBox" name="mLabelBarSpaceSpinBox">
<property name="prefix">
<string>Label space </string>
</property>
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<item row="17" column="0" colspan="2">
<widget class="QDoubleSpinBox" name="mBoxSizeSpinBox">
<property name="prefix">
<string>Box space </string>
Expand All @@ -222,43 +251,34 @@
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="mUnitLabelLabel">
<property name="text">
<string>Unit label</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>mUnitLabelLineEdit</cstring>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="mUnitLabelLineEdit"/>
</item>
<item row="12" column="0" colspan="2">
<widget class="QPushButton" name="mFontButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Font...</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="2">
<widget class="QPushButton" name="mColorPushButton">
<property name="text">
<string>Color...</string>
<item row="19" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout2">
<property name="margin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QPushButton" name="mFontButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Font...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mFontColorPushButton">
<property name="text">
<string>Font color...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="14" column="0" colspan="2">
<item row="22" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -271,8 +291,26 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="mUnitsComboBox"/>
<item row="20" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout3">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="mColorPushButton">
<property name="text">
<string>Fill color...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mStrokeColorPushButton">
<property name="text">
<string>Stroke color...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down
96 changes: 62 additions & 34 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: #fff</string>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
Expand Down Expand Up @@ -266,8 +269,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>654</width>
<height>522</height>
<width>663</width>
<height>562</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
Expand Down Expand Up @@ -521,18 +524,43 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="cbxHideSplash">
<property name="text">
<string>Hide splash screen at startup</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxShowTips">
<property name="text">
<string>Show tips at start up</string>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1" rowspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="mCustomGroupBoxChkBx">
<property name="text">
<string>Use custom group boxes</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cbxShowTips">
<property name="text">
<string>Show tips at start up</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="mBoldGroupBoxTitleChkBx">
<property name="text">
<string>Bold group box titles</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cbxHideSplash">
<property name="text">
<string>Hide splash screen at startup</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -747,8 +775,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>808</height>
<width>652</width>
<height>803</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
Expand Down Expand Up @@ -1077,8 +1105,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<height>417</height>
<width>529</width>
<height>443</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
Expand Down Expand Up @@ -1396,8 +1424,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>615</width>
<height>681</height>
<width>608</width>
<height>728</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
Expand Down Expand Up @@ -1884,8 +1912,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>669</width>
<height>490</height>
<width>483</width>
<height>364</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
Expand Down Expand Up @@ -2123,8 +2151,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>654</width>
<height>718</height>
<width>534</width>
<height>771</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
Expand Down Expand Up @@ -2503,8 +2531,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>517</width>
<height>643</height>
<width>500</width>
<height>691</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
Expand Down Expand Up @@ -2992,8 +3020,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<height>361</height>
<width>462</width>
<height>386</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
Expand Down Expand Up @@ -3132,8 +3160,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>614</width>
<height>393</height>
<width>638</width>
<height>422</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
Expand Down Expand Up @@ -3313,8 +3341,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>248</height>
<width>298</width>
<height>240</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
Expand Down Expand Up @@ -3413,8 +3441,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>654</width>
<height>650</height>
<width>540</width>
<height>672</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
Expand Down
12 changes: 12 additions & 0 deletions tests/src/python/test_qgsrasterlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ def testTransparency(self):
myResultFlag = myChecker.runTest("raster_transparency_python");
assert myResultFlag, "Raster transparency rendering test failed"

def testIssue7023(self):
"""Check if converting a raster from 1.8 to 2 works."""
myPath = os.path.join(unitTestDataPath('raster'),
'raster-pallette-crash2.tif')
myFileInfo = QFileInfo(myPath)
myBaseName = myFileInfo.baseName()
myRasterLayer = QgsRasterLayer(myPath, myBaseName)
myMessage = 'Raster not loaded: %s' % myPath
assert myRasterLayer.isValid(), myMessage
# crash on next line
QgsMapLayerRegistry.instance().addMapLayers([myRasterLayer])

def testShaderCrash(self):
"""Check if we assign a shader and then reassign it no crash occurs."""
myPath = os.path.join(unitTestDataPath('raster'),
Expand Down
44 changes: 44 additions & 0 deletions tests/testdata/raster/raster-pallette-crash2.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="1.8.0-Lisboa" minimumScale="0" maximumScale="1e+08" hasScaleBasedVisibilityFlag="0">
<transparencyLevelInt>255</transparencyLevelInt>
<rasterproperties>
<mDrawingStyle>PalettedColor</mDrawingStyle>
<mColorShadingAlgorithm>ColorRampShader</mColorShadingAlgorithm>
<mInvertColor boolean="false"/>
<mRedBandName>Not Set</mRedBandName>
<mGreenBandName>Not Set</mGreenBandName>
<mBlueBandName>Not Set</mBlueBandName>
<mGrayBandName>Band 1</mGrayBandName>
<mStandardDeviations>0</mStandardDeviations>
<mUserDefinedRGBMinimumMaximum boolean="false"/>
<mRGBMinimumMaximumEstimated boolean="true"/>
<mUserDefinedGrayMinimumMaximum boolean="false"/>
<mGrayMinimumMaximumEstimated boolean="true"/>
<mContrastEnhancementAlgorithm>NoEnhancement</mContrastEnhancementAlgorithm>
<contrastEnhancementMinMaxValues>
<minMaxEntry>
<min>-1.79769e+308</min>
<max>1.79769e+308</max>
</minMaxEntry>
</contrastEnhancementMinMaxValues>
<mNoDataValue mValidNoDataValue="true">nan</mNoDataValue>
<singleValuePixelList>
<pixelListEntry pixelValue="0.419576" percentTransparent="100"/>
<pixelListEntry pixelValue="94.209307" percentTransparent="30"/>
<pixelListEntry pixelValue="187.999039" percentTransparent="30"/>
<pixelListEntry pixelValue="281.788770" percentTransparent="30"/>
<pixelListEntry pixelValue="375.578502" percentTransparent="30"/>
</singleValuePixelList>
<threeValuePixelList>
<pixelListEntry red="nan" blue="nan" green="nan" percentTransparent="100"/>
</threeValuePixelList>
<customColorRamp>
<colorRampType>DISCRETE</colorRampType>
<colorRampEntry red="238" blue="238" value="0.419576" green="255" label="0.42 people/cell"/>
<colorRampEntry red="255" blue="127" value="94.209307" green="255" label=""/>
<colorRampEntry red="225" blue="0" value="187.999039" green="85" label="188.00 people/cell"/>
<colorRampEntry red="228" blue="27" value="281.788770" green="0" label=""/>
<colorRampEntry red="115" blue="0" value="375.578502" green="0" label="375.58 people/cell"/>
</customColorRamp>
</rasterproperties>
</qgis>
Binary file added tests/testdata/raster/raster-pallette-crash2.tif
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/testdata/raster/raster-pallette-crash2.tif.aux.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<PAMDataset>
<PAMRasterBand band="1">
<NoDataValue le_hex_equiv="000000000000F87F">nan</NoDataValue>
</PAMRasterBand>
</PAMDataset>