QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
qgsnewauxiliarylayerdialog.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsnewauxiliarylayerdialog.cpp - description
3
-------------------
4
begin : Aug 28, 2017
5
copyright : (C) 2017 by Paul Blottiere
6
email : paul.blottiere@oslandia.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
#include "
qgsnewauxiliarylayerdialog.h
"
19
20
#include "
qgsauxiliarystorage.h
"
21
#include "
qgsgui.h
"
22
#include "
qgsproject.h
"
23
24
#include <QMessageBox>
25
#include <QPushButton>
26
27
#include "moc_qgsnewauxiliarylayerdialog.cpp"
28
29
QgsNewAuxiliaryLayerDialog::QgsNewAuxiliaryLayerDialog
(
QgsVectorLayer
*layer, QWidget *parent )
30
: QDialog( parent )
31
,
mLayer
( layer )
32
{
33
setupUi(
this
);
34
QgsGui::enableAutoGeometryRestore
(
this
);
35
36
const
QgsFields
fields =
mLayer
->fields();
37
for
(
const
QgsField
&field : fields )
38
comboBox->addItem( field.name() );
39
40
if
( fields.
isEmpty
() )
41
{
42
buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true
);
43
}
44
}
45
46
void
QgsNewAuxiliaryLayerDialog::accept
()
47
{
48
const
int
idx =
mLayer
->fields().lookupField( comboBox->currentText() );
49
50
if
( idx >= 0 )
51
{
52
const
QgsField
field =
mLayer
->fields().field( idx );
53
QgsAuxiliaryLayer
*alayer =
QgsProject::instance
()->
auxiliaryStorage
()->
createAuxiliaryLayer
( field,
mLayer
);
54
55
if
( alayer )
56
{
57
mLayer
->setAuxiliaryLayer( alayer );
58
}
59
else
60
{
61
QDialog::close();
62
const
QString errMsg =
QgsProject::instance
()->
auxiliaryStorage
()->
errorString
();
63
QMessageBox::critical(
this
, tr(
"New Auxiliary Layer"
), errMsg );
64
return
;
65
}
66
}
67
68
QDialog::accept();
69
}
QgsAuxiliaryLayer
Allows managing the auxiliary storage for a vector layer.
Definition
qgsauxiliarystorage.h:65
QgsAuxiliaryStorage::errorString
QString errorString() const
Returns the underlying error string describing potential errors happening in saveAs().
QgsAuxiliaryStorage::createAuxiliaryLayer
QgsAuxiliaryLayer * createAuxiliaryLayer(const QgsField &field, QgsVectorLayer *layer) const
Creates an auxiliary layer for a vector layer.
QgsField
Encapsulate a field in an attribute table or data source.
Definition
qgsfield.h:56
QgsFields
Container of fields for a vector layer.
Definition
qgsfields.h:45
QgsFields::isEmpty
bool isEmpty
Definition
qgsfields.h:48
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
QgsNewAuxiliaryLayerDialog::accept
void accept() override
Definition
qgsnewauxiliarylayerdialog.cpp:46
QgsNewAuxiliaryLayerDialog::mLayer
QgsVectorLayer * mLayer
Definition
qgsnewauxiliarylayerdialog.h:48
QgsNewAuxiliaryLayerDialog::QgsNewAuxiliaryLayerDialog
QgsNewAuxiliaryLayerDialog(QgsVectorLayer *layer, QWidget *parent=nullptr)
Constructor.
Definition
qgsnewauxiliarylayerdialog.cpp:29
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition
qgsproject.cpp:490
QgsProject::auxiliaryStorage
const QgsAuxiliaryStorage * auxiliaryStorage() const
Returns the current const auxiliary storage.
Definition
qgsproject.cpp:5178
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
qgsauxiliarystorage.h
qgsgui.h
qgsnewauxiliarylayerdialog.h
qgsproject.h
Generated on
for QGIS API Documentation by
1.17.0