OSSP CVS Repository

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

Check-in Number: 3844
Date: 2002-Dec-05 15:51:29 (local)
2002-Dec-05 14:51:29 (UTC)
User:ms
Branch:
Comment: Flush dirty state saving changes without considering broken build.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_assist.cpp      1.49 -> 1.50     1 inserted, 1 deleted
ossp-pkg/as/as-gui/as_const.h      1.15 -> 1.16     4 inserted, 0 deleted
ossp-pkg/as/as-gui/as_gui.h      1.41 -> 1.42     1 inserted, 0 deleted
ossp-pkg/as/as-gui/as_slot.cpp      1.40 -> 1.41     82 inserted, 20 deleted
ossp-pkg/as/as-gui/as_table.h      1.6 -> 1.7     1 inserted, 1 deleted

ossp-pkg/as/as-gui/as_assist.cpp 1.49 -> 1.50

--- as_assist.cpp        2002/12/05 10:33:25     1.49
+++ as_assist.cpp        2002/12/05 14:51:29     1.50
@@ -498,7 +498,7 @@
     connect(m_pMaintable, SIGNAL(currentChanged(int, int)), this, SLOT(updEdit(int, int)));
     connect(m_pMaintable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), this, SLOT(inplaceEdit(int, int, int, const QPoint&)));
     connect(m_pTablehead, SIGNAL(sizeChange(int, int, int)), this, SLOT(updSizes(int, int, int)));
-//    connect(m_pMaintable, SIGNAL(valueChanged(int, int)), this, SLOT(tableChanged(int, int)));
+    connect(m_pMaintable, SIGNAL(valueChanged(int, int)), this, SLOT(dataChanged(int, int)));
 }
 
 //


ossp-pkg/as/as-gui/as_const.h 1.15 -> 1.16

--- as_const.h   2002/12/04 18:56:59     1.15
+++ as_const.h   2002/12/05 14:51:29     1.16
@@ -48,6 +48,7 @@
 #define TITRAQ_DEFREMOTELOG     "no"
 #define TITRAQ_PREFLOCALLOG     "loglocal"
 #define TITRAQ_DEFLOCALLOG      "no"
+#define TITRAQ_SAVEFIRST        "The timesheet contains unsaved changes\nDo you want to save the changes or discard them?"
 
 // Other string constants
 #define TITRAQ_DATEZERO         "0000-00-00"
@@ -77,5 +78,8 @@
 #define TITRAQ_MINAMOUNT        0           // Minimum valid amount
 #define TITRAQ_STEPAMOUNT       15          // Line step interval
 #define TITRAQ_MINSINHOUR       60          // Only idiots don't know this
+#define TITRAQ_YES              1           // To signal yes in general
+#define TITRAQ_NO               0           // To signal no in general
+#define TITRAQ_CANCEL           -1          // To not signal anything
 
 #endif // TITCONST_H


ossp-pkg/as/as-gui/as_gui.h 1.41 -> 1.42

--- as_gui.h     2002/12/04 23:22:52     1.41
+++ as_gui.h     2002/12/05 14:51:29     1.42
@@ -129,6 +129,7 @@
     void inplaceEdit(int, int, int, const QPoint &); // Enter in place edit mode
     void updEdit(int, int);             // Update edit controls
     void updSizes(int, int, int);       // Update edit sizes
+    void dataChanged(int, int);         // Timesheet data changed
     void updateDate(const QDate &);     // Update date column
     void updateStart(const QTime &);    // Update start column
     void updateFinish(const QTime &);   // Update finish column


ossp-pkg/as/as-gui/as_slot.cpp 1.40 -> 1.41

