1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/as_slot.cpp Fri Nov 28 11:21:08 2008 +0100 1.3 @@ -0,0 +1,2018 @@ 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 +// 1.11 +// This file is part of OSSP asgui, an accounting system graphical user 1.12 +// interface which can be found at http://www.ossp.org/pkg/tool/asgui/. 1.13 +// 1.14 +// Permission to use, copy, modify, and distribute this software for 1.15 +// any purpose with or without fee is hereby granted, provided that 1.16 +// the above copyright notice and this permission notice appear in all 1.17 +// copies. 1.18 +// 1.19 +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 1.20 +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1.21 +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.22 +// IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 1.23 +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.24 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.25 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 1.26 +// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 1.27 +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1.28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1.29 +// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.30 +// SUCH DAMAGE. 1.31 +// 1.32 +// as_slot.cpp: ISO C++ implementation 1.33 +// 1.34 + 1.35 +// system headers 1.36 +#include <memory> 1.37 +#include <cstring> 1.38 + 1.39 +// Qt headers 1.40 +#include <qfiledialog.h> 1.41 +#include <qcombobox.h> 1.42 +#include <qclipboard.h> 1.43 +#include <qmenudata.h> 1.44 +#include <qdatastream.h> 1.45 +#include <qstatusbar.h> 1.46 +#include <qaction.h> 1.47 +#include <qpopupmenu.h> 1.48 + 1.49 +// Qt style headers 1.50 +#include <qcdestyle.h> 1.51 +#include <qsgistyle.h> 1.52 +#include <qmotifstyle.h> 1.53 +#include <qmotifplusstyle.h> 1.54 +#include <qplatinumstyle.h> 1.55 +#include <qwindowsstyle.h> 1.56 + 1.57 +// User interface 1.58 +#include "as_const.h" // Application constants 1.59 +#include "as_except.h" // Exception classes 1.60 +#include "as_tableitem.h" // For our custom table items 1.61 +#include "as_generic.h" // Generic classes 1.62 +#include "as_uuid.h" // UUID classes 1.63 +#include "as_datedit.h" // Derived from QDateEdit 1.64 +#include "as_amount.h" // Derived from QTimeEdit 1.65 +#include "as_crc.h" // Useful Qualistring class 1.66 +#include "as_pref.h" // For Preferences class 1.67 +#include "as_panel.h" // For Prefpanel class 1.68 +#include "as_reportpanel.h" // For Reportpanel class 1.69 +#include "as_helpanel.h" // For Helpanel class 1.70 +#include "as_sfile.h" // For Simplefile class 1.71 +#include "as_table.h" // For TiTable class 1.72 + 1.73 +// RPC headers 1.74 +#ifdef HAVE_ESOAP 1.75 +#include <easysoap/SOAP.h> 1.76 +#endif // HAVE_ESOAP 1.77 +#ifdef HAVE_MICO 1.78 +#include <coss/CosNaming.h> 1.79 +#include "as_stub.h" // CORBA stubs and skeletons 1.80 +#endif // HAVE_MICO 1.81 + 1.82 +// Icon pixel maps 1.83 +#include "as_gfx/cwlogo.xpm" // static const char *s_kpcCwlogo_xpm[] 1.84 +#include "as_gfx/ossplogo.xpm" // static const char *s_kpcOssplogo_xpm[] 1.85 +#include "as_gfx/statok.xpm" // static const char *s_kpcStatokay_xpm[] 1.86 +#include "as_gfx/staterr.xpm" // static const char *s_kpcStaterror_xpm[] 1.87 +#include "as_gfx/statwrn.xpm" // static const char *s_kpcStatwarn_xpm[] 1.88 +#include "as_gfx/statvoid.xpm" // static const char *s_kpcStatvoid_xpm[] 1.89 + 1.90 + 1.91 +// 1.92 +// Cut an entry 1.93 +// 1.94 +void Titraqform::cutEntry(void) 1.95 +{ 1.96 + this->copyEntry(); // Reuse slot 1.97 + this->delEntry(); // Reuse slot 1.98 +} 1.99 + 1.100 +// 1.101 +// Copy an entry 1.102 +// 1.103 +void Titraqform::copyEntry(void) 1.104 +{ 1.105 + QString Selection; // Will hold the selected text 1.106 + QClipboard *pClip; // Will reference the global clipboard 1.107 + 1.108 + // Initialize data and clipboard handle 1.109 + Selection = getRowdata(); // Use accessor 1.110 + pClip = QApplication::clipboard(); 1.111 + 1.112 + Q_ASSERT(!Selection.isNull()); 1.113 + pClip->setText(Selection, QClipboard::Selection); // Doesn't work on Windows 1.114 + pClip->setText(Selection, QClipboard::Clipboard); // Works on both equally 1.115 +} 1.116 + 1.117 +// 1.118 +// Paste an entry 1.119 +// 1.120 +void Titraqform::pasteEntry(void) 1.121 +{ 1.122 + int nRows = 0; // Paste so many rows as are stored 1.123 + QString Selection; // Will receive the clipboard text 1.124 + QClipboard *pClip = NULL; // Will reference the global clipboard 1.125 + 1.126 + pClip = QApplication::clipboard(); // Prime the clips 1.127 + Selection = pClip->text(QClipboard::Clipboard); // Windows and Unix 1.128 + nRows = Selection.contains(QChar('\n')); // How many rows 1.129 + if (Selection != NULL && nRows > 0) { // Ignore empty clipboards 1.130 + this->addEntry(nRows); // Reuse slot 1.131 + setRowdata(Selection); // Use accessor 1.132 + 1.133 + // Update line numbers for this new row and all subsequent rows 1.134 + for (int nIter = m_pMaintable->currentRow(); nIter < m_pMaintable->numRows(); nIter++) 1.135 + m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter).rightJustify(4, QChar('0'))); 1.136 + 1.137 + // Do basic data validation to warn against missing fields 1.138 + for (int nIter = 0; nIter < nRows; nIter++) 1.139 + this->validateRow(m_pMaintable->currentRow() + nIter, 0); 1.140 + 1.141 + m_pStatbar->message(QString::number(nRows) + trUtf8(" rows pasted"), 4000); 1.142 + updEdit(m_pMaintable->currentRow()); // Reflect in the update controls 1.143 + } 1.144 + else // Well, I guess the user tried to paste an empty clipboard 1.145 + m_pStatbar->message(trUtf8("The clipboard is empty"), 4000); 1.146 +} 1.147 + 1.148 +// 1.149 +// Append a blank row entry 1.150 +// 1.151 +void Titraqform::addEntry(int nRows) 1.152 +{ 1.153 + QTableSelection Select; // Highlighted text 1.154 + int nTotal = 0; // Total row select 1.155 + int nCurrent = 0; // Current row 1.156 + std::auto_ptr<AS::Uuid> pGuid(new AS::Uuid); // For GUID production 1.157 + 1.158 + // Decide how many rows to add 1.159 + Select = m_pMaintable->selection(0); 1.160 + if (nRows > 0) 1.161 + nTotal = nRows; 1.162 + else 1.163 + nTotal = Select.bottomRow() - Select.topRow() + 1; 1.164 + 1.165 + // Optimize viewing by repainting cells only once after processing 1.166 + m_pMaintable->setUpdatesEnabled(false); 1.167 + 1.168 + // Add a row after selection and focus to the new row 1.169 + if (Select.bottomRow() + 1 != m_pMaintable->numRows()) { // Add upwards 1.170 + m_pMaintable->insertRows(Select.topRow(), nTotal); 1.171 + m_pMaintable->setDirty(); // Set data to dirty state 1.172 + m_pMaintable->setCurrentCell(Select.topRow(), m_pMaintable->currentColumn()); 1.173 + 1.174 + // According to Trolltech, insertRows() "clears the selection(s)". 1.175 + // They are pretty wrong about that, so unfortunately we'll have to 1.176 + // take care of the dirty work ourselves with a clearSelection(). 1.177 + m_pMaintable->clearSelection(false); 1.178 + m_pMaintable->selectRow(m_pMaintable->currentRow()); 1.179 + 1.180 + // Update relevant data fields for all new rows 1.181 + for (int nIter = 0; nIter < nTotal; nIter++) { 1.182 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXSTATUS, QString(QChar('W'))); 1.183 + m_pMaintable->setPixmap(Select.topRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm)); 1.184 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER)); 1.185 + pGuid->genId(); 1.186 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXGUID, pGuid->getString()); 1.187 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXCRC, "0"); // 0 = invalid entry 1.188 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXREV, "0"); // Entry not revised 1.189 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate)); 1.190 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXSTART, "00:00"); 1.191 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXFINISH, "00:00"); 1.192 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXAMOUNT, "00:00"); 1.193 +// m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXTASK, "/"); 1.194 +// m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXREMARK, "Remark"); 1.195 + m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXCRC, "1"); // 0 = invalid entry 1.196 + this->calcCrc(Select.topRow() + nIter, -1); 1.197 + } 1.198 + } 1.199 + else { // Special case on last row add downwards 1.200 + m_pMaintable->insertRows(Select.bottomRow() + 1, nTotal); 1.201 + m_pMaintable->setDirty(); // Set data to dirty state 1.202 + m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn()); 1.203 + 1.204 + // According to Trolltech, insertRows() "clears the selection(s)". 1.205 + // They are pretty wrong about that, so unfortunately we'll have to 1.206 + // take care of the dirty work ourselves with a clearSelection(). 1.207 + m_pMaintable->clearSelection(false); 1.208 + m_pMaintable->selectRow(m_pMaintable->currentRow()); 1.209 + 1.210 + // Update relevant data fields for all new rows 1.211 + for (int nIter = 1; nIter <= nTotal; nIter++) { 1.212 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXSTATUS, QString(QChar('W'))); 1.213 + m_pMaintable->setPixmap(Select.bottomRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm)); 1.214 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER)); 1.215 + pGuid->genId(); 1.216 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXGUID, pGuid->getString()); 1.217 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXCRC, "0"); 1.218 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXREV, "0"); 1.219 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate)); 1.220 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXSTART, "00:00"); 1.221 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXFINISH, "00:00"); 1.222 + m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXAMOUNT, "00:00"); 1.223 +// m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXTASK, "/"); 1.224 +// m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXREMARK, "Remark"); 1.225 + this->calcCrc(Select.bottomRow() + nIter, -1); 1.226 + } 1.227 + } 1.228 + 1.229 + // Update line numbers for this new row and all subsequent rows 1.230 + for (int nIter = m_pMaintable->currentRow(); nIter < m_pMaintable->numRows(); nIter++) 1.231 + m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter).rightJustify(4, QChar('0'))); 1.232 + 1.233 + updEdit(m_pMaintable->currentRow()); // Reflect in the update controls 1.234 + m_pStatusedit->setPixmap(QPixmap(s_kpcStatwarn_xpm)); // Show pixmap 1.235 + 1.236 + m_pMaintable->setUpdatesEnabled(true); // Turn updates back on 1.237 + m_pMaintable->repaintContents(true); // Do a general repaint of table 1.238 + m_pMaintable->ensureCellVisible(m_pMaintable->currentRow() + nTotal - 1, m_pMaintable->currentColumn()); 1.239 + m_pMaintable->ensureCellVisible(m_pMaintable->currentRow(), m_pMaintable->currentColumn()); 1.240 + 1.241 + // In case we added the first and only row entry, 1.242 + // do post state adjustments like icon undimming 1.243 + if (m_pMaintable->numRows() == 1) { 1.244 + m_pDelrowact->setEnabled(true); 1.245 + m_pRefreshact->setEnabled(true); 1.246 + m_pCutact->setEnabled(true); 1.247 + m_pCopyact->setEnabled(true); 1.248 + 1.249 + // Brighten all the edit controls also 1.250 + m_pLineedit->setEnabled(true); 1.251 + m_pUseredit->setEnabled(true); 1.252 + m_pGuidedit->setEnabled(true); 1.253 + m_pCrcedit->setEnabled(true); 1.254 + m_pRevedit->setEnabled(true); 1.255 + m_pDateedit->setEnabled(true); 1.256 + m_pStarttime->setEnabled(true); 1.257 + m_pEndtime->setEnabled(true); 1.258 + m_pAmount->setEnabled(true); 1.259 + m_pTasks->setEnabled(true); 1.260 + m_pRemark->setEnabled(true); 1.261 + 1.262 + // And optionally the RPC actions, too 1.263 +#if defined HAVE_MICO || defined HAVE_ESOAP 1.264 + m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON) 1.265 + | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)); 1.266 +#endif // HAVE_MICO || defined HAVE_ESOAP 1.267 + } 1.268 +} 1.269 + 1.270 +// 1.271 +// Delete a row entry 1.272 +// 1.273 +void Titraqform::delEntry(int nRows) 1.274 +{ 1.275 + QTableSelection Select = m_pMaintable->selection(0); // Highlighted text 1.276 + int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total row select 1.277 + QMemArray<int> Rowselect(nTotal); // Row array 1.278 + 1.279 + // Calculate rows to delete from selection highlight 1.280 + for (int nIter = 0; nIter < nTotal; ++nIter) 1.281 + Rowselect[nIter] = Select.topRow() + nIter; 1.282 + 1.283 + // Remove the row at selection and focus to the next row 1.284 + if (m_pMaintable->currentRow() + 1 != m_pMaintable->numRows()) { 1.285 + m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn()); 1.286 + m_pMaintable->removeRows(Rowselect); 1.287 + m_pMaintable->setDirty(); // Set data to dirty state 1.288 + } 1.289 + else { // Special case to handle removing of only row or last row 1.290 + m_pMaintable->removeRows(Rowselect); 1.291 + m_pMaintable->setDirty(); // Set data to dirty state 1.292 + } 1.293 + 1.294 + // Update line numbers for this new row and all subsequent rows 1.295 + for (int nIter = m_pMaintable->currentRow(); nIter < m_pMaintable->numRows(); nIter++) 1.296 + m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter)); 1.297 + 1.298 + // In case we removed the last remaining row, 1.299 + // do post state adjustments like icon dimming 1.300 + if (m_pMaintable->numRows() <= 0) { 1.301 + m_pDelrowact->setEnabled(false); 1.302 + m_pRefreshact->setEnabled(false); 1.303 + m_pCutact->setEnabled(false); 1.304 + m_pCopyact->setEnabled(false); 1.305 + 1.306 + // Dim all the edit controls also 1.307 + m_pStatusedit->setPixmap(s_kpcStatvoid_xpm); 1.308 + m_pLineedit->setEnabled(false); 1.309 + m_pUseredit->setEnabled(false); 1.310 + m_pGuidedit->setEnabled(false); 1.311 + m_pCrcedit->setEnabled(false); 1.312 + m_pRevedit->setEnabled(false); 1.313 + m_pDateedit->setEnabled(false); 1.314 + m_pStarttime->setEnabled(false); 1.315 + m_pEndtime->setEnabled(false); 1.316 + m_pAmount->setEnabled(false); 1.317 + m_pTasks->setEnabled(false); 1.318 + m_pRemark->setEnabled(false); 1.319 + 1.320 + // And optionally dim the RPC actions 1.321 +#if defined HAVE_MICO || defined HAVE_ESOAP 1.322 + m_pSyncact->setEnabled(false); 1.323 +#endif // HAVE_MICO || defined HAVE_ESOAP 1.324 + } 1.325 +} 1.326 + 1.327 +// 1.328 +// Refresh the display of all data items 1.329 +// 1.330 +void Titraqform::refreshDisplay(void) 1.331 +{ 1.332 + int nIter = 0; // Matrix iterator 1.333 + int nRows = m_pMaintable->numRows(); // Total number of rows 1.334 + 1.335 + // Sweep through matrix validating linewise 1.336 + // data and updating line numbers for all rows 1.337 + while (nIter < nRows) { 1.338 + this->validateRow(nIter, 0); 1.339 + m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter).rightJustify(4, QChar('0'))); 1.340 + nIter++; 1.341 + } 1.342 + 1.343 + m_pMaintable->repaintContents(false); // Do a general repaint of table 1.344 + m_pStatbar->message(trUtf8("Display was refreshed"), 4000); // Announce result 1.345 +} 1.346 + 1.347 +// 1.348 +// Make and display a new document window 1.349 +// 1.350 +void Titraqform::newDoc(void) 1.351 +{ 1.352 + int nResult = 0; // Holds return value from save first messagebox 1.353 + 1.354 + // Check modification state of current data 1.355 + if (m_pMaintable->isDirty()) { 1.356 + nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE) 1.357 + + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST), 1.358 + trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2); 1.359 + 1.360 + switch (nResult) { 1.361 + case 0: // First button selected, so save first 1.362 + this->saveFile(); // Save changes first 1.363 + break; 1.364 + case 1: // Second button selected, so don't save 1.365 + break; 1.366 + case 2: // Third button selected, so return sofort 1.367 + default: 1.368 + m_pStatbar->message(trUtf8("New aborted"), 4000); 1.369 + return; 1.370 + break; 1.371 + } 1.372 + } 1.373 + 1.374 + if (!m_pMaintable->isDirty() || nResult == 1) { // Check modification state 1.375 + // Fall through to implicit new doc code 1.376 + this->setCaption(trUtf8("No file name")); 1.377 + m_pStatbar->message(trUtf8("New document"), 4000); 1.378 + this->enableIface(true); // Enable the interface 1.379 + m_pMaintable->setNumRows(0); // Remove all data in table 1.380 + this->setFilename(""); // Signal a closed doc state 1.381 + this->addEntry(1); // Default new op adds a row 1.382 + m_pMaintable->setDirty(false); // Start out clean 1.383 + } 1.384 +} 1.385 + 1.386 +// 1.387 +// Open and display an existing document 1.388 +// 1.389 +void Titraqform::openDoc(void) 1.390 +{ 1.391 + int nResult = 0; // Holds return value from save first messagebox 1.392 + 1.393 +// 1.394 +// This block will guide the user to saving the contents of the timesheet 1.395 +// before losing them in an open operation. The question and dialog box will 1.396 +// not be raised if no open timesheet exists or if it was just serialized. 1.397 +// 1.398 + if (m_pMaintable->isDirty()) { // Check modification state 1.399 + nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE) 1.400 + + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST), 1.401 + trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2); 1.402 + 1.403 + switch (nResult) { 1.404 + case 0: // Save first 1.405 + this->saveFile(); // Save changes first 1.406 + break; 1.407 + case 1: // Don't save first but do load 1.408 + break; 1.409 + case 2: // Don't do a load timesheet 1.410 + default: 1.411 + m_pStatbar->message(trUtf8("Loading aborted"), 4000); 1.412 + return; 1.413 + break; 1.414 + } 1.415 + } 1.416 + 1.417 +// 1.418 +// This block ensures that conditions of first block logic were met if 1.419 +// applicable. If so, the user gives a file name to open or cancels the 1.420 +// operation. The corresponding file will be opened, and if this is 1.421 +// unsuccessful then the post state is exactly the same as the pre state. 1.422 +// 1.423 + if (!m_pMaintable->isDirty() || nResult == 1) { // Check modification state 1.424 + // Make sure we correctly get the name of the default file to open 1.425 + QString Openas = m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR); 1.426 + if (Openas.startsWith(TITRAQ_HOMEDIRTOK)) 1.427 + Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1); 1.428 + 1.429 + // This dialog asks which file the user wants to open 1.430 + QString Filestring = QFileDialog::getOpenFileName(Openas, 1.431 + trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"), 1.432 + this, trUtf8("ChooserDialog"), trUtf8("Choose a file to open"), NULL, false); 1.433 + 1.434 + // We might have a filename to work on, so do something with it 1.435 + if (!Filestring.isEmpty()) { 1.436 + QFile Filetemp(Filestring); // File to load 1.437 + try { 1.438 + if (Filetemp.exists() && validateData(Filetemp)) { // Be extra sure 1.439 + setFilename(Filestring); // Set the new file name 1.440 + m_pMaintable->setNumRows(0); // Clear out old data 1.441 + m_pMaintable->setDirty(false); // Reset dirty flag 1.442 + loadData(Filetemp); // Pass to helper method 1.443 + this->setCaption(Filestring); // Caption in the titlebar 1.444 + m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000); 1.445 + this->enableIface(true); // Turn on the lights 1.446 + this->setOpen(true); // Indicate doc is open 1.447 + } 1.448 + } 1.449 + catch (Genexcept& Genex) { // Crap, we failed 1.450 + m_pStatbar->message(trUtf8("Loading failed"), 4000); 1.451 + Genex.reportErr(); 1.452 + return; 1.453 + } 1.454 + } 1.455 + else // An empty filename returning from the file dialog means cancel 1.456 + m_pStatbar->message(trUtf8("Loading aborted"), 4000); 1.457 + } 1.458 +} 1.459 + 1.460 +// 1.461 +// Serialize current state to the current file 1.462 +// 1.463 +void Titraqform::saveFile(void) 1.464 +{ 1.465 + QString Fname; 1.466 + Simplefile Filevents; 1.467 + 1.468 + try { 1.469 + Fname = *this->getFilename(); 1.470 + 1.471 + // First time saves are really just saveName in disguise 1.472 + if (Fname.isEmpty()) { 1.473 + try { 1.474 + this->saveName(); // Try to 'save as' 1.475 + return; // and short circuit 1.476 + } 1.477 + catch (Genexcept& Genex) { 1.478 +// Genex.reportErr(); // Report the error 1.479 + return; // and short circuit 1.480 + } 1.481 + } 1.482 + 1.483 + Filevents.setName(Fname); // Construct a file to write 1.484 + if (m_pPrefs->getBool(TITRAQ_PREFBAKON, TITRAQ_DEFBAKON)) 1.485 + Filevents.makeBackup(); // Back up to filename.bak 1.486 + this->saveData(Filevents); // Pass to helper method 1.487 + } 1.488 + catch (Genexcept& Genex) { 1.489 + Genex.reportErr(); 1.490 + } 1.491 + // Reset and give output to main window 1.492 + this->setCaption(Fname); 1.493 + m_pStatbar->message(trUtf8("File %1 saved").arg(Fname), 4000); 1.494 + m_pMaintable->setDirty(false); // Set the clean state to allow close 1.495 +} 1.496 + 1.497 +// 1.498 +// Serialize current state to a selected file 1.499 +// 1.500 +void Titraqform::saveAs(void) 1.501 +{ 1.502 + int nResult = 0; // For checking user's answer 1.503 + 1.504 + // Make sure we correctly get the name of the default file to open 1.505 + QString Openas = m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR); 1.506 + if (Openas.startsWith(TITRAQ_HOMEDIRTOK)) 1.507 + Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1); 1.508 + 1.509 + // And then get the name of the selected file to save to 1.510 + 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.511 + if (!Filestring.isEmpty()) { 1.512 + if (QFile::exists(Filestring)) { 1.513 + nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE) 1.514 + + ' ' + asgui_version.v_short, trUtf8(TITRAQ_OVERWRITE), 1.515 + trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1); 1.516 + switch (nResult) { 1.517 + case 0: // Overwrite contents 1.518 + this->setFilename(Filestring); 1.519 + this->saveFile(); 1.520 + break; 1.521 + case 1: // Don't overwrite 1.522 + default: 1.523 + break; 1.524 + } 1.525 + } 1.526 + else { 1.527 + // Conditionally use a unique extension like '.as' if user prefers 1.528 + if (m_pPrefs->getBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON)) { 1.529 + QString Extension = TITRAQ_FEXTENSION; // Logic to handle 1.530 + if (!Filestring.endsWith(Extension)) // AS file extension 1.531 + Filestring += Extension; // insertion 1.532 + } 1.533 + this->setFilename(Filestring); // Set filename of object first 1.534 + this->saveFile(); // Finish by calling the save action 1.535 + } 1.536 + } 1.537 + else 1.538 + // User did not select a valid file and push okay button 1.539 + m_pStatbar->message(trUtf8("Saving aborted"), 4000); 1.540 +} 1.541 + 1.542 +// 1.543 +// Implicitly serialize current state to a selected file 1.544 +// The main difference with saveAs is that this uses exceptions 1.545 +// 1.546 +void Titraqform::saveName(void) 1.547 +{ 1.548 + int nResult = 0; // For checking user's answer 1.549 + 1.550 + // Make sure we correctly get the name of the default file to open 1.551 + QString Openas = m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR); 1.552 + if (Openas.startsWith(TITRAQ_HOMEDIRTOK)) 1.553 + Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1); 1.554 + 1.555 + nResult = 1; // We loop on this dialog only if an indecisive user 1.556 + while (nResult > 0) { // is hesitant to overwrite a file over and over again 1.557 + 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.558 + if (!Filestring.isEmpty()) { 1.559 + if (QFile::exists(Filestring)) { 1.560 + nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE) 1.561 + + ' ' + asgui_version.v_short, trUtf8(TITRAQ_OVERWRITE), 1.562 + trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1); 1.563 + switch (nResult) { 1.564 + case 0: // Overwrite contents 1.565 + this->setFilename(Filestring); 1.566 + this->saveFile(); 1.567 + break; 1.568 + case 1: // Don't overwrite 1.569 + default: 1.570 + break; 1.571 + } 1.572 + } 1.573 + else { 1.574 + 1.575 + // Conditionally use a unique extension like '.as' if user prefers 1.576 + if (m_pPrefs->getBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON)) { 1.577 + QString Extension = TITRAQ_FEXTENSION; // Logic to handle 1.578 + if (!Filestring.endsWith(Extension)) // AS file extension 1.579 + Filestring += Extension; // insertion 1.580 + } 1.581 + this->setFilename(Filestring); // Set filename of object first 1.582 + nResult = 0; // Reset our loop control 1.583 + this->saveFile(); // Finish by calling the save action 1.584 + } 1.585 + } 1.586 + else { 1.587 + // User did not select a valid file and push okay button 1.588 + m_pStatbar->message(trUtf8("Saving aborted"), 4000); 1.589 + throw Genexcept(TITRAQ_SAVECANCELLED); 1.590 + } 1.591 + } 1.592 +} 1.593 + 1.594 +// 1.595 +// Close current document, and then quit the application 1.596 +// 1.597 +void Titraqform::quitApp(void) 1.598 +{ 1.599 + int nResult = 0; 1.600 + 1.601 + if (m_pMaintable->isDirty()) { 1.602 + nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE) 1.603 + + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST), 1.604 + trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2); 1.605 + 1.606 + switch (nResult) { // Maybe save before closing 1.607 + case 0: // Save first 1.608 + this->saveFile(); // Save changes first 1.609 + break; 1.610 + case 1: // Don't save first 1.611 + m_pMaintable->setDirty(false); 1.612 + break; 1.613 + case 2: // Do nothing 1.614 + default: 1.615 + return; // Go away without closing 1.616 + break; 1.617 + } 1.618 + } 1.619 + 1.620 + // We should be clean now, but double check just in case 1.621 + if (!m_pMaintable->isDirty()) 1.622 + qApp->quit(); 1.623 +} 1.624 + 1.625 +// 1.626 +// Close current document, displaying in main window 1.627 +// 1.628 +void Titraqform::closeEvent(QCloseEvent *pClosit) 1.629 +{ 1.630 + int nResult = 0; 1.631 + 1.632 + if (!this->isOpen()) // Short circuit if user 1.633 + qApp->quit(); // selects close twice 1.634 + 1.635 + // Check modification state of current data 1.636 + if (m_pMaintable->isDirty()) { 1.637 + nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE) 1.638 + + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST), 1.639 + trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2); 1.640 + 1.641 + switch (nResult) { // Maybe save before closing 1.642 + case 0: // Save first 1.643 + this->saveFile(); // Save changes first 1.644 + break; 1.645 + case 1: // Don't save first 1.646 + m_pMaintable->setDirty(false); 1.647 + break; 1.648 + case 2: // Do nothing 1.649 + default: 1.650 + pClosit->ignore(); 1.651 + return; // Go away without closing 1.652 + break; 1.653 + } 1.654 + } 1.655 + 1.656 + if (!m_pMaintable->isDirty()) { // Check again 1.657 + // Fall through to implicit close code 1.658 + this->setCaption(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short); 1.659 + try { // There might be problems, so wrap these last ops with error handling 1.660 + QString Lightsout; // It's late, go to bed 1.661 + if (this->isOpen()) 1.662 + Lightsout = trUtf8("Closed document ") + *this->getFilename(); 1.663 + this->setOpen(false); // Set doc state to closed 1.664 + this->enableIface(false); // Turn off the lights 1.665 + m_pStatbar->message(Lightsout, 4000); 1.666 + } 1.667 + catch (Genexcept& Genex) { 1.668 + Genex.reportErr(); 1.669 + } 1.670 + } 1.671 + pClosit->ignore(); // Finish off by not closing 1.672 +} 1.673 + 1.674 +// 1.675 +// Edit menu select all entries 1.676 +// 1.677 +void Titraqform::selAll(void) 1.678 +{ 1.679 + Prototype Unimp; 1.680 + Unimp.doMbox(); 1.681 +} 1.682 + 1.683 +// 1.684 +// Edit a table entry in place, without the usual edit controls 1.685 +// 1.686 +void Titraqform::inplaceEdit(int nRow, int nCol, int nButton, const QPoint &Mousepos) 1.687 +{ 1.688 + // Table read only attribute must be reset here, so that editing can take 1.689 + // place. Otherwise calls to editCell are ignored (for obvious reasons). 1.690 + m_pMaintable->setReadOnly(false); 1.691 + 1.692 + // After editCell() is called, beginEdit() and endEdit() execute. The read 1.693 + // only attribute is reset in endEdit() to return everything to normal. 1.694 + m_pMaintable->editCell(nRow, nCol); 1.695 + 1.696 + m_pMaintable->setEdition(nCol); 1.697 +} 1.698 + 1.699 +// 1.700 +// Update the edit controls widget sizes 1.701 +// 1.702 +void Titraqform::updSizes(int nSection, int nOldsize, int nNewsize) 1.703 +{ 1.704 + switch (nSection) { 1.705 + case TITRAQ_IDXALLCTRLS: 1.706 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) > 0) 1.707 + m_pStatusedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) - TITRAQ_SPACING); 1.708 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) > 0) 1.709 + m_pLineedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) - TITRAQ_SPACING); 1.710 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) > 0) 1.711 + m_pUseredit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) - TITRAQ_SPACING); 1.712 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) > 0) 1.713 + m_pGuidedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) - TITRAQ_SPACING); 1.714 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) > 0) 1.715 + m_pCrcedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) - TITRAQ_SPACING); 1.716 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) > 0) 1.717 + m_pRevedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) - TITRAQ_SPACING); 1.718 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) > 0) 1.719 + m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING); 1.720 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) > 0) 1.721 + m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING); 1.722 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) > 0) 1.723 + m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING); 1.724 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) > 0) 1.725 + m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING); 1.726 + if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) > 0) 1.727 + m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING); 1.728 +// if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXRCOL))) 1.729 +// m_pRemark->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREMARK) - TITRAQ_SPACING); 1.730 + break; 1.731 + case TITRAQ_IDXSTATUS: 1.732 + m_pStatusedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) - TITRAQ_SPACING); 1.733 + break; 1.734 + case TITRAQ_IDXLINE: 1.735 + m_pLineedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) - TITRAQ_SPACING); 1.736 + break; 1.737 + case TITRAQ_IDXUSER: 1.738 + m_pUseredit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) - TITRAQ_SPACING); 1.739 + break; 1.740 + case TITRAQ_IDXGUID: 1.741 + m_pGuidedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) - TITRAQ_SPACING); 1.742 + break; 1.743 + case TITRAQ_IDXCRC: 1.744 + m_pCrcedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) - TITRAQ_SPACING); 1.745 + break; 1.746 + case TITRAQ_IDXREV: 1.747 + m_pRevedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) - TITRAQ_SPACING); 1.748 + break; 1.749 + case TITRAQ_IDXDATE: 1.750 + m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING); 1.751 + break; 1.752 + case TITRAQ_IDXSTART: 1.753 + m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING); 1.754 + break; 1.755 + case TITRAQ_IDXFINISH: 1.756 + m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING); 1.757 + break; 1.758 + case TITRAQ_IDXAMOUNT: 1.759 + m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING); 1.760 + break; 1.761 + case TITRAQ_IDXTASK: 1.762 + m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING); 1.763 + break; 1.764 + case TITRAQ_IDXREMARK: 1.765 +// m_pRemark->setFixedWidth(nNewsize); 1.766 + break; 1.767 + default: 1.768 + throw Genexcept("Unrecognized main window column header."); 1.769 + break; 1.770 + } 1.771 + 1.772 + // As a last and redundant step, adjust size of first visible control 1.773 + switch(this->getFirstcol()) { 1.774 + case TITRAQ_IDXSTATUS: 1.775 + m_pStatusedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.776 + break; 1.777 + case TITRAQ_IDXLINE: 1.778 + m_pLineedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.779 + break; 1.780 + case TITRAQ_IDXUSER: 1.781 + m_pUseredit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.782 + break; 1.783 + case TITRAQ_IDXGUID: 1.784 + m_pGuidedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.785 + break; 1.786 + case TITRAQ_IDXCRC: 1.787 + m_pCrcedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.788 + break; 1.789 + case TITRAQ_IDXREV: 1.790 + m_pRevedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.791 + break; 1.792 + case TITRAQ_IDXDATE: 1.793 + m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.794 + break; 1.795 + case TITRAQ_IDXSTART: 1.796 + m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.797 + break; 1.798 + case TITRAQ_IDXFINISH: 1.799 + m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.800 + break; 1.801 + case TITRAQ_IDXAMOUNT: 1.802 + m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.803 + break; 1.804 + case TITRAQ_IDXTASK: 1.805 + m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING + TITRAQ_SPACING / 2); 1.806 + break; 1.807 + default: // Probably no columns are visible? 1.808 + break; 1.809 + } 1.810 +} 1.811 + 1.812 +// 1.813 +// What to do if a data cell is modified 1.814 +// 1.815 +void Titraqform::dataChanged(int nRow, int nCol) 1.816 +{ 1.817 + if (nCol != TITRAQ_IDXSTATUS && nCol != TITRAQ_IDXLINE) 1.818 + m_pMaintable->setDirty(); // Mark this timesheet dirty, changes pending save 1.819 +} 1.820 + 1.821 +// 1.822 +// Convenience member calculates CRC for current row 1.823 +// 1.824 +void Titraqform::calcCrc(void) 1.825 +{ 1.826 + this->calcCrc(-1, -1); 1.827 +} 1.828 + 1.829 +// 1.830 +// Calculates CRC for the specified row, fires when data is changed 1.831 +// 1.832 +void Titraqform::calcCrc(int nRow, int nCol) 1.833 +{ 1.834 + if (nCol != TITRAQ_IDXSTATUS && nCol != TITRAQ_IDXLINE \ 1.835 + && m_pMaintable->numRows() > 0) { 1.836 + U32 Testcrc, Valcrc; 1.837 + QString Crcstr; 1.838 + std::auto_ptr<Qualistring>pWholerow(new Qualistring); 1.839 + int nRealrow = -1; 1.840 + 1.841 + // Build the data that will be used in testing CRC calculation 1.842 + nRealrow = (nRow >= 0) ? nRow : m_pMaintable->currentRow(); 1.843 + *pWholerow = m_pMaintable->text(nRealrow, TITRAQ_IDXUSER); 1.844 + for (int nIter = TITRAQ_IDXUSER + 1; nIter < TITRAQ_IDXTAIL; nIter++) 1.845 + if (nIter != TITRAQ_IDXCRC) // Don't checksum the checksum! 1.846 + *pWholerow += m_pMaintable->text(nRealrow, nIter); 1.847 + 1.848 + // Update the checksum and revision only if necessary 1.849 + Testcrc = pWholerow->getCrc(); 1.850 + 1.851 + // FIXME: This thing is not very unportable, because toUInt != U32 1.852 + if (Testcrc != m_pMaintable->text(nRealrow, TITRAQ_IDXCRC).toUInt()) { 1.853 + 1.854 +// // Bump the revision number of our entry to control conflicts 1.855 +// nNewrev = m_pMaintable->text(nRealrow, TITRAQ_IDXREV).toInt() + 1; 1.856 +// m_pMaintable->setText(nRealrow, TITRAQ_IDXREV, QString::number(nNewrev)); 1.857 + 1.858 + // Build the data that will be used in setting CRC calculation 1.859 + *pWholerow = m_pMaintable->text(nRealrow, TITRAQ_IDXUSER); 1.860 + for (int nIter = TITRAQ_IDXUSER + 1; nIter < TITRAQ_IDXTAIL; nIter++) 1.861 + if (nIter != TITRAQ_IDXCRC) // Don't checksum the checksum! 1.862 + *pWholerow += m_pMaintable->text(nRealrow, nIter); 1.863 + 1.864 + Valcrc = pWholerow->getCrc(); // Finally set the checksum to its new value 1.865 + Crcstr = QString::number(Valcrc, 16).rightJustify(8, '0'); 1.866 + m_pMaintable->setText(nRealrow, TITRAQ_IDXCRC, "0x" + Crcstr); 1.867 + m_pCrcedit->setText("0x" + Crcstr); 1.868 + } 1.869 + } 1.870 +} 1.871 + 1.872 +// 1.873 +// Gets a hit on every table click 1.874 +// 1.875 +void Titraqform::onClick(int nRow, int nCol, int nButton, const QPoint &Mousepos) 1.876 +{ 1.877 + // Give the clueless user some hints when clicking an empty timesheet 1.878 + if (m_pMaintable->numRows() <= 0) 1.879 + m_pStatbar->message(trUtf8("Empty timesheet, add entries first please"), 2000); 1.880 +} 1.881 + 1.882 +// 1.883 +// Update the edit controls contents 1.884 +// 1.885 +void Titraqform::updEdit(int nRow, int nCol) 1.886 +{ 1.887 + // Why is the app sending negative row signal? I don't know yet, 1.888 + // so add in this nasty hack to fend off the debug spew on stderr 1.889 + if (m_pMaintable->numRows() > 0 && nRow >= 0) { 1.890 + // Field strings to check for validity and process 1.891 + QString Textline(m_pMaintable->text(nRow, TITRAQ_IDXLINE)); 1.892 + QString Textuser(m_pMaintable->text(nRow, TITRAQ_IDXUSER)); 1.893 + QString Textguid(m_pMaintable->text(nRow, TITRAQ_IDXGUID)); 1.894 + QString Textcrc(m_pMaintable->text(nRow, TITRAQ_IDXCRC)); 1.895 + QString Textrev(m_pMaintable->text(nRow, TITRAQ_IDXREV)); 1.896 + QString Textdate(m_pMaintable->text(nRow, TITRAQ_IDXDATE)); 1.897 + QString Textstart(m_pMaintable->text(nRow, TITRAQ_IDXSTART)); 1.898 + QString Textfinish(m_pMaintable->text(nRow, TITRAQ_IDXFINISH)); 1.899 + QString Textamount(m_pMaintable->text(nRow, TITRAQ_IDXAMOUNT)); 1.900 + QString Texttask(m_pMaintable->text(nRow, TITRAQ_IDXTASK)); 1.901 + QString Textremark(m_pMaintable->text(nRow, TITRAQ_IDXREMARK)); 1.902 + 1.903 + // Reset the edition state member 1.904 + m_pMaintable->setEdition(); 1.905 + 1.906 + // Set text of member edit controls 1.907 + if (m_pMaintable->text(nRow, TITRAQ_IDXSTATUS).isEmpty()) // If row is empty 1.908 + m_pStatusedit->setPixmap(s_kpcStatvoid_xpm); // add a placeholder 1.909 + else 1.910 + m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRow, TITRAQ_IDXSTATUS)); 1.911 + m_pLineedit->setText(Textline); 1.912 + m_pUseredit->setText(Textuser); 1.913 + m_pGuidedit->setText(Textguid); 1.914 + m_pCrcedit->setText(Textcrc); 1.915 + m_pRevedit->setText(Textrev); 1.916 + 1.917 +// QRegExp Shorten("/(\\w+)$"); // For stripping prefix off the current task 1.918 +// Texttask.remove(0, Shorten.search(Texttask) + 1); // Strip leading slash 1.919 + 1.920 + m_pRemark->setText(Textremark); 1.921 + m_pTasks->setCurrentText(Texttask); 1.922 + 1.923 + // Date field not suitable for empty string text 1.924 + if (Textdate == ".") 1.925 + m_pDateedit->setDate(QDate::currentDate()); 1.926 + else if (Textdate.isEmpty()) 1.927 + m_pDateedit->setDate(QDate::fromString("0000-00-00", Qt::ISODate)); 1.928 + else 1.929 + m_pDateedit->setDate(QDate::fromString(Textdate, Qt::ISODate)); 1.930 + 1.931 + // Start time not suitable for empty string text 1.932 + if (Textstart == ".") 1.933 + m_pStarttime->setTime(QTime::currentTime()); 1.934 + else if (Textstart.isEmpty()) 1.935 + m_pStarttime->setTime(QTime::QTime(0, 0)); 1.936 + else 1.937 + m_pStarttime->setTime(QTime::fromString(Textstart, Qt::ISODate)); 1.938 + 1.939 + // Finish time not suitable for empty string text 1.940 + if (Textfinish == ".") 1.941 + m_pEndtime->setTime(QTime::currentTime()); 1.942 + else if (Textfinish.isEmpty()) 1.943 + m_pEndtime->setTime(QTime::QTime(0, 0)); 1.944 + else 1.945 + m_pEndtime->setTime(QTime::fromString(Textfinish, Qt::ISODate)); 1.946 + 1.947 + // Amount time not suitable for empty string text 1.948 + if (Textamount == ".") { 1.949 + int nDifference = m_pStarttime->time().secsTo(m_pEndtime->time()); 1.950 + m_pAmount->setTime(QTime(0, 0).addSecs(nDifference)); 1.951 + } 1.952 + else if (Textamount.isEmpty()) 1.953 + m_pAmount->setTime(QTime::QTime(0, 0)); 1.954 + else 1.955 + m_pAmount->setTime(QTime::fromString(Textamount, Qt::ISODate)); 1.956 + } 1.957 +} 1.958 + 1.959 +// 1.960 +// Validate current row of the matrix 1.961 +// 1.962 +void Titraqform::validateRow(void) 1.963 +{ 1.964 + this->validateRow(-1, -1); 1.965 +} 1.966 + 1.967 +// 1.968 +// Validate specified row of the matrix 1.969 +// 1.970 +void Titraqform::validateRow(int nRow, int nCol) 1.971 +{ 1.972 + int nRealrow = -1; 1.973 + 1.974 + if (!this->isOpen()) { // If no data is loaded then short circuit 1.975 + m_pStatbar->message(trUtf8("Timesheet contains no data"), 4000); 1.976 + return; 1.977 + } 1.978 + 1.979 + nRealrow = (nRow >= 0) ? nRow : m_pMaintable->currentRow(); 1.980 + QString Statis = m_pMaintable->text(nRealrow, TITRAQ_IDXSTATUS); // Get text 1.981 + 1.982 + // Review whole data validity, and set pixmap accordingly 1.983 + if (m_pMaintable->text(nRealrow, TITRAQ_IDXUSER).isEmpty() || 1.984 + m_pMaintable->text(nRealrow, TITRAQ_IDXGUID).isEmpty() || 1.985 + m_pMaintable->text(nRealrow, TITRAQ_IDXCRC).isEmpty() || 1.986 + m_pMaintable->text(nRealrow, TITRAQ_IDXREV).isEmpty() || 1.987 + m_pMaintable->text(nRealrow, TITRAQ_IDXDATE).isEmpty() || 1.988 + m_pMaintable->text(nRealrow, TITRAQ_IDXSTART).isEmpty() || 1.989 + m_pMaintable->text(nRealrow, TITRAQ_IDXFINISH).isEmpty() || 1.990 + m_pMaintable->text(nRealrow, TITRAQ_IDXAMOUNT).isEmpty() || 1.991 + m_pMaintable->text(nRealrow, TITRAQ_IDXTASK).isEmpty()) 1.992 + { // No K&R style to show where actual code begins 1.993 + if (Statis.startsWith(QString("W"))) { // Conditionally set pixmap to avoid overhead 1.994 +// FIXME: Next line commented out, and I see that this algorythm needs help 1.995 +// m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRealrow, TITRAQ_IDXSTATUS)); 1.996 + } 1.997 + else if (!Statis.startsWith(QString("E"))) { // Conditionally set pixmap to avoid overhead 1.998 + m_pMaintable->setText(nRealrow, TITRAQ_IDXSTATUS, Statis.replace(TITRAQ_IDXSTATERROR, sizeof(char), 'E')); 1.999 + m_pMaintable->setPixmap(nRealrow, TITRAQ_IDXSTATUS, QPixmap(s_kpcStaterror_xpm)); 1.1000 + m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRealrow, TITRAQ_IDXSTATUS)); 1.1001 + } 1.1002 + } 1.1003 + else { 1.1004 + if (!Statis.startsWith(QString("O"))) { // Conditionally set pixmap to avoid overhead 1.1005 + m_pMaintable->setText(nRealrow, TITRAQ_IDXSTATUS, Statis.replace(TITRAQ_IDXSTATERROR, sizeof(char), 'O')); 1.1006 + m_pMaintable->setPixmap(nRealrow, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatokay_xpm)); 1.1007 + m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRealrow, TITRAQ_IDXSTATUS)); 1.1008 + } 1.1009 + } 1.1010 + 1.1011 + // Test for blank user field, and set to default if so 1.1012 + if (m_pMaintable->text(nRealrow, TITRAQ_IDXUSER).isEmpty()) 1.1013 + m_pMaintable->setText(nRealrow, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER)); 1.1014 + 1.1015 + // Test for blank date field, and set to default if so 1.1016 + if (m_pMaintable->text(nRealrow, TITRAQ_IDXDATE) == ".") 1.1017 + m_pMaintable->setText(nRealrow, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate)); 1.1018 + 1.1019 + // Test for blank start field, and set to default if so 1.1020 + if (m_pMaintable->text(nRealrow, TITRAQ_IDXSTART) == ".") 1.1021 + m_pMaintable->setText(nRealrow, TITRAQ_IDXSTART, QTime::currentTime().toString("hh:mm")); 1.1022 + 1.1023 + // Test for blank finish field, and set to default if so 1.1024 + if (m_pMaintable->text(nRealrow, TITRAQ_IDXFINISH) == ".") 1.1025 + m_pMaintable->setText(nRealrow, TITRAQ_IDXFINISH, QTime::currentTime().toString("hh:mm")); 1.1026 + 1.1027 + // Test for blank amount field, and set to default if so 1.1028 + if (m_pMaintable->text(nRealrow, TITRAQ_IDXAMOUNT) == ".") { 1.1029 + QTime Begin = QTime::fromString(m_pMaintable->text(nRealrow, TITRAQ_IDXSTART), Qt::ISODate); 1.1030 + QTime End = QTime::fromString(m_pMaintable->text(nRealrow, TITRAQ_IDXFINISH), Qt::ISODate); 1.1031 + QString Diff = QTime(0, 0).addSecs(Begin.secsTo(End)).toString("hh:mm"); 1.1032 + m_pMaintable->setText(nRealrow, TITRAQ_IDXAMOUNT, Diff); 1.1033 + } 1.1034 +} 1.1035 + 1.1036 +// 1.1037 +// Update the current line number column item 1.1038 +// 1.1039 +void Titraqform::updateLine(const QString &Instring) 1.1040 +{ 1.1041 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXLINE, Instring); 1.1042 +} 1.1043 + 1.1044 +// 1.1045 +// Update the current user column item 1.1046 +// 1.1047 +void Titraqform::updateUser(const QString &Instring) 1.1048 +{ 1.1049 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXUSER, Instring); 1.1050 +} 1.1051 + 1.1052 +// 1.1053 +// Update the current GUID column item 1.1054 +// 1.1055 +void Titraqform::updateGuid(const QString &Instring) 1.1056 +{ 1.1057 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXGUID, Instring); 1.1058 +} 1.1059 + 1.1060 +// 1.1061 +// Update the current CRC column item 1.1062 +// 1.1063 +void Titraqform::updateCrc(const QString &Instring) 1.1064 +{ 1.1065 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXCRC, Instring); 1.1066 +} 1.1067 + 1.1068 +// 1.1069 +// Update the current rev column item 1.1070 +// 1.1071 +void Titraqform::updateRev(const QString &Instring) 1.1072 +{ 1.1073 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREV, Instring); 1.1074 +} 1.1075 + 1.1076 +// 1.1077 +// Update the current date column item 1.1078 +// 1.1079 +void Titraqform::updateDate(const QDate &Dateup) 1.1080 +{ 1.1081 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXDATE, Dateup.toString(Qt::ISODate)); 1.1082 +} 1.1083 + 1.1084 +// 1.1085 +// Update the current start column item 1.1086 +// 1.1087 +void Titraqform::updateStart(const QTime &Startup) 1.1088 +{ 1.1089 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXSTART, Startup.toString("hh:mm")); 1.1090 +} 1.1091 + 1.1092 +// 1.1093 +// Update the current finish column item 1.1094 +// 1.1095 +void Titraqform::updateFinish(const QTime &Finishup) 1.1096 +{ 1.1097 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXFINISH, Finishup.toString("hh:mm")); 1.1098 +} 1.1099 + 1.1100 +// 1.1101 +// Update the current amount column item 1.1102 +// 1.1103 +void Titraqform::updateAmount(const QTime &Amountup) 1.1104 +{ 1.1105 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXAMOUNT, Amountup.toString("hh:mm")); 1.1106 +} 1.1107 + 1.1108 +// 1.1109 +// Update the current task column item 1.1110 +// 1.1111 +void Titraqform::updateTask(const QString &Taskup) 1.1112 +{ 1.1113 +// // FIXME: Broken 1.1114 +// RtTableItem *pTask = NULL; 1.1115 +// pTask = static_cast<RtTableItem *>(m_pMaintable->item(m_pMaintable->currentRow(), TITRAQ_IDXTASK)); 1.1116 +// pTask->setText(Taskup); 1.1117 + 1.1118 + // Don't try to use the Taskup string, because it ignores autocompletion 1.1119 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXTASK, m_pTasks->currentText()); 1.1120 +} 1.1121 + 1.1122 +// 1.1123 +// Update the current remark column item 1.1124 +// 1.1125 +void Titraqform::updateRemark(const QString &Remarkup) 1.1126 +{ 1.1127 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREMARK, Remarkup); 1.1128 +} 1.1129 + 1.1130 +// 1.1131 +// Confirm any recent editions on a whole row 1.1132 +// 1.1133 +void Titraqform::confirmEdit(void) 1.1134 +{ 1.1135 + RtTableItem *pTask = NULL; // Task item is a derived class 1.1136 + 1.1137 + // Conversions from edit control data formats to native tabular format 1.1138 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXDATE, m_pDateedit->date().toString(Qt::ISODate)); 1.1139 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXSTART, m_pStarttime->time().toString(Qt::ISODate)); 1.1140 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXFINISH, m_pEndtime->time().toString(Qt::ISODate)); 1.1141 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXAMOUNT, m_pAmount->time().toString(Qt::ISODate)); 1.1142 + 1.1143 + // Specially handle task fields 1.1144 + pTask = static_cast<RtTableItem *>(m_pMaintable->item(m_pMaintable->currentRow(), TITRAQ_IDXTASK)); 1.1145 + pTask->setText(m_pTasks->currentText()); 1.1146 + 1.1147 + m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREMARK, m_pRemark->text()); 1.1148 +} 1.1149 + 1.1150 +// 1.1151 +// Edit menu configure preferences 1.1152 +// 1.1153 +void Titraqform::configPrefs(void) 1.1154 +{ 1.1155 + QString Templine; // Used for preferences resetting 1.1156 + Prefpanel *pUserpanel = NULL; // The user preferences panel itself 1.1157 + 1.1158 + // Create a new preferences panel window 1.1159 + pUserpanel = new Prefpanel(this, "Userprefpanel"); 1.1160 + connect(pUserpanel, SIGNAL(applied(void)), SLOT(applyPrefs(void))); 1.1161 + 1.1162 + // Set default values to appear in initialized panel widgets 1.1163 + pUserpanel->setAccounts(m_pPrefs->getString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS)); 1.1164 + pUserpanel->setEvents(m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR)); 1.1165 + pUserpanel->setUser(m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER)); 1.1166 + pUserpanel->setHome(m_pPrefs->getString(TITRAQ_PREFHOME, TITRAQ_DEFHOME)); 1.1167 + pUserpanel->setCorbahost(m_pPrefs->getString(TITRAQ_PREFCORBHOST, TITRAQ_DEFCORBHOST)); 1.1168 + pUserpanel->setSoaphost(m_pPrefs->getString(TITRAQ_PREFSOAPHOST, TITRAQ_DEFSOAPHOST)); 1.1169 +#ifdef HAVE_MICO 1.1170 + pUserpanel->setCorbaon(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON)); 1.1171 +#else 1.1172 + pUserpanel->setCorbaon(false); 1.1173 + pUserpanel->lockCorba(); 1.1174 +#endif 1.1175 +#ifdef HAVE_ESOAP 1.1176 + pUserpanel->setSoapon(m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)); 1.1177 +#else 1.1178 + pUserpanel->setSoapon(false); 1.1179 + pUserpanel->lockSoap(); 1.1180 +#endif 1.1181 + pUserpanel->setBackon(m_pPrefs->getBool(TITRAQ_PREFBAKON, TITRAQ_DEFBAKON)); 1.1182 + pUserpanel->setExtendon(m_pPrefs->getBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON)); 1.1183 + pUserpanel->setDetailon(m_pPrefs->getBool(TITRAQ_PREFDETAILON, TITRAQ_DEFDETAILON)); 1.1184 + pUserpanel->setSignaton(m_pPrefs->getBool(TITRAQ_PREFSIGNATON, TITRAQ_DEFSIGNATON)); 1.1185 + 1.1186 + // Set default style which can be more complicated due to mapping... 1.1187 + switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) { 1.1188 + case TITRAQ_STYLECDE: 1.1189 + pUserpanel->setStyle(TITRAQ_STRCDE); 1.1190 + break; 1.1191 + case TITRAQ_STYLESGI: 1.1192 + pUserpanel->setStyle(TITRAQ_STRSGI); 1.1193 + break; 1.1194 + case TITRAQ_STYLEMOTIF: 1.1195 + pUserpanel->setStyle(TITRAQ_STRMOTIF); 1.1196 + break; 1.1197 + case TITRAQ_STYLEMPLUS: 1.1198 + pUserpanel->setStyle(TITRAQ_STRMPLUS); 1.1199 + break; 1.1200 + case TITRAQ_STYLEPLAT: 1.1201 + pUserpanel->setStyle(TITRAQ_STRPLAT); 1.1202 + break; 1.1203 + case TITRAQ_STYLEMSOFT: 1.1204 + pUserpanel->setStyle(TITRAQ_STRMSOFT); 1.1205 + break; 1.1206 + default: 1.1207 + pUserpanel->setStyle(TITRAQ_STRCDE); // My personal favourite ;-) 1.1208 + break; 1.1209 + } 1.1210 + 1.1211 + // Colour preferences 1.1212 + int nRed, nGreen, nBlue; 1.1213 + QColorGroup Origcolour, Altcolour; 1.1214 + const QColor Origlight = QColor(TITRAQ_DEFLIGHTRED, TITRAQ_DEFLIGHTGREEN, TITRAQ_DEFLIGHTBLUE); 1.1215 + const QColor Origdark = QColor(TITRAQ_DEFDARKRED, TITRAQ_DEFDARKGREEN, TITRAQ_DEFDARKBLUE); 1.1216 + const QColor Altlight = QColor(TITRAQ_DEFLTALTRED, TITRAQ_DEFLTALTGREEN, TITRAQ_DEFLTALTBLUE); 1.1217 + const QColor Altdark = QColor(TITRAQ_DEFDKALTRED, TITRAQ_DEFDKALTGREEN, TITRAQ_DEFDKALTBLUE); 1.1218 + 1.1219 + // Set colours to revert to if user screws up and wants out 1.1220 + Origcolour.setColor(QColorGroup::Foreground, Origlight); 1.1221 + Origcolour.setColor(QColorGroup::Background, Origdark); 1.1222 + pUserpanel->setOrigcolour(&Origcolour); 1.1223 + Altcolour.setColor(QColorGroup::Foreground, Altlight); 1.1224 + Altcolour.setColor(QColorGroup::Background, Altdark); 1.1225 + pUserpanel->setAltcolour(&Altcolour); 1.1226 + 1.1227 + // Set colour preferences saved from last session 1.1228 + nRed = m_pPrefs->getNumber(TITRAQ_PREFLIGHTRED, TITRAQ_DEFLIGHTRED); 1.1229 + nGreen = m_pPrefs->getNumber(TITRAQ_PREFLIGHTGREEN, TITRAQ_DEFLIGHTGREEN); 1.1230 + nBlue = m_pPrefs->getNumber(TITRAQ_PREFLIGHTBLUE, TITRAQ_DEFLIGHTBLUE); 1.1231 + const QColor Lightshade = QColor(nRed, nGreen, nBlue); 1.1232 + pUserpanel->setLight(&Lightshade); 1.1233 + nRed = m_pPrefs->getNumber(TITRAQ_PREFDARKRED, TITRAQ_DEFDARKRED); 1.1234 + nGreen = m_pPrefs->getNumber(TITRAQ_PREFDARKGREEN, TITRAQ_DEFDARKGREEN); 1.1235 + nBlue = m_pPrefs->getNumber(TITRAQ_PREFDARKBLUE, TITRAQ_DEFDARKBLUE); 1.1236 + const QColor Darkshade = QColor(nRed, nGreen, nBlue); 1.1237 + pUserpanel->setDark(&Darkshade); 1.1238 + 1.1239 + // Modal panel handler 1.1240 + if (pUserpanel->exec() == QDialog::Accepted) 1.1241 + this->applyPrefs(pUserpanel); 1.1242 + 1.1243 + // Dispose Panel object 1.1244 + delete pUserpanel; 1.1245 +} 1.1246 + 1.1247 +// 1.1248 +// View menu normal 1.1249 +// 1.1250 +void Titraqform::normalView(void) 1.1251 +{ 1.1252 + // All view types except normal are disabled until implemention, so 1.1253 + // this body can remain empty, causing nothing to happen on selection. 1.1254 +} 1.1255 + 1.1256 +// 1.1257 +// View menu editing 1.1258 +// 1.1259 +void Titraqform::editingView(void) 1.1260 +{ 1.1261 + // All view types except normal are disabled until implemention, so 1.1262 + // this body can remain empty, causing nothing to happen on selection. 1.1263 +} 1.1264 + 1.1265 +// 1.1266 +// View menu timing 1.1267 +// 1.1268 +void Titraqform::timingView(void) 1.1269 +{ 1.1270 + // All view types except normal are disabled until implemention, so 1.1271 + // this body can remain empty, causing nothing to happen on selection. 1.1272 +} 1.1273 + 1.1274 +// 1.1275 +// View menu show file toolbar 1.1276 +// 1.1277 +void Titraqform::showFilebar(void) 1.1278 +{ 1.1279 + if (m_pFiletools->isVisible()) { 1.1280 + m_pFiletools->hide(); 1.1281 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR), false); 1.1282 + } 1.1283 + else { 1.1284 + m_pFiletools->show(); 1.1285 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR), true); 1.1286 + } 1.1287 +} 1.1288 + 1.1289 +// 1.1290 +// View menu show edit toolbar 1.1291 +// 1.1292 +void Titraqform::showEditbar(void) 1.1293 +{ 1.1294 + if (m_pEdittools->isVisible()) { 1.1295 + m_pEdittools->hide(); 1.1296 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR), false); 1.1297 + } 1.1298 + else { 1.1299 + m_pEdittools->show(); 1.1300 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR), true); 1.1301 + } 1.1302 +} 1.1303 + 1.1304 +// 1.1305 +// View menu show view toolbar 1.1306 +// 1.1307 +void Titraqform::showViewbar(void) 1.1308 +{ 1.1309 + if (m_pViewtools->isVisible()) { 1.1310 + m_pViewtools->hide(); 1.1311 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR), false); 1.1312 + } 1.1313 + else { 1.1314 + m_pViewtools->show(); 1.1315 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR), true); 1.1316 + } 1.1317 +} 1.1318 + 1.1319 +// 1.1320 +// View menu show prefs toolbar 1.1321 +// 1.1322 +void Titraqform::showPrefsbar(void) 1.1323 +{ 1.1324 + if (m_pPrefstools->isVisible()) { 1.1325 + m_pPrefstools->hide(); 1.1326 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR), false); 1.1327 + } 1.1328 + else { 1.1329 + m_pPrefstools->show(); 1.1330 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR), true); 1.1331 + } 1.1332 +} 1.1333 + 1.1334 +// 1.1335 +// View menu show whats this toolbar 1.1336 +// 1.1337 +void Titraqform::showWhatsbar(void) 1.1338 +{ 1.1339 + if (m_pWhatstools->isVisible()) { 1.1340 + m_pWhatstools->hide(); 1.1341 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), false); 1.1342 + } 1.1343 + else { 1.1344 + m_pWhatstools->show(); 1.1345 + m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), true); 1.1346 + } 1.1347 +} 1.1348 + 1.1349 +// 1.1350 +// View menu show status column 1.1351 +// 1.1352 +void Titraqform::showStatcol(void) 1.1353 +{ 1.1354 + // Test if column is currently shown, conditionally show or hide it 1.1355 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL))) { 1.1356 + m_pMaintable->hideColumn(TITRAQ_IDXSTATUS); 1.1357 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL), false); 1.1358 + m_pStatusedit->hide(); 1.1359 + } 1.1360 + else { 1.1361 + m_pMaintable->showColumn(TITRAQ_IDXSTATUS); 1.1362 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL), true); 1.1363 + m_pStatusedit->show(); 1.1364 + } 1.1365 + 1.1366 + // Make sure switch take place right away and sizes are handled 1.1367 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTATCOL)); 1.1368 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1369 +} 1.1370 + 1.1371 +// 1.1372 +// View menu show line numbers column 1.1373 +// 1.1374 +void Titraqform::showLinecol(void) 1.1375 +{ 1.1376 + // Test if column is currently shown, conditionally show or hide it 1.1377 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL))) { 1.1378 + m_pMaintable->hideColumn(TITRAQ_IDXLINE); 1.1379 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL), false); 1.1380 + m_pLineedit->hide(); 1.1381 + } 1.1382 + else { 1.1383 + m_pMaintable->showColumn(TITRAQ_IDXLINE); 1.1384 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL), true); 1.1385 + m_pLineedit->show(); 1.1386 + } 1.1387 + 1.1388 + // Make sure switch take place right away and sizes are handled 1.1389 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXLCOL)); 1.1390 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1391 +} 1.1392 + 1.1393 +// 1.1394 +// View menu show users column 1.1395 +// 1.1396 +void Titraqform::showUsercol(void) 1.1397 +{ 1.1398 + // Test if column is currently shown, conditionally show or hide it 1.1399 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL))) { 1.1400 + m_pMaintable->hideColumn(TITRAQ_IDXUSER); 1.1401 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL), false); 1.1402 + m_pUseredit->hide(); 1.1403 + } 1.1404 + else { 1.1405 + m_pMaintable->showColumn(TITRAQ_IDXUSER); 1.1406 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL), true); 1.1407 + m_pUseredit->show(); 1.1408 + } 1.1409 + 1.1410 + // Make sure switch take place right away and sizes are handled 1.1411 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1412 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXUCOL)); 1.1413 +} 1.1414 + 1.1415 +// 1.1416 +// View menu show GUIDs column 1.1417 +// 1.1418 +void Titraqform::showGuidcol(void) 1.1419 +{ 1.1420 + // Test if column is currently shown, conditionally show or hide it 1.1421 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL))) { 1.1422 + m_pMaintable->hideColumn(TITRAQ_IDXGUID); 1.1423 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL), false); 1.1424 + m_pGuidedit->hide(); 1.1425 + } 1.1426 + else { 1.1427 + m_pMaintable->showColumn(TITRAQ_IDXGUID); 1.1428 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL), true); 1.1429 + m_pGuidedit->show(); 1.1430 + } 1.1431 + 1.1432 + // Make sure switch take place right away and sizes are handled 1.1433 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXGCOL)); 1.1434 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1435 +} 1.1436 + 1.1437 +// 1.1438 +// View menu show CRC column 1.1439 +// 1.1440 +void Titraqform::showCrccol(void) 1.1441 +{ 1.1442 + // Test if column is currently shown, conditionally show or hide it 1.1443 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL))) { 1.1444 + m_pMaintable->hideColumn(TITRAQ_IDXCRC); 1.1445 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL), false); 1.1446 + m_pCrcedit->hide(); 1.1447 + } 1.1448 + else { 1.1449 + m_pMaintable->showColumn(TITRAQ_IDXCRC); 1.1450 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL), true); 1.1451 + m_pCrcedit->show(); 1.1452 + } 1.1453 + 1.1454 + // Make sure switch take place right away and sizes are handled 1.1455 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXCCOL)); 1.1456 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1457 +} 1.1458 + 1.1459 +// 1.1460 +// View menu show Rev column 1.1461 +// 1.1462 +void Titraqform::showRevcol(void) 1.1463 +{ 1.1464 + // Test if column is currently shown, conditionally show or hide it 1.1465 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL))) { 1.1466 + m_pMaintable->hideColumn(TITRAQ_IDXREV); 1.1467 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL), false); 1.1468 + m_pRevedit->hide(); 1.1469 + } 1.1470 + else { 1.1471 + m_pMaintable->showColumn(TITRAQ_IDXREV); 1.1472 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL), true); 1.1473 + m_pRevedit->show(); 1.1474 + } 1.1475 + 1.1476 + // Make sure switch take place right away and sizes are handled 1.1477 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREVCOL)); 1.1478 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1479 +} 1.1480 + 1.1481 +// 1.1482 +// View menu show dates column 1.1483 +// 1.1484 +void Titraqform::showDatecol(void) 1.1485 +{ 1.1486 + // Test if column is currently shown, conditionally show or hide it 1.1487 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL))) { 1.1488 + m_pMaintable->hideColumn(TITRAQ_IDXDATE); 1.1489 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL), false); 1.1490 + m_pDateedit->hide(); 1.1491 + } 1.1492 + else { 1.1493 + m_pMaintable->showColumn(TITRAQ_IDXDATE); 1.1494 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL), true); 1.1495 + m_pDateedit->show(); 1.1496 + } 1.1497 + 1.1498 + // Make sure switch take place right away and sizes are handled 1.1499 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXDCOL)); 1.1500 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1501 +} 1.1502 + 1.1503 +// 1.1504 +// View menu show start time column 1.1505 +// 1.1506 +void Titraqform::showStartcol(void) 1.1507 +{ 1.1508 + // Test if column is currently shown, conditionally show or hide it 1.1509 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL))) { 1.1510 + m_pMaintable->hideColumn(TITRAQ_IDXSTART); 1.1511 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL), false); 1.1512 + m_pStarttime->hide(); 1.1513 + } 1.1514 + else { 1.1515 + m_pMaintable->showColumn(TITRAQ_IDXSTART); 1.1516 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL), true); 1.1517 + m_pStarttime->show(); 1.1518 + } 1.1519 + 1.1520 + // Make sure switch take place right away and sizes are handled 1.1521 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL)); 1.1522 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1523 +} 1.1524 + 1.1525 +// 1.1526 +// View menu show finish time column 1.1527 +// 1.1528 +void Titraqform::showFinishcol(void) 1.1529 +{ 1.1530 + // Test if column is currently shown, conditionally show or hide it 1.1531 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL))) { 1.1532 + m_pMaintable->hideColumn(TITRAQ_IDXFINISH); 1.1533 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL), false); 1.1534 + m_pEndtime->hide(); 1.1535 + } 1.1536 + else { 1.1537 + m_pMaintable->showColumn(TITRAQ_IDXFINISH); 1.1538 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL), true); 1.1539 + m_pEndtime->show(); 1.1540 + } 1.1541 + 1.1542 + // Make sure switch take place right away and sizes are handled 1.1543 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXFCOL)); 1.1544 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1545 +} 1.1546 + 1.1547 +// 1.1548 +// View menu show Amounts column 1.1549 +// 1.1550 +void Titraqform::showAmountcol(void) 1.1551 +{ 1.1552 + // Test if column is currently shown, conditionally show or hide it 1.1553 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL))) { 1.1554 + m_pMaintable->hideColumn(TITRAQ_IDXAMOUNT); 1.1555 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL), false); 1.1556 + m_pAmount->hide(); 1.1557 + } 1.1558 + else { 1.1559 + m_pMaintable->showColumn(TITRAQ_IDXAMOUNT); 1.1560 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL), true); 1.1561 + m_pAmount->show(); 1.1562 + } 1.1563 + 1.1564 + // Make sure switch take place right away and sizes are handled 1.1565 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXACOL)); 1.1566 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1567 +} 1.1568 + 1.1569 +// 1.1570 +// View menu show tasks column 1.1571 +// 1.1572 +void Titraqform::showTaskcol(void) 1.1573 +{ 1.1574 + // Test if column is currently shown, conditionally show or hide it 1.1575 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXTCOL))) { 1.1576 + m_pMaintable->hideColumn(TITRAQ_IDXTASK); 1.1577 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXTCOL), false); 1.1578 + m_pTasks->hide(); 1.1579 + } 1.1580 + else { 1.1581 + m_pMaintable->showColumn(TITRAQ_IDXTASK); 1.1582 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXTCOL), true); 1.1583 + m_pTasks->show(); 1.1584 + } 1.1585 + 1.1586 + // Make sure switch take place right away and sizes are handled 1.1587 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXTCOL)); 1.1588 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1589 +} 1.1590 + 1.1591 +// 1.1592 +// View menu show Remarks column 1.1593 +// 1.1594 +void Titraqform::showRemarkcol(void) 1.1595 +{ 1.1596 + // Test if column is currently shown, conditionally show or hide it 1.1597 + if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL))) { 1.1598 + m_pMaintable->hideColumn(TITRAQ_IDXREMARK); 1.1599 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL), false); 1.1600 + m_pRemark->hide(); 1.1601 + } 1.1602 + else { 1.1603 + m_pMaintable->showColumn(TITRAQ_IDXREMARK); 1.1604 + m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL), true); 1.1605 + m_pRemark->show(); 1.1606 + } 1.1607 + 1.1608 + // Make sure switch take place right away and sizes are handled 1.1609 + m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREMCOL)); 1.1610 + this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next 1.1611 +} 1.1612 + 1.1613 +// 1.1614 +// Generate a local formatted report 1.1615 +// 1.1616 +void Titraqform::genReport(void) 1.1617 +{ 1.1618 + try { // Create and execute a new local report window 1.1619 + std::auto_ptr<AS::Reportpanel> pReport(new AS::Reportpanel 1.1620 + (m_pMaintable, m_pPrefs, this, "Locreportpanel")); 1.1621 + pReport->exec(); 1.1622 + delete pReport.release(); // Technically unnecessary, smart pointer 1.1623 + } 1.1624 + catch (Genexcept& Genex) { 1.1625 + Genex.reportErr(); 1.1626 + return; 1.1627 + } 1.1628 +} 1.1629 + 1.1630 +// 1.1631 +// Syncronize data with server using IIOP 1.1632 +// 1.1633 +void Titraqform::syncIiop(void) 1.1634 +{ 1.1635 +#ifdef HAVE_MICO 1.1636 + // Short circuit if user has disabled CORBA transmission in prefs 1.1637 + if (!m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON)) 1.1638 + return; 1.1639 + 1.1640 + char **ppcInargv = NULL; // Parameters to the ORB 1.1641 + CORBA::ORB_var Orb; // The ORB iself 1.1642 + 1.1643 + CORBA::Object_var Nameobj; // Name service reference 1.1644 + CosNaming::NamingContext_var Namectx; // COSS ns context 1.1645 + CosNaming::Name Cosname; // Our requested obj name 1.1646 + 1.1647 + CORBA::Object_var Objcaster; // Generic CORBA object 1.1648 + Asdatabase_var Asdbase; // Casted object to ASDB 1.1649 + Astuple Singlerow; // A single row of AS data 1.1650 + 1.1651 + QString *pOrbargv = new QString(TITRAQ_ORBINIT); 1.1652 + int nCount = pOrbargv->contains(' '); 1.1653 + int nNamesize = 0; 1.1654 + 1.1655 + // Build a false incoming argv with which we initialize the ORB 1.1656 + ppcInargv = new char *[nCount + 3]; // 3 = arg0 + last section + COSS host 1.1657 + *ppcInargv = new char[strlen(*qApp->argv() + 2)]; // For cmd name 1.1658 + strcpy(ppcInargv[0], *qApp->argv()); // Copy cmd name 1.1659 + for (int nIter = 0; nIter <= nCount; nIter++) { 1.1660 + QString Section = pOrbargv->section(' ', nIter, nIter); 1.1661 + ppcInargv[nIter + 1] = new char[strlen(Section.ascii() + 2)]; 1.1662 + strcpy(ppcInargv[nIter + 1], Section.ascii()); 1.1663 + } 1.1664 + 1.1665 + // Build the single string COSS naming host name with associated port number 1.1666 + *pOrbargv = TITRAQ_COSSPART1 1.1667 + + m_pPrefs->getString(TITRAQ_PREFCORBHOST, TITRAQ_DEFCORBHOST) 1.1668 + + TITRAQ_COSSPART2; 1.1669 + nNamesize = strlen(pOrbargv->ascii()); 1.1670 + ppcInargv[nCount + 2] = new char[nNamesize]; 1.1671 + strcpy(ppcInargv[nCount + 2], pOrbargv->ascii()); 1.1672 + 1.1673 + try { 1.1674 + // Initialization of the ORB and COSS naming service 1.1675 + nCount = nCount + 3; // Raise the count to include app, last sec, COSS 1.1676 + Orb = CORBA::ORB_init(nCount, ppcInargv, "mico-local-orb"); 1.1677 + Nameobj = Orb->resolve_initial_references("NameService"); 1.1678 + Namectx = CosNaming::NamingContext::_narrow(Nameobj); 1.1679 + if (CORBA::is_nil(Namectx)) { // Verify sanity 1.1680 + m_pStatbar->message(trUtf8("Could not find the COSS naming service")); 1.1681 + qWarning("Could not find the COSS naming service\n"); 1.1682 + } 1.1683 + 1.1684 + // Clean up our dynamically allocated array 1.1685 + for (int nIter = 0; nIter < nCount; nIter++) 1.1686 + delete ppcInargv[nIter]; 1.1687 + delete ppcInargv; // Free the array itself 1.1688 + delete pOrbargv; // Free the intermediate string 1.1689 + 1.1690 + // Prepare the COSS name request 1.1691 + Cosname.length(1); 1.1692 + Cosname[0].id = CORBA::string_dup("Asdatabase"); 1.1693 + Cosname[0].kind = CORBA::string_dup(""); 1.1694 + 1.1695 + try { // Resolve to a CORBA object 1.1696 + Objcaster = Namectx->resolve(Cosname); 1.1697 + } 1.1698 + catch (CosNaming::NamingContext::NotFound &Cossex) { 1.1699 + m_pStatbar->message(trUtf8("NotFound exception thrown")); 1.1700 + qWarning("NotFound exception thrown\n"); 1.1701 + return; 1.1702 + } 1.1703 + catch (CosNaming::NamingContext::CannotProceed &Cossex) { 1.1704 + m_pStatbar->message(trUtf8("CannotProceed exception thrown")); 1.1705 + qWarning("CannotProceed exception thrown\n"); 1.1706 + return; 1.1707 + } 1.1708 + catch (CosNaming::NamingContext::InvalidName &Cossex) { 1.1709 + m_pStatbar->message(trUtf8("InvalidName exception thrown")); 1.1710 + qWarning("InvalidName exception thrown\n"); 1.1711 + return; 1.1712 + } 1.1713 + 1.1714 + // Cast the generic CORBA object to a AS database type 1.1715 + Asdbase = Asdatabase::_narrow(Objcaster); 1.1716 + if (CORBA::is_nil(Asdbase)) { // Verify sanity 1.1717 + m_pStatbar->message(trUtf8("Could not find the AS database")); 1.1718 + qWarning("Could not find the AS database\n"); 1.1719 + return; 1.1720 + } 1.1721 + 1.1722 + // Open an account object on the remote server 1.1723 + Account_var Account = Asdbase->Open("/tmp/events.as"); 1.1724 + if (CORBA::is_nil(Account)) { // Verify sanity 1.1725 + m_pStatbar->message(trUtf8("Could not create an account object on the server")); 1.1726 + qWarning("Could not create an account object on the server\n"); 1.1727 + return; 1.1728 + } 1.1729 + 1.1730 + // Fill account log object(s) to marshall and transmit 1.1731 + int nRow = m_pMaintable->currentRow(); 1.1732 + QTableSelection Select = m_pMaintable->selection(0); // Capture selected rows 1.1733 + int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total rows selected 1.1734 + 1.1735 + // Remember, CORBA::stri_dup creates smart pointers 1.1736 + for (int nIter = 0; nIter < nTotal; nIter++) { 1.1737 + Singlerow.szUser = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXUSER)); 1.1738 + Singlerow.szGuid = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXGUID)); 1.1739 + Singlerow.szCrc = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXCRC).remove("0x")); 1.1740 + Singlerow.szRev = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXREV)); 1.1741 + Singlerow.szDate = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXDATE)); 1.1742 + Singlerow.szStart = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXSTART)); 1.1743 + Singlerow.szFinish = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXFINISH)); 1.1744 + Singlerow.szAmount = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXAMOUNT)); 1.1745 +// Singlerow.nRev = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXREV).toUInt(); 1.1746 +// Singlerow.nDate = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXDATE).toUInt(); 1.1747 +// Singlerow.nStart = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXSTART).toUInt(); 1.1748 +// Singlerow.nFinish = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXFINISH).toUInt(); 1.1749 +// Singlerow.nAmount = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXAMOUNT).toUInt(); 1.1750 + Singlerow.szTask = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXTASK)); 1.1751 + Singlerow.szRemark = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXREMARK)); 1.1752 + Account->Log(Singlerow); // Finally transmit to server 1.1753 + } 1.1754 + 1.1755 + m_pStatbar->message(trUtf8("Successful transmission of accounting data")); 1.1756 + } 1.1757 + catch (const CORBA::Exception &Corbex) { 1.1758 + m_pStatbar->message(trUtf8("Caught CORBA exception: %1").arg(Corbex._repoid())); 1.1759 + qWarning("Caught CORBA exception: %s", Corbex._repoid()); 1.1760 + } 1.1761 + catch (...) { 1.1762 + qWarning("Caught unknown exception\n"); 1.1763 + } 1.1764 +#endif // HAVE_MICO 1.1765 +} 1.1766 + 1.1767 +// 1.1768 +// Syncronize data with server using SOAP 1.1769 +// 1.1770 +void Titraqform::syncSoap(void) 1.1771 +{ 1.1772 +#ifdef HAVE_ESOAP 1.1773 + // Short circuit if user has disabled SOAP transmission in prefs 1.1774 + if (!m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)) 1.1775 + return; 1.1776 + 1.1777 + USING_EASYSOAP_NAMESPACE 1.1778 + 1.1779 + try { 1.1780 + SOAPMethod Logmeth("Log", TITRAQ_SOAPSPACE); // SOAP namespace 1.1781 + SOAPString Clistr; // Outgoing parameter to marshall 1.1782 + int nCrc; // SOAP unmarshalled return value 1.1783 + 1.1784 + // Build the single string SOAP end point which look like this: 1.1785 + // "http://www.europalab.com/cgi-bin/asdbserv" 1.1786 + QString Endpoint; 1.1787 + Endpoint = TITRAQ_PREFIXHTTP + m_pPrefs->getString(TITRAQ_PREFSOAPHOST, TITRAQ_DEFSOAPHOST); 1.1788 + SOAPProxy Proxy(Endpoint.ascii()); 1.1789 + 1.1790 + // Fill account log object(s) to marshall and transmit 1.1791 + QTableSelection Select = m_pMaintable->selection(0); // Capture selected rows 1.1792 + int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total rows selected 1.1793 + 1.1794 + // Iterate through the selection of row entries to transmit 1.1795 + for (int nRowiter = 0; nRowiter < nTotal; nRowiter++) { 1.1796 + QString Syncthis = m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXUSER); 1.1797 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXGUID); 1.1798 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXCRC).remove("0x"); 1.1799 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXREV); 1.1800 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXDATE); 1.1801 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXSTART); 1.1802 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXFINISH); 1.1803 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXAMOUNT); 1.1804 + Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXTASK); 1.1805 + Syncthis += ' ' + ('"' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXREMARK)) + '"'; 1.1806 + Clistr = Syncthis; // Build RPC parameter 1.1807 + Logmeth.AddParameter("Tuple") << Clistr; // Prepare for marshalling 1.1808 + const SOAPResponse &Logresp = Proxy.Execute(Logmeth); 1.1809 + Logresp.GetReturnValue() >> nCrc; 1.1810 + } 1.1811 + m_pStatbar->message(trUtf8("Successful transmission, CRC returned %1").arg(nCrc)); 1.1812 + } 1.1813 + catch (SOAPException& Soapex) { // Announce the exception we received 1.1814 + m_pStatbar->message(trUtf8("Caught SOAP exception: %1").arg(Soapex.What().Str())); 1.1815 + qDebug("Caught SOAP exception: %s", Soapex.What().Str()); 1.1816 + } 1.1817 + catch (...) { 1.1818 + qDebug("Caught unknown exception\n"); 1.1819 + } 1.1820 +#endif // HAVE_ESOAP 1.1821 +} 1.1822 + 1.1823 +// 1.1824 +// Save user preferences 1.1825 +// 1.1826 +void Titraqform::savePrefs(void) 1.1827 +{ 1.1828 + // Get check status from column menu and pass it to prefs handler 1.1829 + m_pPrefs->setBool(TITRAQ_PREFSTATCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL))); 1.1830 + m_pPrefs->setBool(TITRAQ_PREFLCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL))); 1.1831 + m_pPrefs->setBool(TITRAQ_PREFUCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL))); 1.1832 + m_pPrefs->setBool(TITRAQ_PREFGCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL))); 1.1833 + m_pPrefs->setBool(TITRAQ_PREFCCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL))); 1.1834 + m_pPrefs->setBool(TITRAQ_PREFREVCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL))); 1.1835 + m_pPrefs->setBool(TITRAQ_PREFDCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL))); 1.1836 + m_pPrefs->setBool(TITRAQ_PREFSTARTCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL))); 1.1837 + m_pPrefs->setBool(TITRAQ_PREFFCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL))); 1.1838 + m_pPrefs->setBool(TITRAQ_PREFACOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL))); 1.1839 + m_pPrefs->setBool(TITRAQ_PREFFCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL))); 1.1840 + m_pPrefs->setBool(TITRAQ_PREFREMCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL))); 1.1841 + 1.1842 + // Get check status from toolbar menu and pass it to prefs handler 1.1843 + m_pPrefs->setBool(TITRAQ_PREFFILEBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR))); 1.1844 + m_pPrefs->setBool(TITRAQ_PREFEDITBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR))); 1.1845 + m_pPrefs->setBool(TITRAQ_PREFVIEWBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR))); 1.1846 + m_pPrefs->setBool(TITRAQ_PREFPREFBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR))); 1.1847 + m_pPrefs->setBool(TITRAQ_PREFWHATBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR))); 1.1848 + 1.1849 + // Get column widths from main table and pass it to prefs handler 1.1850 + if (m_pMaintable->columnWidth(TITRAQ_IDXSTATUS) > 0) 1.1851 + m_pPrefs->setNumber(TITRAQ_PREFSTATCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXSTATUS)); 1.1852 + if (m_pMaintable->columnWidth(TITRAQ_IDXLINE) > 0) 1.1853 + m_pPrefs->setNumber(TITRAQ_PREFLCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXLINE)); 1.1854 + if (m_pMaintable->columnWidth(TITRAQ_IDXUSER) > 0) 1.1855 + m_pPrefs->setNumber(TITRAQ_PREFUCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXUSER)); 1.1856 + if (m_pMaintable->columnWidth(TITRAQ_IDXGUID) > 0) 1.1857 + m_pPrefs->setNumber(TITRAQ_PREFGCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXGUID)); 1.1858 + if (m_pMaintable->columnWidth(TITRAQ_IDXCRC) > 0) 1.1859 + m_pPrefs->setNumber(TITRAQ_PREFCCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXCRC)); 1.1860 + if (m_pMaintable->columnWidth(TITRAQ_IDXREV) > 0) 1.1861 + m_pPrefs->setNumber(TITRAQ_PREFREVCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXREV)); 1.1862 + if (m_pMaintable->columnWidth(TITRAQ_IDXDATE) > 0) 1.1863 + m_pPrefs->setNumber(TITRAQ_PREFDCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXDATE)); 1.1864 + if (m_pMaintable->columnWidth(TITRAQ_IDXSTART) > 0) 1.1865 + m_pPrefs->setNumber(TITRAQ_PREFSTARTCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXSTART)); 1.1866 + if (m_pMaintable->columnWidth(TITRAQ_IDXFINISH) > 0) 1.1867 + m_pPrefs->setNumber(TITRAQ_PREFFCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXFINISH)); 1.1868 + if (m_pMaintable->columnWidth(TITRAQ_IDXAMOUNT) > 0) 1.1869 + m_pPrefs->setNumber(TITRAQ_PREFACOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXAMOUNT)); 1.1870 + if (m_pMaintable->columnWidth(TITRAQ_IDXTASK) > 0) 1.1871 + m_pPrefs->setNumber(TITRAQ_PREFTCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXTASK)); 1.1872 + if (m_pMaintable->columnWidth(TITRAQ_IDXREMARK) > 0) 1.1873 + m_pPrefs->setNumber(TITRAQ_PREFREMCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXREMARK)); 1.1874 + 1.1875 + // Get sorting order and direction from table and pass it to prefs handler 1.1876 + m_pPrefs->setNumber(TITRAQ_PREFSORTCOL, (long)m_pMaintable->getSortcol()); 1.1877 + m_pPrefs->setBool(TITRAQ_PREFSORTDIR, (long)m_pMaintable->getSortdir()); 1.1878 + 1.1879 + // Set frame geometry preferences 1.1880 + m_pPrefs->setNumber(TITRAQ_PREFFRAMEWIDTH, (long)this->width()); 1.1881 + m_pPrefs->setNumber(TITRAQ_PREFFRAMEHEIGHT, (long)this->height()); 1.1882 + 1.1883 + // Remember main window layout and doc positions 1.1884 + QString Laystring; 1.1885 + QTextStream Laystream(&Laystring, IO_WriteOnly); 1.1886 + Laystream << *this; // Persist the main window 1.1887 + m_pPrefs->setString(TITRAQ_PREFFRAMELAY, Laystring); 1.1888 +} 1.1889 + 1.1890 +// 1.1891 +// Get help on Titraq functionality 1.1892 +// 1.1893 +void Titraqform::helpContents(void) 1.1894 +{ 1.1895 + try { // Create and execute a new help contents window 1.1896 + std::auto_ptr<AS::Helpanel> pHelpcont(new AS::Helpanel(TITRAQ_REFHELP, this, "Helpanel")); 1.1897 + pHelpcont->exec(); 1.1898 + delete pHelpcont.release(); // Technically unnecessary, smart pointer 1.1899 + } 1.1900 + catch (Genexcept& Genex) { 1.1901 + Genex.reportErr(); 1.1902 + return; 1.1903 + } 1.1904 +} 1.1905 + 1.1906 +// 1.1907 +// Learn more about this program itself 1.1908 +// 1.1909 +void Titraqform::aboutTitraq(void) 1.1910 +{ 1.1911 + QString Namever = QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short; 1.1912 + QMessageBox *pCwmsg = new QMessageBox(Namever, 1.1913 + QObject::trUtf8("The as-gui is a time and task-based accounting\n" 1.1914 + "system that acts as both a work-like punch card and\n" 1.1915 + "time tracker. Development of as-gui is sponsored by\n" 1.1916 + "Cable & Wireless Telecommunications Services GmbH."), 1.1917 + QMessageBox::NoIcon, QMessageBox::Ok | QMessageBox::Default, 1.1918 + QMessageBox::NoButton, QMessageBox::NoButton, 1.1919 + NULL, "Titraqmessage", true, Qt::WStyle_NormalBorder); 1.1920 + 1.1921 + pCwmsg->setIconPixmap(QPixmap(s_kpcCwlogo_xpm)); 1.1922 + pCwmsg->exec(); 1.1923 +} 1.1924 + 1.1925 +// 1.1926 +// Learn more about the OSSP 1.1927 +// 1.1928 +void Titraqform::aboutOSSP(void) 1.1929 +{ 1.1930 + QString Namever = QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short; 1.1931 + QMessageBox *pOsspmsg = new QMessageBox(Namever, 1.1932 + QObject::trUtf8("The open source software project (OSSP) is\n" 1.1933 + "a collective effort aimed at implementing\n" 1.1934 + "high-quality Unix software components,\n" 1.1935 + "ranging from networking, multi-threading\n" 1.1936 + "and algorithmic libraries to networking\n" 1.1937 + "servers and development tools."), 1.1938 + QMessageBox::NoIcon, QMessageBox::Ok | QMessageBox::Default, 1.1939 + QMessageBox::NoButton, QMessageBox::NoButton, 1.1940 + NULL, "Osspmessage", true, Qt::WStyle_NormalBorder); 1.1941 + 1.1942 + pOsspmsg->setIconPixmap(QPixmap(s_kpcOssplogo_xpm)); 1.1943 + pOsspmsg->exec(); 1.1944 +} 1.1945 + 1.1946 +// 1.1947 +// Learn more about this program and Qt 1.1948 +// 1.1949 +void Titraqform::aboutQt(void) 1.1950 +{ 1.1951 + QMessageBox::aboutQt(this, QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short); 1.1952 +} 1.1953 + 1.1954 +// 1.1955 +// Apply preference values from a signal emitting object 1.1956 +// 1.1957 +void Titraqform::applyPrefs(void) 1.1958 +{ 1.1959 + Prefpanel *pPan = (Prefpanel *)QObject::sender(); 1.1960 + this->applyPrefs(pPan); 1.1961 +} 1.1962 + 1.1963 +// 1.1964 +// Accept preference values from a inbound Panel object 1.1965 +// 1.1966 +void Titraqform::applyPrefs(Prefpanel *pPrefpanel) 1.1967 +{ 1.1968 + m_pPrefs->setString(TITRAQ_PREFACCOUNTS, pPrefpanel->getAccounts()); 1.1969 + m_pPrefs->setString(TITRAQ_PREFASDIR, pPrefpanel->getEvents()); 1.1970 + m_pPrefs->setString(TITRAQ_PREFUSER, pPrefpanel->getUser()); 1.1971 + m_pPrefs->setString(TITRAQ_PREFHOME, pPrefpanel->getHome()); 1.1972 + m_pPrefs->setString(TITRAQ_PREFCORBHOST, pPrefpanel->getCorbahost()); 1.1973 + m_pPrefs->setString(TITRAQ_PREFSOAPHOST, pPrefpanel->getSoaphost()); 1.1974 + m_pPrefs->setBool(TITRAQ_PREFCORBON, pPrefpanel->getCorbaon()); 1.1975 + m_pPrefs->setBool(TITRAQ_PREFSOAPON, pPrefpanel->getSoapon()); 1.1976 + m_pPrefs->setBool(TITRAQ_PREFBAKON, pPrefpanel->getBackon()); 1.1977 + m_pPrefs->setBool(TITRAQ_PREFEXTENDON, pPrefpanel->getExtendon()); 1.1978 + m_pPrefs->setBool(TITRAQ_PREFDETAILON, pPrefpanel->getDetailon()); 1.1979 + m_pPrefs->setBool(TITRAQ_PREFSIGNATON, pPrefpanel->getSignaton()); 1.1980 + m_pPrefs->setNumber(TITRAQ_PREFLIGHTRED, pPrefpanel->getLight()->red()); 1.1981 + m_pPrefs->setNumber(TITRAQ_PREFLIGHTGREEN, pPrefpanel->getLight()->green()); 1.1982 + m_pPrefs->setNumber(TITRAQ_PREFLIGHTBLUE, pPrefpanel->getLight()->blue()); 1.1983 + m_pPrefs->setNumber(TITRAQ_PREFDARKRED, pPrefpanel->getDark()->red()); 1.1984 + m_pPrefs->setNumber(TITRAQ_PREFDARKGREEN, pPrefpanel->getDark()->green()); 1.1985 + m_pPrefs->setNumber(TITRAQ_PREFDARKBLUE, pPrefpanel->getDark()->blue()); 1.1986 + 1.1987 + // Dim the lights if no RPC transports are available 1.1988 + if (this->isOpen()) 1.1989 + m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON) 1.1990 + | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)); 1.1991 + else 1.1992 + m_pSyncact->setEnabled(false); 1.1993 + 1.1994 + // Get the selected style which can be more complicated due to mapping... 1.1995 + if (pPrefpanel->getStyle() == TITRAQ_STRCDE) { 1.1996 + m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE); 1.1997 + qApp->setStyle(new QCDEStyle); 1.1998 + } 1.1999 + else if (pPrefpanel->getStyle() == TITRAQ_STRSGI) { 1.2000 + m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLESGI); 1.2001 + qApp->setStyle(new QSGIStyle); 1.2002 + } 1.2003 + else if (pPrefpanel->getStyle() == TITRAQ_STRMOTIF) { 1.2004 + m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMOTIF); 1.2005 + qApp->setStyle(new QMotifStyle); 1.2006 + } 1.2007 + else if (pPrefpanel->getStyle() == TITRAQ_STRMPLUS) { 1.2008 + m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMPLUS); 1.2009 + qApp->setStyle(new QMotifPlusStyle); 1.2010 + } 1.2011 + else if (pPrefpanel->getStyle() == TITRAQ_STRPLAT) { 1.2012 + m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEPLAT); 1.2013 + qApp->setStyle(new QPlatinumStyle); 1.2014 + } 1.2015 + else if (pPrefpanel->getStyle() == TITRAQ_STRMSOFT) { 1.2016 + m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMSOFT); 1.2017 + qApp->setStyle(new QWindowsStyle); 1.2018 + } 1.2019 + else // My personal favourite ;-) 1.2020 + m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE); 1.2021 +}