FileTabs& FileTabs::operator<<(const FileTabs &src) { Clear(); Stacking(false); SortGroups(false); Grouping(false); AddFiles(src.GetFiles(), src.GetIcons(), false); CopySettings(src); stackedicons = src.stackedicons; greyedicons = src.greyedicons; if (src.HasCursor()) SetData(~src); sc.SetPos(src.GetScrollPos()); Refresh(); return *this; }
bool CPdpManager::LoadFromFile(const string& fromFile ) { New(); if (fromFile.find(".hap") != fromFile.npos) { if (LoadFromXml(fromFile)) { SortGroups(); LoadOptionsFile(fromFile); StoreFileModTime(fromFile); StorePathFile(fromFile); return true; } return false; } fstream file( fromFile.c_str(), ios::in ); if( file.good() ) { StoreFileModTime(fromFile); StorePathFile(fromFile); string line = ""; do { char ch; file.read( &ch, 1 ); if( ch ) { if( ch == '\n' ) { if( !ProcessLine( line ) ) { return false; } line = ""; } else { line += ch; } } else { break; } } while( !file.eof() ); file.close(); } SortGroups(); return true; }
int CgptPrioritize(CgptPrioritizeParams *params) { struct drive drive; int priority; int gpt_retval; uint32_t index; uint32_t max_part; int num_root; int i,j; group_list_t *groups; if (params == NULL) return CGPT_FAILED; if (CGPT_OK != DriveOpen(params->drive_name, &drive, 0, O_RDWR)) return CGPT_FAILED; if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive.gpt))) { Error("GptSanityCheck() returned %d: %s\n", gpt_retval, GptError(gpt_retval)); return CGPT_FAILED; } max_part = GetNumberOfEntries(&drive); if (params->set_partition) { if (params->set_partition < 1 || params->set_partition > max_part) { Error("invalid partition number: %d (must be between 1 and %d\n", params->set_partition, max_part); goto bad; } index = params->set_partition - 1; // it must be a kernel if (!IsRoot(&drive, PRIMARY, index) && !IsMarker(&drive, PRIMARY, index)) { Error("partition %d is not a valid root\n", params->set_partition); goto bad; } } // How many kernel partitions do I have? num_root = 0; for (i = 0; i < max_part; i++) { if (IsRoot(&drive, PRIMARY, i) || IsMarker(&drive, PRIMARY, i)) num_root++; } if (num_root) { // Determine the current priority groups groups = NewGroupList(num_root); for (i = 0; i < max_part; i++) { if (!IsRoot(&drive, PRIMARY, i) && !IsMarker(&drive, PRIMARY, i)) continue; priority = GetPriority(&drive, PRIMARY, i); // Is this partition special? if (params->set_partition && (i+1 == params->set_partition)) { params->orig_priority = priority; // remember the original priority if (params->set_friends) AddToGroup(groups, priority, i); // we'll move them all later else AddToGroup(groups, 99, i); // move only this one } else { AddToGroup(groups, priority, i); // just remember } } // If we're including friends, then change the original group priority if (params->set_partition && params->set_friends) { ChangeGroup(groups, params->orig_priority, 99); } // Sorting gives the new order. Now we just need to reassign the // priorities. SortGroups(groups); // We'll never lower anything to zero, so if the last group is priority zero // we can ignore it. i = groups->num_groups; if (groups->group[i-1].priority == 0) groups->num_groups--; // Where do we start? if (params->max_priority) priority = params->max_priority; else priority = groups->num_groups > 15 ? 15 : groups->num_groups; // Figure out what the new values should be for (i=0; i<groups->num_groups; i++) { groups->group[i].priority = priority; if (priority > 1) priority--; } // Now apply the ranking to the GPT for (i=0; i<groups->num_groups; i++) for (j=0; j<groups->group[i].num_parts; j++) SetPriority(&drive, PRIMARY, groups->group[i].part[j], groups->group[i].priority); FreeGroups(groups); } // Write it all out UpdateAllEntries(&drive); return DriveClose(&drive, 1); bad: (void) DriveClose(&drive, 0); return CGPT_FAILED; }
bool QueueEditor::InternEditList(ItemList* itemList, IdList* idList, DownloadQueue::EEditAction action, int offset, const char* text) { ItemList workItems; if (!itemList) { itemList = &workItems; PrepareList(itemList, idList, action, offset); } switch (action) { case DownloadQueue::eaFilePauseAllPars: case DownloadQueue::eaFilePauseExtraPars: PauseParsInGroups(itemList, action == DownloadQueue::eaFilePauseExtraPars); break; case DownloadQueue::eaGroupMerge: return MergeGroups(itemList); case DownloadQueue::eaGroupSort: return SortGroups(itemList, text); case DownloadQueue::eaFileSplit: return SplitGroup(itemList, text); case DownloadQueue::eaFileReorder: ReorderFiles(itemList); break; default: for (EditItem& item : itemList) { switch (action) { case DownloadQueue::eaFilePause: PauseUnpauseEntry(item.m_fileInfo, true); break; case DownloadQueue::eaFileResume: PauseUnpauseEntry(item.m_fileInfo, false); break; case DownloadQueue::eaFileMoveOffset: case DownloadQueue::eaFileMoveTop: case DownloadQueue::eaFileMoveBottom: MoveEntry(item.m_fileInfo, item.m_offset); break; case DownloadQueue::eaFileDelete: DeleteEntry(item.m_fileInfo); break; case DownloadQueue::eaGroupSetPriority: SetNzbPriority(item.m_nzbInfo, text); break; case DownloadQueue::eaGroupSetCategory: case DownloadQueue::eaGroupApplyCategory: SetNzbCategory(item.m_nzbInfo, text, action == DownloadQueue::eaGroupApplyCategory); break; case DownloadQueue::eaGroupSetName: SetNzbName(item.m_nzbInfo, text); break; case DownloadQueue::eaGroupSetDupeKey: case DownloadQueue::eaGroupSetDupeScore: case DownloadQueue::eaGroupSetDupeMode: SetNzbDupeParam(item.m_nzbInfo, action, text); break; case DownloadQueue::eaGroupSetParameter: SetNzbParameter(item.m_nzbInfo, text); break; case DownloadQueue::eaGroupMoveTop: case DownloadQueue::eaGroupMoveBottom: case DownloadQueue::eaGroupMoveOffset: MoveGroup(item.m_nzbInfo, item.m_offset); break; case DownloadQueue::eaGroupPause: case DownloadQueue::eaGroupResume: case DownloadQueue::eaGroupPauseAllPars: case DownloadQueue::eaGroupPauseExtraPars: EditGroup(item.m_nzbInfo, action, offset, text); break; case DownloadQueue::eaGroupDelete: case DownloadQueue::eaGroupParkDelete: case DownloadQueue::eaGroupDupeDelete: case DownloadQueue::eaGroupFinalDelete: if (item.m_nzbInfo->GetKind() == NzbInfo::nkUrl) { DeleteUrl(item.m_nzbInfo, action); } else { EditGroup(item.m_nzbInfo, action, offset, text); } default: // suppress compiler warning "enumeration not handled in switch" break; } } } return itemList->size() > 0; }