Skip to content
Permalink
Browse files

work in progress status

  • Loading branch information
signedav committed Sep 20, 2017
1 parent 8f895f6 commit c8495ea4e92477c7db140cad92bcd6ad19c0ddbb

Large diffs are not rendered by default.

@@ -41,13 +41,19 @@
#include "qgsfieldcalculator.h"
#include "qgsfieldexpressionwidget.h"
#include "qgsaddtaborgroup.h"
#include "qgsattributetypedialog.h"
#include "qgsgui.h"
#include "qgseditorwidgetfactory.h"
#include "qgseditorwidgetregistry.h"

class DnDTree;

class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAttributesFormProperties
{
Q_OBJECT

public:

enum FieldPropertiesRoles
{
DnDTreeRole = Qt::UserRole,
@@ -64,7 +70,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
bool showUnlinkButton;
};

class DnDTreeItemData
class DnDTreeItemData : public QTreeWidgetItem
{
public:
enum Type
@@ -74,6 +80,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
Container
};

//dave: do we need that
DnDTreeItemData()
: mType( Field )
, mColumnCount( 1 )
@@ -122,30 +129,68 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
RelationEditorConfiguration mRelationEditorConfiguration;
};


/**
* Holds the configuration for a field
*/
class FieldConfig
{
public:
FieldConfig();
FieldConfig( QgsVectorLayer *layer, int idx );

bool mEditable;
bool mEditableEnabled;
bool mLabelOnTop;
QgsFieldConstraints::Constraints mConstraints;
QHash< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > mConstraintStrength;
QString mConstraint;
QString mConstraintDescription;
QPushButton *mButton = nullptr;
QString mEditorWidgetType;
QMap<QString, QVariant> mEditorWidgetConfig;
};

public:
explicit QgsAttributesFormProperties( QgsVectorLayer *layer, QWidget *parent = nullptr );
~QgsAttributesFormProperties();

QgsAttributeEditorElement *createAttributeEditorWidget( QTreeWidgetItem *item, QgsAttributeEditorElement *parent, bool forceGroup = true );

void init();
void apply();

void onAttributeSelectionChanged();

void loadRelations();

void loadAttributeEditorTree( DnDTree *mTree );
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree* mTree);

protected:
void updateButtons();

FieldConfig configForChild( int index );
void setConfigForChild( int index, const FieldConfig &cfg );

//QList<QgsRelation> mRelations;
QgsVectorLayer *mLayer = nullptr;

DnDTree *mDragTree = nullptr;
DnDTree *mDropTree = nullptr;

QgsAttributeTypeDialog *mAttributeTypeDialog = nullptr;


private:

signals:

private slots:
void addTabOrGroupButton();
void removeTabOrGroupButton();
void loadAttributeTypeDialog( );
void storeAttributeTypeDialog( );
};


@@ -179,6 +224,7 @@ class DnDTree : public QTreeWidget

Type type;

QList<QTreeWidgetItem *> mIndexedWidgets;
protected:
virtual void dragMoveEvent( QDragMoveEvent *event ) override;
virtual void dropEvent( QDropEvent *event ) override;
@@ -190,15 +236,16 @@ class DnDTree : public QTreeWidget
virtual QStringList mimeTypes() const override;
virtual QMimeData *mimeData( const QList<QTreeWidgetItem *> items ) const override;


private slots:
void onItemDoubleClicked( QTreeWidgetItem *item, int column );
void attributeTypeDialog();

private:
QgsVectorLayer *mLayer = nullptr;
};


Q_DECLARE_METATYPE( QgsAttributesFormProperties::FieldConfig )
Q_DECLARE_METATYPE( QgsAttributesFormProperties::DnDTreeItemData )

#endif // QGSATTRIBUTESFORMPROPERTIES_H
@@ -39,8 +39,8 @@
#include <climits>
#include <cfloat>

QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx )
: QDialog()
QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx, QWidget *parent )
: QWidget( parent )
, mLayer( vl )
, mFieldIdx( fieldIdx )
{
@@ -295,6 +295,12 @@ void QgsAttributeTypeDialog::setDefaultValueExpression( const QString &expressio
mExpressionWidget->setExpression( expression );
}

int QgsAttributeTypeDialog::fieldIdx() const
{
return mFieldIdx;
}


QgsExpressionContext QgsAttributeTypeDialog::createExpressionContext() const
{
QgsExpressionContext context;
@@ -24,14 +24,14 @@
#include "qgsvectordataprovider.h"
#include "qgis_app.h"

class QDialog;
class QWidget;

class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog, QgsExpressionContextGenerator
class APP_EXPORT QgsAttributeTypeDialog: public QWidget, private Ui::QgsAttributeTypeDialog, QgsExpressionContextGenerator
{
Q_OBJECT

public:
QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx );
QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx, QWidget *parent = nullptr );
~QgsAttributeTypeDialog();

/**
@@ -163,6 +163,11 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
*/
void setDefaultValueExpression( const QString &expression );

/**
* Returns the field id
*/
int fieldIdx() const;

QgsExpressionContext createExpressionContext() const override;

private slots:
@@ -581,8 +581,8 @@ void QgsFieldsProperties::attributeTypeDialog()
attributeTypeDialog.setEditorWidgetConfig( cfg.mEditorWidgetConfig );
attributeTypeDialog.setEditorWidgetType( cfg.mEditorWidgetType );

if ( !attributeTypeDialog.exec() )
return;
//if ( !attributeTypeDialog.exec() )
// return;

cfg.mEditable = attributeTypeDialog.fieldEditable();
cfg.mLabelOnTop = attributeTypeDialog.labelOnTop();
@@ -1074,6 +1074,7 @@ void QgsFieldsProperties::apply()
}

mLayer->setEditFormConfig( editFormConfig );

}
/*
* FieldConfig implementation
@@ -92,6 +92,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
, diagramPropertiesDialog( nullptr )
, mFieldsPropertiesDialog( nullptr )
, mSourceFieldsPropertiesDialog( nullptr )
, mAttributesFormPropertiesDialog( nullptr )
{
setupUi( this );
// QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
@@ -213,7 +214,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
//QgisApp::instance(), [ = ]( QgsMapLayer * layer ) { QgisApp::instance()->toggleEditing( layer ); } );

mAttributesFormPropertiesDialog = new QgsAttributesFormProperties( mLayer, mAttributesFormFrame );
//mAttributesFormPropertiesDialog->layout()->setMargin( 0 );
mAttributesFormPropertiesDialog->layout()->setMargin( 0 );
mAttributesFormFrame->setLayout( new QVBoxLayout( mAttributesFormFrame ) );
mAttributesFormFrame->layout()->setMargin( 0 );
mAttributesFormFrame->layout()->addWidget( mAttributesFormPropertiesDialog );
@@ -572,6 +573,8 @@ void QgsVectorLayerProperties::apply()

// Apply fields settings
mFieldsPropertiesDialog->apply();
// has to be done then mSourceFieldsPropertiesDialog->apply();
mAttributesFormPropertiesDialog->apply();

if ( mLayer->renderer() )
{
@@ -13,47 +13,100 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="mRemoveTabOrGroupButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mAddTabOrGroupButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="mDragListWidget" native="true"/>
<widget class="QWidget" name="mDropListWidget" native="true"/>
<widget class="QWidget" name="mOptionsWidget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="Testlable">
<property name="text">
<string>Widget Properties</string>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="mRemoveTabOrGroupButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mAddTabOrGroupButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="mDropListWidget" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="mAttributeTypeFrame" native="true">
<layout class="QGridLayout" name="gridLayout_2"/>
</widget>
</widget>
</item>
</layout>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsAttributeTypeDialog</class>
<widget class="QDialog" name="QgsAttributeTypeDialog">
<widget class="QWidget" name="QgsAttributeTypeDialog">
<property name="geometry">
<rect>
<x>0</x>

0 comments on commit c8495ea

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