Skip to content
Permalink
Browse files

Merge pull request #4629 from boundlessgeo/unified-button

Add layer button
  • Loading branch information
elpaso committed Jun 2, 2017
2 parents 78c3423 + 7a2ce49 commit 106723956526297422c5b2cfa7ea201250d010a4
Showing with 2,562 additions and 1,578 deletions.
  1. +1 −0 images/images.qrc
  2. +67 −0 images/themes/default/mActionDataSourceManager.svg
  3. +10 −1 python/core/qgsproviderregistry.sip
  4. +1 −1 python/gui/qgsowssourceselect.sip
  5. +18 −13 scripts/mkuidefaults.py
  6. +38 −0 src/app/CMakeLists.txt
  7. +25 −9 src/app/ogr/qgsopenvectorlayerdialog.cpp
  8. +10 −1 src/app/ogr/qgsopenvectorlayerdialog.h
  9. +61 −168 src/app/qgisapp.cpp
  10. +44 −47 src/app/qgisapp.h
  11. +4 −4 src/app/qgisappinterface.cpp
  12. +227 −0 src/app/qgsdatasourcemanagerdialog.cpp
  13. +96 −0 src/app/qgsdatasourcemanagerdialog.h
  14. +2 −0 src/app/qgsoptions.cpp
  15. +112 −70 src/app/ui_defaults.h
  16. +3 −3 src/core/qgsproviderregistry.cpp
  17. +12 −1 src/core/qgsproviderregistry.h
  18. +2 −2 src/gui/qgsoptionsdialogbase.cpp
  19. +7 −7 src/gui/qgsowssourceselect.cpp
  20. +3 −2 src/gui/qgsowssourceselect.h
  21. +5 −1 src/gui/qgssourceselectdialog.cpp
  22. +1 −0 src/gui/qgssourceselectdialog.h
  23. +1 −1 src/providers/arcgisrest/qgsafsdataitems.cpp
  24. +2 −2 src/providers/arcgisrest/qgsafsproviderextern.cpp
  25. +3 −3 src/providers/arcgisrest/qgsafssourceselect.cpp
  26. +3 −2 src/providers/arcgisrest/qgsafssourceselect.h
  27. +2 −1 src/providers/arcgisrest/qgsamsdataitems.cpp
  28. +2 −2 src/providers/arcgisrest/qgsamsproviderextern.cpp
  29. +3 −3 src/providers/arcgisrest/qgsamssourceselect.cpp
  30. +2 −1 src/providers/arcgisrest/qgsamssourceselect.h
  31. +2 −2 src/providers/db2/qgsdb2provider.cpp
  32. +6 −6 src/providers/db2/qgsdb2sourceselect.cpp
  33. +3 −2 src/providers/db2/qgsdb2sourceselect.h
  34. +3 −2 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  35. +10 −6 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  36. +3 −1 src/providers/delimitedtext/qgsdelimitedtextsourceselect.h
  37. +1 −1 src/providers/mssql/qgsmssqldataitems.cpp
  38. +2 −2 src/providers/mssql/qgsmssqlprovider.cpp
  39. +6 −6 src/providers/mssql/qgsmssqlsourceselect.cpp
  40. +3 −2 src/providers/mssql/qgsmssqlsourceselect.h
  41. +2 −2 src/providers/oracle/qgsoracleprovider.cpp
  42. +3 −3 src/providers/oracle/qgsoraclesourceselect.cpp
  43. +2 −2 src/providers/oracle/qgsoraclesourceselect.h
  44. +3 −2 src/providers/ows/qgsowsdataitems.cpp
  45. +8 −7 src/providers/postgres/qgspgsourceselect.cpp
  46. +3 −5 src/providers/postgres/qgspgsourceselect.h
  47. +1 −1 src/providers/postgres/qgspostgresdataitems.cpp
  48. +2 −2 src/providers/postgres/qgspostgresprovider.cpp
  49. +3 −3 src/providers/spatialite/qgsspatialitedataitems.cpp
  50. +12 −11 src/providers/spatialite/qgsspatialitesourceselect.cpp
  51. +3 −1 src/providers/spatialite/qgsspatialitesourceselect.h
  52. +20 −14 src/providers/virtual/qgsembeddedlayerselectdialog.cpp
  53. +6 −0 src/providers/virtual/qgsembeddedlayerselectdialog.h
  54. +126 −74 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  55. +6 −1 src/providers/virtual/qgsvirtuallayersourceselect.h
  56. +1 −19 src/providers/virtual/qgsvirtuallayersourceselectbase.ui
  57. +3 −3 src/providers/wcs/qgswcsdataitems.cpp
  58. +3 −2 src/providers/wcs/qgswcssourceselect.cpp
  59. +2 −2 src/providers/wcs/qgswcssourceselect.h
  60. +3 −3 src/providers/wfs/qgswfsdataitems.cpp
  61. +9 −4 src/providers/wfs/qgswfssourceselect.cpp
  62. +4 −1 src/providers/wfs/qgswfssourceselect.h
  63. +3 −3 src/providers/wms/qgswmsdataitems.cpp
  64. +7 −7 src/providers/wms/qgswmssourceselect.cpp
  65. +3 −3 src/providers/wms/qgswmssourceselect.h
  66. +35 −0 src/ui/qgisapp.ui
  67. +163 −0 src/ui/qgsdatasourcemanagerdialog.ui
  68. +1,125 −898 src/ui/qgsdelimitedtextsourceselectbase.ui
  69. +108 −85 src/ui/qgsopenvectorlayerdialogbase.ui
  70. +33 −26 src/ui/qgsoptionsbase.ui
  71. +54 −19 src/ui/qgsowssourceselectbase.ui
