当前位置: 首页>>代码示例>>C++>>正文


C++ CalendarItem::isFetched方法代码示例

本文整理汇总了C++中CalendarItem::isFetched方法的典型用法代码示例。如果您正苦于以下问题:C++ CalendarItem::isFetched方法的具体用法?C++ CalendarItem::isFetched怎么用?C++ CalendarItem::isFetched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CalendarItem的用法示例。


在下文中一共展示了CalendarItem::isFetched方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_todoList_itemChanged

/**
 * @brief Updates the completed state of a calendar item on the ownCloud server
 * @param item
 */
void TodoDialog::on_todoList_itemChanged(QListWidgetItem *item) {
    qDebug() << __func__ << " - 'item': " << item;
    QString uid = item->data(Qt::UserRole).toString();

    CalendarItem calItem = CalendarItem::fetchByUid(uid);
    if (calItem.isFetched()) {
        calItem.updateCompleted(item->checkState() == Qt::Checked);
        calItem.store();

        OwnCloudService *ownCloud = OwnCloudService::instance();

        // post the calendar item to the server
        ownCloud->postCalendarItemToServer(calItem, this);
    }
}
开发者ID:pbek,项目名称:QOwnNotes,代码行数:19,代码来源:tododialog.cpp

示例2: slotReplyFinished

