Add getter/setter for type

This commit is contained in:
Matthias Kuhn 2017-09-28 11:59:26 +02:00
parent 02b3865e42
commit 89943e1259
No known key found for this signature in database
GPG Key ID: A0E766808764D73F
2 changed files with 22 additions and 10 deletions

View File

@ -19,7 +19,7 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
mDragListWidgetLayout->addWidget( mDragTree );
mDragListWidget->setLayout( mDragListWidgetLayout );
mDragTree->setHeaderLabels( QStringList() << tr( "Label" ) );
mDragTree->type = DnDTree::Type::Drag;
mDragTree->setType( DnDTree::Type::Drag );
// drop tree
QGridLayout *mDropListWidgetLayout = new QGridLayout;
@ -28,7 +28,7 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
mDropListWidgetLayout->setMargin( 0 );
mDropListWidget->setLayout( mDropListWidgetLayout );
mDropTree->setHeaderLabels( QStringList() << tr( "Label" ) );
mDropTree->type = DnDTree::Type::Drop;
mDropTree->setType( DnDTree::Type::Drop );
// AttributeTypeDialog
mAttributeTypeDialog = new QgsAttributeTypeDialog( mLayer, 0, mAttributeTypeFrame );
@ -244,7 +244,7 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
void QgsAttributesFormProperties::loadAttributeEditorTree( DnDTree *mTree )
{
if ( mTree->type == DnDTree::Type::Drop )
if ( mTree->type() == DnDTree::Type::Drop )
{
// tabs and groups info
mTree->clear();
@ -821,6 +821,16 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
}
}
DnDTree::Type DnDTree::type() const
{
return mType;
}
void DnDTree::setType( const Type &value )
{
mType = value;
}
/*
* Serialization helpers for DesigerTreeItemData so we can stuff this easily into QMimeData

View File

@ -24,7 +24,6 @@
#include <QSpinBox>
#include <QTreeWidgetItem>
#include <QDropEvent>
#include <QPushButton>
#include <QTableWidgetItem>
#include <QMessageBox>
#include <QFileDialog>
@ -165,7 +164,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
void loadRelations();
void loadAttributeEditorTree( DnDTree *mTree );
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree* mTree);
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree *mTree );
protected:
void updateButtons();
@ -187,10 +186,10 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
signals:
private slots:
void addTabOrGroupButton();
void removeTabOrGroupButton();
void loadAttributeTypeDialog( );
void storeAttributeTypeDialog( );
void addTabOrGroupButton();
void removeTabOrGroupButton();
void loadAttributeTypeDialog( );
void storeAttributeTypeDialog( );
};
@ -222,9 +221,11 @@ class DnDTree : public QTreeWidget
Drop
};
Type type;
QList<QTreeWidgetItem *> mIndexedWidgets;
Type type() const;
void setType( const Type &value );
protected:
virtual void dragMoveEvent( QDragMoveEvent *event ) override;
virtual void dropEvent( QDropEvent *event ) override;
@ -242,6 +243,7 @@ class DnDTree : public QTreeWidget
private:
QgsVectorLayer *mLayer = nullptr;
Type mType;
};