Skip to content

Commit

Permalink
add missing ui headers for gui includes for install and implement Qgs…
Browse files Browse the repository at this point in the history
…ProjectionSelector::setSelectedEpsg()

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10093 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 2, 2009
1 parent d5ff56c commit 9b08521
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -118,6 +118,11 @@ qgsprojectionselector.h
qgsrubberband.h
qgsvertexmarker.h
qgsmaptip.h

${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsdetaileditemwidgetbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsgenericprojectionselectorbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsmessageviewer.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsprojectionselectorbase.h
)


Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsgenericprojectionselector.cpp
Expand Up @@ -16,7 +16,7 @@
* *
***************************************************************************/
/* $Id$ */
#include "qgsgenericprojectionselector.h"
#include <qgsgenericprojectionselector.h>
#include <QApplication>

/**
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsgenericprojectionselector.h
Expand Up @@ -18,8 +18,8 @@
/* $Id$ */
#ifndef QGSGENERICPROJECTIONSELECTOR_H
#define QGSGENERICPROJECTIONSELECTOR_H
#include "ui_qgsgenericprojectionselectorbase.h"
#include "qgisgui.h"
#include <ui_qgsgenericprojectionselectorbase.h>
#include <qgisgui.h>

#include <QSet>

Expand Down
44 changes: 40 additions & 4 deletions src/gui/qgsprojectionselector.cpp
Expand Up @@ -9,7 +9,7 @@
* (at your option) any later version. *
***************************************************************************/
/* $Id$ */
#include "qgsprojectionselector.h"
#include <qgsprojectionselector.h>

//standard includes
#include <cassert>
Expand Down Expand Up @@ -41,8 +41,8 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent,
mProjListDone( FALSE ),
mUserProjListDone( FALSE ),
mCRSNameSelectionPending( FALSE ),
mCRSIDSelectionPending( FALSE )

mCRSIDSelectionPending( FALSE ),
mEPSGIDSelectionPending( FALSE )
{
setupUi( this );
connect( lstCoordinateSystems, SIGNAL( currentItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ),
Expand Down Expand Up @@ -94,6 +94,10 @@ void QgsProjectionSelector::showEvent( QShowEvent * theEvent )
{
applyCRSIDSelection();
}
if ( mEPSGIDSelectionPending )
{
applyEPSGIDSelection();
}

// Pass up the inheritance heirarchy
QWidget::showEvent( theEvent );
Expand Down Expand Up @@ -168,6 +172,7 @@ void QgsProjectionSelector::setSelectedCrsName( QString theCRSName )
mCRSNameSelection = theCRSName;
mCRSNameSelectionPending = TRUE;
mCRSIDSelectionPending = FALSE; // only one type can be pending at a time
mEPSGIDSelectionPending = TRUE;

if ( isVisible() )
{
Expand All @@ -184,6 +189,7 @@ void QgsProjectionSelector::setSelectedCrsId( long theCRSID )
mCRSIDSelection = theCRSID;
mCRSIDSelectionPending = TRUE;
mCRSNameSelectionPending = FALSE; // only one type can be pending at a time
mEPSGIDSelectionPending = FALSE;

if ( isVisible() )
{
Expand All @@ -196,7 +202,10 @@ void QgsProjectionSelector::setSelectedCrsId( long theCRSID )

void QgsProjectionSelector::setSelectedEpsg( long epsg )
{
//QgsSpatial
mEPSGIDSelection = epsg;
mCRSIDSelectionPending = FALSE;
mEPSGIDSelectionPending = TRUE;
mCRSNameSelectionPending = FALSE; // only one type can be pending at a time
}

void QgsProjectionSelector::applyCRSNameSelection()
Expand Down Expand Up @@ -226,6 +235,33 @@ void QgsProjectionSelector::applyCRSNameSelection()
}
}

void QgsProjectionSelector::applyEPSGIDSelection()
{
if (
( mEPSGIDSelectionPending ) &&
( mProjListDone ) &&
( mUserProjListDone )
)
{
//get the srid given the wkt so we can pick the correct list item
QgsDebugMsg( "called with " + QString::number( mEPSGIDSelection ) );
QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( QString::number( mEPSGIDSelection ), Qt::MatchExactly | Qt::MatchRecursive, EPSG_COLUMN );

if ( nodes.count() > 0 )
{
lstCoordinateSystems->setCurrentItem( nodes.first() );
lstCoordinateSystems->scrollToItem( nodes.first() );
}
else // unselect the selected item to avoid confusing the user
{
lstCoordinateSystems->clearSelection();
teProjection->setText( "" );
}

mEPSGIDSelectionPending = FALSE;
}
}

void QgsProjectionSelector::applyCRSIDSelection()
{
if (
Expand Down
24 changes: 21 additions & 3 deletions src/gui/qgsprojectionselector.h
Expand Up @@ -11,7 +11,7 @@
#ifndef QGSCRSSELECTOR_H
#define QGSCRSSELECTOR_H

#include "ui_qgsprojectionselectorbase.h"
#include <ui_qgsprojectionselectorbase.h>

#include <QSet>

Expand Down Expand Up @@ -151,10 +151,22 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio
void applyCRSIDSelection();

/**
* \brief gets an arbitrary sqlite3 attribute of type "long" from the selection
* \brief does the legwork of applying the EPSG ID Selection
*
* \param attributeName The sqlite3 column name, typically "srid" or "epsg"
* \warning This function does nothing unless getUserList() and getUserProjList()
* Have already been called
*
* \warning This function only expands the parents of the selection and
* does not scroll the list to the selection if the widget is not visible.
* Therefore you will typically want to use this in a showEvent().
*/
void applyEPSGIDSelection();

/**
* \brief gets an arbitrary sqlite3 attribute of type "long" from the selection
*
* \param attributeName The sqlite3 column name, typically "srid" or "epsg"
*/
long getSelectedLongAttribute( QString attributeName );

/** Show the user a warning if the srs database could not be found */
Expand Down Expand Up @@ -189,12 +201,18 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio
//! Is there a pending selection to be made by CRS ID?
bool mCRSIDSelectionPending;

//! Is there a pending selection to be made by EPSG ID?
bool mEPSGIDSelectionPending;

//! The CRS Name that wants to be selected on this widget
QString mCRSNameSelection;

//! The CRS ID that wants to be selected on this widget
long mCRSIDSelection;

//! The EPSG ID that wants to be selected on this widget
long mEPSGIDSelection;

//! The set of OGC WMS CRSs that want to be applied to this widget
QSet<QString> mCrsFilter;

Expand Down

0 comments on commit 9b08521

Please sign in to comment.