List:GUI Tools« Previous MessageNext Message »
From:jorge Date:June 11 2002 6:10am
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-06-11 01:10:09-05:00, jorge@stripped
  emptyPkIcon.xpm:
    new file
  Config.h:
    Incremented version
  CTableWindow.cpp:
    Fixed a couple of bugs
    Added a couple of enhancements
    Fixed a critical bug which always set the table type to MyISAM when editing a table.
    Fixed some SHOW CREATE TABLE parsing bugs

  dist/Changelog.txt
    1.35 02/06/11 01:09:56 jorge@stripped +20 -3

  include/CTableWindow.h
    1.11 02/06/11 01:09:50 jorge@stripped +6 -4

  src/CCreditsBox.cpp
    1.9 02/06/11 01:09:44 jorge@stripped +2 -2

  src/Globals.cpp
    1.20 02/06/11 01:09:42 jorge@stripped +1 -1

  src/CTableWindow.cpp
    1.13 02/06/11 01:09:39 jorge@stripped +124 -63

  xpm/emptyPkIcon.xpm
    1.1 02/06/10 20:47:43 jorge@stripped +18 -0

  xpm/emptyPkIcon.xpm
    1.0 02/06/10 20:47:43 jorge@stripped +0 -0
    BitKeeper file /my/mycc/xpm/emptyPkIcon.xpm

  include/Icons.h
    1.13 02/06/10 20:47:01 jorge@stripped +1 -0

  include/Config.h
    1.14 02/06/10 20:46:51 jorge@stripped +1 -1
    Incremented version

  include/CTableWindow.h
    1.10 02/06/10 20:46:49 jorge@stripped +13 -1

  src/Globals.cpp
    1.19 02/06/10 20:46:31 jorge@stripped +1 -0

  src/CTableWindow.cpp
    1.12 02/06/10 20:45:21 jorge@stripped +174 -47
    Fixed a couple of bugs
    Added a couple of enhancements
    Fixed a critical bug which always set the table type to MyISAM when editing a table.
    Fixed some SHOW CREATE TABLE parsing bugs

  src/CShowTableProperties.cpp
    1.11 02/06/10 20:45:19 jorge@stripped +1 -1

# 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.9/include/CTableWindow.h	Sun Jun  9 19:45:22 2002
+++ 1.11/include/CTableWindow.h	Tue Jun 11 01:09:50 2002
@@ -210,9 +210,14 @@
 
 public slots:
   void refresh();
-  void Add(const QString &keyname, IndexType t, QStringList fields);
+  void singleRemove(const QString &keyname, const QString &field);
+  void singleAdd(const QString &keyname, const QString &field);
+  void Add(const QString &keyname, IndexType t, QStringList fields);  
   void ChangeType(bool b, IndexType t);
   void clear();
+
+signals:
+  void primaryKey(bool, int);
   
 private slots:
   void RemoveField();
@@ -302,8 +307,8 @@
   public slots:
     void setEnabled(bool b)
     {
-      if (!b)
-        setText(QString::null);
+    /*  if (!b)
+        setText(QString::null);*/
       QLineEdit::setEnabled(b);
     }
   };
@@ -319,8 +324,8 @@
   public slots:
     void setEnabled(bool b)
     {
-      if (!b)
-        setChecked(false);
+      /*if (!b)
+        setChecked(false);*/
       QWidget::setEnabled(b);
     }
   };
@@ -357,6 +362,9 @@
   QStringList *DeletedFields;  //Stores deleted fields when isAlterTable == true  
   bool checkDuplicateNames(const QString &txt, int row, int col);
 
+public slots:
+  void addPrimaryIcon(bool add, int row);
+
 protected:
   virtual void setWindowCaption();
 
@@ -380,9 +388,14 @@
   bool createTable(const QString &tblName);
   bool alterTable();
   bool exec(const QString &qry);
+  void setPk();
+  void setPrimaryKey(int row, bool b);
   
 private:
   void swapSections(int oldIdx, int newIdx);
+  QIconSet pkIconSet;
+  QPixmap pkIcon;
+  QPixmap emptyPkIcon;
   QString getFieldSpecs(p_FieldInfo *field, QStringList &dups, bool &ok);
   QGridLayout* CTableWindowLayout;
   QTable* Fields;
@@ -406,6 +419,7 @@
   QAction* showMessagesAction;
   QAction* editCopyAction;
   QAction* editPasteAction;
+  QAction* tablePrimaryKeyAction;
   CMySQLConnection *mysql;
   CDatabaseTreeItem *tableItem;
   bool isAlterTable;

