[QGIS Commit] r9587 - in branches/advanced_printing_branch2/src:
app/composer ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Nov 8 04:53:54 EST 2008
Author: mhugent
Date: 2008-11-08 04:53:53 -0500 (Sat, 08 Nov 2008)
New Revision: 9587
Modified:
branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.cpp
branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.h
branches/advanced_printing_branch2/src/ui/qgscomposerpicturewidgetbase.ui
Log:
Add and remove directories for composer picture preview
Modified: branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.cpp
===================================================================
--- branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.cpp 2008-11-08 09:37:18 UTC (rev 9586)
+++ branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.cpp 2008-11-08 09:53:53 UTC (rev 9587)
@@ -160,6 +160,38 @@
mPicture->update();
}
+void QgsComposerPictureWidget::on_mAddDirectoryButton_clicked()
+{
+ //let user select a directory
+ QString directory = QFileDialog::getExistingDirectory(0, tr("Select new preview directory"));
+ if(directory.isNull())
+ {
+ return; //dialog canceled by user
+ }
+
+ //add entry to mSearchDirectoriesComboBox
+ mSearchDirectoriesComboBox->addItem(directory);
+
+ //and add icons to the preview
+ addDirectoryToPreview(directory);
+}
+
+void QgsComposerPictureWidget::on_mRemoveDirectoryButton_clicked()
+{
+ QString directoryToRemove = mSearchDirectoriesComboBox->currentText();
+ mSearchDirectoriesComboBox->removeItem(mSearchDirectoriesComboBox->currentIndex());
+
+ //remove entries from back to front (to have the indices of existing items constant)
+ for(int i = (mPreviewListWidget->count() - 1); i >=0; --i)
+ {
+ QListWidgetItem* currentItem = mPreviewListWidget->item(i);
+ if(currentItem && currentItem->data(Qt::UserRole).toString().startsWith(directoryToRemove))
+ {
+ delete(mPreviewListWidget->takeItem(i));
+ }
+ }
+}
+
void QgsComposerPictureWidget::setGuiElementValues()
{
//set initial gui values
@@ -217,7 +249,7 @@
return; //error
}
- QFileInfoList directoryList = svgDirectory.entryInfoList(QDir::Dirs);
+ QFileInfoList directoryList = svgDirectory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
QFileInfoList::const_iterator dirIt = directoryList.constBegin();
for(; dirIt != directoryList.constEnd(); ++dirIt)
{
Modified: branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.h
===================================================================
--- branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.h 2008-11-08 09:37:18 UTC (rev 9586)
+++ branches/advanced_printing_branch2/src/app/composer/qgscomposerpicturewidget.h 2008-11-08 09:53:53 UTC (rev 9587)
@@ -40,6 +40,8 @@
void on_mWidthLineEdit_editingFinished();
void on_mHeightLineEdit_editingFinished();
void on_mPreviewListWidget_currentItemChanged( QListWidgetItem* current, QListWidgetItem* previous );
+ void on_mAddDirectoryButton_clicked();
+ void on_mRemoveDirectoryButton_clicked();
/**Sets the GUI elements to the values of mPicture*/
void setGuiElementValues();
Modified: branches/advanced_printing_branch2/src/ui/qgscomposerpicturewidgetbase.ui
===================================================================
--- branches/advanced_printing_branch2/src/ui/qgscomposerpicturewidgetbase.ui 2008-11-08 09:37:18 UTC (rev 9586)
+++ branches/advanced_printing_branch2/src/ui/qgscomposerpicturewidgetbase.ui 2008-11-08 09:53:53 UTC (rev 9587)
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>317</width>
- <height>547</height>
+ <width>342</width>
+ <height>613</height>
</rect>
</property>
<property name="sizePolicy" >
@@ -32,26 +32,42 @@
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QComboBox" name="mSearchDirectoriesComboBox" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="mAddDirectoryButton" >
- <property name="text" >
- <string>Add...</string>
- </property>
- </widget>
- </item>
- </layout>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>101</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
+ <item row="0" column="1" >
+ <widget class="QPushButton" name="mAddDirectoryButton" >
+ <property name="text" >
+ <string>Add...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" >
+ <widget class="QPushButton" name="mRemoveDirectoryButton" >
+ <property name="text" >
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="3" >
+ <widget class="QComboBox" name="mSearchDirectoriesComboBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
More information about the QGIS-commit
mailing list