/src/gui/providers/ogr/qgsogrsourceselect.h

https://github.com/ricardogsilva/Quantum-GIS · C Header · 126 lines · 59 code · 15 blank · 52 comment · 0 complexity · 0fd3211d1124d571bb3bc361b1a38d04 MD5 · raw file

  1. /***************************************************************************
  2. qgsogrsourceselect.h
  3. Dialog to select the type and source for ogr vectors, supports
  4. file, database, directory and protocol sources.
  5. -------------------
  6. ---------------------
  7. Adapted to source select:
  8. date : Aug 5, 2017
  9. copyright : (C) 2017 by Alessandro Pasotti
  10. email : apasotti at itopen dot it
  11. Original work done by:
  12. begin : Mon Jan 2 2009
  13. copyright : (C) 2009 by Godofredo Contreras Nava
  14. email : frdcn at hotmail.com
  15. ***************************************************************************/
  16. /***************************************************************************
  17. * *
  18. * This program is free software; you can redistribute it and/or modify *
  19. * it under the terms of the GNU General Public License as published by *
  20. * the Free Software Foundation; either version 2 of the License, or *
  21. * (at your option) any later version. *
  22. * *
  23. ***************************************************************************/
  24. #ifndef QGSOGRSOURCESELECT_H
  25. #define QGSOGRSOURCESELECT_H
  26. #include <QDialog>
  27. #include <vector>
  28. #include "ui_qgsogrsourceselectbase.h"
  29. #include "qgshelp.h"
  30. #include "qgsproviderregistry.h"
  31. #include "qgsabstractdatasourcewidget.h"
  32. #include "qgis_gui.h"
  33. #include "qgis_sip.h"
  34. ///@cond PRIVATE
  35. #define SIP_NO_FILE
  36. /**
  37. * Class for a dialog to select the type and source for ogr vectors, supports
  38. * file, database, directory and protocol sources.
  39. * \note not available in Python bindings
  40. */
  41. class QgsOgrSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsOgrSourceSelectBase
  42. {
  43. Q_OBJECT
  44. public:
  45. QgsOgrSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
  46. //! Opens a dialog to select a file datasource
  47. QStringList openFile();
  48. //! Opens a dialog to select a directory datasource
  49. QString openDirectory();
  50. //! Returns a list of selected datasources
  51. QStringList dataSources();
  52. //! Returns the encoding selected for user
  53. QString encoding();
  54. //! Returns the connection type
  55. QString dataSourceType();
  56. //! Returns whether the protocol is a cloud type
  57. bool isProtocolCloudType();
  58. private:
  59. //! Stores the file vector filters
  60. QString mVectorFileFilter;
  61. //! Stores the selected datasources
  62. QStringList mDataSources;
  63. //! Stores the user selected encoding
  64. QString mEnc;
  65. //! Stores the datasource type
  66. QString mDataSourceType;
  67. //! Embedded dialog (do not call parent's accept) and emit signals
  68. QgsProviderRegistry::WidgetMode mWidgetMode = QgsProviderRegistry::WidgetMode::None;
  69. public slots:
  70. void addButtonClicked() override;
  71. private slots:
  72. //! Opens the create connection dialog to build a new connection
  73. void addNewConnection();
  74. //! Opens a dialog to edit an existing connection
  75. void editConnection();
  76. //! Deletes the selected connection
  77. void deleteConnection();
  78. //! Populate the connection list combo box
  79. void populateConnectionList();
  80. //! Sets the actual position in connection list
  81. void setConnectionListPosition();
  82. //! Sets the actual position in types connection list
  83. void setConnectionTypeListPosition();
  84. //! Sets the selected connection type
  85. void setSelectedConnectionType();
  86. //! Sets the selected connection
  87. void setSelectedConnection();
  88. //! Sets protocol-related widget visibility
  89. void setProtocolWidgetsVisibility();
  90. void radioSrcFile_toggled( bool checked );
  91. void radioSrcDirectory_toggled( bool checked );
  92. void radioSrcDatabase_toggled( bool checked );
  93. void radioSrcProtocol_toggled( bool checked );
  94. void btnNew_clicked();
  95. void btnEdit_clicked();
  96. void btnDelete_clicked();
  97. void cmbDatabaseTypes_currentIndexChanged( const QString &text );
  98. void cmbConnections_currentIndexChanged( const QString &text );
  99. void cmbProtocolTypes_currentIndexChanged( const QString &text );
  100. void showHelp();
  101. private:
  102. void computeDataSources( bool interactive );
  103. void clearOpenOptions();
  104. void fillOpenOptions();
  105. std::vector<QWidget *> mOpenOptionsWidgets;
  106. QString mVectorPath;
  107. };
  108. ///@endcond
  109. #endif // QGSOGRSOURCESELECT_H