Snippets: Add more use-cases

- Restored removed built-in snippets.
- Revert a built-in snippet.
- Reset the snippets collection.
This commit is contained in:
Leandro Melo
2010-11-24 11:04:24 +01:00
parent 22c9b652b0
commit b87861f9b4
5 changed files with 194 additions and 56 deletions

View File

@@ -76,10 +76,14 @@ public:
Hint computeReplacementHint(int index, const Snippet &snippet, Snippet::Group group);
void removeSnippet(int index, Snippet::Group group);
void restoreRemovedSnippets(Snippet::Group group);
void setSnippetContent(int index, Snippet::Group group, const QString &content);
const Snippet &snippet(int index, Snippet::Group group) const;
Snippet revertedSnippet(int index, Snippet::Group group) const;
void reset(Snippet::Group group);
int totalActiveSnippets(Snippet::Group group) const;
int totalSnippets(Snippet::Group group) const;
@@ -89,9 +93,10 @@ public:
private:
void clear();
void clear(Snippet::Group group);
void updateActiveSnippetsEnd(Snippet::Group group);
static QList<Snippet> readXML(const QString &fileName);
static QList<Snippet> readXML(const QString &fileName, const QString &snippetId = QString());
static void writeSnippetXML(const Snippet &snippet, QXmlStreamWriter *writer);
static const QLatin1String kSnippet;
@@ -103,9 +108,15 @@ private:
static const QLatin1String kRemoved;
static const QLatin1String kModified;
// Snippets for each group are kept in a list. However, not all of them are necessarily
// active. Specifically, removed built-in snippets are kept as the last ones (for each
// group there is a iterator that marks the logical end).
QVector<QList<Snippet> > m_snippets;
QVector<QList<Snippet>::iterator> m_activeSnippetsEnd;
// Built-in snippets are specified in an XML embedded as a resource. Snippets created/
// modified/removed by the user are stored in another XML created dynamically in the
// user's folder.
QString m_builtInSnippetsPath;
QString m_userSnippetsPath;
QString m_snippetsFileName;