QVariant BookmarksModel::data (const QModelIndex& index, int role) const { if (index.row () < 0 || index.row () > Bookmarks_.count ()) return QVariant (); auto bookmark = Bookmarks_.at (index.row ()); switch (role) { case BRID: return bookmark->GetID (); case BRUrl: return bookmark->GetUrl (); case BRTitle: return bookmark->GetTitle (); case BRDescription: return bookmark->GetDescription (); case BRImageUrl: return bookmark->GetImageUrl (); case BRFavorite: return bookmark->IsFavorite (); case BRRead: return bookmark->IsRead (); case BRTags: return bookmark->GetTags ().join (','); case BRAddTime: return bookmark->GetAddTime (); case BRUpdateTime: return bookmark->GetUpdateTime (); case BRStatus: return bookmark->GetStatus (); default: return QVariant (); } }
QList<Entry> AccountStorage::GetLastEntries (AccountStorage::Mode mode, int count) { Q_UNUSED (mode); GetLastEntries_.bindValue (":limit", count); if (!GetLastEntries_.exec ()) { Util::DBLock::DumpError (GetLastEntries_); throw std::runtime_error ("unable to get entries"); } QList<Entry> list; while (GetLastEntries_.next ()) { Entry e; e.EntryId_ = GetLastEntries_.value (0).toLongLong (); e.Content_ = GetLastEntries_.value (1).toString (); e.Date_ = GetLastEntries_.value (2).toDateTime (); e.Subject_ = GetLastEntries_.value (3).toString (); GetEntryTags_.bindValue (":entry_id", e.EntryId_); e.Tags_ = GetTags (GetEntryTags_); list << e; } GetLastEntries_.finish (); return list; }
QList<Entry> AccountStorage::GetEntriesByDate (const QDate& date) { GetEntriesByDate_.bindValue (":date", date); if (!GetEntriesByDate_.exec ()) { Util::DBLock::DumpError (GetEntriesByDate_); throw std::runtime_error ("unable to get entries"); } QList<Entry> list; while (GetEntriesByDate_.next ()) { Entry e; e.EntryId_ = GetEntriesByDate_.value (0).toInt (); e.Content_ = GetEntriesByDate_.value (1).toString (); e.Date_ = GetEntriesByDate_.value (2).toDateTime (); e.Subject_ = GetEntriesByDate_.value (3).toString (); GetEntryTags_.bindValue (":entry_id", e.EntryId_); e.Tags_ = GetTags (GetEntryTags_); list << e; } GetEntriesByDate_.finish (); return list; }
boolean CBcmPropertyTags::GetTag (u32 nTagId, void *pTag, unsigned nTagSize, unsigned nRequestParmSize) { assert (pTag != 0); assert (nTagSize >= sizeof (TPropertyTagSimple)); TPropertyTag *pHeader = (TPropertyTag *) pTag; pHeader->nTagId = nTagId; pHeader->nValueBufSize = nTagSize - sizeof (TPropertyTag); pHeader->nValueLength = nRequestParmSize & ~VALUE_LENGTH_RESPONSE; if (!GetTags (pTag, nTagSize)) { return FALSE; } if (!(pHeader->nValueLength & VALUE_LENGTH_RESPONSE)) { return FALSE; } pHeader->nValueLength &= ~VALUE_LENGTH_RESPONSE; if (pHeader->nValueLength == 0) { return FALSE; } return TRUE; }
String VersionInfo::NoncompatibleTagsMessage(const SceneVersion& version) const { const TagsMap& allTags = GetTags(version.version); const TagsMap& warnTags = GetTagsDiff(version.tags, allTags); // List of tags that will be added to scene const String& msg = FormatTagsString(warnTags); return msg; }
String VersionInfo::UnsupportedTagsMessage(const SceneVersion& version) const { const TagsMap& allTags = GetTags(); const TagsMap& errTags = GetTagsDiff(allTags, version.tags); // List of tags that not supported by current version of framework const String& msg = FormatTagsString(errTags); return msg; }
FTag UAbility::GetTag(FString name) { for (FTag tag : GetTags()) { if (tag.name.Equals(name)) return tag; } return FTag(); }
bool UAbility::HasTag(FString name) { for (FTag tag : GetTags()) { if (tag.name.Equals(name)) return true; } return false; }
void BookmarksModel::AddBookmarks (const Bookmarks_t& bookmarks) { Bookmarks_t bmss = bookmarks; for (int i = bmss.count () - 1; i >= 0; --i) { auto bms = bmss.at (i); auto it = std::find_if (Bookmarks_.begin (), Bookmarks_.end (), [bms] (decltype (Bookmarks_.front ()) bookmark) { return bms->GetID () == bookmark->GetID (); }); if (it != Bookmarks_.end ()) { const int pos = std::distance (Bookmarks_.begin (), it); switch (bms->GetStatus ()) { case Bookmark::SDeleted: RemoveBookmark (bms->GetID ()); break; case Bookmark::SArchived: { Bookmark *bm = Bookmarks_ [pos]; bm->SetIsRead (true); emit dataChanged (index (pos), index (pos)); break; } default: { Bookmark *bm = Bookmarks_ [pos]; bm->SetUrl (bms->GetUrl ()); bm->SetTitle (bms->GetTitle ()); bm->SetDescription (bms->GetDescription ()); bm->SetIsFavorite (bms->IsFavorite ()); bm->SetIsRead (bms->IsRead ()); bm->SetAddTime (bms->GetAddTime ()); bm->SetUpdateTime (bms->GetUpdateTime ()); bm->SetTags (bms->GetTags ()); bm->SetImageUrl (bms->GetImageUrl ()); bm->SetStatus (bms->GetStatus ()); emit dataChanged (index (pos), index (pos)); break; } } bmss.takeAt (i)->deleteLater (); } } beginInsertRows (QModelIndex (), rowCount (), rowCount () + bmss.count () - 1); Bookmarks_.append (bmss); endInsertRows (); }
void PolygonItem::StatePerformed(dword state, const String& param) { if (state == PERFORM_SEARCH) { if (param.IsEmpty() || ToLower(GetName() + GetTags()).Find(ToLower(param)) < 0) StateOff(STATE_FOUND); else StateOn (STATE_FOUND); } }
VersionInfo::eStatus VersionInfo::TestVersion(const SceneVersion& version) const { const SceneVersion& current = GetCurrentVersion(); // Checking version if (current.version < version.version) return INVALID; // Checking tags const TagsMap& tags = version.tags; const TagsMap& fwAllTags = GetTags(); const TagsMap& fwVersionedTags = GetTags(version.version); const TagsMap& errTags = GetTagsDiff(tags, fwAllTags); // List of tags that not supported by current version of framework const TagsMap& warnTags = GetTagsDiff(fwVersionedTags, tags); // List of tags that will be added to scene if ( errTags.size() > 0 ) return INVALID; if ( warnTags.size() > 0 ) return COMPATIBLE; return VALID; }
uint32_t Recordset::GetInteger(unsigned int which) const { if (which == mediadb::ID) return m_id; if (IsEOF()) return 0; if (m_got_what & GOT_BASIC) { if (which == mediadb::TYPE) return m_freers->GetInteger(which); } if ((m_got_what & GOT_TAGS) == 0) GetTags(); return m_freers->GetInteger(which); }
void LastfmTrackInfoProvider::RequestFinished() { QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); if (!reply || !requests_.contains(reply)) return; const int id = requests_.take(reply); if (reply->error() != QNetworkReply::NoError) { emit Finished(id); return; } lastfm::XmlQuery query(lastfm::compat::EmptyXmlQuery()); if (lastfm::compat::ParseQuery(reply->readAll(), &query)) { GetPlayCounts(id, query); GetWiki(id, query); GetTags(id, query); } emit Finished(id); }
std::string Recordset::GetString(unsigned int which) const { if (IsEOF()) return std::string(); if (m_got_what & GOT_BASIC) { if (which == mediadb::TITLE) return m_freers->GetString(which); } if (which == mediadb::CHILDREN) { if ((m_got_what & GOT_CHILDREN) == 0) GetChildren(); return m_freers->GetString(which); } if ((m_got_what & GOT_TAGS) == 0) GetTags(); return m_freers->GetString(which); }
QList<Entry> AccountStorage::GetEntriesWithFilter (const Filter& filter) { GetFilteredEntries_.bindValue (":begin_date", filter.BeginDate_); GetFilteredEntries_.bindValue (":end_date", filter.EndDate_); if (!GetFilteredEntries_.exec ()) { Util::DBLock::DumpError (GetFilteredEntries_); throw std::runtime_error ("unable to get entries"); } QList<Entry> list; while (GetFilteredEntries_.next ()) { Entry e; e.EntryId_ = GetFilteredEntries_.value (0).toLongLong (); e.Content_ = GetFilteredEntries_.value (1).toString (); e.Date_ = GetFilteredEntries_.value (2).toDateTime (); e.Subject_ = GetFilteredEntries_.value (3).toString (); GetEntryTags_.bindValue (":entry_id", e.EntryId_); e.Tags_ = GetTags (GetEntryTags_); bool found = false; for (const auto& tag : filter.Tags_) if (e.Tags_.contains (tag)) { found = true; break; } if (found) list << e; } GetFilteredEntries_.finish (); return list; }
Entry AccountStorage::GetFullEntry (qint64 entryId) { GetFullEntry_.bindValue (":entry_id", entryId); if (!GetFullEntry_.exec ()) { Util::DBLock::DumpError (GetFullEntry_); throw std::runtime_error ("unable to get full entry by id"); } Entry e; while (GetFullEntry_.next ()) { e.EntryId_ = entryId; e.Content_ = GetFullEntry_.value (1).toString (); e.Date_ = GetFullEntry_.value (2).toDateTime (); e.Subject_ = GetFullEntry_.value (3).toString (); GetEntryTags_.bindValue (":entry_id", e.EntryId_); e.Tags_ = GetTags (GetEntryTags_); } GetFullEntry_.finish (); return e; }
void Recordset::GetChildren() const { if (!m_freers) m_freers = db::FreeRecordset::Create(); if ((m_got_what & GOT_BASIC) == 0) GetTags(); unsigned int type = m_freers->GetInteger(mediadb::TYPE); if (type != mediadb::DIR && type != mediadb::PLAYLIST) { m_got_what |= GOT_CHILDREN; return; } Connection::Lock lock(m_parent); m_parent->m_infomap.clear(); std::string objectid = m_parent->ObjectIdForId(m_id); // TRACE << "GetChildren(" << m_id << "[=" << objectid << "])\n"; /* We only want objectids, which are obligatory, so we pass filter "". * * Intel libupnp only allows a certain maximum size of a SOAP response, so * in case the list is very long we ask for it in clumps. */ enum { LUMP = 32 }; std::vector<unsigned int> childvec; for (unsigned int start=0; ; start += LUMP) { std::string result; uint32_t nret = 0; uint32_t total = 0; unsigned int rc = m_parent->GetContentDirectory() ->Browse(objectid, ::upnp::ContentDirectory::BROWSEFLAG_BROWSE_DIRECT_CHILDREN, "", start, LUMP, "", &result, &nret, &total, NULL); if (rc == 0) { mediadb::didl::MetadataList ml = mediadb::didl::Parse(result); for (mediadb::didl::MetadataList::iterator i = ml.begin(); i != ml.end(); ++i) { Connection::BasicInfo bi; unsigned int id = 0; for (mediadb::didl::Metadata::iterator j = i->begin(); j != i->end(); ++j) { if (j->tag == "id") { std::string childid = j->content; id = m_parent->IdForObjectId(childid); // TRACE << "child '" << childid << "' = " << id << "\n"; childvec.push_back(id); break; } } if (id) { db::RecordsetPtr child_rs = db::FreeRecordset::Create(); mediadb::didl::ToRecord(*i, child_rs); bi.type = child_rs->GetInteger(mediadb::TYPE); bi.title = child_rs->GetString(mediadb::TITLE); m_parent->m_infomap[id] = bi; } } } else break; if (start + nret == total) break; } m_freers->SetString(mediadb::CHILDREN, mediadb::VectorToChildren(childvec)); m_got_what |= GOT_CHILDREN; }
Tag* Struct::GetTag ( uint32_t type ) const { return FindTag ( GetTags(), type ); }
Tag* Bitfield::GetTag ( uint32_t type ) const { return FindTag ( GetTags(), type ); }
Tag* SelectItem::GetTag ( uint32_t type ) const { return FindTag ( GetTags(), type ); }
int main(int argc, char* argv[]) { char lib1FileName[1000], lib2FileName[1000], chromFileName[1000],configFileName[2000], projectName[1000]; CONFIG_STRUCT config; CHROM_INFO chroms[MAX_CHROM_NUM]; int chromNum; double noiseRate, l1Ratio, l2Ratio; int maxL1Count, maxL2Count; int i; if (argc!=6) { printf("Usage: <library 1 tag file name> <library 2 tag file name> <chromosome length file name> <config file name> <project name>\n"); return 0; } strcpy(lib1FileName, argv[1]); strcpy(lib2FileName, argv[2]); strcpy(chromFileName, argv[3]); strcpy(configFileName, argv[4]); strcpy(projectName, argv[5]); chromNum = GetChromInfo(chromFileName, chroms); if (chromNum<=0) { return 0; } printf("chromosome length information read. chromNum = %d!\n", chromNum); for (i=0;i<chromNum;i++) { chroms[i].l1PosTagNum = 0; chroms[i].l2PosTagNum = 0; chroms[i].l1NegTagNum = 0; chroms[i].l2NegTagNum = 0; chroms[i].l1PeakNum = 0; chroms[i].l2PeakNum = 0; } if (ReadConfigFile(configFileName, &config)<0) { printf("config file not complet. Default setting used.\n"); } printf("config file read.\n"); printf("fragmentSize = %d\n", config.fragmentSize); printf("isStrandSensitiveMode = %d\n", config.isStrandSensitiveMode); printf("slidingWinSize = %d\n", config.slidingWinSize); printf("movingStep = %d\n", config.movingStep); printf("outputNum = %d\n", config.outputNum); printf("minCount = %d\n", config.minCount); printf("minScore = %f\n", config.minScore); printf("bootstrapPass = %d\n", config.bootstrapPass); printf("randSeed = %d\n", config.randomSeed); printf("reading tag files......\n"); if (!GetTags(lib1FileName, lib2FileName, chroms, chromNum)) { printf("tag file error!\n"); return 0; } printf("tag file read.\n"); printf("pre-processing......\n"); if (PreProcessing(chroms, chromNum)<0) { printf("Preprocessing failed!\n CCAT aborted!\n"); return -1; } printf("pre-processing finished.\n"); printf("estimating noise rate......\n"); srand(config.randomSeed); noiseRate = ComputeNoiseRate(chroms,chromNum, &l1Ratio,&l2Ratio, config); printf("noise rate = %f\n", noiseRate); printf("peak-finding......\n"); if (PeakFinding(chroms,chromNum,l1Ratio,l2Ratio, &maxL1Count, &maxL2Count, config)<=0) { return -1; } printf("peak-finding finished.\n"); printf("Significance Analysis......\n"); if (SignificanceAnalysis(chroms, chromNum, l1Ratio, l2Ratio, maxL1Count, maxL2Count, config)<0) { printf("DPS paramter esitmation failed!\n"); return -1; } printf("Significance analysis finished.\n"); printf("saving results.......\n"); OutputFiles(chroms, chromNum, projectName, config); printf("results saved.\n"); FreeChromMem(chroms,chromNum); printf("CCAT process completed!\n"); return 0; }