QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 #include <QPushButton>
21 
23  QDialog( parent, fl ),
24  mWidgetMode( widgetMode )
25 {
26 }
27 
29 {
30  return mWidgetMode;
31 }
32 
34 {
35  return mBrowserModel;
36 }
37 
38 void QgsAbstractDataSourceWidget::setupButtons( QDialogButtonBox *buttonBox )
39 {
40  buttonBox->setStandardButtons( QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Help );
41 #ifdef Q_OS_MACX
42  buttonBox->setStyleSheet( "* { button-layout: 2 }" );
43 #endif
44  mAddButton = buttonBox->button( QDialogButtonBox::Apply );
45  mAddButton->setText( tr( "&Add" ) );
46  mAddButton->setToolTip( tr( "Add selected layers to map" ) );
47  mAddButton->setEnabled( false );
48  connect( mAddButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::addButtonClicked );
49  connect( this, &QgsAbstractDataSourceWidget::enableButtons, mAddButton, &QPushButton::setEnabled );
50 
51  QPushButton *closeButton = buttonBox->button( QDialogButtonBox::Close );
52  closeButton->setToolTip( tr( "Close this dialog without adding any layer" ) );
53  connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::reject );
54 }
55 
57 {
58  mBrowserModel = model;
59 }
60 
62 {
63 }
64 
66 {
67 }
qgsabstractdatasourcewidget.h
QgsAbstractDataSourceWidget::addButtonClicked
virtual void addButtonClicked()
Triggered when the add button is clicked, the add layer signal is emitted Concrete classes should imp...
Definition: qgsabstractdatasourcewidget.cpp:61
QgsProviderRegistry::WidgetMode
WidgetMode
Different ways a source select dialog can be used.
Definition: qgsproviderregistry.h:70
QgsAbstractDataSourceWidget::enableButtons
void enableButtons(bool enable)
Emitted when the ok/add buttons should be enabled/disabled.
QgsAbstractDataSourceWidget::QgsAbstractDataSourceWidget
QgsAbstractDataSourceWidget(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode=QgsProviderRegistry::WidgetMode::None)
Constructor.
Definition: qgsabstractdatasourcewidget.cpp:22
QgsAbstractDataSourceWidget::setupButtons
void setupButtons(QDialogButtonBox *buttonBox)
Connect the ok and apply/add buttons to the slots.
Definition: qgsabstractdatasourcewidget.cpp:38
QgsAbstractDataSourceWidget::setBrowserModel
virtual void setBrowserModel(QgsBrowserModel *model)
Sets a browser model to use with the widget.
Definition: qgsabstractdatasourcewidget.cpp:56
QgsAbstractDataSourceWidget::widgetMode
QgsProviderRegistry::WidgetMode widgetMode() const
Returns the widget mode.
Definition: qgsabstractdatasourcewidget.cpp:28
QgsAbstractDataSourceWidget::reset
virtual void reset()
Called when this source select widget is being shown in a "new and clean" dialog.
Definition: qgsabstractdatasourcewidget.cpp:65
QgsAbstractDataSourceWidget::browserModel
QgsBrowserModel * browserModel()
Returns the associated browser model (may be nullptr).
Definition: qgsabstractdatasourcewidget.cpp:33
QgsBrowserModel
A model for showing available data sources and other items in a structured tree.
Definition: qgsbrowsermodel.h:52