[QGIS Commit] r13300 - in trunk/qgis/src: app app/composer core ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Apr 11 11:02:09 EDT 2010
Author: jef
Date: 2010-04-11 11:02:09 -0400 (Sun, 11 Apr 2010)
New Revision: 13300
Modified:
trunk/qgis/src/app/composer/qgscomposermanager.cpp
trunk/qgis/src/app/composer/qgscomposermanager.h
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/core/qgsgeometry.cpp
trunk/qgis/src/ui/qgscomposermanagerbase.ui
Log:
remove Qt 4.5 dependency and fix a warning
Modified: trunk/qgis/src/app/composer/qgscomposermanager.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposermanager.cpp 2010-04-11 14:12:20 UTC (rev 13299)
+++ trunk/qgis/src/app/composer/qgscomposermanager.cpp 2010-04-11 15:02:09 UTC (rev 13300)
@@ -24,10 +24,25 @@
#include <QListWidgetItem>
#include <QMessageBox>
-QgsComposerManager::QgsComposerManager( QgisApp* app, QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f ), mQgisApp( app )
+QgsComposerManager::QgsComposerManager( QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f )
{
+ QPushButton *pb;
+
setupUi( this );
connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( close() ) );
+
+ pb = new QPushButton( tr( "&Show" ) );
+ mButtonBox->addButton( pb, QDialogButtonBox::ActionRole );
+ connect( pb, SIGNAL( clicked() ), this, SLOT( show_clicked() ) );
+
+ pb = new QPushButton( tr( "&Remove" ) );
+ mButtonBox->addButton( pb, QDialogButtonBox::ActionRole );
+ connect( pb, SIGNAL( clicked() ), this, SLOT( remove_clicked() ) );
+
+ pb = new QPushButton( tr( "Re&name" ) );
+ mButtonBox->addButton( pb, QDialogButtonBox::ActionRole );
+ connect( pb, SIGNAL( clicked() ), this, SLOT( rename_clicked() ) );
+
initialize();
}
@@ -38,12 +53,7 @@
void QgsComposerManager::initialize()
{
- if ( !mQgisApp )
- {
- return;
- }
-
- QSet<QgsComposer*> composers = mQgisApp->printComposers();
+ QSet<QgsComposer*> composers = QgisApp::instance()->printComposers();
QSet<QgsComposer*>::const_iterator it = composers.constBegin();
for ( ; it != composers.constEnd(); ++it )
{
@@ -51,6 +61,18 @@
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
mItemComposerMap.insert( item, *it );
}
+
+ mTemplate->addItem( tr( "Empty composer" ) );
+
+ QMap<QString, QString> templateMap = defaultTemplates();
+ if ( templateMap.size() > 0 )
+ {
+ QMap<QString, QString>::const_iterator templateIt = templateMap.constBegin();
+ for ( ; templateIt != templateMap.constEnd(); ++templateIt )
+ {
+ mTemplate->addItem( templateIt.key(), templateIt.value() );
+ }
+ }
}
QMap<QString, QString> QgsComposerManager::defaultTemplates() const
@@ -75,51 +97,18 @@
void QgsComposerManager::on_mAddButton_clicked()
{
- if ( !mQgisApp )
- {
- return;
- }
-
- QMap<QString, QString> templateMap = defaultTemplates();
- QString composerTemplate;
QgsComposer* newComposer = 0;
- if ( templateMap.size() > 0 )
- {
- //show template dialog
- QStringList templateNameList;
- templateNameList.append( tr( "Empty composer" ) );
- QMap<QString, QString>::const_iterator templateIt = templateMap.constBegin();
- for ( ; templateIt != templateMap.constEnd(); ++templateIt )
- {
- templateNameList.append( templateIt.key() );
- }
-
- QInputDialog templateDialog;
- templateDialog.setLabelText( tr( "Select a composer template" ) );
- templateDialog.setComboBoxItems( templateNameList );
- if ( templateDialog.exec() == QDialog::Rejected )
- {
- return;
- }
-
- QMap<QString, QString>::const_iterator selectedTemplate = templateMap.find( templateDialog.textValue() );
- if ( selectedTemplate != templateMap.constEnd() )
- {
- composerTemplate = selectedTemplate.value();
- }
- }
-
- newComposer = mQgisApp->createNewComposer();
+ newComposer = QgisApp::instance()->createNewComposer();
if ( !newComposer )
{
return;
}
- if ( !composerTemplate.isEmpty() ) //create composer from template
+ if ( mTemplate->currentIndex() > 0 )
{
QDomDocument templateDoc;
- QFile templateFile( composerTemplate );
+ QFile templateFile( mTemplate->itemData( mTemplate->currentIndex() ).toString() );
if ( templateFile.open( QIODevice::ReadOnly ) )
{
if ( templateDoc.setContent( &templateFile, false ) )
@@ -134,13 +123,8 @@
mItemComposerMap.insert( item, newComposer );
}
-void QgsComposerManager::on_mRemoveButton_clicked()
+void QgsComposerManager::remove_clicked()
{
- if ( !mQgisApp )
- {
- return;
- }
-
QListWidgetItem* item = mComposerListWidget->currentItem();
if ( !item )
{
@@ -157,7 +141,7 @@
QMap<QListWidgetItem*, QgsComposer*>::iterator it = mItemComposerMap.find( item );
if ( it != mItemComposerMap.end() )
{
- mQgisApp->deleteComposer( it.value() );
+ QgisApp::instance()->deleteComposer( it.value() );
}
mItemComposerMap.remove( item );
mComposerListWidget->removeItemWidget( item );
@@ -165,13 +149,8 @@
delete( mComposerListWidget->takeItem( mComposerListWidget->row( item ) ) );
}
-void QgsComposerManager::on_mShowPushButton_clicked()
+void QgsComposerManager::show_clicked()
{
- if ( !mQgisApp )
- {
- return;
- }
-
QListWidgetItem* item = mComposerListWidget->currentItem();
if ( !item )
{
@@ -215,7 +194,7 @@
{
return;
}
- c = mQgisApp->createNewComposer();
+ c = QgisApp::instance()->createNewComposer();
c->setTitle( it.key()->text() );
if ( c )
{
@@ -236,7 +215,7 @@
#endif //0
}
-void QgsComposerManager::on_mRenamePushButton_clicked()
+void QgsComposerManager::rename_clicked()
{
QListWidgetItem* item = mComposerListWidget->currentItem();
if ( !item )
Modified: trunk/qgis/src/app/composer/qgscomposermanager.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposermanager.h 2010-04-11 14:12:20 UTC (rev 13299)
+++ trunk/qgis/src/app/composer/qgscomposermanager.h 2010-04-11 15:02:09 UTC (rev 13300)
@@ -19,7 +19,6 @@
#include "ui_qgscomposermanagerbase.h"
-class QgisApp;
class QListWidgetItem;
class QgsComposer;
@@ -29,12 +28,11 @@
{
Q_OBJECT
public:
- QgsComposerManager( QgisApp* app, QWidget * parent = 0, Qt::WindowFlags f = 0 );
+ QgsComposerManager( QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsComposerManager();
private:
- QgisApp* mQgisApp;
/**Stores the relation between items and composer pointers. A 0 pointer for the composer means that
this composer needs to be created from a default template*/
QMap<QListWidgetItem*, QgsComposer*> mItemComposerMap;
@@ -47,9 +45,9 @@
private slots:
void on_mAddButton_clicked();
- void on_mRemoveButton_clicked();
- void on_mShowPushButton_clicked();
- void on_mRenamePushButton_clicked();
+ void remove_clicked();
+ void show_clicked();
+ void rename_clicked();
void on_mComposerListWidget_itemChanged( QListWidgetItem * item );
};
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2010-04-11 14:12:20 UTC (rev 13299)
+++ trunk/qgis/src/app/qgisapp.cpp 2010-04-11 15:02:09 UTC (rev 13300)
@@ -3561,7 +3561,7 @@
void QgisApp::showComposerManager()
{
- QgsComposerManager m( this, 0 );
+ QgsComposerManager m;
m.exec();
}
Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp 2010-04-11 14:12:20 UTC (rev 13299)
+++ trunk/qgis/src/core/qgsgeometry.cpp 2010-04-11 15:02:09 UTC (rev 13300)
@@ -5528,7 +5528,7 @@
}
double x, y;
- for ( int i = 0; i < ( nCoords - 1 ); ++i )
+ for ( unsigned int i = 0; i < ( nCoords - 1 ); ++i )
{
GEOSCoordSeq_getX( bBoxCoordSeq, i, &x );
if ( x > 180 || x < -180 )
Modified: trunk/qgis/src/ui/qgscomposermanagerbase.ui
===================================================================
--- trunk/qgis/src/ui/qgscomposermanagerbase.ui 2010-04-11 14:12:20 UTC (rev 13299)
+++ trunk/qgis/src/ui/qgscomposermanagerbase.ui 2010-04-11 15:02:09 UTC (rev 13300)
@@ -1,72 +1,42 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>QgsComposerManagerBase</class>
- <widget class="QDialog" name="QgsComposerManagerBase" >
- <property name="geometry" >
+ <widget class="QDialog" name="QgsComposerManagerBase">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>346</width>
- <height>203</height>
+ <height>195</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Composer manager</string>
</property>
- <layout class="QGridLayout" name="gridLayout" >
- <item rowspan="5" row="0" column="0" >
- <widget class="QListWidget" name="mComposerListWidget" />
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" rowspan="3" colspan="2">
+ <widget class="QListWidget" name="mComposerListWidget"/>
</item>
- <item row="0" column="1" >
- <widget class="QPushButton" name="mShowPushButton" >
- <property name="text" >
- <string>Show</string>
+ <item row="4" column="0" colspan="2">
+ <widget class="QDialogButtonBox" name="mButtonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QPushButton" name="mRemoveButton" >
- <property name="text" >
- <string>Remove</string>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
- <item row="2" column="1" >
- <widget class="QPushButton" name="mRenamePushButton" >
- <property name="text" >
- <string>Rename</string>
- </property>
- </widget>
+ <item row="3" column="0">
+ <widget class="QComboBox" name="mTemplate"/>
</item>
- <item row="3" column="1" >
- <widget class="QPushButton" name="mAddButton" >
- <property name="text" >
+ <item row="3" column="1">
+ <widget class="QPushButton" name="mAddButton">
+ <property name="text">
<string>Add</string>
</property>
</widget>
</item>
- <item row="4" column="1" >
- <spacer name="verticalSpacer" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>50</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="5" column="0" colspan="2" >
- <widget class="QDialogButtonBox" name="mButtonBox" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Close</set>
- </property>
- </widget>
- </item>
</layout>
</widget>
<resources/>
@@ -77,11 +47,11 @@
<receiver>QgsComposerManagerBase</receiver>
<slot>accept()</slot>
<hints>
- <hint type="sourcelabel" >
+ <hint type="sourcelabel">
<x>251</x>
<y>193</y>
</hint>
- <hint type="destinationlabel" >
+ <hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
@@ -93,11 +63,11 @@
<receiver>QgsComposerManagerBase</receiver>
<slot>reject()</slot>
<hints>
- <hint type="sourcelabel" >
+ <hint type="sourcelabel">
<x>251</x>
<y>193</y>
</hint>
- <hint type="destinationlabel" >
+ <hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
More information about the QGIS-commit
mailing list