Skip to content

Commit 2c0d518

Browse files
committed
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
1 parent d21d45b commit 2c0d518

13 files changed

+282
-177
lines changed

src/app/qgsattributerelationedit.h

-9
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@
2525
#include "qgis_app.h"
2626
#include <QWidget>
2727

28-
/*
29-
namespace Ui {
30-
class QgsAttributeRelationEdit;
31-
}
32-
33-
class QgsAttributeRelationEdit : public QWidget
34-
{
35-
*/
36-
3728
class APP_EXPORT QgsAttributeRelationEdit: public QWidget, private Ui::QgsAttributeRelationEdit
3829
{
3930
Q_OBJECT

src/app/qgsattributesforminitcode.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/***************************************************************************
2+
qgsattributesforminitcode.cpp
3+
---------------------
4+
begin : October 2017
5+
copyright : (C) 2017 by David Signer
6+
email : david at opengis dot ch
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
116
#include "qgsattributesforminitcode.h"
217
#include "ui_qgsattributesforminitcode.h"
318
#include "qgssettings.h"
@@ -9,7 +24,7 @@ QgsAttributesFormInitCode::QgsAttributesFormInitCode()
924
setupUi( this );
1025

1126
// Init function stuff
12-
mInitCodeSourceComboBox->addItem( tr( "" ) );
27+
mInitCodeSourceComboBox->addItem( QString() );
1328
mInitCodeSourceComboBox->addItem( tr( "Load from external file" ) );
1429
mInitCodeSourceComboBox->addItem( tr( "Provide code in this dialog" ) );
1530
mInitCodeSourceComboBox->addItem( tr( "Load from the environment" ) );

src/app/qgsattributesforminitcode.h

-14
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@
1515

1616
#ifndef QGSATTRIBUTESFORMINITCODE_H
1717
#define QGSATTRIBUTESFORMINITCODE_H
18-
/***************************************************************************
19-
qgsattributesforminitcode.h
20-
---------------------
21-
begin : October 2017
22-
copyright : (C) 2017 by David Signer
23-
email : david at opengis dot ch
24-
***************************************************************************
25-
* *
26-
* This program is free software; you can redistribute it and/or modify *
27-
* it under the terms of the GNU General Public License as published by *
28-
* the Free Software Foundation; either version 2 of the License, or *
29-
* (at your option) any later version. *
30-
* *
31-
***************************************************************************/
3218

3319
#include "ui_qgsattributesforminitcode.h"
3420

src/app/qgsattributesformproperties.cpp

+35-25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/***************************************************************************
2+
qgsattributesformproperties.cpp
3+
---------------------
4+
begin : August 2017
5+
copyright : (C) 2017 by David Signer
6+
email : david at opengis dot ch
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
116
#include "qgsattributesformproperties.h"
217
#include "qgsattributetypedialog.h"
318
#include "qgsattributerelationedit.h"
@@ -47,7 +62,7 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
4762
connect( mRemoveTabOrGroupButton, &QAbstractButton::clicked, this, &QgsAttributesFormProperties::removeTabOrGroupButton );
4863
connect( mEditorLayoutComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged );
4964
connect( pbnSelectEditForm, &QToolButton::clicked, this, &QgsAttributesFormProperties::pbnSelectEditForm_clicked );
50-
connect( pBInitCode, &QPushButton::clicked, this, &QgsAttributesFormProperties::pBInitCode_clicked );
65+
connect( mTbInitCode, &QPushButton::clicked, this, &QgsAttributesFormProperties::mTbInitCode_clicked );
5166
}
5267

5368

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

67-
mAttributeTypeDialog->setEnabled( false );
68-
mAttributeRelationEdit->setEnabled( false );
82+
//mAttributeTypeDialog->setEnabled( false );
83+
//mAttributeRelationEdit->setEnabled( false );
6984
}
7085

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

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

120136
QTreeWidgetItem *item = mAvailableWidgetsTree->addItem( catitem, itemData );
121137
item->setData( 0, RelationConfigRole, cfg );
122-
item->setData( 0, FieldNameRole, QStringLiteral( "%1" ).arg( relation.id() ) ); //relation.name() );
138+
item->setData( 0, FieldNameRole, relation.id() );
123139
}
140+
catitem->setExpanded( true );
124141
}
125142

126143
void QgsAttributesFormProperties::initFormLayoutTree()
@@ -138,6 +155,17 @@ void QgsAttributesFormProperties::initFormLayoutTree()
138155
}
139156
}
140157

158+
159+
void QgsAttributesFormProperties::initSuppressCombo()
160+
{
161+
//mFormSuppressCmbBx->addItem( tr( "" ) );
162+
//mFormSuppressCmbBx->addItem( tr( "Load from external file" ) );
163+
//mFormSuppressCmbBx->addItem( tr( "Provide code in this dialog" ) );
164+
//mFormSuppressCmbBx->addItem( tr( "Load from the environment" ) );
165+
mFormSuppressCmbBx->setCurrentIndex( mLayer->editFormConfig().suppress() );
166+
167+
168+
}
141169
void QgsAttributesFormProperties::initLayoutConfig()
142170
{
143171
mEditorLayoutComboBox->setCurrentIndex( mLayer->editFormConfig().layout() );
@@ -194,9 +222,11 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
194222
mAttributeTypeFrame->layout()->removeWidget( mAttributeTypeDialog );
195223
delete mAttributeTypeDialog;
196224

225+
197226
//
198227
mAttributeTypeDialog = new QgsAttributeTypeDialog( mLayer, index, mAttributeTypeFrame );
199228
mAttributeTypeDialog->setAlias( cfg.mAlias );
229+
mAttributeTypeDialog->setComment( mLayer->fields().at( index ).comment() );
200230
mAttributeTypeDialog->setFieldEditable( cfg.mEditable );
201231
mAttributeTypeDialog->setLabelOnTop( cfg.mLabelOnTop );
202232
mAttributeTypeDialog->setNotNull( cfg.mConstraints & QgsFieldConstraints::ConstraintNotNull );
@@ -239,7 +269,6 @@ void QgsAttributesFormProperties::storeAttributeTypeDialog()
239269
cfg.mEditable = mAttributeTypeDialog->fieldEditable();
240270
cfg.mLabelOnTop = mAttributeTypeDialog->labelOnTop();
241271
cfg.mAlias = mAttributeTypeDialog->alias();
242-
cfg.mComment = mAttributeTypeDialog->comment();
243272

244273
//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
245274
QgsFieldConstraints constraints = mLayer->fields().at( mAttributeTypeDialog->fieldIdx() ).constraints();
@@ -571,7 +600,7 @@ void QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged( int
571600
}
572601
}
573602

574-
void QgsAttributesFormProperties::pBInitCode_clicked()
603+
void QgsAttributesFormProperties::mTbInitCode_clicked()
575604
{
576605
QgsAttributesFormInitCode attributesFormInitCode;
577606

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

591620
}
592621

593-
594622
void QgsAttributesFormProperties::pbnSelectEditForm_clicked()
595623
{
596624
QgsSettings myQSettings;
@@ -677,25 +705,7 @@ void QgsAttributesFormProperties::apply()
677705
editFormConfig.setInitFilePath( mInitFilePath );
678706
editFormConfig.setInitCode( mInitCode );
679707

680-
/*
681-
Das heisst wir brauchen von Python-Dialog:
682-
mInitCodeSource
683-
mInitFunction
684-
mInitFilePath
685-
mInitCode
686-
Das heisst, beim init lesen wir die alle...
687-
688-
// Init function configuration
689-
editFormConfig.setInitCodeSource( ( QgsEditFormConfig::PythonInitCodeSource )mInitCodeSourceComboBox->currentIndex() );
690-
editFormConfig.setInitFunction( mInitFunctionLineEdit->text() );
691-
editFormConfig.setInitFilePath( mInitFilePathLineEdit->text() );
692-
editFormConfig.setInitCode( mInitCodeEditorPython->text() );
693-
*/
694-
695-
/*
696708
editFormConfig.setSuppress( ( QgsEditFormConfig::FeatureFormSuppress )mFormSuppressCmbBx->currentIndex() );
697-
*/
698-
699709

700710
// relations
701711
QTreeWidgetItem *relationContainer = mAvailableWidgetsTree->invisibleRootItem()->child( 1 );

src/app/qgsattributesformproperties.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
190190
void initFormLayoutTree();
191191
void initLayoutConfig();
192192
void initInitPython();
193-
194-
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree *tree );
193+
void initSuppressCombo();
195194

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

