Skip to content
Permalink
Browse files
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/qgis@9231 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Aug 31, 2008
1 parent df6ba8c commit 864a224c98785be0d775145fbc4334e3e2356fec
Showing with 224 additions and 224 deletions.
  1. +3 −3 python/gui/qgisinterface.sip
  2. +5 −5 python/gui/qgsgenericprojectionselector.sip
  3. +10 −10 python/gui/qgsprojectionselector.sip
  4. +3 −3 src/app/composer/qgscomposer.cpp
  5. +9 −9 src/app/qgisapp.cpp
  6. +2 −2 src/app/qgisapp.h
  7. +5 −5 src/app/qgisappinterface.cpp
  8. +3 −3 src/app/qgisappinterface.h
  9. +1 −1 src/app/qgsbookmarks.cpp
  10. +7 −7 src/app/qgscustomprojectiondialog.cpp
  11. +1 −1 src/app/qgscustomprojectiondialog.h
  12. +2 −2 src/app/qgsoptions.cpp
  13. +4 −4 src/app/qgsprojectproperties.cpp
  14. +2 −2 src/app/qgsrasterlayerproperties.cpp
  15. +3 −3 src/app/qgsserversourceselect.cpp
  16. +2 −2 src/app/qgsvectorlayerproperties.cpp
  17. +3 −3 src/gui/qgisinterface.h
  18. +4 −4 src/gui/qgsfiledropedit.cpp
  19. +4 −4 src/gui/qgsfiledropedit.h
  20. +10 −10 src/gui/qgsgenericprojectionselector.cpp
  21. +7 −7 src/gui/qgsgenericprojectionselector.h
  22. +19 −19 src/gui/qgsprojectionselector.cpp
  23. +10 −10 src/gui/qgsprojectionselector.h
  24. +8 −8 src/plugins/coordinate_capture/coordinatecapture.cpp
  25. +6 −6 src/plugins/copyright_label/plugin.cpp
  26. +2 −2 src/plugins/delimited_text/qgsdelimitedtextplugin.cpp
  27. +2 −2 src/plugins/dxf2shp_converter/dxf2shpconverter.cpp
  28. +2 −2 src/plugins/geoprocessing/qgspggeoprocessing.cpp
  29. +1 −1 src/plugins/georeferencer/plugin.cpp
  30. +1 −1 src/plugins/georeferencer/qgspointdialog.cpp
  31. +4 −4 src/plugins/gps_importer/qgsgpsplugin.cpp
  32. +1 −1 src/plugins/grass/qgsgrassedit.cpp
  33. +3 −3 src/plugins/grass/qgsgrassedittools.cpp
  34. +1 −1 src/plugins/grass/qgsgrassmapcalc.cpp
  35. +8 −8 src/plugins/grass/qgsgrassmodule.cpp
  36. +13 −13 src/plugins/grass/qgsgrassnewmapset.cpp
  37. +18 −18 src/plugins/grass/qgsgrassplugin.cpp
  38. +1 −1 src/plugins/grass/qgsgrassregion.cpp
  39. +1 −1 src/plugins/grass/qgsgrasstools.cpp
  40. +2 −2 src/plugins/grid_maker/plugin.cpp
  41. +1 −1 src/plugins/interpolation/qgsinterpolationplugin.cpp
  42. +7 −7 src/plugins/north_arrow/plugin.cpp
  43. +2 −2 src/plugins/ogr_converter/plugin.cpp
  44. +2 −2 src/plugins/plugin_template/plugin.cpp
  45. +3 −3 src/plugins/quick_print/quickprintplugin.cpp
  46. +10 −10 src/plugins/scale_bar/plugin.cpp
  47. +2 −2 src/plugins/spit/qgsspitplugin.cpp
  48. +1 −1 src/plugins/wfs/qgswfsplugin.cpp
  49. +3 −3 src/plugins/wfs/qgswfssourceselect.cpp
@@ -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;

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

/**
@@ -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...
@@ -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);


/*!
@@ -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
@@ -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 );
@@ -382,7 +382,7 @@ void QgsComposer::showItemOptions( const QgsComposerItem* item )

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

QgsComposerView *QgsComposer::view( void )
@@ -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 );
@@ -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
@@ -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
@@ -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 );
@@ -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" );
@@ -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
@@ -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
@@ -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 )
@@ -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;
}
@@ -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 );

@@ -231,7 +231,7 @@ void QgsBookmarks::zoomToBookmark()
xmax.toDouble(),
ymax.toDouble() ) );
// redraw the map
QgisApp::instance()->getMapCanvas()->refresh();
QgisApp::instance()->mapCanvas()->refresh();
}
}

@@ -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 + "'"
;
@@ -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;
@@ -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 );

};

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

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

0 comments on commit 864a224

Please sign in to comment.