Index: ossp-pkg/as/as-gui/TODO RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v rcsdiff -q -kk '-r1.90' '-r1.91' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v' 2>/dev/null --- TODO 2003/02/20 16:48:00 1.90 +++ TODO 2003/02/21 23:44:36 1.91 @@ -41,6 +41,7 @@ For which purposes do messages go in each category? Label methods and parameters throughout as const ... const, use & Yank out all #include from headers, replace with class ...; protos +Check for empty amount field in getWeektotals before Hashtasks[Convstring] += Bugs (? = unverified) --------------------- Index: ossp-pkg/as/as-gui/as_reportpanel.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_reportpanel.cpp,v rcsdiff -q -kk '-r1.11' '-r1.12' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_reportpanel.cpp,v' 2>/dev/null --- as_reportpanel.cpp 2003/02/21 21:56:52 1.11 +++ as_reportpanel.cpp 2003/02/21 23:44:36 1.12 @@ -257,8 +257,9 @@ this->writeHeader(nLastweek); // Write new contents to data window - for (int nIter = 0; nIter < m_nWeeks; nIter++) - m_pBrowser->append(this->getWeek(QDate::currentDate().addDays(nIter * -7))); + m_pBrowser->append(this->getWeektotals(QDate::currentDate(), m_nWeeks)); + if (m_pReprefs->getBool(TITRAQ_PREFDETAILON, TITRAQ_DEFDETAILON)) + m_pBrowser->append(this->getWeekdetails(QDate::currentDate(), m_nWeeks)); this->writeFooter(); m_pBrowser->setCursorPosition(0, 0); m_pBrowser->ensureCursorVisible(); @@ -309,8 +310,10 @@ this->writeHeader(Lastmonth); // Write new contents to data window - for (int nIter = 0; nIter < m_nMonths; nIter++) - m_pBrowser->append(this->getMonth(QDate::currentDate().addMonths(nIter * -1))); + m_pBrowser->append(this->getMonthtotals(QDate::currentDate(), m_nMonths)); + if (m_pReprefs->getBool(TITRAQ_PREFDETAILON, TITRAQ_DEFDETAILON)) { + m_pBrowser->append(this->getMonthdetails(QDate::currentDate(), m_nMonths)); + } this->writeFooter(); m_pBrowser->setCursorPosition(0, 0); m_pBrowser->ensureCursorVisible(); @@ -326,15 +329,8 @@ // Set the button in case we arrived from a menu selection m_pWeekmonthgroup->setButton(TITRAQ_REPORTBOTH); - // Clear data window and write header out - m_pBrowser->setUpdatesEnabled(false); - m_pBrowser->clear(); - m_pBrowser->append(trUtf8("The 'both' feature is not working yet.")); - this->writeFooter(); - m_pBrowser->setCursorPosition(0, 0); - m_pBrowser->ensureCursorVisible(); - m_pBrowser->setUpdatesEnabled(true); - m_pBrowser->repaint(false); + // Placeholder text until we figure out what to do with this + m_pBrowser->setText(trUtf8("The 'both' feature is not working yet.")); } // @@ -354,8 +350,6 @@ Header += QTime::currentTime().toString(Qt::ISODate); Header += trUtf8("\nReporting for week %1...").arg(nWeeknum); Header += QString("\n\n"); - Header += QString("Date Hours Task\n"); - Header += QString("---------- ----- ----\n"); m_pBrowser->setText(Header); } @@ -376,8 +370,6 @@ Header += QTime::currentTime().toString(Qt::ISODate); Header += trUtf8("\nReporting for month %1...").arg(Month); Header += QString("\n\n"); - Header += QString("Date Hours Task\n"); - Header += QString("---------- ----- ----\n"); m_pBrowser->setText(Header); } @@ -398,8 +390,6 @@ Header += QTime::currentTime().toString(Qt::ISODate); Header += trUtf8("\nReporting for weeks %1 through %2...").arg(nFirst).arg(nLast); Header += QString("\n\n"); - Header += QString("Date Hours Task\n"); - Header += QString("---------- ----- ----\n"); m_pBrowser->setText(Header); } @@ -420,8 +410,6 @@ Header += QTime::currentTime().toString(Qt::ISODate); Header += trUtf8("\nReporting months %1 through %2...").arg(First).arg(Last); Header += QString("\n\n"); - Header += QString("Date Hours Task\n"); - Header += QString("---------- ----- ----\n"); m_pBrowser->setText(Header); } @@ -430,20 +418,33 @@ // void Reportpanel::writeFooter(void) { + if (m_pReprefs->getBool(TITRAQ_PREFSIGNATON, TITRAQ_DEFSIGNATON)) { + m_pBrowser->append(trUtf8("\n\nPrint name ________________________________________\n")); + m_pBrowser->append(trUtf8("\n\nSignature ________________________________________")); + } } // -// Writes one week of data to the display window +// Returns one week of details data // -QString Reportpanel::getWeek(QDate Dayref) +QString Reportpanel::getWeekdetails(QDate Dayref, int nWeeks) { QString Data, Tempstring; // Output string int nRows = m_pReptable->numRows(); int nIter = nRows - 1; int nFirstrow = 0; int nLastrow = 0; - QDate Firstday = Dayref.addDays(Dayref.dayOfWeek() * -1 + 1); // Do negate - QDate Lastday = Firstday.addDays(7); // Add week + + Q_ASSERT(nWeeks > 0); + QDate Firstday; + QDate Lastday; + Firstday = Dayref.addDays(Dayref.dayOfWeek() * -1 + 1); + Firstday = Firstday.addDays((nWeeks - 1) * -7); + Lastday = Firstday.addDays(7 * nWeeks); + + // Write some quick header text to the outgoing string + Data = trUtf8("\nDate Hours Account details\n"); + Data += QString("---------- ----- ----------------------------------------\n"); // Find data starting the week in question while (QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) >= Firstday) @@ -466,25 +467,103 @@ Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); if (!Tempstring.isEmpty()) Data += QString(TITRAQ_SEPARATORTOK) + Tempstring; - Data += trUtf8("\n"); // Finish off line + Data += QString("\n"); // Finish off line } return Data; } // -// Writes one month of data to the display window +// Returns one week of totals data +// +QString Reportpanel::getWeektotals(QDate Dayref, int nWeeks) +{ + using namespace std; // Needed for hash tables with hmap + map Hashtasks; // Hashtable for storing tasks + map Hashhours; // Hashtable for storing hours + map::iterator Taskiter; // The hashtable task iterator + map::iterator Houriter; // The hashtable hour iterator + + QString Totals; // Data totals to return for writing + QString Tempstring; // Temporary processing string + int nRows = m_pReptable->numRows(); + int nIter = nRows - 1; + int nFirstrow = 0; + int nLastrow = 0; + + Q_ASSERT(nWeeks > 0); + QDate Firstday; + QDate Lastday; + Firstday = Dayref.addDays(Dayref.dayOfWeek() * -1 + 1); + Firstday = Firstday.addDays((nWeeks - 1) * -7); + Lastday = Firstday.addDays(7 * nWeeks); + + // Find data starting the week in question + while (QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) >= Firstday) + nIter--; + nFirstrow = ++nIter; // The first row to operate on + + // Find data ending the week in question + while (nIter < nRows && QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) < Lastday) + nIter++; + nLastrow = nIter - 1; // The last row to operate on + + // Parse the table for interesting values + for (nIter = nLastrow; nIter >= nFirstrow; nIter--) { + Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); + if (!Tempstring.isEmpty()) { + string Convstring = Tempstring; // Convert to string (can't cast?) + QTime Intable = QTime::fromString(m_pReptable->text(nIter, TITRAQ_IDXAMOUNT), Qt::ISODate); + int nTothours = QString(Hashtasks[Convstring]).section(':', 0, 0).toInt() + Intable.hour(); + int nTotminut = QString(Hashtasks[Convstring]).section(':', 1, 1).toInt() + Intable.minute(); + nTothours += nTotminut / 60; + nTotminut %= 60; + QString Hours = QString::number(nTothours).rightJustify(3, ' '); + QString Mins = QString::number(nTotminut).rightJustify(2, '0'); + string Timestring = Hours + ':' + Mins; // Convert to string (can't cast?) + Hashtasks[Convstring] = Timestring; // Finally store in hashtable + } + } + + // Reverse copy the tasks hashtable to both sort and index by amount key + for (Taskiter = Hashtasks.begin(); Taskiter != Hashtasks.end(); Taskiter++) + Hashhours[Taskiter->second] = Taskiter->first; + + // Write the actual data totals to the outgoing string in reverse order + for (Houriter = Hashhours.begin(); Houriter != Hashhours.end(); Houriter++) + Totals = Houriter->first + ' ' + Houriter->second + '\n' + Totals; + + // Write some quick header text to the outgoing string in reverse order + Totals = QString("------ ----------------------------------------\n") + Totals; + Totals = trUtf8("Total Account summary\n") + Totals; + + return Totals; // The outgoing string... its finally gone, let's go to bed +} + +// +// Returns one month of details data // -QString Reportpanel::getMonth(QDate Dayref) +QString Reportpanel::getMonthdetails(QDate Dayref, int nMonths) { QString Data, Tempstring; // Output string int nRows = m_pReptable->numRows(); int nIter = nRows - 1; int nFirstrow = 0; int nLastrow = 0; - QDate Firstday = QDate(Dayref.year(), Dayref.month(), 1); + + // Find range boundaries + Q_ASSERT(nMonths > 0); + int nYear = Dayref.year(); + int nMonth = (Dayref.addMonths(nMonths * -1).month() + 12) % 12 + 1; + if (nMonth > Dayref.month()) + nYear--; + QDate Firstday = QDate(nYear, nMonth, 1); QDate Lastday = QDate(Dayref.year(), Dayref.month(), Dayref.daysInMonth()); + // Write some quick header text to the outgoing string + Data = trUtf8("\nDate Hours Account details\n"); + Data += QString("---------- ----- ----------------------------------------\n"); + // Find data starting the week in question while (QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) >= Firstday) nIter--; @@ -513,6 +592,75 @@ } // +// Returns one month of totals data +// +QString Reportpanel::getMonthtotals(QDate Dayref, int nMonths) +{ + using namespace std; // Needed for hash tables with hmap + map Hashtasks; // Hashtable for storing tasks + map Hashhours; // Hashtable for storing hours + map::iterator Taskiter; // The hashtable task iterator + map::iterator Houriter; // The hashtable hour iterator + + QString Totals; // Data totals to return for writing + QString Tempstring; // Temporary processing string + int nRows = m_pReptable->numRows(); + int nIter = nRows - 1; + int nFirstrow = 0; + int nLastrow = 0; + + // Find range boundaries + Q_ASSERT(nMonths > 0); + int nYear = Dayref.year(); + int nMonth = (Dayref.addMonths(nMonths * -1).month() + 12) % 12 + 1; + if (nMonth > Dayref.month()) + nYear--; + QDate Firstday = QDate(nYear, nMonth, 1); + QDate Lastday = QDate(Dayref.year(), Dayref.month(), Dayref.daysInMonth()); + + // Find data starting the week in question + while (QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) >= Firstday) + nIter--; + nFirstrow = ++nIter; // The first row to operate on + + // Find data ending the week in question + while (nIter < nRows && QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) < Lastday) + nIter++; + nLastrow = nIter - 1; // The last row to operate on + + // Parse the table for interesting values + for (nIter = nLastrow; nIter >= nFirstrow; nIter--) { + Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); + if (!Tempstring.isEmpty()) { + string Convstring = Tempstring; // Convert to string (can't cast?) + QTime Intable = QTime::fromString(m_pReptable->text(nIter, TITRAQ_IDXAMOUNT), Qt::ISODate); + int nTothours = QString(Hashtasks[Convstring]).section(':', 0, 0).toInt() + Intable.hour(); + int nTotminut = QString(Hashtasks[Convstring]).section(':', 1, 1).toInt() + Intable.minute(); + nTothours += nTotminut / 60; + nTotminut %= 60; + QString Hours = QString::number(nTothours).rightJustify(3, ' '); + QString Mins = QString::number(nTotminut).rightJustify(2, '0'); + string Timestring = Hours + ':' + Mins; // Convert to string (can't cast?) + Hashtasks[Convstring] = Timestring; // Finally store in hashtable + } + } + + // Reverse copy the tasks hashtable to both sort and index by amount key + for (Taskiter = Hashtasks.begin(); Taskiter != Hashtasks.end(); Taskiter++) + Hashhours[Taskiter->second] = Taskiter->first; + + // Write the actual data totals to the outgoing string in reverse order + for (Houriter = Hashhours.begin(); Houriter != Hashhours.end(); Houriter++) + Totals = Houriter->first + ' ' + Houriter->second + '\n' + Totals; + + // Write some quick header text to the outgoing string in reverse order + Totals = QString("------ ----------------------------------------\n") + Totals; + Totals = trUtf8("Total Account summary\n") + Totals; + + return Totals; // The outgoing string... its finally gone, let's go to bed +} + +// // Saves the currently displayed local report // void Reportpanel::saveReport(void) Index: ossp-pkg/as/as-gui/as_reportpanel.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_reportpanel.h,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_reportpanel.h,v' 2>/dev/null --- as_reportpanel.h 2003/02/20 21:09:58 1.5 +++ as_reportpanel.h 2003/02/21 23:44:36 1.6 @@ -99,8 +99,10 @@ void writeHeader(QString); void writeHeader(QString, QString); void writeFooter(void); - QString getWeek(QDate Refer = QDate::currentDate()); - QString getMonth(QDate Refer = QDate::currentDate()); + QString getWeektotals(QDate Refer = QDate::currentDate(), int nWeeks = 1); + QString getWeekdetails(QDate Refer = QDate::currentDate(), int nWeeks = 1); + QString getMonthtotals(QDate Refer = QDate::currentDate(), int nMonths = 1); + QString getMonthdetails(QDate Refer = QDate::currentDate(), int nMonths = 1); }; } // namespace AS