Forward port SVN commit 561026 by aacid:

finally commit patch by Mary Ellen Foster to implement wish 109078
Incidentally also implements wish 127382
Sorry for having taken so long.

svn path=/trunk/playground/graphics/okular/; revision=561300
This commit is contained in:
Pino Toscano 2006-07-11 19:57:17 +00:00
parent 80b0e358c7
commit e3825a2870
4 changed files with 19 additions and 3 deletions

View file

@ -50,6 +50,7 @@ class KPDFDocumentPrivate
public:
// find descriptors, mapped by ID (we handle multiple searches)
QMap< int, RunningSearch * > searches;
int m_lastSearchID;
// needed because for remote documents docFileName is a local file and
// we want the remote url when the document refers to relativeNames
@ -121,6 +122,7 @@ KPDFDocument::KPDFDocument( QHash<QString, Generator*> * genList )
d->allocatedPixmapsTotalMemory = 0;
d->memCheckTimer = 0;
d->saveBookmarksTimer = 0;
d->m_lastSearchID = -1;
d->warnedOutOfMemory = false;
d->rotation = 0;
m_usingCachedGenerator = false;
@ -840,6 +842,11 @@ bool KPDFDocument::searchText( int searchID, const QString & text, bool fromStar
search->continueOnPage = -1;
d->searches[ searchID ] = search;
}
if (d->m_lastSearchID != searchID)
{
resetSearch(d->m_lastSearchID);
}
d->m_lastSearchID = searchID;
RunningSearch * s = d->searches[ searchID ];
// update search stucture
@ -1116,6 +1123,10 @@ void KPDFDocument::resetSearch( int searchID )
delete s;
}
bool KPDFDocument::continueLastSearch()
{
return continueSearch( d->m_lastSearchID );
}
void KPDFDocument::toggleBookmark( int n )

View file

@ -134,6 +134,7 @@ class OKULAR_EXPORT KPDFDocument : public QObject
SearchType type, bool moveViewport, const QColor & color, bool noDialogs = false );
bool continueSearch( int searchID );
void resetSearch( int searchID );
bool continueLastSearch();
void toggleBookmark( int page );
void processLink( const KPDFLink * link );

View file

@ -887,11 +887,14 @@ void Part::slotFind()
{
KFindDialog dlg( widget() );
dlg.setHasCursor( false );
if ( !m_searchHistory.empty() )
dlg.setFindHistory( m_searchHistory );
dlg.setSupportsBackwardsFind( false );
dlg.setSupportsWholeWordsFind( false );
dlg.setSupportsRegularExpressionFind( false );
if ( dlg.exec() == QDialog::Accepted )
{
m_searchHistory = dlg.findHistory();
m_searchStarted = true;
m_document->resetSearch( PART_SEARCH_ID );
m_document->searchText( PART_SEARCH_ID, dlg.pattern(), false, dlg.options() & KFind::CaseSensitive,
@ -901,9 +904,7 @@ void Part::slotFind()
void Part::slotFindNext()
{
if ( m_searchStarted )
m_document->continueSearch( PART_SEARCH_ID );
else
if (!m_document->continueLastSearch())
slotFind();
}

3
part.h
View file

@ -167,6 +167,9 @@ private:
QTimer *m_dirtyHandler;
DocumentViewport m_viewportDirty;
// Remember the search history
QStringList m_searchHistory;
// actions
KAction *m_gotoPage;
KAction *m_prevPage;