Skip to content
Permalink
Browse files

some changes in attribute form properties and source data properties

changed style of layout, initcode and suppress-combo
display read only comment
fixed saving of wfs
improved layout
some tooltips
  • Loading branch information
signedav committed Nov 6, 2017
1 parent d21d45b commit 2c0d5188d5d082791e91972f9fbaf8d0faf85da9
@@ -25,15 +25,6 @@
#include "qgis_app.h"
#include <QWidget>

/*
namespace Ui {
class QgsAttributeRelationEdit;
}
class QgsAttributeRelationEdit : public QWidget
{
*/

class APP_EXPORT QgsAttributeRelationEdit: public QWidget, private Ui::QgsAttributeRelationEdit
{
Q_OBJECT
@@ -1,3 +1,18 @@
/***************************************************************************
qgsattributesforminitcode.cpp
---------------------
begin : October 2017
copyright : (C) 2017 by David Signer
email : david at opengis dot ch
***************************************************************************
* *
* 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 "qgsattributesforminitcode.h"
#include "ui_qgsattributesforminitcode.h"
#include "qgssettings.h"
@@ -9,7 +24,7 @@ QgsAttributesFormInitCode::QgsAttributesFormInitCode()
setupUi( this );

// Init function stuff
mInitCodeSourceComboBox->addItem( tr( "" ) );
mInitCodeSourceComboBox->addItem( QString() );
mInitCodeSourceComboBox->addItem( tr( "Load from external file" ) );
mInitCodeSourceComboBox->addItem( tr( "Provide code in this dialog" ) );
mInitCodeSourceComboBox->addItem( tr( "Load from the environment" ) );
@@ -15,20 +15,6 @@

#ifndef QGSATTRIBUTESFORMINITCODE_H
#define QGSATTRIBUTESFORMINITCODE_H
/***************************************************************************
qgsattributesforminitcode.h
---------------------
begin : October 2017
copyright : (C) 2017 by David Signer
email : david at opengis dot ch
***************************************************************************
* *
* 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 "ui_qgsattributesforminitcode.h"

@@ -1,3 +1,18 @@
/***************************************************************************
qgsattributesformproperties.cpp
---------------------
begin : August 2017
copyright : (C) 2017 by David Signer
email : david at opengis dot ch
***************************************************************************
* *
* 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 "qgsattributesformproperties.h"
#include "qgsattributetypedialog.h"
#include "qgsattributerelationedit.h"
@@ -47,7 +62,7 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
connect( mRemoveTabOrGroupButton, &QAbstractButton::clicked, this, &QgsAttributesFormProperties::removeTabOrGroupButton );
connect( mEditorLayoutComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged );
connect( pbnSelectEditForm, &QToolButton::clicked, this, &QgsAttributesFormProperties::pbnSelectEditForm_clicked );
connect( pBInitCode, &QPushButton::clicked, this, &QgsAttributesFormProperties::pBInitCode_clicked );
connect( mTbInitCode, &QPushButton::clicked, this, &QgsAttributesFormProperties::mTbInitCode_clicked );
}


@@ -64,8 +79,8 @@ void QgsAttributesFormProperties::init()
initLayoutConfig();
initInitPython();

mAttributeTypeDialog->setEnabled( false );
mAttributeRelationEdit->setEnabled( false );
//mAttributeTypeDialog->setEnabled( false );
//mAttributeRelationEdit->setEnabled( false );
}

void QgsAttributesFormProperties::initAvailableWidgetsTree()
@@ -97,6 +112,7 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
item->setData( 0, FieldConfigRole, cfg );
item->setData( 0, FieldNameRole, field.name() );
}
catitem->setExpanded( true );

/* stuff
itemData.setIcon(i, mLayer->fields().iconForField( i ));
@@ -119,8 +135,9 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()

QTreeWidgetItem *item = mAvailableWidgetsTree->addItem( catitem, itemData );
item->setData( 0, RelationConfigRole, cfg );
item->setData( 0, FieldNameRole, QStringLiteral( "%1" ).arg( relation.id() ) ); //relation.name() );
item->setData( 0, FieldNameRole, relation.id() );
}
catitem->setExpanded( true );
}

void QgsAttributesFormProperties::initFormLayoutTree()
@@ -138,6 +155,17 @@ void QgsAttributesFormProperties::initFormLayoutTree()
}
}


void QgsAttributesFormProperties::initSuppressCombo()
{
//mFormSuppressCmbBx->addItem( tr( "" ) );
//mFormSuppressCmbBx->addItem( tr( "Load from external file" ) );
//mFormSuppressCmbBx->addItem( tr( "Provide code in this dialog" ) );
//mFormSuppressCmbBx->addItem( tr( "Load from the environment" ) );
mFormSuppressCmbBx->setCurrentIndex( mLayer->editFormConfig().suppress() );


}
void QgsAttributesFormProperties::initLayoutConfig()
{
mEditorLayoutComboBox->setCurrentIndex( mLayer->editFormConfig().layout() );
@@ -194,9 +222,11 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
mAttributeTypeFrame->layout()->removeWidget( mAttributeTypeDialog );
delete mAttributeTypeDialog;


//
mAttributeTypeDialog = new QgsAttributeTypeDialog( mLayer, index, mAttributeTypeFrame );
mAttributeTypeDialog->setAlias( cfg.mAlias );
mAttributeTypeDialog->setComment( mLayer->fields().at( index ).comment() );
mAttributeTypeDialog->setFieldEditable( cfg.mEditable );
mAttributeTypeDialog->setLabelOnTop( cfg.mLabelOnTop );
mAttributeTypeDialog->setNotNull( cfg.mConstraints & QgsFieldConstraints::ConstraintNotNull );
@@ -239,7 +269,6 @@ void QgsAttributesFormProperties::storeAttributeTypeDialog()
cfg.mEditable = mAttributeTypeDialog->fieldEditable();
cfg.mLabelOnTop = mAttributeTypeDialog->labelOnTop();
cfg.mAlias = mAttributeTypeDialog->alias();
cfg.mComment = mAttributeTypeDialog->comment();

//confustion (will be removed): wir laden teilweise sachen einfach beim store anstelle des applys auf die mLayer - eingie Sachen laden wir auch vom layer anstatt über das cfg. wieso
QgsFieldConstraints constraints = mLayer->fields().at( mAttributeTypeDialog->fieldIdx() ).constraints();
@@ -571,7 +600,7 @@ void QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged( int
}
}

void QgsAttributesFormProperties::pBInitCode_clicked()
void QgsAttributesFormProperties::mTbInitCode_clicked()
{
QgsAttributesFormInitCode attributesFormInitCode;

@@ -590,7 +619,6 @@ void QgsAttributesFormProperties::pBInitCode_clicked()

}


void QgsAttributesFormProperties::pbnSelectEditForm_clicked()
{
QgsSettings myQSettings;
@@ -677,25 +705,7 @@ void QgsAttributesFormProperties::apply()
editFormConfig.setInitFilePath( mInitFilePath );
editFormConfig.setInitCode( mInitCode );

/*
Das heisst wir brauchen von Python-Dialog:
mInitCodeSource
mInitFunction
mInitFilePath
mInitCode
Das heisst, beim init lesen wir die alle...
// Init function configuration
editFormConfig.setInitCodeSource( ( QgsEditFormConfig::PythonInitCodeSource )mInitCodeSourceComboBox->currentIndex() );
editFormConfig.setInitFunction( mInitFunctionLineEdit->text() );
editFormConfig.setInitFilePath( mInitFilePathLineEdit->text() );
editFormConfig.setInitCode( mInitCodeEditorPython->text() );
*/

/*
editFormConfig.setSuppress( ( QgsEditFormConfig::FeatureFormSuppress )mFormSuppressCmbBx->currentIndex() );
*/


// relations
QTreeWidgetItem *relationContainer = mAvailableWidgetsTree->invisibleRootItem()->child( 1 );
@@ -190,8 +190,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
void initFormLayoutTree();
void initLayoutConfig();
void initInitPython();

QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree *tree );
void initSuppressCombo();

