as_gui.h

Fri, 28 Nov 2008 14:20:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 28 Nov 2008 14:20:00 +0100
changeset 2
e8292658d5b3
child 3
c1941114ca88
permissions
-rw-r--r--

Added tag ASGUI_0.7.7 for changeset d64aaa7d146f

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

mercurial