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