kexi

object.h
1/* This file is part of the KDE project
2 Copyright (C) 2003-2005 Jaroslaw Staniek <js@iidea.pl>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KEXIDB_OBJECT_H
21#define KEXIDB_OBJECT_H
22
23#include <kexidb/error.h>
24#include <tdemessagebox.h>
25#include <kstdguiitem.h>
26#include <tqstring.h>
27
28namespace KexiDB {
29
30class MessageHandler;
31
34class KEXI_DB_EXPORT Object
35{
36 public:
38 bool error() const { return m_hasError; }
39
42 const TQString& errorMsg() const { return m_errMsg; }
43
46 int errorNum() const { return m_errno; }
47
49 int previousServerResult() const { return m_previousServerResultNum; }
50
51 TQString previousServerResultName() const { return m_previousServerResultName; }
52
54 void debugError();
55
60 virtual void clearError();
61
74 virtual TQString serverErrorMsg();
75
84 virtual int serverResult();
85
96 virtual TQString serverResultName();
97
100 TQString msgTitle() const { return m_msgTitle; }
101
105 const TQString recentSQLString() const { return m_errorSql.isEmpty() ? m_sql : m_errorSql; }
106
107 protected:
108 /* Constructs a new object.
109 \a handler can be provided to receive error messages. */
110 Object(MessageHandler* handler = 0);
111
112 virtual ~Object();
113
121 virtual void setError(int code = ERR_OTHER, const TQString &msg = TQString() );
122
127 virtual void setError( const TQString &msg );
128
131 virtual void setError( const TQString &title, const TQString &msg );
132
134 void setError( KexiDB::Object *obj, const TQString& prependMessage = TQString() );
135
138 virtual void setError( KexiDB::Object *obj, int code,
139 const TQString& prependMessage = TQString() );
140
144 virtual int askQuestion( const TQString& message,
145 KMessageBox::DialogType dlgType, KMessageBox::ButtonCode defaultResult,
146 const KGuiItem &buttonYes=KStdGuiItem::yes(),
147 const KGuiItem &buttonNo=KStdGuiItem::no(),
148 const TQString &dontShowAskAgainName = TQString(),
149 int options = KMessageBox::Notify,
150 MessageHandler* msgHandler = 0 );
151
158 virtual void drv_clearServerResult() {};
159
161 TQString m_sql, m_errorSql;
162 int m_serverResult;
163 TQString m_serverResultName, m_serverErrorMsg;
164 TQString m_errMsg;
165
166 private:
167 int m_errno;
168 bool m_hasError;
169
171 int m_previousServerResultNum, m_previousServerResultNum2;
173 TQString m_previousServerResultName, m_previousServerResultName2;
174
175 TQString m_msgTitle;
176 MessageHandler *m_msgHandler;
177
178 class Private;
179 Private *d;
180
181 friend class MessageTitle;
182};
183
184} //namespace KexiDB
185
186#endif
bool error() const
Definition object.h:38
TQString msgTitle() const
Definition object.h:100
int errorNum() const
Definition object.h:46
TQString m_sql
used to store of actually executed SQL statement
Definition object.h:161
const TQString recentSQLString() const
Definition object.h:105
int previousServerResult() const
Definition object.h:49
virtual void drv_clearServerResult()
Definition object.h:158
const TQString & errorMsg() const
Definition object.h:42
High-level database connectivity library with database backend drivers.