Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Cantor
Commits
6f96a001
Commit
6f96a001
authored
Jul 25, 2020
by
Nikita Sirgienko
Browse files
[GSoC 2020] move some code from CantorShell to PanelPluginHandler
parent
4d97fc8d
Pipeline
#28339
passed with stage
in 19 minutes and 45 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/cantor.cpp
View file @
6f96a001
...
...
@@ -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
())
...
...
src/cantor.h
View file @
6f96a001
...
...
@@ -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
;
...
...
src/lib/panelpluginhandler.cpp
View file @
6f96a001
...
...
@@ -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
;
}
src/lib/panelpluginhandler.h
View file @
6f96a001
...
...
@@ -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:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment