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.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_reportpanel.cpp,v' 2>/dev/null --- as_reportpanel.cpp 2003/02/18 18:27:46 1.2 +++ as_reportpanel.cpp 2003/02/19 18:23:16 1.3 @@ -43,6 +43,8 @@ #include #include "as_reportpanel.h" +#include "as_table.h" +#include "as_pref.h" #include "as_generic.h" #include "as_const.h" @@ -59,8 +61,10 @@ // The dialog will by default be modal, unless you set 'bModal' to // true to construct a modal dialog. // -Reportpanel::Reportpanel(QWidget *pParent, const char *kszName, bool bModal, WFlags Flags) - : QDialog(pParent, kszName, bModal, Flags) +Reportpanel::Reportpanel(TiTable *pTable, Preferences *pPreferences, + QWidget *pParent, const char *kszName, + bool bModal, WFlags Flags) + : QDialog(pParent, kszName, bModal, Flags) { // Boilerplate code to initialize the panel if (!kszName) @@ -71,6 +75,11 @@ this->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth())); + // Store matrix and prefs members + m_pReptable = pTable; +// m_pReptable->sortColumn(TITRAQ_IDXCOLDATE, true, true); + m_pReprefs = pPreferences; + // Build panel using already constructed widgets and layouts m_pFormlay = new QVBoxLayout(this, 11, 6, "Formlayout"); m_pToolay = new QHBoxLayout(0, 0, 6, "Toolbuttonlay"); @@ -88,6 +97,7 @@ m_pBrowser = new QTextEdit(m_pGroupbox, "Reportbrowser"); m_pBrowser->setTextFormat(PlainText); m_pBrowser->setReadOnly(true); + m_pBrowser->setFont(QFont("Courier", 10)); m_pGrouplay->addWidget(m_pBrowser); m_pGrouplay->addLayout(m_pToolay); @@ -113,7 +123,7 @@ connect(m_pDismissbutt, SIGNAL(clicked(void)), SLOT(accept(void))); connect(m_pSavebutt, SIGNAL(clicked(void)), SLOT(saveReport(void))); this->textChange(); - this->resize(QSize(400, 332).expandedTo(minimumSizeHint())); + this->resize(QSize(464, 332).expandedTo(minimumSizeHint())); } // @@ -123,7 +133,7 @@ { m_pBrowser->clear(); this->writeHeader(); - this->writeWeek(); + m_pBrowser->append(this->getWeek()); } // @@ -133,7 +143,7 @@ { m_pBrowser->clear(); this->writeHeader(); - this->writeMonth(); + m_pBrowser->append(this->getMonth()); } // @@ -142,27 +152,75 @@ void Reportpanel::writeHeader(void) { QString Header; - Header = QString("Accounting System 0.6.18 local report\n"); - Header += QString("User XXXXXXXXXXXXXXXXXXXX\n"); - Header += QString("Date X. February 2003\n"); - Header += QString("\n"); + 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 += QString("\n\n"); + Header += QString("Date Hours Task\n"); + Header += QString("---------- ----- ----\n"); m_pBrowser->setText(Header); } // // Writes one week of data to the display window // -void Reportpanel::writeWeek(void) +QString Reportpanel::getWeek(QDate Dayref) { - m_pBrowser->append(trUtf8("No events logged during week\n")); +// m_pBrowser->append(trUtf8("No events logged during week\n")); + 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 + + // 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 = nFirstrow; nIter <= nLastrow; 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; } // // Writes one month of data to the display window // -void Reportpanel::writeMonth(void) +QString Reportpanel::getMonth(QDate Dayref) { - m_pBrowser->append(trUtf8("No events logged during month\n")); + QString Data; + + for (int nIter = 0; nIter < 4; nIter++) + Data += getWeek(Dayref.addDays(nIter * -1)); + + return Data; } // @@ -173,7 +231,7 @@ int nResult = 0; // For checking user's answer QFile Report; // The resulting report file QString Filestring; // The user chosen file name to save - QString Openas = QDir::homeDirPath(); // Default chooser dir + QString Openas = m_pReprefs->getString(TITRAQ_PREFHOME, TITRAQ_DEFHOME); // And then get the name of the selected file to save to Filestring = QFileDialog::getSaveFileName(Openas, trUtf8("Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false); @@ -212,20 +270,20 @@ // Top level push buttons associated with accept and save slots m_pDismissbutt->setText(tr("Dismiss", "Comment for Dismissbutton")); - QToolTip::add(m_pDismissbutt, tr("Closes the report panel", "Comment for tooltip Reportbutton")); - QWhatsThis::add(m_pDismissbutt, tr("The dismiss button dismisses the report panel", "Comment for whatsThis Reportbutton")); + QToolTip::add(m_pDismissbutt, tr("Closes the report panel", "Comment for tooltip Dismissbutton")); + QWhatsThis::add(m_pDismissbutt, tr("The dismiss button dismisses the report panel", "Comment for whatsThis Dsimissbutton")); m_pSavebutt->setText(tr("Save", "Comment for Savebutton")); - QToolTip::add(m_pSavebutt, tr("Closes the report panel", "Comment for tooltip Reportbutton")); - QWhatsThis::add(m_pSavebutt, tr("The dismiss button dismisses the report panel", "Comment for whatsThis Reportbutton")); + QToolTip::add(m_pSavebutt, tr("Saves the report panel text", "Comment for tooltip Savebutton")); + QWhatsThis::add(m_pSavebutt, tr("The save button saves the report panel text to a file", "Comment for whatsThis Savebutton")); // Inner tool buttons for new local report generation m_pWeeklybutt->setText(tr("Weekly", "Comment for Weeklybutt")); QToolTip::add(m_pWeeklybutt, tr("Generates a weekly report", "Comment for tooltip Weeklybutt")); QWhatsThis::add(m_pWeeklybutt, tr("The weekly button generates a new weekly report", "Comment for whatsThis Weeklybutt")); m_pMonthlybutt->setText(tr("Monthly", "Comment for Monthlybutt")); - QToolTip::add(m_pMonthlybutt, tr("Generates a weekly report", "Comment for tooltip Monthlybutt")); - QWhatsThis::add(m_pMonthlybutt, tr("The weekly button generates a new weekly report", "Comment for whatsThis Monthlybutt")); + QToolTip::add(m_pMonthlybutt, tr("Generates a monthly report", "Comment for tooltip Monthlybutt")); + QWhatsThis::add(m_pMonthlybutt, tr("The monthly button generates a new monthly report", "Comment for whatsThis Monthlybutt")); m_pBothbutt->setText(tr("Both", "Comment for Bothbutt")); - QToolTip::add(m_pBothbutt, tr("Generates a weekly report", "Comment for tooltip Bothbutt")); - QWhatsThis::add(m_pBothbutt, tr("The weekly button generates a new weekly report", "Comment for whatsThis Bothbutt")); + QToolTip::add(m_pBothbutt, tr("Generates a both report", "Comment for tooltip Bothbutt")); + QWhatsThis::add(m_pBothbutt, tr("The both button generates a new report with both weekly and monthly items mixed in.", "Comment for whatsThis Bothbutt")); } 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.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_reportpanel.h,v' 2>/dev/null --- as_reportpanel.h 2003/02/18 18:27:46 1.2 +++ as_reportpanel.h 2003/02/19 18:23:16 1.3 @@ -34,8 +34,11 @@ #include #include +#include +class TiTable; +class Preferences; class QVBoxLayout; class QHBoxLayout; class QGridLayout; @@ -49,7 +52,9 @@ Q_OBJECT public: - Reportpanel(QWidget *pParent = 0, const char *kszName = 0, bool bModal = true, WFlags Flags = 0); + Reportpanel(TiTable *pTable, Preferences *pPreferences, + QWidget *pParent = 0, const char *kszName = 0, + bool bModal = true, WFlags Flags = 0); // ~Reportpanel(void); // No need to destroy widgets, because qt does it for us public: @@ -67,6 +72,10 @@ QHBoxLayout *m_pToolay; QHBoxLayout *m_pPushlay; +private: + TiTable *m_pReptable; + Preferences *m_pReprefs; + protected slots: virtual void saveReport(void); virtual void textChange(void); @@ -75,8 +84,8 @@ private: void writeHeader(void); - void writeWeek(void); - void writeMonth(void); + QString getWeek(QDate Refer = QDate::currentDate()); + QString getMonth(QDate Refer = QDate::currentDate()); }; #endif // REPORTPANEL_H 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.127' '-r1.128' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_slot.cpp,v' 2>/dev/null --- as_slot.cpp 2003/02/17 17:19:33 1.127 +++ as_slot.cpp 2003/02/19 18:23:16 1.128 @@ -1561,7 +1561,7 @@ Reportpanel *pReport = NULL; // The local report panel // Create a new local report window - pReport = new Reportpanel(this, "Locreportpanel"); + pReport = new Reportpanel(m_pMaintable, m_pPrefs, this, "Locreportpanel"); pReport->exec(); // Modal panel handler delete pReport; // Dispose Panel object }