7 messages in com.mysql.lists.gui-toolsbk commit - MyCC
FromSent OnAttachments
jor...@mysql.com16 Oct 2002 00:33 
jor...@mysql.com18 Oct 2002 03:40 
jor...@mysql.com20 Oct 2002 20:44 
jor...@mysql.com22 Oct 2002 08:18 
jor...@mysql.com23 Oct 2002 07:00 
jor...@mysql.com26 Oct 2002 08:39 
jor...@mysql.com29 Oct 2002 17:32 
Subject:bk commit - MyCC
From:jor...@mysql.com (jor@mysql.com)
Date:10/22/2002 08:18:10 AM
List:com.mysql.lists.gui-tools

Below is the list of changes that have just been commited into a local MyCC repository of 'jorge'. When 'jorge' does a push, they will be propogaged to the main repository and within 24 hours after the push into the public repository.

ChangeSet 1.104 02/10/22 10:18:31 jor@linux.jorge.mysql.com +13 -0 CTable.cpp: Added a better support for copy CSqlTable.cpp: Added support for updating blob/text & binary fields when no keys where
defined in the table. This implicitly solved a bug which didn't update a field
correctly when the type was text or blob (or varchar w/binary) that was defined
with a key-length Added a better support for copy. CQueryTable.cpp: Added a better copy() function which supports selections rather than cells.

CTableGroupItem.cpp: Fixed a bug which crashed mycc when deleting a table. This was introduced
in 0.8.5 CTableItem.cpp: Fixed a bug which crashed mycc when deleting a table CQueryWindow.cpp: Fixed a bug in the Explain Panel context-menu Fixed a bug which enabled editing queries different than select * from
[table] Enhanced the way Copy works Added a "Database Changed" message if the last executed query was a "use"
query

dist/Changelog.txt 1.44 02/10/22 10:17:17 jor@linux.jorge.mysql.com +19 -0

include/CTableGroupItem.h 1.6 02/10/22 10:16:46 jor@linux.jorge.mysql.com +2 -0

include/CTable.h 1.3 02/10/22 10:16:46 jor@linux.jorge.mysql.com +1 -0

include/CSqlTable.h 1.3 02/10/22 10:16:46 jor@linux.jorge.mysql.com +13 -3

include/CQueryWindow.h 1.14 02/10/22 10:16:46 jor@linux.jorge.mysql.com +4 -1

include/CQueryTable.h 1.22 02/10/22 10:16:46 jor@linux.jorge.mysql.com +1 -0

src/CTable.cpp 1.2 02/10/22 10:16:24 jor@linux.jorge.mysql.com +33 -3 Added a better support for copy

src/CSqlTable.cpp 1.4 02/10/22 10:14:32 jor@linux.jorge.mysql.com +235 -92 Added support for updating blob/text & binary fields when no keys where
defined in the table. This implicitly solved a bug which didn't update a field
correctly when the type was text or blob (or varchar w/binary) that was defined
with a key-length Added a better support for copy.

src/CQueryTable.cpp 1.48 02/10/22 10:13:49 jor@linux.jorge.mysql.com +42 -0 Added a better copy() function which supports selections rather than cells. Added a better copy() function which supports selections rather than cells.

src/CTableGroupItem.cpp 1.17 02/10/22 10:13:29 jor@linux.jorge.mysql.com +6 -0 Fixed a bug which crashed mycc when deleting a table. This was introduced
in 0.8.5

src/CTableItem.cpp 1.11 02/10/22 10:12:47 jor@linux.jorge.mysql.com +1 -2 Fixed a bug which crashed mycc when deleting a table

src/CQueryWindow.cpp 1.37 02/10/22 10:11:11 jor@linux.jorge.mysql.com +43 -14 Fixed a bug in the Explain Panel context-menu Fixed a bug which enabled editing queries different than select * from
[table] Enhanced the way Copy works Added a "Database Changed" message if the last executed query was a "use"
query

src/CMySQLQuery.cpp 1.27 02/10/22 10:11:07 jor@linux.jorge.mysql.com +17 -7

# This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: jorge # Host: linux.jorge.mysql.com # Root: /my/mycc

--- 1.2/include/CSqlTable.h Fri Oct 18 05:39:14 2002 +++ 1.3/include/CSqlTable.h Tue Oct 22 10:16:46 2002 @@ -2,6 +2,7 @@ #define CSQLTABLE_H

