KDevelop API Documentation

abbrevpart.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2002 Roberto Raggi                                      *
00003  *   roberto@kdevelop.org                                                  *
00004  *   Copyright (C) 2002 by Bernd Gehrmann                                  *
00005  *   bernd@kdevelop.org                                                    *
00006  *   Copyright (C) 2003 by Alexander Dymo                                  *
00007  *   cloudtemple@mksat.net                                                 *
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 #ifndef _ABBREVPART_H_
00017 #define _ABBREVPART_H_
00018 
00019 #include <qmap.h>
00020 #include <qptrlist.h>
00021 #include "kdevplugin.h"
00022 
00023 #include <ktexteditor/codecompletioninterface.h>
00024 
00025 class KDialogBase;
00026 
00027 namespace KParts{
00028     class Part;
00029 }
00030 
00031 namespace KTextEditor{
00032     class Document;
00033     class EditInterface;
00034     class ViewCursorInterface;
00035 }
00036 
00037 struct CodeTemplate {
00038     QString name;
00039     QString description;
00040     QString code;
00041     QString suffixes;
00042 };
00043 
00044 class CodeTemplateList {
00045 public:
00046     CodeTemplateList();
00047     ~CodeTemplateList();
00048 
00049     QMap<QString, CodeTemplate* > operator[](QString suffix);
00050     void insert(QString name, QString description, QString code, QString suffixes);
00051     void remove(const QString &suffixes, const QString &name);
00052     void clear();
00053     QStringList suffixes();
00054 
00055     QPtrList<CodeTemplate> allTemplates() const;
00056 
00057 private:
00058     QMap<QString, QMap<QString, CodeTemplate* > > templates;
00059     QPtrList<CodeTemplate> allCodeTemplates;
00060     QStringList m_suffixes;
00061 };
00062 
00063 class AbbrevPart : public KDevPlugin
00064 {
00065     Q_OBJECT
00066 
00067 public:
00068     AbbrevPart( QObject *parent, const char *name, const QStringList & );
00069     ~AbbrevPart();
00070 
00071     bool autoWordCompletionEnabled() const;
00072     void setAutoWordCompletionEnabled( bool enabled );
00073 
00074     void addTemplate(const QString &templ, const QString &descr,
00075                      const QString &suffixes, const QString &code);
00076     void removeTemplate(const QString &suffixes, const QString &name);
00077     void clearTemplates();
00078     CodeTemplateList templates() const;
00079 
00080 private slots:
00081     void slotExpandText();
00082     void slotExpandAbbrev();
00083     void configWidget(KDialogBase *dlg);
00084     void slotActivePartChanged( KParts::Part* );
00085     void slotTextChanged();
00086     void slotCompletionAborted();
00087     void slotCompletionDone();
00088     void slotFilterInsertString( KTextEditor::CompletionEntry*, QString* );
00089     void slotAboutToShowCompletionBox();
00090 
00091 private:
00092     void updateActions();
00093     void load();
00094     void save();
00095     QString currentWord() const;
00096     QValueList<KTextEditor::CompletionEntry> findAllWords(const QString &text, const QString &prefix);
00097     void insertChars( const QString &chars );
00098 //    QAsciiDict<CodeTemplate> m_templates;
00099     CodeTemplateList m_templates;
00100     bool m_inCompletion;
00101     int m_prevLine;
00102     int m_prevColumn;
00103     int m_sequenceLength;
00104     bool m_autoWordCompletionEnabled;
00105     QString m_completionFile;
00106 
00107     KTextEditor::Document* docIface;
00108     KTextEditor::EditInterface* editIface;
00109     KTextEditor::ViewCursorInterface* viewCursorIface;
00110     KTextEditor::CodeCompletionInterface* completionIface;
00111 };
00112 
00113 #endif
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:53 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003