OSSP CVS Repository

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

Check-in Number: 3954
Date: 2003-Jan-27 18:56:56 (local)
2003-Jan-27 17:56:56 (UTC)
User:ms
Branch:
Comment: Break the orthogonal data format and include new token separators '-' and '='. Also, add automatic file backup code back in again.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/ChangeLog      1.14 -> 1.15     2 inserted, 0 deleted
ossp-pkg/as/as-gui/TODO      1.61 -> 1.62     1 inserted, 0 deleted
ossp-pkg/as/as-gui/as_dataop.cpp      1.34 -> 1.35     17 inserted, 10 deleted
ossp-pkg/as/as-gui/as_slot.cpp      1.89 -> 1.90     21 inserted, 3 deleted

ossp-pkg/as/as-gui/ChangeLog 1.14 -> 1.15

--- ChangeLog    2003/01/27 14:43:44     1.14
+++ ChangeLog    2003/01/27 17:56:56     1.15
@@ -3,8 +3,10 @@
 030127 Changed date and time from ISO format to AS specific
        Added logic to dim and undim icons on (non)empty documents
        Improved intuitiveness of a newDoc operation by appending a default row
+       Implemented automatic file backups using a very primitive algorhythm
        Fixed subtle unintentional split else codeblock in slot saveAs
        Added automatic appending of AS event file extension to new docs
+       Added '-' and '=' as arbitrary data token separators between times
 
 030124 Added CRC and basic revision management logic
        Removed sort on load to allow easier file diffs


ossp-pkg/as/as-gui/TODO 1.61 -> 1.62

--- TODO 2003/01/24 16:32:18     1.61
+++ TODO 2003/01/27 17:56:56     1.62
@@ -28,6 +28,7 @@
 After every result write a status bar message
 On multiple selection, no text should appear in edit ctrls
 Make consistent setEdition(), setDirty() default parameters
+Solve problem with nonorthogonal ' ' '-' '=' data token separators
 
 Bugs (? = unverified)
 ---------------------


ossp-pkg/as/as-gui/as_dataop.cpp 1.34 -> 1.35

--- as_dataop.cpp        2003/01/27 12:39:19     1.34
+++ as_dataop.cpp        2003/01/27 17:56:56     1.35
@@ -138,6 +138,7 @@
     bool bValid = true; // Used to warn on globally invalid accounting data
     int nIter = 0;      // Iterator used in loop and also as a count
     QString Line;       // Used for linewise editing and whitespace eating
+    QString Parstring;  // Used to parse all extra '-' and '=' token delimiters
     QString Bitbucket;  // Used for null device until we find a better way
 
     QPixmap Statokay(s_kpcStatokay_xpm);
@@ -165,6 +166,7 @@
         bool bValid = true; // Warns on linewise invalid accounting data
         QString User, Guid, Crc, Rev;                           // Valid admin fields
         QString Date, Start, Finish, Account, Amount, Remark;   // Valid user fields
+        QString Timepack;                       // Packed start finish amount field
         QTextStream Asline(&Line, IO_ReadOnly); // Convert a single line now
 
         if (nIter % g_knBlocks == 0) // Add blocks of rows to optimize loading
@@ -209,26 +211,29 @@
             bValid = false;
 
         Asline.skipWhiteSpace();    // Remove whitespaces
-        Asline >> Start;            // Copy the start field
-        if (!Start.isEmpty()) {
+        Asline >> Timepack;
+
+        // Hack to hard code regex parsing logic into the document format
+        Start = Timepack.section('-', 0, 0, QString::SectionDefault);
+        Finish = Timepack.section('-', 1, 1, QString::SectionDefault);
+        Finish = Finish.section('=', 0, 0, QString::SectionDefault);
+        Amount = Timepack.section('=', 1, 1, QString::SectionDefault);
+
+        if (!Start.isEmpty()) {                             // Write start
             Start.insert(TITRAQ_OFFSETHOUR, QChar(':'));    // Format hour
             m_pMaintable->setText(nIter, TITRAQ_IDXSTART, Start);
         }
         else
             bValid = false;
 
-        Asline.skipWhiteSpace();    // Remove whitespaces
-        Asline >> Finish;           // Copy the finish field
-        if (!Start.isEmpty()) {
+        if (!Finish.isEmpty()) {                            // Write finish
             Finish.insert(TITRAQ_OFFSETHOUR, QChar(':'));   // Format hour
             m_pMaintable->setText(nIter, TITRAQ_IDXFINISH, Finish);
         }
         else
             bValid = false;
 
-        Asline.skipWhiteSpace();    // Remove whitespaces
-        Asline >> Amount;           // Copy the amount field
-        if (!Amount.isEmpty()) {
+        if (!Amount.isEmpty()) {                            // Write amount
             Amount.insert(TITRAQ_OFFSETHOUR, QChar(':'));   // Format hour
             m_pMaintable->setText(nIter, TITRAQ_IDXAMOUNT, Amount);
         }
@@ -353,16 +358,18 @@
         Tempfield.remove(QChar(':'));
         if (Tempfield != NULL)
             Tstream << trUtf8(" ") << Tempfield;                    // Save start field text
+        Tstream << trUtf8("-");                                     // Save start field text
 
         Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXFINISH);    // Load end field text
         Tempfield.remove(QChar(':'));
         if (Tempfield != NULL)
-            Tstream << trUtf8(" ") << Tempfield;                    // Save end field text
+            Tstream << Tempfield;                                   // Save end field text
+        Tstream << trUtf8("=");                                     // Save start field text
 
         Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXAMOUNT);    // Load amount field text
         Tempfield.remove(QChar(':'));
         if (Tempfield != NULL)
-            Tstream << trUtf8(" ") << Tempfield;                    // Save amount field text
+            Tstream << Tempfield;                                   // Save amount field text
 
         Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXTASK);      // Load acct field text
         if (Tempfield != NULL)


ossp-pkg/as/as-gui/as_slot.cpp 1.89 -> 1.90

--- as_slot.cpp  2003/01/27 14:43:44     1.89
+++ as_slot.cpp  2003/01/27 17:56:56     1.90
@@ -34,6 +34,7 @@
 #include <qcombobox.h>
 #include <qclipboard.h>
 #include <qmenudata.h>
+#include <qdatastream.h>
 //#include <qregexp.h>
 
 // User interface
@@ -384,16 +385,33 @@
 void Titraqform::saveFile(void)
 {
     QString Fname;
+    QFile Filevents, Filebak;
+    QTextStream Streamevents, Streambak;
+
     try {
         Fname = QString(*this->getFilename());
+
         // First time saves are really just saveAs in disguise
         if (Fname.isEmpty()) {
             this->saveAs();
             return;
         }
-        // Try to open a file for writing to
-        QFile Filetemp(Fname);
-        this->saveData(Filetemp); // Pass to helper method
+
+        Filevents.setName(Fname); // Construct a file to back up and write
+
+        // Make a backup before overwriting
+        if (Filevents.exists()) {
+            Filevents.open(IO_ReadOnly);
+            Filebak.setName(Fname + ".bak");
+            Filebak.open(IO_WriteOnly);
+            Streamevents.setDevice(&Filevents);
+            Streambak.setDevice(&Filebak);
+            Streambak << Streamevents.read();
+            Filevents.close();
+            Filebak.close();
+        }
+
+        this->saveData(Filevents); // Pass to helper method
     }
     catch (Genexcept& Genex) {
         Genex.reportErr();

CVSTrac 2.0.1