diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /kate/plugins/wordcompletion/docwordcompletion.h | |
download | tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/plugins/wordcompletion/docwordcompletion.h')
-rw-r--r-- | kate/plugins/wordcompletion/docwordcompletion.h | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/kate/plugins/wordcompletion/docwordcompletion.h b/kate/plugins/wordcompletion/docwordcompletion.h new file mode 100644 index 000000000..b42560fca --- /dev/null +++ b/kate/plugins/wordcompletion/docwordcompletion.h @@ -0,0 +1,133 @@ +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + --- + file: docwordcompletion.h + + KTextEditor plugin to autocompletion with document words. + Copyright Anders Lund <[email protected]>, 2003 + + The following completion methods are supported: + * Completion with bigger matching words in + either direction (backward/forward). + * NOT YET Pop up a list of all bigger matching words in document + +*/ + +#ifndef _DocWordCompletionPlugin_h_ +#define _DocWordCompletionPlugin_h_ + +#include <ktexteditor/plugin.h> +#include <ktexteditor/view.h> +#include <ktexteditor/codecompletioninterface.h> +#include <ktexteditor/configinterfaceextension.h> +#include <kxmlguiclient.h> + +#include <qevent.h> +#include <qobject.h> +#include <qvaluelist.h> + +class DocWordCompletionPlugin + : public KTextEditor::Plugin + , public KTextEditor::PluginViewInterface + , public KTextEditor::ConfigInterfaceExtension +{ + Q_OBJECT + + public: + DocWordCompletionPlugin( QObject *parent = 0, + const char* name = 0, + const QStringList &args = QStringList() ); + virtual ~DocWordCompletionPlugin() {}; + + void addView (KTextEditor::View *view); + void removeView (KTextEditor::View *view); + + void readConfig(); + void writeConfig(); + + // ConfigInterfaceExtention + uint configPages() const { return 1; }; + KTextEditor::ConfigPage * configPage( uint number, QWidget *parent, const char *name ); + QString configPageName( uint ) const; + QString configPageFullName( uint ) const; + QPixmap configPagePixmap( uint, int ) const; + + uint treshold() const { return m_treshold; }; + void setTreshold( uint t ) { m_treshold = t; }; + bool autoPopupEnabled() const { return m_autopopup; }; + void setAutoPopupEnabled( bool enable ) { m_autopopup = enable; }; + + + private: + QPtrList<class DocWordCompletionPluginView> m_views; + uint m_treshold; + bool m_autopopup; + +}; + +class DocWordCompletionPluginView + : public QObject, public KXMLGUIClient +{ + Q_OBJECT + + public: + DocWordCompletionPluginView( uint treshold=3, bool autopopup=true, KTextEditor::View *view=0, + const char *name=0 ); + ~DocWordCompletionPluginView() {}; + + void settreshold( uint treshold ); + + private slots: + void completeBackwards(); + void completeForwards(); + void shellComplete(); + + void popupCompletionList( QString word=QString::null ); + void autoPopupCompletionList(); + void toggleAutoPopup(); + + void slotVariableChanged( const QString &, const QString & ); + + private: + void complete( bool fw=true ); + + QString word(); + QValueList<KTextEditor::CompletionEntry> allMatches( const QString &word ); + QString findLongestUnique(const QValueList < KTextEditor::CompletionEntry > &matches); + KTextEditor::View *m_view; + struct DocWordCompletionPluginViewPrivate *d; +}; + +class DocWordCompletionConfigPage : public KTextEditor::ConfigPage +{ + Q_OBJECT + public: + DocWordCompletionConfigPage( DocWordCompletionPlugin *completion, QWidget *parent, const char *name ); + virtual ~DocWordCompletionConfigPage() {}; + + virtual void apply(); + virtual void reset(); + virtual void defaults(); + + private: + DocWordCompletionPlugin *m_completion; + class QCheckBox *cbAutoPopup; + class QSpinBox *sbAutoPopup; + class QLabel *lSbRight; +}; + +#endif // _DocWordCompletionPlugin_h_ +// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off; |