OSSP CVS Repository

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

Check-in Number: 3972
Date: 2003-Jan-30 21:26:03 (local)
2003-Jan-30 20:26:03 (UTC)
User:ms
Branch:
Comment: Implemented writing and testing of a data version symbol.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/ChangeLog      1.20 -> 1.21     1 inserted, 0 deleted
ossp-pkg/as/as-gui/TODO      1.66 -> 1.67     1 inserted, 1 deleted
ossp-pkg/as/as-gui/as_const.h      1.40 -> 1.41     6 inserted, 0 deleted
ossp-pkg/as/as-gui/as_dataop.cpp      1.38 -> 1.39     35 inserted, 0 deleted
ossp-pkg/as/as-gui/as_slot.cpp      1.94 -> 1.95     3 inserted, 0 deleted

ossp-pkg/as/as-gui/ChangeLog 1.20 -> 1.21

--- ChangeLog    2003/01/30 18:14:51     1.20
+++ ChangeLog    2003/01/30 20:26:03     1.21
@@ -4,6 +4,7 @@
        Remove hackful zero date value, replace with current date
        Added aggregate class User, and prefer user data from environment
        Fixed ignored prepared entry bug on new document operation
+       Implemented writing and testing of a data version symbol
 
 030129 Fixed the autoscroll before show bug, causing wrong data position
 


ossp-pkg/as/as-gui/TODO 1.66 -> 1.67

--- TODO 2003/01/30 18:14:51     1.66
+++ TODO 2003/01/30 20:26:03     1.67
@@ -37,7 +37,6 @@
 ---------------------
 Name changes to as-gui throughout
 Allow non alphanumerics in Remarks
-Write a magic cookie on new document generation
 
 Bugs (? = unverified)
 ---------------------
@@ -49,6 +48,7 @@
 Pressing escape on task data cells does not exit edit mode
 On dirty, save is asked, if cancel from file dialog, doesn't revert
 On win32, all or some file reads and writes probably need IO_Translate?
+Method saveData(stream) must write to a new file, otherwise writes data pattern
 
 Nice to have
 ------------


ossp-pkg/as/as-gui/as_const.h 1.40 -> 1.41

--- as_const.h   2003/01/30 18:18:30     1.40
+++ as_const.h   2003/01/30 20:26:03     1.41
@@ -145,6 +145,12 @@
 #define TITRAQ_DATAPATTERN      "%!AS-EVENTS-"
 #define TITRAQ_SAVEFIRST        "The timesheet contains unsaved changes.\nDo you want to save the changes or discard them?"
 #define TITRAQ_OVERWRITE        "A file already exists with the chosen name.\nDo you want to overwrite it with new data?"
+#define TITRAQ_NOPATTERNFOUND   "This data file appears to be invalid,\nbecause the AS data symbol\n        "
+#define TITRAQ_WASNOTFOUNDIN    "\nwas not found inside of it."
+#define TITRAQ_BADVERSIONMAJ    "Incompatible data format. Please\neither upgrade this application or\nthe data you are using with it."
+#define TITRAQ_BADVERSIONMIN    "Incompatible data format. Please either\nupgrade this application or downgrade\nthe data you are using with it."
+#define TITRAQ_INCOMPATDATA     "Error: incompatible data format."
+#define TITRAQ_INVALIDDATA      "Error: invalid data format."
 
 // Indexes of table columns
 #define TITRAQ_IDXALLCTRLS     -1


ossp-pkg/as/as-gui/as_dataop.cpp 1.38 -> 1.39

--- as_dataop.cpp        2003/01/30 18:23:00     1.38
+++ as_dataop.cpp        2003/01/30 20:26:03     1.39
@@ -32,6 +32,7 @@
 // Qt general headers
 #include <qregexp.h>            // Portable regular expressions
 #include <qdatetime.h>
+#include <qmessagebox.h>
 
 // User interface
 #include "as_gui.h"             // Main classes
@@ -149,6 +150,40 @@
     while (Line.isEmpty() && !Tstream.atEnd()) {
         Tstream.skipWhiteSpace();       // Strip and get
         Line = Tstream.readLine();      // the new line
+        if (Line.at(0) == QChar('#'))   // Remove comments
+            Line = QString("");
+    }
+
+    // Ensure that the right data version pattern precedes the data
+    QString Datapattern = QString(TITRAQ_DATAPATTERN);
+    if (!Line.startsWith(Datapattern)) { // Incompatible data format
+        QMessageBox Problema(TITRAQ_APPTITLE,
+            TITRAQ_NOPATTERNFOUND + QString(TITRAQ_DATAPATTERN) + TITRAQ_WASNOTFOUNDIN,
+            QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Escape,
+            QMessageBox::NoButton, QMessageBox::NoButton);
+        Problema.exec(); // Give the user the bad news
+        throw Genexcept(TITRAQ_INVALIDDATA);
+    }
+    else if (Line.section(Datapattern, 1).section('.', 0, 0).toInt() != TITRAQ_DATAVERSIONMAJ) {
+        QMessageBox Problema(TITRAQ_APPTITLE, TITRAQ_BADVERSIONMAJ,
+            QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Escape,
+            QMessageBox::NoButton, QMessageBox::NoButton);
+        Problema.exec(); // Give the user the bad news
+        throw Genexcept(TITRAQ_INCOMPATDATA);
+    }
+    else if (Line.section(Datapattern, 1).section('.', 1, 1).toInt() > TITRAQ_DATAVERSIONMIN) {
+        QMessageBox Problema(TITRAQ_APPTITLE, TITRAQ_BADVERSIONMIN,
+            QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Escape,
+            QMessageBox::NoButton, QMessageBox::NoButton);
+        Problema.exec(); // Give the user the bad news
+        throw Genexcept(TITRAQ_INCOMPATDATA);
+    }
+
+    // Strip out extra line feeds after reading the data symbol
+    Line = QString("");                 // Reset our line
+    while (Line.isEmpty() && !Tstream.atEnd()) {
+        Tstream.skipWhiteSpace();       // Strip and get
+        Line = Tstream.readLine();      // the new line
         if (Line.at(0) == QChar('#'))   // Remove comments
             Line = QString("");
     }


ossp-pkg/as/as-gui/as_slot.cpp 1.94 -> 1.95

--- as_slot.cpp  2003/01/30 18:14:51     1.94
+++ as_slot.cpp  2003/01/30 20:26:03     1.95
@@ -340,6 +340,7 @@
                 }
                 catch (Genexcept& Genex) {
                     Genex.reportErr();
+                    return;
                 }
                 break;
             case 1: // Don't save first but do load
@@ -350,6 +351,7 @@
                 }
                 catch (Genexcept& Genex) {
                     Genex.reportErr();
+                    return;
                 }
                 break;
             case 2: // Don't do a load timesheet
@@ -365,6 +367,7 @@
             }
             catch (Genexcept& Genex) {
                 Genex.reportErr();
+                return;
             }
         }
 

CVSTrac 2.0.1