#include "CQueryTable.h" +#include <qmap.h>

class CMySQLQuery; class CSqlTableItem; @@ -28,6 +29,7 @@ void setDatabaseName(const QString &db_name) { database_name = db_name; } void setTableName(const QString &tbl_name) { table_name = tbl_name; } bool exec(const char *, ulong); + void copy(int row, int col);

private slots: void saveCellToFile(CSqlTableItem *table_item); @@ -39,14 +41,22 @@ QWidget * beginEdit(int row, int col, bool replace); QWidget *createEditor(int row, int col, bool initFromCell) const;

+protected slots: + void ContextMenuRequested(int row, int col, const QPoint &pos); + void openTextEditor(CSqlTableItem *table_item); + void openImageViewer(CSqlTableItem *table_item); + void DoubleClicked(int, int, int, const QPoint &); + private: + enum update_Type { PRIMARY, UNIQUE, ALL_FIELDS }; CMessagePanel *messagePanel; CHistoryPanel *historyPanel; - int maxColumnLength(uint col) const; - void ContextMenuRequested(int row, int col, const QPoint &pos); + int maxColumnLength(uint col) const; bool itemModified(CSqlTableItemEditor *editor, CSqlTableItem *current_item); char * getUpdateQuery(const char *new_value, ulong len, CSqlTableItem
*current_item, ulong *length); - QString getWhereClause(int row) const; + char * getWhereClause(int row, ulong *length); + update_Type update_type; + QMap<uint, QString> update_columns; bool is_read_only; bool add_to_history; bool display_messages;

--- 1.2/include/CTable.h Fri Oct 18 05:39:14 2002 +++ 1.3/include/CTable.h Tue Oct 22 10:16:46 2002 @@ -4,6 +4,7 @@ #include <qvariant.h> #include <qtable.h> #include <qintdict.h> +#include <qclipboard.h>

class QPixmap; class CMySQLServer;

--- 1.3/src/CSqlTable.cpp Sun Oct 20 20:54:07 2002 +++ 1.4/src/CSqlTable.cpp Tue Oct 22 10:14:32 2002 @@ -161,6 +161,7 @@ historyPanel->History(sql); delete qry; return b; + return true; }

bool CSqlTable::itemModified(CSqlTableItemEditor *editor, CSqlTableItem
*current_item) @@ -176,7 +177,7 @@ else current_item->setValue(editor->text(), editor->text().length()); } - free (sql); + delete [] sql; return b; }

@@ -189,7 +190,7 @@ table_item->setValue(v, l); table_item->setTextFromValue(); } - free (sql); + delete [] sql; }

