Skip to content
Permalink
Browse files

[FIX #7508] drag'n'drop form generator wrong creation of group container

  • Loading branch information
m-kuhn committed Apr 12, 2013
1 parent a290fa2 commit 5432618e0c8eb901a6f2f6668f730cc992c6ac0a
Showing with 34 additions and 27 deletions.
  1. +16 −13 src/app/qgsaddtaborgroup.cpp
  2. +8 −3 src/app/qgsaddtaborgroup.h
  3. +10 −11 src/app/qgsfieldsproperties.cpp
@@ -21,24 +21,26 @@
#include "qgsvectorlayer.h"
#include "qgsaddtaborgroup.h"

#include <QTreeWidgetItem>
#include <QComboBox>

QgsAddTabOrGroup::QgsAddTabOrGroup(
QgsVectorLayer *lyr,
QWidget * parent,
QList<QString> tabList
)
: QDialog( parent )
, layer( lyr )
QgsAddTabOrGroup::QgsAddTabOrGroup( QgsVectorLayer *lyr, QList < TabPair > tabList, QWidget * parent )
: QDialog( parent )
, mLayer( lyr )
, mTabs( tabList )
{
setupUi( this );

mTabButton->setChecked( true );
mTabList->setEnabled( false );
if ( tabList.size() > 0 )
if ( mTabs.size() > 0 )
{
for ( QList<QString>::iterator tab = tabList.begin(); tab != tabList.end(); tab++ )
mTabList->addItem( *tab );
int i = 0;
foreach ( TabPair tab, mTabs )
{
mTabList->addItem( tab.first, i );
++i;
}
}
else
{
@@ -48,7 +50,7 @@ QgsAddTabOrGroup::QgsAddTabOrGroup(
connect( mTabButton, SIGNAL( toggled( bool ) ), this, SLOT( on_mTabButton_toggled( bool ) ) );
connect( mGroupButton, SIGNAL( toggled( bool ) ), this, SLOT( on_mGroupButton_toggled( bool ) ) );

setWindowTitle( tr( "Add tab or group for %1" ).arg( layer->name() ) );
setWindowTitle( tr( "Add tab or group for %1" ).arg( mLayer->name() ) );
} // QgsVectorLayerProperties ctor

QgsAddTabOrGroup::~QgsAddTabOrGroup()
@@ -60,9 +62,10 @@ QString QgsAddTabOrGroup::name()
return mName->text();
}

int QgsAddTabOrGroup::tabId()
QTreeWidgetItem* QgsAddTabOrGroup::tab()
{
return mTabList->currentIndex();
TabPair tab = mTabs.at( mTabList->itemData( mTabList->currentIndex() ).toInt() );
return tab.second;
}

bool QgsAddTabOrGroup::tabButtonIsChecked()
@@ -22,19 +22,23 @@
#include "ui_qgsaddtaborgroupbase.h"
#include "qgisgui.h"

class QTreeWidgetItem;
class QgsVectorLayer;

class QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroupBase
{
Q_OBJECT

public:
QgsAddTabOrGroup( QgsVectorLayer *lyr = 0, QWidget *parent = 0, QList<QString> tabList = QList<QString>() );
typedef QPair<QString,QTreeWidgetItem*> TabPair;

public:
QgsAddTabOrGroup( QgsVectorLayer *lyr, QList< TabPair > tabList, QWidget *parent = 0 );
~QgsAddTabOrGroup();

QString name();

int tabId();
QTreeWidgetItem* tab();

bool tabButtonIsChecked();

@@ -43,7 +47,8 @@ class QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroupBase
void on_mTabButton_toggled( bool checked );

protected:
QgsVectorLayer *layer;
QgsVectorLayer *mLayer;
QList< TabPair > mTabs;
};

#endif
@@ -356,17 +356,17 @@ void QgsFieldsProperties::on_mAddItemButton_clicked()

void QgsFieldsProperties::on_mAddTabOrGroupButton_clicked()
{
QList<QString> tabList;
QList<QTreeWidgetItem*> tabWidgetList;
QTreeWidgetItemIterator it( mAttributesTree );
while ( *it )
QList<QgsAddTabOrGroup::TabPair> tabList;


for( QTreeWidgetItemIterator it( mAttributesTree ); *it; ++it )
{
if (( *it )->data( 0 , Qt::UserRole ) == "container" )
tabList.append(( *it )->text( 0 ) );
tabWidgetList.append( *it );
++it;
if ( ( *it )->data( 0 , Qt::UserRole ) == "container" )
{
tabList.append( QgsAddTabOrGroup::TabPair( (*it)->text( 0 ), *it ) );
}
}
QgsAddTabOrGroup addTabOrGroup( mLayer , this, tabList );
QgsAddTabOrGroup addTabOrGroup( mLayer, tabList, this );

if ( !addTabOrGroup.exec() )
return;
@@ -378,8 +378,7 @@ void QgsFieldsProperties::on_mAddTabOrGroupButton_clicked()
}
else
{
int tabId = addTabOrGroup.tabId();
QTreeWidgetItem* tabItem = tabWidgetList[tabId];
QTreeWidgetItem* tabItem = addTabOrGroup.tab();
mAttributesTree->addContainer( tabItem , name );
}
}

0 comments on commit 5432618

Please sign in to comment.
You can’t perform that action at this time.