Skip to content
Permalink
Browse files

Set better window titles for svg annotation

  • Loading branch information
mhugent committed Nov 19, 2012
1 parent 463dec7 commit 5f02bc4d4d9d8e22042692909f0184459d0fe2c1
Showing with 40 additions and 39 deletions.
  1. +39 −38 src/app/qgssvgannotationdialog.cpp
  2. +1 −1 src/ui/qgsformannotationdialogbase.ui
@@ -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 )
@@ -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;
}
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Form annotation</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">

0 comments on commit 5f02bc4

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