Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Nov 20, 2012
2 parents cb07ae4 + 0533e2d commit 5d5f355
Show file tree
Hide file tree
Showing 22 changed files with 306 additions and 177 deletions.
2 changes: 1 addition & 1 deletion python/gui/qgsmapoverviewcanvas.sip
Expand Up @@ -26,7 +26,7 @@ class QgsMapOverviewCanvas : QWidget

void enableAntiAliasing( bool flag );

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

public slots:

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/taudem/CMakeLists.txt
@@ -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})
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/app/qgsannotationwidget.cpp
Expand Up @@ -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 )
Expand All @@ -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();
Expand Down Expand Up @@ -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 );
}
}

1 change: 1 addition & 0 deletions src/app/qgsannotationwidget.h
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions src/app/qgslabelengineconfigdialog.cpp
Expand Up @@ -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() );
Expand All @@ -36,6 +41,8 @@ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWi
chkShowCandidates->setChecked( mLBL->isShowingCandidates() );

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

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


Expand All @@ -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 );
}
2 changes: 2 additions & 0 deletions src/app/qgslabelengineconfigdialog.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsoptions.cpp
Expand Up @@ -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() );

Expand Down
77 changes: 39 additions & 38 deletions src/app/qgssvgannotationdialog.cpp
Expand Up @@ -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 )
Expand All @@ -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;
}
22 changes: 0 additions & 22 deletions src/app/qgstextannotationdialog.cpp
Expand Up @@ -32,7 +32,6 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsTextAnnotationItem* item, Q
{
mTextDocument = mItem->document();
mTextEdit->setDocument( mTextDocument );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
}
setCurrentFontPropertiesToGui();

Expand Down Expand Up @@ -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 );
}
}

1 change: 0 additions & 1 deletion src/app/qgstextannotationdialog.h
Expand Up @@ -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
43 changes: 43 additions & 0 deletions src/core/qgspallabeling.cpp
Expand Up @@ -49,6 +49,7 @@
#include <qgsvectordataprovider.h>
#include <qgsgeometry.h>
#include <qgsmaprenderer.h>
#include <qgsproject.h>
#include <QMessageBox>

using namespace pal;
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgspallabeling.h
Expand Up @@ -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;
Expand All @@ -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;
};

Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsannotationitem.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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() );
Expand Down

0 comments on commit 5d5f355

Please sign in to comment.