void CSqlTable::loadFromFile(CSqlTableItem *current_item) @@ -208,20 +209,25 @@ QDataStream ts(&file); QFileInfo fi(s); ulong len = fi.size(); - char *data; - if ((data=(char*)malloc(len+1))) + char *data; + if (data = new char [len +1]) { ts.readRawBytes(data, len); data[len] = 0; ulong query_length; char *sql = getUpdateQuery(data, len, current_item, &query_length); + + bool a = add_to_history; + add_to_history = false; //Don't add the query to the history file + if (exec(sql, query_length)) { current_item->setValue(data, len); current_item->setTextFromValue(); } - free (sql); - free (data); + delete [] sql; + delete [] data; + add_to_history = a; //restore the original "Add to History" settings. } else mysql()->showMessage(CRITICAL, tr("There is not enough memory to open
the file")); @@ -232,20 +238,17 @@

char * CSqlTable::getUpdateQuery(const char *new_value, ulong len,
CSqlTableItem *current_item, ulong *length) { - QString s = "UPDATE " + mysql()->mysql()->quote(table_name); - s += "\nSET " +
mysql()->mysql()->quote(query()->fields(current_item->index()).name) + "="; + QString s = "UPDATE " + mysql()->mysql()->quote(table_name) + "\nSET " + + mysql()->mysql()->quote(query()->fields(current_item->index()).name) + "=";

- long l = s.length() + 1; - char *update = (char *) malloc(s.length()+1); - strmov(update, s.latin1()); - + ulong l = s.length() + 1; char *value; char *v = 0; ulong value_length = 0; if (!new_value) { value_length = 4; - value = (char *)malloc(5); + value = new char[5];; v = value; v = strmov(v, "NULL"); } @@ -254,7 +257,7 @@ if (current_item->isNumber()) { value_length = len + 2; - value = (char *)malloc(len + 3); + value = new char[len + 3]; v = value; *v++ = '\''; v = strmov(v, new_value); @@ -262,7 +265,7 @@ } else { - value = (char *)malloc(len * 2 + 3); + value = new char[len * 2 + 3]; v = value; *v++ = '\''; value_length = mysql()->mysql()->mysqlRealEscapeString(new_value, v,
len); @@ -273,86 +276,102 @@ }

l += value_length + 1; - - QString where = getWhereClause(current_item->row()); - l += where.length() + 1; - char *w = (char *)malloc(where.length() + 1); - strmov(w, where.latin1()); - char *sql = (char *) malloc(l); + ulong where_length; + char *where = getWhereClause(current_item->row(), &where_length); + l += where_length + 1; + char *sql = new char[l]; char *q = sql; - q = strmov(q, update); + q = strmov(q, s.latin1()); memcpy(q, value, value_length); q += value_length; - q = strmov(q, where); - *q++ = 0; + memcpy(q, where, where_length); + *(q + where_length) = 0; *length = l; - free(update); - free(value); - free(w); + delete [] value; + delete [] where; return sql; }

-QString CSqlTable::getWhereClause(int row) const -{ - /* - TODO: This member should be changed to return a char * and a length
parameter. - */ - QString primKey = QString::null; - QString uniqueKey = QString::null; - QString allFields = QString::null; - QString key; - QString value; - - CSqlTableItem *field = 0; - for (uint index = 0; index < query()->numFields(); index++) - { - field = (CSqlTableItem *) item(row, index); - key = mysql()->mysql()->quote(query()->fields(index).name); - value = field->isNull() ? QString::null : field->value(); +char * CSqlTable::getWhereClause(int row, ulong *length) +{ + ulong len_tmp = 0; + CSqlTableItem *field; + QMap<uint, QString>::Iterator it; + + char where_text[] = "\nWHERE "; + char is_null_text[] = " IS NULL "; + char and_text[] = " AND "; + char limit_text[] = "\nLIMIT 1";

- if (value.isNull()) - key += " IS NULL"; + ulong len=strlen(where_text); + + for (it = update_columns.begin(); it != update_columns.end(); ++it) + { + len += it.data().length(); + field = (CSqlTableItem *) item(row, it.key()); + + if (field->isNull()) + len += strlen(is_null_text); else if (field->isNumber()) - key += "=" + value; + len += field->length() + 1; else - key += "='" + mysql()->mysql()->escape(value) + "'"; + len_tmp += field->length() * 2 + 4; + } + len += (update_columns.count() - 1) * strlen(and_text); + if (update_type == ALL_FIELDS) + len += strlen(limit_text);;

- if (IS_PRI_KEY(query()->fields(index).flags)) - { - if (primKey.length()) - primKey += " AND "; - primKey += key; - } - else - if (!primKey.length() && IS_UNI_KEY(query()->fields(index).flags)) + + char *where = new char[len + len_tmp + 1]; + char *end_ptr; + + end_ptr = strmov(where, where_text); + + uint count = 0; + for (it = update_columns.begin(); it != update_columns.end(); ++it) + { + count++; + field = (CSqlTableItem *) item(row, it.key()); + end_ptr = strmov(end_ptr, it.data()); + if (field->isNull()) + end_ptr = strmov(end_ptr, is_null_text); + else + if (field->isNumber()) { - // if exists some unique key use one - if (uniqueKey.length()) - uniqueKey += " AND "; - uniqueKey += key; + *end_ptr++ = '='; + memcpy(end_ptr, field->value(), field->length()); + end_ptr += field->length(); } - else - if (!primKey.length() && !uniqueKey.length()) + else { - // else use all fields - if (allFields.length()) - allFields += " AND "; - allFields += key; + char * value = new char[field->length() * 2 + 4]; + char *v = value; + *v++ = '='; + *v++ = '\''; + ulong value_length =
mysql()->mysql()->mysqlRealEscapeString(field->value(), v, field->length()); + v += value_length; + *v++ = '\''; + *v = 0; + value_length += 3; + memcpy(end_ptr, value, value_length); + end_ptr += value_length; + len += value_length; + delete [] value; } - }

- QString ret = "\nWHERE "; - if (primKey.length()) - return ret + primKey; + if (count < update_columns.count()) + end_ptr = strmov(end_ptr, and_text); + }

- if (uniqueKey.length()) - return ret + uniqueKey; + if (update_type == ALL_FIELDS) + end_ptr = strmov(end_ptr, limit_text);

- allFields += "\nLIMIT 1"; - return ret + allFields; + *length = end_ptr - where; + return where; }

+ void CSqlTable::refresh() { if (isBlocked()) @@ -360,6 +379,9 @@ reset(); setCaption(realParent()->caption()); m_cancel = false; + update_columns.clear(); + bool is_pk = false; + bool is_unique = false; if (!query()->isResultNull()) { setBlocked(true); @@ -370,16 +392,50 @@ setNumCols(num_fields); QPixmap icon;

+ for (uint j = 0; j < num_fields; j++) + { + if (IS_PRI_KEY(query()->fields(j).flags)) + is_pk = true; + else + if (!is_pk && IS_UNI_KEY(query()->fields(j).flags)) + is_unique = true; + } + + if (is_pk) + update_type = PRIMARY; + else + if (is_unique) + update_type = UNIQUE; + else + update_type = ALL_FIELDS; + for (uint i = 0; i < num_fields; i++) { if (IS_PRI_KEY(query()->fields(i).flags)) + { icon = pkIcon; + if (update_type == PRIMARY) + update_columns.insert(i,
mysql()->mysql()->quote(query()->fields(i).name)); + } else if (IS_MUL_KEY(query()->fields(i).flags)) + { icon = mulIcon; + if (update_type == ALL_FIELDS) + update_columns.insert(i,
mysql()->mysql()->quote(query()->fields(i).name)); + } else if (IS_UNI_KEY(query()->fields(i).flags)) + { icon = uniIcon; - else + if (update_type == UNIQUE) + update_columns.insert(i,
mysql()->mysql()->quote(query()->fields(i).name)); + } + else + { icon = nothingIcon; + if (update_type == ALL_FIELDS) + update_columns.insert(i,
mysql()->mysql()->quote(query()->fields(i).name)); + } + horizontalHeader()->setLabel(i, icon, query()->fields(i).name); switch (query()->fields(i).type) { @@ -396,20 +452,65 @@ } qApp->processEvents();

- ulong j = 0; + ulong z = 0; while (query()->next()) { if (m_cancel) break; for (uint i = 0; i < num_fields; i++) - setItem(j, i, new CSqlTableItem(this, query(), j, i)); - j++; + setItem(z, i, new CSqlTableItem(this, query(), z, i)); + z++; } setBlocked(false); emit refreshed(); } }

+void CSqlTable::openTextEditor(CSqlTableItem *table_item) +{ + CTextFieldEditor *t = new CTextFieldEditor(table_item, isReadOnly()); + connect(this, SIGNAL(about_to_close()), t, SLOT(close())); + connect(t, SIGNAL(message(ushort, const QString &)), mysql()->messagePanel(),
SLOT(message(ushort, const QString &))); + connect(t, SIGNAL(contentsChanged(const QString &, ulong, CSqlTableItem *)),
this, SLOT(textEditorContentsChanged(const QString &, ulong, CSqlTableItem *))); + myShowWindow(t); +} + +void CSqlTable::openImageViewer(CSqlTableItem *table_item) +{ + CImageViewer *t = new CImageViewer(table_item, true); //TODO .. Need to
change this + connect(this, SIGNAL(about_to_close()), t, SLOT(close())); + connect(t, SIGNAL(message(ushort, const QString &)), mysql()->messagePanel(),
SLOT(message(ushort, const QString &))); + myShowWindow(t); +} + +void CSqlTable::DoubleClicked(int row, int col, int button, const QPoint &) +{ + if (button == Qt::LeftButton) + { + switch (query()->fields(col).type) + { + case FIELD_TYPE_TINY_BLOB: + case FIELD_TYPE_MEDIUM_BLOB: + case FIELD_TYPE_LONG_BLOB: + case FIELD_TYPE_BLOB: + { + CSqlTableItem *table_item = (CSqlTableItem *) item(row, col); + if (table_item) + { + if (table_item->isBinary()) + openImageViewer(table_item); + else + openTextEditor(table_item); + } + } + break; + + default: + break; + } + } +} + void CSqlTable::ContextMenuRequested(int row, int col, const QPoint &pos) { if (isBlocked()) @@ -437,7 +538,7 @@ menu->setItemEnabled (MENU_LOAD, !isReadOnly()); //TODO... Need to change

menu->insertItem(getPixmapIcon("saveIcon"), tr("&Save to File"),
MENU_SAVE_TO_FILE); - menu->setItemEnabled(MENU_SAVE, table_item != 0 && !table_item->isNull()); + menu->setItemEnabled(MENU_SAVE_TO_FILE, table_item != 0 &&
!table_item->isNull());

menu->insertSeparator();

@@ -460,22 +561,11 @@ switch (res) { case MENU_OPEN_TEXT: - { - CTextFieldEditor *t = new CTextFieldEditor(table_item, isReadOnly()); - connect(this, SIGNAL(about_to_close()), t, SLOT(close())); - connect(t, SIGNAL(message(ushort, const QString &)),
mysql()->messagePanel(), SLOT(message(ushort, const QString &))); - connect(t, SIGNAL(contentsChanged(const QString &, ulong, CSqlTableItem
*)), this, SLOT(textEditorContentsChanged(const QString &, ulong, CSqlTableItem
*))); - myShowWindow(t); - } + openTextEditor(table_item); break;

case MENU_OPEN_IMAGE: - { - CImageViewer *t = new CImageViewer(table_item, true); //TODO .. Need
to change this - connect(this, SIGNAL(about_to_close()), t, SLOT(close())); - connect(t, SIGNAL(message(ushort, const QString &)),
mysql()->messagePanel(), SLOT(message(ushort, const QString &))); - myShowWindow(t); - } + openImageViewer(table_item); break;

case MENU_SAVE_TO_FILE: @@ -500,6 +590,59 @@ } }

+void CSqlTable::copy(int row, int col) +{ +#ifndef QT_NO_CLIPBOARD + + CSqlTableItem *field; + if (currentSelection() == -1) + { + field = (CSqlTableItem *) item(row, col); + if (field) + QApplication::clipboard()->setText(field->value()); + return; + } + else + { + QTableSelection sel = selection(currentSelection()); + if (sel.topRow() == sel.bottomRow() && sel.leftCol() == sel.rightCol()) + { + field = (CSqlTableItem *) item(row, col); + if (field) + QApplication::clipboard()->setText(field->value()); + return; + } + + QString line_terminator = mysql()->lineTerminator(true); + QString encl = mysql()->fieldEncloser(true); + QString sep = mysql()->fieldSeparator(true); + QString repl_empty = mysql()->replaceEmpty(true); + + QString cpy = QString::null; + + for (int current_row = sel.topRow(); current_row <= sel.bottomRow();
current_row++) + { + for (int current_col = sel.leftCol(); current_col <= sel.rightCol();
current_col++) + { + field = (CSqlTableItem *) item(current_row, current_col); + if (field->isNull()) + cpy += "[NULL]"; + else + if (!*field->value()) + cpy += encl + repl_empty + encl; + else + cpy += encl + field->value() + encl; + + if (current_col < sel.rightCol()) + cpy += sep; + } + cpy += line_terminator; + } + QApplication::clipboard()->setText(cpy); + } +#endif +} + void CSqlTable::saveCellToFile(CSqlTableItem *table_item) { if (table_item == 0)

--- 1.1/src/CTable.cpp Wed Oct 16 02:23:44 2002 +++ 1.2/src/CTable.cpp Tue Oct 22 10:16:24 2002 @@ -3,7 +3,6 @@ #include "CMySQLServer.h" #include "CApplication.h" #include <qdatetime.h> -#include <qclipboard.h> #include <stdlib.h>

CTable::CTable(QWidget * parent, const char * name) @@ -39,8 +38,39 @@

void CTable::copy(int row, int col) { -#ifndef QT_NO_CLIPBOARD - QApplication::clipboard()->setText(text(row, col)); +#ifndef QT_NO_CLIPBOARD + + if (currentSelection() == -1) + QApplication::clipboard()->setText(text(row, col)); + else + { + QTableSelection sel = selection(currentSelection()); + if (sel.topRow() == sel.bottomRow() && sel.leftCol() == sel.rightCol()) + { + QApplication::clipboard()->setText(text(row, col)); + return; + } + +#ifdef WIN32 + QString line_terminator = "\r\n"; +#else + QString line_terminator = "\n"; +#endif + + QString cpy = QString::null; + + for (int current_row = sel.topRow(); current_row <= sel.bottomRow();
current_row++) + { + for (int current_col = sel.leftCol(); current_col <= sel.rightCol();
current_col++) + { + cpy += "'" + text(current_row, current_col) + "'"; + if (current_col < sel.rightCol()) + cpy += ", "; + } + cpy += line_terminator; + } + QApplication::clipboard()->setText(cpy); + } #endif }

--- 1.43/dist/Changelog.txt Sun Oct 20 20:54:23 2002 +++ 1.44/dist/Changelog.txt Tue Oct 22 10:17:17 2002 @@ -8,6 +8,25 @@ Alter / Create Table doesn't reset the field length when changing the field
type anymore unless the types are in different sets.

+ Fixed a bug that didn't refresh the tables list widget after deleting a table
from + the tree panel. + + Inline-Editing now supports updating BLOB / TEXT & Binary fields when the
table + doesn't have any keys or when the BLOB, TEXT or Binary field is defined as a
key + + Fixed a bug that didn't display the status of certain queries + + One can now copy selections instead of cell-values in the Results Panel. + + Double-Clicking in a readOnlyColumn (Results Panel) now opens up the default
editor + .. that is ImageViewer for BLOB fields and the Text Editor for TEXT fields. + + Fixed a bug in the Query Window which allowed queries other than "SELECT *
FROM Tbl" + to be edited. + + Fixed a bug in the Explain Panel that displayed the panel's context menu and
the + default QDockWindow context after the main menu was closed. +

Important Notes for 0.8.5-alpha -------------------------------

--- 1.13/include/CQueryWindow.h Wed Oct 16 07:05:45 2002 +++ 1.14/include/CQueryWindow.h Tue Oct 22 10:16:46 2002 @@ -56,6 +56,7 @@ void setQuery(const QString &s); void setBusy(bool); void cancel(); + void copy();

private slots: void viewMenuAboutToShow(); @@ -79,8 +80,10 @@ CExplainPanel(QWidget * parent, CMySQLQuery *q, CMySQLServer *m); ~CExplainPanel();

+ protected: + void contextMenuEvent (QContextMenuEvent * e); + private: - void ContextMenuRequested(int row, int col, const QPoint &pos); CTableFieldChooser *columnsWindow; };

