michael@1: // michael@1: // OSSP asgui - Accounting system graphical user interface michael@1: // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) michael@1: // Copyright (c) 2002-2004 Ralf S. Engelschall michael@1: // Copyright (c) 2002-2004 Michael Schloh von Bennewitz michael@1: // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH michael@1: // michael@1: // This file is part of OSSP asgui, an accounting system graphical user michael@1: // interface which can be found at http://www.ossp.org/pkg/tool/asgui/. michael@1: // michael@1: // Permission to use, copy, modify, and distribute this software for michael@1: // any purpose with or without fee is hereby granted, provided that michael@1: // the above copyright notice and this permission notice appear in all michael@1: // copies. michael@1: // michael@1: // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@1: // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@1: // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@1: // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@1: // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@1: // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@1: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@1: // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@1: // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@1: // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@1: // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@1: // SUCH DAMAGE. michael@1: // michael@1: // as_gui.h: ISO C++ interface michael@1: // michael@1: michael@1: #ifndef AS_GUI_MWIN_H michael@1: #define AS_GUI_MWIN_H michael@1: michael@1: #include michael@1: michael@1: #ifdef HAVE_CONFIG_H michael@1: #include "ac_config.h" michael@1: #endif michael@1: michael@1: #include "as_except.h" // Exception classes michael@1: michael@1: // Version information michael@1: #define _AS_VERSION_CPP_AS_HEADER_ michael@1: #include "as_version.cpp" michael@1: #undef _AS_VERSION_CPP_AS_HEADER_ michael@1: michael@1: // Trolltech class prototypes michael@1: class QAction; michael@1: class QHeader; michael@1: class QTimeEdit; michael@1: class QComboBox; michael@1: class QLineEdit; michael@1: class QLabel; michael@1: class QDate; michael@1: class QFile; michael@1: michael@1: // Local class prototypes michael@1: class ASTimeEdit; michael@1: class Daydatedit; // Might be replaced with ASTimeEdit throughout michael@1: class TiTable; michael@1: class Preferences; michael@1: class Prefpanel; michael@1: michael@1: // Intentional no operation michael@1: #define TITRAQ_NOP ((void)0) michael@1: michael@1: #ifdef HAVE_CONFIG_H michael@1: #if (SIZEOF_CHAR == 1) michael@1: typedef unsigned char U8; michael@1: #else michael@1: ?==Error: Undefined 8 bit type michael@1: #endif // U8 michael@1: michael@1: #if (SIZEOF_SHORT == 2) michael@1: typedef unsigned short U16; michael@1: #elif (SIZEOF_INT == 2) michael@1: typedef unsigned int U16; michael@1: #elif (SIZEOF_LONG == 2) michael@1: typedef unsigned long U16; michael@1: #else michael@1: ?==Error: Undefined 16 bit type michael@1: #endif // U16 michael@1: michael@1: #if (SIZEOF_SHORT == 4) michael@1: typedef unsigned short U32; michael@1: #elif (SIZEOF_INT == 4) michael@1: typedef unsigned int U32; michael@1: #elif (SIZEOF_LONG == 4) michael@1: typedef unsigned long U32; michael@1: #else michael@1: ?==Error: Undefined 32 bit type michael@1: #endif // U32 michael@1: michael@1: #else // HAVE_CONFIG_H (not defined) michael@1: typedef unsigned char U8; michael@1: michael@1: #if (2 == 2) michael@1: typedef unsigned short U16; michael@1: #elif (4 == 2) michael@1: typedef unsigned int U16; michael@1: #else michael@1: ?==Error: Undefined 16 bit type michael@1: #endif michael@1: michael@1: #if (2 == 4) michael@1: typedef unsigned short U32; michael@1: #elif (4 == 4) michael@1: typedef unsigned int U32; michael@1: #elif (4 == 4) michael@1: typedef unsigned long U32; michael@1: #else michael@1: ?== Error: Undefined 32 bit type michael@1: #endif michael@1: #endif // HAVE_CONFIG_H michael@1: michael@1: michael@1: // Main table size michael@1: const int g_knBlocks = 32; michael@1: michael@1: // Styles enumeration michael@1: typedef enum michael@1: { michael@1: TITRAQ_STYLECDE, michael@1: TITRAQ_STYLESGI, michael@1: TITRAQ_STYLEMOTIF, michael@1: TITRAQ_STYLEMPLUS, michael@1: TITRAQ_STYLEPLAT, michael@1: TITRAQ_STYLEMSOFT michael@1: } styles_t; michael@1: michael@1: // Main application form window michael@1: class Titraqform : public QMainWindow michael@1: { michael@1: Q_OBJECT // Generate MOC object model stubs michael@1: michael@1: public: michael@1: Titraqform(QWidget *pParent = 0, const char *kszName = 0, WFlags Flags = 0); michael@1: ~Titraqform(void); michael@1: michael@1: // Accessor methods michael@1: const QString getRowdata(void) const; // Get a whole row of data michael@1: void setRowdata(QString &) const; // Set a whole row of data michael@1: const int getFirstcol(void) const; // Learn which col is first michael@1: const bool isOpen(void) {return (m_szFilename == NULL) ? false : true;}; // Doc state michael@1: void setOpen(bool bDocopen = true) // Set state of document michael@1: { michael@1: if (bDocopen) { michael@1: if (m_szFilename == NULL) michael@1: m_szFilename = new QString(); michael@1: } michael@1: else michael@1: if (m_szFilename != NULL) { michael@1: delete m_szFilename; michael@1: m_szFilename = NULL; michael@1: } michael@1: }; michael@1: const QString *getFilename(void) // Get the current file name michael@1: { michael@1: if (this->isOpen()) michael@1: return m_szFilename; michael@1: else michael@1: throw Genexcept("File name does not exist."); michael@1: }; michael@1: void setFilename(const QString &Fname) // Set file name michael@1: { michael@1: if (this->isOpen()) // If a file name exists michael@1: setOpen(false); // then get rid of it first michael@1: m_szFilename = new QString(Fname); michael@1: }; michael@1: michael@1: // Utility members michael@1: void loadInit(void); // Parse cmds and open initial file michael@1: michael@1: // Top level members michael@1: Preferences *m_pPrefs; michael@1: michael@1: // Main application actions michael@1: QAction *m_pFilenewact, *m_pFileopenact; michael@1: QAction *m_pFilesaveact, *m_pFilesaveasact; michael@1: QAction *m_pFilecloseact, *m_pFilequitact; michael@1: QAction *m_pAddrowact, *m_pDelrowact; michael@1: QAction *m_pRefreshact, *m_pCutact; michael@1: QAction *m_pCopyact, *m_pPasteact; michael@1: QAction *m_pSyncact, *m_pPrefsact; michael@1: QAction *m_pReportact; michael@1: michael@1: // Table, cells, and entries in package layout michael@1: TiTable *m_pMaintable; michael@1: QHeader *m_pTablehead; michael@1: QStringList *m_pTaskentries; michael@1: michael@1: // Edition widgets michael@1: QLabel *m_pStatusedit; // Control to show entry status michael@1: QLineEdit *m_pLineedit; // Control to line number michael@1: QLineEdit *m_pUseredit; // Control to edit user name michael@1: QLineEdit *m_pGuidedit; // Control to edit GUID michael@1: QLineEdit *m_pCrcedit; // Control to edit CRC michael@1: QLineEdit *m_pRevedit; // Control to edit revision michael@1: Daydatedit *m_pDateedit; // Control to edit date michael@1: QTimeEdit *m_pStarttime; // Control to edit start time michael@1: QTimeEdit *m_pEndtime; // Control to edit finish time michael@1: // QTimeEdit *m_pAmount; // Control to edit total time michael@1: ASTimeEdit *m_pAmount; // Control to edit total time michael@1: QComboBox *m_pTasks; // Control to choose a task michael@1: QLineEdit *m_pRemark; // Control to edit remark michael@1: michael@1: protected slots: michael@1: void cutEntry(void); // Cut task entries from the list michael@1: void copyEntry(void); // Copy task entries from the list michael@1: void pasteEntry(void); // Paste task entries to the list michael@1: void addEntry(int nRows= -1); // Add task entries to the list michael@1: void delEntry(int nRows= -1); // Delete task entries from the list michael@1: void refreshDisplay(void); // Refresh the display of all data items michael@1: void syncIiop(void); // Syncronize data with server using IIOP michael@1: void syncSoap(void); // Syncronize data with server using SOAP michael@1: void newDoc(void); // Make and display a new document window michael@1: void openDoc(void); // Open and display an existing document michael@1: void quitApp(void); // Close the current document and quit michael@1: void saveFile(void); // Serialize to the current file michael@1: void saveAs(void); // Serialize to a selected file michael@1: void saveName(void); // Implicitly serialize to a selected file michael@1: void helpContents(void); // Use the help contents michael@1: void aboutTitraq(void); // Learn more about this program itself michael@1: void aboutOSSP(void); // Learn more about the OSSP michael@1: void aboutQt(void); // Learn more about Qt michael@1: void selAll(void); // Edit menu select all michael@1: void onClick(int, int, int, const QPoint &); // Table was clicked michael@1: void inplaceEdit(int, int, int, const QPoint &); // Enter in place edit mode michael@1: void updEdit(int, int nCol = 0); // Update edit controls michael@1: void validateRow(void); // Validate current row of matrix michael@1: void validateRow(int, int); // Validate specified row of matrix michael@1: void updSizes(int, int, int); // Update edit sizes michael@1: void calcCrc(void); // Calculate CRC of current row michael@1: void calcCrc(int, int); // Calculate CRC of specified row michael@1: void dataChanged(int, int); // Timesheet data changed michael@1: void updateLine(const QString &); // Update line number column michael@1: void updateUser(const QString &); // Update user column michael@1: void updateGuid(const QString &); // Update GUID column michael@1: void updateCrc(const QString &); // Update CRC column michael@1: void updateRev(const QString &); // Update rev column michael@1: void updateDate(const QDate &); // Update date column michael@1: void updateStart(const QTime &); // Update start column michael@1: void updateFinish(const QTime &); // Update finish column michael@1: void updateAmount(const QTime &); // Update amount column michael@1: void updateTask(const QString &); // Update task column michael@1: void updateRemark(const QString &); // Update remark column michael@1: void confirmEdit(void); // Confirm whole row edition michael@1: void configPrefs(void); // Edit menu configure preferences michael@1: void normalView(void); // View menu normal michael@1: void editingView(void); // View menu editing michael@1: void timingView(void); // View menu timing michael@1: void showFilebar(void); // View menu show file toolbar michael@1: void showEditbar(void); // View menu show edit toolbar michael@1: void showViewbar(void); // View menu show view toolbar michael@1: void showPrefsbar(void); // View menu show prefs toolbar michael@1: void showWhatsbar(void); // View menu show whats this toolbar michael@1: void showStatcol(void); // View menu show status column michael@1: void showLinecol(void); // View menu show line numbers column michael@1: void showUsercol(void); // View menu show Users column michael@1: void showGuidcol(void); // View menu show GUIDs column michael@1: void showCrccol(void); // View menu show CRC column michael@1: void showRevcol(void); // View menu show Rev column michael@1: void showDatecol(void); // View menu show Dates column michael@1: void showStartcol(void); // View menu show Start time column michael@1: void showFinishcol(void); // View menu show Finish time column michael@1: void showAmountcol(void); // View menu show Amounts column michael@1: void showTaskcol(void); // View menu show Tasks column michael@1: void showRemarkcol(void); // View menu show Remarks column michael@1: void genReport(void); // Generate a local formatted report michael@1: void savePrefs(void); // Save user preferences michael@1: void applyPrefs(void); // Apply preferences from applied() michael@1: void applyPrefs(Prefpanel *); // Apply preferences from accept() michael@1: michael@1: protected: michael@1: // Application main events michael@1: void closeEvent(QCloseEvent *); // Close current document in main window michael@1: michael@1: // Application main window widgets michael@1: QFrame *m_pCenframe; // Central frame michael@1: QVBoxLayout *m_pMainlayout; // Package and control layouts michael@1: QVBoxLayout *m_pPackagelayout; // Main table control michael@1: QHBoxLayout *m_pEditlayout; // Lower edition widgets michael@1: michael@1: private: michael@1: // Owned by QMainWindow michael@1: QMenuBar *m_pMenubar; michael@1: QPopupMenu *m_pViewpopup; // Saved for manipulating views michael@1: QPopupMenu *m_pTbarspopup; // Saved for manipulating toolbars michael@1: QPopupMenu *m_pColspopup; // Saved for manipulating columns michael@1: QStatusBar *m_pStatbar; michael@1: michael@1: // Belong to us michael@1: QToolBar *m_pFiletools; michael@1: QToolBar *m_pEdittools; michael@1: QToolBar *m_pViewtools; michael@1: QToolBar *m_pPrefstools; michael@1: QToolBar *m_pWhatstools; michael@1: QString *m_szFilename; michael@1: michael@1: // Constructor helpers michael@1: void setupPrefs(void); // Preferences michael@1: void setupActions(void); // Actions michael@1: void setupMenubar(void); // Menu bar michael@1: void setupToolbars(void); // Tool bars michael@1: void setupStatusbar(void); // Status bar michael@1: void setupCentralwidget(void); // Assemble main Frame widget michael@1: void setupTable(void); // Table widget michael@1: void setupEditlay(void); // Editing lay michael@1: void setupPieces(void); // Assemble widget pieces michael@1: void setupColumns(void); // Arrange and configure columns michael@1: void enableIface(bool); // [En/dis]able most ui pieces michael@1: michael@1: // Data processing michael@1: void loadAccounts(QFile &); // Load accounts from file michael@1: void loadAccounts(QTextStream &); // Load accounts from stream michael@1: void loadData(QFile &); // Load personal data from file michael@1: void loadData(QTextStream &); // Load personal data from stream michael@1: void saveData(QFile &); // Save accounting data to file michael@1: void saveData(QTextStream &); // Save accounting data to stream michael@1: const bool validateData(QFile &) const; // Validate personal data in file michael@1: const bool validateData(QString &) const; // Validate personal data from string michael@1: }; michael@1: michael@1: #endif // AS_GUI_MWIN_H