1 /* 2 SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 5 */ 6 7 #ifndef MODULE_MANAGER_H 8 #define MODULE_MANAGER_H 9 10 #include <QStringList> 11 #include <kservice.h> 12 class KConfigGroup; 13 14 /** 15 * The module manager is responsible for discovering the modules (i.e. tabs, 16 * i.e. plugins, i.e. desktop files) to use in the sidebar, and for updating them. 17 * This class contains no GUI code, so that it can be unit-tested. 18 */ 19 class ModuleManager 20 { 21 public: 22 ModuleManager(KConfigGroup *config); 23 24 /// Returns the filenames of the modules that should be shown in the GUI 25 /// Example: "home.desktop" (default module), "dirtree1.desktop" (added by user)... 26 QStringList modules() const; 27 28 /// Returns the names of the available plugin libraries 29 /// Example: konqsidebar_tree, konqsidebar_web 30 KService::List availablePlugins() const; 31 32 /// Returns the paths of all modules that match a given filter, like websidebarplugin*.desktop 33 QStringList localModulePaths(const QString &filter) const; 34 35 /// Returns the relative path in the "data" resource, for a given module 36 QString moduleDataPath(const QString &fileName) const; 37 /// Returns the relative path of the entries directory in the "data" resource relativeDataPath()38 QString relativeDataPath() const 39 { 40 return "konqsidebartng/entries/"; 41 } 42 /// Returns the full path for a given module. TEMP HACK, TO BE REMOVED 43 QString moduleFullPath(const QString &fileName) const; 44 45 void saveOpenViews(const QStringList &fileName); 46 void restoreDeletedButtons(); 47 void rollbackToDefault(); 48 49 void setModuleName(const QString &fileName, const QString &moduleName); 50 void setModuleUrl(const QString &fileName, const QUrl &url); 51 void setModuleIcon(const QString &fileName, const QString &icon); 52 void setShowHiddenFolders(const QString &fileName, const bool &newState); 53 int getMaxKDEWeight(); 54 int getNextAvailableKDEWeight(); 55 56 /// Find a unique filename for a new module, based on a template name 57 /// like "dirtree%1.desktop". 58 /// @return the full path. templ is modified to contain the filename only. 59 QString addModuleFromTemplate(QString &templ); 60 61 /// Called when a module was added 62 void moduleAdded(const QString &fileName); 63 64 /// Remove a module (deletes the local .desktop file) 65 void removeModule(const QString &fileName); 66 67 private: 68 void sortGlobalEntries(QStringList &fileNames) const; 69 70 KConfigGroup *m_config; // owned by SidebarWidget 71 QString m_localPath; // local path 72 }; 73 74 #endif 75