--- 1.11/src/CTableWindow.cpp	Sun Jun  9 20:04:06 2002
+++ 1.13/src/CTableWindow.cpp	Tue Jun 11 01:09:39 2002
@@ -549,12 +549,57 @@
   {
     if (fieldsUsed->findItem(*it2, Qt::CaseSensitive) == 0)
       availableFields->insertItem(*it2);
-  }  
+  }
+
+  if (indexName->currentText().lower() == "primary")
+  {
+    for (int j = 0; j < Fields->numRows(); j++)
+    {
+      QString txt = Fields->text(j, 0).stripWhiteSpace();
+      if (!txt.isEmpty())
+        emit primaryKey((index->indexSort.find(txt) != index->indexSort.end()), j);
+      else
+        emit primaryKey(false, j);
+    }
+  }
+
   addField->setEnabled(availableFields->count() > 0);
   removeField->setEnabled(fieldsUsed->count() > 0);
   deleteIndex->setEnabled(indexName->currentText().lower() != "primary");
 }
 
+void CTableIndexes::singleRemove(const QString &keyname, const QString &field)
+{
+  if (field.isEmpty() || keyname.isEmpty())
+   return;
+  Index *index = Indexes.find(keyname);
+  index->indexSort.remove(field);
+  index->indexFields.remove(field);
+  index->indexFields.resize(index->indexFields.count());
+  refresh();
+}
+
+void CTableIndexes::singleAdd(const QString &keyname, const QString &field)
+{
+  if (field.isEmpty() || keyname.isEmpty())
+   return;
+  Index *index = Indexes.find(keyname);
+  index->indexFields.resize(index->indexFields.count() + 1); 
+  for (int j = 0; j < Fields->numRows(); j++)
+  {
+    CComboFieldItem *c = (CComboFieldItem *)Fields->item(j, 2);
+    if (c->Field->FieldName == field)
+    {
+      index->indexFields.resize(index->indexFields.count() + 1);
+      index->indexSort.append(c->Field->FieldName);
+      index->indexFields.insert(c->Field->FieldName, c->Field);
+      break;
+    }
+  }
+  refresh();
+}
+
+
 void CTableIndexes::RemoveField()
 {
   if (fieldsUsed->count() == 0)
@@ -565,10 +610,10 @@
     if (fieldsUsed->isSelected(i))
     {
       index->indexSort.remove(fieldsUsed->text(i));
-      index->indexFields.remove(fieldsUsed->text(i));
-      index->indexFields.resize(index->indexFields.count());
+      index->indexFields.remove(fieldsUsed->text(i));      
     }
   }
+  index->indexFields.resize(index->indexFields.count());
   refresh();
 }
 
@@ -628,6 +673,8 @@
   indexName->setCurrentText(keyname);
   if (t != PRIMARY)
     ChangeType(true, t);
+  else
+    refresh();
 }
 
 void CTableIndexes::AddIndex()
@@ -982,31 +1029,35 @@
 void CFieldProperties::setFieldType(const QString &t)
 {
   skip = true;
-  QString type = t.lower().stripWhiteSpace();  
+  QString type = t.lower().stripWhiteSpace();
   if (type == "bit" || type == "bool" || (type.find ("int") != -1) || type == "real" || 
     type == "double" || type == "float" || type == "decimal" || type == "numeric")  //AUTO_INCREMENT, ZEROFILL, UNSIGNED
   {    
     Value->setEnabled(false);
     Binary->setEnabled(false);
+
+    Field->Value = QString::null;
+    Field->Binary = false;
+
     Length->setEnabled(true);
     Unsigned->setEnabled(true);
     ZeroFill->setEnabled(true);
     AutoIncrement->setEnabled(true);
     Default->setEnabled(true);
-    if (type == "bit" || type == "bool" || (type.find("int") != -1))
-      Length->setValidator(intValidator);
-    else
-      Length->setValidator(floatValidator);
   }
   else
-  {
-    Length->setValidator(intValidator);
     if (type.find("char") != -1) //BINARY
     {
       Value->setEnabled(false);
       Unsigned->setEnabled(false);
       ZeroFill->setEnabled(false);
       AutoIncrement->setEnabled(false);
+
+      Field->Value = QString::null;
+      Field->Unsigned = false;
+      Field->ZeroFill = false;
+      Field->AutoIncrement = false;
+
       Length->setEnabled(true);
       Binary->setEnabled(true);
       Default->setEnabled(true);
@@ -1019,46 +1070,76 @@
         Binary->setEnabled(false);
         ZeroFill->setEnabled(false);
         AutoIncrement->setEnabled(false);
+
+        Field->Length = QString::null;
+        Field->Unsigned = false;
+        Field->Binary = false;
+        Field->ZeroFill = false;
+        Field->AutoIncrement = false;
+
         Value->setEnabled(true);
         Default->setEnabled(true);
       }
       else
         if ((type.find("blob") != -1) || (type.find("text") != -1))
-        {
+        {          
+          Value->setEnabled(false);          
           Default->setEnabled(false);
-          Value->setEnabled(false);
-          Length->setEnabled(true);  //used for indexes
           Unsigned->setEnabled(false);
           Binary->setEnabled(false);
           ZeroFill->setEnabled(false);
           AutoIncrement->setEnabled(false);
+          
+          Field->Unsigned = false;
+          Field->Binary = false;
+          Field->ZeroFill = false;
+          Field->AutoIncrement = false;
+          Field->Default = QString::null;
+          Field->Value = QString::null;
+
+          Length->setEnabled(true);  //used for indexes
         }
-        else  //No special options .. should never get here!
+        else          
         {
-          Default->setEnabled(false);
           Value->setEnabled(false);
           Length->setEnabled(false);
           Unsigned->setEnabled(false);
           Binary->setEnabled(false);
           ZeroFill->setEnabled(false);
           AutoIncrement->setEnabled(false);
+
+          Field->Unsigned = false;
+          Field->Binary = false;
+          Field->ZeroFill = false;
+          Field->AutoIncrement = false;          
+          Field->Value = QString::null;
+          Field->Length = QString::null;
+
+          bool b = (type != "timestamp");
+          Default->setEnabled(b);
+          if (!b)
+            Field->Default = QString::null;
         }
-  }  
   skip = false;
 }
 
 void CFieldProperties::setField(p_FieldInfo *field)
 {
-  Field = field;
-  setFieldType(field->Type);  
+  Field = field;  
+  QString type = Field->Type.lower();
+  if (type == "real" || type == "double" || type == "float" || type == "decimal" || type == "numeric")
+    Length->setValidator(intValidator);
+  else
+    Length->setValidator(floatValidator);
+  setFieldType(type);
   skip = true;
-  Default->setText(field->Default);
-  Value->setText(field->Value);
-  Length->setText(field->Length);
-  Unsigned->setChecked(field->Unsigned);
-  Binary->setChecked(field->Binary);
-  ZeroFill->setChecked(field->ZeroFill);
-  AutoIncrement->setChecked(field->AutoIncrement);
+  Default->setText(Field->Default);
+  Value->setText(Field->Value);
+  Length->setText(Field->Length);  
+  Unsigned->setChecked(Field->Unsigned);
+  Binary->setChecked(Field->Binary);
+  ZeroFill->setChecked(Field->ZeroFill);
+  AutoIncrement->setChecked(Field->AutoIncrement);
   skip = false;
 }
 
@@ -1137,6 +1218,11 @@
   hasPaste = false;
   hasModified = false;
   tableName = tablename;
+  
+  pkIcon = getPixmapIcon("pkIcon");
+  emptyPkIcon = getPixmapIcon("emptyPkIcon");
+  pkIconSet.setPixmap(pkIcon, QIconSet::Automatic);
+
   FieldTypes = new QStringList();
   DeletedFields = new QStringList();
   bool initOk = loadSyntaxSection(FieldTypes, 9);
@@ -1224,6 +1310,12 @@
   tableDeleteAction->setIconSet(QIconSet(getPixmapIcon("deleteRowIcon")));
   tableDeleteAction->setAccel(0);
 
+  tablePrimaryKeyAction = new QAction(this, "tablePrimaryKeyAction");
+  tablePrimaryKeyAction->setText(trUtf8("Add Primary Key"));
+  tablePrimaryKeyAction->setMenuText(trUtf8("&Add Primary Key"));
+  tablePrimaryKeyAction->setIconSet(QIconSet(pkIcon));
+  tablePrimaryKeyAction->setAccel(0);
+
   editCopyAction = new QAction(this, "editCopyAction");
   editCopyAction->setText(trUtf8("Copy"));
   editCopyAction->setMenuText(trUtf8("&Copy"));
@@ -1245,6 +1337,8 @@
   editPasteAction->addTo(fileBar);
 
   tableBar = new QToolBar(tr("Table"), this, DockTop);
+  tablePrimaryKeyAction->addTo(tableBar);
+  tableBar->addSeparator();
   tableInsertAction->addTo(tableBar);
   tableDeleteAction->addTo(tableBar);
 
@@ -1267,6 +1361,8 @@
   menubar->insertItem(trUtf8("&Edit"), editMenu);
 
   tableMenu = new QPopupMenu(this);
+  tablePrimaryKeyAction->addTo(tableMenu);
+  tableMenu->insertSeparator();
   tableInsertAction->addTo(tableMenu);
   tableDeleteAction->addTo(tableMenu);
   menubar->insertItem(trUtf8("&Table"), tableMenu);
@@ -1284,13 +1380,21 @@
     delete pasteField;  
 }
 
+void CTableWindow::addPrimaryIcon(bool add, int row)
+{  
+  if (add)
+    Fields->verticalHeader()->setLabel(row, pkIconSet, QString::null);
+  else
+    Fields->verticalHeader()->setLabel(row, QIconSet(), QString::null);
+}
+
 bool CTableWindow::checkDuplicateNames(const QString &txt, int row, int col)
 {
   bool err = false;
-  for (int i = 0; i < (int) Fields->numRows(); i++)  
-    if ((Fields->text(i,0) == txt) && (((CComboFieldItem *)Fields->item(i, 2))->Field->getID() != row))
+  for (int i = 0; i < (int) Fields->numRows(); i++)    
+    if ((Fields->text(i,0) == txt) && (Fields->item(i, 2)->row() != row))
     {
-      messagePanel()->Critical(tr("You already have a Field Name called") + " '" + txt + "'");
+      messagePanel()->Warning(tr("You already have a Field Name called") + " '" + txt + "'");
       Fields->editCell(row, col);
       err = true;
       break;
@@ -1326,17 +1430,27 @@
   qDebug("CTableWindow::fieldsValueChanged() - end");
 }
 
-void CTableWindow::fieldsClicked(int row, int, int button, const QPoint &)
+void CTableWindow::fieldsClicked(int row, int, int, const QPoint &)
 {
-  if (button == Qt::LeftButton)
-  {
-    qDebug("CTableWindow::fieldsClicked()");
-    p_FieldInfo *field = ((CComboFieldItem *)Fields->item(row, 2))->Field;   
-    if (field->Type.isNull())
-      field->Type = Fields->text(row, 2);    
-    fieldPropertiesTab->setField(field);
-    qDebug("CTableWindow::fieldsClicked() - end");
+  qDebug("CTableWindow::fieldsClicked()");
+  p_FieldInfo *field = ((CComboFieldItem *)Fields->item(row, 2))->Field;   
+  if (field->Type.isNull())
+    field->Type = Fields->text(row, 2);    
+  fieldPropertiesTab->setField(field);
+
+  if (!Fields->verticalHeader()->iconSet(row)->isNull())
+  {    
+    tablePrimaryKeyAction->setText(trUtf8("Drop Primary Key"));
+    tablePrimaryKeyAction->setMenuText(trUtf8("Dr&op Primary Key"));
+    tablePrimaryKeyAction->setIconSet(QIconSet(emptyPkIcon));
   }
+  else
+  {   
+    tablePrimaryKeyAction->setText(trUtf8("Add Primary Key"));
+    tablePrimaryKeyAction->setMenuText(trUtf8("Add Primary &Key"));
+    tablePrimaryKeyAction->setIconSet(QIconSet(pkIcon));
+  }
+  qDebug("CTableWindow::fieldsClicked() - end");
 }
 
 void CTableWindow::deleteRow()
@@ -1445,13 +1559,13 @@
   fileSaveAsAction->setEnabled(isAlterTable);
   indexesTab->setIsAlterTable(isAlterTable);
   Tab->setTabEnabled(alterTableOptionsTab, isAlterTable);
-  DeletedFields->clear();
-  Fields->setRowMovingEnabled(mysql->getMySQLServerVersion().major > 3 || !isAlterTable);  
+  DeletedFields->clear();  
+  Fields->setRowMovingEnabled(mysql->getMySQLServerVersion().major > 3 || !isAlterTable);
   Fields->setNumRows(0);
+  indexesTab->clear();
   if (isAlterTable)
   {
-    alterTableOptionsTab->reset();
-    indexesTab->clear();    
+    alterTableOptionsTab->reset();    
     CMySQLQuery query(mysql);
     keys.clear();
     query.exec_static("SET SQL_QUOTE_SHOW_CREATE = 1");
@@ -1515,44 +1629,71 @@
                           else
                             if (option == "comment")
                               tablePropertiesTab->comment->setText(value.mid(1, value.length() - 2));
+                            else
+                              if (option == "type")
+                                for (int x = 0; x < tablePropertiesTab->tableType->count(); x++)
+                                  if (tablePropertiesTab->tableType->text(x).lower() == value.lower())
+                                  {
+                                    tablePropertiesTab->tableType->setCurrentItem(x);
+                                    break;
+                                  }
           }
         }
         else  //fields or indexes
         {
-          QString line = (*it).stripWhiteSpace();
+          QString line = (*it).stripWhiteSpace();          
+          if (line.right(1) == ",")
+            line = line.left(line.length() - 1);
           if (line.at(0) == '`')  //its a field
           {
-            p_FieldInfo *f = new p_FieldInfo(cnt);            
-            line = line.mid(1);            
+            p_FieldInfo *f = new p_FieldInfo(cnt);
+            line = line.mid(1);
 
             int p = line.find('`');
-            f->FieldName = line.left(p);            
+            f->FieldName = line.left(p);
 
-            line = line.mid(p + 1).stripWhiteSpace();            
+            line = line.mid(p + 1).stripWhiteSpace();
 
-            p = line.find(' ');
+            bool hasquote = false;
+            bool hasparen = false;
+            for (uint x = 0; x < line.length(); x++)
+            {
+              QChar c = line.at(x);
+              if (c == '\'')
+                hasquote = !hasquote;
+              else
+                if (c == '(' && !hasquote)
+                  hasparen = true;
+                else
+                  if (c == ')' && !hasquote)
+                    hasparen = false;
+              if (!hasquote && !hasparen && c == ' ')
+              {
+                p = x;
+                break;
+              }
+            }
             f->Type = line.left(p);
-            line = line.mid(p + 1).stripWhiteSpace();            
-
+            line = line.mid(p + 1).stripWhiteSpace();
             p = f->Type.find('(');
-
             if (p != -1) // type has length or value;
-            {              
+            {
               f->Length = f->Type.mid(p + 1);
-              f->Length = f->Length.left(f->Length.find(')'));
+              f->Length = f->Length.left(f->Length.findRev(')'));
               f->Type = f->Type.left(p);
               if (f->Type.lower() == "enum" || f->Type.lower() == "set")
               {
-                f->Value = f->Length;                
-                f->Length = QString::null;                
+                f->Value = f->Length;
+                f->Length = QString::null;
               }
             }
             p = line.find("'");
             if (p != -1) //has default ... auto_increment fields can't have default !
             {
               f->Default = line.mid(p + 1);
-              line = line.left(p);              
+              line = line.left(p);
               f->Default = f->Default.left(f->Default.findRev('\''));
+              f->Default = f->Default.replace(QRegExp("''"), "'");
             }
             line = line.lower();
             f->Unsigned = (line.find("unsigned") != -1);
@@ -1586,11 +1727,12 @@
   Fields->horizontalHeader()->setLabel(2, tr("Data Type"));
 
   for (int i = 0; i < Fields->numRows(); ++i)
-  {    
+  {
+    Fields->verticalHeader()->setLabel(i, QString::null);
     CComboFieldItem * combo = 0;    
     QCheckTableItem *check = new QCheckTableItem(Fields, QString::null);
     if (isAlterTable)
-    {
+    {      
       combo = new CComboFieldItem(Fields, fieldsDict->find(i), i, *FieldTypes, false);
       combo->setCurrentItem(combo->Field->Type);      
       check->setChecked(combo->Field->Null);
@@ -1608,7 +1750,6 @@
   }
   if (isAlterTable)
   {
-    indexesTab->refresh();
     alterTableOptionsTab->refresh();
     for (QStringList::Iterator idx = keys.begin(); idx != keys.end(); ++idx)
     {
@@ -1671,13 +1812,13 @@
       }
       indexesTab->Add(name, type, flds);
     }
-    indexesTab->indexName->setCurrentItem(0);
-    indexesTab->refresh();
+    indexesTab->indexName->setCurrentItem(0);  
     delete fieldsDict;
-  }  
+  }
+  indexesTab->refresh();
   Fields->setCurrentCell(0, 0);
+  Fields->adjustRow(0); 
   fieldsClicked(0, 0, Qt::LeftButton, QPoint(0,0));
-  Fields->adjustRow(0);
   qDebug("CTableWindow::reset() - end");
 }
 
@@ -1704,17 +1845,43 @@
   }
 }
 
+void CTableWindow::setPk()
+{
+  bool isPrimaryKey = !Fields->verticalHeader()->iconSet(Fields->currentRow())->isNull();
+  setPrimaryKey(Fields->currentRow(), isPrimaryKey);
+}
+
+void CTableWindow::setPrimaryKey(int row, bool b)
+{
+  QString txt = Fields->text(row, 0);
+  if (!txt.isEmpty())
+  {
+    if (!b)
+      indexesTab->singleAdd("PRIMARY", txt);
+    else
+      indexesTab->singleRemove("PRIMARY", txt);
+  }
+  fieldsClicked(0, 0, Qt::LeftButton, QPoint(0,0));
+}
+
 void CTableWindow::showContextMenu(int, int, const QPoint &pos)
 {
   QPopupMenu *menu = new QPopupMenu();
   Q_CHECK_PTR(menu);
-  menu->insertItem(getPixmapIcon("insertRowIcon"), tr("Insert Row"), 0);
-  menu->insertItem(getPixmapIcon("deleteRowIcon"), tr("Delete Row"), 1);
+  int row = Fields->currentRow();  
+  bool isPrimaryKey = !Fields->verticalHeader()->iconSet(row)->isNull();
+  if (isPrimaryKey)
+    menu->insertItem(emptyPkIcon, tr("Drop Primary Key"), 0);
+  else
+    menu->insertItem(pkIcon, tr("Add Primary Key"), 0);
+  menu->insertSeparator();
+  menu->insertItem(getPixmapIcon("insertRowIcon"), tr("Insert Row"), 1);
+  menu->insertItem(getPixmapIcon("deleteRowIcon"), tr("Delete Row"), 2);
   menu->insertSeparator();
-  menu->insertItem(getPixmapIcon("copyIcon"), tr("Copy"), 2);
-  menu->insertItem(getPixmapIcon("pasteIcon"), tr("Paste"), 3);
+  menu->insertItem(getPixmapIcon("copyIcon"), tr("Copy"), 3);
+  menu->insertItem(getPixmapIcon("pasteIcon"), tr("Paste"), 4);
   menu->insertSeparator();
-  menu->insertItem(getPixmapIcon("refreshTablesIcon"), tr("Reload"), 4);
+  menu->insertItem(getPixmapIcon("refreshTablesIcon"), tr("Reload"), 5);
   
   menu->setItemEnabled(3, hasPaste);  
   menu->setItemEnabled(4, isAlterTable);
@@ -1723,15 +1890,17 @@
   delete menu;
   switch (res)
   {
-  case 0: insertRow();
+  case 0: setPrimaryKey(row, isPrimaryKey);    
+    break;
+  case 1: insertRow();
     break;
-  case 1: deleteRow();
+  case 2: deleteRow();
     break;
-  case 2: copy();
+  case 3: copy();
     break;
-  case 3: paste();
+  case 4: paste();
     break;
-  case 4: reset();
+  case 5: reset();
     break;
   }  
 }
@@ -1775,7 +1944,7 @@
     }
     else
       dups.append(field->FieldName);
-    QString type = field->Type.lower();    
+    QString type = field->Type.lower();
     sql += mysql->Quote(field->FieldName) + " ";
     sql += field->Type;      
     if (field->Type.find("char") != -1 && field->Length.isEmpty())  //char & varchar Need to have Length defined
@@ -1796,21 +1965,21 @@
       if (type == "enum" || type == "set")
       {
         if (!field->Value.isEmpty())
-        {
-          field->Value = field->Value.stripWhiteSpace().simplifyWhiteSpace();
-          QStringList valueList(QStringList::split(",", field->Value.stripWhiteSpace().simplifyWhiteSpace()));
+        {          
+          QStringList valueList(QStringList::split(",", field->Value, true));
           field->Value = QString::null;
           for (QStringList::Iterator it = valueList.begin(); it != valueList.end(); ++it)
           {
             QString value = (*it).stripWhiteSpace();
             if (!value.isEmpty())
             {
-              if (value.at(0) != '\'')
-                value = "'" + value;
-              if (value.at(value.length() - 1) != '\'')
-                value += "'";
+              QChar c = value.at(0);
+              if ((c != '\'' && c != '\"') || ((c == '\'' || c == '\"') && value.at(value.length() - 1) != c))
+                value = "'" + mysql->escape(value).local8Bit() + "'";
               field->Value += value + ",";
             }
+            else
+              field->Value += "'',";
           }            
           field->Value = field->Value.left(field->Value.length() - 1);
           sql += "(" + field->Value + ")";            
@@ -1838,9 +2007,25 @@
     if (!field->Null)
       sql += "NOT NULL ";
     
-    if (!field->Default.isEmpty())
-      sql += "DEFAULT '" + mysql->escape(field->Default).local8Bit() + "' ";
-    
+    bool skipDefault = false;
+
+    if (field->Type == "enum" || field->Type == "set")
+    {
+      if (field->Default.isEmpty())
+        skipDefault = true;
+    }
+    else
+      if ( field->Type.find("blob") != -1 || field->Type.find("text") != -1 || field->Type == "timestamp" || field->AutoIncrement)
+        skipDefault = true;
+
+    if (!skipDefault)
+    {
+      sql += "DEFAULT '";    
+      if (!field->Default.isEmpty())
+        sql += mysql->escape(field->Default).local8Bit();    
+      sql += "' ";
+    }
+
     if (field->AutoIncrement)
       sql += "AUTO_INCREMENT ";    
   }
@@ -2046,27 +2231,30 @@
 void CTableWindow::init(bool ok)
 {
   if (ok)
-  {
-    reset();
+  {    
     connect(tableInsertAction, SIGNAL(activated()), this, SLOT(insertRow()));
     connect(tableDeleteAction, SIGNAL(activated()), this, SLOT(deleteRow()));
+    connect(tablePrimaryKeyAction, SIGNAL(activated()), this, SLOT(setPk()));
     connect(Fields, SIGNAL(contextMenuRequested(int, int, const QPoint &)), this, SLOT(showContextMenu(int, int, const QPoint &)));
     connect(Fields, SIGNAL(clicked(int, int, int, const QPoint &)), this, SLOT(fieldsClicked(int, int, int, const QPoint &)));
-    connect(Fields, SIGNAL(valueChanged(int, int)), this, SLOT(fieldsValueChanged(int, int)));
+    connect(Fields, SIGNAL(valueChanged(int, int)), this, SLOT(fieldsValueChanged(int, int)));    
     connect(fileSaveAction, SIGNAL(activated()), this, SLOT(save()));
     connect(fileSaveAsAction, SIGNAL(activated()), this, SLOT(saveAs()));
     connect(fileReloadAction, SIGNAL(activated()), this, SLOT(reset()));
     connect(editCopyAction, SIGNAL(activated()), this, SLOT(copy()));
     connect(editPasteAction, SIGNAL(activated()), this, SLOT(paste()));
     connect(Tab, SIGNAL(currentChanged(QWidget *)), indexesTab, SLOT(refresh()));
+    connect(indexesTab, SIGNAL(primaryKey(bool, int)), this, SLOT(addPrimaryIcon(bool, int)));
     connect(this, SIGNAL(valueChanged()), indexesTab, SLOT(refresh()));
     connect(this, SIGNAL(valueChanged()), alterTableOptionsTab, SLOT(refresh()));
+    reset();
   }
   else
   {
     setWindowCaption();
     tableInsertAction->setEnabled(false);
     tableDeleteAction->setEnabled(false);
+    tablePrimaryKeyAction->setEnabled(false);
     fileSaveAction->setEnabled(false);
     fileSaveAsAction->setEnabled(false);    
     fileReloadAction->setEnabled(false);
--- New file ---
+++ xpm/emptyPkIcon.xpm	02/06/10 20:47:43
/* XPM */
static const char* const emptyPkIcon_data[] = { 
"10 11 3 1",
"# c #000000",
"a c None",
". c None",
"..#####...",
".#aaaaa#..",
".#aa#aa#..",
".#aaaaa#..",
"..#aaa#...",
"...#a#....",
"...#aa#...",
"...#a#....",
"...#aa#...",
"...#a#....",
"....#....."};



--- 1.34/dist/Changelog.txt	Sun Jun  9 20:19:56 2002
+++ 1.35/dist/Changelog.txt	Tue Jun 11 01:09:56 2002
@@ -1,3 +1,22 @@
+Important Notes for 0.8.4-alpha
+-------------------------------
+MyCC 0.8.3 has a couple of critical bug that affect users who will be using the newly added features: 'New Table' & 'Edit Table'.
+If you are currently using MyCC 0.8.3 and are planning to use the above 2 features, please upgrade to the latest MyCC release.
+
+Changes for 0.8.4-alpha
+-----------------------
+ * Added some enhancements to CTableWindow.
+ * Fixed several SHOW CREATE TABLE parsing bugs.
+ * Fixed a bug that failed to parse correctly the DEFAULT value of a field.
+ * Fixed a bug which didn't generate the correct DEFAULT value for fields.
+ * Fixed a bug that failed to parse correctly ENUM & SET Values.
+ * Fixed a bug which reset the "Table Type" to MyISAM when editing tables.
+ * Fixed a bug generating the quote enclosed values for SET & ENUM fields.
+ * Fixed a bug generating the quote enclosed values for the DEFAULT value of a Field.
+ * Fixed a bug which didn't clear the Field Properties correctly when modifying the Field Type.
+ * Fixed a bug which displayed an erroneous Error message when a field was moved.
+
+
 Important Notes for 0.8.3-alpha
 -------------------------------
 Because of a bug found in all previous versions of MyCC regarding the way Query History was saved, its important
@@ -35,9 +54,7 @@
  * Multiple queries can now be executed in the Query Window.  They need to be separated with ";"
  * Double-Clicking on the Database branch (Navigation Tree) now opens or collapses the child items depending on the current status.
  * One can now define a "Connection Name" when registering a new server.  Before, it was only possible if one was editing a server.
- * The Linux configuration scripts now check for
-     - mysql_real_connect instead of mysql_connect
-     - QT >= 3.0.2
+ * The Linux configuration scripts now check for mysql_real_connect & QT >= 3.0.2
  * MyCC binaries are now compiled with Qt 3.0.4
  * Fixed up CSqlTable's context menu's for when no results where returned by the query.
  * Fixed a design bug which didn't preserve line-feeds in the query history.

--- 1.13/include/Config.h	Tue Jun  4 16:32:41 2002
+++ 1.14/include/Config.h	Mon Jun 10 20:46:51 2002
@@ -28,7 +28,7 @@
 
 #define APPLICATION "MySQL Control Center"
 #define CODENAME "MyCC"
-#define VERSION "0.8.3"
+#define VERSION "0.8.4"
 #define BRANCH "-alpha"
 #define COPYRIGHT "Copyright (C) MySQL AB & Jorge del Conde 2002"
 

--- 1.12/include/Icons.h	Fri Jun  7 03:02:50 2002
+++ 1.13/include/Icons.h	Mon Jun 10 20:47:01 2002
@@ -125,6 +125,7 @@
 #include "../xpm/leftArrowIcon.xpm"
 #include "../xpm/rightArrowIcon.xpm"
 #include "../xpm/eraserIcon.xpm"
+#include "../xpm/emptyPkIcon.xpm"
 
 #endif
 

--- 1.8/src/CCreditsBox.cpp	Thu Apr 18 12:12:51 2002
+++ 1.9/src/CCreditsBox.cpp	Tue Jun 11 01:09:44 2002
@@ -66,11 +66,11 @@
   TextLabel3->setFrameShape( QLabel::Panel );
   TextLabel3->setFrameShadow( QLabel::Sunken );
   TextLabel3->setText(tr(" <b>Jorge del Conde</b> [jorge@stripped]<br>\n"
+    "<b>Adam Hooper</b> [adamh@stripped]<br>\n"
     "<b>Alexander M. Stetsenko</b> [ams@stripped]<br>\n"
     "<b>Sasha Pachev</b> [sasha@stripped]<br>\n"
-    "<b>Michael Widenius</b> [monty@stripped]<br>\n"
     "<b>Reginald Stadlbauer</b> [reggie@stripped]<br>\n"
-    "<b>Adam Hooper</b> [adamh@stripped]" ) );
+    "<b>Michael Widenius</b> [monty@stripped]"));        
 
   TextLabel3->setAlignment( int( QLabel::AlignTop ) );
   QWhatsThis::add( TextLabel3,tr("People who contributed directly to this development." ) );

--- 1.10/src/CShowTableProperties.cpp	Sun Jun  9 19:43:49 2002
+++ 1.11/src/CShowTableProperties.cpp	Mon Jun 10 20:45:19 2002
@@ -81,7 +81,7 @@
                   icon = "nothingIcon";                  
                 else
                   icon = "otherIcon";                
-                setPixmap(j,0, getPixmapIcon(icon));          
+                setPixmap(j,0, getPixmapIcon(icon));
         }
       }
       j++;	

--- 1.18/src/Globals.cpp	Fri Jun  7 03:26:23 2002
+++ 1.20/src/Globals.cpp	Tue Jun 11 01:09:42 2002
@@ -484,7 +484,7 @@
 
 QString charReplace(const QString & Str, const QChar & From, const QString & To)
 {
-  QString tmpStr = "";
+  QString tmpStr = QString::null;
   for (uint i=0; i < Str.length(); i++)
   {
     QChar Tmp = Str.at(i);
@@ -640,5 +640,6 @@
   g_IconsDict->insert("leftArrowIcon", new QPixmap((const char**)leftArrowIcon_data));
   g_IconsDict->insert("rightArrowIcon", new QPixmap((const char**)rightArrowIcon_data));
   g_IconsDict->insert("eraserIcon", new QPixmap((const char**)eraserIcon_data));
+  g_IconsDict->insert("emptyPkIcon", new QPixmap((const char**)emptyPkIcon_data));  
 }
 
Thread
bk commit - MyCCjorge11 Jun