[QGIS Commit] r14356 - in trunk/qgis: python/core src/app/composer
src/core/composer src/ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Oct 8 04:32:06 EDT 2010
Author: mhugent
Date: 2010-10-08 08:32:06 +0000 (Fri, 08 Oct 2010)
New Revision: 14356
Modified:
trunk/qgis/python/core/qgscomposeritem.sip
trunk/qgis/src/app/composer/qgsitempositiondialog.cpp
trunk/qgis/src/app/composer/qgsitempositiondialog.h
trunk/qgis/src/core/composer/qgscomposeritem.cpp
trunk/qgis/src/core/composer/qgscomposeritem.h
trunk/qgis/src/ui/qgsitempositiondialogbase.ui
Log:
[FEATURE]: add capability to show and manipulate composer item with/ height in item position dialog
Modified: trunk/qgis/python/core/qgscomposeritem.sip
===================================================================
--- trunk/qgis/python/core/qgscomposeritem.sip 2010-10-07 21:17:30 UTC (rev 14355)
+++ trunk/qgis/python/core/qgscomposeritem.sip 2010-10-08 08:32:06 UTC (rev 14356)
@@ -76,6 +76,10 @@
/**Moves the item to a new position (in canvas coordinates)*/
void setItemPosition( double x, double y, ItemPositionMode itemPoint = UpperLeft );
+ /**Sets item position and width / height in one go
+ @note: this method was added in version 1.6*/
+ void setItemPosition( double x, double y, double width, double height, ItemPositionMode itemPoint = UpperLeft );
+
/**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 );
Modified: trunk/qgis/src/app/composer/qgsitempositiondialog.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgsitempositiondialog.cpp 2010-10-07 21:17:30 UTC (rev 14355)
+++ trunk/qgis/src/app/composer/qgsitempositiondialog.cpp 2010-10-08 08:32:06 UTC (rev 14356)
@@ -39,9 +39,18 @@
mXLineEdit->setValidator( new QDoubleValidator( 0 ) );
mYLineEdit->setValidator( new QDoubleValidator( 0 ) );
+ mWidthLineEdit->setValidator( new QDoubleValidator( 0 ) );
+ mHeightLineEdit->setValidator( new QDoubleValidator( 0 ) );
//set lower left position of item
mUpperLeftCheckBox->setCheckState( Qt::Checked );
+
+ //set initial width and height
+ if ( mItem )
+ {
+ mWidthLineEdit->setText( QString::number( mItem->rect().width() ) );
+ mHeightLineEdit->setText( QString::number( mItem->rect().height() ) );
+ }
}
QgsItemPositionDialog::QgsItemPositionDialog(): mItem( 0 )
@@ -69,6 +78,22 @@
return 0;
}
+int QgsItemPositionDialog::size( QSizeF& s ) const
+{
+ bool convSuccessWidth, convSuccessHeight;
+ double width = mWidthLineEdit->text().toDouble( &convSuccessWidth );
+ double height = mHeightLineEdit->text().toDouble( &convSuccessHeight );
+
+ if ( !convSuccessWidth || !convSuccessHeight )
+ {
+ return 1;
+ }
+
+ s.setWidth( width );
+ s.setHeight( height );
+ return 0;
+}
+
QgsComposerItem::ItemPositionMode QgsItemPositionDialog::positionMode() const
{
if ( mUpperLeftCheckBox->checkState() == Qt::Checked )
@@ -123,10 +148,18 @@
}
QgsPoint itemPosition;
+ QSizeF itemSize;
+
if ( position( itemPosition ) == 0 )
{
- //query position and mode from dialog
- mItem->setItemPosition( itemPosition.x(), itemPosition.y(), positionMode() );
+ if ( size( itemSize ) == 0 )
+ {
+ mItem->setItemPosition( itemPosition.x(), itemPosition.y(), itemSize.width(), itemSize.height(), positionMode() );
+ }
+ else
+ {
+ mItem->setItemPosition( itemPosition.x(), itemPosition.y(), positionMode() );
+ }
mItem->update();
}
}
Modified: trunk/qgis/src/app/composer/qgsitempositiondialog.h
===================================================================
--- trunk/qgis/src/app/composer/qgsitempositiondialog.h 2010-10-07 21:17:30 UTC (rev 14355)
+++ trunk/qgis/src/app/composer/qgsitempositiondialog.h 2010-10-08 08:32:06 UTC (rev 14356)
@@ -32,6 +32,8 @@
/**Get selected x- and y-coordinate as point. Returns 0 in case of success*/
int position( QgsPoint& point ) const;
+ /**Get selected size. Returns 0 in case of success*/
+ int size( QSizeF& s ) const;
/**A combination of upper/middle/lower and left/middle/right*/
QgsComposerItem::ItemPositionMode positionMode() const;
Modified: trunk/qgis/src/core/composer/qgscomposeritem.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritem.cpp 2010-10-07 21:17:30 UTC (rev 14355)
+++ trunk/qgis/src/core/composer/qgscomposeritem.cpp 2010-10-08 08:32:06 UTC (rev 14356)
@@ -630,7 +630,11 @@
{
double width = rect().width();
double height = rect().height();
+ setItemPosition( x, y, width, height, itemPoint );
+}
+void QgsComposerItem::setItemPosition( double x, double y, double width, double height, ItemPositionMode itemPoint )
+{
double upperLeftX = x;
double upperLeftY = y;
Modified: trunk/qgis/src/core/composer/qgscomposeritem.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritem.h 2010-10-07 21:17:30 UTC (rev 14355)
+++ trunk/qgis/src/core/composer/qgscomposeritem.h 2010-10-08 08:32:06 UTC (rev 14356)
@@ -109,6 +109,10 @@
/**Moves the item to a new position (in canvas coordinates)*/
void setItemPosition( double x, double y, ItemPositionMode itemPoint = UpperLeft );
+ /**Sets item position and width / height in one go
+ @note: this method was added in version 1.6*/
+ void setItemPosition( double x, double y, double width, double height, ItemPositionMode itemPoint = UpperLeft );
+
/**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 );
Modified: trunk/qgis/src/ui/qgsitempositiondialogbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsitempositiondialogbase.ui 2010-10-07 21:17:30 UTC (rev 14355)
+++ trunk/qgis/src/ui/qgsitempositiondialogbase.ui 2010-10-08 08:32:06 UTC (rev 14356)
@@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
- <width>434</width>
- <height>274</height>
+ <width>334</width>
+ <height>192</height>
</rect>
</property>
<property name="windowTitle">
<string>Set item position</string>
</property>
- <layout class="QGridLayout">
+ <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="mPositionGroupBox">
<property name="title">
@@ -91,35 +91,47 @@
<property name="title">
<string>Coordinates</string>
</property>
- <layout class="QGridLayout">
+ <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <layout class="QHBoxLayout">
- <item>
- <widget class="QLabel" name="mXLabel">
- <property name="text">
- <string>x</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="mXLineEdit"/>
- </item>
- </layout>
+ <widget class="QLabel" name="mXLabel">
+ <property name="text">
+ <string>x</string>
+ </property>
+ </widget>
</item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QLineEdit" name="mXLineEdit"/>
+ </item>
<item row="1" column="0">
- <layout class="QHBoxLayout">
- <item>
- <widget class="QLabel" name="mYLabel">
- <property name="text">
- <string>y</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="mYLineEdit"/>
- </item>
- </layout>
+ <widget class="QLabel" name="mYLabel">
+ <property name="text">
+ <string>y</string>
+ </property>
+ </widget>
</item>
+ <item row="1" column="1" colspan="2">
+ <widget class="QLineEdit" name="mYLineEdit"/>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QLabel" name="mWidthLabel">
+ <property name="text">
+ <string>Width</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLineEdit" name="mWidthLineEdit"/>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QLabel" name="mHeightLabel">
+ <property name="text">
+ <string>Height</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QLineEdit" name="mHeightLineEdit"/>
+ </item>
</layout>
</widget>
</item>
More information about the QGIS-commit
mailing list