OSSP CVS Repository

ossp - Difference in ossp-pkg/as/as-gui/as_dataop.cpp versions 1.24 and 1.25
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/as/as-gui/as_dataop.cpp 1.24 -> 1.25

--- as_dataop.cpp        2002/12/16 10:45:25     1.24
+++ as_dataop.cpp        2002/12/16 12:11:40     1.25
@@ -45,7 +45,73 @@
 #include <iostream>
 
 //
-// Convenience method to load accounting data from a file
+// Convenience method to load accounts from a file
+//
+void Titraqform::loadAccounts(QFile &Fileobj)
+{
+    if (Fileobj.isOpen()) {             // Check state of file
+        Fileobj.flush();                // Begin processing file cleanly
+        QTextStream Account(&Fileobj);  // Convert data to stream
+        this->loadAccounts(Account);    // Pass off to do the real work
+    }
+    else {
+        if (!Fileobj.open(IO_ReadOnly)) // Try to open file
+            throw Genexcept("Could not open account file.");
+        else
+            Fileobj.flush();                // Begin processing file cleanly
+            QTextStream Account(&Fileobj);  // Convert data to stream
+            this->loadAccounts(Account);    // Pass off to do the real work
+            Fileobj.close();                // Finish fileop by closing
+    }
+}
+
+//
+// Load accounts themselves data from a stream
+//
+void Titraqform::loadAccounts(QTextStream &Tstream)
+{
+    QString Line; // Used for linewise editing and whitespace eating
+
+    // Eat lines until reading the start accounts token
+    while (!Line.startsWith(trUtf8("%!AS-ACCOUNTS")) && !Tstream.atEnd()) {
+        Line = trUtf8(""); // Empty line for later inspection
+        Line = Tstream.readLine(); // Get a new line to examine
+    }
+
+    // Strip out extra line feeds in stream
+    while (Line.isEmpty() && !Tstream.atEnd()) {
+        Tstream.skipWhiteSpace();       // Strip and get
+        Line = Tstream.readLine();      // the new line
+        if (Line.at(0) == QChar('#'))   // Remove comments
+            Line = trUtf8("");
+    }
+
+    // Set the accounts choices by linewise reading from the input
+    // stream and parsing the corresponding account fields out of it
+    while (!Line.isEmpty()) {
+        QString Temp;                           // For reading from stream
+        QTextStream Asline(&Line, IO_ReadOnly); // Convert a single line
+
+        Asline.skipWhiteSpace();            // Remove whitespaces
+        Asline >> Temp;                     // Copy revision indicator
+
+        if (Temp == QString(QChar('R'))) {  // Copy the account field
+            Asline >> Temp;                 // to temporary for transfer
+            *m_pTaskentries << Temp;        // to internal account bank
+        }
+
+        Line = trUtf8(""); // Clear line for next round
+        while (Line.isEmpty() && !Tstream.atEnd()) {
+            Tstream.skipWhiteSpace();       // Strip and get
+            Line = Tstream.readLine();      // the new line
+            if (Line.at(0) == QChar('#'))   // Remove comments
+                Line = trUtf8("");
+        }
+    }
+}
+
+//
+// Convenience method to load personal data from a file
 //
 void Titraqform::loadData(QFile &Fileobj)
 {
@@ -56,15 +122,17 @@
     }
     else {
         if (!Fileobj.open(IO_ReadOnly)) // Try to open file
-            throw Genexcept("Could not read open accounting file.");
-        QTextStream Asentry(&Fileobj);  // Convert data to stream
-        this->loadData(Asentry);        // Pass off to do the real work
-        Fileobj.close();                // Finish fileop by closing
+            throw Genexcept("Could not open personal data file.");
+        else
+            Fileobj.flush();                // Begin processing file cleanly
+            QTextStream Asentry(&Fileobj);  // Convert data to stream
+            this->loadData(Asentry);        // Pass off to do the real work
+            Fileobj.close();                // Finish fileop by closing
     }
 }
 
 //
-// Load accounting data from a stream
+// Load personal data from a stream
 //
 void Titraqform::loadData(QTextStream &Tstream)
 {
@@ -78,8 +146,12 @@
     QPixmap Staterror(s_kpcStaterror_xpm);
 
     // Strip out extra line feeds at stream start
-    while (Line.isEmpty() && !Tstream.atEnd())
-        Line = Tstream.readLine();
+    while (Line.isEmpty() && !Tstream.atEnd()) {
+        Tstream.skipWhiteSpace();       // Strip and get
+        Line = Tstream.readLine();      // the new line
+        if (Line.at(0) == QChar('#'))   // Remove comments
+            Line = trUtf8("");
+    }
 
     // Optimize viewing by repainting cells only once after processing
     m_pMaintable->setUpdatesEnabled(false);

CVSTrac 2.0.1