--- 1.21/include/CQueryTable.h Wed Oct 16 02:24:56 2002 +++ 1.22/include/CQueryTable.h Tue Oct 22 10:16:46 2002 @@ -27,6 +27,7 @@ virtual void save(); virtual void reset(); virtual void aboutToClose(); + virtual void copy(int row, int col);

protected: bool m_cancel;

--- 1.5/include/CTableGroupItem.h Wed Oct 16 02:24:52 2002 +++ 1.6/include/CTableGroupItem.h Tue Oct 22 10:16:46 2002 @@ -14,6 +14,7 @@ ~CTableGroupItem(); void activated(); void refreshWidget(bool b); + void refreshOnActivate() { refresh_on_activate = true; }

bool isOldMySQL() const { return is_old_mysql; }

@@ -39,6 +40,7 @@ void processMenu(int res);

private: + bool refresh_on_activate; QPopupMenu * tools_menu; QPopupMenu * open_table_menu; void initMenuItems();

--- 1.26/src/CMySQLQuery.cpp Fri Oct 18 05:37:28 2002 +++ 1.27/src/CMySQLQuery.cpp Tue Oct 22 10:11:07 2002 @@ -15,6 +15,7 @@ #endif

#define PROCESS_EVENT 35 +#define HUGE_QUERY 384

CMySQLQuery::QueryThread::QueryThread(MYSQL *m, const char *q, ulong l) : QThread(), m_mysql(m), qry((char *) q), len(l) @@ -124,7 +125,8 @@ QString c = QString::null; if (!m_mysql->connectionName().isEmpty()) c = "[" + m_mysql->connectionName() + "] "; - emit m_mysql->sqldebug(c + qry); + if (len < HUGE_QUERY) //Don't append huge queries to the SQL-Debug Panel + emit m_mysql->sqldebug(c + qry); if (!m_mysql->isConnected()) { if (emiterror) @@ -146,7 +148,7 @@ mysql_res = NULL; num_fields = 0; last_query = qry; - + if (emitmessages) { QString time_buff = " (" + QString::number((double)tm.elapsed() / 1000L,
'f', 2) + ") " + tr("sec"); @@ -178,7 +180,8 @@ QString c = QString::null; if (!m_mysql->connectionName().isEmpty()) c = "[" + m_mysql->connectionName() + "] "; - emit m_mysql->sqldebug(c + qry); + if (len < HUGE_QUERY) //Don't append huge queries to the SQL-Debug Panel + emit m_mysql->sqldebug(c + qry); if (!m_mysql->isConnected()) { if (emiterror) @@ -209,12 +212,19 @@ m_mysql->emitError(); return false; } - else //Query was something such as 'use [database]' - return true; } + last_query = qry; - mysql_fields = mysql_fetch_fields(mysql_res); - num_fields = mysql_num_fields(mysql_res); + if (mysql_res) + { + mysql_fields = mysql_fetch_fields(mysql_res); + num_fields = mysql_num_fields(mysql_res); + } + else + { + mysql_fields = 0; + num_fields = 0; + }

