Commit 70fb3249 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

project: expose additional project information

parent 646193ca
......@@ -298,6 +298,11 @@ QPair<KateProjectView *, KateProjectInfoView *> KateProjectPluginView::viewForPr
m_projectsCombo->addItem(QIcon::fromTheme(QStringLiteral("project-open")), project->name(), project->fileName());
m_projectsComboGit->addItem(QIcon::fromTheme(QStringLiteral("project-open")), project->name(), project->fileName());
/*
* inform onward
*/
Q_EMIT pluginProjectAdded(project->baseDir(), project->name());
/**
* remember and return it
*/
......@@ -387,6 +392,17 @@ QStringList KateProjectPluginView::allProjectsFiles() const
return fileList;
}
QMap<QString, QString> KateProjectPluginView::allProjects() const
{
QMap<QString, QString> projectMap;
const auto projectList = m_plugin->projects();
for (auto project : projectList) {
projectMap[project->baseDir()] = project->name();
}
return projectMap;
}
void KateProjectPluginView::slotViewChanged()
{
/**
......@@ -609,6 +625,9 @@ void KateProjectPluginView::slotProjectClose(KateProject *project)
m_projectsCombo->removeItem(index);
m_projectsComboGit->removeItem(index);
// inform onward
Q_EMIT pluginProjectRemoved(project->baseDir(), project->name());
}
QString KateProjectPluginView::currentWord() const
......
......@@ -26,6 +26,9 @@ class KateProjectView;
class KateProjectPlugin;
class KateProjectInfoView;
typedef QMap<QString, QString> QStringMap;
Q_DECLARE_METATYPE(QStringMap)
class KateProjectPluginView : public QObject, public KXMLGUIClient
{
Q_OBJECT
......@@ -38,6 +41,7 @@ class KateProjectPluginView : public QObject, public KXMLGUIClient
Q_PROPERTY(QString allProjectsCommonBaseDir READ allProjectsCommonBaseDir)
Q_PROPERTY(QStringList allProjectsFiles READ allProjectsFiles)
Q_PROPERTY(QStringMap allProjects READ allProjects)
public:
KateProjectPluginView(KateProjectPlugin *plugin, KTextEditor::MainWindow *mainWindow);
......@@ -84,6 +88,11 @@ public:
*/
QStringList allProjectsFiles() const;
/**
* @returns a map of all open projects which maps base directory to name
*/
QMap<QString, QString> allProjects() const;
/**
* the main window we belong to
* @return our main window
......@@ -199,6 +208,16 @@ private Q_SLOTS:
Q_SIGNALS:
/**
* Emitted if project is about to close.
*/
void pluginProjectRemoved(QString baseDir, QString name);
/**
* Emitted if project is added.
*/
void pluginProjectAdded(QString baseDir, QString name);
/**
* Emitted if project is about to close.
*/
......
Markdown is supported
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