void BookViewPreview::ScrollToFragment(const QString &fragment) { if (IsLoadingFinished()) { ScrollToFragmentInternal(fragment); } else { m_pendingScrollToFragment = fragment; } }
bool FlowTab::SetViewState(MainWindow::ViewState new_view_state) { // There are only two ways a tab can get routed into a particular viewstate. // At FlowTab construction time, all initialisation is done via a timer to // call DelayedInitialization(). So that needs to handle first time tab state. // The second route is via this function, which is invoked from MainWindow // any time a tab is switched to. // Do we really need to do anything? Not if we are already in this state. if (new_view_state == m_ViewState) { return false; } // Ignore this function if we are in the middle of doing an initial load // of the content. We don't want it to save over the content with nothing // if this is called before the delayed initialization function is called. if (m_initialLoad || !IsLoadingFinished()) { return false; } // Our well formed check will be run if switching to BV. If this check fails, // that check will set our tab viewstate to be in CV. if (new_view_state == MainWindow::ViewState_BookView && !IsDataWellFormed()) { return false; } // We do a save (if pending changes) before switching to ensure we don't lose // any unsaved data in the current view, as cannot rely on lost focus happened. SaveTabContent(); // Track our previous view state for the purposes of caret syncing m_previousViewState = m_ViewState; m_ViewState = new_view_state; if (new_view_state == MainWindow::ViewState_CodeView) { // As CV is directly hooked to the QTextDocument, we never have to "Load" content // except for when creating the CV control for the very first time. CreateCodeViewIfRequired(); CodeView(); } else { CreateBookViewIfRequired(); LoadTabContent(); BookView(); } return true; }