File indexing completed on 2024-04-28 04:36:31
0001 /* 0002 SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_ITEMPLATEPROVIDER_H 0008 #define KDEVPLATFORM_ITEMPLATEPROVIDER_H 0009 0010 #include <QObject> 0011 #include "interfacesexport.h" 0012 0013 class QIcon; 0014 class QAbstractItemModel; 0015 class QStringList; 0016 0017 namespace KDevelop 0018 { 0019 0020 /** 0021 * @brief A provider of templates 0022 * 0023 * A template provider loads any kind of source code templates and presents them in a model 0024 * via the tempatesModel() function. This model will usually, but not necessarily, be connected 0025 * to a tree view, so a tree structure is recommended. 0026 * 0027 * If the templates have a similar structure as those used by the AppWizard plugin, 0028 * the TemplatesModel class may be used for convenience. 0029 * 0030 * The provider can also support downloading and uploading additional templates with 0031 * Get Hot New Stuff. If this is the case, return the name of the configuration file 0032 * (ending in .knsrc) from the knsConfigurationFile() function. 0033 * 0034 * If templates can be loaded from local files, the supportedMimeTypes() should return 0035 * all file types the provider can load. If loading is not supported, return an empty list. 0036 * 0037 * @sa TemplatesModel 0038 **/ 0039 class KDEVPLATFORMINTERFACES_EXPORT ITemplateProvider 0040 { 0041 public: 0042 /** 0043 * Destructor 0044 **/ 0045 virtual ~ITemplateProvider(); 0046 0047 /** 0048 * @return The name of this provider. 0049 **/ 0050 virtual QString name() const = 0; 0051 /** 0052 * @return An icon associated with this provider. 0053 **/ 0054 virtual QIcon icon() const = 0; 0055 0056 /** 0057 * @return A model containing all available templates. 0058 * 0059 * The called does not take ownership of the model. 0060 **/ 0061 virtual QAbstractItemModel* templatesModel() const = 0; 0062 0063 /** 0064 * @return The configuration file for Get Hot New Stuff. 0065 * 0066 * If GHNS is not used by this provider, return an empty string. 0067 **/ 0068 virtual QString knsConfigurationFile() const = 0; 0069 0070 /** 0071 * @return Types of files this provider can load. 0072 * 0073 * If loading is not supported, return an empty list. 0074 **/ 0075 virtual QStringList supportedMimeTypes() const = 0; 0076 0077 /** 0078 * Load a template from the file @p fileName. 0079 * 0080 * This function will only be called if @c supportedMimeTypes() returns 0081 * a non-empty list. 0082 * 0083 * @param fileName the name of the file to load. 0084 **/ 0085 virtual void loadTemplate(const QString& fileName) = 0; 0086 0087 /** 0088 * Reloads all template data. 0089 * 0090 * This is usually called after loading or updating new templates. 0091 **/ 0092 virtual void reload() = 0; 0093 }; 0094 0095 } 0096 0097 Q_DECLARE_INTERFACE( KDevelop::ITemplateProvider, "org.kdevelop.ITemplateProvider") 0098 0099 #endif // KDEVPLATFORM_ITEMPLATEPROVIDER_H