kate Library API Documentation

docwordcompletion.h

00001 /* 00002 This library is free software; you can redistribute it and/or 00003 modify it under the terms of the GNU Library General Public 00004 License version 2 as published by the Free Software Foundation. 00005 00006 This library is distributed in the hope that it will be useful, 00007 but WITHOUT ANY WARRANTY; without even the implied warranty of 00008 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00009 Library General Public License for more details. 00010 00011 You should have received a copy of the GNU Library General Public License 00012 along with this library; see the file COPYING.LIB. If not, write to 00013 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00014 Boston, MA 02111-1307, USA. 00015 00016 --- 00017 file: docwordcompletion.h 00018 00019 KTextEditor plugin to autocompletion with document words. 00020 Copyright Anders Lund <anders.lund@lund.tdcadsl.dk>, 2003 00021 00022 The following completion methods are supported: 00023 * Completion with bigger matching words in 00024 either direction (backward/forward). 00025 * NOT YET Pop up a list of all bigger matching words in document 00026 00027 */ 00028 00029 #ifndef _DocWordCompletionPlugin_h_ 00030 #define _DocWordCompletionPlugin_h_ 00031 00032 #include <ktexteditor/plugin.h> 00033 #include <ktexteditor/view.h> 00034 #include <ktexteditor/codecompletioninterface.h> 00035 #include <ktexteditor/configinterfaceextension.h> 00036 #include <kxmlguiclient.h> 00037 00038 #include <qevent.h> 00039 #include <qobject.h> 00040 #include <qvaluelist.h> 00041 00042 class DocWordCompletionPlugin 00043 : public KTextEditor::Plugin 00044 , public KTextEditor::PluginViewInterface 00045 , public KTextEditor::ConfigInterfaceExtension 00046 { 00047 Q_OBJECT 00048 00049 public: 00050 DocWordCompletionPlugin( QObject *parent = 0, 00051 const char* name = 0, 00052 const QStringList &args = QStringList() ); 00053 virtual ~DocWordCompletionPlugin() {}; 00054 00055 void addView (KTextEditor::View *view); 00056 void removeView (KTextEditor::View *view); 00057 00058 void readConfig(); 00059 void writeConfig(); 00060 00061 // ConfigInterfaceExtention 00062 uint configPages() const { return 1; }; 00063 KTextEditor::ConfigPage * configPage( uint number, QWidget *parent, const char *name ); 00064 QString configPageName( uint ) const; 00065 QString configPageFullName( uint ) const; 00066 QPixmap configPagePixmap( uint, int ) const; 00067 00068 uint treshold() const { return m_treshold; }; 00069 void setTreshold( uint t ) { m_treshold = t; }; 00070 bool autoPopupEnabled() const { return m_autopopup; }; 00071 void setAutoPopupEnabled( bool enable ) { m_autopopup = enable; }; 00072 00073 00074 private: 00075 QPtrList<class DocWordCompletionPluginView> m_views; 00076 uint m_treshold; 00077 bool m_autopopup; 00078 00079 }; 00080 00081 class DocWordCompletionPluginView 00082 : public QObject, public KXMLGUIClient 00083 { 00084 Q_OBJECT 00085 00086 public: 00087 DocWordCompletionPluginView( uint treshold=3, bool autopopup=true, KTextEditor::View *view=0, 00088 const char *name=0 ); 00089 ~DocWordCompletionPluginView() {}; 00090 00091 void settreshold( uint treshold ); 00092 00093 private slots: 00094 void completeBackwards(); 00095 void completeForwards(); 00096 00097 void popupCompletionList( QString word=QString::null ); 00098 void autoPopupCompletionList(); 00099 void toggleAutoPopup(); 00100 00101 void slotVariableChanged( const QString &, const QString & ); 00102 00103 private: 00104 void complete( bool fw=true ); 00105 QString word(); 00106 QValueList<KTextEditor::CompletionEntry> allMatches( const QString &word ); 00107 KTextEditor::View *m_view; 00108 struct DocWordCompletionPluginViewPrivate *d; 00109 }; 00110 00111 class DocWordCompletionConfigPage : public KTextEditor::ConfigPage 00112 { 00113 Q_OBJECT 00114 public: 00115 DocWordCompletionConfigPage( DocWordCompletionPlugin *completion, QWidget *parent, const char *name ); 00116 virtual ~DocWordCompletionConfigPage() {}; 00117 00118 virtual void apply(); 00119 virtual void reset(); 00120 virtual void defaults(); 00121 00122 private: 00123 DocWordCompletionPlugin *m_completion; 00124 class QCheckBox *cbAutoPopup; 00125 class QSpinBox *sbAutoPopup; 00126 class QLabel *lSbRight; 00127 }; 00128 00129 #endif // _DocWordCompletionPlugin_h_
KDE Logo
This file is part of the documentation for kate Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Apr 12 23:39:56 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003