OSSP CVS Repository

ossp - Check-in [4065]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4065
Date: 2003-Feb-20 22:09:58 (local)
2003-Feb-20 21:09:58 (UTC)
User:ms
Branch:
Comment: Added logic to iterate over multiple weeks or months according to user preferences, and overloaded writeHeader to make header writing more flexible.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_reportpanel.cpp      1.6 -> 1.7     152 inserted, 22 deleted
ossp-pkg/as/as-gui/as_reportpanel.h      1.4 -> 1.5     4 inserted, 1 deleted

ossp-pkg/as/as-gui/as_reportpanel.cpp 1.6 -> 1.7

--- as_reportpanel.cpp   2003/02/20 17:08:43     1.6
+++ as_reportpanel.cpp   2003/02/20 21:09:58     1.7
@@ -112,10 +112,16 @@
     m_pWeekmonthgroup->setFrameShape(QFrame::NoFrame);
     m_pWeekmonthgroup->setExclusive(true);
     m_pWeeklybutt = new QToolButton(m_pWeekmonthgroup, "Weeklybutton");
-    m_pMonthlybutt = new QToolButton(m_pWeekmonthgroup, "Monthlybutton");
-    m_pBothbutt = new QToolButton(m_pWeekmonthgroup, "Bothbutton");
+    m_pWeeklybutt->setPaletteBackgroundColor(QColor(198, 196, 186));
+    m_pWeeklybutt->setCursor(QCursor(13));
     m_pWeeklybutt->setToggleButton(true);
+    m_pMonthlybutt = new QToolButton(m_pWeekmonthgroup, "Monthlybutton");
+    m_pMonthlybutt->setPaletteBackgroundColor(QColor(198, 196, 186));
+    m_pMonthlybutt->setCursor(QCursor(13));
     m_pMonthlybutt->setToggleButton(true);
+    m_pBothbutt = new QToolButton(m_pWeekmonthgroup, "Bothbutton");
+    m_pBothbutt->setPaletteBackgroundColor(QColor(198, 196, 186));
+    m_pBothbutt->setCursor(QCursor(13));
     m_pBothbutt->setToggleButton(true);
 
     // Popup for number of weeks
@@ -154,7 +160,12 @@
 
     // Push button suite
     m_pSavebutt = new QPushButton(this, "Savebutton");
+    m_pSavebutt->setPaletteBackgroundColor(QColor(202, 194, 182));
+    m_pSavebutt->setCursor(QCursor(13));
     m_pDismissbutt = new QPushButton(this, "Dismissbutton");
+    m_pDismissbutt->setPaletteBackgroundColor(QColor(198, 196, 186));
+    m_pDismissbutt->setCursor(QCursor(13));
+    m_pDismissbutt->setDefault(true);
     m_pPushlay->addWidget(m_pSavebutt);
     m_pPushlay->addWidget(m_pDismissbutt);
 
@@ -209,6 +220,9 @@
 //
 void Reportpanel::reportWeeks(int nMenuid)
 {
+    // Range of weeks to report
+    int nFirstweek, nLastweek;
+
     // Menu index, first item is always 0
     int nIndex = m_pWeekpop->indexOf(nMenuid);
 
@@ -229,11 +243,22 @@
         Unimp.doMbox();
     }
 
-    // Clear data window and write header out
+    // Clear data window
     m_pBrowser->setUpdatesEnabled(false);
     m_pBrowser->clear();
-    this->writeHeader();
-    m_pBrowser->append(this->getWeek());
+
+    // Determine first and last week numbers, then write header
+    nLastweek = QDate::currentDate().weekNumber();
+    if (m_nWeeks > 1) {
+        nFirstweek = QDate::currentDate().addDays(m_nWeeks * -7).weekNumber() + 1;
+        this->writeHeader(nFirstweek, nLastweek);
+    }
+    else
+        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)));
     this->writeFooter();
     m_pBrowser->setCursorPosition(0, 0);
     m_pBrowser->ensureCursorVisible();
@@ -246,6 +271,9 @@
 //
 void Reportpanel::reportMonths(int nMenuid)
 {
+    // Range of months to report
+    QString Firstmonth, Lastmonth;
+
     // Menu index, first item is always 0
     int nIndex = m_pMonthpop->indexOf(nMenuid);
 
@@ -266,11 +294,23 @@
         Unimp.doMbox();
     }
 
-    // Clear data window and write header out
+    // Clear data window
     m_pBrowser->setUpdatesEnabled(false);
     m_pBrowser->clear();
-    this->writeHeader();
-    m_pBrowser->append(this->getMonth());
+
+    // Determine first and last month names, then write header
+    Lastmonth = QDate::longMonthName(QDate::currentDate().month());
+    if (m_nMonths > 1) {
+        int nMonth = (QDate::currentDate().addMonths(m_nMonths * -1).month() + 12) % 12 + 1;
+        Firstmonth = QDate::longMonthName(nMonth);
+        this->writeHeader(Firstmonth, Lastmonth);
+    }
+    else
+        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)));
     this->writeFooter();
     m_pBrowser->setCursorPosition(0, 0);
     m_pBrowser->ensureCursorVisible();
@@ -289,7 +329,6 @@
     // Clear data window and write header out
     m_pBrowser->setUpdatesEnabled(false);
     m_pBrowser->clear();
-    this->writeHeader();
     m_pBrowser->append(tr("The 'both' feature is not working yet."));
     this->writeFooter();
     m_pBrowser->setCursorPosition(0, 0);
@@ -301,7 +340,7 @@
 //
 // Writes a report header to the display window
 //
-void Reportpanel::writeHeader(void)
+void Reportpanel::writeHeader(int nWeeknum)
 {
     QString Header;
     Header = QString("Accounting System ");
@@ -313,6 +352,73 @@
     Header += QDate::currentDate().toString(Qt::ISODate);
     Header += trUtf8(", Time ");
     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);
+}
+
+//
+// Writes a report header to the display window
+//
+void Reportpanel::writeHeader(QString Month)
+{
+    QString Header;
+    Header = QString("Accounting System ");
+    Header += QString(asgui_version.v_short);
+    Header += trUtf8("\nLocal report, username '");
+    Header += m_pReprefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER);
+    Header += QString("'\n");
+    Header += trUtf8("Date ");
+    Header += QDate::currentDate().toString(Qt::ISODate);
+    Header += trUtf8(", Time ");
+    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);
+}
+
+//
+// Writes a report header to the display window
+//
+void Reportpanel::writeHeader(int nFirst, int nLast)
+{
+    QString Header;
+    Header = QString("Accounting System ");
+    Header += QString(asgui_version.v_short);
+    Header += trUtf8("\nLocal report, username '");
+    Header += m_pReprefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER);
+    Header += QString("'\n");
+    Header += trUtf8("Date ");
+    Header += QDate::currentDate().toString(Qt::ISODate);
+    Header += trUtf8(", Time ");
+    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);
+}
+
+//
+// Writes a report header to the display window
+//
+void Reportpanel::writeHeader(QString First, QString Last)
+{
+    QString Header;
+    Header = QString("Accounting System ");
+    Header += QString(asgui_version.v_short);
+    Header += trUtf8("\nLocal report, username '");
+    Header += m_pReprefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER);
+    Header += QString("'\n");
+    Header += trUtf8("Date ");
+    Header += QDate::currentDate().toString(Qt::ISODate);
+    Header += trUtf8(", Time ");
+    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");
@@ -331,7 +437,6 @@
 //
 QString Reportpanel::getWeek(QDate Dayref)
 {
-//    m_pBrowser->append(trUtf8("No events logged during week\n"));
     QString Data, Tempstring; // Output string
     int nRows      = m_pReptable->numRows();
     int nIter      = nRows - 1;
@@ -346,14 +451,12 @@
     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)
+    while (nIter < nRows && QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) <  Lastday)
         nIter++;
     nLastrow = nIter - 1; // The last row to operate on
 
     // Build the long week data string
