1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/as_gui.h Fri Nov 28 11:21:08 2008 +0100 1.3 @@ -0,0 +1,325 @@ 1.4 +// 1.5 +// OSSP asgui - Accounting system graphical user interface 1.6 +// Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) 1.7 +// Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com> 1.8 +// Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com> 1.9 +// Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH 1.10 +// 1.11 +// This file is part of OSSP asgui, an accounting system graphical user 1.12 +// interface which can be found at http://www.ossp.org/pkg/tool/asgui/. 1.13 +// 1.14 +// Permission to use, copy, modify, and distribute this software for 1.15 +// any purpose with or without fee is hereby granted, provided that 1.16 +// the above copyright notice and this permission notice appear in all 1.17 +// copies. 1.18 +// 1.19 +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 1.20 +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1.21 +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.22 +// IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 1.23 +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.24 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.25 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 1.26 +// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 1.27 +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1.28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1.29 +// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.30 +// SUCH DAMAGE. 1.31 +// 1.32 +// as_gui.h: ISO C++ interface 1.33 +// 1.34 + 1.35 +#ifndef AS_GUI_MWIN_H 1.36 +#define AS_GUI_MWIN_H 1.37 + 1.38 +#include <qmainwindow.h> 1.39 + 1.40 +#ifdef HAVE_CONFIG_H 1.41 +#include "ac_config.h" 1.42 +#endif 1.43 + 1.44 +#include "as_except.h" // Exception classes 1.45 + 1.46 +// Version information 1.47 +#define _AS_VERSION_CPP_AS_HEADER_ 1.48 +#include "as_version.cpp" 1.49 +#undef _AS_VERSION_CPP_AS_HEADER_ 1.50 + 1.51 +// Trolltech class prototypes 1.52 +class QAction; 1.53 +class QHeader; 1.54 +class QTimeEdit; 1.55 +class QComboBox; 1.56 +class QLineEdit; 1.57 +class QLabel; 1.58 +class QDate; 1.59 +class QFile; 1.60 + 1.61 +// Local class prototypes 1.62 +class ASTimeEdit; 1.63 +class Daydatedit; // Might be replaced with ASTimeEdit throughout 1.64 +class TiTable; 1.65 +class Preferences; 1.66 +class Prefpanel; 1.67 + 1.68 +// Intentional no operation 1.69 +#define TITRAQ_NOP ((void)0) 1.70 + 1.71 +#ifdef HAVE_CONFIG_H 1.72 +#if (SIZEOF_CHAR == 1) 1.73 +typedef unsigned char U8; 1.74 +#else 1.75 +?==Error: Undefined 8 bit type 1.76 +#endif // U8 1.77 + 1.78 +#if (SIZEOF_SHORT == 2) 1.79 +typedef unsigned short U16; 1.80 +#elif (SIZEOF_INT == 2) 1.81 +typedef unsigned int U16; 1.82 +#elif (SIZEOF_LONG == 2) 1.83 +typedef unsigned long U16; 1.84 +#else 1.85 +?==Error: Undefined 16 bit type 1.86 +#endif // U16 1.87 + 1.88 +#if (SIZEOF_SHORT == 4) 1.89 +typedef unsigned short U32; 1.90 +#elif (SIZEOF_INT == 4) 1.91 +typedef unsigned int U32; 1.92 +#elif (SIZEOF_LONG == 4) 1.93 +typedef unsigned long U32; 1.94 +#else 1.95 +?==Error: Undefined 32 bit type 1.96 +#endif // U32 1.97 + 1.98 +#else // HAVE_CONFIG_H (not defined) 1.99 +typedef unsigned char U8; 1.100 + 1.101 +#if (2 == 2) 1.102 +typedef unsigned short U16; 1.103 +#elif (4 == 2) 1.104 +typedef unsigned int U16; 1.105 +#else 1.106 +?==Error: Undefined 16 bit type 1.107 +#endif 1.108 + 1.109 +#if (2 == 4) 1.110 +typedef unsigned short U32; 1.111 +#elif (4 == 4) 1.112 +typedef unsigned int U32; 1.113 +#elif (4 == 4) 1.114 +typedef unsigned long U32; 1.115 +#else 1.116 +?== Error: Undefined 32 bit type 1.117 +#endif 1.118 +#endif // HAVE_CONFIG_H 1.119 + 1.120 + 1.121 +// Main table size 1.122 +const int g_knBlocks = 32; 1.123 + 1.124 +// Styles enumeration 1.125 +typedef enum 1.126 +{ 1.127 + TITRAQ_STYLECDE, 1.128 + TITRAQ_STYLESGI, 1.129 + TITRAQ_STYLEMOTIF, 1.130 + TITRAQ_STYLEMPLUS, 1.131 + TITRAQ_STYLEPLAT, 1.132 + TITRAQ_STYLEMSOFT 1.133 +} styles_t; 1.134 + 1.135 +// Main application form window 1.136 +class Titraqform : public QMainWindow 1.137 +{ 1.138 + Q_OBJECT // Generate MOC object model stubs 1.139 + 1.140 +public: 1.141 + Titraqform(QWidget *pParent = 0, const char *kszName = 0, WFlags Flags = 0); 1.142 + ~Titraqform(void); 1.143 + 1.144 + // Accessor methods 1.145 + const QString getRowdata(void) const; // Get a whole row of data 1.146 + void setRowdata(QString &) const; // Set a whole row of data 1.147 + const int getFirstcol(void) const; // Learn which col is first 1.148 + const bool isOpen(void) {return (m_szFilename == NULL) ? false : true;}; // Doc state 1.149 + void setOpen(bool bDocopen = true) // Set state of document 1.150 + { 1.151 + if (bDocopen) { 1.152 + if (m_szFilename == NULL) 1.153 + m_szFilename = new QString(); 1.154 + } 1.155 + else 1.156 + if (m_szFilename != NULL) { 1.157 + delete m_szFilename; 1.158 + m_szFilename = NULL; 1.159 + } 1.160 + }; 1.161 + const QString *getFilename(void) // Get the current file name 1.162 + { 1.163 + if (this->isOpen()) 1.164 + return m_szFilename; 1.165 + else 1.166 + throw Genexcept("File name does not exist."); 1.167 + }; 1.168 + void setFilename(const QString &Fname) // Set file name 1.169 + { 1.170 + if (this->isOpen()) // If a file name exists 1.171 + setOpen(false); // then get rid of it first 1.172 + m_szFilename = new QString(Fname); 1.173 + }; 1.174 + 1.175 + // Utility members 1.176 + void loadInit(void); // Parse cmds and open initial file 1.177 + 1.178 + // Top level members 1.179 + Preferences *m_pPrefs; 1.180 + 1.181 + // Main application actions 1.182 + QAction *m_pFilenewact, *m_pFileopenact; 1.183 + QAction *m_pFilesaveact, *m_pFilesaveasact; 1.184 + QAction *m_pFilecloseact, *m_pFilequitact; 1.185 + QAction *m_pAddrowact, *m_pDelrowact; 1.186 + QAction *m_pRefreshact, *m_pCutact; 1.187 + QAction *m_pCopyact, *m_pPasteact; 1.188 + QAction *m_pSyncact, *m_pPrefsact; 1.189 + QAction *m_pReportact; 1.190 + 1.191 + // Table, cells, and entries in package layout 1.192 + TiTable *m_pMaintable; 1.193 + QHeader *m_pTablehead; 1.194 + QStringList *m_pTaskentries; 1.195 + 1.196 + // Edition widgets 1.197 + QLabel *m_pStatusedit; // Control to show entry status 1.198 + QLineEdit *m_pLineedit; // Control to line number 1.199 + QLineEdit *m_pUseredit; // Control to edit user name 1.200 + QLineEdit *m_pGuidedit; // Control to edit GUID 1.201 + QLineEdit *m_pCrcedit; // Control to edit CRC 1.202 + QLineEdit *m_pRevedit; // Control to edit revision 1.203 + Daydatedit *m_pDateedit; // Control to edit date 1.204 + QTimeEdit *m_pStarttime; // Control to edit start time 1.205 + QTimeEdit *m_pEndtime; // Control to edit finish time 1.206 +// QTimeEdit *m_pAmount; // Control to edit total time 1.207 + ASTimeEdit *m_pAmount; // Control to edit total time 1.208 + QComboBox *m_pTasks; // Control to choose a task 1.209 + QLineEdit *m_pRemark; // Control to edit remark 1.210 + 1.211 +protected slots: 1.212 + void cutEntry(void); // Cut task entries from the list 1.213 + void copyEntry(void); // Copy task entries from the list 1.214 + void pasteEntry(void); // Paste task entries to the list 1.215 + void addEntry(int nRows= -1); // Add task entries to the list 1.216 + void delEntry(int nRows= -1); // Delete task entries from the list 1.217 + void refreshDisplay(void); // Refresh the display of all data items 1.218 + void syncIiop(void); // Syncronize data with server using IIOP 1.219 + void syncSoap(void); // Syncronize data with server using SOAP 1.220 + void newDoc(void); // Make and display a new document window 1.221 + void openDoc(void); // Open and display an existing document 1.222 + void quitApp(void); // Close the current document and quit 1.223 + void saveFile(void); // Serialize to the current file 1.224 + void saveAs(void); // Serialize to a selected file 1.225 + void saveName(void); // Implicitly serialize to a selected file 1.226 + void helpContents(void); // Use the help contents 1.227 + void aboutTitraq(void); // Learn more about this program itself 1.228 + void aboutOSSP(void); // Learn more about the OSSP 1.229 + void aboutQt(void); // Learn more about Qt 1.230 + void selAll(void); // Edit menu select all 1.231 + void onClick(int, int, int, const QPoint &); // Table was clicked 1.232 + void inplaceEdit(int, int, int, const QPoint &); // Enter in place edit mode 1.233 + void updEdit(int, int nCol = 0); // Update edit controls 1.234 + void validateRow(void); // Validate current row of matrix 1.235 + void validateRow(int, int); // Validate specified row of matrix 1.236 + void updSizes(int, int, int); // Update edit sizes 1.237 + void calcCrc(void); // Calculate CRC of current row 1.238 + void calcCrc(int, int); // Calculate CRC of specified row 1.239 + void dataChanged(int, int); // Timesheet data changed 1.240 + void updateLine(const QString &); // Update line number column 1.241 + void updateUser(const QString &); // Update user column 1.242 + void updateGuid(const QString &); // Update GUID column 1.243 + void updateCrc(const QString &); // Update CRC column 1.244 + void updateRev(const QString &); // Update rev column 1.245 + void updateDate(const QDate &); // Update date column 1.246 + void updateStart(const QTime &); // Update start column 1.247 + void updateFinish(const QTime &); // Update finish column 1.248 + void updateAmount(const QTime &); // Update amount column 1.249 + void updateTask(const QString &); // Update task column 1.250 + void updateRemark(const QString &); // Update remark column 1.251 + void confirmEdit(void); // Confirm whole row edition 1.252 + void configPrefs(void); // Edit menu configure preferences 1.253 + void normalView(void); // View menu normal 1.254 + void editingView(void); // View menu editing 1.255 + void timingView(void); // View menu timing 1.256 + void showFilebar(void); // View menu show file toolbar 1.257 + void showEditbar(void); // View menu show edit toolbar 1.258 + void showViewbar(void); // View menu show view toolbar 1.259 + void showPrefsbar(void); // View menu show prefs toolbar 1.260 + void showWhatsbar(void); // View menu show whats this toolbar 1.261 + void showStatcol(void); // View menu show status column 1.262 + void showLinecol(void); // View menu show line numbers column 1.263 + void showUsercol(void); // View menu show Users column 1.264 + void showGuidcol(void); // View menu show GUIDs column 1.265 + void showCrccol(void); // View menu show CRC column 1.266 + void showRevcol(void); // View menu show Rev column 1.267 + void showDatecol(void); // View menu show Dates column 1.268 + void showStartcol(void); // View menu show Start time column 1.269 + void showFinishcol(void); // View menu show Finish time column 1.270 + void showAmountcol(void); // View menu show Amounts column 1.271 + void showTaskcol(void); // View menu show Tasks column 1.272 + void showRemarkcol(void); // View menu show Remarks column 1.273 + void genReport(void); // Generate a local formatted report 1.274 + void savePrefs(void); // Save user preferences 1.275 + void applyPrefs(void); // Apply preferences from applied() 1.276 + void applyPrefs(Prefpanel *); // Apply preferences from accept() 1.277 + 1.278 +protected: 1.279 + // Application main events 1.280 + void closeEvent(QCloseEvent *); // Close current document in main window 1.281 + 1.282 + // Application main window widgets 1.283 + QFrame *m_pCenframe; // Central frame 1.284 + QVBoxLayout *m_pMainlayout; // Package and control layouts 1.285 + QVBoxLayout *m_pPackagelayout; // Main table control 1.286 + QHBoxLayout *m_pEditlayout; // Lower edition widgets 1.287 + 1.288 +private: 1.289 + // Owned by QMainWindow 1.290 + QMenuBar *m_pMenubar; 1.291 + QPopupMenu *m_pViewpopup; // Saved for manipulating views 1.292 + QPopupMenu *m_pTbarspopup; // Saved for manipulating toolbars 1.293 + QPopupMenu *m_pColspopup; // Saved for manipulating columns 1.294 + QStatusBar *m_pStatbar; 1.295 + 1.296 + // Belong to us 1.297 + QToolBar *m_pFiletools; 1.298 + QToolBar *m_pEdittools; 1.299 + QToolBar *m_pViewtools; 1.300 + QToolBar *m_pPrefstools; 1.301 + QToolBar *m_pWhatstools; 1.302 + QString *m_szFilename; 1.303 + 1.304 + // Constructor helpers 1.305 + void setupPrefs(void); // Preferences 1.306 + void setupActions(void); // Actions 1.307 + void setupMenubar(void); // Menu bar 1.308 + void setupToolbars(void); // Tool bars 1.309 + void setupStatusbar(void); // Status bar 1.310 + void setupCentralwidget(void); // Assemble main Frame widget 1.311 + void setupTable(void); // Table widget 1.312 + void setupEditlay(void); // Editing lay 1.313 + void setupPieces(void); // Assemble widget pieces 1.314 + void setupColumns(void); // Arrange and configure columns 1.315 + void enableIface(bool); // [En/dis]able most ui pieces 1.316 + 1.317 + // Data processing 1.318 + void loadAccounts(QFile &); // Load accounts from file 1.319 + void loadAccounts(QTextStream &); // Load accounts from stream 1.320 + void loadData(QFile &); // Load personal data from file 1.321 + void loadData(QTextStream &); // Load personal data from stream 1.322 + void saveData(QFile &); // Save accounting data to file 1.323 + void saveData(QTextStream &); // Save accounting data to stream 1.324 + const bool validateData(QFile &) const; // Validate personal data in file 1.325 + const bool validateData(QString &) const; // Validate personal data from string 1.326 +}; 1.327 + 1.328 +#endif // AS_GUI_MWIN_H