18 changes: 9 additions & 9 deletions python/plugins/sextante/r/RAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,29 @@ def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/r.png")

def defineCharacteristicsFromScript(self):
lines = self.script.split("\n")
lines = self.script.split("\n")
self.name = "[Unnamed algorithm]"
self.group = "User R scripts"
self.parseDescription(iter(lines))
def defineCharacteristicsFromFile(self):


def defineCharacteristicsFromFile(self):
filename = os.path.basename(self.descriptionFile)
self.name = filename[:filename.rfind(".")].replace("_", " ")
self.group = "User R scripts"
self.group = "User R scripts"
with open(self.descriptionFile, 'r') as f:
lines = [line.strip() for line in f]
self.parseDescription(iter(lines))
def parseDescription(self, lines):

def parseDescription(self, lines):
self.script = ""
self.commands=[]
self.showPlots = False
self.showConsoleOutput = False
self.useRasterPackage = True
self.passFileNames = False
self.verboseCommands = []
ender = 0
ender = 0
line = lines.next().strip("\n").strip("\r")
while ender < 10:
if line.startswith("##"):
Expand Down Expand Up @@ -285,7 +285,7 @@ def getImportCommands(self):
commands.append(
'tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE, lib="%s"))' % rLibDir)
commands.append("library(\"raster\")");

for param in self.parameters:
if isinstance(param, ParameterRaster):
value = param.value
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@ def exportRasterLayer(self, layer):
def checkBeforeOpeningParametersDialog(self):
pass
#return SagaUtils.checkSagaIsInstalled()


def checkParameterValuesBeforeExecuting(self):
'''We check that there are no multiband layers, which are not supported by SAGA'''
for param in self.parameters:
if isinstance(param, ParameterRaster):
if isinstance(param, ParameterRaster):
value = param.value
layer = QGisLayers.getObjectFromUri(value)
if layer is not None and layer.bandCount() > 1:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SplitRGBBands.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def processAlgorithm(self, progress):
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
safeBasename = ''.join(c for c in basename if c in validChars)
temp = os.path.join(os.path.dirname(temp), safeBasename)

r = self.getOutputValue(SplitRGBBands.R)
g = self.getOutputValue(SplitRGBBands.G)
b = self.getOutputValue(SplitRGBBands.B)
Expand Down
93 changes: 46 additions & 47 deletions python/plugins/sextante/tests/AlgTests.py

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions python/plugins/sextante/tests/GeoAlgorithmTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm

def testAlg(algname, *args):

#test simple execution
alg = Sextante.runAlgorithm(algname, None, *args)
assert alg is not None

out = alg.getOutputValuesAsDictionary()

return out

#test execution in a model

#===========================================================================
# model = ModelerAlgorithm()
# model.addAlgorithm(alg, parametersMap, valuesMap, outputsMap, dependencies)
#===========================================================================
#test

#test
24 changes: 12 additions & 12 deletions python/plugins/sextante/tests/ModelerAlgorithmTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
from osgeo.gdalconst import GA_ReadOnly

class ModelerAlgorithmTest(unittest.TestCase):

def testCreateModel(self):
pass

def testRemoveParameter(self):
pass

def testRemoveAlgorithm(self):
pass


def test_modelersagagrass(self):
outputs=sextante.runalg("modeler:sagagrass",points(),None)
output=outputs['CENTROIDS_ALG1']
Expand All @@ -39,32 +39,32 @@ def test_modelersagagrass(self):
self.assertEqual(expectedvalues, values)
wkt='POINT(270839.65586926 4458983.16267036)'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_modelersimplemodel(self):
outputs=sextante.runalg("modeler:simplemodel",raster(),None)
output=outputs['SLOPE_ALG0']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,1891122097)

def test_modelerfieldautoextent(self):
outputs=sextante.runalg("modeler:fieldautoextent",polygons(),"POLY_NUM_A",None)
output=outputs['USER_GRID_ALG0']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,2026100494)



def suite():
suite = unittest.makeSuite(ModelerAlgorithmTest, 'test')
suite = unittest.makeSuite(ModelerAlgorithmTest, 'test')
return suite

def runtests():
result = unittest.TestResult()
result = unittest.TestResult()
testsuite = suite()
testsuite.run(result)
return result

40 changes: 20 additions & 20 deletions python/plugins/sextante/tests/ParametersTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@ def testParameterNumber(self):
assert param.setValue(5)
assert param.value == 5
assert param.setValue(None)
assert param.value == param.default
assert param.value == param.default
s = param.serialize()
param2 = ParameterNumber()
param2.deserialize(s)
param2.deserialize(s)
assert param.default == param2.default
assert param.max == param2.max
assert param.min == param2.min
assert param.description == param2.description
assert param.name == param2.name
assert param.name == param2.name

def testParameterCRS(self):
param = ParameterCrs("name", "desc")
assert param.setValue("EPSG:12003")
param = ParameterCrs("name", "desc")
assert param.setValue("EPSG:12003")
assert param.value == "EPSG:12003"
assert param.setValue(None)
assert param.value == param.default
assert param.value == param.default
s = param.serialize()
param2 = ParameterCrs()
param2.deserialize(s)
assert param.default == param2.default
param2.deserialize(s)
assert param.default == param2.default
assert param.description == param2.description
assert param.name == param2.name
assert param.name == param2.name

def testParameterExtent(self):
param = ParameterExtent("name", "desc")
param = ParameterExtent("name", "desc")
assert not param.setValue("0,2,0")
assert not param.setValue("0,2,0,a")
assert not param.setValue("0,2,2,4")
assert not param.setValue("0,2,2,4")
assert param.value == "0,2,2,4"
assert param.setValue(None)
assert param.value == param.default
assert param.value == param.default
s = param.serialize()
param2 = ParameterExtent()
param2.deserialize(s)
assert param.default == param2.default
param2.deserialize(s)
assert param.default == param2.default
assert param.description == param2.description
assert param.name == param2.name
assert param.name == param2.name



if __name__ == '__main__':
unittest.main()
11 changes: 5 additions & 6 deletions python/plugins/sextante/tools/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from sextante.core.SextanteUtils import mkdir
from sextante.parameters.ParameterSelection import ParameterSelection

def createBaseHelpFile(alg, folder):
def createBaseHelpFile(alg, folder):
folder = os.path.join(folder, alg.provider.getName().lower())
mkdir(folder)
cmdLineName = alg.commandLineName()[alg.commandLineName().find(":") + 1:].lower()
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
safeFilename = ''.join(c for c in cmdLineName if c in validChars)
safeFilename = ''.join(c for c in cmdLineName if c in validChars)
filepath = os.path.join(folder, safeFilename + ".rst")
file = open(filepath, "w")
file.write(alg.name.upper())
Expand All @@ -24,9 +24,9 @@ def createBaseHelpFile(alg, folder):
file.write("\nOutputs\n")
file.write("-------\n\n")
for out in alg.outputs:
file.write("- ``" + out.description + "[" + out.outputTypeName()[6:] + "]``:\n")
file.write("- ``" + out.description + "[" + out.outputTypeName()[6:] + "]``:\n")
file.write("\nSee also\n")
file.write("---------\n\n")
file.write("---------\n\n")
file.write("\nConsole usage\n")
file.write("-------------\n\n")
file.write("\n::\n\n")
Expand All @@ -38,7 +38,7 @@ def createBaseHelpFile(alg, folder):
s+=str(out.name.lower().strip()) + ", "
s = s[:-2] +")\n"
file.write(s)

s =""
hasSelection = False
for param in alg.parameters:
Expand All @@ -59,4 +59,3 @@ def createBaseHelpFiles(folder):
for provider in Sextante.providers:
for alg in provider.algs:
createBaseHelpFile(alg, folder)

22 changes: 22 additions & 0 deletions src/app/composer/qgsatlascompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,27 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureKeyComboBox_currentIndexChan
}
}

void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int state )
{
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
if ( !atlasMap )
{
return;
}

if ( state == Qt::Checked )
{
mAtlasFeatureFilterEdit->setEnabled( true );
mAtlasFeatureFilterButton->setEnabled( true );
}
else
{
mAtlasFeatureFilterEdit->setEnabled( false );
mAtlasFeatureFilterButton->setEnabled( false );
}
atlasMap->setFilterFeatures( state == Qt::Checked );
}

void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_textChanged( const QString& text )
{
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
Expand Down Expand Up @@ -421,6 +442,7 @@ void QgsAtlasCompositionWidget::updateGuiElements()
mAtlasSortFeatureKeyComboBox->setCurrentIndex( atlasMap->sortKeyAttributeIndex() );
mAtlasSortFeatureDirectionButton->setArrowType( atlasMap->sortAscending() ? Qt::UpArrow : Qt::DownArrow );
mAtlasFeatureFilterEdit->setText( atlasMap->featureFilter() );
mAtlasFeatureFilterCheckBox->setCheckState( atlasMap->filterFeatures() ? Qt::Checked : Qt::Unchecked );
}

void QgsAtlasCompositionWidget::blockAllSignals( bool b )
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgsatlascompositionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class QgsAtlasCompositionWidget:
void on_mAtlasSortFeatureDirectionButton_clicked();
void on_mAtlasFeatureFilterEdit_textChanged( const QString& text );
void on_mAtlasFeatureFilterButton_clicked();
void on_mAtlasFeatureFilterCheckBox_stateChanged( int state );

// extract fields from the current coverage layer and populate the corresponding combo box
void fillSortColumns();
Expand Down
10 changes: 5 additions & 5 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,12 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
}
if ( !atlasOnASingleFile )
{
// bugs #7263 and #6856
// QPrinter does not seem to be reset correctly and may cause generated PDFs (all except the first) corrupted
// when transparent objects are rendered. We thus use a new QPrinter object here
QPrinter multiFilePrinter;
// bugs #7263 and #6856
// QPrinter does not seem to be reset correctly and may cause generated PDFs (all except the first) corrupted
// when transparent objects are rendered. We thus use a new QPrinter object here
QPrinter multiFilePrinter;
outputFileName = QDir( outputDir ).filePath( atlasMap->currentFilename() ) + ".pdf";
mComposition->beginPrintAsPDF( multiFilePrinter, outputFileName );
mComposition->beginPrintAsPDF( multiFilePrinter, outputFileName );
// set the correct resolution
mComposition->beginPrint( multiFilePrinter );
painter.begin( &multiFilePrinter );
Expand Down
118 changes: 98 additions & 20 deletions src/app/composer/qgscomposerlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,75 @@

#include <QMessageBox>

QgsComposerLegendWidgetStyleDelegate::QgsComposerLegendWidgetStyleDelegate( QObject *parent ): QItemDelegate( parent )
{
}

QWidget *QgsComposerLegendWidgetStyleDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem & item, const QModelIndex & index ) const
{
Q_UNUSED( item );
Q_UNUSED( index );
QgsDebugMsg( "Entered" );

QComboBox *editor = new QComboBox( parent );
QList<QgsComposerLegendStyle::Style> list;
list << QgsComposerLegendStyle::Group << QgsComposerLegendStyle::Subgroup << QgsComposerLegendStyle::Hidden;
foreach ( QgsComposerLegendStyle::Style s, list )
{
editor->addItem( QgsComposerLegendStyle::styleLabel( s ), s );
}

return editor;
}

void QgsComposerLegendWidgetStyleDelegate::setEditorData( QWidget *editor, const QModelIndex &index ) const
{
QgsDebugMsg( "Entered" );
//int s = index.model()->data(index, Qt::UserRole).toInt();
QComboBox *comboBox = static_cast<QComboBox*>( editor );

const QStandardItemModel * standardModel = dynamic_cast<const QStandardItemModel*>( index.model() );
if ( standardModel )
{
QModelIndex firstColumnIndex = standardModel->index( index.row(), 0, index.parent() );
QStandardItem* firstColumnItem = standardModel->itemFromIndex( firstColumnIndex );

QgsComposerLegendItem* cItem = dynamic_cast<QgsComposerLegendItem*>( firstColumnItem );
if ( cItem )
{
comboBox->setCurrentIndex( comboBox->findData( cItem->style() ) );
}
}
}

void QgsComposerLegendWidgetStyleDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
{
QgsDebugMsg( "Entered" );
QComboBox *comboBox = static_cast<QComboBox*>( editor );
QgsComposerLegendStyle::Style s = ( QgsComposerLegendStyle::Style ) comboBox->itemData( comboBox->currentIndex() ).toInt();
model->setData( index, s, Qt::UserRole );
model->setData( index, QgsComposerLegendStyle::styleLabel( s ), Qt::DisplayRole );
QStandardItemModel * standardModel = dynamic_cast<QStandardItemModel*>( model );
if ( standardModel )
{
QModelIndex firstColumnIndex = standardModel->index( index.row(), 0, index.parent() );
QStandardItem* firstColumnItem = standardModel->itemFromIndex( firstColumnIndex );

QgsComposerLegendItem* cItem = dynamic_cast<QgsComposerLegendItem*>( firstColumnItem );
if ( cItem )
{
cItem->setStyle( s );
}
}
}

void QgsComposerLegendWidgetStyleDelegate::updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & index ) const
{
Q_UNUSED( index );
editor->setGeometry( option.rect );
}


QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): mLegend( legend )
{
setupUi( this );
Expand All @@ -54,9 +123,15 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): m

if ( legend )
{
legend->model()->setHorizontalHeaderLabels( QStringList() << tr( "Item" ) << tr( "Style" ) );
mItemTreeView->setModel( legend->model() );
}

QgsComposerLegendWidgetStyleDelegate* styleDelegate = new QgsComposerLegendWidgetStyleDelegate();
mItemTreeView->setItemDelegateForColumn( 0, styleDelegate );
mItemTreeView->setItemDelegateForColumn( 1, styleDelegate );
mItemTreeView->setEditTriggers( QAbstractItemView::AllEditTriggers );

mItemTreeView->setDragEnabled( true );
mItemTreeView->setAcceptDrops( true );
mItemTreeView->setDropIndicatorShown( true );
Expand Down Expand Up @@ -93,10 +168,11 @@ void QgsComposerLegendWidget::setGuiElements()
mEqualColumnWidthCheckBox->setChecked( mLegend->equalColumnWidth() );
mSymbolWidthSpinBox->setValue( mLegend->symbolWidth() );
mSymbolHeightSpinBox->setValue( mLegend->symbolHeight() );
mGroupSpaceSpinBox->setValue( mLegend->groupSpace() );
mLayerSpaceSpinBox->setValue( mLegend->layerSpace() );
mSymbolSpaceSpinBox->setValue( mLegend->symbolSpace() );
mIconLabelSpaceSpinBox->setValue( mLegend->iconLabelSpace() );
mGroupSpaceSpinBox->setValue( mLegend->style( QgsComposerLegendStyle::Group ).margin( QgsComposerLegendStyle::Top ) );
mLayerSpaceSpinBox->setValue( mLegend->style( QgsComposerLegendStyle::Subgroup ).margin( QgsComposerLegendStyle::Top ) );
// We keep Symbol and SymbolLabel Top in sync for now
mSymbolSpaceSpinBox->setValue( mLegend->style( QgsComposerLegendStyle::Symbol ).margin( QgsComposerLegendStyle::Top ) );
mIconLabelSpaceSpinBox->setValue( mLegend->style( QgsComposerLegendStyle::SymbolLabel ).margin( QgsComposerLegendStyle::Left ) );
mBoxSpaceSpinBox->setValue( mLegend->boxSpace() );
mColumnSpaceSpinBox->setValue( mLegend->columnSpace() );
if ( mLegend->model() )
Expand Down Expand Up @@ -208,7 +284,7 @@ void QgsComposerLegendWidget::on_mGroupSpaceSpinBox_valueChanged( double d )
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend group space" ), QgsComposerMergeCommand::LegendGroupSpace );
mLegend->setGroupSpace( d );
mLegend->rstyle( QgsComposerLegendStyle::Group ).setMargin( QgsComposerLegendStyle::Top, d );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand All @@ -220,7 +296,7 @@ void QgsComposerLegendWidget::on_mLayerSpaceSpinBox_valueChanged( double d )
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend layer space" ), QgsComposerMergeCommand::LegendLayerSpace );
mLegend->setLayerSpace( d );
mLegend->rstyle( QgsComposerLegendStyle::Subgroup ).setMargin( QgsComposerLegendStyle::Top, d );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand All @@ -232,7 +308,9 @@ void QgsComposerLegendWidget::on_mSymbolSpaceSpinBox_valueChanged( double d )
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend symbol space" ), QgsComposerMergeCommand::LegendSymbolSpace );
mLegend->setSymbolSpace( d );
// We keep Symbol and SymbolLabel Top in sync for now
mLegend->rstyle( QgsComposerLegendStyle::Symbol ).setMargin( QgsComposerLegendStyle::Top, d );
mLegend->rstyle( QgsComposerLegendStyle::SymbolLabel ).setMargin( QgsComposerLegendStyle::Top, d );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand All @@ -244,7 +322,7 @@ void QgsComposerLegendWidget::on_mIconLabelSpaceSpinBox_valueChanged( double d )
if ( mLegend )
{
mLegend->beginCommand( tr( "Legend icon label space" ), QgsComposerMergeCommand::LegendIconSymbolSpace );
mLegend->setIconLabelSpace( d );
mLegend->rstyle( QgsComposerLegendStyle::SymbolLabel ).setMargin( QgsComposerLegendStyle::Left, d );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand All @@ -258,14 +336,14 @@ void QgsComposerLegendWidget::on_mTitleFontButton_clicked()
bool ok;
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->titleFont(), 0, QString(), QFontDialog::DontUseNativeDialog );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Title ).font(), 0, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->titleFont() );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Title ).font() );
#endif
if ( ok )
{
mLegend->beginCommand( tr( "Title font changed" ) );
mLegend->setTitleFont( newFont );
mLegend->setStyleFont( QgsComposerLegendStyle::Title, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand All @@ -280,14 +358,14 @@ void QgsComposerLegendWidget::on_mGroupFontButton_clicked()
bool ok;
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->groupFont(), 0, QString(), QFontDialog::DontUseNativeDialog );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Group ).font(), 0, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->groupFont() );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Group ).font() );
#endif
if ( ok )
{
mLegend->beginCommand( tr( "Legend group font changed" ) );
mLegend->setGroupFont( newFont );
mLegend->setStyleFont( QgsComposerLegendStyle::Group, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand All @@ -302,14 +380,14 @@ void QgsComposerLegendWidget::on_mLayerFontButton_clicked()
bool ok;
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->layerFont(), 0, QString(), QFontDialog::DontUseNativeDialog );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Subgroup ).font(), 0, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->layerFont() );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::Subgroup ).font() );
#endif
if ( ok )
{
mLegend->beginCommand( tr( "Legend layer font changed" ) );
mLegend->setLayerFont( newFont );
mLegend->setStyleFont( QgsComposerLegendStyle::Subgroup, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand All @@ -324,14 +402,14 @@ void QgsComposerLegendWidget::on_mItemFontButton_clicked()
bool ok;
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
QFont newFont = QFontDialog::getFont( &ok, mLegend->itemFont(), 0, QString(), QFontDialog::DontUseNativeDialog );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::SymbolLabel ).font(), 0, QString(), QFontDialog::DontUseNativeDialog );
#else
QFont newFont = QFontDialog::getFont( &ok, mLegend->itemFont() );
QFont newFont = QFontDialog::getFont( &ok, mLegend->style( QgsComposerLegendStyle::SymbolLabel ).font() );
#endif
if ( ok )
{
mLegend->beginCommand( tr( "Legend item font changed" ) );
mLegend->setItemFont( newFont );
mLegend->setStyleFont( QgsComposerLegendStyle::SymbolLabel, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
Expand Down
13 changes: 13 additions & 0 deletions src/app/composer/qgscomposerlegendwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,22 @@

#include "ui_qgscomposerlegendwidgetbase.h"
#include <QWidget>
#include <QItemDelegate>

class QgsComposerLegend;

class QgsComposerLegendWidgetStyleDelegate : public QItemDelegate
{
Q_OBJECT

public:
QgsComposerLegendWidgetStyleDelegate( QObject *parent = 0 );
QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const;
void setEditorData( QWidget *editor, const QModelIndex &index ) const;
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const;
void updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index ) const;
};

/** \ingroup MapComposer
* A widget for setting properties relating to a composer legend.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ int main( int argc, char *argv[] )
if ( !customizationfile.isEmpty() )
{
customizationsettings = new QSettings( customizationfile, QSettings::IniFormat );
QgsCustomization::instance()->setEnabled(true);
QgsCustomization::instance()->setEnabled( true );
}

// Load and set possible default customization, must be done afterQgsApplication init and QSettings ( QCoreApplication ) init
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b

QDialog* QgisAppInterface::getFeatureForm( QgsVectorLayer *l, QgsFeature &f )
{
QgsAttributeDialog *dialog = new QgsAttributeDialog( l, &f, false );
return dialog->dialog();
QgsAttributeDialog *dialog = new QgsAttributeDialog( l, &f, false );
return dialog->dialog();
}

QList<QgsMapLayer *> QgisAppInterface::editableLayers( bool modified ) const
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class QgisAppInterface : public QgisInterface
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false );

virtual QDialog* getFeatureForm(QgsVectorLayer *l, QgsFeature &f);
virtual QDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f );

/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
Expand Down
18 changes: 9 additions & 9 deletions src/app/qgscustomization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,15 +909,15 @@ void QgsCustomization::preNotify( QObject * receiver, QEvent * event, bool * don

QString QgsCustomization::splashPath()
{
if ( isEnabled() )
{
QString path = mSettings->value( "/Customization/splashpath", QgsApplication::splashPath() ).toString();
return path;
}
else
{
return QgsApplication::splashPath();
}
if ( isEnabled() )
{
QString path = mSettings->value( "/Customization/splashpath", QgsApplication::splashPath() ).toString();
return path;
}
else
{
return QgsApplication::splashPath();
}
}

void QgsCustomization::loadDefault()
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdiagramproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
setupUi( this );


mBackgroundColorButton->setColorDialogTitle( tr( "Background color" ) );
mBackgroundColorButton->setColorDialogTitle( tr( "Background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mDiagramPenColorButton->setColorDialogTitle( tr( "Pen color" ) );
mDiagramPenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgspluginregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void QgsPluginRegistry::loadPythonPlugin( QString packageName )
// if plugin is not compatible, disable it
if ( ! isPythonPluginCompatible( packageName ) )
{
QgsMessageLog::logMessage( QObject::tr("Plugin \"%1\" is not compatible with this version of Quantum GIS.\nIt will be disabled.").arg( packageName ),
QgsMessageLog::logMessage( QObject::tr( "Plugin \"%1\" is not compatible with this version of Quantum GIS.\nIt will be disabled." ).arg( packageName ),
QObject::tr( "Plugins" ) );
settings.setValue( "/PythonPlugins/" + packageName, false );
return;
Expand Down
200 changes: 102 additions & 98 deletions src/app/qtmain_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,128 +43,132 @@ static QSemaphore m_quitAppSemaphore;
static QList<QByteArray> m_applicationParams;
static const char * const QtNativeClassPathName = "org/kde/necessitas/industrius/QtNative";

extern "C" int main(int, char **); //use the standard main method to start the application
static void * startMainMethod(void * /*data*/)
extern "C" int main( int, char ** ); //use the standard main method to start the application
static void * startMainMethod( void * /*data*/ )
{

char ** params;
params=(char**)malloc(sizeof(char*)*m_applicationParams.length());
for (int i=0;i<m_applicationParams.size();i++)
params[i]= (char*)m_applicationParams[i].constData();

int ret = main(m_applicationParams.length(), params);

qDebug()<<"MainMethod finished, it's time to cleanup";
free(params);
Q_UNUSED(ret);

JNIEnv* env;
if (m_javaVM->AttachCurrentThread(&env, NULL)<0)
{
qCritical()<<"AttachCurrentThread failed";
return false;
}
jclass applicationClass = env->GetObjectClass(objptr);
if (applicationClass){
jmethodID quitApp = env->GetStaticMethodID(applicationClass, "quitApp", "()V");
env->CallStaticVoidMethod(applicationClass, quitApp);
}
m_javaVM->DetachCurrentThread();
return NULL;
char ** params;
params = ( char** )malloc( sizeof( char* ) * m_applicationParams.length() );
for ( int i = 0;i < m_applicationParams.size();i++ )
params[i] = ( char* )m_applicationParams[i].constData();

int ret = main( m_applicationParams.length(), params );

qDebug() << "MainMethod finished, it's time to cleanup";
free( params );
Q_UNUSED( ret );

JNIEnv* env;
if ( m_javaVM->AttachCurrentThread( &env, NULL ) < 0 )
{
qCritical() << "AttachCurrentThread failed";
return false;
}
jclass applicationClass = env->GetObjectClass( objptr );
if ( applicationClass )
{
jmethodID quitApp = env->GetStaticMethodID( applicationClass, "quitApp", "()V" );
env->CallStaticVoidMethod( applicationClass, quitApp );
}
m_javaVM->DetachCurrentThread();
return NULL;
}

