head 1.18; access; symbols; locks; strict; comment @// @; 1.18 date 2004.05.27.21.48.41; author ms; state Exp; branches; next 1.17; 1.17 date 2003.12.01.17.43.57; author ms; state Exp; branches; next 1.16; 1.16 date 2003.11.20.11.31.20; author ms; state Exp; branches; next 1.15; 1.15 date 2003.02.27.13.56.22; author ms; state Exp; branches; next 1.14; 1.14 date 2003.02.25.09.29.31; author ms; state Exp; branches; next 1.13; 1.13 date 2003.02.24.17.39.04; author ms; state Exp; branches; next 1.12; 1.12 date 2003.02.21.23.44.36; author ms; state Exp; branches; next 1.11; 1.11 date 2003.02.21.21.56.52; author ms; state Exp; branches; next 1.10; 1.10 date 2003.02.21.15.04.04; author ms; state Exp; branches; next 1.9; 1.9 date 2003.02.21.10.12.37; author ms; state Exp; branches; next 1.8; 1.8 date 2003.02.20.21.28.57; author ms; state Exp; branches; next 1.7; 1.7 date 2003.02.20.21.09.58; author ms; state Exp; branches; next 1.6; 1.6 date 2003.02.20.17.08.43; author ms; state Exp; branches; next 1.5; 1.5 date 2003.02.20.16.51.05; author ms; state Exp; branches; next 1.4; 1.4 date 2003.02.20.16.48.00; author ms; state Exp; branches; next 1.3; 1.3 date 2003.02.19.18.23.16; author ms; state Exp; branches; next 1.2; 1.2 date 2003.02.18.18.27.46; author ms; state Exp; branches; next 1.1; 1.1 date 2003.02.17.17.16.18; author ms; state Exp; branches; next ; desc @@ 1.18 log @Modernize copyright text in source and graphic headers. @ text @// // OSSP asgui - Accounting system graphical user interface // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) // Copyright (c) 2002-2004 Ralf S. Engelschall // Copyright (c) 2002-2004 Michael Schloh von Bennewitz // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH // // This file is part of OSSP asgui, an accounting system graphical user // interface which can be found at http://www.ossp.org/pkg/tool/asgui/. // // Permission to use, copy, modify, and distribute this software for // any purpose with or without fee is hereby granted, provided that // the above copyright notice and this permission notice appear in all // copies. // // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // as_reportpanel.cpp: ISO C++ implementation // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "as_reportpanel.h" #include "as_numdial.h" #include "as_table.h" #include "as_pref.h" #include "as_generic.h" #include "as_const.h" #include "as_except.h" // Version information #define _AS_VERSION_CPP_AS_HEADER_ #include "as_version.cpp" #undef _AS_VERSION_CPP_AS_HEADER_ namespace AS { // // Constructs a Reportpanel as a child of 'pParent', with the // name 'kszName' and widget flags set to 'Flags'. // // The dialog will by default be modal, unless you set 'bModal' to // false to construct a modeless dialog. // 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) this->setName("Reportpanel"); // Make panel resizeable this->setSizeGripEnabled(true); this->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, this->sizePolicy().hasHeightForWidth())); // Store matrix and prefs members m_pReptable = pTable; m_pReprefs = pPreferences; m_pPrinter = new QPrinter; // Preset number of weeks and months to report m_nWeeks = m_pReprefs->getNumber(TITRAQ_PREFREPORTWEEKS, TITRAQ_DEFREPORTWEEKS); m_nMonths = m_pReprefs->getNumber(TITRAQ_PREFREPORTMONTHS, TITRAQ_DEFREPORTMONTHS); // Build panel using already constructed widgets and layouts m_pFormlay = new QVBoxLayout(this, 11, 6, "Formlayout"); m_pToolay = new QHBoxLayout(0, 0, 6, "Toolbuttonlay"); m_pPushlay = new QHBoxLayout(0, 0, 6, "Pushbuttonlay"); // Groupbox and its text display m_pBrowser = new QTextEdit(this, "Reportbrowser"); m_pBrowser->setTextFormat(PlainText); m_pBrowser->setReadOnly(true); m_pBrowser->setFont(QFont("Courier", 10)); m_pFormlay->addWidget(m_pBrowser); m_pFormlay->addSpacing(6); m_pFormlay->addLayout(m_pToolay); m_pFormlay->addSpacing(6); m_pFormlay->addLayout(m_pPushlay); // Tool button suite m_pWeekmonthgroup = new QButtonGroup(this, "Weekmonthgroup"); m_pWeekmonthgroup->setColumnLayout(0, Qt::Horizontal); m_pWeekmonthgroup->layout()->setSpacing(11); m_pWeekmonthgroup->layout()->setMargin(0); m_pWeekmonthlay = new QHBoxLayout(m_pWeekmonthgroup->layout()); m_pWeekmonthgroup->setFrameShape(QFrame::NoFrame); m_pWeekmonthgroup->setExclusive(true); m_pWeeklybutt = new QToolButton(m_pWeekmonthgroup, "Weeklybutton"); // m_pWeeklybutt->setPaletteBackgroundColor(QColor(198, 196, 186)); m_pWeeklybutt->setFocusPolicy(QWidget::TabFocus); 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->setFocusPolicy(QWidget::TabFocus); m_pMonthlybutt->setCursor(QCursor(13)); m_pMonthlybutt->setToggleButton(true); // Popup for number of weeks m_pWeekpop = new QPopupMenu(this); if (m_pWeekpop == NULL) // Sanity check throw Genexcept("Weekly toolbutton popup creation failed."); m_pWeekpop->insertItem(trUtf8("One week"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(trUtf8("Two weeks"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(trUtf8("Three weeks"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(trUtf8("Four weeks"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(trUtf8("N... weeks"), this, SLOT(reportWeeks(int))); m_pWeekpop->setCheckable(true); m_pWeeklybutt->setPopup(m_pWeekpop); m_pWeeklybutt->setPopupDelay(TITRAQ_POPUPMSECS); { // Initialize check button correctly int nPosition = (m_nWeeks < m_pWeekpop->count()) ? m_nWeeks : m_pWeekpop->count(); m_pWeekpop->setItemChecked(m_pWeekpop->idAt(--nPosition), true); } // Popup for number of months m_pMonthpop = new QPopupMenu(this); if (m_pMonthpop == NULL) // Sanity check throw Genexcept("Monthly toolbutton popup creation failed."); m_pMonthpop->insertItem(trUtf8("One month"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(trUtf8("Two months"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(trUtf8("Three months"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(trUtf8("Four months"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(trUtf8("N... months"), this, SLOT(reportMonths(int))); m_pMonthpop->setCheckable(true); m_pMonthlybutt->setPopup(m_pMonthpop); m_pMonthlybutt->setPopupDelay(TITRAQ_POPUPMSECS); { // Initialize check button correctly int nPosition = (m_nMonths < m_pMonthpop->count()) ? m_nMonths : m_pMonthpop->count(); m_pMonthpop->setItemChecked(m_pMonthpop->idAt(--nPosition), true); } // Add our tool buttons m_pWeekmonthlay->addWidget(m_pWeeklybutt); m_pWeekmonthlay->addWidget(m_pMonthlybutt); m_pToolay->addWidget(m_pWeekmonthgroup); // Push button suite m_pSavebutt = new QPushButton(this, "Savebutton"); m_pSavebutt->setPaletteBackgroundColor(QColor(202, 194, 182)); m_pSavebutt->setCursor(QCursor(13)); m_pPrintbutt = new QPushButton(this, "Printbutton"); m_pPrintbutt->setPaletteBackgroundColor(QColor(198, 196, 186)); m_pPrintbutt->setCursor(QCursor(13)); #ifdef QT_NO_PRINTER m_pPrintbutt->setEnabled(false); #endif 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_pPrintbutt); m_pPushlay->addWidget(m_pDismissbutt); // Connect signals to slots, accept() and reject() are Qt implicit connect(m_pWeeklybutt, SIGNAL(clicked(void)), SLOT(reportWeeks(void))); connect(m_pMonthlybutt, SIGNAL(clicked(void)), SLOT(reportMonths(void))); connect(m_pSavebutt, SIGNAL(clicked(void)), SLOT(saveReport(void))); connect(m_pPrintbutt, SIGNAL(clicked(void)), SLOT(printReport(void))); connect(m_pDismissbutt, SIGNAL(clicked(void)), SLOT(accept(void))); this->resize(QSize(464, 332).expandedTo(minimumSizeHint())); this->textChange(); } // // Overload QDialog::exec(), and generate a report before executing modally // int Reportpanel::exec(void) { int nRet = 0; int nPeriod = m_pReprefs->getNumber(TITRAQ_PREFREPORTYPE, TITRAQ_DEFREPORTYPE); switch (nPeriod) { case TITRAQ_REPORTWEEK: this->reportWeeks(1); m_pWeekmonthgroup->setButton(TITRAQ_REPORTWEEK); break; case TITRAQ_REPORTMONTH: this->reportMonths(1); m_pWeekmonthgroup->setButton(TITRAQ_REPORTMONTH); break; default: throw Genexcept("Reportpanel: Modal event loop entered with no report period."); break; } nRet = QDialog::exec(); // Blast off // Before losing scope, the preferred report period m_pReprefs->setNumber(TITRAQ_PREFREPORTYPE, m_pWeekmonthgroup->id(m_pWeekmonthgroup->selected())); m_pReprefs->setNumber(TITRAQ_PREFREPORTWEEKS, m_nWeeks); m_pReprefs->setNumber(TITRAQ_PREFREPORTMONTHS, m_nMonths); return nRet; } // // Makes a new weekly report of so many weeks // 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); // Corresponds to weeks int nLastid = 0; // Last menu id selected if (m_nWeeks < m_pWeekpop->count()) nLastid = m_pWeekpop->idAt(m_nWeeks - 1); // Probably not last item else nLastid = m_pWeekpop->idAt(m_pWeekpop->count() - 1); // Last item selected // Set the button in case from a menu selection m_pWeekmonthgroup->setButton(TITRAQ_REPORTWEEK); // Update m_nWeeks only if user prefers a different number if (nIndex >= 0) { // User selected N... to indicate an arbitrary number if (nIndex == m_pWeekpop->count() - 1) { Numdial Weeksinput; Weeksinput.setNum(m_nWeeks); if (Weeksinput.exec() == QDialog::Accepted) { m_nWeeks = Weeksinput.getNum(); m_pWeekpop->setItemChecked(nLastid, false); m_pWeekpop->setItemChecked(nMenuid, true); } else return; } else { // User selected a preset menu item such as '2 weeks' m_nWeeks = nIndex + 1; m_pWeekpop->setItemChecked(nLastid, false); m_pWeekpop->setItemChecked(nMenuid, true); } } // Clear data window m_pBrowser->setUpdatesEnabled(false); m_pBrowser->clear(); // 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 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(); m_pBrowser->setUpdatesEnabled(true); m_pBrowser->repaint(false); } // // Makes a new monthly report of so many months // 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); // Corresponds to months int nLastid = 0; // Last menu id selected if (m_nMonths < m_pMonthpop->count()) nLastid = m_pMonthpop->idAt(m_nMonths - 1); // Probably not last item else nLastid = m_pMonthpop->idAt(m_pMonthpop->count() - 1); // Last item selected // Set the button in case from a menu selection m_pWeekmonthgroup->setButton(TITRAQ_REPORTMONTH); // Update m_nMonths only if user prefers a different number if (nIndex >= 0) { // User selected N... to indicate an arbitrary number if (nIndex == m_pMonthpop->count() - 1) { Numdial Monthsinput; Monthsinput.setNum(m_nMonths); if (Monthsinput.exec() == QDialog::Accepted) { m_nMonths = Monthsinput.getNum(); m_pMonthpop->setItemChecked(nLastid, false); m_pMonthpop->setItemChecked(nMenuid, true); } else return; } else { // User selected a preset menu item such as '2 months' m_nMonths = nIndex + 1; m_pMonthpop->setItemChecked(nLastid, false); m_pMonthpop->setItemChecked(nMenuid, true); } } // Clear data window m_pBrowser->setUpdatesEnabled(false); m_pBrowser->clear(); // 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 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(); m_pBrowser->setUpdatesEnabled(true); m_pBrowser->repaint(false); } // // Writes a report header to the display window // void Reportpanel::writeHeader(int nWeeknum) { 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 week %1...").arg(nWeeknum); Header += QString("\n\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"); 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"); 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"); m_pBrowser->setText(Header); } // // Writes a report footer to the display window // 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 ________________________________________")); } } // // Returns one week of details data // QString Reportpanel::getWeekdetails(QDate Dayref, int nWeeks) { QString Data; // Output string QString Tempstring; // Temp churning int nRows = m_pReptable->numRows(); // Find range boundaries Q_ASSERT(nWeeks > 0); QDate Tempdate; 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"); // Build the long week data string for (int nIter = nRows - 1; nIter >= 0; nIter--) { // Work on this tuple only if it within the reporting range Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); Tempdate = QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate); if (!Tempstring.isEmpty() && Firstday <= Tempdate && Tempdate < Lastday) { 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 += QString("\n"); // Finish off line } } return Data; } // // Returns one week of totals data // QString Reportpanel::getWeektotals(QDate Dayref, int nWeeks) { using namespace std; // Needed for maps and hash map Hashtasks; // Hashtable to store tasks multimap Hashhours; // Hashtable to store hours map::iterator Taskiter; // Hashtable task iterator multimap::iterator Houriter; // Hashtable hour iterator QString Totals; // Data totals to return for writing QString Tempstring; // Temporary processing string QDate Tempdate; // Temporary processing date int nRows = m_pReptable->numRows(); // Find range boundaries 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); // Parse the table for interesting values for (int nIter = 0; nIter < nRows; nIter++) { // Work on this tuple only if it within the reporting range Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); Tempdate = QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate); if (!Tempstring.isEmpty() && Firstday <= Tempdate && Tempdate < Lastday) { 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.insert(pair(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::getMonthdetails(QDate Dayref, int nMonths) { QString Data; // Output string QString Tempstring; // Temp churning QDate Tempdate; // For comparing QDate Firstday; // Minimum boundary QDate Lastday; // Maximum boundary int nRows = m_pReptable->numRows(); // 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--; Firstday = QDate(nYear, nMonth, 1); 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"); // Build the long week data string for (int nIter = nRows - 1; nIter >= 0; nIter--) { // Work on this tuple only if it within the reporting range Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); Tempdate = QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate); if (!Tempstring.isEmpty() && Firstday <= Tempdate && Tempdate < Lastday) { 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; } // // Returns one month of totals data // QString Reportpanel::getMonthtotals(QDate Dayref, int nMonths) { using namespace std; // Needed for maps and hash map Hashtasks; // Hashtable to store tasks multimap Hashhours; // Hashtable to store hours map::iterator Taskiter; // Hashtable task iterator multimap::iterator Houriter; // Hashtable hour iterator QString Totals; // Data totals to return for writing QString Tempstring; // Temporary processing string QDate Tempdate; // Temporary processing date int nRows = m_pReptable->numRows(); // 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()); // Parse the table for interesting values for (int nIter = 0; nIter < nRows; nIter++) { // Work on this tuple only if it within the reporting range Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); Tempdate = QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate); if (!Tempstring.isEmpty() && Firstday <= Tempdate && Tempdate < Lastday) { 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.insert(pair(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) { 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 = 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); if (!Filestring.isEmpty()) { if (QFile::exists(Filestring)) { nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short, trUtf8(TITRAQ_OVERWRITE), trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1); if (nResult = QMessageBox::Ok) { // Overwrite a file Report.setName(Filestring); // User wished name Report.open(IO_WriteOnly | IO_Truncate); // Open report file QTextStream Outstream(&Report); // Convert to stream Outstream << m_pBrowser->text(); // Write the data Report.close(); // Finish by closing } } else { // User gave a file name, and there was no preexisting file there Report.setName(Filestring); // User wished name Report.open(IO_WriteOnly | IO_Truncate); // Open report file QTextStream Outstream(&Report); // Convert to stream Outstream << m_pBrowser->text(); // Write the data Report.close(); // Finish by closing } } // Otherwise, user did not select a valid file and push okay button } // // Prints the currently displayed local report // void Reportpanel::printReport(void) { #ifndef QT_NO_PRINTER if (m_pPrinter->setup(this)) { // Opens printer dialog m_pPrinter->setFullPage(true); // Set our own margins QPainter Paint; // Our painter (for pages) Paint.begin(m_pPrinter); // Paint on printer Paint.setFont(m_pBrowser->font()); QFontMetrics Fontmetrics = Paint.fontMetrics(); QPaintDeviceMetrics Devmetrics(m_pPrinter); // Need width/height of printer surface const int knMargin = Devmetrics.logicalDpiX() / 2; // Half-inch margin int nYpos = knMargin; // Y position for each line int nPageno = 1; // The starting page number for (int nIter = 0; nIter < m_pBrowser->lines() && !m_pPrinter->aborted(); nIter++) { // See if there is some space on this page to paint on if (nYpos + Fontmetrics.lineSpacing() > Devmetrics.height() - knMargin) { // QString Printmsg(trUtf8("Printing page ")) // + QString::number(++nPageno) + QString("..."); // m_pStatus()->message(Printmsg); // Not in scope (crap) if (!m_pPrinter->newPage()) // Start new page break; // Some error nYpos = knMargin; // Back to top of page } Paint.drawText(knMargin, nYpos, Devmetrics.width() - 2 * knMargin, Fontmetrics.lineSpacing(), Qt::ExpandTabs, m_pBrowser->text(nIter)); nYpos += Fontmetrics.lineSpacing(); } Paint.end(); // Send job to printer // m_pStatus()->message(trUtf8("Printing completed"), 2000); // Not in scope } // m_pStatusBar()->message(trUtf8("Printing completed"), 2000); // Not in scope #endif } // // Sets the strings of the subwidgets using the current language // void Reportpanel::textChange(void) { this->setCaption(trUtf8("AS local report", "Local report using weekly or monthly data.")); // Top level push buttons associated with accept and save slots m_pSavebutt->setText(trUtf8("Save As...", "Comment for Savebutton")); QToolTip::add(m_pSavebutt, trUtf8("Saves the report text", "Comment for tooltip Savebutton")); QWhatsThis::add(m_pSavebutt, trUtf8("The save button saves the report text to a file", "Comment for whatsThis Savebutton")); m_pPrintbutt->setText(trUtf8("Print...", "Comment for Printbutton")); QToolTip::add(m_pPrintbutt, trUtf8("Print the report text", "Comment for tooltip Printbutton")); QWhatsThis::add(m_pPrintbutt, trUtf8("The print button prints the report text to a file", "Comment for whatsThis Printbutton")); m_pDismissbutt->setText(trUtf8("Dismiss", "Comment for Dismissbutton")); QToolTip::add(m_pDismissbutt, trUtf8("Closes the report panel", "Comment for tooltip Dismissbutton")); QWhatsThis::add(m_pDismissbutt, trUtf8("The dismiss button dismisses the report panel", "Comment for whatsThis Dismissbutton")); // Inner tool buttons for new local report generation m_pWeeklybutt->setText(trUtf8("Weekly", "Comment for Weeklybutt")); QToolTip::add(m_pWeeklybutt, trUtf8("Hold down for options", "Comment for tooltip Weeklybutt")); QWhatsThis::add(m_pWeeklybutt, trUtf8("The Weekly button generates a new weekly report.\nHold this button down to specify many weeks.", "Comment for whatsThis Weeklybutt")); m_pMonthlybutt->setText(trUtf8("Monthly", "Comment for Monthlybutt")); QToolTip::add(m_pMonthlybutt, trUtf8("Hold down for options", "Comment for tooltip Monthlybutt")); QWhatsThis::add(m_pMonthlybutt, trUtf8("The Monthly button makes a new monthly report.\nHold this button down to specify how many months.", "Comment for whatsThis Monthlybutt")); } } // namespace AS @ 1.17 log @Correct label text on save and print buttons. @ text @d3 4 a6 4 // Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/) // Copyright (c) 2002-2003 Ralf S. Engelschall // Copyright (c) 2002-2003 Michael Schloh von Bennewitz // Copyright (c) 2002-2003 Cable & Wireless Telecommunications Services GmbH @ 1.16 log @Handle the time consuming bureaucracy of changing a company name. @ text @d744 1 a744 1 m_pSavebutt->setText(trUtf8("Save", "Comment for Savebutton")); d747 1 a747 1 m_pPrintbutt->setText(trUtf8("Print", "Comment for Printbutton")); @ 1.15 log @Layout adjustments, and text string corrections. @ text @a3 1 // Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/) d6 1 @ 1.14 log @Hook in number dialog for arbitrary weeks and months user entry, add postscript printing, remove 'both' button, and fix detailed and total calculating algorhythms. This no longer depends on a date-sorted table. @ text @a87 1 // m_pReptable->sortColumn(TITRAQ_IDXDATE, true, true); d106 1 d108 1 d114 2 a116 3 m_pWeekmonthlay->setSpacing(11); m_pWeekmonthlay->setMargin(0); m_pWeekmonthlay->setAlignment(Qt::AlignTop); d120 2 a121 1 m_pWeeklybutt->setPaletteBackgroundColor(QColor(198, 196, 186)); d125 2 a126 1 m_pMonthlybutt->setPaletteBackgroundColor(QColor(198, 196, 186)); a174 4 m_pDismissbutt = new QPushButton(this, "Dismissbutton"); m_pDismissbutt->setPaletteBackgroundColor(QColor(198, 196, 186)); m_pDismissbutt->setCursor(QCursor(13)); m_pDismissbutt->setDefault(true); d181 4 a191 1 connect(m_pDismissbutt, SIGNAL(clicked(void)), SLOT(accept(void))); d194 1 a743 3 m_pDismissbutt->setText(trUtf8("Dismiss", "Comment for Dismissbutton")); QToolTip::add(m_pDismissbutt, trUtf8("Closes the report panel", "Comment for tooltip Dismissbutton")); QWhatsThis::add(m_pDismissbutt, trUtf8("The dismiss button dismisses the report panel", "Comment for whatsThis Dismissbutton")); d750 3 @ 1.13 log @Fix bug causing merging of independent account entries. @ text @d43 3 d50 1 d70 1 a70 1 // true to construct a modal dialog. d81 1 a81 1 // Make Panel resizeable d90 1 a126 4 m_pBothbutt = new QToolButton(m_pWeekmonthgroup, "Bothbutton"); m_pBothbutt->setPaletteBackgroundColor(QColor(198, 196, 186)); m_pBothbutt->setCursor(QCursor(13)); m_pBothbutt->setToggleButton(true); a137 1 m_pWeekpop->setItemChecked(m_pWeekpop->idAt(m_nWeeks - 1), true); d141 5 a155 1 m_pMonthpop->setItemChecked(m_pMonthpop->idAt(m_nMonths - 1), true); d159 5 a166 1 m_pWeekmonthlay->addWidget(m_pBothbutt); d177 6 d184 1 a189 1 connect(m_pBothbutt, SIGNAL(clicked(void)), SLOT(reportBoth(void))); d192 2 a194 1 this->resize(QSize(464, 332).expandedTo(minimumSizeHint())); a213 4 case TITRAQ_REPORTBOTH: this->reportBoth(1); m_pWeekmonthgroup->setButton(TITRAQ_REPORTBOTH); break; d238 7 a244 1 int nIndex = m_pWeekpop->indexOf(nMenuid); d251 17 a267 10 int nLastid = m_pWeekpop->idAt(m_nWeeks - 1); m_nWeeks = nIndex + 1; m_pWeekpop->setItemChecked(nLastid, false); m_pWeekpop->setItemChecked(nMenuid, true); } // User selected N... to indicate an arbitrary number if (nIndex == m_pWeekpop->count() - 1) { Prototype Unimp; Unimp.doMbox(); d303 7 a309 1 int nIndex = m_pMonthpop->indexOf(nMenuid); d316 17 a332 10 int nLastid = m_pMonthpop->idAt(m_nMonths - 1); m_nMonths = nIndex + 1; m_pMonthpop->setItemChecked(nLastid, false); m_pMonthpop->setItemChecked(nMenuid, true); } // User selected N... to indicate an arbitrary number if (nIndex == m_pMonthpop->count() - 1) { Prototype Unimp; Unimp.doMbox(); a361 12 // Makes a new monthly report of so many weeks and months // void Reportpanel::reportBoth(int nMenuid) { // Set the button in case we arrived from a menu selection m_pWeekmonthgroup->setButton(TITRAQ_REPORTBOTH); // Placeholder text until we figure out what to do with this m_pBrowser->setText(trUtf8("The 'both' feature is not working yet.")); } // d457 3 a459 5 QString Data, Tempstring; // Output string int nRows = m_pReptable->numRows(); int nIter = nRows - 1; int nFirstrow = 0; int nLastrow = 0; d461 1 d463 1 a473 10 // 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 d475 2 a476 7 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; d478 13 a490 3 if (!Tempstring.isEmpty()) Data += QString(TITRAQ_SEPARATORTOK) + Tempstring; Data += QString("\n"); // Finish off line d509 2 a510 4 int nRows = m_pReptable->numRows(); int nIter = nRows - 1; int nFirstrow = 0; int nLastrow = 0; d512 1 a519 10 // 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 d521 2 a522 1 for (nIter = nLastrow; nIter >= nFirstrow; nIter--) { d524 2 a525 1 if (!Tempstring.isEmpty()) { d559 6 a564 5 QString Data, Tempstring; // Output string int nRows = m_pReptable->numRows(); int nIter = nRows - 1; int nFirstrow = 0; int nLastrow = 0; d572 2 a573 2 QDate Firstday = QDate(nYear, nMonth, 1); QDate Lastday = QDate(Dayref.year(), Dayref.month(), Dayref.daysInMonth()); a578 10 // 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 d580 2 a581 7 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; d583 13 a595 3 if (!Tempstring.isEmpty()) Data += QString(TITRAQ_SEPARATORTOK) + Tempstring; Data += trUtf8("\n"); // Finish off line d614 2 a615 4 int nRows = m_pReptable->numRows(); int nIter = nRows - 1; int nFirstrow = 0; int nLastrow = 0; a625 10 // 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 d627 2 a628 1 for (nIter = nLastrow; nIter >= nFirstrow; nIter--) { d630 2 a631 1 if (!Tempstring.isEmpty()) { d697 38 d739 1 a739 1 this->setCaption(trUtf8("AS local report", "Local report using weekly data or monthly data or both.")); d744 1 a744 1 QWhatsThis::add(m_pDismissbutt, trUtf8("The dismiss button dismisses the report panel", "Comment for whatsThis Dsimissbutton")); d746 5 a750 2 QToolTip::add(m_pSavebutt, trUtf8("Saves the report panel text", "Comment for tooltip Savebutton")); QWhatsThis::add(m_pSavebutt, trUtf8("The save button saves the report panel text to a file", "Comment for whatsThis Savebutton")); a758 3 m_pBothbutt->setText(trUtf8("Both", "Comment for Bothbutt")); QToolTip::add(m_pBothbutt, trUtf8("Report with both week data and month data", "Comment for tooltip Bothbutt")); QWhatsThis::add(m_pBothbutt, trUtf8("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")); @ 1.12 log @Completed summary and detailed listing logic by using a hashtable to index account items, and nearly finish this pig of a class. @ text @d481 5 a485 5 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 d530 1 a530 1 Hashhours[Taskiter->second] = Taskiter->first; d599 5 a603 5 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 d650 1 a650 1 Hashhours[Taskiter->second] = Taskiter->first; @ 1.11 log @Remove accidental debug call. @ text @d260 3 a262 2 for (int nIter = 0; nIter < m_nWeeks; nIter++) m_pBrowser->append(this->getWeek(QDate::currentDate().addDays(nIter * -7))); d313 4 a316 2 for (int nIter = 0; nIter < m_nMonths; nIter++) m_pBrowser->append(this->getMonth(QDate::currentDate().addMonths(nIter * -1))); d332 2 a333 9 // 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); a352 2 Header += QString("Date Hours Task\n"); Header += QString("---------- ----- ----\n"); a372 2 Header += QString("Date Hours Task\n"); Header += QString("---------- ----- ----\n"); a392 2 Header += QString("Date Hours Task\n"); Header += QString("---------- ----- ----\n"); a412 2 Header += QString("Date Hours Task\n"); Header += QString("---------- ----- ----\n"); d421 4 d428 1 a428 1 // Writes one week of data to the display window d430 1 a430 1 QString Reportpanel::getWeek(QDate Dayref) d437 11 a447 2 QDate Firstday = Dayref.addDays(Dayref.dayOfWeek() * -1 + 1); // Do negate QDate Lastday = Firstday.addDays(7); // Add week d470 1 a470 1 Data += trUtf8("\n"); // Finish off line d477 68 a544 1 // Writes one month of data to the display window d546 1 a546 1 QString Reportpanel::getMonth(QDate Dayref) d553 8 a560 1 QDate Firstday = QDate(Dayref.year(), Dayref.month(), 1); d563 4 d592 69 @ 1.10 log @Last touches to colour dialogs and preferences. @ text @a545 1 qDebug(m_pBrowser->text().ascii()); @ 1.9 log @Polished text for button labels, tooltips, and whatsthis docs. @ text @d80 1 a80 1 (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth())); @ 1.8 log @Use unicode macro translations instead of ASCII ones. @ text @d570 1 a570 1 QWhatsThis::add(m_pWeeklybutt, trUtf8("The weekly button generates a new weekly report.\nHold this button down to specify many weeks.", "Comment for whatsThis Weeklybutt")); d573 1 a573 1 QWhatsThis::add(m_pMonthlybutt, trUtf8("The monthly button makes a new monthly report.\nHold this button down to specify how many months.", "Comment for whatsThis Monthlybutt")); @ 1.7 log @Added logic to iterate over multiple weeks or months according to user preferences, and overloaded writeHeader to make header writing more flexible. @ text @d131 5 a135 5 m_pWeekpop->insertItem(tr("One week"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(tr("Two weeks"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(tr("Three weeks"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(tr("Four weeks"), this, SLOT(reportWeeks(int))); m_pWeekpop->insertItem(tr("N... weeks"), this, SLOT(reportWeeks(int))); d145 5 a149 5 m_pMonthpop->insertItem(tr("One month"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(tr("Two months"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(tr("Three months"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(tr("Four months"), this, SLOT(reportMonths(int))); m_pMonthpop->insertItem(tr("N... months"), this, SLOT(reportMonths(int))); d332 1 a332 1 m_pBrowser->append(tr("The 'both' feature is not working yet.")); d557 1 a557 1 this->setCaption(tr("AS local report", "Local report using weekly data or monthly data or both.")); d560 6 a565 6 m_pDismissbutt->setText(tr("Dismiss", "Comment for Dismissbutton")); 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("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")); d568 9 a576 9 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.\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 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 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")); @ 1.6 log @Added checkmarks to menus, so user knows how many weeks and months report. @ text @d115 3 d119 3 d123 2 a124 2 m_pWeeklybutt->setToggleButton(true); m_pMonthlybutt->setToggleButton(true); d163 2 d166 3 d223 3 d246 1 a246 1 // Clear data window and write header out d249 13 a261 2 this->writeHeader(); m_pBrowser->append(this->getWeek()); d274 3 d297 1 a297 1 // Clear data window and write header out d300 14 a313 2 this->writeHeader(); m_pBrowser->append(this->getMonth()); a331 1 this->writeHeader(); d343 1 a343 1 void Reportpanel::writeHeader(void) d355 67 a439 1 // m_pBrowser->append(trUtf8("No events logged during week\n")); d454 1 a454 3 while (nIter < nRows && QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate) < Lastday) d459 1 a459 1 for (nIter = nFirstrow; nIter <= nLastrow; nIter++) { d480 31 a510 4 QString Data; for (int nIter = 0; nIter < 4; nIter++) Data += getWeek(Dayref.addDays(nIter * -1)); d570 1 a570 1 QWhatsThis::add(m_pWeeklybutt, tr("The weekly button generates a new weekly report. Hold this button down for options.", "Comment for whatsThis Weeklybutt")); d573 1 a573 1 QWhatsThis::add(m_pMonthlybutt, tr("The monthly button generates a new monthly report. Hold this button down for options.", "Comment for whatsThis Monthlybutt")); d576 1 a576 1 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")); @ 1.5 log @Don't sort internal report matrix data until TiTable copy constructor is working. @ text @d130 2 d144 2 d215 3 d219 2 a220 1 if (nIndex >= 0) d222 3 a231 3 // Set the button in case we arrived from a menu selection m_pWeekmonthgroup->setButton(TITRAQ_REPORTWEEK); d252 3 d256 2 a257 1 if (nIndex >= 0) d259 3 a267 3 // Set the button in case we arrived from a menu selection m_pWeekmonthgroup->setButton(TITRAQ_REPORTMONTH); @ 1.4 log @Vast report generation improvements and additions. @ text @d84 1 a84 1 m_pReptable->sortColumn(TITRAQ_IDXDATE, true, true); @ 1.3 log @Added necessary coupling between report panel and table and preferences to get local reports working. Fixed some strings, and removed hard coded text in favour of pref values. @ text @a32 1 #include d36 2 d51 1 d59 2 d84 1 a84 1 // m_pReptable->sortColumn(TITRAQ_IDXCOLDATE, true, true); d87 4 d97 1 a97 9 m_pGroupbox = new QGroupBox(this, "Groupbox"); m_pGroupbox->setFrameShape(QGroupBox::GroupBoxPanel); m_pGroupbox->setFrameShadow(QGroupBox::Sunken); m_pGroupbox->setColumnLayout(0, Qt::Vertical); m_pGroupbox->layout()->setSpacing(6); m_pGroupbox->layout()->setMargin(11); m_pGrouplay = new QVBoxLayout(m_pGroupbox->layout()); m_pGrouplay->setAlignment(Qt::AlignTop); m_pBrowser = new QTextEdit(m_pGroupbox, "Reportbrowser"); d101 3 a103 2 m_pGrouplay->addWidget(m_pBrowser); m_pGrouplay->addLayout(m_pToolay); d106 44 a149 7 m_pWeeklybutt = new QToolButton(m_pGroupbox, "Weeklybutton"); m_pMonthlybutt = new QToolButton(m_pGroupbox, "Monthlybutton"); m_pBothbutt = new QToolButton(m_pGroupbox, "Bothbutton"); m_pToolay->addWidget(m_pWeeklybutt); m_pToolay->addWidget(m_pMonthlybutt); m_pToolay->addWidget(m_pBothbutt); m_pFormlay->addWidget(m_pGroupbox); a155 1 m_pFormlay->addLayout(m_pPushlay); d160 1 d168 36 d206 1 a206 1 void Reportpanel::reportWeeks(int nWeeks) d208 18 d229 5 d239 1 a239 1 void Reportpanel::reportMonths(int nMonths) d241 18 d262 25 d311 7 a415 1 m_pGroupbox->setTitle(tr("Local report", "Comment for Groupbox")); d427 2 a428 2 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")); d430 2 a431 2 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")); d433 2 a434 2 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")); d436 1 @ 1.2 log @Added logic to save to a file the contents of the report display window, and generally added to the Reportpanel class. @ text @d46 2 d64 4 a67 2 Reportpanel::Reportpanel(QWidget *pParent, const char *kszName, bool bModal, WFlags Flags) : QDialog(pParent, kszName, bModal, Flags) d78 5 d100 1 d126 1 a126 1 this->resize(QSize(400, 332).expandedTo(minimumSizeHint())); d136 1 a136 1 this->writeWeek(); d146 1 a146 1 this->writeMonth(); d155 12 a166 4 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"); d173 1 a173 1 void Reportpanel::writeWeek(void) d175 36 a210 1 m_pBrowser->append(trUtf8("No events logged during week\n")); d216 1 a216 1 void Reportpanel::writeMonth(void) d218 6 a223 1 m_pBrowser->append(trUtf8("No events logged during month\n")); d234 1 a234 1 QString Openas = QDir::homeDirPath(); // Default chooser dir d273 2 a274 2 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")); d276 2 a277 2 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")); d284 2 a285 2 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")); d287 2 a288 2 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")); @ 1.1 log @Implemented new class Reportpanel. @ text @d35 1 a35 1 #include d40 4 d47 6 d79 1 a79 1 // Groupbox and its browser d88 3 a90 1 m_pBrowser = new QTextBrowser(m_pGroupbox, "Reportbrowser"); d111 2 d120 49 d173 30 a202 2 Prototype Unimp; Unimp.doMbox(); @