Skip to content

Commit

Permalink
some changes in attribute form properties and source data properties
Browse files Browse the repository at this point in the history
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 2c0d518
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 177 deletions.
9 changes: 0 additions & 9 deletions src/app/qgsattributerelationedit.h
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/app/qgsattributesforminitcode.cpp
@@ -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"
Expand All @@ -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" ) );
Expand Down
14 changes: 0 additions & 14 deletions src/app/qgsattributesforminitcode.h
Expand Up @@ -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"

Expand Down
60 changes: 35 additions & 25 deletions src/app/qgsattributesformproperties.cpp
@@ -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"
Expand Down Expand Up @@ -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 );
}


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

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

void QgsAttributesFormProperties::initAvailableWidgetsTree()
Expand Down Expand Up @@ -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 ));
Expand All @@ -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()
Expand All @@ -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() );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -571,7 +600,7 @@ void QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged( int
}
}

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

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

}


void QgsAttributesFormProperties::pbnSelectEditForm_clicked()
{
QgsSettings myQSettings;
Expand Down Expand Up @@ -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 );
Expand Down
7 changes: 4 additions & 3 deletions src/app/qgsattributesformproperties.h
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
};


Expand Down
17 changes: 2 additions & 15 deletions src/app/qgsattributetypedialog.cpp
Expand Up @@ -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();
Expand Down
7 changes: 1 addition & 6 deletions src/app/qgsattributetypedialog.h
Expand Up @@ -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
*/
Expand Down
55 changes: 49 additions & 6 deletions src/app/qgssourcefieldsproperties.cpp
@@ -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 )
Expand Down Expand Up @@ -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() ) ) );
Expand All @@ -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 );
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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();
Expand All @@ -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 ||
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -630,6 +630,7 @@ void QgsVectorLayerProperties::apply()
mFieldsPropertiesDialog->apply();
// has to be done then mSourceFieldsPropertiesDialog->apply();
mAttributesFormPropertiesDialog->apply();
mSourceFieldsPropertiesDialog->apply();

if ( mLayer->renderer() )
{
Expand Down

0 comments on commit 2c0d518

Please sign in to comment.