Skip to content
Permalink
Browse files
Update of composer item's GUI
  • Loading branch information
olivierdalang authored and dakcarto committed Feb 19, 2013
1 parent a645f43 commit 2d4220bba92ab28acaf612ed0df229747e6540c2
Showing with 3,155 additions and 3,201 deletions.
  1. +5 −0 python/core/composer/qgscomposeritem.sip
  2. +0 −8 python/core/composer/qgscomposershape.sip
  3. +0 −2 src/app/CMakeLists.txt
  4. +1 −1 src/app/composer/qgscomposerarrowwidget.cpp
  5. +1 −1 src/app/composer/qgscomposerhtmlwidget.cpp
  6. +175 −20 src/app/composer/qgscomposeritemwidget.cpp
  7. +25 −2 src/app/composer/qgscomposeritemwidget.h
  8. +3 −5 src/app/composer/qgscomposerlabelwidget.cpp
  9. +1 −1 src/app/composer/qgscomposerlegendwidget.cpp
  10. +8 −58 src/app/composer/qgscomposermapwidget.cpp
  11. +1 −3 src/app/composer/qgscomposermapwidget.h
  12. +1 −44 src/app/composer/qgscomposerpicturewidget.cpp
  13. +0 −2 src/app/composer/qgscomposerpicturewidget.h
  14. +1 −1 src/app/composer/qgscomposerscalebarwidget.cpp
  15. +2 −90 src/app/composer/qgscomposershapewidget.cpp
  16. +0 −4 src/app/composer/qgscomposershapewidget.h
  17. +6 −11 src/app/composer/qgscomposertablewidget.cpp
  18. +1 −1 src/app/composer/qgscomposertablewidget.h
  19. +13 −49 src/app/composer/qgscompositionwidget.cpp
  20. +3 −3 src/app/composer/qgscompositionwidget.h
  21. +0 −247 src/app/composer/qgsitempositiondialog.cpp
  22. +0 −63 src/app/composer/qgsitempositiondialog.h
  23. +12 −1 src/core/composer/qgscomposeritem.cpp
  24. +10 −0 src/core/composer/qgscomposeritem.h
  25. +47 −140 src/core/composer/qgscomposershape.cpp
  26. +12 −17 src/core/composer/qgscomposershape.h
  27. +2 −2 src/core/composer/qgscomposition.cpp
  28. +124 −75 src/ui/qgscomposerarrowwidgetbase.ui
  29. +64 −47 src/ui/qgscomposerhtmlwidgetbase.ui
  30. +316 −77 src/ui/qgscomposeritemwidgetbase.ui
  31. +255 −173 src/ui/qgscomposerlabelwidgetbase.ui
  32. +587 −462 src/ui/qgscomposerlegendwidgetbase.ui
  33. +530 −628 src/ui/qgscomposermapwidgetbase.ui
  34. +102 −176 src/ui/qgscomposerpicturewidgetbase.ui
  35. +366 −245 src/ui/qgscomposerscalebarwidgetbase.ui
  36. +59 −61 src/ui/qgscomposershapewidgetbase.ui
  37. +179 −174 src/ui/qgscomposertablewidgetbase.ui
  38. +243 −134 src/ui/qgscompositionwidgetbase.ui
  39. +0 −173 src/ui/qgsitempositiondialogbase.ui
@@ -189,6 +189,11 @@ class QgsComposerItem: QObject, QGraphicsRectItem
@note: this method was added in version 1.6*/
void setItemPosition( double x, double y, double width, double height, ItemPositionMode itemPoint = UpperLeft );

/**Returns item's last used position mode.
@note: This property has no effect on actual's item position, which is always the top-left corner.
@note: this method was added in version 2.0*/
ItemPositionMode lastUsedPositionMode();

/**Sets this items bound in scene coordinates such that 1 item size units
corresponds to 1 scene size unit*/
virtual void setSceneRect( const QRectF& rectangle );
@@ -36,16 +36,8 @@ class QgsComposerShape: QgsComposerItem
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );

//setters and getters
void setLineWidth( double width );
double lineWidth() const;
void setOutlineColor( const QColor& color );
QColor outlineColor() const;
void setFillColor( const QColor& color );
QColor fillColor() const;
QgsComposerShape::Shape shapeType() const;
void setShapeType( QgsComposerShape::Shape s );
bool transparentFill() const;
void setTransparentFill( bool transparent );

