QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsabstractdatasourcewidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractdatasourcewidget.cpp - base class for source selector widgets
3 -------------------
4 begin : 10 July 2017
5 original : (C) 2017 by Alessandro Pasotti
6 email : apasotti at boundlessgeo dot com
7
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
20
21#include <QPushButton>
22
23#include "moc_qgsabstractdatasourcewidget.cpp"
24
26 : QDialog( parent, fl ), mWidgetMode( widgetMode )
27{
28}
29
34
39
40void QgsAbstractDataSourceWidget::setupButtons( QDialogButtonBox *buttonBox )
41{
42 buttonBox->setStandardButtons( QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Help );
43#ifdef Q_OS_MACOS
44 buttonBox->setStyleSheet( "* { button-layout: 2 }" );
45#endif
46 mAddButton = buttonBox->button( QDialogButtonBox::Apply );
47 mAddButton->setText( tr( "&Add" ) );
48 mAddButton->setToolTip( tr( "Add selected layers to map" ) );
49 mAddButton->setEnabled( false );
50 connect( mAddButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::addButtonClicked );
51 connect( this, &QgsAbstractDataSourceWidget::enableButtons, mAddButton, &QPushButton::setEnabled );
52
53 QPushButton *closeButton = buttonBox->button( QDialogButtonBox::Close );
54 closeButton->setToolTip( tr( "Close this dialog without adding any layer" ) );
55 connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::reject );
56}
57
59{
60 mBrowserModel = model;
61}
62
66
70
72{
73 Q_UNUSED( uri );
74 return false;
75}
void enableButtons(bool enable)
Emitted when the ok/add buttons should be enabled/disabled.
QgsBrowserModel * browserModel()
Returns the associated browser model (may be nullptr).
void setupButtons(QDialogButtonBox *buttonBox)
Connect the ok and apply/add buttons to the slots.
QgsAbstractDataSourceWidget(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode=QgsProviderRegistry::WidgetMode::Standalone)
Constructor.
virtual void addButtonClicked()
Triggered when the add button is clicked, the add layer signal is emitted Concrete classes should imp...
virtual void setBrowserModel(QgsBrowserModel *model)
Sets a browser model to use with the widget.
QgsProviderRegistry::WidgetMode widgetMode() const
Returns the widget mode.
virtual bool configureFromUri(const QString &uri)
Configure the widget from a layer uri by selecting the layer path or connection options.
virtual void reset()
Called when this source select widget is being shown in a "new and clean" dialog.
A model for showing available data sources and other items in a structured tree.
WidgetMode
Different ways a source select dialog can be used.