protected:
void updateButtons();
@@ -222,12 +221,14 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
QString mInitFilePath;
QString mInitCode;

QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree *tree );

private slots:
void addTabOrGroupButton();
void removeTabOrGroupButton();
void mEditorLayoutComboBox_currentIndexChanged( int index );
void pbnSelectEditForm_clicked();
void pBInitCode_clicked();
void mTbInitCode_clicked();
};


@@ -341,34 +341,21 @@ void QgsAttributeTypeDialog::setAlias( const QString &alias )
leAlias->setText( alias );
}

QString QgsAttributeTypeDialog::alias()
QString QgsAttributeTypeDialog::alias() const
{
return leAlias->text();
}

void QgsAttributeTypeDialog::setComment( const QString &comment )
{
leComment->setText( comment );
laComment->setText( comment );
}

QString QgsAttributeTypeDialog::comment()
{
return leComment->text();
}


void QgsAttributeTypeDialog::setLabelOnTop( bool onTop )
{
labelOnTopCheckBox->setChecked( onTop );
}

//removed selectionListWidget: void QgsAttributeTypeDialog::selectionListWidget_currentRowChanged( int index )
//removed selectionListWidget: {
//removed selectionListWidget: const QString editType = selectionListWidget->item( index )->data( Qt::UserRole ).toString();
//removed selectionListWidget:
//removed selectionListWidget: setEditorWidgetType( editType );
//removed selectionListWidget: }

void QgsAttributeTypeDialog::defaultExpressionChanged()
{
QString expression = mExpressionWidget->expression();
@@ -71,18 +71,13 @@ class APP_EXPORT QgsAttributeTypeDialog: public QWidget, private Ui::QgsAttribut
/**
* Getter for lable alias
*/
QString alias();
QString alias() const;

/**
* Setter for lable comment
*/
void setComment( const QString &comment );

/**
* Getter for lable comment
*/
QString comment();

/**
* Setter for checkbox for editable state of field
*/
@@ -1,3 +1,19 @@
/***************************************************************************
qgssourcefieldsproperties.cpp
---------------------
begin : July 2017
copyright : (C) 2017 by David Signer
email : david at opengis dot ch
***************************************************************************
* *
* 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 "qgssourcefieldsproperties.h"

QgsSourceFieldsProperties::QgsSourceFieldsProperties( QgsVectorLayer *layer, QWidget *parent )
@@ -185,6 +201,7 @@ void QgsSourceFieldsProperties::setRow( int row, int idx, const QgsField &field

mIndexedWidgets.insert( idx, mFieldsList->item( row, 0 ) );
mFieldsList->setItem( row, AttrNameCol, new QTableWidgetItem( field.name() ) );
mFieldsList->setItem( row, AttrAliasCol, new QTableWidgetItem( field.alias() ) );
mFieldsList->setItem( row, AttrTypeCol, new QTableWidgetItem( QVariant::typeToName( field.type() ) ) );
mFieldsList->setItem( row, AttrTypeNameCol, new QTableWidgetItem( field.typeName() ) );
mFieldsList->setItem( row, AttrLengthCol, new QTableWidgetItem( QString::number( field.length() ) ) );
@@ -211,22 +228,24 @@ void QgsSourceFieldsProperties::setRow( int row, int idx, const QgsField &field
QList<int> notEditableCols = QList<int>()
<< AttrIdCol
<< AttrNameCol
<< AttrAliasCol
<< AttrTypeCol
<< AttrTypeNameCol
<< AttrLengthCol
<< AttrPrecCol;
<< AttrPrecCol
<< AttrCommentCol;
Q_FOREACH ( int i, notEditableCols )
{
mFieldsList->item( row, i )->setFlags( mFieldsList->item( row, i )->flags() & ~Qt::ItemIsEditable );

if ( notEditableCols[i] == AttrAliasCol )
mFieldsList->item( row, i )->setToolTip( tr( "Edit alias in the Form config tab" ) );
}
bool canRenameFields = mLayer->isEditable() && ( mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::RenameAttributes ) && !mLayer->readOnly();
if ( canRenameFields )
mFieldsList->item( row, AttrNameCol )->setFlags( mFieldsList->item( row, AttrNameCol )->flags() | Qt::ItemIsEditable );
else
mFieldsList->item( row, AttrNameCol )->setFlags( mFieldsList->item( row, AttrNameCol )->flags() & ~Qt::ItemIsEditable );

//set the alias for the attribute
mFieldsList->setItem( row, AttrAliasCol, new QTableWidgetItem( field.alias() ) );

//published WMS/WFS attributes
QTableWidgetItem *wmsAttrItem = new QTableWidgetItem();
wmsAttrItem->setCheckState( mLayer->excludeAttributesWms().contains( field.name() ) ? Qt::Unchecked : Qt::Checked );
@@ -255,6 +274,27 @@ bool QgsSourceFieldsProperties::addAttribute( const QgsField &field )
}
}

void QgsSourceFieldsProperties::apply()
{
// Disabled: we deal with the configuration in the new tabs
QSet<QString> excludeAttributesWMS, excludeAttributesWFS;

for ( int i = 0; i < mFieldsList->rowCount(); i++ )
{
if ( mFieldsList->item( i, AttrWMSCol )->checkState() == Qt::Unchecked )
{
excludeAttributesWMS.insert( mFieldsList->item( i, AttrNameCol )->text() );
}
if ( mFieldsList->item( i, AttrWFSCol )->checkState() == Qt::Unchecked )
{
excludeAttributesWFS.insert( mFieldsList->item( i, AttrNameCol )->text() );
}
}

mLayer->setExcludeAttributesWms( excludeAttributesWMS );
mLayer->setExcludeAttributesWfs( excludeAttributesWFS );

}

//SLOTS

@@ -319,6 +359,7 @@ void QgsSourceFieldsProperties::calculateFieldClicked()

void QgsSourceFieldsProperties::attributesListCellChanged( int row, int column )
{
/* this is made read only
if ( column == AttrAliasCol && mLayer )
{
int idx = mFieldsList->item( row, AttrIdCol )->text().toInt();
@@ -343,7 +384,9 @@ void QgsSourceFieldsProperties::attributesListCellChanged( int row, int column )
}
}
}
else if ( column == AttrNameCol && mLayer && mLayer->isEditable() )
else
*/
if ( column == AttrNameCol && mLayer && mLayer->isEditable() )
{
QTableWidgetItem *nameItem = mFieldsList->item( row, column );
if ( !nameItem ||
@@ -630,6 +630,7 @@ void QgsVectorLayerProperties::apply()
mFieldsPropertiesDialog->apply();
// has to be done then mSourceFieldsPropertiesDialog->apply();
mAttributesFormPropertiesDialog->apply();
mSourceFieldsPropertiesDialog->apply();

if ( mLayer->renderer() )
{

0 comments on commit 2c0d518

Please sign in to comment.
You can’t perform that action at this time.