/* * templates.h - set of utils to make editing templates easier * Copyright (C) 2005 Maciej Niedzielski * * 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. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef TEMPLATES_UTILS_H #define TEMPLATES_UTILS_H #include #include #include #include class QTextEdit; //---------------------------------------------------------------------------- // TemplatePopup //---------------------------------------------------------------------------- // popup menu containing template tags class TemplatePopup : public QPopupMenu { Q_OBJECT public: TemplatePopup(QTextEdit *edt, QWidget * parent = 0, const char * name = 0); ~TemplatePopup(); int insertTemplateItem(const QString &name, const QString &tag, const QString &desc=""); private: class Private; Private *d; private slots: void onActivated(int id); }; //---------------------------------------------------------------------------- // TemplateEditHighlighter //---------------------------------------------------------------------------- // text highlighter highlighting template tags class TemplateEditHighlighter : public QSyntaxHighlighter { public: typedef QValueVector TagsVector; TemplateEditHighlighter(QTextEdit *edt, TagsVector templateTags); int highlightParagraph(const QString & text, int endStateOfLastPara); private: TagsVector tags; }; //---------------------------------------------------------------------------- // Template //---------------------------------------------------------------------------- class Template : public QString { public: Template() : QString() {} Template(const QString &s) : QString(s) {} Template(const Template &t) : QString(t) {} Template(const char *str) : QString(str) {} typedef QMap ExpandData; Template expand(const ExpandData &values) const; }; #endif