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