コード例 #1
0
void COARpeakAny::SetupArtifactInfo(const IOARpeak *p)
{
  // this is used for setting artifact info in
  // a peak that was created as an allele and
  // is now being set to be an artifact also
  if(p->IsArtifact())
  {
    SetIsArtifact(true);
    SetArtifactLabel(p->GetArtifactLabel());
    SetCriticalLevel(p->GetCriticalLevel());
    const wxDateTime &dt(p->GetUpdateTime());
    if(dt > GetUpdateTime())
    {
      SetUpdateTime(dt);
    }
  }
}
コード例 #2
0
ファイル: getpocketapi.cpp プロジェクト: Maledictus/LinksBag
void GetPocketApi::handleLoadBookmarks()
{
    emit requestFinished(true);

    bool ok = false;
    QJsonDocument doc = PreparsingReply(sender(), ok);
    if (!ok)
    {
        qWarning() << Q_FUNC_INFO << "Failed preparsing reply phase";
        return;
    }

    QJsonObject rootObject = doc.object();
    const quint64 since = rootObject["since"].toDouble();

    const auto& listObject = rootObject["list"].toObject();
    Bookmarks_t bookmarks;
    for(const auto& key : listObject.keys())
    {
        QJsonObject bookmarkObject = listObject[key].toObject();

        if (!bookmarkObject.contains("resolved_url") ||
                !bookmarkObject.contains("item_id"))
        {
            continue;
        }

        auto bm = std::make_shared<Bookmark>();
        bm->SetID(bookmarkObject["item_id"].toString());
        bm->SetUrl(bookmarkObject["resolved_url"].toString());
        QString title = bookmarkObject["resolved_title"].toString();
        if(title.isEmpty())
        {
            title = bookmarkObject["given_title"].toString();
        }
        if(title.isEmpty())
        {
            title = bm->GetUrl().toString();
        }
        bm->SetTitle(title);
        bm->SetDescription(bookmarkObject["excerpt"].toString());
        bm->SetIsFavorite(bookmarkObject["favorite"].toString() != "0" ||
                bookmarkObject["time_favorited"].toString() != "0");
        bm->SetIsRead(bookmarkObject["read"].toString() == "1" ||
                bookmarkObject["time_read"].toString() != "0");
        bm->SetAddTime(QDateTime::fromTime_t(bookmarkObject["time_added"]
                .toString().toLongLong()));
        bm->SetUpdateTime(QDateTime::fromTime_t(bookmarkObject["time_updated"]
                .toString().toLongLong()));
        const auto& tagsObject = bookmarkObject["tags"].toObject();
        bm->SetTags(tagsObject.keys());
        bm->SetImageUrl(bookmarkObject["image"].toObject()["src"].toString());
        bm->SetStatus(static_cast<Bookmark::Status>(bookmarkObject["status"]
                .toString().toInt()));
        Bookmark::ContentType ct = Bookmark::CTNoType;
        if (bookmarkObject.contains("is_article") && bookmarkObject["is_article"].toString().toInt() == 1)
        {
            ct = Bookmark::CTArticle;
        }
        else if (bookmarkObject.contains("has_image") && bookmarkObject["has_image"].toString().toInt() == 2)
        {
            ct = Bookmark::CTImage;
        }
        else if (bookmarkObject.contains("has_video") && bookmarkObject["has_video"].toString().toInt() == 2)
        {
            ct = Bookmark::CTVideo;
        }
        bm->SetContentType(ct);
        if (bookmarkObject.contains("images"))
        {
            const auto& imagesObject = bookmarkObject["images"].toObject();
            QList<QUrl> images;
            for(const auto& imageKey : imagesObject.keys())
            {
                QJsonObject imageObject = imagesObject[imageKey].toObject();
                if (imageObject.contains("src"))
                {
                    images << QUrl(imagesObject["src"].toString());
                }
            }
            bm->SetImages(images);
        }

        if (bookmarkObject.contains("videos"))
        {
            const auto& videosObject = bookmarkObject["videos"].toObject();
            QList<QUrl> videos;
            for(const auto& videoKey : videosObject.keys())
            {
                QJsonObject videoObject = videosObject[videoKey].toObject();
                if (videoObject.contains("src"))
                {
                    videos << QUrl(videoObject["src"].toString());
                }
            }
        }
        bookmarks << bm;
    }

    emit gotBookmarks(bookmarks, since);
}