static jboolean startQtApp(JNIEnv* env, jobject /*object*/, jstring paramsString, jstring environmentString)
static jboolean startQtApp( JNIEnv* env, jobject /*object*/, jstring paramsString, jstring environmentString )
{
qDebug()<<"startQtApp";
const char * nativeString = env->GetStringUTFChars(environmentString, 0);
QByteArray string=nativeString;
env->ReleaseStringUTFChars(environmentString, nativeString);
m_applicationParams=string.split('\t');
qDebug()<<"environmentString"<<string<<m_applicationParams;
foreach (string, m_applicationParams)
if (putenv(string.constData()))
qWarning()<<"Can't set environment"<<string;

nativeString = env->GetStringUTFChars(paramsString, 0);
string=nativeString;
env->ReleaseStringUTFChars(paramsString, nativeString);

qDebug()<<"paramsString"<<string;
m_applicationParams=string.split('\t');

// Go home
QDir::setCurrent(QDir::homePath());

pthread_t appThread;
return pthread_create(&appThread, NULL, startMainMethod, NULL)==0;
qDebug() << "startQtApp";
const char * nativeString = env->GetStringUTFChars( environmentString, 0 );
QByteArray string = nativeString;
env->ReleaseStringUTFChars( environmentString, nativeString );
m_applicationParams = string.split( '\t' );
qDebug() << "environmentString" << string << m_applicationParams;
foreach ( string, m_applicationParams )
if ( putenv( string.constData() ) )
qWarning() << "Can't set environment" << string;

nativeString = env->GetStringUTFChars( paramsString, 0 );
string = nativeString;
env->ReleaseStringUTFChars( paramsString, nativeString );

qDebug() << "paramsString" << string;
m_applicationParams = string.split( '\t' );

// Go home
QDir::setCurrent( QDir::homePath() );

pthread_t appThread;
return pthread_create( &appThread, NULL, startMainMethod, NULL ) == 0;
}


