Skip to content

Commit 7117ef8

Browse files
author
timlinux
committed
Implemented more gui api cleanups and suggestions from Albert Areny to clean the api. Note this commit breaks most python plugins out there. Please refer to the plugin interface header to see what is required to (trivially) repair your plugins.
git-svn-id: http://svn.osgeo.org/qgis/trunk@9231 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 66ed0b9 commit 7117ef8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+224
-224
lines changed

python/gui/qgisinterface.sip

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ class QgisInterface : QObject
7272
virtual void openURL(QString url, bool useQgisDocDirectory=true)=0;
7373

7474
/** Return a pointer to the map canvas */
75-
virtual QgsMapCanvas * getMapCanvas()=0;
75+
virtual QgsMapCanvas * mapCanvas()=0;
7676

7777
/** Return a pointer to the main window (instance of QgisApp in case of QGIS) */
78-
virtual QWidget * getMainWindow()=0;
78+
virtual QWidget * mainWindow()=0;
7979

8080
/** Add action to the plugins menu */
81-
virtual void addPluginMenu(QString name, QAction* action)=0;
81+
virtual void addPluginToMenu(QString name, QAction* action)=0;
8282
/** Remove action from the plugins menu */
8383
virtual void removePluginMenu(QString name, QAction* action)=0;
8484

python/gui/qgsgenericprojectionselector.sip

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ class QgsGenericProjectionSelector : QDialog //, private Ui::QgsGenericProjectio
2525
*/
2626
void setMessage(QString theMessage="");
2727

28-
QString getSelectedProj4String();
29-
long getSelectedCRSID();
30-
long getSelectedEpsg();
28+
QString selectedProj4String();
29+
long selectedCrsId();
30+
long selectedEpsg();
3131

32-
void setSelectedCRSName(QString theName);
33-
void setSelectedCRSID(long theID);
32+
void setSelectedCrsName(QString theName);
33+
void setSelectedCrsId(long theID);
3434
void setSelectedEpsg(long theID);
3535

3636
/**

python/gui/qgsprojectionselector.sip

+10-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase
2828
*
2929
* \todo Should this be public?
3030
*/
31-
void applyUserProjList(QSet<QString> * crsFilter = 0);
31+
void loadUserCrsList(QSet<QString> * crsFilter = 0);
3232

3333
/**
3434
* \brief Populate the proj tree view with system projection names...
@@ -39,7 +39,7 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase
3939
*
4040
* \todo Should this be public?
4141
*/
42-
void applyProjList(QSet<QString> * crsFilter = 0);
42+
void loadCrsList(QSet<QString> * crsFilter = 0);
4343

4444

4545
/*!
@@ -51,27 +51,27 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase
5151
* \arg const QString in The input string to make safe.
5252
* \return The string made safe for SQL statements.
5353
*/
54-
const QString stringSQLSafe(const QString theSQL);
54+
const QString sqlSafeString(const QString theSQL);
5555

5656
//! Gets the current EPSG-style projection identifier
57-
long getSelectedEpsg();
57+
long selectedEpsg();
5858

5959
public slots:
60-
void setSelectedCRSName(QString theCRSName);
60+
void setSelectedCrsName(QString theCRSName);
6161

62-
QString getSelectedName();
62+
QString selectedName();
6363

64-
void setSelectedCRSID(long theCRSID);
64+
void setSelectedCrsId(long theCRSID);
6565

6666
void setSelectedEpsg(long epsg);
6767

68-
QString getSelectedProj4String();
68+
QString selectedProj4String();
6969

7070
//! Gets the current PostGIS-style projection identifier
71-
long getSelectedSRID();
71+
long selectedPostgresSrId();
7272

7373
//! Gets the current QGIS projection identfier
74-
long getSelectedCRSID();
74+
long selectedCrsId();
7575

