Commit 6686e5f6 authored by loh tar's avatar loh tar Committed by Christoph Cullmann

BuildView: Fix broken load of project plugin targets

Summary: Most changes are only a little code cosmetic, like unwrap lines or remove spaces

Test Plan:
Here it was reproducible e.g. by changing between my sessions "kate" and "sonnet". I think you can guess what they are.

1. Start Kate with session "kate" -> Project Targets shown
2. Switch to "sonnet" -> No Project Targets shown. I think there are no (however) defined (any illuminating tip is appreciated)
3. Switch back to "kate" -> Also NO Project Targets shown, but should!

With this patch are at 3. the Project Targets back again

Reviewers: #kate, sars

Reviewed By: #kate, sars

Subscribers: sars, kwrite-devel, #kate

Tags: #kate

Differential Revision: https://phabricator.kde.org/D17339
parent e8496c60
......@@ -152,8 +152,7 @@ KateBuildView::KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindo
m_buildUi.cancelBuildButton->setEnabled(false);
m_buildUi.cancelBuildButton2->setEnabled(false);
connect(m_buildUi.errTreeWidget, &QTreeWidget::itemClicked,
this, &KateBuildView::slotErrorSelected);
connect(m_buildUi.errTreeWidget, &QTreeWidget::itemClicked, this, &KateBuildView::slotErrorSelected);
m_buildUi.plainTextEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
m_buildUi.plainTextEdit->setReadOnly(true);
......@@ -186,14 +185,12 @@ KateBuildView::KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindo
m_win->guiFactory()->addClient(this);
// watch for project plugin view creation/deletion
connect(m_win, &KTextEditor::MainWindow::pluginViewCreated,
this, &KateBuildView::slotPluginViewCreated);
connect(m_win, &KTextEditor::MainWindow::pluginViewDeleted,
this, &KateBuildView::slotPluginViewDeleted);
// update once project plugin state manually
m_projectPluginView = m_win->pluginView (QStringLiteral("kateprojectplugin"));
slotProjectMapChanged ();
connect(m_win, &KTextEditor::MainWindow::pluginViewCreated, this, &KateBuildView::slotPluginViewCreated);
connect(m_win, &KTextEditor::MainWindow::pluginViewDeleted, this, &KateBuildView::slotPluginViewDeleted);
// Connect signals from project plugin to our slots
m_projectPluginView = m_win->pluginView(QStringLiteral("kateprojectplugin"));
slotPluginViewCreated(QStringLiteral("kateprojectplugin"), m_projectPluginView);
}
......@@ -264,12 +261,17 @@ void KateBuildView::readSessionConfig(const KConfigGroup& cg)
QModelIndex root = m_targetsUi->targetsModel.index(tmpIndex);
QModelIndex cmdIndex = m_targetsUi->targetsModel.index(tmpCmd, 0, root);
m_targetsUi->targetsView->setCurrentIndex(cmdIndex);
// Add project targets, if any
slotAddProjectTarget();
}
/******************************************************************/
void KateBuildView::writeSessionConfig(KConfigGroup& cg)
{
// Don't save project targets, is not our area of accountability
m_targetsUi->targetsModel.deleteTargetSet(i18n("Project Plugin Targets"));
QList<TargetModel::TargetSet> targets = m_targetsUi->targetsModel.targetSets();
cg.writeEntry("NumTargets", targets.size());
......@@ -302,6 +304,8 @@ void KateBuildView::writeSessionConfig(KConfigGroup& cg)
cg.writeEntry(QStringLiteral("Active Target Index"), set);
cg.writeEntry(QStringLiteral("Active Target Command"), setRow);
// Restore project targets, if any
slotAddProjectTarget();
}
......@@ -914,18 +918,18 @@ void KateBuildView::slotDisplayMode(int mode) {
}
/******************************************************************/
void KateBuildView::slotPluginViewCreated (const QString &name, QObject *pluginView)
void KateBuildView::slotPluginViewCreated(const QString &name, QObject *pluginView)
{
// add view
if (name == QLatin1String("kateprojectplugin")) {
if (pluginView && name == QLatin1String("kateprojectplugin")) {
m_projectPluginView = pluginView;
slotProjectMapChanged ();
connect(pluginView, SIGNAL(projectMapChanged()), this, SLOT(slotProjectMapChanged()));
slotAddProjectTarget();
connect(pluginView, SIGNAL(projectMapChanged()), this, SLOT(slotProjectMapChanged()), Qt::UniqueConnection);
}
}
/******************************************************************/
void KateBuildView::slotPluginViewDeleted (const QString &name, QObject *)
void KateBuildView::slotPluginViewDeleted(const QString &name, QObject *)
{
// remove view
if (name == QLatin1String("kateprojectplugin")) {
......@@ -935,7 +939,7 @@ void KateBuildView::slotPluginViewDeleted (const QString &name, QObject *)
}
/******************************************************************/
void KateBuildView::slotProjectMapChanged ()
void KateBuildView::slotProjectMapChanged()
{
// only do stuff with valid project
if (!m_projectPluginView) {
......
......@@ -160,7 +160,7 @@ class KateBuildView : public QObject, public KXMLGUIClient, public KTextEditor::
/**
* current project plugin view, if any
*/
QObject *m_projectPluginView;
QObject *m_projectPluginView = nullptr;
};
......
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