Commit 6f96a001 authored by Nikita Sirgienko's avatar Nikita Sirgienko

[GSoC 2020] move some code from CantorShell to PanelPluginHandler

parent 4d97fc8d
Pipeline #28339 passed with stage
in 19 minutes and 45 seconds
......@@ -414,7 +414,7 @@ void CantorShell::activateWorksheet(int index)
Cantor::WorksheetAccessInterface* wa=m_part->findChild<Cantor::WorksheetAccessInterface*>(Cantor::WorksheetAccessInterface::Name);
assert(wa);
PanelStates states;
Cantor::PanelPluginHandler::PanelStates states;
QList<Cantor::PanelPlugin*> plugins=m_panelHandler.plugins(wa->session());
for(Cantor::PanelPlugin* plugin : plugins)
{
......@@ -718,26 +718,9 @@ void CantorShell::updatePanel()
if (wa)
{
QDockWidget* last=nullptr;
plugins = m_panelHandler.plugins(wa->session());
plugins = m_panelHandler.activePluginsForSession(wa->session(), m_pluginsStates.contains(m_part) ? m_pluginsStates[m_part] : Cantor::PanelPluginHandler::PanelStates());
for(Cantor::PanelPlugin* plugin : plugins)
{
if(plugin==nullptr)
{
qDebug()<<"somethings wrong";
continue;
}
qDebug()<<"adding panel for "<<plugin->name();
if (m_pluginsStates.contains(m_part))
plugin->restoreState(m_pluginsStates[m_part][plugin->name()]);
else
{
Cantor::PanelPlugin::State initState;
initState.session = wa->session();
plugin->restoreState(initState);
}
QDockWidget* foundDocker = nullptr;
for (QDockWidget* docker : m_panels)
if (docker->objectName() == plugin->name())
......
......@@ -43,8 +43,6 @@ namespace KParts{
class ReadWritePart;
}
using PanelStates = QMap<QString, Cantor::PanelPlugin::State>;
/**
* This is the application "Shell". It has a menubar, toolbar, and
* statusbar but relies on the "Part" to do all the real work.
......@@ -123,7 +121,7 @@ private:
private:
QMap<KParts::ReadWritePart*, QStringList> m_pluginsVisibility;
QMap<KParts::ReadWritePart*, PanelStates> m_pluginsStates;
QMap<KParts::ReadWritePart*, Cantor::PanelPluginHandler::PanelStates> m_pluginsStates;
QList<KParts::ReadWritePart *> m_parts;
QMap<KParts::ReadWritePart*, QString> m_parts2Backends;
KParts::ReadWritePart* m_part;
......
......@@ -128,3 +128,26 @@ QList<PanelPlugin*> PanelPluginHandler::plugins(Session* session)
return pluginsForSession;
}
QList<PanelPlugin*> PanelPluginHandler::activePluginsForSession(Session* session, const PanelStates& previousPluginStates)
{
QList<Cantor::PanelPlugin*> plugins = this->plugins(session);
for(Cantor::PanelPlugin* plugin : plugins)
{
if(plugin==nullptr)
{
qDebug()<<"somethings wrong with plugin inside PanelPluginHandler";
continue;
}
if (previousPluginStates.contains(plugin->name()))
plugin->restoreState(previousPluginStates[plugin->name()]);
else
{
Cantor::PanelPlugin::State initState;
initState.session = session;
plugin->restoreState(initState);
}
}
return plugins;
}
......@@ -22,12 +22,12 @@
#define _PANELPLUGINHANDLER_H
#include <QObject>
#include <panelplugin.h>
#include "cantor_export.h"
namespace Cantor
{
class PanelPluginHandlerPrivate;
class PanelPlugin;
class Session;
/**
......@@ -45,6 +45,9 @@ class CANTOR_EXPORT PanelPluginHandler : public QObject
QList<PanelPlugin*> allPlugins();
QList<PanelPlugin*> plugins(Session* session);
using PanelStates = QMap<QString, Cantor::PanelPlugin::State>;
QList<PanelPlugin*> activePluginsForSession(Session* session, const PanelStates& previousPluginStates);
void loadPlugins();
private:
......
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