-    for (nIter = nFirstrow; nIter <= nLastrow; nIter++) {
+    for (nIter = nLastrow; nIter >= nFirstrow; nIter--) {
         Tempstring = m_pReptable->text(nIter, TITRAQ_IDXDATE);
         if (!Tempstring.isEmpty())
             Data += Tempstring;
@@ -374,10 +477,37 @@
 //
 QString Reportpanel::getMonth(QDate Dayref)
 {
-    QString Data;
-    
-    for (int nIter = 0; nIter < 4; nIter++)
-        Data += getWeek(Dayref.addDays(nIter * -1));
+    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);
+    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
+
+    // Build the long week data string
+    for (nIter = nLastrow; nIter >= nFirstrow; nIter--) {
+        Tempstring = m_pReptable->text(nIter, TITRAQ_IDXDATE);
+        if (!Tempstring.isEmpty())
+            Data += Tempstring;
+        Tempstring = m_pReptable->text(nIter, TITRAQ_IDXAMOUNT);
+        if (!Tempstring.isEmpty())
+            Data += QString(TITRAQ_SEPARATORTOK) + Tempstring;
+        Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK);
+        if (!Tempstring.isEmpty())
+            Data += QString(TITRAQ_SEPARATORTOK) + Tempstring;
+        Data += trUtf8("\n"); // Finish off line
+    }
 
     return Data;
 }
@@ -437,12 +567,12 @@
     // Inner tool buttons for new local report generation
     m_pWeeklybutt->setText(tr("Weekly", "Comment for Weeklybutt"));
     QToolTip::add(m_pWeeklybutt, tr("Hold down for options", "Comment for tooltip Weeklybutt"));
-    QWhatsThis::add(m_pWeeklybutt, tr("The weekly button generates a new weekly report. Hold this button down for options.", "Comment for whatsThis Weeklybutt"));
+    QWhatsThis::add(m_pWeeklybutt, tr("The weekly button generates a new weekly report.\nHold this button down to specify many weeks.", "Comment for whatsThis Weeklybutt"));
     m_pMonthlybutt->setText(tr("Monthly", "Comment for Monthlybutt"));
     QToolTip::add(m_pMonthlybutt, tr("Hold down for options", "Comment for tooltip Monthlybutt"));
-    QWhatsThis::add(m_pMonthlybutt, tr("The monthly button generates a new monthly report. Hold this button down for options.", "Comment for whatsThis Monthlybutt"));
+    QWhatsThis::add(m_pMonthlybutt, tr("The monthly button makes a new monthly report.\nHold this button down to specify how many months.", "Comment for whatsThis Monthlybutt"));
     m_pBothbutt->setText(tr("Both", "Comment for Bothbutt"));
     QToolTip::add(m_pBothbutt, tr("Report with both week data and month data", "Comment for tooltip Bothbutt"));
-    QWhatsThis::add(m_pBothbutt, tr("The both button generates a new report with both weekly and monthly items mixed in. Hold this button down for options.", "Comment for whatsThis Bothbutt"));
+    QWhatsThis::add(m_pBothbutt, tr("The both button makes a new report with both weekly and monthly items mixed in. Hold this button down to specify how many weeks mixed of data.", "Comment for whatsThis Bothbutt"));
 }
 } // namespace AS


ossp-pkg/as/as-gui/as_reportpanel.h 1.4 -> 1.5

--- as_reportpanel.h     2003/02/20 16:48:00     1.4
+++ as_reportpanel.h     2003/02/20 21:09:58     1.5
@@ -94,7 +94,10 @@
     virtual void reportBoth(int nMenuid = -1);
 
 private:
-    void writeHeader(void);
+    void writeHeader(int);
+    void writeHeader(int, int);
+    void writeHeader(QString);
+    void writeHeader(QString, QString);
     void writeFooter(void);
     QString getWeek(QDate Refer = QDate::currentDate());
     QString getMonth(QDate Refer = QDate::currentDate());

CVSTrac 2.0.1