Skip to content

Commit

Permalink
drag'n'drop improvements part 3 (#34479)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
3nids committed Feb 14, 2020
1 parent 504d43a commit 9441fcc
Show file tree
Hide file tree
Showing 19 changed files with 281 additions and 64 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
9 changes: 5 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 @@ -112,8 +115,6 @@ SET(QGIS_APP_SRCS
qgsmaptoolsvgannotation.cpp
qgsmaptooltextannotation.cpp

attributeformconfig/qgsattributeformcontaineredit.cpp

decorations/qgsdecorationitem.cpp
decorations/qgsdecorationtitle.cpp
decorations/qgsdecorationtitledialog.cpp
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
87 changes: 87 additions & 0 deletions src/app/attributeformconfig/qgsattributewidgetedit.cpp
@@ -0,0 +1,87 @@
/***************************************************************************
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>();
Q_ASSERT( itemData.type() == QgsAttributesFormProperties::DnDTreeItemData::Container );

// 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 9441fcc

Please sign in to comment.