Skip to content
Permalink
Browse files
Remember user specified image directories in composerimage widget. Fi…
…xes bug #3072

git-svn-id: http://svn.osgeo.org/qgis/trunk@14321 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Oct 1, 2010
1 parent ec3e0ac commit 2dcc91603404f04b06a1534a6125ca427f43beb2
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/app/composer/qgscomposerpicturewidget.cpp
@@ -27,6 +27,7 @@
#include <QMessageBox>
#include <QPainter>
#include <QProgressDialog>
#include <QSettings>
#include <QSvgRenderer>

QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture ): QWidget(), mPicture( picture )
@@ -180,11 +181,24 @@ void QgsComposerPictureWidget::on_mAddDirectoryButton_clicked()

//and add icons to the preview
addDirectoryToPreview( directory );

//update the image directory list in the settings
QSettings s;
QStringList userDirList = s.value( "/Composer/PictureWidgetDirectories" ).toStringList();
if ( !userDirList.contains( directory ) )
{
userDirList.append( directory );
}
s.setValue( "/Composer/PictureWidgetDirectories", userDirList );
}

void QgsComposerPictureWidget::on_mRemoveDirectoryButton_clicked()
{
QString directoryToRemove = mSearchDirectoriesComboBox->currentText();
if ( directoryToRemove.isEmpty() )
{
return;
}
mSearchDirectoriesComboBox->removeItem( mSearchDirectoriesComboBox->currentIndex() );

//remove entries from back to front (to have the indices of existing items constant)
@@ -196,6 +210,12 @@ void QgsComposerPictureWidget::on_mRemoveDirectoryButton_clicked()
delete( mPreviewListWidget->takeItem( i ) );
}
}

//update the image directory list in the settings
QSettings s;
QStringList userDirList = s.value( "/Composer/PictureWidgetDirectories" ).toStringList();
userDirList.removeOne( directoryToRemove );
s.setValue( "/Composer/PictureWidgetDirectories", userDirList );
}

void QgsComposerPictureWidget::on_mRotationFromComposerMapCheckBox_stateChanged( int state )
@@ -463,6 +483,16 @@ void QgsComposerPictureWidget::addStandardDirectoriesToPreview()
}
}
}

//include additional user-defined directories for images
QSettings s;
QStringList userDirList = s.value( "/Composer/PictureWidgetDirectories" ).toStringList();
QStringList::const_iterator userDirIt = userDirList.constBegin();
for ( ; userDirIt != userDirList.constEnd(); ++userDirIt )
{
addDirectoryToPreview( *userDirIt );
mSearchDirectoriesComboBox->addItem( *userDirIt );
}
}

bool QgsComposerPictureWidget::testSvgFile( const QString& filename ) const

0 comments on commit 2dcc916

Please sign in to comment.