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