Skip to content
Permalink
Browse files

Merge pull request #7350 from PeterPetrik/quick_featurepanel

[quick] [feature] Feature attribute panel
  • Loading branch information
m-kuhn committed Jul 13, 2018
2 parents 2699a42 + 660ce87 commit 12c8f394a51e7cf989281583c5914b89fe68cc1e
Showing with 3,089 additions and 14 deletions.
  1. +3 −0 doc/qgsquick.dox
  2. +11 −0 src/quickgui/CMakeLists.txt
  3. +72 −0 src/quickgui/attributes/qgsquickattributeformmodel.cpp
  4. +122 −0 src/quickgui/attributes/qgsquickattributeformmodel.h
  5. +383 −0 src/quickgui/attributes/qgsquickattributeformmodelbase.cpp
  6. +132 −0 src/quickgui/attributes/qgsquickattributeformmodelbase.h
  7. +331 −0 src/quickgui/attributes/qgsquickattributemodel.cpp
  8. +153 −0 src/quickgui/attributes/qgsquickattributemodel.h
  9. +183 −0 src/quickgui/attributes/qgsquicksubmodel.cpp
  10. +93 −0 src/quickgui/attributes/qgsquicksubmodel.h
  11. +5 −0 src/quickgui/images/ic_broken_image_black.svg
  12. +71 −0 src/quickgui/images/ic_camera_alt_border.svg
  13. +4 −0 src/quickgui/images/ic_check_black.svg
  14. +4 −0 src/quickgui/images/ic_clear_black.svg
  15. +4 −0 src/quickgui/images/ic_clear_white.svg
  16. +5 −0 src/quickgui/images/ic_delete_forever_white.svg
  17. +66 −0 src/quickgui/images/ic_photo_notavailable_white.svg
  18. +4 −0 src/quickgui/images/ic_save_white.svg
  19. +8 −0 src/quickgui/images/images.qrc
  20. +8 −0 src/quickgui/plugin/CMakeLists.txt
  21. +49 −0 src/quickgui/plugin/editor/qgsquickcheckbox.qml
  22. +125 −0 src/quickgui/plugin/editor/qgsquickdatetime.qml
  23. +85 −0 src/quickgui/plugin/editor/qgsquickexternalresource.qml
  24. +88 −0 src/quickgui/plugin/editor/qgsquicktextedit.qml
  25. +109 −0 src/quickgui/plugin/editor/qgsquickvaluemap.qml
  26. +487 −0 src/quickgui/plugin/qgsquickfeatureform.qml
  27. +47 −0 src/quickgui/plugin/qgsquickfeatureformstyling.qml
  28. +222 −0 src/quickgui/plugin/qgsquickphotopanel.qml
  29. +7 −0 src/quickgui/plugin/qgsquickplugin.cpp
  30. +3 −0 src/quickgui/plugin/qmldir
  31. +1 −1 src/quickgui/qgsquickcoordinatetransformer.h
  32. +1 −1 src/quickgui/qgsquickfeaturehighlight.h
  33. +5 −0 src/quickgui/qgsquickfeaturelayerpair.cpp
  34. +3 −0 src/quickgui/qgsquickfeaturelayerpair.h
  35. +3 −3 src/quickgui/qgsquickmaptransform.h
  36. +34 −0 src/quickgui/qgsquickutils.cpp
  37. +27 −2 src/quickgui/qgsquickutils.h
  38. +1 −0 tests/src/quickgui/app/CMakeLists.txt
  39. +73 −0 tests/src/quickgui/app/FeaturePanel.qml
  40. +27 −6 tests/src/quickgui/app/main.qml
  41. +1 −0 tests/src/quickgui/app/qml.qrc
  42. +1 −1 tests/src/quickgui/testqgsquickidentifykit.cpp
  43. +28 −0 tests/src/quickgui/testqgsquickutils.cpp
@@ -13,6 +13,9 @@ QGIS Quick consists of a Qt plugin that provides the QML components and of a sha

\subsection qgsquick_overview_widgets QML Classes
\subsubsection qgsquick_overview_widgets_mapcanvas MapCanvas
\subsubsection qgsquick_overview_widgets_featureform FeatureForm
A form listing attributes of a given feature. It supports basic edit field widgets for types such as edit text, map value,
checkbox, date/time picker or external resource (photo capture).
\subsubsection qgsquick_overview_widgets_positionmarker PositionMarker
The element refers to current position according gps location device connected to it. It holds information about longitude, latitude, altitude,
direction of the movement and accuracy of the signal. See also QgsQuickPositionKit.
@@ -1,6 +1,11 @@
############################################################
# sources
SET(QGIS_QUICK_GUI_MOC_HDRS
attributes/qgsquickattributeformmodel.h
attributes/qgsquickattributeformmodelbase.h
attributes/qgsquickattributemodel.h
attributes/qgsquicksubmodel.h

qgsquickfeaturelayerpair.h
qgsquickcoordinatetransformer.h
qgsquickfeaturehighlight.h
@@ -20,6 +25,11 @@ SET(QGIS_QUICK_GUI_HDRS
)

SET(QGIS_QUICK_GUI_SRC
attributes/qgsquickattributeformmodel.cpp
attributes/qgsquickattributeformmodelbase.cpp
attributes/qgsquickattributemodel.cpp
attributes/qgsquicksubmodel.cpp

qgsquickfeaturelayerpair.cpp
qgsquickcoordinatetransformer.cpp
qgsquickfeaturehighlight.cpp
@@ -37,6 +47,7 @@ SET(QGIS_QUICK_GUI_SRC

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/attributes
${CMAKE_CURRENT_BINARY_DIR}

${CMAKE_SOURCE_DIR}/src/core
@@ -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

0 comments on commit 12c8f39

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