if (emitmessages) {

--- 1.36/src/CQueryWindow.cpp Fri Oct 18 05:37:33 2002 +++ 1.37/src/CQueryWindow.cpp Tue Oct 22 10:11:11 2002 @@ -35,6 +35,7 @@ columnsWindow = new CTableFieldChooser(0, this,
"CExplainPanelColumnsWindow"); setCaption(tr("Explain Panel")); columnsWindow->setCaption(tr("EXPLAIN Columns")); + disconnect(SIGNAL(contextMenuRequested(int, int, const QPoint &))); }

CQueryWindow::CExplainPanel::~CExplainPanel() @@ -42,16 +43,15 @@ delete columnsWindow; }

-void CQueryWindow::CExplainPanel::ContextMenuRequested(int row, int col, const
QPoint &pos) +void CQueryWindow::CExplainPanel::contextMenuEvent(QContextMenuEvent * e) { if (isBlocked()) return; QPopupMenu *menu = new QPopupMenu(); - menu->insertItem(getPixmapIcon("chooseFieldsIcon"), tr("Choose &Fields"),
MENU_COLUMNS_WINDOW); menu->insertSeparator(); menu->insertItem(getPixmapIcon("copyIcon"), tr("&Copy"), MENU_COPY); - int res = menu->exec(pos); + int res = menu->exec(e->globalPos()); delete menu;

switch (res) @@ -63,9 +63,10 @@ break;

case MENU_COPY: - copy(row, col); + copy(rowAt(e->pos().y()), columnAt( e->pos().x())); break; } + e->accept(); }

