michael@1: // michael@1: // OSSP asgui - Accounting system graphical user interface michael@12: // Copyright (c) 2002-2009 The OSSP Project (http://www.ossp.org/) michael@12: // Copyright (c) 2002-2009 Ralf S. Engelschall michael@12: // Copyright (c) 2002-2009 Michael Schloh von Bennewitz michael@12: // Copyright (c) 2002-2009 Cable & Wireless Telecommunications Services GmbH michael@1: // michael@1: // This file is part of OSSP asgui, an accounting system graphical user michael@3: // interface which can be found at http://asgui.europalab.com/. michael@1: // michael@1: // Permission to use, copy, modify, and distribute this software for michael@1: // any purpose with or without fee is hereby granted, provided that michael@1: // the above copyright notice and this permission notice appear in all michael@1: // copies. michael@1: // michael@1: // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@1: // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@1: // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@1: // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@1: // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@1: // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@1: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@1: // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@1: // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@1: // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@1: // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@1: // SUCH DAMAGE. michael@1: // michael@1: // as_assist.cpp: ISO C++ implementation michael@1: // michael@1: michael@3: #define QT3_SUPPORT michael@3: michael@3: #include michael@3: michael@1: // Qt style headers michael@1: #include michael@3: #include michael@3: #include michael@1: #include michael@3: #include michael@3: #include michael@3: #include michael@1: #include michael@3: #include michael@3: #include michael@1: michael@1: // Qt general headers michael@1: #include michael@3: #include michael@1: #include michael@3: #include michael@1: #include michael@3: #include michael@1: #include michael@1: #include michael@1: #include michael@1: #include michael@1: #include michael@1: #include michael@1: michael@3: //Added by qt3to4: michael@3: #include michael@3: #include michael@3: #include michael@3: #include michael@3: #include michael@3: #include michael@3: michael@1: // User interface michael@1: #include "as_amount.h" // AmountBox class michael@1: #include "as_user.h" // User class michael@1: #include "as_const.h" // Application constants michael@1: #include "as_table.h" // Class TiTable michael@1: #include "as_pref.h" // Class Preferences michael@1: #include "as_panel.h" // Class Prefpanel michael@1: #include "as_datedit.h" // Class Daydateedit michael@1: michael@1: // Icon pixel maps michael@1: #include "as_gfx/filenew.xpm" // static const char *s_kpcFilenew_xpm[] michael@1: #include "as_gfx/fileopen.xpm" // static const char *s_kpcFileopen_xpm[] michael@1: #include "as_gfx/filesave.xpm" // static const char *s_kpcFilesave_xpm[] michael@1: #include "as_gfx/filesaved.xpm" // static const char *s_kpcDfilesave_xpm[] michael@1: #include "as_gfx/cut.xpm" // static const char *s_kpcCut_xpm[] michael@1: #include "as_gfx/cutd.xpm" // static const char *s_kpcDcut_xpm[] michael@1: #include "as_gfx/copy.xpm" // static const char *s_kpcCopy_xpm[] michael@1: #include "as_gfx/copyd.xpm" // static const char *s_kpcDcopy_xpm[] michael@1: #include "as_gfx/paste.xpm" // static const char *s_kpcPaste_xpm[] michael@1: #include "as_gfx/pasted.xpm" // static const char *s_kpcDcaste_xpm[] michael@1: #include "as_gfx/rowadd.xpm" // static const char *s_kpcRowadd_xpm[] michael@1: #include "as_gfx/rowdel.xpm" // static const char *s_kpcRowdel_xpm[] michael@1: #include "as_gfx/rowaddd.xpm" // static const char *s_kpcDrowadd_xpm[] michael@1: #include "as_gfx/rowdeld.xpm" // static const char *s_kpcDrowdel_xpm[] michael@1: #include "as_gfx/osspicon.xpm" // static const char *s_kpcOsspicon_xpm[] michael@1: #include "as_gfx/whatsthis.xpm" // static const char *s_kpcWhatsthis_xpm[] michael@1: #include "as_gfx/statok.xpm" // static const char *s_kpcStatokay_xpm[] michael@1: #include "as_gfx/staterr.xpm" // static const char *s_kpcStaterror_xpm[] michael@1: #include "as_gfx/statwrn.xpm" // static const char *s_kpcStatwarn_xpm[] michael@1: #include "as_gfx/statvoid.xpm" // static const char *s_kpcStatvoid_xpm[] michael@1: #include "as_gfx/refresh.xpm" // static const char *s_kpcRefresh_xpm[] michael@1: #include "as_gfx/refreshd.xpm" // static const char *s_kpcDrefresh_xpm[] michael@1: #include "as_gfx/sync.xpm" // static const char *s_kpcSync_xpm[] michael@1: #include "as_gfx/syncd.xpm" // static const char *s_kpcDsync_xpm[] michael@1: #include "as_gfx/report.xpm" // static const char *s_kpcReport_xpm[] michael@1: #include "as_gfx/reportd.xpm" // static const char *s_kpcDreport_xpm[] michael@1: #include "as_gfx/prefs.xpm" // static const char *s_kpcPrefs_xpm[] michael@1: michael@1: michael@1: // michael@1: // Construct the preferences michael@1: // michael@1: void Titraqform::setupPrefs(void) michael@1: { michael@1: // Can't bootstrap until we know who is using our tool, so find out michael@1: User Localuser = User(); michael@3: QString Username = QString::fromStdString(Localuser.getName()); michael@3: QString Homedir = QString::fromStdString(Localuser.getHomedir()); michael@1: michael@1: // Bootstrap a user preferences object from operating system info michael@1: m_pPrefs = new Preferences(Homedir + QChar('/') + michael@1: QString::fromLocal8Bit(TITRAQ_PREFNAME), michael@1: QString::fromLocal8Bit(TITRAQ_APPTITLE), michael@1: QString::fromLocal8Bit(TITRAQ_PREFVER)); michael@1: if (!m_pPrefs->fileState()) { // No file was found, so assume a null state michael@1: if (!Homedir.isEmpty()) michael@1: m_pPrefs->setString(TITRAQ_PREFHOME, Homedir); michael@1: else michael@1: m_pPrefs->setString(TITRAQ_PREFHOME, TITRAQ_DEFHOME); michael@1: if (!Username.isEmpty()) michael@1: m_pPrefs->setString(TITRAQ_PREFUSER, Username); michael@1: else michael@1: m_pPrefs->setString(TITRAQ_PREFUSER, TITRAQ_DEFUSER); michael@1: michael@1: m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE); michael@1: m_pPrefs->setString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS); michael@1: m_pPrefs->setString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR); michael@1: m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW); michael@1: m_pPrefs->setNumber(TITRAQ_PREFSORTCOL, TITRAQ_DEFSORTCOL); michael@1: m_pPrefs->setBool(TITRAQ_PREFSORTDIR, TITRAQ_DEFSORTDIR); michael@1: m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG); michael@1: m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG); michael@1: m_pPrefs->setString(TITRAQ_PREFCORBHOST, TITRAQ_DEFCORBHOST); michael@1: m_pPrefs->setString(TITRAQ_PREFSOAPHOST, TITRAQ_DEFSOAPHOST); michael@1: m_pPrefs->setBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON); michael@1: m_pPrefs->setBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON); michael@1: m_pPrefs->setBool(TITRAQ_PREFBAKON, TITRAQ_DEFBAKON); michael@1: m_pPrefs->setBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON); michael@1: m_pPrefs->setBool(TITRAQ_PREFDETAILON, TITRAQ_DEFDETAILON); michael@1: m_pPrefs->setBool(TITRAQ_PREFSIGNATON, TITRAQ_DEFSIGNATON); michael@1: m_pPrefs->setNumber(TITRAQ_PREFREPORTYPE, TITRAQ_DEFREPORTYPE); michael@1: m_pPrefs->setNumber(TITRAQ_PREFREPORTWEEKS, TITRAQ_DEFREPORTWEEKS); michael@1: m_pPrefs->setNumber(TITRAQ_PREFREPORTMONTHS, TITRAQ_DEFREPORTMONTHS); michael@1: m_pPrefs->setNumber(TITRAQ_PREFLIGHTRED, TITRAQ_DEFLIGHTRED); michael@1: m_pPrefs->setNumber(TITRAQ_PREFLIGHTGREEN, TITRAQ_DEFLIGHTGREEN); michael@1: m_pPrefs->setNumber(TITRAQ_PREFLIGHTBLUE, TITRAQ_DEFLIGHTBLUE); michael@1: m_pPrefs->setNumber(TITRAQ_PREFDARKRED, TITRAQ_DEFDARKRED); michael@1: m_pPrefs->setNumber(TITRAQ_PREFDARKGREEN, TITRAQ_DEFDARKGREEN); michael@1: m_pPrefs->setNumber(TITRAQ_PREFDARKBLUE, TITRAQ_DEFDARKBLUE); michael@1: m_pPrefs->flush(); // Write the new conf file michael@3: Q3TextStream cerr(stderr, QIODevice::WriteOnly); michael@1: cerr << trUtf8("Created new preferences file ") << Homedir << QChar('/') michael@1: << QString::fromLocal8Bit(TITRAQ_PREFNAME) << endl; michael@1: } michael@1: michael@1: // Use the preferred configuration values to initialize titraq michael@1: switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) { michael@1: case TITRAQ_STYLECDE: michael@1: qApp->setStyle(new QCDEStyle); michael@1: break; michael@3: //case TITRAQ_STYLESGI: // SGI Style is unsupported michael@3: // qApp->setStyle(new QSGIStyle); michael@3: // break; michael@1: case TITRAQ_STYLEMOTIF: michael@1: qApp->setStyle(new QMotifStyle); michael@1: break; michael@3: //case TITRAQ_STYLEMPLUS: // MotifPlus Style is unsupported michael@3: // qApp->setStyle(new QMotifPlusStyle); michael@3: // break; michael@3: //case TITRAQ_STYLEPLAT: // Platinum Style is unsupported michael@3: // qApp->setStyle(new QPlatinumStyle); michael@3: // break; michael@1: case TITRAQ_STYLEMSOFT: michael@1: qApp->setStyle(new QWindowsStyle); michael@1: break; michael@1: default: michael@1: qApp->setStyle(new QCDEStyle); michael@1: break; michael@1: } michael@1: } michael@1: michael@1: // michael@1: // Construct various actions michael@1: // michael@1: void Titraqform::setupActions(void) michael@1: { michael@3: QIcon Saveiset, Cutiset, Copyiset, Pasteiset; michael@3: QIcon Rowaddiset, Rowdeliset, Refreshiset; michael@3: QIcon Synciset, Reportiset; michael@1: michael@1: // Construct iconsets to use later for multistate action images michael@3: Saveiset.setPixmap(QPixmap(s_kpcFilesave_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Saveiset.setPixmap(QPixmap(s_kpcDfilesave_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Cutiset.setPixmap(QPixmap(s_kpcCut_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Cutiset.setPixmap(QPixmap(s_kpcDcut_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Copyiset.setPixmap(QPixmap(s_kpcCopy_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Copyiset.setPixmap(QPixmap(s_kpcDcopy_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Pasteiset.setPixmap(QPixmap(s_kpcPaste_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Pasteiset.setPixmap(QPixmap(s_kpcDpaste_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Rowaddiset.setPixmap(QPixmap(s_kpcRowadd_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Rowaddiset.setPixmap(QPixmap(s_kpcDrowadd_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Rowdeliset.setPixmap(QPixmap(s_kpcRowdel_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Rowdeliset.setPixmap(QPixmap(s_kpcDrowdel_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Refreshiset.setPixmap(QPixmap(s_kpcRefresh_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Refreshiset.setPixmap(QPixmap(s_kpcDrefresh_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Synciset.setPixmap(QPixmap(s_kpcSync_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Synciset.setPixmap(QPixmap(s_kpcDsync_xpm), QIcon::Automatic, QIcon::Disabled); michael@3: Reportiset.setPixmap(QPixmap(s_kpcReport_xpm), QIcon::Automatic, QIcon::Normal); michael@3: Reportiset.setPixmap(QPixmap(s_kpcDreport_xpm), QIcon::Automatic, QIcon::Disabled); michael@1: michael@1: // First associate the graphics with MIME types michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("osspicon", QPixmap(s_kpcOsspicon_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("filenew", QPixmap(s_kpcFilenew_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("fileopen", QPixmap(s_kpcFileopen_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("filesave", QPixmap(s_kpcFilesave_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("cut", QPixmap(s_kpcCut_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("copy", QPixmap(s_kpcCopy_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("paste", QPixmap(s_kpcPaste_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("rowadd", QPixmap(s_kpcRowadd_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("rowdel", QPixmap(s_kpcRowdel_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("refresh", QPixmap(s_kpcRefresh_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("syncrpc", QPixmap(s_kpcSync_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("locreport", QPixmap(s_kpcReport_xpm)); michael@3: Q3MimeSourceFactory::defaultFactory()->setPixmap("prefs", QPixmap(s_kpcPrefs_xpm)); michael@1: michael@1: // File new action michael@3: m_pFilenewact = new Q3Action(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New"), Qt::CTRL+Qt::Key_N, this, "New"); michael@1: if (m_pFilenewact == NULL) // Sanity check michael@1: throw Genexcept("Main window file new action creation failed."); michael@1: connect(m_pFilenewact, SIGNAL(activated()), SLOT(newDoc())); michael@1: const char *kszFilenewtext = "

" michael@1: "Click this button to make a " michael@1: "blank file. You can also " michael@1: "select the New command from " michael@1: "the File menu.

"; michael@1: m_pFilenewact->setWhatsThis(kszFilenewtext); michael@1: michael@1: // File open action michael@3: m_pFileopenact = new Q3Action(trUtf8("Open File"), QPixmap(s_kpcFileopen_xpm), trUtf8("&Open..."), Qt::CTRL+Qt::Key_O, this, "Open"); michael@1: if (m_pFileopenact == NULL) // Sanity check michael@1: throw Genexcept("Main window file open action creation failed."); michael@1: connect(m_pFileopenact, SIGNAL(activated()), SLOT(openDoc())); michael@1: const char *kszFileopentext = "

" michael@1: "Click this button to open a " michael@1: "new file. You can also select " michael@1: "the Open command from the " michael@1: "File menu.

"; michael@1: m_pFileopenact->setWhatsThis(kszFileopentext); michael@1: michael@1: // File save current action michael@3: m_pFilesaveact = new Q3Action(trUtf8("Save File"), Saveiset, trUtf8("&Save"), Qt::CTRL+Qt::Key_S, this, "Save"); michael@1: if (m_pFilesaveact == NULL) // Sanity check michael@1: throw Genexcept("Main window file save action creation failed."); michael@1: connect(m_pFilesaveact, SIGNAL(activated()), SLOT(saveFile())); michael@1: const char *kszFilesavetext = "

" michael@1: "Click this button to save " michael@1: "the file you are editing. You will be " michael@1: "prompted for a file name. You can also " michael@1: "select the Save command from " michael@1: "the File menu.

"; michael@1: m_pFilesaveact->setWhatsThis(kszFilesavetext); michael@1: michael@1: // File save selected action michael@3: m_pFilesaveasact = new Q3Action(trUtf8("Save File As"), trUtf8("Save &As..."), 0, this, "SaveAs"); michael@1: if (m_pFilesaveasact == NULL) // Sanity check michael@1: throw Genexcept("Main window file save as action creation failed."); michael@1: connect(m_pFilesaveasact, SIGNAL(activated()), SLOT(saveAs())); michael@1: m_pFilesaveasact->setWhatsThis(kszFilesavetext); michael@1: michael@1: // File close current action michael@3: m_pFilecloseact = new Q3Action(trUtf8("Close"), trUtf8("&Close"), Qt::CTRL+Qt::Key_W, this, "Close"); michael@1: if (m_pFilecloseact == NULL) // Sanity check michael@1: throw Genexcept("Main window file close action creation failed."); michael@1: connect(m_pFilecloseact, SIGNAL(activated()), SLOT(close())); michael@1: michael@1: // File quit action michael@3: m_pFilequitact = new Q3Action(trUtf8("Exit"), trUtf8("E&xit"), Qt::CTRL+Qt::Key_Q, this, "Exit"); michael@1: if (m_pFilequitact == NULL) // Sanity check michael@1: throw Genexcept("Main window file quit action creation failed."); michael@1: connect(m_pFilequitact, SIGNAL(activated()), SLOT(quitApp())); michael@1: michael@1: // Cut action michael@3: m_pCutact = new Q3Action(trUtf8("Cut"), Cutiset, trUtf8("&Cut"), Qt::CTRL+Qt::Key_X, this, "Cut"); michael@1: if (m_pCutact == NULL) // Sanity check michael@1: throw Genexcept("Main window cut edit action creation failed."); michael@1: connect(m_pCutact, SIGNAL(activated()), SLOT(cutEntry())); michael@1: const char *kszCuttext = "

" michael@1: "Click this button to cut an entry. " michael@1: "You can also select the Cut command " michael@1: "from the Edit menu.

"; michael@1: m_pCutact->setWhatsThis(kszCuttext); michael@1: michael@1: // Copy action michael@3: m_pCopyact = new Q3Action(trUtf8("Copy"), Copyiset, trUtf8("&Copy"), Qt::CTRL+Qt::Key_C, this, "Copy"); michael@1: if (m_pCopyact == NULL) // Sanity check michael@1: throw Genexcept("Main window copy edit action creation failed."); michael@1: connect(m_pCopyact, SIGNAL(activated()), SLOT(copyEntry())); michael@1: const char *kszCopytext = "

" michael@1: "Click this button to copy an entry. " michael@1: "You can also select the Copy command " michael@1: "from the Edit menu.

"; michael@1: m_pCopyact->setWhatsThis(kszCopytext); michael@1: michael@1: // Paste action michael@3: m_pPasteact = new Q3Action(trUtf8("Paste"), Pasteiset, trUtf8("&Paste"), Qt::CTRL+Qt::Key_V, this, "Paste"); michael@1: if (m_pPasteact == NULL) // Sanity check michael@1: throw Genexcept("Main window paste edit action creation failed."); michael@1: connect(m_pPasteact, SIGNAL(activated()), SLOT(pasteEntry())); michael@1: const char *kszPastetext = "

" michael@1: "Click this button to paste an entry. " michael@1: "You can also select the Paste command " michael@1: "from the Edit menu.

"; michael@1: m_pPasteact->setWhatsThis(kszPastetext); michael@1: michael@1: // Add data row action michael@3: m_pAddrowact = new Q3Action(trUtf8("Add Entry"), Rowaddiset, trUtf8("&Add entry"), Qt::Key_Insert, this, "Addentry"); michael@1: if (m_pAddrowact == NULL) // Sanity check michael@1: throw Genexcept("Main window add entry action creation failed."); michael@1: connect(m_pAddrowact, SIGNAL(activated()), SLOT(addEntry())); michael@1: const char *kszAddrowtext = "

" michael@1: "Click this button to add a new entry. " michael@1: "You can also select the Add command " michael@1: "from the Edit menu.

"; michael@1: m_pAddrowact->setWhatsThis(kszAddrowtext); michael@1: michael@1: // Delete data row action michael@3: m_pDelrowact = new Q3Action(trUtf8("Delete Entry"), Rowdeliset, trUtf8("&Delete entry"), Qt::Key_Delete, this, "Delentry"); michael@1: if (m_pDelrowact == NULL) // Sanity check michael@1: throw Genexcept("Main window delete entry action creation failed."); michael@1: connect(m_pDelrowact, SIGNAL(activated()), SLOT(delEntry())); michael@1: const char *kszDelrowtext = "

" michael@1: "Click this button to delete a entry. " michael@1: "You can also select the Delete command " michael@1: "from the Edit menu.

"; michael@1: m_pDelrowact->setWhatsThis(kszDelrowtext); michael@1: michael@1: // Refresh data display action michael@3: m_pRefreshact = new Q3Action(trUtf8("Refresh Display"), Refreshiset, trUtf8("&Refresh display"), Qt::CTRL+Qt::Key_R, this, "Refresh"); michael@1: if (m_pRefreshact == NULL) // Sanity check michael@1: throw Genexcept("Main window refresh action creation failed."); michael@1: connect(m_pRefreshact, SIGNAL(activated()), SLOT(refreshDisplay())); michael@1: const char *kszRefreshtext = "

" michael@1: "Click this button to refresh the display. " michael@1: "You can also select the Refresh command " michael@1: "from the View menu.

"; michael@1: m_pRefreshact->setWhatsThis(kszRefreshtext); michael@1: michael@1: // Syncronize data with remote server over IIOP or SOAP action michael@3: m_pSyncact = new Q3Action(trUtf8("Synchronize with server"), Synciset, trUtf8("&Synchronize"), Qt::CTRL+Qt::Key_E, this, "Synchronize"); michael@1: if (m_pSyncact == NULL) // Sanity check michael@1: throw Genexcept("Main window synchronize RPC action creation failed."); michael@1: connect(m_pSyncact, SIGNAL(activated()), SLOT(syncIiop())); michael@1: connect(m_pSyncact, SIGNAL(activated()), SLOT(syncSoap())); michael@1: const char *kszSynctext = "

" michael@1: "Click this button to synchronize the data. " michael@1: "Your changed entries will be sent to the server. " michael@1: "You can also select the Synchronize command " michael@1: "from the Report menu.

"; michael@1: m_pSyncact->setWhatsThis(kszSynctext); michael@1: michael@1: // Local report generation action michael@3: m_pReportact = new Q3Action(trUtf8("Generate a local report"), Reportiset, trUtf8("&Report"), Qt::CTRL+Qt::Key_T, this, "LocalReport"); michael@1: if (m_pReportact == NULL) // Sanity check michael@1: throw Genexcept("Main window local report action creation failed."); michael@1: connect(m_pReportact, SIGNAL(activated()), SLOT(genReport())); michael@1: const char *kszReporttext = "

" michael@1: "Click this button to report your data. " michael@1: "A local report will be generated for you to view. " michael@1: "You can also select the Local Report command " michael@1: "from the Report menu.

"; michael@1: m_pReportact->setWhatsThis(kszReporttext); michael@1: michael@1: // Offer a formatted preferences panel for intuitive prefs object editing michael@3: m_pPrefsact = new Q3Action(trUtf8("Edit the preferences"), QPixmap(s_kpcPrefs_xpm), trUtf8("P&references..."), Qt::CTRL+Qt::Key_F, this, "Prefspanel"); michael@1: if (m_pPrefsact == NULL) // Sanity check michael@1: throw Genexcept("Main window preferences panel action creation failed."); michael@1: connect(m_pPrefsact, SIGNAL(activated()), SLOT(configPrefs())); michael@1: const char *kszPrefstext = "

" michael@1: "Click this button to edit the preferences. " michael@1: "You can then apply, accept, or cancel your changes. " michael@1: "You can also select the Preferences command " michael@1: "from the Edit menu.

