-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
part 2 display the container editor in the right panel this avoids opening a modal dialog a new type of itemData has been added as WidgetType to distinguish them in the available widgets from the containers in the form layout fixes #29063
- Loading branch information
Showing
7 changed files
with
312 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/app/attributeformconfig/qgsattributeformcontaineredit.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
45
src/app/attributeformconfig/qgsattributeformcontaineredit.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.