1.1 --- a/as_reportpanel.cpp Fri Nov 28 14:20:00 2008 +0100 1.2 +++ b/as_reportpanel.cpp Fri Dec 05 23:14:02 2008 +0100 1.3 @@ -1,12 +1,12 @@ 1.4 // 1.5 // OSSP asgui - Accounting system graphical user interface 1.6 -// Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) 1.7 -// Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com> 1.8 -// Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com> 1.9 -// Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH 1.10 +// Copyright (c) 2002-2008 The OSSP Project (http://www.ossp.org/) 1.11 +// Copyright (c) 2002-2008 Ralf S. Engelschall <rse@engelschall.com> 1.12 +// Copyright (c) 2002-2008 Michael Schloh von Bennewitz <michael@schloh.com> 1.13 +// Copyright (c) 2002-2008 Cable & Wireless Telecommunications Services GmbH 1.14 // 1.15 // This file is part of OSSP asgui, an accounting system graphical user 1.16 -// interface which can be found at http://www.ossp.org/pkg/tool/asgui/. 1.17 +// interface which can be found at http://asgui.europalab.com/. 1.18 // 1.19 // Permission to use, copy, modify, and distribute this software for 1.20 // any purpose with or without fee is hereby granted, provided that 1.21 @@ -29,23 +29,30 @@ 1.22 // as_reportpanel.cpp: ISO C++ implementation 1.23 // 1.24 1.25 +#define QT3_SUPPORT 1.26 + 1.27 #include <qvariant.h> 1.28 #include <qpushbutton.h> 1.29 -#include <qtextedit.h> 1.30 +#include <q3textedit.h> 1.31 #include <qtoolbutton.h> 1.32 -#include <qbuttongroup.h> 1.33 -#include <qpopupmenu.h> 1.34 +#include <q3buttongroup.h> 1.35 +#include <q3popupmenu.h> 1.36 #include <qlayout.h> 1.37 #include <qtooltip.h> 1.38 -#include <qwhatsthis.h> 1.39 -#include <qtextstream.h> 1.40 -#include <qfiledialog.h> 1.41 +#include <q3whatsthis.h> 1.42 +#include <q3textstream.h> 1.43 +#include <q3filedialog.h> 1.44 #include <qprinter.h> 1.45 -#include <qpaintdevicemetrics.h> 1.46 +#include <q3paintdevicemetrics.h> 1.47 #include <qpainter.h> 1.48 #include <qfile.h> 1.49 #include <qdir.h> 1.50 1.51 +//Added by qt3to4: 1.52 +#include <Q3HBoxLayout> 1.53 +#include <Q3Frame> 1.54 +#include <Q3VBoxLayout> 1.55 + 1.56 #include "as_reportpanel.h" 1.57 #include "as_numdial.h" 1.58 #include "as_table.h" 1.59 @@ -71,7 +78,7 @@ 1.60 // 1.61 Reportpanel::Reportpanel(TiTable *pTable, Preferences *pPreferences, 1.62 QWidget *pParent, const char *kszName, 1.63 - bool bModal, WFlags Flags) 1.64 + bool bModal, Qt::WFlags Flags) 1.65 : QDialog(pParent, kszName, bModal, Flags) 1.66 { 1.67 // Boilerplate code to initialize the panel 1.68 @@ -93,13 +100,13 @@ 1.69 m_nMonths = m_pReprefs->getNumber(TITRAQ_PREFREPORTMONTHS, TITRAQ_DEFREPORTMONTHS); 1.70 1.71 // Build panel using already constructed widgets and layouts 1.72 - m_pFormlay = new QVBoxLayout(this, 11, 6, "Formlayout"); 1.73 - m_pToolay = new QHBoxLayout(0, 0, 6, "Toolbuttonlay"); 1.74 - m_pPushlay = new QHBoxLayout(0, 0, 6, "Pushbuttonlay"); 1.75 + m_pFormlay = new Q3VBoxLayout(this, 11, 6, "Formlayout"); 1.76 + m_pToolay = new Q3HBoxLayout(0, 0, 6, "Toolbuttonlay"); 1.77 + m_pPushlay = new Q3HBoxLayout(0, 0, 6, "Pushbuttonlay"); 1.78 1.79 // Groupbox and its text display 1.80 - m_pBrowser = new QTextEdit(this, "Reportbrowser"); 1.81 - m_pBrowser->setTextFormat(PlainText); 1.82 + m_pBrowser = new Q3TextEdit(this, "Reportbrowser"); 1.83 + m_pBrowser->setTextFormat(Qt::PlainText); 1.84 m_pBrowser->setReadOnly(true); 1.85 m_pBrowser->setFont(QFont("Courier", 10)); 1.86 m_pFormlay->addWidget(m_pBrowser); 1.87 @@ -109,26 +116,26 @@ 1.88 m_pFormlay->addLayout(m_pPushlay); 1.89 1.90 // Tool button suite 1.91 - m_pWeekmonthgroup = new QButtonGroup(this, "Weekmonthgroup"); 1.92 + m_pWeekmonthgroup = new Q3ButtonGroup(this, "Weekmonthgroup"); 1.93 m_pWeekmonthgroup->setColumnLayout(0, Qt::Horizontal); 1.94 m_pWeekmonthgroup->layout()->setSpacing(11); 1.95 m_pWeekmonthgroup->layout()->setMargin(0); 1.96 - m_pWeekmonthlay = new QHBoxLayout(m_pWeekmonthgroup->layout()); 1.97 - m_pWeekmonthgroup->setFrameShape(QFrame::NoFrame); 1.98 + m_pWeekmonthlay = new Q3HBoxLayout(m_pWeekmonthgroup->layout()); 1.99 + //m_pWeekmonthgroup->setFrameShape(QFrame::NoFrame); 1.100 m_pWeekmonthgroup->setExclusive(true); 1.101 m_pWeeklybutt = new QToolButton(m_pWeekmonthgroup, "Weeklybutton"); 1.102 // m_pWeeklybutt->setPaletteBackgroundColor(QColor(198, 196, 186)); 1.103 - m_pWeeklybutt->setFocusPolicy(QWidget::TabFocus); 1.104 + m_pWeeklybutt->setFocusPolicy(Qt::TabFocus); 1.105 m_pWeeklybutt->setCursor(QCursor(13)); 1.106 m_pWeeklybutt->setToggleButton(true); 1.107 m_pMonthlybutt = new QToolButton(m_pWeekmonthgroup, "Monthlybutton"); 1.108 // m_pMonthlybutt->setPaletteBackgroundColor(QColor(198, 196, 186)); 1.109 - m_pMonthlybutt->setFocusPolicy(QWidget::TabFocus); 1.110 + m_pMonthlybutt->setFocusPolicy(Qt::TabFocus); 1.111 m_pMonthlybutt->setCursor(QCursor(13)); 1.112 m_pMonthlybutt->setToggleButton(true); 1.113 1.114 // Popup for number of weeks 1.115 - m_pWeekpop = new QPopupMenu(this); 1.116 + m_pWeekpop = new Q3PopupMenu(this); 1.117 if (m_pWeekpop == NULL) // Sanity check 1.118 throw Genexcept("Weekly toolbutton popup creation failed."); 1.119 m_pWeekpop->insertItem(trUtf8("One week"), this, SLOT(reportWeeks(int))); 1.120 @@ -146,7 +153,7 @@ 1.121 } 1.122 1.123 // Popup for number of months 1.124 - m_pMonthpop = new QPopupMenu(this); 1.125 + m_pMonthpop = new Q3PopupMenu(this); 1.126 if (m_pMonthpop == NULL) // Sanity check 1.127 throw Genexcept("Monthly toolbutton popup creation failed."); 1.128 m_pMonthpop->insertItem(trUtf8("One month"), this, SLOT(reportMonths(int))); 1.129 @@ -525,15 +532,16 @@ 1.130 Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); 1.131 Tempdate = QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate); 1.132 if (!Tempstring.isEmpty() && Firstday <= Tempdate && Tempdate < Lastday) { 1.133 - string Convstring = Tempstring; // Convert to string (can't cast?) 1.134 + string Convstring = Tempstring.toStdString(); // Convert to string (can't cast?) 1.135 QTime Intable = QTime::fromString(m_pReptable->text(nIter, TITRAQ_IDXAMOUNT), Qt::ISODate); 1.136 - int nTothours = QString(Hashtasks[Convstring]).section(':', 0, 0).toInt() + Intable.hour(); 1.137 - int nTotminut = QString(Hashtasks[Convstring]).section(':', 1, 1).toInt() + Intable.minute(); 1.138 + string Gethashed = Hashtasks[Convstring]; 1.139 + int nTothours = QString::fromStdString(Gethashed).section(':', 0, 0).toInt() + Intable.hour();; 1.140 + int nTotminut = QString::fromStdString(Gethashed).section(':', 1, 1).toInt() + Intable.minute(); 1.141 nTothours += nTotminut / 60; 1.142 nTotminut %= 60; 1.143 QString Hours = QString::number(nTothours).rightJustify(3, ' '); 1.144 QString Mins = QString::number(nTotminut).rightJustify(2, '0'); 1.145 - string Timestring = Hours + ':' + Mins; // Convert to string (can't cast?) 1.146 + string Timestring = Hours.toStdString() + ':' + Mins.toStdString(); // Convert to string (can't cast?) 1.147 Hashtasks[Convstring] = Timestring; // Finally store in hashtable 1.148 } 1.149 } 1.150 @@ -544,7 +552,7 @@ 1.151 1.152 // Write the actual data totals to the outgoing string in reverse order 1.153 for (Houriter = Hashhours.begin(); Houriter != Hashhours.end(); Houriter++) 1.154 - Totals = Houriter->first + ' ' + Houriter->second + '\n' + Totals; 1.155 + Totals = QString::fromStdString(Houriter->first + ' ' + Houriter->second + '\n' + Totals.toStdString()); 1.156 1.157 // Write some quick header text to the outgoing string in reverse order 1.158 Totals = QString("------ ----------------------------------------\n") + Totals; 1.159 @@ -631,16 +639,17 @@ 1.160 Tempstring = m_pReptable->text(nIter, TITRAQ_IDXTASK); 1.161 Tempdate = QDate::fromString(m_pReptable->text(nIter, TITRAQ_IDXDATE), Qt::ISODate); 1.162 if (!Tempstring.isEmpty() && Firstday <= Tempdate && Tempdate < Lastday) { 1.163 - string Convstring = Tempstring; // Convert to string (can't cast?) 1.164 + string Convstring = Tempstring.toStdString(); // Convert to string (can't cast?) 1.165 QTime Intable = QTime::fromString(m_pReptable->text(nIter, TITRAQ_IDXAMOUNT), Qt::ISODate); 1.166 - int nTothours = QString(Hashtasks[Convstring]).section(':', 0, 0).toInt() + Intable.hour(); 1.167 - int nTotminut = QString(Hashtasks[Convstring]).section(':', 1, 1).toInt() + Intable.minute(); 1.168 + string Gethashed = Hashtasks[Convstring]; 1.169 + int nTothours = QString::fromStdString(Gethashed).section(':', 0, 0).toInt() + Intable.hour();; 1.170 + int nTotminut = QString::fromStdString(Gethashed).section(':', 1, 1).toInt() + Intable.minute(); 1.171 nTothours += nTotminut / 60; 1.172 nTotminut %= 60; 1.173 QString Hours = QString::number(nTothours).rightJustify(3, ' '); 1.174 QString Mins = QString::number(nTotminut).rightJustify(2, '0'); 1.175 - string Timestring = Hours + ':' + Mins; // Convert to string (can't cast?) 1.176 - Hashtasks[Convstring] = Timestring; // Finally store in hashtable 1.177 + QString Timestring = Hours + ':' + Mins; // Convert to string (can't cast?) 1.178 + Hashtasks[Convstring] = Timestring.toStdString(); // Finally store in hashtable 1.179 } 1.180 } 1.181 1.182 @@ -650,7 +659,7 @@ 1.183 1.184 // Write the actual data totals to the outgoing string in reverse order 1.185 for (Houriter = Hashhours.begin(); Houriter != Hashhours.end(); Houriter++) 1.186 - Totals = Houriter->first + ' ' + Houriter->second + '\n' + Totals; 1.187 + Totals = QString::fromStdString(Houriter->first + ' ' + Houriter->second + '\n' + Totals.toStdString()); 1.188 1.189 // Write some quick header text to the outgoing string in reverse order 1.190 Totals = QString("------ ----------------------------------------\n") + Totals; 1.191 @@ -670,7 +679,7 @@ 1.192 QString Openas = m_pReprefs->getString(TITRAQ_PREFHOME, TITRAQ_DEFHOME); 1.193 1.194 // And then get the name of the selected file to save to 1.195 - Filestring = QFileDialog::getSaveFileName(Openas, trUtf8("Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false); 1.196 + Filestring = Q3FileDialog::getSaveFileName(Openas, trUtf8("Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false); 1.197 if (!Filestring.isEmpty()) { 1.198 if (QFile::exists(Filestring)) { 1.199 nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE) 1.200 @@ -678,16 +687,16 @@ 1.201 trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1); 1.202 if (nResult = QMessageBox::Ok) { // Overwrite a file 1.203 Report.setName(Filestring); // User wished name 1.204 - Report.open(IO_WriteOnly | IO_Truncate); // Open report file 1.205 - QTextStream Outstream(&Report); // Convert to stream 1.206 + Report.open(QIODevice::WriteOnly | QIODevice::Truncate); // Open report file 1.207 + Q3TextStream Outstream(&Report); // Convert to stream 1.208 Outstream << m_pBrowser->text(); // Write the data 1.209 Report.close(); // Finish by closing 1.210 } 1.211 } 1.212 else { // User gave a file name, and there was no preexisting file there 1.213 Report.setName(Filestring); // User wished name 1.214 - Report.open(IO_WriteOnly | IO_Truncate); // Open report file 1.215 - QTextStream Outstream(&Report); // Convert to stream 1.216 + Report.open(QIODevice::WriteOnly | QIODevice::Truncate); // Open report file 1.217 + Q3TextStream Outstream(&Report); // Convert to stream 1.218 Outstream << m_pBrowser->text(); // Write the data 1.219 Report.close(); // Finish by closing 1.220 } 1.221 @@ -707,7 +716,7 @@ 1.222 Paint.begin(m_pPrinter); // Paint on printer 1.223 Paint.setFont(m_pBrowser->font()); 1.224 QFontMetrics Fontmetrics = Paint.fontMetrics(); 1.225 - QPaintDeviceMetrics Devmetrics(m_pPrinter); // Need width/height of printer surface 1.226 + Q3PaintDeviceMetrics Devmetrics(m_pPrinter); // Need width/height of printer surface 1.227 const int knMargin = Devmetrics.logicalDpiX() / 2; // Half-inch margin 1.228 int nYpos = knMargin; // Y position for each line 1.229 int nPageno = 1; // The starting page number 1.230 @@ -743,20 +752,20 @@ 1.231 // Top level push buttons associated with accept and save slots 1.232 m_pSavebutt->setText(trUtf8("Save As...", "Comment for Savebutton")); 1.233 QToolTip::add(m_pSavebutt, trUtf8("Saves the report text", "Comment for tooltip Savebutton")); 1.234 - QWhatsThis::add(m_pSavebutt, trUtf8("The save button saves the report text to a file", "Comment for whatsThis Savebutton")); 1.235 + Q3WhatsThis::add(m_pSavebutt, trUtf8("The save button saves the report text to a file", "Comment for whatsThis Savebutton")); 1.236 m_pPrintbutt->setText(trUtf8("Print...", "Comment for Printbutton")); 1.237 QToolTip::add(m_pPrintbutt, trUtf8("Print the report text", "Comment for tooltip Printbutton")); 1.238 - QWhatsThis::add(m_pPrintbutt, trUtf8("The print button prints the report text to a file", "Comment for whatsThis Printbutton")); 1.239 + Q3WhatsThis::add(m_pPrintbutt, trUtf8("The print button prints the report text to a file", "Comment for whatsThis Printbutton")); 1.240 m_pDismissbutt->setText(trUtf8("Dismiss", "Comment for Dismissbutton")); 1.241 QToolTip::add(m_pDismissbutt, trUtf8("Closes the report panel", "Comment for tooltip Dismissbutton")); 1.242 - QWhatsThis::add(m_pDismissbutt, trUtf8("The dismiss button dismisses the report panel", "Comment for whatsThis Dismissbutton")); 1.243 + Q3WhatsThis::add(m_pDismissbutt, trUtf8("The dismiss button dismisses the report panel", "Comment for whatsThis Dismissbutton")); 1.244 1.245 // Inner tool buttons for new local report generation 1.246 m_pWeeklybutt->setText(trUtf8("Weekly", "Comment for Weeklybutt")); 1.247 QToolTip::add(m_pWeeklybutt, trUtf8("Hold down for options", "Comment for tooltip Weeklybutt")); 1.248 - 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")); 1.249 + Q3WhatsThis::add(m_pWeeklybutt, trUtf8("The Weekly button generates a new weekly report.\nHold this button down to specify many weeks.", "Comment for whatsThis Weeklybutt")); 1.250 m_pMonthlybutt->setText(trUtf8("Monthly", "Comment for Monthlybutt")); 1.251 QToolTip::add(m_pMonthlybutt, trUtf8("Hold down for options", "Comment for tooltip Monthlybutt")); 1.252 - 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.253 + Q3WhatsThis::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.254 } 1.255 } // namespace AS