Snippets: Make it easier for plugins to add snippets groups

Groups are no longer enum values but identified from snippet providers.
This commit is contained in:
Leandro Melo
2010-12-02 17:02:23 +01:00
parent fdbb34adb8
commit 1175705bfc
32 changed files with 411 additions and 272 deletions

View File

@@ -40,18 +40,11 @@ namespace TextEditor {
class TEXTEDITOR_EXPORT Snippet
{
public:
Snippet(const QString &id = QString());
Snippet(const QString &groupId = QString(), const QString &id = QString());
~Snippet();
// Values from this enumeration need to be contiguous (they are used as indexes).
enum Group {
Cpp = 0,
Qml,
PlainText,
GroupSize
};
const QString &id() const;
const QString &groupId() const;
bool isBuiltIn() const;
@@ -70,9 +63,6 @@ public:
void setIsModified(bool modified);
bool isModified() const;
void setGroup(Group group);
Group group() const;
QString generateTip() const;
static const QChar kVariableDelimiter;
@@ -80,19 +70,13 @@ public:
private:
bool m_isRemoved;
bool m_isModified;
QString m_groupId;
QString m_id; // Only built-in snippets have an id.
QString m_trigger;
QString m_content;
QString m_complement;
Group m_group;
};
inline Snippet::Group& operator++(Snippet::Group& group)
{
group = Snippet::Group(group + 1);
return group;
}
} // TextEditor
#endif // SNIPPET_H