|
@@ -28,6 +28,7 @@ |
|
|
#include <QHeaderView> |
|
|
#include <QResizeEvent> |
|
|
#include <QMessageBox> |
|
|
#include <QSettings> |
|
|
#include "qgslogger.h" |
|
|
|
|
|
const int NAME_COLUMN = 0; |
|
@@ -54,11 +55,35 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, |
|
|
lstCoordinateSystems->header()->setResizeMode( EPSG_COLUMN, QHeaderView::Stretch ); |
|
|
lstCoordinateSystems->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 ); |
|
|
lstCoordinateSystems->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed ); |
|
|
|
|
|
// Read settings from persistent storage |
|
|
QSettings settings; |
|
|
mRecentProjections = settings.value("/UI/recentProjections").toStringList(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
QgsProjectionSelector::~QgsProjectionSelector() |
|
|
{} |
|
|
{ |
|
|
// Save persistent list of projects |
|
|
QSettings settings; |
|
|
long crsId; |
|
|
|
|
|
// Push current projection to front, only if set |
|
|
crsId = selectedCrsId(); |
|
|
if ( crsId ) |
|
|
{ |
|
|
mRecentProjections.removeAll( QString::number( crsId ) ); |
|
|
mRecentProjections.prepend( QString::number( crsId ) ); |
|
|
// Prunse size of list |
|
|
while ( mRecentProjections.size() > 4 ) |
|
|
{ |
|
|
mRecentProjections.removeLast(); |
|
|
} |
|
|
// Save to file |
|
|
settings.setValue( "/UI/recentProjections", mRecentProjections); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void QgsProjectionSelector::resizeEvent( QResizeEvent * theEvent ) |
|
@@ -99,6 +124,40 @@ void QgsProjectionSelector::showEvent( QShowEvent * theEvent ) |
|
|
applyEPSGIDSelection(); |
|
|
} |
|
|
|
|
|
// Update buttons |
|
|
pbnPopular1->setDisabled(true); |
|
|
pbnPopular2->setDisabled(true); |
|
|
pbnPopular3->setDisabled(true); |
|
|
pbnPopular4->setDisabled(true); |
|
|
pbnPopular1->hide(); |
|
|
pbnPopular2->hide(); |
|
|
pbnPopular3->hide(); |
|
|
pbnPopular4->hide(); |
|
|
|
|
|
if ( mRecentProjections.size() > 0) { |
|
|
pbnPopular1->setText( getCrsIdName( mRecentProjections.at(0).toLong() ) ); |
|
|
pbnPopular1->setDisabled(false); |
|
|
pbnPopular1->show(); |
|
|
} |
|
|
|
|
|
if ( mRecentProjections.size() > 1) { |
|
|
pbnPopular2->setText( getCrsIdName( mRecentProjections.at(1).toLong() ) ); |
|
|
pbnPopular2->setDisabled(false); |
|
|
pbnPopular2->show(); |
|
|
} |
|
|
|
|
|
if ( mRecentProjections.size() > 2) { |
|
|
pbnPopular3->setText( getCrsIdName( mRecentProjections.at(2).toLong() ) ); |
|
|
pbnPopular3->setDisabled(false); |
|
|
pbnPopular3->show(); |
|
|
} |
|
|
|
|
|
if ( mRecentProjections.size() > 3) { |
|
|
pbnPopular4->setText( getCrsIdName( mRecentProjections.at(3).toLong() ) ); |
|
|
pbnPopular4->setDisabled(false); |
|
|
pbnPopular4->show(); |
|
|
} |
|
|
|
|
|
// Pass up the inheritance heirarchy |
|
|
QWidget::showEvent( theEvent ); |
|
|
} |
|
@@ -235,6 +294,26 @@ void QgsProjectionSelector::applyCRSNameSelection() |
|
|
} |
|
|
} |
|
|
|
|
|
QString QgsProjectionSelector::getCrsIdName( long theCrsId ) |
|
|
{ |
|
|
if ( |
|
|
( mProjListDone ) && |
|
|
( mUserProjListDone ) |
|
|
) |
|
|
{ |
|
|
QString myCRSIDString = QString::number( theCrsId ); |
|
|
|
|
|
QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( myCRSIDString, Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN ); |
|
|
|
|
|
if ( nodes.count() > 0 ) |
|
|
{ |
|
|
return nodes.first()->text(0); |
|
|
} |
|
|
} |
|
|
return QString( "" ); |
|
|
|
|
|
} |
|
|
|
|
|
void QgsProjectionSelector::applyEPSGIDSelection() |
|
|
{ |
|
|
if ( |
|
@@ -761,6 +840,24 @@ void QgsProjectionSelector::coordinateSystemSelected( QTreeWidgetItem * theItem |
|
|
} |
|
|
} |
|
|
|
|
|
void QgsProjectionSelector::on_pbnPopular1_clicked() |
|
|
{ |
|
|
setSelectedCrsId( mRecentProjections.at(0).toLong() ); |
|
|
} |
|
|
|
|
|
void QgsProjectionSelector::on_pbnPopular2_clicked() |
|
|
{ |
|
|
setSelectedCrsId( mRecentProjections.at(1).toLong() ); |
|
|
} |
|
|
void QgsProjectionSelector::on_pbnPopular3_clicked() |
|
|
{ |
|
|
setSelectedCrsId( mRecentProjections.at(2).toLong() ); |
|
|
} |
|
|
void QgsProjectionSelector::on_pbnPopular4_clicked() |
|
|
{ |
|
|
setSelectedCrsId( mRecentProjections.at(3).toLong() ); |
|
|
} |
|
|
|
|
|
void QgsProjectionSelector::on_pbnFind_clicked() |
|
|
{ |
|
|
|
|
|