Skip to content

Commit

Permalink
Drag'n'drop improvements backport to 3.10 (#34656)
Browse files Browse the repository at this point in the history
* [FEATURE] Merge pull request #34411 from 3nids/dnd_sync_selec

improvement of the Drag'n'Drop designer

* Merge pull request #34433 from 3nids/dnd_part2

drad'n'drop improvents part 2

* drag'n'drop improvements part 3 (#34479)

* drag'n'drop improvements

part 3

this completely removes hidden config accessible under double click
now a widget groupbox (by opposition to the field config) is shown on top of the right panel

* remove assert from a left over (fix crash) (#34503)

the assert was copied from other class and I was running with RelWithDebugInfo and not Debug.

* Update CMakeLists.txt

* Update CMakeLists.txt

* move to moc headers

* sip include
  • Loading branch information
3nids committed Mar 12, 2020
1 parent f92f59c commit 2225fb6
Show file tree
Hide file tree
Showing 25 changed files with 752 additions and 246 deletions.
4 changes: 4 additions & 0 deletions python/core/auto_additions/qgseditformconfig.py
@@ -0,0 +1,4 @@
# The following has been generated automatically from src/core/qgseditformconfig.h
QgsEditFormConfig.EditorLayout.baseClass = QgsEditFormConfig
QgsEditFormConfig.FeatureFormSuppress.baseClass = QgsEditFormConfig
QgsEditFormConfig.PythonInitCodeSource.baseClass = QgsEditFormConfig
3 changes: 3 additions & 0 deletions python/core/auto_generated/qgseditformconfig.sip.in
Expand Up @@ -17,6 +17,9 @@ class QgsEditFormConfig
%TypeHeaderCode
#include "qgseditformconfig.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

enum EditorLayout
Expand Down
2 changes: 1 addition & 1 deletion python/core/core_auto.sip
Expand Up @@ -36,7 +36,6 @@
%Include auto_generated/qgsdbfilterproxymodel.sip
%Include auto_generated/qgsdiagramrenderer.sip
%Include auto_generated/qgsdistancearea.sip
%Include auto_generated/qgseditformconfig.sip
%Include auto_generated/qgseditorwidgetsetup.sip
%Include auto_generated/qgsellipsoidutils.sip
%Include auto_generated/qgserror.sip
Expand Down Expand Up @@ -352,6 +351,7 @@
%Include auto_generated/qgsdataprovider.sip
%Include auto_generated/qgsdatasourceuri.sip
%Include auto_generated/qgsdefaultvalue.sip
%Include auto_generated/qgseditformconfig.sip
%Include auto_generated/qgsfeature.sip
%Include auto_generated/qgsfeedback.sip
%Include auto_generated/qgsfield.sip
Expand Down
15 changes: 11 additions & 4 deletions src/app/CMakeLists.txt
Expand Up @@ -7,6 +7,11 @@ SET(QGIS_APP_SRCS
${CMAKE_SOURCE_DIR}/external/nmea/gmath.c
${CMAKE_SOURCE_DIR}/external/nmea/time.c

attributeformconfig/qgsattributeformcontaineredit.cpp
attributeformconfig/qgsattributerelationedit.cpp
attributeformconfig/qgsattributetypedialog.cpp
attributeformconfig/qgsattributewidgetedit.cpp

qgisapp.cpp
qgisappinterface.cpp
qgisappstylesheet.cpp
Expand All @@ -26,8 +31,6 @@ SET(QGIS_APP_SRCS
qgsappsslerrorhandler.cpp
qgsattributeactiondialog.cpp
qgsattributeactionpropertiesdialog.cpp
qgsattributetypedialog.cpp
qgsattributerelationedit.cpp
qgsattributesforminitcode.cpp
qgsattributetabledialog.cpp
qgsbookmarks.cpp
Expand Down Expand Up @@ -274,8 +277,6 @@ SET (QGIS_APP_MOC_HDRS
qgsapplayertreeviewmenuprovider.h
qgsattributeactiondialog.h
qgsattributeactionpropertiesdialog.h
qgsattributetypedialog.h
qgsattributerelationedit.h
qgsattributesforminitcode.h
qgsattributetabledialog.h
qgsbookmarks.h
Expand Down Expand Up @@ -387,6 +388,11 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolregularpolygon2points.h
qgsmaptoolregularpolygoncenterpoint.h
qgsmaptoolregularpolygoncentercorner.h

attributeformconfig/qgsattributetypedialog.h
attributeformconfig/qgsattributeformcontaineredit.h
attributeformconfig/qgsattributerelationedit.h
attributeformconfig/qgsattributewidgetedit.h

decorations/qgsdecorationitem.h
decorations/qgsdecorationtitle.h
Expand Down Expand Up @@ -686,6 +692,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/external

${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/src/app/attributeformconfig
${CMAKE_SOURCE_DIR}/src/app/decorations
${CMAKE_SOURCE_DIR}/src/app/layout
${CMAKE_SOURCE_DIR}/src/app/pluginmanager
Expand Down
71 changes: 71 additions & 0 deletions src/app/attributeformconfig/qgsattributeformcontaineredit.cpp
@@ -0,0 +1,71 @@
/***************************************************************************
qgsattributeformcontaineredit.cpp
---------------------
begin : February 2020
copyright : (C) 2020 Denis Rouzaud
email : denis@opengis.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 "qgsattributeformcontaineredit.h"
#include "ui_qgsattributeformcontaineredit.h"
#include "qgsattributesformproperties.h"


QgsAttributeFormContainerEdit::QgsAttributeFormContainerEdit( QTreeWidgetItem *item, QWidget *parent )
: QWidget( parent )
, mTreeItem( item )

{
setupUi( this );



const QgsAttributesFormProperties::DnDTreeItemData itemData = mTreeItem->data( 0, QgsAttributesFormProperties::DnDTreeRole ).value<QgsAttributesFormProperties::DnDTreeItemData>();
Q_ASSERT( itemData.type() == QgsAttributesFormProperties::DnDTreeItemData::Container );

if ( item->parent() )
{
// only top level items can be tabs
// i.e. it's always a group box if it's a nested container
mShowAsGroupBoxCheckBox->hide();
}

mTitleLineEdit->setText( itemData.name() );
mShowLabelCheckBox->setChecked( itemData.showLabel() );
mShowLabelCheckBox->setEnabled( itemData.showAsGroupBox() ); // show label makes sense for group box, not for tabs
mShowAsGroupBoxCheckBox->setChecked( itemData.showAsGroupBox() );

mControlVisibilityGroupBox->setChecked( itemData.visibilityExpression().enabled() );
mVisibilityExpressionWidget->setExpression( itemData.visibilityExpression()->expression() );
mColumnCountSpinBox->setValue( itemData.columnCount() );
mBackgroundColorButton->setColor( itemData.backgroundColor() );

// show label makes sense for group box, not for tabs
connect( mShowAsGroupBoxCheckBox, &QCheckBox::stateChanged, mShowLabelCheckBox, &QCheckBox::setEnabled );
}

void QgsAttributeFormContainerEdit::updateItemData()
{
QgsAttributesFormProperties::DnDTreeItemData itemData = mTreeItem->data( 0, QgsAttributesFormProperties::DnDTreeRole ).value<QgsAttributesFormProperties::DnDTreeItemData>();

itemData.setColumnCount( mColumnCountSpinBox->value() );
itemData.setShowAsGroupBox( mShowAsGroupBoxCheckBox->isVisible() ? mShowAsGroupBoxCheckBox->isChecked() : true );
itemData.setName( mTitleLineEdit->text() );
itemData.setShowLabel( mShowLabelCheckBox->isChecked() );
itemData.setBackgroundColor( mBackgroundColorButton->color() );

QgsOptionalExpression visibilityExpression;
visibilityExpression.setData( QgsExpression( mVisibilityExpressionWidget->expression() ) );
visibilityExpression.setEnabled( mControlVisibilityGroupBox->isChecked() );
itemData.setVisibilityExpression( visibilityExpression );

mTreeItem->setData( 0, QgsAttributesFormProperties::DnDTreeRole, itemData );
mTreeItem->setText( 0, itemData.name() );
}
45 changes: 45 additions & 0 deletions src/app/attributeformconfig/qgsattributeformcontaineredit.h
@@ -0,0 +1,45 @@
/***************************************************************************
qgsattributeformcontaineredit.h
---------------------
begin : February 2020
copyright : (C) 2020 Denis Rouzaud
email : denis@opengis.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. *
* *
***************************************************************************/

#ifndef QGSATTRIBUTEFORMCONTAINEREDIT_H
#define QGSATTRIBUTEFORMCONTAINEREDIT_H

#include <QWidget>

#include "ui_qgsattributeformcontaineredit.h"

#include "qgis_app.h"

class QTreeWidgetItem;

/**
* Widget to edit a container (tab or group box) of a form configuration
*/
class APP_EXPORT QgsAttributeFormContainerEdit: public QWidget, private Ui_QgsAttributeFormContainerEdit
{
Q_OBJECT

public:
explicit QgsAttributeFormContainerEdit( QTreeWidgetItem *item, QWidget *parent = nullptr );


void updateItemData();


private:
QTreeWidgetItem *mTreeItem;
};

#endif // QGSATTRIBUTEFORMCONTAINEREDIT_H
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
86 changes: 86 additions & 0 deletions src/app/attributeformconfig/qgsattributewidgetedit.cpp
@@ -0,0 +1,86 @@
/***************************************************************************
qgsattributewidgetedit.cpp
---------------------
begin : February 2020
copyright : (C) 2020 Denis Rouzaud
email : denis@opengis.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 "qgsattributewidgetedit.h"
#include "qgsattributesformproperties.h"


QgsAttributeWidgetEdit::QgsAttributeWidgetEdit( QTreeWidgetItem *item, QWidget *parent )
: QgsCollapsibleGroupBox( parent )
, mTreeItem( item )

{
setupUi( this );

const QgsAttributesFormProperties::DnDTreeItemData itemData = mTreeItem->data( 0, QgsAttributesFormProperties::DnDTreeRole ).value<QgsAttributesFormProperties::DnDTreeItemData>();

// common configs
mShowLabelCheckBox->setChecked( itemData.showLabel() );

// hide specific configs
mRelationShowLinkCheckBox->hide();
mRelationShowUnlinkCheckBox->hide();

switch ( itemData.type() )
{
case QgsAttributesFormProperties::DnDTreeItemData::Relation:
{
mRelationShowLinkCheckBox->show();
mRelationShowUnlinkCheckBox->show();
mRelationShowLinkCheckBox->setChecked( itemData.relationEditorConfiguration().showLinkButton );
mRelationShowUnlinkCheckBox->setChecked( itemData.relationEditorConfiguration().showUnlinkButton );
}
break;

case QgsAttributesFormProperties::DnDTreeItemData::Field:
case QgsAttributesFormProperties::DnDTreeItemData::Container:
case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
case QgsAttributesFormProperties::DnDTreeItemData::HtmlWidget:
case QgsAttributesFormProperties::DnDTreeItemData::WidgetType:
break;
}


}

void QgsAttributeWidgetEdit::updateItemData()
{
QgsAttributesFormProperties::DnDTreeItemData itemData = mTreeItem->data( 0, QgsAttributesFormProperties::DnDTreeRole ).value<QgsAttributesFormProperties::DnDTreeItemData>();

// common configs
itemData.setShowLabel( mShowLabelCheckBox->isChecked() );

// specific configs
switch ( itemData.type() )
{
case QgsAttributesFormProperties::DnDTreeItemData::Relation:
{
QgsAttributesFormProperties::RelationEditorConfiguration relEdCfg;
relEdCfg.showLinkButton = mRelationShowLinkCheckBox->isChecked();
relEdCfg.showUnlinkButton = mRelationShowUnlinkCheckBox->isChecked();
itemData.setRelationEditorConfiguration( relEdCfg );
}
break;

case QgsAttributesFormProperties::DnDTreeItemData::Field:
case QgsAttributesFormProperties::DnDTreeItemData::Container:
case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
case QgsAttributesFormProperties::DnDTreeItemData::HtmlWidget:
case QgsAttributesFormProperties::DnDTreeItemData::WidgetType:
break;
}

mTreeItem->setData( 0, QgsAttributesFormProperties::DnDTreeRole, itemData );
}
45 changes: 45 additions & 0 deletions src/app/attributeformconfig/qgsattributewidgetedit.h
@@ -0,0 +1,45 @@
/***************************************************************************
qgsattributewidgetedit.h
---------------------
begin : February 2020
copyright : (C) 2020 Denis Rouzaud
email : denis@opengis.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. *
* *
***************************************************************************/

#ifndef QGSATTRIBUTEWIDGETEDIT_H
#define QGSATTRIBUTEWIDGETEDIT_H

#include <QWidget>

#include "ui_qgsattributewidgeteditgroupbox.h"

#include "qgis_app.h"

class QTreeWidgetItem;

/**
* Widget to edit a container (tab or group box) of a form configuration
*/
class APP_EXPORT QgsAttributeWidgetEdit: public QgsCollapsibleGroupBox, private Ui_QgsAttributeWidgetEditGroupBox
{
Q_OBJECT

public:
explicit QgsAttributeWidgetEdit( QTreeWidgetItem *item, QWidget *parent = nullptr );


void updateItemData();


private:
QTreeWidgetItem *mTreeItem;
};

#endif // QGSATTRIBUTEWIDGETEDIT_H

0 comments on commit 2225fb6

Please sign in to comment.