Commit 8f2f2428 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Make SnippetRepository a non qobject

parent 4478e509
Pipeline #172276 passed with stage
in 6 minutes and 1 second
......@@ -53,7 +53,9 @@ SnippetRepository::SnippetRepository(const QString &file)
if (QFile::exists(file)) {
// Tell the new repository to load it's snippets
QTimer::singleShot(0, this, &SnippetRepository::slotParseFile);
QTimer::singleShot(0, model(), [this] {
parseFile();
});
}
// qDebug() << "created new snippet repo" << file << this;
......@@ -82,7 +84,7 @@ SnippetRepository *SnippetRepository::createRepoFromName(const QString &name)
const auto &dir = dataPath();
const auto &path = dir.absoluteFilePath(cleanName + QLatin1String(".xml"));
qDebug() << "repo path:" << path << cleanName;
// qDebug() << "repo path:" << path << cleanName;
SnippetRepository *repo = new SnippetRepository(path);
repo->setText(name);
......@@ -170,7 +172,7 @@ static void addAndCreateElement(QDomDocument &doc, QDomElement &item, const QStr
void SnippetRepository::save()
{
qDebug() << "*** called";
// qDebug() << "*** called";
/// based on the code from snippets_tng/lib/completionmodel.cpp
///@copyright 2009 Joseph Wenninger <jowenn@kde.org>
/*
......@@ -260,7 +262,7 @@ void SnippetRepository::save()
config.sync();
}
void SnippetRepository::slotParseFile()
void SnippetRepository::parseFile()
{
/// based on the code from snippets_tng/lib/completionmodel.cpp
///@copyright 2009 Joseph Wenninger <jowenn@kde.org>
......
......@@ -34,10 +34,8 @@ namespace KTextEditor
* @author Robert Gruber <rgruber@users.sourceforge.net>
* @author Milian Wolff <mail@milianw.de>
*/
class SnippetRepository : public QObject, public QStandardItem
class SnippetRepository : public QStandardItem
{
Q_OBJECT
public:
/**
* Creates a new SnippetRepository. When @p file exists it will be parsed (XML).
......@@ -130,9 +128,8 @@ public:
QVariant data(int role = Qt::UserRole + 1) const override;
void setData(const QVariant &value, int role = Qt::UserRole + 1) override;
private Q_SLOTS:
/// parses the XML file and load the containing snippets.
void slotParseFile();
void parseFile();
private:
/// path to the repository file
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment