OSSP CVS Repository

ossp - Difference in ossp-pkg/as/as-gui/as_table.cpp versions 1.26 and 1.27
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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