File indexing completed on 2024-05-12 16:39:35
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003-2012 Jarosław Staniek <staniek@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this program; see the file COPYING. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KEXI_H 0021 #define KEXI_H 0022 0023 #include <QPointer> 0024 0025 #include <KexiVersion.h> 0026 #include "kexiprojectdata.h" 0027 #include "kexidbconnectionset.h" 0028 #include "kexiprojectset.h" 0029 0030 class QLabel; 0031 class KDbDriverManager; 0032 class KexiRecentProjects; 0033 0034 namespace KexiPart 0035 { 0036 class Manager; 0037 } 0038 0039 namespace Kexi 0040 { 0041 /*! Modes of view for the dialogs. Used mostly for parts and KexiWindow. */ 0042 enum ViewMode { 0043 AllViewModes = 0, //!< Usable primarily in KexiPart::initInstanceActions() 0044 NoViewMode = 0, //!< In KexiView::afterSwitchFrom() and KexiView::beforeSwitchTo() 0045 //!< means that parent dialog of the view has not been defined yet. 0046 DataViewMode = 1, 0047 DesignViewMode = 2, 0048 TextViewMode = 4 //!< Also known as SQL View Mode 0049 }; 0050 Q_DECLARE_FLAGS(ViewModes, ViewMode) 0051 0052 /*! @return i18n'ed name of view mode @a mode. If @a withAmpersand is true, 0053 ampersands used for accelerators are included, e.g. "&Data View".*/ 0054 KEXICORE_EXPORT QString nameForViewMode(ViewMode mode, bool withAmpersand = false); 0055 0056 /*! @return icon name of view mode @a mode. */ 0057 KEXICORE_EXPORT QString iconNameForViewMode(ViewMode mode); 0058 0059 //! A set of known connections 0060 KEXICORE_EXPORT KexiDBConnectionSet& connset(); 0061 0062 //! A set available of project information 0063 KEXICORE_EXPORT KexiRecentProjects* recentProjects(); 0064 0065 //! shared driver manager 0066 KEXICORE_EXPORT KDbDriverManager& driverManager(); 0067 0068 //! shared part manager 0069 KEXICORE_EXPORT KexiPart::Manager& partManager(); 0070 0071 //! can be called to delete global objects like driverManager and partManager 0072 //! (and thus, all loaded factories/plugins) 0073 //! before KLibrary::~KLibrary() do this for us 0074 KEXICORE_EXPORT void deleteGlobalObjects(); 0075 0076 //some temporary flags 0077 0078 //! false by default, flag loaded on main window startup 0079 KEXICORE_EXPORT bool& tempShowMacros(); 0080 0081 //! false by default, flag loaded on main window startup 0082 KEXICORE_EXPORT bool& tempShowScripts(); 0083 0084 //! false by default, flag loaded on main window startup 0085 KEXICORE_EXPORT bool& tempShowScripts(); 0086 0087 /*! Helper class for storing object status. */ 0088 class KEXICORE_EXPORT ObjectStatus 0089 { 0090 public: 0091 ObjectStatus(); 0092 0093 ObjectStatus(const QString& message, const QString& description); 0094 0095 ObjectStatus(const KDbResultable* resultable, const QString& message, const QString& description); 0096 0097 ~ObjectStatus(); 0098 0099 const ObjectStatus& status() const; 0100 0101 bool error() const; 0102 0103 void setStatus(const QString& message, const QString& description); 0104 0105 //! Note: for safety, \a dbObject needs to be derived from QObject, 0106 //! otherwise it won't be assigned 0107 void setStatus(const KDbResultable* resultable, 0108 const QString& message = QString(), const QString& description = QString()); 0109 0110 void setStatus(KDbResultInfo* resultInfo, 0111 const QString& message = QString(), const QString& description = QString()); 0112 0113 void setStatus(const KDbResultable* resultable, KDbResultInfo* resultInfo, 0114 const QString& message = QString(), const QString& description = QString()); 0115 0116 void setStatus(const KDbResult& result, KDbResultInfo* resultInfo, 0117 const QString& message = QString(), const QString& description = QString()); 0118 0119 void clearStatus(); 0120 0121 QString singleStatusString() const; 0122 0123 void append(const ObjectStatus& otherStatus); 0124 0125 const KDbResultable* resultable() const { return m_resultable; } 0126 0127 //! Helper returning pseudo handler that just updates this ObjectStatus object 0128 //! by receiving a message 0129 operator KDbMessageHandler*(); 0130 0131 QString message, description; 0132 protected: 0133 const KDbResultable* m_resultable; 0134 KDbMessageHandler* m_msgHandler; 0135 }; 0136 0137 /*! \return icon name for default file-based driver 0138 (typically icon for something like "application/x-kexiproject-sqlite"). 0139 @see KDb::defaultFileBasedDriverMimeType() */ 0140 KEXICORE_EXPORT QString defaultFileBasedDriverIconName(); 0141 0142 /*! \return icon for default file-based driver 0143 (typically icon for something like "application/x-kexiproject-sqlite"). 0144 If contains special workaround to properly load mimetype icon according to current theme, 0145 at least needed for Breeze. 0146 @see KDb::defaultFileBasedDriverIconName() */ 0147 KEXICORE_EXPORT QIcon defaultFileBasedDriverIcon(); 0148 0149 /*! \return icon name for database servers. */ 0150 KEXICORE_EXPORT QString serverIconName(); 0151 0152 /*! \return icon for database servers. */ 0153 KEXICORE_EXPORT QIcon serverIcon(); 0154 0155 /*! @return message text "Kexi could have been incorrectly installed or started. 0156 The application will be closed." useful for critical errors. */ 0157 KEXICORE_EXPORT QString appIncorrectlyInstalledMessage(); 0158 0159 //! @return base path (without the filename for file-based connection data @a connectionData. 0160 //! Empty string is returned if @a connectionData does not point to a file-based connection with 0161 //! database name specified. 0162 KEXICORE_EXPORT QString basePathForProject(const KDbConnectionData& connectionData); 0163 0164 //! @return @c true if this is a Kexi app instance 0165 //! @c false is returned e.g. for test apps that are based on Kexi. 0166 //! This function is useful to decide if certain actions should be performed that only 0167 //! belong to the "real" Kexi app, for example updating a list of recent documents 0168 //! or collecting usage information. 0169 //! The check is performed by comparing component name of KAboutData to the string "kexi". 0170 KEXICORE_EXPORT bool isKexiInstance(); 0171 0172 }//namespace Kexi 0173 0174 Q_DECLARE_OPERATORS_FOR_FLAGS(Kexi::ViewModes) 0175 0176 //! Displays information that feature "feature_name" is not availabe in the current application version 0177 KEXICORE_EXPORT void KEXI_UNFINISHED( 0178 const QString& feature_name, const QString& extra_text = QString()); 0179 0180 //! Like KEXI_UNFINISHED but returns new label instance with expected text 0181 KEXICORE_EXPORT QLabel *KEXI_UNFINISHED_LABEL( 0182 const QString& feature_name, const QString& extra_text = QString()); 0183 0184 //! Like above - for use inside KexiActionProxy subclass - reuses feature name from shared action's text 0185 #define KEXI_UNFINISHED_SHARED_ACTION(action_name) \ 0186 KEXI_UNFINISHED(sharedAction(action_name) ? sharedAction(action_name)->text() : QString()) 0187 0188 //! Implementation of plugin's entry point 0189 #define KEXI_PLUGIN_FACTORY(class_name, name) \ 0190 K_PLUGIN_FACTORY_WITH_JSON(class_name ## Factory, name, registerPlugin<class_name>();) 0191 0192 #endif