• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • ui
  • findbar
khtmlfind.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2008 Bernhard Beschow <bbeschow cs tu berlin de>
4  * (C) 2009 Germain Garand <germain@ebooksfrance.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #include "khtmlfind_p.h"
23 
24 #include "khtml_part.h"
25 #include "khtmlviewbar.h"
26 #include "khtmlfindbar.h"
27 
28 #include "dom/html_document.h"
29 #include "html/html_documentimpl.h"
30 #include "rendering/render_text.h"
31 #include "rendering/render_replaced.h"
32 #include "xml/dom_selection.h"
33 
34 #include "khtmlview.h"
35 
36 #include <config.h>
37 
38 #include <QtGui/QClipboard>
39 
40 #include "rendering/render_form.h"
41 
42 #define d this
43 
44 using khtml::RenderPosition;
45 
46 using namespace DOM;
47 
48 KHTMLFind::KHTMLFind( KHTMLPart *part, KHTMLFind *parent ) :
49  m_part( part ),
50  m_find( 0 ),
51  m_parent( parent ),
52  m_findDialog( 0 )
53 {
54  connect( part, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()) );
55 }
56 
57 
58 KHTMLFind::~KHTMLFind()
59 {
60  d->m_find = 0; // deleted by its parent, the view.
61 }
62 
63 void KHTMLFind::findTextBegin()
64 {
65  d->m_findPos = -1;
66  d->m_findNode = 0;
67  d->m_findPosEnd = -1;
68  d->m_findNodeEnd= 0;
69  d->m_findPosStart = -1;
70  d->m_findNodeStart = 0;
71  d->m_findNodePrevious = 0;
72  delete d->m_find;
73  d->m_find = 0L;
74 }
75 
76 bool KHTMLFind::initFindNode( bool selection, bool reverse, bool fromCursor )
77 {
78  if ( m_part->document().isNull() )
79  return false;
80 
81  DOM::NodeImpl* firstNode = 0L;
82  if (m_part->document().isHTMLDocument())
83  firstNode = m_part->htmlDocument().body().handle();
84  else
85  firstNode = m_part->document().handle();
86 
87  if ( !firstNode )
88  {
89  //kDebug(6050) << "no first node (body or doc) -> return false";
90  return false;
91  }
92  if ( selection && m_part->hasSelection() )
93  {
94  //kDebug(6050) << "using selection";
95  const Selection &sel = m_part->caret();
96  if ( !fromCursor )
97  {
98  d->m_findNode = reverse ? sel.end().node() : sel.start().node();
99  d->m_findPos = reverse ? sel.end().offset() : sel.start().offset();
100  }
101  d->m_findNodeEnd = reverse ? sel.start().node() : sel.end().node();
102  d->m_findPosEnd = reverse ? sel.start().offset() : sel.end().offset();
103  d->m_findNodeStart = !reverse ? sel.start().node() : sel.end().node();
104  d->m_findPosStart = !reverse ? sel.start().offset() : sel.end().offset();
105  d->m_findNodePrevious = d->m_findNodeStart;
106  }
107  else // whole document
108  {
109  //kDebug(6050) << "whole doc";
110  if ( !fromCursor )
111  {
112  d->m_findNode = firstNode;
113  d->m_findPos = reverse ? -1 : 0;
114  }
115  d->m_findNodeEnd = reverse ? firstNode : 0;
116  d->m_findPosEnd = reverse ? 0 : -1;
117  d->m_findNodeStart = !reverse ? firstNode : 0;
118  d->m_findPosStart = !reverse ? 0 : -1;
119  d->m_findNodePrevious = d->m_findNodeStart;
120  if ( reverse )
121  {
122  // Need to find out the really last object, to start from it
123  khtml::RenderObject* obj = d->m_findNode ? d->m_findNode->renderer() : 0;
124  if ( obj )
125  {
126  // find the last object in the render tree
127  while ( obj->lastChild() )
128  {
129  obj = obj->lastChild();
130  }
131  // now get the last object with a NodeImpl associated
132  while ( !obj->element() && obj->objectAbove() )
133  {
134  obj = obj->objectAbove();
135  }
136  d->m_findNode = obj->element();
137  }
138  }
139  }
140  return true;
141 }
142 
143 void KHTMLFind::deactivate()
144 {
145  kDebug(6050);
146  d->m_lastFindState.options = d->m_findDialog->options();
147  d->m_lastFindState.history = d->m_findDialog->findHistory();
148  if (!m_parent) {
149  d->m_findDialog->hide();
150  d->m_findDialog->disconnect();
151  d->m_findDialog->deleteLater();
152  }
153  d->m_findDialog = 0L;
154 
155  // if the selection is limited to a single link, that link gets focus
156  const DOM::Selection sel = m_part->caret();
157  if(sel.start().node() == sel.end().node())
158  {
159  bool isLink = false;
160 
161  // checks whether the node has a <A> parent
162  DOM::NodeImpl *parent = sel.start().node();
163  while ( parent )
164  {
165  if ( parent->nodeType() == Node::ELEMENT_NODE && parent->id() == ID_A )
166  {
167  isLink = true;
168  break;
169  }
170  parent = parent->parentNode();
171  }
172 
173  if(isLink == true)
174  {
175  static_cast<DOM::DocumentImpl *>( m_part->document().handle() )->setFocusNode( parent );
176  }
177  }
178 }
179 
180 void KHTMLFind::slotFindDestroyed()
181 {
182  d->m_find = 0;
183 }
184 
185 void KHTMLFind::activate()
186 {
187  // First do some init to make sure we can search in this frame
188  if ( m_part->document().isNull() )
189  return;
190 
191  // Raise if already opened
192  if ( d->m_findDialog && !m_parent )
193  {
194  m_part->pBottomViewBar()->showBarWidget( d->m_findDialog );
195  return;
196  }
197 
198  // The lineedit of the dialog would make khtml lose its selection, otherwise
199 #ifndef QT_NO_CLIPBOARD
200  disconnect( qApp->clipboard(), SIGNAL(selectionChanged()), m_part, SLOT(slotClearSelection()) );
201 #endif
202 
203  if (m_parent)
204  d->m_findDialog = m_parent->findBar();
205  else
206  {
207  // Now show the dialog in which the user can choose options.
208  d->m_findDialog = new KHTMLFindBar( m_part->widget() );
209  d->m_findDialog->setHasSelection( m_part->hasSelection() );
210  d->m_findDialog->setHasCursor( d->m_findNode != 0 );
211 #if 0
212  if ( d->m_findNode ) // has a cursor -> default to 'FromCursor'
213  d->m_lastFindState.options |= KFind::FromCursor;
214 #endif
215 
216  // TODO? optionsDialog.setPattern( d->m_lastFindState.text );
217  d->m_findDialog->setFindHistory( d->m_lastFindState.history );
218  d->m_findDialog->setOptions( d->m_lastFindState.options );
219  d->m_findDialog->setFocus();
220 
221  d->m_lastFindState.options = -1; // force update in findTextNext
222  d->m_lastFindState.last_dir = -1;
223 
224  m_part->pBottomViewBar()->addBarWidget( d->m_findDialog );
225  m_part->pBottomViewBar()->showBarWidget( d->m_findDialog );
226  connect( d->m_findDialog, SIGNAL(searchChanged()), this, SLOT(slotSearchChanged()) );
227  connect( d->m_findDialog, SIGNAL(findNextClicked()), this, SLOT(slotFindNext()) );
228  connect( d->m_findDialog, SIGNAL(findPreviousClicked()), this, SLOT(slotFindPrevious()) );
229  connect( d->m_findDialog, SIGNAL(hideMe()), this, SLOT(deactivate()) );
230  }
231 #ifndef QT_NO_CLIPBOARD
232  connect( qApp->clipboard(), SIGNAL(selectionChanged()), m_part, SLOT(slotClearSelection()) );
233 #endif
234  if (m_findDialog) {
235  createNewKFind( m_findDialog->pattern() , 0 /*options*/, m_findDialog, 0 );
236  } else if (m_parent && m_parent->find()) {
237  createNewKFind( m_parent->find()->pattern(), m_parent->find()->options(), static_cast<QWidget*>(m_parent->find()->parent()), 0 );
238  }
239 }
240 
241 // ### this crawling through the render tree sucks. There should be another way to
242 // do that.
243 static inline KHTMLPart* innerPart( khtml::RenderObject *ro ) {
244  if (!ro || !ro->isWidget() || ro->isFormElement())
245  return 0;
246  KHTMLView* v = qobject_cast<KHTMLView*>( static_cast<khtml::RenderWidget*>(ro)->widget() );
247  return v ? v->part() : 0;
248 }
249 static inline KHTMLPart* innerPartFromNode( DOM::NodeImpl *node ) {
250  return (node && node->renderer() ? innerPart( node->renderer() ) : 0);
251 }
252 
253 void KHTMLFind::createNewKFind( const QString &str, long options, QWidget *parent, KFindDialog *findDialog )
254 {
255  // First do some init to make sure we can search in this frame
256  if ( m_part->document().isNull() )
257  return;
258 
259  if (m_findNode) {
260  if (KHTMLPart* p = innerPartFromNode(m_findNode)) {
261  p->clearSelection();
262  p->findTextBegin();
263  }
264  }
265 
266  // Create the KFind object
267  delete d->m_find;
268  d->m_find = new KFind( str, options, parent, findDialog );
269  d->m_find->closeFindNextDialog(); // we use KFindDialog non-modal, so we don't want other dlg popping up
270  connect( d->m_find, SIGNAL(highlight(QString,int,int)),
271  this, SLOT(slotHighlight(QString,int,int)) );
272  connect( d->m_find, SIGNAL(destroyed()),
273  this, SLOT(slotFindDestroyed()) );
274  //connect(d->m_find, SIGNAL(findNext()),
275  // this, SLOT(slotFindNext()) );
276 
277  if ( !findDialog )
278  {
279  d->m_lastFindState.options = options;
280  initFindNode( options & KFind::SelectedText,
281  options & KFind::FindBackwards,
282  options & KFind::FromCursor );
283  }
284 }
285 
286 bool KHTMLFind::findTextNext( bool reverse )
287 {
288  if (!d->m_find)
289  {
290  // We didn't show the find dialog yet, let's do it then (#49442)
291  activate();
292 
293  // FIXME Ugly hack: activate() may not create KFind object, so check whether it was created
294  if (!d->m_find)
295  return false;
296 
297  // It also means the user is trying to match a previous pattern, so try and
298  // restore the last saved pattern.
299  if (!m_parent && (!d->m_findDialog || !d->m_findDialog->restoreLastPatternFromHistory()))
300  return false;
301  }
302 
303  long options = 0;
304  if ( d->m_findDialog ) // 0 when we close the dialog
305  {
306  // there is a search dialog
307  // make sure pattern from search dialog is used
308  // (### in fact pattern changes should always trigger a reconstruction of the KFind object cf. slotSearchChanged
309  // - so make this an assert)
310  if ( (d->m_find->pattern() != d->m_findDialog->pattern()) ) {
311  d->m_find->setPattern( d->m_findDialog->pattern() );
312  d->m_find->resetCounts();
313  }
314 
315  // make sure options from search dialog are used
316  options = d->m_findDialog->options();
317  if ( d->m_lastFindState.options != options )
318  {
319  d->m_find->setOptions( options );
320 
321  if ( options & KFind::SelectedText ) //#### FIXME find in selection for frames!
322  Q_ASSERT( m_part->hasSelection() );
323 
324  long difference = d->m_lastFindState.options ^ options;
325  if ( difference & (KFind::SelectedText | KFind::FromCursor ) )
326  {
327  // Important options changed -> reset search range
328  (void) initFindNode( options & KFind::SelectedText,
329  options & KFind::FindBackwards,
330  options & KFind::FromCursor );
331  }
332  d->m_lastFindState.options = options;
333  }
334  } else {
335  // no dialog
336  options = d->m_lastFindState.options;
337  }
338 
339  // only adopt options for search direction manually
340  if( reverse )
341  options = options ^ KFind::FindBackwards;
342 
343  // make sure our options are used by KFind
344  if( d->m_find->options() != options )
345  d->m_find->setOptions( options );
346 
347  // Changing find direction. Start and end nodes must be switched.
348  // Additionally since d->m_findNode points after the last node
349  // that was searched, it needs to be "after" it in the opposite direction.
350  if( d->m_lastFindState.last_dir != -1
351  && bool( d->m_lastFindState.last_dir ) != bool( options & KFind::FindBackwards ))
352  {
353  qSwap( d->m_findNodeEnd, d->m_findNodeStart );
354  qSwap( d->m_findPosEnd, d->m_findPosStart );
355  qSwap( d->m_findNode, d->m_findNodePrevious );
356 
357  // d->m_findNode now point at the end of the last searched line - advance one node
358  khtml::RenderObject* obj = d->m_findNode ? d->m_findNode->renderer() : 0;
359  khtml::RenderObject* end = d->m_findNodeEnd ? d->m_findNodeEnd->renderer() : 0;
360  if ( obj == end )
361  obj = 0L;
362  else if ( obj )
363  {
364  do {
365  obj = (options & KFind::FindBackwards) ? obj->objectAbove() : obj->objectBelow();
366  } while ( obj && ( !obj->element() || obj->isInlineContinuation() ) );
367  }
368  if ( obj )
369  d->m_findNode = obj->element();
370  else {
371  // already at end, start again
372  (void) initFindNode( options & KFind::SelectedText,
373  options & KFind::FindBackwards,
374  options & KFind::FromCursor );
375  }
376  }
377  d->m_lastFindState.last_dir = ( options & KFind::FindBackwards ) ? 1 : 0;
378 
379  int numMatchesOld = m_find->numMatches();
380  KFind::Result res = KFind::NoMatch;
381  khtml::RenderObject* obj = d->m_findNode ? d->m_findNode->renderer() : 0;
382  khtml::RenderObject* end = d->m_findNodeEnd ? d->m_findNodeEnd->renderer() : 0;
383  //kDebug(6050) << "obj=" << obj << " end=" << end;
384  while( res == KFind::NoMatch )
385  {
386  if ( d->m_find->needData() )
387  {
388  if ( !obj ) {
389  //kDebug(6050) << "obj=0 -> done";
390  break; // we're done
391  }
392  //kDebug(6050) << " gathering data";
393  // First make up the QString for the current 'line' (i.e. up to \n)
394  // We also want to remember the DOMNode for every portion of the string.
395  // We store this in an index->node list.
396 
397  d->m_stringPortions.clear();
398  bool newLine = false;
399  QString str;
400  DOM::NodeImpl* lastNode = d->m_findNode;
401  while ( obj && !newLine )
402  {
403  // Grab text from render object
404  QString s;
405  if ( obj->renderName() == QLatin1String("RenderTextArea") )
406  {
407  s = static_cast<khtml::RenderTextArea *>(obj)->text();
408  s = s.replace(0xa0, ' ');
409  }
410  else if ( obj->renderName() == QLatin1String("RenderLineEdit") )
411  {
412  khtml::RenderLineEdit *parentLine= static_cast<khtml::RenderLineEdit *>(obj);
413  if (parentLine->widget()->echoMode() == QLineEdit::Normal)
414  s = parentLine->widget()->text();
415  s = s.replace(0xa0, ' ');
416  }
417  else if ( obj->isText() )
418  {
419  bool isLink = false;
420 
421  // checks whether the node has a <A> parent
422  if ( options & KHTMLPart::FindLinksOnly )
423  {
424  DOM::NodeImpl *parent = obj->element();
425  while ( parent )
426  {
427  if ( parent->nodeType() == Node::ELEMENT_NODE && parent->id() == ID_A )
428  {
429  isLink = true;
430  break;
431  }
432  parent = parent->parentNode();
433  }
434  }
435  else
436  {
437  isLink = true;
438  }
439 
440  if ( isLink )
441  {
442  s = static_cast<khtml::RenderText *>(obj)->data().string();
443  s = s.replace(0xa0, ' ');
444  }
445  }
446  else if ( KHTMLPart *p = innerPart(obj) )
447  {
448  if (p->pFindTextNextInThisFrame(reverse))
449  {
450  numMatchesOld++;
451  res = KFind::Match;
452  lastNode = obj->element();
453  break;
454  }
455 
456  }
457  else if ( obj->isBR() )
458  s = '\n';
459  else if ( !obj->isInline() && !str.isEmpty() )
460  s = '\n';
461 
462  if ( lastNode == d->m_findNodeEnd )
463  s.truncate( d->m_findPosEnd );
464  if ( !s.isEmpty() )
465  {
466  newLine = s.indexOf( '\n' ) != -1; // did we just get a newline?
467  if( !( options & KFind::FindBackwards ))
468  {
469  //kDebug(6050) << "StringPortion: " << index << "-" << index+s.length()-1 << " -> " << lastNode;
470  d->m_stringPortions.append( StringPortion( str.length(), lastNode ) );
471  str += s;
472  }
473  else // KFind itself can search backwards, so str must not be built backwards
474  {
475  for( QList<StringPortion>::Iterator it = d->m_stringPortions.begin();
476  it != d->m_stringPortions.end();
477  ++it )
478  (*it).index += s.length();
479  d->m_stringPortions.prepend( StringPortion( 0, lastNode ) );
480  str.prepend( s );
481  }
482  }
483  // Compare obj and end _after_ we processed the 'end' node itself
484  if ( obj == end )
485  obj = 0L;
486  else
487  {
488  // Move on to next object (note: if we found a \n already, then obj (and lastNode)
489  // will point to the _next_ object, i.e. they are in advance.
490  do {
491  // We advance until the next RenderObject that has a NodeImpl as its element().
492  // Otherwise (if we keep the 'last node', and it has a '\n') we might be stuck
493  // on that object forever...
494  obj = (options & KFind::FindBackwards) ? obj->objectAbove() : obj->objectBelow();
495  } while ( obj && ( !obj->element() || obj->isInlineContinuation() ) );
496  }
497  if ( obj )
498  lastNode = obj->element();
499  else
500  lastNode = 0;
501  } // end while
502 
503  if ( !str.isEmpty() )
504  {
505  d->m_find->setData( str, d->m_findPos );
506  }
507  d->m_findPos = -1; // not used during the findnext loops. Only during init.
508  d->m_findNodePrevious = d->m_findNode;
509  d->m_findNode = lastNode;
510  }
511  if ( !d->m_find->needData() && !(res == KFind::Match) ) // happens if str was empty
512  {
513  // Let KFind inspect the text fragment, and emit highlighted if a match is found
514  res = d->m_find->find();
515  }
516  } // end while
517 
518  if ( res == KFind::NoMatch ) // i.e. we're done
519  {
520  kDebug(6050) << "No more matches.";
521  if ( !(options & KHTMLPart::FindNoPopups) && d->m_find->shouldRestart() )
522  {
523  kDebug(6050) << "Restarting";
524  initFindNode( false, options & KFind::FindBackwards, false );
525  d->m_find->resetCounts();
526  findTextNext( reverse );
527  }
528  else // really done
529  {
530  kDebug(6050) << "Finishing";
531  //delete d->m_find;
532  //d->m_find = 0L;
533  initFindNode( false, options & KFind::FindBackwards, false );
534  d->m_find->resetCounts();
535  d->m_part->clearSelection();
536  }
537  kDebug(6050) << "Dialog closed.";
538  }
539 
540  if ( m_findDialog != 0 )
541  {
542  m_findDialog->setFoundMatch( res == KFind::Match );
543  m_findDialog->setAtEnd( m_find->numMatches() < numMatchesOld );
544  }
545 
546  return res == KFind::Match;
547 }
548 
549 void KHTMLFind::slotHighlight( const QString& /*text*/, int index, int length )
550 {
551  //kDebug(6050) << "slotHighlight index=" << index << " length=" << length;
552  QList<StringPortion>::Iterator it = d->m_stringPortions.begin();
553  const QList<StringPortion>::Iterator itEnd = d->m_stringPortions.end();
554  QList<StringPortion>::Iterator prev = it;
555  // We stop at the first portion whose index is 'greater than', and then use the previous one
556  while ( it != itEnd && (*it).index <= index )
557  {
558  prev = it;
559  ++it;
560  }
561  Q_ASSERT ( prev != itEnd );
562  DOM::NodeImpl* node = (*prev).node;
563  Q_ASSERT( node );
564 
565  Selection sel(RenderPosition(node, index - (*prev).index).position());
566 
567  khtml::RenderObject* obj = node->renderer();
568  khtml::RenderTextArea *renderTextArea = 0L;
569  khtml::RenderLineEdit *renderLineEdit = 0L;
570 
571  Q_ASSERT( obj );
572  if ( obj )
573  {
574  int x = 0, y = 0;
575 
576  if ( obj->renderName() == QLatin1String("RenderTextArea") )
577  renderTextArea = static_cast<khtml::RenderTextArea *>(obj);
578  if ( obj->renderName() == QLatin1String("RenderLineEdit") )
579  renderLineEdit = static_cast<khtml::RenderLineEdit *>(obj);
580  if ( !renderLineEdit && !renderTextArea )
581  //if (static_cast<khtml::RenderText *>(node->renderer())
582  // ->posOfChar(d->m_startOffset, x, y))
583  {
584  int dummy;
585  static_cast<khtml::RenderText *>(node->renderer())
586  ->caretPos( RenderPosition::fromDOMPosition(sel.start()).renderedOffset(), false, x, y, dummy, dummy ); // more precise than posOfChar
587  //kDebug(6050) << "topleft: " << x << "," << y;
588  if ( x != -1 || y != -1 )
589  {
590  int gox = m_part->view()->contentsX();
591  if (x+50 > m_part->view()->contentsX() + m_part->view()->visibleWidth())
592  gox = x - m_part->view()->visibleWidth() + 50;
593  if (x-10 < m_part->view()->contentsX())
594  gox = x - m_part->view()->visibleWidth() - 10;
595  if (gox < 0) gox = 0;
596  m_part->view()->setContentsPos(gox, y-50);
597  }
598  }
599  }
600  // Now look for end node
601  it = prev; // no need to start from beginning again
602  while ( it != itEnd && (*it).index < index + length )
603  {
604  prev = it;
605  ++it;
606  }
607  Q_ASSERT ( prev != itEnd );
608 
609  sel.moveTo(sel.start(), RenderPosition((*prev).node, index + length - (*prev).index).position());
610 
611 #if 0
612  kDebug(6050) << "slotHighlight: " << d->m_selectionStart.handle() << "," << d->m_startOffset << " - " <<
613  d->m_selectionEnd.handle() << "," << d->m_endOffset << endl;
614  it = d->m_stringPortions.begin();
615  for ( ; it != d->m_stringPortions.end() ; ++it )
616  kDebug(6050) << " StringPortion: from index=" << (*it).index << " -> node=" << (*it).node;
617 #endif
618  if ( renderTextArea )
619  renderTextArea->highLightWord( length, sel.end().offset()-length );
620  else if ( renderLineEdit )
621  renderLineEdit->highLightWord( length, sel.end().offset()-length );
622  else
623  {
624  m_part->setCaret( sel );
625 // d->m_doc->updateSelection();
626  if (sel.end().node()->renderer() )
627  {
628  int x, y, height, dummy;
629  static_cast<khtml::RenderText *>(sel.end().node()->renderer())
630  ->caretPos( RenderPosition::fromDOMPosition(sel.end()).renderedOffset(), false, x, y, dummy, height ); // more precise than posOfChar
631  //kDebug(6050) << "bottomright: " << x << "," << y+height;
632  }
633  }
634  m_part->emitSelectionChanged();
635 
636 }
637 
638 void KHTMLFind::slotSelectionChanged()
639 {
640  if ( d->m_findDialog )
641  d->m_findDialog->setHasSelection( m_part->hasSelection() );
642 }
643 
644 void KHTMLFind::slotSearchChanged()
645 {
646  createNewKFind( m_findDialog->pattern(), m_findDialog->options(), m_findDialog, 0 );
647  findTextNext();
648 }
649 
650 void KHTMLFind::slotFindNext()
651 {
652  findTextNext();
653 }
654 
655 void KHTMLFind::slotFindPrevious()
656 {
657  findTextNext( true ); // find backwards
658 }
KFindDialog
KHTMLViewBar::showBarWidget
void showBarWidget(KHTMLViewBarWidget *barWidget)
Shows barWidget that was previously added with addBarWidget.
Definition: khtmlviewbar.cpp:91
KHTMLFind::initFindNode
bool initFindNode(bool selection, bool reverse, bool fromCursor)
Definition: khtmlfind.cpp:76
innerPartFromNode
static KHTMLPart * innerPartFromNode(DOM::NodeImpl *node)
Definition: khtmlfind.cpp:249
khtmlfindbar.h
khtml_part.h
d
#define d
Definition: khtmlfind.cpp:42
KHTMLFind::findTextNext
bool findTextNext(bool reverse=false)
Definition: khtmlfind.cpp:286
QWidget
KHTMLViewBar::addBarWidget
void addBarWidget(KHTMLViewBarWidget *newBarWidget)
Adds a widget to this viewbar.
Definition: khtmlviewbar.cpp:42
html_document.h
KHTMLPart::FindNoPopups
Definition: khtml_part.h:790
KHTMLPart
This class is khtml's main class.
Definition: khtml_part.h:206
KHTMLFind::deactivate
void deactivate()
Definition: khtmlfind.cpp:143
KHTMLView
Renders and displays HTML in a QScrollArea.
Definition: khtmlview.h:92
KParts::Part::widget
virtual QWidget * widget()
QString
KHTMLView::setContentsPos
void setContentsPos(int x, int y)
Place the contents area point x/y at the top left of the viewport.
Definition: khtmlview.cpp:734
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KHTMLFind::findTextBegin
void findTextBegin()
Definition: khtmlfind.cpp:63
KHTMLFind::createNewKFind
void createNewKFind(const QString &str, long options, QWidget *parent, KFindDialog *findDialog)
Definition: khtmlfind.cpp:253
KHTMLFind
This class implements the find activity for the KHTMLPart.
Definition: khtmlfind_p.h:46
khtmlviewbar.h
KHTMLPart::view
KHTMLView * view() const
Returns a pointer to the HTML document's view.
Definition: khtml_part.cpp:1056
KHTMLView::part
KHTMLPart * part() const
Returns a pointer to the KHTMLPart that is rendering the page.
Definition: khtmlview.h:135
KHTMLView::visibleWidth
int visibleWidth() const
Returns the width of the viewport.
Definition: khtmlview.cpp:702
khtmlfind_p.h
KFind::FromCursor
KFind::Match
qSwap
void qSwap(KParts::SelectorInterface::Element &lhs, KParts::SelectorInterface::Element &rhs)
KFind::numMatches
int numMatches() const
DOM::Node::isNull
bool isNull() const
tests if this Node is 0.
Definition: dom_node.h:920
KHTMLPart::FindLinksOnly
Definition: khtml_part.h:789
KHTMLFindBar
Definition: khtmlfindbar.h:29
KHTMLFind::~KHTMLFind
~KHTMLFind()
Definition: khtmlfind.cpp:58
KFind::Result
Result
KFind
KFind::pattern
QString pattern() const
khtmlview.h
KHTMLFind::findBar
KHTMLFindBar * findBar() const
Definition: khtmlfind_p.h:56
KFind::SelectedText
KFind::FindBackwards
innerPart
static KHTMLPart * innerPart(khtml::RenderObject *ro)
Definition: khtmlfind.cpp:243
KHTMLView::contentsX
int contentsX() const
Returns the x coordinate of the contents area point that is currently located at the top left in the ...
Definition: khtmlview.cpp:692
DOM::Document::isHTMLDocument
bool isHTMLDocument() const
Definition: dom_doc.cpp:342
KHTMLFind::KHTMLFind
KHTMLFind(KHTMLPart *part, KHTMLFind *parent=0)
Definition: khtmlfind.cpp:48
KHTMLPart::htmlDocument
DOM::HTMLDocument htmlDocument() const
Returns a reference to the DOM HTML document (for non-HTML documents, returns null) ...
Definition: khtml_part.cpp:1001
KHTMLPart::document
DOM::Document document() const
Returns a reference to the DOM document.
Definition: khtml_part.cpp:1009
KFind::options
long options() const
KFind::NoMatch
DOM::Node::handle
NodeImpl * handle() const
Definition: dom_node.h:925
KHTMLFind::activate
void activate()
Definition: khtmlfind.cpp:185
end
const KShortcut & end()
KHTMLPart::hasSelection
bool hasSelection() const
Has the user selected anything?
Definition: khtml_part.cpp:3259
KHTMLFind::find
KFind * find() const
Definition: khtmlfind_p.h:74
QList
DOM::HTMLDocument::body
HTMLElement body() const
The element that contains the content for the document.
Definition: html_document.cpp:126
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal