Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #7350 from PeterPetrik/quick_featurepanel
[quick] [feature] Feature attribute panel
- Loading branch information
Showing
with
3,089 additions
and 14 deletions.
- +3 −0 doc/qgsquick.dox
- +11 −0 src/quickgui/CMakeLists.txt
- +72 −0 src/quickgui/attributes/qgsquickattributeformmodel.cpp
- +122 −0 src/quickgui/attributes/qgsquickattributeformmodel.h
- +383 −0 src/quickgui/attributes/qgsquickattributeformmodelbase.cpp
- +132 −0 src/quickgui/attributes/qgsquickattributeformmodelbase.h
- +331 −0 src/quickgui/attributes/qgsquickattributemodel.cpp
- +153 −0 src/quickgui/attributes/qgsquickattributemodel.h
- +183 −0 src/quickgui/attributes/qgsquicksubmodel.cpp
- +93 −0 src/quickgui/attributes/qgsquicksubmodel.h
- +5 −0 src/quickgui/images/ic_broken_image_black.svg
- +71 −0 src/quickgui/images/ic_camera_alt_border.svg
- +4 −0 src/quickgui/images/ic_check_black.svg
- +4 −0 src/quickgui/images/ic_clear_black.svg
- +4 −0 src/quickgui/images/ic_clear_white.svg
- +5 −0 src/quickgui/images/ic_delete_forever_white.svg
- +66 −0 src/quickgui/images/ic_photo_notavailable_white.svg
- +4 −0 src/quickgui/images/ic_save_white.svg
- +8 −0 src/quickgui/images/images.qrc
- +8 −0 src/quickgui/plugin/CMakeLists.txt
- +49 −0 src/quickgui/plugin/editor/qgsquickcheckbox.qml
- +125 −0 src/quickgui/plugin/editor/qgsquickdatetime.qml
- +85 −0 src/quickgui/plugin/editor/qgsquickexternalresource.qml
- +88 −0 src/quickgui/plugin/editor/qgsquicktextedit.qml
- +109 −0 src/quickgui/plugin/editor/qgsquickvaluemap.qml
- +487 −0 src/quickgui/plugin/qgsquickfeatureform.qml
- +47 −0 src/quickgui/plugin/qgsquickfeatureformstyling.qml
- +222 −0 src/quickgui/plugin/qgsquickphotopanel.qml
- +7 −0 src/quickgui/plugin/qgsquickplugin.cpp
- +3 −0 src/quickgui/plugin/qmldir
- +1 −1 src/quickgui/qgsquickcoordinatetransformer.h
- +1 −1 src/quickgui/qgsquickfeaturehighlight.h
- +5 −0 src/quickgui/qgsquickfeaturelayerpair.cpp
- +3 −0 src/quickgui/qgsquickfeaturelayerpair.h
- +3 −3 src/quickgui/qgsquickmaptransform.h
- +34 −0 src/quickgui/qgsquickutils.cpp
- +27 −2 src/quickgui/qgsquickutils.h
- +1 −0 tests/src/quickgui/app/CMakeLists.txt
- +73 −0 tests/src/quickgui/app/FeaturePanel.qml
- +27 −6 tests/src/quickgui/app/main.qml
- +1 −0 tests/src/quickgui/app/qml.qrc
- +1 −1 tests/src/quickgui/testqgsquickidentifykit.cpp
- +28 −0 tests/src/quickgui/testqgsquickutils.cpp
@@ -0,0 +1,72 @@ | ||
/*************************************************************************** | ||
qgsquickattributeformmodel.cpp | ||
-------------------------------------- | ||
Date : 22.9.2016 | ||
Copyright : (C) 2016 by Matthias Kuhn | ||
Email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsquickattributeformmodel.h" | ||
#include "qgsquickattributeformmodelbase.h" | ||
|
||
QgsQuickAttributeFormModel::QgsQuickAttributeFormModel( QObject *parent ) | ||
: QSortFilterProxyModel( parent ) | ||
, mSourceModel( new QgsQuickAttributeFormModelBase( this ) ) | ||
{ | ||
setSourceModel( mSourceModel ); | ||
connect( mSourceModel, &QgsQuickAttributeFormModelBase::hasTabsChanged, this, &QgsQuickAttributeFormModel::hasTabsChanged ); | ||
connect( mSourceModel, &QgsQuickAttributeFormModelBase::attributeModelChanged, this, &QgsQuickAttributeFormModel::attributeModelChanged ); | ||
connect( mSourceModel, &QgsQuickAttributeFormModelBase::constraintsValidChanged, this, &QgsQuickAttributeFormModel::constraintsValidChanged ); | ||
} | ||
|
||
bool QgsQuickAttributeFormModel::hasTabs() const | ||
{ | ||
return mSourceModel->hasTabs(); | ||
} | ||
|
||
void QgsQuickAttributeFormModel::setHasTabs( bool hasTabs ) | ||
{ | ||
mSourceModel->setHasTabs( hasTabs ); | ||
} | ||
|
||
QgsQuickAttributeModel *QgsQuickAttributeFormModel::attributeModel() const | ||
{ | ||
return mSourceModel->attributeModel(); | ||
} | ||
|
||
void QgsQuickAttributeFormModel::setAttributeModel( QgsQuickAttributeModel *attributeModel ) | ||
{ | ||
mSourceModel->setAttributeModel( attributeModel ); | ||
} | ||
|
||
bool QgsQuickAttributeFormModel::constraintsValid() const | ||
{ | ||
return mSourceModel->constraintsValid(); | ||
} | ||
|
||
void QgsQuickAttributeFormModel::save() | ||
{ | ||
mSourceModel->save(); | ||
} | ||
|
||
void QgsQuickAttributeFormModel::create() | ||
{ | ||
mSourceModel->create(); | ||
} | ||
|
||
QVariant QgsQuickAttributeFormModel::attribute( const QString &name ) const | ||
{ | ||
return mSourceModel->attribute( name ); | ||
} | ||
|
||
bool QgsQuickAttributeFormModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const | ||
{ | ||
return mSourceModel->data( mSourceModel->index( source_row, 0, source_parent ), CurrentlyVisible ).toBool(); | ||
} |
@@ -0,0 +1,122 @@ | ||
/*************************************************************************** | ||
qgsquickattributeformmodel.h | ||
-------------------------------------- | ||
Date : 22.9.2016 | ||
Copyright : (C) 2016 by Matthias Kuhn | ||
Email : matthias@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSQUICKATTRIBUTEFORMMODEL_H | ||
#define QGSQUICKATTRIBUTEFORMMODEL_H | ||
|
||
#include <QSortFilterProxyModel> | ||
|
||
#include "qgis_quick.h" | ||
|
||
class QgsQuickAttributeFormModelBase; | ||
class QgsQuickAttributeModel; | ||
class QVariant; | ||
|
||
/** | ||
* \ingroup quick | ||
* This is a model implementation for attribute form of a feature from a vector layer. | ||
* | ||
* The model is based on vector layer's edit form config (QgsEditFormConfig). It supports | ||
* auto-generated editor layouts and "tab" layout (layout defined with groups and tabs). | ||
* The form layout gets flattened into a list, each row has a bunch of roles with values | ||
* extracted from the edit form config. | ||
* | ||
* It also adds filtering of attribute (attributes may be visible or hidden based on expressions). | ||
* | ||
* \note QML Type: AttributeFormModel | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
class QUICK_EXPORT QgsQuickAttributeFormModel : public QSortFilterProxyModel | ||
{ | ||
Q_OBJECT | ||
|
||
//! Feature model with attributes | ||
Q_PROPERTY( QgsQuickAttributeModel *attributeModel READ attributeModel WRITE setAttributeModel NOTIFY attributeModelChanged ) | ||
|
||
//! Whether use tabs layout | ||
Q_PROPERTY( bool hasTabs READ hasTabs WRITE setHasTabs NOTIFY hasTabsChanged ) | ||
|
||
//! Returns true if all constraints defined on fields are satisfied with the current attribute values | ||
Q_PROPERTY( bool constraintsValid READ constraintsValid NOTIFY constraintsValidChanged ) | ||
|
||
public: | ||
|
||
//! Feature fields's roles | ||
enum FeatureFieldRoles | ||
{ | ||
ElementType = Qt::UserRole + 1, //!< User role used to identify either "field" or "container" type of item | ||
Name, //!< Field Name | ||
AttributeValue, //!< Field Value | ||
AttributeEditable, //!< Whether is field editable | ||
EditorWidget, //!< Widget type to represent the data (text field, value map, ...) | ||
EditorWidgetConfig, //!< Widget configuration | ||
RememberValue, //!< Remember value (default value for next feature) | ||
Field, //!< Field | ||
FieldIndex, //!< Index | ||
Group, //!< Group | ||
AttributeEditorElement, //!< Attribute editor element | ||
CurrentlyVisible, //!< Field visible | ||
ConstraintValid, //!< Contraint valid | ||
ConstraintDescription //!< Contraint description | ||
}; | ||
|
||
Q_ENUM( FeatureFieldRoles ) | ||
|
||
//! Create new attribute form model | ||
QgsQuickAttributeFormModel( QObject *parent = nullptr ); | ||
|
||
//! \copydoc QgsQuickAttributeFormModel::hasTabs | ||
bool hasTabs() const; | ||
|
||
//! \copydoc QgsQuickAttributeFormModel::hasTabs | ||
void setHasTabs( bool hasTabs ); | ||
|
||
//! \copydoc QgsQuickAttributeFormModel::attributeModel | ||
QgsQuickAttributeModel *attributeModel() const; | ||
|
||
//! \copydoc QgsQuickAttributeFormModel::attributeModel | ||
void setAttributeModel( QgsQuickAttributeModel *attributeModel ); | ||
|
||
//! \copydoc QgsQuickAttributeFormModel::constraintsValid | ||
bool constraintsValid() const; | ||
|
||
//! Updates QgsFeature based on changes | ||
Q_INVOKABLE void save(); | ||
|
||
//! Creates new QgsFeature | ||
Q_INVOKABLE void create(); | ||
|
||
//! Returns attribute value with name | ||
Q_INVOKABLE QVariant attribute( const QString &name ) const; | ||
|
||
signals: | ||
//! \copydoc QgsQuickAttributeFormModel::attributeModel | ||
void attributeModelChanged(); | ||
|
||
//! \copydoc QgsQuickAttributeFormModel::hasTabs | ||
void hasTabsChanged(); | ||
|
||
//! \copydoc QgsQuickAttributeFormModel::constraintsValid | ||
void constraintsValidChanged(); | ||
|
||
protected: | ||
virtual bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override; | ||
|
||
private: | ||
QgsQuickAttributeFormModelBase *mSourceModel = nullptr; //not owned | ||
}; | ||
|
||
#endif // QGSQUICKATTRIBUTEFORMMODEL_H |
Oops, something went wrong.