File indexing completed on 2024-05-12 16:39:38
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org> 0003 Copyright (C) 2003-2014 Jarosław Staniek <staniek@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KEXIPARTBASE_H 0022 #define KEXIPARTBASE_H 0023 0024 #include <kexiutils/InternalPropertyMap.h> 0025 #include "kexi.h" 0026 0027 #include <KLocalizedString> 0028 #include <KPluginFactory> 0029 0030 class QTabWidget; 0031 class KexiWindow; 0032 0033 namespace KexiPart 0034 { 0035 class Info; 0036 0037 //! @short The base class for Kexi frontend parts (plugins) 0038 //! @see KexiPart::Part KexiInternalPart 0039 class KEXICORE_EXPORT PartBase : public QObject, protected KexiUtils::InternalPropertyMap 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 virtual ~PartBase(); 0045 0046 /*! @return Info structure for this part. */ 0047 Info *info() const; 0048 0049 /*! \return i18n'd message translated from \a englishMessage. 0050 This method is useful for messages like: 0051 "<p>Table \"%1\" has been modified.</p>", 0052 -- such messages can be accurately translated, 0053 while this could not: "<p>%1 \"%2\" has been modified.</p>". 0054 See implementation of this method in KexiTablePart to see 0055 what strings are needed for translation. 0056 0057 Default implementation returns generic \a englishMessage. 0058 In special cases, \a englishMessage can start with ":", 0059 to indicate that empty string will be generated if 0060 a part does not offer a message for such \a englishMessage. 0061 This is used e.g. in KexiMainWindow::closeWindow(). 0062 0063 @note As number of %n parameters is unspecified, 0064 you should add appropriate number of parameters using .subs(). 0065 to result of i18nMessage(). 0066 In your implementation, you should use kxi18nc(I18NC_NOOP("@info", "...")) 0067 instead of i18n(). 0068 Example: 0069 @code 0070 QString tableName = "Employees"; 0071 QString translated 0072 = part->i18nMessage("Design of object <resource>%1</resource> has been modified.") 0073 .subs(tableName).toString(); 0074 @endcode */ 0075 virtual KLocalizedString i18nMessage(const QString& englishMessage, 0076 KexiWindow *window) const; 0077 0078 /*! @internal 0079 This method can be reimplemented to setup additional tabs 0080 in the property editor panel. Default implementation does nothing. 0081 This method is called whenever current window (KexiWindow) is switched and 0082 type (mime type) of its contents differs from previous one. 0083 For example, if a user switched from Table Designer to Form Designer, 0084 additional tab containing Form Designer's object tree should be shown. */ 0085 virtual void setupCustomPropertyPanelTabs(QTabWidget *tab); 0086 0087 protected: 0088 /*! 0089 Creates new Plugin 0090 @param parent parent of this plugin 0091 @param list extra arguments passed to the plugin 0092 */ 0093 PartBase(QObject *parent, 0094 const QVariantList& list); 0095 0096 /*! Sets Info structure for this part. */ 0097 void setInfo(Info *info); 0098 0099 Q_DISABLE_COPY(PartBase) 0100 0101 class Private; 0102 Private * const d; 0103 0104 friend class Manager; 0105 }; 0106 0107 } // namespace KexiPart 0108 0109 #endif