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
PIM
KOrganizer
Commits
1856b09d
Commit
1856b09d
authored
Aug 17, 2021
by
Nicolas Fella
Browse files
Remove unused part loading
There are no first-party parts that get loaded
parent
71f7d44c
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/actionmanager.cpp
View file @
1856b09d
...
...
@@ -100,9 +100,6 @@ ActionManager::ActionManager(KXMLGUIClient *client,
ActionManager
::~
ActionManager
()
{
// Remove Part plugins
KOCore
::
self
()
->
unloadParts
(
mMainWindow
,
mParts
);
delete
mTempFile
;
// Take this window out of the window list.
...
...
@@ -999,8 +996,6 @@ void ActionManager::updateConfig()
korgacInterface
.
show
();
}
// Commented out because it crashes KOrganizer.
// mParts = KOCore::self()->reloadParts( mMainWindow, mParts );
#ifdef AKONADI_PORT_DISABLED // shouldn't be required anymore
if
(
mCollectionView
)
{
mCollectionView
->
updateView
();
...
...
@@ -1340,19 +1335,9 @@ void ActionManager::keyBindings()
dlg
.
addCollection
(
mMainWindow
->
getActionCollection
());
}
for
(
KOrg
::
Part
*
part
:
std
::
as_const
(
mParts
))
{
if
(
part
)
{
dlg
.
addCollection
(
part
->
actionCollection
(),
part
->
shortInfo
());
}
}
dlg
.
configure
();
}
void
ActionManager
::
loadParts
()
{
mParts
=
KOCore
::
self
()
->
loadParts
(
mMainWindow
);
}
void
ActionManager
::
setTitle
()
{
mMainWindow
->
setTitle
();
...
...
src/actionmanager.h
View file @
1856b09d
...
...
@@ -224,8 +224,6 @@ public Q_SLOTS:
void
saveProperties
(
KConfigGroup
&
);
void
readProperties
(
const
KConfigGroup
&
);
void
loadParts
();
void
importCalendar
(
const
QUrl
&
url
);
protected
Q_SLOTS
:
...
...
@@ -297,7 +295,6 @@ private:
Akonadi
::
Collection
selectedCollection
()
const
;
KOrg
::
Part
::
List
mParts
;
// List of parts loaded
QUrl
mURL
;
// URL of calendar file
QString
mFile
;
// Local name of calendar file
QString
mLastUrl
;
// URL of last loaded calendar.
...
...
src/kocore.cpp
View file @
1856b09d
...
...
@@ -51,11 +51,6 @@ KService::List KOCore::availableCalendarDecorations()
return
availablePlugins
(
EventViews
::
CalendarDecoration
::
Decoration
::
serviceType
(),
EventViews
::
CalendarDecoration
::
Decoration
::
interfaceVersion
());
}
KService
::
List
KOCore
::
availableParts
()
{
return
availablePlugins
(
KOrg
::
Part
::
serviceType
(),
KOrg
::
Part
::
interfaceVersion
());
}
EventViews
::
CalendarDecoration
::
Decoration
*
KOCore
::
loadCalendarDecoration
(
const
KService
::
Ptr
&
service
)
{
KPluginLoader
loader
(
*
service
);
...
...
@@ -89,32 +84,6 @@ EventViews::CalendarDecoration::Decoration *KOCore::loadCalendarDecoration(const
return
nullptr
;
}
KOrg
::
Part
*
KOCore
::
loadPart
(
const
KService
::
Ptr
&
service
,
KOrg
::
MainWindow
*
parent
)
{
qCDebug
(
KORGANIZER_LOG
)
<<
service
->
library
();
if
(
!
service
->
hasServiceType
(
KOrg
::
Part
::
serviceType
()))
{
return
nullptr
;
}
KPluginLoader
loader
(
*
service
);
KPluginFactory
*
factory
=
loader
.
factory
();
if
(
!
factory
)
{
qCDebug
(
KORGANIZER_LOG
)
<<
"Factory creation failed"
;
return
nullptr
;
}
auto
pluginFactory
=
static_cast
<
KOrg
::
PartFactory
*>
(
factory
);
if
(
!
pluginFactory
)
{
qCDebug
(
KORGANIZER_LOG
)
<<
"Cast failed"
;
return
nullptr
;
}
return
pluginFactory
->
createPluginFactory
(
parent
);
}
void
KOCore
::
addXMLGUIClient
(
QWidget
*
wdg
,
KXMLGUIClient
*
guiclient
)
{
mXMLGUIClients
.
insert
(
wdg
,
guiclient
);
...
...
@@ -140,18 +109,6 @@ KXMLGUIClient *KOCore::xmlguiClient(QWidget *wdg) const
return
nullptr
;
}
KOrg
::
Part
*
KOCore
::
loadPart
(
const
QString
&
name
,
KOrg
::
MainWindow
*
parent
)
{
const
KService
::
List
list
=
availableParts
();
KService
::
List
::
ConstIterator
end
(
list
.
constEnd
());
for
(
KService
::
List
::
ConstIterator
it
=
list
.
constBegin
();
it
!=
end
;
++
it
)
{
if
((
*
it
)
->
desktopEntryName
()
==
name
)
{
return
loadPart
(
*
it
,
parent
);
}
}
return
nullptr
;
}
EventViews
::
CalendarDecoration
::
Decoration
::
List
KOCore
::
loadCalendarDecorations
()
{
if
(
!
mCalendarDecorationsLoaded
)
{
...
...
@@ -176,30 +133,6 @@ EventViews::CalendarDecoration::Decoration::List KOCore::loadCalendarDecorations
return
mCalendarDecorations
;
}
KOrg
::
Part
::
List
KOCore
::
loadParts
(
KOrg
::
MainWindow
*
parent
)
{
KOrg
::
Part
::
List
parts
;
const
QStringList
selectedPlugins
=
KOPrefs
::
instance
()
->
mSelectedPlugins
;
const
KService
::
List
plugins
=
availableParts
();
const
KService
::
List
::
ConstIterator
end
(
plugins
.
constEnd
());
for
(
KService
::
List
::
ConstIterator
it
=
plugins
.
constBegin
();
it
!=
end
;
++
it
)
{
if
(
selectedPlugins
.
contains
((
*
it
)
->
desktopEntryName
()))
{
KOrg
::
Part
*
part
=
loadPart
(
*
it
,
parent
);
if
(
part
)
{
if
(
!
parent
->
mainGuiClient
())
{
qCCritical
(
KORGANIZER_LOG
)
<<
"parent has no mainGuiClient."
;
}
else
{
parent
->
mainGuiClient
()
->
insertChildClient
(
part
);
parts
.
append
(
part
);
}
}
}
}
return
parts
;
}
void
KOCore
::
unloadPlugins
()
{
qDeleteAll
(
mCalendarDecorations
);
...
...
@@ -207,30 +140,6 @@ void KOCore::unloadPlugins()
mCalendarDecorationsLoaded
=
false
;
}
void
KOCore
::
unloadParts
(
KOrg
::
MainWindow
*
parent
,
KOrg
::
Part
::
List
&
parts
)
{
// copy in case caller updates parts on destruction of a part
const
KOrg
::
Part
::
List
currentParts
=
parts
;
for
(
KOrg
::
Part
*
part
:
currentParts
)
{
parent
->
mainGuiClient
()
->
removeChildClient
(
part
);
delete
part
;
}
parts
.
clear
();
}
KOrg
::
Part
::
List
KOCore
::
reloadParts
(
KOrg
::
MainWindow
*
parent
,
KOrg
::
Part
::
List
&
parts
)
{
KXMLGUIFactory
*
factory
=
parent
->
mainGuiClient
()
->
factory
();
factory
->
removeClient
(
parent
->
mainGuiClient
());
unloadParts
(
parent
,
parts
);
const
KOrg
::
Part
::
List
list
=
loadParts
(
parent
);
factory
->
addClient
(
parent
->
mainGuiClient
());
return
list
;
}
void
KOCore
::
reloadPlugins
()
{
// TODO: does this still apply?
...
...
src/kocore.h
View file @
1856b09d
...
...
@@ -29,40 +29,19 @@ public:
static
KOCore
*
self
();
Q_REQUIRED_RESULT
KService
::
List
availableCalendarDecorations
();
Q_REQUIRED_RESULT
KService
::
List
availableParts
();
EventViews
::
CalendarDecoration
::
Decoration
*
loadCalendarDecoration
(
const
KService
::
Ptr
&
service
);
EventViews
::
CalendarDecoration
::
Decoration
*
loadCalendarDecoration
(
const
QString
&
);
KOrg
::
Part
*
loadPart
(
const
KService
::
Ptr
&
,
KOrg
::
MainWindow
*
parent
);
KOrg
::
Part
*
loadPart
(
const
QString
&
,
KOrg
::
MainWindow
*
parent
);
EventViews
::
CalendarDecoration
::
Decoration
::
List
loadCalendarDecorations
();
Q_REQUIRED_RESULT
KOrg
::
Part
::
List
loadParts
(
KOrg
::
MainWindow
*
parent
);
void
addXMLGUIClient
(
QWidget
*
,
KXMLGUIClient
*
guiclient
);
void
removeXMLGUIClient
(
QWidget
*
);
KXMLGUIClient
*
xmlguiClient
(
QWidget
*
)
const
;
/**
Unload the parts in &p parts for this main window. Clears
parts.
@param parent the parent main window for all parts
@param parts the list of parts to be undloaded
*/
void
unloadParts
(
KOrg
::
MainWindow
*
parent
,
KOrg
::
Part
::
List
&
parts
);
void
unloadPlugins
();
void
reloadPlugins
();
/**
Unloads the parts from the main window. Loads the parts that
are listed in KOPrefs and returns a list of these parts.
@param parent the parent main window for all parts
@param parts the list of parts to be reloaded
*/
KOrg
::
Part
::
List
reloadParts
(
KOrg
::
MainWindow
*
parent
,
KOrg
::
Part
::
List
&
parts
);
KIdentityManagement
::
IdentityManager
*
identityManager
();
protected:
...
...
src/korganizer.cpp
View file @
1856b09d
...
...
@@ -77,7 +77,6 @@ void KOrganizer::init(bool document)
mActionManager
->
createCalendarAkonadi
();
mActionManager
->
init
();
mActionManager
->
loadParts
();
KOrganizerPluginInterface
::
self
()
->
setActionCollection
(
actionCollection
());
KOrganizerPluginInterface
::
self
()
->
initializePlugins
();
...
...
src/korganizer_part.cpp
View file @
1856b09d
...
...
@@ -72,7 +72,6 @@ KOrganizerPart::KOrganizerPart(QWidget *parentWidget, QObject *parent, const QVa
mActionManager
->
readSettings
();
setXMLFile
(
QStringLiteral
(
"korganizer_part.rc"
),
true
);
mActionManager
->
loadParts
();
setTitle
();
}
...
...
src/prefs/koprefsdialogplugins.cpp
View file @
1856b09d
...
...
@@ -124,7 +124,6 @@ void KOPrefsDialogPlugins::usrReadConfig()
{
mTreeWidget
->
clear
();
KService
::
List
plugins
=
KOCore
::
self
()
->
availableCalendarDecorations
();
plugins
+=
KOCore
::
self
()
->
availableParts
();
EventViews
::
PrefsPtr
viewPrefs
=
KOPrefs
::
instance
()
->
eventViewsPreferences
();
...
...
src/tests/korgplugins.cpp
View file @
1856b09d
...
...
@@ -24,18 +24,7 @@ int main(int argc, char **argv)
parser
.
process
(
app
);
KService
::
List
::
ConstIterator
it
;
KService
::
List
plugins
=
KOCore
::
self
()
->
availableParts
();
for
(
it
=
plugins
.
constBegin
();
it
!=
plugins
.
constEnd
();
++
it
)
{
qDebug
()
<<
"Part:"
<<
(
*
it
)
->
desktopEntryName
()
<<
"("
<<
(
*
it
)
->
name
()
<<
")"
;
KOrg
::
Part
*
p
=
KOCore
::
self
()
->
loadPart
(
*
it
,
nullptr
);
if
(
!
p
)
{
qDebug
()
<<
"Part loading failed."
;
}
else
{
qDebug
()
<<
"PART INFO:"
<<
p
->
info
();
}
}
plugins
=
KOCore
::
self
()
->
availableCalendarDecorations
();
KService
::
List
plugins
=
KOCore
::
self
()
->
availableCalendarDecorations
();
for
(
it
=
plugins
.
constBegin
();
it
!=
plugins
.
constEnd
();
++
it
)
{
qDebug
()
<<
"CalendarDecoration:"
<<
(
*
it
)
->
desktopEntryName
()
<<
"("
<<
(
*
it
)
->
name
()
<<
")"
;
EventViews
::
CalendarDecoration
::
Decoration
*
p
=
KOCore
::
self
()
->
loadCalendarDecoration
(
*
it
);
...
...
Write
Preview
Markdown
is supported
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