OSSP CVS Repository

ossp - ossp-pkg/as/as-gui/as_assist.cpp 1.37
Not logged in
[Honeypot]  [Browse]  [Directory]  [Home]  [Login
[Reports]  [Search]  [Ticket]  [Timeline
  [Raw

ossp-pkg/as/as-gui/as_assist.cpp 1.37
//
//  OSSP asgui - Accounting system graphical user interface
//  Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/)
//  Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/)
//  Copyright (c) 2002-2003 Ralf S. Engelschall <rse@engelschall.com>
//  Copyright (c) 2002-2003 Michael Schloh von Bennewitz <michael@schloh.com>
//
//  This file is part of OSSP asgui, an accounting system graphical user
//  interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
//
//  Permission to use, copy, modify, and distribute this software for
//  any purpose with or without fee is hereby granted, provided that
//  the above copyright notice and this permission notice appear in all
//  copies.
//
//  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
//  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
//  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
//  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
//  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
//  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
//  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
//  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
//  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
//  SUCH DAMAGE.
//
//  titassist.cpp: ISO C++ implementation
//

// Qt style headers
#include <qcdestyle.h>
#include <qsgistyle.h>
#include <qmotifstyle.h>
#include <qmotifplusstyle.h>
#include <qplatinumstyle.h>
#include <qwindowsstyle.h>

// Qt general headers
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qstringlist.h>
#include <qcombobox.h>
#include <qlistbox.h>
#include <qcursor.h>

// User interface
#include "titraq.h"             // Main classes
#include "titrex.h"             // Exception classes
#include "titamount.h"          // AmountBox class

// Icon pixel maps
#include "gfx/filenew.xpm"      // static const char *s_kpcFilenew_xpm[]
#include "gfx/fileopen.xpm"     // static const char *s_kpcFileopen_xpm[]
#include "gfx/filesave.xpm"     // static const char *s_kpcFilesave_xpm[]
#include "gfx/cut.xpm"          // static const char *s_kpcCut_xpm[]
#include "gfx/copy.xpm"         // static const char *s_kpcCopy_xpm[]
#include "gfx/paste.xpm"        // static const char *s_kpcPaste_xpm[]
#include "gfx/rowadd.xpm"       // static const char *s_kpcRowadd_xpm[]
#include "gfx/rowdel.xpm"       // static const char *s_kpcRowdel_xpm[]
#include "gfx/osspicon.xpm"     // static const char *s_kpcOsspicon_xpm[]
#include "gfx/whatsthis.xpm"    // static const char *s_kpcWhatsthis_xpm[]


//
// Construct the preferences
//
void Titraqform::setupPrefs(void)
{
    m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
    if (!m_pPrefs->fileState()) { // No file was found, so assume a null state
        m_pPrefs->setString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
        m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
        m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);
        m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG);
        m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG);
        m_pPrefs->flush();  // Write the new conf file
        QTextStream cerr(stderr, IO_WriteOnly);
        cerr << trUtf8("Created new preferences file ") << trUtf8(TITRAQ_PREFNAME) << endl;
    }

    // Use the preferred configuration values to initialize titraq
    switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) {
    case TITRAQ_STYLECDE:
        qApp->setStyle(new QCDEStyle);
        break;
    case TITRAQ_STYLESGI:
        qApp->setStyle(new QSGIStyle);
        break;
    case TITRAQ_STYLEMOTIF:
        qApp->setStyle(new QMotifStyle);
        break;
    case TITRAQ_STYLEMPLUS:
        qApp->setStyle(new QMotifPlusStyle);
        break;
    case TITRAQ_STYLEPLAT:
        qApp->setStyle(new QPlatinumStyle);
        break;
    case TITRAQ_STYLEMSOFT:
        qApp->setStyle(new QWindowsStyle);
        break;
    default:
        qApp->setStyle(new QCDEStyle);
        break;
    }
}

