Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
375 additions
and 15 deletions.
- +11 −1 python/core/qgsauxiliarystorage.sip
- +15 −2 python/core/qgsproperty.sip
- +13 −3 src/app/qgsvectorlayerproperties.cpp
- +28 −2 src/core/qgsauxiliarystorage.cpp
- +10 −1 src/core/qgsauxiliarystorage.h
- +4 −2 src/core/qgsproperty.cpp
- +15 −2 src/core/qgsproperty.h
- +2 −0 src/gui/CMakeLists.txt
- +82 −0 src/gui/qgsnewauxiliaryfielddialog.cpp
- +63 −0 src/gui/qgsnewauxiliaryfielddialog.h
- +11 −2 src/gui/symbology/qgssymbollayerwidget.cpp
- +111 −0 src/ui/qgsnewauxiliaryfielddialogbase.ui
- +10 −0 src/ui/qgsvectorlayerpropertiesbase.ui
@@ -0,0 +1,82 @@ | ||
/*************************************************************************** | ||
qgsnewauxiliaryfielddialog.cpp - description | ||
------------------- | ||
begin : Sept 05, 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 "qgsnewauxiliaryfielddialog.h" | ||
#include "qgsauxiliarystorage.h" | ||
|
||
#include <QMessageBox> | ||
|
||
QgsNewAuxiliaryFieldDialog::QgsNewAuxiliaryFieldDialog( const QgsPropertyDefinition &def, QgsVectorLayer *layer, bool nameOnly, QWidget *parent ) | ||
: QDialog( parent ) | ||
, mLayer( layer ) | ||
, mNameOnly( nameOnly ) | ||
, mPropertyDefinition( def ) | ||
{ | ||
setupUi( this ); | ||
|
||
mType->addItem( tr( "String" ) ); | ||
mType->addItem( tr( "Numeric" ) ); | ||
mType->addItem( tr( "Boolean" ) ); | ||
|
||
switch ( def.dataType() ) | ||
{ | ||
case QgsPropertyDefinition::DataTypeString: | ||
mType->setCurrentIndex( mType->findText( tr( "String" ) ) ); | ||
break; | ||
case QgsPropertyDefinition::DataTypeNumeric: | ||
mType->setCurrentIndex( mType->findText( tr( "Numeric" ) ) ); | ||
break; | ||
case QgsPropertyDefinition::DataTypeBoolean: | ||
mType->setCurrentIndex( mType->findText( tr( "Boolean" ) ) ); | ||
break; | ||
} | ||
|
||
if ( mNameOnly ) | ||
mType->setEnabled( false ); | ||
} | ||
|
||
void QgsNewAuxiliaryFieldDialog::accept() | ||
{ | ||
QgsPropertyDefinition def = mPropertyDefinition; | ||
def.setComment( mName->text() ); | ||
|
||
QString fieldName = QgsAuxiliaryField::nameFromProperty( def, true ); | ||
const int idx = mLayer->fields().lookupField( fieldName ); | ||
if ( idx >= 0 ) | ||
{ | ||
const QString title = tr( "Invalid name" ); | ||
const QString msg = tr( "Auxiliary field '%1' already exists" ).arg( fieldName ); | ||
QMessageBox::critical( this, title, msg, QMessageBox::Ok ); | ||
} | ||
else if ( def.comment().isEmpty() ) | ||
{ | ||
const QString title = tr( "Invalid name" ); | ||
const QString msg = tr( "Name is a mandatory parameter" ); | ||
QMessageBox::critical( this, title, msg, QMessageBox::Ok ); | ||
} | ||
else | ||
{ | ||
if ( mLayer->auxiliaryLayer()->addAuxiliaryField( def ) ) | ||
mPropertyDefinition = def; | ||
QDialog::accept(); | ||
} | ||
} | ||
|
||
QgsPropertyDefinition QgsNewAuxiliaryFieldDialog::propertyDefinition() const | ||
{ | ||
return mPropertyDefinition; | ||
} |
Oops, something went wrong.