Commit 5f48094e authored by Enrico Ros's avatar Enrico Ros

History saving/restoring in addition to the current viewport.

svn path=/trunk/kdegraphics/kpdf/; revision=383327
parent f644f4e8
......@@ -11,7 +11,6 @@ Status:
mechanism the core is ready for a public release.
In progress 3.4 features (deadline is 2k5-Feb-2):
-> save/restore history (partially committed)
-> new word highlighting for searches / other highlights
More items (first items will enter 'In progress list' first):
......@@ -23,13 +22,12 @@ More items (first items will enter 'In progress list' first):
-> cleanup code and update README.png
-> find-as-you-type: use shortcut for 'find next' action (not the default one)
-> show Viewport in ThumbnailsList (blended/contour)
-> history as a toolbox child (collecting Doc's viewport changes notifications)
-> Delay TOC (DocumentSynapsis) generation (and move it on thread)
-> refactor ThumbnailsList to do internal rendering as pageview does (way faster
than using QScrollView + inserted Widgets and saves 8% on document loading)
-> move toolbar view actions in the PageView instead of the part. maybe.. or not...
-> usability: layout 2PPV [1 2,3 4,5 6] -> [1,2 3,4 5]. add option for 'ebook' style alignment
-> usability: trigger redraw on 'filter text' on current page
-> usability: trigger redraw on 'filter text' on current page (need new highligh engine first)
-> abstract TextPage generation (the last xpdf dependant class!). then go dancing in the
streets.
-> better boomark rendering (tested a 'clip overlay' but looks bad actually)
......@@ -39,7 +37,7 @@ More items (first items will enter 'In progress list' first):
- <X> Synopsis will go there after 1st generation (so we can edit it too)
- <X> Document info (after the 1st gen)
- <X> Bookmarked pages
- <X - only for viewport> General info (like viewport state)
- <X> Current Viewport and 10 history steps
- Edited pages (rotated/with_data for example)
- Overlay editing (hilighting/notations/etc..)
- Presentation related overrides (FS mode, individual / global transitions)
......@@ -47,7 +45,6 @@ More items (first items will enter 'In progress list' first):
The Object will reside into the Document and must not be accessible by Oservers in
a direct way. Dom format, relations to other classes and accessing must be specified
in a separated diagram or text file.
-> right click and drag while in 'scroll' mode changes to 'selection' mode and selects
-> add kpdf manual in PDF format loaded on the first startup or on menu->help->manual
this visually explains basic usage, mouse buttons functions & more..
-> take care of TODOs in code
......@@ -56,7 +53,7 @@ More items (first items will enter 'In progress list' first):
-> screen editing (annotations): tools (BR67300), yellow notes 'post-it' like
-> export all text in plain_text/html
-> extract(export?) images (have a look at ImageOutputDev.cc and pdfimages.cc from xpdf (not in our xpdf sources))
-> text selection in wordprocessor style (very hard/impossible)
-> text selection in wordprocessor style (very hard)
-> zoom: fit text (with configurable margin)
-> open gzipped (.pdf.gz?) files
-> kttsd output with menu entries. speech{document/page/selection}. (patch available - enrico)
......@@ -70,6 +67,7 @@ More items (first items will enter 'In progress list' first):
-> presentation: save a flag (to the xml) to open a pdf in presentation mode
-> presentation: link following (difficult due to pagerects related to pageview pixmap only)
-> presentation: wheel not visible on black. gradient appreciated on lighter backgrounds.
-> history as a toolbox child (collecting Doc's viewport changes notifications)
-> investigate 'Splash' lack of smoothness at low resolutions (see lines in thumbnails)
-> add search on the toc widget (a prune on type lineedit like in thumbnails widget)
-> goto 'logical' page (usually differs from pdf's page) (req. by Luca Burrelli)
......@@ -81,8 +79,9 @@ More items (first items will enter 'In progress list' first):
-> export: export to other formats keeping formatting (a dream.. except for PNG :-) (PS is easy, we just have PSOutputDev that does it :-D)
Done (newest features come first):
-> CHG: right click and drag while in 'normal' mode changes to 'selection' mode and selects
-> FIX: complete valgrind check and leakfix (2 leaks were present) [27-Jan-04]
-> ADD: history (100 steps) and forward/back actions
-> ADD: history, forward/back history actions, history links and xml storage (10 steps)
-> ADD: rmb popup on thumbnailslist (the popup shared with pageView: same behavior)
-> ADD: display 'current page' / 'total pages' with analog indicator, active labels, etc
-> CHG: Presentation mode is now Ctrl+Shift+p instead of F9 because it was colliding with Konqueror's toggle sidebar
......
......@@ -929,65 +929,90 @@ void KPDFDocument::loadDocumentInfo()
{
//kdDebug() << "Using '" << d->xmlFileName << "' as document info file." << endl;
QFile infoFile( d->xmlFileName );
if (infoFile.exists() && infoFile.open( IO_ReadOnly ) )
if ( !infoFile.exists() || !infoFile.open( IO_ReadOnly ) )
return;
// Load DOM from XML file
QDomDocument doc( "documentInfo" );
if ( !doc.setContent( &infoFile ) )
{
// Load DOM from XML file
QDomDocument doc( "documentInfo" );
if ( !doc.setContent( &infoFile ) )
{
kdDebug() << "Could not set content" << endl;
infoFile.close();
return;
}
kdDebug() << "Could not set content" << endl;
infoFile.close();
return;
}
infoFile.close();
QDomElement root = doc.documentElement();
if (root.tagName() != "documentInfo") return;
QDomElement root = doc.documentElement();
if ( root.tagName() != "documentInfo" )
return;
// Parse the DOM tree
QDomNode topLevelNode = root.firstChild();
while ( topLevelNode.isElement() )
{
QString catName = topLevelNode.toElement().tagName();
// Parse the DOM tree
QDomNode topLevelNode = root.firstChild();
while ( topLevelNode.isElement() )
{
QString catName = topLevelNode.toElement().tagName();
// Get bookmarks list from DOM
if ( catName == "bookmarkList" )
// Get bookmarks list from DOM
if ( catName == "bookmarkList" )
{
QDomNode n = topLevelNode.firstChild();
QDomElement e;
int pageNumber;
bool ok;
while ( n.isElement() )
{
QDomNode n = topLevelNode.firstChild();
QDomElement e;
int pageNumber;
bool ok;
while ( n.isElement() )
e = n.toElement();
if (e.tagName() == "page")
{
e = n.toElement();
if (e.tagName() == "page")
{
pageNumber = e.text().toInt(&ok);
if ( ok && pageNumber >= 0 && pageNumber < (int)pages_vector.count() )
pages_vector[ pageNumber ]->setAttribute( KPDFPage::Bookmark );
}
n = n.nextSibling();
pageNumber = e.text().toInt(&ok);
if ( ok && pageNumber >= 0 && pageNumber < (int)pages_vector.count() )
pages_vector[ pageNumber ]->setAttribute( KPDFPage::Bookmark );
}
n = n.nextSibling();
}
// Get 'general info' from the DOM
else if ( catName == "generalInfo" )
} // </bookmarkList>
// Get 'general info' from the DOM
else if ( catName == "generalInfo" )
{
QDomNode infoNode = topLevelNode.firstChild();
while ( infoNode.isElement() )
{
QDomNode infoNode = topLevelNode.firstChild();
while ( infoNode.isElement() )
QDomElement infoElement = infoNode.toElement();
// compatibility: [pre-3.4 viewport storage] @remove after 3.4 relase
if ( infoElement.tagName() == "activePage" )
{
QDomElement infoElement = infoNode.toElement();
if ( infoElement.tagName() == "activePage" )
if ( infoElement.hasAttribute( "viewport" ) )
*d->viewportIterator = DocumentViewport( infoElement.attribute( "viewport" ) );
}
// restore viewports history
if ( infoElement.tagName() == "history" )
{
// clear history
d->viewportHistory.clear();
// append old viewports
QDomNode historyNode = infoNode.firstChild();
while ( historyNode.isElement() )
{
if ( infoElement.hasAttribute( "viewport" ) )
*d->viewportIterator = DocumentViewport( infoElement.attribute( "viewport" ) );
QDomElement historyElement = historyNode.toElement();
if ( historyElement.hasAttribute( "viewport" ) )
{
QString vpString = historyElement.attribute( "viewport" );
d->viewportIterator = d->viewportHistory.append(
DocumentViewport( vpString ) );
}
historyNode = historyNode.nextSibling();
}
infoNode = infoNode.nextSibling();
// consistancy check
if ( d->viewportHistory.isEmpty() )
d->viewportIterator = d->viewportHistory.append( DocumentViewport() );
}
infoNode = infoNode.nextSibling();
}
topLevelNode = topLevelNode.nextSibling();
}
}
infoFile.close();
} // </generalInfo>
topLevelNode = topLevelNode.nextSibling();
} // </documentInfo>
}
QString KPDFDocument::giveAbsolutePath( const QString & fileName )
......@@ -1088,21 +1113,32 @@ void KPDFDocument::saveDocumentInfo() const
QDomElement generalInfo = doc.createElement( "generalInfo" );
root.appendChild( generalInfo );
// <general info><activePage />
QDomElement activePage = doc.createElement( "activePage" );
activePage.setAttribute( "viewport", (*d->viewportIterator).toString() );
generalInfo.appendChild( activePage );
/*
// <general info><history> ... </history>
QDomElement historyNode = doc.createElement( "history" );
generalInfo.appendChild( historyNode );
for ( uint i = 0; i < 6 ; i++ )
// <general info><history> ... </history> saves history up to 10 viewports
QValueList< DocumentViewport >::iterator backIterator = d->viewportIterator;
if ( backIterator != d->viewportHistory.end() )
{
QDomElement historyEntry = doc.createElement( "entry" );
historyEntry.setAttribute( "viewport", DocumentViewport().toString() );
historyNode.appendChild( historyEntry );
// go back up to 10 steps from the current viewportIterator
int backSteps = 10;
while ( backSteps-- && backIterator != d->viewportHistory.begin() )
--backIterator;
// create history root node
QDomElement historyNode = doc.createElement( "history" );
generalInfo.appendChild( historyNode );
// add old[backIterator] and present[viewportIterator] items
QValueList< DocumentViewport >::iterator endIt = d->viewportIterator;
++endIt;
while ( backIterator != endIt )
{
QString name = (backIterator == d->viewportIterator) ? "current" : "oldPage";
QDomElement historyEntry = doc.createElement( name );
historyEntry.setAttribute( "viewport", (*backIterator).toString() );
historyNode.appendChild( historyEntry );
++backIterator;
}
}
*/
// Save DOM to XML file
QString xml = doc.toString();
QTextStream os( &infoFile );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment