Skip to content

Commit

Permalink
relations in list
Browse files Browse the repository at this point in the history
alias comment in gui (not ready yet)
  • Loading branch information
signedav committed Oct 26, 2017
1 parent 18b6caf commit 3a547dc
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 64 deletions.
33 changes: 26 additions & 7 deletions src/app/qgsattributesformproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
{
QTreeWidgetItem *currentItem = mAvailableWidgetsTree->currentItem();

if ( !currentItem )
if ( !currentItem || !( currentItem->data( 0, DnDTreeRole ).value<DnDTreeItemData>().type()==DnDTreeItemData::Field ) )
mAttributeTypeDialog->setEnabled( false );
else
{
Expand Down Expand Up @@ -270,6 +270,7 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
mAvailableWidgetsTree->setDragDropMode( QAbstractItemView::DragOnly );

//load Fields

DnDTreeItemData catItemData = DnDTreeItemData( DnDTreeItemData::Container, "Fields");
QTreeWidgetItem *catitem = mAvailableWidgetsTree->addItem( mAvailableWidgetsTree->invisibleRootItem(), catItemData );

Expand All @@ -283,6 +284,8 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
FieldConfig cfg( mLayer, i );

QTreeWidgetItem *item = mAvailableWidgetsTree->addItem( catitem, itemData );
//QTreeWidgetItem *item = mAvailableWidgetsTree->addItem( mAvailableWidgetsTree->invisibleRootItem(), itemData );

item->setData( 0, FieldConfigRole, cfg );
item->setData( 0, FieldNameRole, field.name() );
}
Expand All @@ -293,6 +296,7 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
itemData.setText(i, fields.at( i ).name() );
*/


//load Relations
catItemData = DnDTreeItemData( DnDTreeItemData::Container, "Relations");
catitem = mAvailableWidgetsTree->addItem( mAvailableWidgetsTree->invisibleRootItem(), catItemData );
Expand All @@ -308,6 +312,7 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
item->setData( 0, FieldNameRole, relation.name() );
}


}


Expand Down Expand Up @@ -362,7 +367,6 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
break;
}

/*dave to do
case DnDTreeItemData::Relation:
{
QgsRelation relation = QgsProject::instance()->relationManager()->relation( itemData.name() );
Expand All @@ -372,7 +376,6 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
widgetDef = relDef;
break;
}
*/

case DnDTreeItemData::Container:
{
Expand Down Expand Up @@ -401,9 +404,13 @@ void QgsAttributesFormProperties::apply()
{
QgsEditFormConfig editFormConfig = mLayer->editFormConfig();

for ( QTreeWidgetItemIterator it( mAvailableWidgetsTree ); *it; ++it )
QTreeWidgetItem* fieldContainer=mAvailableWidgetsTree->invisibleRootItem()->child(0);

for ( int i = 0; i < fieldContainer->childCount(); i++ )
{
int idx = mAvailableWidgetsTree->invisibleRootItem()->indexOfChild( ( *it ) );
QTreeWidgetItem *fieldItem = fieldContainer->child( i );
int idx=fieldContainer->indexOfChild( fieldItem );

QString name = mLayer->fields().at( idx ).name();
FieldConfig cfg = configForChild( idx );

Expand Down Expand Up @@ -436,6 +443,8 @@ void QgsAttributesFormProperties::apply()
{
mLayer->removeFieldConstraint( idx, QgsFieldConstraints::ConstraintExpression );
}

//mLayer->setFieldAlias( idx, aliasItem->text() );
}

// tabs and groups
Expand All @@ -457,8 +466,19 @@ void QgsAttributesFormProperties::apply()
editFormConfig.setInitFilePath( mInitFilePathLineEdit->text() );
editFormConfig.setInitCodeSource( ( QgsEditFormConfig::PythonInitCodeSource )mInitCodeSourceComboBox->currentIndex() );
editFormConfig.setSuppress( ( QgsEditFormConfig::FeatureFormSuppress )mFormSuppressCmbBx->currentIndex() );
*/

/*
// relations
QTreeWidgetItem* relationContainer=mAvailableWidgetsTree->invisibleRootItem()->child(1);
for ( int i = 0; i < relationContainer->childCount(); i++ )
{
QTreeWidgetItem *relationItem = relationContainer->child( i );
int idx=relationContainer->indexOfChild( relationItem );
QString name = mLayer->fields().at( idx ).name();
for ( int i = 0; i < mRelationsList->rowCount(); ++i )
{
QVariantMap cfg;
Expand All @@ -477,8 +497,7 @@ void QgsAttributesFormProperties::apply()
editFormConfig.setWidgetConfig( relationName, cfg );
}
*/

*/
mLayer->setEditFormConfig( editFormConfig );
}

Expand Down
76 changes: 19 additions & 57 deletions src/ui/qgsattributesformproperties.ui
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,36 @@
</property>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="1">
<widget class="QToolButton" name="mRemoveTabOrGroupButton">
<item row="0" column="2">
<widget class="QToolButton" name="mAddTabOrGroupButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="0" column="1" rowspan="6">
<widget class="QWidget" name="mFormLayoutWidget" native="true"/>
</item>
<item row="0" column="0" rowspan="6">
<widget class="QWidget" name="mAvailableWidgetsWidget" native="true"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="mRemoveTabOrGroupButton">
<property name="text">
<string>...</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
</property>
</spacer>
</widget>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_2">
<item row="3" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
Expand All @@ -70,23 +74,6 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="mAddTabOrGroupButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="4">
<widget class="QWidget" name="mFormLayoutWidget" native="true"/>
</item>
<item row="0" column="0" rowspan="4">
<widget class="QWidget" name="mAvailableWidgetsWidget" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="mAttributeTypeFrame" native="true">
Expand All @@ -98,31 +85,6 @@
</widget>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
</ui>
29 changes: 29 additions & 0 deletions src/ui/qgsattributetypeedit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@
<string>Edit Widget Properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Alias</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Comment</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leAlias"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leComment"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
Expand Down

0 comments on commit 3a547dc

Please sign in to comment.