Commit e3850b5d authored by Mark Nauwelaerts's avatar Mark Nauwelaerts Committed by Christoph Cullmann
Browse files

project: expose some project data directly on plugin

parent f1ac0c58
......@@ -41,6 +41,9 @@ class KateProject : public QObject
{
Q_OBJECT
Q_PROPERTY(QString baseDir READ baseDir)
Q_PROPERTY(QString name READ name)
public:
/**
* Construct project by reading from given file.
......@@ -174,7 +177,7 @@ public:
* rename a file
*/
void renameFile(const QString &newName, const QString &oldName);
/**
* remove a file
*/
......
......@@ -111,6 +111,12 @@ KateProjectPlugin::KateProjectPlugin(QObject *parent, const QList<QVariant> &)
Q_EMIT activateProject(projectToActivate);
});
}
/**
* forward to meta-object system friendly version
*/
connect(this, &KateProjectPlugin::projectCreated, this, &KateProjectPlugin::projectAdded);
connect(this, &KateProjectPlugin::pluginViewProjectClosing, this, &KateProjectPlugin::projectRemoved);
}
KateProjectPlugin::~KateProjectPlugin()
......@@ -267,6 +273,15 @@ void KateProjectPlugin::closeProject(KateProject *project)
}
}
QList<QObject *> KateProjectPlugin::projectsObjects() const
{
QList<QObject *> list;
for (auto &p : m_projects) {
list.push_back(p);
}
return list;
}
bool KateProjectPlugin::projectHasOpenDocuments(KateProject *project) const
{
for (const auto &it : m_document2Project) {
......@@ -396,7 +411,6 @@ KateProject *KateProjectPlugin::createProjectForDirectory(const QDir &dir)
return project;
}
KateProject *KateProjectPlugin::createProjectForDirectory(const QDir &dir, const QVariantMap &projectMap)
{
// check if we already have the needed project opened
......
......@@ -35,6 +35,7 @@ class KateProjectPlugin : public KTextEditor::Plugin, public KTextEditor::Sessio
{
Q_OBJECT
Q_INTERFACES(KTextEditor::SessionConfigInterface)
Q_PROPERTY(QList<QObject *> projects READ projectsObjects)
public:
explicit KateProjectPlugin(QObject *parent = nullptr, const QList<QVariant> & = QList<QVariant>());
......@@ -89,6 +90,11 @@ public:
return m_projects;
}
/**
* As above, in different form for property access.
*/
QList<QObject *> projectsObjects() const;
/**
* Has the given project open documents?
* @param project project to check open document for
......@@ -173,6 +179,12 @@ Q_SIGNALS:
*/
void projectCreated(KateProject *project);
/**
* As above, but with adjusted naming and meta-object type friendly.
*/
void projectRemoved(QObject *project);
void projectAdded(QObject *project);
/**
* Signal that plugin configuration changed
*/
......
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