3
* TOra - An Oracle Toolkit for DBA's and developers
4
* Copyright (C) 2003-2005 Quest Software, Inc
5
* Portions Copyright (C) 2005 Other Contributors
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; only version 2 of
10
* the License is valid for this program.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* As a special exception, you have permission to link this program
22
* with the Oracle Client libraries and distribute executables, as long
23
* as you follow the requirements of the GNU GPL in regard to all of the
24
* software in the executable aside from Oracle client libraries.
26
* Specifically you are not permitted to link this program with the
27
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
28
* And you are not permitted to distribute binaries compiled against
29
* these libraries without written consent from Quest Software, Inc.
30
* Observe that this does not disallow linking to the Qt Free Edition.
32
* You may link this product with any GPL'd Qt library such as Qt/Free
34
* All trademarks belong to their respective owners.
40
#include "toresultlong.h"
41
#include "toresultlong.moc"
44
#include "tonoblockquery.h"
49
#include <qclipboard.h>
53
toResultLong::toResultLong(bool readable, bool dispCol, toQuery::queryMode mode,
54
QWidget *parent, const char *name, WFlags f)
55
: toResultView(readable, dispCol, parent, name, f)
60
connect(&Timer, SIGNAL(timeout(void)), this, SLOT(addItem(void)));
63
toResultLong::toResultLong(QWidget *parent, const char *name, WFlags f)
64
: toResultView(parent, name, f)
69
connect(&Timer, SIGNAL(timeout(void)), this, SLOT(addItem(void)));
72
void toResultLong::query(const QString &sql, const toQList ¶m)
74
if (!setSQLParams(sql, param))
76
emit firstResult(toResult::sql(),
77
toConnection::exception(tr("Will not reexecute same query")), false);
97
addColumn(QString::fromLatin1("#"));
98
setColumnAlignment(0, AlignRight);
102
Filter->startingQuery();
106
Query = new toNoBlockQuery(connection(), Mode, sql, param, Statistics);
111
MaxNumber = toConfigurationSingle::Instance().globalConfig(CONF_MAX_NUMBER, DEFAULT_MAX_NUMBER).toInt();
114
catch (const toConnection::exception &str)
117
emit firstResult(toResult::sql(), str, true);
119
if (Mode != toQuery::Long)
120
toStatusMessage(str);
122
catch (const QString &str)
125
emit firstResult(toResult::sql(), str, true);
127
if (Mode != toQuery::Long)
128
toStatusMessage(str);
133
#define TO_POLL_CHECK 100
135
void toResultLong::editReadAll(void)
137
if (Query && !Query->eof())
140
Timer.start(TO_POLL_CHECK);
144
void toResultLong::addItem(void)
148
if (!toCheckModal(this))
158
QString tmp = sql().simplifyWhiteSpace().mid(0, 10).lower();
159
if (tmp.startsWith(QString::fromLatin1("update")) ||
160
tmp.startsWith(QString::fromLatin1("delete")) ||
161
tmp.startsWith(QString::fromLatin1("insert")))
162
buffer = tr("%1 rows processed").arg(Query->rowsProcessed());
163
else if (tmp.startsWith(QString::fromLatin1("select")))
164
buffer = tr("Query executed");
166
buffer = tr("Statement executed");
171
Description = Query->describe();
174
for (toQDescList::iterator i = Description.begin();i != Description.end();i++)
176
QString name = (*i).Name;
178
toReadableColumn(name);
179
if (name.length() > 0 && name[0].latin1() != ' ')
182
throw tr("Can only hide last column in query");
183
if (name[0].latin1() == '-')
185
addColumn(toTranslateMayby(sqlName(), name.right(name.length() - 1)));
186
setColumnAlignment(columns() - 1, AlignRight);
190
addColumn(toTranslateMayby(sqlName(), name));
192
setColumnAlignment(columns() - 1, AlignRight);
200
if (resizeMode() != QListView::NoColumn)
201
setResizeMode(resizeMode());
203
if (sortColumn() < 0)
208
setSorting(Description.size());
215
unsigned int cols = Description.size();
222
QListViewItem *last = LastItem;
223
LastItem = createItem(LastItem, QString::null);
225
LastItem->setText(0, QString::number(RowNumber + 1));
227
LastItem->setText(cols, QString::number(RowNumber + 1));
228
toResultViewItem *ri = dynamic_cast<toResultViewItem *>(LastItem);
229
toResultViewCheck *ci = dynamic_cast<toResultViewCheck *>(LastItem);
230
for (unsigned int j = 0;(j < cols || j == 0) && !Query->eof();j++)
233
ri->setText(j + disp, Query->readValue());
235
ci->setText(j + disp, Query->readValue());
237
LastItem->setText(j + disp, Query->readValue());
239
if (Filter && !Filter->check(LastItem))
247
while (Query->poll() && !Query->eof() && (MaxNumber < 0 || MaxNumber > RowNumber));
252
emit firstResult(sql(), toConnection::exception(buffer), false);
259
if (MaxNumber < 0 || MaxNumber > RowNumber)
261
if (!Timer.isActive())
262
Timer.start(1); // Must use timer, would mean really long recursion otherwise
264
Timer.start(TO_POLL_CHECK);
276
else if (!Timer.isActive())
277
Timer.start(TO_POLL_CHECK);
281
catch (const toConnection::exception &str)
286
emit firstResult(sql(), str, true);
287
if (Mode != toQuery::Long)
288
toStatusMessage(str);
291
toStatusMessage(str);
294
catch (const QString &str)
299
emit firstResult(sql(), str, true);
300
if (Mode != toQuery::Long)
301
toStatusMessage(str);
304
toStatusMessage(str);
309
void toResultLong::cleanup(void)
317
bool toResultLong::eof(void)
319
return !Query || Query->eof();
322
void toResultLong::stop(void)
333
toResultLong::~toResultLong()