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

michael@1 1 //
michael@1 2 // OSSP asgui - Accounting system graphical user interface
michael@1 3 // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/)
michael@1 4 // Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com>
michael@1 5 // Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com>
michael@1 6 // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH
michael@1 7 //
michael@1 8 // This file is part of OSSP asgui, an accounting system graphical user
michael@1 9 // interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
michael@1 10 //
michael@1 11 // Permission to use, copy, modify, and distribute this software for
michael@1 12 // any purpose with or without fee is hereby granted, provided that
michael@1 13 // the above copyright notice and this permission notice appear in all
michael@1 14 // copies.
michael@1 15 //
michael@1 16 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@1 17 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@1 18 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@1 19 // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@1 20 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@1 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@1 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@1 23 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@1 24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@1 25 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@1 26 // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@1 27 // SUCH DAMAGE.
michael@1 28 //
michael@1 29 // as_gui.h: ISO C++ interface
michael@1 30 //
michael@1 31
michael@1 32 #ifndef AS_GUI_MWIN_H
michael@1 33 #define AS_GUI_MWIN_H
michael@1 34
michael@1 35 #include <qmainwindow.h>
michael@1 36
michael@1 37 #ifdef HAVE_CONFIG_H
michael@1 38 #include "ac_config.h"
michael@1 39 #endif
michael@1 40
michael@1 41 #include "as_except.h" // Exception classes
michael@1 42
michael@1 43 // Version information
michael@1 44 #define _AS_VERSION_CPP_AS_HEADER_
michael@1 45 #include "as_version.cpp"
michael@1 46 #undef _AS_VERSION_CPP_AS_HEADER_
michael@1 47
michael@1 48 // Trolltech class prototypes
michael@1 49 class QAction;
michael@1 50 class QHeader;
michael@1 51 class QTimeEdit;
michael@1 52 class QComboBox;
michael@1 53 class QLineEdit;
michael@1 54 class QLabel;
michael@1 55 class QDate;
michael@1 56 class QFile;
michael@1 57
michael@1 58 // Local class prototypes
michael@1 59 class ASTimeEdit;
michael@1 60 class Daydatedit; // Might be replaced with ASTimeEdit throughout
michael@1 61 class TiTable;
michael@1 62 class Preferences;
michael@1 63 class Prefpanel;
michael@1 64
michael@1 65 // Intentional no operation
michael@1 66 #define TITRAQ_NOP ((void)0)
michael@1 67
michael@1 68 #ifdef HAVE_CONFIG_H
michael@1 69 #if (SIZEOF_CHAR == 1)
michael@1 70 typedef unsigned char U8;
michael@1 71 #else
michael@1 72 ?==Error: Undefined 8 bit type
michael@1 73 #endif // U8
michael@1 74
michael@1 75 #if (SIZEOF_SHORT == 2)
michael@1 76 typedef unsigned short U16;
michael@1 77 #elif (SIZEOF_INT == 2)
michael@1 78 typedef unsigned int U16;
michael@1 79 #elif (SIZEOF_LONG == 2)
michael@1 80 typedef unsigned long U16;
michael@1 81 #else
michael@1 82 ?==Error: Undefined 16 bit type
michael@1 83 #endif // U16
michael@1 84
michael@1 85 #if (SIZEOF_SHORT == 4)
michael@1 86 typedef unsigned short U32;
michael@1 87 #elif (SIZEOF_INT == 4)
michael@1 88 typedef unsigned int U32;
michael@1 89 #elif (SIZEOF_LONG == 4)
michael@1 90 typedef unsigned long U32;
michael@1 91 #else
michael@1 92 ?==Error: Undefined 32 bit type
michael@1 93 #endif // U32
michael@1 94
michael@1 95 #else // HAVE_CONFIG_H (not defined)
michael@1 96 typedef unsigned char U8;
michael@1 97
michael@1 98 #if (2 == 2)
michael@1 99 typedef unsigned short U16;
michael@1 100 #elif (4 == 2)
michael@1 101 typedef unsigned int U16;
michael@1 102 #else
michael@1 103 ?==Error: Undefined 16 bit type
michael@1 104 #endif
michael@1 105
michael@1 106 #if (2 == 4)
michael@1 107 typedef unsigned short U32;
michael@1 108 #elif (4 == 4)
michael@1 109 typedef unsigned int U32;
michael@1 110 #elif (4 == 4)
michael@1 111 typedef unsigned long U32;
michael@1 112 #else
michael@1 113 ?== Error: Undefined 32 bit type
michael@1 114 #endif
michael@1 115 #endif // HAVE_CONFIG_H
michael@1 116
michael@1 117
michael@1 118 // Main table size
michael@1 119 const int g_knBlocks = 32;
michael@1 120
michael@1 121 // Styles enumeration
michael@1 122 typedef enum
michael@1 123 {
michael@1 124 TITRAQ_STYLECDE,
michael@1 125 TITRAQ_STYLESGI,
michael@1 126 TITRAQ_STYLEMOTIF,
michael@1 127 TITRAQ_STYLEMPLUS,
michael@1 128 TITRAQ_STYLEPLAT,
michael@1 129 TITRAQ_STYLEMSOFT
michael@1 130 } styles_t;
michael@1 131
michael@1 132 // Main application form window
michael@1 133 class Titraqform : public QMainWindow
michael@1 134 {
michael@1 135 Q_OBJECT // Generate MOC object model stubs
michael@1 136
michael@1 137 public:
michael@1 138 Titraqform(QWidget *pParent = 0, const char *kszName = 0, WFlags Flags = 0);
michael@1 139 ~Titraqform(void);
michael@1 140
michael@1 141 // Accessor methods
michael@1 142 const QString getRowdata(void) const; // Get a whole row of data
michael@1 143 void setRowdata(QString &) const; // Set a whole row of data
michael@1 144 const int getFirstcol(void) const; // Learn which col is first
michael@1 145 const bool isOpen(void) {return (m_szFilename == NULL) ? false : true;}; // Doc state
michael@1 146 void setOpen(bool bDocopen = true) // Set state of document
michael@1 147 {
michael@1 148 if (bDocopen) {
michael@1 149 if (m_szFilename == NULL)
michael@1 150 m_szFilename = new QString();
michael@1 151 }
michael@1 152 else
michael@1 153 if (m_szFilename != NULL) {
michael@1 154 delete m_szFilename;
michael@1 155 m_szFilename = NULL;
michael@1 156 }
michael@1 157 };
michael@1 158 const QString *getFilename(void) // Get the current file name
michael@1 159 {
michael@1 160 if (this->isOpen())
michael@1 161 return m_szFilename;
michael@1 162 else
michael@1 163 throw Genexcept("File name does not exist.");
michael@1 164 };
michael@1 165 void setFilename(const QString &Fname) // Set file name
michael@1 166 {
michael@1 167 if (this->isOpen()) // If a file name exists
michael@1 168 setOpen(false); // then get rid of it first
michael@1 169 m_szFilename = new QString(Fname);
michael@1 170 };
michael@1 171
michael@1 172 // Utility members
michael@1 173 void loadInit(void); // Parse cmds and open initial file
michael@1 174
michael@1 175 // Top level members
michael@1 176 Preferences *m_pPrefs;
michael@1 177
michael@1 178 // Main application actions
michael@1 179 QAction *m_pFilenewact, *m_pFileopenact;
michael@1 180 QAction *m_pFilesaveact, *m_pFilesaveasact;
michael@1 181 QAction *m_pFilecloseact, *m_pFilequitact;
michael@1 182 QAction *m_pAddrowact, *m_pDelrowact;
michael@1 183 QAction *m_pRefreshact, *m_pCutact;
michael@1 184 QAction *m_pCopyact, *m_pPasteact;
michael@1 185 QAction *m_pSyncact, *m_pPrefsact;
michael@1 186 QAction *m_pReportact;
michael@1 187
michael@1 188 // Table, cells, and entries in package layout
michael@1 189 TiTable *m_pMaintable;
michael@1 190 QHeader *m_pTablehead;
michael@1 191 QStringList *m_pTaskentries;
michael@1 192
michael@1 193 // Edition widgets
michael@1 194 QLabel *m_pStatusedit; // Control to show entry status
michael@1 195 QLineEdit *m_pLineedit; // Control to line number
michael@1 196 QLineEdit *m_pUseredit; // Control to edit user name
michael@1 197 QLineEdit *m_pGuidedit; // Control to edit GUID
michael@1 198 QLineEdit *m_pCrcedit; // Control to edit CRC
michael@1 199 QLineEdit *m_pRevedit; // Control to edit revision
michael@1 200 Daydatedit *m_pDateedit; // Control to edit date
michael@1 201 QTimeEdit *m_pStarttime; // Control to edit start time
michael@1 202 QTimeEdit *m_pEndtime; // Control to edit finish time
michael@1 203 // QTimeEdit *m_pAmount; // Control to edit total time
michael@1 204 ASTimeEdit *m_pAmount; // Control to edit total time
michael@1 205 QComboBox *m_pTasks; // Control to choose a task
michael@1 206 QLineEdit *m_pRemark; // Control to edit remark
michael@1 207
michael@1 208 protected slots:
michael@1 209 void cutEntry(void); // Cut task entries from the list
michael@1 210 void copyEntry(void); // Copy task entries from the list
michael@1 211 void pasteEntry(void); // Paste task entries to the list
michael@1 212 void addEntry(int nRows= -1); // Add task entries to the list
michael@1 213 void delEntry(int nRows= -1); // Delete task entries from the list
michael@1 214 void refreshDisplay(void); // Refresh the display of all data items
michael@1 215 void syncIiop(void); // Syncronize data with server using IIOP
michael@1 216 void syncSoap(void); // Syncronize data with server using SOAP
michael@1 217 void newDoc(void); // Make and display a new document window
michael@1 218 void openDoc(void); // Open and display an existing document
michael@1 219 void quitApp(void); // Close the current document and quit
michael@1 220 void saveFile(void); // Serialize to the current file
michael@1 221 void saveAs(void); // Serialize to a selected file
michael@1 222 void saveName(void); // Implicitly serialize to a selected file
michael@1 223 void helpContents(void); // Use the help contents
michael@1 224 void aboutTitraq(void); // Learn more about this program itself
michael@1 225 void aboutOSSP(void); // Learn more about the OSSP
michael@1 226 void aboutQt(void); // Learn more about Qt
michael@1 227 void selAll(void); // Edit menu select all
michael@1 228 void onClick(int, int, int, const QPoint &); // Table was clicked
michael@1 229 void inplaceEdit(int, int, int, const QPoint &); // Enter in place edit mode
michael@1 230 void updEdit(int, int nCol = 0); // Update edit controls
michael@1 231 void validateRow(void); // Validate current row of matrix
michael@1 232 void validateRow(int, int); // Validate specified row of matrix
michael@1 233 void updSizes(int, int, int); // Update edit sizes
michael@1 234 void calcCrc(void); // Calculate CRC of current row
michael@1 235 void calcCrc(int, int); // Calculate CRC of specified row
michael@1 236 void dataChanged(int, int); // Timesheet data changed
michael@1 237 void updateLine(const QString &); // Update line number column
michael@1 238 void updateUser(const QString &); // Update user column
michael@1 239 void updateGuid(const QString &); // Update GUID column
michael@1 240 void updateCrc(const QString &); // Update CRC column
michael@1 241 void updateRev(const QString &); // Update rev column
michael@1 242 void updateDate(const QDate &); // Update date column
michael@1 243 void updateStart(const QTime &); // Update start column
michael@1 244 void updateFinish(const QTime &); // Update finish column
michael@1 245 void updateAmount(const QTime &); // Update amount column
michael@1 246 void updateTask(const QString &); // Update task column
michael@1 247 void updateRemark(const QString &); // Update remark column
michael@1 248 void confirmEdit(void); // Confirm whole row edition
michael@1 249 void configPrefs(void); // Edit menu configure preferences
michael@1 250 void normalView(void); // View menu normal
michael@1 251 void editingView(void); // View menu editing
michael@1 252 void timingView(void); // View menu timing
michael@1 253 void showFilebar(void); // View menu show file toolbar
michael@1 254 void showEditbar(void); // View menu show edit toolbar
michael@1 255 void showViewbar(void); // View menu show view toolbar
michael@1 256 void showPrefsbar(void); // View menu show prefs toolbar
michael@1 257 void showWhatsbar(void); // View menu show whats this toolbar
michael@1 258 void showStatcol(void); // View menu show status column
michael@1 259 void showLinecol(void); // View menu show line numbers column
michael@1 260 void showUsercol(void); // View menu show Users column
michael@1 261 void showGuidcol(void); // View menu show GUIDs column
michael@1 262 void showCrccol(void); // View menu show CRC column
michael@1 263 void showRevcol(void); // View menu show Rev column
michael@1 264 void showDatecol(void); // View menu show Dates column
michael@1 265 void showStartcol(void); // View menu show Start time column
michael@1 266 void showFinishcol(void); // View menu show Finish time column
michael@1 267 void showAmountcol(void); // View menu show Amounts column
michael@1 268 void showTaskcol(void); // View menu show Tasks column
michael@1 269 void showRemarkcol(void); // View menu show Remarks column
michael@1 270 void genReport(void); // Generate a local formatted report
michael@1 271 void savePrefs(void); // Save user preferences
michael@1 272 void applyPrefs(void); // Apply preferences from applied()
michael@1 273 void applyPrefs(Prefpanel *); // Apply preferences from accept()
michael@1 274
michael@1 275 protected:
michael@1 276 // Application main events
michael@1 277 void closeEvent(QCloseEvent *); // Close current document in main window
michael@1 278
michael@1 279 // Application main window widgets
michael@1 280 QFrame *m_pCenframe; // Central frame
michael@1 281 QVBoxLayout *m_pMainlayout; // Package and control layouts
michael@1 282 QVBoxLayout *m_pPackagelayout; // Main table control
michael@1 283 QHBoxLayout *m_pEditlayout; // Lower edition widgets
michael@1 284
michael@1 285 private:
michael@1 286 // Owned by QMainWindow
michael@1 287 QMenuBar *m_pMenubar;
michael@1 288 QPopupMenu *m_pViewpopup; // Saved for manipulating views
michael@1 289 QPopupMenu *m_pTbarspopup; // Saved for manipulating toolbars
michael@1 290 QPopupMenu *m_pColspopup; // Saved for manipulating columns
michael@1 291 QStatusBar *m_pStatbar;
michael@1 292
michael@1 293 // Belong to us
michael@1 294 QToolBar *m_pFiletools;
michael@1 295 QToolBar *m_pEdittools;
michael@1 296 QToolBar *m_pViewtools;
michael@1 297 QToolBar *m_pPrefstools;
michael@1 298 QToolBar *m_pWhatstools;
michael@1 299 QString *m_szFilename;
michael@1 300
michael@1 301 // Constructor helpers
michael@1 302 void setupPrefs(void); // Preferences
michael@1 303 void setupActions(void); // Actions
michael@1 304 void setupMenubar(void); // Menu bar
michael@1 305 void setupToolbars(void); // Tool bars
michael@1 306 void setupStatusbar(void); // Status bar
michael@1 307 void setupCentralwidget(void); // Assemble main Frame widget
michael@1 308 void setupTable(void); // Table widget
michael@1 309 void setupEditlay(void); // Editing lay
michael@1 310 void setupPieces(void); // Assemble widget pieces
michael@1 311 void setupColumns(void); // Arrange and configure columns
michael@1 312 void enableIface(bool); // [En/dis]able most ui pieces
michael@1 313
michael@1 314 // Data processing
michael@1 315 void loadAccounts(QFile &); // Load accounts from file
michael@1 316 void loadAccounts(QTextStream &); // Load accounts from stream
michael@1 317 void loadData(QFile &); // Load personal data from file
michael@1 318 void loadData(QTextStream &); // Load personal data from stream
michael@1 319 void saveData(QFile &); // Save accounting data to file
michael@1 320 void saveData(QTextStream &); // Save accounting data to stream
michael@1 321 const bool validateData(QFile &) const; // Validate personal data in file
michael@1 322 const bool validateData(QString &) const; // Validate personal data from string
michael@1 323 };
michael@1 324
michael@1 325 #endif // AS_GUI_MWIN_H

mercurial