Skip to content
Permalink
Browse files

Fix creation of default composer names (fix #13339)

  • Loading branch information
nyalldawson committed Sep 11, 2015
1 parent 9251fae commit 8731065715eff4784aab1ad614cd4dd1c0463413
Showing with 21 additions and 19 deletions.
  1. +6 −6 src/app/composer/qgscomposer.cpp
  2. +7 −7 src/app/composer/qgscomposermanager.cpp
  3. +7 −5 src/app/qgisapp.cpp
  4. +1 −1 src/app/qgisapp.h
@@ -2717,8 +2717,8 @@ void QgsComposer::on_mActionSaveProject_triggered()

void QgsComposer::on_mActionNewComposer_triggered()
{
QString title = mQgis->uniqueComposerTitle( this, true );
if ( title.isNull() )
QString title;
if ( !mQgis->uniqueComposerTitle( this, title, true ) )
{
return;
}
@@ -2727,8 +2727,8 @@ void QgsComposer::on_mActionNewComposer_triggered()

void QgsComposer::on_mActionDuplicateComposer_triggered()
{
QString newTitle = mQgis->uniqueComposerTitle( this, false, title() + tr( " copy" ) );
if ( newTitle.isNull() )
QString newTitle;
if ( !mQgis->uniqueComposerTitle( this, newTitle, false, title() + tr( " copy" ) ) )
{
return;
}
@@ -2827,8 +2827,8 @@ void QgsComposer::loadTemplate( const bool newComposer )

if ( newComposer )
{
QString newTitle = mQgis->uniqueComposerTitle( this, true );
if ( newTitle.isNull() )
QString newTitle;
if ( !mQgis->uniqueComposerTitle( this, newTitle, true ) )
{
return;
}
@@ -193,8 +193,8 @@ void QgsComposerManager::on_mAddButton_clicked()
QgsComposer* newComposer = 0;
bool loadedOK = false;

QString title = QgisApp::instance()->uniqueComposerTitle( this, true );
if ( title.isNull() )
QString title;
if ( !QgisApp::instance()->uniqueComposerTitle( this, title, true ) )
{
return;
}
@@ -255,7 +255,7 @@ void QgsComposerManager::on_mTemplatePathBtn_pressed()
tr( "Choose template" ),
lastTmplDir,
tr( "Composer templates" ) + " (*.qpt)" );
if ( !tmplPath.isNull() )
if ( !tmplPath.isEmpty() )
{
mTemplatePathLineEdit->setText( tmplPath );
settings.setValue( "UI/ComposerManager/templatePath", tmplPath );
@@ -420,8 +420,8 @@ void QgsComposerManager::duplicate_clicked()
return;
}

QString newTitle = QgisApp::instance()->uniqueComposerTitle( this, false, currentTitle + tr( " copy" ) );
if ( newTitle.isNull() )
QString newTitle;
if ( !QgisApp::instance()->uniqueComposerTitle( this, newTitle, false, currentTitle + tr( " copy" ) ) )
{
return;
}
@@ -469,8 +469,8 @@ void QgsComposerManager::rename_clicked()
{
return;
}
QString newTitle = QgisApp::instance()->uniqueComposerTitle( this, false, currentTitle );
if ( newTitle.isNull() )
QString newTitle;
if ( !QgisApp::instance()->uniqueComposerTitle( this, newTitle, false, currentTitle ) )
{
return;
}
@@ -4596,8 +4596,8 @@ void QgisApp::openFile( const QString & fileName )

void QgisApp::newPrintComposer()
{
QString title = uniqueComposerTitle( this, true );
if ( title.isNull() )
QString title;
if ( !uniqueComposerTitle( this, title, true ) )
{
return;
}
@@ -5695,7 +5695,7 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
return unionGeom;
}

QString QgisApp::uniqueComposerTitle( QWidget* parent, bool acceptEmpty, const QString& currentName )
bool QgisApp::uniqueComposerTitle( QWidget* parent, QString& composerTitle, bool acceptEmpty, const QString& currentName )
{
if ( !parent )
{
@@ -5729,7 +5729,7 @@ QString QgisApp::uniqueComposerTitle( QWidget* parent, bool acceptEmpty, const Q
&ok );
if ( !ok )
{
return QString::null;
return false;
}

if ( newTitle.isEmpty() )
@@ -5754,7 +5754,9 @@ QString QgisApp::uniqueComposerTitle( QWidget* parent, bool acceptEmpty, const Q
}
}

return newTitle;
composerTitle = newTitle;

return true;
}

QgsComposer* QgisApp::createNewComposer( QString title )
@@ -256,7 +256,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* @param currentTitle base name for initial title choice
* @return QString::null if user cancels input dialog
*/
QString uniqueComposerTitle( QWidget *parent, bool acceptEmpty, const QString& currentTitle = QString() );
bool uniqueComposerTitle( QWidget *parent, QString& composerTitle, bool acceptEmpty, const QString& currentTitle = QString() );
/** Creates a new composer and returns a pointer to it*/
QgsComposer* createNewComposer( QString title = QString() );
/** Deletes a composer and removes entry from Set*/

0 comments on commit 8731065

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