//
// Construct various actions
//
void Titraqform::setupActions(void)
{
    // First associate the graphics with MIME types
    QMimeSourceFactory::defaultFactory()->setPixmap("osspicon", QPixmap(s_kpcOsspicon_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("filenew", QPixmap(s_kpcFilenew_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", QPixmap(s_kpcFileopen_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("filesave", QPixmap(s_kpcFilesave_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("cut", QPixmap(s_kpcCut_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("copy", QPixmap(s_kpcCopy_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("paste", QPixmap(s_kpcPaste_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("rowadd", QPixmap(s_kpcRowadd_xpm));
    QMimeSourceFactory::defaultFactory()->setPixmap("rowdel", QPixmap(s_kpcRowdel_xpm));

    // File new action
    m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New..."), CTRL+Key_N, this, "New");
    if (m_pFilenewact == NULL) // Sanity check
        throw Genexcept("Main window file new action creation failed.");
    connect(m_pFilenewact, SIGNAL(activated()), this, SLOT(newDoc()));
    const char *kszFilenewtext = "<p><img source=\"filenew\"> "
                                        "Click this button to make a "
                                        "<em>blank file</em>. You can also "
                                        "select the <b>New</b> command from "
                                        "the <b>File</b> menu.</p>";
    m_pFilenewact->setWhatsThis(kszFilenewtext);

    // File open action
    m_pFileopenact = new QAction(trUtf8("Open File"), QPixmap(s_kpcFileopen_xpm), trUtf8("&Open..."), CTRL+Key_O, this, "Open");
    if (m_pFileopenact == NULL) // Sanity check
        throw Genexcept("Main window file open action creation failed.");
    connect(m_pFileopenact, SIGNAL(activated()), this, SLOT(chooseFile()));
    const char *kszFileopentext = "<p><img source=\"fileopen\"> "
                                  "Click this button to open a "
                                  "<em>new file</em>. You can also select "
                                  "the <b>Open</b> command from the "
                                  "<b>File</b> menu.</p>";
    m_pFileopenact->setWhatsThis(kszFileopentext);

    // File save current action
    m_pFilesaveact = new QAction(trUtf8("Save File"), QPixmap(s_kpcFilesave_xpm), trUtf8("&Save"), CTRL+Key_S, this, "Save");
    if (m_pFilesaveact == NULL) // Sanity check
        throw Genexcept("Main window file save action creation failed.");
    connect(m_pFilesaveact, SIGNAL(activated()), this, SLOT(saveFile()));
    const char *kszFilesavetext = "<p><img source=\"filesave\"> "
                                  "Click this button to <em>save</em> "
                                  "the file you are editing. You will be "
                                  "prompted for a file name. You can also "
                                  "select the<b> Save</b> command from "
                                  "the <b>File</b> menu.</p>";
    m_pFilesaveact->setWhatsThis(kszFilesavetext);

    // File save selected action
    m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &As..."), 0, this, "SaveAs");
    if (m_pFilesaveasact == NULL) // Sanity check
        throw Genexcept("Main window file save as action creation failed.");
    connect(m_pFilesaveasact, SIGNAL(activated()), this, SLOT(saveAs()));
    m_pFilesaveasact->setWhatsThis(kszFilesavetext);

    // File close current action
    m_pFilecloseact = new QAction(trUtf8("Close"), trUtf8("&Close"), CTRL+Key_W, this, "Close");
    if (m_pFilecloseact == NULL)    // Sanity check
        throw Genexcept("Main window file close action creation failed.");
    connect(m_pFilecloseact, SIGNAL(activated()), this, SLOT(close()));

    // File quit action
    m_pFilequitact = new QAction(trUtf8("Exit"), trUtf8("E&xit"), CTRL+Key_Q, this, "Exit");
    if (m_pFilequitact == NULL)     // Sanity check
        throw Genexcept("Main window file quit action creation failed.");
    connect(m_pFilequitact, SIGNAL(activated()), qApp, SLOT(quit()));

    // Cut action
    m_pCutact = new QAction(trUtf8("Cut"), QPixmap(s_kpcCut_xpm), trUtf8("&Cut"), 0, this, "Cut");
    if (m_pCutact == NULL)          // Sanity check
        throw Genexcept("Main window cut edit action creation failed.");
    connect(m_pCutact, SIGNAL(activated()), this, SLOT(cutEntry()));
    const char *kszCuttext = "<p><img source=\"cut\"> "
                                   "Click this button to cut an <em>entry</em>. "
                                   "You can also select the <b>Cut</b> command "
                                   "from the <b>Edit</b> menu.</p>";
    m_pCutact->setWhatsThis(kszCuttext);

    // Copy action
    m_pCopyact = new QAction(trUtf8("Copy"), QPixmap(s_kpcCopy_xpm), trUtf8("&Copy"), 0, this, "Copy");
    if (m_pCopyact == NULL)         // Sanity check
        throw Genexcept("Main window copy edit action creation failed.");
    connect(m_pCopyact, SIGNAL(activated()), this, SLOT(copyEntry()));
    const char *kszCopytext = "<p><img source=\"copy\"> "
                                   "Click this button to copy an <em>entry</em>. "
                                   "You can also select the <b>Copy</b> command "
                                   "from the <b>Edit</b> menu.</p>";
    m_pCopyact->setWhatsThis(kszCopytext);

    // Paste action
    m_pPasteact = new QAction(trUtf8("Paste"), QPixmap(s_kpcPaste_xpm), trUtf8("&Paste"), 0, this, "Paste");
    if (m_pPasteact == NULL)         // Sanity check
        throw Genexcept("Main window paste edit action creation failed.");
    connect(m_pPasteact, SIGNAL(activated()), this, SLOT(pasteEntry()));
    const char *kszPastetext = "<p><img source=\"paste\"> "
                                   "Click this button to paste an <em>entry</em>. "
                                   "You can also select the <b>Paste</b> command "
                                   "from the <b>Edit</b> menu.</p>";
    m_pPasteact->setWhatsThis(kszPastetext);

    // Add data row action
    m_pAddrowact = new QAction(trUtf8("Add Row"), QPixmap(s_kpcRowadd_xpm), trUtf8("&Add row"), 0, this, "Addrow");
    if (m_pAddrowact == NULL)       // Sanity check
        throw Genexcept("Main window add row action creation failed.");
    connect(m_pAddrowact, SIGNAL(activated()), this, SLOT(addEntry()));
    const char *kszAddrowtext = "<p><img source=\"rowadd\"> "
                                "Click this button to add a <em>new row</em>. "
                                "You can also select the <b>Add</b> command "
                                "from the <b>Edit</b> menu.</p>";
    m_pAddrowact->setWhatsThis(kszAddrowtext);

    // Delete data row action
    m_pDelrowact = new QAction(trUtf8("Delete Row"), QPixmap(s_kpcRowdel_xpm), trUtf8("&Delete row"), 0, this, "Delrow");
    if (m_pDelrowact == NULL)       // Sanity check
        throw Genexcept("Main window delete row action creation failed.");
    connect(m_pDelrowact, SIGNAL(activated()), this, SLOT(delEntry()));
    const char *kszDelrowtext = "<p><img source=\"rowdel\"> "
                                   "Click this button to delete a <em>row</em>. "
                                   "You can also select the <b>Delete</b> command "
                                   "from the <b>Edit</b> menu.</p>";
    m_pDelrowact->setWhatsThis(kszDelrowtext);
}

//
// Construct the menu bar
//
void Titraqform::setupMenubar(void)
{
    int nMenuid = 0;        // Used to store id during menu item creation

    m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow
    if (m_pMenubar == NULL) // Sanity check
        throw Genexcept("Main window menu bar nonexistant.");

    // Make an easter egg ;-)
    QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter Egg");

    // Construct and populate the file menu with actions
    QPopupMenu *pFilepopup = new QPopupMenu(this);
    if (pFilepopup == NULL) // Sanity check
        throw Genexcept("Main window file popup creation failed.");
    m_pMenubar->insertItem(trUtf8("&File"), pFilepopup);
    m_pFilenewact->addTo(pFilepopup);
    m_pFileopenact->addTo(pFilepopup);
    pFilepopup->insertSeparator();
    m_pFilecloseact->addTo(pFilepopup);
    pFilepopup->insertSeparator();
    m_pFilesaveact->addTo(pFilepopup);
    m_pFilesaveasact->addTo(pFilepopup);
    pFilepopup->insertSeparator();
    m_pFilequitact->addTo(pFilepopup);

    // Construct and populate the edit menu with subitems
    QPopupMenu *pEditpopup = new QPopupMenu(this);
    if (pEditpopup == NULL) // Sanity check
        throw Genexcept("Main window edit popup creation failed.");
    m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup);
    m_pCutact->addTo(pEditpopup);
    m_pCopyact->addTo(pEditpopup);
    m_pPasteact->addTo(pEditpopup);
    pEditpopup->insertSeparator();
    m_pAddrowact->addTo(pEditpopup);
    m_pDelrowact->addTo(pEditpopup);
    pEditpopup->insertSeparator();
    pEditpopup->insertItem("Preferences...", this, SLOT(configPrefs()));

    // Construct the view menu and submenus
    m_pViewpopup = new QPopupMenu(this);
    m_pTbarspopup = new QPopupMenu(this);
    m_pColspopup = new QPopupMenu(this);

    // Give the new menus krass attributes
    m_pTbarspopup->insertTearOffHandle();
    m_pTbarspopup->setCheckable(true);
    m_pColspopup->insertTearOffHandle();
    m_pColspopup->setCheckable(true);

    // Major sanity check wrapped in one call
    if (!(m_pViewpopup && m_pTbarspopup && m_pColspopup))
        throw Genexcept("Main window view popups creation failed.");

    // Populate the view menu with subitems
    m_pMenubar->insertItem(trUtf8("&View"), m_pViewpopup);
    m_pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView()));
    nMenuid = m_pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView()));
    m_pViewpopup->setItemEnabled(nMenuid, false);
    m_pViewpopup->insertSeparator();
    m_pViewpopup->insertItem(trUtf8("&Toolbars"), m_pTbarspopup);
    nMenuid = m_pTbarspopup->insertItem(trUtf8("&File"), this, SLOT(showFilebar()));
    m_pTbarspopup->setItemChecked(nMenuid, true);
    nMenuid = m_pTbarspopup->insertItem(trUtf8("&Edit"), this, SLOT(showEditbar()));
    m_pTbarspopup->setItemChecked(nMenuid, true);
    nMenuid = m_pTbarspopup->insertItem(trUtf8("&Whats"), this, SLOT(showWhatsbar()));
    m_pTbarspopup->setItemChecked(nMenuid, true);
    m_pViewpopup->insertSeparator();
    m_pViewpopup->insertItem(trUtf8("&Columns"), m_pColspopup);
    nMenuid = m_pColspopup->insertItem(trUtf8("&Line number"), this, SLOT(showLinecol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&GUID"), this, SLOT(showGuidcol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&Date"), this, SLOT(showDatecol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&User"), this, SLOT(showUsercol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&Task"), this, SLOT(showTaskcol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&Start time"), this, SLOT(showStartcol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&Finish time"), this, SLOT(showFinishcol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&Amount time"), this, SLOT(showAmountcol()));
    m_pColspopup->setItemEnabled(nMenuid, false);
    nMenuid = m_pColspopup->insertItem(trUtf8("&Remark"), this, SLOT(showRemarkcol()));
    m_pColspopup->setItemEnabled(nMenuid, false);

    // Pad spacing to force help menu to appear far right
    m_pMenubar->insertSeparator();

    // Construct and populate the help menu with subitems
    QPopupMenu *pHelppopup = new QPopupMenu(this);
    if (pHelppopup == NULL) // Sanity check
        throw Genexcept("Main window help popup creation failed.");
    m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup);
    pHelppopup->insertItem(trUtf8("&Contents"), this, SLOT(helpContents()), Key_F1);
    pHelppopup->insertSeparator();
    pHelppopup->insertItem(trUtf8("About &Titraq"), this, SLOT(aboutTitraq()));
    pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
    pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt()));
    pHelppopup->insertSeparator();
    pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
}

//
// Construct the file tool bar
//
void Titraqform::setupFiletools(void)
{
    // Construct and populate the file tool bar
    m_pFiletools = new QToolBar("Toolfile", this, DockTop);
    if (m_pFiletools == NULL)                   // Sanity check
        throw Genexcept("File tool bar creation failed.");
    m_pFiletools->setLabel(trUtf8("File Ops"));
    m_pFiletools->setOpaqueMoving(false);
    m_pFiletools->setCloseMode(QDockWindow::Never);
    m_pFilenewact->addTo(m_pFiletools);
    m_pFileopenact->addTo(m_pFiletools);
    m_pFilesaveact->addTo(m_pFiletools);

    // Construct and populate the edit tool bar
    m_pEdittools = new QToolBar("Tooledit", this, DockTop);
    if (m_pEdittools == NULL)                   // Sanity check
        throw Genexcept("Edit tool bar creation failed.");
    m_pEdittools->setLabel(trUtf8("Edit Ops"));
    m_pEdittools->setOpaqueMoving(false);
    m_pEdittools->setCloseMode(QDockWindow::Never);
    m_pCutact->addTo(m_pEdittools);
    m_pCopyact->addTo(m_pEdittools);
    m_pPasteact->addTo(m_pEdittools);
    m_pEdittools->addSeparator();
    m_pAddrowact->addTo(m_pEdittools);
    m_pDelrowact->addTo(m_pEdittools);

    // Construct and populate the lonely whatsthis tool bar
    m_pWhatstools = new QToolBar("Toolwhats", this, DockTop);
    if (m_pWhatstools == NULL)                  // Sanity check
        throw Genexcept("Whats this tool bar creation failed.");
    m_pWhatstools->setLabel(trUtf8("Whats this"));
    m_pWhatstools->setOpaqueMoving(false);
    m_pWhatstools->setCloseMode(QDockWindow::Never);
    QWhatsThis::whatsThisButton(m_pWhatstools); // Preconfigured whats this button
}

//
// Construct the central frame
//
void Titraqform::setupCentralwidget(void)
{
    // Create a central frame and associated layout for QMainWindow
    m_pCenframe = new QFrame(this, "Centralframe");
    if (m_pCenframe == NULL)    // Sanity check
        throw Genexcept("Main window central frame creation failed.");
    m_pCenframe->setFrameShape(QFrame::StyledPanel);
    m_pCenframe->setFrameShadow(QFrame::Sunken);
    setCentralWidget(m_pCenframe);

    // Layout controls for table, editing widgets
    m_pMainlayout = new QVBoxLayout(m_pCenframe, TITRAQ_MARGIN, TITRAQ_SPACING, "Mainlayout");  // For layouts
    m_pPackagelayout = new QVBoxLayout(0, 0, TITRAQ_SPACING, "Packagelayout");  // For table
    m_pEditlayout = new QHBoxLayout(0, 0, TITRAQ_SPACING, "Editlayout");        // For edits

    // Major sanity check wrapped in one call
    if (!(m_pMainlayout && m_pPackagelayout && m_pEditlayout))
        throw Genexcept("Main window layout creation failed.");

    // Specify ordering of the layouts
    m_pMainlayout->addLayout(m_pPackagelayout);
    m_pMainlayout->addLayout(m_pEditlayout);
}

