1.1 --- a/as_slot.cpp Fri Nov 28 14:20:00 2008 +0100 1.2 +++ b/as_slot.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,27 +29,40 @@ 1.22 // as_slot.cpp: ISO C++ implementation 1.23 // 1.24 1.25 +#define QT3_SUPPORT 1.26 + 1.27 // system headers 1.28 #include <memory> 1.29 #include <cstring> 1.30 1.31 // Qt headers 1.32 -#include <qfiledialog.h> 1.33 +#include <q3filedialog.h> 1.34 #include <qcombobox.h> 1.35 #include <qclipboard.h> 1.36 #include <qmenudata.h> 1.37 #include <qdatastream.h> 1.38 #include <qstatusbar.h> 1.39 #include <qaction.h> 1.40 -#include <qpopupmenu.h> 1.41 +#include <q3popupmenu.h> 1.42 1.43 // Qt style headers 1.44 #include <qcdestyle.h> 1.45 -#include <qsgistyle.h> 1.46 +#include <qcleanlooksstyle.h> 1.47 +#include <qcommonstyle.h> 1.48 #include <qmotifstyle.h> 1.49 -#include <qmotifplusstyle.h> 1.50 -#include <qplatinumstyle.h> 1.51 +#include <qplastiquestyle.h> 1.52 +#include <qwindowscestyle.h> 1.53 +#include <qwindowsmobilestyle.h> 1.54 #include <qwindowsstyle.h> 1.55 +#include <qwindowsvistastyle.h> 1.56 +#include <qwindowsxpstyle.h> 1.57 + 1.58 +//Added by qt3to4: 1.59 +#include <QPixmap> 1.60 +#include <QCloseEvent> 1.61 +#include <Q3TextStream> 1.62 +#include <Q3MemArray> 1.63 +#include <Q3Action> 1.64 1.65 // User interface 1.66 #include "as_const.h" // Application constants 1.67 @@ -122,8 +135,8 @@ 1.68 1.69 pClip = QApplication::clipboard(); // Prime the clips 1.70 Selection = pClip->text(QClipboard::Clipboard); // Windows and Unix 1.71 - nRows = Selection.contains(QChar('\n')); // How many rows 1.72 - if (Selection != NULL && nRows > 0) { // Ignore empty clipboards 1.73 + nRows = Selection.count(QChar('\n')); // How many rows 1.74 + if (Selection.isNull() && nRows > 0) { // Ignore empty clipboards 1.75 this->addEntry(nRows); // Reuse slot 1.76 setRowdata(Selection); // Use accessor 1.77 1.78 @@ -147,7 +160,7 @@ 1.79 // 1.80 void Titraqform::addEntry(int nRows) 1.81 { 1.82 - QTableSelection Select; // Highlighted text 1.83 + Q3TableSelection Select; // Highlighted text 1.84 int nTotal = 0; // Total row select 1.85 int nCurrent = 0; // Current row 1.86 std::auto_ptr<AS::Uuid> pGuid(new AS::Uuid); // For GUID production 1.87 @@ -180,7 +193,7 @@ 1.88 m_pMaintable->setPixmap(Select.topRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm)); 1.89 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER)); 1.90 pGuid->genId(); 1.91 - m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXGUID, pGuid->getString()); 1.92 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXGUID, QString::fromStdString(pGuid->getString())); 1.93 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXCRC, "0"); // 0 = invalid entry 1.94 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXREV, "0"); // Entry not revised 1.95 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate)); 1.96 @@ -210,7 +223,7 @@ 1.97 m_pMaintable->setPixmap(Select.bottomRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm)); 1.98 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER)); 1.99 pGuid->genId(); 1.100 - m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXGUID, pGuid->getString()); 1.101 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXGUID, QString::fromStdString(pGuid->getString())); 1.102 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXCRC, "0"); 1.103 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXREV, "0"); 1.104 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate)); 1.105 @@ -269,9 +282,9 @@ 1.106 // 1.107 void Titraqform::delEntry(int nRows) 1.108 { 1.109 - QTableSelection Select = m_pMaintable->selection(0); // Highlighted text 1.110 + Q3TableSelection Select = m_pMaintable->selection(0); // Highlighted text 1.111 int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total row select 1.112 - QMemArray<int> Rowselect(nTotal); // Row array 1.113 + Q3MemArray<int> Rowselect(nTotal); // Row array 1.114 1.115 // Calculate rows to delete from selection highlight 1.116 for (int nIter = 0; nIter < nTotal; ++nIter) 1.117 @@ -424,7 +437,7 @@ 1.118 Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1); 1.119 1.120 // This dialog asks which file the user wants to open 1.121 - QString Filestring = QFileDialog::getOpenFileName(Openas, 1.122 + QString Filestring = Q3FileDialog::getOpenFileName(Openas, 1.123 trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"), 1.124 this, trUtf8("ChooserDialog"), trUtf8("Choose a file to open"), NULL, false); 1.125 1.126 @@ -504,7 +517,7 @@ 1.127 Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1); 1.128 1.129 // And then get the name of the selected file to save to 1.130 - QString Filestring = QFileDialog::getSaveFileName(Openas, trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false); 1.131 + QString Filestring = Q3FileDialog::getSaveFileName(Openas, trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false); 1.132 if (!Filestring.isEmpty()) { 1.133 if (QFile::exists(Filestring)) { 1.134 nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE) 1.135 @@ -551,7 +564,7 @@ 1.136 1.137 nResult = 1; // We loop on this dialog only if an indecisive user 1.138 while (nResult > 0) { // is hesitant to overwrite a file over and over again 1.139 - QString Filestring = QFileDialog::getSaveFileName(Openas, trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false); 1.140 + QString Filestring = Q3FileDialog::getSaveFileName(Openas, trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false); 1.141 if (!Filestring.isEmpty()) { 1.142 if (QFile::exists(Filestring)) { 1.143 nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE) 1.144 @@ -1361,7 +1374,7 @@ 1.145 } 1.146 1.147 // Make sure switch take place right away and sizes are handled 1.148 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTATCOL)); 1.149 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTATCOL)); 1.150 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.151 } 1.152 1.153 @@ -1383,7 +1396,7 @@ 1.154 } 1.155 1.156 // Make sure switch take place right away and sizes are handled 1.157 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXLCOL)); 1.158 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXLCOL)); 1.159 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.160 } 1.161 1.162 @@ -1406,7 +1419,7 @@ 1.163 1.164 // Make sure switch take place right away and sizes are handled 1.165 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.166 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXUCOL)); 1.167 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXUCOL)); 1.168 } 1.169 1.170 // 1.171 @@ -1427,7 +1440,7 @@ 1.172 } 1.173 1.174 // Make sure switch take place right away and sizes are handled 1.175 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXGCOL)); 1.176 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXGCOL)); 1.177 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.178 } 1.179 1.180 @@ -1449,7 +1462,7 @@ 1.181 } 1.182 1.183 // Make sure switch take place right away and sizes are handled 1.184 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXCCOL)); 1.185 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXCCOL)); 1.186 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.187 } 1.188 1.189 @@ -1471,7 +1484,7 @@ 1.190 } 1.191 1.192 // Make sure switch take place right away and sizes are handled 1.193 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREVCOL)); 1.194 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREVCOL)); 1.195 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.196 } 1.197 1.198 @@ -1493,7 +1506,7 @@ 1.199 } 1.200 1.201 // Make sure switch take place right away and sizes are handled 1.202 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXDCOL)); 1.203 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXDCOL)); 1.204 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.205 } 1.206 1.207 @@ -1515,7 +1528,7 @@ 1.208 } 1.209 1.210 // Make sure switch take place right away and sizes are handled 1.211 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL)); 1.212 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL)); 1.213 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.214 } 1.215 1.216 @@ -1537,7 +1550,7 @@ 1.217 } 1.218 1.219 // Make sure switch take place right away and sizes are handled 1.220 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXFCOL)); 1.221 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXFCOL)); 1.222 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.223 } 1.224 1.225 @@ -1559,7 +1572,7 @@ 1.226 } 1.227 1.228 // Make sure switch take place right away and sizes are handled 1.229 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXACOL)); 1.230 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXACOL)); 1.231 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.232 } 1.233 1.234 @@ -1581,7 +1594,7 @@ 1.235 } 1.236 1.237 // Make sure switch take place right away and sizes are handled 1.238 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXTCOL)); 1.239 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXTCOL)); 1.240 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.241 } 1.242 1.243 @@ -1603,7 +1616,7 @@ 1.244 } 1.245 1.246 // Make sure switch take place right away and sizes are handled 1.247 - m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREMCOL)); 1.248 + //m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREMCOL)); 1.249 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.250 } 1.251 1.252 @@ -1726,7 +1739,7 @@ 1.253 1.254 // Fill account log object(s) to marshall and transmit 1.255 int nRow = m_pMaintable->currentRow(); 1.256 - QTableSelection Select = m_pMaintable->selection(0); // Capture selected rows 1.257 + Q3TableSelection Select = m_pMaintable->selection(0); // Capture selected rows 1.258 int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total rows selected 1.259 1.260 // Remember, CORBA::stri_dup creates smart pointers 1.261 @@ -1785,7 +1798,7 @@ 1.262 SOAPProxy Proxy(Endpoint.ascii()); 1.263 1.264 // Fill account log object(s) to marshall and transmit 1.265 - QTableSelection Select = m_pMaintable->selection(0); // Capture selected rows 1.266 + Q3TableSelection Select = m_pMaintable->selection(0); // Capture selected rows 1.267 int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total rows selected 1.268 1.269 // Iterate through the selection of row entries to transmit 1.270 @@ -1879,8 +1892,8 @@ 1.271 1.272 // Remember main window layout and doc positions 1.273 QString Laystring; 1.274 - QTextStream Laystream(&Laystring, IO_WriteOnly); 1.275 - Laystream << *this; // Persist the main window 1.276 + Q3TextStream Laystream(&Laystring, QIODevice::WriteOnly); 1.277 + //Laystream << *this; // Persist the main window 1.278 m_pPrefs->setString(TITRAQ_PREFFRAMELAY, Laystring); 1.279 } 1.280 1.281 @@ -1993,22 +2006,22 @@ 1.282 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE); 1.283 qApp->setStyle(new QCDEStyle); 1.284 } 1.285 - else if (pPrefpanel->getStyle() == TITRAQ_STRSGI) { 1.286 - m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLESGI); 1.287 - qApp->setStyle(new QSGIStyle); 1.288 - } 1.289 + //else if (pPrefpanel->getStyle() == TITRAQ_STRSGI) { // Not supported 1.290 + // m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLESGI); 1.291 + // qApp->setStyle(new QSGIStyle); 1.292 + //} 1.293 else if (pPrefpanel->getStyle() == TITRAQ_STRMOTIF) { 1.294 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMOTIF); 1.295 qApp->setStyle(new QMotifStyle); 1.296 } 1.297 - else if (pPrefpanel->getStyle() == TITRAQ_STRMPLUS) { 1.298 - m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMPLUS); 1.299 - qApp->setStyle(new QMotifPlusStyle); 1.300 - } 1.301 - else if (pPrefpanel->getStyle() == TITRAQ_STRPLAT) { 1.302 - m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEPLAT); 1.303 - qApp->setStyle(new QPlatinumStyle); 1.304 - } 1.305 + //else if (pPrefpanel->getStyle() == TITRAQ_STRMPLUS) { // Not supported 1.306 + // m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMPLUS); 1.307 + // qApp->setStyle(new QMotifPlusStyle); 1.308 + //} 1.309 + //else if (pPrefpanel->getStyle() == TITRAQ_STRPLAT) { // Not supported 1.310 + // m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEPLAT); 1.311 + // qApp->setStyle(new QPlatinumStyle); 1.312 + //} 1.313 else if (pPrefpanel->getStyle() == TITRAQ_STRMSOFT) { 1.314 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMSOFT); 1.315 qApp->setStyle(new QWindowsStyle);