224+
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree *tree );
225+
225226
private slots:
226227
void addTabOrGroupButton();
227228
void removeTabOrGroupButton();
228229
void mEditorLayoutComboBox_currentIndexChanged( int index );
229230
void pbnSelectEditForm_clicked();
230-
void pBInitCode_clicked();
231+
void mTbInitCode_clicked();
231232
};
232233

233234

src/app/qgsattributetypedialog.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -341,34 +341,21 @@ void QgsAttributeTypeDialog::setAlias( const QString &alias )
341341
leAlias->setText( alias );
342342
}
343343

344-
QString QgsAttributeTypeDialog::alias()
344+
QString QgsAttributeTypeDialog::alias() const
345345
{
346346
return leAlias->text();
347347
}
348348

349349
void QgsAttributeTypeDialog::setComment( const QString &comment )
350350
{
351-
leComment->setText( comment );
351+
laComment->setText( comment );
352352
}
353353

354-
QString QgsAttributeTypeDialog::comment()
355-
{
356-
return leComment->text();
357-
}
358-
359-
360354
void QgsAttributeTypeDialog::setLabelOnTop( bool onTop )
361355
{
362356
labelOnTopCheckBox->setChecked( onTop );
363357
}
364358

365-
//removed selectionListWidget: void QgsAttributeTypeDialog::selectionListWidget_currentRowChanged( int index )
366-
//removed selectionListWidget: {
367-
//removed selectionListWidget: const QString editType = selectionListWidget->item( index )->data( Qt::UserRole ).toString();
368-
//removed selectionListWidget:
369-
//removed selectionListWidget: setEditorWidgetType( editType );
370-
//removed selectionListWidget: }
371-
372359
void QgsAttributeTypeDialog::defaultExpressionChanged()
373360
{
374361
QString expression = mExpressionWidget->expression();

src/app/qgsattributetypedialog.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,13 @@ class APP_EXPORT QgsAttributeTypeDialog: public QWidget, private Ui::QgsAttribut
7171
/**
7272
* Getter for lable alias
7373
*/
74-
QString alias();
74+
QString alias() const;
7575

7676
/**
7777
* Setter for lable comment
7878
*/
7979
void setComment( const QString &comment );
8080

81-
/**
82-
* Getter for lable comment
83-
*/
84-
QString comment();
85-
8681
/**
8782
* Setter for checkbox for editable state of field
8883
*/

src/app/qgssourcefieldsproperties.cpp

+49-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/***************************************************************************
2+
qgssourcefieldsproperties.cpp
3+
---------------------
4+
begin : July 2017
5+
copyright : (C) 2017 by David Signer
6+
email : david at opengis dot ch
7+
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
117
#include "qgssourcefieldsproperties.h"
218

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

186202
mIndexedWidgets.insert( idx, mFieldsList->item( row, 0 ) );
187203
mFieldsList->setItem( row, AttrNameCol, new QTableWidgetItem( field.name() ) );
204+
mFieldsList->setItem( row, AttrAliasCol, new QTableWidgetItem( field.alias() ) );
188205
mFieldsList->setItem( row, AttrTypeCol, new QTableWidgetItem( QVariant::typeToName( field.type() ) ) );
189206
mFieldsList->setItem( row, AttrTypeNameCol, new QTableWidgetItem( field.typeName() ) );
190207
mFieldsList->setItem( row, AttrLengthCol, new QTableWidgetItem( QString::number( field.length() ) ) );
@@ -211,22 +228,24 @@ void QgsSourceFieldsProperties::setRow( int row, int idx, const QgsField &field
211228
QList<int> notEditableCols = QList<int>()
212229
<< AttrIdCol
213230
<< AttrNameCol
231+
<< AttrAliasCol
214232
<< AttrTypeCol
215233
<< AttrTypeNameCol
216234
<< AttrLengthCol
217-
<< AttrPrecCol;
235+
<< AttrPrecCol
236+
<< AttrCommentCol;
218237
Q_FOREACH ( int i, notEditableCols )
238+
{
219239
mFieldsList->item( row, i )->setFlags( mFieldsList->item( row, i )->flags() & ~Qt::ItemIsEditable );
220-
240+
if ( notEditableCols[i] == AttrAliasCol )
241+
mFieldsList->item( row, i )->setToolTip( tr( "Edit alias in the Form config tab" ) );
242+
}
221243
bool canRenameFields = mLayer->isEditable() && ( mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::RenameAttributes ) && !mLayer->readOnly();
222244
if ( canRenameFields )
223245
mFieldsList->item( row, AttrNameCol )->setFlags( mFieldsList->item( row, AttrNameCol )->flags() | Qt::ItemIsEditable );
224246
else
225247
mFieldsList->item( row, AttrNameCol )->setFlags( mFieldsList->item( row, AttrNameCol )->flags() & ~Qt::ItemIsEditable );
226248

227-
//set the alias for the attribute
228-
mFieldsList->setItem( row, AttrAliasCol, new QTableWidgetItem( field.alias() ) );
229-
230249
//published WMS/WFS attributes
231250
QTableWidgetItem *wmsAttrItem = new QTableWidgetItem();
232251
wmsAttrItem->setCheckState( mLayer->excludeAttributesWms().contains( field.name() ) ? Qt::Unchecked : Qt::Checked );
@@ -255,6 +274,27 @@ bool QgsSourceFieldsProperties::addAttribute( const QgsField &field )
255274
}
256275
}
257276

277+
void QgsSourceFieldsProperties::apply()
278+
{
279+
// Disabled: we deal with the configuration in the new tabs
280+
QSet<QString> excludeAttributesWMS, excludeAttributesWFS;
281+
282+
for ( int i = 0; i < mFieldsList->rowCount(); i++ )
283+
{
284+
if ( mFieldsList->item( i, AttrWMSCol )->checkState() == Qt::Unchecked )
285+
{
286+
excludeAttributesWMS.insert( mFieldsList->item( i, AttrNameCol )->text() );
287+
}
288+
if ( mFieldsList->item( i, AttrWFSCol )->checkState() == Qt::Unchecked )
289+
{
290+
excludeAttributesWFS.insert( mFieldsList->item( i, AttrNameCol )->text() );
291+
}
292+
}
293+
294+
mLayer->setExcludeAttributesWms( excludeAttributesWMS );
295+
mLayer->setExcludeAttributesWfs( excludeAttributesWFS );
296+
297+
}
258298

259299
//SLOTS
260300

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

320360
void QgsSourceFieldsProperties::attributesListCellChanged( int row, int column )
321361
{
362+
/* this is made read only
322363
if ( column == AttrAliasCol && mLayer )
323364
{
324365
int idx = mFieldsList->item( row, AttrIdCol )->text().toInt();
@@ -343,7 +384,9 @@ void QgsSourceFieldsProperties::attributesListCellChanged( int row, int column )
343384
}
344385
}
345386
}
346-
else if ( column == AttrNameCol && mLayer && mLayer->isEditable() )
387+
else
388+
*/
389+
if ( column == AttrNameCol && mLayer && mLayer->isEditable() )
347390
{
348391
QTableWidgetItem *nameItem = mFieldsList->item( row, column );
349392
if ( !nameItem ||

src/app/qgsvectorlayerproperties.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ void QgsVectorLayerProperties::apply()
630630
mFieldsPropertiesDialog->apply();
631631
// has to be done then mSourceFieldsPropertiesDialog->apply();
632632
mAttributesFormPropertiesDialog->apply();
633+
mSourceFieldsPropertiesDialog->apply();
633634

634635
if ( mLayer->renderer() )
635636
{

0 commit comments

Comments
 (0)