List:GUI Tools« Previous MessageNext Message »
From:jorge Date:May 14 2002 11:10pm
Subject:bk commit - MyCC
View as plain text  
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@stripped, 2002-05-14 18:10:42-05:00, jorge@stripped
  CFieldEditorWindow.cpp:
    Fixed a bug with BLOB & TEXT Fields
  CSqlTable.cpp:
    Fixed a bug with BLOB & TEXT fields

  include/CSqlTable.h
    1.16 02/05/14 18:10:23 jorge@stripped +5 -2

  include/CFieldEditorWindow.h
    1.5 02/05/14 18:10:22 jorge@stripped +4 -0

  src/CFieldEditorWindow.cpp
    1.10 02/05/14 18:09:53 jorge@stripped +3 -0
    Fixed a bug with BLOB & TEXT Fields

  src/CSqlTable.cpp
    1.39 02/05/14 18:09:39 jorge@stripped +45 -35
    Fixed a bug with BLOB & TEXT fields

# 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.4/include/CFieldEditorWindow.h	Wed Apr 17 11:11:15 2002
+++ 1.5/include/CFieldEditorWindow.h	Tue May 14 18:10:22 2002
@@ -33,6 +33,7 @@
 #include "Globals.h"
 #include "Config.h"
 
+class CDefaultTableItem;
 class QVBoxLayout; 
 class QHBoxLayout; 
 class QGridLayout; 
@@ -47,6 +48,7 @@
 public:
   CFieldEditorWindow(QWidget* parent, QPtrList<CFieldEditorWindow> *editorList, const char* name = 0, CMySQLConnection *m=0, bool ro=false);
   ~CFieldEditorWindow();
+  void setTableItem(CDefaultTableItem *x) { tableItem = x; };
   virtual void doResize(int, int) {} ;
   
 protected:  
@@ -64,9 +66,11 @@
 
 private:
   void init();
+  CDefaultTableItem *tableItem;
   
 signals:
   void changesApplied();
+  void changeTableItem(CDefaultTableItem *);
 };
 
 #endif

--- 1.15/include/CSqlTable.h	Sat May 11 23:27:07 2002
+++ 1.16/include/CSqlTable.h	Tue May 14 18:10:23 2002
@@ -107,7 +107,7 @@
   unsigned long row() { return p_row; }
   void setRealValue(const QString & value) { realValue = value; };
   QString getRealValue() { return realValue; };
-
+  virtual void setText(const QString &str);
 
 private:
   QString realValue;
@@ -253,6 +253,8 @@
   QString getCurrentQuery() { return m_Query; }  
   void setNumCols(int r);  
   virtual QString getSaveTitle();
+  virtual void setText (int row, int col, const QString & text);
+  QString prepareCellText (const QString & text);
   void setSaveTitle(const QString &title);
   privateCSqlTableColumns *ColumnsWindow;  
   bool hasAutomaticFieldEditors() { return hasAutoFieldEditors; } ;  
@@ -325,7 +327,8 @@
   void OpenTextEditor(QTableItem *x);
   void OpenImageEditor(QTableItem *x);
   void P_saveToFile(QTableItem *x);
-  void P_loadFromFile(QTableItem *x);  
+  void P_loadFromFile(QTableItem *x);
+  void blockCell(CDefaultTableItem *);
 
 private:
   bool autoCloseEditors;

--- 1.9/src/CFieldEditorWindow.cpp	Thu Apr 18 07:56:56 2002
+++ 1.10/src/CFieldEditorWindow.cpp	Tue May 14 18:09:53 2002
@@ -36,6 +36,7 @@
 #ifdef DEBUG
   qDebug("CFieldEditorWindow()");
 #endif
+  tableItem = 0;
   EditorList = editorList;
   mysql = m;
   if ( !name )
@@ -77,6 +78,8 @@
 void CFieldEditorWindow::applyButtonClicked()
 {
   emit changesApplied();
+  if (tableItem != 0)
+    emit changeTableItem(tableItem);
   close();
 }
 

--- 1.38/src/CSqlTable.cpp	Tue May 14 01:00:34 2002
+++ 1.39/src/CSqlTable.cpp	Tue May 14 18:09:39 2002
@@ -83,6 +83,11 @@
   realValue = QString::null;
 }
 
+void CDefaultTableItem::setText(const QString &str)
+{  
+	QTableItem::setText(((CSqlTable *)table())->prepareCellText(str));
+}
+
 int CDefaultTableItem::alignment() const
 {
   return (numericField ? Qt::AlignRight : Qt::AlignLeft);
@@ -104,14 +109,14 @@
   if ( w->inherits( "privateEllipseBox" ) )      
     setText(((privateEllipseBox*)w)->text());  
   else
-  	QTableItem::setContentFromEditor( w );
+  	CDefaultTableItem::setContentFromEditor( w );
 }
 
 void CEllipseTableItem::setText( const QString &str )
 {
 	if (eb)
 		eb->setText(str);
-	QTableItem::setText(str);
+	CDefaultTableItem::setText(str);
 }
 
 void CEllipseTableItem::signalConnectButton(const QString & sig, QObject *rec, const QString & s)
@@ -872,18 +877,9 @@
       else
       {
         for (unsigned int i = 0; i < nFields; i++)
-        {
-          char* text = Query->row[i];
-          unsigned int text_len;
-          if (!text) text = "NULL";
-          text_len = strlen(text);
-          if ((maxCellTextSize > 0) && (text_len > (uint)maxCellTextSize))
-          {
-            char* p = text + text_len - 1;
-            *p-- = '.'; *p-- = '.'; *p-- = '.';
-          }
+        {          
           QTextCodec *codec = QTextCodec::codecForLocale();
-          QString tmp  = codec->toUnicode(text);
+          QString tmp = prepareCellText(codec->toUnicode(Query->row[i]));
           
           if (hasAutoFieldEditors)
           {
@@ -907,8 +903,8 @@
               }
             default:
               {
-                CDefaultTableItem *ti = new CDefaultTableItem(this, j, tmp, (Query->Fields[i].flags & NUM_FLAG), QTableItem::OnTyping);
-                ti->setRealValue(tmp);
+                CDefaultTableItem *ti = new CDefaultTableItem(this, j, tmp, (Query->Fields[i].flags & NUM_FLAG), CDefaultTableItem::OnTyping);
+                ti->setRealValue(Query->row[i]);
                 setItem(j, i, ti);
               }
               break;
@@ -916,8 +912,8 @@
           }
           else
           {
-            CDefaultTableItem *ti2 = new CDefaultTableItem(this, j, text, (Query->Fields[i].flags & NUM_FLAG), QTableItem::OnTyping);
-            ti2->setRealValue(text);
+            CDefaultTableItem *ti2 = new CDefaultTableItem(this, j, tmp, (Query->Fields[i].flags & NUM_FLAG), CDefaultTableItem::OnTyping);
+            ti2->setRealValue(Query->row[i]);
             setItem(j, i, ti2);
           }            
         }
@@ -931,6 +927,12 @@
   isExecuting = false;
 }
 
+void CSqlTable::blockCell(CDefaultTableItem *x)
+{
+  if (x != 0)
+    ((CEllipseTableItem *)x)->setBlocked(true);  
+}
+
 void CSqlTable::OpenTextEditor(QTableItem *x)
 {
   if (((CEllipseTableItem *)x)->isBlocked())
@@ -943,7 +945,9 @@
     CTextFieldEditor *TextEditor = new CTextFieldEditor(g_WorkSpace, EditorList, "CTextFieldEditor", m_pDatabaseConnection, myReadOnly);
     TextEditor->setCaption(tr("Text Editor - Column ") + "'" + ((CEllipseTableItem *)x)->getFieldName() + "' Row " + QString::number(currentRow() + 1));
     TextEditor->setText(Query->getFieldValue(((CEllipseTableItem *)x)->getRowOffset(), ((CEllipseTableItem *)x)->getFieldIndex()));
+    TextEditor->setTableItem((CDefaultTableItem *) x);
     connect(TextEditor, SIGNAL(textChanged(const QString &)), this, SLOT(changeValue(const QString &)));
+    connect(TextEditor, SIGNAL(changeTableItem(CDefaultTableItem *)), this, SLOT(blockCell(CDefaultTableItem *)));
     myShowWindow(TextEditor);
   }
 }
@@ -1058,6 +1062,25 @@
   return QTable::beginEdit(row, col, replace);
 }
 
+QString CSqlTable::prepareCellText (const QString & text)
+{
+  QString txt;
+  uint len = text.length();  
+  if ( (maxCellTextSize > 0) && (len > (uint) maxCellTextSize) )
+  {
+    txt = text.left(maxCellTextSize - 3);
+    txt += "...";
+  }  
+  else
+    txt = text;
+  return txt;
+}
+
+void CSqlTable::setText (int row, int col, const QString & text)
+{  
+  QTable::setText(row, col, prepareCellText(text));
+}
+
 QString CSqlTable::getChangeValueQuery(const QString &value, int row, int col)
 {  
   QString quotedValue = m_pDatabaseConnection->escape(value.isNull() ? text(row, col) : value);
@@ -1087,16 +1110,9 @@
 	CMySQLQuery *query = new CMySQLQuery(m_pDatabaseConnection);
 	if (query->exec_static(getChangeValueQuery(value, row, col), true))
   {
-    char* v = (char *) value.latin1();
-    unsigned int text_len = strlen(v);
-    if ((maxCellTextSize > 0) && (text_len > (uint)maxCellTextSize))
-    {
-      char* p = v + text_len - 1;
-      *p-- = '.'; *p-- = '.'; *p-- = '.';
-    }
-		setText(row, col, QString(v));
+		setText(row, col, value);
 		updateCell(row, col);    
-    setRealValue(row, col, value);    
+    setRealValue(row, col, value);
 	}
   delete query;
 }
@@ -1225,16 +1241,10 @@
               *end++ = tmp2.at(l).latin1();	
             CMySQLQuery *query = new CMySQLQuery(m_pDatabaseConnection);
 	          if (query->exec_real_static(query_string, (unsigned long) (end - query_string), true))
-            {
-              char *v = data;              
-              if ((maxCellTextSize > 0) && (len > (uint)maxCellTextSize))
-              {
-                char* p = v + len - 1;
-                *p-- = '.'; *p-- = '.'; *p-- = '.';
-              }
-              setText(row, col, QString(v));
+            {              
+              setText(row, col, data);
 		          updateCell(row, col);
-              ((CEllipseTableItem *)x)->setBlocked(true);              
+              ((CEllipseTableItem *)x)->setBlocked(true);
               setRealValue(row, col, QString::null);
             }
             delete query;
Thread
bk commit - MyCCjorge15 May