author | thufir <thufir> | 2002-10-08 16:43:57 (UTC) |
---|---|---|
committer | thufir <thufir> | 2002-10-08 16:43:57 (UTC) |
commit | 9475b63d025c1ca386764784b7dad460935f45b0 (patch) (unidiff) | |
tree | f0b209ab08afb75e94f6d3f2b0ff4bc235774cbd | |
parent | 76fb8a57bf9fbae3a7073c8b0be1216f34adf99c (diff) | |
download | opie-9475b63d025c1ca386764784b7dad460935f45b0.zip opie-9475b63d025c1ca386764784b7dad460935f45b0.tar.gz opie-9475b63d025c1ca386764784b7dad460935f45b0.tar.bz2 |
fixed bug #250
-rw-r--r-- | noncore/apps/opie-sheet/ChangeLog | 11 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/opie-sheet.control | 2 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 32 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.h | 4 |
5 files changed, 36 insertions, 16 deletions
diff --git a/noncore/apps/opie-sheet/ChangeLog b/noncore/apps/opie-sheet/ChangeLog index c12a6db..90060e2 100644 --- a/noncore/apps/opie-sheet/ChangeLog +++ b/noncore/apps/opie-sheet/ChangeLog | |||
@@ -1,25 +1,34 @@ | |||
1 | October 08, 2002 | ||
2 | |||
3 | * Release 1.0.2 (by thufir) | ||
4 | - Fixed bug #250 (exhibiting re-calculation error in multi-level calculation). (by thufir) | ||
5 | |||
6 | October 06, 2002 | ||
7 | |||
8 | - Fixed data edit box clear problem. (by thufir) | ||
9 | |||
1 | October 05, 2002 | 10 | October 05, 2002 |
2 | 11 | ||
3 | - Fixed bug #252. (by thufir) | 12 | - Fixed bug #252 (starting up in 'mouse button' mode). (by thufir) |
4 | 13 | ||
5 | August 31, 2002 | 14 | August 31, 2002 |
6 | 15 | ||
7 | - Fixed and updated opie-sheet.pro file. (by cniehaus) | 16 | - Fixed and updated opie-sheet.pro file. (by cniehaus) |
8 | 17 | ||
9 | August 01, 2002 | 18 | August 01, 2002 |
10 | 19 | ||
11 | - Fixed gcc3 compile problems. (by harlekin) | 20 | - Fixed gcc3 compile problems. (by harlekin) |
12 | 21 | ||
13 | July 06, 2002 | 22 | July 06, 2002 |
14 | 23 | ||
15 | - Fixed DocLnk management to save documents correctly. (by leseb) | 24 | - Fixed DocLnk management to save documents correctly. (by leseb) |
16 | 25 | ||
17 | July 04, 2002 | 26 | July 04, 2002 |
18 | 27 | ||
19 | * Release 1.0.1 (by thufir) | 28 | * Release 1.0.1 (by thufir) |
20 | - Sheet/Qt is now a part of Opie, so its name is changed to Opie Sheet. (by thufir) | 29 | - Sheet/Qt is now a part of Opie, so its name is changed to Opie Sheet. (by thufir) |
21 | - Fixed sorting bug. (by thufir) | 30 | - Fixed sorting bug. (by thufir) |
22 | 31 | ||
23 | April 14, 2002 | 32 | April 14, 2002 |
24 | 33 | ||
25 | * Release 1.0.0 (by thufir) | 34 | * Release 1.0.0 (by thufir) |
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 2f07bae..b9f8e57 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -174,48 +174,49 @@ int MainWindow::saveCurrentFile(bool ask) | |||
174 | if (result!=QMessageBox::Yes) return result; | 174 | if (result!=QMessageBox::Yes) return result; |
175 | } | 175 | } |
176 | 176 | ||
177 | if (!currentDoc->isValid()) | 177 | if (!currentDoc->isValid()) |
178 | { | 178 | { |
179 | TextDialog dialogText(this); | 179 | TextDialog dialogText(this); |
180 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; | 180 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; |
181 | 181 | ||
182 | currentDoc->setName(dialogText.getValue()); | 182 | currentDoc->setName(dialogText.getValue()); |
183 | currentDoc->setFile(QString::null); | 183 | currentDoc->setFile(QString::null); |
184 | currentDoc->setLinkFile(QString::null); | 184 | currentDoc->setLinkFile(QString::null); |
185 | } | 185 | } |
186 | 186 | ||
187 | documentSave(currentDoc); | 187 | documentSave(currentDoc); |
188 | return QMessageBox::Yes; | 188 | return QMessageBox::Yes; |
189 | } | 189 | } |
190 | 190 | ||
191 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) | 191 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) |
192 | { | 192 | { |
193 | selectorHide(); | 193 | selectorHide(); |
194 | 194 | ||
195 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 195 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
196 | if (currentDoc) delete currentDoc; | 196 | if (currentDoc) delete currentDoc; |
197 | currentDoc = new DocLnk(lnkDoc); | 197 | currentDoc = new DocLnk(lnkDoc); |
198 | editData->clear(); | ||
198 | listSheets.clear(); | 199 | listSheets.clear(); |
199 | comboSheets->clear(); | 200 | comboSheets->clear(); |
200 | 201 | ||
201 | typeSheet *newSheet=createNewSheet(); | 202 | typeSheet *newSheet=createNewSheet(); |
202 | newSheet->data.setAutoDelete(TRUE); | 203 | newSheet->data.setAutoDelete(TRUE); |
203 | sheet->setName(newSheet->name); | 204 | sheet->setName(newSheet->name); |
204 | sheet->setSheetData(&newSheet->data); | 205 | sheet->setSheetData(&newSheet->data); |
205 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) | 206 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) |
206 | createNewSheet(); | 207 | createNewSheet(); |
207 | documentModified=FALSE; | 208 | documentModified=FALSE; |
208 | } | 209 | } |
209 | 210 | ||
210 | void MainWindow::closeEvent(QCloseEvent *e) | 211 | void MainWindow::closeEvent(QCloseEvent *e) |
211 | { | 212 | { |
212 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); | 213 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); |
213 | else e->accept(); | 214 | else e->accept(); |
214 | } | 215 | } |
215 | 216 | ||
216 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) | 217 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) |
217 | { | 218 | { |
218 | selectorHide(); | 219 | selectorHide(); |
219 | 220 | ||
220 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 221 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
221 | if (currentDoc) delete currentDoc; | 222 | if (currentDoc) delete currentDoc; |
@@ -512,49 +513,49 @@ void MainWindow::initEditToolbar() | |||
512 | editData=new QLineEdit(toolbarEdit); | 513 | editData=new QLineEdit(toolbarEdit); |
513 | toolbarEdit->setStretchableWidget(editData); | 514 | toolbarEdit->setStretchableWidget(editData); |
514 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 515 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
515 | 516 | ||
516 | editCellSelect->addTo(toolbarEdit); | 517 | editCellSelect->addTo(toolbarEdit); |
517 | } | 518 | } |
518 | 519 | ||
519 | void MainWindow::slotHelpGeneral() | 520 | void MainWindow::slotHelpGeneral() |
520 | { | 521 | { |
521 | if (QFile::exists(helpFile)) | 522 | if (QFile::exists(helpFile)) |
522 | { | 523 | { |
523 | QCopEnvelope e("QPE/Application/helpbrowser", "showFile(QString)"); | 524 | QCopEnvelope e("QPE/Application/helpbrowser", "showFile(QString)"); |
524 | e << helpFile; | 525 | e << helpFile; |
525 | } | 526 | } |
526 | else | 527 | else |
527 | QMessageBox::critical(this, tr("Error"), tr("Help file not found!")); | 528 | QMessageBox::critical(this, tr("Error"), tr("Help file not found!")); |
528 | } | 529 | } |
529 | 530 | ||
530 | void MainWindow::slotHelpAbout() | 531 | void MainWindow::slotHelpAbout() |
531 | { | 532 | { |
532 | QDialog dialogAbout(this, 0, TRUE); | 533 | QDialog dialogAbout(this, 0, TRUE); |
533 | dialogAbout.resize(width()-40, height()-80); | 534 | dialogAbout.resize(width()-40, height()-80); |
534 | dialogAbout.setCaption(tr("About Opie Sheet")); | 535 | dialogAbout.setCaption(tr("About Opie Sheet")); |
535 | 536 | ||
536 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.1\nRelease Date: July 04, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); | 537 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); |
537 | label.setGeometry(dialogAbout.rect()); | 538 | label.setGeometry(dialogAbout.rect()); |
538 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 539 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
539 | 540 | ||
540 | dialogAbout.exec(); | 541 | dialogAbout.exec(); |
541 | } | 542 | } |
542 | 543 | ||
543 | void MainWindow::initSheet() | 544 | void MainWindow::initSheet() |
544 | { | 545 | { |
545 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 546 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
546 | setCentralWidget(sheet); | 547 | setCentralWidget(sheet); |
547 | 548 | ||
548 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 549 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); |
549 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 550 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); |
550 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 551 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
551 | 552 | ||
552 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 553 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
553 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 554 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
554 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 555 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
555 | } | 556 | } |
556 | 557 | ||
557 | void MainWindow::slotEditAccept() | 558 | void MainWindow::slotEditAccept() |
558 | { | 559 | { |
559 | sheet->setData(editData->text()); | 560 | sheet->setData(editData->text()); |
560 | } | 561 | } |
diff --git a/noncore/apps/opie-sheet/opie-sheet.control b/noncore/apps/opie-sheet/opie-sheet.control index 38f9083..cc322bb 100644 --- a/noncore/apps/opie-sheet/opie-sheet.control +++ b/noncore/apps/opie-sheet/opie-sheet.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Files: bin/sheetqt apps/Applications/opie-sheet.desktop help/sheetqt.html help/sheetqt/* pics/opie-sheet/sheetqt.png | 1 | Files: bin/sheetqt apps/Applications/opie-sheet.desktop help/sheetqt.html help/sheetqt/* pics/opie-sheet/sheetqt.png |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Serdar Ozler <sozler@sitebest.com> | 4 | Maintainer: Serdar Ozler <sozler@sitebest.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: 1.0.1 | 6 | Version: 1.0.2 |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | License: Public Domain | 8 | License: Public Domain |
9 | Description: Opie Sheet | 9 | Description: Opie Sheet |
10 | Spreadsheet software for Opie. | 10 | Spreadsheet software for Opie. |
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index be4046b..c2563c2 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp | |||
@@ -67,64 +67,64 @@ void Sheet::slotCellSelected(int row, int col) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | typeCellData *Sheet::createCellData(int row, int col) | 69 | typeCellData *Sheet::createCellData(int row, int col) |
70 | { | 70 | { |
71 | if (row<0 || col<0) return NULL; | 71 | if (row<0 || col<0) return NULL; |
72 | typeCellData *cellData=new typeCellData; | 72 | typeCellData *cellData=new typeCellData; |
73 | cellData->row=row; | 73 | cellData->row=row; |
74 | cellData->col=col; | 74 | cellData->col=col; |
75 | cellData->data=defaultCellData.data; | 75 | cellData->data=defaultCellData.data; |
76 | cellData->borders=defaultCellData.borders; | 76 | cellData->borders=defaultCellData.borders; |
77 | cellData->alignment=defaultCellData.alignment; | 77 | cellData->alignment=defaultCellData.alignment; |
78 | cellData->font=defaultCellData.font; | 78 | cellData->font=defaultCellData.font; |
79 | cellData->fontColor=defaultCellData.fontColor; | 79 | cellData->fontColor=defaultCellData.fontColor; |
80 | cellData->background=defaultCellData.background; | 80 | cellData->background=defaultCellData.background; |
81 | sheetData.append(cellData); | 81 | sheetData.append(cellData); |
82 | return cellData; | 82 | return cellData; |
83 | } | 83 | } |
84 | 84 | ||
85 | void Sheet::slotCellChanged(int row, int col) | 85 | void Sheet::slotCellChanged(int row, int col) |
86 | { | 86 | { |
87 | typeCellData *cellData=findCellData(row, col); | 87 | typeCellData *cellData=findCellData(row, col); |
88 | if (!cellData) cellData=createCellData(row, col); | 88 | if (!cellData) cellData=createCellData(row, col); |
89 | if (cellData) cellData->data=text(row, col); | 89 | if (cellData) cellData->data=text(row, col); |
90 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 90 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
91 | setText(cellData->row, cellData->col, dataParser(cellData->data)); | 91 | setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
92 | emit sheetModified(); | 92 | emit sheetModified(); |
93 | } | 93 | } |
94 | 94 | ||
95 | void Sheet::swapCells(int row1, int col1, int row2, int col2) | 95 | void Sheet::swapCells(int row1, int col1, int row2, int col2) |
96 | { | 96 | { |
97 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); | 97 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); |
98 | if (!cellData1) cellData1=createCellData(row1, col1); | 98 | if (!cellData1) cellData1=createCellData(row1, col1); |
99 | if (!cellData2) cellData2=createCellData(row2, col2); | 99 | if (!cellData2) cellData2=createCellData(row2, col2); |
100 | if (cellData1 && cellData2) | 100 | if (cellData1 && cellData2) |
101 | { | 101 | { |
102 | QString tempData(cellData1->data); | 102 | QString tempData(cellData1->data); |
103 | cellData1->data=cellData2->data; | 103 | cellData1->data=cellData2->data; |
104 | cellData2->data=tempData; | 104 | cellData2->data=tempData; |
105 | setText(cellData1->row, cellData1->col, dataParser(cellData1->data)); | 105 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); |
106 | setText(cellData2->row, cellData2->col, dataParser(cellData2->data)); | 106 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); |
107 | emit sheetModified(); | 107 | emit sheetModified(); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | QString Sheet::getParameter(const QString ¶meters, int paramNo, bool giveError, const QString funcName) | 111 | QString Sheet::getParameter(const QString ¶meters, int paramNo, bool giveError, const QString funcName) |
112 | { | 112 | { |
113 | QString params(parameters); | 113 | QString params(parameters); |
114 | int position; | 114 | int position; |
115 | for (int i=0; i<paramNo; ++i) | 115 | for (int i=0; i<paramNo; ++i) |
116 | { | 116 | { |
117 | position=params.find(','); | 117 | position=params.find(','); |
118 | if (position<0) | 118 | if (position<0) |
119 | { | 119 | { |
120 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\'')); | 120 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\'')); |
121 | return QString(); | 121 | return QString(); |
122 | } | 122 | } |
123 | params=params.mid(position+1); | 123 | params=params.mid(position+1); |
124 | } | 124 | } |
125 | position=params.find(','); | 125 | position=params.find(','); |
126 | if (position<0) return params; | 126 | if (position<0) return params; |
127 | return params.left(position); | 127 | return params.left(position); |
128 | } | 128 | } |
129 | 129 | ||
130 | bool Sheet::findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2) | 130 | bool Sheet::findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2) |
@@ -145,49 +145,49 @@ bool Sheet::findRange(const QString &variable1, const QString &variable2, int *r | |||
145 | } | 145 | } |
146 | return TRUE; | 146 | return TRUE; |
147 | } | 147 | } |
148 | 148 | ||
149 | bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError) | 149 | bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError) |
150 | { | 150 | { |
151 | int position=variable.find(QRegExp("\\d")); | 151 | int position=variable.find(QRegExp("\\d")); |
152 | if (position<1) | 152 | if (position<1) |
153 | { | 153 | { |
154 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\'')); | 154 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\'')); |
155 | return FALSE; | 155 | return FALSE; |
156 | } | 156 | } |
157 | *row=variable.mid(position).toInt()-1; | 157 | *row=variable.mid(position).toInt()-1; |
158 | *col=getHeaderColumn(variable.left(position))-1; | 158 | *col=getHeaderColumn(variable.left(position))-1; |
159 | return TRUE; | 159 | return TRUE; |
160 | } | 160 | } |
161 | 161 | ||
162 | double Sheet::calculateVariable(const QString &variable) | 162 | double Sheet::calculateVariable(const QString &variable) |
163 | { | 163 | { |
164 | bool ok; | 164 | bool ok; |
165 | double tempResult=variable.toDouble(&ok); | 165 | double tempResult=variable.toDouble(&ok); |
166 | if (ok) return tempResult; | 166 | if (ok) return tempResult; |
167 | 167 | ||
168 | int row, col; | 168 | int row, col; |
169 | return (findRowColumn(variable, &row, &col, TRUE) ? text(row, col).toDouble() : 0); | 169 | return (findRowColumn(variable, &row, &col, TRUE) ? dataParser(variable, text(row, col)).toDouble() : 0); |
170 | } | 170 | } |
171 | 171 | ||
172 | double Sheet::functionSum(const QString ¶m1, const QString ¶m2) | 172 | double Sheet::functionSum(const QString ¶m1, const QString ¶m2) |
173 | { | 173 | { |
174 | int row1, col1, row2, col2, row, col; | 174 | int row1, col1, row2, col2, row, col; |
175 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; | 175 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; |
176 | 176 | ||
177 | double result=0, tempResult; | 177 | double result=0, tempResult; |
178 | bool ok; | 178 | bool ok; |
179 | for (row=row1; row<=row2; ++row) | 179 | for (row=row1; row<=row2; ++row) |
180 | for (col=col1; col<=col2; ++col) | 180 | for (col=col1; col<=col2; ++col) |
181 | { | 181 | { |
182 | tempResult=text(row, col).toDouble(&ok); | 182 | tempResult=text(row, col).toDouble(&ok); |
183 | if (ok) result+=tempResult; | 183 | if (ok) result+=tempResult; |
184 | } | 184 | } |
185 | 185 | ||
186 | return result; | 186 | return result; |
187 | } | 187 | } |
188 | 188 | ||
189 | double Sheet::functionMin(const QString ¶m1, const QString ¶m2) | 189 | double Sheet::functionMin(const QString ¶m1, const QString ¶m2) |
190 | { | 190 | { |
191 | int row1, col1, row2, col2, row, col; | 191 | int row1, col1, row2, col2, row, col; |
192 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; | 192 | if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; |
193 | 193 | ||
@@ -399,63 +399,66 @@ QString Sheet::dataParserHelper(const QString &data) | |||
399 | if (tempElement.isEmpty()) | 399 | if (tempElement.isEmpty()) |
400 | tempElement=temp2Element; | 400 | tempElement=temp2Element; |
401 | else | 401 | else |
402 | tempElement.setNum(calculateFunction(tempElement, temp2Element)); | 402 | tempElement.setNum(calculateFunction(tempElement, temp2Element)); |
403 | --i; | 403 | --i; |
404 | } | 404 | } |
405 | else | 405 | else |
406 | tempElement+=data[i]; | 406 | tempElement+=data[i]; |
407 | } | 407 | } |
408 | if (!tempElement.isEmpty()) pushStringStack(&stackElements, tempElement); | 408 | if (!tempElement.isEmpty()) pushStringStack(&stackElements, tempElement); |
409 | while (!stackOperators.isEmpty()) | 409 | while (!stackOperators.isEmpty()) |
410 | { | 410 | { |
411 | secondElement=popStringStack(&stackElements); | 411 | secondElement=popStringStack(&stackElements); |
412 | firstElement=popStringStack(&stackElements); | 412 | firstElement=popStringStack(&stackElements); |
413 | pushStringStack(&stackElements, QString::number(calculateFunction(popCharStack(&stackOperators), firstElement+","+secondElement))); | 413 | pushStringStack(&stackElements, QString::number(calculateFunction(popCharStack(&stackOperators), firstElement+","+secondElement))); |
414 | } | 414 | } |
415 | 415 | ||
416 | if (!stackElements.isEmpty()) | 416 | if (!stackElements.isEmpty()) |
417 | tempElement=popStringStack(&stackElements); | 417 | tempElement=popStringStack(&stackElements); |
418 | while (!stackElements.isEmpty()) | 418 | while (!stackElements.isEmpty()) |
419 | tempElement.prepend(popStringStack(&stackElements)+","); | 419 | tempElement.prepend(popStringStack(&stackElements)+","); |
420 | return tempElement; | 420 | return tempElement; |
421 | } | 421 | } |
422 | 422 | ||
423 | QString Sheet::dataParser(const QString &data) | 423 | QString Sheet::dataParser(const QString &cell, const QString &data) |
424 | { | 424 | { |
425 | QString strippedData(data); | 425 | QString strippedData(data); |
426 | strippedData.replace(QRegExp("\\s"), ""); | 426 | strippedData.replace(QRegExp("\\s"), ""); |
427 | if (strippedData.isEmpty() || strippedData[0]!='=') return data; | 427 | if (strippedData.isEmpty() || strippedData[0]!='=') return data; |
428 | if (listDataParser.find(cell)!=listDataParser.end()) return "0"; | ||
429 | listDataParser.append(cell); | ||
428 | strippedData=dataParserHelper(strippedData.remove(0, 1).upper().replace(QRegExp(":"), ",")); | 430 | strippedData=dataParserHelper(strippedData.remove(0, 1).upper().replace(QRegExp(":"), ",")); |
429 | 431 | ||
430 | int i=0; | 432 | int i=0; |
431 | QString tempParameter(getParameter(strippedData, i)), result=""; | 433 | QString tempParameter(getParameter(strippedData, i)), result=""; |
432 | do | 434 | do |
433 | { | 435 | { |
434 | result+=","+QString::number(calculateVariable(tempParameter)); | 436 | result+=","+QString::number(calculateVariable(tempParameter)); |
435 | tempParameter=getParameter(strippedData, ++i); | 437 | tempParameter=getParameter(strippedData, ++i); |
436 | } | 438 | } |
437 | while (!tempParameter.isNull()); | 439 | while (!tempParameter.isNull()); |
440 | listDataParser.remove(cell); | ||
438 | return result.mid(1); | 441 | return result.mid(1); |
439 | } | 442 | } |
440 | 443 | ||
441 | void Sheet::setData(const QString &data) | 444 | void Sheet::setData(const QString &data) |
442 | { | 445 | { |
443 | setText(currentRow(), currentColumn(), data); | 446 | setText(currentRow(), currentColumn(), data); |
444 | slotCellChanged(currentRow(), currentColumn()); | 447 | slotCellChanged(currentRow(), currentColumn()); |
445 | activateNextCell(); | 448 | activateNextCell(); |
446 | } | 449 | } |
447 | 450 | ||
448 | QString Sheet::getData() | 451 | QString Sheet::getData() |
449 | { | 452 | { |
450 | typeCellData *cellData=findCellData(currentRow(), currentColumn()); | 453 | typeCellData *cellData=findCellData(currentRow(), currentColumn()); |
451 | if (cellData) | 454 | if (cellData) |
452 | return cellData->data; | 455 | return cellData->data; |
453 | return ""; | 456 | return ""; |
454 | } | 457 | } |
455 | 458 | ||
456 | void Sheet::lockClicks(bool lock) | 459 | void Sheet::lockClicks(bool lock) |
457 | { | 460 | { |
458 | clicksLocked=lock; | 461 | clicksLocked=lock; |
459 | } | 462 | } |
460 | 463 | ||
461 | void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected) | 464 | void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected) |
@@ -518,86 +521,91 @@ void Sheet::viewportMouseMoveEvent(QMouseEvent *e) | |||
518 | { | 521 | { |
519 | QTableSelection oldSelection(selection(selectionNo)); | 522 | QTableSelection oldSelection(selection(selectionNo)); |
520 | oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x())); | 523 | oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x())); |
521 | if (!(oldSelection==selection(selectionNo))) | 524 | if (!(oldSelection==selection(selectionNo))) |
522 | { | 525 | { |
523 | removeSelection(selectionNo); | 526 | removeSelection(selectionNo); |
524 | selectionNo=addSelection(oldSelection); | 527 | selectionNo=addSelection(oldSelection); |
525 | } | 528 | } |
526 | } | 529 | } |
527 | } | 530 | } |
528 | else | 531 | else |
529 | QTable::contentsMouseMoveEvent(&ce); | 532 | QTable::contentsMouseMoveEvent(&ce); |
530 | } | 533 | } |
531 | 534 | ||
532 | void Sheet::viewportMouseReleaseEvent(QMouseEvent *e) | 535 | void Sheet::viewportMouseReleaseEvent(QMouseEvent *e) |
533 | { | 536 | { |
534 | QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state()); | 537 | QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state()); |
535 | if (clicksLocked && selectionNo>=0) | 538 | if (clicksLocked && selectionNo>=0) |
536 | { | 539 | { |
537 | QTableSelection oldSelection(selection(selectionNo)); | 540 | QTableSelection oldSelection(selection(selectionNo)); |
538 | oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x())); | 541 | oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x())); |
539 | removeSelection(selectionNo); | 542 | removeSelection(selectionNo); |
540 | selectionNo=-1; | 543 | selectionNo=-1; |
541 | if (oldSelection.topRow()==oldSelection.bottomRow() && oldSelection.leftCol()==oldSelection.rightCol()) | 544 | if (oldSelection.topRow()==oldSelection.bottomRow() && oldSelection.leftCol()==oldSelection.rightCol()) |
542 | emit cellClicked(getHeaderString(oldSelection.leftCol()+1)+QString::number(oldSelection.topRow()+1)); | 545 | emit cellClicked(findCellName(oldSelection.topRow(), oldSelection.leftCol())); |
543 | else | 546 | else |
544 | emit cellClicked(getHeaderString(oldSelection.leftCol()+1)+QString::number(oldSelection.topRow()+1)+','+getHeaderString(oldSelection.rightCol()+1)+QString::number(oldSelection.bottomRow()+1)); | 547 | emit cellClicked(findCellName(oldSelection.topRow(), oldSelection.leftCol())+','+findCellName(oldSelection.bottomRow(), oldSelection.rightCol())); |
545 | } | 548 | } |
546 | else | 549 | else |
547 | QTable::contentsMouseReleaseEvent(&ce); | 550 | QTable::contentsMouseReleaseEvent(&ce); |
548 | } | 551 | } |
549 | 552 | ||
553 | QString Sheet::findCellName(int row, int col) | ||
554 | { | ||
555 | return (getHeaderString(col+1)+QString::number(row+1)); | ||
556 | } | ||
557 | |||
550 | void Sheet::copySheetData(QList<typeCellData> *destSheetData) | 558 | void Sheet::copySheetData(QList<typeCellData> *destSheetData) |
551 | { | 559 | { |
552 | typeCellData *tempCellData, *newCellData; | 560 | typeCellData *tempCellData, *newCellData; |
553 | destSheetData->clear(); | 561 | destSheetData->clear(); |
554 | 562 | ||
555 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 563 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
556 | { | 564 | { |
557 | newCellData=new typeCellData; | 565 | newCellData=new typeCellData; |
558 | *newCellData=*tempCellData; | 566 | *newCellData=*tempCellData; |
559 | destSheetData->append(newCellData); | 567 | destSheetData->append(newCellData); |
560 | } | 568 | } |
561 | } | 569 | } |
562 | 570 | ||
563 | void Sheet::setSheetData(QList<typeCellData> *srcSheetData) | 571 | void Sheet::setSheetData(QList<typeCellData> *srcSheetData) |
564 | { | 572 | { |
565 | typeCellData *tempCellData, *newCellData; | 573 | typeCellData *tempCellData, *newCellData; |
566 | 574 | ||
567 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 575 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
568 | { | 576 | { |
569 | clearCell(tempCellData->row, tempCellData->col); | 577 | clearCell(tempCellData->row, tempCellData->col); |
570 | updateCell(tempCellData->row, tempCellData->col); | 578 | updateCell(tempCellData->row, tempCellData->col); |
571 | } | 579 | } |
572 | sheetData.clear(); | 580 | sheetData.clear(); |
573 | 581 | ||
574 | for (tempCellData=srcSheetData->first(); tempCellData; tempCellData=srcSheetData->next()) | 582 | for (tempCellData=srcSheetData->first(); tempCellData; tempCellData=srcSheetData->next()) |
575 | { | 583 | { |
576 | newCellData=new typeCellData; | 584 | newCellData=new typeCellData; |
577 | *newCellData=*tempCellData; | 585 | *newCellData=*tempCellData; |
578 | sheetData.append(newCellData); | 586 | sheetData.append(newCellData); |
579 | setText(newCellData->row, newCellData->col, dataParser(newCellData->data)); | 587 | setText(newCellData->row, newCellData->col, dataParser(findCellName(newCellData->row, newCellData->col), newCellData->data)); |
580 | } | 588 | } |
581 | emit sheetModified(); | 589 | emit sheetModified(); |
582 | } | 590 | } |
583 | 591 | ||
584 | void Sheet::setName(const QString &name) | 592 | void Sheet::setName(const QString &name) |
585 | { | 593 | { |
586 | sheetName=name; | 594 | sheetName=name; |
587 | emit sheetModified(); | 595 | emit sheetModified(); |
588 | } | 596 | } |
589 | 597 | ||
590 | QString Sheet::getName() | 598 | QString Sheet::getName() |
591 | { | 599 | { |
592 | return sheetName; | 600 | return sheetName; |
593 | } | 601 | } |
594 | 602 | ||
595 | void Sheet::setBrush(int row, int col, const QBrush &brush) | 603 | void Sheet::setBrush(int row, int col, const QBrush &brush) |
596 | { | 604 | { |
597 | typeCellData *cellData=findCellData(row, col); | 605 | typeCellData *cellData=findCellData(row, col); |
598 | if (!cellData) cellData=createCellData(row, col); | 606 | if (!cellData) cellData=createCellData(row, col); |
599 | if (cellData) | 607 | if (cellData) |
600 | { | 608 | { |
601 | cellData->background=brush; | 609 | cellData->background=brush; |
602 | emit sheetModified(); | 610 | emit sheetModified(); |
603 | } | 611 | } |
@@ -735,125 +743,125 @@ void Sheet::editCut() | |||
735 | { | 743 | { |
736 | editCopy(); | 744 | editCopy(); |
737 | editClear(); | 745 | editClear(); |
738 | } | 746 | } |
739 | 747 | ||
740 | void Sheet::editPaste(bool onlyContents) | 748 | void Sheet::editPaste(bool onlyContents) |
741 | { | 749 | { |
742 | int row1=currentRow(), col1=currentColumn(); | 750 | int row1=currentRow(), col1=currentColumn(); |
743 | typeCellData *cellData, *tempCellData; | 751 | typeCellData *cellData, *tempCellData; |
744 | 752 | ||
745 | for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next()) | 753 | for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next()) |
746 | { | 754 | { |
747 | cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1); | 755 | cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1); |
748 | if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1); | 756 | if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1); |
749 | if (cellData) | 757 | if (cellData) |
750 | { | 758 | { |
751 | if (onlyContents) | 759 | if (onlyContents) |
752 | cellData->data=tempCellData->data; | 760 | cellData->data=tempCellData->data; |
753 | else | 761 | else |
754 | { | 762 | { |
755 | *cellData=*tempCellData; | 763 | *cellData=*tempCellData; |
756 | cellData->row+=row1; | 764 | cellData->row+=row1; |
757 | cellData->col+=col1; | 765 | cellData->col+=col1; |
758 | } | 766 | } |
759 | setText(cellData->row, cellData->col, dataParser(cellData->data)); | 767 | setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
760 | emit sheetModified(); | 768 | emit sheetModified(); |
761 | } | 769 | } |
762 | } | 770 | } |
763 | } | 771 | } |
764 | 772 | ||
765 | void Sheet::insertRows(int no, bool allColumns) | 773 | void Sheet::insertRows(int no, bool allColumns) |
766 | { | 774 | { |
767 | setNumRows(numRows()+no); | 775 | setNumRows(numRows()+no); |
768 | 776 | ||
769 | typeCellData *tempCellData; | 777 | typeCellData *tempCellData; |
770 | int row=currentRow(), col=currentColumn(); | 778 | int row=currentRow(), col=currentColumn(); |
771 | 779 | ||
772 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 780 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
773 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) | 781 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) |
774 | { | 782 | { |
775 | clearCell(tempCellData->row, tempCellData->col); | 783 | clearCell(tempCellData->row, tempCellData->col); |
776 | tempCellData->row+=no; | 784 | tempCellData->row+=no; |
777 | } | 785 | } |
778 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 786 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
779 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) | 787 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) |
780 | { | 788 | { |
781 | updateCell(tempCellData->row-no, tempCellData->col); | 789 | updateCell(tempCellData->row-no, tempCellData->col); |
782 | setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); | 790 | setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data)); |
783 | } | 791 | } |
784 | emit sheetModified(); | 792 | emit sheetModified(); |
785 | } | 793 | } |
786 | 794 | ||
787 | void Sheet::insertColumns(int no, bool allRows) | 795 | void Sheet::insertColumns(int no, bool allRows) |
788 | { | 796 | { |
789 | int noCols=numCols(); | 797 | int noCols=numCols(); |
790 | int newCols=noCols+no; | 798 | int newCols=noCols+no; |
791 | setNumCols(newCols); | 799 | setNumCols(newCols); |
792 | for (int i=noCols; i<newCols; ++i) | 800 | for (int i=noCols; i<newCols; ++i) |
793 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); | 801 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); |
794 | 802 | ||
795 | typeCellData *tempCellData; | 803 | typeCellData *tempCellData; |
796 | int col=currentColumn(), row=currentRow(); | 804 | int col=currentColumn(), row=currentRow(); |
797 | 805 | ||
798 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 806 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
799 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) | 807 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) |
800 | { | 808 | { |
801 | clearCell(tempCellData->row, tempCellData->col); | 809 | clearCell(tempCellData->row, tempCellData->col); |
802 | tempCellData->col+=no; | 810 | tempCellData->col+=no; |
803 | } | 811 | } |
804 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 812 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
805 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) | 813 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) |
806 | { | 814 | { |
807 | updateCell(tempCellData->row, tempCellData->col-no); | 815 | updateCell(tempCellData->row, tempCellData->col-no); |
808 | setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); | 816 | setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data)); |
809 | } | 817 | } |
810 | emit sheetModified(); | 818 | emit sheetModified(); |
811 | } | 819 | } |
812 | 820 | ||
813 | void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase, bool allCells, bool entireCell, bool replace, bool replaceAll) | 821 | void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase, bool allCells, bool entireCell, bool replace, bool replaceAll) |
814 | { | 822 | { |
815 | typeCellData *tempCellData; | 823 | typeCellData *tempCellData; |
816 | int row1, col1, row2, col2; | 824 | int row1, col1, row2, col2; |
817 | getSelection(&row1, &col1, &row2, &col2); | 825 | getSelection(&row1, &col1, &row2, &col2); |
818 | bool found=FALSE; | 826 | bool found=FALSE; |
819 | 827 | ||
820 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 828 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
821 | if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2)) | 829 | if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2)) |
822 | { | 830 | { |
823 | QTableItem *cellItem=item(tempCellData->row, tempCellData->col); | 831 | QTableItem *cellItem=item(tempCellData->row, tempCellData->col); |
824 | if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0)) | 832 | if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0)) |
825 | { | 833 | { |
826 | if (!found) | 834 | if (!found) |
827 | { | 835 | { |
828 | found=TRUE; | 836 | found=TRUE; |
829 | clearSelection(); | 837 | clearSelection(); |
830 | } | 838 | } |
831 | setCurrentCell(tempCellData->row, tempCellData->col); | 839 | setCurrentCell(tempCellData->row, tempCellData->col); |
832 | if (replace) | 840 | if (replace) |
833 | { | 841 | { |
834 | tempCellData->data=cellItem->text().replace(QRegExp(findStr, matchCase), replaceStr); | 842 | tempCellData->data=cellItem->text().replace(QRegExp(findStr, matchCase), replaceStr); |
835 | setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); | 843 | setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data)); |
836 | } | 844 | } |
837 | if (!replace || !replaceAll) break; | 845 | if (!replace || !replaceAll) break; |
838 | } | 846 | } |
839 | } | 847 | } |
840 | 848 | ||
841 | if (found) | 849 | if (found) |
842 | { | 850 | { |
843 | if (replace) | 851 | if (replace) |
844 | slotCellChanged(currentRow(), currentColumn()); | 852 | slotCellChanged(currentRow(), currentColumn()); |
845 | } | 853 | } |
846 | else | 854 | else |
847 | QMessageBox::warning(this, tr("Error"), tr("Search key not found!")); | 855 | QMessageBox::warning(this, tr("Error"), tr("Search key not found!")); |
848 | } | 856 | } |
849 | 857 | ||
850 | // | 858 | // |
851 | // Static functions | 859 | // Static functions |
852 | // | 860 | // |
853 | 861 | ||
854 | QString Sheet::getHeaderString(int section) | 862 | QString Sheet::getHeaderString(int section) |
855 | { | 863 | { |
856 | if (section<1) return ""; | 864 | if (section<1) return ""; |
857 | return getHeaderString((section-1)/26)+QChar('A'+(section-1)%26); | 865 | return getHeaderString((section-1)/26)+QChar('A'+(section-1)%26); |
858 | } | 866 | } |
859 | 867 | ||
diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h index f78a684..f4e9d38 100644 --- a/noncore/apps/opie-sheet/sheet.h +++ b/noncore/apps/opie-sheet/sheet.h | |||
@@ -26,59 +26,61 @@ typedef struct typeCellBorders | |||
26 | typedef struct typeCellData | 26 | typedef struct typeCellData |
27 | { | 27 | { |
28 | int col, row; | 28 | int col, row; |
29 | typeCellBorders borders; | 29 | typeCellBorders borders; |
30 | QBrush background; | 30 | QBrush background; |
31 | Qt::AlignmentFlags alignment; | 31 | Qt::AlignmentFlags alignment; |
32 | QColor fontColor; | 32 | QColor fontColor; |
33 | QFont font; | 33 | QFont font; |
34 | QString data; | 34 | QString data; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | class Sheet: public QTable | 37 | class Sheet: public QTable |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | // Variables | 41 | // Variables |
42 | bool clicksLocked; | 42 | bool clicksLocked; |
43 | int selectionNo; | 43 | int selectionNo; |
44 | typeCellBorders defaultBorders; | 44 | typeCellBorders defaultBorders; |
45 | typeCellData defaultCellData; | 45 | typeCellData defaultCellData; |
46 | 46 | ||
47 | // QT objects | 47 | // QT objects |
48 | QList<typeCellData> sheetData, clipboardData; | 48 | QList<typeCellData> sheetData, clipboardData; |
49 | QString pressedCell, releasedCell, sheetName; | 49 | QString pressedCell, releasedCell, sheetName; |
50 | QStringList listDataParser; | ||
50 | 51 | ||
51 | // Private functions | 52 | // Private functions |
52 | int getOperatorPriority(char oper); | 53 | int getOperatorPriority(char oper); |
53 | bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); | 54 | bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); |
55 | QString findCellName(int row, int col); | ||
54 | bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); | 56 | bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); |
55 | double calculateVariable(const QString &variable); | 57 | double calculateVariable(const QString &variable); |
56 | double calculateFunction(const QString &function, const QString ¶meters); | 58 | double calculateFunction(const QString &function, const QString ¶meters); |
57 | QChar popCharStack(QStack<QChar> *stackChars); | 59 | QChar popCharStack(QStack<QChar> *stackChars); |
58 | QString popStringStack(QStack<QString> *stackStrings); | 60 | QString popStringStack(QStack<QString> *stackStrings); |
59 | QString getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName=""); | 61 | QString getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName=""); |
60 | QString dataParser(const QString &data); | 62 | QString dataParser(const QString &cell, const QString &data); |
61 | QString dataParserHelper(const QString &data); | 63 | QString dataParserHelper(const QString &data); |
62 | typeCellData *createCellData(int row, int col); | 64 | typeCellData *createCellData(int row, int col); |
63 | typeCellData *findCellData(int row, int col); | 65 | typeCellData *findCellData(int row, int col); |
64 | void pushCharStack(QStack<QChar> *stackChars, const QChar &character); | 66 | void pushCharStack(QStack<QChar> *stackChars, const QChar &character); |
65 | void pushStringStack(QStack<QString> *stackStrings, const QString &string); | 67 | void pushStringStack(QStack<QString> *stackStrings, const QString &string); |
66 | 68 | ||
67 | // Sheet/Qt parser functions | 69 | // Sheet/Qt parser functions |
68 | double functionSum(const QString ¶m1, const QString ¶m2); | 70 | double functionSum(const QString ¶m1, const QString ¶m2); |
69 | double functionAvg(const QString ¶m1, const QString ¶m2); | 71 | double functionAvg(const QString ¶m1, const QString ¶m2); |
70 | double functionMax(const QString ¶m1, const QString ¶m2); | 72 | double functionMax(const QString ¶m1, const QString ¶m2); |
71 | double functionMin(const QString ¶m1, const QString ¶m2); | 73 | double functionMin(const QString ¶m1, const QString ¶m2); |
72 | double functionCount(const QString ¶m1, const QString ¶m2); | 74 | double functionCount(const QString ¶m1, const QString ¶m2); |
73 | 75 | ||
74 | // Reimplemented QTable functions | 76 | // Reimplemented QTable functions |
75 | void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected); | 77 | void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected); |
76 | void viewportMousePressEvent(QMouseEvent *e); | 78 | void viewportMousePressEvent(QMouseEvent *e); |
77 | void viewportMouseMoveEvent(QMouseEvent *e); | 79 | void viewportMouseMoveEvent(QMouseEvent *e); |
78 | void viewportMouseReleaseEvent(QMouseEvent *e); | 80 | void viewportMouseReleaseEvent(QMouseEvent *e); |
79 | 81 | ||
80 | private slots: | 82 | private slots: |
81 | void slotCellSelected(int row, int col); | 83 | void slotCellSelected(int row, int col); |
82 | void slotCellChanged(int row, int col); | 84 | void slotCellChanged(int row, int col); |
83 | 85 | ||
84 | public: | 86 | public: |