void OwnCloudService::slotReplyFinished(QNetworkReply *reply) {
    qDebug() << "Reply from " << reply->url().path();
    // qDebug() << reply->errorString();

    // this should only be called from the settings dialog
    if (reply->url().path().endsWith(appInfoPath)) {
        qDebug() << "Reply from app info";

        // check if everything is all right and call the callback method
        checkAppInfo(reply);

        return;
    } else {
        QByteArray arr = reply->readAll();
        QString data = QString(arr);

        if (reply->url().path().endsWith(versionListPath)) {
            qDebug() << "Reply from version list";
            // qDebug() << data;

            // handle the versions loading
            handleVersionsLoading(data);
            return;
        } else if (reply->url().path().endsWith(trashListPath)) {
            qDebug() << "Reply from trash list";
            // qDebug() << data;

            // handle the loading of trashed notes
            handleTrashedLoading(data);
            return;
        } else if (reply->url().path().endsWith(capabilitiesPath)) {
            qDebug() << "Reply from capabilities page";

            if (data.startsWith("<?xml version=")) {
                settingsDialog->setOKLabelData(3, "ok", SettingsDialog::OK);
            } else {
                settingsDialog->setOKLabelData(3, "not correct",
                                               SettingsDialog::Failure);
            }

            return;
        } else if (reply->url().path().endsWith(ownCloudTestPath)) {
            qDebug() << "Reply from ownCloud test page";

            if (data.startsWith("<?xml version=")) {
                settingsDialog->setOKLabelData(2, "ok", SettingsDialog::OK);
            } else {
                settingsDialog->setOKLabelData(2, "not detected",
                                               SettingsDialog::Failure);
            }

            return;
        } else if (reply->url().path().endsWith(restoreTrashedNotePath)) {
            qDebug() << "Reply from ownCloud restore trashed note page";
            // qDebug() << data;

            return;
        } else if (reply->url().path().endsWith(serverUrlPath + calendarPath)) {
            qDebug() << "Reply from ownCloud calendar page";
            // qDebug() << data;

            QStringList calendarHrefList = parseCalendarHrefList(data);
            settingsDialog->refreshTodoCalendarList(calendarHrefList);

            return;
        } else if (reply->url().path()
                .startsWith(serverUrlPath + calendarPath)) {
            // check if we have a reply from a calendar item request
            if (reply->url().path().endsWith(".ics")) {
                qDebug() << "Reply from ownCloud calendar item ics page";
                // qDebug() << data;

                // a workaround for a ownCloud error message
                if (data.indexOf(
                        "<s:message>Unable to generate a URL for the named"
                                " route \"tasksplus.page.index\" as such route"
                                " does not exist.</s:message>") >
                    20) {
                    data = "";
                }

                // this will mostly happen after the PUT request to update
                // or create a todo item
                if (data == "") {
                    // reload the todo list from server
                    this->todoDialog->reloadTodoList();
                }

                // increment the progress bar
                this->todoDialog->todoItemLoadingProgressBarIncrement();

                // fetch the calendar item, that was already stored
                // by loadTodoItems()
                CalendarItem calItem = CalendarItem::fetchByUrlAndCalendar(
                        reply->url().toString(), calendarName);
                if (calItem.isFetched()) {
                    // update the item with the ics data
                    bool wasUpdated = calItem.updateWithICSData(data);

                    // if item wasn't updated (for example because it was no
//.........这里部分代码省略.........
开发者ID:hckweb,项目名称:QOwnNotes,代码行数:101,代码来源:owncloudservice.cpp

示例3: loadTodoItems

void OwnCloudService::loadTodoItems(QString &data) {
    QDomDocument doc;
    doc.setContent(data, true);

    // fetch all urls that are currently in the calendar
    QList<QUrl> calendarItemUrlRemoveList =
            CalendarItem::fetchAllUrlsByCalendar(calendarName);

    QDomNodeList responseNodes = doc.elementsByTagNameNS(NS_DAV, "response");
    int responseNodesCount = responseNodes.length();
    int requestCount = 0;

    // set the preliminary maximum of the progress bar
    this->todoDialog->todoItemLoadingProgressBarSetMaximum(responseNodesCount);

    // loop all response blocks
    for (int i = 0; i < responseNodesCount; ++i) {
        QDomNode responseNode = responseNodes.at(i);
        if (responseNode.isElement()) {
            QDomElement elem = responseNode.toElement();

            // check if we have an url
            QDomNodeList urlPartNodes = elem.elementsByTagNameNS(NS_DAV,
                                                                 "href");
            if (urlPartNodes.length()) {
                QString urlPart = urlPartNodes.at(0).toElement().text();

                if (urlPart == "") {
                    continue;
                }

                QUrl calendarItemUrl = QUrl(serverUrlWithoutPath + urlPart);

                // check if we have an etag
                QDomNodeList etagNodes = elem.elementsByTagNameNS(NS_DAV,
                                                                  "getetag");
                if (etagNodes.length()) {
                    QString etag = etagNodes.at(0).toElement().text();
                    etag.replace("\"", "");
                    qDebug() << __func__ << " - 'etag': " << etag;

                    // check if we have a last modified date
                    QDomNodeList lastModifiedNodes = elem.elementsByTagNameNS(
                            NS_DAV, "getlastmodified");
                    if (lastModifiedNodes.length()) {
                        const QString lastModified = lastModifiedNodes.at(
                                0).toElement().text();
                        bool fetchItem = false;

                        // try to fetch the calendar item by url
                        CalendarItem calItem = CalendarItem::fetchByUrl(
                                calendarItemUrl);
                        if (calItem.isFetched()) {
                            // check if calendar item was modified
                            if (calItem.getETag() != etag) {
                                // store etag and last modified date
                                calItem.setETag(etag);
                                calItem.setLastModifiedString(lastModified);
                                calItem.store();

                                // we want to update the item from server
                                fetchItem = true;
                            }
                        } else {
                            // calendar item was not found
                            // create calendar item for fetching
                            CalendarItem::addCalendarItemForRequest(
                                    calendarName, calendarItemUrl, etag,
                                    lastModified);
                            fetchItem = true;
                        }

                        // remove the url from the list of calendar item urls
                        // to remove
                        if (calendarItemUrlRemoveList.contains(
                                calendarItemUrl)) {
                            calendarItemUrlRemoveList.removeAll(
                                    calendarItemUrl);
                        }

                        // fetch the calendar item
                        if (fetchItem) {
                            QNetworkRequest r(calendarItemUrl);
                            addAuthHeader(&r);

                            QNetworkReply *reply = networkManager->get(r);
                            ignoreSslErrorsIfAllowed(reply);

                            requestCount++;
                        }
                    }
                }
            }
        }
    }

    // set the real maximum of the progress bar
    this->todoDialog->todoItemLoadingProgressBarSetMaximum(requestCount);

    // hide progress bar if there were no updates
//.........这里部分代码省略.........
开发者ID:hckweb,项目名称:QOwnNotes,代码行数:101,代码来源:owncloudservice.cpp


注:本文中的CalendarItem::isFetched方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。