kate
docwordcompletion.h
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 <tdetexteditor/plugin.h>
00033 #include <tdetexteditor/view.h>
00034 #include <tdetexteditor/codecompletioninterface.h>
00035 #include <tdetexteditor/configinterfaceextension.h>
00036 #include <kxmlguiclient.h>
00037
00038 #include <tqevent.h>
00039 #include <tqobject.h>
00040 #include <tqvaluelist.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( TQObject *parent = 0,
00051 const char* name = 0,
00052 const TQStringList &args = TQStringList() );
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, TQWidget *parent, const char *name );
00064 TQString configPageName( uint ) const;
00065 TQString configPageFullName( uint ) const;
00066 TQPixmap 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 TQPtrList<class DocWordCompletionPluginView> m_views;
00076 uint m_treshold;
00077 bool m_autopopup;
00078
00079 };
00080
00081 class DocWordCompletionPluginView
00082 : public TQObject, 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( TQString word=TQString::null );
00099 void autoPopupCompletionList();
00100 void toggleAutoPopup();
00101
00102 void slotVariableChanged( const TQString &, const TQString & );
00103
00104 private:
00105 void complete( bool fw=true );
00106
00107 TQString word();
00108 TQValueList<KTextEditor::CompletionEntry> allMatches( const TQString &word );
00109 TQString findLongestUnique(const TQValueList < 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, TQWidget *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 TQCheckBox *cbAutoPopup;
00128 class TQSpinBox *sbAutoPopup;
00129 class TQLabel *lSbRight;
00130 };
00131
00132 #endif // _DocWordCompletionPlugin_h_
00133