kexi

object.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003-2005 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KEXIDB_OBJECT_H
00021 #define KEXIDB_OBJECT_H
00022 
00023 #include <kexidb/error.h>
00024 #include <kmessagebox.h>
00025 #include <kstdguiitem.h>
00026 #include <qstring.h>
00027 
00028 namespace KexiDB {
00029 
00030 class MessageHandler;
00031 
00034 class KEXI_DB_EXPORT Object
00035 {
00036     public:
00038         bool error() const { return m_hasError; }
00039 
00042         const QString& errorMsg() const { return m_errMsg; }
00043 
00046         int errorNum() const { return m_errno; }
00047 
00049         int previousServerResult() const { return m_previousServerResultNum; }
00050 
00051         QString previousServerResultName() const { return m_previousServerResultName; }
00052 
00054         void debugError();
00055 
00060         virtual void clearError();
00061 
00074         virtual QString serverErrorMsg();
00075 
00084         virtual int serverResult();
00085 
00096         virtual QString serverResultName();
00097         
00100         QString msgTitle() const { return m_msgTitle; }
00101 
00105         const QString recentSQLString() const { return m_errorSql.isEmpty() ? m_sql : m_errorSql; }
00106 
00107     protected:
00108         /* Constructs a new object. 
00109          \a handler can be provided to receive error messages. */
00110         Object(MessageHandler* handler = 0);
00111         
00112         virtual ~Object();
00113         
00121         virtual void setError(int code = ERR_OTHER, const QString &msg = QString::null );
00122 
00127         virtual void setError( const QString &msg );
00128 
00131         virtual void setError( const QString &title, const QString &msg );
00132         
00134         void setError( KexiDB::Object *obj, const QString& prependMessage = QString::null );
00135 
00138         virtual void setError( KexiDB::Object *obj, int code, 
00139             const QString& prependMessage = QString::null );
00140 
00144         virtual int askQuestion( const QString& message, 
00145             KMessageBox::DialogType dlgType, KMessageBox::ButtonCode defaultResult,
00146             const KGuiItem &buttonYes=KStdGuiItem::yes(), 
00147             const KGuiItem &buttonNo=KStdGuiItem::no(),
00148             const QString &dontShowAskAgainName = QString::null,
00149             int options = KMessageBox::Notify,
00150             MessageHandler* msgHandler = 0 );
00151 
00158         virtual void drv_clearServerResult() {};
00159 
00161         QString m_sql, m_errorSql;
00162         int m_serverResult;
00163         QString m_serverResultName, m_serverErrorMsg;
00164         QString m_errMsg;
00165 
00166     private:
00167         int m_errno;
00168         bool m_hasError;
00169 
00171         int m_previousServerResultNum, m_previousServerResultNum2;
00173         QString m_previousServerResultName, m_previousServerResultName2;
00174 
00175         QString m_msgTitle;
00176         MessageHandler *m_msgHandler;
00177 
00178         class Private;
00179         Private *d; 
00180 
00181         friend class MessageTitle;
00182 };
00183 
00184 } //namespace KexiDB
00185 
00186 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys