Skip to content

Commit

Permalink
Use a checkbox instead of tree item for "no projection" option
Browse files Browse the repository at this point in the history
Makes this option more visible and easier to associate with the
old "OTF off" option
  • Loading branch information
nyalldawson committed Mar 7, 2017
1 parent 7dbe494 commit cc0007c
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 188 deletions.
15 changes: 8 additions & 7 deletions src/gui/qgsprojectionselectiontreewidget.cpp
Expand Up @@ -65,8 +65,8 @@ QgsProjectionSelectionTreeWidget::QgsProjectionSelectionTreeWidget( QWidget *par

mRecentProjections = QgsCoordinateReferenceSystem::recentProjections();

mNoProjItem = new QTreeWidgetItem( lstCoordinateSystems, QStringList( tr( "No projection" ) ) );
mNoProjItem->setHidden( true );
mCheckBoxNoProjection->setHidden( true );
connect( mCheckBoxNoProjection, &QCheckBox::toggled, mFrameProjections, &QFrame::setDisabled );
}

QgsProjectionSelectionTreeWidget::~QgsProjectionSelectionTreeWidget()
Expand Down Expand Up @@ -273,10 +273,11 @@ void QgsProjectionSelectionTreeWidget::setCrs( const QgsCoordinateReferenceSyste
{
if ( !crs.isValid() )
{
lstCoordinateSystems->setCurrentItem( mNoProjItem );
mCheckBoxNoProjection->setChecked( true );
}
else
{
mCheckBoxNoProjection->setChecked( false );
applySelection( AuthidColumn, crs.authid() );
}
}
Expand Down Expand Up @@ -424,7 +425,7 @@ QString QgsProjectionSelectionTreeWidget::getSelectedExpression( const QString &

QgsCoordinateReferenceSystem QgsProjectionSelectionTreeWidget::crs() const
{
if ( lstCoordinateSystems->currentItem() == mNoProjItem )
if ( mCheckBoxNoProjection->isChecked() )
return QgsCoordinateReferenceSystem();

int srid = getSelectedExpression( QStringLiteral( "srs_id" ) ).toLong();
Expand All @@ -436,18 +437,18 @@ QgsCoordinateReferenceSystem QgsProjectionSelectionTreeWidget::crs() const

void QgsProjectionSelectionTreeWidget::setShowNoProjection( bool show )
{
mNoProjItem->setHidden( !show );
mCheckBoxNoProjection->setHidden( !show );
}

bool QgsProjectionSelectionTreeWidget::showNoProjection() const
{
return !mNoProjItem->isHidden();
return !mCheckBoxNoProjection->isHidden();
}

bool QgsProjectionSelectionTreeWidget::hasValidSelection() const
{
QTreeWidgetItem *item = lstCoordinateSystems->currentItem();
if ( item == mNoProjItem )
if ( mCheckBoxNoProjection->isChecked() )
return true;
else
return item && !item->text( QgisCrsIdColumn ).isEmpty();
Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgsprojectionselectiontreewidget.h
Expand Up @@ -213,8 +213,6 @@ class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::
QTreeWidgetItem *mGeoList = nullptr;
//! PROJCS node
QTreeWidgetItem *mProjList = nullptr;
//! "No projection" item
QTreeWidgetItem *mNoProjItem = nullptr;

//! Users custom coordinate system file
QString mCustomCsFile;
Expand Down

0 comments on commit cc0007c

Please sign in to comment.