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