Esempio n. 1
0
DisplayState* FileHistory::MarkFileLoaded(const WCHAR* filePath) {
    CrashIf(!filePath);
    // if a history entry with the same name already exists,
    // then reuse it. That way we don't have duplicates and
    // the file moves to the front of the list
    DisplayState* state = Find(filePath);
    if (!state) {
        state = NewDisplayState(filePath);
        state->useDefaultState = true;
    } else {
        states->Remove(state);
        state->isMissing = false;
    }
    states->InsertAt(0, state);
    state->openCount++;
    return state;
}
Esempio n. 2
0
void Favorites::AddOrReplace(const WCHAR* filePath, int pageNo, const WCHAR* name, const WCHAR* pageLabel) {
    DisplayState* fav = GetFavByFilePath(filePath);
    if (!fav) {
        CrashIf(gGlobalPrefs->rememberOpenedFiles);
        fav = NewDisplayState(filePath);
        gFileHistory.Append(fav);
    }

    Favorite* fn = FindByPage(fav, pageNo, pageLabel);
    if (fn) {
        str::ReplacePtr(&fn->name, name);
        CrashIf(fn->pageLabel && !str::Eq(fn->pageLabel, pageLabel));
    } else {
        fn = NewFavorite(pageNo, name, pageLabel);
        fav->favorites->Append(fn);
        fav->favorites->Sort(SortByPageNo);
    }
}