QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgsexpressionaddfunctionfiledialog.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsexpressionaddfunctionfiledialog.cpp
3
---------------------
4
begin : May 2024
5
copyright : (C) 2024 by Germán Carrillo
6
email : german at opengis dot ch
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgsexpressionaddfunctionfiledialog.h
"
17
18
#include "
qgshelp.h
"
19
20
#include <QPushButton>
21
#include <QStandardItemModel>
22
#include <QString>
23
24
#include "moc_qgsexpressionaddfunctionfiledialog.cpp"
25
26
using namespace
Qt::StringLiterals;
27
28
QgsExpressionAddFunctionFileDialog::QgsExpressionAddFunctionFileDialog
(
bool
enableProjectFunctions, QWidget *parent )
29
: QDialog( parent )
30
{
31
setupUi(
this
);
32
cboFileOptions->addItem( tr(
"Function file"
) );
33
cboFileOptions->addItem( tr(
"Project functions"
), u
"project"
_s );
34
35
// Disable project functions (they should be created only once)
36
if
( !enableProjectFunctions )
37
{
38
QStandardItem *item = qobject_cast<QStandardItemModel *>( cboFileOptions->model() )->item( 1 );
39
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
40
}
41
42
connect( cboFileOptions, qOverload<int>( &QComboBox::currentIndexChanged ),
this
, &QgsExpressionAddFunctionFileDialog::cboFileOptions_currentIndexChanged );
43
connect( txtNewFileName, &QLineEdit::textChanged,
this
, [
this
](
const
QString & ) { updateOkButtonStatus(); } );
44
connect( buttonBox, &QDialogButtonBox::helpRequested,
this
, [] {
QgsHelp::openHelp
( u
"expressions/expression.html#function-editor"
_s ); } );
45
46
updateOkButtonStatus();
47
}
48
49
void
QgsExpressionAddFunctionFileDialog::cboFileOptions_currentIndexChanged(
int
)
50
{
51
bool
projectSelected = cboFileOptions->currentData() ==
"project"
_L1;
52
lblNewFileName->setVisible( !projectSelected );
53
txtNewFileName->setVisible( !projectSelected );
54
updateOkButtonStatus();
55
}
56
57
void
QgsExpressionAddFunctionFileDialog::updateOkButtonStatus()
58
{
59
QPushButton *okBtn = buttonBox->button( QDialogButtonBox::StandardButton::Ok );
60
okBtn->setEnabled(
true
);
61
62
if
( cboFileOptions->currentData() !=
"project"
_L1 )
63
{
64
okBtn->setEnabled( !txtNewFileName->text().trimmed().isEmpty() );
65
}
66
}
67
68
bool
QgsExpressionAddFunctionFileDialog::createProjectFunctions
()
const
69
{
70
return
cboFileOptions->currentData() ==
"project"
_L1;
71
}
72
73
QString
QgsExpressionAddFunctionFileDialog::fileName
()
74
{
75
return
txtNewFileName->text().trimmed();
76
}
QgsExpressionAddFunctionFileDialog::QgsExpressionAddFunctionFileDialog
QgsExpressionAddFunctionFileDialog(bool enableProjectFunctions, QWidget *parent)
Creates a QgsExpressionAddFunctionFileDialog to create function files or to set the current project a...
Definition
qgsexpressionaddfunctionfiledialog.cpp:28
QgsExpressionAddFunctionFileDialog::fileName
QString fileName()
Returns the new file name.
Definition
qgsexpressionaddfunctionfiledialog.cpp:73
QgsExpressionAddFunctionFileDialog::createProjectFunctions
bool createProjectFunctions() const
Returns whether user has selected to create project functions.
Definition
qgsexpressionaddfunctionfiledialog.cpp:68
QgsHelp::openHelp
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition
qgshelp.cpp:41
qgsexpressionaddfunctionfiledialog.h
qgshelp.h
Generated on
for QGIS API Documentation by
1.17.0