MCPcopy Create free account
hub / github.com/alpha-liu-01/SpeedyNote / insertPageInDocument

Method insertPageInDocument

source/MainWindow.cpp:3932–3988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3930}
3931
3932void MainWindow::insertPageInDocument()
3933{
3934 // Phase 3: Insert new page after current page
3935 // Works for both PDF and non-PDF documents (inserted page has no PDF background)
3936
3937 if (!tabManager()) {
3938#ifdef SPEEDYNOTE_DEBUG
3939 qDebug() << "insertPageInDocument: No tab manager";
3940#endif
3941 return;
3942 }
3943
3944 DocumentViewport* viewport = tabManager()->currentViewport();
3945 if (!viewport) {
3946#ifdef SPEEDYNOTE_DEBUG
3947 qDebug() << "insertPageInDocument: No current viewport";
3948#endif
3949 return;
3950 }
3951
3952 Document* doc = viewport->document();
3953 if (!doc) {
3954#ifdef SPEEDYNOTE_DEBUG
3955 qDebug() << "insertPageInDocument: No document in viewport";
3956#endif
3957 return;
3958 }
3959
3960 // Get current page index and insert after it
3961 int currentPageIndex = viewport->currentPageIndex();
3962 int insertIndex = currentPageIndex + 1;
3963
3964 // Clear undo/redo for pages >= insertIndex (they're shifting)
3965 // This must be done BEFORE the insert to avoid stale undo applying to wrong pages
3966 viewport->clearUndoStacksFrom(insertIndex);
3967
3968 // Insert page after current
3969 Page* newPage = doc->insertPage(insertIndex);
3970 if (newPage) {
3971#ifdef SPEEDYNOTE_DEBUG
3972 qDebug() << "insertPageInDocument: Inserted page at" << insertIndex
3973 << "in document" << doc->name << "(now" << doc->pageCount() << "pages)";
3974#endif
3975
3976 // Notify viewport that document structure changed
3977 viewport->notifyDocumentStructureChanged();
3978
3979 // Mark tab as modified
3980 int tabIndex = tabManager()->currentIndex();
3981 if (tabIndex >= 0) {
3982 tabManager()->markTabModified(tabIndex, true);
3983 }
3984
3985 // Update PagePanel and action bar
3986 notifyPageStructureChanged(doc);
3987 }
3988}
3989

Callers 1

Calls 9

clearUndoStacksFromMethod · 0.80
insertPageMethod · 0.80
currentIndexMethod · 0.80
markTabModifiedMethod · 0.80
currentViewportMethod · 0.45
documentMethod · 0.45
currentPageIndexMethod · 0.45
pageCountMethod · 0.45

Tested by

no test coverage detected