as_slot.cpp

Fri, 28 Nov 2008 11:21:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 28 Nov 2008 11:21:08 +0100
changeset 1
d64aaa7d146f
child 3
c1941114ca88
permissions
-rw-r--r--

Fork project trunk at version 0.7.7 to maintain for future usage.
The original Cable & Wireless development team no longer exists.
The OSSP CVS repository is unavailable (cvs co ossp-pkg/as fails),
however http://cvs.ossp.org/dirview?d=ossp-pkg/as/as-gui is working.

michael@1 1 //
michael@1 2 // OSSP asgui - Accounting system graphical user interface
michael@1 3 // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/)
michael@1 4 // Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com>
michael@1 5 // Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com>
michael@1 6 // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH
michael@1 7 //
michael@1 8 // This file is part of OSSP asgui, an accounting system graphical user
michael@1 9 // interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
michael@1 10 //
michael@1 11 // Permission to use, copy, modify, and distribute this software for
michael@1 12 // any purpose with or without fee is hereby granted, provided that
michael@1 13 // the above copyright notice and this permission notice appear in all
michael@1 14 // copies.
michael@1 15 //
michael@1 16 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@1 17 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@1 18 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@1 19 // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@1 20 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@1 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@1 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@1 23 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@1 24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@1 25 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@1 26 // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@1 27 // SUCH DAMAGE.
michael@1 28 //
michael@1 29 // as_slot.cpp: ISO C++ implementation
michael@1 30 //
michael@1 31
michael@1 32 // system headers
michael@1 33 #include <memory>
michael@1 34 #include <cstring>
michael@1 35
michael@1 36 // Qt headers
michael@1 37 #include <qfiledialog.h>
michael@1 38 #include <qcombobox.h>
michael@1 39 #include <qclipboard.h>
michael@1 40 #include <qmenudata.h>
michael@1 41 #include <qdatastream.h>
michael@1 42 #include <qstatusbar.h>
michael@1 43 #include <qaction.h>
michael@1 44 #include <qpopupmenu.h>
michael@1 45
michael@1 46 // Qt style headers
michael@1 47 #include <qcdestyle.h>
michael@1 48 #include <qsgistyle.h>
michael@1 49 #include <qmotifstyle.h>
michael@1 50 #include <qmotifplusstyle.h>
michael@1 51 #include <qplatinumstyle.h>
michael@1 52 #include <qwindowsstyle.h>
michael@1 53
michael@1 54 // User interface
michael@1 55 #include "as_const.h" // Application constants
michael@1 56 #include "as_except.h" // Exception classes
michael@1 57 #include "as_tableitem.h" // For our custom table items
michael@1 58 #include "as_generic.h" // Generic classes
michael@1 59 #include "as_uuid.h" // UUID classes
michael@1 60 #include "as_datedit.h" // Derived from QDateEdit
michael@1 61 #include "as_amount.h" // Derived from QTimeEdit
michael@1 62 #include "as_crc.h" // Useful Qualistring class
michael@1 63 #include "as_pref.h" // For Preferences class
michael@1 64 #include "as_panel.h" // For Prefpanel class
michael@1 65 #include "as_reportpanel.h" // For Reportpanel class
michael@1 66 #include "as_helpanel.h" // For Helpanel class
michael@1 67 #include "as_sfile.h" // For Simplefile class
michael@1 68 #include "as_table.h" // For TiTable class
michael@1 69
michael@1 70 // RPC headers
michael@1 71 #ifdef HAVE_ESOAP
michael@1 72 #include <easysoap/SOAP.h>
michael@1 73 #endif // HAVE_ESOAP
michael@1 74 #ifdef HAVE_MICO
michael@1 75 #include <coss/CosNaming.h>
michael@1 76 #include "as_stub.h" // CORBA stubs and skeletons
michael@1 77 #endif // HAVE_MICO
michael@1 78
michael@1 79 // Icon pixel maps
michael@1 80 #include "as_gfx/cwlogo.xpm" // static const char *s_kpcCwlogo_xpm[]
michael@1 81 #include "as_gfx/ossplogo.xpm" // static const char *s_kpcOssplogo_xpm[]
michael@1 82 #include "as_gfx/statok.xpm" // static const char *s_kpcStatokay_xpm[]
michael@1 83 #include "as_gfx/staterr.xpm" // static const char *s_kpcStaterror_xpm[]
michael@1 84 #include "as_gfx/statwrn.xpm" // static const char *s_kpcStatwarn_xpm[]
michael@1 85 #include "as_gfx/statvoid.xpm" // static const char *s_kpcStatvoid_xpm[]
michael@1 86
michael@1 87
michael@1 88 //
michael@1 89 // Cut an entry
michael@1 90 //
michael@1 91 void Titraqform::cutEntry(void)
michael@1 92 {
michael@1 93 this->copyEntry(); // Reuse slot
michael@1 94 this->delEntry(); // Reuse slot
michael@1 95 }
michael@1 96
michael@1 97 //
michael@1 98 // Copy an entry
michael@1 99 //
michael@1 100 void Titraqform::copyEntry(void)
michael@1 101 {
michael@1 102 QString Selection; // Will hold the selected text
michael@1 103 QClipboard *pClip; // Will reference the global clipboard
michael@1 104
michael@1 105 // Initialize data and clipboard handle
michael@1 106 Selection = getRowdata(); // Use accessor
michael@1 107 pClip = QApplication::clipboard();
michael@1 108
michael@1 109 Q_ASSERT(!Selection.isNull());
michael@1 110 pClip->setText(Selection, QClipboard::Selection); // Doesn't work on Windows
michael@1 111 pClip->setText(Selection, QClipboard::Clipboard); // Works on both equally
michael@1 112 }
michael@1 113
michael@1 114 //
michael@1 115 // Paste an entry
michael@1 116 //
michael@1 117 void Titraqform::pasteEntry(void)
michael@1 118 {
michael@1 119 int nRows = 0; // Paste so many rows as are stored
michael@1 120 QString Selection; // Will receive the clipboard text
michael@1 121 QClipboard *pClip = NULL; // Will reference the global clipboard
michael@1 122
michael@1 123 pClip = QApplication::clipboard(); // Prime the clips
michael@1 124 Selection = pClip->text(QClipboard::Clipboard); // Windows and Unix
michael@1 125 nRows = Selection.contains(QChar('\n')); // How many rows
michael@1 126 if (Selection != NULL && nRows > 0) { // Ignore empty clipboards
michael@1 127 this->addEntry(nRows); // Reuse slot
michael@1 128 setRowdata(Selection); // Use accessor
michael@1 129
michael@1 130 // Update line numbers for this new row and all subsequent rows
michael@1 131 for (int nIter = m_pMaintable->currentRow(); nIter < m_pMaintable->numRows(); nIter++)
michael@1 132 m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter).rightJustify(4, QChar('0')));
michael@1 133
michael@1 134 // Do basic data validation to warn against missing fields
michael@1 135 for (int nIter = 0; nIter < nRows; nIter++)
michael@1 136 this->validateRow(m_pMaintable->currentRow() + nIter, 0);
michael@1 137
michael@1 138 m_pStatbar->message(QString::number(nRows) + trUtf8(" rows pasted"), 4000);
michael@1 139 updEdit(m_pMaintable->currentRow()); // Reflect in the update controls
michael@1 140 }
michael@1 141 else // Well, I guess the user tried to paste an empty clipboard
michael@1 142 m_pStatbar->message(trUtf8("The clipboard is empty"), 4000);
michael@1 143 }
michael@1 144
michael@1 145 //
michael@1 146 // Append a blank row entry
michael@1 147 //
michael@1 148 void Titraqform::addEntry(int nRows)
michael@1 149 {
michael@1 150 QTableSelection Select; // Highlighted text
michael@1 151 int nTotal = 0; // Total row select
michael@1 152 int nCurrent = 0; // Current row
michael@1 153 std::auto_ptr<AS::Uuid> pGuid(new AS::Uuid); // For GUID production
michael@1 154
michael@1 155 // Decide how many rows to add
michael@1 156 Select = m_pMaintable->selection(0);
michael@1 157 if (nRows > 0)
michael@1 158 nTotal = nRows;
michael@1 159 else
michael@1 160 nTotal = Select.bottomRow() - Select.topRow() + 1;
michael@1 161
michael@1 162 // Optimize viewing by repainting cells only once after processing
michael@1 163 m_pMaintable->setUpdatesEnabled(false);
michael@1 164
michael@1 165 // Add a row after selection and focus to the new row
michael@1 166 if (Select.bottomRow() + 1 != m_pMaintable->numRows()) { // Add upwards
michael@1 167 m_pMaintable->insertRows(Select.topRow(), nTotal);
michael@1 168 m_pMaintable->setDirty(); // Set data to dirty state
michael@1 169 m_pMaintable->setCurrentCell(Select.topRow(), m_pMaintable->currentColumn());
michael@1 170
michael@1 171 // According to Trolltech, insertRows() "clears the selection(s)".
michael@1 172 // They are pretty wrong about that, so unfortunately we'll have to
michael@1 173 // take care of the dirty work ourselves with a clearSelection().
michael@1 174 m_pMaintable->clearSelection(false);
michael@1 175 m_pMaintable->selectRow(m_pMaintable->currentRow());
michael@1 176
michael@1 177 // Update relevant data fields for all new rows
michael@1 178 for (int nIter = 0; nIter < nTotal; nIter++) {
michael@1 179 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXSTATUS, QString(QChar('W')));
michael@1 180 m_pMaintable->setPixmap(Select.topRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm));
michael@1 181 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER));
michael@1 182 pGuid->genId();
michael@1 183 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXGUID, pGuid->getString());
michael@1 184 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXCRC, "0"); // 0 = invalid entry
michael@1 185 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXREV, "0"); // Entry not revised
michael@1 186 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate));
michael@1 187 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXSTART, "00:00");
michael@1 188 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXFINISH, "00:00");
michael@1 189 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXAMOUNT, "00:00");
michael@1 190 // m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXTASK, "/");
michael@1 191 // m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXREMARK, "Remark");
michael@1 192 m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXCRC, "1"); // 0 = invalid entry
michael@1 193 this->calcCrc(Select.topRow() + nIter, -1);
michael@1 194 }
michael@1 195 }
michael@1 196 else { // Special case on last row add downwards
michael@1 197 m_pMaintable->insertRows(Select.bottomRow() + 1, nTotal);
michael@1 198 m_pMaintable->setDirty(); // Set data to dirty state
michael@1 199 m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
michael@1 200
michael@1 201 // According to Trolltech, insertRows() "clears the selection(s)".
michael@1 202 // They are pretty wrong about that, so unfortunately we'll have to
michael@1 203 // take care of the dirty work ourselves with a clearSelection().
michael@1 204 m_pMaintable->clearSelection(false);
michael@1 205 m_pMaintable->selectRow(m_pMaintable->currentRow());
michael@1 206
michael@1 207 // Update relevant data fields for all new rows
michael@1 208 for (int nIter = 1; nIter <= nTotal; nIter++) {
michael@1 209 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXSTATUS, QString(QChar('W')));
michael@1 210 m_pMaintable->setPixmap(Select.bottomRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm));
michael@1 211 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER));
michael@1 212 pGuid->genId();
michael@1 213 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXGUID, pGuid->getString());
michael@1 214 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXCRC, "0");
michael@1 215 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXREV, "0");
michael@1 216 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate));
michael@1 217 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXSTART, "00:00");
michael@1 218 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXFINISH, "00:00");
michael@1 219 m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXAMOUNT, "00:00");
michael@1 220 // m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXTASK, "/");
michael@1 221 // m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXREMARK, "Remark");
michael@1 222 this->calcCrc(Select.bottomRow() + nIter, -1);
michael@1 223 }
michael@1 224 }
michael@1 225
michael@1 226 // Update line numbers for this new row and all subsequent rows
michael@1 227 for (int nIter = m_pMaintable->currentRow(); nIter < m_pMaintable->numRows(); nIter++)
michael@1 228 m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter).rightJustify(4, QChar('0')));
michael@1 229
michael@1 230 updEdit(m_pMaintable->currentRow()); // Reflect in the update controls
michael@1 231 m_pStatusedit->setPixmap(QPixmap(s_kpcStatwarn_xpm)); // Show pixmap
michael@1 232
michael@1 233 m_pMaintable->setUpdatesEnabled(true); // Turn updates back on
michael@1 234 m_pMaintable->repaintContents(true); // Do a general repaint of table
michael@1 235 m_pMaintable->ensureCellVisible(m_pMaintable->currentRow() + nTotal - 1, m_pMaintable->currentColumn());
michael@1 236 m_pMaintable->ensureCellVisible(m_pMaintable->currentRow(), m_pMaintable->currentColumn());
michael@1 237
michael@1 238 // In case we added the first and only row entry,
michael@1 239 // do post state adjustments like icon undimming
michael@1 240 if (m_pMaintable->numRows() == 1) {
michael@1 241 m_pDelrowact->setEnabled(true);
michael@1 242 m_pRefreshact->setEnabled(true);
michael@1 243 m_pCutact->setEnabled(true);
michael@1 244 m_pCopyact->setEnabled(true);
michael@1 245
michael@1 246 // Brighten all the edit controls also
michael@1 247 m_pLineedit->setEnabled(true);
michael@1 248 m_pUseredit->setEnabled(true);
michael@1 249 m_pGuidedit->setEnabled(true);
michael@1 250 m_pCrcedit->setEnabled(true);
michael@1 251 m_pRevedit->setEnabled(true);
michael@1 252 m_pDateedit->setEnabled(true);
michael@1 253 m_pStarttime->setEnabled(true);
michael@1 254 m_pEndtime->setEnabled(true);
michael@1 255 m_pAmount->setEnabled(true);
michael@1 256 m_pTasks->setEnabled(true);
michael@1 257 m_pRemark->setEnabled(true);
michael@1 258
michael@1 259 // And optionally the RPC actions, too
michael@1 260 #if defined HAVE_MICO || defined HAVE_ESOAP
michael@1 261 m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON)
michael@1 262 | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON));
michael@1 263 #endif // HAVE_MICO || defined HAVE_ESOAP
michael@1 264 }
michael@1 265 }
michael@1 266
michael@1 267 //
michael@1 268 // Delete a row entry
michael@1 269 //
michael@1 270 void Titraqform::delEntry(int nRows)
michael@1 271 {
michael@1 272 QTableSelection Select = m_pMaintable->selection(0); // Highlighted text
michael@1 273 int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total row select
michael@1 274 QMemArray<int> Rowselect(nTotal); // Row array
michael@1 275
michael@1 276 // Calculate rows to delete from selection highlight
michael@1 277 for (int nIter = 0; nIter < nTotal; ++nIter)
michael@1 278 Rowselect[nIter] = Select.topRow() + nIter;
michael@1 279
michael@1 280 // Remove the row at selection and focus to the next row
michael@1 281 if (m_pMaintable->currentRow() + 1 != m_pMaintable->numRows()) {
michael@1 282 m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
michael@1 283 m_pMaintable->removeRows(Rowselect);
michael@1 284 m_pMaintable->setDirty(); // Set data to dirty state
michael@1 285 }
michael@1 286 else { // Special case to handle removing of only row or last row
michael@1 287 m_pMaintable->removeRows(Rowselect);
michael@1 288 m_pMaintable->setDirty(); // Set data to dirty state
michael@1 289 }
michael@1 290
michael@1 291 // Update line numbers for this new row and all subsequent rows
michael@1 292 for (int nIter = m_pMaintable->currentRow(); nIter < m_pMaintable->numRows(); nIter++)
michael@1 293 m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter));
michael@1 294
michael@1 295 // In case we removed the last remaining row,
michael@1 296 // do post state adjustments like icon dimming
michael@1 297 if (m_pMaintable->numRows() <= 0) {
michael@1 298 m_pDelrowact->setEnabled(false);
michael@1 299 m_pRefreshact->setEnabled(false);
michael@1 300 m_pCutact->setEnabled(false);
michael@1 301 m_pCopyact->setEnabled(false);
michael@1 302
michael@1 303 // Dim all the edit controls also
michael@1 304 m_pStatusedit->setPixmap(s_kpcStatvoid_xpm);
michael@1 305 m_pLineedit->setEnabled(false);
michael@1 306 m_pUseredit->setEnabled(false);
michael@1 307 m_pGuidedit->setEnabled(false);
michael@1 308 m_pCrcedit->setEnabled(false);
michael@1 309 m_pRevedit->setEnabled(false);
michael@1 310 m_pDateedit->setEnabled(false);
michael@1 311 m_pStarttime->setEnabled(false);
michael@1 312 m_pEndtime->setEnabled(false);
michael@1 313 m_pAmount->setEnabled(false);
michael@1 314 m_pTasks->setEnabled(false);
michael@1 315 m_pRemark->setEnabled(false);
michael@1 316
michael@1 317 // And optionally dim the RPC actions
michael@1 318 #if defined HAVE_MICO || defined HAVE_ESOAP
michael@1 319 m_pSyncact->setEnabled(false);
michael@1 320 #endif // HAVE_MICO || defined HAVE_ESOAP
michael@1 321 }
michael@1 322 }
michael@1 323
michael@1 324 //
michael@1 325 // Refresh the display of all data items
michael@1 326 //
michael@1 327 void Titraqform::refreshDisplay(void)
michael@1 328 {
michael@1 329 int nIter = 0; // Matrix iterator
michael@1 330 int nRows = m_pMaintable->numRows(); // Total number of rows
michael@1 331
michael@1 332 // Sweep through matrix validating linewise
michael@1 333 // data and updating line numbers for all rows
michael@1 334 while (nIter < nRows) {
michael@1 335 this->validateRow(nIter, 0);
michael@1 336 m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter).rightJustify(4, QChar('0')));
michael@1 337 nIter++;
michael@1 338 }
michael@1 339
michael@1 340 m_pMaintable->repaintContents(false); // Do a general repaint of table
michael@1 341 m_pStatbar->message(trUtf8("Display was refreshed"), 4000); // Announce result
michael@1 342 }
michael@1 343
michael@1 344 //
michael@1 345 // Make and display a new document window
michael@1 346 //
michael@1 347 void Titraqform::newDoc(void)
michael@1 348 {
michael@1 349 int nResult = 0; // Holds return value from save first messagebox
michael@1 350
michael@1 351 // Check modification state of current data
michael@1 352 if (m_pMaintable->isDirty()) {
michael@1 353 nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE)
michael@1 354 + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST),
michael@1 355 trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
michael@1 356
michael@1 357 switch (nResult) {
michael@1 358 case 0: // First button selected, so save first
michael@1 359 this->saveFile(); // Save changes first
michael@1 360 break;
michael@1 361 case 1: // Second button selected, so don't save
michael@1 362 break;
michael@1 363 case 2: // Third button selected, so return sofort
michael@1 364 default:
michael@1 365 m_pStatbar->message(trUtf8("New aborted"), 4000);
michael@1 366 return;
michael@1 367 break;
michael@1 368 }
michael@1 369 }
michael@1 370
michael@1 371 if (!m_pMaintable->isDirty() || nResult == 1) { // Check modification state
michael@1 372 // Fall through to implicit new doc code
michael@1 373 this->setCaption(trUtf8("No file name"));
michael@1 374 m_pStatbar->message(trUtf8("New document"), 4000);
michael@1 375 this->enableIface(true); // Enable the interface
michael@1 376 m_pMaintable->setNumRows(0); // Remove all data in table
michael@1 377 this->setFilename(""); // Signal a closed doc state
michael@1 378 this->addEntry(1); // Default new op adds a row
michael@1 379 m_pMaintable->setDirty(false); // Start out clean
michael@1 380 }
michael@1 381 }
michael@1 382
michael@1 383 //
michael@1 384 // Open and display an existing document
michael@1 385 //
michael@1 386 void Titraqform::openDoc(void)
michael@1 387 {
michael@1 388 int nResult = 0; // Holds return value from save first messagebox
michael@1 389
michael@1 390 //
michael@1 391 // This block will guide the user to saving the contents of the timesheet
michael@1 392 // before losing them in an open operation. The question and dialog box will
michael@1 393 // not be raised if no open timesheet exists or if it was just serialized.
michael@1 394 //
michael@1 395 if (m_pMaintable->isDirty()) { // Check modification state
michael@1 396 nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE)
michael@1 397 + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST),
michael@1 398 trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
michael@1 399
michael@1 400 switch (nResult) {
michael@1 401 case 0: // Save first
michael@1 402 this->saveFile(); // Save changes first
michael@1 403 break;
michael@1 404 case 1: // Don't save first but do load
michael@1 405 break;
michael@1 406 case 2: // Don't do a load timesheet
michael@1 407 default:
michael@1 408 m_pStatbar->message(trUtf8("Loading aborted"), 4000);
michael@1 409 return;
michael@1 410 break;
michael@1 411 }
michael@1 412 }
michael@1 413
michael@1 414 //
michael@1 415 // This block ensures that conditions of first block logic were met if
michael@1 416 // applicable. If so, the user gives a file name to open or cancels the
michael@1 417 // operation. The corresponding file will be opened, and if this is
michael@1 418 // unsuccessful then the post state is exactly the same as the pre state.
michael@1 419 //
michael@1 420 if (!m_pMaintable->isDirty() || nResult == 1) { // Check modification state
michael@1 421 // Make sure we correctly get the name of the default file to open
michael@1 422 QString Openas = m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR);
michael@1 423 if (Openas.startsWith(TITRAQ_HOMEDIRTOK))
michael@1 424 Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1);
michael@1 425
michael@1 426 // This dialog asks which file the user wants to open
michael@1 427 QString Filestring = QFileDialog::getOpenFileName(Openas,
michael@1 428 trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"),
michael@1 429 this, trUtf8("ChooserDialog"), trUtf8("Choose a file to open"), NULL, false);
michael@1 430
michael@1 431 // We might have a filename to work on, so do something with it
michael@1 432 if (!Filestring.isEmpty()) {
michael@1 433 QFile Filetemp(Filestring); // File to load
michael@1 434 try {
michael@1 435 if (Filetemp.exists() && validateData(Filetemp)) { // Be extra sure
michael@1 436 setFilename(Filestring); // Set the new file name
michael@1 437 m_pMaintable->setNumRows(0); // Clear out old data
michael@1 438 m_pMaintable->setDirty(false); // Reset dirty flag
michael@1 439 loadData(Filetemp); // Pass to helper method
michael@1 440 this->setCaption(Filestring); // Caption in the titlebar
michael@1 441 m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
michael@1 442 this->enableIface(true); // Turn on the lights
michael@1 443 this->setOpen(true); // Indicate doc is open
michael@1 444 }
michael@1 445 }
michael@1 446 catch (Genexcept& Genex) { // Crap, we failed
michael@1 447 m_pStatbar->message(trUtf8("Loading failed"), 4000);
michael@1 448 Genex.reportErr();
michael@1 449 return;
michael@1 450 }
michael@1 451 }
michael@1 452 else // An empty filename returning from the file dialog means cancel
michael@1 453 m_pStatbar->message(trUtf8("Loading aborted"), 4000);
michael@1 454 }
michael@1 455 }
michael@1 456
michael@1 457 //
michael@1 458 // Serialize current state to the current file
michael@1 459 //
michael@1 460 void Titraqform::saveFile(void)
michael@1 461 {
michael@1 462 QString Fname;
michael@1 463 Simplefile Filevents;
michael@1 464
michael@1 465 try {
michael@1 466 Fname = *this->getFilename();
michael@1 467
michael@1 468 // First time saves are really just saveName in disguise
michael@1 469 if (Fname.isEmpty()) {
michael@1 470 try {
michael@1 471 this->saveName(); // Try to 'save as'
michael@1 472 return; // and short circuit
michael@1 473 }
michael@1 474 catch (Genexcept& Genex) {
michael@1 475 // Genex.reportErr(); // Report the error
michael@1 476 return; // and short circuit
michael@1 477 }
michael@1 478 }
michael@1 479
michael@1 480 Filevents.setName(Fname); // Construct a file to write
michael@1 481 if (m_pPrefs->getBool(TITRAQ_PREFBAKON, TITRAQ_DEFBAKON))
michael@1 482 Filevents.makeBackup(); // Back up to filename.bak
michael@1 483 this->saveData(Filevents); // Pass to helper method
michael@1 484 }
michael@1 485 catch (Genexcept& Genex) {
michael@1 486 Genex.reportErr();
michael@1 487 }
michael@1 488 // Reset and give output to main window
michael@1 489 this->setCaption(Fname);
michael@1 490 m_pStatbar->message(trUtf8("File %1 saved").arg(Fname), 4000);
michael@1 491 m_pMaintable->setDirty(false); // Set the clean state to allow close
michael@1 492 }
michael@1 493
michael@1 494 //
michael@1 495 // Serialize current state to a selected file
michael@1 496 //
michael@1 497 void Titraqform::saveAs(void)
michael@1 498 {
michael@1 499 int nResult = 0; // For checking user's answer
michael@1 500
michael@1 501 // Make sure we correctly get the name of the default file to open
michael@1 502 QString Openas = m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR);
michael@1 503 if (Openas.startsWith(TITRAQ_HOMEDIRTOK))
michael@1 504 Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1);
michael@1 505
michael@1 506 // And then get the name of the selected file to save to
michael@1 507 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);
michael@1 508 if (!Filestring.isEmpty()) {
michael@1 509 if (QFile::exists(Filestring)) {
michael@1 510 nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE)
michael@1 511 + ' ' + asgui_version.v_short, trUtf8(TITRAQ_OVERWRITE),
michael@1 512 trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1);
michael@1 513 switch (nResult) {
michael@1 514 case 0: // Overwrite contents
michael@1 515 this->setFilename(Filestring);
michael@1 516 this->saveFile();
michael@1 517 break;
michael@1 518 case 1: // Don't overwrite
michael@1 519 default:
michael@1 520 break;
michael@1 521 }
michael@1 522 }
michael@1 523 else {
michael@1 524 // Conditionally use a unique extension like '.as' if user prefers
michael@1 525 if (m_pPrefs->getBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON)) {
michael@1 526 QString Extension = TITRAQ_FEXTENSION; // Logic to handle
michael@1 527 if (!Filestring.endsWith(Extension)) // AS file extension
michael@1 528 Filestring += Extension; // insertion
michael@1 529 }
michael@1 530 this->setFilename(Filestring); // Set filename of object first
michael@1 531 this->saveFile(); // Finish by calling the save action
michael@1 532 }
michael@1 533 }
michael@1 534 else
michael@1 535 // User did not select a valid file and push okay button
michael@1 536 m_pStatbar->message(trUtf8("Saving aborted"), 4000);
michael@1 537 }
michael@1 538
michael@1 539 //
michael@1 540 // Implicitly serialize current state to a selected file
michael@1 541 // The main difference with saveAs is that this uses exceptions
michael@1 542 //
michael@1 543 void Titraqform::saveName(void)
michael@1 544 {
michael@1 545 int nResult = 0; // For checking user's answer
michael@1 546
michael@1 547 // Make sure we correctly get the name of the default file to open
michael@1 548 QString Openas = m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR);
michael@1 549 if (Openas.startsWith(TITRAQ_HOMEDIRTOK))
michael@1 550 Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1);
michael@1 551
michael@1 552 nResult = 1; // We loop on this dialog only if an indecisive user
michael@1 553 while (nResult > 0) { // is hesitant to overwrite a file over and over again
michael@1 554 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);
michael@1 555 if (!Filestring.isEmpty()) {
michael@1 556 if (QFile::exists(Filestring)) {
michael@1 557 nResult = QMessageBox::warning(this, QString(TITRAQ_APPTITLE)
michael@1 558 + ' ' + asgui_version.v_short, trUtf8(TITRAQ_OVERWRITE),
michael@1 559 trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1);
michael@1 560 switch (nResult) {
michael@1 561 case 0: // Overwrite contents
michael@1 562 this->setFilename(Filestring);
michael@1 563 this->saveFile();
michael@1 564 break;
michael@1 565 case 1: // Don't overwrite
michael@1 566 default:
michael@1 567 break;
michael@1 568 }
michael@1 569 }
michael@1 570 else {
michael@1 571
michael@1 572 // Conditionally use a unique extension like '.as' if user prefers
michael@1 573 if (m_pPrefs->getBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON)) {
michael@1 574 QString Extension = TITRAQ_FEXTENSION; // Logic to handle
michael@1 575 if (!Filestring.endsWith(Extension)) // AS file extension
michael@1 576 Filestring += Extension; // insertion
michael@1 577 }
michael@1 578 this->setFilename(Filestring); // Set filename of object first
michael@1 579 nResult = 0; // Reset our loop control
michael@1 580 this->saveFile(); // Finish by calling the save action
michael@1 581 }
michael@1 582 }
michael@1 583 else {
michael@1 584 // User did not select a valid file and push okay button
michael@1 585 m_pStatbar->message(trUtf8("Saving aborted"), 4000);
michael@1 586 throw Genexcept(TITRAQ_SAVECANCELLED);
michael@1 587 }
michael@1 588 }
michael@1 589 }
michael@1 590
michael@1 591 //
michael@1 592 // Close current document, and then quit the application
michael@1 593 //
michael@1 594 void Titraqform::quitApp(void)
michael@1 595 {
michael@1 596 int nResult = 0;
michael@1 597
michael@1 598 if (m_pMaintable->isDirty()) {
michael@1 599 nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE)
michael@1 600 + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST),
michael@1 601 trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
michael@1 602
michael@1 603 switch (nResult) { // Maybe save before closing
michael@1 604 case 0: // Save first
michael@1 605 this->saveFile(); // Save changes first
michael@1 606 break;
michael@1 607 case 1: // Don't save first
michael@1 608 m_pMaintable->setDirty(false);
michael@1 609 break;
michael@1 610 case 2: // Do nothing
michael@1 611 default:
michael@1 612 return; // Go away without closing
michael@1 613 break;
michael@1 614 }
michael@1 615 }
michael@1 616
michael@1 617 // We should be clean now, but double check just in case
michael@1 618 if (!m_pMaintable->isDirty())
michael@1 619 qApp->quit();
michael@1 620 }
michael@1 621
michael@1 622 //
michael@1 623 // Close current document, displaying in main window
michael@1 624 //
michael@1 625 void Titraqform::closeEvent(QCloseEvent *pClosit)
michael@1 626 {
michael@1 627 int nResult = 0;
michael@1 628
michael@1 629 if (!this->isOpen()) // Short circuit if user
michael@1 630 qApp->quit(); // selects close twice
michael@1 631
michael@1 632 // Check modification state of current data
michael@1 633 if (m_pMaintable->isDirty()) {
michael@1 634 nResult = QMessageBox::information(this, QString(TITRAQ_APPTITLE)
michael@1 635 + ' ' + asgui_version.v_short, trUtf8(TITRAQ_SAVEFIRST),
michael@1 636 trUtf8("&Save"), trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
michael@1 637
michael@1 638 switch (nResult) { // Maybe save before closing
michael@1 639 case 0: // Save first
michael@1 640 this->saveFile(); // Save changes first
michael@1 641 break;
michael@1 642 case 1: // Don't save first
michael@1 643 m_pMaintable->setDirty(false);
michael@1 644 break;
michael@1 645 case 2: // Do nothing
michael@1 646 default:
michael@1 647 pClosit->ignore();
michael@1 648 return; // Go away without closing
michael@1 649 break;
michael@1 650 }
michael@1 651 }
michael@1 652
michael@1 653 if (!m_pMaintable->isDirty()) { // Check again
michael@1 654 // Fall through to implicit close code
michael@1 655 this->setCaption(QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short);
michael@1 656 try { // There might be problems, so wrap these last ops with error handling
michael@1 657 QString Lightsout; // It's late, go to bed
michael@1 658 if (this->isOpen())
michael@1 659 Lightsout = trUtf8("Closed document ") + *this->getFilename();
michael@1 660 this->setOpen(false); // Set doc state to closed
michael@1 661 this->enableIface(false); // Turn off the lights
michael@1 662 m_pStatbar->message(Lightsout, 4000);
michael@1 663 }
michael@1 664 catch (Genexcept& Genex) {
michael@1 665 Genex.reportErr();
michael@1 666 }
michael@1 667 }
michael@1 668 pClosit->ignore(); // Finish off by not closing
michael@1 669 }
michael@1 670
michael@1 671 //
michael@1 672 // Edit menu select all entries
michael@1 673 //
michael@1 674 void Titraqform::selAll(void)
michael@1 675 {
michael@1 676 Prototype Unimp;
michael@1 677 Unimp.doMbox();
michael@1 678 }
michael@1 679
michael@1 680 //
michael@1 681 // Edit a table entry in place, without the usual edit controls
michael@1 682 //
michael@1 683 void Titraqform::inplaceEdit(int nRow, int nCol, int nButton, const QPoint &Mousepos)
michael@1 684 {
michael@1 685 // Table read only attribute must be reset here, so that editing can take
michael@1 686 // place. Otherwise calls to editCell are ignored (for obvious reasons).
michael@1 687 m_pMaintable->setReadOnly(false);
michael@1 688
michael@1 689 // After editCell() is called, beginEdit() and endEdit() execute. The read
michael@1 690 // only attribute is reset in endEdit() to return everything to normal.
michael@1 691 m_pMaintable->editCell(nRow, nCol);
michael@1 692
michael@1 693 m_pMaintable->setEdition(nCol);
michael@1 694 }
michael@1 695
michael@1 696 //
michael@1 697 // Update the edit controls widget sizes
michael@1 698 //
michael@1 699 void Titraqform::updSizes(int nSection, int nOldsize, int nNewsize)
michael@1 700 {
michael@1 701 switch (nSection) {
michael@1 702 case TITRAQ_IDXALLCTRLS:
michael@1 703 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) > 0)
michael@1 704 m_pStatusedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) - TITRAQ_SPACING);
michael@1 705 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) > 0)
michael@1 706 m_pLineedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) - TITRAQ_SPACING);
michael@1 707 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) > 0)
michael@1 708 m_pUseredit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) - TITRAQ_SPACING);
michael@1 709 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) > 0)
michael@1 710 m_pGuidedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) - TITRAQ_SPACING);
michael@1 711 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) > 0)
michael@1 712 m_pCrcedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) - TITRAQ_SPACING);
michael@1 713 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) > 0)
michael@1 714 m_pRevedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) - TITRAQ_SPACING);
michael@1 715 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) > 0)
michael@1 716 m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING);
michael@1 717 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) > 0)
michael@1 718 m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING);
michael@1 719 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) > 0)
michael@1 720 m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING);
michael@1 721 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) > 0)
michael@1 722 m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING);
michael@1 723 if (m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) > 0)
michael@1 724 m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING);
michael@1 725 // if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXRCOL)))
michael@1 726 // m_pRemark->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREMARK) - TITRAQ_SPACING);
michael@1 727 break;
michael@1 728 case TITRAQ_IDXSTATUS:
michael@1 729 m_pStatusedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) - TITRAQ_SPACING);
michael@1 730 break;
michael@1 731 case TITRAQ_IDXLINE:
michael@1 732 m_pLineedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) - TITRAQ_SPACING);
michael@1 733 break;
michael@1 734 case TITRAQ_IDXUSER:
michael@1 735 m_pUseredit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) - TITRAQ_SPACING);
michael@1 736 break;
michael@1 737 case TITRAQ_IDXGUID:
michael@1 738 m_pGuidedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) - TITRAQ_SPACING);
michael@1 739 break;
michael@1 740 case TITRAQ_IDXCRC:
michael@1 741 m_pCrcedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) - TITRAQ_SPACING);
michael@1 742 break;
michael@1 743 case TITRAQ_IDXREV:
michael@1 744 m_pRevedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) - TITRAQ_SPACING);
michael@1 745 break;
michael@1 746 case TITRAQ_IDXDATE:
michael@1 747 m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING);
michael@1 748 break;
michael@1 749 case TITRAQ_IDXSTART:
michael@1 750 m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING);
michael@1 751 break;
michael@1 752 case TITRAQ_IDXFINISH:
michael@1 753 m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING);
michael@1 754 break;
michael@1 755 case TITRAQ_IDXAMOUNT:
michael@1 756 m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING);
michael@1 757 break;
michael@1 758 case TITRAQ_IDXTASK:
michael@1 759 m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING);
michael@1 760 break;
michael@1 761 case TITRAQ_IDXREMARK:
michael@1 762 // m_pRemark->setFixedWidth(nNewsize);
michael@1 763 break;
michael@1 764 default:
michael@1 765 throw Genexcept("Unrecognized main window column header.");
michael@1 766 break;
michael@1 767 }
michael@1 768
michael@1 769 // As a last and redundant step, adjust size of first visible control
michael@1 770 switch(this->getFirstcol()) {
michael@1 771 case TITRAQ_IDXSTATUS:
michael@1 772 m_pStatusedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTATUS) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 773 break;
michael@1 774 case TITRAQ_IDXLINE:
michael@1 775 m_pLineedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXLINE) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 776 break;
michael@1 777 case TITRAQ_IDXUSER:
michael@1 778 m_pUseredit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXUSER) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 779 break;
michael@1 780 case TITRAQ_IDXGUID:
michael@1 781 m_pGuidedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXGUID) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 782 break;
michael@1 783 case TITRAQ_IDXCRC:
michael@1 784 m_pCrcedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXCRC) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 785 break;
michael@1 786 case TITRAQ_IDXREV:
michael@1 787 m_pRevedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREV) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 788 break;
michael@1 789 case TITRAQ_IDXDATE:
michael@1 790 m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 791 break;
michael@1 792 case TITRAQ_IDXSTART:
michael@1 793 m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 794 break;
michael@1 795 case TITRAQ_IDXFINISH:
michael@1 796 m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 797 break;
michael@1 798 case TITRAQ_IDXAMOUNT:
michael@1 799 m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 800 break;
michael@1 801 case TITRAQ_IDXTASK:
michael@1 802 m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING + TITRAQ_SPACING / 2);
michael@1 803 break;
michael@1 804 default: // Probably no columns are visible?
michael@1 805 break;
michael@1 806 }
michael@1 807 }
michael@1 808
michael@1 809 //
michael@1 810 // What to do if a data cell is modified
michael@1 811 //
michael@1 812 void Titraqform::dataChanged(int nRow, int nCol)
michael@1 813 {
michael@1 814 if (nCol != TITRAQ_IDXSTATUS && nCol != TITRAQ_IDXLINE)
michael@1 815 m_pMaintable->setDirty(); // Mark this timesheet dirty, changes pending save
michael@1 816 }
michael@1 817
michael@1 818 //
michael@1 819 // Convenience member calculates CRC for current row
michael@1 820 //
michael@1 821 void Titraqform::calcCrc(void)
michael@1 822 {
michael@1 823 this->calcCrc(-1, -1);
michael@1 824 }
michael@1 825
michael@1 826 //
michael@1 827 // Calculates CRC for the specified row, fires when data is changed
michael@1 828 //
michael@1 829 void Titraqform::calcCrc(int nRow, int nCol)
michael@1 830 {
michael@1 831 if (nCol != TITRAQ_IDXSTATUS && nCol != TITRAQ_IDXLINE \
michael@1 832 && m_pMaintable->numRows() > 0) {
michael@1 833 U32 Testcrc, Valcrc;
michael@1 834 QString Crcstr;
michael@1 835 std::auto_ptr<Qualistring>pWholerow(new Qualistring);
michael@1 836 int nRealrow = -1;
michael@1 837
michael@1 838 // Build the data that will be used in testing CRC calculation
michael@1 839 nRealrow = (nRow >= 0) ? nRow : m_pMaintable->currentRow();
michael@1 840 *pWholerow = m_pMaintable->text(nRealrow, TITRAQ_IDXUSER);
michael@1 841 for (int nIter = TITRAQ_IDXUSER + 1; nIter < TITRAQ_IDXTAIL; nIter++)
michael@1 842 if (nIter != TITRAQ_IDXCRC) // Don't checksum the checksum!
michael@1 843 *pWholerow += m_pMaintable->text(nRealrow, nIter);
michael@1 844
michael@1 845 // Update the checksum and revision only if necessary
michael@1 846 Testcrc = pWholerow->getCrc();
michael@1 847
michael@1 848 // FIXME: This thing is not very unportable, because toUInt != U32
michael@1 849 if (Testcrc != m_pMaintable->text(nRealrow, TITRAQ_IDXCRC).toUInt()) {
michael@1 850
michael@1 851 // // Bump the revision number of our entry to control conflicts
michael@1 852 // nNewrev = m_pMaintable->text(nRealrow, TITRAQ_IDXREV).toInt() + 1;
michael@1 853 // m_pMaintable->setText(nRealrow, TITRAQ_IDXREV, QString::number(nNewrev));
michael@1 854
michael@1 855 // Build the data that will be used in setting CRC calculation
michael@1 856 *pWholerow = m_pMaintable->text(nRealrow, TITRAQ_IDXUSER);
michael@1 857 for (int nIter = TITRAQ_IDXUSER + 1; nIter < TITRAQ_IDXTAIL; nIter++)
michael@1 858 if (nIter != TITRAQ_IDXCRC) // Don't checksum the checksum!
michael@1 859 *pWholerow += m_pMaintable->text(nRealrow, nIter);
michael@1 860
michael@1 861 Valcrc = pWholerow->getCrc(); // Finally set the checksum to its new value
michael@1 862 Crcstr = QString::number(Valcrc, 16).rightJustify(8, '0');
michael@1 863 m_pMaintable->setText(nRealrow, TITRAQ_IDXCRC, "0x" + Crcstr);
michael@1 864 m_pCrcedit->setText("0x" + Crcstr);
michael@1 865 }
michael@1 866 }
michael@1 867 }
michael@1 868
michael@1 869 //
michael@1 870 // Gets a hit on every table click
michael@1 871 //
michael@1 872 void Titraqform::onClick(int nRow, int nCol, int nButton, const QPoint &Mousepos)
michael@1 873 {
michael@1 874 // Give the clueless user some hints when clicking an empty timesheet
michael@1 875 if (m_pMaintable->numRows() <= 0)
michael@1 876 m_pStatbar->message(trUtf8("Empty timesheet, add entries first please"), 2000);
michael@1 877 }
michael@1 878
michael@1 879 //
michael@1 880 // Update the edit controls contents
michael@1 881 //
michael@1 882 void Titraqform::updEdit(int nRow, int nCol)
michael@1 883 {
michael@1 884 // Why is the app sending negative row signal? I don't know yet,
michael@1 885 // so add in this nasty hack to fend off the debug spew on stderr
michael@1 886 if (m_pMaintable->numRows() > 0 && nRow >= 0) {
michael@1 887 // Field strings to check for validity and process
michael@1 888 QString Textline(m_pMaintable->text(nRow, TITRAQ_IDXLINE));
michael@1 889 QString Textuser(m_pMaintable->text(nRow, TITRAQ_IDXUSER));
michael@1 890 QString Textguid(m_pMaintable->text(nRow, TITRAQ_IDXGUID));
michael@1 891 QString Textcrc(m_pMaintable->text(nRow, TITRAQ_IDXCRC));
michael@1 892 QString Textrev(m_pMaintable->text(nRow, TITRAQ_IDXREV));
michael@1 893 QString Textdate(m_pMaintable->text(nRow, TITRAQ_IDXDATE));
michael@1 894 QString Textstart(m_pMaintable->text(nRow, TITRAQ_IDXSTART));
michael@1 895 QString Textfinish(m_pMaintable->text(nRow, TITRAQ_IDXFINISH));
michael@1 896 QString Textamount(m_pMaintable->text(nRow, TITRAQ_IDXAMOUNT));
michael@1 897 QString Texttask(m_pMaintable->text(nRow, TITRAQ_IDXTASK));
michael@1 898 QString Textremark(m_pMaintable->text(nRow, TITRAQ_IDXREMARK));
michael@1 899
michael@1 900 // Reset the edition state member
michael@1 901 m_pMaintable->setEdition();
michael@1 902
michael@1 903 // Set text of member edit controls
michael@1 904 if (m_pMaintable->text(nRow, TITRAQ_IDXSTATUS).isEmpty()) // If row is empty
michael@1 905 m_pStatusedit->setPixmap(s_kpcStatvoid_xpm); // add a placeholder
michael@1 906 else
michael@1 907 m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRow, TITRAQ_IDXSTATUS));
michael@1 908 m_pLineedit->setText(Textline);
michael@1 909 m_pUseredit->setText(Textuser);
michael@1 910 m_pGuidedit->setText(Textguid);
michael@1 911 m_pCrcedit->setText(Textcrc);
michael@1 912 m_pRevedit->setText(Textrev);
michael@1 913
michael@1 914 // QRegExp Shorten("/(\\w+)$"); // For stripping prefix off the current task
michael@1 915 // Texttask.remove(0, Shorten.search(Texttask) + 1); // Strip leading slash
michael@1 916
michael@1 917 m_pRemark->setText(Textremark);
michael@1 918 m_pTasks->setCurrentText(Texttask);
michael@1 919
michael@1 920 // Date field not suitable for empty string text
michael@1 921 if (Textdate == ".")
michael@1 922 m_pDateedit->setDate(QDate::currentDate());
michael@1 923 else if (Textdate.isEmpty())
michael@1 924 m_pDateedit->setDate(QDate::fromString("0000-00-00", Qt::ISODate));
michael@1 925 else
michael@1 926 m_pDateedit->setDate(QDate::fromString(Textdate, Qt::ISODate));
michael@1 927
michael@1 928 // Start time not suitable for empty string text
michael@1 929 if (Textstart == ".")
michael@1 930 m_pStarttime->setTime(QTime::currentTime());
michael@1 931 else if (Textstart.isEmpty())
michael@1 932 m_pStarttime->setTime(QTime::QTime(0, 0));
michael@1 933 else
michael@1 934 m_pStarttime->setTime(QTime::fromString(Textstart, Qt::ISODate));
michael@1 935
michael@1 936 // Finish time not suitable for empty string text
michael@1 937 if (Textfinish == ".")
michael@1 938 m_pEndtime->setTime(QTime::currentTime());
michael@1 939 else if (Textfinish.isEmpty())
michael@1 940 m_pEndtime->setTime(QTime::QTime(0, 0));
michael@1 941 else
michael@1 942 m_pEndtime->setTime(QTime::fromString(Textfinish, Qt::ISODate));
michael@1 943
michael@1 944 // Amount time not suitable for empty string text
michael@1 945 if (Textamount == ".") {
michael@1 946 int nDifference = m_pStarttime->time().secsTo(m_pEndtime->time());
michael@1 947 m_pAmount->setTime(QTime(0, 0).addSecs(nDifference));
michael@1 948 }
michael@1 949 else if (Textamount.isEmpty())
michael@1 950 m_pAmount->setTime(QTime::QTime(0, 0));
michael@1 951 else
michael@1 952 m_pAmount->setTime(QTime::fromString(Textamount, Qt::ISODate));
michael@1 953 }
michael@1 954 }
michael@1 955
michael@1 956 //
michael@1 957 // Validate current row of the matrix
michael@1 958 //
michael@1 959 void Titraqform::validateRow(void)
michael@1 960 {
michael@1 961 this->validateRow(-1, -1);
michael@1 962 }
michael@1 963
michael@1 964 //
michael@1 965 // Validate specified row of the matrix
michael@1 966 //
michael@1 967 void Titraqform::validateRow(int nRow, int nCol)
michael@1 968 {
michael@1 969 int nRealrow = -1;
michael@1 970
michael@1 971 if (!this->isOpen()) { // If no data is loaded then short circuit
michael@1 972 m_pStatbar->message(trUtf8("Timesheet contains no data"), 4000);
michael@1 973 return;
michael@1 974 }
michael@1 975
michael@1 976 nRealrow = (nRow >= 0) ? nRow : m_pMaintable->currentRow();
michael@1 977 QString Statis = m_pMaintable->text(nRealrow, TITRAQ_IDXSTATUS); // Get text
michael@1 978
michael@1 979 // Review whole data validity, and set pixmap accordingly
michael@1 980 if (m_pMaintable->text(nRealrow, TITRAQ_IDXUSER).isEmpty() ||
michael@1 981 m_pMaintable->text(nRealrow, TITRAQ_IDXGUID).isEmpty() ||
michael@1 982 m_pMaintable->text(nRealrow, TITRAQ_IDXCRC).isEmpty() ||
michael@1 983 m_pMaintable->text(nRealrow, TITRAQ_IDXREV).isEmpty() ||
michael@1 984 m_pMaintable->text(nRealrow, TITRAQ_IDXDATE).isEmpty() ||
michael@1 985 m_pMaintable->text(nRealrow, TITRAQ_IDXSTART).isEmpty() ||
michael@1 986 m_pMaintable->text(nRealrow, TITRAQ_IDXFINISH).isEmpty() ||
michael@1 987 m_pMaintable->text(nRealrow, TITRAQ_IDXAMOUNT).isEmpty() ||
michael@1 988 m_pMaintable->text(nRealrow, TITRAQ_IDXTASK).isEmpty())
michael@1 989 { // No K&R style to show where actual code begins
michael@1 990 if (Statis.startsWith(QString("W"))) { // Conditionally set pixmap to avoid overhead
michael@1 991 // FIXME: Next line commented out, and I see that this algorythm needs help
michael@1 992 // m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRealrow, TITRAQ_IDXSTATUS));
michael@1 993 }
michael@1 994 else if (!Statis.startsWith(QString("E"))) { // Conditionally set pixmap to avoid overhead
michael@1 995 m_pMaintable->setText(nRealrow, TITRAQ_IDXSTATUS, Statis.replace(TITRAQ_IDXSTATERROR, sizeof(char), 'E'));
michael@1 996 m_pMaintable->setPixmap(nRealrow, TITRAQ_IDXSTATUS, QPixmap(s_kpcStaterror_xpm));
michael@1 997 m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRealrow, TITRAQ_IDXSTATUS));
michael@1 998 }
michael@1 999 }
michael@1 1000 else {
michael@1 1001 if (!Statis.startsWith(QString("O"))) { // Conditionally set pixmap to avoid overhead
michael@1 1002 m_pMaintable->setText(nRealrow, TITRAQ_IDXSTATUS, Statis.replace(TITRAQ_IDXSTATERROR, sizeof(char), 'O'));
michael@1 1003 m_pMaintable->setPixmap(nRealrow, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatokay_xpm));
michael@1 1004 m_pStatusedit->setPixmap(m_pMaintable->pixmap(nRealrow, TITRAQ_IDXSTATUS));
michael@1 1005 }
michael@1 1006 }
michael@1 1007
michael@1 1008 // Test for blank user field, and set to default if so
michael@1 1009 if (m_pMaintable->text(nRealrow, TITRAQ_IDXUSER).isEmpty())
michael@1 1010 m_pMaintable->setText(nRealrow, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER));
michael@1 1011
michael@1 1012 // Test for blank date field, and set to default if so
michael@1 1013 if (m_pMaintable->text(nRealrow, TITRAQ_IDXDATE) == ".")
michael@1 1014 m_pMaintable->setText(nRealrow, TITRAQ_IDXDATE, QDate::currentDate().toString(Qt::ISODate));
michael@1 1015
michael@1 1016 // Test for blank start field, and set to default if so
michael@1 1017 if (m_pMaintable->text(nRealrow, TITRAQ_IDXSTART) == ".")
michael@1 1018 m_pMaintable->setText(nRealrow, TITRAQ_IDXSTART, QTime::currentTime().toString("hh:mm"));
michael@1 1019
michael@1 1020 // Test for blank finish field, and set to default if so
michael@1 1021 if (m_pMaintable->text(nRealrow, TITRAQ_IDXFINISH) == ".")
michael@1 1022 m_pMaintable->setText(nRealrow, TITRAQ_IDXFINISH, QTime::currentTime().toString("hh:mm"));
michael@1 1023
michael@1 1024 // Test for blank amount field, and set to default if so
michael@1 1025 if (m_pMaintable->text(nRealrow, TITRAQ_IDXAMOUNT) == ".") {
michael@1 1026 QTime Begin = QTime::fromString(m_pMaintable->text(nRealrow, TITRAQ_IDXSTART), Qt::ISODate);
michael@1 1027 QTime End = QTime::fromString(m_pMaintable->text(nRealrow, TITRAQ_IDXFINISH), Qt::ISODate);
michael@1 1028 QString Diff = QTime(0, 0).addSecs(Begin.secsTo(End)).toString("hh:mm");
michael@1 1029 m_pMaintable->setText(nRealrow, TITRAQ_IDXAMOUNT, Diff);
michael@1 1030 }
michael@1 1031 }
michael@1 1032
michael@1 1033 //
michael@1 1034 // Update the current line number column item
michael@1 1035 //
michael@1 1036 void Titraqform::updateLine(const QString &Instring)
michael@1 1037 {
michael@1 1038 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXLINE, Instring);
michael@1 1039 }
michael@1 1040
michael@1 1041 //
michael@1 1042 // Update the current user column item
michael@1 1043 //
michael@1 1044 void Titraqform::updateUser(const QString &Instring)
michael@1 1045 {
michael@1 1046 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXUSER, Instring);
michael@1 1047 }
michael@1 1048
michael@1 1049 //
michael@1 1050 // Update the current GUID column item
michael@1 1051 //
michael@1 1052 void Titraqform::updateGuid(const QString &Instring)
michael@1 1053 {
michael@1 1054 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXGUID, Instring);
michael@1 1055 }
michael@1 1056
michael@1 1057 //
michael@1 1058 // Update the current CRC column item
michael@1 1059 //
michael@1 1060 void Titraqform::updateCrc(const QString &Instring)
michael@1 1061 {
michael@1 1062 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXCRC, Instring);
michael@1 1063 }
michael@1 1064
michael@1 1065 //
michael@1 1066 // Update the current rev column item
michael@1 1067 //
michael@1 1068 void Titraqform::updateRev(const QString &Instring)
michael@1 1069 {
michael@1 1070 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREV, Instring);
michael@1 1071 }
michael@1 1072
michael@1 1073 //
michael@1 1074 // Update the current date column item
michael@1 1075 //
michael@1 1076 void Titraqform::updateDate(const QDate &Dateup)
michael@1 1077 {
michael@1 1078 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXDATE, Dateup.toString(Qt::ISODate));
michael@1 1079 }
michael@1 1080
michael@1 1081 //
michael@1 1082 // Update the current start column item
michael@1 1083 //
michael@1 1084 void Titraqform::updateStart(const QTime &Startup)
michael@1 1085 {
michael@1 1086 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXSTART, Startup.toString("hh:mm"));
michael@1 1087 }
michael@1 1088
michael@1 1089 //
michael@1 1090 // Update the current finish column item
michael@1 1091 //
michael@1 1092 void Titraqform::updateFinish(const QTime &Finishup)
michael@1 1093 {
michael@1 1094 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXFINISH, Finishup.toString("hh:mm"));
michael@1 1095 }
michael@1 1096
michael@1 1097 //
michael@1 1098 // Update the current amount column item
michael@1 1099 //
michael@1 1100 void Titraqform::updateAmount(const QTime &Amountup)
michael@1 1101 {
michael@1 1102 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXAMOUNT, Amountup.toString("hh:mm"));
michael@1 1103 }
michael@1 1104
michael@1 1105 //
michael@1 1106 // Update the current task column item
michael@1 1107 //
michael@1 1108 void Titraqform::updateTask(const QString &Taskup)
michael@1 1109 {
michael@1 1110 // // FIXME: Broken
michael@1 1111 // RtTableItem *pTask = NULL;
michael@1 1112 // pTask = static_cast<RtTableItem *>(m_pMaintable->item(m_pMaintable->currentRow(), TITRAQ_IDXTASK));
michael@1 1113 // pTask->setText(Taskup);
michael@1 1114
michael@1 1115 // Don't try to use the Taskup string, because it ignores autocompletion
michael@1 1116 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXTASK, m_pTasks->currentText());
michael@1 1117 }
michael@1 1118
michael@1 1119 //
michael@1 1120 // Update the current remark column item
michael@1 1121 //
michael@1 1122 void Titraqform::updateRemark(const QString &Remarkup)
michael@1 1123 {
michael@1 1124 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREMARK, Remarkup);
michael@1 1125 }
michael@1 1126
michael@1 1127 //
michael@1 1128 // Confirm any recent editions on a whole row
michael@1 1129 //
michael@1 1130 void Titraqform::confirmEdit(void)
michael@1 1131 {
michael@1 1132 RtTableItem *pTask = NULL; // Task item is a derived class
michael@1 1133
michael@1 1134 // Conversions from edit control data formats to native tabular format
michael@1 1135 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXDATE, m_pDateedit->date().toString(Qt::ISODate));
michael@1 1136 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXSTART, m_pStarttime->time().toString(Qt::ISODate));
michael@1 1137 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXFINISH, m_pEndtime->time().toString(Qt::ISODate));
michael@1 1138 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXAMOUNT, m_pAmount->time().toString(Qt::ISODate));
michael@1 1139
michael@1 1140 // Specially handle task fields
michael@1 1141 pTask = static_cast<RtTableItem *>(m_pMaintable->item(m_pMaintable->currentRow(), TITRAQ_IDXTASK));
michael@1 1142 pTask->setText(m_pTasks->currentText());
michael@1 1143
michael@1 1144 m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXREMARK, m_pRemark->text());
michael@1 1145 }
michael@1 1146
michael@1 1147 //
michael@1 1148 // Edit menu configure preferences
michael@1 1149 //
michael@1 1150 void Titraqform::configPrefs(void)
michael@1 1151 {
michael@1 1152 QString Templine; // Used for preferences resetting
michael@1 1153 Prefpanel *pUserpanel = NULL; // The user preferences panel itself
michael@1 1154
michael@1 1155 // Create a new preferences panel window
michael@1 1156 pUserpanel = new Prefpanel(this, "Userprefpanel");
michael@1 1157 connect(pUserpanel, SIGNAL(applied(void)), SLOT(applyPrefs(void)));
michael@1 1158
michael@1 1159 // Set default values to appear in initialized panel widgets
michael@1 1160 pUserpanel->setAccounts(m_pPrefs->getString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS));
michael@1 1161 pUserpanel->setEvents(m_pPrefs->getString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR));
michael@1 1162 pUserpanel->setUser(m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER));
michael@1 1163 pUserpanel->setHome(m_pPrefs->getString(TITRAQ_PREFHOME, TITRAQ_DEFHOME));
michael@1 1164 pUserpanel->setCorbahost(m_pPrefs->getString(TITRAQ_PREFCORBHOST, TITRAQ_DEFCORBHOST));
michael@1 1165 pUserpanel->setSoaphost(m_pPrefs->getString(TITRAQ_PREFSOAPHOST, TITRAQ_DEFSOAPHOST));
michael@1 1166 #ifdef HAVE_MICO
michael@1 1167 pUserpanel->setCorbaon(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON));
michael@1 1168 #else
michael@1 1169 pUserpanel->setCorbaon(false);
michael@1 1170 pUserpanel->lockCorba();
michael@1 1171 #endif
michael@1 1172 #ifdef HAVE_ESOAP
michael@1 1173 pUserpanel->setSoapon(m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON));
michael@1 1174 #else
michael@1 1175 pUserpanel->setSoapon(false);
michael@1 1176 pUserpanel->lockSoap();
michael@1 1177 #endif
michael@1 1178 pUserpanel->setBackon(m_pPrefs->getBool(TITRAQ_PREFBAKON, TITRAQ_DEFBAKON));
michael@1 1179 pUserpanel->setExtendon(m_pPrefs->getBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON));
michael@1 1180 pUserpanel->setDetailon(m_pPrefs->getBool(TITRAQ_PREFDETAILON, TITRAQ_DEFDETAILON));
michael@1 1181 pUserpanel->setSignaton(m_pPrefs->getBool(TITRAQ_PREFSIGNATON, TITRAQ_DEFSIGNATON));
michael@1 1182
michael@1 1183 // Set default style which can be more complicated due to mapping...
michael@1 1184 switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) {
michael@1 1185 case TITRAQ_STYLECDE:
michael@1 1186 pUserpanel->setStyle(TITRAQ_STRCDE);
michael@1 1187 break;
michael@1 1188 case TITRAQ_STYLESGI:
michael@1 1189 pUserpanel->setStyle(TITRAQ_STRSGI);
michael@1 1190 break;
michael@1 1191 case TITRAQ_STYLEMOTIF:
michael@1 1192 pUserpanel->setStyle(TITRAQ_STRMOTIF);
michael@1 1193 break;
michael@1 1194 case TITRAQ_STYLEMPLUS:
michael@1 1195 pUserpanel->setStyle(TITRAQ_STRMPLUS);
michael@1 1196 break;
michael@1 1197 case TITRAQ_STYLEPLAT:
michael@1 1198 pUserpanel->setStyle(TITRAQ_STRPLAT);
michael@1 1199 break;
michael@1 1200 case TITRAQ_STYLEMSOFT:
michael@1 1201 pUserpanel->setStyle(TITRAQ_STRMSOFT);
michael@1 1202 break;
michael@1 1203 default:
michael@1 1204 pUserpanel->setStyle(TITRAQ_STRCDE); // My personal favourite ;-)
michael@1 1205 break;
michael@1 1206 }
michael@1 1207
michael@1 1208 // Colour preferences
michael@1 1209 int nRed, nGreen, nBlue;
michael@1 1210 QColorGroup Origcolour, Altcolour;
michael@1 1211 const QColor Origlight = QColor(TITRAQ_DEFLIGHTRED, TITRAQ_DEFLIGHTGREEN, TITRAQ_DEFLIGHTBLUE);
michael@1 1212 const QColor Origdark = QColor(TITRAQ_DEFDARKRED, TITRAQ_DEFDARKGREEN, TITRAQ_DEFDARKBLUE);
michael@1 1213 const QColor Altlight = QColor(TITRAQ_DEFLTALTRED, TITRAQ_DEFLTALTGREEN, TITRAQ_DEFLTALTBLUE);
michael@1 1214 const QColor Altdark = QColor(TITRAQ_DEFDKALTRED, TITRAQ_DEFDKALTGREEN, TITRAQ_DEFDKALTBLUE);
michael@1 1215
michael@1 1216 // Set colours to revert to if user screws up and wants out
michael@1 1217 Origcolour.setColor(QColorGroup::Foreground, Origlight);
michael@1 1218 Origcolour.setColor(QColorGroup::Background, Origdark);
michael@1 1219 pUserpanel->setOrigcolour(&Origcolour);
michael@1 1220 Altcolour.setColor(QColorGroup::Foreground, Altlight);
michael@1 1221 Altcolour.setColor(QColorGroup::Background, Altdark);
michael@1 1222 pUserpanel->setAltcolour(&Altcolour);
michael@1 1223
michael@1 1224 // Set colour preferences saved from last session
michael@1 1225 nRed = m_pPrefs->getNumber(TITRAQ_PREFLIGHTRED, TITRAQ_DEFLIGHTRED);
michael@1 1226 nGreen = m_pPrefs->getNumber(TITRAQ_PREFLIGHTGREEN, TITRAQ_DEFLIGHTGREEN);
michael@1 1227 nBlue = m_pPrefs->getNumber(TITRAQ_PREFLIGHTBLUE, TITRAQ_DEFLIGHTBLUE);
michael@1 1228 const QColor Lightshade = QColor(nRed, nGreen, nBlue);
michael@1 1229 pUserpanel->setLight(&Lightshade);
michael@1 1230 nRed = m_pPrefs->getNumber(TITRAQ_PREFDARKRED, TITRAQ_DEFDARKRED);
michael@1 1231 nGreen = m_pPrefs->getNumber(TITRAQ_PREFDARKGREEN, TITRAQ_DEFDARKGREEN);
michael@1 1232 nBlue = m_pPrefs->getNumber(TITRAQ_PREFDARKBLUE, TITRAQ_DEFDARKBLUE);
michael@1 1233 const QColor Darkshade = QColor(nRed, nGreen, nBlue);
michael@1 1234 pUserpanel->setDark(&Darkshade);
michael@1 1235
michael@1 1236 // Modal panel handler
michael@1 1237 if (pUserpanel->exec() == QDialog::Accepted)
michael@1 1238 this->applyPrefs(pUserpanel);
michael@1 1239
michael@1 1240 // Dispose Panel object
michael@1 1241 delete pUserpanel;
michael@1 1242 }
michael@1 1243
michael@1 1244 //
michael@1 1245 // View menu normal
michael@1 1246 //
michael@1 1247 void Titraqform::normalView(void)
michael@1 1248 {
michael@1 1249 // All view types except normal are disabled until implemention, so
michael@1 1250 // this body can remain empty, causing nothing to happen on selection.
michael@1 1251 }
michael@1 1252
michael@1 1253 //
michael@1 1254 // View menu editing
michael@1 1255 //
michael@1 1256 void Titraqform::editingView(void)
michael@1 1257 {
michael@1 1258 // All view types except normal are disabled until implemention, so
michael@1 1259 // this body can remain empty, causing nothing to happen on selection.
michael@1 1260 }
michael@1 1261
michael@1 1262 //
michael@1 1263 // View menu timing
michael@1 1264 //
michael@1 1265 void Titraqform::timingView(void)
michael@1 1266 {
michael@1 1267 // All view types except normal are disabled until implemention, so
michael@1 1268 // this body can remain empty, causing nothing to happen on selection.
michael@1 1269 }
michael@1 1270
michael@1 1271 //
michael@1 1272 // View menu show file toolbar
michael@1 1273 //
michael@1 1274 void Titraqform::showFilebar(void)
michael@1 1275 {
michael@1 1276 if (m_pFiletools->isVisible()) {
michael@1 1277 m_pFiletools->hide();
michael@1 1278 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR), false);
michael@1 1279 }
michael@1 1280 else {
michael@1 1281 m_pFiletools->show();
michael@1 1282 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR), true);
michael@1 1283 }
michael@1 1284 }
michael@1 1285
michael@1 1286 //
michael@1 1287 // View menu show edit toolbar
michael@1 1288 //
michael@1 1289 void Titraqform::showEditbar(void)
michael@1 1290 {
michael@1 1291 if (m_pEdittools->isVisible()) {
michael@1 1292 m_pEdittools->hide();
michael@1 1293 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR), false);
michael@1 1294 }
michael@1 1295 else {
michael@1 1296 m_pEdittools->show();
michael@1 1297 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR), true);
michael@1 1298 }
michael@1 1299 }
michael@1 1300
michael@1 1301 //
michael@1 1302 // View menu show view toolbar
michael@1 1303 //
michael@1 1304 void Titraqform::showViewbar(void)
michael@1 1305 {
michael@1 1306 if (m_pViewtools->isVisible()) {
michael@1 1307 m_pViewtools->hide();
michael@1 1308 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR), false);
michael@1 1309 }
michael@1 1310 else {
michael@1 1311 m_pViewtools->show();
michael@1 1312 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR), true);
michael@1 1313 }
michael@1 1314 }
michael@1 1315
michael@1 1316 //
michael@1 1317 // View menu show prefs toolbar
michael@1 1318 //
michael@1 1319 void Titraqform::showPrefsbar(void)
michael@1 1320 {
michael@1 1321 if (m_pPrefstools->isVisible()) {
michael@1 1322 m_pPrefstools->hide();
michael@1 1323 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR), false);
michael@1 1324 }
michael@1 1325 else {
michael@1 1326 m_pPrefstools->show();
michael@1 1327 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR), true);
michael@1 1328 }
michael@1 1329 }
michael@1 1330
michael@1 1331 //
michael@1 1332 // View menu show whats this toolbar
michael@1 1333 //
michael@1 1334 void Titraqform::showWhatsbar(void)
michael@1 1335 {
michael@1 1336 if (m_pWhatstools->isVisible()) {
michael@1 1337 m_pWhatstools->hide();
michael@1 1338 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), false);
michael@1 1339 }
michael@1 1340 else {
michael@1 1341 m_pWhatstools->show();
michael@1 1342 m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), true);
michael@1 1343 }
michael@1 1344 }
michael@1 1345
michael@1 1346 //
michael@1 1347 // View menu show status column
michael@1 1348 //
michael@1 1349 void Titraqform::showStatcol(void)
michael@1 1350 {
michael@1 1351 // Test if column is currently shown, conditionally show or hide it
michael@1 1352 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL))) {
michael@1 1353 m_pMaintable->hideColumn(TITRAQ_IDXSTATUS);
michael@1 1354 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL), false);
michael@1 1355 m_pStatusedit->hide();
michael@1 1356 }
michael@1 1357 else {
michael@1 1358 m_pMaintable->showColumn(TITRAQ_IDXSTATUS);
michael@1 1359 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL), true);
michael@1 1360 m_pStatusedit->show();
michael@1 1361 }
michael@1 1362
michael@1 1363 // Make sure switch take place right away and sizes are handled
michael@1 1364 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTATCOL));
michael@1 1365 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1366 }
michael@1 1367
michael@1 1368 //
michael@1 1369 // View menu show line numbers column
michael@1 1370 //
michael@1 1371 void Titraqform::showLinecol(void)
michael@1 1372 {
michael@1 1373 // Test if column is currently shown, conditionally show or hide it
michael@1 1374 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL))) {
michael@1 1375 m_pMaintable->hideColumn(TITRAQ_IDXLINE);
michael@1 1376 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL), false);
michael@1 1377 m_pLineedit->hide();
michael@1 1378 }
michael@1 1379 else {
michael@1 1380 m_pMaintable->showColumn(TITRAQ_IDXLINE);
michael@1 1381 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL), true);
michael@1 1382 m_pLineedit->show();
michael@1 1383 }
michael@1 1384
michael@1 1385 // Make sure switch take place right away and sizes are handled
michael@1 1386 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXLCOL));
michael@1 1387 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1388 }
michael@1 1389
michael@1 1390 //
michael@1 1391 // View menu show users column
michael@1 1392 //
michael@1 1393 void Titraqform::showUsercol(void)
michael@1 1394 {
michael@1 1395 // Test if column is currently shown, conditionally show or hide it
michael@1 1396 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL))) {
michael@1 1397 m_pMaintable->hideColumn(TITRAQ_IDXUSER);
michael@1 1398 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL), false);
michael@1 1399 m_pUseredit->hide();
michael@1 1400 }
michael@1 1401 else {
michael@1 1402 m_pMaintable->showColumn(TITRAQ_IDXUSER);
michael@1 1403 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL), true);
michael@1 1404 m_pUseredit->show();
michael@1 1405 }
michael@1 1406
michael@1 1407 // Make sure switch take place right away and sizes are handled
michael@1 1408 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1409 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXUCOL));
michael@1 1410 }
michael@1 1411
michael@1 1412 //
michael@1 1413 // View menu show GUIDs column
michael@1 1414 //
michael@1 1415 void Titraqform::showGuidcol(void)
michael@1 1416 {
michael@1 1417 // Test if column is currently shown, conditionally show or hide it
michael@1 1418 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL))) {
michael@1 1419 m_pMaintable->hideColumn(TITRAQ_IDXGUID);
michael@1 1420 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL), false);
michael@1 1421 m_pGuidedit->hide();
michael@1 1422 }
michael@1 1423 else {
michael@1 1424 m_pMaintable->showColumn(TITRAQ_IDXGUID);
michael@1 1425 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL), true);
michael@1 1426 m_pGuidedit->show();
michael@1 1427 }
michael@1 1428
michael@1 1429 // Make sure switch take place right away and sizes are handled
michael@1 1430 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXGCOL));
michael@1 1431 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1432 }
michael@1 1433
michael@1 1434 //
michael@1 1435 // View menu show CRC column
michael@1 1436 //
michael@1 1437 void Titraqform::showCrccol(void)
michael@1 1438 {
michael@1 1439 // Test if column is currently shown, conditionally show or hide it
michael@1 1440 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL))) {
michael@1 1441 m_pMaintable->hideColumn(TITRAQ_IDXCRC);
michael@1 1442 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL), false);
michael@1 1443 m_pCrcedit->hide();
michael@1 1444 }
michael@1 1445 else {
michael@1 1446 m_pMaintable->showColumn(TITRAQ_IDXCRC);
michael@1 1447 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL), true);
michael@1 1448 m_pCrcedit->show();
michael@1 1449 }
michael@1 1450
michael@1 1451 // Make sure switch take place right away and sizes are handled
michael@1 1452 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXCCOL));
michael@1 1453 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1454 }
michael@1 1455
michael@1 1456 //
michael@1 1457 // View menu show Rev column
michael@1 1458 //
michael@1 1459 void Titraqform::showRevcol(void)
michael@1 1460 {
michael@1 1461 // Test if column is currently shown, conditionally show or hide it
michael@1 1462 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL))) {
michael@1 1463 m_pMaintable->hideColumn(TITRAQ_IDXREV);
michael@1 1464 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL), false);
michael@1 1465 m_pRevedit->hide();
michael@1 1466 }
michael@1 1467 else {
michael@1 1468 m_pMaintable->showColumn(TITRAQ_IDXREV);
michael@1 1469 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL), true);
michael@1 1470 m_pRevedit->show();
michael@1 1471 }
michael@1 1472
michael@1 1473 // Make sure switch take place right away and sizes are handled
michael@1 1474 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREVCOL));
michael@1 1475 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1476 }
michael@1 1477
michael@1 1478 //
michael@1 1479 // View menu show dates column
michael@1 1480 //
michael@1 1481 void Titraqform::showDatecol(void)
michael@1 1482 {
michael@1 1483 // Test if column is currently shown, conditionally show or hide it
michael@1 1484 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL))) {
michael@1 1485 m_pMaintable->hideColumn(TITRAQ_IDXDATE);
michael@1 1486 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL), false);
michael@1 1487 m_pDateedit->hide();
michael@1 1488 }
michael@1 1489 else {
michael@1 1490 m_pMaintable->showColumn(TITRAQ_IDXDATE);
michael@1 1491 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL), true);
michael@1 1492 m_pDateedit->show();
michael@1 1493 }
michael@1 1494
michael@1 1495 // Make sure switch take place right away and sizes are handled
michael@1 1496 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXDCOL));
michael@1 1497 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1498 }
michael@1 1499
michael@1 1500 //
michael@1 1501 // View menu show start time column
michael@1 1502 //
michael@1 1503 void Titraqform::showStartcol(void)
michael@1 1504 {
michael@1 1505 // Test if column is currently shown, conditionally show or hide it
michael@1 1506 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL))) {
michael@1 1507 m_pMaintable->hideColumn(TITRAQ_IDXSTART);
michael@1 1508 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL), false);
michael@1 1509 m_pStarttime->hide();
michael@1 1510 }
michael@1 1511 else {
michael@1 1512 m_pMaintable->showColumn(TITRAQ_IDXSTART);
michael@1 1513 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL), true);
michael@1 1514 m_pStarttime->show();
michael@1 1515 }
michael@1 1516
michael@1 1517 // Make sure switch take place right away and sizes are handled
michael@1 1518 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL));
michael@1 1519 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1520 }
michael@1 1521
michael@1 1522 //
michael@1 1523 // View menu show finish time column
michael@1 1524 //
michael@1 1525 void Titraqform::showFinishcol(void)
michael@1 1526 {
michael@1 1527 // Test if column is currently shown, conditionally show or hide it
michael@1 1528 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL))) {
michael@1 1529 m_pMaintable->hideColumn(TITRAQ_IDXFINISH);
michael@1 1530 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL), false);
michael@1 1531 m_pEndtime->hide();
michael@1 1532 }
michael@1 1533 else {
michael@1 1534 m_pMaintable->showColumn(TITRAQ_IDXFINISH);
michael@1 1535 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL), true);
michael@1 1536 m_pEndtime->show();
michael@1 1537 }
michael@1 1538
michael@1 1539 // Make sure switch take place right away and sizes are handled
michael@1 1540 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXFCOL));
michael@1 1541 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1542 }
michael@1 1543
michael@1 1544 //
michael@1 1545 // View menu show Amounts column
michael@1 1546 //
michael@1 1547 void Titraqform::showAmountcol(void)
michael@1 1548 {
michael@1 1549 // Test if column is currently shown, conditionally show or hide it
michael@1 1550 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL))) {
michael@1 1551 m_pMaintable->hideColumn(TITRAQ_IDXAMOUNT);
michael@1 1552 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL), false);
michael@1 1553 m_pAmount->hide();
michael@1 1554 }
michael@1 1555 else {
michael@1 1556 m_pMaintable->showColumn(TITRAQ_IDXAMOUNT);
michael@1 1557 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL), true);
michael@1 1558 m_pAmount->show();
michael@1 1559 }
michael@1 1560
michael@1 1561 // Make sure switch take place right away and sizes are handled
michael@1 1562 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXACOL));
michael@1 1563 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1564 }
michael@1 1565
michael@1 1566 //
michael@1 1567 // View menu show tasks column
michael@1 1568 //
michael@1 1569 void Titraqform::showTaskcol(void)
michael@1 1570 {
michael@1 1571 // Test if column is currently shown, conditionally show or hide it
michael@1 1572 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXTCOL))) {
michael@1 1573 m_pMaintable->hideColumn(TITRAQ_IDXTASK);
michael@1 1574 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXTCOL), false);
michael@1 1575 m_pTasks->hide();
michael@1 1576 }
michael@1 1577 else {
michael@1 1578 m_pMaintable->showColumn(TITRAQ_IDXTASK);
michael@1 1579 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXTCOL), true);
michael@1 1580 m_pTasks->show();
michael@1 1581 }
michael@1 1582
michael@1 1583 // Make sure switch take place right away and sizes are handled
michael@1 1584 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXTCOL));
michael@1 1585 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1586 }
michael@1 1587
michael@1 1588 //
michael@1 1589 // View menu show Remarks column
michael@1 1590 //
michael@1 1591 void Titraqform::showRemarkcol(void)
michael@1 1592 {
michael@1 1593 // Test if column is currently shown, conditionally show or hide it
michael@1 1594 if (m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL))) {
michael@1 1595 m_pMaintable->hideColumn(TITRAQ_IDXREMARK);
michael@1 1596 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL), false);
michael@1 1597 m_pRemark->hide();
michael@1 1598 }
michael@1 1599 else {
michael@1 1600 m_pMaintable->showColumn(TITRAQ_IDXREMARK);
michael@1 1601 m_pColspopup->setItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL), true);
michael@1 1602 m_pRemark->show();
michael@1 1603 }
michael@1 1604
michael@1 1605 // Make sure switch take place right away and sizes are handled
michael@1 1606 m_pColspopup->updateItem(m_pColspopup->idAt(TITRAQ_IDXREMCOL));
michael@1 1607 this->updSizes(TITRAQ_IDXALLCTRLS, 0, 0); // Update size of this and next
michael@1 1608 }
michael@1 1609
michael@1 1610 //
michael@1 1611 // Generate a local formatted report
michael@1 1612 //
michael@1 1613 void Titraqform::genReport(void)
michael@1 1614 {
michael@1 1615 try { // Create and execute a new local report window
michael@1 1616 std::auto_ptr<AS::Reportpanel> pReport(new AS::Reportpanel
michael@1 1617 (m_pMaintable, m_pPrefs, this, "Locreportpanel"));
michael@1 1618 pReport->exec();
michael@1 1619 delete pReport.release(); // Technically unnecessary, smart pointer
michael@1 1620 }
michael@1 1621 catch (Genexcept& Genex) {
michael@1 1622 Genex.reportErr();
michael@1 1623 return;
michael@1 1624 }
michael@1 1625 }
michael@1 1626
michael@1 1627 //
michael@1 1628 // Syncronize data with server using IIOP
michael@1 1629 //
michael@1 1630 void Titraqform::syncIiop(void)
michael@1 1631 {
michael@1 1632 #ifdef HAVE_MICO
michael@1 1633 // Short circuit if user has disabled CORBA transmission in prefs
michael@1 1634 if (!m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON))
michael@1 1635 return;
michael@1 1636
michael@1 1637 char **ppcInargv = NULL; // Parameters to the ORB
michael@1 1638 CORBA::ORB_var Orb; // The ORB iself
michael@1 1639
michael@1 1640 CORBA::Object_var Nameobj; // Name service reference
michael@1 1641 CosNaming::NamingContext_var Namectx; // COSS ns context
michael@1 1642 CosNaming::Name Cosname; // Our requested obj name
michael@1 1643
michael@1 1644 CORBA::Object_var Objcaster; // Generic CORBA object
michael@1 1645 Asdatabase_var Asdbase; // Casted object to ASDB
michael@1 1646 Astuple Singlerow; // A single row of AS data
michael@1 1647
michael@1 1648 QString *pOrbargv = new QString(TITRAQ_ORBINIT);
michael@1 1649 int nCount = pOrbargv->contains(' ');
michael@1 1650 int nNamesize = 0;
michael@1 1651
michael@1 1652 // Build a false incoming argv with which we initialize the ORB
michael@1 1653 ppcInargv = new char *[nCount + 3]; // 3 = arg0 + last section + COSS host
michael@1 1654 *ppcInargv = new char[strlen(*qApp->argv() + 2)]; // For cmd name
michael@1 1655 strcpy(ppcInargv[0], *qApp->argv()); // Copy cmd name
michael@1 1656 for (int nIter = 0; nIter <= nCount; nIter++) {
michael@1 1657 QString Section = pOrbargv->section(' ', nIter, nIter);
michael@1 1658 ppcInargv[nIter + 1] = new char[strlen(Section.ascii() + 2)];
michael@1 1659 strcpy(ppcInargv[nIter + 1], Section.ascii());
michael@1 1660 }
michael@1 1661
michael@1 1662 // Build the single string COSS naming host name with associated port number
michael@1 1663 *pOrbargv = TITRAQ_COSSPART1
michael@1 1664 + m_pPrefs->getString(TITRAQ_PREFCORBHOST, TITRAQ_DEFCORBHOST)
michael@1 1665 + TITRAQ_COSSPART2;
michael@1 1666 nNamesize = strlen(pOrbargv->ascii());
michael@1 1667 ppcInargv[nCount + 2] = new char[nNamesize];
michael@1 1668 strcpy(ppcInargv[nCount + 2], pOrbargv->ascii());
michael@1 1669
michael@1 1670 try {
michael@1 1671 // Initialization of the ORB and COSS naming service
michael@1 1672 nCount = nCount + 3; // Raise the count to include app, last sec, COSS
michael@1 1673 Orb = CORBA::ORB_init(nCount, ppcInargv, "mico-local-orb");
michael@1 1674 Nameobj = Orb->resolve_initial_references("NameService");
michael@1 1675 Namectx = CosNaming::NamingContext::_narrow(Nameobj);
michael@1 1676 if (CORBA::is_nil(Namectx)) { // Verify sanity
michael@1 1677 m_pStatbar->message(trUtf8("Could not find the COSS naming service"));
michael@1 1678 qWarning("Could not find the COSS naming service\n");
michael@1 1679 }
michael@1 1680
michael@1 1681 // Clean up our dynamically allocated array
michael@1 1682 for (int nIter = 0; nIter < nCount; nIter++)
michael@1 1683 delete ppcInargv[nIter];
michael@1 1684 delete ppcInargv; // Free the array itself
michael@1 1685 delete pOrbargv; // Free the intermediate string
michael@1 1686
michael@1 1687 // Prepare the COSS name request
michael@1 1688 Cosname.length(1);
michael@1 1689 Cosname[0].id = CORBA::string_dup("Asdatabase");
michael@1 1690 Cosname[0].kind = CORBA::string_dup("");
michael@1 1691
michael@1 1692 try { // Resolve to a CORBA object
michael@1 1693 Objcaster = Namectx->resolve(Cosname);
michael@1 1694 }
michael@1 1695 catch (CosNaming::NamingContext::NotFound &Cossex) {
michael@1 1696 m_pStatbar->message(trUtf8("NotFound exception thrown"));
michael@1 1697 qWarning("NotFound exception thrown\n");
michael@1 1698 return;
michael@1 1699 }
michael@1 1700 catch (CosNaming::NamingContext::CannotProceed &Cossex) {
michael@1 1701 m_pStatbar->message(trUtf8("CannotProceed exception thrown"));
michael@1 1702 qWarning("CannotProceed exception thrown\n");
michael@1 1703 return;
michael@1 1704 }
michael@1 1705 catch (CosNaming::NamingContext::InvalidName &Cossex) {
michael@1 1706 m_pStatbar->message(trUtf8("InvalidName exception thrown"));
michael@1 1707 qWarning("InvalidName exception thrown\n");
michael@1 1708 return;
michael@1 1709 }
michael@1 1710
michael@1 1711 // Cast the generic CORBA object to a AS database type
michael@1 1712 Asdbase = Asdatabase::_narrow(Objcaster);
michael@1 1713 if (CORBA::is_nil(Asdbase)) { // Verify sanity
michael@1 1714 m_pStatbar->message(trUtf8("Could not find the AS database"));
michael@1 1715 qWarning("Could not find the AS database\n");
michael@1 1716 return;
michael@1 1717 }
michael@1 1718
michael@1 1719 // Open an account object on the remote server
michael@1 1720 Account_var Account = Asdbase->Open("/tmp/events.as");
michael@1 1721 if (CORBA::is_nil(Account)) { // Verify sanity
michael@1 1722 m_pStatbar->message(trUtf8("Could not create an account object on the server"));
michael@1 1723 qWarning("Could not create an account object on the server\n");
michael@1 1724 return;
michael@1 1725 }
michael@1 1726
michael@1 1727 // Fill account log object(s) to marshall and transmit
michael@1 1728 int nRow = m_pMaintable->currentRow();
michael@1 1729 QTableSelection Select = m_pMaintable->selection(0); // Capture selected rows
michael@1 1730 int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total rows selected
michael@1 1731
michael@1 1732 // Remember, CORBA::stri_dup creates smart pointers
michael@1 1733 for (int nIter = 0; nIter < nTotal; nIter++) {
michael@1 1734 Singlerow.szUser = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXUSER));
michael@1 1735 Singlerow.szGuid = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXGUID));
michael@1 1736 Singlerow.szCrc = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXCRC).remove("0x"));
michael@1 1737 Singlerow.szRev = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXREV));
michael@1 1738 Singlerow.szDate = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXDATE));
michael@1 1739 Singlerow.szStart = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXSTART));
michael@1 1740 Singlerow.szFinish = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXFINISH));
michael@1 1741 Singlerow.szAmount = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXAMOUNT));
michael@1 1742 // Singlerow.nRev = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXREV).toUInt();
michael@1 1743 // Singlerow.nDate = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXDATE).toUInt();
michael@1 1744 // Singlerow.nStart = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXSTART).toUInt();
michael@1 1745 // Singlerow.nFinish = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXFINISH).toUInt();
michael@1 1746 // Singlerow.nAmount = m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXAMOUNT).toUInt();
michael@1 1747 Singlerow.szTask = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXTASK));
michael@1 1748 Singlerow.szRemark = CORBA::string_dup(m_pMaintable->text(Select.topRow() + nIter, TITRAQ_IDXREMARK));
michael@1 1749 Account->Log(Singlerow); // Finally transmit to server
michael@1 1750 }
michael@1 1751
michael@1 1752 m_pStatbar->message(trUtf8("Successful transmission of accounting data"));
michael@1 1753 }
michael@1 1754 catch (const CORBA::Exception &Corbex) {
michael@1 1755 m_pStatbar->message(trUtf8("Caught CORBA exception: %1").arg(Corbex._repoid()));
michael@1 1756 qWarning("Caught CORBA exception: %s", Corbex._repoid());
michael@1 1757 }
michael@1 1758 catch (...) {
michael@1 1759 qWarning("Caught unknown exception\n");
michael@1 1760 }
michael@1 1761 #endif // HAVE_MICO
michael@1 1762 }
michael@1 1763
michael@1 1764 //
michael@1 1765 // Syncronize data with server using SOAP
michael@1 1766 //
michael@1 1767 void Titraqform::syncSoap(void)
michael@1 1768 {
michael@1 1769 #ifdef HAVE_ESOAP
michael@1 1770 // Short circuit if user has disabled SOAP transmission in prefs
michael@1 1771 if (!m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON))
michael@1 1772 return;
michael@1 1773
michael@1 1774 USING_EASYSOAP_NAMESPACE
michael@1 1775
michael@1 1776 try {
michael@1 1777 SOAPMethod Logmeth("Log", TITRAQ_SOAPSPACE); // SOAP namespace
michael@1 1778 SOAPString Clistr; // Outgoing parameter to marshall
michael@1 1779 int nCrc; // SOAP unmarshalled return value
michael@1 1780
michael@1 1781 // Build the single string SOAP end point which look like this:
michael@1 1782 // "http://www.europalab.com/cgi-bin/asdbserv"
michael@1 1783 QString Endpoint;
michael@1 1784 Endpoint = TITRAQ_PREFIXHTTP + m_pPrefs->getString(TITRAQ_PREFSOAPHOST, TITRAQ_DEFSOAPHOST);
michael@1 1785 SOAPProxy Proxy(Endpoint.ascii());
michael@1 1786
michael@1 1787 // Fill account log object(s) to marshall and transmit
michael@1 1788 QTableSelection Select = m_pMaintable->selection(0); // Capture selected rows
michael@1 1789 int nTotal = Select.bottomRow() - Select.topRow() + 1; // Total rows selected
michael@1 1790
michael@1 1791 // Iterate through the selection of row entries to transmit
michael@1 1792 for (int nRowiter = 0; nRowiter < nTotal; nRowiter++) {
michael@1 1793 QString Syncthis = m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXUSER);
michael@1 1794 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXGUID);
michael@1 1795 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXCRC).remove("0x");
michael@1 1796 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXREV);
michael@1 1797 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXDATE);
michael@1 1798 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXSTART);
michael@1 1799 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXFINISH);
michael@1 1800 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXAMOUNT);
michael@1 1801 Syncthis += ' ' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXTASK);
michael@1 1802 Syncthis += ' ' + ('"' + m_pMaintable->text(Select.topRow() + nRowiter, TITRAQ_IDXREMARK)) + '"';
michael@1 1803 Clistr = Syncthis; // Build RPC parameter
michael@1 1804 Logmeth.AddParameter("Tuple") << Clistr; // Prepare for marshalling
michael@1 1805 const SOAPResponse &Logresp = Proxy.Execute(Logmeth);
michael@1 1806 Logresp.GetReturnValue() >> nCrc;
michael@1 1807 }
michael@1 1808 m_pStatbar->message(trUtf8("Successful transmission, CRC returned %1").arg(nCrc));
michael@1 1809 }
michael@1 1810 catch (SOAPException& Soapex) { // Announce the exception we received
michael@1 1811 m_pStatbar->message(trUtf8("Caught SOAP exception: %1").arg(Soapex.What().Str()));
michael@1 1812 qDebug("Caught SOAP exception: %s", Soapex.What().Str());
michael@1 1813 }
michael@1 1814 catch (...) {
michael@1 1815 qDebug("Caught unknown exception\n");
michael@1 1816 }
michael@1 1817 #endif // HAVE_ESOAP
michael@1 1818 }
michael@1 1819
michael@1 1820 //
michael@1 1821 // Save user preferences
michael@1 1822 //
michael@1 1823 void Titraqform::savePrefs(void)
michael@1 1824 {
michael@1 1825 // Get check status from column menu and pass it to prefs handler
michael@1 1826 m_pPrefs->setBool(TITRAQ_PREFSTATCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTATCOL)));
michael@1 1827 m_pPrefs->setBool(TITRAQ_PREFLCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXLCOL)));
michael@1 1828 m_pPrefs->setBool(TITRAQ_PREFUCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXUCOL)));
michael@1 1829 m_pPrefs->setBool(TITRAQ_PREFGCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXGCOL)));
michael@1 1830 m_pPrefs->setBool(TITRAQ_PREFCCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXCCOL)));
michael@1 1831 m_pPrefs->setBool(TITRAQ_PREFREVCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREVCOL)));
michael@1 1832 m_pPrefs->setBool(TITRAQ_PREFDCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXDCOL)));
michael@1 1833 m_pPrefs->setBool(TITRAQ_PREFSTARTCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXSTARTCOL)));
michael@1 1834 m_pPrefs->setBool(TITRAQ_PREFFCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL)));
michael@1 1835 m_pPrefs->setBool(TITRAQ_PREFACOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXACOL)));
michael@1 1836 m_pPrefs->setBool(TITRAQ_PREFFCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXFCOL)));
michael@1 1837 m_pPrefs->setBool(TITRAQ_PREFREMCOLON, m_pColspopup->isItemChecked(m_pColspopup->idAt(TITRAQ_IDXREMCOL)));
michael@1 1838
michael@1 1839 // Get check status from toolbar menu and pass it to prefs handler
michael@1 1840 m_pPrefs->setBool(TITRAQ_PREFFILEBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR)));
michael@1 1841 m_pPrefs->setBool(TITRAQ_PREFEDITBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR)));
michael@1 1842 m_pPrefs->setBool(TITRAQ_PREFVIEWBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR)));
michael@1 1843 m_pPrefs->setBool(TITRAQ_PREFPREFBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR)));
michael@1 1844 m_pPrefs->setBool(TITRAQ_PREFWHATBAR, m_pTbarspopup->isItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR)));
michael@1 1845
michael@1 1846 // Get column widths from main table and pass it to prefs handler
michael@1 1847 if (m_pMaintable->columnWidth(TITRAQ_IDXSTATUS) > 0)
michael@1 1848 m_pPrefs->setNumber(TITRAQ_PREFSTATCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXSTATUS));
michael@1 1849 if (m_pMaintable->columnWidth(TITRAQ_IDXLINE) > 0)
michael@1 1850 m_pPrefs->setNumber(TITRAQ_PREFLCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXLINE));
michael@1 1851 if (m_pMaintable->columnWidth(TITRAQ_IDXUSER) > 0)
michael@1 1852 m_pPrefs->setNumber(TITRAQ_PREFUCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXUSER));
michael@1 1853 if (m_pMaintable->columnWidth(TITRAQ_IDXGUID) > 0)
michael@1 1854 m_pPrefs->setNumber(TITRAQ_PREFGCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXGUID));
michael@1 1855 if (m_pMaintable->columnWidth(TITRAQ_IDXCRC) > 0)
michael@1 1856 m_pPrefs->setNumber(TITRAQ_PREFCCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXCRC));
michael@1 1857 if (m_pMaintable->columnWidth(TITRAQ_IDXREV) > 0)
michael@1 1858 m_pPrefs->setNumber(TITRAQ_PREFREVCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXREV));
michael@1 1859 if (m_pMaintable->columnWidth(TITRAQ_IDXDATE) > 0)
michael@1 1860 m_pPrefs->setNumber(TITRAQ_PREFDCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXDATE));
michael@1 1861 if (m_pMaintable->columnWidth(TITRAQ_IDXSTART) > 0)
michael@1 1862 m_pPrefs->setNumber(TITRAQ_PREFSTARTCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXSTART));
michael@1 1863 if (m_pMaintable->columnWidth(TITRAQ_IDXFINISH) > 0)
michael@1 1864 m_pPrefs->setNumber(TITRAQ_PREFFCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXFINISH));
michael@1 1865 if (m_pMaintable->columnWidth(TITRAQ_IDXAMOUNT) > 0)
michael@1 1866 m_pPrefs->setNumber(TITRAQ_PREFACOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXAMOUNT));
michael@1 1867 if (m_pMaintable->columnWidth(TITRAQ_IDXTASK) > 0)
michael@1 1868 m_pPrefs->setNumber(TITRAQ_PREFTCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXTASK));
michael@1 1869 if (m_pMaintable->columnWidth(TITRAQ_IDXREMARK) > 0)
michael@1 1870 m_pPrefs->setNumber(TITRAQ_PREFREMCOLWIDTH, (long)m_pMaintable->columnWidth(TITRAQ_IDXREMARK));
michael@1 1871
michael@1 1872 // Get sorting order and direction from table and pass it to prefs handler
michael@1 1873 m_pPrefs->setNumber(TITRAQ_PREFSORTCOL, (long)m_pMaintable->getSortcol());
michael@1 1874 m_pPrefs->setBool(TITRAQ_PREFSORTDIR, (long)m_pMaintable->getSortdir());
michael@1 1875
michael@1 1876 // Set frame geometry preferences
michael@1 1877 m_pPrefs->setNumber(TITRAQ_PREFFRAMEWIDTH, (long)this->width());
michael@1 1878 m_pPrefs->setNumber(TITRAQ_PREFFRAMEHEIGHT, (long)this->height());
michael@1 1879
michael@1 1880 // Remember main window layout and doc positions
michael@1 1881 QString Laystring;
michael@1 1882 QTextStream Laystream(&Laystring, IO_WriteOnly);
michael@1 1883 Laystream << *this; // Persist the main window
michael@1 1884 m_pPrefs->setString(TITRAQ_PREFFRAMELAY, Laystring);
michael@1 1885 }
michael@1 1886
michael@1 1887 //
michael@1 1888 // Get help on Titraq functionality
michael@1 1889 //
michael@1 1890 void Titraqform::helpContents(void)
michael@1 1891 {
michael@1 1892 try { // Create and execute a new help contents window
michael@1 1893 std::auto_ptr<AS::Helpanel> pHelpcont(new AS::Helpanel(TITRAQ_REFHELP, this, "Helpanel"));
michael@1 1894 pHelpcont->exec();
michael@1 1895 delete pHelpcont.release(); // Technically unnecessary, smart pointer
michael@1 1896 }
michael@1 1897 catch (Genexcept& Genex) {
michael@1 1898 Genex.reportErr();
michael@1 1899 return;
michael@1 1900 }
michael@1 1901 }
michael@1 1902
michael@1 1903 //
michael@1 1904 // Learn more about this program itself
michael@1 1905 //
michael@1 1906 void Titraqform::aboutTitraq(void)
michael@1 1907 {
michael@1 1908 QString Namever = QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short;
michael@1 1909 QMessageBox *pCwmsg = new QMessageBox(Namever,
michael@1 1910 QObject::trUtf8("The as-gui is a time and task-based accounting\n"
michael@1 1911 "system that acts as both a work-like punch card and\n"
michael@1 1912 "time tracker. Development of as-gui is sponsored by\n"
michael@1 1913 "Cable & Wireless Telecommunications Services GmbH."),
michael@1 1914 QMessageBox::NoIcon, QMessageBox::Ok | QMessageBox::Default,
michael@1 1915 QMessageBox::NoButton, QMessageBox::NoButton,
michael@1 1916 NULL, "Titraqmessage", true, Qt::WStyle_NormalBorder);
michael@1 1917
michael@1 1918 pCwmsg->setIconPixmap(QPixmap(s_kpcCwlogo_xpm));
michael@1 1919 pCwmsg->exec();
michael@1 1920 }
michael@1 1921
michael@1 1922 //
michael@1 1923 // Learn more about the OSSP
michael@1 1924 //
michael@1 1925 void Titraqform::aboutOSSP(void)
michael@1 1926 {
michael@1 1927 QString Namever = QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short;
michael@1 1928 QMessageBox *pOsspmsg = new QMessageBox(Namever,
michael@1 1929 QObject::trUtf8("The open source software project (OSSP) is\n"
michael@1 1930 "a collective effort aimed at implementing\n"
michael@1 1931 "high-quality Unix software components,\n"
michael@1 1932 "ranging from networking, multi-threading\n"
michael@1 1933 "and algorithmic libraries to networking\n"
michael@1 1934 "servers and development tools."),
michael@1 1935 QMessageBox::NoIcon, QMessageBox::Ok | QMessageBox::Default,
michael@1 1936 QMessageBox::NoButton, QMessageBox::NoButton,
michael@1 1937 NULL, "Osspmessage", true, Qt::WStyle_NormalBorder);
michael@1 1938
michael@1 1939 pOsspmsg->setIconPixmap(QPixmap(s_kpcOssplogo_xpm));
michael@1 1940 pOsspmsg->exec();
michael@1 1941 }
michael@1 1942
michael@1 1943 //
michael@1 1944 // Learn more about this program and Qt
michael@1 1945 //
michael@1 1946 void Titraqform::aboutQt(void)
michael@1 1947 {
michael@1 1948 QMessageBox::aboutQt(this, QString(TITRAQ_APPTITLE) + ' ' + asgui_version.v_short);
michael@1 1949 }
michael@1 1950
michael@1 1951 //
michael@1 1952 // Apply preference values from a signal emitting object
michael@1 1953 //
michael@1 1954 void Titraqform::applyPrefs(void)
michael@1 1955 {
michael@1 1956 Prefpanel *pPan = (Prefpanel *)QObject::sender();
michael@1 1957 this->applyPrefs(pPan);
michael@1 1958 }
michael@1 1959
michael@1 1960 //
michael@1 1961 // Accept preference values from a inbound Panel object
michael@1 1962 //
michael@1 1963 void Titraqform::applyPrefs(Prefpanel *pPrefpanel)
michael@1 1964 {
michael@1 1965 m_pPrefs->setString(TITRAQ_PREFACCOUNTS, pPrefpanel->getAccounts());
michael@1 1966 m_pPrefs->setString(TITRAQ_PREFASDIR, pPrefpanel->getEvents());
michael@1 1967 m_pPrefs->setString(TITRAQ_PREFUSER, pPrefpanel->getUser());
michael@1 1968 m_pPrefs->setString(TITRAQ_PREFHOME, pPrefpanel->getHome());
michael@1 1969 m_pPrefs->setString(TITRAQ_PREFCORBHOST, pPrefpanel->getCorbahost());
michael@1 1970 m_pPrefs->setString(TITRAQ_PREFSOAPHOST, pPrefpanel->getSoaphost());
michael@1 1971 m_pPrefs->setBool(TITRAQ_PREFCORBON, pPrefpanel->getCorbaon());
michael@1 1972 m_pPrefs->setBool(TITRAQ_PREFSOAPON, pPrefpanel->getSoapon());
michael@1 1973 m_pPrefs->setBool(TITRAQ_PREFBAKON, pPrefpanel->getBackon());
michael@1 1974 m_pPrefs->setBool(TITRAQ_PREFEXTENDON, pPrefpanel->getExtendon());
michael@1 1975 m_pPrefs->setBool(TITRAQ_PREFDETAILON, pPrefpanel->getDetailon());
michael@1 1976 m_pPrefs->setBool(TITRAQ_PREFSIGNATON, pPrefpanel->getSignaton());
michael@1 1977 m_pPrefs->setNumber(TITRAQ_PREFLIGHTRED, pPrefpanel->getLight()->red());
michael@1 1978 m_pPrefs->setNumber(TITRAQ_PREFLIGHTGREEN, pPrefpanel->getLight()->green());
michael@1 1979 m_pPrefs->setNumber(TITRAQ_PREFLIGHTBLUE, pPrefpanel->getLight()->blue());
michael@1 1980 m_pPrefs->setNumber(TITRAQ_PREFDARKRED, pPrefpanel->getDark()->red());
michael@1 1981 m_pPrefs->setNumber(TITRAQ_PREFDARKGREEN, pPrefpanel->getDark()->green());
michael@1 1982 m_pPrefs->setNumber(TITRAQ_PREFDARKBLUE, pPrefpanel->getDark()->blue());
michael@1 1983
michael@1 1984 // Dim the lights if no RPC transports are available
michael@1 1985 if (this->isOpen())
michael@1 1986 m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON)
michael@1 1987 | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON));
michael@1 1988 else
michael@1 1989 m_pSyncact->setEnabled(false);
michael@1 1990
michael@1 1991 // Get the selected style which can be more complicated due to mapping...
michael@1 1992 if (pPrefpanel->getStyle() == TITRAQ_STRCDE) {
michael@1 1993 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
michael@1 1994 qApp->setStyle(new QCDEStyle);
michael@1 1995 }
michael@1 1996 else if (pPrefpanel->getStyle() == TITRAQ_STRSGI) {
michael@1 1997 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLESGI);
michael@1 1998 qApp->setStyle(new QSGIStyle);
michael@1 1999 }
michael@1 2000 else if (pPrefpanel->getStyle() == TITRAQ_STRMOTIF) {
michael@1 2001 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMOTIF);
michael@1 2002 qApp->setStyle(new QMotifStyle);
michael@1 2003 }
michael@1 2004 else if (pPrefpanel->getStyle() == TITRAQ_STRMPLUS) {
michael@1 2005 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMPLUS);
michael@1 2006 qApp->setStyle(new QMotifPlusStyle);
michael@1 2007 }
michael@1 2008 else if (pPrefpanel->getStyle() == TITRAQ_STRPLAT) {
michael@1 2009 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEPLAT);
michael@1 2010 qApp->setStyle(new QPlatinumStyle);
michael@1 2011 }
michael@1 2012 else if (pPrefpanel->getStyle() == TITRAQ_STRMSOFT) {
michael@1 2013 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLEMSOFT);
michael@1 2014 qApp->setStyle(new QWindowsStyle);
michael@1 2015 }
michael@1 2016 else // My personal favourite ;-)
michael@1 2017 m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
michael@1 2018 }

mercurial