KHTML
khtmlfind_p.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2008 Bernhard Beschow <bbeschow AT cs DOT tu-berlin DOT de> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 #ifndef __khtml_find_p_h__ 00021 #define __khtml_find_p_h__ 00022 00023 #include <QObject> 00024 00025 #include "xml/dom_nodeimpl.h" 00026 00027 #include <kfind.h> 00028 00029 #include <QStringList> 00030 #include <QPointer> 00031 #include "khtmlfindbar.h" 00032 00033 class KHTMLPart; 00034 class QString; 00035 class QWidget; 00036 class KFindDialog; 00037 class KFind; 00038 00046 class KHTMLFind : public QObject 00047 { 00048 Q_OBJECT 00049 public: 00050 KHTMLFind( KHTMLPart *part, KHTMLFind *parent=0 ); 00051 ~KHTMLFind(); 00052 void findTextBegin(); 00053 bool initFindNode( bool selection, bool reverse, bool fromCursor ); 00054 void createNewKFind( const QString &str, long options, QWidget *parent, KFindDialog *findDialog ); 00055 bool findTextNext( bool reverse = false ); 00056 KHTMLFindBar *findBar() const { return m_parent ? m_parent->findBar() : m_findDialog.data(); } 00057 00058 public slots: 00059 void activate(); 00060 void deactivate(); 00061 00062 private slots: 00063 void slotFindDestroyed(); 00064 void slotSelectionChanged(); 00065 void slotHighlight( const QString &, int index, int length ); 00066 void slotSearchChanged(); 00067 void slotFindNext(); 00068 void slotFindPrevious(); 00069 00070 signals: 00071 void foundMatch( const DOM::Selection &selection, int length ); 00072 00073 protected: 00074 KFind *find() const { return m_find; } 00075 00076 private: 00077 KHTMLPart *m_part; 00078 00079 struct StringPortion 00080 { 00081 // Just basic ref/deref on our node to make sure it doesn't get deleted 00082 StringPortion( int i, DOM::NodeImpl* n ) : index(i), node(n) { if (node) node->ref(); } 00083 StringPortion() : index(0), node(0) {} // for QValueList 00084 StringPortion( const StringPortion& other ) : node(0) { operator=(other); } 00085 StringPortion& operator=( const StringPortion& other ) { 00086 index=other.index; 00087 if (other.node) other.node->ref(); 00088 if (node) node->deref(); 00089 node=other.node; 00090 return *this; 00091 } 00092 ~StringPortion() { if (node) node->deref(); } 00093 00094 int index; 00095 DOM::NodeImpl *node; 00096 }; 00097 QList<StringPortion> m_stringPortions; 00098 00099 KFind *m_find; 00100 KHTMLFind *m_parent; 00101 QPointer<KHTMLFindBar> m_findDialog; 00102 00103 struct findState 00104 { 00105 findState() : options( 0 ), last_dir( -1 ) {} 00106 QStringList history; 00107 QString text; 00108 int options; 00109 int last_dir; // -1=unknown,0=forward,1=backward 00110 }; 00111 00112 findState m_lastFindState; 00113 00114 DOM::NodeImpl *m_findNode; // current node 00115 DOM::NodeImpl *m_findNodeEnd; // end node 00116 DOM::NodeImpl *m_findNodeStart; // start node 00117 DOM::NodeImpl *m_findNodePrevious; // previous node used for find 00118 int m_findPos; // current pos in current node 00119 int m_findPosEnd; // pos in end node 00120 int m_findPosStart; // pos in start node 00121 }; 00122 00123 #endif
KDE 4.6 API Reference