File indexing completed on 2024-05-12 05:21:08

0001 /*
0002   This file is part of the KDE Kontact Plugin Interface Library.
0003 
0004   SPDX-FileCopyrightText: 2001 Matthias Hoelzer-Kluepfel <mhk@kde.org>
0005   SPDX-FileCopyrightText: 2002-2003 Daniel Molkentin <molkentin@kde.org>
0006 
0007   SPDX-License-Identifier: LGPL-2.0-or-later
0008 
0009 */
0010 #pragma once
0011 
0012 #include "kontactinterface_export.h"
0013 
0014 #include <KParts/MainWindow>
0015 #include <KParts/Part>
0016 
0017 namespace KontactInterface
0018 {
0019 class Plugin;
0020 class CorePrivate;
0021 /**
0022  * @short The abstract interface that represents the Kontact core.
0023  *
0024  * This class provides the interface to the Kontact core for the plugins.
0025  */
0026 class KONTACTINTERFACE_EXPORT Core : public KParts::MainWindow
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     /**
0032      * Destroys the core object.
0033      */
0034     ~Core() override;
0035 
0036     /**
0037      * Selects the given plugin and raises the associated part.
0038      * @see selectPlugin(const QString &)
0039      *
0040      * @param plugin is a pointer to the Kontact Plugin to select.
0041      */
0042     virtual void selectPlugin(KontactInterface::Plugin *plugin) = 0;
0043 
0044     /**
0045      * This is an overloaded member function
0046      * @see selectPlugin(KontactInterface::Plugin *)
0047      *
0048      * @param plugin is the name of the Kontact Plugin select.
0049      */
0050     virtual void selectPlugin(const QString &plugin) = 0;
0051 
0052     /**
0053      * Returns the pointer list of available plugins.
0054      */
0055     virtual QList<KontactInterface::Plugin *> pluginList() const = 0;
0056 
0057     /**
0058      * @internal (for Plugin)
0059      *
0060      * @param library the library to create part from
0061      * Creates a part from the given @p library.
0062      */
0063     [[nodiscard]] KParts::Part *createPart(const char *library);
0064 
0065     /**
0066      * @internal (for Plugin)
0067      *
0068      * Tells the kontact core that a part has been loaded.
0069      */
0070     virtual void partLoaded(Plugin *plugin, KParts::Part *part) = 0;
0071 
0072 Q_SIGNALS:
0073     /**
0074      * This signal is emitted whenever a new day starts.
0075      *
0076      * @param date The date of the new day
0077      */
0078     void dayChanged(const QDate &date);
0079 
0080 protected:
0081     /**
0082      * Creates a new core object.
0083      *
0084      * @param parent The parent widget.
0085      * @param flags The window flags.
0086      */
0087     explicit Core(QWidget *parent = nullptr, Qt::WindowFlags flags = {});
0088 
0089     /**
0090      * Returns the last error message for problems during
0091      * KParts loading.
0092      */
0093     QString lastErrorMessage() const;
0094 
0095 private:
0096     //@cond PRIVATE
0097     friend class CorePrivate;
0098     std::unique_ptr<CorePrivate> const d;
0099     //@endcond
0100 };
0101 
0102 }