"; michael@1: m_pPrefsact->setWhatsThis(kszPrefstext); michael@1: } michael@1: michael@1: // michael@1: // Construct the menu bar michael@1: // michael@1: void Titraqform::setupMenubar(void) michael@1: { michael@1: int nMenuid = 0; // Used to store id during menu item creation michael@1: michael@1: m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow michael@1: if (m_pMenubar == NULL) // Sanity check michael@1: throw Genexcept("Main window menu bar nonexistant."); michael@1: michael@1: // // Make an easter egg ;-) michael@1: // QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), trUtf8("Easter Egg")); michael@1: michael@1: // Construct and populate the file menu with actions michael@3: Q3PopupMenu *pFilepopup = new Q3PopupMenu(this); michael@1: if (pFilepopup == NULL) // Sanity check michael@1: throw Genexcept("Main window file popup creation failed."); michael@1: m_pMenubar->insertItem(trUtf8("&File"), pFilepopup); michael@1: m_pFilenewact->addTo(pFilepopup); michael@1: m_pFileopenact->addTo(pFilepopup); michael@1: pFilepopup->insertSeparator(); michael@1: m_pFilecloseact->addTo(pFilepopup); michael@1: pFilepopup->insertSeparator(); michael@1: m_pFilesaveact->addTo(pFilepopup); michael@1: m_pFilesaveasact->addTo(pFilepopup); michael@1: pFilepopup->insertSeparator(); michael@1: m_pFilequitact->addTo(pFilepopup); michael@1: michael@1: // Construct and populate the edit menu with subitems michael@3: Q3PopupMenu *pEditpopup = new Q3PopupMenu(this); michael@1: if (pEditpopup == NULL) // Sanity check michael@1: throw Genexcept("Main window edit popup creation failed."); michael@1: m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup); michael@1: m_pCutact->addTo(pEditpopup); michael@1: m_pCopyact->addTo(pEditpopup); michael@1: m_pPasteact->addTo(pEditpopup); michael@1: pEditpopup->insertSeparator(); michael@1: m_pAddrowact->addTo(pEditpopup); michael@1: m_pDelrowact->addTo(pEditpopup); michael@1: pEditpopup->insertSeparator(); michael@1: m_pPrefsact->addTo(pEditpopup); michael@1: michael@1: // Construct the view menu and submenus michael@3: m_pViewpopup = new Q3PopupMenu(this); michael@3: m_pTbarspopup = new Q3PopupMenu(this); michael@3: m_pColspopup = new Q3PopupMenu(this); michael@1: michael@1: // Give the new menus krass attributes michael@1: m_pTbarspopup->insertTearOffHandle(); michael@1: m_pTbarspopup->setCheckable(true); michael@1: m_pColspopup->insertTearOffHandle(); michael@1: m_pColspopup->setCheckable(true); michael@1: michael@1: // Major sanity check wrapped in one call michael@1: if (!(m_pViewpopup && m_pTbarspopup && m_pColspopup)) michael@1: throw Genexcept("Main window view popups creation failed."); michael@1: michael@1: // Populate the view menu with subitems michael@1: m_pMenubar->insertItem(trUtf8("&View"), m_pViewpopup); michael@1: m_pViewpopup->insertItem(trUtf8("&Normal"), this, SLOT(normalView())); michael@1: nMenuid = m_pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView())); michael@1: m_pViewpopup->setItemEnabled(nMenuid, false); michael@1: nMenuid = m_pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView())); michael@1: m_pViewpopup->setItemEnabled(nMenuid, false); michael@1: m_pViewpopup->insertSeparator(); michael@1: m_pRefreshact->addTo(m_pViewpopup); // Refresh action michael@1: m_pViewpopup->insertSeparator(); michael@1: m_pViewpopup->insertItem(trUtf8("&Toolbars"), m_pTbarspopup); michael@1: nMenuid = m_pTbarspopup->insertItem(trUtf8("&File"), this, SLOT(showFilebar())); michael@1: m_pTbarspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pTbarspopup->insertItem(trUtf8("&Edit"), this, SLOT(showEditbar())); michael@1: m_pTbarspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pTbarspopup->insertItem(trUtf8("&View"), this, SLOT(showViewbar())); michael@1: m_pTbarspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pTbarspopup->insertItem(trUtf8("&Prefs"), this, SLOT(showPrefsbar())); michael@1: m_pTbarspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pTbarspopup->insertItem(trUtf8("&Whats"), this, SLOT(showWhatsbar())); michael@1: m_pTbarspopup->setItemChecked(nMenuid, true); michael@1: m_pViewpopup->insertItem(trUtf8("&Columns"), m_pColspopup); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Status"), this, SLOT(showStatcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Line"), this, SLOT(showLinecol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&User"), this, SLOT(showUsercol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&GUID"), this, SLOT(showGuidcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&CRC"), this, SLOT(showCrccol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Rev"), this, SLOT(showRevcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Date"), this, SLOT(showDatecol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Start"), this, SLOT(showStartcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Finish"), this, SLOT(showFinishcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Amount"), this, SLOT(showAmountcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Task"), this, SLOT(showTaskcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: nMenuid = m_pColspopup->insertItem(trUtf8("&Remark"), this, SLOT(showRemarkcol())); michael@1: m_pColspopup->setItemChecked(nMenuid, true); michael@1: michael@1: // Construct and populate the report menu with subitems michael@3: Q3PopupMenu *pReportpopup = new Q3PopupMenu(this); michael@1: if (pReportpopup == NULL) // Sanity check michael@1: throw Genexcept("Main window report popup creation failed."); michael@1: m_pMenubar->insertItem(trUtf8("&Report"), pReportpopup); michael@1: #if defined HAVE_MICO || defined HAVE_ESOAP michael@1: m_pSyncact->addTo(pReportpopup); michael@1: m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON) michael@1: | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)); michael@1: #endif // defined HAVE_MICO || defined HAVE_ESOAP michael@1: m_pReportact->addTo(pReportpopup); michael@1: michael@1: // Pad spacing to force help menu to appear far right michael@1: m_pMenubar->insertSeparator(); michael@1: michael@1: // Construct and populate the help menu with subitems michael@3: Q3PopupMenu *pHelppopup = new Q3PopupMenu(this); michael@1: if (pHelppopup == NULL) // Sanity check michael@1: throw Genexcept("Main window help popup creation failed."); michael@1: m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup); michael@3: pHelppopup->insertItem(trUtf8("&Contents"), this, SLOT(helpContents()), Qt::Key_F1); michael@1: pHelppopup->insertSeparator(); michael@1: pHelppopup->insertItem(trUtf8("About &as-gui"), this, SLOT(aboutTitraq())); michael@1: pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP())); michael@1: pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt())); michael@1: pHelppopup->insertSeparator(); michael@3: pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), Qt::SHIFT+Qt::Key_F1); michael@1: } michael@1: michael@1: // michael@1: // Construct the tool bars michael@1: // michael@1: void Titraqform::setupToolbars(void) michael@1: { michael@1: // Construct and populate the file tool bar michael@3: m_pFiletools = new Q3ToolBar("Toolfile", this, Qt::DockTop); michael@1: if (m_pFiletools == NULL) // Sanity check michael@1: throw Genexcept("File tool bar creation failed."); michael@1: m_pFiletools->setLabel(trUtf8("File Ops")); michael@1: m_pFiletools->setOpaqueMoving(false); michael@3: m_pFiletools->setCloseMode(Q3DockWindow::Never); michael@1: m_pFilenewact->addTo(m_pFiletools); michael@1: m_pFileopenact->addTo(m_pFiletools); michael@1: m_pFilesaveact->addTo(m_pFiletools); michael@1: michael@1: // Construct and populate the edit tool bar michael@3: m_pEdittools = new Q3ToolBar("Tooledit", this, Qt::DockTop); michael@1: if (m_pEdittools == NULL) // Sanity check michael@1: throw Genexcept("Edit tool bar creation failed."); michael@1: m_pEdittools->setLabel(trUtf8("Edit Ops")); michael@1: m_pEdittools->setOpaqueMoving(false); michael@3: m_pEdittools->setCloseMode(Q3DockWindow::Never); michael@1: m_pCutact->addTo(m_pEdittools); michael@1: m_pCopyact->addTo(m_pEdittools); michael@1: m_pPasteact->addTo(m_pEdittools); michael@1: m_pEdittools->addSeparator(); michael@1: m_pAddrowact->addTo(m_pEdittools); michael@1: m_pDelrowact->addTo(m_pEdittools); michael@1: michael@1: // Construct and populate the view tool bar michael@3: m_pViewtools = new Q3ToolBar("Toolview", this, Qt::DockTop); michael@1: if (m_pViewtools == NULL) // Sanity check michael@1: throw Genexcept("View tool bar creation failed."); michael@1: m_pViewtools->setLabel(trUtf8("View Ops")); michael@1: m_pViewtools->setOpaqueMoving(false); michael@3: m_pViewtools->setCloseMode(Q3DockWindow::Never); michael@1: m_pRefreshact->addTo(m_pViewtools); michael@1: m_pReportact->addTo(m_pViewtools); michael@1: m_pSyncact->addTo(m_pViewtools); michael@1: michael@1: // Construct and populate the lonely preferences tool bar michael@3: m_pPrefstools = new Q3ToolBar("Preferences", this, Qt::DockTop); michael@1: if (m_pPrefstools == NULL) // Sanity check michael@1: throw Genexcept("Prefs tool bar creation failed."); michael@1: m_pPrefstools->setLabel(trUtf8("Preferences editor")); michael@1: m_pPrefstools->setOpaqueMoving(false); michael@3: m_pPrefstools->setCloseMode(Q3DockWindow::Never); michael@1: m_pPrefsact->addTo(m_pPrefstools); michael@1: michael@1: // Construct and populate the lonely whatsthis tool bar michael@3: m_pWhatstools = new Q3ToolBar("Toolwhats", this, Qt::DockTop); michael@1: if (m_pWhatstools == NULL) // Sanity check michael@1: throw Genexcept("Whats this tool bar creation failed."); michael@1: m_pWhatstools->setLabel(trUtf8("Whats this")); michael@1: m_pWhatstools->setOpaqueMoving(false); michael@3: m_pWhatstools->setCloseMode(Q3DockWindow::Never); michael@3: Q3WhatsThis::whatsThisButton(m_pWhatstools); // Preconfigured whats this button michael@1: } michael@1: michael@1: // michael@1: // Construct the central frame michael@1: // michael@1: void Titraqform::setupCentralwidget(void) michael@1: { michael@1: // Create a central frame and associated layout for QMainWindow michael@3: m_pCenframe = new Q3Frame(this, "Centralframe"); michael@1: if (m_pCenframe == NULL) // Sanity check michael@1: throw Genexcept("Main window central frame creation failed."); michael@3: m_pCenframe->setFrameShape(Q3Frame::StyledPanel); michael@3: m_pCenframe->setFrameShadow(Q3Frame::Sunken); michael@1: this->setCentralWidget(m_pCenframe); michael@1: michael@1: // Layout controls for table, editing widgets michael@3: m_pMainlayout = new Q3VBoxLayout(m_pCenframe, TITRAQ_MARGIN, TITRAQ_SPACING, "Mainlayout"); // For layouts michael@3: m_pPackagelayout = new Q3VBoxLayout(0, 0, TITRAQ_SPACING, "Packagelayout"); // For table michael@3: m_pEditlayout = new Q3HBoxLayout(0, 0, TITRAQ_SPACING, "Editlayout"); // For edits michael@1: michael@1: // Major sanity check wrapped in one call michael@1: if (!(m_pMainlayout && m_pPackagelayout && m_pEditlayout)) michael@1: throw Genexcept("Main window layout creation failed."); michael@1: michael@1: // Specify ordering of the layouts michael@1: m_pMainlayout->addLayout(m_pPackagelayout); michael@1: m_pMainlayout->addLayout(m_pEditlayout); michael@1: } michael@1: michael@1: // michael@1: // Construct the status bar michael@1: // michael@1: void Titraqform::setupStatusbar(void) michael@1: { michael@1: m_pStatbar = statusBar(); // Grab status bar owned by QMainWindow michael@1: if (m_pStatbar == NULL) // Sanity check michael@1: throw Genexcept("Main window status bar nonexistant."); michael@1: } michael@1: michael@1: // michael@1: // Construct the table michael@1: // michael@1: void Titraqform::setupTable(void) michael@1: { michael@1: // Create, configure, and setup the table itself michael@1: m_pMaintable = new TiTable(m_pPrefs, m_pCenframe, "Maintable"); michael@1: if (m_pMaintable == NULL) // Sanity check michael@1: throw Genexcept("Main window table creation failed."); michael@1: m_pMaintable->setNumCols(TITRAQ_IDXTAIL); michael@1: m_pMaintable->setDirty(false); // Reset data to clean state michael@1: m_pMaintable->setReadOnly(true); // Table is read only michael@1: m_pMaintable->setColumnMovingEnabled(false); // Ctrl-drag disabled michael@3: m_pMaintable->setSelectionMode(Q3Table::MultiRow); // Multi row selection michael@3: m_pMaintable->setFocusStyle(Q3Table::FollowStyle); // How cells are drawn michael@1: m_pMaintable->setLeftMargin(0); // Get rid of the vertical header michael@1: m_pMaintable->verticalHeader()->hide(); // by hiding it with a margin of 0 michael@1: m_pMaintable->horizontalHeader()->setResizeEnabled(true); michael@1: m_pMaintable->horizontalHeader()->setClickEnabled(true); // Allow click signals michael@1: m_pMaintable->horizontalHeader()->setTracking(false); // No continuous tracking michael@1: m_pMaintable->setColumnStretchable(TITRAQ_IDXTAIL - 1, true); michael@1: michael@1: // Allow for user determined data sorting and use saved values michael@1: m_pMaintable->setSortcol((int)m_pPrefs->getNumber(TITRAQ_PREFSORTCOL, TITRAQ_DEFSORTCOL)); michael@1: m_pMaintable->setSortdir(m_pPrefs->getBool(TITRAQ_PREFSORTDIR, TITRAQ_DEFSORTDIR)); michael@1: m_pMaintable->setSorting(true); michael@1: michael@1: // Table header row michael@1: m_pTablehead = m_pMaintable->horizontalHeader(); michael@3: m_pMaintable->setHScrollBarMode(Q3ScrollView::AlwaysOff); michael@1: m_pTablehead->setLabel(TITRAQ_IDXSTATUS, QObject::trUtf8("Stat"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFSTATCOLWIDTH, TITRAQ_DEFSTATCOLWIDTH)); michael@1: m_pMaintable->setColumnReadOnly (TITRAQ_IDXSTATUS, true); michael@1: m_pTablehead->setLabel(TITRAQ_IDXLINE, QObject::trUtf8("Line"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFLCOLWIDTH, TITRAQ_DEFLCOLWIDTH)); michael@1: m_pMaintable->setColumnReadOnly (TITRAQ_IDXLINE, true); michael@1: m_pTablehead->setLabel(TITRAQ_IDXUSER, QObject::trUtf8("User"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFUCOLWIDTH, TITRAQ_DEFUCOLWIDTH)); michael@1: m_pTablehead->setLabel(TITRAQ_IDXGUID, QObject::trUtf8("GUID"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFGCOLWIDTH, TITRAQ_DEFGCOLWIDTH)); michael@1: m_pMaintable->setColumnReadOnly (TITRAQ_IDXGUID, true); michael@1: m_pTablehead->setLabel(TITRAQ_IDXCRC, QObject::trUtf8("CRC"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFCCOLWIDTH, TITRAQ_DEFCCOLWIDTH)); michael@1: m_pMaintable->setColumnReadOnly (TITRAQ_IDXCRC, true); michael@1: m_pTablehead->setLabel(TITRAQ_IDXREV, QObject::trUtf8("Rev"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFREVCOLWIDTH, TITRAQ_DEFREVCOLWIDTH)); michael@1: m_pMaintable->setColumnReadOnly (TITRAQ_IDXREV, true); michael@1: m_pTablehead->setLabel(TITRAQ_IDXDATE, QObject::trUtf8("Date"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFDCOLWIDTH, TITRAQ_DEFDCOLWIDTH)); michael@1: m_pTablehead->setLabel(TITRAQ_IDXSTART, QObject::trUtf8("Begin"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFSTARTCOLWIDTH, TITRAQ_DEFSTARTCOLWIDTH)); michael@1: m_pTablehead->setLabel(TITRAQ_IDXFINISH, QObject::trUtf8("End"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFFCOLWIDTH, TITRAQ_DEFFCOLWIDTH)); michael@1: m_pTablehead->setLabel(TITRAQ_IDXAMOUNT, QObject::trUtf8("Amount"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFACOLWIDTH, TITRAQ_DEFACOLWIDTH)); michael@1: m_pTablehead->setLabel(TITRAQ_IDXTASK, QObject::trUtf8("Task"), michael@1: m_pPrefs->getNumber(TITRAQ_PREFTCOLWIDTH, TITRAQ_DEFTCOLWIDTH)); michael@1: m_pTablehead->setLabel(TITRAQ_IDXREMARK, QObject::trUtf8("Remark")); michael@1: michael@1: m_pPackagelayout->addWidget(m_pMaintable); // Finally add the damn table michael@1: michael@1: // Table update signals michael@1: connect(m_pMaintable, SIGNAL(currentChanged(int, int)), SLOT(updEdit(int, int))); michael@1: connect(m_pMaintable, SIGNAL(clicked(int, int, int, const QPoint&)), SLOT(onClick(int, int, int, const QPoint&))); michael@1: connect(m_pMaintable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), SLOT(inplaceEdit(int, int, int, const QPoint&))); michael@1: connect(m_pTablehead, SIGNAL(sizeChange(int, int, int)), SLOT(updSizes(int, int, int))); michael@1: connect(m_pMaintable, SIGNAL(textEdited(int, int)), SLOT(dataChanged(int, int))); michael@1: connect(m_pMaintable, SIGNAL(valueChanged(int, int)), SLOT(dataChanged(int, int))); michael@1: } michael@1: michael@1: // michael@1: // Construct the bottom edit widgets michael@1: // michael@1: void Titraqform::setupEditlay(void) michael@1: { michael@1: // QSpacerItem Pad(TITRAQ_SPACING / 2, 0, QSizePolicy::Fixed); michael@1: // m_pEditlayout->addWidget(&Pad); // Padd left side of control layout michael@1: michael@1: // Make the status edit michael@1: m_pStatusedit = new QLabel(m_pCenframe, "Status"); michael@1: if (m_pStatusedit == NULL) // Sanity check michael@1: throw Genexcept("Main window status edit creation failed."); michael@1: m_pStatusedit->setPixmap(QPixmap(s_kpcStatvoid_xpm)); // Placeholder michael@1: michael@1: michael@1: // Whatsthis info for the item status edit michael@1: const char *kszStatustext = "The item status shows a green " michael@1: "symbol for valid entries, a yellow symbol " michael@1: "for warning, and a red symbol for flawed entries."; michael@3: Q3WhatsThis::add(m_pStatusedit, kszStatustext); michael@1: QToolTip::add(m_pStatusedit, trUtf8("Status Indicator")); michael@1: m_pEditlayout->addWidget(m_pStatusedit); // Finally add the item status edit michael@1: michael@1: // Make the line number edit michael@1: m_pLineedit = new QLineEdit(m_pCenframe, "Lineno"); michael@1: if (m_pLineedit == NULL) // Sanity check michael@1: throw Genexcept("Main window line number edit creation failed."); michael@1: m_pLineedit->setFrameShape(QLineEdit::LineEditPanel); michael@1: m_pLineedit->setFrameShadow(QLineEdit::Sunken); michael@1: m_pLineedit->setFrame(true); michael@1: m_pLineedit->setReadOnly(true); michael@1: m_pLineedit->setEnabled(false); michael@1: m_pLineedit->setAlignment(Qt::AlignRight); michael@1: michael@1: // Whatsthis info for the line number edit michael@1: const char *kszLinenotext = "The line number helps identify " michael@1: "an entry when a warning or error message " michael@1: "appears."; michael@3: Q3WhatsThis::add(m_pLineedit, kszLinenotext); michael@1: QToolTip::add(m_pLineedit, trUtf8("Line Number")); michael@1: m_pEditlayout->addWidget(m_pLineedit); // Finally add the line number edit michael@1: michael@1: // Make the user edit michael@1: m_pUseredit = new QLineEdit(m_pCenframe, "User"); michael@1: if (m_pUseredit == NULL) // Sanity check michael@1: throw Genexcept("Main window user edit creation failed."); michael@1: m_pUseredit->setFrameShape(QLineEdit::LineEditPanel); michael@1: m_pUseredit->setFrameShadow(QLineEdit::Sunken); michael@1: m_pUseredit->setFrame(true); michael@1: m_pUseredit->setReadOnly(false); michael@1: m_pUseredit->setEnabled(false); michael@1: michael@1: // Whatsthis info for the user edit michael@1: const char *kszUsertext = "Edit the user name by clicking " michael@1: "on this control and typing the user name " michael@1: "you want to account."; michael@3: Q3WhatsThis::add(m_pUseredit, kszUsertext); michael@1: QToolTip::add(m_pUseredit, trUtf8("User Name")); michael@1: m_pEditlayout->addWidget(m_pUseredit); // Finally add the user edit michael@1: michael@1: // Make the GUID edit michael@1: m_pGuidedit = new QLineEdit(m_pCenframe, "Guid"); michael@1: if (m_pGuidedit == NULL) // Sanity check michael@1: throw Genexcept("Main window GUID edit creation failed."); michael@1: m_pGuidedit->setFrameShape(QLineEdit::LineEditPanel); michael@1: m_pGuidedit->setFrameShadow(QLineEdit::Sunken); michael@1: m_pGuidedit->setFrame(true); michael@1: m_pGuidedit->setReadOnly(true); michael@1: m_pGuidedit->setEnabled(false); michael@1: michael@1: // Whatsthis info for the GUID edit michael@1: const char *kszGuidtext = "Edit the GUID by clicking " michael@1: "on this control and typing the GUID " michael@1: "corresponding to this account item."; michael@3: Q3WhatsThis::add(m_pGuidedit, kszGuidtext); michael@1: QToolTip::add(m_pGuidedit, trUtf8("GUID")); michael@1: m_pEditlayout->addWidget(m_pGuidedit); // Finally add the GUID edit michael@1: michael@1: // Make the CRC edit michael@1: m_pCrcedit = new QLineEdit(m_pCenframe, "Crc"); michael@1: if (m_pCrcedit == NULL) // Sanity check michael@1: throw Genexcept("Main window CRC edit creation failed."); michael@1: m_pCrcedit->setFrameShape(QLineEdit::LineEditPanel); michael@1: m_pCrcedit->setFrameShadow(QLineEdit::Sunken); michael@1: m_pCrcedit->setFrame(true); michael@1: m_pCrcedit->setReadOnly(true); michael@1: m_pCrcedit->setEnabled(false); michael@1: michael@1: // Whatsthis info for the CRC edit michael@1: const char *kszCrctext = "Edit the CRC by clicking " michael@1: "on this control and typing the new " michael@1: "value for this account item."; michael@3: Q3WhatsThis::add(m_pCrcedit, kszCrctext); michael@1: QToolTip::add(m_pCrcedit, trUtf8("CRC")); michael@1: m_pEditlayout->addWidget(m_pCrcedit); // Finally add the CRC edit michael@1: michael@1: // Make the revision edit michael@1: m_pRevedit = new QLineEdit(m_pCenframe, "Revision"); michael@1: if (m_pRevedit == NULL) // Sanity check michael@1: throw Genexcept("Main window revision edit creation failed."); michael@1: m_pRevedit->setFrameShape(QLineEdit::LineEditPanel); michael@1: m_pRevedit->setFrameShadow(QLineEdit::Sunken); michael@1: m_pRevedit->setFrame(true); michael@1: m_pRevedit->setReadOnly(true); michael@1: m_pRevedit->setEnabled(false); michael@1: michael@1: // Whatsthis info for the revision edit michael@1: const char *kszRevtext = "Edit the revision by clicking " michael@1: "on this control and typing the new value " michael@1: "for this account type."; michael@3: Q3WhatsThis::add(m_pRevedit, kszRevtext); michael@1: QToolTip::add(m_pRevedit, trUtf8("Revision")); michael@1: m_pEditlayout->addWidget(m_pRevedit); // Finally add the revision edit michael@1: michael@1: // Make the date selector michael@1: m_pDateedit = new Daydatedit(QDate::currentDate(), m_pCenframe, "Date"); michael@1: if (m_pDateedit == NULL) // Sanity check michael@1: throw Genexcept("Main window date edit creation failed."); // Spew errors michael@1: michael@1: // Configure attributes michael@3: m_pDateedit->setOrder(Q3DateEdit::YMD); michael@1: m_pDateedit->setAutoAdvance(true); michael@1: m_pDateedit->setSeparator(trUtf8("-")); michael@1: m_pDateedit->setEnabled(false); michael@1: michael@1: // Whatsthis info for the date editor michael@1: const char *kszDateedit = "Edit the task date by clicking on " michael@1: "the year, month, or day, and then changing their " michael@1: "values with the arrow buttons."; michael@3: Q3WhatsThis::add(m_pDateedit, kszDateedit); michael@1: QToolTip::add(m_pDateedit, trUtf8("Task Date")); michael@1: m_pEditlayout->addWidget(m_pDateedit); // Finally add the date editor michael@1: michael@1: // Make the start time selector michael@3: m_pStarttime = new Q3TimeEdit(m_pCenframe, "StartTime"); michael@1: if (m_pStarttime == NULL) // Sanity check michael@1: throw Genexcept("Main window start time creation failed."); // Spew errors michael@1: michael@1: // Configure attributes michael@3: m_pStarttime->setDisplay(Q3TimeEdit::Hours | Q3TimeEdit::Minutes); michael@1: m_pStarttime->setAutoAdvance(true); michael@1: m_pStarttime->setEnabled(false); michael@1: michael@1: // Whatsthis info for the time editor michael@1: const char *kszStarttime = "Edit the task starting time by clicking on " michael@1: "the hour and minute, and then changing their " michael@1: "values with the arrow buttons."; michael@3: Q3WhatsThis::add(m_pStarttime, kszStarttime); michael@1: QToolTip::add(m_pStarttime, trUtf8("Task Starting Time")); michael@1: m_pEditlayout->addWidget(m_pStarttime); // Finally add the start editor michael@1: michael@1: // Make the end time selector michael@3: m_pEndtime = new Q3TimeEdit(m_pCenframe, "EndTime"); michael@1: if (m_pEndtime == NULL) // Sanity check michael@1: throw Genexcept("Main window end time creation failed."); // Spew errors michael@1: michael@1: // Configure attributes michael@3: m_pEndtime->setDisplay(Q3TimeEdit::Hours | Q3TimeEdit::Minutes); michael@1: m_pEndtime->setAutoAdvance(true); michael@1: m_pEndtime->setEnabled(false); michael@1: michael@1: // Whatsthis info for the time editor michael@1: const char *kszEndtime = "Edit the task ending time by clicking on " michael@1: "the hour and minute, and then changing their " michael@1: "values with the arrow buttons."; michael@3: Q3WhatsThis::add(m_pEndtime, kszEndtime); michael@1: QToolTip::add(m_pEndtime, trUtf8("Task Ending Time")); michael@1: m_pEditlayout->addWidget(m_pEndtime); // Finally add the end editor michael@1: michael@1: // // Make the total time amount selector michael@1: // m_pAmount = new QTimeEdit(m_pCenframe, "TotalAmount"); michael@1: // if (m_pAmount == NULL) // Sanity check michael@1: // throw Genexcept("Main window amount creation failed."); // Spew errors michael@1: // michael@1: // // Configure attributes michael@1: // m_pAmount->setDisplay(QTimeEdit::Hours | QTimeEdit::Minutes); michael@1: // m_pAmount->setAutoAdvance(true); michael@1: // m_pAmount->setEnabled(false); michael@1: michael@1: // Make the amount selector michael@1: m_pAmount = new ASTimeEdit(m_pCenframe, "TotalAmount"); michael@1: if (m_pAmount == NULL) // Sanity check michael@1: throw Genexcept("Main window amount creation failed."); // Spew errors michael@1: michael@1: // Whatsthis info for the amount editor michael@1: const char *kszAmount = "Edit the task amount by clicking on " michael@1: "the amount, and then changing its " michael@1: "value with the arrow buttons."; michael@3: Q3WhatsThis::add(m_pAmount, kszAmount); michael@1: QToolTip::add(m_pAmount, trUtf8("Task Amount")); michael@1: m_pAmount->setEnabled(false); // Don't enable until it's ready michael@1: m_pEditlayout->addWidget(m_pAmount); // Finally add the amount editor michael@1: michael@1: // Construct a stringlist just to hold task values michael@1: m_pTaskentries = new QStringList; michael@1: if (m_pTaskentries == NULL) // Sanity check michael@1: throw Genexcept("Main window task entries creation failed."); michael@1: michael@1: // Populate the stringlist with fresh accounts, taken from filename in prefs michael@1: QString Asdir = m_pPrefs->getString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS); michael@1: if (Asdir.startsWith(TITRAQ_HOMEDIRTOK)) michael@1: Asdir = QDir::homeDirPath() + Asdir.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1); michael@1: QFile Filetemp(Asdir); michael@1: this->loadAccounts(Filetemp); // Load account helper method michael@1: michael@1: // Make the combobox task edit michael@3: m_pTasks = new Q3ComboBox(true, m_pCenframe, "Tasks"); michael@1: if (m_pTasks == NULL) // Sanity check michael@1: throw Genexcept("Main window task edit creation failed."); michael@1: m_pTasks->insertStringList(*m_pTaskentries); michael@1: m_pTasks->setCurrentText(NULL); michael@1: m_pTasks->setSizeLimit(TITRAQ_ACCTBOXHEIGHT); michael@1: m_pTasks->setAutoCompletion(true); michael@1: m_pTasks->setDuplicatesEnabled(false); michael@1: m_pTasks->setEnabled(false); michael@1: // m_pTasks->setEditable(false); // Only idiots define noneditable and autocompletion michael@1: michael@1: // Add an auto scroll bar if possible under current GUI style michael@1: if (m_pTasks->listBox()) { // Motif style has no list box michael@1: int nPopupwidth = m_pTasks->listBox()->maxItemWidth(); michael@1: nPopupwidth += m_pTasks->listBox()->horizontalScrollBar()->height(); michael@1: m_pTasks->listBox()->setFixedWidth(nPopupwidth); michael@3: m_pTasks->listBox()->setHScrollBarMode(Q3ScrollView::Auto); michael@1: m_pTasks->listBox()->sort(); michael@1: } michael@1: michael@1: // Whatsthis info for the task editor michael@1: const char *kszTasktext = "Choose a task account by clicking on " michael@1: "this box, and choosing whichever item most " michael@1: "closely resembles your task."; michael@3: Q3WhatsThis::add(m_pTasks, kszTasktext); michael@1: QToolTip::add(m_pTasks, trUtf8("Task Selector")); michael@1: m_pEditlayout->addWidget(m_pTasks); // Finally add the task edit michael@1: michael@1: // Make the Remark line michael@1: m_pRemark = new QLineEdit(m_pCenframe, "Remark"); michael@1: if (m_pRemark == NULL) // Sanity check michael@1: throw Genexcept("Main window remark line creation failed."); michael@1: m_pRemark->setFrameShape(QLineEdit::LineEditPanel); michael@1: m_pRemark->setFrameShadow(QLineEdit::Sunken); michael@1: m_pRemark->setFrame(true); michael@1: m_pRemark->setReadOnly(false); michael@1: m_pRemark->setEnabled(false); michael@1: michael@1: // Whatsthis info for the remark line michael@1: const char *kszRemarktext = "Edit the task remarks by clicking on " michael@1: "this line control and typing the remarks you " michael@1: "have about the task."; michael@3: Q3WhatsThis::add(m_pRemark, kszRemarktext); michael@1: QToolTip::add(m_pRemark, trUtf8("Remark Line")); michael@1: m_pEditlayout->addWidget(m_pRemark); // Finally add the remark line michael@1: michael@1: // Start edit controls off at right size michael@1: this->updSizes(TITRAQ_IDXALLCTRLS, -1, -1); michael@1: michael@1: // Validate data just as it is being entered michael@1: connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(validateRow(void))); michael@1: connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void))); michael@1: connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void))); michael@1: connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void))); michael@1: connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(validateRow(void))); michael@1: connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(validateRow(void))); michael@1: michael@1: // Signals sent between table cells and corresponding edit control widgets michael@1: connect(m_pLineedit, SIGNAL(textChanged(const QString &)), SLOT(updateLine(const QString &))); michael@1: connect(m_pUseredit, SIGNAL(textChanged(const QString &)), SLOT(updateUser(const QString &))); michael@1: connect(m_pGuidedit, SIGNAL(textChanged(const QString &)), SLOT(updateGuid(const QString &))); michael@1: connect(m_pCrcedit, SIGNAL(textChanged(const QString &)), SLOT(updateCrc(const QString &))); michael@1: connect(m_pRevedit, SIGNAL(textChanged(const QString &)), SLOT(updateRev(const QString &))); michael@1: connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(updateDate(const QDate &))); michael@1: connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(updateStart(const QTime &))); michael@1: connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(updateFinish(const QTime &))); michael@1: connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(updateAmount(const QTime &))); michael@1: connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(updateTask(const QString &))); michael@1: connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(updateRemark(const QString &))); michael@1: michael@1: // Correctly update checksum and revision fields also michael@1: connect(m_pUseredit, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void))); michael@1: connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(calcCrc(void))); michael@1: connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void))); michael@1: connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void))); michael@1: connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void))); michael@1: connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void))); michael@1: connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void))); michael@1: } michael@1: michael@1: // michael@1: // Arrange and configure columns michael@1: // michael@1: void Titraqform::setupColumns(void) michael@1: { michael@1: // Handle column view handling presets and defaults michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFSTATCOLON, TITRAQ_DEFSTATCOLON)) michael@1: showStatcol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFLCOLON, TITRAQ_DEFLCOLON)) michael@1: showLinecol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFUCOLON, TITRAQ_DEFUCOLON)) michael@1: showUsercol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFGCOLON, TITRAQ_DEFGCOLON)) michael@1: showGuidcol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFCCOLON, TITRAQ_DEFCCOLON)) michael@1: showCrccol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFREVCOLON, TITRAQ_DEFREVCOLON)) michael@1: showRevcol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFDCOLON, TITRAQ_DEFDCOLON)) michael@1: showDatecol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFSTARTCOLON, TITRAQ_DEFSTARTCOLON)) michael@1: showStartcol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFFCOLON, TITRAQ_DEFFCOLON)) michael@1: showFinishcol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFACOLON, TITRAQ_DEFACOLON)) michael@1: showAmountcol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFTCOLON, TITRAQ_DEFTCOLON)) michael@1: showTaskcol(); michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFREMCOLON, TITRAQ_DEFREMCOLON)) michael@1: showRemarkcol(); michael@1: michael@1: // Handle tool bar view handling presets and defaults michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFFILEBAR, TITRAQ_DEFFILEBAR)) { michael@1: m_pFiletools->hide(); michael@1: m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR), false); michael@1: } michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFEDITBAR, TITRAQ_DEFEDITBAR)) { michael@1: m_pEdittools->hide(); michael@1: m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR), false); michael@1: } michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFVIEWBAR, TITRAQ_DEFVIEWBAR)) { michael@1: m_pViewtools->hide(); michael@1: m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR), false); michael@1: } michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFPREFBAR, TITRAQ_DEFPREFBAR)) { michael@1: m_pPrefstools->hide(); michael@1: m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR), false); michael@1: } michael@1: if (!m_pPrefs->getBool(TITRAQ_PREFWHATBAR, TITRAQ_DEFWHATBAR)) { michael@1: m_pWhatstools->hide(); michael@1: m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), false); michael@1: } michael@1: } michael@1: michael@1: // michael@1: // [En|dis]able most ui pieces to suit or restrict user michael@1: // michael@1: void Titraqform::enableIface(bool bTurned) michael@1: { michael@1: // FIXME: Does not belong here, so relocate michael@1: if (bTurned) // Turn off the interface michael@1: m_pDateedit->setDayfocus(); // Default focus is on day michael@1: else { // Turn on the interface michael@1: m_pMaintable->setNumRows(0); // Remove table data michael@1: m_pStatusedit->setPixmap(QPixmap(s_kpcStatvoid_xpm)); michael@1: } michael@1: michael@1: // Enable or disable the widgets michael@1: m_pMaintable->setEnabled(bTurned); michael@1: m_pLineedit->setEnabled(bTurned); michael@1: m_pUseredit->setEnabled(bTurned); michael@1: m_pGuidedit->setEnabled(bTurned); michael@1: m_pCrcedit->setEnabled(bTurned); michael@1: m_pRevedit->setEnabled(bTurned); michael@1: m_pDateedit->setEnabled(bTurned); michael@1: m_pStarttime->setEnabled(bTurned); michael@1: m_pEndtime->setEnabled(bTurned); michael@1: m_pAmount->setEnabled(bTurned); michael@1: m_pTasks->setEnabled(bTurned); michael@1: m_pRemark->setEnabled(bTurned); michael@1: michael@1: // Enable or disable the actions michael@1: m_pFilesaveact->setEnabled(bTurned); michael@1: m_pFilesaveasact->setEnabled(bTurned); michael@1: m_pFilecloseact->setEnabled(bTurned); michael@1: m_pAddrowact->setEnabled(bTurned); michael@1: m_pDelrowact->setEnabled(bTurned); michael@1: m_pRefreshact->setEnabled(bTurned); michael@1: m_pCutact->setEnabled(bTurned); michael@1: m_pCopyact->setEnabled(bTurned); michael@1: m_pPasteact->setEnabled(bTurned); michael@1: m_pReportact->setEnabled(bTurned); michael@1: #if defined HAVE_MICO || defined HAVE_ESOAP michael@1: if (bTurned) michael@1: m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON) michael@1: | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)); michael@1: else michael@1: m_pSyncact->setEnabled(false); michael@1: #endif // defined HAVE_MICO || defined HAVE_ESOAP michael@1: michael@1: // Unconditional settings michael@1: m_pMaintable->setDirty(false); // Reset to clean data michael@1: } michael@1: michael@1: // michael@1: // Parse command line arguments for an existing filename, and michael@1: // open it to edit the intended (but optional) initial data michael@1: // michael@1: void Titraqform::loadInit(void) michael@1: { michael@1: // If the user gives a filename argument to the shell, then open that file michael@1: int nNumargs = qApp->argc(); // Holds the number of cmd arguments michael@1: int nValid = 0; // Holds the return value michael@1: QFile Initial; // Initial event data file michael@1: michael@1: if (nNumargs > 1) { // Warm up a nice cascade, to set my mind on four weeks of vacation michael@1: for (int nIter = 1; nIter < nNumargs; nIter++) { // Salad in New Zealand michael@1: if (QChar(*qApp->argv()[nIter]) != '-') { // Bunuelos in Colombia michael@1: try { michael@1: this->setFilename(qApp->argv()[nIter]); // Store inital filename michael@1: Initial.setName(*this->getFilename()); // Initial file to load michael@1: if (Initial.exists(*getFilename()) && validateData(Initial)) { michael@1: this->loadData(Initial); // Pass to helper method michael@1: enableIface(true); // Turn on the lights michael@1: m_pStatbar->message(trUtf8("Loaded document ") + *this->getFilename()); michael@1: } michael@1: else // The inital file name does not correspond to a file michael@1: m_pStatbar->message(trUtf8(QString("The file ") + *this->getFilename() + QString(" does not exist."))); michael@1: } michael@1: catch (Genexcept& Genex) { michael@1: Genex.reportErr(); michael@1: } michael@1: } michael@1: } michael@1: } michael@1: else michael@1: m_pStatbar->message(trUtf8("Ready")); // Signal a ready condition michael@1: }