as_slot.cpp

Thu, 06 Aug 2009 13:21:30 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 06 Aug 2009 13:21:30 +0200
changeset 15
0e0eb7c91312
parent 12
ceb4ba3d2d00
permissions
-rw-r--r--

Remove seemingly declarations unnecessary according to Qt 4.5.2 headers.

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

mercurial