/**Sets this items bound in scene coordinates such that 1 item size units
corresponds to 1 scene size unit. Also, the shape is scaled*/
@@ -133,7 +133,6 @@ SET(QGIS_APP_SRCS
composer/qgscomposerlegendwidget.cpp
composer/qgscompositionwidget.cpp
composer/qgsatlascompositionwidget.cpp
composer/qgsitempositiondialog.cpp

legend/qgslegendgroup.cpp
legend/qgslegend.cpp
@@ -281,7 +280,6 @@ SET (QGIS_APP_MOC_HDRS
composer/qgscomposershapewidget.h
composer/qgscompositionwidget.h
composer/qgsatlascompositionwidget.h
composer/qgsitempositiondialog.h

legend/qgslegend.h
legend/qgsapplegendinterface.h
@@ -36,7 +36,7 @@ QgsComposerArrowWidget::QgsComposerArrowWidget( QgsComposerArrow* arrow ): QWidg

//add widget for general composer item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, mArrow );
toolBox->addItem( itemPropertiesWidget, tr( "General options" ) );
mainLayout->addWidget( itemPropertiesWidget );

setGuiElementValues();

@@ -42,7 +42,7 @@ QgsComposerHtmlWidget::QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposer
{
//add widget for general composer item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, mFrame );
mToolBox->addItem( itemPropertiesWidget, tr( "General options" ) );
mainLayout->addWidget( itemPropertiesWidget );
}
}

@@ -18,14 +18,35 @@
#include "qgscomposeritemwidget.h"
#include "qgscomposeritem.h"
#include "qgscomposermap.h"
#include "qgsitempositiondialog.h"
#include "qgspoint.h"
#include <QColorDialog>

QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem* item ): QWidget( parent ), mItem( item )
{

setupUi( this );

//make button exclusive
QButtonGroup* buttonGroup = new QButtonGroup( this );
buttonGroup->addButton( mUpperLeftCheckBox );
buttonGroup->addButton( mUpperMiddleCheckBox );
buttonGroup->addButton( mUpperRightCheckBox );
buttonGroup->addButton( mMiddleLeftCheckBox );
buttonGroup->addButton( mMiddleCheckBox );
buttonGroup->addButton( mMiddleRightCheckBox );
buttonGroup->addButton( mLowerLeftCheckBox );
buttonGroup->addButton( mLowerMiddleCheckBox );
buttonGroup->addButton( mLowerRightCheckBox );
buttonGroup->setExclusive( true );

mXLineEdit->setValidator( new QDoubleValidator( 0 ) );
mYLineEdit->setValidator( new QDoubleValidator( 0 ) );
mWidthLineEdit->setValidator( new QDoubleValidator( 0 ) );
mHeightLineEdit->setValidator( new QDoubleValidator( 0 ) );

setValuesForGuiElements();
connect( mItem, SIGNAL( sizeChanged() ), this, SLOT( setValuesForGuiPositionElements() ) );

}

QgsComposerItemWidget::QgsComposerItemWidget(): QWidget( 0 ), mItem( 0 )
@@ -126,6 +147,70 @@ void QgsComposerItemWidget::changeItemOpacity( int value )
mItem->endCommand();
}

void QgsComposerItemWidget::changeItemPosition()
{
mItem->beginCommand( tr( "Item position changed" ) );

bool convXSuccess, convYSuccess;
double x = mXLineEdit->text().toDouble( &convXSuccess );
double y = mYLineEdit->text().toDouble( &convYSuccess );

bool convSuccessWidth, convSuccessHeight;
double width = mWidthLineEdit->text().toDouble( &convSuccessWidth );
double height = mHeightLineEdit->text().toDouble( &convSuccessHeight );

if ( !convXSuccess || !convYSuccess || !convSuccessWidth || !convSuccessHeight )
{
return;
}

mItem->setItemPosition( x, y, width, height, positionMode() );

mItem->update();
mItem->endCommand();
}

QgsComposerItem::ItemPositionMode QgsComposerItemWidget::positionMode() const
{
if ( mUpperLeftCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::UpperLeft;
}
else if ( mUpperMiddleCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::UpperMiddle;
}
else if ( mUpperRightCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::UpperRight;
}
else if ( mMiddleLeftCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::MiddleLeft;
}
else if ( mMiddleCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::Middle;
}
else if ( mMiddleRightCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::MiddleRight;
}
else if ( mLowerLeftCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::LowerLeft;
}
else if ( mLowerMiddleCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::LowerMiddle;
}
else if ( mLowerRightCheckBox->checkState() == Qt::Checked )
{
return QgsComposerItem::LowerRight;
}
return QgsComposerItem::UpperLeft;
}

void QgsComposerItemWidget::on_mOutlineWidthSpinBox_valueChanged( double d )
{
if ( !mItem )
@@ -166,13 +251,102 @@ void QgsComposerItemWidget::on_mBackgroundGroupBox_toggled( bool state )
mItem->endCommand();
}


void QgsComposerItemWidget::setValuesForGuiPositionElements()
{
if ( !mItem )
{
return;
}

mXLineEdit->blockSignals( true );
mYLineEdit->blockSignals( true );
mWidthLineEdit->blockSignals( true );
mHeightLineEdit->blockSignals( true );


if( mItem->lastUsedPositionMode() == QgsComposerItem::UpperLeft )
{
mUpperLeftCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::UpperMiddle )
{
mUpperMiddleCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() / 2.0 ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::UpperRight )
{
mUpperRightCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleLeft )
{
mMiddleLeftCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() / 2.0 ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::Middle )
{
mMiddleCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() / 2.0 ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() / 2.0 ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleRight )
{
mMiddleRightCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() / 2.0 ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::LowerLeft )
{
mLowerLeftCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::LowerMiddle )
{
mLowerMiddleCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() / 2.0 ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() ) );
}

if( mItem->lastUsedPositionMode() == QgsComposerItem::LowerRight )
{
mLowerRightCheckBox->setChecked( true );
mXLineEdit->setText( QString::number( mItem->transform().dx() + mItem->rect().width() ) );
mYLineEdit->setText( QString::number( mItem->transform().dy() + mItem->rect().height() ) );
}

mWidthLineEdit->setText( QString::number( mItem->rect().width() ) );
mHeightLineEdit->setText( QString::number( mItem->rect().height() ) );


mXLineEdit->blockSignals( false );
mYLineEdit->blockSignals( false );
mWidthLineEdit->blockSignals( false );
mHeightLineEdit->blockSignals( false );
}

void QgsComposerItemWidget::setValuesForGuiElements()
{
if ( !mItem )
{
return;
}

setValuesForGuiPositionElements();

mOpacitySlider->blockSignals( true );
mOutlineWidthSpinBox->blockSignals( true );
mFrameGroupBox->blockSignals( true );
@@ -195,25 +369,6 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mOpacitySpinBox->blockSignals( false );
}

void QgsComposerItemWidget::on_mPositionButton_clicked()
{
if ( !mItem )
{
return;
}

mItem->beginCommand( tr( "Item position changed" ) );
QgsItemPositionDialog d( mItem, 0 );
if ( d.exec() == QDialog::Accepted )
{
mItem->endCommand();
}
else
{
mItem->cancelCommand();
}
}

void QgsComposerItemWidget::on_mItemIdLineEdit_textChanged( const QString &text )
{
if ( mItem )
@@ -19,6 +19,7 @@
#define QGSCOMPOSERITEMWIDGET_H

#include "ui_qgscomposeritemwidgetbase.h"
#include "qgscomposeritem.h"

class QgsComposerItem;

@@ -31,6 +32,10 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
QgsComposerItemWidget( QWidget* parent, QgsComposerItem* item );
~QgsComposerItemWidget();

/**A combination of upper/middle/lower and left/middle/right*/
QgsComposerItem::ItemPositionMode positionMode() const;


public slots:
void on_mFrameColorButton_clicked();
void on_mBackgroundColorButton_clicked();
@@ -39,13 +44,31 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_mFrameGroupBox_toggled( bool state );
void on_mBackgroundGroupBox_toggled( bool state );
void on_mPositionButton_clicked();
void on_mItemIdLineEdit_textChanged( const QString& text );

//adjust coordinates in line edits
void on_mXLineEdit_editingFinished(){ changeItemPosition(); }
void on_mYLineEdit_editingFinished(){ changeItemPosition(); }
void on_mWidthLineEdit_editingFinished(){ changeItemPosition(); }
void on_mHeightLineEdit_editingFinished(){ changeItemPosition(); }

void on_mUpperLeftCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mUpperMiddleCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mUpperRightCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mMiddleLeftCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mMiddleCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mMiddleRightCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mLowerLeftCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mLowerMiddleCheckBox_stateChanged( int state ){ changeItemPosition(); }
void on_mLowerRightCheckBox_stateChanged( int state ){ changeItemPosition(); }

void setValuesForGuiElements();
void setValuesForGuiPositionElements();

private:
QgsComposerItemWidget();
void setValuesForGuiElements();
void changeItemOpacity( int value );
void changeItemPosition();

QgsComposerItem* mItem;
};
@@ -30,7 +30,7 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel* label ): QWidg

//add widget for general composer item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, label );
toolBox->addItem( itemPropertiesWidget, tr( "General options" ) );
mainLayout->addWidget( itemPropertiesWidget );


if ( mComposerLabel )
@@ -48,15 +48,13 @@ void QgsComposerLabelWidget::on_mHtmlCheckBox_stateChanged( int state )
{
mFontButton->setEnabled( false );
mFontColorButton->setEnabled( false );
mHorizontalAlignementGroup->setEnabled( false );
mVerticalAlignementGroup->setEnabled( false );
mAlignementGroup->setEnabled( false );
}
else
{
mFontButton->setEnabled( true );
mFontColorButton->setEnabled( true );
mHorizontalAlignementGroup->setEnabled( true );
mVerticalAlignementGroup->setEnabled( true );
mAlignementGroup->setEnabled( true );
}

mComposerLabel->beginCommand( tr( "Label text HTML state changed" ), QgsComposerMergeCommand::ComposerLabelSetText );
@@ -49,7 +49,7 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): m

//add widget for item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, legend );
toolBox->addItem( itemPropertiesWidget, tr( "General Options" ) );
mainLayout->addWidget( itemPropertiesWidget );

if ( legend )
{
Loading

0 comments on commit 2d4220b

Please sign in to comment.