1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/as_table.h Fri Nov 28 11:21:08 2008 +0100 1.3 @@ -0,0 +1,99 @@ 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_table.h: ISO C++ interface 1.33 +// 1.34 + 1.35 +#ifndef TITABLE_H 1.36 +#define TITABLE_H 1.37 + 1.38 +#include <qtable.h> 1.39 + 1.40 +#include "as_pref.h" 1.41 + 1.42 + 1.43 +class TiTable : public QTable 1.44 +{ 1.45 + Q_OBJECT 1.46 + 1.47 +private: 1.48 + int m_nSortcol; // To track current sort column 1.49 + int m_bSortdir; // To track current sort direction 1.50 + bool m_bDirt; // To track dirty and clean states 1.51 + Preferences *m_pTiprefs; // To read current color values 1.52 + 1.53 +public: 1.54 + // Try to match QTable's default constructor with an initializer list 1.55 + TiTable(Preferences *pPrefs, QWidget *pParent = 0, const char *szName = 0) : QTable(pParent, szName) 1.56 + { 1.57 + this->setSortcol(0); 1.58 + this->setSortdir(true); 1.59 + this->setDirty(false); 1.60 + this->setEdition(); // Reset edition state 1.61 + m_pTiprefs = pPrefs; 1.62 + horizontalHeader()->installEventFilter(this); 1.63 + }; 1.64 + 1.65 + bool eventFilter(QObject *, QEvent *); 1.66 + 1.67 + // Standard members 1.68 + int m_nEdit; // To track edition state 1.69 + 1.70 + // Accessor methods 1.71 + const bool isDirty(void) {return m_bDirt;}; // Check for changed state danger 1.72 + void setDirty(bool bDirty = true) {m_bDirt = bDirty;}; // Clean or dirty 1.73 + const int getEdition(void) {return m_nEdit;}; // Which edited column was confirmed 1.74 + void setEdition(const int nEdit = -1) {m_nEdit = nEdit;}; // Set edition status 1.75 + const int getSortcol(void) {return m_nSortcol;}; 1.76 + void setSortcol(const int nColin) {m_nSortcol = nColin;}; 1.77 + const bool getSortdir(void) {return m_bSortdir;}; 1.78 + void setSortdir(const bool bDirection) {m_bSortdir = bDirection;}; 1.79 + 1.80 + // Overridden accessors 1.81 + void setText(int, int, const QString &); 1.82 + void sortColumn(int nCol, bool bAscend = true, bool bWhole = true); 1.83 +// virtual QTableItem *item(int nRow, int nCol) const {return QTable::item(nRow, nCol);}; 1.84 + 1.85 + // Deny a cell special handling of the focus rectangle 1.86 + // by overriding class QTable's paintFocus method 1.87 + virtual void paintFocus(QPainter *, const QRect &) {}; 1.88 + 1.89 + // Override for special linewise shading according to sort key 1.90 + virtual void paintCell(QPainter *, int, int, const QRect &, bool, const QColorGroup &); 1.91 + 1.92 + // Override to properly handle read only attribute during edition 1.93 + virtual void endEdit(int, int, bool, bool); 1.94 + 1.95 + // For special focus handling on return key in edit mode 1.96 + virtual void activateNextCell(void); 1.97 + 1.98 +signals: 1.99 + void textEdited(int, int); // A cell was edited and data was modified 1.100 +}; 1.101 + 1.102 +#endif // TITABLE_H