7676
/**
7777
* \brief filters this widget by the given CRSs

src/app/composer/qgscomposer.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
204204
mView = new QgsComposerView( mViewFrame );
205205
connectSlots();
206206

207-
mComposition = new QgsComposition( mQgis->getMapCanvas()->mapRenderer() );
207+
mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
208208
mView->setComposition( mComposition );
209209

210210
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mCompositionOptionsFrame, mComposition );
@@ -382,7 +382,7 @@ void QgsComposer::showItemOptions( const QgsComposerItem* item )
382382

383383
QgsMapCanvas *QgsComposer::mapCanvas( void )
384384
{
385-
return mQgis->getMapCanvas();
385+
return mQgis->mapCanvas();
386386
}
387387

388388
QgsComposerView *QgsComposer::view( void )
@@ -1395,7 +1395,7 @@ void QgsComposer::readXML( const QDomDocument& doc )
13951395
mView = new QgsComposerView( mViewFrame );
13961396
connectSlots();
13971397

1398-
mComposition = new QgsComposition( mQgis->getMapCanvas()->mapRenderer() );
1398+
mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
13991399
mComposition->readXML( compositionElem, doc );
14001400

14011401
QGridLayout *l = new QGridLayout( mViewFrame );

src/app/qgisapp.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem* srs )
275275
QgsCoordinateReferenceSystem defaultCRS;
276276
if ( defaultCRS.createFromProj4( proj4String ) )
277277
{
278-
mySelector->setSelectedCRSID( defaultCRS.srsid() );
278+
mySelector->setSelectedCrsId( defaultCRS.srsid() );
279279
}
280280

281281
if ( mySelector->exec() )
282282
{
283-
QgsDebugMsg( "Layer srs set from dialog: " + QString::number( mySelector->getSelectedCRSID() ) );
284-
srs->createFromProj4( mySelector->getSelectedProj4String() );
283+
QgsDebugMsg( "Layer srs set from dialog: " + QString::number( mySelector->selectedCrsId() ) );
284+
srs->createFromProj4( mySelector->selectedProj4String() );
285285
srs->debugPrint();
286286
}
287287
else
@@ -3506,11 +3506,11 @@ void QgisApp::toggleFullScreen()
35063506
// showMaxmized() is a work-around. Turn off rendering for this as it
35073507
// would otherwise cause two re-renders of the map, which can take a
35083508
// long time.
3509-
bool renderFlag = getMapCanvas()->renderFlag();
3510-
getMapCanvas()->setRenderFlag( false );
3509+
bool renderFlag = mapCanvas()->renderFlag();
3510+
mapCanvas()->setRenderFlag( false );
35113511
showNormal();
35123512
showMaximized();
3513-
getMapCanvas()->setRenderFlag( renderFlag );
3513+
mapCanvas()->setRenderFlag( renderFlag );
35143514
mPrevScreenModeMaximized = false;
35153515
}
35163516
else
@@ -4761,7 +4761,7 @@ QMenu* QgisApp::getPluginMenu( QString menuName )
47614761
return menu;
47624762
}
47634763

4764-
void QgisApp::addPluginMenu( QString name, QAction* action )
4764+
void QgisApp::addPluginToMenu( QString name, QAction* action )
47654765
{
47664766
QMenu* menu = getPluginMenu( name );
47674767
menu->addAction( action );
@@ -4891,8 +4891,8 @@ void QgisApp::updateMouseCoordinatePrecision()
48914891
// coordinates with the aim of always having enough decimal places
48924892
// to show the difference in position between adjacent pixels.
48934893
// Also avoid taking the log of 0.
4894-
if ( getMapCanvas()->mapUnitsPerPixel() != 0.0 )
4895-
dp = static_cast<int>( ceil( -1.0 * log10( getMapCanvas()->mapUnitsPerPixel() ) ) );
4894+
if ( mapCanvas()->mapUnitsPerPixel() != 0.0 )
4895+
dp = static_cast<int>( ceil( -1.0 * log10( mapCanvas()->mapUnitsPerPixel() ) ) );
48964896
}
48974897
else
48984898
dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );

src/app/qgisapp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class QgisApp : public QMainWindow
135135
//!Overloaded version of the private function with same name that takes the imagename as a parameter
136136
void saveMapAsImage( QString, QPixmap * );
137137
/** Get the mapcanvas object from the app */
138-
QgsMapCanvas * getMapCanvas() { return mMapCanvas; };
138+
QgsMapCanvas * mapCanvas() { return mMapCanvas; };
139139
//! Set theme (icons)
140140
void setTheme( QString themeName = "default" );
141141
//! Setup the toolbar popup menus for a given theme
@@ -384,7 +384,7 @@ class QgisApp : public QMainWindow
384384
//! Find the QMenu with the given name (ie the user visible text on the menu item)
385385
QMenu* getPluginMenu( QString menuName );
386386
//! Add the action to the submenu with the given name under the plugin menu
387-
void addPluginMenu( QString name, QAction* action );
387+
void addPluginToMenu( QString name, QAction* action );
388388
//! Remove the action to the submenu with the given name under the plugin menu
389389
void removePluginMenu( QString name, QAction* action );
390390
//! Add an icon to the plugin toolbar

src/app/qgisappinterface.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ QgsMapLayer *QgisAppInterface::activeLayer()
9999
return qgis->activeLayer();
100100
}
101101

102-
void QgisAppInterface::addPluginMenu( QString name, QAction* action )
102+
void QgisAppInterface::addPluginToMenu( QString name, QAction* action )
103103
{
104-
qgis->addPluginMenu( name, action );
104+
qgis->addPluginToMenu( name, action );
105105
}
106106