CQueryWindow::CQueryWindow(QWidget * parent, CMySQLServer *m, int querytype,
ushort display, const char *name, WFlags f) @@ -215,7 +216,7 @@ editCopyAction = new CAction(tr("Copy"), getPixmapIcon("copyIcon"), tr("&Copy"), Qt::CTRL + Qt::Key_C, this, "editCopyAction"); editCopyAction->setParentMenuText(tr("Edit")); - connect(editCopyAction, SIGNAL(activated()), query_editor, SLOT(copy())); + connect(editCopyAction, SIGNAL(activated()), this, SLOT(copy()));

editPasteAction = new CAction(tr("Paste"), getPixmapIcon("pasteIcon"), tr("&Paste"), Qt::CTRL + Qt::Key_V, this, "editPasteAction"); @@ -360,6 +361,8 @@ editUndoAction->setEnabled(false); editRedoAction->setEnabled(false); connect(query_editor, SIGNAL(selectionChanged()), this,
SLOT(selectionChanged())); + connect(results_table, SIGNAL(selectionChanged()), this,
SLOT(selectionChanged())); + connect(query_editor, SIGNAL(undoAvailable(bool)), editUndoAction,
SLOT(setEnabled(bool))); connect(query_editor, SIGNAL(redoAvailable(bool)), editRedoAction,
SLOT(setEnabled(bool))); connect(query_editor, SIGNAL(copyAvailable(bool)), this,
SLOT(copyAvailable(bool))); @@ -526,6 +529,15 @@ CHistoryView::historyView()->loadTo(historyPanel); }

+void CQueryWindow::copy() +{ + if (query_editor->hasFocus()) + query_editor->copy(); + else + if (results_table->hasFocus()) + results_table->copy(results_table->currentRow(),
results_table->currentColumn()); +} + void CQueryWindow::copyAvailable(bool b) { #ifndef QT_NO_CLIPBOARD @@ -545,9 +557,16 @@ qDebug("CQueryWindow::selectionChanged()"); #endif

- bool s = query_editor->hasSelectedText(); - editCutAction->setEnabled(s); - editCopyAction->setEnabled(s); + bool s; + if (query_editor->hasFocus()) + s = query_editor->hasSelectedText(); + else + if (results_table->hasFocus()) + s = results_table->numSelections() > 0; + else + s = false; + editCutAction->setEnabled(query_editor->hasFocus() ? s : false); + editCopyAction->setEnabled(s); }

void CQueryWindow::viewMenuAboutToShow() @@ -757,15 +776,24 @@ { if (use_history_file) historyPanel->History(last_query); - if (query_ok = query->exec(q)) + + queryType = CMySQLQuery::query_type(q.lower()); + + if (queryType == "use" && query->hasEmitMessages()) { - queryType = CMySQLQuery::query_type(q.lower()); - if (queryType == "use") + query->setEmitMessages(false); + if (query_ok = query->exec(q)) + { + mysql()->mysql()->emitMessage(INFORMATION, tr("Database
Changed")); db_changed = true; + } + query->setEmitMessages(true); } else - if (!force) - break; + query_ok = query->exec(q); + + if (!query_ok && !force) + break; } } q = QString::null; @@ -814,7 +842,8 @@ { results_table->setTableName(default_table); results_table->setDatabaseName(default_database); - results_table->setReadOnly(default_database.isEmpty()); + last_query = last_query.simplifyWhiteSpace().lower(); + results_table->setReadOnly(default_database.isEmpty() ||
!last_query.startsWith("select * from")); query_type = SQL_ALL_ROWS; } else

--- 1.47/src/CQueryTable.cpp Fri Oct 18 05:37:51 2002 +++ 1.48/src/CQueryTable.cpp Tue Oct 22 10:13:49 2002 @@ -174,6 +174,48 @@ setBlocked(false); }

+void CQueryTable::copy(int row, int col) +{ +#ifndef QT_NO_CLIPBOARD + + if (currentSelection() == -1) + QApplication::clipboard()->setText(text(row, col)); + else + { + QTableSelection sel = selection(currentSelection()); + if (sel.topRow() == sel.bottomRow() && sel.leftCol() == sel.rightCol()) + { + QApplication::clipboard()->setText(text(row, col)); + return; + } + + QString line_terminator = mysql()->lineTerminator(true); + QString encl = mysql()->fieldEncloser(true); + QString sep = mysql()->fieldSeparator(true); + QString repl_empty = mysql()->replaceEmpty(true); + + QString cpy = QString::null; + + QString txt; + for (int current_row = sel.topRow(); current_row <= sel.bottomRow();
current_row++) + { + for (int current_col = sel.leftCol(); current_col <= sel.rightCol();
current_col++) + { + txt = text(current_row, current_col); + if (txt.isEmpty()) + txt = repl_empty; + cpy += encl + txt + encl; + + if (current_col < sel.rightCol()) + cpy += sep; + } + cpy += line_terminator; + } + QApplication::clipboard()->setText(cpy); + } +#endif +} + void CQueryTable::sortColumn(int col, bool ascending, bool wholeRows) { #ifdef DEBUG

--- 1.16/src/CTableGroupItem.cpp Wed Oct 16 02:23:30 2002 +++ 1.17/src/CTableGroupItem.cpp Tue Oct 22 10:13:29 2002 @@ -68,6 +68,7 @@ qDebug("CTableGroupItem::init('%s')", debug_string(dbname)); #endif

+ refresh_on_activate = false; setDatabaseName(dbname); tools_menu = CTableTools::tableToolsMenu(); connect(tools_menu, SIGNAL(activated(int)), this, SLOT(processMenu(int))); @@ -229,6 +230,11 @@ if (isBlocked()) return;

+ if (refresh_on_activate) + { + refreshWidget(true); + refresh_on_activate = false; + } refreshWidget(false); }

--- 1.10/src/CTableItem.cpp Wed Oct 16 02:23:28 2002 +++ 1.11/src/CTableItem.cpp Tue Oct 22 10:12:47 2002 @@ -233,10 +233,9 @@ case MENU_DELETE: if (CTableSpecific::deleteTable(mysql(), text(0))) { - //listView()->setCurrentItem(QListViewItem::parent()); + my_parent->refreshOnActivate(); setVisible(false); delete this; - //my_parent->refreshWidget(true); } break;