Fri, 28 Nov 2008 11:21:08 +0100
Fork project trunk at version 0.7.7 to maintain for future usage.
The original Cable & Wireless development team no longer exists.
The OSSP CVS repository is unavailable (cvs co ossp-pkg/as fails),
however http://cvs.ossp.org/dirview?d=ossp-pkg/as/as-gui is working.
michael@1 | 1 | // |
michael@1 | 2 | // OSSP asgui - Accounting system graphical user interface |
michael@1 | 3 | // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) |
michael@1 | 4 | // Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com> |
michael@1 | 5 | // Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com> |
michael@1 | 6 | // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH |
michael@1 | 7 | // |
michael@1 | 8 | // This file is part of OSSP asgui, an accounting system graphical user |
michael@1 | 9 | // interface which can be found at http://www.ossp.org/pkg/tool/asgui/. |
michael@1 | 10 | // |
michael@1 | 11 | // Permission to use, copy, modify, and distribute this software for |
michael@1 | 12 | // any purpose with or without fee is hereby granted, provided that |
michael@1 | 13 | // the above copyright notice and this permission notice appear in all |
michael@1 | 14 | // copies. |
michael@1 | 15 | // |
michael@1 | 16 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
michael@1 | 17 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
michael@1 | 18 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
michael@1 | 19 | // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
michael@1 | 20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@1 | 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@1 | 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
michael@1 | 23 | // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
michael@1 | 24 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
michael@1 | 25 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
michael@1 | 26 | // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
michael@1 | 27 | // SUCH DAMAGE. |
michael@1 | 28 | // |
michael@1 | 29 | // as_assist.cpp: ISO C++ implementation |
michael@1 | 30 | // |
michael@1 | 31 | |
michael@1 | 32 | // Qt style headers |
michael@1 | 33 | #include <qcdestyle.h> |
michael@1 | 34 | #include <qsgistyle.h> |
michael@1 | 35 | #include <qmotifstyle.h> |
michael@1 | 36 | #include <qmotifplusstyle.h> |
michael@1 | 37 | #include <qplatinumstyle.h> |
michael@1 | 38 | #include <qwindowsstyle.h> |
michael@1 | 39 | |
michael@1 | 40 | // Qt general headers |
michael@1 | 41 | #include <qtooltip.h> |
michael@1 | 42 | #include <qwhatsthis.h> |
michael@1 | 43 | #include <qstringlist.h> |
michael@1 | 44 | #include <qpopupmenu.h> |
michael@1 | 45 | #include <qcombobox.h> |
michael@1 | 46 | #include <qlistbox.h> |
michael@1 | 47 | #include <qstatusbar.h> |
michael@1 | 48 | #include <qmenubar.h> |
michael@1 | 49 | #include <qcursor.h> |
michael@1 | 50 | #include <qaction.h> |
michael@1 | 51 | #include <qrect.h> |
michael@1 | 52 | #include <qdir.h> |
michael@1 | 53 | |
michael@1 | 54 | // User interface |
michael@1 | 55 | #include "as_amount.h" // AmountBox class |
michael@1 | 56 | #include "as_user.h" // User class |
michael@1 | 57 | #include "as_const.h" // Application constants |
michael@1 | 58 | #include "as_table.h" // Class TiTable |
michael@1 | 59 | #include "as_pref.h" // Class Preferences |
michael@1 | 60 | #include "as_panel.h" // Class Prefpanel |
michael@1 | 61 | #include "as_datedit.h" // Class Daydateedit |
michael@1 | 62 | |
michael@1 | 63 | // Icon pixel maps |
michael@1 | 64 | #include "as_gfx/filenew.xpm" // static const char *s_kpcFilenew_xpm[] |
michael@1 | 65 | #include "as_gfx/fileopen.xpm" // static const char *s_kpcFileopen_xpm[] |
michael@1 | 66 | #include "as_gfx/filesave.xpm" // static const char *s_kpcFilesave_xpm[] |
michael@1 | 67 | #include "as_gfx/filesaved.xpm" // static const char *s_kpcDfilesave_xpm[] |
michael@1 | 68 | #include "as_gfx/cut.xpm" // static const char *s_kpcCut_xpm[] |
michael@1 | 69 | #include "as_gfx/cutd.xpm" // static const char *s_kpcDcut_xpm[] |
michael@1 | 70 | #include "as_gfx/copy.xpm" // static const char *s_kpcCopy_xpm[] |
michael@1 | 71 | #include "as_gfx/copyd.xpm" // static const char *s_kpcDcopy_xpm[] |
michael@1 | 72 | #include "as_gfx/paste.xpm" // static const char *s_kpcPaste_xpm[] |
michael@1 | 73 | #include "as_gfx/pasted.xpm" // static const char *s_kpcDcaste_xpm[] |
michael@1 | 74 | #include "as_gfx/rowadd.xpm" // static const char *s_kpcRowadd_xpm[] |
michael@1 | 75 | #include "as_gfx/rowdel.xpm" // static const char *s_kpcRowdel_xpm[] |
michael@1 | 76 | #include "as_gfx/rowaddd.xpm" // static const char *s_kpcDrowadd_xpm[] |
michael@1 | 77 | #include "as_gfx/rowdeld.xpm" // static const char *s_kpcDrowdel_xpm[] |
michael@1 | 78 | #include "as_gfx/osspicon.xpm" // static const char *s_kpcOsspicon_xpm[] |
michael@1 | 79 | #include "as_gfx/whatsthis.xpm" // static const char *s_kpcWhatsthis_xpm[] |
michael@1 | 80 | #include "as_gfx/statok.xpm" // static const char *s_kpcStatokay_xpm[] |
michael@1 | 81 | #include "as_gfx/staterr.xpm" // static const char *s_kpcStaterror_xpm[] |
michael@1 | 82 | #include "as_gfx/statwrn.xpm" // static const char *s_kpcStatwarn_xpm[] |
michael@1 | 83 | #include "as_gfx/statvoid.xpm" // static const char *s_kpcStatvoid_xpm[] |
michael@1 | 84 | #include "as_gfx/refresh.xpm" // static const char *s_kpcRefresh_xpm[] |
michael@1 | 85 | #include "as_gfx/refreshd.xpm" // static const char *s_kpcDrefresh_xpm[] |
michael@1 | 86 | #include "as_gfx/sync.xpm" // static const char *s_kpcSync_xpm[] |
michael@1 | 87 | #include "as_gfx/syncd.xpm" // static const char *s_kpcDsync_xpm[] |
michael@1 | 88 | #include "as_gfx/report.xpm" // static const char *s_kpcReport_xpm[] |
michael@1 | 89 | #include "as_gfx/reportd.xpm" // static const char *s_kpcDreport_xpm[] |
michael@1 | 90 | #include "as_gfx/prefs.xpm" // static const char *s_kpcPrefs_xpm[] |
michael@1 | 91 | |
michael@1 | 92 | |
michael@1 | 93 | // |
michael@1 | 94 | // Construct the preferences |
michael@1 | 95 | // |
michael@1 | 96 | void Titraqform::setupPrefs(void) |
michael@1 | 97 | { |
michael@1 | 98 | // Can't bootstrap until we know who is using our tool, so find out |
michael@1 | 99 | User Localuser = User(); |
michael@1 | 100 | QString Username = Localuser.getName(); |
michael@1 | 101 | QString Homedir = Localuser.getHomedir(); |
michael@1 | 102 | |
michael@1 | 103 | // Bootstrap a user preferences object from operating system info |
michael@1 | 104 | m_pPrefs = new Preferences(Homedir + QChar('/') + |
michael@1 | 105 | QString::fromLocal8Bit(TITRAQ_PREFNAME), |
michael@1 | 106 | QString::fromLocal8Bit(TITRAQ_APPTITLE), |
michael@1 | 107 | QString::fromLocal8Bit(TITRAQ_PREFVER)); |
michael@1 | 108 | if (!m_pPrefs->fileState()) { // No file was found, so assume a null state |
michael@1 | 109 | if (!Homedir.isEmpty()) |
michael@1 | 110 | m_pPrefs->setString(TITRAQ_PREFHOME, Homedir); |
michael@1 | 111 | else |
michael@1 | 112 | m_pPrefs->setString(TITRAQ_PREFHOME, TITRAQ_DEFHOME); |
michael@1 | 113 | if (!Username.isEmpty()) |
michael@1 | 114 | m_pPrefs->setString(TITRAQ_PREFUSER, Username); |
michael@1 | 115 | else |
michael@1 | 116 | m_pPrefs->setString(TITRAQ_PREFUSER, TITRAQ_DEFUSER); |
michael@1 | 117 | |
michael@1 | 118 | m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE); |
michael@1 | 119 | m_pPrefs->setString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS); |
michael@1 | 120 | m_pPrefs->setString(TITRAQ_PREFASDIR, TITRAQ_DEFASDIR); |
michael@1 | 121 | m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW); |
michael@1 | 122 | m_pPrefs->setNumber(TITRAQ_PREFSORTCOL, TITRAQ_DEFSORTCOL); |
michael@1 | 123 | m_pPrefs->setBool(TITRAQ_PREFSORTDIR, TITRAQ_DEFSORTDIR); |
michael@1 | 124 | m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG); |
michael@1 | 125 | m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG); |
michael@1 | 126 | m_pPrefs->setString(TITRAQ_PREFCORBHOST, TITRAQ_DEFCORBHOST); |
michael@1 | 127 | m_pPrefs->setString(TITRAQ_PREFSOAPHOST, TITRAQ_DEFSOAPHOST); |
michael@1 | 128 | m_pPrefs->setBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON); |
michael@1 | 129 | m_pPrefs->setBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON); |
michael@1 | 130 | m_pPrefs->setBool(TITRAQ_PREFBAKON, TITRAQ_DEFBAKON); |
michael@1 | 131 | m_pPrefs->setBool(TITRAQ_PREFEXTENDON, TITRAQ_DEFEXTENDON); |
michael@1 | 132 | m_pPrefs->setBool(TITRAQ_PREFDETAILON, TITRAQ_DEFDETAILON); |
michael@1 | 133 | m_pPrefs->setBool(TITRAQ_PREFSIGNATON, TITRAQ_DEFSIGNATON); |
michael@1 | 134 | m_pPrefs->setNumber(TITRAQ_PREFREPORTYPE, TITRAQ_DEFREPORTYPE); |
michael@1 | 135 | m_pPrefs->setNumber(TITRAQ_PREFREPORTWEEKS, TITRAQ_DEFREPORTWEEKS); |
michael@1 | 136 | m_pPrefs->setNumber(TITRAQ_PREFREPORTMONTHS, TITRAQ_DEFREPORTMONTHS); |
michael@1 | 137 | m_pPrefs->setNumber(TITRAQ_PREFLIGHTRED, TITRAQ_DEFLIGHTRED); |
michael@1 | 138 | m_pPrefs->setNumber(TITRAQ_PREFLIGHTGREEN, TITRAQ_DEFLIGHTGREEN); |
michael@1 | 139 | m_pPrefs->setNumber(TITRAQ_PREFLIGHTBLUE, TITRAQ_DEFLIGHTBLUE); |
michael@1 | 140 | m_pPrefs->setNumber(TITRAQ_PREFDARKRED, TITRAQ_DEFDARKRED); |
michael@1 | 141 | m_pPrefs->setNumber(TITRAQ_PREFDARKGREEN, TITRAQ_DEFDARKGREEN); |
michael@1 | 142 | m_pPrefs->setNumber(TITRAQ_PREFDARKBLUE, TITRAQ_DEFDARKBLUE); |
michael@1 | 143 | m_pPrefs->flush(); // Write the new conf file |
michael@1 | 144 | QTextStream cerr(stderr, IO_WriteOnly); |
michael@1 | 145 | cerr << trUtf8("Created new preferences file ") << Homedir << QChar('/') |
michael@1 | 146 | << QString::fromLocal8Bit(TITRAQ_PREFNAME) << endl; |
michael@1 | 147 | } |
michael@1 | 148 | |
michael@1 | 149 | // Use the preferred configuration values to initialize titraq |
michael@1 | 150 | switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) { |
michael@1 | 151 | case TITRAQ_STYLECDE: |
michael@1 | 152 | qApp->setStyle(new QCDEStyle); |
michael@1 | 153 | break; |
michael@1 | 154 | case TITRAQ_STYLESGI: |
michael@1 | 155 | qApp->setStyle(new QSGIStyle); |
michael@1 | 156 | break; |
michael@1 | 157 | case TITRAQ_STYLEMOTIF: |
michael@1 | 158 | qApp->setStyle(new QMotifStyle); |
michael@1 | 159 | break; |
michael@1 | 160 | case TITRAQ_STYLEMPLUS: |
michael@1 | 161 | qApp->setStyle(new QMotifPlusStyle); |
michael@1 | 162 | break; |
michael@1 | 163 | case TITRAQ_STYLEPLAT: |
michael@1 | 164 | qApp->setStyle(new QPlatinumStyle); |
michael@1 | 165 | break; |
michael@1 | 166 | case TITRAQ_STYLEMSOFT: |
michael@1 | 167 | qApp->setStyle(new QWindowsStyle); |
michael@1 | 168 | break; |
michael@1 | 169 | default: |
michael@1 | 170 | qApp->setStyle(new QCDEStyle); |
michael@1 | 171 | break; |
michael@1 | 172 | } |
michael@1 | 173 | } |
michael@1 | 174 | |
michael@1 | 175 | // |
michael@1 | 176 | // Construct various actions |
michael@1 | 177 | // |
michael@1 | 178 | void Titraqform::setupActions(void) |
michael@1 | 179 | { |
michael@1 | 180 | QIconSet Saveiset, Cutiset, Copyiset, Pasteiset; |
michael@1 | 181 | QIconSet Rowaddiset, Rowdeliset, Refreshiset; |
michael@1 | 182 | QIconSet Synciset, Reportiset; |
michael@1 | 183 | |
michael@1 | 184 | // Construct iconsets to use later for multistate action images |
michael@1 | 185 | Saveiset.setPixmap(QPixmap(s_kpcFilesave_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 186 | Saveiset.setPixmap(QPixmap(s_kpcDfilesave_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 187 | Cutiset.setPixmap(QPixmap(s_kpcCut_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 188 | Cutiset.setPixmap(QPixmap(s_kpcDcut_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 189 | Copyiset.setPixmap(QPixmap(s_kpcCopy_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 190 | Copyiset.setPixmap(QPixmap(s_kpcDcopy_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 191 | Pasteiset.setPixmap(QPixmap(s_kpcPaste_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 192 | Pasteiset.setPixmap(QPixmap(s_kpcDpaste_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 193 | Rowaddiset.setPixmap(QPixmap(s_kpcRowadd_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 194 | Rowaddiset.setPixmap(QPixmap(s_kpcDrowadd_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 195 | Rowdeliset.setPixmap(QPixmap(s_kpcRowdel_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 196 | Rowdeliset.setPixmap(QPixmap(s_kpcDrowdel_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 197 | Refreshiset.setPixmap(QPixmap(s_kpcRefresh_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 198 | Refreshiset.setPixmap(QPixmap(s_kpcDrefresh_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 199 | Synciset.setPixmap(QPixmap(s_kpcSync_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 200 | Synciset.setPixmap(QPixmap(s_kpcDsync_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 201 | Reportiset.setPixmap(QPixmap(s_kpcReport_xpm), QIconSet::Automatic, QIconSet::Normal); |
michael@1 | 202 | Reportiset.setPixmap(QPixmap(s_kpcDreport_xpm), QIconSet::Automatic, QIconSet::Disabled); |
michael@1 | 203 | |
michael@1 | 204 | // First associate the graphics with MIME types |
michael@1 | 205 | QMimeSourceFactory::defaultFactory()->setPixmap("osspicon", QPixmap(s_kpcOsspicon_xpm)); |
michael@1 | 206 | QMimeSourceFactory::defaultFactory()->setPixmap("filenew", QPixmap(s_kpcFilenew_xpm)); |
michael@1 | 207 | QMimeSourceFactory::defaultFactory()->setPixmap("fileopen", QPixmap(s_kpcFileopen_xpm)); |
michael@1 | 208 | QMimeSourceFactory::defaultFactory()->setPixmap("filesave", QPixmap(s_kpcFilesave_xpm)); |
michael@1 | 209 | QMimeSourceFactory::defaultFactory()->setPixmap("cut", QPixmap(s_kpcCut_xpm)); |
michael@1 | 210 | QMimeSourceFactory::defaultFactory()->setPixmap("copy", QPixmap(s_kpcCopy_xpm)); |
michael@1 | 211 | QMimeSourceFactory::defaultFactory()->setPixmap("paste", QPixmap(s_kpcPaste_xpm)); |
michael@1 | 212 | QMimeSourceFactory::defaultFactory()->setPixmap("rowadd", QPixmap(s_kpcRowadd_xpm)); |
michael@1 | 213 | QMimeSourceFactory::defaultFactory()->setPixmap("rowdel", QPixmap(s_kpcRowdel_xpm)); |
michael@1 | 214 | QMimeSourceFactory::defaultFactory()->setPixmap("refresh", QPixmap(s_kpcRefresh_xpm)); |
michael@1 | 215 | QMimeSourceFactory::defaultFactory()->setPixmap("syncrpc", QPixmap(s_kpcSync_xpm)); |
michael@1 | 216 | QMimeSourceFactory::defaultFactory()->setPixmap("locreport", QPixmap(s_kpcReport_xpm)); |
michael@1 | 217 | QMimeSourceFactory::defaultFactory()->setPixmap("prefs", QPixmap(s_kpcPrefs_xpm)); |
michael@1 | 218 | |
michael@1 | 219 | // File new action |
michael@1 | 220 | m_pFilenewact = new QAction(trUtf8("New File"), QPixmap(s_kpcFilenew_xpm), trUtf8("&New"), CTRL+Key_N, this, "New"); |
michael@1 | 221 | if (m_pFilenewact == NULL) // Sanity check |
michael@1 | 222 | throw Genexcept("Main window file new action creation failed."); |
michael@1 | 223 | connect(m_pFilenewact, SIGNAL(activated()), SLOT(newDoc())); |
michael@1 | 224 | const char *kszFilenewtext = "<p><img source=\"filenew\"> " |
michael@1 | 225 | "Click this button to make a " |
michael@1 | 226 | "<em>blank file</em>. You can also " |
michael@1 | 227 | "select the <b>New</b> command from " |
michael@1 | 228 | "the <b>File</b> menu.</p>"; |
michael@1 | 229 | m_pFilenewact->setWhatsThis(kszFilenewtext); |
michael@1 | 230 | |
michael@1 | 231 | // File open action |
michael@1 | 232 | m_pFileopenact = new QAction(trUtf8("Open File"), QPixmap(s_kpcFileopen_xpm), trUtf8("&Open..."), CTRL+Key_O, this, "Open"); |
michael@1 | 233 | if (m_pFileopenact == NULL) // Sanity check |
michael@1 | 234 | throw Genexcept("Main window file open action creation failed."); |
michael@1 | 235 | connect(m_pFileopenact, SIGNAL(activated()), SLOT(openDoc())); |
michael@1 | 236 | const char *kszFileopentext = "<p><img source=\"fileopen\"> " |
michael@1 | 237 | "Click this button to open a " |
michael@1 | 238 | "<em>new file</em>. You can also select " |
michael@1 | 239 | "the <b>Open</b> command from the " |
michael@1 | 240 | "<b>File</b> menu.</p>"; |
michael@1 | 241 | m_pFileopenact->setWhatsThis(kszFileopentext); |
michael@1 | 242 | |
michael@1 | 243 | // File save current action |
michael@1 | 244 | m_pFilesaveact = new QAction(trUtf8("Save File"), Saveiset, trUtf8("&Save"), CTRL+Key_S, this, "Save"); |
michael@1 | 245 | if (m_pFilesaveact == NULL) // Sanity check |
michael@1 | 246 | throw Genexcept("Main window file save action creation failed."); |
michael@1 | 247 | connect(m_pFilesaveact, SIGNAL(activated()), SLOT(saveFile())); |
michael@1 | 248 | const char *kszFilesavetext = "<p><img source=\"filesave\"> " |
michael@1 | 249 | "Click this button to <em>save</em> " |
michael@1 | 250 | "the file you are editing. You will be " |
michael@1 | 251 | "prompted for a file name. You can also " |
michael@1 | 252 | "select the<b> Save</b> command from " |
michael@1 | 253 | "the <b>File</b> menu.</p>"; |
michael@1 | 254 | m_pFilesaveact->setWhatsThis(kszFilesavetext); |
michael@1 | 255 | |
michael@1 | 256 | // File save selected action |
michael@1 | 257 | m_pFilesaveasact = new QAction(trUtf8("Save File As"), trUtf8("Save &As..."), 0, this, "SaveAs"); |
michael@1 | 258 | if (m_pFilesaveasact == NULL) // Sanity check |
michael@1 | 259 | throw Genexcept("Main window file save as action creation failed."); |
michael@1 | 260 | connect(m_pFilesaveasact, SIGNAL(activated()), SLOT(saveAs())); |
michael@1 | 261 | m_pFilesaveasact->setWhatsThis(kszFilesavetext); |
michael@1 | 262 | |
michael@1 | 263 | // File close current action |
michael@1 | 264 | m_pFilecloseact = new QAction(trUtf8("Close"), trUtf8("&Close"), CTRL+Key_W, this, "Close"); |
michael@1 | 265 | if (m_pFilecloseact == NULL) // Sanity check |
michael@1 | 266 | throw Genexcept("Main window file close action creation failed."); |
michael@1 | 267 | connect(m_pFilecloseact, SIGNAL(activated()), SLOT(close())); |
michael@1 | 268 | |
michael@1 | 269 | // File quit action |
michael@1 | 270 | m_pFilequitact = new QAction(trUtf8("Exit"), trUtf8("E&xit"), CTRL+Key_Q, this, "Exit"); |
michael@1 | 271 | if (m_pFilequitact == NULL) // Sanity check |
michael@1 | 272 | throw Genexcept("Main window file quit action creation failed."); |
michael@1 | 273 | connect(m_pFilequitact, SIGNAL(activated()), SLOT(quitApp())); |
michael@1 | 274 | |
michael@1 | 275 | // Cut action |
michael@1 | 276 | m_pCutact = new QAction(trUtf8("Cut"), Cutiset, trUtf8("&Cut"), CTRL+Key_X, this, "Cut"); |
michael@1 | 277 | if (m_pCutact == NULL) // Sanity check |
michael@1 | 278 | throw Genexcept("Main window cut edit action creation failed."); |
michael@1 | 279 | connect(m_pCutact, SIGNAL(activated()), SLOT(cutEntry())); |
michael@1 | 280 | const char *kszCuttext = "<p><img source=\"cut\"> " |
michael@1 | 281 | "Click this button to cut an <em>entry</em>. " |
michael@1 | 282 | "You can also select the <b>Cut</b> command " |
michael@1 | 283 | "from the <b>Edit</b> menu.</p>"; |
michael@1 | 284 | m_pCutact->setWhatsThis(kszCuttext); |
michael@1 | 285 | |
michael@1 | 286 | // Copy action |
michael@1 | 287 | m_pCopyact = new QAction(trUtf8("Copy"), Copyiset, trUtf8("&Copy"), CTRL+Key_C, this, "Copy"); |
michael@1 | 288 | if (m_pCopyact == NULL) // Sanity check |
michael@1 | 289 | throw Genexcept("Main window copy edit action creation failed."); |
michael@1 | 290 | connect(m_pCopyact, SIGNAL(activated()), SLOT(copyEntry())); |
michael@1 | 291 | const char *kszCopytext = "<p><img source=\"copy\"> " |
michael@1 | 292 | "Click this button to copy an <em>entry</em>. " |
michael@1 | 293 | "You can also select the <b>Copy</b> command " |
michael@1 | 294 | "from the <b>Edit</b> menu.</p>"; |
michael@1 | 295 | m_pCopyact->setWhatsThis(kszCopytext); |
michael@1 | 296 | |
michael@1 | 297 | // Paste action |
michael@1 | 298 | m_pPasteact = new QAction(trUtf8("Paste"), Pasteiset, trUtf8("&Paste"), CTRL+Key_V, this, "Paste"); |
michael@1 | 299 | if (m_pPasteact == NULL) // Sanity check |
michael@1 | 300 | throw Genexcept("Main window paste edit action creation failed."); |
michael@1 | 301 | connect(m_pPasteact, SIGNAL(activated()), SLOT(pasteEntry())); |
michael@1 | 302 | const char *kszPastetext = "<p><img source=\"paste\"> " |
michael@1 | 303 | "Click this button to paste an <em>entry</em>. " |
michael@1 | 304 | "You can also select the <b>Paste</b> command " |
michael@1 | 305 | "from the <b>Edit</b> menu.</p>"; |
michael@1 | 306 | m_pPasteact->setWhatsThis(kszPastetext); |
michael@1 | 307 | |
michael@1 | 308 | // Add data row action |
michael@1 | 309 | m_pAddrowact = new QAction(trUtf8("Add Entry"), Rowaddiset, trUtf8("&Add entry"), Key_Insert, this, "Addentry"); |
michael@1 | 310 | if (m_pAddrowact == NULL) // Sanity check |
michael@1 | 311 | throw Genexcept("Main window add entry action creation failed."); |
michael@1 | 312 | connect(m_pAddrowact, SIGNAL(activated()), SLOT(addEntry())); |
michael@1 | 313 | const char *kszAddrowtext = "<p><img source=\"rowadd\"> " |
michael@1 | 314 | "Click this button to add a <em>new entry</em>. " |
michael@1 | 315 | "You can also select the <b>Add</b> command " |
michael@1 | 316 | "from the <b>Edit</b> menu.</p>"; |
michael@1 | 317 | m_pAddrowact->setWhatsThis(kszAddrowtext); |
michael@1 | 318 | |
michael@1 | 319 | // Delete data row action |
michael@1 | 320 | m_pDelrowact = new QAction(trUtf8("Delete Entry"), Rowdeliset, trUtf8("&Delete entry"), Key_Delete, this, "Delentry"); |
michael@1 | 321 | if (m_pDelrowact == NULL) // Sanity check |
michael@1 | 322 | throw Genexcept("Main window delete entry action creation failed."); |
michael@1 | 323 | connect(m_pDelrowact, SIGNAL(activated()), SLOT(delEntry())); |
michael@1 | 324 | const char *kszDelrowtext = "<p><img source=\"rowdel\"> " |
michael@1 | 325 | "Click this button to delete a <em>entry</em>. " |
michael@1 | 326 | "You can also select the <b>Delete</b> command " |
michael@1 | 327 | "from the <b>Edit</b> menu.</p>"; |
michael@1 | 328 | m_pDelrowact->setWhatsThis(kszDelrowtext); |
michael@1 | 329 | |
michael@1 | 330 | // Refresh data display action |
michael@1 | 331 | m_pRefreshact = new QAction(trUtf8("Refresh Display"), Refreshiset, trUtf8("&Refresh display"), CTRL+Key_R, this, "Refresh"); |
michael@1 | 332 | if (m_pRefreshact == NULL) // Sanity check |
michael@1 | 333 | throw Genexcept("Main window refresh action creation failed."); |
michael@1 | 334 | connect(m_pRefreshact, SIGNAL(activated()), SLOT(refreshDisplay())); |
michael@1 | 335 | const char *kszRefreshtext = "<p><img source=\"refresh\"> " |
michael@1 | 336 | "Click this button to <em>refresh the display</em>. " |
michael@1 | 337 | "You can also select the <b>Refresh</b> command " |
michael@1 | 338 | "from the <b>View</b> menu.</p>"; |
michael@1 | 339 | m_pRefreshact->setWhatsThis(kszRefreshtext); |
michael@1 | 340 | |
michael@1 | 341 | // Syncronize data with remote server over IIOP or SOAP action |
michael@1 | 342 | m_pSyncact = new QAction(trUtf8("Synchronize with server"), Synciset, trUtf8("&Synchronize"), CTRL+Key_E, this, "Synchronize"); |
michael@1 | 343 | if (m_pSyncact == NULL) // Sanity check |
michael@1 | 344 | throw Genexcept("Main window synchronize RPC action creation failed."); |
michael@1 | 345 | connect(m_pSyncact, SIGNAL(activated()), SLOT(syncIiop())); |
michael@1 | 346 | connect(m_pSyncact, SIGNAL(activated()), SLOT(syncSoap())); |
michael@1 | 347 | const char *kszSynctext = "<p><img source=\"syncrpc\"> " |
michael@1 | 348 | "Click this button to <em>synchronize the data</em>. " |
michael@1 | 349 | "Your changed entries will be sent to the server. " |
michael@1 | 350 | "You can also select the <b>Synchronize</b> command " |
michael@1 | 351 | "from the <b>Report</b> menu.</p>"; |
michael@1 | 352 | m_pSyncact->setWhatsThis(kszSynctext); |
michael@1 | 353 | |
michael@1 | 354 | // Local report generation action |
michael@1 | 355 | m_pReportact = new QAction(trUtf8("Generate a local report"), Reportiset, trUtf8("&Report"), CTRL+Key_T, this, "LocalReport"); |
michael@1 | 356 | if (m_pReportact == NULL) // Sanity check |
michael@1 | 357 | throw Genexcept("Main window local report action creation failed."); |
michael@1 | 358 | connect(m_pReportact, SIGNAL(activated()), SLOT(genReport())); |
michael@1 | 359 | const char *kszReporttext = "<p><img source=\"locreport\"> " |
michael@1 | 360 | "Click this button to <em>report your data</em>. " |
michael@1 | 361 | "A local report will be generated for you to view. " |
michael@1 | 362 | "You can also select the <b>Local Report</b> command " |
michael@1 | 363 | "from the <b>Report</b> menu.</p>"; |
michael@1 | 364 | m_pReportact->setWhatsThis(kszReporttext); |
michael@1 | 365 | |
michael@1 | 366 | // Offer a formatted preferences panel for intuitive prefs object editing |
michael@1 | 367 | m_pPrefsact = new QAction(trUtf8("Edit the preferences"), QPixmap(s_kpcPrefs_xpm), trUtf8("P&references..."), CTRL+Key_F, this, "Prefspanel"); |
michael@1 | 368 | if (m_pPrefsact == NULL) // Sanity check |
michael@1 | 369 | throw Genexcept("Main window preferences panel action creation failed."); |
michael@1 | 370 | connect(m_pPrefsact, SIGNAL(activated()), SLOT(configPrefs())); |
michael@1 | 371 | const char *kszPrefstext = "<p><img source=\"prefs\"> " |
michael@1 | 372 | "Click this button to <em>edit the preferences</em>. " |
michael@1 | 373 | "You can then apply, accept, or cancel your changes. " |
michael@1 | 374 | "You can also select the <b>Preferences</b> command " |
michael@1 | 375 | "from the <b>Edit</b> menu.</p>"; |
michael@1 | 376 | m_pPrefsact->setWhatsThis(kszPrefstext); |
michael@1 | 377 | } |
michael@1 | 378 | |
michael@1 | 379 | // |
michael@1 | 380 | // Construct the menu bar |
michael@1 | 381 | // |
michael@1 | 382 | void Titraqform::setupMenubar(void) |
michael@1 | 383 | { |
michael@1 | 384 | int nMenuid = 0; // Used to store id during menu item creation |
michael@1 | 385 | |
michael@1 | 386 | m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow |
michael@1 | 387 | if (m_pMenubar == NULL) // Sanity check |
michael@1 | 388 | throw Genexcept("Main window menu bar nonexistant."); |
michael@1 | 389 | |
michael@1 | 390 | // // Make an easter egg ;-) |
michael@1 | 391 | // QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), trUtf8("Easter Egg")); |
michael@1 | 392 | |
michael@1 | 393 | // Construct and populate the file menu with actions |
michael@1 | 394 | QPopupMenu *pFilepopup = new QPopupMenu(this); |
michael@1 | 395 | if (pFilepopup == NULL) // Sanity check |
michael@1 | 396 | throw Genexcept("Main window file popup creation failed."); |
michael@1 | 397 | m_pMenubar->insertItem(trUtf8("&File"), pFilepopup); |
michael@1 | 398 | m_pFilenewact->addTo(pFilepopup); |
michael@1 | 399 | m_pFileopenact->addTo(pFilepopup); |
michael@1 | 400 | pFilepopup->insertSeparator(); |
michael@1 | 401 | m_pFilecloseact->addTo(pFilepopup); |
michael@1 | 402 | pFilepopup->insertSeparator(); |
michael@1 | 403 | m_pFilesaveact->addTo(pFilepopup); |
michael@1 | 404 | m_pFilesaveasact->addTo(pFilepopup); |
michael@1 | 405 | pFilepopup->insertSeparator(); |
michael@1 | 406 | m_pFilequitact->addTo(pFilepopup); |
michael@1 | 407 | |
michael@1 | 408 | // Construct and populate the edit menu with subitems |
michael@1 | 409 | QPopupMenu *pEditpopup = new QPopupMenu(this); |
michael@1 | 410 | if (pEditpopup == NULL) // Sanity check |
michael@1 | 411 | throw Genexcept("Main window edit popup creation failed."); |
michael@1 | 412 | m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup); |
michael@1 | 413 | m_pCutact->addTo(pEditpopup); |
michael@1 | 414 | m_pCopyact->addTo(pEditpopup); |
michael@1 | 415 | m_pPasteact->addTo(pEditpopup); |
michael@1 | 416 | pEditpopup->insertSeparator(); |
michael@1 | 417 | m_pAddrowact->addTo(pEditpopup); |
michael@1 | 418 | m_pDelrowact->addTo(pEditpopup); |
michael@1 | 419 | pEditpopup->insertSeparator(); |
michael@1 | 420 | m_pPrefsact->addTo(pEditpopup); |
michael@1 | 421 | |
michael@1 | 422 | // Construct the view menu and submenus |
michael@1 | 423 | m_pViewpopup = new QPopupMenu(this); |
michael@1 | 424 | m_pTbarspopup = new QPopupMenu(this); |
michael@1 | 425 | m_pColspopup = new QPopupMenu(this); |
michael@1 | 426 | |
michael@1 | 427 | // Give the new menus krass attributes |
michael@1 | 428 | m_pTbarspopup->insertTearOffHandle(); |
michael@1 | 429 | m_pTbarspopup->setCheckable(true); |
michael@1 | 430 | m_pColspopup->insertTearOffHandle(); |
michael@1 | 431 | m_pColspopup->setCheckable(true); |
michael@1 | 432 | |
michael@1 | 433 | // Major sanity check wrapped in one call |
michael@1 | 434 | if (!(m_pViewpopup && m_pTbarspopup && m_pColspopup)) |
michael@1 | 435 | throw Genexcept("Main window view popups creation failed."); |
michael@1 | 436 | |
michael@1 | 437 | // Populate the view menu with subitems |
michael@1 | 438 | m_pMenubar->insertItem(trUtf8("&View"), m_pViewpopup); |
michael@1 | 439 | m_pViewpopup->insertItem(trUtf8("&Normal"), this, SLOT(normalView())); |
michael@1 | 440 | nMenuid = m_pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView())); |
michael@1 | 441 | m_pViewpopup->setItemEnabled(nMenuid, false); |
michael@1 | 442 | nMenuid = m_pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView())); |
michael@1 | 443 | m_pViewpopup->setItemEnabled(nMenuid, false); |
michael@1 | 444 | m_pViewpopup->insertSeparator(); |
michael@1 | 445 | m_pRefreshact->addTo(m_pViewpopup); // Refresh action |
michael@1 | 446 | m_pViewpopup->insertSeparator(); |
michael@1 | 447 | m_pViewpopup->insertItem(trUtf8("&Toolbars"), m_pTbarspopup); |
michael@1 | 448 | nMenuid = m_pTbarspopup->insertItem(trUtf8("&File"), this, SLOT(showFilebar())); |
michael@1 | 449 | m_pTbarspopup->setItemChecked(nMenuid, true); |
michael@1 | 450 | nMenuid = m_pTbarspopup->insertItem(trUtf8("&Edit"), this, SLOT(showEditbar())); |
michael@1 | 451 | m_pTbarspopup->setItemChecked(nMenuid, true); |
michael@1 | 452 | nMenuid = m_pTbarspopup->insertItem(trUtf8("&View"), this, SLOT(showViewbar())); |
michael@1 | 453 | m_pTbarspopup->setItemChecked(nMenuid, true); |
michael@1 | 454 | nMenuid = m_pTbarspopup->insertItem(trUtf8("&Prefs"), this, SLOT(showPrefsbar())); |
michael@1 | 455 | m_pTbarspopup->setItemChecked(nMenuid, true); |
michael@1 | 456 | nMenuid = m_pTbarspopup->insertItem(trUtf8("&Whats"), this, SLOT(showWhatsbar())); |
michael@1 | 457 | m_pTbarspopup->setItemChecked(nMenuid, true); |
michael@1 | 458 | m_pViewpopup->insertItem(trUtf8("&Columns"), m_pColspopup); |
michael@1 | 459 | nMenuid = m_pColspopup->insertItem(trUtf8("&Status"), this, SLOT(showStatcol())); |
michael@1 | 460 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 461 | nMenuid = m_pColspopup->insertItem(trUtf8("&Line"), this, SLOT(showLinecol())); |
michael@1 | 462 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 463 | nMenuid = m_pColspopup->insertItem(trUtf8("&User"), this, SLOT(showUsercol())); |
michael@1 | 464 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 465 | nMenuid = m_pColspopup->insertItem(trUtf8("&GUID"), this, SLOT(showGuidcol())); |
michael@1 | 466 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 467 | nMenuid = m_pColspopup->insertItem(trUtf8("&CRC"), this, SLOT(showCrccol())); |
michael@1 | 468 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 469 | nMenuid = m_pColspopup->insertItem(trUtf8("&Rev"), this, SLOT(showRevcol())); |
michael@1 | 470 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 471 | nMenuid = m_pColspopup->insertItem(trUtf8("&Date"), this, SLOT(showDatecol())); |
michael@1 | 472 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 473 | nMenuid = m_pColspopup->insertItem(trUtf8("&Start"), this, SLOT(showStartcol())); |
michael@1 | 474 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 475 | nMenuid = m_pColspopup->insertItem(trUtf8("&Finish"), this, SLOT(showFinishcol())); |
michael@1 | 476 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 477 | nMenuid = m_pColspopup->insertItem(trUtf8("&Amount"), this, SLOT(showAmountcol())); |
michael@1 | 478 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 479 | nMenuid = m_pColspopup->insertItem(trUtf8("&Task"), this, SLOT(showTaskcol())); |
michael@1 | 480 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 481 | nMenuid = m_pColspopup->insertItem(trUtf8("&Remark"), this, SLOT(showRemarkcol())); |
michael@1 | 482 | m_pColspopup->setItemChecked(nMenuid, true); |
michael@1 | 483 | |
michael@1 | 484 | // Construct and populate the report menu with subitems |
michael@1 | 485 | QPopupMenu *pReportpopup = new QPopupMenu(this); |
michael@1 | 486 | if (pReportpopup == NULL) // Sanity check |
michael@1 | 487 | throw Genexcept("Main window report popup creation failed."); |
michael@1 | 488 | m_pMenubar->insertItem(trUtf8("&Report"), pReportpopup); |
michael@1 | 489 | #if defined HAVE_MICO || defined HAVE_ESOAP |
michael@1 | 490 | m_pSyncact->addTo(pReportpopup); |
michael@1 | 491 | m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON) |
michael@1 | 492 | | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)); |
michael@1 | 493 | #endif // defined HAVE_MICO || defined HAVE_ESOAP |
michael@1 | 494 | m_pReportact->addTo(pReportpopup); |
michael@1 | 495 | |
michael@1 | 496 | // Pad spacing to force help menu to appear far right |
michael@1 | 497 | m_pMenubar->insertSeparator(); |
michael@1 | 498 | |
michael@1 | 499 | // Construct and populate the help menu with subitems |
michael@1 | 500 | QPopupMenu *pHelppopup = new QPopupMenu(this); |
michael@1 | 501 | if (pHelppopup == NULL) // Sanity check |
michael@1 | 502 | throw Genexcept("Main window help popup creation failed."); |
michael@1 | 503 | m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup); |
michael@1 | 504 | pHelppopup->insertItem(trUtf8("&Contents"), this, SLOT(helpContents()), Key_F1); |
michael@1 | 505 | pHelppopup->insertSeparator(); |
michael@1 | 506 | pHelppopup->insertItem(trUtf8("About &as-gui"), this, SLOT(aboutTitraq())); |
michael@1 | 507 | pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP())); |
michael@1 | 508 | pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt())); |
michael@1 | 509 | pHelppopup->insertSeparator(); |
michael@1 | 510 | pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1); |
michael@1 | 511 | } |
michael@1 | 512 | |
michael@1 | 513 | // |
michael@1 | 514 | // Construct the tool bars |
michael@1 | 515 | // |
michael@1 | 516 | void Titraqform::setupToolbars(void) |
michael@1 | 517 | { |
michael@1 | 518 | // Construct and populate the file tool bar |
michael@1 | 519 | m_pFiletools = new QToolBar("Toolfile", this, DockTop); |
michael@1 | 520 | if (m_pFiletools == NULL) // Sanity check |
michael@1 | 521 | throw Genexcept("File tool bar creation failed."); |
michael@1 | 522 | m_pFiletools->setLabel(trUtf8("File Ops")); |
michael@1 | 523 | m_pFiletools->setOpaqueMoving(false); |
michael@1 | 524 | m_pFiletools->setCloseMode(QDockWindow::Never); |
michael@1 | 525 | m_pFilenewact->addTo(m_pFiletools); |
michael@1 | 526 | m_pFileopenact->addTo(m_pFiletools); |
michael@1 | 527 | m_pFilesaveact->addTo(m_pFiletools); |
michael@1 | 528 | |
michael@1 | 529 | // Construct and populate the edit tool bar |
michael@1 | 530 | m_pEdittools = new QToolBar("Tooledit", this, DockTop); |
michael@1 | 531 | if (m_pEdittools == NULL) // Sanity check |
michael@1 | 532 | throw Genexcept("Edit tool bar creation failed."); |
michael@1 | 533 | m_pEdittools->setLabel(trUtf8("Edit Ops")); |
michael@1 | 534 | m_pEdittools->setOpaqueMoving(false); |
michael@1 | 535 | m_pEdittools->setCloseMode(QDockWindow::Never); |
michael@1 | 536 | m_pCutact->addTo(m_pEdittools); |
michael@1 | 537 | m_pCopyact->addTo(m_pEdittools); |
michael@1 | 538 | m_pPasteact->addTo(m_pEdittools); |
michael@1 | 539 | m_pEdittools->addSeparator(); |
michael@1 | 540 | m_pAddrowact->addTo(m_pEdittools); |
michael@1 | 541 | m_pDelrowact->addTo(m_pEdittools); |
michael@1 | 542 | |
michael@1 | 543 | // Construct and populate the view tool bar |
michael@1 | 544 | m_pViewtools = new QToolBar("Toolview", this, DockTop); |
michael@1 | 545 | if (m_pViewtools == NULL) // Sanity check |
michael@1 | 546 | throw Genexcept("View tool bar creation failed."); |
michael@1 | 547 | m_pViewtools->setLabel(trUtf8("View Ops")); |
michael@1 | 548 | m_pViewtools->setOpaqueMoving(false); |
michael@1 | 549 | m_pViewtools->setCloseMode(QDockWindow::Never); |
michael@1 | 550 | m_pRefreshact->addTo(m_pViewtools); |
michael@1 | 551 | m_pReportact->addTo(m_pViewtools); |
michael@1 | 552 | m_pSyncact->addTo(m_pViewtools); |
michael@1 | 553 | |
michael@1 | 554 | // Construct and populate the lonely preferences tool bar |
michael@1 | 555 | m_pPrefstools = new QToolBar("Preferences", this, DockTop); |
michael@1 | 556 | if (m_pPrefstools == NULL) // Sanity check |
michael@1 | 557 | throw Genexcept("Prefs tool bar creation failed."); |
michael@1 | 558 | m_pPrefstools->setLabel(trUtf8("Preferences editor")); |
michael@1 | 559 | m_pPrefstools->setOpaqueMoving(false); |
michael@1 | 560 | m_pPrefstools->setCloseMode(QDockWindow::Never); |
michael@1 | 561 | m_pPrefsact->addTo(m_pPrefstools); |
michael@1 | 562 | |
michael@1 | 563 | // Construct and populate the lonely whatsthis tool bar |
michael@1 | 564 | m_pWhatstools = new QToolBar("Toolwhats", this, DockTop); |
michael@1 | 565 | if (m_pWhatstools == NULL) // Sanity check |
michael@1 | 566 | throw Genexcept("Whats this tool bar creation failed."); |
michael@1 | 567 | m_pWhatstools->setLabel(trUtf8("Whats this")); |
michael@1 | 568 | m_pWhatstools->setOpaqueMoving(false); |
michael@1 | 569 | m_pWhatstools->setCloseMode(QDockWindow::Never); |
michael@1 | 570 | QWhatsThis::whatsThisButton(m_pWhatstools); // Preconfigured whats this button |
michael@1 | 571 | } |
michael@1 | 572 | |
michael@1 | 573 | // |
michael@1 | 574 | // Construct the central frame |
michael@1 | 575 | // |
michael@1 | 576 | void Titraqform::setupCentralwidget(void) |
michael@1 | 577 | { |
michael@1 | 578 | // Create a central frame and associated layout for QMainWindow |
michael@1 | 579 | m_pCenframe = new QFrame(this, "Centralframe"); |
michael@1 | 580 | if (m_pCenframe == NULL) // Sanity check |
michael@1 | 581 | throw Genexcept("Main window central frame creation failed."); |
michael@1 | 582 | m_pCenframe->setFrameShape(QFrame::StyledPanel); |
michael@1 | 583 | m_pCenframe->setFrameShadow(QFrame::Sunken); |
michael@1 | 584 | this->setCentralWidget(m_pCenframe); |
michael@1 | 585 | |
michael@1 | 586 | // Layout controls for table, editing widgets |
michael@1 | 587 | m_pMainlayout = new QVBoxLayout(m_pCenframe, TITRAQ_MARGIN, TITRAQ_SPACING, "Mainlayout"); // For layouts |
michael@1 | 588 | m_pPackagelayout = new QVBoxLayout(0, 0, TITRAQ_SPACING, "Packagelayout"); // For table |
michael@1 | 589 | m_pEditlayout = new QHBoxLayout(0, 0, TITRAQ_SPACING, "Editlayout"); // For edits |
michael@1 | 590 | |
michael@1 | 591 | // Major sanity check wrapped in one call |
michael@1 | 592 | if (!(m_pMainlayout && m_pPackagelayout && m_pEditlayout)) |
michael@1 | 593 | throw Genexcept("Main window layout creation failed."); |
michael@1 | 594 | |
michael@1 | 595 | // Specify ordering of the layouts |
michael@1 | 596 | m_pMainlayout->addLayout(m_pPackagelayout); |
michael@1 | 597 | m_pMainlayout->addLayout(m_pEditlayout); |
michael@1 | 598 | } |
michael@1 | 599 | |
michael@1 | 600 | // |
michael@1 | 601 | // Construct the status bar |
michael@1 | 602 | // |
michael@1 | 603 | void Titraqform::setupStatusbar(void) |
michael@1 | 604 | { |
michael@1 | 605 | m_pStatbar = statusBar(); // Grab status bar owned by QMainWindow |
michael@1 | 606 | if (m_pStatbar == NULL) // Sanity check |
michael@1 | 607 | throw Genexcept("Main window status bar nonexistant."); |
michael@1 | 608 | } |
michael@1 | 609 | |
michael@1 | 610 | // |
michael@1 | 611 | // Construct the table |
michael@1 | 612 | // |
michael@1 | 613 | void Titraqform::setupTable(void) |
michael@1 | 614 | { |
michael@1 | 615 | // Create, configure, and setup the table itself |
michael@1 | 616 | m_pMaintable = new TiTable(m_pPrefs, m_pCenframe, "Maintable"); |
michael@1 | 617 | if (m_pMaintable == NULL) // Sanity check |
michael@1 | 618 | throw Genexcept("Main window table creation failed."); |
michael@1 | 619 | m_pMaintable->setNumCols(TITRAQ_IDXTAIL); |
michael@1 | 620 | m_pMaintable->setDirty(false); // Reset data to clean state |
michael@1 | 621 | m_pMaintable->setReadOnly(true); // Table is read only |
michael@1 | 622 | m_pMaintable->setColumnMovingEnabled(false); // Ctrl-drag disabled |
michael@1 | 623 | m_pMaintable->setSelectionMode(QTable::MultiRow); // Multi row selection |
michael@1 | 624 | m_pMaintable->setFocusStyle(QTable::FollowStyle); // How cells are drawn |
michael@1 | 625 | m_pMaintable->setLeftMargin(0); // Get rid of the vertical header |
michael@1 | 626 | m_pMaintable->verticalHeader()->hide(); // by hiding it with a margin of 0 |
michael@1 | 627 | m_pMaintable->horizontalHeader()->setResizeEnabled(true); |
michael@1 | 628 | m_pMaintable->horizontalHeader()->setClickEnabled(true); // Allow click signals |
michael@1 | 629 | m_pMaintable->horizontalHeader()->setTracking(false); // No continuous tracking |
michael@1 | 630 | m_pMaintable->setColumnStretchable(TITRAQ_IDXTAIL - 1, true); |
michael@1 | 631 | |
michael@1 | 632 | // Allow for user determined data sorting and use saved values |
michael@1 | 633 | m_pMaintable->setSortcol((int)m_pPrefs->getNumber(TITRAQ_PREFSORTCOL, TITRAQ_DEFSORTCOL)); |
michael@1 | 634 | m_pMaintable->setSortdir(m_pPrefs->getBool(TITRAQ_PREFSORTDIR, TITRAQ_DEFSORTDIR)); |
michael@1 | 635 | m_pMaintable->setSorting(true); |
michael@1 | 636 | |
michael@1 | 637 | // Table header row |
michael@1 | 638 | m_pTablehead = m_pMaintable->horizontalHeader(); |
michael@1 | 639 | m_pMaintable->setHScrollBarMode(QScrollView::AlwaysOff); |
michael@1 | 640 | m_pTablehead->setLabel(TITRAQ_IDXSTATUS, QObject::trUtf8("Stat"), |
michael@1 | 641 | m_pPrefs->getNumber(TITRAQ_PREFSTATCOLWIDTH, TITRAQ_DEFSTATCOLWIDTH)); |
michael@1 | 642 | m_pMaintable->setColumnReadOnly (TITRAQ_IDXSTATUS, true); |
michael@1 | 643 | m_pTablehead->setLabel(TITRAQ_IDXLINE, QObject::trUtf8("Line"), |
michael@1 | 644 | m_pPrefs->getNumber(TITRAQ_PREFLCOLWIDTH, TITRAQ_DEFLCOLWIDTH)); |
michael@1 | 645 | m_pMaintable->setColumnReadOnly (TITRAQ_IDXLINE, true); |
michael@1 | 646 | m_pTablehead->setLabel(TITRAQ_IDXUSER, QObject::trUtf8("User"), |
michael@1 | 647 | m_pPrefs->getNumber(TITRAQ_PREFUCOLWIDTH, TITRAQ_DEFUCOLWIDTH)); |
michael@1 | 648 | m_pTablehead->setLabel(TITRAQ_IDXGUID, QObject::trUtf8("GUID"), |
michael@1 | 649 | m_pPrefs->getNumber(TITRAQ_PREFGCOLWIDTH, TITRAQ_DEFGCOLWIDTH)); |
michael@1 | 650 | m_pMaintable->setColumnReadOnly (TITRAQ_IDXGUID, true); |
michael@1 | 651 | m_pTablehead->setLabel(TITRAQ_IDXCRC, QObject::trUtf8("CRC"), |
michael@1 | 652 | m_pPrefs->getNumber(TITRAQ_PREFCCOLWIDTH, TITRAQ_DEFCCOLWIDTH)); |
michael@1 | 653 | m_pMaintable->setColumnReadOnly (TITRAQ_IDXCRC, true); |
michael@1 | 654 | m_pTablehead->setLabel(TITRAQ_IDXREV, QObject::trUtf8("Rev"), |
michael@1 | 655 | m_pPrefs->getNumber(TITRAQ_PREFREVCOLWIDTH, TITRAQ_DEFREVCOLWIDTH)); |
michael@1 | 656 | m_pMaintable->setColumnReadOnly (TITRAQ_IDXREV, true); |
michael@1 | 657 | m_pTablehead->setLabel(TITRAQ_IDXDATE, QObject::trUtf8("Date"), |
michael@1 | 658 | m_pPrefs->getNumber(TITRAQ_PREFDCOLWIDTH, TITRAQ_DEFDCOLWIDTH)); |
michael@1 | 659 | m_pTablehead->setLabel(TITRAQ_IDXSTART, QObject::trUtf8("Begin"), |
michael@1 | 660 | m_pPrefs->getNumber(TITRAQ_PREFSTARTCOLWIDTH, TITRAQ_DEFSTARTCOLWIDTH)); |
michael@1 | 661 | m_pTablehead->setLabel(TITRAQ_IDXFINISH, QObject::trUtf8("End"), |
michael@1 | 662 | m_pPrefs->getNumber(TITRAQ_PREFFCOLWIDTH, TITRAQ_DEFFCOLWIDTH)); |
michael@1 | 663 | m_pTablehead->setLabel(TITRAQ_IDXAMOUNT, QObject::trUtf8("Amount"), |
michael@1 | 664 | m_pPrefs->getNumber(TITRAQ_PREFACOLWIDTH, TITRAQ_DEFACOLWIDTH)); |
michael@1 | 665 | m_pTablehead->setLabel(TITRAQ_IDXTASK, QObject::trUtf8("Task"), |
michael@1 | 666 | m_pPrefs->getNumber(TITRAQ_PREFTCOLWIDTH, TITRAQ_DEFTCOLWIDTH)); |
michael@1 | 667 | m_pTablehead->setLabel(TITRAQ_IDXREMARK, QObject::trUtf8("Remark")); |
michael@1 | 668 | |
michael@1 | 669 | m_pPackagelayout->addWidget(m_pMaintable); // Finally add the damn table |
michael@1 | 670 | |
michael@1 | 671 | // Table update signals |
michael@1 | 672 | connect(m_pMaintable, SIGNAL(currentChanged(int, int)), SLOT(updEdit(int, int))); |
michael@1 | 673 | connect(m_pMaintable, SIGNAL(clicked(int, int, int, const QPoint&)), SLOT(onClick(int, int, int, const QPoint&))); |
michael@1 | 674 | connect(m_pMaintable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), SLOT(inplaceEdit(int, int, int, const QPoint&))); |
michael@1 | 675 | connect(m_pTablehead, SIGNAL(sizeChange(int, int, int)), SLOT(updSizes(int, int, int))); |
michael@1 | 676 | connect(m_pMaintable, SIGNAL(textEdited(int, int)), SLOT(dataChanged(int, int))); |
michael@1 | 677 | connect(m_pMaintable, SIGNAL(valueChanged(int, int)), SLOT(dataChanged(int, int))); |
michael@1 | 678 | } |
michael@1 | 679 | |
michael@1 | 680 | // |
michael@1 | 681 | // Construct the bottom edit widgets |
michael@1 | 682 | // |
michael@1 | 683 | void Titraqform::setupEditlay(void) |
michael@1 | 684 | { |
michael@1 | 685 | // QSpacerItem Pad(TITRAQ_SPACING / 2, 0, QSizePolicy::Fixed); |
michael@1 | 686 | // m_pEditlayout->addWidget(&Pad); // Padd left side of control layout |
michael@1 | 687 | |
michael@1 | 688 | // Make the status edit |
michael@1 | 689 | m_pStatusedit = new QLabel(m_pCenframe, "Status"); |
michael@1 | 690 | if (m_pStatusedit == NULL) // Sanity check |
michael@1 | 691 | throw Genexcept("Main window status edit creation failed."); |
michael@1 | 692 | m_pStatusedit->setPixmap(QPixmap(s_kpcStatvoid_xpm)); // Placeholder |
michael@1 | 693 | |
michael@1 | 694 | |
michael@1 | 695 | // Whatsthis info for the item status edit |
michael@1 | 696 | const char *kszStatustext = "The <em>item status</em> shows a green " |
michael@1 | 697 | "symbol for valid entries, a yellow symbol " |
michael@1 | 698 | "for warning, and a red symbol for flawed entries."; |
michael@1 | 699 | QWhatsThis::add(m_pStatusedit, kszStatustext); |
michael@1 | 700 | QToolTip::add(m_pStatusedit, trUtf8("Status Indicator")); |
michael@1 | 701 | m_pEditlayout->addWidget(m_pStatusedit); // Finally add the item status edit |
michael@1 | 702 | |
michael@1 | 703 | // Make the line number edit |
michael@1 | 704 | m_pLineedit = new QLineEdit(m_pCenframe, "Lineno"); |
michael@1 | 705 | if (m_pLineedit == NULL) // Sanity check |
michael@1 | 706 | throw Genexcept("Main window line number edit creation failed."); |
michael@1 | 707 | m_pLineedit->setFrameShape(QLineEdit::LineEditPanel); |
michael@1 | 708 | m_pLineedit->setFrameShadow(QLineEdit::Sunken); |
michael@1 | 709 | m_pLineedit->setFrame(true); |
michael@1 | 710 | m_pLineedit->setReadOnly(true); |
michael@1 | 711 | m_pLineedit->setEnabled(false); |
michael@1 | 712 | m_pLineedit->setAlignment(Qt::AlignRight); |
michael@1 | 713 | |
michael@1 | 714 | // Whatsthis info for the line number edit |
michael@1 | 715 | const char *kszLinenotext = "The <em>line number</em> helps identify " |
michael@1 | 716 | "an entry when a warning or error message " |
michael@1 | 717 | "appears."; |
michael@1 | 718 | QWhatsThis::add(m_pLineedit, kszLinenotext); |
michael@1 | 719 | QToolTip::add(m_pLineedit, trUtf8("Line Number")); |
michael@1 | 720 | m_pEditlayout->addWidget(m_pLineedit); // Finally add the line number edit |
michael@1 | 721 | |
michael@1 | 722 | // Make the user edit |
michael@1 | 723 | m_pUseredit = new QLineEdit(m_pCenframe, "User"); |
michael@1 | 724 | if (m_pUseredit == NULL) // Sanity check |
michael@1 | 725 | throw Genexcept("Main window user edit creation failed."); |
michael@1 | 726 | m_pUseredit->setFrameShape(QLineEdit::LineEditPanel); |
michael@1 | 727 | m_pUseredit->setFrameShadow(QLineEdit::Sunken); |
michael@1 | 728 | m_pUseredit->setFrame(true); |
michael@1 | 729 | m_pUseredit->setReadOnly(false); |
michael@1 | 730 | m_pUseredit->setEnabled(false); |
michael@1 | 731 | |
michael@1 | 732 | // Whatsthis info for the user edit |
michael@1 | 733 | const char *kszUsertext = "Edit the <em>user name</em> by clicking " |
michael@1 | 734 | "on this control and typing the user name " |
michael@1 | 735 | "you want to account."; |
michael@1 | 736 | QWhatsThis::add(m_pUseredit, kszUsertext); |
michael@1 | 737 | QToolTip::add(m_pUseredit, trUtf8("User Name")); |
michael@1 | 738 | m_pEditlayout->addWidget(m_pUseredit); // Finally add the user edit |
michael@1 | 739 | |
michael@1 | 740 | // Make the GUID edit |
michael@1 | 741 | m_pGuidedit = new QLineEdit(m_pCenframe, "Guid"); |
michael@1 | 742 | if (m_pGuidedit == NULL) // Sanity check |
michael@1 | 743 | throw Genexcept("Main window GUID edit creation failed."); |
michael@1 | 744 | m_pGuidedit->setFrameShape(QLineEdit::LineEditPanel); |
michael@1 | 745 | m_pGuidedit->setFrameShadow(QLineEdit::Sunken); |
michael@1 | 746 | m_pGuidedit->setFrame(true); |
michael@1 | 747 | m_pGuidedit->setReadOnly(true); |
michael@1 | 748 | m_pGuidedit->setEnabled(false); |
michael@1 | 749 | |
michael@1 | 750 | // Whatsthis info for the GUID edit |
michael@1 | 751 | const char *kszGuidtext = "Edit the <em>GUID</em> by clicking " |
michael@1 | 752 | "on this control and typing the GUID " |
michael@1 | 753 | "corresponding to this account item."; |
michael@1 | 754 | QWhatsThis::add(m_pGuidedit, kszGuidtext); |
michael@1 | 755 | QToolTip::add(m_pGuidedit, trUtf8("GUID")); |
michael@1 | 756 | m_pEditlayout->addWidget(m_pGuidedit); // Finally add the GUID edit |
michael@1 | 757 | |
michael@1 | 758 | // Make the CRC edit |
michael@1 | 759 | m_pCrcedit = new QLineEdit(m_pCenframe, "Crc"); |
michael@1 | 760 | if (m_pCrcedit == NULL) // Sanity check |
michael@1 | 761 | throw Genexcept("Main window CRC edit creation failed."); |
michael@1 | 762 | m_pCrcedit->setFrameShape(QLineEdit::LineEditPanel); |
michael@1 | 763 | m_pCrcedit->setFrameShadow(QLineEdit::Sunken); |
michael@1 | 764 | m_pCrcedit->setFrame(true); |
michael@1 | 765 | m_pCrcedit->setReadOnly(true); |
michael@1 | 766 | m_pCrcedit->setEnabled(false); |
michael@1 | 767 | |
michael@1 | 768 | // Whatsthis info for the CRC edit |
michael@1 | 769 | const char *kszCrctext = "Edit the <em>CRC</em> by clicking " |
michael@1 | 770 | "on this control and typing the new " |
michael@1 | 771 | "value for this account item."; |
michael@1 | 772 | QWhatsThis::add(m_pCrcedit, kszCrctext); |
michael@1 | 773 | QToolTip::add(m_pCrcedit, trUtf8("CRC")); |
michael@1 | 774 | m_pEditlayout->addWidget(m_pCrcedit); // Finally add the CRC edit |
michael@1 | 775 | |
michael@1 | 776 | // Make the revision edit |
michael@1 | 777 | m_pRevedit = new QLineEdit(m_pCenframe, "Revision"); |
michael@1 | 778 | if (m_pRevedit == NULL) // Sanity check |
michael@1 | 779 | throw Genexcept("Main window revision edit creation failed."); |
michael@1 | 780 | m_pRevedit->setFrameShape(QLineEdit::LineEditPanel); |
michael@1 | 781 | m_pRevedit->setFrameShadow(QLineEdit::Sunken); |
michael@1 | 782 | m_pRevedit->setFrame(true); |
michael@1 | 783 | m_pRevedit->setReadOnly(true); |
michael@1 | 784 | m_pRevedit->setEnabled(false); |
michael@1 | 785 | |
michael@1 | 786 | // Whatsthis info for the revision edit |
michael@1 | 787 | const char *kszRevtext = "Edit the <em>revision</em> by clicking " |
michael@1 | 788 | "on this control and typing the new value " |
michael@1 | 789 | "for this account type."; |
michael@1 | 790 | QWhatsThis::add(m_pRevedit, kszRevtext); |
michael@1 | 791 | QToolTip::add(m_pRevedit, trUtf8("Revision")); |
michael@1 | 792 | m_pEditlayout->addWidget(m_pRevedit); // Finally add the revision edit |
michael@1 | 793 | |
michael@1 | 794 | // Make the date selector |
michael@1 | 795 | m_pDateedit = new Daydatedit(QDate::currentDate(), m_pCenframe, "Date"); |
michael@1 | 796 | if (m_pDateedit == NULL) // Sanity check |
michael@1 | 797 | throw Genexcept("Main window date edit creation failed."); // Spew errors |
michael@1 | 798 | |
michael@1 | 799 | // Configure attributes |
michael@1 | 800 | m_pDateedit->setOrder(QDateEdit::YMD); |
michael@1 | 801 | m_pDateedit->setAutoAdvance(true); |
michael@1 | 802 | m_pDateedit->setSeparator(trUtf8("-")); |
michael@1 | 803 | m_pDateedit->setEnabled(false); |
michael@1 | 804 | |
michael@1 | 805 | // Whatsthis info for the date editor |
michael@1 | 806 | const char *kszDateedit = "Edit the <em>task date</em> by clicking on " |
michael@1 | 807 | "the year, month, or day, and then changing their " |
michael@1 | 808 | "values with the arrow buttons."; |
michael@1 | 809 | QWhatsThis::add(m_pDateedit, kszDateedit); |
michael@1 | 810 | QToolTip::add(m_pDateedit, trUtf8("Task Date")); |
michael@1 | 811 | m_pEditlayout->addWidget(m_pDateedit); // Finally add the date editor |
michael@1 | 812 | |
michael@1 | 813 | // Make the start time selector |
michael@1 | 814 | m_pStarttime = new QTimeEdit(m_pCenframe, "StartTime"); |
michael@1 | 815 | if (m_pStarttime == NULL) // Sanity check |
michael@1 | 816 | throw Genexcept("Main window start time creation failed."); // Spew errors |
michael@1 | 817 | |
michael@1 | 818 | // Configure attributes |
michael@1 | 819 | m_pStarttime->setDisplay(QTimeEdit::Hours | QTimeEdit::Minutes); |
michael@1 | 820 | m_pStarttime->setAutoAdvance(true); |
michael@1 | 821 | m_pStarttime->setEnabled(false); |
michael@1 | 822 | |
michael@1 | 823 | // Whatsthis info for the time editor |
michael@1 | 824 | const char *kszStarttime = "Edit the <em>task starting time</em> by clicking on " |
michael@1 | 825 | "the hour and minute, and then changing their " |
michael@1 | 826 | "values with the arrow buttons."; |
michael@1 | 827 | QWhatsThis::add(m_pStarttime, kszStarttime); |
michael@1 | 828 | QToolTip::add(m_pStarttime, trUtf8("Task Starting Time")); |
michael@1 | 829 | m_pEditlayout->addWidget(m_pStarttime); // Finally add the start editor |
michael@1 | 830 | |
michael@1 | 831 | // Make the end time selector |
michael@1 | 832 | m_pEndtime = new QTimeEdit(m_pCenframe, "EndTime"); |
michael@1 | 833 | if (m_pEndtime == NULL) // Sanity check |
michael@1 | 834 | throw Genexcept("Main window end time creation failed."); // Spew errors |
michael@1 | 835 | |
michael@1 | 836 | // Configure attributes |
michael@1 | 837 | m_pEndtime->setDisplay(QTimeEdit::Hours | QTimeEdit::Minutes); |
michael@1 | 838 | m_pEndtime->setAutoAdvance(true); |
michael@1 | 839 | m_pEndtime->setEnabled(false); |
michael@1 | 840 | |
michael@1 | 841 | // Whatsthis info for the time editor |
michael@1 | 842 | const char *kszEndtime = "Edit the <em>task ending time</em> by clicking on " |
michael@1 | 843 | "the hour and minute, and then changing their " |
michael@1 | 844 | "values with the arrow buttons."; |
michael@1 | 845 | QWhatsThis::add(m_pEndtime, kszEndtime); |
michael@1 | 846 | QToolTip::add(m_pEndtime, trUtf8("Task Ending Time")); |
michael@1 | 847 | m_pEditlayout->addWidget(m_pEndtime); // Finally add the end editor |
michael@1 | 848 | |
michael@1 | 849 | // // Make the total time amount selector |
michael@1 | 850 | // m_pAmount = new QTimeEdit(m_pCenframe, "TotalAmount"); |
michael@1 | 851 | // if (m_pAmount == NULL) // Sanity check |
michael@1 | 852 | // throw Genexcept("Main window amount creation failed."); // Spew errors |
michael@1 | 853 | // |
michael@1 | 854 | // // Configure attributes |
michael@1 | 855 | // m_pAmount->setDisplay(QTimeEdit::Hours | QTimeEdit::Minutes); |
michael@1 | 856 | // m_pAmount->setAutoAdvance(true); |
michael@1 | 857 | // m_pAmount->setEnabled(false); |
michael@1 | 858 | |
michael@1 | 859 | // Make the amount selector |
michael@1 | 860 | m_pAmount = new ASTimeEdit(m_pCenframe, "TotalAmount"); |
michael@1 | 861 | if (m_pAmount == NULL) // Sanity check |
michael@1 | 862 | throw Genexcept("Main window amount creation failed."); // Spew errors |
michael@1 | 863 | |
michael@1 | 864 | // Whatsthis info for the amount editor |
michael@1 | 865 | const char *kszAmount = "Edit the <em>task amount</em> by clicking on " |
michael@1 | 866 | "the amount, and then changing its " |
michael@1 | 867 | "value with the arrow buttons."; |
michael@1 | 868 | QWhatsThis::add(m_pAmount, kszAmount); |
michael@1 | 869 | QToolTip::add(m_pAmount, trUtf8("Task Amount")); |
michael@1 | 870 | m_pAmount->setEnabled(false); // Don't enable until it's ready |
michael@1 | 871 | m_pEditlayout->addWidget(m_pAmount); // Finally add the amount editor |
michael@1 | 872 | |
michael@1 | 873 | // Construct a stringlist just to hold task values |
michael@1 | 874 | m_pTaskentries = new QStringList; |
michael@1 | 875 | if (m_pTaskentries == NULL) // Sanity check |
michael@1 | 876 | throw Genexcept("Main window task entries creation failed."); |
michael@1 | 877 | |
michael@1 | 878 | // Populate the stringlist with fresh accounts, taken from filename in prefs |
michael@1 | 879 | QString Asdir = m_pPrefs->getString(TITRAQ_PREFACCOUNTS, TITRAQ_DEFACCOUNTS); |
michael@1 | 880 | if (Asdir.startsWith(TITRAQ_HOMEDIRTOK)) |
michael@1 | 881 | Asdir = QDir::homeDirPath() + Asdir.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1); |
michael@1 | 882 | QFile Filetemp(Asdir); |
michael@1 | 883 | this->loadAccounts(Filetemp); // Load account helper method |
michael@1 | 884 | |
michael@1 | 885 | // Make the combobox task edit |
michael@1 | 886 | m_pTasks = new QComboBox(true, m_pCenframe, "Tasks"); |
michael@1 | 887 | if (m_pTasks == NULL) // Sanity check |
michael@1 | 888 | throw Genexcept("Main window task edit creation failed."); |
michael@1 | 889 | m_pTasks->insertStringList(*m_pTaskentries); |
michael@1 | 890 | m_pTasks->setCurrentText(NULL); |
michael@1 | 891 | m_pTasks->setSizeLimit(TITRAQ_ACCTBOXHEIGHT); |
michael@1 | 892 | m_pTasks->setAutoCompletion(true); |
michael@1 | 893 | m_pTasks->setDuplicatesEnabled(false); |
michael@1 | 894 | m_pTasks->setEnabled(false); |
michael@1 | 895 | // m_pTasks->setEditable(false); // Only idiots define noneditable and autocompletion |
michael@1 | 896 | |
michael@1 | 897 | // Add an auto scroll bar if possible under current GUI style |
michael@1 | 898 | if (m_pTasks->listBox()) { // Motif style has no list box |
michael@1 | 899 | int nPopupwidth = m_pTasks->listBox()->maxItemWidth(); |
michael@1 | 900 | nPopupwidth += m_pTasks->listBox()->horizontalScrollBar()->height(); |
michael@1 | 901 | m_pTasks->listBox()->setFixedWidth(nPopupwidth); |
michael@1 | 902 | m_pTasks->listBox()->setHScrollBarMode(QScrollView::Auto); |
michael@1 | 903 | m_pTasks->listBox()->sort(); |
michael@1 | 904 | } |
michael@1 | 905 | |
michael@1 | 906 | // Whatsthis info for the task editor |
michael@1 | 907 | const char *kszTasktext = "Choose a <em>task account</em> by clicking on " |
michael@1 | 908 | "this box, and choosing whichever item most " |
michael@1 | 909 | "closely resembles your task."; |
michael@1 | 910 | QWhatsThis::add(m_pTasks, kszTasktext); |
michael@1 | 911 | QToolTip::add(m_pTasks, trUtf8("Task Selector")); |
michael@1 | 912 | m_pEditlayout->addWidget(m_pTasks); // Finally add the task edit |
michael@1 | 913 | |
michael@1 | 914 | // Make the Remark line |
michael@1 | 915 | m_pRemark = new QLineEdit(m_pCenframe, "Remark"); |
michael@1 | 916 | if (m_pRemark == NULL) // Sanity check |
michael@1 | 917 | throw Genexcept("Main window remark line creation failed."); |
michael@1 | 918 | m_pRemark->setFrameShape(QLineEdit::LineEditPanel); |
michael@1 | 919 | m_pRemark->setFrameShadow(QLineEdit::Sunken); |
michael@1 | 920 | m_pRemark->setFrame(true); |
michael@1 | 921 | m_pRemark->setReadOnly(false); |
michael@1 | 922 | m_pRemark->setEnabled(false); |
michael@1 | 923 | |
michael@1 | 924 | // Whatsthis info for the remark line |
michael@1 | 925 | const char *kszRemarktext = "Edit the <em>task remarks</em> by clicking on " |
michael@1 | 926 | "this line control and typing the remarks you " |
michael@1 | 927 | "have about the task."; |
michael@1 | 928 | QWhatsThis::add(m_pRemark, kszRemarktext); |
michael@1 | 929 | QToolTip::add(m_pRemark, trUtf8("Remark Line")); |
michael@1 | 930 | m_pEditlayout->addWidget(m_pRemark); // Finally add the remark line |
michael@1 | 931 | |
michael@1 | 932 | // Start edit controls off at right size |
michael@1 | 933 | this->updSizes(TITRAQ_IDXALLCTRLS, -1, -1); |
michael@1 | 934 | |
michael@1 | 935 | // Validate data just as it is being entered |
michael@1 | 936 | connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(validateRow(void))); |
michael@1 | 937 | connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void))); |
michael@1 | 938 | connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void))); |
michael@1 | 939 | connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(validateRow(void))); |
michael@1 | 940 | connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(validateRow(void))); |
michael@1 | 941 | connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(validateRow(void))); |
michael@1 | 942 | |
michael@1 | 943 | // Signals sent between table cells and corresponding edit control widgets |
michael@1 | 944 | connect(m_pLineedit, SIGNAL(textChanged(const QString &)), SLOT(updateLine(const QString &))); |
michael@1 | 945 | connect(m_pUseredit, SIGNAL(textChanged(const QString &)), SLOT(updateUser(const QString &))); |
michael@1 | 946 | connect(m_pGuidedit, SIGNAL(textChanged(const QString &)), SLOT(updateGuid(const QString &))); |
michael@1 | 947 | connect(m_pCrcedit, SIGNAL(textChanged(const QString &)), SLOT(updateCrc(const QString &))); |
michael@1 | 948 | connect(m_pRevedit, SIGNAL(textChanged(const QString &)), SLOT(updateRev(const QString &))); |
michael@1 | 949 | connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(updateDate(const QDate &))); |
michael@1 | 950 | connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(updateStart(const QTime &))); |
michael@1 | 951 | connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(updateFinish(const QTime &))); |
michael@1 | 952 | connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(updateAmount(const QTime &))); |
michael@1 | 953 | connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(updateTask(const QString &))); |
michael@1 | 954 | connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(updateRemark(const QString &))); |
michael@1 | 955 | |
michael@1 | 956 | // Correctly update checksum and revision fields also |
michael@1 | 957 | connect(m_pUseredit, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void))); |
michael@1 | 958 | connect(m_pDateedit, SIGNAL(valueChanged(const QDate &)), SLOT(calcCrc(void))); |
michael@1 | 959 | connect(m_pStarttime, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void))); |
michael@1 | 960 | connect(m_pEndtime, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void))); |
michael@1 | 961 | connect(m_pAmount, SIGNAL(valueChanged(const QTime &)), SLOT(calcCrc(void))); |
michael@1 | 962 | connect(m_pTasks, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void))); |
michael@1 | 963 | connect(m_pRemark, SIGNAL(textChanged(const QString &)), SLOT(calcCrc(void))); |
michael@1 | 964 | } |
michael@1 | 965 | |
michael@1 | 966 | // |
michael@1 | 967 | // Arrange and configure columns |
michael@1 | 968 | // |
michael@1 | 969 | void Titraqform::setupColumns(void) |
michael@1 | 970 | { |
michael@1 | 971 | // Handle column view handling presets and defaults |
michael@1 | 972 | if (!m_pPrefs->getBool(TITRAQ_PREFSTATCOLON, TITRAQ_DEFSTATCOLON)) |
michael@1 | 973 | showStatcol(); |
michael@1 | 974 | if (!m_pPrefs->getBool(TITRAQ_PREFLCOLON, TITRAQ_DEFLCOLON)) |
michael@1 | 975 | showLinecol(); |
michael@1 | 976 | if (!m_pPrefs->getBool(TITRAQ_PREFUCOLON, TITRAQ_DEFUCOLON)) |
michael@1 | 977 | showUsercol(); |
michael@1 | 978 | if (!m_pPrefs->getBool(TITRAQ_PREFGCOLON, TITRAQ_DEFGCOLON)) |
michael@1 | 979 | showGuidcol(); |
michael@1 | 980 | if (!m_pPrefs->getBool(TITRAQ_PREFCCOLON, TITRAQ_DEFCCOLON)) |
michael@1 | 981 | showCrccol(); |
michael@1 | 982 | if (!m_pPrefs->getBool(TITRAQ_PREFREVCOLON, TITRAQ_DEFREVCOLON)) |
michael@1 | 983 | showRevcol(); |
michael@1 | 984 | if (!m_pPrefs->getBool(TITRAQ_PREFDCOLON, TITRAQ_DEFDCOLON)) |
michael@1 | 985 | showDatecol(); |
michael@1 | 986 | if (!m_pPrefs->getBool(TITRAQ_PREFSTARTCOLON, TITRAQ_DEFSTARTCOLON)) |
michael@1 | 987 | showStartcol(); |
michael@1 | 988 | if (!m_pPrefs->getBool(TITRAQ_PREFFCOLON, TITRAQ_DEFFCOLON)) |
michael@1 | 989 | showFinishcol(); |
michael@1 | 990 | if (!m_pPrefs->getBool(TITRAQ_PREFACOLON, TITRAQ_DEFACOLON)) |
michael@1 | 991 | showAmountcol(); |
michael@1 | 992 | if (!m_pPrefs->getBool(TITRAQ_PREFTCOLON, TITRAQ_DEFTCOLON)) |
michael@1 | 993 | showTaskcol(); |
michael@1 | 994 | if (!m_pPrefs->getBool(TITRAQ_PREFREMCOLON, TITRAQ_DEFREMCOLON)) |
michael@1 | 995 | showRemarkcol(); |
michael@1 | 996 | |
michael@1 | 997 | // Handle tool bar view handling presets and defaults |
michael@1 | 998 | if (!m_pPrefs->getBool(TITRAQ_PREFFILEBAR, TITRAQ_DEFFILEBAR)) { |
michael@1 | 999 | m_pFiletools->hide(); |
michael@1 | 1000 | m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXFILEBAR), false); |
michael@1 | 1001 | } |
michael@1 | 1002 | if (!m_pPrefs->getBool(TITRAQ_PREFEDITBAR, TITRAQ_DEFEDITBAR)) { |
michael@1 | 1003 | m_pEdittools->hide(); |
michael@1 | 1004 | m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXEDITBAR), false); |
michael@1 | 1005 | } |
michael@1 | 1006 | if (!m_pPrefs->getBool(TITRAQ_PREFVIEWBAR, TITRAQ_DEFVIEWBAR)) { |
michael@1 | 1007 | m_pViewtools->hide(); |
michael@1 | 1008 | m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXVIEWBAR), false); |
michael@1 | 1009 | } |
michael@1 | 1010 | if (!m_pPrefs->getBool(TITRAQ_PREFPREFBAR, TITRAQ_DEFPREFBAR)) { |
michael@1 | 1011 | m_pPrefstools->hide(); |
michael@1 | 1012 | m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXPREFBAR), false); |
michael@1 | 1013 | } |
michael@1 | 1014 | if (!m_pPrefs->getBool(TITRAQ_PREFWHATBAR, TITRAQ_DEFWHATBAR)) { |
michael@1 | 1015 | m_pWhatstools->hide(); |
michael@1 | 1016 | m_pTbarspopup->setItemChecked(m_pTbarspopup->idAt(TITRAQ_IDXWHATBAR), false); |
michael@1 | 1017 | } |
michael@1 | 1018 | } |
michael@1 | 1019 | |
michael@1 | 1020 | // |
michael@1 | 1021 | // [En|dis]able most ui pieces to suit or restrict user |
michael@1 | 1022 | // |
michael@1 | 1023 | void Titraqform::enableIface(bool bTurned) |
michael@1 | 1024 | { |
michael@1 | 1025 | // FIXME: Does not belong here, so relocate |
michael@1 | 1026 | if (bTurned) // Turn off the interface |
michael@1 | 1027 | m_pDateedit->setDayfocus(); // Default focus is on day |
michael@1 | 1028 | else { // Turn on the interface |
michael@1 | 1029 | m_pMaintable->setNumRows(0); // Remove table data |
michael@1 | 1030 | m_pStatusedit->setPixmap(QPixmap(s_kpcStatvoid_xpm)); |
michael@1 | 1031 | } |
michael@1 | 1032 | |
michael@1 | 1033 | // Enable or disable the widgets |
michael@1 | 1034 | m_pMaintable->setEnabled(bTurned); |
michael@1 | 1035 | m_pLineedit->setEnabled(bTurned); |
michael@1 | 1036 | m_pUseredit->setEnabled(bTurned); |
michael@1 | 1037 | m_pGuidedit->setEnabled(bTurned); |
michael@1 | 1038 | m_pCrcedit->setEnabled(bTurned); |
michael@1 | 1039 | m_pRevedit->setEnabled(bTurned); |
michael@1 | 1040 | m_pDateedit->setEnabled(bTurned); |
michael@1 | 1041 | m_pStarttime->setEnabled(bTurned); |
michael@1 | 1042 | m_pEndtime->setEnabled(bTurned); |
michael@1 | 1043 | m_pAmount->setEnabled(bTurned); |
michael@1 | 1044 | m_pTasks->setEnabled(bTurned); |
michael@1 | 1045 | m_pRemark->setEnabled(bTurned); |
michael@1 | 1046 | |
michael@1 | 1047 | // Enable or disable the actions |
michael@1 | 1048 | m_pFilesaveact->setEnabled(bTurned); |
michael@1 | 1049 | m_pFilesaveasact->setEnabled(bTurned); |
michael@1 | 1050 | m_pFilecloseact->setEnabled(bTurned); |
michael@1 | 1051 | m_pAddrowact->setEnabled(bTurned); |
michael@1 | 1052 | m_pDelrowact->setEnabled(bTurned); |
michael@1 | 1053 | m_pRefreshact->setEnabled(bTurned); |
michael@1 | 1054 | m_pCutact->setEnabled(bTurned); |
michael@1 | 1055 | m_pCopyact->setEnabled(bTurned); |
michael@1 | 1056 | m_pPasteact->setEnabled(bTurned); |
michael@1 | 1057 | m_pReportact->setEnabled(bTurned); |
michael@1 | 1058 | #if defined HAVE_MICO || defined HAVE_ESOAP |
michael@1 | 1059 | if (bTurned) |
michael@1 | 1060 | m_pSyncact->setEnabled(m_pPrefs->getBool(TITRAQ_PREFCORBON, TITRAQ_DEFCORBON) |
michael@1 | 1061 | | m_pPrefs->getBool(TITRAQ_PREFSOAPON, TITRAQ_DEFSOAPON)); |
michael@1 | 1062 | else |
michael@1 | 1063 | m_pSyncact->setEnabled(false); |
michael@1 | 1064 | #endif // defined HAVE_MICO || defined HAVE_ESOAP |
michael@1 | 1065 | |
michael@1 | 1066 | // Unconditional settings |
michael@1 | 1067 | m_pMaintable->setDirty(false); // Reset to clean data |
michael@1 | 1068 | } |
michael@1 | 1069 | |
michael@1 | 1070 | // |
michael@1 | 1071 | // Parse command line arguments for an existing filename, and |
michael@1 | 1072 | // open it to edit the intended (but optional) initial data |
michael@1 | 1073 | // |
michael@1 | 1074 | void Titraqform::loadInit(void) |
michael@1 | 1075 | { |
michael@1 | 1076 | // If the user gives a filename argument to the shell, then open that file |
michael@1 | 1077 | int nNumargs = qApp->argc(); // Holds the number of cmd arguments |
michael@1 | 1078 | int nValid = 0; // Holds the return value |
michael@1 | 1079 | QFile Initial; // Initial event data file |
michael@1 | 1080 | |
michael@1 | 1081 | if (nNumargs > 1) { // Warm up a nice cascade, to set my mind on four weeks of vacation |
michael@1 | 1082 | for (int nIter = 1; nIter < nNumargs; nIter++) { // Salad in New Zealand |
michael@1 | 1083 | if (QChar(*qApp->argv()[nIter]) != '-') { // Bunuelos in Colombia |
michael@1 | 1084 | try { |
michael@1 | 1085 | this->setFilename(qApp->argv()[nIter]); // Store inital filename |
michael@1 | 1086 | Initial.setName(*this->getFilename()); // Initial file to load |
michael@1 | 1087 | if (Initial.exists(*getFilename()) && validateData(Initial)) { |
michael@1 | 1088 | this->loadData(Initial); // Pass to helper method |
michael@1 | 1089 | enableIface(true); // Turn on the lights |
michael@1 | 1090 | m_pStatbar->message(trUtf8("Loaded document ") + *this->getFilename()); |
michael@1 | 1091 | } |
michael@1 | 1092 | else // The inital file name does not correspond to a file |
michael@1 | 1093 | m_pStatbar->message(trUtf8(QString("The file ") + *this->getFilename() + QString(" does not exist."))); |
michael@1 | 1094 | } |
michael@1 | 1095 | catch (Genexcept& Genex) { |
michael@1 | 1096 | Genex.reportErr(); |
michael@1 | 1097 | } |
michael@1 | 1098 | } |
michael@1 | 1099 | } |
michael@1 | 1100 | } |
michael@1 | 1101 | else |
michael@1 | 1102 | m_pStatbar->message(trUtf8("Ready")); // Signal a ready condition |
michael@1 | 1103 | } |