Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 28, 2017
1 parent c8495ea commit 02b3865
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions src/app/qgsattributesformproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
if ( !layer )
return;

setupUi(this);
setupUi( this );

// drag tree (not mixup with drag queen)
QGridLayout *mDragListWidgetLayout = new QGridLayout;
mDragTree = new DnDTree( mLayer, mDragListWidget );
mDragListWidgetLayout->addWidget( mDragTree );
mDragListWidget->setLayout(mDragListWidgetLayout);
mDragListWidget->setLayout( mDragListWidgetLayout );
mDragTree->setHeaderLabels( QStringList() << tr( "Label" ) );
mDragTree->type = DnDTree::Type::Drag;

// drop tree
QGridLayout *mDropListWidgetLayout = new QGridLayout;
mDropTree = new DnDTree( mLayer, mDropListWidget );
mDropListWidgetLayout->addWidget( mDropTree );
mDropListWidgetLayout->setMargin(0);
mDropListWidget->setLayout(mDropListWidgetLayout);
mDropListWidgetLayout->setMargin( 0 );
mDropListWidget->setLayout( mDropListWidgetLayout );
mDropTree->setHeaderLabels( QStringList() << tr( "Label" ) );
mDropTree->type = DnDTree::Type::Drop;

Expand All @@ -51,8 +51,8 @@ QgsAttributesFormProperties::~QgsAttributesFormProperties()

void QgsAttributesFormProperties::init()
{
loadAttributeEditorTree(mDragTree);
loadAttributeEditorTree(mDropTree);
loadAttributeEditorTree( mDragTree );
loadAttributeEditorTree( mDropTree );
loadAttributeTypeDialog();
}

Expand All @@ -63,27 +63,27 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()

FieldConfig cfg;

int index = mDragTree->mIndexedWidgets.indexOf(mDragTree->currentItem());
int index = mDragTree->mIndexedWidgets.indexOf( mDragTree->currentItem() );

if( index<0 ) index=0;
if ( index < 0 ) index = 0;

Q_FOREACH ( QTreeWidgetItem *wdg, mDragTree->mIndexedWidgets )
{
if ( mDragTree->invisibleRootItem()->indexOfChild(wdg) == index)
if ( mDragTree->invisibleRootItem()->indexOfChild( wdg ) == index )
{
cfg = wdg->data(0, FieldConfigRole ).value<FieldConfig>();
cfg = wdg->data( 0, FieldConfigRole ).value<FieldConfig>();
}
}

// AttributeTypeDialog

mAttributeTypeFrame->layout()->removeWidget(mAttributeTypeDialog );
mAttributeTypeFrame->layout()->removeWidget( mAttributeTypeDialog );
delete mAttributeTypeDialog;

//
mAttributeTypeDialog = new QgsAttributeTypeDialog( mLayer, index, mAttributeTypeFrame );

mAttributeTypeDialog->setFieldEditable( cfg.mEditable );
mAttributeTypeDialog->setFieldEditable( cfg.mEditable );
mAttributeTypeDialog->setLabelOnTop( cfg.mLabelOnTop );
mAttributeTypeDialog->setNotNull( cfg.mConstraints & QgsFieldConstraints::ConstraintNotNull );
mAttributeTypeDialog->setNotNullEnforced( cfg.mConstraintStrength.value( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintStrengthHard ) == QgsFieldConstraints::ConstraintStrengthHard );
Expand Down Expand Up @@ -112,7 +112,7 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
mAttributeTypeFrame->setLayout( new QVBoxLayout( mAttributeTypeFrame ) );
mAttributeTypeFrame->layout()->setMargin( 0 );

mAttributeTypeFrame->layout()->addWidget(mAttributeTypeDialog );
mAttributeTypeFrame->layout()->addWidget( mAttributeTypeDialog );
}


Expand Down Expand Up @@ -148,7 +148,7 @@ void QgsAttributesFormProperties::storeAttributeTypeDialog()

cfg.mConstraintDescription = mAttributeTypeDialog->constraintExpressionDescription();
cfg.mConstraint = mAttributeTypeDialog->constraintExpression();
mLayer->setDefaultValueExpression( mAttributeTypeDialog->fieldIdx() , mAttributeTypeDialog->defaultValueExpression() );
mLayer->setDefaultValueExpression( mAttributeTypeDialog->fieldIdx(), mAttributeTypeDialog->defaultValueExpression() );

