Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/qgis/Quantum-GIS

  • Loading branch information
volaya committed Nov 20, 2012
2 parents cb07ae4 + 0533e2d commit 5d5f355b430d120daba161bb6d771033e3e115b5
@@ -26,7 +26,7 @@ class QgsMapOverviewCanvas : QWidget

void enableAntiAliasing( bool flag );

void updateFullExtent( const QgsRectangle& rect );
void updateFullExtent();

public slots:

@@ -1,6 +1,6 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB DESCR_FILES description/*.txt)
FILE(GLOB HELP_FILES help/*.html)
FILE(GLOB HELP_FILES help/*.*)

PLUGIN_INSTALL(sextante taudem ${PY_FILES})
PLUGIN_INSTALL(sextante taudem/description ${DESCR_FILES})
@@ -3377,6 +3377,9 @@ bool QgisApp::addProject( QString projectFile )
}
}

// load PAL engine settings
mLBL->loadEngineSettings();

emit projectRead(); // let plug-ins know that we've read in a new
// project so that they can check any project
// specific plug-in state
@@ -42,6 +42,7 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
}
mFrameWidthSpinBox->setValue( mItem->frameBorderWidth() );
mFrameColorButton->setColor( mItem->frameColor() );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );

const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
if ( symbol )
@@ -66,6 +67,7 @@ void QgsAnnotationWidget::apply()
mItem->setMapPositionFixed( mMapPositionFixedCheckBox->checkState() == Qt::Checked );
mItem->setFrameBorderWidth( mFrameWidthSpinBox->value() );
mItem->setFrameColor( mFrameColorButton->color() );
mItem->setFrameBackgroundColor( mBackgroundColorButton->color() );
mItem->setMarkerSymbol( mMarkerSymbol );
mMarkerSymbol = 0; //item takes ownership
mItem->update();
@@ -129,3 +131,24 @@ void QgsAnnotationWidget::updateCenterIcon()
mMapMarkerButton->setIcon( icon );
}

void QgsAnnotationWidget::on_mBackgroundColorButton_clicked()
{
if ( !mItem )
{
return;
}

QColor bgColor;
#if QT_VERSION >= 0x040500
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor(), 0, tr( "Select background color" ), QColorDialog::ShowAlphaChannel );
#else
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor() );
#endif

if ( bgColor.isValid() )
{
mItem->setFrameBackgroundColor( bgColor );
mBackgroundColorButton->setColor( bgColor );
}
}

@@ -37,6 +37,7 @@ class QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase
private slots:
void on_mMapMarkerButton_clicked();
void on_mFrameColorButton_clicked();
void on_mBackgroundColorButton_clicked();

private:
QgsAnnotationItem* mItem;
@@ -15,13 +15,18 @@
#include "qgslabelengineconfigdialog.h"

#include "qgspallabeling.h"
#include <pal/pal.h>

#include <QPushButton>

QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWidget* parent )
: QDialog( parent ), mLBL( lbl )
{
setupUi( this );

connect( buttonBox, SIGNAL( accepted() ), this, SLOT( onOK() ) );
connect( buttonBox->button( QDialogButtonBox::RestoreDefaults ), SIGNAL( clicked() ),
this, SLOT( setDefaults() ) );

// search method
cboSearchMethod->setCurrentIndex( mLBL->searchMethod() );
@@ -36,6 +41,8 @@ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWi
chkShowCandidates->setChecked( mLBL->isShowingCandidates() );

chkShowAllLabels->setChecked( mLBL->isShowingAllLabels() );

mSaveWithProjectChkBox->setChecked( mLBL->isStoredWithProject() );
}


@@ -52,5 +59,24 @@ void QgsLabelEngineConfigDialog::onOK()

mLBL->setShowingAllLabels( chkShowAllLabels->isChecked() );

if ( mSaveWithProjectChkBox->isChecked() )
{
mLBL->saveEngineSettings();
}
else if ( mLBL->isStoredWithProject() )
{
mLBL->clearEngineSettings();
}
accept();
}

void QgsLabelEngineConfigDialog::setDefaults()
{
pal::Pal p;
cboSearchMethod->setCurrentIndex(( int )p.getSearch() );
spinCandPoint->setValue( p.getPointP() );
spinCandLine->setValue( p.getLineP() );
spinCandPolygon->setValue( p.getPolyP() );
chkShowCandidates->setChecked( false );
chkShowAllLabels->setChecked( false );
}
@@ -29,6 +29,8 @@ class QgsLabelEngineConfigDialog : public QDialog, private Ui::QgsEngineConfigDi

public slots:
void onOK();
/** @note Added in QGIS 1.9 */
void setDefaults();

protected:
QgsPalLabeling* mLBL;
@@ -429,7 +429,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cbxCreateRasterLegendIcons->setChecked( settings.value( "/qgis/createRasterLegendIcons", true ).toBool() );
cbxCopyWKTGeomFromTable->setChecked( settings.value( "/qgis/copyGeometryAsWKT", true ).toBool() );
leNullValue->setText( settings.value( "qgis/nullValue", "NULL" ).toString() );
cbxIgnoreShapeEncoding->setChecked( settings.value( "/qgis/ignoreShapeEncoding", false ).toBool() );
cbxIgnoreShapeEncoding->setChecked( settings.value( "/qgis/ignoreShapeEncoding", true ).toBool() );

cmbLegendDoubleClickAction->setCurrentIndex( settings.value( "/qgis/legendDoubleClickAction", 0 ).toInt() );

@@ -22,24 +22,25 @@
#include <QFileInfo>
#include <QGraphicsScene>

QgsSvgAnnotationDialog::QgsSvgAnnotationDialog( QgsSvgAnnotationItem* item, QWidget * parent, Qt::WindowFlags f):
QgsSvgAnnotationDialog::QgsSvgAnnotationDialog( QgsSvgAnnotationItem* item, QWidget * parent, Qt::WindowFlags f ):
QDialog( parent, f ), mItem( item ), mEmbeddedWidget( 0 )
{
setupUi( this );
mEmbeddedWidget = new QgsAnnotationWidget( mItem );
mEmbeddedWidget->show();
mStackedWidget->addWidget( mEmbeddedWidget );
mStackedWidget->setCurrentWidget( mEmbeddedWidget );
setupUi( this );
setWindowTitle( tr( "SVG annotation" ) );
mEmbeddedWidget = new QgsAnnotationWidget( mItem );
mEmbeddedWidget->show();
mStackedWidget->addWidget( mEmbeddedWidget );
mStackedWidget->setCurrentWidget( mEmbeddedWidget );

if( mItem )
{
mFileLineEdit->setText( mItem->filePath() );
}
if ( mItem )
{
mFileLineEdit->setText( mItem->filePath() );
}

QObject::connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( applySettingsToItem() ) );
QPushButton* deleteButton = new QPushButton( tr( "Delete" ) );
QObject::connect( deleteButton, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );
QObject::connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( applySettingsToItem() ) );
QPushButton* deleteButton = new QPushButton( tr( "Delete" ) );
QObject::connect( deleteButton, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );
}

QgsSvgAnnotationDialog::QgsSvgAnnotationDialog(): QDialog(), mItem( 0 ), mEmbeddedWidget( 0 )
@@ -54,38 +55,38 @@ QgsSvgAnnotationDialog::~QgsSvgAnnotationDialog()

