00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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_