static JNINativeMethod methods[] = {
{"startQtApp", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApp}
static JNINativeMethod methods[] =
{
{"startQtApp", "(Ljava/lang/String;Ljava/lang/String;)V", ( void * )startQtApp}
};

/*
* Register several native methods for one class.
*/
static int registerNativeMethods(JNIEnv* env, const char* className,
JNINativeMethod* gMethods, int numMethods)
static int registerNativeMethods( JNIEnv* env, const char* className,
JNINativeMethod* gMethods, int numMethods )
{
jclass clazz=env->FindClass(className);
if (clazz == NULL)
{
__android_log_print(ANDROID_LOG_FATAL,"Qt", "Native registration unable to find class '%s'", className);
return JNI_FALSE;
}
jmethodID constr = env->GetMethodID(clazz, "<init>", "()V");
if(!constr) {
__android_log_print(ANDROID_LOG_FATAL,"Qt", "Native registration unable to find constructor for class '%s'", className);
return JNI_FALSE;;
}
jobject obj = env->NewObject(clazz, constr);
objptr = env->NewGlobalRef(obj);
if (env->RegisterNatives(clazz, gMethods, numMethods) < 0)
{
__android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed for '%s'", className);
return JNI_FALSE;
}
return JNI_TRUE;
jclass clazz = env->FindClass( className );
if ( clazz == NULL )
{
__android_log_print( ANDROID_LOG_FATAL, "Qt", "Native registration unable to find class '%s'", className );
return JNI_FALSE;
}
jmethodID constr = env->GetMethodID( clazz, "<init>", "()V" );
if ( !constr )
{
__android_log_print( ANDROID_LOG_FATAL, "Qt", "Native registration unable to find constructor for class '%s'", className );
return JNI_FALSE;;
}
jobject obj = env->NewObject( clazz, constr );
objptr = env->NewGlobalRef( obj );
if ( env->RegisterNatives( clazz, gMethods, numMethods ) < 0 )
{
__android_log_print( ANDROID_LOG_FATAL, "Qt", "RegisterNatives failed for '%s'", className );
return JNI_FALSE;
}
return JNI_TRUE;
}

/*
* Register native methods for all classes we know about.
*/
static int registerNatives(JNIEnv* env)
static int registerNatives( JNIEnv* env )
{
if (!registerNativeMethods(env, QtNativeClassPathName, methods, sizeof(methods) / sizeof(methods[0])))
return JNI_FALSE;
if ( !registerNativeMethods( env, QtNativeClassPathName, methods, sizeof( methods ) / sizeof( methods[0] ) ) )
return JNI_FALSE;

return JNI_TRUE;
return JNI_TRUE;
}

typedef union {
JNIEnv* nativeEnvironment;
void* venv;
typedef union
{
JNIEnv* nativeEnvironment;
void* venv;
} UnionJNIEnvToVoid;

Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
Q_DECL_EXPORT jint JNICALL JNI_OnLoad( JavaVM* vm, void* /*reserved*/ )
{
__android_log_print(ANDROID_LOG_INFO,"Qt", "qt start");
UnionJNIEnvToVoid uenv;
uenv.venv = NULL;
m_javaVM = 0;

if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK)
{
__android_log_print(ANDROID_LOG_FATAL,"Qt","GetEnv failed");
return -1;
}
m_env = uenv.nativeEnvironment;
if (!registerNatives(m_env))
{
__android_log_print(ANDROID_LOG_FATAL, "Qt", "registerNatives failed");
return -1;
}
m_javaVM = vm;
return JNI_VERSION_1_4;
__android_log_print( ANDROID_LOG_INFO, "Qt", "qt start" );
UnionJNIEnvToVoid uenv;
uenv.venv = NULL;
m_javaVM = 0;

if ( vm->GetEnv( &uenv.venv, JNI_VERSION_1_4 ) != JNI_OK )
{
__android_log_print( ANDROID_LOG_FATAL, "Qt", "GetEnv failed" );
return -1;
}
m_env = uenv.nativeEnvironment;
if ( !registerNatives( m_env ) )
{
__android_log_print( ANDROID_LOG_FATAL, "Qt", "registerNatives failed" );
return -1;
}
m_javaVM = vm;
return JNI_VERSION_1_4;
}
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ SET(QGIS_CORE_SRCS
composer/qgsatlascomposition.cpp
composer/qgslegendmodel.cpp
composer/qgscomposerlegend.cpp
composer/qgscomposerlegendstyle.cpp
composer/qgspaperitem.cpp
composer/qgsscalebarstyle.cpp
composer/qgsdoubleboxscalebarstyle.cpp
Expand Down Expand Up @@ -322,6 +323,7 @@ SET(QGIS_CORE_MOC_HDRS

composer/qgsaddremoveitemcommand.h
composer/qgscomposerlegend.h
composer/qgscomposerlegendstyle.h
composer/qgscomposermap.h
composer/qgscomposerpicture.h
composer/qgscomposerscalebar.h
Expand Down
18 changes: 13 additions & 5 deletions src/core/composer/qgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void QgsAtlasComposition::beginRender()
QgsFeatureIterator fit = mCoverageLayer->getFeatures();

std::auto_ptr<QgsExpression> filterExpression;
if ( mFeatureFilter.size() > 0 )
if ( mFilterFeatures )
{
filterExpression = std::auto_ptr<QgsExpression>( new QgsExpression( mFeatureFilter ) );
if ( filterExpression->hasParserError() )
Expand All @@ -134,7 +134,7 @@ void QgsAtlasComposition::beginRender()
mFeatureKeys.clear();
while ( fit.nextFeature( feat ) )
{
if ( mFeatureFilter.size() > 0 )
if ( mFilterFeatures )
{
QVariant result = filterExpression->evaluate( &feat, mCoverageLayer->pendingFields() );
if ( filterExpression->hasEvalError() )
Expand Down Expand Up @@ -228,7 +228,7 @@ void QgsAtlasComposition::prepareForFeature( size_t featureI )
if ( !mSingleFile && mFilenamePattern.size() > 0 )
{
QgsExpression::setSpecialColumn( "$feature", QVariant(( int )featureI + 1 ) );
QVariant filenameRes = mFilenameExpr->evaluate( &mCurrentFeature );
QVariant filenameRes = mFilenameExpr->evaluate( &mCurrentFeature, mCoverageLayer->pendingFields() );
if ( mFilenameExpr->hasEvalError() )
{
throw std::runtime_error( tr( "Filename eval error: %1" ).arg( mFilenameExpr->evalErrorString() ).toLocal8Bit().data() );
Expand Down Expand Up @@ -360,7 +360,11 @@ void QgsAtlasComposition::writeXML( QDomElement& elem, QDomDocument& doc ) const
atlasElem.setAttribute( "sortKey", QString::number( mSortKeyAttributeIdx ) );
atlasElem.setAttribute( "sortAscending", mSortAscending ? "true" : "false" );
}
atlasElem.setAttribute( "featureFilter", mFeatureFilter );
atlasElem.setAttribute( "filterFeatures", mFilterFeatures ? "true" : "false" );
if ( mFilterFeatures )
{
atlasElem.setAttribute( "featureFilter", mFeatureFilter );
}

elem.appendChild( atlasElem );
}
Expand Down Expand Up @@ -408,7 +412,11 @@ void QgsAtlasComposition::readXML( const QDomElement& atlasElem, const QDomDocum
mSortKeyAttributeIdx = atlasElem.attribute( "sortKey", "0" ).toInt();
mSortAscending = atlasElem.attribute( "sortAscending", "true" ) == "true" ? true : false;
}
mFeatureFilter = atlasElem.attribute( "featureFilter", "" );
mFilterFeatures = atlasElem.attribute( "filterFeatures", "false" ) == "true" ? true : false;
if ( mFilterFeatures )
{
mFeatureFilter = atlasElem.attribute( "featureFilter", "" );
}

emit parameterChanged();
}
7 changes: 6 additions & 1 deletion src/core/composer/qgsatlascomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
bool sortAscending() const { return mSortAscending; }
void setSortAscending( bool ascending ) { mSortAscending = ascending; }

bool filterFeatures() const { return mFilterFeatures; }
void setFilterFeatures( bool doFilter ) { mFilterFeatures = doFilter; }

QString featureFilter() const { return mFeatureFilter; }
void setFeatureFilter( const QString& expression ) { mFeatureFilter = expression; }

Expand Down Expand Up @@ -127,7 +130,9 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
// key (attribute index) used for ordering
size_t mSortKeyAttributeIdx;

// feature expression filter (or empty)
// feature filtering
bool mFilterFeatures;
// feature expression filter
QString mFeatureFilter;

// id of each iterated feature (after filtering and sorting)
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument&

//id
QString id = itemElem.attribute( "id", "" );
setId(id);
setId( id );

//frame
QString frame = itemElem.attribute( "frame" );
Expand Down Expand Up @@ -1268,7 +1268,7 @@ void QgsComposerItem::repaint()
}

void QgsComposerItem::setId( const QString& id )
{
{
setToolTip( id );
mId = id;
}
283 changes: 142 additions & 141 deletions src/core/composer/qgscomposerlegend.cpp

Large diffs are not rendered by default.

56 changes: 18 additions & 38 deletions src/core/composer/qgscomposerlegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef QGSCOMPOSERLEGEND_H
#define QGSCOMPOSERLEGEND_H

#include "qgscomposerlegendstyle.h"
#include "qgscomposeritem.h"
#include "qgscomposerlegenditem.h"
#include "qgslegendmodel.h"
Expand All @@ -33,10 +34,9 @@ class QgsComposerMap;
*/
class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
{
Q_OBJECT
Q_OBJECT;

public:

QgsComposerLegend( QgsComposition* composition );
~QgsComposerLegend();

Expand All @@ -60,38 +60,28 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
void setTitle( const QString& t ) {mTitle = t;}
QString title() const {return mTitle;}

QFont titleFont() const;
void setTitleFont( const QFont& f );

QFont groupFont() const;
void setGroupFont( const QFont& f );

QFont layerFont() const;
void setLayerFont( const QFont& f );
/** Returns reference to modifiable style */
QgsComposerLegendStyle & rstyle( QgsComposerLegendStyle::Style s ) { return mStyleMap[s]; }
/** Returns style */
QgsComposerLegendStyle style( QgsComposerLegendStyle::Style s ) const { return mStyleMap.value( s ); }
void setStyle( QgsComposerLegendStyle::Style s, const QgsComposerLegendStyle style ) { mStyleMap[s] = style; }

QFont itemFont() const;
void setItemFont( const QFont& f );
QFont styleFont( QgsComposerLegendStyle::Style s ) const { return style( s ).font(); }
/** Set style font */
void setStyleFont( QgsComposerLegendStyle::Style s, const QFont& f );

QColor fontColor() const {return mFontColor;}
void setFontColor( const QColor& c ) {mFontColor = c;}
/** Set style margin*/
void setStyleMargin( QgsComposerLegendStyle::Style s, double margin );
void setStyleMargin( QgsComposerLegendStyle::Style s, QgsComposerLegendStyle::Side side, double margin );

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

double columnSpace() const {return mColumnSpace;}
void setColumnSpace( double s ) { mColumnSpace = s;}

double groupSpace() const {return mGroupSpace;}
void setGroupSpace( double s ) {mGroupSpace = s;}

double layerSpace() const {return mLayerSpace;}
void setLayerSpace( double s ) {mLayerSpace = s;}

double symbolSpace() const {return mSymbolSpace;}
void setSymbolSpace( double s ) {mSymbolSpace = s;}

double iconLabelSpace() const {return mIconLabelSpace;}
void setIconLabelSpace( double s ) {mIconLabelSpace = s;}
QColor fontColor() const {return mFontColor;}
void setFontColor( const QColor& c ) {mFontColor = c;}

double symbolWidth() const {return mSymbolWidth;}
void setSymbolWidth( double w ) {mSymbolWidth = w;}
Expand Down Expand Up @@ -139,25 +129,13 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
QString mTitle;
QString mWrapChar;

//different fonts for entries
QFont mTitleFont;
QFont mGroupFont;
QFont mLayerFont;
QFont mItemFont;
QColor mFontColor;

/**Space between item box and contents*/
qreal mBoxSpace;
/**Space between columns*/
double mColumnSpace;
/**Vertical space between group entries*/
double mGroupSpace;
/**Vertical space between layer entries*/
double mLayerSpace;
/**Vertical space between symbol entries*/
double mSymbolSpace;
/**Horizontal space between item icon and label*/
double mIconLabelSpace;

/**Width of symbol icon*/
double mSymbolWidth;
/**Height of symbol icon*/
Expand Down Expand Up @@ -257,6 +235,8 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
/** Splits a string using the wrap char taking into account handling empty
wrap char which means no wrapping */
QStringList splitStringForWrapping( QString stringToSplt );

QMap<QgsComposerLegendStyle::Style, QgsComposerLegendStyle> mStyleMap;
};

#endif
85 changes: 68 additions & 17 deletions src/core/composer/qgscomposerlegenditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
* *
***************************************************************************/

#include "qgscomposerlegendstyle.h"
#include "qgscomposerlegenditem.h"
#include "qgscomposerlegend.h"
#include "qgsmaplayerregistry.h"
#include "qgsrasterlayer.h"
#include "qgsrenderer.h"
#include "qgsrendererv2.h"
#include "qgssymbol.h"
#include "qgssymbolv2.h"
#include "qgssymbollayerv2utils.h"
Expand All @@ -26,15 +30,18 @@
#include <QDomDocument>
#include <QDomElement>

QgsComposerLegendItem::QgsComposerLegendItem(): QStandardItem()
QgsComposerLegendItem::QgsComposerLegendItem( QgsComposerLegendStyle::Style s ): QStandardItem()
, mStyle( s )
{
}

QgsComposerLegendItem::QgsComposerLegendItem( const QString& text ): QStandardItem( text )
QgsComposerLegendItem::QgsComposerLegendItem( const QString& text, QgsComposerLegendStyle::Style s ): QStandardItem( text )
, mStyle( s )
{
}

QgsComposerLegendItem::QgsComposerLegendItem( const QIcon& icon, const QString& text ): QStandardItem( icon, text )
QgsComposerLegendItem::QgsComposerLegendItem( const QIcon& icon, const QString& text, QgsComposerLegendStyle::Style s ): QStandardItem( icon, text )
, mStyle( s )
{
}

Expand All @@ -58,15 +65,15 @@ void QgsComposerLegendItem::writeXMLChildren( QDomElement& elem, QDomDocument& d

//////////////////////////////QgsComposerSymbolItem

QgsComposerSymbolItem::QgsComposerSymbolItem(): QgsComposerLegendItem(), mSymbol( 0 )
QgsComposerSymbolItem::QgsComposerSymbolItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Symbol ), mSymbol( 0 )
{
}

QgsComposerSymbolItem::QgsComposerSymbolItem( const QString& text ): QgsComposerLegendItem( text ), mSymbol( 0 )
QgsComposerSymbolItem::QgsComposerSymbolItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Symbol ), mSymbol( 0 )
{
}

QgsComposerSymbolItem::QgsComposerSymbolItem( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text ), mSymbol( 0 )
QgsComposerSymbolItem::QgsComposerSymbolItem( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text, QgsComposerLegendStyle::Symbol ), mSymbol( 0 )
{
}

Expand Down Expand Up @@ -155,15 +162,15 @@ void QgsComposerSymbolItem::readXML( const QDomElement& itemElem, bool xServerAv

#include "qgssymbolv2.h"

QgsComposerSymbolV2Item::QgsComposerSymbolV2Item(): QgsComposerLegendItem(), mSymbolV2( 0 )
QgsComposerSymbolV2Item::QgsComposerSymbolV2Item(): QgsComposerLegendItem( QgsComposerLegendStyle::Symbol ), mSymbolV2( 0 )
{
}

QgsComposerSymbolV2Item::QgsComposerSymbolV2Item( const QString& text ): QgsComposerLegendItem( text ), mSymbolV2( 0 )
QgsComposerSymbolV2Item::QgsComposerSymbolV2Item( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Symbol ), mSymbolV2( 0 )
{
}

QgsComposerSymbolV2Item::QgsComposerSymbolV2Item( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text ), mSymbolV2( 0 )
QgsComposerSymbolV2Item::QgsComposerSymbolV2Item( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text, QgsComposerLegendStyle::Symbol ), mSymbolV2( 0 )
{
}

Expand Down Expand Up @@ -234,15 +241,15 @@ void QgsComposerSymbolV2Item::setSymbolV2( QgsSymbolV2* s )

////////////////////QgsComposerRasterSymbolItem

QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem(): QgsComposerLegendItem()
QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Symbol )
{
}

QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem( const QString& text ): QgsComposerLegendItem( text )
QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Symbol )
{
}

QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text )
QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text, QgsComposerLegendStyle::Symbol )
{
}

Expand Down Expand Up @@ -287,12 +294,12 @@ void QgsComposerRasterSymbolItem::readXML( const QDomElement& itemElem, bool xSe

////////////////////QgsComposerLayerItem

QgsComposerLayerItem::QgsComposerLayerItem(): QgsComposerLegendItem()
QgsComposerLayerItem::QgsComposerLayerItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Subgroup )
, mShowFeatureCount( false )
{
}

QgsComposerLayerItem::QgsComposerLayerItem( const QString& text ): QgsComposerLegendItem( text )
QgsComposerLayerItem::QgsComposerLayerItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Subgroup )
, mShowFeatureCount( false )
{
}
Expand All @@ -315,6 +322,7 @@ void QgsComposerLayerItem::writeXML( QDomElement& elem, QDomDocument& doc ) cons
layerItemElem.setAttribute( "layerId", mLayerID );
layerItemElem.setAttribute( "text", text() );
layerItemElem.setAttribute( "showFeatureCount", showFeatureCount() );
layerItemElem.setAttribute( "style", QgsComposerLegendStyle::styleName( mStyle ) );
writeXMLChildren( layerItemElem, doc );
elem.appendChild( layerItemElem );
}
Expand All @@ -328,6 +336,7 @@ void QgsComposerLayerItem::readXML( const QDomElement& itemElem, bool xServerAva
setText( itemElem.attribute( "text", "" ) );
setLayerID( itemElem.attribute( "layerId", "" ) );
setShowFeatureCount( itemElem.attribute( "showFeatureCount", "" ) == "1" ? true : false );
setStyle( QgsComposerLegendStyle::styleFromName( itemElem.attribute( "style", "subgroup" ) ) );

//now call readXML for all the child items
QDomNodeList childList = itemElem.childNodes();
Expand Down Expand Up @@ -367,13 +376,36 @@ void QgsComposerLayerItem::readXML( const QDomElement& itemElem, bool xServerAva
}
}

void QgsComposerLayerItem::setDefaultStyle()
{
// set default style according to number of symbols
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerID() ) );
if ( vLayer )
{
QgsFeatureRendererV2* renderer = vLayer->rendererV2();
if ( renderer )
{
QPair<QString, QgsSymbolV2*> symbolItem = renderer->legendSymbolItems().value( 0 );
if ( renderer->legendSymbolItems().size() > 1 || !symbolItem.first.isEmpty() )
{
setStyle( QgsComposerLegendStyle::Subgroup );
}
else
{
// Hide title by default for single symbol
setStyle( QgsComposerLegendStyle::Hidden );
}
}
}
}

////////////////////QgsComposerGroupItem

QgsComposerGroupItem::QgsComposerGroupItem(): QgsComposerLegendItem()
QgsComposerGroupItem::QgsComposerGroupItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Group )
{
}

QgsComposerGroupItem::QgsComposerGroupItem( const QString& text ): QgsComposerLegendItem( text )
QgsComposerGroupItem::QgsComposerGroupItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Group )
{
}

Expand All @@ -392,6 +424,7 @@ void QgsComposerGroupItem::writeXML( QDomElement& elem, QDomDocument& doc ) cons
{
QDomElement layerGroupElem = doc.createElement( "GroupItem" );
layerGroupElem.setAttribute( "text", text() );
layerGroupElem.setAttribute( "style", QgsComposerLegendStyle::styleName( mStyle ) );
writeXMLChildren( layerGroupElem, doc );
elem.appendChild( layerGroupElem );
}
Expand All @@ -404,6 +437,8 @@ void QgsComposerGroupItem::readXML( const QDomElement& itemElem, bool xServerAva
}
setText( itemElem.attribute( "text", "" ) );

setStyle( QgsComposerLegendStyle::styleFromName( itemElem.attribute( "style", "group" ) ) );

//now call readXML for all the child items
QDomNodeList childList = itemElem.childNodes();
QDomNode currentNode;
Expand Down Expand Up @@ -435,6 +470,22 @@ void QgsComposerGroupItem::readXML( const QDomElement& itemElem, bool xServerAva
continue; //unsupported child item type
}
currentChildItem->readXML( currentElem, xServerAvailable );
appendRow( currentChildItem );

QList<QStandardItem *> itemsList;
itemsList << currentChildItem << new QgsComposerStyleItem( currentChildItem );
appendRow( itemsList );
}
}

QgsComposerStyleItem::QgsComposerStyleItem(): QStandardItem()
{
}

QgsComposerStyleItem::QgsComposerStyleItem( QgsComposerLegendItem *item ): QStandardItem()
{
setData( QgsComposerLegendStyle::styleLabel( item->style() ) , Qt::DisplayRole );
}

QgsComposerStyleItem::~QgsComposerStyleItem()
{
}
25 changes: 21 additions & 4 deletions src/core/composer/qgscomposerlegenditem.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef QGSCOMPOSERLEGENDITEM_H
#define QGSCOMPOSERLEGENDITEM_H

#include "qgscomposerlegendstyle.h"
#include <QStandardItem>
class QDomDocument;
class QDomElement;
Expand All @@ -26,9 +27,9 @@ class QDomElement;
class CORE_EXPORT QgsComposerLegendItem: public QStandardItem
{
public:
QgsComposerLegendItem();
QgsComposerLegendItem( const QString& text );
QgsComposerLegendItem( const QIcon& icon, const QString& text );
QgsComposerLegendItem( QgsComposerLegendStyle::Style s = QgsComposerLegendStyle::Undefined );
QgsComposerLegendItem( const QString& text, QgsComposerLegendStyle::Style s = QgsComposerLegendStyle::Undefined );
QgsComposerLegendItem( const QIcon& icon, const QString& text, QgsComposerLegendStyle::Style s = QgsComposerLegendStyle::Undefined );
virtual ~QgsComposerLegendItem();

enum ItemType
Expand All @@ -37,7 +38,8 @@ class CORE_EXPORT QgsComposerLegendItem: public QStandardItem
LayerItem,
SymbologyItem,
SymbologyV2Item,
RasterSymbolItem
RasterSymbolItem,
StyleItem
};

virtual void writeXML( QDomElement& elem, QDomDocument& doc ) const = 0;
Expand All @@ -49,8 +51,13 @@ class CORE_EXPORT QgsComposerLegendItem: public QStandardItem
virtual ItemType itemType() const = 0;
virtual QStandardItem* clone() const = 0;

QgsComposerLegendStyle::Style style() const { return mStyle; }
void setStyle( QgsComposerLegendStyle::Style style ) { mStyle = style; }

protected:
void writeXMLChildren( QDomElement& elem, QDomDocument& doc ) const;

QgsComposerLegendStyle::Style mStyle;
};

class QgsSymbol;
Expand Down Expand Up @@ -151,6 +158,8 @@ class CORE_EXPORT QgsComposerLayerItem: public QgsComposerLegendItem
void setShowFeatureCount( bool show ) { mShowFeatureCount = show; }
bool showFeatureCount() const { return mShowFeatureCount; }

void setDefaultStyle();

private:
QString mLayerID;
// Show vector feature counts
Expand All @@ -171,4 +180,12 @@ class CORE_EXPORT QgsComposerGroupItem: public QgsComposerLegendItem
ItemType itemType() const { return GroupItem; }
};

class CORE_EXPORT QgsComposerStyleItem: public QStandardItem
{
public:
QgsComposerStyleItem( );
QgsComposerStyleItem( QgsComposerLegendItem *item );
~QgsComposerStyleItem();
};

#endif // QGSCOMPOSERLEGENDITEM_H
126 changes: 126 additions & 0 deletions src/core/composer/qgscomposerlegendstyle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/***************************************************************************
qgscomposerlegendstyle.cpp
---------------------
begin : March 2013
copyright : (C) 2013 by Radim Blazek
email : radim.blazek@gmail.com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgscomposerlegendstyle.h"
#include <QFont>
#include <QMap>
#include <QString>
#include <QDomElement>
#include <QDomDocument>
#include <QDomNode>

QgsComposerLegendStyle::QgsComposerLegendStyle()
{
}

QgsComposerLegendStyle::~QgsComposerLegendStyle()
{
}

void QgsComposerLegendStyle::setMargin( double margin )
{
mMarginMap[Top] = margin;
mMarginMap[Bottom] = margin;
mMarginMap[Left] = margin;
mMarginMap[Right] = margin;
}

void QgsComposerLegendStyle::writeXML( QString name, QDomElement& elem, QDomDocument & doc ) const
{
if ( elem.isNull() ) return;

QDomElement styleElem = doc.createElement( "style" );

styleElem.setAttribute( "name", name );

styleElem.setAttribute( "marginTop", QString::number( mMarginMap[Top] ) );
styleElem.setAttribute( "marginBottom", QString::number( mMarginMap[Bottom] ) );
styleElem.setAttribute( "marginLeft", QString::number( mMarginMap[Left] ) );
styleElem.setAttribute( "marginRight", QString::number( mMarginMap[Right] ) );

styleElem.setAttribute( "font", mFont.toString() );

elem.appendChild( styleElem );
}

void QgsComposerLegendStyle::readXML( const QDomElement& elem, const QDomDocument& doc )
{
Q_UNUSED( doc );
if ( elem.isNull() ) return;

mFont.fromString( elem.attribute( "font" ) );

mMarginMap[Top] = elem.attribute( "marginTop" ).toDouble();
mMarginMap[Bottom] = elem.attribute( "marginBottom" ).toDouble();
mMarginMap[Left] = elem.attribute( "marginLeft" ).toDouble();
mMarginMap[Right] = elem.attribute( "marginRight" ).toDouble();
}

QString QgsComposerLegendStyle::styleName ( Style s )
{
switch ( s )
{
case Undefined:
return "";
case Hidden:
return "hidden";
case Title:
return "title";
case Group:
return "group";
case Subgroup:
return "subgroup";
case Symbol:
return "symbol";
case SymbolLabel:
return "symbolLabel";
}
return "";
}

QgsComposerLegendStyle::Style QgsComposerLegendStyle::styleFromName ( QString styleName )
{
if ( styleName == "hidden" ) return Hidden;
else if ( styleName == "title" ) return Title;
else if ( styleName == "group" ) return Group;
else if ( styleName == "subgroup" ) return Subgroup;
else if ( styleName == "symbol" ) return Symbol;
else if ( styleName == "symbolLabel" ) return SymbolLabel;
return Undefined;
}

QString QgsComposerLegendStyle::styleLabel ( Style s )
{
switch ( s )
{
case Undefined:
return QObject::tr("Undefined");
case Hidden:
return QObject::tr("Hidden");
case Title:
return QObject::tr("Title");
case Group:
return QObject::tr("Group");
case Subgroup:
return QObject::tr("Subgroup");
case Symbol:
return QObject::tr("Symbol");
case SymbolLabel:
return QObject::tr("Symbol label");
}
return "";
}
82 changes: 82 additions & 0 deletions src/core/composer/qgscomposerlegendstyle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/***************************************************************************
qgscomposerlegendstyle.h
-------------------
begin : March 2013
copyright : (C) 2013 by Radim Blazek
email : radim.blazek@gmail.com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSCOMPOSERLEGENDSTYLE_H
#define QGSCOMPOSERLEGENDSTYLE_H

#include <QFont>
#include <QMap>
#include <QString>
#include <QDomElement>
#include <QDomDocument>

/** \ingroup MapComposer
* Composer legend components style
*/
class CORE_EXPORT QgsComposerLegendStyle
{
public:
enum Style
{
Undefined, // should not happen, only if corrupted project file
Hidden, // special style, item is hidden includeing margins around
Title,
Group,
Subgroup, // layer
Symbol, // symbol without label
SymbolLabel
};
enum Side // margin side
{
Top = 0,
Bottom = 1,
Left = 2,
Right = 3
};
QgsComposerLegendStyle();
~QgsComposerLegendStyle();

QFont font() const { return mFont; }
QFont & rfont() { return mFont; }
void setFont( const QFont & font ) { mFont = font; }

double margin( Side side ) { return mMarginMap.value( side ); }
void setMargin( Side side, double margin ) { mMarginMap[side] = margin; }

// set all margins
void setMargin( double margin );

void writeXML( QString name, QDomElement& elem, QDomDocument & doc ) const;

void readXML( const QDomElement& elem, const QDomDocument& doc );

/** Get name for style, used in project file */
static QString styleName ( Style s );

/** Get style from name, used in project file */
static Style styleFromName ( QString styleName );

/** Get style label, translated, used in UI */
static QString styleLabel ( Style s );

private:
QFont mFont;
// Space around element
QMap<Side,double> mMarginMap;
};

#endif
55 changes: 45 additions & 10 deletions src/core/composer/qgslegendmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

QgsLegendModel::QgsLegendModel(): QStandardItemModel(), mAutoUpdate( true )
{
setColumnCount( 2 );

if ( QgsMapLayerRegistry::instance() )
{
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) );
Expand Down Expand Up @@ -82,7 +84,6 @@ void QgsLegendModel::setLayerSetAndGroups( const QStringList& layerIds, const QL
{
return; //should never happen
}
//QString layerID = currentItem->data(Qt::UserRole + 2).toString();
QString layerID = layerItem->layerID();
if ( layerList.contains( layerID ) )
{
Expand Down Expand Up @@ -123,14 +124,15 @@ QStandardItem* QgsLegendModel::addGroup( QString text, int position )
text = tr( "Group" );

QgsComposerGroupItem* groupItem = new QgsComposerGroupItem( text );

if ( position == -1 )
{
invisibleRootItem()->insertRow( invisibleRootItem()->rowCount(), groupItem );
}
else
{
invisibleRootItem()->insertRow( position, groupItem );
position = invisibleRootItem()->rowCount();
}
QList<QStandardItem *> itemsList;
itemsList << groupItem << new QgsComposerStyleItem( groupItem );
invisibleRootItem()->insertRow( position, itemsList );

emit layersChanged();
return groupItem;
}
Expand Down Expand Up @@ -377,9 +379,12 @@ void QgsLegendModel::addLayer( QgsMapLayer* theMapLayer )

QgsComposerLayerItem* layerItem = new QgsComposerLayerItem( theMapLayer->name() );
layerItem->setLayerID( theMapLayer->id() );
layerItem->setDefaultStyle();
layerItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );

invisibleRootItem()->setChild( invisibleRootItem()->rowCount(), layerItem );
QList<QStandardItem *> itemsList;
itemsList << layerItem << new QgsComposerStyleItem( layerItem );
invisibleRootItem()->appendRow( itemsList );

switch ( theMapLayer->type() )
{
Expand Down Expand Up @@ -548,7 +553,10 @@ bool QgsLegendModel::readXML( const QDomElement& legendModelElem, const QDomDocu
currentItem = new QgsComposerGroupItem();
}
currentItem->readXML( currentElem, mHasTopLevelWindow );
appendRow( currentItem );

QList<QStandardItem *> itemsList;
itemsList << currentItem << new QgsComposerStyleItem( currentItem );
appendRow( itemsList );
}

setAutoUpdate( legendModelElem.attribute( "autoUpdate", "1" ).toInt() );
Expand Down Expand Up @@ -585,6 +593,29 @@ Qt::ItemFlags QgsLegendModel::flags( const QModelIndex &index ) const
flags |= Qt::ItemIsDragEnabled;
}
}
if ( index.column() == 1 && item )
{
// Style
QStandardItem* firstColumnItem = 0;
if ( item->parent() )
{
firstColumnItem = item->parent()->child( index.row(), 0 );
}
else
{
firstColumnItem = QgsLegendModel::item( index.row(), 0 );
}
cItem = dynamic_cast<QgsComposerLegendItem*>( firstColumnItem );

if ( cItem )
{
if ( cItem->itemType() == QgsComposerLegendItem::GroupItem ||
cItem->itemType() == QgsComposerLegendItem::LayerItem )
{
flags |= Qt::ItemIsEditable;
}
}
}
return flags;
}

Expand Down Expand Up @@ -706,14 +737,18 @@ bool QgsLegendModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
continue;
}
currentItem->readXML( currentElem );
int index;
if ( row < 0 )
{
dropIntoItem->insertRow( dropIntoItem->rowCount(), currentItem );
index = dropIntoItem->rowCount();
}
else
{
dropIntoItem->insertRow( row + i, currentItem );
index = row + i;
}
QList<QStandardItem *> itemsList;
itemsList << currentItem << new QgsComposerStyleItem( currentItem );
dropIntoItem->insertRow( index, itemsList );
}
emit layersChanged();
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsfeaturerequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ QgsFeatureRequest::QgsFeatureRequest()
}

QgsFeatureRequest::QgsFeatureRequest( QgsFeatureId fid )
: mFilter( FilterFid )
, mFilterFid( fid )
, mFlags( 0 )
: mFilter( FilterFid )
, mFilterFid( fid )
, mFlags( 0 )
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsmaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
RasterLayer,
PluginLayer // added in 1.5
};

/** Blending modes enum defining the available composition modes that can
* be used when rendering a layer
*/
Expand Down Expand Up @@ -492,7 +492,7 @@ class CORE_EXPORT QgsMapLayer : public QObject

/** Type of the layer (eg. vector, raster) */
QgsMapLayer::LayerType mLayerType;

/** Blend mode for the layer */
QgsMapLayer::BlendMode mBlendMode;