107107
void QgisAppInterface::removePluginMenu( QString name, QAction* action )
@@ -131,12 +131,12 @@ void QgisAppInterface::openURL( QString url, bool useQgisDocDirectory )
131131
qgis->openURL( url, useQgisDocDirectory );
132132
}
133133

134-
QgsMapCanvas * QgisAppInterface::getMapCanvas()
134+
QgsMapCanvas * QgisAppInterface::mapCanvas()
135135
{
136-
return qgis->getMapCanvas();
136+
return qgis->mapCanvas();
137137
}
138138

139-
QWidget * QgisAppInterface::getMainWindow()
139+
QWidget * QgisAppInterface::mainWindow()
140140
{
141141
return qgis;
142142
}

src/app/qgisappinterface.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ class QgisAppInterface : public QgisInterface
8787
void openURL( QString url, bool useQgisDocDirectory = true );
8888

8989
/** Return a pointer to the map canvas used by qgisapp */
90-
QgsMapCanvas * getMapCanvas();
90+
QgsMapCanvas * mapCanvas();
9191

9292
/** Gives access to main QgisApp object
9393
9494
Plugins don't need to know about QgisApp, as we pass it as QWidget,
9595
it can be used for connecting slots and using as widget's parent
9696
*/
97-
QWidget * getMainWindow();
97+
QWidget * mainWindow();
9898

9999
/** Add action to the plugins menu */
100-
void addPluginMenu( QString name, QAction* action );
100+
void addPluginToMenu( QString name, QAction* action );
101101
/** Remove action from the plugins menu */
102102
void removePluginMenu( QString name, QAction* action );
103103

src/app/qgsbookmarks.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void QgsBookmarks::zoomToBookmark()
231231
xmax.toDouble(),
232232
ymax.toDouble() ) );
233233
// redraw the map
234-
QgisApp::instance()->getMapCanvas()->refresh();
234+
QgisApp::instance()->mapCanvas()->refresh();
235235
}
236236
}
237237