@@ -102,6 +102,7 @@
<file>themes/default/lockedGray.svg</file>
<file>themes/default/mAction.svg</file>
<file>themes/default/mActionAdd.svg</file>
<file>themes/default/mActionDataSourceManager.svg</file>
<file>themes/default/mActionAddLayer.svg</file>
<file>themes/default/mActionAddAllToOverview.svg</file>
<file>themes/default/mActionAddArrow.svg</file>
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg id="svg2" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" style="enable-background:new;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title id="title4552">GIS icon theme 0.2</title>
<defs id="defs4">
<linearGradient id="linearGradient3632" y2="10" gradientUnits="userSpaceOnUse" y1="10" x2="13" x1="9">
<stop id="stop3628" stop-color="#82a0b4" offset="0"/>
<stop id="stop3630" stop-color="#82a0b4" stop-opacity="0" offset="1"/>
</linearGradient>
</defs>
<metadata id="metadata7">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/"/>
<dc:title>GIS icon theme 0.2</dc:title>
<dc:creator>
<cc:Agent>
<dc:title>Robert Szczepanek</dc:title>
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title>Robert Szczepanek</dc:title>
</cc:Agent>
</dc:rights>
<dc:subject>
<rdf:Bag>
<rdf:li>GIS</rdf:li>
<rdf:li>icon</rdf:li>
<rdf:li>layer</rdf:li>
<rdf:li>vector</rdf:li>
<rdf:li>raster</rdf:li>
<rdf:li>GRASS</rdf:li>
<rdf:li>QGIS</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:date>2017-06-01</dc:date>
<dc:language>en</dc:language>
<dc:coverage>GIS, icon</dc:coverage>
<dc:description>http://robert.szczepanek.pl</dc:description>
</cc:Work>
<cc:License rdf:about="http://creativecommons.org/licenses/by-sa/3.0/">
<cc:permits rdf:resource="http://creativecommons.org/ns#Reproduction"/>
<cc:permits rdf:resource="http://creativecommons.org/ns#Distribution"/>
<cc:requires rdf:resource="http://creativecommons.org/ns#Notice"/>
<cc:requires rdf:resource="http://creativecommons.org/ns#Attribution"/>
<cc:permits rdf:resource="http://creativecommons.org/ns#DerivativeWorks"/>
<cc:requires rdf:resource="http://creativecommons.org/ns#ShareAlike"/>
</cc:License>
</rdf:RDF>
</metadata>
<g id="layer56">
<path id="rect4012" stroke-linejoin="miter" d="m2.5,2.5,19,0,0,18-19,0z" stroke="#969696" stroke-linecap="square" stroke-miterlimit="4" stroke-width="1" fill="#e6e6e6"/>
<path id="path4020" stroke-linejoin="miter" d="m0.5,7.5,0,15,8,0" stroke="#969696" stroke-linecap="square" stroke-width="1px" fill="none"/>
<rect id="rect3616" opacity="0.9" height="0" width="4" y="7" x="9" fill="url(#linearGradient3632)"/>
</g>
<g id="layer11">
<g id="layer18">
<rect id="rect3563" ry="2.0115" height="10" width="10" stroke-miterlimit="4" y="14" x="14" stroke-width="0" fill="#5a8c5a"/>
<path id="path3807" stroke-linejoin="round" style="enable-background:accumulate;" d="m16,19,6,0" fill-rule="evenodd" stroke-dashoffset="0" stroke="#e6e6e6" stroke-linecap="round" stroke-miterlimit="4" stroke-dasharray="none" stroke-width="2" fill="#fcffff"/>
<path id="path3809" stroke-linejoin="round" style="enable-background:accumulate;" d="m19,22,0-6" fill-rule="evenodd" stroke-dashoffset="0" stroke="#e6e6e6" stroke-linecap="round" stroke-miterlimit="4" stroke-dasharray="none" stroke-width="2" fill="#fcffff"/>
<path id="path6992" opacity="0.3" style="enable-background:new;" d="m15,19,8,0v-2c0-2-0.5-2-4-2s-4,0-4,2v2z" fill-rule="evenodd" fill="#fcffff"/>
</g>
</g>
</svg>
@@ -35,6 +35,13 @@ class QgsProviderRegistry
%End
public:

enum WidgetMode
{
None,
Embedded,
Manager,
};

static QgsProviderRegistry *instance( const QString &pluginPath = QString::null );
%Docstring
Means of accessing canonical single instance
@@ -88,7 +95,9 @@ Set library directory where to search for plugins
%End

QWidget *createSelectionWidget( const QString &providerKey,
QWidget *parent = 0, Qt::WindowFlags fl = Qt::WindowFlags() );
QWidget *parent = 0,
Qt::WindowFlags fl = Qt::WindowFlags(),
QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
%Docstring
Returns a new widget for selecting layers from a provider.
Either the ``parent`` widget must be set or the caller becomes
@@ -23,7 +23,7 @@ class QgsOWSSourceSelect : QDialog
};

//! Constructor
QgsOWSSourceSelect( const QString &service, QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags, bool managerMode = false, bool embeddedMode = false );
QgsOWSSourceSelect( const QString &service, QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None);
//! Destructor
~QgsOWSSourceSelect();

@@ -37,35 +37,40 @@ def chunks(l, n):

s = QSettings()

ba = s.value("/UI/geometry").toByteArray()
ba = bytes(s.value("/UI/geometry"))

f = open("src/app/ui_defaults.h", "w")

f.write("#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n\nstatic const unsigned char defaultUIgeometry[] =\n{\n")

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))

f.write("};\n\nstatic const unsigned char defaultUIstate[] =\n{\n")

ba = s.value("/UI/state").toByteArray()
ba = bytes(s.value("/UI/state"))

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))

ba = s.value("/Composer/geometry").toByteArray()
try:
ba = bytes(s.value("/Composer/geometry"))

f.write("};\n\nstatic const unsigned char defaultComposerUIgeometry[] =\n{\n")
f.write("};\n\nstatic const unsigned char defaultComposerUIgeometry[] =\n{\n")

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))

f.write("};\n\nstatic const unsigned char defaultComposerUIstate[] =\n{\n")
for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))
except TypeError as ex:
pass

ba = s.value("/ComposerUI/state").toByteArray()
try:
ba = bytes(s.value("/ComposerUI/state"))
f.write("};\n\nstatic const unsigned char defaultComposerUIstate[] =\n{\n")

for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
for chunk in chunks(ba, 16):
f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % x, chunk)))
except TypeError as ex:
pass

f.write("};\n\n#endif // UI_DEFAULTS_H\n")

@@ -61,6 +61,7 @@ SET(QGIS_APP_SRCS
qgsversioninfo.cpp
qgswelcomepageitemsmodel.cpp
qgswelcomepage.cpp
qgsdatasourcemanagerdialog.cpp

qgsmaptooladdfeature.cpp
qgsmaptooladdpart.cpp
@@ -247,6 +248,7 @@ SET (QGIS_APP_MOC_HDRS
qgsversioninfo.h
qgswelcomepageitemsmodel.h
qgswelcomepage.h
qgsdatasourcemanagerdialog.h

qgsmaptooladdfeature.h
qgsmaptoolannotation.h
@@ -531,6 +533,42 @@ INCLUDE_DIRECTORIES(SYSTEM
${QT_QTUITOOLS_INCLUDE_DIR}
${QSCINTILLA_INCLUDE_DIR}
${QEXTSERIALPORT_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES(
../analysis/raster
../analysis/openstreetmap
../core
../core/annotations
../core/auth
../core/gps
../core/composer
../core/dxf
../core/geometry
../core/metadata
../core/layertree
../core/providers/memory
../core/raster
../core/scalebar
../core/symbology-ng
../gui
../gui/symbology-ng
../gui/attributetable
../gui/auth
../gui/raster
../gui/editorwidgets
../gui/editorwidgets/core
../gui/layertree
../plugins
../python
gps
ogr
openstreetmap
dwg
dwg/libdxfrw
${CMAKE_SOURCE_DIR}/src/native
${CMAKE_BINARY_DIR}/src/native
)
INCLUDE_DIRECTORIES(SYSTEM
${SPATIALITE_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
${PROJ_INCLUDE_DIR}
@@ -31,11 +31,24 @@
#include "qgscontexthelp.h"
#include "qgsapplication.h"

QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget *parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QDialog( parent, fl ),
mWidgetMode( widgetMode ),
mAddButton( nullptr )
{
setupUi( this );

if ( mWidgetMode != QgsProviderRegistry::WidgetMode::None )
{
this->layout()->setSizeConstraint( QLayout::SetNoConstraint );
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Cancel ) );
}

mAddButton = new QPushButton( tr( "&Add" ) );
// TODO: enable/disable according to valid selection
mAddButton->setEnabled( true );
buttonBox->addButton( mAddButton, QDialogButtonBox::AcceptRole );

cmbDatabaseTypes->blockSignals( true );
cmbConnections->blockSignals( true );
radioSrcFile->setChecked( true );
@@ -49,7 +62,7 @@ QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget *parent, Qt::WindowF

restoreGeometry( settings.value( QStringLiteral( "Windows/OpenVectorLayer/geometry" ) ).toByteArray() );

// The specified decoding is added if not existing alread, and then set current.
// The specified decoding is added if not existing already, and then set current.
// This should select it.
int encindex = cmbEncodings->findText( enc );
if ( encindex < 0 )
@@ -274,7 +287,7 @@ void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()
if ( !selected.isEmpty() )
{
inputSrcDataset->setText( selected.join( QStringLiteral( ";" ) ) );
buttonBox->button( QDialogButtonBox::Open )->setFocus();
mAddButton->setFocus();
}
}
else if ( radioSrcDirectory->isChecked() )
@@ -382,7 +395,14 @@ void QgsOpenVectorLayerDialog::accept()
// Save the used encoding
settings.setValue( QStringLiteral( "UI/encoding" ), encoding() );

QDialog::accept();
if ( mWidgetMode == QgsProviderRegistry::WidgetMode::None )
{
QDialog::accept();
}
else if ( ! mDataSources.isEmpty( ) )
{
emit addVectorLayers( mDataSources, encoding(), dataSourceType( ) );
}
}

void QgsOpenVectorLayerDialog::on_radioSrcFile_toggled( bool checked )
@@ -394,7 +414,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcFile_toggled( bool checked )
fileGroupBox->show();
dbGroupBox->hide();
protocolGroupBox->hide();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "file" );
}
}
@@ -408,7 +427,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcDirectory_toggled( bool checked )
fileGroupBox->show();
dbGroupBox->hide();
protocolGroupBox->hide();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "directory" );
}
}
@@ -422,7 +440,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcDatabase_toggled( bool checked )
protocolGroupBox->hide();
dbGroupBox->show();
layout()->blockSignals( false );
layout()->setSizeConstraint( QLayout::SetFixedSize );
setConnectionTypeListPosition();
populateConnectionList();
setConnectionListPosition();
@@ -437,7 +454,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcProtocol_toggled( bool checked )
fileGroupBox->hide();
dbGroupBox->hide();
protocolGroupBox->show();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "protocol" );
}
}
@@ -22,6 +22,7 @@
#include <ui_qgsopenvectorlayerdialogbase.h>
#include <QDialog>
#include "qgshelp.h"
#include "qgsproviderregistry.h"

/**
* Class for a dialog to select the type and source for ogr vectors, supports
@@ -32,7 +33,7 @@ class QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenVectorLayerD
Q_OBJECT

public:
QgsOpenVectorLayerDialog( QWidget *parent = nullptr, Qt::WindowFlags fl = 0 );
QgsOpenVectorLayerDialog( QWidget *parent = nullptr, Qt::WindowFlags fl = 0, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
~QgsOpenVectorLayerDialog();
//! Opens a dialog to select a file datasource*/
QStringList openFile();
@@ -53,6 +54,10 @@ class QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenVectorLayerD
QString mEnc;
//! Stores the datasource type
QString mDataSourceType;
//! Embedded dialog (do not call parent's accept) and emit signals
QgsProviderRegistry::WidgetMode mWidgetMode = QgsProviderRegistry::WidgetMode::None;
//! Add layer button
QPushButton *mAddButton = nullptr;

private slots:
//! Opens the create connection dialog to build a new connection
@@ -85,6 +90,10 @@ class QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenVectorLayerD
void on_cmbDatabaseTypes_currentIndexChanged( const QString &text );
void on_cmbConnections_currentIndexChanged( const QString &text );
void on_buttonBox_helpRequested() { QgsHelp::openHelp( QStringLiteral( "working_with_vector/supported_data.html#loading-a-layer-from-a-file" ) ); }

signals:
//! Emitted when in embedded mode
void addVectorLayers( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType );
};

#endif // QGSOPENVECTORDIALOG_H

0 comments on commit 1067239

Please sign in to comment.
You can’t perform that action at this time.