void QgsSvgAnnotationDialog::on_mBrowseToolButton_clicked()
{
QString directory;
QFileInfo fi( mFileLineEdit->text() );
if ( fi.exists() )
{
directory = fi.absolutePath();
}
QString filename = QFileDialog::getOpenFileName( 0, tr( "html" ), directory, "*.html" );
mFileLineEdit->setText( filename );
QString directory;
QFileInfo fi( mFileLineEdit->text() );
if ( fi.exists() )
{
directory = fi.absolutePath();
}
QString filename = QFileDialog::getOpenFileName( 0, tr( "Select SVG file" ), directory, tr( "SVG files" ) + " (*.svg)" );
mFileLineEdit->setText( filename );
}

void QgsSvgAnnotationDialog::applySettingsToItem()
{
if ( mEmbeddedWidget )
{
mEmbeddedWidget->apply();
}
if ( mEmbeddedWidget )
{
mEmbeddedWidget->apply();
}

if( mItem )
{
mItem->setFilePath( mFileLineEdit->text() );
mItem->update();
}
if ( mItem )
{
mItem->setFilePath( mFileLineEdit->text() );
mItem->update();
}

}

void QgsSvgAnnotationDialog::deleteItem()
{
QGraphicsScene* scene = mItem->scene();
if ( scene )
{
scene->removeItem( mItem );
}
delete mItem;
mItem = 0;
QGraphicsScene* scene = mItem->scene();
if ( scene )
{
scene->removeItem( mItem );
}
delete mItem;
mItem = 0;
}
@@ -32,7 +32,6 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsTextAnnotationItem* item, Q
{
mTextDocument = mItem->document();
mTextEdit->setDocument( mTextDocument );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
}
setCurrentFontPropertiesToGui();

@@ -148,24 +147,3 @@ void QgsTextAnnotationDialog::deleteItem()
mItem = 0;
}

void QgsTextAnnotationDialog::on_mBackgroundColorButton_clicked()
{
if ( !mItem )
{
return;
}

QColor bgColor;
#if QT_VERSION >= 0x040500
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor(), 0, tr( "Select background color" ), QColorDialog::ShowAlphaChannel );
#else
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor() );
#endif

if ( bgColor.isValid() )
{
mItem->setFrameBackgroundColor( bgColor );
mBackgroundColorButton->setColor( bgColor );
}
}

@@ -44,7 +44,6 @@ class QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnnotationDial
void on_mFontColorButton_clicked();
void setCurrentFontPropertiesToGui();
void deleteItem();
void on_mBackgroundColorButton_clicked();
};

#endif // QGSTEXTANNOTATIONDIALOG_H
@@ -49,6 +49,7 @@
#include <qgsvectordataprovider.h>
#include <qgsgeometry.h>
#include <qgsmaprenderer.h>
#include <qgsproject.h>
#include <QMessageBox>

using namespace pal;
@@ -1929,6 +1930,48 @@ void QgsPalLabeling::drawLabelBuffer( QPainter* p, QString text, const QFont& fo
p->drawPath( path );
}

void QgsPalLabeling::loadEngineSettings()
{
// start with engine defaults for new project, or project that has no saved settings
Pal p;
bool saved = false;
mSearch = ( QgsPalLabeling::Search )( QgsProject::instance()->readNumEntry(
"PAL", "/SearchMethod", ( int )p.getSearch(), &saved ) );
mCandPoint = QgsProject::instance()->readNumEntry(
"PAL", "/CandidatesPoint", p.getPointP(), &saved );
mCandLine = QgsProject::instance()->readNumEntry(
"PAL", "/CandidatesLine", p.getLineP(), &saved );
mCandPolygon = QgsProject::instance()->readNumEntry(
"PAL", "/CandidatesPolygon", p.getPolyP(), &saved );
mShowingCandidates = QgsProject::instance()->readBoolEntry(
"PAL", "/ShowingCandidates", false, &saved );
mShowingAllLabels = QgsProject::instance()->readBoolEntry(
"PAL", "/ShowingAllLabels", false, &saved );
mSavedWithProject = saved;
}

