[QGIS Commit] r10106 - in trunk/qgis/src: gui
plugins/delimited_text ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Feb 4 16:09:26 EST 2009
Author: homann
Date: 2009-02-04 16:09:26 -0500 (Wed, 04 Feb 2009)
New Revision: 10106
Modified:
trunk/qgis/src/gui/qgsprojectionselector.cpp
trunk/qgis/src/gui/qgsprojectionselector.h
trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp
trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.h
trunk/qgis/src/ui/qgsprojectionselectorbase.ui
Log:
Very CRUDE list of most recently used projections. I love the functionality, the UI could be nicer. Please do not remove, but instead improve!
Modified: trunk/qgis/src/gui/qgsprojectionselector.cpp
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.cpp 2009-02-04 08:41:51 UTC (rev 10105)
+++ trunk/qgis/src/gui/qgsprojectionselector.cpp 2009-02-04 21:09:26 UTC (rev 10106)
@@ -28,6 +28,7 @@
#include <QHeaderView>
#include <QResizeEvent>
#include <QMessageBox>
+#include <QSettings>
#include "qgslogger.h"
const int NAME_COLUMN = 0;
@@ -54,13 +55,37 @@
lstCoordinateSystems->header()->setResizeMode( EPSG_COLUMN, QHeaderView::Stretch );
lstCoordinateSystems->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
lstCoordinateSystems->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed );
+
+ // Read settings from persistent storage
+ QSettings settings;
+ mRecentProjections = settings.value("/UI/recentProjections").toStringList();
+
}
QgsProjectionSelector::~QgsProjectionSelector()
-{}
+{
+ // Save persistent list of projects
+ QSettings settings;
+ long crsId;
+ // Push current projection to front, only if set
+ crsId = selectedCrsId();
+ if ( crsId )
+ {
+ mRecentProjections.removeAll( QString::number( crsId ) );
+ mRecentProjections.prepend( QString::number( crsId ) );
+ // Prunse size of list
+ while ( mRecentProjections.size() > 4 )
+ {
+ mRecentProjections.removeLast();
+ }
+ // Save to file
+ settings.setValue( "/UI/recentProjections", mRecentProjections);
+ }
+}
+
void QgsProjectionSelector::resizeEvent( QResizeEvent * theEvent )
{
@@ -99,6 +124,40 @@
applyEPSGIDSelection();
}
+ // Update buttons
+ pbnPopular1->setDisabled(true);
+ pbnPopular2->setDisabled(true);
+ pbnPopular3->setDisabled(true);
+ pbnPopular4->setDisabled(true);
+ pbnPopular1->hide();
+ pbnPopular2->hide();
+ pbnPopular3->hide();
+ pbnPopular4->hide();
+
+ 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 heirarchy
QWidget::showEvent( theEvent );
}
@@ -235,6 +294,26 @@
}
}
+QString QgsProjectionSelector::getCrsIdName( long theCrsId )
+{
+ if (
+ ( mProjListDone ) &&
+ ( mUserProjListDone )
+ )
+ {
+ QString myCRSIDString = QString::number( theCrsId );
+
+ QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( myCRSIDString, Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN );
+
+ if ( nodes.count() > 0 )
+ {
+ return nodes.first()->text(0);
+ }
+ }
+ return QString( "" );
+
+}
+
void QgsProjectionSelector::applyEPSGIDSelection()
{
if (
@@ -761,6 +840,24 @@
}
}
+void QgsProjectionSelector::on_pbnPopular1_clicked()
+{
+ setSelectedCrsId( mRecentProjections.at(0).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()
{
Modified: trunk/qgis/src/gui/qgsprojectionselector.h
===================================================================
--- trunk/qgis/src/gui/qgsprojectionselector.h 2009-02-04 08:41:51 UTC (rev 10105)
+++ trunk/qgis/src/gui/qgsprojectionselector.h 2009-02-04 21:09:26 UTC (rev 10106)
@@ -14,6 +14,7 @@
#include <ui_qgsprojectionselectorbase.h>
#include <QSet>
+#include <QStringList>
class QResizeEvent;
@@ -104,6 +105,11 @@
void on_pbnFind_clicked();
+ 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 );
@@ -189,6 +195,9 @@
*/
long getLargestCRSIDMatch( QString theSql );
+ //! Returns name from CRS Id
+ QString getCrsIdName( long theCrsId );
+
//! Has the Projection List been populated?
bool mProjListDone;
@@ -216,6 +225,9 @@
//! The set of OGC WMS CRSs that want to be applied to this widget
QSet<QString> mCrsFilter;
+ //! Most recently used projections (trimmed at 25 entries)
+ QStringList mRecentProjections;
+
private slots:
/**private handler for when user selects a cs
*it will cause wktSelected and sridSelected events to be spawned
Modified: trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp
===================================================================
--- trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp 2009-02-04 08:41:51 UTC (rev 10105)
+++ trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp 2009-02-04 21:09:26 UTC (rev 10106)
@@ -140,14 +140,14 @@
if ( QFile::exists( txtFilePath->text() ) )
{
QFile *file = new QFile( txtFilePath->text() );
- if ( file->open( QIODevice::ReadOnly ) )
+ if ( file->open( QIODevice::ReadOnly | QIODevice::Text ) )
{
// clear the field lists
cmbXField->clear();
cmbYField->clear();
QTextStream stream( file );
QString line;
- line = stream.readLine(); // line of text excluding '\n'
+ line = readLine( stream ); // line of text excluding '\n'
if ( txtDelimiter->text().length() > 0 )
{
QgsDebugMsg( QString( "Attempting to split the input line: %1 using delimiter %2" ).arg( line ).arg( txtDelimiter->text() ) );
@@ -212,13 +212,12 @@
txtSample->insertPlainText( line + "\n" );
// put a few more lines into the sample box
int counter = 0;
- while (
- ( !( line = stream.readLine() ).isEmpty() ) &&
- ( counter < 20 )
- )
+ line = QgsDelimitedTextPluginGui::readLine( stream );
+ while ( not line.isEmpty() && ( counter < 20 ) )
{
txtSample->insertPlainText( line + "\n" );
counter++;
+ line = QgsDelimitedTextPluginGui::readLine( stream );
}
// close the file
file->close();
@@ -265,3 +264,52 @@
pbnParse->setEnabled( true );
}
}
+
+QString QgsDelimitedTextPluginGui::readLine( QTextStream & stream )
+{
+ QString buffer("");
+ QString c;
+
+ // Strip leading newlines
+
+ c = stream.read( 1 );
+ if ( c == NULL or c.size() == 0 )
+ {
+ // Reach end of file
+ return buffer;
+ }
+ while ( c == (char *)"\r" or c == (char *)"\n" )
+ {
+ c = stream.read( 1 );
+ if ( c == NULL or c.size() == 0 )
+ {
+ // Reach end of file
+ return buffer;
+ }
+ }
+
+ // First non-newline character
+ buffer.append( c );
+
+ c = stream.read( 1 );
+ if ( c == NULL or c.size() == 0 )
+ {
+ // Reach end of file
+ return buffer;
+ }
+
+ while ( not ( c == (char *)"\r" or c == (char *)"\n" ) )
+ {
+
+ buffer.append( c );
+ c = stream.read( 1 );
+ if ( c == NULL or c.size() == 0 )
+ {
+ // Reach end of file
+ return buffer;
+ }
+ }
+
+ return buffer;
+
+}
Modified: trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.h
===================================================================
--- trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.h 2009-02-04 08:41:51 UTC (rev 10105)
+++ trunk/qgis/src/plugins/delimited_text/qgsdelimitedtextplugingui.h 2009-02-04 21:09:26 UTC (rev 10106)
@@ -14,6 +14,7 @@
#define PLUGINGUI_H
#include "ui_qgsdelimitedtextpluginguibase.h"
+#include <QTextStream>
class QgisInterface;
@@ -27,6 +28,8 @@
QgsDelimitedTextPluginGui( QgisInterface * _qI, QWidget* parent = 0, Qt::WFlags fl = 0 );
~QgsDelimitedTextPluginGui();
+ static QString readLine( QTextStream & stream );
+
public slots:
void help();
@@ -53,4 +56,5 @@
void drawVectorLayer( QString, QString, QString );
};
+
#endif
Modified: trunk/qgis/src/ui/qgsprojectionselectorbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsprojectionselectorbase.ui 2009-02-04 08:41:51 UTC (rev 10105)
+++ trunk/qgis/src/ui/qgsprojectionselectorbase.ui 2009-02-04 21:09:26 UTC (rev 10106)
@@ -162,6 +162,34 @@
</layout>
</widget>
</item>
+ <item row="3" column="0" >
+ <widget class="QPushButton" name="pbnPopular1">
+ <property name="text" >
+ <string>CRS ID : 100000</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QPushButton" name="pbnPopular2">
+ <property name="text" >
+ <string>CRS ID : 3344</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <widget class="QPushButton" name="pbnPopular3">
+ <property name="text" >
+ <string>CRS ID : whatever</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" >
+ <widget class="QPushButton" name="pbnPopular4">
+ <property name="text" >
+ <string>CRS ID : whatever</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
More information about the QGIS-commit
mailing list