[QGIS Commit] r13253 - in trunk/qgis/src: gui ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Apr 5 13:20:30 EDT 2010
Author: jef
Date: 2010-04-05 13:20:30 -0400 (Mon, 05 Apr 2010)
New Revision: 13253
Modified:
trunk/qgis/src/gui/qgsprojectionselector.cpp
trunk/qgis/src/gui/qgsprojectionselector.h
trunk/qgis/src/ui/qgsprojectionselectorbase.ui
Log:
use list instead of buttons for popular/recent projections
Modified: trunk/qgis/src/gui/qgsprojectionselector.cpp
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.cpp 2010-04-05 17:19:07 UTC (rev 13252)
+++ trunk/qgis/src/gui/qgsprojectionselector.cpp 2010-04-05 17:20:30 UTC (rev 13253)
@@ -34,7 +34,6 @@
const int NAME_COLUMN = 0;
const int AUTHID_COLUMN = 1;
const int QGIS_CRS_ID_COLUMN = 2;
-const int POPULAR_CRSES = 3;
QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char * name, Qt::WFlags fl )
: QWidget( parent, fl )
@@ -47,7 +46,6 @@
setupUi( this );
connect( lstCoordinateSystems, SIGNAL( currentItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ),
this, SLOT( coordinateSystemSelected( QTreeWidgetItem* ) ) );
- connect( leSearch, SIGNAL( returnPressed() ), pbnFind, SLOT( animateClick() ) );
// Get the full path name to the sqlite3 spatial reference database.
mSrsDatabaseFileName = QgsApplication::srsDbFilePath();
@@ -55,13 +53,17 @@
lstCoordinateSystems->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
lstCoordinateSystems->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed );
+ lstRecent->header()->setResizeMode( AUTHID_COLUMN, QHeaderView::Stretch );
+ lstRecent->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
+ lstRecent->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed );
+
cbxAuthority->addItem( tr( "All" ) );
cbxAuthority->addItems( authorities() );
// Read settings from persistent storage
QSettings settings;
mRecentProjections = settings.value( "/UI/recentProjections" ).toStringList();
- /*** The reading (above) of internal id from persistent storage should be removed sometims in the future */
+ /*** The reading (above) of internal id from persistent storage should be removed sometime in the future */
/*** This is kept now for backwards compatibility */
QStringList projectionsEpsg = settings.value( "/UI/recentProjectionsEpsg" ).toStringList();
@@ -135,10 +137,13 @@
void QgsProjectionSelector::resizeEvent( QResizeEvent * theEvent )
{
-
lstCoordinateSystems->header()->resizeSection( NAME_COLUMN, theEvent->size().width() - 240 );
lstCoordinateSystems->header()->resizeSection( AUTHID_COLUMN, 240 );
lstCoordinateSystems->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
+
+ lstRecent->header()->resizeSection( NAME_COLUMN, theEvent->size().width() - 240 );
+ lstRecent->header()->resizeSection( AUTHID_COLUMN, 240 );
+ lstRecent->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
}
void QgsProjectionSelector::showEvent( QShowEvent * theEvent )
@@ -171,44 +176,9 @@
applyAuthIDSelection();
}
- // Update buttons
- pbnPopular1->setDisabled( true );
- pbnPopular2->setDisabled( true );
- pbnPopular3->setDisabled( true );
- pbnPopular4->setDisabled( true );
- pbnPopular1->hide();
- pbnPopular2->hide();
- pbnPopular3->hide();
- pbnPopular4->hide();
+ for ( int i = mRecentProjections.size() - 1; i >= 0; i-- )
+ insertRecent( mRecentProjections.at( i ).toLong() );
- 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 hierarchy
QWidget::showEvent( theEvent );
}
@@ -347,26 +317,20 @@
}
}
-QString QgsProjectionSelector::getCrsIdName( long theCrsId )
+void QgsProjectionSelector::insertRecent( long theCrsId )
{
- QString retvalue( "" );
- if ( mProjListDone && mUserProjListDone )
- {
- QString myCRSIDString = QString::number( theCrsId );
+ if ( !mProjListDone || !mUserProjListDone )
+ return;
- QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( myCRSIDString, Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN );
+ QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( QString::number( theCrsId ), Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN );
- if ( nodes.count() > 0 )
- {
- retvalue = nodes.first()->text( NAME_COLUMN );
- if ( nodes.first()->text( AUTHID_COLUMN ) != "" )
- {
- retvalue += " " + nodes.first()->text( AUTHID_COLUMN );
- }
- }
- }
- return retvalue;
+ if ( nodes.count() == 0 )
+ return;
+ lstRecent->insertTopLevelItem( 0, new QTreeWidgetItem( lstRecent, QStringList()
+ << nodes.first()->text( NAME_COLUMN )
+ << nodes.first()->text( AUTHID_COLUMN )
+ << nodes.first()->text( QGIS_CRS_ID_COLUMN ) ) );
}
void QgsProjectionSelector::applyAuthIDSelection()
@@ -889,6 +853,8 @@
QString myProjString = selectedProj4String();
lstCoordinateSystems->scrollToItem( theItem );
teProjection->setText( myProjString );
+
+ lstRecent->clearSelection();
}
else
{
@@ -920,26 +886,11 @@
hideDeprecated( lstCoordinateSystems->topLevelItem( i ) );
}
-void QgsProjectionSelector::on_pbnPopular1_clicked()
+void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *previous )
{
- setSelectedCrsId( mRecentProjections.at( 0 ).toLong() );
+ setSelectedCrsId( current->text( QGIS_CRS_ID_COLUMN ).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()
{
QgsDebugMsg( "pbnFind..." );
Modified: trunk/qgis/src/gui/qgsprojectionselector.h
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.h 2010-04-05 17:19:07 UTC (rev 13252)
+++ trunk/qgis/src/gui/qgsprojectionselector.h 2010-04-05 17:20:30 UTC (rev 13253)
@@ -110,13 +110,9 @@
void setOgcWmsCrsFilter( QSet<QString> crsFilter );
void on_pbnFind_clicked();
+ void on_lstRecent_currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * );
void on_cbxHideDeprecated_stateChanged();
- void on_pbnPopular1_clicked();
- void on_pbnPopular2_clicked();
- void on_pbnPopular3_clicked();
- void on_pbnPopular4_clicked();
-
protected:
/** Used to ensure the projection list view is actually populated */
void showEvent( QShowEvent * theEvent );
@@ -201,8 +197,8 @@
*/
long getLargestCRSIDMatch( QString theSql );
- //! Returns name from CRS Id
- QString getCrsIdName( long theCrsId );
+ //! add recently used CRS
+ void insertRecent( long theCrsId );
//! Has the Projection List been populated?
bool mProjListDone;
Modified: trunk/qgis/src/ui/qgsprojectionselectorbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsprojectionselectorbase.ui 2010-04-05 17:19:07 UTC (rev 13252)
+++ trunk/qgis/src/ui/qgsprojectionselectorbase.ui 2010-04-05 17:20:30 UTC (rev 13253)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>374</width>
- <height>464</height>
+ <width>590</width>
+ <height>358</height>
</rect>
</property>
<property name="sizePolicy">
@@ -65,18 +65,6 @@
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QPushButton" name="pbnPopular1"/>
- </item>
- <item row="4" column="0">
- <widget class="QPushButton" name="pbnPopular2"/>
- </item>
- <item row="5" column="0">
- <widget class="QPushButton" name="pbnPopular3"/>
- </item>
- <item row="6" column="0">
- <widget class="QPushButton" name="pbnPopular4"/>
- </item>
<item row="0" column="0">
<widget class="QTreeWidget" name="lstCoordinateSystems">
<property name="alternatingRowColors">
@@ -116,67 +104,144 @@
<property name="title">
<string>Search</string>
</property>
- <layout class="QGridLayout">
- <item row="1" column="1">
- <widget class="QComboBox" name="cbxMode">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <property name="text">
- <string>ID</string>
- </property>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Authority</string>
+ </property>
+ </widget>
</item>
<item>
- <property name="text">
- <string>Name</string>
- </property>
+ <widget class="QComboBox" name="cbxAuthority"/>
</item>
- </widget>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Search for</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cbxMode">
+ <item>
+ <property name="text">
+ <string>ID</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <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="text">
+ <string>Hide deprecated CRSs</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Authority</string>
- </property>
- </widget>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="leSearch"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pbnFind">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Find</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item row="0" column="1">
- <widget class="QComboBox" name="cbxAuthority"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Search for</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLineEdit" name="leSearch"/>
- </item>
- <item row="0" column="3">
- <widget class="QPushButton" name="pbnFind">
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Find</string>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="2" colspan="2">
- <widget class="QCheckBox" name="cbxHideDeprecated">
- <property name="text">
- <string>Hide deprecated CRSs</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Recently used coordinate references systems</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QTreeWidget" name="lstRecent">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <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>105</height>
+ </size>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </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>
+ </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
More information about the QGIS-commit
mailing list