void QgsPalLabeling::saveEngineSettings()
{
QgsProject::instance()->writeEntry( "PAL", "/SearchMethod", ( int )mSearch );
QgsProject::instance()->writeEntry( "PAL", "/CandidatesPoint", mCandPoint );
QgsProject::instance()->writeEntry( "PAL", "/CandidatesLine", mCandLine );
QgsProject::instance()->writeEntry( "PAL", "/CandidatesPolygon", mCandPolygon );
QgsProject::instance()->writeEntry( "PAL", "/ShowingCandidates", mShowingCandidates );
QgsProject::instance()->writeEntry( "PAL", "/ShowingAllLabels", mShowingAllLabels );
mSavedWithProject = true;
}

void QgsPalLabeling::clearEngineSettings()
{
QgsProject::instance()->removeEntry( "PAL", "/SearchMethod" );
QgsProject::instance()->removeEntry( "PAL", "/CandidatesPoint" );
QgsProject::instance()->removeEntry( "PAL", "/CandidatesLine" );
QgsProject::instance()->removeEntry( "PAL", "/CandidatesPolygon" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingCandidates" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingAllLabels" );
mSavedWithProject = false;
}

QgsLabelingEngineInterface* QgsPalLabeling::clone()
{
QgsPalLabeling* lbl = new QgsPalLabeling();
@@ -314,6 +314,14 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
const QColor& bufferColor = QColor( 255, 255, 255 ), bool drawBuffer = false );
static void drawLabelBuffer( QPainter* p, QString text, const QFont& font, double size, QColor color , Qt::PenJoinStyle joinstyle = Qt::BevelJoin, bool noFill = false );

//! load/save engine settings to project file
//! @note added in QGIS 1.9
void loadEngineSettings();
void saveEngineSettings();
void clearEngineSettings();
bool isStoredWithProject() const { return mSavedWithProject; }
void setStoredWithProject( bool store ) { mSavedWithProject = store; }

protected:
// hashtable of layer settings, being filled during labeling
QHash<QgsVectorLayer*, QgsPalLayerSettings> mActiveLayers;
@@ -333,6 +341,8 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface

bool mShowingAllLabels; // whether to avoid collisions or not

bool mSavedWithProject; // whether engine settings have been read from project file

QgsLabelSearchTree* mLabelSearchTree;
};

@@ -397,6 +397,7 @@ void QgsAnnotationItem::_writeXML( QDomDocument& doc, QDomElement& itemElem ) co
annotationElem.setAttribute( "canvasPosY", QString::number( canvasPos.y() ) );
annotationElem.setAttribute( "frameBorderWidth", QString::number( mFrameBorderWidth ) );
annotationElem.setAttribute( "frameColor", mFrameColor.name() );
annotationElem.setAttribute( "frameColorAlpha", mFrameColor.alpha() );
annotationElem.setAttribute( "frameBackgroundColor", mFrameBackgroundColor.name() );
annotationElem.setAttribute( "frameBackgroundColorAlpha", mFrameBackgroundColor.alpha() );
annotationElem.setAttribute( "visible", isVisible() );
@@ -428,6 +429,7 @@ void QgsAnnotationItem::_readXML( const QDomDocument& doc, const QDomElement& an
mMapPosition = mapPos;
mFrameBorderWidth = annotationElem.attribute( "frameBorderWidth", "0.5" ).toDouble();
mFrameColor.setNamedColor( annotationElem.attribute( "frameColor", "#000000" ) );
mFrameColor.setAlpha( annotationElem.attribute( "frameColorAlpha", "255" ).toInt() );
mFrameBackgroundColor.setNamedColor( annotationElem.attribute( "frameBackgroundColor" ) );
mFrameBackgroundColor.setAlpha( annotationElem.attribute( "frameBackgroundColorAlpha", "255" ).toInt() );
mFrameSize.setWidth( annotationElem.attribute( "frameWidth", "50" ).toDouble() );

0 comments on commit 5d5f355

Please sign in to comment.
You can’t perform that action at this time.