示例#1
0
/**
 * Handles the loading of trashed notes
 *
 * @brief OwnCloudService::handleTrashedLoading
 * @param data
 */
void OwnCloudService::handleTrashedLoading(QString data) {
    mainWindow->enableShowTrashButton();
    mainWindow->showStatusBarMessage(
            tr("done with loading trashed notes"), 2000);

    // check if we get any data at all
    if (data == "") {
        showOwnCloudServerErrorMessage();
        return;
    }

    // we have to add [], so the string can be parsed as JSON
    data = QString("[") + data + QString("]");

    QJSEngine engine;
    QJSValue result = engine.evaluate(data);

    // get a possible error messages
    // we are casting to QVariant first because otherwise we might get a
    // "undefined" string if "message" is not set
    QString message = result.property(0).property("message").toVariant()
            .toString();

    // check if we got an error message
    if (!message.isEmpty()) {
        showOwnCloudServerErrorMessage(message);
        return;
    }

    // get the directory to check if everything is all right
    QString directory = result.property(0).property("directory").toString();

    // check if we got no useful data
    if (directory == "") {
        showOwnCloudServerErrorMessage();
        return;
    }

    // get the versions
    QJSValue notes = result.property(0).property("notes");

    // check if we got no usefull data
    if (notes.toString() == "") {
        QMessageBox::information(0, "no other version",
                                 "There are no trashed notes on the server.");
        return;
    }

    TrashDialog *dialog = new TrashDialog(notes, mainWindow);
    dialog->exec();
}
示例#2
0
/**
 * Handles the loading of trashed notes
 *
 * @brief OwnCloudService::handleTrashedLoading
 * @param data
 */
void OwnCloudService::handleTrashedLoading(QString data) {
    // check if we get any data at all
    if (data == "") {
        if (QMessageBox::critical(
                0, "ownCloud server connection error!",
                "Cannot connect to the ownCloud server!<br />"
                        "Please check your configuration in the settings!",
                "Open &settings", "&Cancel", QString::null, 0, 1) == 0) {
            mainWindow->openSettingsDialog();
        }

        return;
    }

    // we have to add [], so the string can be parsed as JSON
    data = QString("[") + data + QString("]");

    QScriptEngine engine;
    QScriptValue result = engine.evaluate(data);

    // get a possible error messages
    QString message = result.property(0).property("message").toString();

    // check if we got an error message
    if (message != "") {
        if (QMessageBox::critical(
                0, "ownCloud server connection error!",
                "ownCloud server error: <strong>" + message + "</strong><br />"
                        "Please check your configuration in the settings!",
                "Open &settings", "&Cancel", QString::null, 0, 1) == 0) {
            mainWindow->openSettingsDialog();
        }

        return;
    }

    // get the directory to check if everything is all right
    QString directory = result.property(0).property("directory").toString();

    // check if we got no usefull data
    if (directory == "") {
        if (QMessageBox::critical(
                0, "ownCloud server connection error!",
                "QOwnNotes was unable to connect to your ownCloud server! "
                        "Please check the configuration in the settings!",
                "Open &settings", "&Cancel", QString::null, 0, 1) == 0) {
            mainWindow->openSettingsDialog();
        }

        return;
    }

    // get the versions
    QScriptValue notes = result.property(0).property("notes");

    // check if we got no usefull data
    if (notes.toString() == "") {
        QMessageBox::information(0, "no other version",
                                 "There are no trashed notes on the server.");
        return;
    }

    TrashDialog *dialog = new TrashDialog(notes, mainWindow);
    dialog->exec();
}