Skip to content

Commit

Permalink
when adding new container in form designer, preselect the current gro…
Browse files Browse the repository at this point in the history
…up as parent (#35332)
  • Loading branch information
3nids committed Mar 25, 2020
1 parent b1d50c2 commit e697b7f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/gui/qgsaddtaborgroup.cpp
Expand Up @@ -25,7 +25,7 @@
#include <QComboBox>
#include <QRadioButton>

QgsAddTabOrGroup::QgsAddTabOrGroup( QgsVectorLayer *lyr, const QList < TabPair > &tabList, QWidget *parent )
QgsAddTabOrGroup::QgsAddTabOrGroup( QgsVectorLayer *lyr, const QList < TabPair > &tabList, QTreeWidgetItem *currentTab, QWidget *parent )
: QDialog( parent )
, mLayer( lyr )
, mTabs( tabList )
Expand All @@ -43,6 +43,11 @@ QgsAddTabOrGroup::QgsAddTabOrGroup( QgsVectorLayer *lyr, const QList < TabPair >
for ( const TabPair &tab : constMTabs )
{
mTabList->addItem( tab.first, i );
if ( tab.second == currentTab )
{
mTabList->setCurrentIndex( i );
mGroupButton->setChecked( true );
}
++i;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsaddtaborgroup.h
Expand Up @@ -46,7 +46,7 @@ class GUI_EXPORT QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroup

public:
//! constructor
QgsAddTabOrGroup( QgsVectorLayer *lyr, const QList<TabPair> &tabList, QWidget *parent = nullptr );
QgsAddTabOrGroup( QgsVectorLayer *lyr, const QList<TabPair> &tabList, QTreeWidgetItem *currentTab = nullptr, QWidget *parent = nullptr );

//! Returns the name of the tab or group
QString name();
Expand Down
3 changes: 2 additions & 1 deletion src/gui/vector/qgsattributesformproperties.cpp
Expand Up @@ -658,7 +658,8 @@ void QgsAttributesFormProperties::addTabOrGroupButton()
tabList.append( QgsAddTabOrGroup::TabPair( itemData.name(), *it ) );
}
}
QgsAddTabOrGroup addTabOrGroup( mLayer, tabList, this );
QTreeWidgetItem *currentItem = mFormLayoutTree->selectedItems().at( 0 );
QgsAddTabOrGroup addTabOrGroup( mLayer, tabList, currentItem, this );

if ( !addTabOrGroup.exec() )
return;
Expand Down

0 comments on commit e697b7f

Please sign in to comment.