OSSP CVS Repository

ossp - Check-in [4686]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4686
Date: 2004-Aug-24 23:47:30 (local)
2004-Aug-24 21:47:30 (UTC)
User:ms
Branch:
Comment: Repair selection bug when using the tab and shift tab keys with in place edition, and implement in place edition logic for use with the return and enter keys. Also override the QTable::endEdit method to properly deactivate in place edition when finished.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_table.cpp      1.26 -> 1.27     42 inserted, 6 deleted

ossp-pkg/as/as-gui/as_table.cpp 1.26 -> 1.27

--- as_table.cpp 2004/05/27 21:48:41     1.26
+++ as_table.cpp 2004/08/24 21:47:30     1.27
@@ -54,14 +54,16 @@
 
                 // Advance the column or both row and column possibly
                 int nColadvance = ((currentColumn() + nIter) % TITRAQ_IDXTAIL);
-                if ((currentColumn() + nIter) >= TITRAQ_IDXTAIL)
+                if ((currentColumn() + nIter) >= TITRAQ_IDXTAIL) {
+                    this->clearSelection(true);
                     this->setCurrentCell(currentRow() + 1, nColadvance);
+//                    this->repaint(false);   // Really necessary?
+                }
                 else
                     this->setCurrentCell(currentRow(), nColadvance);
                 this->setReadOnly(false);
                 this->editCell(currentRow(), currentColumn());
                 this->setEdition(currentColumn());
-                this->setReadOnly(true);
             }
             return true; // Handle the tab key event and cancel its progress
         }
@@ -74,23 +76,47 @@
 
                 // Advance the column or both row and column possibly
                 int nColadvance = (currentColumn() - nIter + TITRAQ_IDXTAIL) % TITRAQ_IDXTAIL;
-                if ((currentColumn() - nIter) < 0)
+                if ((currentColumn() - nIter) < 0) {
+                    this->clearSelection(true);
                     this->setCurrentCell(currentRow() - 1, nColadvance);
+//                    this->repaint(false);   // Really necessary?
+                }
                 else
                     this->setCurrentCell(currentRow(), nColadvance);
                 this->setReadOnly(false);
                 this->editCell(currentRow(), currentColumn());
                 this->setEdition(currentColumn());
-                this->setReadOnly(true);
             }
             return true; // Handle the shift tab key event and cancel its progress
         }
+        else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Return && this->getEdition() >= 0) { // Return key
+            this->endEdit(currEditRow(), currEditCol(), true, false);
+            this->setEdition();                             // Reset edition
+            return true;                                    // Cancel progress
+        }
+        else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Enter && this->getEdition() >= 0) { // Enter key
+            this->endEdit(currEditRow(), currEditCol(), true, false);
+            this->setEdition();                             // Reset edition
+            return true;                                    // Cancel progress
+        }
+        else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Return) { // Return key without edition
+            this->setReadOnly(false);                       // Allow edition
+            this->editCell(currentRow(), currentColumn());  // Begin edition
+            this->setEdition(currentColumn());              // Store edition state
+            return true;                                    // Cancel further progress
+        }
+        else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Enter) { // Enter key without edition
+            this->setReadOnly(false);                       // Allow edition
+            this->editCell(currentRow(), currentColumn());  // Begin edition
+            this->setEdition(currentColumn());              // Store edition state
+            return true;                                    // Cancel further progress
+        }
+        else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Escape)    // Handle escape key
+            this->setEdition();
         else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Up && this->getEdition() >= 0) // Handle up key
             return true;                                            // Capture
         else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Down && this->getEdition() >= 0) // Handle down key
             return true;                                            // Capture
-        else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Escape)    // Handle escape key
-            this->setEdition();
 
         // Forward incompletely handled key events
         return QTable::eventFilter(pObject, pEvent);
@@ -211,5 +237,15 @@
     this->setReadOnly(false);
     this->editCell(currentRow(), currentColumn());
     this->setEdition(currentColumn());
+}
+
+// Overriden member to properly handle read only attribute after edition
+void TiTable::endEdit(int nRow, int nCol, bool bAccept, bool bReplace)
+{
+    QTable::endEdit(nRow, nCol, bAccept, bReplace);
+
+    // Table read only attribute must be set to return to the normal
+    // row highlight and selection behaviour of AS. The reason it was
+    // reset in inplaceEdit() was to allow editing in the first place.
     this->setReadOnly(true);
 }

CVSTrac 2.0.1