Index: ossp-pkg/as/as-gui/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v rcsdiff -q -kk '-r1.20' '-r1.21' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/TODO RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v rcsdiff -q -kk '-r1.66' '-r1.67' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v' 2>/dev/null --- 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 ------------ Index: ossp-pkg/as/as-gui/as_const.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_const.h,v rcsdiff -q -kk '-r1.40' '-r1.41' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_const.h,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/as_dataop.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_dataop.cpp,v rcsdiff -q -kk '-r1.38' '-r1.39' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_dataop.cpp,v' 2>/dev/null --- 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 // Portable regular expressions #include +#include // 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(""); } Index: ossp-pkg/as/as-gui/as_slot.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_slot.cpp,v rcsdiff -q -kk '-r1.94' '-r1.95' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_slot.cpp,v' 2>/dev/null --- 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; } }