[QGIS Commit] r9058 - in branches/advanced_printing_branch/src/app:
. composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Aug 13 12:16:35 EDT 2008
Author: mhugent
Date: 2008-08-13 12:16:34 -0400 (Wed, 13 Aug 2008)
New Revision: 9058
Modified:
branches/advanced_printing_branch/src/app/CMakeLists.txt
branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.h
branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.h
Log:
More updates for composer picture
Modified: branches/advanced_printing_branch/src/app/CMakeLists.txt
===================================================================
--- branches/advanced_printing_branch/src/app/CMakeLists.txt 2008-08-13 15:02:56 UTC (rev 9057)
+++ branches/advanced_printing_branch/src/app/CMakeLists.txt 2008-08-13 16:16:34 UTC (rev 9058)
@@ -135,6 +135,7 @@
composer/qgscomposerlegendwidget.h
composer/qgscomposermap.h
composer/qgscomposermapwidget.h
+ composer/qgscomposerpicture.h
composer/qgscomposerpicturewidget.h
composer/qgscomposerscalebar.h
composer/qgscomposerscalebarwidget.h
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp 2008-08-13 15:02:56 UTC (rev 9057)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp 2008-08-13 16:16:34 UTC (rev 9058)
@@ -22,11 +22,11 @@
#include <QPainter>
#include <QSvgRenderer>
-QgsComposerPicture::QgsComposerPicture(QgsComposition *composition): QgsComposerItem(composition), mMode(UNKNOWN), mSvgCacheUpToDate(false), mCachedDpi(0)
+QgsComposerPicture::QgsComposerPicture(QgsComposition *composition): QgsComposerItem(composition), QObject(0), mRotation(0.0), mMode(UNKNOWN), mSvgCacheUpToDate(false), mCachedDpi(0)
{
}
-QgsComposerPicture::QgsComposerPicture(): QgsComposerItem(0), mMode(UNKNOWN), mSvgCacheUpToDate(false)
+QgsComposerPicture::QgsComposerPicture(): QgsComposerItem(0), mRotation(0.0), mMode(UNKNOWN), mSvgCacheUpToDate(false)
{
}
@@ -127,6 +127,7 @@
mMode = UNKNOWN;
}
}
+ emit settingsChanged();
}
void QgsComposerPicture::updateImageFromSvg()
@@ -166,6 +167,7 @@
mImage = QImage(newImageWidth, newImageHeight, QImage::Format_ARGB32);
}
QgsComposerItem::setSceneRect(rectangle);
+ emit settingsChanged();
}
void QgsComposerPicture::setRotation(double rotation)
@@ -180,6 +182,11 @@
}
}
+QString QgsComposerPicture::pictureFile() const
+{
+ return mSourceFile.fileName();
+}
+
bool QgsComposerPicture::writeXML(QDomElement& elem, QDomDocument & doc)
{
return false; //soon...
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.h 2008-08-13 15:02:56 UTC (rev 9057)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.h 2008-08-13 16:16:34 UTC (rev 9058)
@@ -20,10 +20,12 @@
#include "qgscomposeritem.h"
#include <QFile>
#include <QImage>
+#include <QObject>
/**A composer class that displays svg files or raster format (jpg, png, ...)*/
-class QgsComposerPicture: public QgsComposerItem
+class QgsComposerPicture: public QObject, public QgsComposerItem
{
+ Q_OBJECT
public:
QgsComposerPicture(QgsComposition *composition);
~QgsComposerPicture();
@@ -33,6 +35,7 @@
/**Sets the source file of the image (may be svg or a raster format)*/
void setPictureFile(const QString& path);
+ QString pictureFile() const;
/**Sets this items bound in scene coordinates such that 1 item size units
corresponds to 1 scene size unit*/
@@ -75,6 +78,10 @@
bool mSvgCacheUpToDate;
int mCachedDpi; //store dpis for which the svg cache is valid
QSize mDefaultSvgSize;
+
+ signals:
+ /**Tell the configuration widget that the settings need to be updated*/
+ void settingsChanged();
};
#endif
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.cpp 2008-08-13 15:02:56 UTC (rev 9057)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.cpp 2008-08-13 16:16:34 UTC (rev 9058)
@@ -17,6 +17,7 @@
#include "qgscomposerpicturewidget.h"
#include "qgscomposerpicture.h"
+#include <QDoubleValidator>
#include <QFileDialog>
#include <QFileInfo>
#include <QMessageBox>
@@ -24,6 +25,13 @@
QgsComposerPictureWidget::QgsComposerPictureWidget(QgsComposerPicture* picture): QWidget(), mPicture(picture)
{
setupUi(this);
+
+ mWidthLineEdit->setValidator(new QDoubleValidator(this));
+ mHeightLineEdit->setValidator(new QDoubleValidator(this));
+
+ setGuiElementValues();
+
+ connect(mPicture, SIGNAL(settingsChanged()), this, SLOT(setGuiElementValues()));
}
QgsComposerPictureWidget::~QgsComposerPictureWidget()
@@ -33,8 +41,17 @@
void QgsComposerPictureWidget::on_mPictureBrowseButton_clicked()
{
+ QString openDir;
+ QString lineEditText = mPictureLineEdit->text();
+ if(!lineEditText.isEmpty())
+ {
+ QFileInfo openDirFileInfo(lineEditText);
+ openDir = openDirFileInfo.path();
+ }
+
+
//show file dialog
- QString filePath = QFileDialog::getOpenFileName(0, tr("Select svg/image file"));
+ QString filePath = QFileDialog::getOpenFileName(0, tr("Select svg or image file"), openDir);
if(filePath.isEmpty())
{
return;
@@ -80,6 +97,38 @@
}
}
+void QgsComposerPictureWidget::on_mWidthLineEdit_editingFinished()
+{
+ if(mPicture)
+ {
+ QRectF pictureRect = mPicture->rect();
+
+ bool conversionOk;
+ double newWidth = mWidthLineEdit->text().toDouble(&conversionOk);
+ if(conversionOk)
+ {
+ QRectF newSceneRect(mPicture->transform().dx(), mPicture->transform().dy(), newWidth, pictureRect.height());
+ mPicture->setSceneRect(newSceneRect);
+ }
+ }
+}
+
+void QgsComposerPictureWidget::on_mHeightLineEdit_editingFinished()
+{
+ if(mPicture)
+ {
+ QRectF pictureRect = mPicture->rect();
+
+ bool conversionOk;
+ double newHeight = mHeightLineEdit->text().toDouble(&conversionOk);
+ if(conversionOk)
+ {
+ QRectF newSceneRect(mPicture->transform().dx(), mPicture->transform().dy(), pictureRect.width(), newHeight);
+ mPicture->setSceneRect(newSceneRect);
+ }
+ }
+}
+
void QgsComposerPictureWidget::on_mRotationSpinBox_valueChanged(double d)
{
if(mPicture)
@@ -88,3 +137,36 @@
mPicture->update();
}
}
+
+void QgsComposerPictureWidget::setGuiElementValues()
+{
+ //set initial gui values
+ if(mPicture)
+ {
+ mWidthLineEdit->blockSignals(true);
+ mHeightLineEdit->blockSignals(true);
+ mRotationSpinBox->blockSignals(true);
+ mFrameCheckBox->blockSignals(true);
+ mPictureLineEdit->blockSignals(true);
+
+ mPictureLineEdit->setText(mPicture->pictureFile());
+ QRectF pictureRect = mPicture->rect();
+ mWidthLineEdit->setText(QString::number(pictureRect.width()));
+ mHeightLineEdit->setText(QString::number(pictureRect.height()));
+ mRotationSpinBox->setValue(mPicture->rotation());
+ if(mPicture->frame())
+ {
+ mFrameCheckBox->setCheckState(Qt::Checked);
+ }
+ else
+ {
+ mFrameCheckBox->setCheckState(Qt::Unchecked);
+ }
+
+ mWidthLineEdit->blockSignals(false);
+ mHeightLineEdit->blockSignals(false);
+ mRotationSpinBox->blockSignals(false);
+ mFrameCheckBox->blockSignals(false);
+ mPictureLineEdit->blockSignals(false);
+ }
+}
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.h 2008-08-13 15:02:56 UTC (rev 9057)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerpicturewidget.h 2008-08-13 16:16:34 UTC (rev 9058)
@@ -34,6 +34,10 @@
void on_mPictureBrowseButton_clicked();
void on_mPictureLineEdit_editingFinished();
void on_mRotationSpinBox_valueChanged(double d);
+ void on_mWidthLineEdit_editingFinished();
+ void on_mHeightLineEdit_editingFinished();
+ /**Sets the GUI elements to the values of mPicture*/
+ void setGuiElementValues();
private:
QgsComposerPicture* mPicture;
More information about the QGIS-commit
mailing list