UI tweaks to the projection UI; Remove old buttons and code etc

This commit is contained in:
Nathan Woodrow 2011-11-23 23:40:52 +10:00 committed by Juergen E. Fischer
parent dc56ea9b24
commit 36e178f7c4
6 changed files with 171 additions and 340 deletions

View File

@ -89,8 +89,6 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase
*/ */
void setOgcWmsCrsFilter(QSet<QString> crsFilter); void setOgcWmsCrsFilter(QSet<QString> crsFilter);
void on_pbnFind_clicked();
protected: protected:
/** Used to ensure the projection list view is actually populated */ /** Used to ensure the projection list view is actually populated */
void showEvent ( QShowEvent * theEvent ); void showEvent ( QShowEvent * theEvent );

View File

@ -551,6 +551,16 @@ QString QgsApplication::reportStyleSheet()
" color: black;" " color: black;"
" font-family: arial,sans-serif;" " font-family: arial,sans-serif;"
"}" "}"
"h1{ background-color: #F6F6F6;"
" color: #8FB171; "
" font-size: x-large; "
" font-weight: normal;"
" font-family: luxi serif, georgia, times new roman, times, serif;"
" background: none;"
" padding: 0.75em 0 0;"
" margin: 0;"
" line-height: 3em;"
"}"
"h2{ background-color: #F6F6F6;" "h2{ background-color: #F6F6F6;"
" color: #8FB171; " " color: #8FB171; "
" font-size: medium; " " font-size: medium; "

View File

@ -15,6 +15,8 @@
* (at your option) any later version. * * (at your option) any later version. *
* * * *
***************************************************************************/ ***************************************************************************/
#include "qgsapplication.h"
#include <qgsgenericprojectionselector.h> #include <qgsgenericprojectionselector.h>
#include <QApplication> #include <QApplication>
@ -38,20 +40,18 @@ void QgsGenericProjectionSelector::setMessage( QString theMessage )
if ( theMessage.isEmpty() ) if ( theMessage.isEmpty() )
{ {
// Set up text edit pane // Set up text edit pane
QString format( "<h2>%1</h2>%2 %3" ); QString format( "<h1>%1</h1>%2 %3" );
QString header = tr( "Define this layer's coordinate reference system:" ); QString header = tr( "Define this layer's coordinate reference system:" );
QString sentence1 = tr( "This layer appears to have no projection specification." ); QString sentence1 = tr( "This layer appears to have no projection specification." );
QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, " QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, "
"but you may override this by selecting a different projection below." ); "but you may override this by selecting a different projection below." );
textEdit->setHtml( format.arg( header ).arg( sentence1 ) theMessage = format.arg( header ).arg( sentence1 ).arg( sentence2 );
.arg( sentence2 ) );
} }
else
{
textEdit->setHtml( theMessage );
}
textEdit->show();
QString myStyle = QgsApplication::reportStyleSheet();
theMessage = "<head><style>" + myStyle + "</style></head><body>" + theMessage + "</body>";
textEdit->setHtml( theMessage );
textEdit->show();
} }
//! Destructor //! Destructor
QgsGenericProjectionSelector::~QgsGenericProjectionSelector() QgsGenericProjectionSelector::~QgsGenericProjectionSelector()

View File

@ -61,16 +61,6 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
// Hide (internal) ID column // Hide (internal) ID column
lstRecent->setColumnHidden(QGIS_CRS_ID_COLUMN, true); lstRecent->setColumnHidden(QGIS_CRS_ID_COLUMN, true);
cbxAuthority->addItem( tr( "All" ) );
cbxAuthority->addItems( authorities() );
// TEMP? hide buttons, we now implemented filter
cbxAuthority->hide();
cbxMode->hide();
label->hide();
label_2->hide();
pbnFind->hide();
// Read settings from persistent storage // Read settings from persistent storage
QSettings settings; QSettings settings;
mRecentProjections = settings.value( "/UI/recentProjections" ).toStringList(); mRecentProjections = settings.value( "/UI/recentProjections" ).toStringList();
@ -146,7 +136,6 @@ QgsProjectionSelector::~QgsProjectionSelector()
} }
} }
void QgsProjectionSelector::resizeEvent( QResizeEvent * theEvent ) void QgsProjectionSelector::resizeEvent( QResizeEvent * theEvent )
{ {
lstCoordinateSystems->header()->resizeSection( NAME_COLUMN, theEvent->size().width() - 240 ); lstCoordinateSystems->header()->resizeSection( NAME_COLUMN, theEvent->size().width() - 240 );
@ -877,121 +866,6 @@ void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *cu
setSelectedCrsId( current->text( QGIS_CRS_ID_COLUMN ).toLong() ); setSelectedCrsId( current->text( QGIS_CRS_ID_COLUMN ).toLong() );
} }
void QgsProjectionSelector::on_pbnFind_clicked()
{
QgsDebugMsg( "pbnFind..." );
QString mySearchString( sqlSafeString( leSearch->text() ) );
// Set up the query to retrieve the projection information needed to populate the list
QString mySql = "select srs_id from tbl_srs where ";
if ( cbxAuthority->currentIndex() > 0 )
{
mySql += QString( "auth_name='%1' AND " ).arg( cbxAuthority->currentText() );
}
if ( cbxHideDeprecated->isChecked() )
{
mySql += "not deprecated AND ";
}
if ( cbxMode->currentIndex() == 0 )
{
mySql += QString( "auth_id='%1'" ).arg( mySearchString );
}
else
{
mySql += "upper(description) like '%" + mySearchString.toUpper() + "%' ";
long myLargestSrsId = getLargestCRSIDMatch( QString( "%1 order by srs_id desc limit 1" ).arg( mySql ) );
QgsDebugMsg( QString( "Largest CRSID%1" ).arg( myLargestSrsId ) );
//a name search is ambiguous, so we find the first srsid after the current selected srsid
// each time the find button is pressed. This means we can loop through all matches.
if ( myLargestSrsId <= selectedCrsId() )
{
mySql = QString( "%1 order by srs_id limit 1" ).arg( mySql );
}
else
{
// search ahead of the current position
mySql = QString( "%1 and srs_id > %2 order by srs_id limit 1" ).arg( mySql ).arg( selectedCrsId() );
}
}
QgsDebugMsg( QString( " Search sql: %1" ).arg( mySql ) );
//
// Now perform the actual search
//
sqlite3 *myDatabase;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;
//check the db is available
myResult = sqlite3_open( mSrsDatabaseFileName.toUtf8().data(), &myDatabase );
if ( myResult )
{
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist. But we checked earlier for its existance
// and aborted in that case. This is because we may be runnig from read only
// media such as live cd and don't want to force trying to create a db.
showDBMissingWarning( mSrsDatabaseFileName );
return;
}
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
// XXX Need to free memory from the error msg if one is set
if ( myResult == SQLITE_OK )
{
myResult = sqlite3_step( myPreparedStatement );
if ( myResult == SQLITE_ROW )
{
QString mySrsId = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) );
setSelectedCrsId( mySrsId.toLong() );
// close the sqlite3 statement
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
return;
}
}
//search the users db
QString myDatabaseFileName = QgsApplication::qgisUserDbFilePath();
QFileInfo myFileInfo;
myFileInfo.setFile( myDatabaseFileName );
if ( !myFileInfo.exists( ) ) //its not critical if this happens
{
QgsDebugMsg( QString( "%1\nUser db does not exist" ).arg( myDatabaseFileName ) );
return ;
}
myResult = sqlite3_open( myDatabaseFileName.toUtf8().data(), &myDatabase );
if ( myResult )
{
QgsDebugMsg( QString( "Can't open * user * database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
//no need for assert because user db may not have been created yet
return;
}
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
// XXX Need to free memory from the error msg if one is set
if ( myResult == SQLITE_OK )
{
myResult = sqlite3_step( myPreparedStatement );
if ( myResult == SQLITE_ROW )
{
QString mySrsId = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) );
setSelectedCrsId( mySrsId.toLong() );
// close the sqlite3 statement
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
return;
}
}
QMessageBox::information( this, tr( "Find projection" ), tr( "No matching projection found." ) );
lstCoordinateSystems->clearSelection();
teProjection->setText( "" );
}
void QgsProjectionSelector::on_leSearch_textChanged( const QString & theFilterTxt) void QgsProjectionSelector::on_leSearch_textChanged( const QString & theFilterTxt)
{ {

View File

@ -113,8 +113,6 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio
* \warning This function's behaviour is undefined if it is called after the widget is shown. * \warning This function's behaviour is undefined if it is called after the widget is shown.
*/ */
void setOgcWmsCrsFilter( QSet<QString> crsFilter ); void setOgcWmsCrsFilter( QSet<QString> crsFilter );
void on_pbnFind_clicked();
void on_lstRecent_currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * ); void on_lstRecent_currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * );
void on_cbxHideDeprecated_stateChanged(); void on_cbxHideDeprecated_stateChanged();
void on_leSearch_textChanged(const QString &); void on_leSearch_textChanged(const QString &);

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>574</width> <width>574</width>
<height>389</height> <height>390</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -24,170 +24,172 @@
<normaloff/> <normaloff/>
</iconset> </iconset>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>3</number>
</property>
<property name="margin">
<number>3</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum"> <widget class="QLabel" name="label_5">
<horstretch>0</horstretch> <property name="text">
<verstretch>0</verstretch> <string>Filter</string>
</sizepolicy> </property>
</property> </widget>
<property name="title"> </item>
<string>Filter</string> <item>
</property> <widget class="QLineEdit" name="leSearch"/>
<layout class="QVBoxLayout" name="verticalLayout"> </item>
<item> </layout>
<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>
</layout>
</widget>
</item> </item>
<item row="3" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Recently used coordinate references systems</string> <string>Recently used coordinate references systems</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="2" column="0">
<widget class="QTreeWidget" name="lstRecent"> <widget class="QSplitter" name="splitter">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> <enum>Qt::Vertical</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="childrenCollapsible">
<size>
<width>0</width>
<height>105</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="rootIsDecorated"> <widget class="QTreeWidget" name="lstRecent">
<bool>false</bool> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<property name="uniformRowHeights"> <horstretch>0</horstretch>
<bool>true</bool> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="columnCount">
<number>3</number>
</property>
<column>
<property name="text">
<string>Coordinate Reference System</string>
</property> </property>
</column> <property name="minimumSize">
<column> <size>
<property name="text"> <width>0</width>
<string>Authority ID</string> <height>105</height>
</size>
</property> </property>
</column> <property name="maximumSize">
<column> <size>
<property name="text"> <width>16777215</width>
<string>ID</string> <height>200</height>
</size>
</property> </property>
</column> <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>
<widget class="QWidget" name="">
<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>7</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>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item row="7" column="0" rowspan="5"> <item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>15</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<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="text">
<string>Hide deprecated CRSs</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="15" 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="19" column="0">
<widget class="QTextEdit" name="teProjection"> <widget class="QTextEdit" name="teProjection">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum"> <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
@ -198,7 +200,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>30</height> <height>40</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -210,7 +212,7 @@
<property name="baseSize"> <property name="baseSize">
<size> <size>
<width>0</width> <width>0</width>
<height>50</height> <height>40</height>
</size> </size>
</property> </property>
<property name="autoFormatting"> <property name="autoFormatting">
@ -221,64 +223,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="16" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Authority</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbxAuthority"/>
</item>
<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>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<tabstops> <tabstops>
<tabstop>lstCoordinateSystems</tabstop> <tabstop>lstCoordinateSystems</tabstop>
<tabstop>teProjection</tabstop> <tabstop>teProjection</tabstop>
<tabstop>cbxAuthority</tabstop>
<tabstop>cbxMode</tabstop>
<tabstop>leSearch</tabstop> <tabstop>leSearch</tabstop>
<tabstop>pbnFind</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>