as_assist.cpp

changeset 1
d64aaa7d146f
child 3
c1941114ca88
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/as_assist.cpp	Fri Nov 28 11:21:08 2008 +0100
     1.3 @@ -0,0 +1,1103 @@
     1.4 +//
     1.5 +//  OSSP asgui - Accounting system graphical user interface
     1.6 +//  Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/)
     1.7 +//  Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com>
     1.8 +//  Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com>
     1.9 +//  Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH
    1.10 +//
    1.11 +//  This file is part of OSSP asgui, an accounting system graphical user
    1.12 +//  interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
    1.13 +//
    1.14 +//  Permission to use, copy, modify, and distribute this software for
    1.15 +//  any purpose with or without fee is hereby granted, provided that
    1.16 +//  the above copyright notice and this permission notice appear in all
    1.17 +//  copies.
    1.18 +//
    1.19 +//  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    1.20 +//  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    1.21 +//  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    1.22 +//  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    1.23 +//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.24 +//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.25 +//  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    1.26 +//  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    1.27 +//  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    1.28 +//  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    1.29 +//  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.30 +//  SUCH DAMAGE.
    1.31 +//
    1.32 +//  as_assist.cpp: ISO C++ implementation
    1.33 +//
    1.34 +
    1.35 +// Qt style headers
    1.36 +#include <qcdestyle.h>
    1.37 +#include <qsgistyle.h>
    1.38 +#include <qmotifstyle.h>
    1.39 +#include <qmotifplusstyle.h>
    1.40 +#include <qplatinumstyle.h>
    1.41 +#include <qwindowsstyle.h>
    1.42 +
    1.43 +// Qt general headers
    1.44 +#include <qtooltip.h>
    1.45 +#include <qwhatsthis.h>
    1.46 +#include <qstringlist.h>
    1.47 +#include <qpopupmenu.h>
    1.48 +#include <qcombobox.h>
    1.49 +#include <qlistbox.h>
    1.50 +#include <qstatusbar.h>
    1.51 +#include <qmenubar.h>
    1.52 +#include <qcursor.h>
    1.53 +#include <qaction.h>
    1.54 +#include <qrect.h>
    1.55 +#include <qdir.h>
    1.56 +
    1.57 +// User interface
    1.58 +#include "as_amount.h"          // AmountBox class
    1.59 +#include "as_user.h"            // User class
    1.60 +#include "as_const.h"           // Application constants
    1.61 +#include "as_table.h"           // Class TiTable
    1.62 +#include "as_pref.h"            // Class Preferences
    1.63 +#include "as_panel.h"           // Class Prefpanel
    1.64 +#include "as_datedit.h"         // Class Daydateedit
    1.65 +
    1.66 +// Icon pixel maps
    1.67 +#include "as_gfx/filenew.xpm"   // static const char *s_kpcFilenew_xpm[]
    1.68 +#include "as_gfx/fileopen.xpm"  // static const char *s_kpcFileopen_xpm[]
    1.69 +#include "as_gfx/filesave.xpm"  // static const char *s_kpcFilesave_xpm[]
    1.70 +#include "as_gfx/filesaved.xpm" // static const char *s_kpcDfilesave_xpm[]
    1.71 +#include "as_gfx/cut.xpm"       // static const char *s_kpcCut_xpm[]
    1.72 +#include "as_gfx/cutd.xpm"      // static const char *s_kpcDcut_xpm[]
    1.73 +#include "as_gfx/copy.xpm"      // static const char *s_kpcCopy_xpm[]
    1.74 +#include "as_gfx/copyd.xpm"     // static const char *s_kpcDcopy_xpm[]
    1.75 +#include "as_gfx/paste.xpm"     // static const char *s_kpcPaste_xpm[]
    1.76 +#include "as_gfx/pasted.xpm"    // static const char *s_kpcDcaste_xpm[]
    1.77 +#include "as_gfx/rowadd.xpm"    // static const char *s_kpcRowadd_xpm[]
    1.78 +#include "as_gfx/rowdel.xpm"    // static const char *s_kpcRowdel_xpm[]
    1.79 +#include "as_gfx/rowaddd.xpm"   // static const char *s_kpcDrowadd_xpm[]
    1.80 +#include "as_gfx/rowdeld.xpm"   // static const char *s_kpcDrowdel_xpm[]
    1.81 +#include "as_gfx/osspicon.xpm"  // static const char *s_kpcOsspicon_xpm[]
    1.82 +#include "as_gfx/whatsthis.xpm" // static const char *s_kpcWhatsthis_xpm[]
    1.83 +#include "as_gfx/statok.xpm"    // static const char *s_kpcStatokay_xpm[]
    1.84 +#include "as_gfx/staterr.xpm"   // static const char *s_kpcStaterror_xpm[]
    1.85 +#include "as_gfx/statwrn.xpm"   // static const char *s_kpcStatwarn_xpm[]
    1.86 +#include "as_gfx/statvoid.xpm"  // static const char *s_kpcStatvoid_xpm[]
    1.87 +#include "as_gfx/refresh.xpm"   // static const char *s_kpcRefresh_xpm[]
    1.88 +#include "as_gfx/refreshd.xpm"  // static const char *s_kpcDrefresh_xpm[]
    1.89 +#include "as_gfx/sync.xpm"      // static const char *s_kpcSync_xpm[]
    1.90 +#include "as_gfx/syncd.xpm"     // static const char *s_kpcDsync_xpm[]
    1.91 +#include "as_gfx/report.xpm"    // static const char *s_kpcReport_xpm[]
    1.92 +#include "as_gfx/reportd.xpm"   // static const char *s_kpcDreport_xpm[]
    1.93 +#include "as_gfx/prefs.xpm"     // static const char *s_kpcPrefs_xpm[]
    1.94 +
    1.95 +
    1.96 +//
    1.97 +// Construct the preferences
    1.98 +//
    1.99 +void Titraqform::setupPrefs(void)
   1.100 +{
   1.101 +    // Can't bootstrap until we know who is using our tool, so find out
   1.102 +    User Localuser   = User();
   1.103 +    QString Username = Localuser.getName();
   1.104 +    QString Homedir  = Localuser.getHomedir();
   1.105 +
   1.106 +    // Bootstrap a user preferences object from operating system info
   1.107 +    m_pPrefs = new Preferences(Homedir + QChar('/') +
   1.108 +                               QString::fromLocal8Bit(TITRAQ_PREFNAME),
   1.109 +                               QString::fromLocal8Bit(TITRAQ_APPTITLE),
   1.110 +                               QString::fromLocal8Bit(TITRAQ_PREFVER));
   1.111 +    if (!m_pPrefs->fileState()) {   // No file was found, so assume a null state
   1.112 +        if (!Homedir.isEmpty())
   1.113 +            m_pPrefs->setString(TITRAQ_PREFHOME, Homedir);
   1.114 +        else
   1.115 +            m_pPrefs->setString(TITRAQ_PREFHOME, TITRAQ_DEFHOME);
   1.116 +        if (!Username.isEmpty())
   1.117 +            m_pPrefs->setString(TITRAQ_PREFUSER, Username);
   1.118 +        else
   1.119 +            m_pPrefs->setString(TITRAQ_PREFUSER, TITRAQ_DEFUSER);
   1.120 +
   1.121 +        m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
   1.122 +        m_pPrefs->setString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS);
   1.123 +        m_pPrefs->setString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR);
   1.124 +        m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);
   1.125 +        m_pPrefs->setNumber(TITRAQ_PREFSORTCOL, TITRAQ_DEFSORTCOL);
   1.126 +        m_pPrefs->setBool(TITRAQ_PREFSORTDIR, TITRAQ_DEFSORTDIR);
   1.127 +        m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG);
   1.128 +        m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG);
   1.129 +        m_pPrefs->setString(TITRAQ_PREFCORBHOST, TITRAQ_DEFCORBHOST);
   1.130 +        m_pPrefs->setString(TITRAQ_PREFSOAPHOST, TITRAQ_DEFSOAPHOST);
   1.131 +        m_pPrefs->setBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON);
   1.132 +        m_pPrefs->setBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON);
   1.133 +        m_pPrefs->setBool(TITRAQ_PREFBAKON, TITRAQ_DEFBAKON);
   1.134 +        m_pPrefs->setBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON);
   1.135 +        m_pPrefs->setBool(TITRAQ_PREFDETAILON, TITRAQ_DEFDETAILON);
   1.136 +        m_pPrefs->setBool(TITRAQ_PREFSIGNATON, TITRAQ_DEFSIGNATON);
   1.137 +        m_pPrefs->setNumber(TITRAQ_PREFREPORTYPE, TITRAQ_DEFREPORTYPE);
   1.138 +        m_pPrefs->setNumber(TITRAQ_PREFREPORTWEEKS, TITRAQ_DEFREPORTWEEKS);
   1.139 +        m_pPrefs->setNumber(TITRAQ_PREFREPORTMONTHS, TITRAQ_DEFREPORTMONTHS);
   1.140 +        m_pPrefs->setNumber(TITRAQ_PREFLIGHTRED, TITRAQ_DEFLIGHTRED);
   1.141 +        m_pPrefs->setNumber(TITRAQ_PREFLIGHTGREEN, TITRAQ_DEFLIGHTGREEN);
   1.142 +        m_pPrefs->setNumber(TITRAQ_PREFLIGHTBLUE, TITRAQ_DEFLIGHTBLUE);
   1.143 +        m_pPrefs->setNumber(TITRAQ_PREFDARKRED, TITRAQ_DEFDARKRED);
   1.144 +        m_pPrefs->setNumber(TITRAQ_PREFDARKGREEN, TITRAQ_DEFDARKGREEN);
   1.145 +        m_pPrefs->setNumber(TITRAQ_PREFDARKBLUE, TITRAQ_DEFDARKBLUE);
   1.146 +        m_pPrefs->flush();  // Write the new conf file
   1.147 +        QTextStream cerr(stderr, IO_WriteOnly);
   1.148 +        cerr << trUtf8("Created new preferences file ") << Homedir << QChar('/')
   1.149 +             << QString::fromLocal8Bit(TITRAQ_PREFNAME) << endl;
   1.150 +    }
   1.151 +
   1.152 +    // Use the preferred configuration values to initialize titraq
   1.153 +    switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) {
   1.154 +    case TITRAQ_STYLECDE:
   1.155 +        qApp->setStyle(new QCDEStyle);
   1.156 +        break;
   1.157 +    case TITRAQ_STYLESGI:
   1.158 +        qApp->setStyle(new QSGIStyle);
   1.159 +        break;
   1.160 +    case TITRAQ_STYLEMOTIF:
   1.161 +        qApp->setStyle(new QMotifStyle);
   1.162 +        break;
   1.163 +    case TITRAQ_STYLEMPLUS:
   1.164 +        qApp->setStyle(new QMotifPlusStyle);
   1.165 +        break;
   1.166 +    case TITRAQ_STYLEPLAT:
   1.167 +        qApp->setStyle(new QPlatinumStyle);
   1.168 +        break;
   1.169 +    case TITRAQ_STYLEMSOFT:
   1.170 +        qApp->setStyle(new QWindowsStyle);
   1.171 +        break;
   1.172 +    default:
   1.173 +        qApp->setStyle(new QCDEStyle);
   1.174 +        break;
   1.175 +    }
   1.176 +}
   1.177 +
   1.178 +//
   1.179 +// Construct various actions
   1.180 +//
   1.181 +void Titraqform::setupActions(void)
   1.182 +{
   1.183 +    QIconSet Saveiset, Cutiset, Copyiset, Pasteiset;
   1.184 +    QIconSet Rowaddiset, Rowdeliset, Refreshiset;
   1.185 +    QIconSet Synciset, Reportiset;
   1.186 +
   1.187 +    // Construct iconsets to use later for multistate action images
   1.188 +    Saveiset.setPixmap(QPixmap(s_kpcFilesave_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.189 +    Saveiset.setPixmap(QPixmap(s_kpcDfilesave_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.190 +    Cutiset.setPixmap(QPixmap(s_kpcCut_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.191 +    Cutiset.setPixmap(QPixmap(s_kpcDcut_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.192 +    Copyiset.setPixmap(QPixmap(s_kpcCopy_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.193 +    Copyiset.setPixmap(QPixmap(s_kpcDcopy_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.194 +    Pasteiset.setPixmap(QPixmap(s_kpcPaste_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.195 +    Pasteiset.setPixmap(QPixmap(s_kpcDpaste_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.196 +    Rowaddiset.setPixmap(QPixmap(s_kpcRowadd_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.197 +    Rowaddiset.setPixmap(QPixmap(s_kpcDrowadd_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.198 +    Rowdeliset.setPixmap(QPixmap(s_kpcRowdel_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.199 +    Rowdeliset.setPixmap(QPixmap(s_kpcDrowdel_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.200 +    Refreshiset.setPixmap(QPixmap(s_kpcRefresh_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.201 +    Refreshiset.setPixmap(QPixmap(s_kpcDrefresh_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.202 +    Synciset.setPixmap(QPixmap(s_kpcSync_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.203 +    Synciset.setPixmap(QPixmap(s_kpcDsync_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.204 +    Reportiset.setPixmap(QPixmap(s_kpcReport_xpm), QIconSet::Automatic, QIconSet::Normal);
   1.205 +    Reportiset.setPixmap(QPixmap(s_kpcDreport_xpm), QIconSet::Automatic, QIconSet::Disabled);
   1.206 +
   1.207 +    // First associate the graphics with MIME types
   1.208 +    QMimeSourceFactory::defaultFactory()->setPixmap("osspicon", QPixmap(s_kpcOsspicon_xpm));
   1.209 +    QMimeSourceFactory::defaultFactory()->setPixmap("filenew", QPixmap(s_kpcFilenew_xpm));
   1.210 +    QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", QPixmap(s_kpcFileopen_xpm));
   1.211 +    QMimeSourceFactory::defaultFactory()->setPixmap("filesave", QPixmap(s_kpcFilesave_xpm));
   1.212 +    QMimeSourceFactory::defaultFactory()->setPixmap("cut", QPixmap(s_kpcCut_xpm));
   1.213 +    QMimeSourceFactory::defaultFactory()->setPixmap("copy", QPixmap(s_kpcCopy_xpm));
   1.214 +    QMimeSourceFactory::defaultFactory()->setPixmap("paste", QPixmap(s_kpcPaste_xpm));
   1.215 +    QMimeSourceFactory::defaultFactory()->setPixmap("rowadd", QPixmap(s_kpcRowadd_xpm));
   1.216 +    QMimeSourceFactory::defaultFactory()->setPixmap("rowdel", QPixmap(s_kpcRowdel_xpm));
   1.217 +    QMimeSourceFactory::defaultFactory()->setPixmap("refresh", QPixmap(s_kpcRefresh_xpm));
   1.218 +    QMimeSourceFactory::defaultFactory()->setPixmap("syncrpc", QPixmap(s_kpcSync_xpm));
   1.219 +    QMimeSourceFactory::defaultFactory()->setPixmap("locreport", QPixmap(s_kpcReport_xpm));
   1.220 +    QMimeSourceFactory::defaultFactory()->setPixmap("prefs", QPixmap(s_kpcPrefs_xpm));
   1.221 +
   1.222 +    // File new action
   1.223 +    m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New"), CTRL+Key_N, this, "New");
   1.224 +    if (m_pFilenewact == NULL)  // Sanity check
   1.225 +        throw Genexcept("Main window file new action creation failed.");
   1.226 +    connect(m_pFilenewact, SIGNAL(activated()), SLOT(newDoc()));
   1.227 +    const char *kszFilenewtext = "<p><img source=\"filenew\"> "
   1.228 +                                        "Click this button to make a "
   1.229 +                                        "<em>blank file</em>. You can also "
   1.230 +                                        "select the <b>New</b> command from "
   1.231 +                                        "the <b>File</b> menu.</p>";
   1.232 +    m_pFilenewact->setWhatsThis(kszFilenewtext);
   1.233 +
   1.234 +    // File open action
   1.235 +    m_pFileopenact = new QAction(trUtf8("Open File"), QPixmap(s_kpcFileopen_xpm), trUtf8("&Open..."), CTRL+Key_O, this, "Open");
   1.236 +    if (m_pFileopenact == NULL) // Sanity check
   1.237 +        throw Genexcept("Main window file open action creation failed.");
   1.238 +    connect(m_pFileopenact, SIGNAL(activated()), SLOT(openDoc()));
   1.239 +    const char *kszFileopentext = "<p><img source=\"fileopen\"> "
   1.240 +                                  "Click this button to open a "
   1.241 +                                  "<em>new file</em>. You can also select "
   1.242 +                                  "the <b>Open</b> command from the "
   1.243 +                                  "<b>File</b> menu.</p>";
   1.244 +    m_pFileopenact->setWhatsThis(kszFileopentext);
   1.245 +
   1.246 +    // File save current action
   1.247 +    m_pFilesaveact = new QAction(trUtf8("Save File"), Saveiset, trUtf8("&Save"), CTRL+Key_S, this, "Save");
   1.248 +    if (m_pFilesaveact == NULL) // Sanity check
   1.249 +        throw Genexcept("Main window file save action creation failed.");
   1.250 +    connect(m_pFilesaveact, SIGNAL(activated()), SLOT(saveFile()));
   1.251 +    const char *kszFilesavetext = "<p><img source=\"filesave\"> "
   1.252 +                                  "Click this button to <em>save</em> "
   1.253 +                                  "the file you are editing. You will be "
   1.254 +                                  "prompted for a file name. You can also "
   1.255 +                                  "select the<b> Save</b> command from "
   1.256 +                                  "the <b>File</b> menu.</p>";
   1.257 +    m_pFilesaveact->setWhatsThis(kszFilesavetext);
   1.258 +
   1.259 +    // File save selected action
   1.260 +    m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &As..."), 0, this, "SaveAs");
   1.261 +    if (m_pFilesaveasact == NULL)   // Sanity check
   1.262 +        throw Genexcept("Main window file save as action creation failed.");
   1.263 +    connect(m_pFilesaveasact, SIGNAL(activated()), SLOT(saveAs()));
   1.264 +    m_pFilesaveasact->setWhatsThis(kszFilesavetext);
   1.265 +
   1.266 +    // File close current action
   1.267 +    m_pFilecloseact = new QAction(trUtf8("Close"), trUtf8("&Close"), CTRL+Key_W, this, "Close");
   1.268 +    if (m_pFilecloseact == NULL)    // Sanity check
   1.269 +        throw Genexcept("Main window file close action creation failed.");
   1.270 +    connect(m_pFilecloseact, SIGNAL(activated()), SLOT(close()));
   1.271 +
   1.272 +    // File quit action
   1.273 +    m_pFilequitact = new QAction(trUtf8("Exit"), trUtf8("E&xit"), CTRL+Key_Q, this, "Exit");
   1.274 +    if (m_pFilequitact == NULL)     // Sanity check
   1.275 +        throw Genexcept("Main window file quit action creation failed.");
   1.276 +    connect(m_pFilequitact, SIGNAL(activated()), SLOT(quitApp()));
   1.277 +
   1.278 +    // Cut action
   1.279 +    m_pCutact = new QAction(trUtf8("Cut"), Cutiset, trUtf8("&Cut"), CTRL+Key_X, this, "Cut");
   1.280 +    if (m_pCutact == NULL)      // Sanity check
   1.281 +        throw Genexcept("Main window cut edit action creation failed.");
   1.282 +    connect(m_pCutact, SIGNAL(activated()), SLOT(cutEntry()));
   1.283 +    const char *kszCuttext = "<p><img source=\"cut\"> "
   1.284 +                                   "Click this button to cut an <em>entry</em>. "
   1.285 +                                   "You can also select the <b>Cut</b> command "
   1.286 +                                   "from the <b>Edit</b> menu.</p>";
   1.287 +    m_pCutact->setWhatsThis(kszCuttext);
   1.288 +
   1.289 +    // Copy action
   1.290 +    m_pCopyact = new QAction(trUtf8("Copy"), Copyiset, trUtf8("&Copy"), CTRL+Key_C, this, "Copy");
   1.291 +    if (m_pCopyact == NULL)     // Sanity check
   1.292 +        throw Genexcept("Main window copy edit action creation failed.");
   1.293 +    connect(m_pCopyact, SIGNAL(activated()), SLOT(copyEntry()));
   1.294 +    const char *kszCopytext = "<p><img source=\"copy\"> "
   1.295 +                                   "Click this button to copy an <em>entry</em>. "
   1.296 +                                   "You can also select the <b>Copy</b> command "
   1.297 +                                   "from the <b>Edit</b> menu.</p>";
   1.298 +    m_pCopyact->setWhatsThis(kszCopytext);
   1.299 +
   1.300 +    // Paste action
   1.301 +    m_pPasteact = new QAction(trUtf8("Paste"), Pasteiset, trUtf8("&Paste"), CTRL+Key_V, this, "Paste");
   1.302 +    if (m_pPasteact == NULL)    // Sanity check
   1.303 +        throw Genexcept("Main window paste edit action creation failed.");
   1.304 +    connect(m_pPasteact, SIGNAL(activated()), SLOT(pasteEntry()));
   1.305 +    const char *kszPastetext = "<p><img source=\"paste\"> "
   1.306 +                                   "Click this button to paste an <em>entry</em>. "
   1.307 +                                   "You can also select the <b>Paste</b> command "
   1.308 +                                   "from the <b>Edit</b> menu.</p>";
   1.309 +    m_pPasteact->setWhatsThis(kszPastetext);
   1.310 +
   1.311 +    // Add data row action
   1.312 +    m_pAddrowact = new QAction(trUtf8("Add Entry"), Rowaddiset, trUtf8("&Add entry"), Key_Insert, this, "Addentry");
   1.313 +    if (m_pAddrowact == NULL)   // Sanity check
   1.314 +        throw Genexcept("Main window add entry action creation failed.");
   1.315 +    connect(m_pAddrowact, SIGNAL(activated()), SLOT(addEntry()));
   1.316 +    const char *kszAddrowtext = "<p><img source=\"rowadd\"> "
   1.317 +                                "Click this button to add a <em>new entry</em>. "
   1.318 +                                "You can also select the <b>Add</b> command "
   1.319 +                                "from the <b>Edit</b> menu.</p>";
   1.320 +    m_pAddrowact->setWhatsThis(kszAddrowtext);
   1.321 +
   1.322 +    // Delete data row action
   1.323 +    m_pDelrowact = new QAction(trUtf8("Delete Entry"), Rowdeliset, trUtf8("&Delete entry"), Key_Delete, this, "Delentry");
   1.324 +    if (m_pDelrowact == NULL)   // Sanity check
   1.325 +        throw Genexcept("Main window delete entry action creation failed.");
   1.326 +    connect(m_pDelrowact, SIGNAL(activated()), SLOT(delEntry()));
   1.327 +    const char *kszDelrowtext = "<p><img source=\"rowdel\"> "
   1.328 +                                   "Click this button to delete a <em>entry</em>. "
   1.329 +                                   "You can also select the <b>Delete</b> command "
   1.330 +                                   "from the <b>Edit</b> menu.</p>";
   1.331 +    m_pDelrowact->setWhatsThis(kszDelrowtext);
   1.332 +
   1.333 +    // Refresh data display action
   1.334 +    m_pRefreshact = new QAction(trUtf8("Refresh Display"), Refreshiset, trUtf8("&Refresh display"), CTRL+Key_R, this, "Refresh");
   1.335 +    if (m_pRefreshact == NULL)  // Sanity check
   1.336 +        throw Genexcept("Main window refresh action creation failed.");
   1.337 +    connect(m_pRefreshact, SIGNAL(activated()), SLOT(refreshDisplay()));
   1.338 +    const char *kszRefreshtext = "<p><img source=\"refresh\"> "
   1.339 +                                 "Click this button to <em>refresh the display</em>. "
   1.340 +                                 "You can also select the <b>Refresh</b> command "
   1.341 +                                 "from the <b>View</b> menu.</p>";
   1.342 +    m_pRefreshact->setWhatsThis(kszRefreshtext);
   1.343 +
   1.344 +    // Syncronize data with remote server over IIOP or SOAP action
   1.345 +    m_pSyncact = new QAction(trUtf8("Synchronize with server"), Synciset, trUtf8("&Synchronize"), CTRL+Key_E, this, "Synchronize");
   1.346 +    if (m_pSyncact == NULL) // Sanity check
   1.347 +        throw Genexcept("Main window synchronize RPC action creation failed.");
   1.348 +    connect(m_pSyncact, SIGNAL(activated()), SLOT(syncIiop()));
   1.349 +    connect(m_pSyncact, SIGNAL(activated()), SLOT(syncSoap()));
   1.350 +    const char *kszSynctext = "<p><img source=\"syncrpc\"> "
   1.351 +                              "Click this button to <em>synchronize the data</em>. "
   1.352 +                              "Your changed entries will be sent to the server. "
   1.353 +                              "You can also select the <b>Synchronize</b> command "
   1.354 +                              "from the <b>Report</b> menu.</p>";
   1.355 +    m_pSyncact->setWhatsThis(kszSynctext);
   1.356 +
   1.357 +    // Local report generation action
   1.358 +    m_pReportact = new QAction(trUtf8("Generate a local report"), Reportiset, trUtf8("&Report"), CTRL+Key_T, this, "LocalReport");
   1.359 +    if (m_pReportact == NULL) // Sanity check
   1.360 +        throw Genexcept("Main window local report action creation failed.");
   1.361 +    connect(m_pReportact, SIGNAL(activated()), SLOT(genReport()));
   1.362 +    const char *kszReporttext = "<p><img source=\"locreport\"> "
   1.363 +                                "Click this button to <em>report your data</em>. "
   1.364 +                                "A local report will be generated for you to view. "
   1.365 +                                "You can also select the <b>Local Report</b> command "
   1.366 +                                "from the <b>Report</b> menu.</p>";
   1.367 +    m_pReportact->setWhatsThis(kszReporttext);
   1.368 +
   1.369 +    // Offer a formatted preferences panel for intuitive prefs object editing
   1.370 +    m_pPrefsact = new QAction(trUtf8("Edit the preferences"), QPixmap(s_kpcPrefs_xpm), trUtf8("P&references..."), CTRL+Key_F, this, "Prefspanel");
   1.371 +    if (m_pPrefsact == NULL) // Sanity check
   1.372 +        throw Genexcept("Main window preferences panel action creation failed.");
   1.373 +    connect(m_pPrefsact, SIGNAL(activated()), SLOT(configPrefs()));
   1.374 +    const char *kszPrefstext = "<p><img source=\"prefs\"> "
   1.375 +                               "Click this button to <em>edit the preferences</em>. "
   1.376 +                               "You can then apply, accept, or cancel your changes. "
   1.377 +                               "You can also select the <b>Preferences</b> command "
   1.378 +                               "from the <b>Edit</b> menu.</p>";
   1.379 +    m_pPrefsact->setWhatsThis(kszPrefstext);
   1.380 +}
   1.381 +
   1.382 +//
   1.383 +// Construct the menu bar
   1.384 +//
   1.385 +void Titraqform::setupMenubar(void)
   1.386 +{
   1.387 +    int nMenuid = 0;        // Used to store id during menu item creation
   1.388 +
   1.389 +    m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow
   1.390 +    if (m_pMenubar == NULL) // Sanity check
   1.391 +        throw Genexcept("Main window menu bar nonexistant.");
   1.392 +
   1.393 +//    // Make an easter egg ;-)
   1.394 +//    QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), trUtf8("Easter Egg"));
   1.395 +
   1.396 +    // Construct and populate the file menu with actions
   1.397 +    QPopupMenu *pFilepopup = new QPopupMenu(this);
   1.398 +    if (pFilepopup == NULL) // Sanity check
   1.399 +        throw Genexcept("Main window file popup creation failed.");
   1.400 +    m_pMenubar->insertItem(trUtf8("&File"), pFilepopup);
   1.401 +    m_pFilenewact->addTo(pFilepopup);
   1.402 +    m_pFileopenact->addTo(pFilepopup);
   1.403 +    pFilepopup->insertSeparator();
   1.404 +    m_pFilecloseact->addTo(pFilepopup);
   1.405 +    pFilepopup->insertSeparator();
   1.406 +    m_pFilesaveact->addTo(pFilepopup);
   1.407 +    m_pFilesaveasact->addTo(pFilepopup);
   1.408 +    pFilepopup->insertSeparator();
   1.409 +    m_pFilequitact->addTo(pFilepopup);
   1.410 +
   1.411 +    // Construct and populate the edit menu with subitems
   1.412 +    QPopupMenu *pEditpopup = new QPopupMenu(this);
   1.413 +    if (pEditpopup == NULL) // Sanity check
   1.414 +        throw Genexcept("Main window edit popup creation failed.");
   1.415 +    m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup);
   1.416 +    m_pCutact->addTo(pEditpopup);
   1.417 +    m_pCopyact->addTo(pEditpopup);
   1.418 +    m_pPasteact->addTo(pEditpopup);
   1.419 +    pEditpopup->insertSeparator();
   1.420 +    m_pAddrowact->addTo(pEditpopup);
   1.421 +    m_pDelrowact->addTo(pEditpopup);
   1.422 +    pEditpopup->insertSeparator();
   1.423 +    m_pPrefsact->addTo(pEditpopup);
   1.424 +
   1.425 +    // Construct the view menu and submenus
   1.426 +    m_pViewpopup = new QPopupMenu(this);
   1.427 +    m_pTbarspopup = new QPopupMenu(this);
   1.428 +    m_pColspopup = new QPopupMenu(this);
   1.429 +
   1.430 +    // Give the new menus krass attributes
   1.431 +    m_pTbarspopup->insertTearOffHandle();
   1.432 +    m_pTbarspopup->setCheckable(true);
   1.433 +    m_pColspopup->insertTearOffHandle();
   1.434 +    m_pColspopup->setCheckable(true);
   1.435 +
   1.436 +    // Major sanity check wrapped in one call
   1.437 +    if (!(m_pViewpopup && m_pTbarspopup && m_pColspopup))
   1.438 +        throw Genexcept("Main window view popups creation failed.");
   1.439 +
   1.440 +    // Populate the view menu with subitems
   1.441 +    m_pMenubar->insertItem(trUtf8("&View"), m_pViewpopup);
   1.442 +    m_pViewpopup->insertItem(trUtf8("&Normal"), this, SLOT(normalView()));
   1.443 +    nMenuid = m_pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView()));
   1.444 +    m_pViewpopup->setItemEnabled(nMenuid, false);
   1.445 +    nMenuid = m_pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView()));
   1.446 +    m_pViewpopup->setItemEnabled(nMenuid, false);
   1.447 +    m_pViewpopup->insertSeparator();
   1.448 +    m_pRefreshact->addTo(m_pViewpopup); // Refresh action
   1.449 +    m_pViewpopup->insertSeparator();
   1.450 +    m_pViewpopup->insertItem(trUtf8("&Toolbars"), m_pTbarspopup);
   1.451 +    nMenuid = m_pTbarspopup->insertItem(trUtf8("&File"), this, SLOT(showFilebar()));
   1.452 +    m_pTbarspopup->setItemChecked(nMenuid, true);
   1.453 +    nMenuid = m_pTbarspopup->insertItem(trUtf8("&Edit"), this, SLOT(showEditbar()));
   1.454 +    m_pTbarspopup->setItemChecked(nMenuid, true);
   1.455 +    nMenuid = m_pTbarspopup->insertItem(trUtf8("&View"), this, SLOT(showViewbar()));
   1.456 +    m_pTbarspopup->setItemChecked(nMenuid, true);
   1.457 +    nMenuid = m_pTbarspopup->insertItem(trUtf8("&Prefs"), this, SLOT(showPrefsbar()));
   1.458 +    m_pTbarspopup->setItemChecked(nMenuid, true);
   1.459 +    nMenuid = m_pTbarspopup->insertItem(trUtf8("&Whats"), this, SLOT(showWhatsbar()));
   1.460 +    m_pTbarspopup->setItemChecked(nMenuid, true);
   1.461 +    m_pViewpopup->insertItem(trUtf8("&Columns"), m_pColspopup);
   1.462 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Status"), this, SLOT(showStatcol()));
   1.463 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.464 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Line"), this, SLOT(showLinecol()));
   1.465 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.466 +    nMenuid = m_pColspopup->insertItem(trUtf8("&User"), this, SLOT(showUsercol()));
   1.467 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.468 +    nMenuid = m_pColspopup->insertItem(trUtf8("&GUID"), this, SLOT(showGuidcol()));
   1.469 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.470 +    nMenuid = m_pColspopup->insertItem(trUtf8("&CRC"), this, SLOT(showCrccol()));
   1.471 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.472 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Rev"), this, SLOT(showRevcol()));
   1.473 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.474 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Date"), this, SLOT(showDatecol()));
   1.475 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.476 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Start"), this, SLOT(showStartcol()));
   1.477 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.478 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Finish"), this, SLOT(showFinishcol()));
   1.479 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.480 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Amount"), this, SLOT(showAmountcol()));
   1.481 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.482 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Task"), this, SLOT(showTaskcol()));
   1.483 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.484 +    nMenuid = m_pColspopup->insertItem(trUtf8("&Remark"), this, SLOT(showRemarkcol()));
   1.485 +    m_pColspopup->setItemChecked(nMenuid, true);
   1.486 +
   1.487 +    // Construct and populate the report menu with subitems
   1.488 +    QPopupMenu *pReportpopup = new QPopupMenu(this);
   1.489 +    if (pReportpopup == NULL) // Sanity check
   1.490 +        throw Genexcept("Main window report popup creation failed.");
   1.491 +    m_pMenubar->insertItem(trUtf8("&Report"), pReportpopup);
   1.492 +#if defined HAVE_MICO || defined HAVE_ESOAP
   1.493 +    m_pSyncact->addTo(pReportpopup);
   1.494 +    m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON)
   1.495 +        | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON));
   1.496 +#endif // defined HAVE_MICO || defined HAVE_ESOAP
   1.497 +    m_pReportact->addTo(pReportpopup);
   1.498 +
   1.499 +    // Pad spacing to force help menu to appear far right
   1.500 +    m_pMenubar->insertSeparator();
   1.501 +
   1.502 +    // Construct and populate the help menu with subitems
   1.503 +    QPopupMenu *pHelppopup = new QPopupMenu(this);
   1.504 +    if (pHelppopup == NULL) // Sanity check
   1.505 +        throw Genexcept("Main window help popup creation failed.");
   1.506 +    m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup);
   1.507 +    pHelppopup->insertItem(trUtf8("&Contents"), this, SLOT(helpContents()), Key_F1);
   1.508 +    pHelppopup->insertSeparator();
   1.509 +    pHelppopup->insertItem(trUtf8("About &as-gui"), this, SLOT(aboutTitraq()));
   1.510 +    pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
   1.511 +    pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt()));
   1.512 +    pHelppopup->insertSeparator();
   1.513 +    pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
   1.514 +}
   1.515 +
   1.516 +//
   1.517 +// Construct the tool bars
   1.518 +//
   1.519 +void Titraqform::setupToolbars(void)
   1.520 +{
   1.521 +    // Construct and populate the file tool bar
   1.522 +    m_pFiletools = new QToolBar("Toolfile", this, DockTop);
   1.523 +    if (m_pFiletools == NULL)                   // Sanity check
   1.524 +        throw Genexcept("File tool bar creation failed.");
   1.525 +    m_pFiletools->setLabel(trUtf8("File Ops"));
   1.526 +    m_pFiletools->setOpaqueMoving(false);
   1.527 +    m_pFiletools->setCloseMode(QDockWindow::Never);
   1.528 +    m_pFilenewact->addTo(m_pFiletools);
   1.529 +    m_pFileopenact->addTo(m_pFiletools);
   1.530 +    m_pFilesaveact->addTo(m_pFiletools);
   1.531 +
   1.532 +    // Construct and populate the edit tool bar
   1.533 +    m_pEdittools = new QToolBar("Tooledit", this, DockTop);
   1.534 +    if (m_pEdittools == NULL)                   // Sanity check
   1.535 +        throw Genexcept("Edit tool bar creation failed.");
   1.536 +    m_pEdittools->setLabel(trUtf8("Edit Ops"));
   1.537 +    m_pEdittools->setOpaqueMoving(false);
   1.538 +    m_pEdittools->setCloseMode(QDockWindow::Never);
   1.539 +    m_pCutact->addTo(m_pEdittools);
   1.540 +    m_pCopyact->addTo(m_pEdittools);
   1.541 +    m_pPasteact->addTo(m_pEdittools);
   1.542 +    m_pEdittools->addSeparator();
   1.543 +    m_pAddrowact->addTo(m_pEdittools);
   1.544 +    m_pDelrowact->addTo(m_pEdittools);
   1.545 +
   1.546 +    // Construct and populate the view tool bar
   1.547 +    m_pViewtools = new QToolBar("Toolview", this, DockTop);
   1.548 +    if (m_pViewtools == NULL)                   // Sanity check
   1.549 +        throw Genexcept("View tool bar creation failed.");
   1.550 +    m_pViewtools->setLabel(trUtf8("View Ops"));
   1.551 +    m_pViewtools->setOpaqueMoving(false);
   1.552 +    m_pViewtools->setCloseMode(QDockWindow::Never);
   1.553 +    m_pRefreshact->addTo(m_pViewtools);
   1.554 +    m_pReportact->addTo(m_pViewtools);
   1.555 +    m_pSyncact->addTo(m_pViewtools);
   1.556 +
   1.557 +    // Construct and populate the lonely preferences tool bar
   1.558 +    m_pPrefstools = new QToolBar("Preferences", this, DockTop);
   1.559 +    if (m_pPrefstools == NULL)                   // Sanity check
   1.560 +        throw Genexcept("Prefs tool bar creation failed.");
   1.561 +    m_pPrefstools->setLabel(trUtf8("Preferences editor"));
   1.562 +    m_pPrefstools->setOpaqueMoving(false);
   1.563 +    m_pPrefstools->setCloseMode(QDockWindow::Never);
   1.564 +    m_pPrefsact->addTo(m_pPrefstools);
   1.565 +
   1.566 +    // Construct and populate the lonely whatsthis tool bar
   1.567 +    m_pWhatstools = new QToolBar("Toolwhats", this, DockTop);
   1.568 +    if (m_pWhatstools == NULL)                  // Sanity check
   1.569 +        throw Genexcept("Whats this tool bar creation failed.");
   1.570 +    m_pWhatstools->setLabel(trUtf8("Whats this"));
   1.571 +    m_pWhatstools->setOpaqueMoving(false);
   1.572 +    m_pWhatstools->setCloseMode(QDockWindow::Never);
   1.573 +    QWhatsThis::whatsThisButton(m_pWhatstools); // Preconfigured whats this button
   1.574 +}
   1.575 +
   1.576 +//
   1.577 +// Construct the central frame
   1.578 +//
   1.579 +void Titraqform::setupCentralwidget(void)
   1.580 +{
   1.581 +    // Create a central frame and associated layout for QMainWindow
   1.582 +    m_pCenframe = new QFrame(this, "Centralframe");
   1.583 +    if (m_pCenframe == NULL)    // Sanity check
   1.584 +        throw Genexcept("Main window central frame creation failed.");
   1.585 +    m_pCenframe->setFrameShape(QFrame::StyledPanel);
   1.586 +    m_pCenframe->setFrameShadow(QFrame::Sunken);
   1.587 +    this->setCentralWidget(m_pCenframe);
   1.588 +
   1.589 +    // Layout controls for table, editing widgets
   1.590 +    m_pMainlayout = new QVBoxLayout(m_pCenframe, TITRAQ_MARGIN, TITRAQ_SPACING, "Mainlayout");  // For layouts
   1.591 +    m_pPackagelayout = new QVBoxLayout(0, 0, TITRAQ_SPACING, "Packagelayout");  // For table
   1.592 +    m_pEditlayout = new QHBoxLayout(0, 0, TITRAQ_SPACING, "Editlayout");        // For edits
   1.593 +
   1.594 +    // Major sanity check wrapped in one call
   1.595 +    if (!(m_pMainlayout && m_pPackagelayout && m_pEditlayout))
   1.596 +        throw Genexcept("Main window layout creation failed.");
   1.597 +
   1.598 +    // Specify ordering of the layouts
   1.599 +    m_pMainlayout->addLayout(m_pPackagelayout);
   1.600 +    m_pMainlayout->addLayout(m_pEditlayout);
   1.601 +}
   1.602 +
   1.603 +//
   1.604 +// Construct the status bar
   1.605 +//
   1.606 +void Titraqform::setupStatusbar(void)
   1.607 +{
   1.608 +    m_pStatbar = statusBar();   // Grab status bar owned by QMainWindow
   1.609 +    if (m_pStatbar == NULL)     // Sanity check
   1.610 +        throw Genexcept("Main window status bar nonexistant.");
   1.611 +}
   1.612 +
   1.613 +//
   1.614 +// Construct the table
   1.615 +//
   1.616 +void Titraqform::setupTable(void)
   1.617 +{
   1.618 +    // Create, configure, and setup the table itself
   1.619 +    m_pMaintable = new TiTable(m_pPrefs, m_pCenframe, "Maintable");
   1.620 +    if (m_pMaintable == NULL)   // Sanity check
   1.621 +        throw Genexcept("Main window table creation failed.");
   1.622 +    m_pMaintable->setNumCols(TITRAQ_IDXTAIL);
   1.623 +    m_pMaintable->setDirty(false);              // Reset data to clean state
   1.624 +    m_pMaintable->setReadOnly(true);                    // Table is read only
   1.625 +    m_pMaintable->setColumnMovingEnabled(false);        // Ctrl-drag disabled
   1.626 +    m_pMaintable->setSelectionMode(QTable::MultiRow);   // Multi row selection
   1.627 +    m_pMaintable->setFocusStyle(QTable::FollowStyle);   // How cells are drawn
   1.628 +    m_pMaintable->setLeftMargin(0);             // Get rid of the vertical header
   1.629 +    m_pMaintable->verticalHeader()->hide();     // by hiding it with a margin of 0
   1.630 +    m_pMaintable->horizontalHeader()->setResizeEnabled(true);
   1.631 +    m_pMaintable->horizontalHeader()->setClickEnabled(true); // Allow click signals
   1.632 +    m_pMaintable->horizontalHeader()->setTracking(false); // No continuous tracking
   1.633 +    m_pMaintable->setColumnStretchable(TITRAQ_IDXTAIL - 1, true);
   1.634 +
   1.635 +    // Allow for user determined data sorting and use saved values
   1.636 +    m_pMaintable->setSortcol((int)m_pPrefs->getNumber(TITRAQ_PREFSORTCOL, TITRAQ_DEFSORTCOL));
   1.637 +    m_pMaintable->setSortdir(m_pPrefs->getBool(TITRAQ_PREFSORTDIR, TITRAQ_DEFSORTDIR));
   1.638 +    m_pMaintable->setSorting(true);
   1.639 +
   1.640 +    // Table header row
   1.641 +    m_pTablehead = m_pMaintable->horizontalHeader();
   1.642 +    m_pMaintable->setHScrollBarMode(QScrollView::AlwaysOff);
   1.643 +    m_pTablehead->setLabel(TITRAQ_IDXSTATUS, QObject::trUtf8("Stat"),
   1.644 +        m_pPrefs->getNumber(TITRAQ_PREFSTATCOLWIDTH, TITRAQ_DEFSTATCOLWIDTH));
   1.645 +    m_pMaintable->setColumnReadOnly (TITRAQ_IDXSTATUS, true);
   1.646 +    m_pTablehead->setLabel(TITRAQ_IDXLINE, QObject::trUtf8("Line"),
   1.647 +        m_pPrefs->getNumber(TITRAQ_PREFLCOLWIDTH, TITRAQ_DEFLCOLWIDTH));
   1.648 +    m_pMaintable->setColumnReadOnly (TITRAQ_IDXLINE, true);
   1.649 +    m_pTablehead->setLabel(TITRAQ_IDXUSER, QObject::trUtf8("User"),
   1.650 +        m_pPrefs->getNumber(TITRAQ_PREFUCOLWIDTH, TITRAQ_DEFUCOLWIDTH));
   1.651 +    m_pTablehead->setLabel(TITRAQ_IDXGUID, QObject::trUtf8("GUID"),
   1.652 +        m_pPrefs->getNumber(TITRAQ_PREFGCOLWIDTH, TITRAQ_DEFGCOLWIDTH));
   1.653 +    m_pMaintable->setColumnReadOnly (TITRAQ_IDXGUID, true);
   1.654 +    m_pTablehead->setLabel(TITRAQ_IDXCRC, QObject::trUtf8("CRC"),
   1.655 +        m_pPrefs->getNumber(TITRAQ_PREFCCOLWIDTH, TITRAQ_DEFCCOLWIDTH));
   1.656 +    m_pMaintable->setColumnReadOnly (TITRAQ_IDXCRC, true);
   1.657 +    m_pTablehead->setLabel(TITRAQ_IDXREV, QObject::trUtf8("Rev"),
   1.658 +        m_pPrefs->getNumber(TITRAQ_PREFREVCOLWIDTH, TITRAQ_DEFREVCOLWIDTH));
   1.659 +    m_pMaintable->setColumnReadOnly (TITRAQ_IDXREV, true);
   1.660 +    m_pTablehead->setLabel(TITRAQ_IDXDATE, QObject::trUtf8("Date"),
   1.661 +        m_pPrefs->getNumber(TITRAQ_PREFDCOLWIDTH, TITRAQ_DEFDCOLWIDTH));
   1.662 +    m_pTablehead->setLabel(TITRAQ_IDXSTART, QObject::trUtf8("Begin"),
   1.663 +        m_pPrefs->getNumber(TITRAQ_PREFSTARTCOLWIDTH, TITRAQ_DEFSTARTCOLWIDTH));
   1.664 +    m_pTablehead->setLabel(TITRAQ_IDXFINISH, QObject::trUtf8("End"),
   1.665 +        m_pPrefs->getNumber(TITRAQ_PREFFCOLWIDTH, TITRAQ_DEFFCOLWIDTH));
   1.666 +    m_pTablehead->setLabel(TITRAQ_IDXAMOUNT, QObject::trUtf8("Amount"),
   1.667 +        m_pPrefs->getNumber(TITRAQ_PREFACOLWIDTH, TITRAQ_DEFACOLWIDTH));
   1.668 +    m_pTablehead->setLabel(TITRAQ_IDXTASK, QObject::trUtf8("Task"),
   1.669 +        m_pPrefs->getNumber(TITRAQ_PREFTCOLWIDTH, TITRAQ_DEFTCOLWIDTH));
   1.670 +    m_pTablehead->setLabel(TITRAQ_IDXREMARK, QObject::trUtf8("Remark"));
   1.671 +
   1.672 +    m_pPackagelayout->addWidget(m_pMaintable);  // Finally add the damn table
   1.673 +
   1.674 +    // Table update signals
   1.675 +    connect(m_pMaintable, SIGNAL(currentChanged(int, int)), SLOT(updEdit(int, int)));
   1.676 +    connect(m_pMaintable, SIGNAL(clicked(int, int, int, const QPoint&)), SLOT(onClick(int, int, int, const QPoint&)));
   1.677 +    connect(m_pMaintable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), SLOT(inplaceEdit(int, int, int, const QPoint&)));
   1.678 +    connect(m_pTablehead, SIGNAL(sizeChange(int, int, int)), SLOT(updSizes(int, int, int)));
   1.679 +    connect(m_pMaintable, SIGNAL(textEdited(int, int)), SLOT(dataChanged(int, int)));
   1.680 +    connect(m_pMaintable, SIGNAL(valueChanged(int, int)), SLOT(dataChanged(int, int)));
   1.681 +}
   1.682 +
   1.683 +//
   1.684 +// Construct the bottom edit widgets
   1.685 +//
   1.686 +void Titraqform::setupEditlay(void)
   1.687 +{
   1.688 +//    QSpacerItem Pad(TITRAQ_SPACING / 2, 0, QSizePolicy::Fixed);
   1.689 +//    m_pEditlayout->addWidget(&Pad); // Padd left side of control layout
   1.690 +
   1.691 +    // Make the status edit
   1.692 +    m_pStatusedit = new QLabel(m_pCenframe, "Status");
   1.693 +    if (m_pStatusedit == NULL) // Sanity check
   1.694 +        throw Genexcept("Main window status edit creation failed.");
   1.695 +    m_pStatusedit->setPixmap(QPixmap(s_kpcStatvoid_xpm));   // Placeholder
   1.696 +
   1.697 +
   1.698 +    // Whatsthis info for the item status edit
   1.699 +    const char *kszStatustext = "The <em>item status</em> shows a green "
   1.700 +                                "symbol for valid entries, a yellow symbol "
   1.701 +                                "for warning, and a red symbol for flawed entries.";
   1.702 +    QWhatsThis::add(m_pStatusedit, kszStatustext);
   1.703 +    QToolTip::add(m_pStatusedit, trUtf8("Status Indicator"));
   1.704 +    m_pEditlayout->addWidget(m_pStatusedit);  // Finally add the item status edit
   1.705 +
   1.706 +    // Make the line number edit
   1.707 +    m_pLineedit = new QLineEdit(m_pCenframe, "Lineno");
   1.708 +    if (m_pLineedit == NULL) // Sanity check
   1.709 +        throw Genexcept("Main window line number edit creation failed.");
   1.710 +    m_pLineedit->setFrameShape(QLineEdit::LineEditPanel);
   1.711 +    m_pLineedit->setFrameShadow(QLineEdit::Sunken);
   1.712 +    m_pLineedit->setFrame(true);
   1.713 +    m_pLineedit->setReadOnly(true);
   1.714 +    m_pLineedit->setEnabled(false);
   1.715 +    m_pLineedit->setAlignment(Qt::AlignRight);
   1.716 +
   1.717 +    // Whatsthis info for the line number edit
   1.718 +    const char *kszLinenotext = "The <em>line number</em> helps identify "
   1.719 +                                "an entry when a warning or error message "
   1.720 +                                "appears.";
   1.721 +    QWhatsThis::add(m_pLineedit, kszLinenotext);
   1.722 +    QToolTip::add(m_pLineedit, trUtf8("Line Number"));
   1.723 +    m_pEditlayout->addWidget(m_pLineedit);  // Finally add the line number edit
   1.724 +
   1.725 +    // Make the user edit
   1.726 +    m_pUseredit = new QLineEdit(m_pCenframe, "User");
   1.727 +    if (m_pUseredit == NULL) // Sanity check
   1.728 +        throw Genexcept("Main window user edit creation failed.");
   1.729 +    m_pUseredit->setFrameShape(QLineEdit::LineEditPanel);
   1.730 +    m_pUseredit->setFrameShadow(QLineEdit::Sunken);
   1.731 +    m_pUseredit->setFrame(true);
   1.732 +    m_pUseredit->setReadOnly(false);
   1.733 +    m_pUseredit->setEnabled(false);
   1.734 +
   1.735 +    // Whatsthis info for the user edit
   1.736 +    const char *kszUsertext = "Edit the <em>user name</em> by clicking "
   1.737 +                              "on this control and typing the user name "
   1.738 +                              "you want to account.";
   1.739 +    QWhatsThis::add(m_pUseredit, kszUsertext);
   1.740 +    QToolTip::add(m_pUseredit, trUtf8("User Name"));
   1.741 +    m_pEditlayout->addWidget(m_pUseredit);  // Finally add the user edit
   1.742 +
   1.743 +    // Make the GUID edit
   1.744 +    m_pGuidedit = new QLineEdit(m_pCenframe, "Guid");
   1.745 +    if (m_pGuidedit == NULL) // Sanity check
   1.746 +        throw Genexcept("Main window GUID edit creation failed.");
   1.747 +    m_pGuidedit->setFrameShape(QLineEdit::LineEditPanel);
   1.748 +    m_pGuidedit->setFrameShadow(QLineEdit::Sunken);
   1.749 +    m_pGuidedit->setFrame(true);
   1.750 +    m_pGuidedit->setReadOnly(true);
   1.751 +    m_pGuidedit->setEnabled(false);
   1.752 +
   1.753 +    // Whatsthis info for the GUID edit
   1.754 +    const char *kszGuidtext = "Edit the <em>GUID</em> by clicking "
   1.755 +                              "on this control and typing the GUID "
   1.756 +                              "corresponding to this account item.";
   1.757 +    QWhatsThis::add(m_pGuidedit, kszGuidtext);
   1.758 +    QToolTip::add(m_pGuidedit, trUtf8("GUID"));
   1.759 +    m_pEditlayout->addWidget(m_pGuidedit);  // Finally add the GUID edit
   1.760 +
   1.761 +    // Make the CRC edit
   1.762 +    m_pCrcedit = new QLineEdit(m_pCenframe, "Crc");
   1.763 +    if (m_pCrcedit == NULL) // Sanity check
   1.764 +        throw Genexcept("Main window CRC edit creation failed.");
   1.765 +    m_pCrcedit->setFrameShape(QLineEdit::LineEditPanel);
   1.766 +    m_pCrcedit->setFrameShadow(QLineEdit::Sunken);
   1.767 +    m_pCrcedit->setFrame(true);
   1.768 +    m_pCrcedit->setReadOnly(true);
   1.769 +    m_pCrcedit->setEnabled(false);
   1.770 +
   1.771 +    // Whatsthis info for the CRC edit
   1.772 +    const char *kszCrctext = "Edit the <em>CRC</em> by clicking "
   1.773 +                             "on this control and typing the new "
   1.774 +                             "value for this account item.";
   1.775 +    QWhatsThis::add(m_pCrcedit, kszCrctext);
   1.776 +    QToolTip::add(m_pCrcedit, trUtf8("CRC"));
   1.777 +    m_pEditlayout->addWidget(m_pCrcedit);  // Finally add the CRC edit
   1.778 +
   1.779 +    // Make the revision edit
   1.780 +    m_pRevedit = new QLineEdit(m_pCenframe, "Revision");
   1.781 +    if (m_pRevedit == NULL) // Sanity check
   1.782 +        throw Genexcept("Main window revision edit creation failed.");
   1.783 +    m_pRevedit->setFrameShape(QLineEdit::LineEditPanel);
   1.784 +    m_pRevedit->setFrameShadow(QLineEdit::Sunken);
   1.785 +    m_pRevedit->setFrame(true);
   1.786 +    m_pRevedit->setReadOnly(true);
   1.787 +    m_pRevedit->setEnabled(false);
   1.788 +
   1.789 +    // Whatsthis info for the revision edit
   1.790 +    const char *kszRevtext = "Edit the <em>revision</em> by clicking "
   1.791 +                             "on this control and typing the new value "
   1.792 +                             "for this account type.";
   1.793 +    QWhatsThis::add(m_pRevedit, kszRevtext);
   1.794 +    QToolTip::add(m_pRevedit, trUtf8("Revision"));
   1.795 +    m_pEditlayout->addWidget(m_pRevedit);  // Finally add the revision edit
   1.796 +
   1.797 +    // Make the date selector
   1.798 +    m_pDateedit = new Daydatedit(QDate::currentDate(), m_pCenframe, "Date");
   1.799 +    if (m_pDateedit == NULL)                                        // Sanity check
   1.800 +        throw Genexcept("Main window date edit creation failed.");  // Spew errors
   1.801 +
   1.802 +    // Configure attributes
   1.803 +    m_pDateedit->setOrder(QDateEdit::YMD);
   1.804 +    m_pDateedit->setAutoAdvance(true);
   1.805 +    m_pDateedit->setSeparator(trUtf8("-"));
   1.806 +    m_pDateedit->setEnabled(false);
   1.807 +
   1.808 +    // Whatsthis info for the date editor
   1.809 +    const char *kszDateedit = "Edit the <em>task date</em> by clicking on "
   1.810 +                              "the year, month, or day, and then changing their "
   1.811 +                              "values with the arrow buttons.";
   1.812 +    QWhatsThis::add(m_pDateedit, kszDateedit);
   1.813 +    QToolTip::add(m_pDateedit, trUtf8("Task Date"));
   1.814 +    m_pEditlayout->addWidget(m_pDateedit);                          // Finally add the date editor
   1.815 +
   1.816 +    // Make the start time selector
   1.817 +    m_pStarttime = new QTimeEdit(m_pCenframe, "StartTime");
   1.818 +    if (m_pStarttime == NULL)                                       // Sanity check
   1.819 +        throw Genexcept("Main window start time creation failed."); // Spew errors
   1.820 +
   1.821 +    // Configure attributes
   1.822 +    m_pStarttime->setDisplay(QTimeEdit::Hours | QTimeEdit::Minutes);
   1.823 +    m_pStarttime->setAutoAdvance(true);
   1.824 +    m_pStarttime->setEnabled(false);
   1.825 +
   1.826 +    // Whatsthis info for the time editor
   1.827 +    const char *kszStarttime = "Edit the <em>task starting time</em> by clicking on "
   1.828 +                               "the hour and minute, and then changing their "
   1.829 +                               "values with the arrow buttons.";
   1.830 +    QWhatsThis::add(m_pStarttime, kszStarttime);
   1.831 +    QToolTip::add(m_pStarttime, trUtf8("Task Starting Time"));
   1.832 +    m_pEditlayout->addWidget(m_pStarttime);                         // Finally add the start editor
   1.833 +
   1.834 +    // Make the end time selector
   1.835 +    m_pEndtime = new QTimeEdit(m_pCenframe, "EndTime");
   1.836 +    if (m_pEndtime == NULL)                                         // Sanity check
   1.837 +        throw Genexcept("Main window end time creation failed.");   // Spew errors
   1.838 +
   1.839 +    // Configure attributes
   1.840 +    m_pEndtime->setDisplay(QTimeEdit::Hours | QTimeEdit::Minutes);
   1.841 +    m_pEndtime->setAutoAdvance(true);
   1.842 +    m_pEndtime->setEnabled(false);
   1.843 +
   1.844 +    // Whatsthis info for the time editor
   1.845 +    const char *kszEndtime = "Edit the <em>task ending time</em> by clicking on "
   1.846 +                             "the hour and minute, and then changing their "
   1.847 +                             "values with the arrow buttons.";
   1.848 +    QWhatsThis::add(m_pEndtime, kszEndtime);
   1.849 +    QToolTip::add(m_pEndtime, trUtf8("Task Ending Time"));
   1.850 +    m_pEditlayout->addWidget(m_pEndtime);                           // Finally add the end editor
   1.851 +
   1.852 +//    // Make the total time amount selector
   1.853 +//    m_pAmount = new QTimeEdit(m_pCenframe, "TotalAmount");
   1.854 +//    if (m_pAmount == NULL)                                          // Sanity check
   1.855 +//        throw Genexcept("Main window amount creation failed.");     // Spew errors
   1.856 +//
   1.857 +//    // Configure attributes
   1.858 +//    m_pAmount->setDisplay(QTimeEdit::Hours | QTimeEdit::Minutes);
   1.859 +//    m_pAmount->setAutoAdvance(true);
   1.860 +//    m_pAmount->setEnabled(false);
   1.861 +
   1.862 +    // Make the amount selector
   1.863 +    m_pAmount = new ASTimeEdit(m_pCenframe, "TotalAmount");
   1.864 +    if (m_pAmount == NULL)                                      // Sanity check
   1.865 +        throw Genexcept("Main window amount creation failed."); // Spew errors
   1.866 +
   1.867 +    // Whatsthis info for the amount editor
   1.868 +    const char *kszAmount = "Edit the <em>task amount</em> by clicking on "
   1.869 +                            "the amount, and then changing its "
   1.870 +                            "value with the arrow buttons.";
   1.871 +    QWhatsThis::add(m_pAmount, kszAmount);
   1.872 +    QToolTip::add(m_pAmount, trUtf8("Task Amount"));
   1.873 +    m_pAmount->setEnabled(false);           // Don't enable until it's ready
   1.874 +    m_pEditlayout->addWidget(m_pAmount);    // Finally add the amount editor
   1.875 +
   1.876 +    // Construct a stringlist just to hold task values
   1.877 +    m_pTaskentries = new QStringList;
   1.878 +    if (m_pTaskentries == NULL) // Sanity check
   1.879 +        throw Genexcept("Main window task entries creation failed.");
   1.880 +
   1.881 +    // Populate the stringlist with fresh accounts, taken from filename in prefs
   1.882 +    QString Asdir = m_pPrefs->getString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS);
   1.883 +    if (Asdir.startsWith(TITRAQ_HOMEDIRTOK))
   1.884 +        Asdir = QDir::homeDirPath() + Asdir.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1);
   1.885 +    QFile Filetemp(Asdir);
   1.886 +    this->loadAccounts(Filetemp);   // Load account helper method
   1.887 +
   1.888 +    // Make the combobox task edit
   1.889 +    m_pTasks = new QComboBox(true, m_pCenframe, "Tasks");
   1.890 +    if (m_pTasks == NULL)   // Sanity check
   1.891 +        throw Genexcept("Main window task edit creation failed.");
   1.892 +    m_pTasks->insertStringList(*m_pTaskentries);
   1.893 +    m_pTasks->setCurrentText(NULL);
   1.894 +    m_pTasks->setSizeLimit(TITRAQ_ACCTBOXHEIGHT);
   1.895 +    m_pTasks->setAutoCompletion(true);
   1.896 +    m_pTasks->setDuplicatesEnabled(false);
   1.897 +    m_pTasks->setEnabled(false);
   1.898 +//    m_pTasks->setEditable(false);   // Only idiots define noneditable and autocompletion
   1.899 +
   1.900 +    // Add an auto scroll bar if possible under current GUI style
   1.901 +    if (m_pTasks->listBox()) {  // Motif style has no list box
   1.902 +        int nPopupwidth = m_pTasks->listBox()->maxItemWidth();
   1.903 +        nPopupwidth += m_pTasks->listBox()->horizontalScrollBar()->height();
   1.904 +        m_pTasks->listBox()->setFixedWidth(nPopupwidth);
   1.905 +        m_pTasks->listBox()->setHScrollBarMode(QScrollView::Auto);
   1.906 +        m_pTasks->listBox()->sort();
   1.907 +    }
   1.908 +
   1.909 +    // Whatsthis info for the task editor
   1.910 +    const char *kszTasktext = "Choose a <em>task account</em> by clicking on "
   1.911 +                              "this box, and choosing whichever item most "
   1.912 +                              "closely resembles your task.";
   1.913 +    QWhatsThis::add(m_pTasks, kszTasktext);
   1.914 +    QToolTip::add(m_pTasks, trUtf8("Task Selector"));
   1.915 +    m_pEditlayout->addWidget(m_pTasks); // Finally add the task edit
   1.916 +
   1.917 +    // Make the Remark line
   1.918 +    m_pRemark = new QLineEdit(m_pCenframe, "Remark");
   1.919 +    if (m_pRemark == NULL)  // Sanity check
   1.920 +        throw Genexcept("Main window remark line creation failed.");
   1.921 +    m_pRemark->setFrameShape(QLineEdit::LineEditPanel);
   1.922 +    m_pRemark->setFrameShadow(QLineEdit::Sunken);
   1.923 +    m_pRemark->setFrame(true);
   1.924 +    m_pRemark->setReadOnly(false);
   1.925 +    m_pRemark->setEnabled(false);
   1.926 +
   1.927 +    // Whatsthis info for the remark line
   1.928 +    const char *kszRemarktext = "Edit the <em>task remarks</em> by clicking on "
   1.929 +                                "this line control and typing the remarks you "
   1.930 +                                "have about the task.";
   1.931 +    QWhatsThis::add(m_pRemark, kszRemarktext);
   1.932 +    QToolTip::add(m_pRemark, trUtf8("Remark Line"));
   1.933 +    m_pEditlayout->addWidget(m_pRemark);    // Finally add the remark line
   1.934 +
   1.935 +    // Start edit controls off at right size
   1.936 +    this->updSizes(TITRAQ_IDXALLCTRLS, -1, -1);
   1.937 +
   1.938 +    // Validate data just as it is being entered
   1.939 +    connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(validateRow(void)));
   1.940 +    connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void)));
   1.941 +    connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void)));
   1.942 +    connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void)));
   1.943 +    connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(validateRow(void)));
   1.944 +    connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(validateRow(void)));
   1.945 +
   1.946 +    // Signals sent between table cells and corresponding edit control widgets
   1.947 +    connect(m_pLineedit, SIGNAL(textChanged(const QString &)), SLOT(updateLine(const QString &)));
   1.948 +    connect(m_pUseredit, SIGNAL(textChanged(const QString &)), SLOT(updateUser(const QString &)));
   1.949 +    connect(m_pGuidedit, SIGNAL(textChanged(const QString &)), SLOT(updateGuid(const QString &)));
   1.950 +    connect(m_pCrcedit, SIGNAL(textChanged(const QString &)), SLOT(updateCrc(const QString &)));
   1.951 +    connect(m_pRevedit, SIGNAL(textChanged(const QString &)), SLOT(updateRev(const QString &)));
   1.952 +    connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(updateDate(const QDate &)));
   1.953 +    connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(updateStart(const QTime &)));
   1.954 +    connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(updateFinish(const QTime &)));
   1.955 +    connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(updateAmount(const QTime &)));
   1.956 +    connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(updateTask(const QString &)));
   1.957 +    connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(updateRemark(const QString &)));
   1.958 +
   1.959 +    // Correctly update checksum and revision fields also
   1.960 +    connect(m_pUseredit, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void)));
   1.961 +    connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(calcCrc(void)));
   1.962 +    connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void)));
   1.963 +    connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void)));
   1.964 +    connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void)));
   1.965 +    connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void)));
   1.966 +    connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void)));
   1.967 +}
   1.968 +
   1.969 +//
   1.970 +// Arrange and configure columns
   1.971 +//
   1.972 +void Titraqform::setupColumns(void)
   1.973 +{
   1.974 +    // Handle column view handling presets and defaults
   1.975 +    if (!m_pPrefs->getBool(TITRAQ_PREFSTATCOLON, TITRAQ_DEFSTATCOLON))
   1.976 +        showStatcol();
   1.977 +    if (!m_pPrefs->getBool(TITRAQ_PREFLCOLON, TITRAQ_DEFLCOLON))
   1.978 +        showLinecol();
   1.979 +    if (!m_pPrefs->getBool(TITRAQ_PREFUCOLON, TITRAQ_DEFUCOLON))
   1.980 +        showUsercol();
   1.981 +    if (!m_pPrefs->getBool(TITRAQ_PREFGCOLON, TITRAQ_DEFGCOLON))
   1.982 +        showGuidcol();
   1.983 +    if (!m_pPrefs->getBool(TITRAQ_PREFCCOLON, TITRAQ_DEFCCOLON))
   1.984 +        showCrccol();
   1.985 +    if (!m_pPrefs->getBool(TITRAQ_PREFREVCOLON, TITRAQ_DEFREVCOLON))
   1.986 +        showRevcol();
   1.987 +    if (!m_pPrefs->getBool(TITRAQ_PREFDCOLON, TITRAQ_DEFDCOLON))
   1.988 +        showDatecol();
   1.989 +    if (!m_pPrefs->getBool(TITRAQ_PREFSTARTCOLON, TITRAQ_DEFSTARTCOLON))
   1.990 +        showStartcol();
   1.991 +    if (!m_pPrefs->getBool(TITRAQ_PREFFCOLON, TITRAQ_DEFFCOLON))
   1.992 +        showFinishcol();
   1.993 +    if (!m_pPrefs->getBool(TITRAQ_PREFACOLON, TITRAQ_DEFACOLON))
   1.994 +        showAmountcol();
   1.995 +    if (!m_pPrefs->getBool(TITRAQ_PREFTCOLON, TITRAQ_DEFTCOLON))
   1.996 +        showTaskcol();
   1.997 +    if (!m_pPrefs->getBool(TITRAQ_PREFREMCOLON, TITRAQ_DEFREMCOLON))
   1.998 +        showRemarkcol();
   1.999 +
  1.1000 +    // Handle tool bar view handling presets and defaults
  1.1001 +    if (!m_pPrefs->getBool(TITRAQ_PREFFILEBAR, TITRAQ_DEFFILEBAR)) {
  1.1002 +        m_pFiletools->hide();
  1.1003 +        m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR), false);
  1.1004 +    }
  1.1005 +    if (!m_pPrefs->getBool(TITRAQ_PREFEDITBAR, TITRAQ_DEFEDITBAR)) {
  1.1006 +        m_pEdittools->hide();
  1.1007 +        m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR), false);
  1.1008 +    }
  1.1009 +    if (!m_pPrefs->getBool(TITRAQ_PREFVIEWBAR, TITRAQ_DEFVIEWBAR)) {
  1.1010 +        m_pViewtools->hide();
  1.1011 +        m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR), false);
  1.1012 +    }
  1.1013 +    if (!m_pPrefs->getBool(TITRAQ_PREFPREFBAR, TITRAQ_DEFPREFBAR)) {
  1.1014 +        m_pPrefstools->hide();
  1.1015 +        m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR), false);
  1.1016 +    }
  1.1017 +    if (!m_pPrefs->getBool(TITRAQ_PREFWHATBAR, TITRAQ_DEFWHATBAR)) {
  1.1018 +        m_pWhatstools->hide();
  1.1019 +        m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), false);
  1.1020 +    }
  1.1021 +}
  1.1022 +
  1.1023 +//
  1.1024 +// [En|dis]able most ui pieces to suit or restrict user
  1.1025 +//
  1.1026 +void Titraqform::enableIface(bool bTurned)
  1.1027 +{
  1.1028 +    // FIXME: Does not belong here, so relocate
  1.1029 +    if (bTurned)                       // Turn off the interface
  1.1030 +        m_pDateedit->setDayfocus();     // Default focus is on day
  1.1031 +    else {                              // Turn on the interface
  1.1032 +        m_pMaintable->setNumRows(0);    // Remove table data
  1.1033 +        m_pStatusedit->setPixmap(QPixmap(s_kpcStatvoid_xpm));
  1.1034 +    }
  1.1035 +
  1.1036 +    // Enable or disable the widgets
  1.1037 +    m_pMaintable->setEnabled(bTurned);
  1.1038 +    m_pLineedit->setEnabled(bTurned);
  1.1039 +    m_pUseredit->setEnabled(bTurned);
  1.1040 +    m_pGuidedit->setEnabled(bTurned);
  1.1041 +    m_pCrcedit->setEnabled(bTurned);
  1.1042 +    m_pRevedit->setEnabled(bTurned);
  1.1043 +    m_pDateedit->setEnabled(bTurned);
  1.1044 +    m_pStarttime->setEnabled(bTurned);
  1.1045 +    m_pEndtime->setEnabled(bTurned);
  1.1046 +    m_pAmount->setEnabled(bTurned);
  1.1047 +    m_pTasks->setEnabled(bTurned);
  1.1048 +    m_pRemark->setEnabled(bTurned);
  1.1049 +
  1.1050 +    // Enable or disable the actions
  1.1051 +    m_pFilesaveact->setEnabled(bTurned);
  1.1052 +    m_pFilesaveasact->setEnabled(bTurned);
  1.1053 +    m_pFilecloseact->setEnabled(bTurned);
  1.1054 +    m_pAddrowact->setEnabled(bTurned);
  1.1055 +    m_pDelrowact->setEnabled(bTurned);
  1.1056 +    m_pRefreshact->setEnabled(bTurned);
  1.1057 +    m_pCutact->setEnabled(bTurned);
  1.1058 +    m_pCopyact->setEnabled(bTurned);
  1.1059 +    m_pPasteact->setEnabled(bTurned);
  1.1060 +    m_pReportact->setEnabled(bTurned);
  1.1061 +#if defined HAVE_MICO || defined HAVE_ESOAP
  1.1062 +    if (bTurned)
  1.1063 +        m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON)
  1.1064 +            | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON));
  1.1065 +    else
  1.1066 +        m_pSyncact->setEnabled(false);
  1.1067 +#endif // defined HAVE_MICO || defined HAVE_ESOAP
  1.1068 +
  1.1069 +    // Unconditional settings
  1.1070 +    m_pMaintable->setDirty(false);                  // Reset to clean data
  1.1071 +}
  1.1072 +
  1.1073 +//
  1.1074 +// Parse command line arguments for an existing filename, and
  1.1075 +// open it to edit the intended (but optional) initial data
  1.1076 +//
  1.1077 +void Titraqform::loadInit(void)
  1.1078 +{
  1.1079 +    // If the user gives a filename argument to the shell, then open that file
  1.1080 +    int nNumargs = qApp->argc();    // Holds the number of cmd arguments
  1.1081 +    int nValid = 0;                 // Holds the return value
  1.1082 +    QFile Initial;                  // Initial event data file
  1.1083 +
  1.1084 +    if (nNumargs > 1) { // Warm up a nice cascade, to set my mind on four weeks of vacation
  1.1085 +        for (int nIter = 1; nIter < nNumargs; nIter++) {    // Salad in New Zealand
  1.1086 +            if (QChar(*qApp->argv()[nIter]) != '-') {       // Bunuelos in Colombia
  1.1087 +                try {
  1.1088 +                    this->setFilename(qApp->argv()[nIter]); // Store inital filename
  1.1089 +                    Initial.setName(*this->getFilename());  // Initial file to load
  1.1090 +                    if (Initial.exists(*getFilename()) && validateData(Initial)) {
  1.1091 +                        this->loadData(Initial);            // Pass to helper method
  1.1092 +                        enableIface(true);                  // Turn on the lights
  1.1093 +                        m_pStatbar->message(trUtf8("Loaded document ") + *this->getFilename());
  1.1094 +                    }
  1.1095 +                    else // The inital file name does not correspond to a file
  1.1096 +                        m_pStatbar->message(trUtf8(QString("The file ") + *this->getFilename() + QString(" does not exist.")));
  1.1097 +                }
  1.1098 +                catch (Genexcept& Genex) {
  1.1099 +                    Genex.reportErr();
  1.1100 +                }
  1.1101 +            }
  1.1102 +        }
  1.1103 +    }
  1.1104 +    else
  1.1105 +        m_pStatbar->message(trUtf8("Ready"));   // Signal a ready condition
  1.1106 +}

mercurial