ArcGIS for Developers

VersionNumber QML Type

Allows for containing and altering of version numbers. More...

Import Statement: import ArcGIS.AppFramework 1.0
Inherits:

AppFrameworkObject

Properties

Methods

Detailed Description

The VersionNumber component provides an interface to check the app's current version number, as well as to edit if necessary.

Version numbers are separated into three separate numbers, separated by decimal points. The first is the macro number, followed by the minor, and then the micro.

This code sample demonstrates a potential usage of VersionNumber, by comparing the version number of the current AppStudio version with one provided in a text field.

App {
    id: app
    width: 400
    height: 640

    Column {
        anchors.fill: parent
        anchors.margins: 10
        spacing: 10

        RowLayout {

            Text {
                text: qsTr("AppFramework Version: " + AppFramework.version)
            }

        }

        RowLayout {

            Text {
                text: qsTr("Enter a version number")
            }

            TextField {
                id: version2Text
                placeholderText: "0.0.0"
                width: 60
            }
        }

        RowLayout {
            Button {
                text: "Compare"
                onClicked: {
                    var ver1 = AppFramework.versionNumber(AppFramework.version);//AppFramework.versionNumber(version1Text.text);
                    var ver2 = AppFramework.versionNumber(version2Text.text);

                    var result =  ver1.compare(ver2);
                    if (result < 0 )
                        logTextArea.text = "Result: " + result + ". AppFramework Version is less than the input version";
                    else if (result === 0 )
                        logTextArea.text = "Result: " + result + ". AppFramework Version is equal to the input version";
                    else
                        logTextArea.text = "Result: " + result + ". AppFramework Version is greater than the input version";

                }
            }

            Button {
                text: "Clear"
                onClicked: {
                    logTextArea.text = "";
                }
            }
        }

        TextArea {
            id: logTextArea
            visible: text != ""
            width: parent.width
            height: 200
        }
   }
}

Property Documentation

major : int

The first of the three components of a version number. For example, for version 3.7.355, this property would contain 3.


micro : int

The third of the three components of a version number. For example, for version 3.7.355, this property would contain 355.


minor : int

The second of the three components of a version number. For example, for version 3.7.355, this property would contain 7.


[read-only] versionString : string

Contains a full, read-only string of the version number. For example, 3.7.355.


Method Documentation

int compare(version2)

Compares a provided version number, other than the version number already contained in this component. This will return an integer less than, equal to, or greater than zero, depending on if the contained version number is less than, equal to, or greater than the provided version number, respectively.

The version2 parameter

The other version number, to compare the contained version number against.