DocumentDialog QML Type

(BETA) Provides access to documents external to your app. More...

Import Statement: import ArcGIS.AppFramework.Platform 1.0

Properties

Signals

Methods

Detailed Description

The DocumentDialog component is used to access documents external to your app, of any filetype. This component doesn't facilitate interaction with these files; this needs to be provided by other components.

On Android, the External Storage capability must be enabled in the Capabilities tab of the Settings tool to use this component in an app. You also need to use a PermissionDialog pop-up before invoking the document dialog. The app will crash if this capability is not enabled.

Only files available on the device's local storage can be accessed using DocumentDialog. Files stored in a cloud service will first need to be downloaded before using DocumentDialog to browse to and select them.

The following code sample demonstrates opening a document dialog to search through your device's files.

Item {

    property bool storagePermissionGranted

    Component.onCompleted: {
        // Check if storage permission is granted (this is only required for Android)
        storagePermissionGranted = Permission.checkPermission(Permission.PermissionTypeStorage) === Permission.PermissionResultGranted
    }

    PermissionDialog {
        id: permissionDialog
        openSettingsWhenDenied: true
        permission: PermissionDialog.PermissionDialogTypeStorage

        onAccepted: {
            doc.open()
            console.log("Permission accepted")
        }

        onRejected: {
            console.log("Permission rejected")
        }
    }

    Button {
        text: "Select document"
        onClicked: {
            if (doc.supported) {
                if (storagePermissionGranted) {
                    doc.open();
                } else {
                    permissionDialog.open();
                }
            } else {
                console.log("Not Supported");
            }
        }
    }

        DocumentDialog {
                id: doc

                onAccepted: {
                        console.log("selected file path " , fileUrl.filePath)
                }

                onRejected: {
                        if (status == DocumentDialog.DocumentDialogCancelledByUser) {
                                // Cancelled By User
                        }
                        if (status == DocumentDialog.DocumentDialogPermissionDenied) {
                                // Permission Denied
                        }
                        if (status == DocumentDialog.DocumentDialogNotSupported) {
                                // Not Supported
                        }
                        if (status == DocumentDialog.DocumentDialogFileReadError) {
                                // File Read Error
                        }
                }
        }
}

Property Documentation

defaultSuffix : string

The suffix to be added to the filename, provided no other suffix was specified.


error : object

If the document dialog faces an error, this property will contain a description fo the error.


fileUrl : url

The path of the file selected by the user.


fileUrls : object

The list of file paths selected by the user.


folder : url

The path to the currently selected folder. Setting this property before invoking the open method will cause the file browser to be initially positioned on the specified folder.

On desktop platforms, this property supports any valid folder path.

On Android and iOS, this property only supports either being set to the fileUrl property from another DocumentDialog component with the selectFolder property set to true, or by setting it to appFramework.userPath or any subfolders inside the user home path.


modality : int

This property is informed by Qt's WindowModality enum. If set to Qt::NonModal, the document dialog will not block input to other windows. If set to Qt::WindowModal, the document dialog will block all input to any parent windows, and siblings of the parent windows. If set to Qt::ApplicationModal, the dialog blocks all input to all other windows. By default, this property is set to Qt::WindowModal.

This property has no effect on iOS and Android devices.


nameFilters : QStringList

A list of strings to be used as file name filters. Each string can be a space-separated list of filters; filters may include the ? and * wildcards.


selectExisting : bool

Setting this to true allows only selection of existing files and folders. When set to false, DocumentDialog can be used to save and create files.


selectFolder : bool

Setting this to true allows selection of folders. Setting this to false only alows the user to select files.


selectMultiple : bool

True if more than one filename can be selected. Otherwise, false.


selectedNameFilter : string

Which of the possible NameFIlters is currently selected.


[read-only] shortcuts : var

A map of some useful paths from StandardPaths to their URLs. Each path is verified to exist on the user's device before being added to this list at the time when this component is created.


sidebarVisible : bool


title : string

The title of the dialog window.


Signal Documentation

accepted()

Signal emitted when the process of opening an external document has succeeded. The signal will return the filepath of the document that was opened.

Note: The corresponding handler is onAccepted.


rejected()

Signal emitted when the request to access external documents has failed, either by encountering an error or cancelling the dialog. This signal also returns the error state, informed by the DocumentDialogErrorStatus enum.

Note: The corresponding handler is onRejected.


Method Documentation

object close()

Closes the document dialog.


object open()

Attempts to open a document selection dialog.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.