OSSP CVS Repository

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

Check-in Number: 4061
Date: 2003-Feb-20 17:48:00 (local)
2003-Feb-20 16:48:00 (UTC)
User:ms
Branch:
Comment: Vast report generation improvements and additions.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/TODO      1.89 -> 1.90     1 inserted, 0 deleted
ossp-pkg/as/as-gui/as_const.h      1.55 -> 1.56     12 inserted, 0 deleted
ossp-pkg/as/as-gui/as_reportpanel.cpp      1.3 -> 1.4     177 inserted, 30 deleted
ossp-pkg/as/as-gui/as_reportpanel.h      1.3 -> 1.4     20 inserted, 7 deleted

ossp-pkg/as/as-gui/TODO 1.89 -> 1.90

--- TODO 2003/02/17 17:19:33     1.89
+++ TODO 2003/02/20 16:48:00     1.90
@@ -59,6 +59,7 @@
 Loesch mal alle Text vom Task Editctrl, dann drueck mal Obentaste
 Memory leak in vector<QRadioButton> as_panel
 Opendoc, schau amount unten Knopf (ist dimmed)
+Reporting only works if event data is sorted by date
 
 Nice to have
 ------------


ossp-pkg/as/as-gui/as_const.h 1.55 -> 1.56

--- as_const.h   2003/02/14 19:27:03     1.55
+++ as_const.h   2003/02/20 16:48:00     1.56
@@ -66,6 +66,12 @@
 #define TITRAQ_DEFBAKON         1
 #define TITRAQ_PREFEXTENDON     "filextension"
 #define TITRAQ_DEFEXTENDON      1
+#define TITRAQ_PREFREPORTYPE    "reportperiod"
+#define TITRAQ_DEFREPORTYPE     TITRAQ_REPORTWEEK
+#define TITRAQ_PREFREPORTWEEKS  "reportweeks"
+#define TITRAQ_DEFREPORTWEEKS   1
+#define TITRAQ_PREFREPORTMONTHS "reportmonths"
+#define TITRAQ_DEFREPORTMONTHS  1
 
 // Column show preferences
 #define TITRAQ_PREFSTATCOLON    "statcolshow"
@@ -228,6 +234,12 @@
 #define TITRAQ_OFFSETMONTH      7
 #define TITRAQ_OFFSETHOUR       2
 
+// Report periods
+#define TITRAQ_REPORTWEEK       0
+#define TITRAQ_REPORTMONTH      1
+#define TITRAQ_REPORTBOTH       2
+#define TITRAQ_POPUPMSECS       200
+
 // Values
 #define TITRAQ_MARGIN           10          // Default layout margin
 #define TITRAQ_SPACING          6           // Default layout spacing


ossp-pkg/as/as-gui/as_reportpanel.cpp 1.3 -> 1.4

--- as_reportpanel.cpp   2003/02/19 18:23:16     1.3
+++ as_reportpanel.cpp   2003/02/20 16:48:00     1.4
@@ -30,10 +30,11 @@
 //
 
 #include <qvariant.h>
-#include <qgroupbox.h>
 #include <qpushbutton.h>
 #include <qtextedit.h>
 #include <qtoolbutton.h>
+#include <qbuttongroup.h>
+#include <qpopupmenu.h>
 #include <qlayout.h>
 #include <qtooltip.h>
 #include <qwhatsthis.h>
@@ -47,6 +48,7 @@
 #include "as_pref.h"
 #include "as_generic.h"
 #include "as_const.h"
+#include "as_except.h"
 
 // Version information
 #define _AS_VERSION_CPP_AS_HEADER_
@@ -54,6 +56,8 @@
 #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'.
@@ -77,49 +81,83 @@
 
     // Store matrix and prefs members
     m_pReptable = pTable;
-//    m_pReptable->sortColumn(TITRAQ_IDXCOLDATE, true, true);
+    m_pReptable->sortColumn(TITRAQ_IDXDATE, true, true);
     m_pReprefs  = pPreferences;
 
+    // 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_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");
+    m_pBrowser = new QTextEdit(this, "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);
+    m_pFormlay->addWidget(m_pBrowser);
+    m_pFormlay->addLayout(m_pToolay);
+    m_pFormlay->addLayout(m_pPushlay);
 
     // Tool button suite
-    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);
+    m_pWeekmonthgroup = new QButtonGroup(this, "Weekmonthgroup");
+    m_pWeekmonthgroup->setColumnLayout(0, Qt::Horizontal);
+    m_pWeekmonthlay = new QHBoxLayout(m_pWeekmonthgroup->layout());
+    m_pWeekmonthlay->setSpacing(11);
+    m_pWeekmonthlay->setMargin(0);
+    m_pWeekmonthlay->setAlignment(Qt::AlignTop);
+    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->setToggleButton(true);
+    m_pMonthlybutt->setToggleButton(true);
+    m_pBothbutt->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(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)));
+    m_pWeeklybutt->setPopup(m_pWeekpop);
+    m_pWeeklybutt->setPopupDelay(TITRAQ_POPUPMSECS);
+
+    // 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(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)));
+    m_pMonthlybutt->setPopup(m_pMonthpop);
+    m_pMonthlybutt->setPopupDelay(TITRAQ_POPUPMSECS);
+
+    // Add our tool buttons
+    m_pWeekmonthlay->addWidget(m_pWeeklybutt);
+    m_pWeekmonthlay->addWidget(m_pMonthlybutt);
+    m_pWeekmonthlay->addWidget(m_pBothbutt);
+    m_pToolay->addWidget(m_pWeekmonthgroup);
 
     // Push button suite
     m_pSavebutt = new QPushButton(this, "Savebutton");
     m_pDismissbutt = new QPushButton(this, "Dismissbutton");
     m_pPushlay->addWidget(m_pSavebutt);
     m_pPushlay->addWidget(m_pDismissbutt);
-    m_pFormlay->addLayout(m_pPushlay);
 
     // 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_pBothbutt, SIGNAL(clicked(void)), SLOT(reportBoth(void)));
     connect(m_pDismissbutt, SIGNAL(clicked(void)), SLOT(accept(void)));
     connect(m_pSavebutt, SIGNAL(clicked(void)), SLOT(saveReport(void)));
     this->textChange();
@@ -127,23 +165,125 @@
 }
 
 //
