as_table.cpp

changeset 3
c1941114ca88
parent 1
d64aaa7d146f
child 12
ceb4ba3d2d00
equal deleted inserted replaced
0:df4be0dc1fe6 1:3452eaba2a60
1 // 1 //
2 // OSSP asgui - Accounting system graphical user interface 2 // OSSP asgui - Accounting system graphical user interface
3 // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) 3 // Copyright (c) 2002-2008 The OSSP Project (http://www.ossp.org/)
4 // Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com> 4 // Copyright (c) 2002-2008 Ralf S. Engelschall <rse@engelschall.com>
5 // Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com> 5 // Copyright (c) 2002-2008 Michael Schloh von Bennewitz <michael@schloh.com>
6 // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH 6 // Copyright (c) 2002-2008 Cable & Wireless Telecommunications Services GmbH
7 // 7 //
8 // This file is part of OSSP asgui, an accounting system graphical user 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/. 9 // interface which can be found at http://asgui.europalab.com/.
10 // 10 //
11 // Permission to use, copy, modify, and distribute this software for 11 // Permission to use, copy, modify, and distribute this software for
12 // any purpose with or without fee is hereby granted, provided that 12 // any purpose with or without fee is hereby granted, provided that
13 // the above copyright notice and this permission notice appear in all 13 // the above copyright notice and this permission notice appear in all
14 // copies. 14 // copies.
27 // SUCH DAMAGE. 27 // SUCH DAMAGE.
28 // 28 //
29 // as_table.cpp: ISO C++ implementation 29 // as_table.cpp: ISO C++ implementation
30 // 30 //
31 31
32 #include <qheader.h> 32 #define QT3_SUPPORT
33
34 #include <q3header.h>
35
36 //Added by qt3to4:
37 #include <QEvent>
38 #include <QMouseEvent>
39 #include <QKeyEvent>
33 40
34 #include "as_const.h" 41 #include "as_const.h"
35 #include "as_table.h" 42 #include "as_table.h"
36 43
37 44
39 bool TiTable::eventFilter(QObject *pObject, QEvent *pEvent) 46 bool TiTable::eventFilter(QObject *pObject, QEvent *pEvent)
40 { 47 {
41 if (pObject == horizontalHeader() && pEvent->type() == QEvent::MouseButtonDblClick) 48 if (pObject == horizontalHeader() && pEvent->type() == QEvent::MouseButtonDblClick)
42 return true; 49 return true;
43 if (pEvent->type() == QEvent::MouseButtonPress && // Ignore mid, right clicks 50 if (pEvent->type() == QEvent::MouseButtonPress && // Ignore mid, right clicks
44 ((QMouseEvent *)pEvent)->button() == QMouseEvent::RightButton || 51 ((QMouseEvent *)pEvent)->button() == Qt::RightButton ||
45 ((QMouseEvent *)pEvent)->button() == QMouseEvent::MidButton) 52 ((QMouseEvent *)pEvent)->button() == Qt::MidButton)
46 return true; 53 return true;
47 else if (pEvent->type() == QEvent::KeyPress) { 54 else if (pEvent->type() == QEvent::KeyPress) {
48 if (((QKeyEvent *)pEvent)->key() == Qt::Key_Tab) { // Handle tab key 55 if (((QKeyEvent *)pEvent)->key() == Qt::Key_Tab) { // Handle tab key
49 if (this->getEdition() >= 0) { 56 if (this->getEdition() >= 0) {
50 int nIter = 1; // Logic to skip invisible or read only columns 57 int nIter = 1; // Logic to skip invisible or read only columns
117 return true; // Capture 124 return true; // Capture
118 else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Down && this->getEdition() >= 0) // Handle down key 125 else if (((QKeyEvent *)pEvent)->key() == Qt::Key_Down && this->getEdition() >= 0) // Handle down key
119 return true; // Capture 126 return true; // Capture
120 127
121 // Forward incompletely handled key events 128 // Forward incompletely handled key events
122 return QTable::eventFilter(pObject, pEvent); 129 return Q3Table::eventFilter(pObject, pEvent);
123 } 130 }
124 else // Default behaviour is to pass the event onwards 131 else // Default behaviour is to pass the event onwards
125 return QTable::eventFilter(pObject, pEvent); 132 return Q3Table::eventFilter(pObject, pEvent);
126 } 133 }
127 134
128 // Overridden member hack to allow externally connected control 135 // Overridden member hack to allow externally connected control
129 // widgets to influence dirty or clean state of table data 136 // widgets to influence dirty or clean state of table data
130 void TiTable::setText(int nRow, int nCol, const QString &nText) 137 void TiTable::setText(int nRow, int nCol, const QString &nText)
133 // If a cell was edited, emit a signal indicating so 140 // If a cell was edited, emit a signal indicating so
134 // We can't rely on valueChanged for unknown reasons 141 // We can't rely on valueChanged for unknown reasons
135 if (nText != this->text(nRow, nCol) && nCol != TITRAQ_IDXLINE) 142 if (nText != this->text(nRow, nCol) && nCol != TITRAQ_IDXLINE)
136 emit textEdited(nRow, nCol); 143 emit textEdited(nRow, nCol);
137 144
138 QTable::setText(nRow, nCol, nText); 145 Q3Table::setText(nRow, nCol, nText);
139 } 146 }
140 } 147 }
141 148
142 // Overridden member hack to allow externally connected control 149 // Overridden member hack to allow externally connected control
143 // widgets to influence dirty or clean state of table data 150 // widgets to influence dirty or clean state of table data
148 this->setSortdir(!bAscend); 155 this->setSortdir(!bAscend);
149 else 156 else
150 this->setSortdir(bAscend); 157 this->setSortdir(bAscend);
151 158
152 this->setSortcol(nCol); 159 this->setSortcol(nCol);
153 QTable::sortColumn(nCol, this->getSortdir(), true); 160 Q3Table::sortColumn(nCol, this->getSortdir(), true);
154 161
155 // // Announce sorting policy with multiple selections 162 // // Announce sorting policy with multiple selections
156 // QTableSelection Testsel = this->selection(this->currentSelection()); 163 // QTableSelection Testsel = this->selection(this->currentSelection());
157 // if (Testsel.topRow() != Testsel.bottomRow()) 164 // if (Testsel.topRow() != Testsel.bottomRow())
158 // m_pStatbar->message(trUtf8("Multiple selections dropped when sorting"), 4000); 165 // m_pStatbar->message(trUtf8("Multiple selections dropped when sorting"), 4000);
215 if (this->text(nRow, TITRAQ_IDXSTATUS).at(TITRAQ_IDXSTATCOLOR) != QChar(TITRAQ_BRIGHT)) 222 if (this->text(nRow, TITRAQ_IDXSTATUS).at(TITRAQ_IDXSTATCOLOR) != QChar(TITRAQ_BRIGHT))
216 this->setText(nRow, TITRAQ_IDXSTATUS, this->text(nRow, TITRAQ_IDXSTATUS).replace(TITRAQ_IDXSTATCOLOR, sizeof(char), QChar(TITRAQ_BRIGHT))); 223 this->setText(nRow, TITRAQ_IDXSTATUS, this->text(nRow, TITRAQ_IDXSTATUS).replace(TITRAQ_IDXSTATCOLOR, sizeof(char), QChar(TITRAQ_BRIGHT)));
217 } 224 }
218 } 225 }
219 226
220 QTable::paintCell(pPainter, nRow, nCol, Recto, bSelect, Cgroup); 227 Q3Table::paintCell(pPainter, nRow, nCol, Recto, bSelect, Cgroup);
221 }; 228 };
222 229
223 // Blah 230 // Blah
224 void TiTable::activateNextCell(void) 231 void TiTable::activateNextCell(void)
225 { 232 {
240 } 247 }
241 248
242 // Overriden member to properly handle read only attribute after edition 249 // Overriden member to properly handle read only attribute after edition
243 void TiTable::endEdit(int nRow, int nCol, bool bAccept, bool bReplace) 250 void TiTable::endEdit(int nRow, int nCol, bool bAccept, bool bReplace)
244 { 251 {
245 QTable::endEdit(nRow, nCol, bAccept, bReplace); 252 Q3Table::endEdit(nRow, nCol, bAccept, bReplace);
246 253
247 // Table read only attribute must be set to return to the normal 254 // Table read only attribute must be set to return to the normal
248 // row highlight and selection behaviour of AS. The reason it was 255 // row highlight and selection behaviour of AS. The reason it was
249 // reset in inplaceEdit() was to allow editing in the first place. 256 // reset in inplaceEdit() was to allow editing in the first place.
250 this->setReadOnly(true); 257 this->setReadOnly(true);

mercurial