diff --git a/doc/plugins/delimited_text/dialog.png b/doc/plugins/delimited_text/dialog.png deleted file mode 100644 index fc9b46d9325..00000000000 Binary files a/doc/plugins/delimited_text/dialog.png and /dev/null differ diff --git a/doc/plugins/delimited_text/ellipsis.png b/doc/plugins/delimited_text/ellipsis.png deleted file mode 100644 index 8349c29cdc5..00000000000 Binary files a/doc/plugins/delimited_text/ellipsis.png and /dev/null differ diff --git a/doc/plugins/delimited_text/file_selected.png b/doc/plugins/delimited_text/file_selected.png deleted file mode 100644 index 9c731d97734..00000000000 Binary files a/doc/plugins/delimited_text/file_selected.png and /dev/null differ diff --git a/doc/plugins/delimited_text/file_selected1.png b/doc/plugins/delimited_text/file_selected1.png deleted file mode 100644 index a9c69e0db2d..00000000000 Binary files a/doc/plugins/delimited_text/file_selected1.png and /dev/null differ diff --git a/doc/plugins/delimited_text/file_selected2.png b/doc/plugins/delimited_text/file_selected2.png deleted file mode 100644 index 9f4aea3d297..00000000000 Binary files a/doc/plugins/delimited_text/file_selected2.png and /dev/null differ diff --git a/doc/plugins/delimited_text/file_selected3.png b/doc/plugins/delimited_text/file_selected3.png deleted file mode 100644 index 6b6350be01b..00000000000 Binary files a/doc/plugins/delimited_text/file_selected3.png and /dev/null differ diff --git a/doc/plugins/delimited_text/index.html b/doc/plugins/delimited_text/index.html deleted file mode 100644 index 81d32ce1871..00000000000 --- a/doc/plugins/delimited_text/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - -

Delmited Text Plugin

- The Delimited Text plugin allows you to load a delimited text file - as a layer in QGIS. -

Requirements

