Bug 116771 - [patch] Don't always switch to thumbnail view on reload
Summary: [patch] Don't always switch to thumbnail view on reload
Status: RESOLVED FIXED
Alias: None
Product: kpdf
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Albert Astals Cid
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-20 15:48 UTC by Mary Ellen Foster
Modified: 2007-04-21 01:19 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mary Ellen Foster 2005-11-20 15:48:58 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources
Compiler:          gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) 
OS:                Linux

Whenever kpdf loads a new document -- either from a "watch document" reload, or when truly loading a new document -- it always switches to "Thumbnails" mode in the sidebar, even if "Contents" was previously opened and the new document also has a set of bookmarks.

This is because, when closing a document, an empty document is temporarily sent around to all of the observers. The TOC widget processes this document, sees that it has no TOC, and disables itself, so the sidebar switches to "thumbnail" view. Then the real document gets opened and the TOC widget re-enables itself, but the sidebar stays switched.

This patch (against KPDF from KDE 3.5RC1) works around this issue by not changing the state of the TOC widget when an empty document is processed. I don't think this should break anything, but there may be implications I don't understand ...

--- kpdf/ui/toc.cpp.orig	2005-11-20 14:39:38.000000000 +0000
+++ kpdf/ui/toc.cpp	2005-11-20 14:40:00.000000000 +0000
@@ -72,7 +72,7 @@
     return TOC_ID;
 }
 
-void TOC::notifySetup( const QValueVector< KPDFPage * > & /*pages*/, bool documentChanged )
+void TOC::notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged )
 {
     if ( !documentChanged )
         return;
@@ -80,6 +80,11 @@
     // clear contents
     clear();
 
+    // if document is empty, return without checking the TOC status (we're probably
+    // inside closeDocument()).
+    if (pages.count() < 1)
+        return;
+
     // request synopsis description (is a dom tree)
     const DocumentSynopsis * syn = m_document->documentSynopsis();
Comment 1 Albert Astals Cid 2005-11-20 22:41:31 UTC
That's a bad solution because closing the document only (i know you can not do it from the ui, but it can be done), would leave the contents tab enabled. I will see if i find time to fix it.
Comment 2 Aleksey Nogin 2006-11-07 23:18:59 UTC
I would also like to see this feature implemented. In general, on reload (especially on "watch file" reload), the state of the program should be preserved as much as possible. In case of the "Contents" panel, this means that it should stay open, it should preserve the "expanded/collapsed" state as much as possible, etc.

P.S. Re: comment #2. I am not very qualified here, but what is wrong with keeping the contents tab enabled when there is no document opened - why would anybody care which tab happens to be enabled at this point?
Comment 3 Pino Toscano 2007-04-21 01:19:42 UTC
SVN commit 656308 by pino:

Restore the previously open pane in the side toolbox after reloading a watched document.

BUG: 116771


 M  +5 -0      part.cpp  
 M  +1 -0      part.h  


--- branches/KDE/3.5/kdegraphics/kpdf/part.cpp #656307:656308
@@ -603,6 +603,7 @@
   if (m_viewportDirty.pageNumber == -1)
   {
     m_viewportDirty = m_document->viewport();
+    m_dirtyToolboxIndex = m_toolBox->currentIndex();
     m_wasPresentationOpen = ((PresentationWidget*)m_presentationWidget != 0);
     m_pageView->showText(i18n("Reloading the document..."), 0);
   }
@@ -612,6 +613,10 @@
     if (m_viewportDirty.pageNumber >= (int)m_document->pages()) m_viewportDirty.pageNumber = (int)m_document->pages() - 1;
     m_document->setViewport(m_viewportDirty);
     m_viewportDirty.pageNumber = -1;
+    if ( m_toolBox->currentIndex() != m_dirtyToolboxIndex && m_toolBox->isItemEnabled( m_dirtyToolboxIndex ) )
+    {
+      m_toolBox->setCurrentIndex( m_dirtyToolboxIndex );
+    }
     if (m_wasPresentationOpen) slotShowPresentation();
     emit enablePrintAction(true);
   }
--- branches/KDE/3.5/kdegraphics/kpdf/part.h #656307:656308
@@ -161,6 +161,7 @@
 	QTimer *m_dirtyHandler;
 	DocumentViewport m_viewportDirty;
 	bool m_wasPresentationOpen;
+	int m_dirtyToolboxIndex;
 	
 	// Remember the search history
 	QStringList m_searchHistory;