From 194cf519e45c2c80035014dad11cb7fb245accc4 Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Sat, 2 Mar 2013 22:09:16 -0600 Subject: Add GUI check box control whether to retainn kpdf metadata. This resolves bug report 1215. --- kghostview/kghostview.kcfg | 15 ++++-- kpdf/conf/dlggeneral.ui | 20 +++++--- kpdf/conf/kpdf.kcfg | 5 +- kpdf/core/document.cpp | 117 +++++++++++++++++++++++---------------------- kviewshell/kviewshell.kcfg | 3 ++ 5 files changed, 91 insertions(+), 69 deletions(-) diff --git a/kghostview/kghostview.kcfg b/kghostview/kghostview.kcfg index 362191f3..441e1bb3 100644 --- a/kghostview/kghostview.kcfg +++ b/kghostview/kghostview.kcfg @@ -41,11 +41,16 @@ true - - - If this is on, then the file will be reloaded whenever it changes on disk - false - + + + If this is on, then the file will be reloaded whenever it changes on disk + false + + + + If this is on, then document viewing options are retained + true + diff --git a/kpdf/conf/dlggeneral.ui b/kpdf/conf/dlggeneral.ui index 430f3dfb..5348111d 100644 --- a/kpdf/conf/dlggeneral.ui +++ b/kpdf/conf/dlggeneral.ui @@ -85,12 +85,20 @@ - - kcfg_WatchFile - - - &Watch file - + + kcfg_WatchFile + + + &Watch file + + + + + kcfg_RetainDocumentData + + + &Retain document viewing data + diff --git a/kpdf/conf/kpdf.kcfg b/kpdf/conf/kpdf.kcfg index d980fd95..9f54b412 100644 --- a/kpdf/conf/kpdf.kcfg +++ b/kpdf/conf/kpdf.kcfg @@ -54,7 +54,10 @@ true - true + true + + + true diff --git a/kpdf/core/document.cpp b/kpdf/core/document.cpp index 8b5a1d4f..f97be985 100644 --- a/kpdf/core/document.cpp +++ b/kpdf/core/document.cpp @@ -1404,65 +1404,68 @@ void KPDFDocument::saveDocumentInfo() const if ( d->docFileName.isNull() ) return; - TQFile infoFile( d->xmlFileName ); - if (infoFile.open( IO_WriteOnly | IO_Truncate) ) + if ( KpdfSettings::retainDocumentData() ) { - // Create DOM - TQDomDocument doc( "documentInfo" ); - TQDomElement root = doc.createElement( "documentInfo" ); - doc.appendChild( root ); - - // Add bookmark list to DOM - TQDomElement bookmarkList = doc.createElement( "bookmarkList" ); - root.appendChild( bookmarkList ); - - for ( uint i = 0; i < pages_vector.count() ; i++ ) - { - if ( pages_vector[i]->hasBookmark() ) - { - TQDomElement page = doc.createElement( "page" ); - page.appendChild( doc.createTextNode( TQString::number(i) ) ); - - bookmarkList.appendChild( page ); - } - } - - // Add general info to DOM - TQDomElement generalInfo = doc.createElement( "generalInfo" ); - root.appendChild( generalInfo ); - - // ... saves history up to 10 viewports - TQValueList< DocumentViewport >::iterator backIterator = d->viewportIterator; - if ( backIterator != d->viewportHistory.end() ) - { - // go back up to 10 steps from the current viewportIterator - int backSteps = 10; - while ( backSteps-- && backIterator != d->viewportHistory.begin() ) - --backIterator; - - // create history root node - TQDomElement historyNode = doc.createElement( "history" ); - generalInfo.appendChild( historyNode ); - - // add old[backIterator] and present[viewportIterator] items - TQValueList< DocumentViewport >::iterator endIt = d->viewportIterator; - ++endIt; - while ( backIterator != endIt ) - { - TQString name = (backIterator == d->viewportIterator) ? "current" : "oldPage"; - TQDomElement historyEntry = doc.createElement( name ); - historyEntry.setAttribute( "viewport", (*backIterator).toString() ); - historyNode.appendChild( historyEntry ); - ++backIterator; - } - } - - // Save DOM to XML file - TQString xml = doc.toString(); - TQTextStream os( &infoFile ); - os << xml; + TQFile infoFile( d->xmlFileName ); + if (infoFile.open( IO_WriteOnly | IO_Truncate) ) + { + // Create DOM + TQDomDocument doc( "documentInfo" ); + TQDomElement root = doc.createElement( "documentInfo" ); + doc.appendChild( root ); + + // Add bookmark list to DOM + TQDomElement bookmarkList = doc.createElement( "bookmarkList" ); + root.appendChild( bookmarkList ); + + for ( uint i = 0; i < pages_vector.count() ; i++ ) + { + if ( pages_vector[i]->hasBookmark() ) + { + TQDomElement page = doc.createElement( "page" ); + page.appendChild( doc.createTextNode( TQString::number(i) ) ); + + bookmarkList.appendChild( page ); + } + } + + // Add general info to DOM + TQDomElement generalInfo = doc.createElement( "generalInfo" ); + root.appendChild( generalInfo ); + + // ... saves history up to 10 viewports + TQValueList< DocumentViewport >::iterator backIterator = d->viewportIterator; + if ( backIterator != d->viewportHistory.end() ) + { + // go back up to 10 steps from the current viewportIterator + int backSteps = 10; + while ( backSteps-- && backIterator != d->viewportHistory.begin() ) + --backIterator; + + // create history root node + TQDomElement historyNode = doc.createElement( "history" ); + generalInfo.appendChild( historyNode ); + + // add old[backIterator] and present[viewportIterator] items + TQValueList< DocumentViewport >::iterator endIt = d->viewportIterator; + ++endIt; + while ( backIterator != endIt ) + { + TQString name = (backIterator == d->viewportIterator) ? "current" : "oldPage"; + TQDomElement historyEntry = doc.createElement( name ); + historyEntry.setAttribute( "viewport", (*backIterator).toString() ); + historyNode.appendChild( historyEntry ); + ++backIterator; + } + } + + // Save DOM to XML file + TQString xml = doc.toString(); + TQTextStream os( &infoFile ); + os << xml; + } + infoFile.close(); } - infoFile.close(); } void KPDFDocument::slotTimedMemoryCheck() diff --git a/kviewshell/kviewshell.kcfg b/kviewshell/kviewshell.kcfg index 3114929c..b292b1ec 100644 --- a/kviewshell/kviewshell.kcfg +++ b/kviewshell/kviewshell.kcfg @@ -11,6 +11,9 @@ true + + true + 1.0 -- cgit v1.2.1