as_table.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_table.h: ISO C++ interface
michael@1 30 //
michael@1 31
michael@1 32 #ifndef TITABLE_H
michael@1 33 #define TITABLE_H
michael@1 34
michael@1 35 #include <qtable.h>
michael@1 36
michael@1 37 #include "as_pref.h"
michael@1 38
michael@1 39
michael@1 40 class TiTable : public QTable
michael@1 41 {
michael@1 42 Q_OBJECT
michael@1 43
michael@1 44 private:
michael@1 45 int m_nSortcol; // To track current sort column
michael@1 46 int m_bSortdir; // To track current sort direction
michael@1 47 bool m_bDirt; // To track dirty and clean states
michael@1 48 Preferences *m_pTiprefs; // To read current color values
michael@1 49
michael@1 50 public:
michael@1 51 // Try to match QTable's default constructor with an initializer list
michael@1 52 TiTable(Preferences *pPrefs, QWidget *pParent = 0, const char *szName = 0) : QTable(pParent, szName)
michael@1 53 {
michael@1 54 this->setSortcol(0);
michael@1 55 this->setSortdir(true);
michael@1 56 this->setDirty(false);
michael@1 57 this->setEdition(); // Reset edition state
michael@1 58 m_pTiprefs = pPrefs;
michael@1 59 horizontalHeader()->installEventFilter(this);
michael@1 60 };
michael@1 61
michael@1 62 bool eventFilter(QObject *, QEvent *);
michael@1 63
michael@1 64 // Standard members
michael@1 65 int m_nEdit; // To track edition state
michael@1 66
michael@1 67 // Accessor methods
michael@1 68 const bool isDirty(void) {return m_bDirt;}; // Check for changed state danger
michael@1 69 void setDirty(bool bDirty = true) {m_bDirt = bDirty;}; // Clean or dirty
michael@1 70 const int getEdition(void) {return m_nEdit;}; // Which edited column was confirmed
michael@1 71 void setEdition(const int nEdit = -1) {m_nEdit = nEdit;}; // Set edition status
michael@1 72 const int getSortcol(void) {return m_nSortcol;};
michael@1 73 void setSortcol(const int nColin) {m_nSortcol = nColin;};
michael@1 74 const bool getSortdir(void) {return m_bSortdir;};
michael@1 75 void setSortdir(const bool bDirection) {m_bSortdir = bDirection;};
michael@1 76
michael@1 77 // Overridden accessors
michael@1 78 void setText(int, int, const QString &);
michael@1 79 void sortColumn(int nCol, bool bAscend = true, bool bWhole = true);
michael@1 80 // virtual QTableItem *item(int nRow, int nCol) const {return QTable::item(nRow, nCol);};
michael@1 81
michael@1 82 // Deny a cell special handling of the focus rectangle
michael@1 83 // by overriding class QTable's paintFocus method
michael@1 84 virtual void paintFocus(QPainter *, const QRect &) {};
michael@1 85
michael@1 86 // Override for special linewise shading according to sort key
michael@1 87 virtual void paintCell(QPainter *, int, int, const QRect &, bool, const QColorGroup &);
michael@1 88
michael@1 89 // Override to properly handle read only attribute during edition
michael@1 90 virtual void endEdit(int, int, bool, bool);
michael@1 91
michael@1 92 // For special focus handling on return key in edit mode
michael@1 93 virtual void activateNextCell(void);
michael@1 94
michael@1 95 signals:
michael@1 96 void textEdited(int, int); // A cell was edited and data was modified
michael@1 97 };
michael@1 98
michael@1 99 #endif // TITABLE_H

mercurial