-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[needs-doc] Auxiliary layers can be created from the auxiliary storag…
…e tab
- Loading branch information
1 parent
a550a32
commit 37783f7
Showing
6 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*************************************************************************** | ||
qgsnewauxiliarylayerdialog.cpp - description | ||
------------------- | ||
begin : Aug 28, 2017 | ||
copyright : (C) 2017 by Paul Blottiere | ||
email : paul.blottiere@oslandia.com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsnewauxiliarylayerdialog.h" | ||
#include "qgsproject.h" | ||
#include "qgsauxiliarystorage.h" | ||
|
||
#include <QMessageBox> | ||
|
||
QgsNewAuxiliaryLayerDialog::QgsNewAuxiliaryLayerDialog( QgsVectorLayer *layer, QWidget *parent ) | ||
: QDialog( parent ) | ||
, mLayer( layer ) | ||
{ | ||
setupUi( this ); | ||
|
||
Q_FOREACH ( const QgsField &field, mLayer->fields() ) | ||
comboBox->addItem( field.name() ); | ||
} | ||
|
||
void QgsNewAuxiliaryLayerDialog::accept() | ||
{ | ||
const int idx = mLayer->fields().lookupField( comboBox->currentText() ); | ||
|
||
if ( idx >= 0 ) | ||
{ | ||
const QgsField field = mLayer->fields().field( idx ); | ||
QgsAuxiliaryLayer *alayer = QgsProject::instance()->auxiliaryStorage()->createAuxiliaryLayer( field, mLayer ); | ||
|
||
if ( alayer ) | ||
{ | ||
mLayer->setAuxiliaryLayer( alayer ); | ||
} | ||
} | ||
|
||
QDialog::accept(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*************************************************************************** | ||
qgsnewauxiliarylayerdialog.h - description | ||
------------------- | ||
begin : Aug 28, 2017 | ||
copyright : (C) 2017 by Paul Blottiere | ||
email : paul.blottiere@oslandia.com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSNEWAUXILIARYLAYERDIALOG_H | ||
#define QGSNEWAUXILIARYLAYERDIALOG_H | ||
|
||
#include "ui_qgsnewauxiliarylayerdialogbase.h" | ||
#include "qgsguiutils.h" | ||
#include "qgis_app.h" | ||
#include "qgsvectorlayer.h" | ||
|
||
/** | ||
* \ingroup app | ||
* | ||
* \brief A dialog to create a new auxiliary layer | ||
* | ||
* \since QGIS 3.0 | ||
*/ | ||
class APP_EXPORT QgsNewAuxiliaryLayerDialog: public QDialog, private Ui::QgsNewAuxiliaryLayerDialogBase | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* \param layer The vector layer for which the auxiliary layer has to be created | ||
* \param parent Parent window | ||
*/ | ||
QgsNewAuxiliaryLayerDialog( QgsVectorLayer *layer, QWidget *parent = nullptr ); | ||
|
||
private: | ||
void accept() override; | ||
|
||
QgsVectorLayer *mLayer; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>QgsNewAuxiliaryLayerDialogBase</class> | ||
<widget class="QDialog" name="QgsNewAuxiliaryLayerDialogBase"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>139</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Auxiliary storage : choose primary key</string> | ||
</property> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>50</x> | ||
<y>100</y> | ||
<width>341</width> | ||
<height>32</height> | ||
</rect> | ||
</property> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
<widget class="QWidget" name="verticalLayoutWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>10</x> | ||
<y>10</y> | ||
<width>381</width> | ||
<height>81</height> | ||
</rect> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>Select the primary key to use for joining with internal data storage</string> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QComboBox" name="comboBox"/> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>QgsNewAuxiliaryLayerDialogBase</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>QgsNewAuxiliaryLayerDialogBase</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |