QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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
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
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
30 : QDialog( parent )
31 , mLayer( layer )
32{
33 setupUi( 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
47{
48 const int idx = mLayer->fields().lookupField( comboBox->currentText() );
49
50 if ( idx >= 0 )
51 {
52 const QgsField field = mLayer->fields().field( idx );
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}
Allows managing the auxiliary storage for a vector layer.
QString errorString() const
Returns the underlying error string describing potential errors happening in saveAs().
QgsAuxiliaryLayer * createAuxiliaryLayer(const QgsField &field, QgsVectorLayer *layer) const
Creates an auxiliary layer for a vector layer.
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:54
Container of fields for a vector layer.
Definition qgsfields.h:46
bool isEmpty
Definition qgsfields.h:49
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:221
QgsNewAuxiliaryLayerDialog(QgsVectorLayer *layer, QWidget *parent=nullptr)
Constructor.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsAuxiliaryStorage * auxiliaryStorage() const
Returns the current const auxiliary storage.
Represents a vector layer which manages a vector based dataset.