Expand Down
49 changes: 32 additions & 17 deletions src/core/qgsogcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLPoint( const QDomElement& geometryEleme
{
return 0;
}
} else {
}
else
{
QDomNodeList posList = geometryElement.elementsByTagNameNS( GML_NAMESPACE, "pos" );
if ( posList.size() < 1 )
{
Expand Down Expand Up @@ -150,7 +152,9 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLLineString( const QDomElement& geometry
{
return 0;
}
} else {
}
else
{
QDomNodeList posList = geometryElement.elementsByTagNameNS( GML_NAMESPACE, "posList" );
if ( posList.size() < 1 )
{
Expand Down Expand Up @@ -235,7 +239,9 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLPolygon( const QDomElement& geometryEle
}
ringCoordinates.push_back( interiorPointList );
}
} else {
}
else
{
//read coordinates for exterior
QDomNodeList exteriorList = geometryElement.elementsByTagNameNS( GML_NAMESPACE, "exterior" );
if ( exteriorList.size() < 1 ) //outer ring is necessary
Expand Down Expand Up @@ -359,7 +365,9 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLMultiPoint( const QDomElement& geometry
}
pointList.push_back(( *currentPoint.begin() ) );
continue;
} else {
}
else
{
//<pos> element
posList = pointNodeList.at( 0 ).toElement().elementsByTagNameNS( GML_NAMESPACE, "pos" );
if ( posList.size() < 1 )
Expand Down Expand Up @@ -455,7 +463,9 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLMultiLineString( const QDomElement& geo
return 0;
}
lineCoordinates.push_back( currentPointList );
} else {
}
else
{
currentPosList = currentLineStringElement.elementsByTagNameNS( GML_NAMESPACE, "posList" );
if ( currentPosList.size() < 1 )
{
Expand Down Expand Up @@ -488,7 +498,9 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLMultiLineString( const QDomElement& geo
}
lineCoordinates.push_back( currentPointList );
return 0;
} else {
}
else
{
currentPosList = currentLineStringElement.elementsByTagNameNS( GML_NAMESPACE, "posList" );
if ( currentPosList.size() < 1 )
{
Expand Down Expand Up @@ -646,7 +658,9 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLMultiPolygon( const QDomElement& geomet
}
currentPolygonList.push_back( ringCoordinates );
}
} else {
}
else
{
//find exterior ring
exteriorList = currentPolygonElement.elementsByTagNameNS( GML_NAMESPACE, "exterior" );
if ( exteriorList.size() < 1 )
Expand Down Expand Up @@ -880,13 +894,14 @@ bool QgsOgcUtils::readGMLPositions( std::list<QgsPoint>& coords, const QDomEleme
}
}

for (int i=0; i<posSize/srsDimension; i++) {
x = pos.at( i*srsDimension ).toDouble( &conversionSuccess );
for ( int i = 0; i < posSize / srsDimension; i++ )
{
x = pos.at( i * srsDimension ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
return 1;
}
y = pos.at( i*srsDimension+1 ).toDouble( &conversionSuccess );
y = pos.at( i * srsDimension + 1 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
return 1;
Expand Down Expand Up @@ -1054,18 +1069,18 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc
case QGis::WKBPoint:
case QGis::WKBMultiPoint25D:
case QGis::WKBMultiPoint:
baseCoordElem = doc.createElement( "gml:pos");;
baseCoordElem = doc.createElement( "gml:pos" );;
break;
default:
baseCoordElem = doc.createElement( "gml:posList");;
baseCoordElem = doc.createElement( "gml:posList" );;
break;
}
baseCoordElem.setAttribute( "srsDimension", "2" );
cs = " ";
}
else
{
baseCoordElem = doc.createElement( "gml:coordinates");;
baseCoordElem = doc.createElement( "gml:coordinates" );;
baseCoordElem.setAttribute( "cs", cs );
baseCoordElem.setAttribute( "ts", ts );
}
Expand Down Expand Up @@ -1341,11 +1356,11 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc

QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc )
{
return geometryToGML( geometry, doc, "GML2");
return geometryToGML( geometry, doc, "GML2" );
}

QDomElement QgsOgcUtils::createGMLCoordinates( const QVector<QgsPoint> points, QDomDocument& doc )
{
{
QDomElement coordElem = doc.createElement( "gml:coordinates" );
coordElem.setAttribute( "cs", "," );
coordElem.setAttribute( "ts", " " );
Expand All @@ -1369,7 +1384,7 @@ QDomElement QgsOgcUtils::createGMLCoordinates( const QVector<QgsPoint> points, Q
}

QDomElement QgsOgcUtils::createGMLPositions( const QVector<QgsPoint> points, QDomDocument& doc )
{
{
QDomElement posElem = doc.createElement( "gml:pos" );
if ( points.size() > 1 )
posElem = doc.createElement( "gml:posList" );
Expand Down Expand Up @@ -2076,7 +2091,7 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
Q_ASSERT( argNodes.count() == 2 ); // binary spatial ops must have two args

QgsExpression::Node* otherNode = 0;
if ( isGeometryColumn( argNodes[0]) )
if ( isGeometryColumn( argNodes[0] ) )
otherNode = argNodes[1];
else if ( isGeometryColumn( argNodes[1] ) )
otherNode = argNodes[0];
Expand Down
146 changes: 73 additions & 73 deletions src/core/qgsogcutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,88 +29,88 @@ class CORE_EXPORT QgsOgcUtils
{
public:

/** static method that creates geometry from GML
@param XML representation of the geometry. GML elements are expected to be
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
*/
static QgsGeometry* geometryFromGML( const QString& xmlString );

/** static method that creates geometry from GML
*/
static QgsGeometry* geometryFromGML( const QDomNode& geometryNode );

/** read rectangle from GML2 Box */
static QgsRectangle rectangleFromGMLBox( const QDomNode& boxNode );

/** read rectangle from GML3 Envelope */
static QgsRectangle rectangleFromGMLEnvelope( const QDomNode& envelopeNode );

/** Exports the geometry to GML2 or GML3
@return QDomELement
*/
static QDomElement geometryToGML( QgsGeometry* geometry, QDomDocument& doc, QString format );

/** Exports the geometry to GML2
@return QDomElement
*/
static QDomElement geometryToGML( QgsGeometry* geometry, QDomDocument& doc );

/** Exports the rectangle to GML2 Box
@return QDomElement
*/
static QDomElement rectangleToGMLBox( QgsRectangle* box, QDomDocument& doc );

/** Exports the rectangle to GML2 Envelope
@return QDomElement
*/
static QDomElement rectangleToGMLEnvelope( QgsRectangle* env, QDomDocument& doc );


/** Parse XML with OGC filter into QGIS expression */
static QgsExpression* expressionFromOgcFilter( const QDomElement& element );

/** Creates OGC filter XML element. Supports minimum standard filter according to the OGC filter specs (=,!=,<,>,<=,>=,AND,OR,NOT)
@return valid <Filter> QDomElement on success, otherwise null QDomElement
*/
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage = 0 );

private:
/** static method that creates geometry from GML Point */
static QgsGeometry* geometryFromGMLPoint( const QDomElement& geometryElement );
/** static method that creates geometry from GML LineString */
static QgsGeometry* geometryFromGMLLineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML Polygon */
static QgsGeometry* geometryFromGMLPolygon( const QDomElement& geometryElement );
/** static method that creates geometry from GML MultiPoint */
static QgsGeometry* geometryFromGMLMultiPoint( const QDomElement& geometryElement );
/** static method that creates geometry from GML MultiLineString */
static QgsGeometry* geometryFromGMLMultiLineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML MultiPolygon */
static QgsGeometry* geometryFromGMLMultiPolygon( const QDomElement& geometryElement );
/** Reads the <gml:coordinates> element and extracts the coordinates as points
@param coords list where the found coordinates are appended
@param elem the <gml:coordinates> element
@return boolean for success*/
static bool readGMLCoordinates( std::list<QgsPoint>& coords, const QDomElement elem );
/** Reads the <gml:pos> or <gml:posList> element and extracts the coordinates as points
@param coords list where the found coordinates are appended
@param elem the <gml:pos> or <gml:posList> element
@return boolean for success*/
static bool readGMLPositions( std::list<QgsPoint>& coords, const QDomElement elem );

/** static method that creates geometry from GML
@param XML representation of the geometry. GML elements are expected to be
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
*/
static QgsGeometry* geometryFromGML( const QString& xmlString );

/** static method that creates geometry from GML
*/
static QgsGeometry* geometryFromGML( const QDomNode& geometryNode );

/** read rectangle from GML2 Box */
static QgsRectangle rectangleFromGMLBox( const QDomNode& boxNode );

/** read rectangle from GML3 Envelope */
static QgsRectangle rectangleFromGMLEnvelope( const QDomNode& envelopeNode );

/** Exports the geometry to GML2 or GML3
@return QDomELement
*/
static QDomElement geometryToGML( QgsGeometry* geometry, QDomDocument& doc, QString format );

/** Exports the geometry to GML2
@return QDomElement
*/
static QDomElement geometryToGML( QgsGeometry* geometry, QDomDocument& doc );

/** Exports the rectangle to GML2 Box
@return QDomElement
*/
static QDomElement rectangleToGMLBox( QgsRectangle* box, QDomDocument& doc );

/** Exports the rectangle to GML2 Envelope
@return QDomElement
*/
static QDomElement rectangleToGMLEnvelope( QgsRectangle* env, QDomDocument& doc );


/** Parse XML with OGC filter into QGIS expression */
static QgsExpression* expressionFromOgcFilter( const QDomElement& element );

/** Creates OGC filter XML element. Supports minimum standard filter according to the OGC filter specs (=,!=,<,>,<=,>=,AND,OR,NOT)
@return valid <Filter> QDomElement on success, otherwise null QDomElement
*/
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage = 0 );

private:
/** static method that creates geometry from GML Point */
static QgsGeometry* geometryFromGMLPoint( const QDomElement& geometryElement );
/** static method that creates geometry from GML LineString */
static QgsGeometry* geometryFromGMLLineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML Polygon */
static QgsGeometry* geometryFromGMLPolygon( const QDomElement& geometryElement );
/** static method that creates geometry from GML MultiPoint */
static QgsGeometry* geometryFromGMLMultiPoint( const QDomElement& geometryElement );
/** static method that creates geometry from GML MultiLineString */
static QgsGeometry* geometryFromGMLMultiLineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML MultiPolygon */
static QgsGeometry* geometryFromGMLMultiPolygon( const QDomElement& geometryElement );
/** Reads the <gml:coordinates> element and extracts the coordinates as points
@param coords list where the found coordinates are appended
@param elem the <gml:coordinates> element
@return boolean for success*/
static bool readGMLCoordinates( std::list<QgsPoint>& coords, const QDomElement elem );
/** Reads the <gml:pos> or <gml:posList> element and extracts the coordinates as points
@param coords list where the found coordinates are appended
@param elem the <gml:pos> or <gml:posList> element
@return boolean for success*/
static bool readGMLPositions( std::list<QgsPoint>& coords, const QDomElement elem );


/**Create a GML coordinates element from a point list.
@param points list of data points
@param the GML document
@return QDomElement */
static QDomElement createGMLCoordinates( const QVector<QgsPoint> points, QDomDocument& doc );
static QDomElement createGMLCoordinates( const QVector<QgsPoint> points, QDomDocument& doc );

/**Create a GML pos or posList element from a point list.
@param points list of data points
@param the GML document
@return QDomElement */
static QDomElement createGMLPositions( const QVector<QgsPoint> points, QDomDocument& doc );
static QDomElement createGMLPositions( const QVector<QgsPoint> points, QDomDocument& doc );

//! handle a generic sub-expression
static QgsExpression::Node* nodeFromOgcFilter( QDomElement &element, QString &errorMessage );
//! handle a generic binary operator
Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature
// Null values should not be categorized
if ( attrs[mAttrNum].isNull() )
return NULL;
// find the right category

// find the right category
QgsSymbolV2* symbol = symbolForValue( attrs[mAttrNum].toDouble() );
if ( symbol == NULL )
return NULL;
Expand Down Expand Up @@ -806,7 +806,7 @@ QgsGraduatedSymbolRendererV2* QgsGraduatedSymbolRendererV2::createRenderer(
lst.append( attrNum );

QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( lst ) );

// create list of non-null attribute values
while ( fit.nextFeature( f ) )
if ( !f.attribute( attrNum ).isNull() )
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgssymbolv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ QgsSymbolV2::~QgsSymbolV2()

QgsSymbolV2::OutputUnit QgsSymbolV2::outputUnit() const
{
QgsSymbolV2::OutputUnit unit;
QgsSymbolV2::OutputUnit unit( QgsSymbolV2::Mixed );

QgsSymbolLayerV2List::const_iterator it = mLayers.constBegin();
for ( ; it != mLayers.constEnd(); ++it )
Expand Down
16 changes: 8 additions & 8 deletions src/gui/qgscomposerview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,13 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
if ( e->matches( QKeySequence::Copy ) )
{
// remove all uuid attributes
QDomNodeList composerItemsNodes = doc.elementsByTagName("ComposerItem");
for (int i=0; i<composerItemsNodes.count(); ++i)
QDomNodeList composerItemsNodes = doc.elementsByTagName( "ComposerItem" );
for ( int i = 0; i < composerItemsNodes.count(); ++i )
{
QDomNode composerItemNode = composerItemsNodes.at(i);
if( composerItemNode.isElement() )
QDomNode composerItemNode = composerItemsNodes.at( i );
if ( composerItemNode.isElement() )
{
composerItemNode.toElement().removeAttribute("uuid");
composerItemNode.toElement().removeAttribute( "uuid" );
}
}
}
Expand All @@ -530,8 +530,8 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
clipboard->setMimeData( mimeData );
}

//TODO : "Ctrl+Shift+V" is one way to paste, but on some platefoms you can use Shift+Ins and F18
if ( e->matches( QKeySequence::Paste ) || (e->key() == Qt::Key_V && e->modifiers() & Qt::ControlModifier && e->modifiers() & Qt::ShiftModifier) )
//TODO : "Ctrl+Shift+V" is one way to paste, but on some platefoms you can use Shift+Ins and F18
if ( e->matches( QKeySequence::Paste ) || ( e->key() == Qt::Key_V && e->modifiers() & Qt::ControlModifier && e->modifiers() & Qt::ShiftModifier ) )
{
QDomDocument doc;
QClipboard *clipboard = QApplication::clipboard();
Expand All @@ -543,7 +543,7 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
if ( composition() )
{
QPointF pt = mapToScene( mapFromGlobal( QCursor::pos() ) );
bool pasteInPlace = (e->modifiers() & Qt::ShiftModifier);
bool pasteInPlace = ( e->modifiers() & Qt::ShiftModifier );
composition()->addItemsFromXML( docElem, doc, 0, true, &pt, pasteInPlace );
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgscomposerview.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
/**Update rulers with current scene rect*/
void updateRulers();

void setHorizontalRuler( QgsComposerRuler* r ){ mHorizontalRuler = r; }
void setVerticalRuler( QgsComposerRuler* r ){ mVerticalRuler = r; }
void setHorizontalRuler( QgsComposerRuler* r ) { mHorizontalRuler = r; }
void setVerticalRuler( QgsComposerRuler* r ) { mVerticalRuler = r; }

protected:
void mousePressEvent( QMouseEvent* );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void QgsGraduatedSymbolRendererV2Widget::populateColumns()
const QgsFields& flds = mLayer->pendingFields();
for ( int idx = 0; idx < flds.count(); ++idx )
{
if ( flds[idx].type() == QVariant::Double || flds[idx].type() == QVariant::Int || flds[idx].type() == QVariant::LongLong)
if ( flds[idx].type() == QVariant::Double || flds[idx].type() == QVariant::Int || flds[idx].type() == QVariant::LongLong )
cboGraduatedColumn->addItem( flds[idx].name() );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgswfsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class QgsWFSServer

//methods to write GML2
QDomElement createFeatureGML2( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs, QgsFields fields, QSet<QString> excludedAttributes ) /*const*/;

//methods to write GML3
QDomElement createFeatureGML3( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs, QgsFields fields, QSet<QString> excludedAttributes ) /*const*/;
};
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/heatmap/heatmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void Heatmap::run()
// Handle different radius options
double radius;
double radiusToMapUnits = 1;
int myBuffer;
int myBuffer = 0;
if ( d.variableRadius() )
{
rField = d.radiusField();
Expand Down Expand Up @@ -367,7 +367,7 @@ double Heatmap::calculateKernelValue( double distance, int bandwidth, int kernel

double Heatmap::uniformKernel( double distance, int bandwidth )
{
Q_UNUSED(distance);
Q_UNUSED( distance );
// Normalizing constant
double k = 2. / ( M_PI * ( double )bandwidth );

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/heatmap/heatmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Heatmap: public QObject, public QgisPlugin
Heatmap( QgisInterface * theInterface );
//! Destructor
virtual ~Heatmap();

// Kernel shape type
enum kernelShape
{
Expand Down
16 changes: 8 additions & 8 deletions src/providers/mssql/qgsmssqlgeometryparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ ShapeType (1 byte)
#define PointOffset(iFigure) (ReadInt32(nFigurePos + (iFigure) * 5 + 1))
#define NextPointOffset(iFigure) (iFigure + 1 < nNumFigures? PointOffset((iFigure) +1) : nNumPoints)

#define ReadX(iPoint) (ReadDouble(nPointPos + 16 * (iPoint)))
#define ReadY(iPoint) (ReadDouble(nPointPos + 16 * (iPoint) + 8))
#define ReadZ(iPoint) (ReadDouble(nPointPos + 16 * nNumPoints + 8 * (iPoint)))
#define ReadM(iPoint) (ReadDouble(nPointPos + 24 * nNumPoints + 8 * (iPoint)))
#define ReadX(iPoint) (ReadDouble(nPointPos + 16 * (iPoint)))
#define ReadY(iPoint) (ReadDouble(nPointPos + 16 * (iPoint) + 8))
#define ReadZ(iPoint) (ReadDouble(nPointPos + 16 * nNumPoints + 8 * (iPoint)))
#define ReadM(iPoint) (ReadDouble(nPointPos + 24 * nNumPoints + 8 * (iPoint)))

/************************************************************************/
/* QgsMssqlGeometryParser() */
Expand Down Expand Up @@ -180,15 +180,15 @@ void QgsMssqlGeometryParser::CopyCoordinates( int iPoint )
{
if ( IsGeography )
{
CopyBytes(pszData + nPointPos + 16 * iPoint + 8, 8); // longitude
CopyBytes(pszData + nPointPos + 16 * iPoint, 8); // latitude
CopyBytes( pszData + nPointPos + 16 * iPoint + 8, 8 ); // longitude
CopyBytes( pszData + nPointPos + 16 * iPoint, 8 ); // latitude
}
else
// copy geometry coords
CopyBytes(pszData + nPointPos + 16 * iPoint, 16);
CopyBytes( pszData + nPointPos + 16 * iPoint, 16 );

if ( chProps & SP_HASZVALUES )
CopyBytes(pszData + nPointPos + 16 * nNumPoints + 8 * iPoint, 8); // copy z value
CopyBytes( pszData + nPointPos + 16 * nNumPoints + 8 * iPoint, 8 ); // copy z value
}

/************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlnewconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ QgsMssqlNewConnection::QgsMssqlNewConnection( QWidget *parent, const QString& co
{
txtUsername->setText( settings.value( key + "/username" ).toString() );
chkStoreUsername->setChecked( true );
cb_trustedConnection->setChecked (false);
cb_trustedConnection->setChecked( false );
}

if ( settings.value( key + "/savePassword" ).toString() == "true" )
Expand Down
14 changes: 7 additions & 7 deletions src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap & at
return true;

if ( mFidColName.isEmpty() )
return false;
return false;

for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
Expand Down Expand Up @@ -1056,7 +1056,7 @@ bool QgsMssqlProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
return true;

if ( mFidColName.isEmpty() )
return false;
return false;

for ( QgsGeometryMap::iterator it = geometry_map.begin(); it != geometry_map.end(); ++it )
{
Expand Down Expand Up @@ -1129,8 +1129,8 @@ bool QgsMssqlProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
bool QgsMssqlProvider::deleteFeatures( const QgsFeatureIds & id )
{
if ( mFidColName.isEmpty() )
return false;
return false;

QString featureIds;
for ( QgsFeatureIds::const_iterator it = id.begin(); it != id.end(); ++it )
{
Expand Down Expand Up @@ -1162,12 +1162,12 @@ bool QgsMssqlProvider::deleteFeatures( const QgsFeatureIds & id )

int QgsMssqlProvider::capabilities() const
{
if (mFidColName.isEmpty())
if ( mFidColName.isEmpty() )
return CreateSpatialIndex | CreateAttributeIndex | AddFeatures | AddAttributes;
else
return CreateSpatialIndex | CreateAttributeIndex | AddFeatures | DeleteFeatures |
ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
}

bool QgsMssqlProvider::createSpatialIndex()
Expand Down
18 changes: 9 additions & 9 deletions src/ui/qgsatlascompositionwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<x>0</x>
<y>0</y>
<width>431</width>
<height>566</height>
<height>567</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
Expand Down Expand Up @@ -256,8 +256,15 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="1">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="mAtlasFeatureFilterCheckBox">
<property name="text">
<string>Filter with</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mAtlasFeatureFilterEdit"/>
</item>
Expand All @@ -270,13 +277,6 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Filter with</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
67 changes: 41 additions & 26 deletions src/ui/qgscomposerlegendwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-150</y>
<width>376</width>
<height>1186</height>
<y>-118</y>
<width>369</width>
<height>1088</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
Expand Down Expand Up @@ -192,10 +192,13 @@
<bool>false</bool>
</property>
<property name="headerHidden">
<bool>true</bool>
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
<bool>true</bool>
</attribute>
<attribute name="headerVisible">
<bool>true</bool>
</attribute>
</widget>
</item>
Expand Down Expand Up @@ -377,7 +380,7 @@
<item>
<widget class="QPushButton" name="mLayerFontButton">
<property name="text">
<string>Layer Font...</string>
<string>Subgroup Font...</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -443,14 +446,14 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="mEqualColumnWidthCheckBox">
<property name="text">
<string>Equal column widths</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="mSplitLayerCheckBox">
<property name="toolTip">
<string>Allow to split layer items into multiple columns.</string>
Expand All @@ -460,23 +463,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Spacing</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mColumnSpaceSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -561,6 +547,9 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="toolTip">
<string>Space above text using group style.</string>
</property>
<property name="text">
<string>Group Space</string>
</property>
Expand All @@ -581,8 +570,11 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="toolTip">
<string>Space above text using subgroup style.</string>
</property>
<property name="text">
<string>Layer space</string>
<string>Subgroup space</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand All @@ -601,6 +593,9 @@
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="toolTip">
<string>Space above symbol and symbol label.</string>
</property>
<property name="text">
<string>Symbol space</string>
</property>
Expand All @@ -621,6 +616,9 @@
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="toolTip">
<string>Space between symbol icon and symbol label (symbol label left margin).</string>
</property>
<property name="text">
<string>Icon label space</string>
</property>
Expand Down Expand Up @@ -659,6 +657,23 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Column space</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="mColumnSpaceSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/testqgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,9 @@ class TestQgsExpression: public QObject
QTest::newRow( "GML Box" ) << "geomFromGML('<gml:Box srsName=\"foo\"><gml:coordinates>135.2239,34.4879 135.8578,34.8471</gml:coordinates></gml:Box>')" << ( void * ) QgsGeometry::fromRect( rect ) << false;
// Envelope is from GML3 ?
QTest::newRow( "GML Envelope" ) << "geomFromGML('<gml:Envelope>"
"<gml:lowerCorner>135.2239 34.4879</gml:lowerCorner>"
"<gml:upperCorner>135.8578 34.8471</gml:upperCorner>"
"</gml:Envelope>')" << ( void * ) QgsGeometry::fromRect( rect ) << false;
"<gml:lowerCorner>135.2239 34.4879</gml:lowerCorner>"
"<gml:upperCorner>135.8578 34.8471</gml:upperCorner>"
"</gml:Envelope>')" << ( void * ) QgsGeometry::fromRect( rect ) << false;
}

void eval_geometry_constructor()
Expand Down
96 changes: 48 additions & 48 deletions tests/src/core/testqgsogcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ void TestQgsOgcUtils::testExpressionToOgcFilter()

doc.appendChild( filterElem );

qDebug("EXPR: %s", exp.dump().toAscii().data() );
qDebug("OGC : %s", doc.toString( -1 ).toAscii().data() );
qDebug( "EXPR: %s", exp.dump().toAscii().data() );
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );

QCOMPARE( xmlText, doc.toString( -1 ) );
}
Expand All @@ -258,74 +258,74 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data()
"</ogc:PropertyIsGreaterThan></ogc:Filter>" );

QTest::newRow( "and+or" ) << QString( "(FIELD1 = 10 OR FIELD1 = 20) AND STATUS = 'VALID'" ) << QString(
"<ogc:Filter>"
"<ogc:Filter>"
"<ogc:And>"
"<ogc:Or>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>FIELD1</ogc:PropertyName>"
"<ogc:Literal>10</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>FIELD1</ogc:PropertyName>"
"<ogc:Literal>20</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"</ogc:Or>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>STATUS</ogc:PropertyName>"
"<ogc:Literal>VALID</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:Or>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>FIELD1</ogc:PropertyName>"
"<ogc:Literal>10</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>FIELD1</ogc:PropertyName>"
"<ogc:Literal>20</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"</ogc:Or>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>STATUS</ogc:PropertyName>"
"<ogc:Literal>VALID</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"</ogc:And>"
"</ogc:Filter>" );
"</ogc:Filter>" );

QTest::newRow( "is null" ) << QString( "X IS NULL" ) << QString(
"<ogc:Filter>"
"<ogc:Filter>"
"<ogc:PropertyIsNull>"
"<ogc:PropertyName>X</ogc:PropertyName>"
"<ogc:PropertyName>X</ogc:PropertyName>"
"</ogc:PropertyIsNull>"
"</ogc:Filter>" );
"</ogc:Filter>" );

QTest::newRow( "is not null" ) << QString( "X IS NOT NULL" ) << QString(
"<ogc:Filter>"
"<ogc:Filter>"
"<ogc:Not>"
"<ogc:PropertyIsNull>"
"<ogc:PropertyName>X</ogc:PropertyName>"
"</ogc:PropertyIsNull>"
"<ogc:PropertyIsNull>"
"<ogc:PropertyName>X</ogc:PropertyName>"
"</ogc:PropertyIsNull>"
"</ogc:Not>"
"</ogc:Filter>" );
"</ogc:Filter>" );

QTest::newRow( "in" ) << QString( "A IN (10,20,30)" ) << QString(
"<ogc:Filter>"
"<ogc:Filter>"
"<ogc:Or>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>A</ogc:PropertyName>"
"<ogc:Literal>10</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>A</ogc:PropertyName>"
"<ogc:Literal>20</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>A</ogc:PropertyName>"
"<ogc:Literal>30</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>A</ogc:PropertyName>"
"<ogc:Literal>10</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>A</ogc:PropertyName>"
"<ogc:Literal>20</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>A</ogc:PropertyName>"
"<ogc:Literal>30</ogc:Literal>"
"</ogc:PropertyIsEqualTo>"
"</ogc:Or>"
"</ogc:Filter>" );
"</ogc:Filter>" );

QTest::newRow( "intersects + wkt" ) << QString( "intersects($geometry, geomFromWKT('POINT (5 6)'))" ) << QString(
"<ogc:Filter>"
"<ogc:Filter>"
"<ogc:Intersects>"
"<ogc:PropertyName>geometry</ogc:PropertyName>"
"<gml:Point><gml:coordinates cs=\",\" ts=\" \">5.0,6.0</gml:coordinates></gml:Point>"
"<ogc:PropertyName>geometry</ogc:PropertyName>"
"<gml:Point><gml:coordinates cs=\",\" ts=\" \">5.0,6.0</gml:coordinates></gml:Point>"
"</ogc:Intersects>"
"</ogc:Filter>" );
"</ogc:Filter>" );

QTest::newRow( "contains + gml" ) << QString( "contains($geometry, geomFromGML('<Point><coordinates cs=\",\" ts=\" \">5.0,6.0</coordinates></Point>'))" ) << QString(
"<ogc:Filter>"
"<ogc:Filter>"
"<ogc:Contains>"
"<ogc:PropertyName>geometry</ogc:PropertyName>"
"<Point><coordinates cs=\",\" ts=\" \">5.0,6.0</coordinates></Point>"
"<ogc:PropertyName>geometry</ogc:PropertyName>"
"<Point><coordinates cs=\",\" ts=\" \">5.0,6.0</coordinates></Point>"
"</ogc:Contains>"
"</ogc:Filter>" );
"</ogc:Filter>" );

/*
QTest::newRow( "bbox with GML3 Envelope" )
Expand Down