• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • 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/codecompletionmodel.h>
00036 #include <ktexteditor/configpage.h>
00037 #include <kxmlguiclient.h>
00038 
00039 #include <QtCore/QEvent>
00040 #include <QtCore/QObject>
00041 #include <QtCore/QList>
00042 
00043 #include <kdebug.h>
00044 
00045 class DocWordCompletionModel
00046   : public KTextEditor::CodeCompletionModel
00047 {
00048   Q_OBJECT
00049   public:
00050     DocWordCompletionModel( QObject *parent );
00051     ~DocWordCompletionModel();
00052 
00063     void completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType);
00064 
00065     void saveMatches( KTextEditor::View* view,
00066                             const KTextEditor::Range& range);
00067 
00068     int rowCount ( const QModelIndex & parent ) const;
00069 
00070     QVariant data(const QModelIndex& index, int role) const;
00071     virtual QModelIndex index(int row, int column, const QModelIndex& parent=QModelIndex()) const;
00072 
00073     const QStringList allMatches( KTextEditor::View *view, const KTextEditor::Range &range, int minAdditionalLength = 1 ) const;
00074 
00075   private:
00076     QStringList m_matches;
00077 };
00078 
00079 class DocWordCompletionPlugin
00080   : public KTextEditor::Plugin
00081 {
00082   Q_OBJECT
00083 
00084   public:
00085     explicit DocWordCompletionPlugin( QObject *parent,
00086                             const QVariantList &args );
00087     virtual ~DocWordCompletionPlugin(){ plugin = 0; kDebug( 13040 )<<"~DocWordCompletionPlugin";}
00088 
00089     static DocWordCompletionPlugin *self() { return plugin; }
00090 
00091     void addView (KTextEditor::View *view);
00092     void removeView (KTextEditor::View *view);
00093 
00094     void readConfig();
00095     void writeConfig();
00096 
00097     uint treshold() const;
00098     void setTreshold( uint t );
00099     bool autoPopupEnabled() const;
00100     void setAutoPopupEnabled( bool enable );
00101   private:
00102     static DocWordCompletionPlugin *plugin;
00103     QList<class DocWordCompletionPluginView*> m_views;
00104     uint m_treshold;
00105     bool m_autopopup;
00106     DocWordCompletionModel *m_dWCompletionModel;
00107 
00108 };
00109 
00110 class DocWordCompletionPluginView
00111    : public QObject, public KXMLGUIClient
00112 {
00113   Q_OBJECT
00114 
00115   public:
00116     explicit DocWordCompletionPluginView( uint treshold=3,
00117                                  bool autopopup=true,
00118                                  KTextEditor::View *view=0,
00119                                  DocWordCompletionModel *completionModel=0 );
00120     ~DocWordCompletionPluginView();
00121 
00122     void setTreshold( uint treshold );
00123     void setAutoPopupEnabled( bool enable );
00124 
00125   public Q_SLOTS:
00126     void toggleAutoPopup();
00127 
00128   private Q_SLOTS:
00129     void completeBackwards();
00130     void completeForwards();
00131     void slotCursorMoved();
00132 
00133     void shellComplete();
00134 
00135     void popupCompletionList();
00136     void autoPopupCompletionList();
00137 
00138     void slotVariableChanged(KTextEditor::Document*, const QString &, const QString & );
00139 
00140   private:
00141     void complete( bool fw=true );
00142 
00143     const QString word() const;
00144     const KTextEditor::Range range() const;
00145 
00146     QString findLongestUnique( const QStringList &matches, int lead ) const;
00147 
00148     KTextEditor::View *m_view;
00149     DocWordCompletionModel *m_dWCompletionModel;
00150     struct DocWordCompletionPluginViewPrivate *d;
00151 };
00152 
00153 #endif // _DocWordCompletionPlugin_h_
00154 // 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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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