QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
processing
models
qgsmodelgroupboxdefinitionwidget.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsmodelgroupboxdefinitionwidget.cpp
3
------------------------------------------
4
begin : March 2020
5
copyright : (C) 2020 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
19
#include "
qgsmodelgroupboxdefinitionwidget.h
"
20
21
#include "
qgscolorbutton.h
"
22
#include "
qgsgui.h
"
23
24
#include <QDialogButtonBox>
25
#include <QLabel>
26
#include <QString>
27
#include <QTextEdit>
28
#include <QVBoxLayout>
29
30
#include "moc_qgsmodelgroupboxdefinitionwidget.cpp"
31
32
using namespace
Qt::StringLiterals;
33
34
//
35
// QgsModelGroupBoxDefinitionPanelWidget
36
//
37
38
QgsModelGroupBoxDefinitionPanelWidget::QgsModelGroupBoxDefinitionPanelWidget
(
const
QgsProcessingModelGroupBox &box, QWidget *parent )
39
:
QgsProcessingModelConfigWidget
( parent )
40
, mBox( box )
41
{
42
QVBoxLayout *commentLayout =
new
QVBoxLayout();
43
commentLayout->setContentsMargins( 0, 0, 0, 0 );
44
commentLayout->addWidget(
new
QLabel( tr(
"Title"
) ) );
45
mCommentEdit =
new
QTextEdit();
46
mCommentEdit->setAcceptRichText(
false
);
47
mCommentEdit->setText( box.description() );
48
commentLayout->addWidget( mCommentEdit, 1 );
49
50
QHBoxLayout *hl =
new
QHBoxLayout();
51
hl->setContentsMargins( 0, 0, 0, 0 );
52
hl->addWidget(
new
QLabel( tr(
"Color"
) ) );
53
mCommentColorButton =
new
QgsColorButton
();
54
mCommentColorButton->setAllowOpacity(
true
);
55
mCommentColorButton->setWindowTitle( tr(
"Comment Color"
) );
56
mCommentColorButton->setShowNull(
true
, tr(
"Default"
) );
57
58
if
( box.color().isValid() )
59
mCommentColorButton->setColor( box.color() );
60
else
61
mCommentColorButton->setToNull();
62
63
hl->addWidget( mCommentColorButton );
64
commentLayout->addLayout( hl );
65
66
setLayout( commentLayout );
67
68
setPanelTitle
( tr(
"Group Box Properties"
) );
69
setObjectName( u
"QgsModelGroupBoxDefinitionPanelWidget"
_s );
70
71
mCommentEdit->setFocus();
72
mCommentEdit->selectAll();
73
74
connect( mCommentEdit, &QTextEdit::textChanged,
this
, &
QgsPanelWidget::changed
);
75
connect( mCommentColorButton, &
QgsColorButton::colorChanged
,
this
, &
QgsPanelWidget::changed
);
76
}
77
78
QgsProcessingModelGroupBox
QgsModelGroupBoxDefinitionPanelWidget::groupBox
()
const
79
{
80
QgsProcessingModelGroupBox box = mBox;
81
box.setColor( mCommentColorButton->isNull() ? QColor() : mCommentColorButton->color() );
82
box.setDescription( mCommentEdit->toPlainText() );
83
return
box;
84
}
85
86
//
87
// QgsModelGroupBoxDefinitionDialog
88
//
89
90
QgsModelGroupBoxDefinitionDialog::QgsModelGroupBoxDefinitionDialog
(
const
QgsProcessingModelGroupBox &box, QWidget *parent )
91
: QDialog( parent )
92
{
93
QVBoxLayout *commentLayout =
new
QVBoxLayout();
94
mWidget =
new
QgsModelGroupBoxDefinitionPanelWidget
( box );
95
commentLayout->addWidget( mWidget, 1 );
96
97
QDialogButtonBox *bbox =
new
QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
98
connect( bbox, &QDialogButtonBox::accepted,
this
, &QgsModelGroupBoxDefinitionDialog::accept );
99
connect( bbox, &QDialogButtonBox::rejected,
this
, &QgsModelGroupBoxDefinitionDialog::reject );
100
101
commentLayout->addWidget( bbox );
102
setLayout( commentLayout );
103
setWindowTitle( tr(
"Group Box Properties"
) );
104
setObjectName( u
"QgsModelGroupBoxDefinitionWidget"
_s );
105
QgsGui::enableAutoGeometryRestore
(
this
);
106
107
connect( mWidget, &
QgsPanelWidget::panelAccepted
,
this
, &QgsModelGroupBoxDefinitionDialog::reject );
108
}
109
110
QgsProcessingModelGroupBox
QgsModelGroupBoxDefinitionDialog::groupBox
()
const
111
{
112
return
mWidget->groupBox();
113
}
QgsColorButton
A cross platform button subclass for selecting colors.
Definition
qgscolorbutton.h:39
QgsColorButton::colorChanged
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
QgsGui::enableAutoGeometryRestore
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition
qgsgui.cpp:225
QgsModelGroupBoxDefinitionDialog::QgsModelGroupBoxDefinitionDialog
QgsModelGroupBoxDefinitionDialog(const QgsProcessingModelGroupBox &box, QWidget *parent=nullptr)
Constructor for QgsModelGroupBoxDefinitionWidget, for the specified group box.
Definition
qgsmodelgroupboxdefinitionwidget.cpp:90
QgsModelGroupBoxDefinitionDialog::groupBox
QgsProcessingModelGroupBox groupBox() const
Returns a new instance of the group box, using the current settings defined in the dialog.
Definition
qgsmodelgroupboxdefinitionwidget.cpp:110
QgsModelGroupBoxDefinitionPanelWidget
A widget which allows users to specify the properties of a model group box.
Definition
qgsmodelgroupboxdefinitionwidget.h:46
QgsModelGroupBoxDefinitionPanelWidget::QgsModelGroupBoxDefinitionPanelWidget
QgsModelGroupBoxDefinitionPanelWidget(const QgsProcessingModelGroupBox &box, QWidget *parent=nullptr)
Constructor for QgsModelGroupBoxDefinitionPanelWidget, for the specified group box.
Definition
qgsmodelgroupboxdefinitionwidget.cpp:38
QgsModelGroupBoxDefinitionPanelWidget::groupBox
QgsProcessingModelGroupBox groupBox() const
Returns a new instance of the group box, using the current settings defined in the dialog.
Definition
qgsmodelgroupboxdefinitionwidget.cpp:78
QgsPanelWidget::changed
void changed()
Emitted when the widget state changes.
QgsPanelWidget::panelAccepted
void panelAccepted(QgsPanelWidget *panel)
Emitted when the panel is accepted by the user.
QgsPanelWidget::setPanelTitle
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
Definition
qgspanelwidget.h:45
QgsProcessingModelConfigWidget::QgsProcessingModelConfigWidget
QgsProcessingModelConfigWidget(QWidget *parent=nullptr)
Constructor for QgsProcessingModelConfigWidget().
Definition
qgsmodeldesignerconfigwidget.cpp:26
qgscolorbutton.h
qgsgui.h
qgsmodelgroupboxdefinitionwidget.h
Generated on
for QGIS API Documentation by
1.17.0