Skip to content

Commit

Permalink
disable double click on items in the available widgets tree
Browse files Browse the repository at this point in the history
show info message for relation and qml/html widget, where to configure it
select the dropped feature
  • Loading branch information
signedav committed Aug 10, 2020
1 parent 0542f9f commit 292c622
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
67 changes: 40 additions & 27 deletions src/gui/vector/qgsattributesformproperties.cpp
Expand Up @@ -363,6 +363,13 @@ void QgsAttributesFormProperties::loadAttributeWidgetEdit()
mAttributeTypeFrame->layout()->addWidget( mAttributeWidgetEdit );
}

void QgsAttributesFormProperties::loadInfoWidget( const QString &infoText )
{
mInfoTextWidget = new QLabel( infoText );
mAttributeTypeFrame->layout()->setMargin( 0 );
mAttributeTypeFrame->layout()->addWidget( mInfoTextWidget );
}

void QgsAttributesFormProperties::storeAttributeContainerEdit()
{
if ( !mAttributeContainerEdit )
Expand Down Expand Up @@ -508,7 +515,13 @@ void QgsAttributesFormProperties::loadAttributeSpecificEditor( QgsAttributesDnDT
{
receiver->selectFirstMatchingItem( itemData );
if ( layout == QgsEditFormConfig::EditorLayout::TabLayout )
{
loadAttributeWidgetEdit();
}
else
{
loadInfoWidget( tr( "This configuration is available in the Drag and Drop Designer" ) );
}
break;
}
case DnDTreeItemData::Field:
Expand All @@ -525,10 +538,19 @@ void QgsAttributesFormProperties::loadAttributeSpecificEditor( QgsAttributesDnDT
loadAttributeContainerEdit();
break;
}

case DnDTreeItemData::WidgetType:
case DnDTreeItemData::QmlWidget:
case DnDTreeItemData::HtmlWidget:
{
if ( layout != QgsEditFormConfig::EditorLayout::TabLayout )
{
loadInfoWidget( tr( "This configuration is available with double click in the Drag and Drop Designer" ) );
}
else
{
loadInfoWidget( tr( "This configuration is available with double click" ) );
}
}
case DnDTreeItemData::WidgetType:
{
receiver->clearSelection();
break;
Expand Down Expand Up @@ -557,6 +579,12 @@ void QgsAttributesFormProperties::clearAttributeTypeFrame()
mAttributeContainerEdit->deleteLater();
mAttributeContainerEdit = nullptr;
}
if ( mInfoTextWidget )
{
mAttributeTypeFrame->layout()->removeWidget( mInfoTextWidget );
mInfoTextWidget->deleteLater();
mInfoTextWidget = nullptr;
}
}

void QgsAttributesFormProperties::onInvertSelectionButtonClicked( bool checked )
Expand Down Expand Up @@ -1010,6 +1038,8 @@ bool QgsAttributesDnDTree::dropMimeData( QTreeWidgetItem *parent, int index, con
{
onItemDoubleClicked( newItem, 0 );
}
clearSelection();
newItem->setSelected( true );
}
}

Expand Down Expand Up @@ -1068,6 +1098,7 @@ QMimeData *QgsAttributesDnDTree::mimeData( const QList<QTreeWidgetItem *> items
void QgsAttributesDnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
{
Q_UNUSED( column )

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

QGroupBox *baseData = new QGroupBox( tr( "Base configuration" ) );
Expand All @@ -1084,11 +1115,15 @@ void QgsAttributesDnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int colum
{
case QgsAttributesFormProperties::DnDTreeItemData::Container:
case QgsAttributesFormProperties::DnDTreeItemData::WidgetType:
case QgsAttributesFormProperties::DnDTreeItemData::Relation:
case QgsAttributesFormProperties::DnDTreeItemData::Relation:
case QgsAttributesFormProperties::DnDTreeItemData::Field:
break;

case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
{
if ( mType == QgsAttributesDnDTree::Type::Drag )
return;

QDialog dlg;
dlg.setWindowTitle( tr( "Configure QML Widget" ) );

Expand Down Expand Up @@ -1250,6 +1285,8 @@ void QgsAttributesDnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int colum

case QgsAttributesFormProperties::DnDTreeItemData::HtmlWidget:
{
if ( mType == QgsAttributesDnDTree::Type::Drag )
return;
QDialog dlg;
dlg.setWindowTitle( tr( "Configure HTML Widget" ) );

Expand Down Expand Up @@ -1326,30 +1363,6 @@ void QgsAttributesDnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int colum
}
}
break;

case QgsAttributesFormProperties::DnDTreeItemData::Field:
{
QDialog dlg;
dlg.setWindowTitle( tr( "Configure Field" ) );
dlg.setLayout( new QGridLayout() );
dlg.layout()->addWidget( baseWidget );

QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok
| QDialogButtonBox::Cancel );

connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );

dlg.layout()->addWidget( buttonBox );

if ( dlg.exec() )
{
itemData.setShowLabel( showLabelCheckbox->isChecked() );

item->setData( 0, QgsAttributesFormProperties::DnDTreeRole, itemData );
}
}
break;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/vector/qgsattributesformproperties.h
Expand Up @@ -208,6 +208,7 @@ class GUI_EXPORT QgsAttributesFormProperties : public QWidget, public QgsExpress
QgsAttributeWidgetEdit *mAttributeWidgetEdit = nullptr;
QgsAttributeTypeDialog *mAttributeTypeDialog = nullptr;
QgsAttributeFormContainerEdit *mAttributeContainerEdit = nullptr;
QLabel *mInfoTextWidget = nullptr;

private slots:

Expand All @@ -229,6 +230,8 @@ class GUI_EXPORT QgsAttributesFormProperties : public QWidget, public QgsExpress
void storeAttributeContainerEdit();
void loadAttributeContainerEdit();

void loadInfoWidget( const QString &infoText );

QgsEditFormConfig::PythonInitCodeSource mInitCodeSource = QgsEditFormConfig::CodeSourceNone;
QString mInitFunction;
QString mInitFilePath;
Expand Down

0 comments on commit 292c622

Please sign in to comment.