//
// Construct the status bar
//
void Titraqform::setupStatusbar(void)
{
    m_pStatbar = statusBar();   // Grab status bar owned by QMainWindow
    if (m_pStatbar == NULL)     // Sanity check
        throw Genexcept("Main window status bar nonexistant.");
}

//
// Construct the table
//
void Titraqform::setupTable(void)
{
    // The table itself
    m_pMaintable = new TiTable(m_pCenframe, "Maintable");
    if (m_pMaintable == NULL)   // Sanity check
        throw Genexcept("Main window table creation failed.");
    m_pMaintable->setNumCols(g_knCols);
    m_pMaintable->setReadOnly(true);                    // Table is read only
    m_pMaintable->setColumnMovingEnabled(false);        // Ctrl-drag disabled
    m_pMaintable->setSelectionMode(QTable::MultiRow);   // Multi row selection
    m_pMaintable->setCurrentCell(-1, 0);                // Initial row value -1
    m_pMaintable->setFocusStyle(QTable::FollowStyle);   // How cells are drawn
    m_pMaintable->setLeftMargin(0);             // Get rid of the vertical header
    m_pMaintable->verticalHeader()->hide();     // by hiding it with a margin of 0
    m_pMaintable->horizontalHeader()->setResizeEnabled(true);
    m_pMaintable->horizontalHeader()->setClickEnabled(true); // No click signals
    m_pMaintable->horizontalHeader()->setTracking(false); // No continuous tracking
    m_pMaintable->setColumnStretchable(g_knCols - 1, true);
    m_pMaintable->setSorting(false);

    // Table header row
    m_pTablehead = m_pMaintable->horizontalHeader();
    m_pMaintable->setHScrollBarMode(QScrollView::AlwaysOff);
    m_pTablehead->setLabel(0, QObject::trUtf8("Date"), 94);
    m_pTablehead->setLabel(1, QObject::trUtf8("Begin"), 86);
    m_pTablehead->setLabel(2, QObject::trUtf8("End"), 86);
    m_pTablehead->setLabel(3, QObject::trUtf8("Amount"), 96);
    m_pTablehead->setLabel(4, QObject::trUtf8("Task"), 96);
    m_pTablehead->setLabel(5, QObject::trUtf8("Remark"));

    m_pPackagelayout->addWidget(m_pMaintable);  // Finally add the damn table

    // Table update signals
    connect(m_pMaintable, SIGNAL(currentChanged(int, int)), this, SLOT(updEdit(int, int)));
    connect(m_pMaintable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), this, SLOT(inplaceEdit(int, int, int, const QPoint&)));
    connect(m_pMaintable->horizontalHeader(), SIGNAL(sizeChange(int, int, int)), this, SLOT(updSizes(int, int, int)));
//    connect(m_pMaintable, SIGNAL(valueChanged(int, int)), this, SLOT(tableChanged(int, int)));
}

//
// Construct the bottom edit widgets
//
void Titraqform::setupEditlay(void)
{
//    QSpacerItem Pad(TITRAQ_SPACING / 2, 0, QSizePolicy::Fixed);
//    m_pEditlayout->addWidget(&Pad); // Padd left side of control layout

    // Make the date selector
    m_pDateedit = new QDateEdit(m_pCenframe, "Date");
    m_pDatezero = new QDate(m_pDateedit->date());                   // Hack to store empty date
    if (m_pDateedit == NULL)                                        // Sanity check
        throw Genexcept("Main window date edit creation failed.");  // Spew errors

    // Configure attributes
    m_pDateedit->setOrder(QDateEdit::YMD);
    m_pDateedit->setAutoAdvance(true);
    m_pDateedit->setSeparator(trUtf8("."));

    m_pEditlayout->addWidget(m_pDateedit);                          // Finally add the date editor
    QToolTip::add(m_pDateedit, trUtf8("Task Date"));

    // Whatsthis info for the date editor
    const char *kszDateedit = "Edit the <em>task date</em> by clicking on "
                              "the year, month, or day, and then changing their "
                              "values with the arrow buttons.";
    QWhatsThis::add(m_pDateedit, kszDateedit);

    // Make the start time selector
    m_pStarttime = new QTimeEdit(m_pCenframe, "StartTime");
    if (m_pStarttime == NULL)                                       // Sanity check
        throw Genexcept("Main window start time creation failed."); // Spew errors

    // Configure attributes
    m_pStarttime->setAutoAdvance(true);

    m_pEditlayout->addWidget(m_pStarttime);                      // Finally add the start editor
    QToolTip::add(m_pStarttime, trUtf8("Task Starting Time"));

    // Whatsthis info for the time editor
    const char *kszStarttime = "Edit the <em>task starting time</em> by clicking on "
                               "the hour and minute, and then changing their "
                               "values with the arrow buttons.";
    QWhatsThis::add(m_pStarttime, kszStarttime);

    // Make the end time selector
    m_pEndtime = new QTimeEdit(m_pCenframe, "EndTime");
    if (m_pEndtime == NULL)                                        // Sanity check
        throw Genexcept("Main window end time creation failed.");  // Spew errors

    m_pEditlayout->addWidget(m_pEndtime);                       // Finally add the end editor
    QToolTip::add(m_pEndtime, trUtf8("Task Ending Time"));

    // Whatsthis info for the time editor
    const char *kszEndtime = "Edit the <em>task ending time</em> by clicking on "
                             "the hour and minute, and then changing their "
                             "values with the arrow buttons.";
    QWhatsThis::add(m_pEndtime, kszEndtime);

    // Make the amount selector
    m_pAmount = new AmountBox(TITRAQ_MINAMOUNT, TITRAQ_MAXAMOUNT, TITRAQ_STEPAMOUNT, m_pCenframe, "Amount");
    if (m_pAmount == NULL)                                      // Sanity check
        throw Genexcept("Main window amount creation failed."); // Spew errors

    // Configure attributes
    m_pAmount->setButtonSymbols(QSpinBox::PlusMinus);
    m_pAmount->setSuffix(trUtf8(" Minutes"));
//    m_pAmount->setSpecialValueText(trUtf8("In progress"));

    m_pEditlayout->addWidget(m_pAmount);    // Finally add the amount editor
    QToolTip::add(m_pAmount, trUtf8("Task Amount"));

    // Whatsthis info for the amount editor
    const char *kszAmount = "Edit the <em>task amount</em> by clicking on "
                            "the amount, and then changing its "
                            "value with the arrow buttons.";
    QWhatsThis::add(m_pAmount, kszAmount);

    // Construct a stringlist just to hold task values
    m_pTaskentries = new QStringList;
    if (m_pTaskentries == NULL) // Sanity check
        throw Genexcept("Main window task entries creation failed.");

    // Populate the stringlist with fresh tasks
    *m_pTaskentries << trUtf8("titraq")         << trUtf8("opgui")
                    << trUtf8("email")          << trUtf8("admin")
                    << trUtf8("pmod")           << trUtf8("psod")
                    << trUtf8("brainstorming")  << trUtf8("communication")
                    << trUtf8("evaluation")     << trUtf8("holiday")
                    << trUtf8("implementation") << trUtf8("maintainance")
                    << trUtf8("prepare")        << trUtf8("perform")
                    << trUtf8("visit")          << trUtf8("meeting")
                    << trUtf8("troubleshooting") << trUtf8("weekly");

    // Make the combobox task edit
    m_pTasks = new QComboBox(true, m_pCenframe, "Tasks");
    if (m_pTasks == NULL)   // Sanity check
        throw Genexcept("Main window task edit creation failed.");
    m_pTasks->insertStringList(*m_pTaskentries);
    m_pTasks->setCurrentText(NULL);
    m_pTasks->setAutoCompletion(true);

    // Add an auto scroll bar if possible under current GUI style
    if (m_pTasks->listBox())    // Motif style has no list box
        m_pTasks->listBox()->setHScrollBarMode(QScrollView::Auto);
//        m_pTasks->setMinimumWidth(m_pTasks->listBox()->maxItemWidth());

    // Whatsthis info for the remark line
    const char *kszTasktext = "Choose a <em>task account</em> by clicking on "
                              "this box, and choosing whichever item most "
                              "closely resembles your task.";
    m_pEditlayout->addWidget(m_pTasks); // Finally add the task edit

    // Make the Remark line
    m_pRemark = new QLineEdit(m_pCenframe, "Remark");
    if (m_pRemark == NULL)  // Sanity check
        throw Genexcept("Main window remark line creation failed.");
    m_pRemark->setText(trUtf8("Happy birthday to Ralf"));
    m_pRemark->setFrameShape(QLineEdit::LineEditPanel);
    m_pRemark->setFrameShadow(QLineEdit::Sunken);
    m_pRemark->setFrame(true);
    m_pRemark->setReadOnly(false);
    QToolTip::add(m_pRemark, trUtf8("Remark Line"));
    m_pEditlayout->addWidget(m_pRemark);    // Finally add the remark line

    // Whatsthis info for the remark line
    const char *kszRemarktext = "Edit the <em>task remarks</em> by clicking on "
                                "this line control and typing the remarks you "
                                "have about the task.";
    QWhatsThis::add(m_pRemark, kszRemarktext);

    // Start edit controls off at right size
    this->updSizes(TITRAQ_IDXALLCTRLS, -1, -1);

//    // Signals
//    connect(m_pDateedit, SIGNAL(valueChanged(const QDate &date)), this, SLOT(updateDate()));
//    connect(m_pStarttime, SIGNAL(valueChanged(const QTime &time)), this, SLOT(updateStart()));
//    connect(m_pEndtime, SIGNAL(valueChanged(const QTime &time)), this, SLOT(updateFinish()));
//    connect(m_pAmount, SIGNAL(valueChanged(int value), this, SLOT(updateAmount()));
//    connect(m_pTasks, SIGNAL(textChanged(const QString &string), this, SLOT(updateTask()));
}

CVSTrac 2.0.1