Use a checkbox instead of tree item for "no projection" option

Makes this option more visible and easier to associate with the
old "OTF off" option
This commit is contained in:
Nyall Dawson 2017-03-07 10:33:25 +10:00
parent 7dbe4943d6
commit cc0007c380
3 changed files with 229 additions and 188 deletions

View File

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

View File

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

View File

@ -21,147 +21,102 @@
</property>
<property name="windowIcon">
<iconset>
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Selected CRS</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="teSelected">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QFrame" name="mFrameProjections">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="childrenCollapsible">
<bool>true</bool>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<widget class="QTreeWidget" name="lstRecent">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>105</height>
</size>
<property name="topMargin">
<number>0</number>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
<property name="rightMargin">
<number>0</number>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="columnCount">
<number>3</number>
</property>
<column>
<property name="text">
<string>Coordinate Reference System</string>
</property>
</column>
<column>
<property name="text">
<string>Authority ID</string>
</property>
</column>
<column>
<property name="text">
<string>ID</string>
</property>
</column>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFilterLineEdit" name="leSearch"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Recently used coordinate reference systems</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="childrenCollapsible">
<bool>true</bool>
</property>
<widget class="QTreeWidget" name="lstRecent">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>105</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Coordinate reference systems of the world</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="cbxHideDeprecated">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Hide deprecated CRSs</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTreeWidget" name="lstCoordinateSystems">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
@ -184,63 +139,150 @@
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Coordinate reference systems of the world</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="cbxHideDeprecated">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Hide deprecated CRSs</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTreeWidget" name="lstCoordinateSystems">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="columnCount">
<number>3</number>
</property>
<column>
<property name="text">
<string>Coordinate Reference System</string>
</property>
</column>
<column>
<property name="text">
<string>Authority ID</string>
</property>
</column>
<column>
<property name="text">
<string>ID</string>
</property>
</column>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Selected CRS</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="teSelected">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextEdit" name="teProjection">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>90</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoBulletList</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFilterLineEdit" name="leSearch"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
<widget class="QCheckBox" name="mCheckBoxNoProjection">
<property name="toolTip">
<string>Use this option to treat all coordinates as cartesian coordinates in an unknown reference system.</string>
</property>
<property name="text">
<string>Recently used coordinate reference systems</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QTextEdit" name="teProjection">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>90</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoBulletList</set>
</property>
<property name="readOnly">
<bool>true</bool>
<string>No projection (or unknown/non-Earth projection)</string>
</property>
</widget>
</item>