diff --git a/plugins/delimited_text/qgsdelimitedtextplugin.cpp b/plugins/delimited_text/qgsdelimitedtextplugin.cpp index 162be4ef8f2..7adfeb9ba58 100644 --- a/plugins/delimited_text/qgsdelimitedtextplugin.cpp +++ b/plugins/delimited_text/qgsdelimitedtextplugin.cpp @@ -4,9 +4,9 @@ Functions: ------------------- -begin : Jan 21, 2004 -copyright : (C) 2004 by Tim Sutton -email : tim@linfiniti.com + begin : Feb 21, 2004 + copyright : (C) 2004 by Gary Sherman + email : sherman at mrcc.com ***************************************************************************/ @@ -46,15 +46,15 @@ email : tim@linfiniti.com // xpm for creating the toolbar icon #include "icon.xpm" // -static const char *pluginVersion = "0.1"; +static const char *pluginVersion = "Version 0.1"; /** * Constructor for the plugin. The plugin is passed a pointer to the main app * and an interface object that provides access to exposed functions in QGIS. * @param qgis Pointer to the QGIS main window * @param _qI Pointer to the QGIS interface object */ -QgsDelimitedTextPlugin::QgsDelimitedTextPlugin(QgisApp * theQGisApp, QgisIface * theQgisInterFace): - qgisMainWindowPointer(theQGisApp), qGisInterface(theQgisInterFace) + QgsDelimitedTextPlugin::QgsDelimitedTextPlugin(QgisApp * theQGisApp, QgisIface * theQgisInterFace): +qgisMainWindowPointer(theQGisApp), qGisInterface(theQgisInterFace) { /** Initialize the plugin and set the required attributes */ pluginNameQString = "DelimitedTextLayer"; @@ -126,25 +126,30 @@ void QgsDelimitedTextPlugin::initGui() // Slot called when the buffer menu item is activated void QgsDelimitedTextPlugin::run() { - QgsDelimitedTextPluginGui *myQgsDelimitedTextPluginGui=new QgsDelimitedTextPluginGui(qGisInterface, qgisMainWindowPointer,"Add Delimited Text Layer",true,0); + QgsDelimitedTextPluginGui *myQgsDelimitedTextPluginGui= + new QgsDelimitedTextPluginGui(qGisInterface, qgisMainWindowPointer, + "Add Delimited Text Layer",true,0); //listen for when the layer has been made so we can draw it - connect(myQgsDelimitedTextPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString))); - connect(myQgsDelimitedTextPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString))); + connect(myQgsDelimitedTextPluginGui, + SIGNAL(drawRasterLayer(QString)), + this, SLOT(drawRasterLayer(QString))); + connect(myQgsDelimitedTextPluginGui, + SIGNAL(drawVectorLayer(QString,QString,QString)), + this, SLOT(drawVectorLayer(QString,QString,QString))); myQgsDelimitedTextPluginGui->show(); } -//!draw a raster layer in the qui - intended to respond to signal sent by diolog when it as finished creating -//layer -void QgsDelimitedTextPlugin::drawRasterLayer(QString theQString) -{ - qGisInterface->addRasterLayer(theQString); -} -//!draw a vector layer in the qui - intended to respond to signal sent by diolog when it as finished creating a layer -////needs to be given vectorLayerPath, baseName, providerKey ("ogr" or "postgres"); -void QgsDelimitedTextPlugin::drawVectorLayer(QString thePathNameQString, QString theBaseNameQString, QString theProviderQString) +//!draw a vector layer in the qui - intended to respond to signal +//sent by diolog when it as finished creating a layer +////needs to be given vectorLayerPath, baseName, +//providerKey ("ogr" or "postgres"); +void QgsDelimitedTextPlugin::drawVectorLayer(QString thePathNameQString, + QString theBaseNameQString, QString theProviderQString) { std::cerr << "Calling addVectorLayer with:" - << thePathNameQString << ", " << theBaseNameQString << ", " << theProviderQString << std::endl; - qGisInterface->addVectorLayer( thePathNameQString, theBaseNameQString, theProviderQString); + << thePathNameQString << ", " << theBaseNameQString + << ", " << theProviderQString << std::endl; + qGisInterface->addVectorLayer( thePathNameQString, + theBaseNameQString, theProviderQString); } // Unload the plugin by cleaning up the GUI @@ -160,7 +165,8 @@ void QgsDelimitedTextPlugin::unload() * of the plugin class */ // Class factory to return a new instance of the plugin class -extern "C" QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer) +extern "C" QgisPlugin * classFactory(QgisApp * theQGisAppPointer, + QgisIface * theQgisInterfacePointer) { return new QgsDelimitedTextPlugin(theQGisAppPointer, theQgisInterfacePointer); } diff --git a/plugins/delimited_text/qgsdelimitedtextplugin.h b/plugins/delimited_text/qgsdelimitedtextplugin.h index a68e0b06425..cbe14b03e84 100644 --- a/plugins/delimited_text/qgsdelimitedtextplugin.h +++ b/plugins/delimited_text/qgsdelimitedtextplugin.h @@ -63,8 +63,6 @@ class QgsDelimitedTextPlugin:public QObject, public QgisPlugin public slots: //! Show the dialog box void run(); - //!draw a raster layer in the qui - void drawRasterLayer(QString); //! Add a vector layer given vectorLayerPath, baseName, providerKey ("ogr" or "postgres"); void drawVectorLayer(QString,QString,QString); //! unload the plugin diff --git a/plugins/delimited_text/qgsdelimitedtextplugingui.cpp b/plugins/delimited_text/qgsdelimitedtextplugingui.cpp index b8b3212db07..93338fec78d 100644 --- a/plugins/delimited_text/qgsdelimitedtextplugingui.cpp +++ b/plugins/delimited_text/qgsdelimitedtextplugingui.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include "qgsdelimitedtextplugingui.h" #include "../../src/qgisiface.h" @@ -27,6 +29,11 @@ QgsDelimitedTextPluginGui::QgsDelimitedTextPluginGui() : QgsDelimitedTextPluginG QgsDelimitedTextPluginGui::QgsDelimitedTextPluginGui( QgisIface * _qI, QWidget* parent , const char* name , bool modal , WFlags fl ) : QgsDelimitedTextPluginGuiBase( parent, name, modal, fl ), qI(_qI) { + // at startup, fetch the last used delimiter and directory from + // settings + QSettings settings; + QString key = "/Qgis/delimited_text_plugin"; + txtDelimiter->setText(settings.readEntry(key + "/delimiter")); } QgsDelimitedTextPluginGui::~QgsDelimitedTextPluginGui() @@ -43,7 +50,14 @@ void QgsDelimitedTextPluginGui::pbnOK_clicked() .arg(cmbYField->currentText()); std::cerr << "Adding layer using " << uri << std::endl; // add the layer to the map - emit drawVectorLayer(uri,QString("layername"),"delimitedtext"); + emit drawVectorLayer(uri,txtLayerName->text(),"delimitedtext"); + // store the settings + + QSettings settings; + QString key = "/Qgis/delimited_text_plugin"; + settings.writeEntry(key + "/delimiter", txtDelimiter->text()); + QFileInfo fi(txtFilePath->text()); + settings.writeEntry(key + "/text_path", fi.dirPath()); } void QgsDelimitedTextPluginGui::updateFieldLists() @@ -92,8 +106,11 @@ void QgsDelimitedTextPluginGui::updateFieldLists() void QgsDelimitedTextPluginGui::getOpenFileName() { // Get a file to process, starting at the current directory + // Set inital dir to last used + QSettings settings; + QString s = QFileDialog::getOpenFileName( - "./", + settings.readEntry("/Qgis/delimited_text_plugin/text_path","./"), "Text files (*.txt)", 0, "open file dialog", diff --git a/plugins/delimited_text/qgsdelimitedtextplugingui.h b/plugins/delimited_text/qgsdelimitedtextplugingui.h index 21cc3074f84..43259a2697d 100644 --- a/plugins/delimited_text/qgsdelimitedtextplugingui.h +++ b/plugins/delimited_text/qgsdelimitedtextplugingui.h @@ -27,7 +27,7 @@ class QgsDelimitedTextPluginGui : public QgsDelimitedTextPluginGuiBase QgsDelimitedTextPluginGui( QgisIface * _qI, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~QgsDelimitedTextPluginGui(); public slots: - void pbnOK_clicked(); + void pbnOK_clicked(); void updateFieldLists(); void getOpenFileName(); void enableBrowseButton(const QString &); diff --git a/plugins/delimited_text/qgsdelimitedtextpluginguibase.ui b/plugins/delimited_text/qgsdelimitedtextpluginguibase.ui index bb7af7c3575..64af595eccd 100644 --- a/plugins/delimited_text/qgsdelimitedtextpluginguibase.ui +++ b/plugins/delimited_text/qgsdelimitedtextpluginguibase.ui @@ -9,7 +9,7 @@ 0 0 383 - 157 + 161 @@ -66,6 +66,12 @@ false + + + 30 + 32767 + + ... @@ -80,7 +86,7 @@ - layout2 + layout6 @@ -98,6 +104,20 @@ cmbXField + + + 7 + 0 + 0 + 0 + + + + + 120 + 0 + + true @@ -120,6 +140,20 @@ cmbYField + + + 7 + 0 + 0 + 0 + + + + + 120 + 0 + + true @@ -132,58 +166,6 @@ - - - layout6 - - - - unnamed - - - - textLabel3 - - - Delimiter - - - - - txtDelimiter - - - - 25 - 32767 - - - - Delimiter to use when splitting fields in the text file. The delimiter can be more than one character. - - - Delimiter to use when splitting fields in the delimited text file. The delimiter can be 1 or more characters in length. - - - - - spacer2_2 - - - Horizontal - - - Expanding - - - - 320 - 21 - - - - - layout5 @@ -218,11 +200,25 @@ - 100 + 16 21 + + + pbnParse + + + Parse + + + Parse the header row and update the X and Y field lists + + + Parse the header row of the input file and refresh the fields in the X and Y field drop-down lists. Use this button to refresh the field lists if you change the delimiter after selecting the delimited text file. + + pbnOK @@ -253,6 +249,77 @@ + + + layout5 + + + + unnamed + + + + textLabel1_2 + + + Layer name + + + + + txtLayerName + + + Name to display in the map legend + + + Name displayed in the map legend + + + + + spacer2_2 + + + Horizontal + + + Fixed + + + + 20 + 21 + + + + + + textLabel3 + + + Delimiter + + + + + txtDelimiter + + + + 25 + 32767 + + + + Delimiter to use when splitting fields in the text file. The delimiter can be more than one character. + + + Delimiter to use when splitting fields in the delimited text file. The delimiter can be 1 or more characters in length. + + + + @@ -273,12 +340,6 @@ QgsDelimitedTextPluginGuiBase reject() - - txtFilePath - textChanged(const QString&) - QgsDelimitedTextPluginGuiBase - updateFieldLists(const QString&) - btnBrowseForFile clicked() @@ -297,6 +358,12 @@ QgsDelimitedTextPluginGuiBase help() + + pbnParse + clicked() + QgsDelimitedTextPluginGuiBase + updateFieldLists() + txtDelimiter @@ -313,6 +380,7 @@ getOpenFileName() enableBrowseButton(const QString &) help() + updateFieldLists()