Diffstat (limited to 'noncore/apps/opie-sheet/sheet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
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 | |||
@@ -90,3 +90,3 @@ void Sheet::slotCellChanged(int row, int 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(); |
@@ -104,4 +104,4 @@ void Sheet::swapCells(int row1, int col1, int row2, int col2) | |||
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(); |
@@ -168,3 +168,3 @@ double Sheet::calculateVariable(const QString &variable) | |||
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 | } |
@@ -422,3 +422,3 @@ QString Sheet::dataParserHelper(const QString &data) | |||
422 | 422 | ||
423 | QString Sheet::dataParser(const QString &data) | 423 | QString Sheet::dataParser(const QString &cell, const QString &data) |
424 | { | 424 | { |
@@ -427,2 +427,4 @@ QString Sheet::dataParser(const QString &data) | |||
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(":"), ",")); |
@@ -437,2 +439,3 @@ QString Sheet::dataParser(const QString &data) | |||
437 | while (!tempParameter.isNull()); | 439 | while (!tempParameter.isNull()); |
440 | listDataParser.remove(cell); | ||
438 | return result.mid(1); | 441 | return result.mid(1); |
@@ -541,5 +544,5 @@ void Sheet::viewportMouseReleaseEvent(QMouseEvent *e) | |||
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 | } |
@@ -549,2 +552,7 @@ void Sheet::viewportMouseReleaseEvent(QMouseEvent *e) | |||
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) |
@@ -578,3 +586,3 @@ void Sheet::setSheetData(QList<typeCellData> *srcSheetData) | |||
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 | } |
@@ -758,3 +766,3 @@ void Sheet::editPaste(bool onlyContents) | |||
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(); |
@@ -781,3 +789,3 @@ void Sheet::insertRows(int no, bool allColumns) | |||
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 | } |
@@ -807,3 +815,3 @@ void Sheet::insertColumns(int no, bool allRows) | |||
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 | } |
@@ -834,3 +842,3 @@ void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, b | |||
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 | } |