Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implemented more gui api cleanups and suggestions from Albert Areny t…
…o 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
  • Loading branch information
timlinux committed Aug 31, 2008
1 parent 66ed0b9 commit 7117ef8
Show file tree
Hide file tree
Showing 49 changed files with 224 additions and 224 deletions.
6 changes: 3 additions & 3 deletions python/gui/qgisinterface.sip
Expand Up @@ -72,13 +72,13 @@ class QgisInterface : QObject
virtual void openURL(QString url, bool useQgisDocDirectory=true)=0;

/** Return a pointer to the map canvas */
virtual QgsMapCanvas * getMapCanvas()=0;
virtual QgsMapCanvas * mapCanvas()=0;

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

/** Add action to the plugins menu */
virtual void addPluginMenu(QString name, QAction* action)=0;
virtual void addPluginToMenu(QString name, QAction* action)=0;
/** Remove action from the plugins menu */
virtual void removePluginMenu(QString name, QAction* action)=0;

Expand Down
10 changes: 5 additions & 5 deletions python/gui/qgsgenericprojectionselector.sip
Expand Up @@ -25,12 +25,12 @@ class QgsGenericProjectionSelector : QDialog //, private Ui::QgsGenericProjectio
*/
void setMessage(QString theMessage="");

QString getSelectedProj4String();
long getSelectedCRSID();
long getSelectedEpsg();
QString selectedProj4String();
long selectedCrsId();
long selectedEpsg();

void setSelectedCRSName(QString theName);
void setSelectedCRSID(long theID);
void setSelectedCrsName(QString theName);
void setSelectedCrsId(long theID);
void setSelectedEpsg(long theID);

/**
Expand Down
20 changes: 10 additions & 10 deletions python/gui/qgsprojectionselector.sip
Expand Up @@ -28,7 +28,7 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase
*
* \todo Should this be public?
*/
void applyUserProjList(QSet<QString> * crsFilter = 0);
void loadUserCrsList(QSet<QString> * crsFilter = 0);

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


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

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

public slots:
void setSelectedCRSName(QString theCRSName);
void setSelectedCrsName(QString theCRSName);

QString getSelectedName();
QString selectedName();

void setSelectedCRSID(long theCRSID);
void setSelectedCrsId(long theCRSID);

void setSelectedEpsg(long epsg);

QString getSelectedProj4String();
QString selectedProj4String();

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

//! Gets the current QGIS projection identfier
long getSelectedCRSID();
long selectedCrsId();

/**
* \brief filters this widget by the given CRSs
Expand Down
6 changes: 3 additions & 3 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -204,7 +204,7 @@ QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
mView = new QgsComposerView( mViewFrame );
connectSlots();

mComposition = new QgsComposition( mQgis->getMapCanvas()->mapRenderer() );
mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
mView->setComposition( mComposition );

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

QgsMapCanvas *QgsComposer::mapCanvas( void )
{
return mQgis->getMapCanvas();
return mQgis->mapCanvas();
}

QgsComposerView *QgsComposer::view( void )
Expand Down Expand Up @@ -1395,7 +1395,7 @@ void QgsComposer::readXML( const QDomDocument& doc )
mView = new QgsComposerView( mViewFrame );
connectSlots();

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

QGridLayout *l = new QGridLayout( mViewFrame );
Expand Down
18 changes: 9 additions & 9 deletions src/app/qgisapp.cpp
Expand Up @@ -275,13 +275,13 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem* srs )
QgsCoordinateReferenceSystem defaultCRS;
if ( defaultCRS.createFromProj4( proj4String ) )
{
mySelector->setSelectedCRSID( defaultCRS.srsid() );
mySelector->setSelectedCrsId( defaultCRS.srsid() );
}

if ( mySelector->exec() )
{
QgsDebugMsg( "Layer srs set from dialog: " + QString::number( mySelector->getSelectedCRSID() ) );
srs->createFromProj4( mySelector->getSelectedProj4String() );
QgsDebugMsg( "Layer srs set from dialog: " + QString::number( mySelector->selectedCrsId() ) );
srs->createFromProj4( mySelector->selectedProj4String() );
srs->debugPrint();
}
else
Expand Down Expand Up @@ -3506,11 +3506,11 @@ void QgisApp::toggleFullScreen()
// showMaxmized() is a work-around. Turn off rendering for this as it
// would otherwise cause two re-renders of the map, which can take a
// long time.
bool renderFlag = getMapCanvas()->renderFlag();
getMapCanvas()->setRenderFlag( false );
bool renderFlag = mapCanvas()->renderFlag();
mapCanvas()->setRenderFlag( false );
showNormal();
showMaximized();
getMapCanvas()->setRenderFlag( renderFlag );
mapCanvas()->setRenderFlag( renderFlag );
mPrevScreenModeMaximized = false;
}
else
Expand Down Expand Up @@ -4761,7 +4761,7 @@ QMenu* QgisApp::getPluginMenu( QString menuName )
return menu;
}

void QgisApp::addPluginMenu( QString name, QAction* action )
void QgisApp::addPluginToMenu( QString name, QAction* action )
{
QMenu* menu = getPluginMenu( name );
menu->addAction( action );
Expand Down Expand Up @@ -4891,8 +4891,8 @@ void QgisApp::updateMouseCoordinatePrecision()
// coordinates with the aim of always having enough decimal places
// to show the difference in position between adjacent pixels.
// Also avoid taking the log of 0.
if ( getMapCanvas()->mapUnitsPerPixel() != 0.0 )
dp = static_cast<int>( ceil( -1.0 * log10( getMapCanvas()->mapUnitsPerPixel() ) ) );
if ( mapCanvas()->mapUnitsPerPixel() != 0.0 )
dp = static_cast<int>( ceil( -1.0 * log10( mapCanvas()->mapUnitsPerPixel() ) ) );
}
else
dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.h
Expand Up @@ -135,7 +135,7 @@ class QgisApp : public QMainWindow
//!Overloaded version of the private function with same name that takes the imagename as a parameter
void saveMapAsImage( QString, QPixmap * );
/** Get the mapcanvas object from the app */
QgsMapCanvas * getMapCanvas() { return mMapCanvas; };
QgsMapCanvas * mapCanvas() { return mMapCanvas; };
//! Set theme (icons)
void setTheme( QString themeName = "default" );
//! Setup the toolbar popup menus for a given theme
Expand Down Expand Up @@ -384,7 +384,7 @@ class QgisApp : public QMainWindow
//! Find the QMenu with the given name (ie the user visible text on the menu item)
QMenu* getPluginMenu( QString menuName );
//! Add the action to the submenu with the given name under the plugin menu
void addPluginMenu( QString name, QAction* action );
void addPluginToMenu( QString name, QAction* action );
//! Remove the action to the submenu with the given name under the plugin menu
void removePluginMenu( QString name, QAction* action );
//! Add an icon to the plugin toolbar
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgisappinterface.cpp
Expand Up @@ -99,9 +99,9 @@ QgsMapLayer *QgisAppInterface::activeLayer()
return qgis->activeLayer();
}

