mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
Added Parse button to reparse the header row if the delimiter is changed
Added layer name field to specify the name as it will appear in the legend Added WhatsThis help and tooltips for all widgets on the dialog git-svn-id: http://svn.osgeo.org/qgis/trunk@1034 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
1b7ad1ae91
commit
4db696924a
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include <qfile.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qsettings.h>
|
||||
#include <qfileinfo.h>
|
||||
#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",
|
||||
|
@ -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 &);
|
||||
|
@ -9,7 +9,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>383</width>
|
||||
<height>157</height>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="paletteBackgroundColor">
|
||||
@ -66,6 +66,12 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
@ -80,7 +86,7 @@
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout2</cstring>
|
||||
<cstring>layout6</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
@ -98,6 +104,20 @@
|
||||
<property name="name">
|
||||
<cstring>cmbXField</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -120,6 +140,20 @@
|
||||
<property name="name">
|
||||
<cstring>cmbYField</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -132,58 +166,6 @@
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout6</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel3</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delimiter</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>txtDelimiter</cstring>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Delimiter to use when splitting fields in the text file. The delimiter can be more than one character.</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>Delimiter to use when splitting fields in the delimited text file. The delimiter can be 1 or more characters in length.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer2_2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>320</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="3" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout5</cstring>
|
||||
@ -218,11 +200,25 @@
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>16</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>pbnParse</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Parse</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Parse the header row and update the X and Y field lists</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>pbnOK</cstring>
|
||||
@ -253,6 +249,77 @@
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout5</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Layer name</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>txtLayerName</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Name to display in the map legend</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>Name displayed in the map legend</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer2_2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel3</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delimiter</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>txtDelimiter</cstring>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Delimiter to use when splitting fields in the text file. The delimiter can be more than one character.</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>Delimiter to use when splitting fields in the delimited text file. The delimiter can be 1 or more characters in length.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<images>
|
||||
@ -273,12 +340,6 @@
|
||||
<receiver>QgsDelimitedTextPluginGuiBase</receiver>
|
||||
<slot>reject()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>txtFilePath</sender>
|
||||
<signal>textChanged(const QString&)</signal>
|
||||
<receiver>QgsDelimitedTextPluginGuiBase</receiver>
|
||||
<slot>updateFieldLists(const QString&)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnBrowseForFile</sender>
|
||||
<signal>clicked()</signal>
|
||||
@ -297,6 +358,12 @@
|
||||
<receiver>QgsDelimitedTextPluginGuiBase</receiver>
|
||||
<slot>help()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pbnParse</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QgsDelimitedTextPluginGuiBase</receiver>
|
||||
<slot>updateFieldLists()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<tabstops>
|
||||
<tabstop>txtDelimiter</tabstop>
|
||||
@ -313,6 +380,7 @@
|
||||
<slot>getOpenFileName()</slot>
|
||||
<slot>enableBrowseButton(const QString &)</slot>
|
||||
<slot>help()</slot>
|
||||
<slot>updateFieldLists()</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
||||
|
Loading…
x
Reference in New Issue
Block a user