--- as_slot.cpp  2002/12/04 23:22:52     1.40
+++ as_slot.cpp  2002/12/05 14:51:29     1.41
@@ -167,7 +167,29 @@
 //
 void Titraqform::newDoc(void)
 {
-    m_pMaintable->setNumRows(0); // Get rid of any data in table
+    int nResult = 0;
+
+    // Check modification state of current data
+    if (this->isDirty()) {
+        nResult = QMessageBox::information(this, trUtf8(TITRAQ_APPTITLE),
+                  trUtf8(TITRAQ_SAVEFIRST), trUtf8("&Save"),
+                  trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
+
+        switch (nResult) {
+        case 0: // Save first
+            this->saveFile();               // Save changes first
+            m_pMaintable->setNumRows(0);    // Remove all data in table
+            break;
+        case 1: // Don't save first but do new
+            m_pMaintable->setNumRows(0);    // Remove all data in table
+            break;
+        case 2: // Don't do a new timesheet
+        default:
+            break;
+        }
+    }
+    else                                    // Data is already up to date
+        m_pMaintable->setNumRows(0);        // Remove all data in table
 }
 
 //
@@ -242,28 +264,30 @@
 //
 void Titraqform::closeEvent(QCloseEvent *pClosit)
 {
+    int nResult = 0;
+
     // Check modification state of current data
-    if (!this->isDirty()) {
-        pClosit->accept();
-        return;
+    if (this->isDirty()) {
+        nResult = QMessageBox::information(this, trUtf8(TITRAQ_APPTITLE),
+                  trUtf8(TITRAQ_SAVEFIRST), trUtf8("&Save"),
+                  trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
+
+        switch (nResult) {
+        case 0: // Save first
+            this->saveFile();               // Save changes first
+            pClosit->accept();              // then close timesheet
+            break;
+        case 1: // Don't save first but close
+            pClosit->accept();              // Close timesheet
+            break;
+        case 2: // Don't close
+        default:
+            pClosit->ignore();
+            break;
+        }
     }
-
-    // Ask user to acknowlege a possibly data-damaging close event
-    switch(QMessageBox::information(this, "OSSP titraq",
-        trUtf8("The document has been\nchanged since the last save.")),
-        trUtf8("Save Now"), trUtf8("Cancel"), trUtf8("Leave Anyway"), 0, 1) {
-    case 0:
-        saveFile();
-        pClosit->accept();
-        break;
-    case 1:
-        default:    // Just for sanity
-        pClosit->ignore();
-        break;
-    case 2:
+    else                                    // Data is already up to date
         pClosit->accept();
-        break;
-    }
 }
 
 //
@@ -291,6 +315,44 @@
 //
 void Titraqform::updSizes(int nSection, int nOldsize, int nNewsize)
 {
+    switch (nSection) {
+    case TITRAQ_IDXALLCTRLS:
+        m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
+        m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING);
+        m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING);
+        m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING);
+        m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING);
+//        m_pRemark->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREMARK) - TITRAQ_SPACING);
+        break;
+    case TITRAQ_IDXDATE:
+        m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
+        break;
+    case TITRAQ_IDXSTART:
+        m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING);
+        break;
+    case TITRAQ_IDXFINISH:
+        m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING);
+        break;
+    case TITRAQ_IDXAMOUNT:
+        m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING);
+        break;
+    case TITRAQ_IDXTASK:
+        m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING);
+        break;
+    case TITRAQ_IDXREMARK:
+//        m_pRemark->setFixedWidth(nNewsize);
+        break;
+    default:
+        throw Genexcept("Unrecognized main window column header.");
+        break;
+    }
+}
+
+//
+// 
+//
+void Titraqform::updSizes(int nSection, int nOldsize, int nNewsize)
+{
     switch (nSection) {
     case TITRAQ_IDXALLCTRLS:
         m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2);


ossp-pkg/as/as-gui/as_table.h 1.6 -> 1.7

--- as_table.h   2002/12/04 20:30:54     1.6
+++ as_table.h   2002/12/05 14:51:29     1.7
@@ -42,7 +42,7 @@
     // Try to match QTable's default constructor with an initializer list
     TiTable(QWidget *pParent = 0, const char *szName = 0) : QTable(pParent, szName)
     {
-        this->installEventFilter(this);
+        horizontalHeader()->installEventFilter(this);
         this->setEdition(); // Reset edition state
     };
 

CVSTrac 2.0.1