Skip to content
Permalink
Browse files

remove Qt 4.5 dependency and fix a warning

git-svn-id: http://svn.osgeo.org/qgis/trunk@13300 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Apr 11, 2010
1 parent 04f5190 commit e795414e20524485afb3c30c4a5a5707f788e154
@@ -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,19 +53,26 @@ QgsComposerManager::~QgsComposerManager()

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 )
{
QListWidgetItem* item = new QListWidgetItem(( *it )->title(), mComposerListWidget );
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 @@ QMap<QString, QString> QgsComposerManager::defaultTemplates() const

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 @@ void QgsComposerManager::on_mAddButton_clicked()
mItemComposerMap.insert( item, newComposer );
}

void QgsComposerManager::on_mRemoveButton_clicked()
void QgsComposerManager::remove_clicked()
{
if ( !mQgisApp )
{
return;
}

QListWidgetItem* item = mComposerListWidget->currentItem();
if ( !item )
{
@@ -157,21 +141,16 @@ void QgsComposerManager::on_mRemoveButton_clicked()
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 );
//and remove the list widget row
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 @@ void QgsComposerManager::on_mShowPushButton_clicked()
{
return;
}
c = mQgisApp->createNewComposer();
c = QgisApp::instance()->createNewComposer();
c->setTitle( it.key()->text() );
if ( c )
{
@@ -236,7 +215,7 @@ void QgsComposerManager::on_mShowPushButton_clicked()
#endif //0
}

void QgsComposerManager::on_mRenamePushButton_clicked()
void QgsComposerManager::rename_clicked()
{
QListWidgetItem* item = mComposerListWidget->currentItem();
if ( !item )
@@ -19,7 +19,6 @@

#include "ui_qgscomposermanagerbase.h"

class QgisApp;
class QListWidgetItem;
class QgsComposer;

@@ -29,12 +28,11 @@ class QgsComposerManager: public QDialog, private Ui::QgsComposerManagerBase
{
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 @@ class QgsComposerManager: public QDialog, private Ui::QgsComposerManagerBase

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 );
};

@@ -3561,7 +3561,7 @@ void QgisApp::newPrintComposer()

void QgisApp::showComposerManager()
{
QgsComposerManager m( this, 0 );
QgsComposerManager m;
m.exec();
}

@@ -5528,7 +5528,7 @@ bool QgsGeometry::geomInDegrees( const GEOSGeometry* geom )
}

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 )
@@ -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>

0 comments on commit e795414

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