EOutlinerTextStyle XFE_AddrBookView::getColumnHeaderStyle(int column) { ABID sortType = 0; switch (column) { case OUTLINER_COLUMN_TYPE: sortType = ABTypeEntry; break; case OUTLINER_COLUMN_NAME: sortType = ABFullName; break; case OUTLINER_COLUMN_EMAIL: sortType = ABEmailAddress; break; case OUTLINER_COLUMN_NICKNAME: sortType = ABNickname; break; case OUTLINER_COLUMN_COMPANY: sortType = ABCompany; break; case OUTLINER_COLUMN_LOCALITY: sortType = ABLocality; break; }/* switch */ if (sortType == getSortType()) return OUTLINER_Bold; else return OUTLINER_Default; }
Boolean XFE_AddrBookView::isCommandSelected(CommandType cmd, void */* calldata */, XFE_CommandInfo* /* i */) { /* * XP_Bool AB_GetPaneSortedAscending(ABPane * pABookPane); * ABID AB_GetPaneSortedBy(ABPane * pABookPane); */ ABID sortType = 0; if (cmd == xfeCmdABByType) sortType = ABTypeEntry; else if (cmd == xfeCmdABByName) sortType = ABFullName; else if (cmd == xfeCmdABByEmailAddress) sortType = ABEmailAddress; else if (cmd == xfeCmdABByCompany) sortType = ABCompany; else if (cmd == xfeCmdABByLocality) sortType = ABLocality; else if (cmd == xfeCmdABByNickName) sortType = ABNickname; if (sortType > 0) { if (sortType == getSortType()) return True; return False; }/* if */ else if ((cmd == xfeCmdSortAscending && isAscending())|| (cmd == xfeCmdSortDescending && !isAscending())) return True; return False; }
bool operator()(const AnyAtomicType::Ptr &a, const AnyAtomicType::Ptr &b) const { AnyAtomicType::AtomicObjectType atype = getSortType(a); AnyAtomicType::AtomicObjectType btype = getSortType(b); if(atype != btype) return atype < btype; // Items are comparable switch(atype) { case AnyAtomicType::STRING: return collation_->compare(a->asString(context_), b->asString(context_)) < 0; case AnyAtomicType::DOUBLE: return ((const Numeric *)a.get())->compare((const Numeric *)b.get(), context_) < 0; case AnyAtomicType::DURATION: return ((const ATDurationOrDerived *)a.get())->compare((const ATDurationOrDerived *)b.get(), context_) < 0; case AnyAtomicType::BASE_64_BINARY: return ((const ATBase64BinaryOrDerived *)a.get())->compare((const ATBase64BinaryOrDerived *)b.get(), context_) < 0; case AnyAtomicType::BOOLEAN: return ((const ATBooleanOrDerived *)a.get())->compare((const ATBooleanOrDerived *)b.get(), context_) < 0; case AnyAtomicType::DATE: return ((const ATDateOrDerived *)a.get())->compare((const ATDateOrDerived *)b.get(), context_) < 0; case AnyAtomicType::DATE_TIME: return ((const ATDateTimeOrDerived *)a.get())->compare((const ATDateTimeOrDerived *)b.get(), context_) < 0; case AnyAtomicType::G_DAY: return ((const ATGDayOrDerived *)a.get())->compare((const ATGDayOrDerived *)b.get(), context_) < 0; case AnyAtomicType::G_MONTH: return ((const ATGMonthOrDerived *)a.get())->compare((const ATGMonthOrDerived *)b.get(), context_) < 0; case AnyAtomicType::G_MONTH_DAY: return ((const ATGMonthDayOrDerived *)a.get())->compare((const ATGMonthDayOrDerived *)b.get(), context_) < 0; case AnyAtomicType::G_YEAR: return ((const ATGYearOrDerived *)a.get())->compare((const ATGYearOrDerived *)b.get(), context_) < 0; case AnyAtomicType::G_YEAR_MONTH: return ((const ATGYearMonthOrDerived *)a.get())->compare((const ATGYearMonthOrDerived *)b.get(), context_) < 0; case AnyAtomicType::HEX_BINARY: return ((const ATHexBinaryOrDerived *)a.get())->compare((const ATHexBinaryOrDerived *)b.get(), context_) < 0; case AnyAtomicType::NOTATION: return ((const ATNotationOrDerived *)a.get())->compare((const ATNotationOrDerived *)b.get(), context_) < 0; case AnyAtomicType::QNAME: return ((const ATQNameOrDerived *)a.get())->compare((const ATQNameOrDerived *)b.get(), context_) < 0; case AnyAtomicType::TIME: return ((const ATTimeOrDerived *)a.get())->compare((const ATTimeOrDerived *)b.get(), context_) < 0; default: break; } assert(false); return false; }
// this updates all collection files related to the argument file void CollectionSystemManager::updateCollectionSystems(FileData* file) { // collection files use the full path as key, to avoid clashes std::string key = file->getFullPath(); // find games in collection systems for(auto sysIt = SystemData::sSystemVector.begin(); sysIt != SystemData::sSystemVector.end(); sysIt++) { if ((*sysIt)->isCollection()) { const std::unordered_map<std::string, FileData*>& children = (*sysIt)->getRootFolder()->getChildrenByFilename(); bool found = children.find(key) != children.end(); FileData* rootFolder = (*sysIt)->getRootFolder(); FileFilterIndex* fileIndex = (*sysIt)->getIndex(); std::string name = (*sysIt)->getName(); if (found) { // if we found it, we need to update it FileData* collectionEntry = children.at(key); // remove from index, so we can re-index metadata after refreshing fileIndex->removeFromIndex(collectionEntry); collectionEntry->refreshMetadata(); if (name == "favorites" && file->metadata.get("favorite") == "false") { // need to check if still marked as favorite, if not remove ViewController::get()->getGameListView((*sysIt)).get()->remove(collectionEntry, false); ViewController::get()->onFileChanged((*sysIt)->getRootFolder(), FILE_REMOVED); } else { // re-index with new metadata fileIndex->addToIndex(collectionEntry); ViewController::get()->onFileChanged(collectionEntry, FILE_METADATA_CHANGED); } } else { // we didn't find it here - we need to check if we should add it if (name == "recent" && file->metadata.get("playcount") > "0" || name == "favorites" && file->metadata.get("favorite") == "true") { CollectionFileData* newGame = new CollectionFileData(file, (*sysIt)); rootFolder->addChild(newGame); fileIndex->addToIndex(newGame); ViewController::get()->onFileChanged(file, FILE_METADATA_CHANGED); ViewController::get()->getGameListView((*sysIt))->onFileChanged(newGame, FILE_METADATA_CHANGED); } } rootFolder->sort(getSortType(mCollectionSystemDecls[name].defaultSort)); ViewController::get()->onFileChanged(rootFolder, FILE_SORTED); } } }
void CollectionSystemManager::loadAutoCollectionSystems() { for(std::map<std::string, CollectionSystemDecl>::iterator it = mCollectionSystemDecls.begin() ; it != mCollectionSystemDecls.end() ; it++ ) { CollectionSystemDecl sysDecl = it->second; if (!sysDecl.isCustom && !findCollectionSystem(sysDecl.name)) { SystemData* newSys = new SystemData(sysDecl.name, sysDecl.longName, mCollectionEnvData, sysDecl.themeFolder, true); FileData* rootFolder = newSys->getRootFolder(); FileFilterIndex* index = newSys->getIndex(); for(auto sysIt = SystemData::sSystemVector.begin(); sysIt != SystemData::sSystemVector.end(); sysIt++) { if ((*sysIt)->isGameSystem()) { std::vector<FileData*> files = (*sysIt)->getRootFolder()->getFilesRecursive(GAME); for(auto gameIt = files.begin(); gameIt != files.end(); gameIt++) { bool include = includeFileInAutoCollections((*gameIt)); switch(sysDecl.type) { case AUTO_LAST_PLAYED: include = include && (*gameIt)->metadata.get("playcount") > "0"; break; case AUTO_FAVORITES: // we may still want to add files we don't want in auto collections in "favorites" include = (*gameIt)->metadata.get("favorite") == "true"; break; } if (include) { CollectionFileData* newGame = new CollectionFileData(*gameIt, newSys); rootFolder->addChild(newGame); index->addToIndex(newGame); } } } } rootFolder->sort(getSortType(sysDecl.defaultSort)); mAutoCollectionSystems.push_back(newSys); CollectionSystemData newCollectionData; newCollectionData.system = newSys; newCollectionData.decl = sysDecl; newCollectionData.isEnabled = false; mAllCollectionSystems[sysDecl.name] = newCollectionData; } } }