Wed, 07 Jan 2009 18:49:25 +0100
Bump copyright year number.
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_gui.h: ISO C++ interface
30 //
32 #ifndef AS_GUI_MWIN_H
33 #define AS_GUI_MWIN_H
35 #define QT3_SUPPORT
36 #include <q3mainwindow.h>
38 //Added by qt3to4:
39 #include <Q3TextStream>
40 #include <Q3HBoxLayout>
41 #include <QCloseEvent>
42 #include <Q3Frame>
43 #include <QLabel>
44 #include <Q3PopupMenu>
45 #include <Q3VBoxLayout>
46 #include <Q3Action>
47 #include <Q3ComboBox>
49 #ifdef HAVE_CONFIG_H
50 #include "ac_config.h"
51 #endif
53 #include "as_except.h" // Exception classes
55 // Version information
56 #define _AS_VERSION_CPP_AS_HEADER_
57 #include "as_version.cpp"
58 #undef _AS_VERSION_CPP_AS_HEADER_
60 // Trolltech class prototypes
61 class Q3Action;
62 class Q3Header;
63 class Q3TimeEdit;
64 class Q3ComboBox;
65 class QLineEdit;
66 class QLabel;
67 class QDate;
68 class QFile;
70 // Local class prototypes
71 class ASTimeEdit;
72 class Daydatedit; // Might be replaced with ASTimeEdit throughout
73 class TiTable;
74 class Preferences;
75 class Prefpanel;
77 // Intentional no operation
78 #define TITRAQ_NOP ((void)0)
80 #ifdef HAVE_CONFIG_H
81 #if (SIZEOF_CHAR == 1)
82 typedef unsigned char U8;
83 #else
84 ?==Error: Undefined 8 bit type
85 #endif // U8
87 #if (SIZEOF_SHORT == 2)
88 typedef unsigned short U16;
89 #elif (SIZEOF_INT == 2)
90 typedef unsigned int U16;
91 #elif (SIZEOF_LONG == 2)
92 typedef unsigned long U16;
93 #else
94 ?==Error: Undefined 16 bit type
95 #endif // U16
97 #if (SIZEOF_SHORT == 4)
98 typedef unsigned short U32;
99 #elif (SIZEOF_INT == 4)
100 typedef unsigned int U32;
101 #elif (SIZEOF_LONG == 4)
102 typedef unsigned long U32;
103 #else
104 ?==Error: Undefined 32 bit type
105 #endif // U32
107 #else // HAVE_CONFIG_H (not defined)
108 typedef unsigned char U8;
110 #if (2 == 2)
111 typedef unsigned short U16;
112 #elif (4 == 2)
113 typedef unsigned int U16;
114 #else
115 ?==Error: Undefined 16 bit type
116 #endif
118 #if (2 == 4)
119 typedef unsigned short U32;
120 #elif (4 == 4)
121 typedef unsigned int U32;
122 #elif (4 == 4)
123 typedef unsigned long U32;
124 #else
125 ?== Error: Undefined 32 bit type
126 #endif
127 #endif // HAVE_CONFIG_H
130 // Main table size
131 const int g_knBlocks = 32;
133 // Styles enumeration
134 typedef enum
135 {
136 TITRAQ_STYLECDE,
137 TITRAQ_STYLESGI,
138 TITRAQ_STYLEMOTIF,
139 TITRAQ_STYLEMPLUS,
140 TITRAQ_STYLEPLAT,
141 TITRAQ_STYLEMSOFT
142 } styles_t;
144 // Main application form window
145 class Titraqform : public Q3MainWindow
146 {
147 Q_OBJECT // Generate MOC object model stubs
149 public:
150 Titraqform(QWidget *pParent = 0, const char *kszName = 0, Qt::WFlags Flags = 0);
151 ~Titraqform(void);
153 // Accessor methods
154 const QString getRowdata(void) const; // Get a whole row of data
155 void setRowdata(QString &) const; // Set a whole row of data
156 const int getFirstcol(void) const; // Learn which col is first
157 const bool isOpen(void) {return (m_szFilename == NULL) ? false : true;}; // Doc state
158 void setOpen(bool bDocopen = true) // Set state of document
159 {
160 if (bDocopen) {
161 if (m_szFilename == NULL)
162 m_szFilename = new QString();
163 }
164 else
165 if (m_szFilename != NULL) {
166 delete m_szFilename;
167 m_szFilename = NULL;
168 }
169 };
170 const QString *getFilename(void) // Get the current file name
171 {
172 if (this->isOpen())
173 return m_szFilename;
174 else
175 throw Genexcept("File name does not exist.");
176 };
177 void setFilename(const QString &Fname) // Set file name
178 {
179 if (this->isOpen()) // If a file name exists
180 setOpen(false); // then get rid of it first
181 m_szFilename = new QString(Fname);
182 };
184 // Utility members
185 void loadInit(void); // Parse cmds and open initial file
187 // Top level members
188 Preferences *m_pPrefs;
190 // Main application actions
191 Q3Action *m_pFilenewact, *m_pFileopenact;
192 Q3Action *m_pFilesaveact, *m_pFilesaveasact;
193 Q3Action *m_pFilecloseact, *m_pFilequitact;
194 Q3Action *m_pAddrowact, *m_pDelrowact;
195 Q3Action *m_pRefreshact, *m_pCutact;
196 Q3Action *m_pCopyact, *m_pPasteact;
197 Q3Action *m_pSyncact, *m_pPrefsact;
198 Q3Action *m_pReportact;
200 // Table, cells, and entries in package layout
201 TiTable *m_pMaintable;
202 Q3Header *m_pTablehead;
203 QStringList *m_pTaskentries;
205 // Edition widgets
206 QLabel *m_pStatusedit; // Control to show entry status
207 QLineEdit *m_pLineedit; // Control to line number
208 QLineEdit *m_pUseredit; // Control to edit user name
209 QLineEdit *m_pGuidedit; // Control to edit GUID
210 QLineEdit *m_pCrcedit; // Control to edit CRC
211 QLineEdit *m_pRevedit; // Control to edit revision
212 Daydatedit *m_pDateedit; // Control to edit date
213 Q3TimeEdit *m_pStarttime; // Control to edit start time
214 Q3TimeEdit *m_pEndtime; // Control to edit finish time
215 // QTimeEdit *m_pAmount; // Control to edit total time
216 ASTimeEdit *m_pAmount; // Control to edit total time
217 Q3ComboBox *m_pTasks; // Control to choose a task
218 QLineEdit *m_pRemark; // Control to edit remark
220 protected slots:
221 void cutEntry(void); // Cut task entries from the list
222 void copyEntry(void); // Copy task entries from the list
223 void pasteEntry(void); // Paste task entries to the list
224 void addEntry(int nRows= -1); // Add task entries to the list
225 void delEntry(int nRows= -1); // Delete task entries from the list
226 void refreshDisplay(void); // Refresh the display of all data items
227 void syncIiop(void); // Syncronize data with server using IIOP
228 void syncSoap(void); // Syncronize data with server using SOAP
229 void newDoc(void); // Make and display a new document window
230 void openDoc(void); // Open and display an existing document
231 void quitApp(void); // Close the current document and quit
232 void saveFile(void); // Serialize to the current file
233 void saveAs(void); // Serialize to a selected file
234 void saveName(void); // Implicitly serialize to a selected file
235 void helpContents(void); // Use the help contents
236 void aboutTitraq(void); // Learn more about this program itself
237 void aboutOSSP(void); // Learn more about the OSSP
238 void aboutQt(void); // Learn more about Qt
239 void selAll(void); // Edit menu select all
240 void onClick(int, int, int, const QPoint &); // Table was clicked
241 void inplaceEdit(int, int, int, const QPoint &); // Enter in place edit mode
242 void updEdit(int, int nCol = 0); // Update edit controls
243 void validateRow(void); // Validate current row of matrix
244 void validateRow(int, int); // Validate specified row of matrix
245 void updSizes(int, int, int); // Update edit sizes
246 void calcCrc(void); // Calculate CRC of current row
247 void calcCrc(int, int); // Calculate CRC of specified row
248 void dataChanged(int, int); // Timesheet data changed
249 void updateLine(const QString &); // Update line number column
250 void updateUser(const QString &); // Update user column
251 void updateGuid(const QString &); // Update GUID column
252 void updateCrc(const QString &); // Update CRC column
253 void updateRev(const QString &); // Update rev column
254 void updateDate(const QDate &); // Update date column
255 void updateStart(const QTime &); // Update start column
256 void updateFinish(const QTime &); // Update finish column
257 void updateAmount(const QTime &); // Update amount column
258 void updateTask(const QString &); // Update task column
259 void updateRemark(const QString &); // Update remark column
260 void confirmEdit(void); // Confirm whole row edition
261 void configPrefs(void); // Edit menu configure preferences
262 void normalView(void); // View menu normal
263 void editingView(void); // View menu editing
264 void timingView(void); // View menu timing
265 void showFilebar(void); // View menu show file toolbar
266 void showEditbar(void); // View menu show edit toolbar
267 void showViewbar(void); // View menu show view toolbar
268 void showPrefsbar(void); // View menu show prefs toolbar
269 void showWhatsbar(void); // View menu show whats this toolbar
270 void showStatcol(void); // View menu show status column
271 void showLinecol(void); // View menu show line numbers column
272 void showUsercol(void); // View menu show Users column
273 void showGuidcol(void); // View menu show GUIDs column
274 void showCrccol(void); // View menu show CRC column
275 void showRevcol(void); // View menu show Rev column
276 void showDatecol(void); // View menu show Dates column
277 void showStartcol(void); // View menu show Start time column
278 void showFinishcol(void); // View menu show Finish time column
279 void showAmountcol(void); // View menu show Amounts column
280 void showTaskcol(void); // View menu show Tasks column
281 void showRemarkcol(void); // View menu show Remarks column
282 void genReport(void); // Generate a local formatted report
283 void savePrefs(void); // Save user preferences
284 void applyPrefs(void); // Apply preferences from applied()
285 void applyPrefs(Prefpanel *); // Apply preferences from accept()
287 protected:
288 // Application main events
289 void closeEvent(QCloseEvent *); // Close current document in main window
291 // Application main window widgets
292 Q3Frame *m_pCenframe; // Central frame
293 Q3VBoxLayout *m_pMainlayout; // Package and control layouts
294 Q3VBoxLayout *m_pPackagelayout; // Main table control
295 Q3HBoxLayout *m_pEditlayout; // Lower edition widgets
297 private:
298 // Owned by QMainWindow
299 QMenuBar *m_pMenubar;
300 Q3PopupMenu *m_pViewpopup; // Saved for manipulating views
301 Q3PopupMenu *m_pTbarspopup; // Saved for manipulating toolbars
302 Q3PopupMenu *m_pColspopup; // Saved for manipulating columns
303 QStatusBar *m_pStatbar;
305 // Belong to us
306 Q3ToolBar *m_pFiletools;
307 Q3ToolBar *m_pEdittools;
308 Q3ToolBar *m_pViewtools;
309 Q3ToolBar *m_pPrefstools;
310 Q3ToolBar *m_pWhatstools;
311 QString *m_szFilename;
313 // Constructor helpers
314 void setupPrefs(void); // Preferences
315 void setupActions(void); // Actions
316 void setupMenubar(void); // Menu bar
317 void setupToolbars(void); // Tool bars
318 void setupStatusbar(void); // Status bar
319 void setupCentralwidget(void); // Assemble main Frame widget
320 void setupTable(void); // Table widget
321 void setupEditlay(void); // Editing lay
322 void setupPieces(void); // Assemble widget pieces
323 void setupColumns(void); // Arrange and configure columns
324 void enableIface(bool); // [En/dis]able most ui pieces
326 // Data processing
327 void loadAccounts(QFile &); // Load accounts from file
328 void loadAccounts(Q3TextStream &); // Load accounts from stream
329 void loadData(QFile &); // Load personal data from file
330 void loadData(Q3TextStream &); // Load personal data from stream
331 void saveData(QFile &); // Save accounting data to file
332 void saveData(Q3TextStream &); // Save accounting data to stream
333 const bool validateData(QFile &) const; // Validate personal data in file
334 const bool validateData(QString &) const; // Validate personal data from string
335 };
337 #endif // AS_GUI_MWIN_H