+// 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;
+    case TITRAQ_REPORTBOTH:
+        this->reportBoth(1);
+        m_pWeekmonthgroup->setButton(TITRAQ_REPORTBOTH);
+        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 nWeeks)
+void Reportpanel::reportWeeks(int nMenuid)
 {
+    // Menu index, first item is always 0
+    int nIndex = m_pWeekpop->indexOf(nMenuid);
+
+    // Update m_nWeeks only if user prefers a different number
+    if (nIndex >= 0)
+        m_nWeeks = nIndex + 1;
+
+    // User selected N... to indicate an arbitrary number
+    if (nIndex == m_pWeekpop->count() - 1) {
+        Prototype Unimp;
+        Unimp.doMbox();
+    }
+
+    // Set the button in case we arrived from a menu selection
+    m_pWeekmonthgroup->setButton(TITRAQ_REPORTWEEK);
+
+    // Clear data window and write header out
+    m_pBrowser->setUpdatesEnabled(false);
     m_pBrowser->clear();
     this->writeHeader();
     m_pBrowser->append(this->getWeek());
+    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 nMonths)
+void Reportpanel::reportMonths(int nMenuid)
 {
+    // Menu index, first item is always 0
+    int nIndex = m_pMonthpop->indexOf(nMenuid);
+
+    // Update m_nMonths only if user prefers a different number
+    if (nIndex >= 0)
+        m_nMonths = nIndex + 1;
+
+    // User selected N... to indicate an arbitrary number
+    if (nIndex == m_pMonthpop->count() - 1) {
+        Prototype Unimp;
+        Unimp.doMbox();
+    }
+
+    // Set the button in case we arrived from a menu selection
+    m_pWeekmonthgroup->setButton(TITRAQ_REPORTMONTH);
+
+    // Clear data window and write header out
+    m_pBrowser->setUpdatesEnabled(false);
     m_pBrowser->clear();
     this->writeHeader();
     m_pBrowser->append(this->getMonth());
+    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 weeks and months
+//
+void Reportpanel::reportBoth(int nMenuid)
+{
+    // 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();
+    this->writeHeader();
+    m_pBrowser->append(tr("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);
 }
 
 //
@@ -168,6 +308,13 @@
 }
 
 //
+// Writes a report footer to the display window
+//
+void Reportpanel::writeFooter(void)
+{
+}
+
+//
 // Writes one week of data to the display window
 //
 QString Reportpanel::getWeek(QDate Dayref)
@@ -266,7 +413,6 @@
 void Reportpanel::textChange(void)
 {
     this->setCaption(tr("AS local report", "Local report using weekly data or monthly data or both."));
-    m_pGroupbox->setTitle(tr("Local report", "Comment for Groupbox"));
 
     // Top level push buttons associated with accept and save slots
     m_pDismissbutt->setText(tr("Dismiss", "Comment for Dismissbutton"));
@@ -278,12 +424,13 @@
 
     // 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"));
+    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"));
     m_pMonthlybutt->setText(tr("Monthly", "Comment for 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"));
+    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"));
     m_pBothbutt->setText(tr("Both", "Comment for 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"));
+    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"));
 }
+} // namespace AS


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

--- as_reportpanel.h     2003/02/19 18:23:16     1.3
+++ as_reportpanel.h     2003/02/20 16:48:00     1.4
@@ -42,23 +42,25 @@
 class QVBoxLayout;
 class QHBoxLayout;
 class QGridLayout;
-class QGroupBox;
 class QPushButton;
 class QTextEdit;
 class QToolButton;
+class QButtonGroup;
+class QPopupMenu;
+
+namespace AS {
 
 class Reportpanel : public QDialog
 {
     Q_OBJECT
 
 public:
-    Reportpanel(TiTable *pTable, Preferences *pPreferences,
-                QWidget *pParent = 0, const char *kszName = 0,
-                bool bModal = true, WFlags Flags = 0);
+    Reportpanel(TiTable *, Preferences *, 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:
-    QGroupBox    *m_pGroupbox;
+    QButtonGroup *m_pWeekmonthgroup;
     QToolButton  *m_pWeeklybutt;
     QToolButton  *m_pMonthlybutt;
     QToolButton  *m_pBothbutt;
@@ -71,21 +73,32 @@
     QVBoxLayout *m_pGrouplay;
     QHBoxLayout *m_pToolay;
     QHBoxLayout *m_pPushlay;
+    QHBoxLayout *m_pWeekmonthlay;
+    QPopupMenu  *m_pWeekpop;
+    QPopupMenu  *m_pMonthpop;
 
 private:
+    int          m_nWeeks;
+    int          m_nMonths;
     TiTable     *m_pReptable;
     Preferences *m_pReprefs;
 
+public slots:
+    int exec(void);
+
 protected slots:
     virtual void saveReport(void);
     virtual void textChange(void);
-    virtual void reportWeeks(int nWeeks = 1);
-    virtual void reportMonths(int nMonths = 1);
+    virtual void reportWeeks(int nMenuid = -1);
+    virtual void reportMonths(int nMenuid = -1);
+    virtual void reportBoth(int nMenuid = -1);
 
 private:
     void writeHeader(void);
+    void writeFooter(void);
     QString getWeek(QDate Refer = QDate::currentDate());
     QString getMonth(QDate Refer = QDate::currentDate());
 };
+} // namespace AS
 
 #endif // REPORTPANEL_H

CVSTrac 2.0.1