OSSP CVS Repository

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

Check-in Number: 3862
Date: 2002-Dec-12 17:18:54 (local)
2002-Dec-12 16:18:54 (UTC)
User:ms
Branch:
Comment: Remove clean state handling to TiTable subclass and generalize add row logic to remove two conditions.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_slot.cpp      1.52 -> 1.53     22 inserted, 57 deleted

ossp-pkg/as/as-gui/as_slot.cpp 1.52 -> 1.53

--- as_slot.cpp  2002/12/12 13:27:22     1.52
+++ as_slot.cpp  2002/12/12 16:18:54     1.53
@@ -86,10 +86,8 @@
     nRows = Selection.contains(QChar('\n'));        // How many rows
     this->addEntry(nRows);                          // Reuse slot
 
-    if (Selection) {
+    if (Selection)
         setRowdata(Selection);                      // Use accessor
-        this->setDirty(true);                       // Set dirty state
-    }
 }
 
 //
@@ -101,37 +99,19 @@
     int nTotal = 0;         // Total row select
     int nCurrent = 0;       // Current row
 
-    if (nRows == -1) {      // Assume a user selection range
-        Select = m_pMaintable->selection(0);
-        nTotal = Select.bottomRow() - Select.topRow() + 1;
-        // Add a row after selection and focus to the new row
-        if (Select.bottomRow() + 1 != m_pMaintable->numRows()) { // Add upwards
-            m_pMaintable->insertRows(Select.topRow(), nTotal);
-            this->setDirty(true);   // Set data to dirty state
-            m_pMaintable->setCurrentCell(Select.topRow(), m_pMaintable->currentColumn());
-        }
-        else { // Special case on last row add downwards
-            m_pMaintable->insertRows(Select.bottomRow() + 1, nTotal);
-            this->setDirty(true);   // Set data to dirty state
-            m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
-            m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
-        }
-    }
-    else {                  // Do not count a user selection
-        nTotal   = nRows;
-        nCurrent = m_pMaintable->currentRow();
-        // Add a row after selection and focus to the new row
-        if (nCurrent + 1 != m_pMaintable->numRows()) { // Add upwards
-            m_pMaintable->insertRows(nCurrent, nTotal);
-            this->setDirty(false);  // Reset data to clean state
-            m_pMaintable->setCurrentCell(nCurrent, m_pMaintable->currentColumn());
-        }
-        else { // Special case on last row add downwards
-            m_pMaintable->insertRows(nCurrent + 1, nTotal);
-            this->setDirty(false);  // Reset data to clean state
-            m_pMaintable->setCurrentCell(nCurrent + 1, m_pMaintable->currentColumn());
-            m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
-        }
+    Select = m_pMaintable->selection(0);
+    nTotal = Select.bottomRow() - Select.topRow() + 1;
+    // Add a row after selection and focus to the new row
+    if (Select.bottomRow() + 1 != m_pMaintable->numRows()) { // Add upwards
+        m_pMaintable->insertRows(Select.topRow(), nTotal);
+        this->setDirty();   // Set data to dirty state
+        m_pMaintable->setCurrentCell(Select.topRow(), m_pMaintable->currentColumn());
+    }
+    else { // Special case on last row add downwards
+        m_pMaintable->insertRows(Select.bottomRow() + 1, nTotal);
+        this->setDirty();   // Set data to dirty state
+        m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
+        m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
     }
 
 //    updateDate(*m_pDatezero);
@@ -164,11 +144,11 @@
     if (m_pMaintable->currentRow() + 1 != m_pMaintable->numRows()) {
         m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
         m_pMaintable->removeRows(Rowselect);
-        this->setDirty(true);   // Set data to dirty state
+        this->setDirty();   // Set data to dirty state
     }
     else {  // Special case to handle removing of only row or last row
         m_pMaintable->removeRows(Rowselect);
-        this->setDirty(true);   // Set data to dirty state
+        this->setDirty();   // Set data to dirty state
     }
 }
 
@@ -350,12 +330,12 @@
         switch (nResult) {
         case 0: // Save first
             this->saveFile();               // Save changes first
-            pClosit->accept();              // then close timesheet
             this->setDirty(false);          // Reset data to clean state
+            pClosit->accept();              // then close timesheet
             break;
         case 1: // Don't save first but close
-            pClosit->accept();              // Close timesheet
             this->setDirty(false);          // Reset data to clean state
+            pClosit->accept();              // Close timesheet
             break;
         case 2: // Don't close
         default:
@@ -364,8 +344,8 @@
         }
     }
     else {                                  // Data is already up to date
-        pClosit->accept();
         this->setDirty(false);              // Reset data to clean state
+        pClosit->accept();
     }
 }
 
@@ -505,7 +485,7 @@
 //
 // What to do if a data cell is modified
 //
-void Titraqform::dataChanged(int nRow, int nCol)
+void Titraqform::dataChanged(void)
 {
     setDirty(); // Mark this timesheet dirty, changes pending save
 }
@@ -568,7 +548,6 @@
 //
 void Titraqform::updateStatus(const QString &Instring)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXSTATUS, Instring);
 }
 
@@ -577,7 +556,6 @@
 //
 void Titraqform::updateLine(const QString &Instring)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXLINE, Instring);
 }
 
@@ -586,7 +564,6 @@
 //
 void Titraqform::updateUser(const QString &Instring)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXUSER, Instring);
 }
 
@@ -595,7 +572,6 @@
 //
 void Titraqform::updateGuid(const QString &Instring)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXGUID, Instring);
 }
 
@@ -604,7 +580,6 @@
 //
 void Titraqform::updateCrc(const QString &Instring)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXCRC, Instring);
 }
 
@@ -613,7 +588,6 @@
 //
 void Titraqform::updateRev(const QString &Instring)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREV, Instring);
 }
 
@@ -622,14 +596,10 @@
 //
 void Titraqform::updateDate(const QDate &Dateup)
 {
-    if (Dateup == *m_pDatezero) { // Complete the already nasty hack
-        setDirty(); // Mark this timesheet dirty, changes pending save
+    if (Dateup == *m_pDatezero) // Complete the already nasty hack
         m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXDATE, trUtf8(TITRAQ_DATEZERO));
-    }
-    else {
-        setDirty(); // Mark this timesheet dirty, changes pending save
+    else
         m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXDATE, Dateup.toString(Qt::ISODate));
-    }
 }
 
 //
@@ -637,7 +607,6 @@
 //
 void Titraqform::updateStart(const QTime &Startup)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXSTART, Startup.toString(Qt::ISODate));
 }
 
@@ -646,7 +615,6 @@
 //
 void Titraqform::updateFinish(const QTime &Finishup)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXFINISH, Finishup.toString(Qt::ISODate));
 }
 
@@ -656,7 +624,6 @@
 void Titraqform::updateAmount(const QString &Amountup)
 {
     // Ignore incoming data and use widget managed data because its easier
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXAMOUNT, m_pAmount->text());
 }
 
@@ -670,7 +637,6 @@
 //    pTask = static_cast<RtTableItem *>(m_pMaintable->item(m_pMaintable->currentRow(), TITRAQ_IDXTASK));
 //    pTask->setText(Taskup);
 
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXTASK, Taskup);
 }
 
@@ -679,7 +645,6 @@
 //
 void Titraqform::updateRemark(const QString &Remarkup)
 {
-    setDirty(); // Mark this timesheet dirty, changes pending save
     m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREMARK, Remarkup);
 }
 

CVSTrac 2.0.1