1 // |
1 // |
2 // OSSP asgui - Accounting system graphical user interface |
2 // OSSP asgui - Accounting system graphical user interface |
3 // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) |
3 // Copyright (c) 2002-2008 The OSSP Project (http://www.ossp.org/) |
4 // Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com> |
4 // Copyright (c) 2002-2008 Ralf S. Engelschall <rse@engelschall.com> |
5 // Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com> |
5 // Copyright (c) 2002-2008 Michael Schloh von Bennewitz <michael@schloh.com> |
6 // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH |
6 // Copyright (c) 2002-2008 Cable & Wireless Telecommunications Services GmbH |
7 // |
7 // |
8 // This file is part of OSSP asgui, an accounting system graphical user |
8 // This file is part of OSSP asgui, an accounting system graphical user |
9 // interface which can be found at http://www.ossp.org/pkg/tool/asgui/. |
9 // interface which can be found at http://asgui.europalab.com/. |
10 // |
10 // |
11 // Permission to use, copy, modify, and distribute this software for |
11 // Permission to use, copy, modify, and distribute this software for |
12 // any purpose with or without fee is hereby granted, provided that |
12 // any purpose with or without fee is hereby granted, provided that |
13 // the above copyright notice and this permission notice appear in all |
13 // the above copyright notice and this permission notice appear in all |
14 // copies. |
14 // copies. |
59 // |
63 // |
60 void Titraqform::loadAccounts(QFile &Fileobj) |
64 void Titraqform::loadAccounts(QFile &Fileobj) |
61 { |
65 { |
62 if (Fileobj.isOpen()) { // Check state of file |
66 if (Fileobj.isOpen()) { // Check state of file |
63 Fileobj.flush(); // Begin processing file cleanly |
67 Fileobj.flush(); // Begin processing file cleanly |
64 QTextStream Account(&Fileobj); // Convert data to stream |
68 Q3TextStream Account(&Fileobj); // Convert data to stream |
65 this->loadAccounts(Account); // Pass off to do the real work |
69 this->loadAccounts(Account); // Pass off to do the real work |
66 } |
70 } |
67 else { |
71 else { |
68 if (!Fileobj.open(IO_ReadOnly)) { // Try to open file |
72 if (!Fileobj.open(QIODevice::ReadOnly)) { // Try to open file |
69 QString Readerrstr; |
73 QString Readerrstr; |
70 Readerrstr = trUtf8(TITRAQ_READAFILFAIL).arg(Fileobj.name()); |
74 Readerrstr = trUtf8(TITRAQ_READAFILFAIL).arg(Fileobj.name()); |
71 throw Genexcept(Readerrstr.ascii()); |
75 throw Genexcept(Readerrstr.ascii()); |
72 } |
76 } |
73 else |
77 else |
74 Fileobj.flush(); // Begin processing file cleanly |
78 Fileobj.flush(); // Begin processing file cleanly |
75 QTextStream Account(&Fileobj); // Convert data to stream |
79 Q3TextStream Account(&Fileobj); // Convert data to stream |
76 this->loadAccounts(Account); // Pass off to do the real work |
80 this->loadAccounts(Account); // Pass off to do the real work |
77 Fileobj.close(); // Finish fileop by closing |
81 Fileobj.close(); // Finish fileop by closing |
78 } |
82 } |
79 } |
83 } |
80 |
84 |
81 // |
85 // |
82 // Load accounts themselves data from a stream |
86 // Load accounts themselves data from a stream |
83 // |
87 // |
84 void Titraqform::loadAccounts(QTextStream &Tstream) |
88 void Titraqform::loadAccounts(Q3TextStream &Tstream) |
85 { |
89 { |
86 using namespace std; // Needed for hash tables with hmap |
90 using namespace std; // Needed for hash tables with hmap |
87 map<string, int> Hashnames; // Hashtable for storing names |
91 map<string, int> Hashnames; // Hashtable for storing names |
88 map<int, string> Hashnums; // Hashtable for storing repetitions |
92 map<int, string> Hashnums; // Hashtable for storing repetitions |
89 map<string, int>::iterator Nameiter; // The hashtable name iterator |
93 map<string, int>::iterator Nameiter; // The hashtable name iterator |
107 |
111 |
108 // Set the accounts choices by linewise reading from the input |
112 // Set the accounts choices by linewise reading from the input |
109 // stream and parsing the corresponding account fields out of it |
113 // stream and parsing the corresponding account fields out of it |
110 while (!Line.isEmpty()) { |
114 while (!Line.isEmpty()) { |
111 QString Temp; // For reading from stream |
115 QString Temp; // For reading from stream |
112 QTextStream Asline(&Line, IO_ReadOnly); // Convert a single line |
116 Q3TextStream Asline(&Line, QIODevice::ReadOnly); // Convert a single line |
113 |
117 |
114 Asline.skipWhiteSpace(); // Remove whitespaces |
118 Asline.skipWhiteSpace(); // Remove whitespaces |
115 Asline >> Temp; // Copy revision indicator |
119 Asline >> Temp; // Copy revision indicator |
116 |
120 |
117 if (Temp == QString(QChar('R'))) { // Copy the account field |
121 if (Temp == QString(QChar('R'))) { // Copy the account field |
118 Asline >> Temp; // to temporary for transfer |
122 Asline >> Temp; // to temporary for transfer |
119 string Convstring = Temp; // Convert to string (can't cast?) |
123 string Convstring = Temp.toStdString(); // Convert to string (can't cast?) |
120 Hashnames[Convstring] += Hashnames[Convstring]; |
124 Hashnames[Convstring] += Hashnames[Convstring]; |
121 } |
125 } |
122 |
126 |
123 Line = QString(""); // Clear line for next round |
127 Line = QString(""); // Clear line for next round |
124 while (Line.isEmpty() && !Tstream.atEnd()) { |
128 while (Line.isEmpty() && !Tstream.atEnd()) { |
136 // FIXME: Put this in loadData, to load custom and most used task names before |
140 // FIXME: Put this in loadData, to load custom and most used task names before |
137 // FIXME: default listings are sorted and inserted |
141 // FIXME: default listings are sorted and inserted |
138 for (Numiter = Hashnums.begin(); Numiter != Hashnums.end(); Numiter++) { |
142 for (Numiter = Hashnums.begin(); Numiter != Hashnums.end(); Numiter++) { |
139 |
143 |
140 // Count the number of lines of sorted task names |
144 // Count the number of lines of sorted task names |
141 int nNumlines = QString(Numiter->second).contains('\n'); |
145 int nNumlines = QString::fromStdString(Numiter->second).count('\n'); |
142 |
146 |
143 // Iterate through the lines of task names, feeding them into the menu |
147 // Iterate through the lines of task names, feeding them into the menu |
144 for (int nIter = 0; nIter < nNumlines; nIter++) |
148 for (int nIter = 0; nIter < nNumlines; nIter++) |
145 *m_pTaskentries << QString(Numiter->second).section('\n', nIter, nIter); |
149 *m_pTaskentries << QString::fromStdString(Numiter->second).section('\n', nIter, nIter); |
146 } |
150 } |
147 } |
151 } |
148 |
152 |
149 // |
153 // |
150 // Convenience method to load personal data from a file |
154 // Convenience method to load personal data from a file |
151 // |
155 // |
152 void Titraqform::loadData(QFile &Fileobj) |
156 void Titraqform::loadData(QFile &Fileobj) |
153 { |
157 { |
154 if (Fileobj.isOpen()) { // Check state of file |
158 if (Fileobj.isOpen()) { // Check state of file |
155 Fileobj.flush(); // Begin processing file cleanly |
159 Fileobj.flush(); // Begin processing file cleanly |
156 QTextStream Asentry(&Fileobj); // Convert data to stream |
160 Q3TextStream Asentry(&Fileobj); // Convert data to stream |
157 this->loadData(Asentry); // Pass off to do the real work |
161 this->loadData(Asentry); // Pass off to do the real work |
158 } |
162 } |
159 else { |
163 else { |
160 if (!Fileobj.open(IO_ReadOnly)) // Try to open file |
164 if (!Fileobj.open(QIODevice::ReadOnly)) // Try to open file |
161 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL)); |
165 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL)); |
162 else |
166 else |
163 Fileobj.flush(); // Begin processing file cleanly |
167 Fileobj.flush(); // Begin processing file cleanly |
164 QTextStream Asentry(&Fileobj); // Convert data to stream |
168 Q3TextStream Asentry(&Fileobj); // Convert data to stream |
165 this->loadData(Asentry); // Pass off to do the real work |
169 this->loadData(Asentry); // Pass off to do the real work |
166 Fileobj.close(); // Finish fileop by closing |
170 Fileobj.close(); // Finish fileop by closing |
167 } |
171 } |
168 } |
172 } |
169 |
173 |
170 // |
174 // |
171 // Load personal data from a stream |
175 // Load personal data from a stream |
172 // |
176 // |
173 void Titraqform::loadData(QTextStream &Tstream) |
177 void Titraqform::loadData(Q3TextStream &Tstream) |
174 { |
178 { |
175 bool bValid = true; // Used to warn on globally invalid accounting data |
179 bool bValid = true; // Used to warn on globally invalid accounting data |
176 int nIter = 0; // Iterator used in loop and also as a count |
180 int nIter = 0; // Iterator used in loop and also as a count |
177 QString Line; // Used for linewise editing and whitespace eating |
181 QString Line; // Used for linewise editing and whitespace eating |
178 QString Bitbucket; // Used for null device until we find a better way |
182 QString Bitbucket; // Used for null device until we find a better way |
209 // and parsing date, time, account, and other columns out of it |
213 // and parsing date, time, account, and other columns out of it |
210 while (!Line.isEmpty()) { |
214 while (!Line.isEmpty()) { |
211 bool bValid = true; // Warns on linewise invalid accounting data |
215 bool bValid = true; // Warns on linewise invalid accounting data |
212 QString User, Guid, Crc, Rev; // Valid admin fields |
216 QString User, Guid, Crc, Rev; // Valid admin fields |
213 QString Date, Start, Finish, Account, Amount, Remark; // Valid user fields |
217 QString Date, Start, Finish, Account, Amount, Remark; // Valid user fields |
214 QTextStream Asline(&Line, IO_ReadOnly); // Convert a single line now |
218 Q3TextStream Asline(&Line, QIODevice::ReadOnly); // Convert a single line now |
215 |
219 |
216 if (nIter % g_knBlocks == 0) // Add blocks of rows to optimize loading |
220 if (nIter % g_knBlocks == 0) // Add blocks of rows to optimize loading |
217 m_pMaintable->setNumRows(m_pMaintable->numRows() + g_knBlocks); |
221 m_pMaintable->setNumRows(m_pMaintable->numRows() + g_knBlocks); |
218 |
222 |
219 Asline.skipWhiteSpace(); // Remove whitespaces |
223 Asline.skipWhiteSpace(); // Remove whitespaces |
267 bValid = false; |
271 bValid = false; |
268 |
272 |
269 Asline.skipWhiteSpace(); // Remove whitespaces |
273 Asline.skipWhiteSpace(); // Remove whitespaces |
270 Asline >> Account; // Copy the account field |
274 Asline >> Account; // Copy the account field |
271 if (!Account.isEmpty()) { |
275 if (!Account.isEmpty()) { |
272 QTableItem *pOld = m_pMaintable->item(nIter, TITRAQ_IDXTASK); |
276 Q3TableItem *pOld = m_pMaintable->item(nIter, TITRAQ_IDXTASK); |
273 delete(pOld); // Get rid of the old before going with the new |
277 delete(pOld); // Get rid of the old before going with the new |
274 RtTableItem *pSwapitem = new RtTableItem(m_pMaintable, QTableItem::WhenCurrent, Account); |
278 RtTableItem *pSwapitem = new RtTableItem(m_pMaintable, Q3TableItem::WhenCurrent, Account); |
275 pSwapitem->setAlignment(AlignLeft | AlignVCenter); |
279 pSwapitem->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); |
276 m_pMaintable->setItem(nIter, TITRAQ_IDXTASK, pSwapitem); |
280 m_pMaintable->setItem(nIter, TITRAQ_IDXTASK, pSwapitem); |
277 } |
281 } |
278 else |
282 else |
279 bValid = false; |
283 bValid = false; |
280 |
284 |
362 // |
366 // |
363 void Titraqform::saveData(QFile &Fileobj) |
367 void Titraqform::saveData(QFile &Fileobj) |
364 { |
368 { |
365 if (Fileobj.isOpen()) { // Check state of file |
369 if (Fileobj.isOpen()) { // Check state of file |
366 Fileobj.flush(); // Begin processing file cleanly |
370 Fileobj.flush(); // Begin processing file cleanly |
367 QTextStream Asentry(&Fileobj); // Convert data to stream |
371 Q3TextStream Asentry(&Fileobj); // Convert data to stream |
368 this->saveData(Asentry); // Pass off to do the real work |
372 this->saveData(Asentry); // Pass off to do the real work |
369 } |
373 } |
370 else { |
374 else { |
371 if (!Fileobj.open(IO_WriteOnly)) // Try to open file |
375 if (!Fileobj.open(QIODevice::WriteOnly)) // Try to open file |
372 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL)); |
376 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL)); |
373 QTextStream Asentry(&Fileobj); // Convert data to stream |
377 Q3TextStream Asentry(&Fileobj); // Convert data to stream |
374 this->saveData(Asentry); // Pass off to do the real work |
378 this->saveData(Asentry); // Pass off to do the real work |
375 Fileobj.close(); // Finish fileop by closing |
379 Fileobj.close(); // Finish fileop by closing |
376 } |
380 } |
377 } |
381 } |
378 |
382 |
379 // |
383 // |
380 // Save accounting data to a stream |
384 // Save accounting data to a stream |
381 // |
385 // |
382 void Titraqform::saveData(QTextStream &Tstream) |
386 void Titraqform::saveData(Q3TextStream &Tstream) |
383 { |
387 { |
384 const int nRows = m_pMaintable->numRows(); // Max rows used in loop |
388 const int nRows = m_pMaintable->numRows(); // Max rows used in loop |
385 QString Tempfield; // Current field string |
389 QString Tempfield; // Current field string |
386 QString Strsearch; // String to strip search |
390 QString Strsearch; // String to strip search |
387 QRegExp Stripper("\\s*$"); // Pattern to strip off |
391 QRegExp Stripper("\\s*$"); // Pattern to strip off |
391 << QChar('.') << TITRAQ_DATAVERSIONMIN << endl; |
395 << QChar('.') << TITRAQ_DATAVERSIONMIN << endl; |
392 |
396 |
393 // Linewise save from the main table date, time, account, and others |
397 // Linewise save from the main table date, time, account, and others |
394 for (int nIter = 0; nIter < nRows; nIter++) { |
398 for (int nIter = 0; nIter < nRows; nIter++) { |
395 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXUSER); // Load user field text |
399 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXUSER); // Load user field text |
396 if (Tempfield != NULL) |
400 if (Tempfield.isNull()) |
397 Tstream << Tempfield; // Save user field text |
401 Tstream << Tempfield; // Save user field text |
398 |
402 |
399 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXGUID); // Load GUID field text |
403 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXGUID); // Load GUID field text |
400 if (Tempfield != NULL) |
404 if (Tempfield.isNull()) |
401 Tstream << trUtf8(" ") << Tempfield; // Save GUID field text |
405 Tstream << trUtf8(" ") << Tempfield; // Save GUID field text |
402 |
406 |
403 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXCRC); // Load CRC field text |
407 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXCRC); // Load CRC field text |
404 Tempfield.remove("0x"); |
408 Tempfield.remove("0x"); |
405 if (Tempfield != NULL) |
409 if (Tempfield.isNull()) |
406 Tstream << trUtf8(" ") << Tempfield; // Save CRC field text |
410 Tstream << trUtf8(" ") << Tempfield; // Save CRC field text |
407 |
411 |
408 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXREV); // Load rev field text |
412 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXREV); // Load rev field text |
409 if (Tempfield != NULL) |
413 if (Tempfield.isNull()) |
410 Tstream << trUtf8(" ") << Tempfield; // Save rev field text |
414 Tstream << trUtf8(" ") << Tempfield; // Save rev field text |
411 |
415 |
412 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXDATE); // Load date field text |
416 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXDATE); // Load date field text |
413 if (Tempfield != NULL) |
417 if (Tempfield.isNull()) |
414 Tstream << trUtf8(" ") << Tempfield; // Save date field text |
418 Tstream << trUtf8(" ") << Tempfield; // Save date field text |
415 |
419 |
416 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXSTART); // Load start field text |
420 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXSTART); // Load start field text |
417 if (Tempfield != NULL) |
421 if (Tempfield.isNull()) |
418 Tstream << trUtf8(" ") << Tempfield; // Save start field text |
422 Tstream << trUtf8(" ") << Tempfield; // Save start field text |
419 |
423 |
420 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXFINISH); // Load end field text |
424 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXFINISH); // Load end field text |
421 if (Tempfield != NULL) |
425 if (Tempfield.isNull()) |
422 Tstream << trUtf8(" ") << Tempfield; // Save end field text |
426 Tstream << trUtf8(" ") << Tempfield; // Save end field text |
423 |
427 |
424 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXAMOUNT); // Load amount field text |
428 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXAMOUNT); // Load amount field text |
425 if (Tempfield != NULL) |
429 if (Tempfield.isNull()) |
426 Tstream << trUtf8(" ") << Tempfield; // Save amount |
430 Tstream << trUtf8(" ") << Tempfield; // Save amount |
427 |
431 |
428 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXTASK); // Load acct field text |
432 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXTASK); // Load acct field text |
429 if (Tempfield != NULL) |
433 if (Tempfield.isNull()) |
430 Tstream << trUtf8(" ") << Tempfield; // Save acct field text |
434 Tstream << trUtf8(" ") << Tempfield; // Save acct field text |
431 |
435 |
432 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXREMARK); // Load remark field text |
436 Tempfield = m_pMaintable->text(nIter, TITRAQ_IDXREMARK); // Load remark field text |
433 Tstream << trUtf8(" \""); // Save beginning double quote |
437 Tstream << trUtf8(" \""); // Save beginning double quote |
434 if (Tempfield != NULL) { |
438 if (Tempfield.isNull()) { |
435 Strsearch = QRegExp::escape(Tempfield); // Incoming string escaped |
439 Strsearch = QRegExp::escape(Tempfield); // Incoming string escaped |
436 Stripper.search(Strsearch); |
440 Stripper.search(Strsearch); |
437 Tempfield.truncate(Stripper.pos()); // Cut off whitespace |
441 Tempfield.truncate(Stripper.pos()); // Cut off whitespace |
438 Tempfield.replace(QChar('\\'), QString("\\\\")); // Escape back slashes |
442 Tempfield.replace(QChar('\\'), QString("\\\\")); // Escape back slashes |
439 Tempfield.replace(QChar('\"'), QString("\\\"")); // Escape double quotes |
443 Tempfield.replace(QChar('\"'), QString("\\\"")); // Escape double quotes |
449 // Convenience method to validate AS data in a file |
453 // Convenience method to validate AS data in a file |
450 // |
454 // |
451 const bool Titraqform::validateData(QFile &Filin) const |
455 const bool Titraqform::validateData(QFile &Filin) const |
452 { |
456 { |
453 QString Firstline; // Will contain the first line of text |
457 QString Firstline; // Will contain the first line of text |
|
458 char *pReadline; // Contains the read line of text file |
454 bool bRet = false; // Set the initial return value |
459 bool bRet = false; // Set the initial return value |
455 |
460 |
456 if (Filin.isOpen()) { // Check open state of file |
461 if (Filin.isOpen()) { // Check open state of file |
457 Filin.flush(); // Not sure if this is needed |
462 Filin.flush(); // Not sure if this is needed |
458 Filin.reset(); // Set the file index position to 0 |
463 Filin.reset(); // Set the file index position to 0 |
459 Filin.readLine(Firstline, QString(TITRAQ_DATAPATTERN).length() + 2L); |
464 Filin.readLine(pReadline, QString(TITRAQ_DATAPATTERN).length() + 2L); |
460 } |
465 } |
461 else { |
466 else { |
462 if (!Filin.open(IO_ReadOnly)) // Try to open file |
467 if (!Filin.open(QIODevice::ReadOnly)) // Try to open file |
463 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL)); |
468 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL)); |
464 else { // File is now open |
469 else { // File is now open |
465 Filin.readLine(Firstline, QString(TITRAQ_DATAPATTERN).length() + 2L); |
470 Filin.readLine(pReadline, QString(TITRAQ_DATAPATTERN).length() + 2L); |
466 Filin.close(); // Remember to close |
471 Filin.close(); // Remember to close |
467 } |
472 } |
468 } |
473 } |
469 |
474 |
470 try { // Pass off to worker method |
475 try { // Pass off to worker method |
|
476 Firstline = QString::fromAscii(pReadline); |
471 bRet = this->validateData(Firstline); |
477 bRet = this->validateData(Firstline); |
472 } |
478 } |
473 catch (Genexcept &) { |
479 catch (Genexcept &) { |
474 throw; // Rethrow onwards |
480 throw; // Rethrow onwards |
475 } |
481 } |
487 QString Datapattern = QString(TITRAQ_DATAPATTERN); |
493 QString Datapattern = QString(TITRAQ_DATAPATTERN); |
488 if (!Linin.startsWith(Datapattern)) { // Incompatible data format |
494 if (!Linin.startsWith(Datapattern)) { // Incompatible data format |
489 QMessageBox Problema(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short, |
495 QMessageBox Problema(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short, |
490 TITRAQ_NOPATTERNFOUND + QString(TITRAQ_DATAPATTERN) + TITRAQ_WASNOTFOUNDIN, |
496 TITRAQ_NOPATTERNFOUND + QString(TITRAQ_DATAPATTERN) + TITRAQ_WASNOTFOUNDIN, |
491 QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Escape, |
497 QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Escape, |
492 QMessageBox::NoButton, QMessageBox::NoButton); |
498 Qt::NoButton, Qt::NoButton); |
493 Problema.exec(); // Give the user the bad news |
499 Problema.exec(); // Give the user the bad news |
494 throw Genexcept(TITRAQ_INVALIDDATA); |
500 throw Genexcept(TITRAQ_INVALIDDATA); |
495 } |
501 } |
496 else if (Linin.section(Datapattern, 1).section('.', 0, 0).toInt() != TITRAQ_DATAVERSIONMAJ) { |
502 else if (Linin.section(Datapattern, 1).section('.', 0, 0).toInt() != TITRAQ_DATAVERSIONMAJ) { |
497 QMessageBox Problema(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short, |
503 QMessageBox Problema(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short, |
498 TITRAQ_BADVERSIONMAJ, QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Escape, |
504 TITRAQ_BADVERSIONMAJ, QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Escape, |
499 QMessageBox::NoButton, QMessageBox::NoButton); |
505 Qt::NoButton, Qt::NoButton); |
500 Problema.exec(); // Give the user the bad news |
506 Problema.exec(); // Give the user the bad news |
501 throw Genexcept(TITRAQ_INCOMPATDATA); |
507 throw Genexcept(TITRAQ_INCOMPATDATA); |
502 } |
508 } |
503 else if (Linin.section(Datapattern, 1).section('.', 1, 1).toInt() > TITRAQ_DATAVERSIONMIN) { |
509 else if (Linin.section(Datapattern, 1).section('.', 1, 1).toInt() > TITRAQ_DATAVERSIONMIN) { |
504 QMessageBox Problema(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short, |
510 QMessageBox Problema(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short, |
505 TITRAQ_BADVERSIONMIN, QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Escape, |
511 TITRAQ_BADVERSIONMIN, QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Escape, |
506 QMessageBox::NoButton, QMessageBox::NoButton); |
512 Qt::NoButton, Qt::NoButton); |
507 Problema.exec(); // Give the user the bad news |
513 Problema.exec(); // Give the user the bad news |
508 throw Genexcept(TITRAQ_INCOMPATDATA); |
514 throw Genexcept(TITRAQ_INCOMPATDATA); |
509 } |
515 } |
510 else |
516 else |
511 bRet = true; |
517 bRet = true; |
567 // |
573 // |
568 // Set a whole row of data |
574 // Set a whole row of data |
569 // |
575 // |
570 void Titraqform::setRowdata(QString &Rowdata) const |
576 void Titraqform::setRowdata(QString &Rowdata) const |
571 { |
577 { |
572 int nRows = Rowdata.contains(QChar('\n')); // Set so many rows |
578 int nRows = Rowdata.count(QChar('\n')); // Set so many rows |
573 int nCurrentrow = m_pMaintable->currentRow(); // Current table row |
579 int nCurrentrow = m_pMaintable->currentRow(); // Current table row |
574 QTableItem *pItem = NULL; // Old item to change out |
580 Q3TableItem *pItem = NULL; // Old item to change out |
575 QString Line, User, Guid, Crc, Rev; // Admin fields in table |
581 QString Line, User, Guid, Crc, Rev; // Admin fields in table |
576 QString Date, Start, Finish, Amount, Task, Remark; // Viewable fields in table |
582 QString Date, Start, Finish, Amount, Task, Remark; // Viewable fields in table |
577 QTextStream Datastream(&Rowdata, IO_ReadOnly); // Convert data to stream |
583 Q3TextStream Datastream(&Rowdata, QIODevice::ReadOnly); // Convert data to stream |
578 |
584 |
579 for (int nIter = 0; nIter < nRows; ++nIter) { |
585 for (int nIter = 0; nIter < nRows; ++nIter) { |
580 QString Singlerow = Datastream.readLine(); // For linewise operation |
586 QString Singlerow = Datastream.readLine(); // For linewise operation |
581 QTextStream Rowstream(&Singlerow, IO_ReadOnly); // Convert row to stream |
587 Q3TextStream Rowstream(&Singlerow, QIODevice::ReadOnly); // Convert row to stream |
582 |
588 |
583 Rowstream >> Line >> User >> Guid >> Crc >> Rev; // Stream data fields |
589 Rowstream >> Line >> User >> Guid >> Crc >> Rev; // Stream data fields |
584 Rowstream >> Date >> Start >> Finish >> Amount >> Task; // to corresponding vars |
590 Rowstream >> Date >> Start >> Finish >> Amount >> Task; // to corresponding vars |
585 Remark = Rowstream.readLine(); // Remark is a whole line |
591 Remark = Rowstream.readLine(); // Remark is a whole line |
586 |
592 |
602 // pTask->setText(Task); |
608 // pTask->setText(Task); |
603 |
609 |
604 // Change out old item and replace with new task data |
610 // Change out old item and replace with new task data |
605 pItem = m_pMaintable->item(nCurrentrow + nIter, TITRAQ_IDXTASK); |
611 pItem = m_pMaintable->item(nCurrentrow + nIter, TITRAQ_IDXTASK); |
606 delete(pItem); // Get rid of the old before going with the new |
612 delete(pItem); // Get rid of the old before going with the new |
607 RtTableItem *pSwapitem = new RtTableItem(m_pMaintable, QTableItem::WhenCurrent, Task); |
613 RtTableItem *pSwapitem = new RtTableItem(m_pMaintable, Q3TableItem::WhenCurrent, Task); |
608 pSwapitem->setAlignment(AlignLeft | AlignVCenter); |
614 pSwapitem->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); |
609 m_pMaintable->setItem(nCurrentrow + nIter, TITRAQ_IDXTASK, pSwapitem); |
615 m_pMaintable->setItem(nCurrentrow + nIter, TITRAQ_IDXTASK, pSwapitem); |
610 |
616 |
611 // Continue with field processing business as usual |
617 // Continue with field processing business as usual |
612 m_pMaintable->setText(nCurrentrow + nIter, TITRAQ_IDXREMARK, Remark.simplifyWhiteSpace()); |
618 m_pMaintable->setText(nCurrentrow + nIter, TITRAQ_IDXREMARK, Remark.simplifyWhiteSpace()); |
613 } |
619 } |