Index: ossp-pkg/as/as-gui/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v rcsdiff -q -kk '-r1.14' '-r1.15' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/TODO RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v rcsdiff -q -kk '-r1.61' '-r1.62' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v' 2>/dev/null --- 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) --------------------- 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.34' '-r1.35' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_dataop.cpp,v' 2>/dev/null --- 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) 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.89' '-r1.90' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_slot.cpp,v' 2>/dev/null --- 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 #include #include +#include //#include // 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();