From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- parts/abbrev/abbrevpart.h | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 parts/abbrev/abbrevpart.h (limited to 'parts/abbrev/abbrevpart.h') diff --git a/parts/abbrev/abbrevpart.h b/parts/abbrev/abbrevpart.h new file mode 100644 index 00000000..f0029b51 --- /dev/null +++ b/parts/abbrev/abbrevpart.h @@ -0,0 +1,113 @@ +/*************************************************************************** + * Copyright (C) 2002 Roberto Raggi * + * roberto@kdevelop.org * + * Copyright (C) 2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * Copyright (C) 2003 by Alexander Dymo * + * cloudtemple@mksat.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _ABBREVPART_H_ +#define _ABBREVPART_H_ + +#include +#include +#include "kdevplugin.h" + +#include + +class KDialogBase; + +namespace KParts{ + class Part; +} + +namespace KTextEditor{ + class Document; + class EditInterface; + class ViewCursorInterface; +} + +struct CodeTemplate { + QString name; + QString description; + QString code; + QString suffixes; +}; + +class CodeTemplateList { +public: + CodeTemplateList(); + ~CodeTemplateList(); + + QMap operator[](QString suffix); + void insert(QString name, QString description, QString code, QString suffixes); + void remove(const QString &suffixes, const QString &name); + void clear(); + QStringList suffixes(); + + QPtrList allTemplates() const; + +private: + QMap > templates; + QPtrList allCodeTemplates; + QStringList m_suffixes; +}; + +class AbbrevPart : public KDevPlugin +{ + Q_OBJECT + +public: + AbbrevPart( QObject *parent, const char *name, const QStringList & ); + ~AbbrevPart(); + + bool autoWordCompletionEnabled() const; + void setAutoWordCompletionEnabled( bool enabled ); + + void addTemplate(const QString &templ, const QString &descr, + const QString &suffixes, const QString &code); + void removeTemplate(const QString &suffixes, const QString &name); + void clearTemplates(); + CodeTemplateList templates() const; + +private slots: + void slotExpandText(); + void slotExpandAbbrev(); + void configWidget(KDialogBase *dlg); + void slotActivePartChanged( KParts::Part* ); + void slotTextChanged(); + void slotCompletionAborted(); + void slotCompletionDone(); + void slotFilterInsertString( KTextEditor::CompletionEntry*, QString* ); + void slotAboutToShowCompletionBox(); + +private: + void updateActions(); + void load(); + void save(); + QString currentWord() const; + QValueList findAllWords(const QString &text, const QString &prefix); + void insertChars( const QString &chars ); +// QAsciiDict m_templates; + CodeTemplateList m_templates; + bool m_inCompletion; + int m_prevLine; + int m_prevColumn; + int m_sequenceLength; + bool m_autoWordCompletionEnabled; + QString m_completionFile; + + KTextEditor::Document* docIface; + KTextEditor::EditInterface* editIface; + KTextEditor::ViewCursorInterface* viewCursorIface; + KTextEditor::CodeCompletionInterface* completionIface; +}; + +#endif -- cgit v1.2.1