- To view a delimited text file as layer, the text file must contain: -
    -
  1. A delimited header row of field names. This must be the - first line in the text file
  2. -
  3. The header row must contain an X and Y field. These fields - can have any name.
  4. -
  5. The x and y coordinates must be specified as a number. The - coordinate system is not important
  6. -

    Example of a valid text file

    -
    -        name|latdec|longdec|cell|
    -        196 mile creek|61.89806|-150.0775|tyonek d-1 ne|
    -        197 1/2 mile creek|61.89472|-150.09972|tyonek d-1 ne|
    -        a b mountain|59.52889|-135.28333|skagway c-1 sw|
    -        apw dam number 2|60.53|-145.75167|cordova c-5 sw|
    -        apw reservoir|60.53167|-145.75333|cordova c-5 sw|
    -        apw reservoir|60.53|-145.75167|cordova c-5 sw|
    -        aaron creek|56.37861|-131.96556|bradfield canal b-6|
    -        aaron island|58.43778|-134.81944|juneau b-3 ne|
    -        aats bay|55.905|-134.24639|craig d-7|
    -      
    - Some items of note about the text file are: -
      -
    1. The example text file uses | as delimter. Any character can be used to - delimit the fields.
    2. -
    3. The first row is the header row. It contains the fields name, latdec, longdec, and cell
    4. -
    5. No quotes (") are used to delimit text fields
    6. -
    7. The x coordinates are contained in the longdec field
    8. -
    9. The y coordinates are contained in the latdec field
    10. - -
    -

    Using the Plugin

    - To use the plugin you must have QGIS running and use the Plugin Manager to load the plugin: -
      -
    1. Start QGIS
    2. -
    3. Open the Plugin Manager by choosing the Tools|Plugin Manager menu. The - Plugin Manager displays a list of available plugins. Plugins that are already loaded have - a checkmark to the left of their name. Click on the checkbox to the left of the Add Delimited Text - Layer plugin and click Ok to load it.

      - Plugin Manager -
    4. -
    5. A new toolbar icon is now present: - Delimited Text toolbar icon
    6. -
    7. Click on the icon to open the Delimited Text dialog: -

      - Add delimited text layer dialog

      - -
    8. -
    9. First select the file to import by clicking on the ellipsis button:
    10. -
    11. Select the desired text file from the file dialog
    12. -
    13. Once the file is selected, the plugin attempts to parse the file using the last used delimiter, in this case |

      -

    14. -
    15. In this case the delimiter | is not correct for the file. The file is actually tab delimited. Note that the X and Y field drop down boxes do not contain valid field names.
    16. -
    17. To properly parse the file, change the delimiter to tab using \t (this is a regular expression for the tab character). After changing the delimiter, click Parse
    18. -
    19. The drop down boxes now contain the fields properly parsed:

      -

    20. -
    21. Choose the X and Y fields from the drop down boxes and enter a Layer name

      -

    22. -
    23. Click Add Layer
    24. -
    25. The layer is added to the map:

    26. - -
    - - diff --git a/doc/plugins/delimited_text/layer_added.png b/doc/plugins/delimited_text/layer_added.png deleted file mode 100644 index f91bdf8df4d..00000000000 Binary files a/doc/plugins/delimited_text/layer_added.png and /dev/null differ diff --git a/doc/plugins/delimited_text/plugin_manager.png b/doc/plugins/delimited_text/plugin_manager.png deleted file mode 100644 index 4c9eb4fb1b4..00000000000 Binary files a/doc/plugins/delimited_text/plugin_manager.png and /dev/null differ diff --git a/doc/plugins/delimited_text/toolbar_icon.png b/doc/plugins/delimited_text/toolbar_icon.png deleted file mode 100644 index 75a6b36431a..00000000000 Binary files a/doc/plugins/delimited_text/toolbar_icon.png and /dev/null differ diff --git a/images/images.qrc b/images/images.qrc index c7f06ce5e8f..d755cafa34b 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -140,6 +140,7 @@ themes/default/mActionAddWcsLayer.png themes/default/mActionAddWfsLayer.png themes/default/mActionAddWmsLayer.png + themes/default/mActionAddDelimitedTextLayer.png themes/default/mActionAlignBottom.png themes/default/mActionAlignHCenter.png themes/default/mActionAlignLeft.png @@ -360,7 +361,6 @@ themes/default/plugin.png themes/default/plugins/coordinate_capture/coordinate_capture.png themes/default/plugins/copyright_label.png - themes/default/plugins/delimited_text.png themes/default/plugins/dxf2shp_converter.png themes/default/plugins/gps_importer.png themes/default/plugins/gps_importer/create_gpx.png diff --git a/images/themes/default/plugins/delimited_text.png b/images/themes/default/mActionAddDelimitedTextLayer.png similarity index 100% rename from images/themes/default/plugins/delimited_text.png rename to images/themes/default/mActionAddDelimitedTextLayer.png diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 21d423b29b3..752d4882560 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -980,6 +980,7 @@ void QgisApp::createActions() connect( mActionAddWmsLayer, SIGNAL( triggered() ), this, SLOT( addWmsLayer() ) ); connect( mActionAddWcsLayer, SIGNAL( triggered() ), this, SLOT( addWcsLayer() ) ); connect( mActionAddWfsLayer, SIGNAL( triggered() ), this, SLOT( addWfsLayer() ) ); + connect( mActionAddDelimitedText, SIGNAL( triggered()), this, SLOT(addDelimitedTextLayer())); connect( mActionOpenTable, SIGNAL( triggered() ), this, SLOT( attributeTable() ) ); connect( mActionToggleEditing, SIGNAL( triggered() ), this, SLOT( toggleEditing() ) ); connect( mActionSaveLayerEdits, SIGNAL( triggered() ), this, SLOT( saveActiveLayerEdits() ) ); @@ -2970,6 +2971,31 @@ void QgisApp::addSpatiaLiteLayer() delete dbs; } // QgisApp::addSpatiaLiteLayer() +void QgisApp::addDelimitedTextLayer() +{ + if ( mMapCanvas && mMapCanvas->isDrawing() ) + { + return; + } + + // show the Delimited text dialog + QDialog *dts = dynamic_cast( QgsProviderRegistry::instance()->selectWidget( "delimitedtext", this ) ); + if ( !dts ) + { + QMessageBox::warning( this, tr( "DelimitedText" ), tr( "Cannot get Delimited Text select dialog from provider." ) ); + return; + } + connect( dts, SIGNAL( addVectorLayer( QString, QString, QString ) ), + this, SLOT( addSelectedVectorLayer( QString, QString, QString ) ) ); + dts->exec(); + delete dts; +} // QgisApp::addDelimitedTextLayer() + +void QgisApp::addSelectedVectorLayer( QString uri, QString layerName, QString provider ) +{ + addVectorLayer( uri, layerName, provider ); +} // QgisApp:addSelectedVectorLayer + void QgisApp::addMssqlLayer() { #ifdef HAVE_MSSQL diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 8083f5a2f2e..6ccbea45b6b 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -115,7 +115,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow */ QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey ); - /** \brief overloaded vesion of the privat addLayer method that takes a list of + /** \brief overloaded version of the private addLayer method that takes a list of * file names instead of prompting user with a dialog. @param enc encoding type for the layer @param dataSourceType type of ogr datasource @@ -623,6 +623,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow void addDatabaseLayers( QStringList const & layerPathList, QString const & providerKey ); //! Add a SpatiaLite layer to the map void addSpatiaLiteLayer(); + //! Add a Delimited Text layer to the map + void addDelimitedTextLayer(); + //! Add a vector layer defined by uri, layer name, data source uri + void addSelectedVectorLayer(QString uri, QString layerName, QString provider ); //#ifdef HAVE_MSSQL //! Add a MSSQL layer to the map void addMssqlLayer(); diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 171cb172a56..6eddd3b127e 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -2,7 +2,6 @@ SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}) SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}) -ADD_SUBDIRECTORY(delimited_text) ADD_SUBDIRECTORY(diagram_overlay) ADD_SUBDIRECTORY(interpolation) ADD_SUBDIRECTORY(oracle_raster) diff --git a/src/plugins/delimited_text/CMakeLists.txt b/src/plugins/delimited_text/CMakeLists.txt deleted file mode 100644 index c15dfc73187..00000000000 --- a/src/plugins/delimited_text/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ - -######################################################## -# Files - -SET (DLTEXT_SRCS qgsdelimitedtextplugin.cpp) - -SET (DLTEXT_MOC_HDRS qgsdelimitedtextplugin.h) - -SET (DLTEXT_RCCS delimited_text.qrc) - -######################################################## -# Build - -QT4_WRAP_CPP (DLTEXT_MOC_SRCS ${DLTEXT_MOC_HDRS}) - -QT4_ADD_RESOURCES(DLTEXT_RCC_SRCS ${DLTEXT_RCCS}) - -ADD_LIBRARY (delimitedtextplugin MODULE ${DLTEXT_SRCS} ${DLTEXT_MOC_SRCS} ${DLTEXT_RCC_SRCS}) - -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ../../core ../../core/raster - ../../gui - .. - ../../providers/delimitedtext/delimitedtext -) - -TARGET_LINK_LIBRARIES(delimitedtextplugin - qgis_core - qgis_gui -) - - -######################################################## -# Install - -INSTALL(TARGETS delimitedtextplugin - RUNTIME DESTINATION ${QGIS_PLUGIN_DIR} - LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}) diff --git a/src/plugins/delimited_text/delimitedText.svg b/src/plugins/delimited_text/delimitedText.svg deleted file mode 100644 index 2522c45a2fd..00000000000 --- a/src/plugins/delimited_text/delimitedText.svg +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - ,,, - - - diff --git a/src/plugins/delimited_text/delimited_text.png b/src/plugins/delimited_text/delimited_text.png deleted file mode 100644 index ef4e03385e8..00000000000 Binary files a/src/plugins/delimited_text/delimited_text.png and /dev/null differ diff --git a/src/plugins/delimited_text/delimited_text.qrc b/src/plugins/delimited_text/delimited_text.qrc deleted file mode 100644 index 702e738e4ae..00000000000 --- a/src/plugins/delimited_text/delimited_text.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - delimited_text.png - - diff --git a/src/plugins/delimited_text/qgsdelimitedtextplugin.cpp b/src/plugins/delimited_text/qgsdelimitedtextplugin.cpp deleted file mode 100644 index 33469c8968b..00000000000 --- a/src/plugins/delimited_text/qgsdelimitedtextplugin.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/*************************************************************************** - qgsdelimitedtextplugin.cpp - Import tool for various worldmap analysis output files -Functions: - -------------------- - begin : Feb 21, 2004 - copyright : (C) 2004 by Gary Sherman - email : sherman at mrcc.com - - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -// includes - -#include "qgisinterface.h" -#include "qgisgui.h" -#include "qgsapplication.h" -#include "qgsmaplayer.h" -#include "qgsproviderregistry.h" -#include "qgsdelimitedtextplugin.h" - -#include -#include -#include -#include -#include - -static const QString pluginVersion = QObject::tr( "Version 0.2" ); -static const QString description_ = QObject::tr( "Loads and displays delimited text files containing x,y coordinates" ); -static const QString category_ = QObject::tr( "Layers" ); -static const QString icon_ = ":/delimited_text.png"; - -/** - * 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( QgisInterface * theQgisInterFace ) - : qGisInterface( theQgisInterFace ) -{ - /** Initialize the plugin and set the required attributes */ - pluginNameQString = tr( "DelimitedTextLayer" ); - pluginVersionQString = pluginVersion; - pluginDescriptionQString = description_; - pluginCategoryQString = category_; -} - -QgsDelimitedTextPlugin::~QgsDelimitedTextPlugin() -{ - -} - -/* Following functions return name, description, version, and type for the plugin */ -QString QgsDelimitedTextPlugin::name() -{ - return pluginNameQString; -} - -QString QgsDelimitedTextPlugin::version() -{ - return pluginVersionQString; - -} - -QString QgsDelimitedTextPlugin::description() -{ - return pluginDescriptionQString; - -} - -QString QgsDelimitedTextPlugin::category() -{ - return pluginCategoryQString; - -} - -int QgsDelimitedTextPlugin::type() -{ - return QgisPlugin::UI; -} -//method defined in interface -void QgsDelimitedTextPlugin::help() -{ - //implement me! -} - -/* - * Initialize the GUI interface for the plugin - */ -void QgsDelimitedTextPlugin::initGui() -{ - // Create the action for tool - myQActionPointer = new QAction( QIcon(), tr( "&Add Delimited Text Layer" ), this ); - setCurrentTheme( "" ); - myQActionPointer->setWhatsThis( tr( "Add a delimited text file as a map layer. " - "The file must have a header row containing the field names. " - "The file must either contain X and Y fields with coordinates in decimal units or a WKT field." ) ); - // Connect the action to the run - connect( myQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) ); - // Add the icon to the toolbar - qGisInterface->layerToolBar()->addAction( myQActionPointer ); - qGisInterface->insertAddLayerAction( myQActionPointer ); - // this is called when the icon theme is changed - connect( qGisInterface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) ); -} - -// Slot called when the buffer menu item is activated -void QgsDelimitedTextPlugin::run() -{ - // show the DelimitedText dialog - QDialog *dlg = dynamic_cast( QgsProviderRegistry::instance()->selectWidget( QString( "delimitedtext" ), qGisInterface->mainWindow() ) ); - if ( !dlg ) - { - QMessageBox::warning( qGisInterface->mainWindow(), tr( "Delimited Text" ), tr( "Cannot get Delimited Text select dialog from provider." ) ); - return; - } - //listen for when the layer has been made so we can draw it - connect( dlg, SIGNAL( addVectorLayer( QString, QString, QString ) ), - this, SLOT( addVectorLayer( QString, QString, QString ) ) ); - - dlg->exec(); - delete dlg; -} - -//!add a vector layer - intended to respond to signal -//sent by dialog when it as finished -void QgsDelimitedTextPlugin::addVectorLayer( QString thePathNameQString, - QString theBaseNameQString, QString theProviderQString ) -{ - qGisInterface->addVectorLayer( thePathNameQString, - theBaseNameQString, theProviderQString ); -} - -// Unload the plugin by cleaning up the GUI -void QgsDelimitedTextPlugin::unload() -{ - // remove the GUI - qGisInterface->layerToolBar()->removeAction( myQActionPointer ); - qGisInterface->removeAddLayerAction( myQActionPointer ); - delete myQActionPointer; -} - -//! Set icons to the current theme -void QgsDelimitedTextPlugin::setCurrentTheme( QString theThemeName ) -{ - Q_UNUSED( theThemeName ); - QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/delimited_text.png"; - QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/delimited_text.png"; - QString myQrcPath = ":/delimited_text.png"; - if ( QFile::exists( myCurThemePath ) ) - { - myQActionPointer->setIcon( QIcon( myCurThemePath ) ); - } - else if ( QFile::exists( myDefThemePath ) ) - { - myQActionPointer->setIcon( QIcon( myDefThemePath ) ); - } - else if ( QFile::exists( myQrcPath ) ) - { - myQActionPointer->setIcon( QIcon( myQrcPath ) ); - } - else - { - myQActionPointer->setIcon( QIcon() ); - } -} - -/** - * Required extern functions needed for every plugin - * These functions can be called prior to creating an instance - * of the plugin class - */ -// Class factory to return a new instance of the plugin class -QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer ) -{ - return new QgsDelimitedTextPlugin( theQgisInterfacePointer ); -} - -// Return the name of the plugin - note that we do not user class members as -// the class may not yet be insantiated when this method is called. -QGISEXTERN QString name() -{ - return QString( QObject::tr( "Add Delimited Text Layer" ) ); -} - -// Return the description -QGISEXTERN QString description() -{ - return description_; -} - -// Return the category -QGISEXTERN QString category() -{ - return category_; -} - -// Return the type (either UI or MapLayer plugin) -QGISEXTERN int type() -{ - return QgisPlugin::UI; -} - -// Return the version number for the plugin -QGISEXTERN QString version() -{ - return pluginVersion; -} - -QGISEXTERN QString icon() -{ - return icon_; -} - -// Delete ourself -QGISEXTERN void unload( QgisPlugin * theQgsDelimitedTextPluginPointer ) -{ - delete theQgsDelimitedTextPluginPointer; -} diff --git a/src/plugins/delimited_text/qgsdelimitedtextplugin.h b/src/plugins/delimited_text/qgsdelimitedtextplugin.h deleted file mode 100644 index a473db7bc7d..00000000000 --- a/src/plugins/delimited_text/qgsdelimitedtextplugin.h +++ /dev/null @@ -1,97 +0,0 @@ -/*************************************************************************** - qgsdelimitedtextplugin.h - Functions: - ------------------- - begin : Jan 21, 2004 - copyright : (C) 2004 by Tim Sutton - email : tim@linfiniti.com - - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#ifndef PLUGIN -#define PLUGIN -#include - -#include "../qgisplugin.h" - -class QgisInterface; -class QAction; - -/** -* \class QgsDelimitedTextPlugin -* \brief Delimited text plugin for QGIS -* -*/ -class QgsDelimitedTextPlugin: public QObject, public QgisPlugin -{ - Q_OBJECT public: - /** - * Constructor for a plugin. The QgisInterface pointer is passed by - * QGIS when it attempts to instantiate the plugin. - * @param qI Pointer to the QgisInterface object - */ - QgsDelimitedTextPlugin( QgisInterface * ); - /** - * Virtual function to return the name of the plugin. The name will be used when presenting a list - * of installable plugins to the user - */ - virtual QString name(); - /** - * Virtual function to return the version of the plugin. - */ - virtual QString version(); - /** - * Virtual function to return a description of the plugins functions - */ - virtual QString description(); - /** - * Virtual function to return a plugin category - */ - virtual QString category(); - /** - * Return the plugin type - */ - virtual int type(); - //! Destructor - virtual ~ QgsDelimitedTextPlugin(); - public slots: - //! init the gui - virtual void initGui(); - //! Show the dialog box - void run(); - //! Add a vector layer given vectorLayerPath, baseName, providerKey (i.e. delimitedtext) - void addVectorLayer( QString, QString, QString ); - //! unload the plugin - void unload(); - //! show the help document - void help(); - //! update the plugins theme when the app tells us its theme is changed - void setCurrentTheme( QString theThemeName ); - private: - - - //! Name of the plugin - QString pluginNameQString; - //! Version - QString pluginVersionQString; - //! Descrption of the plugin - QString pluginDescriptionQString; - //! Category of the plugin - QString pluginCategoryQString; - //! Plugin type as defined in Plugin::PLUGINTYPE - int pluginType; - //! Pointer to the QGIS interface object - QgisInterface *qGisInterface; - //! Pointer to the QAction object used in the menu and toolbar - QAction *myQActionPointer; -}; - -#endif diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index 7df2fa8cc9d..c7393f6ace0 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -17,7 +17,7 @@ 0 0 1050 - 21 + 23 @@ -160,6 +160,7 @@ + @@ -287,6 +288,7 @@ + @@ -2074,6 +2076,18 @@ Acts on currently active editable layer Need Support? + + + + :/images/themes/default/mActionAddDelimitedTextLayer.png:/images/themes/default/mActionAddDelimitedTextLayer.png + + + Add Delimited Text Layer... + + + Add Delimited Text Layer + +