• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Kate

docwordcompletion.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00014     Boston, MA 02110-1301, 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     void shellComplete();
00097 
00098     void popupCompletionList( QString word=QString::null );
00099     void autoPopupCompletionList();
00100     void toggleAutoPopup();
00101 
00102     void slotVariableChanged( const QString &, const QString & );
00103 
00104   private:
00105     void complete( bool fw=true );
00106 
00107     QString word();
00108     QValueList<KTextEditor::CompletionEntry> allMatches( const QString &word );
00109     QString findLongestUnique(const QValueList < KTextEditor::CompletionEntry > &matches);
00110     KTextEditor::View *m_view;
00111     struct DocWordCompletionPluginViewPrivate *d;
00112 };
00113 
00114 class DocWordCompletionConfigPage : public KTextEditor::ConfigPage
00115 {
00116   Q_OBJECT
00117   public:
00118     DocWordCompletionConfigPage( DocWordCompletionPlugin *completion, QWidget *parent, const char *name );
00119     virtual ~DocWordCompletionConfigPage() {};
00120 
00121     virtual void apply();
00122     virtual void reset();
00123     virtual void defaults();
00124 
00125   private:
00126     DocWordCompletionPlugin *m_completion;
00127     class QCheckBox *cbAutoPopup;
00128     class QSpinBox *sbAutoPopup;
00129     class QLabel *lSbRight;
00130 };
00131 
00132 #endif // _DocWordCompletionPlugin_h_
00133 // kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;

Kate

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal