Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drag'n'drop improvements #34479

Merged
merged 2 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/core/auto_additions/qgseditformconfig.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
87 changes: 87 additions & 0 deletions src/app/attributeformconfig/qgsattributewidgetedit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/***************************************************************************
qgsattributewidgetedit.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call it form widget (since these are not for attributes only)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave it as since it's named accordingly to the others (like the relation edit)

---------------------
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
Original file line number Diff line number Diff line change
@@ -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
Loading