int CPatchUndoTest::ApplyEdit(int UndoCode) { CString UndoTitle(LDS(CMainFrame::GetUndoTitleID(UndoCode))); switch (UndoCode) { case UCODE_BASE_PATCH: { CString PageName, CtrlCaption; if (!DoPageEdit(&m_Main->GetPatchBar(), PageName, CtrlCaption)) return(DISABLED); PRINTF(_T("%s/%s/%s\n"), UndoTitle, PageName, CtrlCaption); } break; case UCODE_PART: { if (!gEngine.GetPartCount()) return(DISABLED); CString PageName, CtrlCaption; if (!DoPageEdit(m_Main->GetPartsBar().GetPageView(), PageName, CtrlCaption)) return(DISABLED); PRINTF(_T("%s[%d]/%s/%s\n"), UndoTitle, m_Main->GetPartsBar().GetCurPart(), PageName, CtrlCaption); } break; case UCODE_SELECT_PATCH_PAGE: { // get random patch page, excluding current page int iPage = RandomExcluding(CPatchBar::PAGES, m_Main->GetPatchBar().GetCurPage()); ASSERT(iPage >= 0); m_UndoMgr->NotifyEdit(0, UCODE_SELECT_PATCH_PAGE, CUndoable::UE_COALESCE | CUndoable::UE_INSIGNIFICANT); m_Main->GetPatchBar().SetCurPage(iPage); PRINTF(_T("%s %d\n"), UndoTitle, iPage); } break; case UCODE_SELECT_PART_PAGE: { // get random part page, excluding current page int iPage = RandomExcluding(CPartPageView::PAGES, m_Main->GetPartsBar().GetPageView()->GetCurPage()); ASSERT(iPage >= 0); m_UndoMgr->NotifyEdit(0, UCODE_SELECT_PART_PAGE, CUndoable::UE_COALESCE | CUndoable::UE_INSIGNIFICANT); m_Main->GetPartsBar().GetPageView()->SetCurPage(iPage); PRINTF(_T("%s %d\n"), UndoTitle, iPage); } break; case UCODE_SELECT_PART: { // get any part or none, excluding current part int iPart = RandomExcluding(gEngine.GetPartCount() + 1, gEngine.GetCurPart()) - 1; m_Main->GetPartsBar().GetListCtrl().SelectOnly(iPart); PRINTF(_T("%s %d\n"), UndoTitle, iPart); } break; case UCODE_ENABLE_PART: { int iPart = GetRandomPart(); if (iPart < 0) return(DISABLED); CListCtrl& list = m_Main->GetPartsBar().GetListCtrl(); list.SetCheck(iPart, !list.GetCheck(iPart)); PRINTF(_T("%s %d\n"), UndoTitle, iPart); } break; case UCODE_RENAME: { static const LPCTSTR SuffixTag = _T("$UT"); int iPart = GetRandomPart(); if (iPart < 0) return(DISABLED); CString name(m_Main->GetPartsBar().GetPartName(iPart)); int iChr = name.Find(SuffixTag); if (iChr >= 0) // if name already has suffix name = name.Left(iChr); // remove existing suffix CString suffix; suffix.Format(CString(SuffixTag) + _T("%d"), m_EditsDone); name += suffix; // append suffix to part name m_Main->GetUndoMgr().NotifyEdit(iPart, UCODE_RENAME); m_Main->GetPartsBar().SetPartName(iPart, name); PRINTF(_T("%s %d '%s'\n"), UndoTitle, iPart, name); } break; case UCODE_CUT: { CString sSel; if (!SelectRandomParts(sSel)) return(DISABLED); m_Main->SendMessage(WM_COMMAND, ID_EDIT_CUT); PRINTF(_T("%s %s\n"), UndoTitle, sSel); } break; case UCODE_PASTE: if (!m_Main->GetPartsBar().CanPaste()) return(DISABLED); m_Main->SendMessage(WM_COMMAND, ID_EDIT_PASTE); PRINTF(_T("%s %d\n"), UndoTitle, gEngine.GetCurPart()); break; case UCODE_INSERT: m_Main->SendMessage(WM_COMMAND, ID_EDIT_INSERT); PRINTF(_T("%s %d\n"), UndoTitle, gEngine.GetCurPart()); break; case UCODE_DELETE: { CString sSel; if (!SelectRandomParts(sSel)) return(DISABLED); m_Main->SendMessage(WM_COMMAND, ID_EDIT_DELETE); PRINTF(_T("%s %s\n"), UndoTitle, sSel); } break; case UCODE_REORDER: { if (gEngine.GetPartCount() < 2) return(DISABLED); CString sSel; if (!SelectRandomParts(sSel)) return(DISABLED); int InsPos = GetRandomInsertPos(); m_Main->GetPartsBar().OnListDrop(InsPos); PRINTF(_T("%s %s %d\n"), UndoTitle, sSel, InsPos); } break; default: NODEFAULTCASE; return(ABORT); } return(SUCCESS); }
QString MenuCommands::Get(int ind, What w) const { int cur = 0; if (cur++ == ind) return (w == Key ? FileKey() : (w == Title? FileTitle() : "")); if (cur++ == ind) return (w == Key ? NewWinKey() : (w == Title? NewWinTitle() : GetStr(NewWinShortcuts()))); if (cur++ == ind) return (w == Key ? OpenFileKey() : (w == Title? OpenFileTitle() : GetStr(OpenFileShortcuts()))); if (cur++ == ind) return (w == Key ? OpenLocKey() : (w == Title? OpenLocTitle() : GetStr(OpenLocShortcuts()))); if (cur++ == ind) return (w == Key ? SaveAsKey() : (w == Title? SaveAsTitle() : GetStr(SaveAsShortcuts()))); if (cur++ == ind) return (w == Key ? SavePdfKey() : (w == Title? SavePdfTitle() : GetStr(SavePdfShortcuts()))); if (cur++ == ind) return (w == Key ? ImportKey() : (w == Title? ImportTitle() : "")); if (cur++ == ind) return (w == Key ? ImportIEKey() : (w == Title? ImportIETitle() : GetStr(ImportIEShortcuts()))); if (cur++ == ind) return (w == Key ? ImportFFKey() : (w == Title? ImportFFTitle() : GetStr(ImportFFShortcuts()))); if (cur++ == ind) return (w == Key ? ImportHtmlKey() : (w == Title? ImportHtmlTitle() : GetStr(ImportHtmlShortcuts()))); if (cur++ == ind) return (w == Key ? ImportXmlKey() : (w == Title? ImportXmlTitle() : GetStr(ImportXmlShortcuts()))); if (cur++ == ind) return (w == Key ? ExportKey() : (w == Title? ExportTitle() : GetStr(ExportShortcuts()))); if (cur++ == ind) return (w == Key ? PrintKey() : (w == Title? PrintTitle() : GetStr(PrintShortcuts()))); if (cur++ == ind) return (w == Key ? PreviewKey() : (w == Title? PreviewTitle() : GetStr(PreviewShortcuts()))); if (cur++ == ind) return (w == Key ? QuitKey() : (w == Title? QuitTitle() : GetStr(QuitShortcuts()))); if (cur++ == ind) return (w == Key ? EditKey() : (w == Title? EditTitle() : "")); if (cur++ == ind) return (w == Key ? UndoKey() : (w == Title? UndoTitle() : GetStr(UndoShortcuts()))); if (cur++ == ind) return (w == Key ? RedoKey() : (w == Title? RedoTitle() : GetStr(RedoShortcuts()))); if (cur++ == ind) return (w == Key ? CutKey() : (w == Title? CutTitle() : GetStr(CutShortcuts()))); if (cur++ == ind) return (w == Key ? CopyKey() : (w == Title? CopyTitle() : GetStr(CopyShortcuts()))); if (cur++ == ind) return (w == Key ? PasteKey() : (w == Title? PasteTitle() : GetStr(PasteShortcuts()))); if (cur++ == ind) return (w == Key ? FindKey() : (w == Title? FindTitle() : GetStr(FindShortcuts()))); if (cur++ == ind) return (w == Key ? NextKey() : (w == Title? NextTitle() : GetStr(NextShortcuts()))); if (cur++ == ind) return (w == Key ? PrevKey() : (w == Title? PrevTitle() : GetStr(PrevShortcuts()))); if (cur++ == ind) return (w == Key ? PrefsKey() : (w == Title? PrefsTitle() : GetStr(PrefsShortcuts()))); if (cur++ == ind) return (w == Key ? ViewKey() : (w == Title? ViewTitle() : "")); if (cur++ == ind) return (w == Key ? AppStylesKey() : (w == Title? AppStylesTitle() : "")); if (cur++ == ind) return (w == Key ? StatusKey() : (w == Title? StatusTitle() : GetStr(StatusShortcuts()))); if (cur++ == ind) return (w == Key ? MenuKey() : (w == Title? MenuTitle() : GetStr(MenuShortcuts()))); if (cur++ == ind) return (w == Key ? TabKey() : (w == Title? TabTitle() : GetStr(TabShortcuts()))); if (cur++ == ind) return (w == Key ? NavKey() : (w == Title? NavTitle() : GetStr(NavShortcuts()))); if (cur++ == ind) return (w == Key ? BooksKey() : (w == Title? BooksTitle() : GetStr(BooksShortcuts()))); // if (cur++ == ind) // return (w == Key ? Key() : (w == Title? Title() : GetStr(Shortcuts()))); if (cur++ == ind) return (w == Key ? StopKey() : (w == Title? StopTitle() : GetStr(StopShortcuts()))); if (cur++ == ind) return (w == Key ? ReloadKey() : (w == Title? ReloadTitle() : GetStr(ReloadShortcuts()))); if (cur++ == ind) return (w == Key ? LargerKey() : (w == Title? LargerTitle() : GetStr(LargerShortcuts()))); if (cur++ == ind) return (w == Key ? NormalKey() : (w == Title? NormalTitle() : GetStr(NormalShortcuts()))); if (cur++ == ind) return (w == Key ? SmallerKey() : (w == Title? SmallerTitle() : GetStr(SmallerShortcuts()))); if (cur++ == ind) return (w == Key ? TextOnlyKey() : (w == Title? TextOnlyTitle() : GetStr(TextOnlyShortcuts()))); if (cur++ == ind) return (w == Key ? EncodeKey() : (w == Title? EncodeTitle() : "")); if (cur++ == ind) return (w == Key ? SourceKey() : (w == Title? SourceTitle() : GetStr(SourceShortcuts()))); if (cur++ == ind) return (w == Key ? FullKey() : (w == Title? FullTitle() : GetStr(FullShortcuts()))); if (cur++ == ind) return (w == Key ? HistoryKey() : (w == Title? HistoryTitle() : "")); if (cur++ == ind) return (w == Key ? BackKey() : (w == Title? BackTitle() : GetStr(BackShortcuts()))); if (cur++ == ind) return (w == Key ? ForwKey() : (w == Title? ForwTitle() : GetStr(ForwShortcuts()))); if (cur++ == ind) return (w == Key ? HomeKey() : (w == Title? HomeTitle() : GetStr(HomeShortcuts()))); if (cur++ == ind) return (w == Key ? LastTabKey() : (w == Title? LastTabTitle() : GetStr(LastTabShortcuts()))); if (cur++ == ind) return (w == Key ? LastTabsKey() : (w == Title? LastTabsTitle() : GetStr(LastTabsShortcuts()))); if (cur++ == ind) return (w == Key ? SessionKey() : (w == Title? SessionTitle() : GetStr(SessionShortcuts()))); if (cur++ == ind) return (w == Key ? AllHistKey() : (w == Title? AllHistTitle() : GetStr(AllHistShortcuts()))); if (cur++ == ind) return (w == Key ? ClearKey() : (w == Title? ClearTitle() : GetStr(ClearShortcuts()))); if (cur++ == ind) return (w == Key ? BookmarksKey() : (w == Title? BookmarksTitle() : "")); if (cur++ == ind) return (w == Key ? AllBooksKey() : (w == Title? AllBooksTitle() : GetStr(AllBooksShortcuts()))); if (cur++ == ind) return (w == Key ? AddBookKey() : (w == Title? AddBookTitle() : GetStr(AddBookShortcuts()))); if (cur++ == ind) return (w == Key ? PrivacyKey() : (w == Title? PrivacyTitle() : "")); if (cur++ == ind) return (w == Key ? PrivateKey() : (w == Title? PrivateTitle() : GetStr(PrivateShortcuts()))); if (cur++ == ind) return (w == Key ? JavaScriptKey() : (w == Title? JavaScriptTitle() : GetStr(JavaScriptShortcuts()))); if (cur++ == ind) return (w == Key ? ImagesKey() : (w == Title? ImagesTitle() : GetStr(ImagesShortcuts()))); if (cur++ == ind) return (w == Key ? CookiesKey() : (w == Title? CookiesTitle() : GetStr(CookiesShortcuts()))); if (cur++ == ind) return (w == Key ? PlugInsKey() : (w == Title? PlugInsTitle() : GetStr(PlugInsShortcuts()))); if (cur++ == ind) return (w == Key ? AgentKey() : (w == Title? AgentTitle() : GetStr(AgentShortcuts()))); if (cur++ == ind) return (w == Key ? PopUpsKey() : (w == Title? PopUpsTitle() : GetStr(PopUpsShortcuts()))); if (cur++ == ind) return (w == Key ? ProxyKey() : (w == Title? ProxyTitle() : GetStr(ProxyShortcuts()))); if (cur++ == ind) return (w == Key ? EmptyKey() : (w == Title? EmptyTitle() : GetStr(EmptyShortcuts()))); if (cur++ == ind) return (w == Key ? ResetKey() : (w == Title? ResetTitle() : GetStr(ResetShortcuts()))); if (cur++ == ind) return (w == Key ? FullResetKey() : (w == Title? FullResetTitle() : GetStr(FullResetShortcuts()))); if (cur++ == ind) return (w == Key ? ToolsKey() : (w == Title? ToolsTitle() : "")); if (cur++ == ind) return (w == Key ? CompatKey() : (w == Title? CompatTitle() : "")); if (cur++ == ind) return (w == Key ? SearchKey() : (w == Title? SearchTitle() : GetStr(SearchShortcuts()))); if (cur++ == ind) return (w == Key ? KeyboardKey() : (w == Title? KeyboardTitle() : GetStr(KeyboardShortcuts()))); if (cur++ == ind) return (w == Key ? InspectorKey() : (w == Title? InspectorTitle() : GetStr(InspectorShortcuts()))); if (cur++ == ind) return (w == Key ? InspectKey() : (w == Title? InspectTitle() : GetStr(InspectShortcuts()))); if (cur++ == ind) return (w == Key ? OptionsKey() : (w == Title? OptionsTitle() : GetStr(OptionsShortcuts()))); if (cur++ == ind) return (w == Key ? WindowKey() : (w == Title? WindowTitle() : "")); if (cur++ == ind) return (w == Key ? NextTabKey() : (w == Title? NextTabTitle() : GetStr(NextTabShortcuts()))); if (cur++ == ind) return (w == Key ? PrevTabKey() : (w == Title? PrevTabTitle() : GetStr(PrevTabShortcuts()))); if (cur++ == ind) return (w == Key ? NewTabKey() : (w == Title? NewTabTitle() : GetStr(NewTabShortcuts()))); if (cur++ == ind) return (w == Key ? CloseTabKey() : (w == Title? CloseTabTitle() : GetStr(CloseTabShortcuts()))); if (cur++ == ind) return (w == Key ? CloseOtherKey() : (w == Title? CloseOtherTitle() : GetStr(CloseOtherShortcuts()))); if (cur++ == ind) return (w == Key ? CloneTabKey() : (w == Title? CloneTabTitle() : GetStr(CloneTabShortcuts()))); if (cur++ == ind) return (w == Key ? ReloadTabKey() : (w == Title? ReloadTabTitle() : GetStr(ReloadTabShortcuts()))); if (cur++ == ind) return (w == Key ? ReloadAllKey() : (w == Title? ReloadAllTitle() : GetStr(ReloadAllShortcuts()))); if (cur++ == ind) return (w == Key ? OpenNewTabKey() : (w == Title? OpenNewTabTitle() : GetStr(OpenNewTabShortcuts()))); if (cur++ == ind) return (w == Key ? OpenAdBlockKey() : (w == Title? OpenAdBlockTitle() : GetStr(OpenAdBlockShortcuts()))); if (cur++ == ind) return (w == Key ? SwapFocusKey() : (w == Title? SwapFocusTitle() : GetStr(SwapFocusShortcuts()))); if (cur++ == ind) return (w == Key ? CopyAddrKey() : (w == Title? CopyAddrTitle() : "")); if (cur++ == ind) return (w == Key ? DownsKey() : (w == Title? DownsTitle() : GetStr(DownsShortcuts()))); if (cur++ == ind) return (w == Key ? TorrentsKey() : (w == Title? TorrentsTitle() : GetStr(TorrentsShortcuts()))); if (cur++ == ind) return (w == Key ? HelpKey() : (w == Title? HelpTitle() : GetStr(HelpShortcuts()))); if (cur++ == ind) return (w == Key ? OnlineKey() : (w == Title? OnlineTitle() : GetStr(OnlineShortcuts()))); if (cur++ == ind) return (w == Key ? UpdatesKey() : (w == Title? UpdatesTitle() : GetStr(UpdatesShortcuts()))); if (cur++ == ind) return (w == Key ? AboutKey() : (w == Title? AboutTitle() : GetStr(AboutShortcuts()))); return ""; }