Bug 127382

Summary: find-dialog forgets find entry text
Product: [Unmaintained] kpdf Reporter: Maciej Pilichowski <bluedzins>
Component: generalAssignee: Albert Astals Cid <aacid>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Maciej Pilichowski 2006-05-15 20:51:19 UTC
Version:            (using KDE KDE 3.5.2)
Installed from:    SuSE RPMs

Do "find" something (via find-dialog). Do it again -- the previous entry is not suggested as it should.
Comment 1 Albert Astals Cid 2006-05-15 21:01:01 UTC
is this explained on some KDE guideline?
Comment 2 Maciej Pilichowski 2006-05-16 08:18:11 UTC
> is this explained on some KDE guideline? 

I don't know. But for example kate works correctly, and this is good. Entering long text like "dophisticated" (typo) just to enter it again properly "sophisticated" instead of just correcting the first letter... let's say it is counterproductive.
Comment 3 Albert Astals Cid 2006-07-11 20:43:27 UTC
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.
FEATURE: 109078
FEATURE: 127382


 M  +11 -0     core/document.cpp  
 M  +1 -0      core/document.h  
 M  +4 -3      part.cpp  
 M  +3 -0      part.h  


--- branches/KDE/3.5/kdegraphics/kpdf/core/document.cpp #561025:561026
@@ -44,6 +44,7 @@
     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
@@ -111,6 +112,7 @@
     d->allocatedPixmapsTotalMemory = 0;
     d->memCheckTimer = 0;
     d->saveBookmarksTimer = 0;
+    d->m_lastSearchID = -1;
     KImageIO::registerFormats();
     QStringList list = QImage::inputFormatList();
     QStringList::Iterator it = list.begin();
@@ -627,6 +629,11 @@
         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
@@ -903,6 +910,10 @@
     delete s;
 }
 
+bool KPDFDocument::continueLastSearch()
+{
+    return continueSearch( d->m_lastSearchID );
+}
 
 
 void KPDFDocument::toggleBookmark( int n )
--- branches/KDE/3.5/kdegraphics/kpdf/core/document.h #561025:561026
@@ -96,6 +96,7 @@
                          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 );
         bool print( KPrinter &printer );
--- branches/KDE/3.5/kdegraphics/kpdf/part.cpp #561025:561026
@@ -681,6 +681,8 @@
 {
     KFindDialog dlg( widget() );
     dlg.setHasCursor( false );
+    if ( !m_searchHistory.empty() )
+        dlg.setFindHistory( m_searchHistory );
 #if KDE_IS_VERSION(3,3,90)
     dlg.setSupportsBackwardsFind( false );
     dlg.setSupportsWholeWordsFind( false );
@@ -688,6 +690,7 @@
 #endif
     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() & KFindDialog::CaseSensitive,
@@ -697,9 +700,7 @@
 
 void Part::slotFindNext()
 {
-    if ( m_searchStarted )
-        m_document->continueSearch( PART_SEARCH_ID );
-    else
+    if (!m_document->continueLastSearch())
         slotFind();
 }
 
--- branches/KDE/3.5/kdegraphics/kpdf/part.h #561025:561026
@@ -158,6 +158,9 @@
 	KDirWatch *m_watcher;
 	QTimer *m_dirtyHandler;
 	DocumentViewport m_viewportDirty;
+	
+	// Remember the search history
+	QStringList m_searchHistory;
 
 	// actions
 	KAction *m_gotoPage;