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 on_pbnFind_clicked();
protected:
/** Used to ensure the projection list view is actually populated */
void showEvent ( QShowEvent * theEvent );

View File

@ -551,6 +551,16 @@ QString QgsApplication::reportStyleSheet()
" color: black;"
" 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;"
" color: #8FB171; "
" font-size: medium; "

View File

@ -15,6 +15,8 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsapplication.h"
#include <qgsgenericprojectionselector.h>
#include <QApplication>
@ -38,20 +40,18 @@ void QgsGenericProjectionSelector::setMessage( QString theMessage )
if ( theMessage.isEmpty() )
{
// 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 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, "
"but you may override this by selecting a different projection below." );
textEdit->setHtml( format.arg( header ).arg( sentence1 )
.arg( sentence2 ) );
theMessage = format.arg( header ).arg( sentence1 ).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
QgsGenericProjectionSelector::~QgsGenericProjectionSelector()

View File

@ -61,16 +61,6 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
// Hide (internal) ID column
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
QSettings settings;
mRecentProjections = settings.value( "/UI/recentProjections" ).toStringList();
@ -146,7 +136,6 @@ QgsProjectionSelector::~QgsProjectionSelector()
}
}
void QgsProjectionSelector::resizeEvent( QResizeEvent * theEvent )
{
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() );
}
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)
{

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.
*/
void setOgcWmsCrsFilter( QSet<QString> crsFilter );
void on_pbnFind_clicked();
void on_lstRecent_currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * );
void on_cbxHideDeprecated_stateChanged();
void on_leSearch_textChanged(const QString &);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>574</width>
<height>389</height>
<height>390</height>
</rect>
</property>
<property name="sizePolicy">
@ -24,170 +24,172 @@
<normaloff/>
</iconset>
</property>
<layout class="QGridLayout">
<property name="verticalSpacing">
<number>3</number>
</property>
<property name="margin">
<number>3</number>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Filter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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>
</layout>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leSearch"/>
</item>
</layout>
</item>
<item row="3" column="0">
<item row="1" 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 references systems</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QTreeWidget" name="lstRecent">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="2" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</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>
<property name="alternatingRowColors">
<property name="childrenCollapsible">
<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>
<widget class="QTreeWidget" name="lstRecent">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</column>
<column>
<property name="text">
<string>Authority ID</string>
<property name="minimumSize">
<size>
<width>0</width>
<height>105</height>
</size>
</property>
</column>
<column>
<property name="text">
<string>ID</string>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</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>
</item>
<item row="7" column="0" rowspan="5">
<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">
<item row="3" column="0">
<widget class="QTextEdit" name="teProjection">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
@ -198,7 +200,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>40</height>
</size>
</property>
<property name="maximumSize">
@ -210,7 +212,7 @@
<property name="baseSize">
<size>
<width>0</width>
<height>50</height>
<height>40</height>
</size>
</property>
<property name="autoFormatting">
@ -221,64 +223,13 @@
</property>
</widget>
</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>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>lstCoordinateSystems</tabstop>
<tabstop>teProjection</tabstop>
<tabstop>cbxAuthority</tabstop>
<tabstop>cbxMode</tabstop>
<tabstop>leSearch</tabstop>
<tabstop>pbnFind</tabstop>
</tabstops>
<resources/>
<connections/>