cfg.mEditorWidgetType = mAttributeTypeDialog->editorWidgetType();
cfg.mEditorWidgetConfig = mAttributeTypeDialog->editorWidgetConfig();
Expand All @@ -162,9 +162,9 @@ void QgsAttributesFormProperties::storeAttributeTypeDialog()

Q_FOREACH ( QTreeWidgetItem *wdg, mDragTree->mIndexedWidgets )
{
if ( mDragTree->invisibleRootItem()->indexOfChild(wdg) == mAttributeTypeDialog->fieldIdx() )
if ( mDragTree->invisibleRootItem()->indexOfChild( wdg ) == mAttributeTypeDialog->fieldIdx() )
{
wdg->setData(0, FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );
wdg->setData( 0, FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );
}
}
}
Expand All @@ -173,7 +173,7 @@ QgsAttributesFormProperties::FieldConfig QgsAttributesFormProperties::configForC
{
Q_FOREACH ( QTreeWidgetItem *wdg, mDragTree->mIndexedWidgets )
{
if ( mDragTree->invisibleRootItem()->indexOfChild(wdg) == index )
if ( mDragTree->invisibleRootItem()->indexOfChild( wdg ) == index )
{
return wdg->data( 0, FieldConfigRole ).value<FieldConfig>();
}
Expand All @@ -185,7 +185,7 @@ QgsAttributesFormProperties::FieldConfig QgsAttributesFormProperties::configForC
}


QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree* mTree)
QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree *mTree )
{
QTreeWidgetItem *newWidget = nullptr;
switch ( widgetDef->type() )
Expand Down Expand Up @@ -242,9 +242,10 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt



void QgsAttributesFormProperties::loadAttributeEditorTree(DnDTree* mTree)
void QgsAttributesFormProperties::loadAttributeEditorTree( DnDTree *mTree )
{
if( mTree->type==DnDTree::Type::Drop ){
if ( mTree->type == DnDTree::Type::Drop )
{
// tabs and groups info
mTree->clear();
mTree->setSortingEnabled( false );
Expand All @@ -255,10 +256,12 @@ void QgsAttributesFormProperties::loadAttributeEditorTree(DnDTree* mTree)

Q_FOREACH ( QgsAttributeEditorElement *wdg, mLayer->editFormConfig().tabs() )
{
loadAttributeEditorTreeItem( wdg, mTree->invisibleRootItem(), mTree);
loadAttributeEditorTreeItem( wdg, mTree->invisibleRootItem(), mTree );
}

}else{
}
else
{
mTree->clear();
mTree->setSortingEnabled( false );
mTree->setSelectionBehavior( QAbstractItemView::SelectRows );
Expand All @@ -269,14 +272,16 @@ void QgsAttributesFormProperties::loadAttributeEditorTree(DnDTree* mTree)
mTree->mIndexedWidgets.clear();

const QgsFields &fields = mLayer->fields();
for ( int i = 0; i < fields.count(); ++i ){
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::Field, fields.at( i ).name());
for ( int i = 0; i < fields.size(); ++i )
{
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::Field, fields.at( i ).name() );
itemData.setShowLabel( true );

FieldConfig cfg( mLayer, i );
QgsGui::editorWidgetRegistry()->name( cfg.mEditorWidgetType );

itemData.setData(0, FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );

itemData.setData( 0, FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );

mTree->mIndexedWidgets.insert( i, mTree->addItem( mTree->invisibleRootItem(), itemData ) );
}
Expand Down Expand Up @@ -401,7 +406,7 @@ void QgsAttributesFormProperties::apply()

for ( QTreeWidgetItemIterator it( mDragTree ); *it; ++it )
{
int idx = mDragTree->invisibleRootItem()->indexOfChild((*it));
int idx = mDragTree->invisibleRootItem()->indexOfChild( ( *it ) );
QString name = mLayer->fields().at( idx ).name();
FieldConfig cfg = configForChild( idx );

Expand Down

0 comments on commit 02b3865

Please sign in to comment.