src/app/qgscustomprojectiondialog.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -800,24 +800,24 @@ void QgsCustomProjectionDialog::on_pbnSave_clicked()
800800
{
801801
mySql = QString( "insert into tbl_srs (srs_id,description,projection_acronym,ellipsoid_acronym,parameters,is_geo) " )
802802
+ " values (" + QString::number( USER_PROJECTION_START_ID ) + ",'"
803-
+ stringSQLSafe( myName ) + "','" + myProjectionAcronym
804-
+ "','" + myEllipsoidAcronym + "','" + stringSQLSafe( myParameters )
803+
+ sqlSafeString( myName ) + "','" + myProjectionAcronym
804+
+ "','" + myEllipsoidAcronym + "','" + sqlSafeString( myParameters )
805805
+ "',0)"; // <-- is_geo shamelessly hard coded for now
806806
}
807807
else
808808
{
809809
mySql = "insert into tbl_srs (description,projection_acronym,ellipsoid_acronym,parameters,is_geo) values ('"
810-
+ stringSQLSafe( myName ) + "','" + myProjectionAcronym
811-
+ "','" + myEllipsoidAcronym + "','" + stringSQLSafe( myParameters )
810+
+ sqlSafeString( myName ) + "','" + myProjectionAcronym
811+
+ "','" + myEllipsoidAcronym + "','" + sqlSafeString( myParameters )
812812
+ "',0)"; // <-- is_geo shamelessly hard coded for now
813813
}
814814
}
815815
else //user is updating an existing record
816816
{
817-
mySql = "update tbl_srs set description='" + stringSQLSafe( myName )
817+
mySql = "update tbl_srs set description='" + sqlSafeString( myName )
818818
+ "',projection_acronym='" + myProjectionAcronym
819819
+ "',ellipsoid_acronym='" + myEllipsoidAcronym
820-
+ "',parameters='" + stringSQLSafe( myParameters ) + "' "
820+
+ "',parameters='" + sqlSafeString( myParameters ) + "' "
821821
+ ",is_geo=0" // <--shamelessly hard coded for now
822822
+ " where srs_id='" + mCurrentRecordId + "'"
823823
;
@@ -1021,7 +1021,7 @@ QString QgsCustomProjectionDialog::getEllipseFromParameters()
10211021
* \arg const QString in The input string to make safe.
10221022
* \return The string made safe for SQL statements.
10231023
*/
1024-
const QString QgsCustomProjectionDialog::stringSQLSafe( const QString theSQL )
1024+
const QString QgsCustomProjectionDialog::sqlSafeString( const QString theSQL )
10251025
{
10261026

10271027
QString myRetval;

src/app/qgscustomprojectiondialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class QgsCustomProjectionDialog : public QDialog, private Ui::QgsCustomProjectio
7070
//so that we can return to it if the record insert is aborted
7171
long mLastRecordLong;
7272
long mRecordCountLong;
73-
const QString stringSQLSafe( const QString theSQL );
73+
const QString sqlSafeString( const QString theSQL );
7474

7575
};
7676

src/app/qgsoptions.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,14 @@ void QgsOptions::on_pbnSelectProjection_clicked()
370370
QgsCoordinateReferenceSystem refSys;
371371
if ( refSys.createFromProj4( txtGlobalWKT->toPlainText() ) )
372372
{
373-
mySelector->setSelectedCRSID( refSys.srsid() );
373+
mySelector->setSelectedCrsId( refSys.srsid() );
374374
}
375375

376376
if ( mySelector->exec() )
377377
{
378378
QgsDebugMsg( "------ Global Default Projection Selection Set ----------" );
379379
//! @todo changes this control name in gui to txtGlobalProjString
380-
txtGlobalWKT->setText( mySelector->getSelectedProj4String() );
380+
txtGlobalWKT->setText( mySelector->selectedProj4String() );
381381
QgsDebugMsg( QString( "------ Global Default Projection now set to ----------\n%1" ).arg( mGlobalCRSID ) );
382382
}
383383
else

src/app/qgsprojectproperties.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
6161

6262
long myCRSID = myRender->destinationSrs().srsid();
6363
QgsDebugMsg( "Read project CRSID: " + QString::number( myCRSID ) );
64-
projectionSelector->setSelectedCRSID( myCRSID );
64+
projectionSelector->setSelectedCrsId( myCRSID );
6565

6666
///////////////////////////////////////////////////////////
6767
// Properties stored in QgsProject
@@ -245,15 +245,15 @@ void QgsProjectProperties::apply()
245245
// selected that has an srid. This prevents error if the user
246246
// selects a top-level node rather than an actual coordinate
247247
// system
248-
long myCRSID = projectionSelector->getSelectedCRSID();
248+
long myCRSID = projectionSelector->selectedCrsId();
249249
if ( myCRSID )
250250
{
251251
QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::QGIS_CRSID );
252252
myRender->setDestinationSrs( srs );
253253

254254
// write the currently selected projections _proj string_ to project settings
255-
QgsDebugMsg( QString( "SpatialRefSys/ProjectCRSProj4String: %1" ).arg( projectionSelector->getSelectedProj4String() ) );
256-
QgsProject::instance()->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", projectionSelector->getSelectedProj4String() );
255+
QgsDebugMsg( QString( "SpatialRefSys/ProjectCRSProj4String: %1" ).arg( projectionSelector->selectedProj4String() ) );
256+
QgsProject::instance()->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", projectionSelector->selectedProj4String() );
257257

258258
// Set the map units to the projected coordinates if we are projecting
259259
if ( isProjected() )

src/app/qgsrasterlayerproperties.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1661,10 +1661,10 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
16611661
{
16621662

16631663
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
1664-
mySelector->setSelectedCRSID( mRasterLayer->srs().srsid() );
1664+
mySelector->setSelectedCrsId( mRasterLayer->srs().srsid() );
16651665
if ( mySelector->exec() )
16661666
{
1667-
QgsCoordinateReferenceSystem srs( mySelector->getSelectedCRSID(), QgsCoordinateReferenceSystem::QGIS_CRSID );
1667+
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID );
16681668
mRasterLayer->setSrs( srs );
16691669
}
16701670
else

src/app/qgsserversourceselect.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -392,20 +392,20 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
392392
QgsCoordinateReferenceSystem defaultCRS;
393393
if ( defaultCRS.createFromProj4( myDefaultProjString ) )
394394
{
395-
mySelector->setSelectedCRSID( defaultCRS.srsid() );
395+
mySelector->setSelectedCrsId( defaultCRS.srsid() );
396396
}
397397

398398
if ( mySelector->exec() )
399399
{
400-
m_Epsg = mySelector->getSelectedEpsg();
400+
m_Epsg = mySelector->selectedEpsg();
401401
}
402402
else
403403
{
404404
// NOOP
405405
}
406406

407407
labelCoordRefSys->setText( descriptionForEpsg( m_Epsg ) );
408-
// labelCoordRefSys->setText( mySelector->getSelectedProj4String() );
408+
// labelCoordRefSys->setText( mySelector->selectedProj4String() );
409409

410410
delete mySelector;
411411

src/app/qgsvectorlayerproperties.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,10 @@ void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked()
861861
{
862862
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
863863
mySelector->setMessage();
864-
mySelector->setSelectedCRSID( layer->srs().srsid() );
864+
mySelector->setSelectedCrsId( layer->srs().srsid() );
865865
if ( mySelector->exec() )
866866
{
867-
QgsCoordinateReferenceSystem srs( mySelector->getSelectedCRSID(), QgsCoordinateReferenceSystem::QGIS_CRSID );
867+
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID );
868868
layer->setSrs( srs );
869869
}
870870
else

0 commit comments

Comments
 (0)