Skip to content

Commit

Permalink
[addlayerbutton] More embeddable dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jun 2, 2017
1 parent b31f05c commit 143e0c6
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 34 deletions.
7 changes: 4 additions & 3 deletions src/gui/qgsowssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include <QNetworkRequest>
#include <QNetworkReply>

QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent, Qt::WindowFlags fl, bool managerMode, bool embeddedMode )
QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent, Qt::WindowFlags fl, bool embeddedMode, bool managerMode )
: QDialog( parent, fl )
, mService( service )
, mManagerMode( managerMode )
Expand All @@ -65,12 +65,13 @@ QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent,

if ( mEmbeddedMode )
{
mDialogButtonBox->button( QDialogButtonBox::Close )->hide();
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
}


setWindowTitle( tr( "Add Layer(s) from a %1 Server" ).arg( service ) );

mAddButton = mDialogButtonBox->button( QDialogButtonBox::Apply );
mAddButton = buttonBox->button( QDialogButtonBox::Apply );
mAddButton->setText( tr( "&Add" ) );
mAddButton->setToolTip( tr( "Add selected layers to map" ) );
mAddButton->setEnabled( false );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsowssourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, public Ui::QgsOWSSourceSel
};

//! Constructor
QgsOWSSourceSelect( const QString &service, QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, bool managerMode = false, bool embeddedMode = false );
QgsOWSSourceSelect( const QString &service, QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, bool embeddedMode = false, bool managerMode = false );

~QgsOWSSourceSelect();

Expand Down
3 changes: 2 additions & 1 deletion src/providers/db2/qgsdb2sourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ QgsDb2SourceSelect::QgsDb2SourceSelect( QWidget *parent, Qt::WindowFlags fl, boo

if ( mEmbeddedMode )
{
buttonBox->button( QDialogButtonBox::Close )->hide();
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
mHoldDialogOpen->hide();
}

mAddButton = new QPushButton( tr( "&Add" ) );
Expand Down
3 changes: 2 additions & 1 deletion src/providers/mssql/qgsmssqlsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ QgsMssqlSourceSelect::QgsMssqlSourceSelect( QWidget *parent, Qt::WindowFlags fl,

if ( mEmbeddedMode )
{
buttonBox->button( QDialogButtonBox::Close )->hide();
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
mHoldDialogOpen->hide();
}

mAddButton = new QPushButton( tr( "&Add" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialitedataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void QgsSLRootItem::createDatabase()
QGISEXTERN QgsSpatiaLiteSourceSelect *selectWidget( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode )
{
// TODO: this should be somewhere else
return new QgsSpatiaLiteSourceSelect( parent, fl, false );
return new QgsSpatiaLiteSourceSelect( parent, fl, embeddedMode );
}

QGISEXTERN int dataCapabilities()
Expand Down
10 changes: 3 additions & 7 deletions src/providers/spatialite/qgsspatialitesourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget *parent, Qt::Windo
{
setupUi( this );

if ( embeddedMode )
{
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
}

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/SpatiaLiteSourceSelect/geometry" ) ).toByteArray() );
mHoldDialogOpen->setChecked( settings.value( QStringLiteral( "Windows/SpatiaLiteSourceSelect/HoldDialogOpen" ), false ).toBool() );
Expand All @@ -73,7 +68,8 @@ QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget *parent, Qt::Windo

if ( mEmbeddedMode )
{
buttonBox->button( QDialogButtonBox::Close )->hide();
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
mHoldDialogOpen->hide();
}
else
{
Expand Down Expand Up @@ -423,7 +419,7 @@ void QgsSpatiaLiteSourceSelect::addTables()
else
{
emit addDatabaseLayers( m_selectedTables, QStringLiteral( "spatialite" ) );
if ( !mHoldDialogOpen->isChecked() )
if ( !( mEmbeddedMode || mHoldDialogOpen->isChecked() ) )
{
accept();
}
Expand Down
1 change: 1 addition & 0 deletions src/providers/wcs/qgswcssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
QgsWCSSourceSelect::QgsWCSSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode, bool managerMode )
: QgsOWSSourceSelect( QStringLiteral( "WCS" ), parent, fl, embeddedMode, managerMode )
{

// Hide irrelevant widgets
mWMSGroupBox->hide();
mLayersTab->layout()->removeWidget( mWMSGroupBox );
Expand Down
26 changes: 25 additions & 1 deletion src/ui/qgsdatasourcemanagerdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,34 @@
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsDataSourceManagerDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>504</x>
<y>578</y>
</hint>
<hint type="destinationlabel">
<x>504</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
</ui>
73 changes: 54 additions & 19 deletions src/ui/qgsowssourceselectbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<class>QgsOWSSourceSelectBase</class>
<widget class="QDialog" name="QgsOWSSourceSelectBase">
<property name="geometry">
<rect>:
<rect>
<x>0</x>
<y>0</y>
<width>743</width>
Expand All @@ -15,8 +15,7 @@
</property>
<property name="windowIcon">
<iconset>
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
Expand All @@ -26,7 +25,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QDialogButtonBox" name="mDialogButtonBox">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
Expand Down Expand Up @@ -68,12 +67,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="mConnectButton">
<property name="toolTip">
<string>Connect to selected service</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Connect to selected service</string>
</property>
<property name="text">
<string>C&amp;onnect</string>
</property>
Expand All @@ -91,25 +90,25 @@
</item>
<item>
<widget class="QPushButton" name="mEditButton">
<property name="toolTip">
<string>Edit selected service connection</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Edit selected service connection</string>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mDeleteButton">
<property name="toolTip">
<string>Remove connection to selected service</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Remove connection to selected service</string>
</property>
<property name="text">
<string>Remove</string>
</property>
Expand Down Expand Up @@ -202,7 +201,16 @@
<item>
<widget class="QWidget" name="mTimeWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -231,7 +239,16 @@
<item>
<widget class="QWidget" name="mCRSWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -273,7 +290,16 @@
<item>
<widget class="QWidget" name="mFormatWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -350,7 +376,16 @@
<item>
<widget class="QWidget" name="mCacheWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -585,12 +620,12 @@ Always network: always load from network and do not check if the cache has a val
<tabstop>mSearchButton</tabstop>
<tabstop>mSearchTableWidget</tabstop>
<tabstop>mSearchAddButton</tabstop>
<tabstop>mDialogButtonBox</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>mDialogButtonBox</sender>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsOWSSourceSelectBase</receiver>
<slot>reject()</slot>
Expand Down

0 comments on commit 143e0c6

Please sign in to comment.