Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QField 💖 QML & HTML #1221

Merged
merged 4 commits into from
Aug 21, 2020
Merged

QField 💖 QML & HTML #1221

merged 4 commits into from
Aug 21, 2020

Conversation

nirvn
Copy link
Member

@nirvn nirvn commented Aug 17, 2020

This PR implements QML widget support in the feature form. An obligatory GIF:
Peek 2020-08-17 13-33

As the above screencast demonstrates, the current implementation QField supports expression.evaluate(...). The method I've settled on to do it (i.e. string substitution in the QML source string) was the most appropriate solution I could come up with. On the plus side, the general idea behind it can easily be used to come up with an HTML widget support (via the WebView item).

@nirvn
Copy link
Member Author

nirvn commented Aug 17, 2020

BTW, the QML widget in the GIF nicely occupies the available width in QField:
Peek 2020-08-17 13-41

The way you set this up is by using the following declaration in the QML widget source code:

ChartView {
   ...
    width:parent.parent === null ? 400 : parent.width
   ...
}

Users can't simply use parent.width as in QGIS, the parent is a QQuickRootItem, which doesn't have a width value. Since there's no proper way to check whether a QML item is a root or not, we can check whether the parent has a parent (if it doesn't, it's the root).

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@@ -49,7 +49,7 @@ FeatureModel::ModelModes FeatureModel::modelMode() const

void FeatureModel::setFeature( const QgsFeature &feature )
{
if ( mModelMode != SingleFeatureModel || mFeature == feature )
if ( mModelMode != SingleFeatureModel )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To trigger a refresh when the feature is modified. If you look into FeatureModel::save(), you'll see it calls setFeature( modifiedFeature ), which ended up doing nothing as mFeature == modifiedFeature will be true even if the modifiedFeature has different attribute values et al.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth adding a bool force = false argument to the method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na, I've seen other weird behaviors which is fixed by this removed check. So I'd prefer just removing it all together.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mFeature == modifiedFeature will be true even if the modifiedFeature has different attribute values et al.

According to QgsFeatore::operator== attributes should be compared as well. What did I miss?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so no.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/qgis/QGIS/blob/master/src/core/qgsfeature.cpp#L68

I am no expert, but I would like to avoid having setters being executed too many times. It makes the debugging more difficult and might be noticeable by the user (rendering time, flickering).
but that's not my call to make here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll adjust.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3nids , done.

@nirvn
Copy link
Member Author

nirvn commented Aug 17, 2020

BTW, animations also work, can make for nice attention grabbing elements, e.g.:
Peek 2020-08-17 17-59

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@nirvn nirvn changed the title QField 💖 QML QField 💖 QML & HTML Aug 18, 2020
@nirvn
Copy link
Member Author

nirvn commented Aug 18, 2020

HTML widget support added:
Peek 2020-08-18 13-24

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@nirvn
Copy link
Member Author

nirvn commented Aug 18, 2020

@m-kuhn , I think we might have a bit of work to do on the osgeo4a side of things to add the QML WebView module.

@nirvn
Copy link
Member Author

nirvn commented Aug 18, 2020

@m-kuhn , I suspect a similar update will be required for QML charts module too. See how the QML chart widget is missing when testing on my smartphone:
image

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@m-kuhn
Copy link
Member

m-kuhn commented Aug 19, 2020

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@nirvn nirvn force-pushed the qml branch 2 times, most recently from f739e28 to 0f031eb Compare August 19, 2020 07:25
@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@nirvn
Copy link
Member Author

nirvn commented Aug 19, 2020

@m-kuhn , this is all green and ready to approve.

sdk.conf Show resolved Hide resolved
@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

.docker/testing/Dockerfile Outdated Show resolved Hide resolved
@qfield-fairy
Copy link
Collaborator

Uploaded test apks for

@nirvn nirvn merged commit a1793f4 into master Aug 21, 2020
@m-kuhn m-kuhn deleted the qml branch September 7, 2020 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants