Skip to content
Permalink
Browse files

Flip all composer double spin boxes to QgsDoubleSpin (refs #10544)

Add clear buttons to applicable properties.
  • Loading branch information
nyalldawson committed Dec 5, 2014
1 parent 7400106 commit dfe79807641884821985633fda14918c0c556db5
@@ -108,7 +108,13 @@ QgsVectorLayer* QgsComposerItemBaseWidget::atlasCoverageLayer() const

//QgsComposerItemWidget

QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem* item ): QgsComposerItemBaseWidget( parent, item ), mItem( item )
QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem* item )
: QgsComposerItemBaseWidget( parent, item )
, mItem( item )
, mFreezeXPosSpin( false )
, mFreezeYPosSpin( false )
, mFreezeWidthSpin( false )
, mFreezeHeightSpin( false )
{

setupUi( this );
@@ -376,68 +382,88 @@ void QgsComposerItemWidget::setValuesForGuiPositionElements()
if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperLeft )
{
mUpperLeftCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() );
mYPosSpin->setValue( pos.y() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperMiddle )
{
mUpperMiddleCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
mYPosSpin->setValue( pos.y() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::UpperRight )
{
mUpperRightCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
mYPosSpin->setValue( pos.y() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleLeft )
{
mMiddleLeftCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::Middle )
{
mMiddleCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::MiddleRight )
{
mMiddleRightCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() / 2.0 );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerLeft )
{
mLowerLeftCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerMiddle )
{
mLowerMiddleCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() / 2.0 );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
}

if ( mItem->lastUsedPositionMode() == QgsComposerItem::LowerRight )
{
mLowerRightCheckBox->setChecked( true );
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
if ( !mFreezeXPosSpin )
mXPosSpin->setValue( pos.x() + mItem->rect().width() );
if ( !mFreezeYPosSpin )
mYPosSpin->setValue( pos.y() + mItem->rect().height() );
}

mWidthSpin->setValue( mItem->rect().width() );
mHeightSpin->setValue( mItem->rect().height() );
if ( !mFreezeWidthSpin )
mWidthSpin->setValue( mItem->rect().width() );
if ( !mFreezeHeightSpin )
mHeightSpin->setValue( mItem->rect().height() );
mPageSpinBox->setValue( mItem->page() );

mXPosSpin->blockSignals( false );
@@ -635,6 +661,34 @@ void QgsComposerItemWidget::on_mItemIdLineEdit_editingFinished()
}
}

void QgsComposerItemWidget::on_mXPosSpin_valueChanged( double )
{
mFreezeXPosSpin = true;
changeItemPosition();
mFreezeXPosSpin = false;
}

void QgsComposerItemWidget::on_mYPosSpin_valueChanged( double )
{
mFreezeYPosSpin = true;
changeItemPosition();
mFreezeYPosSpin = false;
}

void QgsComposerItemWidget::on_mWidthSpin_valueChanged( double )
{
mFreezeWidthSpin = true;
changeItemPosition();
mFreezeWidthSpin = false;
}

void QgsComposerItemWidget::on_mHeightSpin_valueChanged( double )
{
mFreezeHeightSpin = true;
changeItemPosition();
mFreezeHeightSpin = false;
}

void QgsComposerItemWidget::on_mUpperLeftCheckBox_stateChanged( int state )
{
if ( state != Qt::Checked )
@@ -91,10 +91,10 @@ class QgsComposerItemWidget: public QgsComposerItemBaseWidget, private Ui::QgsCo

//adjust coordinates in line edits
void on_mPageSpinBox_valueChanged( int ) { changeItemPosition(); }
void on_mXPosSpin_valueChanged( double ) { changeItemPosition(); }
void on_mYPosSpin_valueChanged( double ) { changeItemPosition(); }
void on_mWidthSpin_valueChanged( double ) { changeItemPosition(); }
void on_mHeightSpin_valueChanged( double ) { changeItemPosition(); }
void on_mXPosSpin_valueChanged( double );
void on_mYPosSpin_valueChanged( double );
void on_mWidthSpin_valueChanged( double );
void on_mHeightSpin_valueChanged( double );

void on_mUpperLeftCheckBox_stateChanged( int state );
void on_mUpperMiddleCheckBox_stateChanged( int state );
@@ -130,6 +130,11 @@ class QgsComposerItemWidget: public QgsComposerItemBaseWidget, private Ui::QgsCo

QgsComposerItem* mItem;

bool mFreezeXPosSpin;
bool mFreezeYPosSpin;
bool mFreezeWidthSpin;
bool mFreezeHeightSpin;

// void changeItemTransparency( int value );
void changeItemPosition();

@@ -36,6 +36,9 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel* label ): QgsCo
mFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mFontColorButton->setContext( "composer" );

mMarginXDoubleSpinBox->setClearValue( 0.0 );
mMarginYDoubleSpinBox->setClearValue( 0.0 );

if ( mComposerLabel )
{
setGuiElementValues();
@@ -188,13 +188,16 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
<widget class="QgsDoubleSpinBox" name="mOutlineWidthSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0">
@@ -205,13 +208,16 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="mArrowHeadWidthSpinBox">
<widget class="QgsDoubleSpinBox" name="mArrowHeadWidthSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
@@ -266,18 +272,23 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorButtonV2</class>
<extends>QToolButton</extends>
<header>qgscolorbuttonv2.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>scrollArea</tabstop>
@@ -45,9 +45,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-400</y>
<y>0</y>
<width>392</width>
<height>1192</height>
<height>1204</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
@@ -260,10 +260,13 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mMarginSpinBox">
<widget class="QgsDoubleSpinBox" name="mMarginSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
@@ -397,10 +400,13 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="mGridStrokeWidthSpinBox">
<widget class="QgsDoubleSpinBox" name="mGridStrokeWidthSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
@@ -705,22 +711,27 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorButtonV2</class>
<extends>QToolButton</extends>
<header>qgscolorbuttonv2.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsMapLayerComboBox</class>
<extends>QComboBox</extends>
<header location="global">qgsmaplayercombobox.h</header>
<header>qgsmaplayercombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
@@ -45,9 +45,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-157</y>
<y>-155</y>
<width>391</width>
<height>517</height>
<height>515</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
@@ -222,7 +222,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="mMaxDistanceSpinBox">
<widget class="QgsDoubleSpinBox" name="mMaxDistanceSpinBox">
<property name="suffix">
<string> mm</string>
</property>
@@ -235,6 +235,9 @@
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="showClearButton">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
@@ -278,17 +281,22 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsDataDefinedButton</class>
<extends>QToolButton</extends>
<header>qgsdatadefinedbutton.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDataDefinedButton</class>
<extends>QToolButton</extends>
<header>qgsdatadefinedbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>scrollArea</tabstop>

0 comments on commit dfe7980

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