void QgisAppInterface::addPluginMenu( QString name, QAction* action )
void QgisAppInterface::addPluginToMenu( QString name, QAction* action )
{
qgis->addPluginMenu( name, action );
qgis->addPluginToMenu( name, action );
}

void QgisAppInterface::removePluginMenu( QString name, QAction* action )
Expand Down Expand Up @@ -131,12 +131,12 @@ void QgisAppInterface::openURL( QString url, bool useQgisDocDirectory )
qgis->openURL( url, useQgisDocDirectory );
}

QgsMapCanvas * QgisAppInterface::getMapCanvas()
QgsMapCanvas * QgisAppInterface::mapCanvas()
{
return qgis->getMapCanvas();
return qgis->mapCanvas();
}

QWidget * QgisAppInterface::getMainWindow()
QWidget * QgisAppInterface::mainWindow()
{
return qgis;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgisappinterface.h
Expand Up @@ -87,17 +87,17 @@ class QgisAppInterface : public QgisInterface
void openURL( QString url, bool useQgisDocDirectory = true );

/** Return a pointer to the map canvas used by qgisapp */
QgsMapCanvas * getMapCanvas();
QgsMapCanvas * mapCanvas();

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

/** Add action to the plugins menu */
void addPluginMenu( QString name, QAction* action );
void addPluginToMenu( QString name, QAction* action );
/** Remove action from the plugins menu */
void removePluginMenu( QString name, QAction* action );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsbookmarks.cpp
Expand Up @@ -231,7 +231,7 @@ void QgsBookmarks::zoomToBookmark()
xmax.toDouble(),
ymax.toDouble() ) );
// redraw the map
QgisApp::instance()->getMapCanvas()->refresh();
QgisApp::instance()->mapCanvas()->refresh();
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/app/qgscustomprojectiondialog.cpp
Expand Up @@ -800,24 +800,24 @@ void QgsCustomProjectionDialog::on_pbnSave_clicked()
{
mySql = QString( "insert into tbl_srs (srs_id,description,projection_acronym,ellipsoid_acronym,parameters,is_geo) " )
+ " values (" + QString::number( USER_PROJECTION_START_ID ) + ",'"
+ stringSQLSafe( myName ) + "','" + myProjectionAcronym
+ "','" + myEllipsoidAcronym + "','" + stringSQLSafe( myParameters )
+ sqlSafeString( myName ) + "','" + myProjectionAcronym
+ "','" + myEllipsoidAcronym + "','" + sqlSafeString( myParameters )
+ "',0)"; // <-- is_geo shamelessly hard coded for now
}
else
{
mySql = "insert into tbl_srs (description,projection_acronym,ellipsoid_acronym,parameters,is_geo) values ('"
+ stringSQLSafe( myName ) + "','" + myProjectionAcronym
+ "','" + myEllipsoidAcronym + "','" + stringSQLSafe( myParameters )
+ sqlSafeString( myName ) + "','" + myProjectionAcronym
+ "','" + myEllipsoidAcronym + "','" + sqlSafeString( myParameters )
+ "',0)"; // <-- is_geo shamelessly hard coded for now
}
}
else //user is updating an existing record
{
mySql = "update tbl_srs set description='" + stringSQLSafe( myName )
mySql = "update tbl_srs set description='" + sqlSafeString( myName )
+ "',projection_acronym='" + myProjectionAcronym
+ "',ellipsoid_acronym='" + myEllipsoidAcronym
+ "',parameters='" + stringSQLSafe( myParameters ) + "' "
+ "',parameters='" + sqlSafeString( myParameters ) + "' "
+ ",is_geo=0" // <--shamelessly hard coded for now
+ " where srs_id='" + mCurrentRecordId + "'"
;
Expand Down Expand Up @@ -1021,7 +1021,7 @@ QString QgsCustomProjectionDialog::getEllipseFromParameters()
* \arg const QString in The input string to make safe.
* \return The string made safe for SQL statements.
*/
const QString QgsCustomProjectionDialog::stringSQLSafe( const QString theSQL )
const QString QgsCustomProjectionDialog::sqlSafeString( const QString theSQL )
{

QString myRetval;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgscustomprojectiondialog.h
Expand Up @@ -70,7 +70,7 @@ class QgsCustomProjectionDialog : public QDialog, private Ui::QgsCustomProjectio
//so that we can return to it if the record insert is aborted
long mLastRecordLong;
long mRecordCountLong;
const QString stringSQLSafe( const QString theSQL );
const QString sqlSafeString( const QString theSQL );

};

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsoptions.cpp
Expand Up @@ -370,14 +370,14 @@ void QgsOptions::on_pbnSelectProjection_clicked()
QgsCoordinateReferenceSystem refSys;
if ( refSys.createFromProj4( txtGlobalWKT->toPlainText() ) )
{
mySelector->setSelectedCRSID( refSys.srsid() );
mySelector->setSelectedCrsId( refSys.srsid() );
}

if ( mySelector->exec() )
{
QgsDebugMsg( "------ Global Default Projection Selection Set ----------" );
//! @todo changes this control name in gui to txtGlobalProjString
txtGlobalWKT->setText( mySelector->getSelectedProj4String() );
txtGlobalWKT->setText( mySelector->selectedProj4String() );
QgsDebugMsg( QString( "------ Global Default Projection now set to ----------\n%1" ).arg( mGlobalCRSID ) );
}
else
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -61,7 +61,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa

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

///////////////////////////////////////////////////////////
// Properties stored in QgsProject
Expand Down Expand Up @@ -245,15 +245,15 @@ void QgsProjectProperties::apply()
// selected that has an srid. This prevents error if the user
// selects a top-level node rather than an actual coordinate
// system
long myCRSID = projectionSelector->getSelectedCRSID();
long myCRSID = projectionSelector->selectedCrsId();
if ( myCRSID )
{
QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::QGIS_CRSID );
myRender->setDestinationSrs( srs );

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

// Set the map units to the projected coordinates if we are projecting
if ( isProjected() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -1661,10 +1661,10 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
{

QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
mySelector->setSelectedCRSID( mRasterLayer->srs().srsid() );
mySelector->setSelectedCrsId( mRasterLayer->srs().srsid() );
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->getSelectedCRSID(), QgsCoordinateReferenceSystem::QGIS_CRSID );
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID );
mRasterLayer->setSrs( srs );
}
else
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsserversourceselect.cpp
Expand Up @@ -392,20 +392,20 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
QgsCoordinateReferenceSystem defaultCRS;
if ( defaultCRS.createFromProj4( myDefaultProjString ) )
{
mySelector->setSelectedCRSID( defaultCRS.srsid() );
mySelector->setSelectedCrsId( defaultCRS.srsid() );
}

if ( mySelector->exec() )
{
m_Epsg = mySelector->getSelectedEpsg();
m_Epsg = mySelector->selectedEpsg();
}
else
{
// NOOP
}

labelCoordRefSys->setText( descriptionForEpsg( m_Epsg ) );
// labelCoordRefSys->setText( mySelector->getSelectedProj4String() );
// labelCoordRefSys->setText( mySelector->selectedProj4String() );

delete mySelector;

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -861,10 +861,10 @@ void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked()
{
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
mySelector->setMessage();
mySelector->setSelectedCRSID( layer->srs().srsid() );
mySelector->setSelectedCrsId( layer->srs().srsid() );
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->getSelectedCRSID(), QgsCoordinateReferenceSystem::QGIS_CRSID );
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::QGIS_CRSID );
layer->setSrs( srs );
}
else
Expand Down

0 comments on commit 7117ef8

Please sign in to comment.