-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a custom name for symbol layers in property definition
- Loading branch information
1 parent
4fa3400
commit 4e10a11
Showing
13 changed files
with
375 additions
and
15 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
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
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
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,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.