• Skip to content
  • Skip to link menu
KDE 4.2 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, class DocWordCompletionPlugin *plugin );
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     class DocWordCompletionPlugin *m_plugin;
00078 };
00079 
00080 class DocWordCompletionPlugin
00081   : public KTextEditor::Plugin
00082 {
00083   Q_OBJECT
00084 
00085   public:
00086     explicit DocWordCompletionPlugin( QObject *parent,
00087                             const QVariantList &args );
00088     virtual ~DocWordCompletionPlugin(){ plugin = 0; kDebug( 13040 )<<"~DocWordCompletionPlugin";}
00089 
00090     static DocWordCompletionPlugin *self() { return plugin; }
00091 
00092     void addView (KTextEditor::View *view);
00093     void removeView (KTextEditor::View *view);
00094 
00095     void readConfig();
00096     void writeConfig();
00097 
00098     uint treshold() const;
00099     void setTreshold( uint t );
00100     bool autoPopupEnabled() const;
00101     void setAutoPopupEnabled( bool enable );
00102   private:
00103     static DocWordCompletionPlugin *plugin;
00104     friend class DocWordCompletionModel;
00105     QHash<class KTextEditor::View*,class DocWordCompletionPluginView*> m_views;
00106     uint m_treshold;
00107     bool m_autopopup;
00108     DocWordCompletionModel *m_dWCompletionModel;
00109 
00110 };
00111 
00112 class DocWordCompletionPluginView
00113    : public QObject, public KXMLGUIClient
00114 {
00115   Q_OBJECT
00116 
00117   public:
00118     explicit DocWordCompletionPluginView( uint treshold=3,
00119                                  bool autopopup=true,
00120                                  KTextEditor::View *view=0,
00121                                  DocWordCompletionModel *completionModel=0 );
00122     ~DocWordCompletionPluginView();
00123 
00124     void setTreshold( uint treshold );
00125     void setAutoPopupEnabled( bool enable );
00126     uint threshold();
00127     bool autoPopupEnabled();
00128   public Q_SLOTS:
00129     void toggleAutoPopup();
00130 
00131   private Q_SLOTS:
00132     void completeBackwards();
00133     void completeForwards();
00134     void slotCursorMoved();
00135 
00136     void shellComplete();
00137 
00138     void popupCompletionList();
00139     void autoPopupCompletionList();
00140 
00141     void slotVariableChanged(KTextEditor::Document*, const QString &, const QString & );
00142 
00143   private:
00144     void complete( bool fw=true );
00145 
00146     const QString word() const;
00147     const KTextEditor::Range range() const;
00148 
00149     QString findLongestUnique( const QStringList &matches, int lead ) const;
00150 
00151     KTextEditor::View *m_view;
00152     DocWordCompletionModel *m_dWCompletionModel;
00153     struct DocWordCompletionPluginViewPrivate *d;
00154 };
00155 
00156 #endif // _DocWordCompletionPlugin_h_
00157 // 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
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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