File 4_1_BRANCH_r898242.diff of Package kdepim4
Index: knotes/knote.cpp
===================================================================
--- knotes/knote.cpp (revision 898241)
+++ knotes/knote.cpp (revision 898242)
@@ -230,11 +230,10 @@
saveData();
}
-void KNote::find( const QString& pattern, long options )
+void KNote::find( KFind* kfind )
{
- delete m_find;
- m_find = new KFind( pattern, options, this );
-
+ m_find = kfind;
+ disconnect( m_find );
connect( m_find, SIGNAL( highlight( const QString &, int, int ) ),
this, SLOT( slotHighlight( const QString &, int, int ) ) );
connect( m_find, SIGNAL( findNext() ), this, SLOT( slotFindNext() ) );
@@ -246,19 +245,21 @@
void KNote::slotFindNext()
{
// TODO: honor FindBackwards
- // TODO: dialogClosed() -> delete m_find
// Let KFind inspect the text fragment, and display a dialog if a match is
// found
KFind::Result res = m_find->find();
if ( res == KFind::NoMatch ) { // i.e. at end-pos
- // use a different text cursor!
- m_editor->textCursor().clearSelection();
+
+ QTextCursor c = m_editor->textCursor(); //doesn't return by reference, so we use setTextCursor
+ c.clearSelection();
+ m_editor->setTextCursor( c );
+
+ disconnect( m_find, 0, this, 0 );
emit sigFindFinished();
- delete m_find;
- m_find = 0;
} else {
+
show();
#ifdef Q_WS_X11
KWindowSystem::setCurrentDesktop( KWindowSystem::windowInfo( winId(),
@@ -269,9 +270,9 @@
void KNote::slotHighlight( const QString& /*str*/, int idx, int len )
{
- QTextCursor c = m_editor->textCursor();
- c.setPosition( idx );
- c.setPosition( idx + len, QTextCursor::KeepAnchor );
+ m_editor->textCursor().clearSelection();
+ m_editor->highlightWord( len, idx );
+
// TODO: modify the selection color, use a different QTextCursor?
}
Index: knotes/knotesapp.cpp
===================================================================
--- knotes/knotesapp.cpp (revision 898241)
+++ knotes/knotesapp.cpp (revision 898242)
@@ -455,11 +455,11 @@
void KNotesApp::slotFindNext()
{
if ( *m_findPos != m_notes.end() ) {
- KNote *note = * ( *m_findPos++ );
- note->find( m_find->pattern(), m_find->options() );
+ KNote *note = * ( (*m_findPos)++ );
+ note->find( m_find );
} else {
m_find->displayFinalDialog();
- delete m_find;
+ m_find->deleteLater(); //we can't delete m_find now because its the signal emitter
m_find = 0;
delete m_findPos;
m_findPos = 0;
Index: knotes/knote.h
===================================================================
--- knotes/knote.h (revision 898241)
+++ knotes/knote.h (revision 898242)
@@ -66,7 +66,7 @@
void setName( const QString &name );
void setText( const QString &text );
- void find( const QString &pattern, long options );
+ void find( KFind* kfind );
bool isModified() const;