Diffstat (limited to 'noncore/apps/opie-sheet/sheet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index 1d7ec6f..2279191 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp | |||
@@ -98,25 +98,25 @@ void Sheet::swapCells(int row1, int col1, int row2, int col2) | |||
98 | if (!cellData2) cellData2=createCellData(row2, col2); | 98 | if (!cellData2) cellData2=createCellData(row2, col2); |
99 | if (cellData1 && cellData2) | 99 | if (cellData1 && cellData2) |
100 | { | 100 | { |
101 | QString tempData(cellData1->data); | 101 | QString tempData(cellData1->data); |
102 | cellData1->data=cellData2->data; | 102 | cellData1->data=cellData2->data; |
103 | cellData2->data=tempData; | 103 | cellData2->data=tempData; |
104 | setText(cellData1->row, cellData1->col, dataParser(cellData1->data)); | 104 | setText(cellData1->row, cellData1->col, dataParser(cellData1->data)); |
105 | setText(cellData2->row, cellData2->col, dataParser(cellData2->data)); | 105 | setText(cellData2->row, cellData2->col, dataParser(cellData2->data)); |
106 | emit sheetModified(); | 106 | emit sheetModified(); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | QString Sheet::getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName="") | 110 | QString Sheet::getParameter(const QString ¶meters, int paramNo, bool giveError, const QString funcName) |
111 | { | 111 | { |
112 | QString params(parameters); | 112 | QString params(parameters); |
113 | int position; | 113 | int position; |
114 | for (int i=0; i<paramNo; ++i) | 114 | for (int i=0; i<paramNo; ++i) |
115 | { | 115 | { |
116 | position=params.find(','); | 116 | position=params.find(','); |
117 | if (position<0) | 117 | if (position<0) |
118 | { | 118 | { |
119 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\'')); | 119 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\'')); |
120 | return QString(); | 120 | return QString(); |
121 | } | 121 | } |
122 | params=params.mid(position+1); | 122 | params=params.mid(position+1); |
@@ -136,25 +136,25 @@ bool Sheet::findRange(const QString &variable1, const QString &variable2, int *r | |||
136 | *row1=*row2; | 136 | *row1=*row2; |
137 | *row2=row; | 137 | *row2=row; |
138 | } | 138 | } |
139 | if (*col1>*col2) | 139 | if (*col1>*col2) |
140 | { | 140 | { |
141 | col=*col1; | 141 | col=*col1; |
142 | *col1=*col2; | 142 | *col1=*col2; |
143 | *col2=col; | 143 | *col2=col; |
144 | } | 144 | } |
145 | return TRUE; | 145 | return TRUE; |
146 | } | 146 | } |
147 | 147 | ||
148 | bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE) | 148 | bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError) |
149 | { | 149 | { |
150 | int position=variable.find(QRegExp("\\d")); | 150 | int position=variable.find(QRegExp("\\d")); |
151 | if (position<1) | 151 | if (position<1) |
152 | { | 152 | { |
153 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\'')); | 153 | if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\'')); |
154 | return FALSE; | 154 | return FALSE; |
155 | } | 155 | } |
156 | *row=variable.mid(position).toInt()-1; | 156 | *row=variable.mid(position).toInt()-1; |
157 | *col=getHeaderColumn(variable.left(position))-1; | 157 | *col=getHeaderColumn(variable.left(position))-1; |
158 | return TRUE; | 158 | return TRUE; |
159 | } | 159 | } |
160 | 160 | ||
@@ -443,25 +443,25 @@ void Sheet::setData(const QString &data) | |||
443 | slotCellChanged(currentRow(), currentColumn()); | 443 | slotCellChanged(currentRow(), currentColumn()); |
444 | activateNextCell(); | 444 | activateNextCell(); |
445 | } | 445 | } |
446 | 446 | ||
447 | QString Sheet::getData() | 447 | QString Sheet::getData() |
448 | { | 448 | { |
449 | typeCellData *cellData=findCellData(currentRow(), currentColumn()); | 449 | typeCellData *cellData=findCellData(currentRow(), currentColumn()); |
450 | if (cellData) | 450 | if (cellData) |
451 | return cellData->data; | 451 | return cellData->data; |
452 | return ""; | 452 | return ""; |
453 | } | 453 | } |
454 | 454 | ||
455 | void Sheet::lockClicks(bool lock=TRUE) | 455 | void Sheet::lockClicks(bool lock) |
456 | { | 456 | { |
457 | clicksLocked=lock; | 457 | clicksLocked=lock; |
458 | } | 458 | } |
459 | 459 | ||
460 | void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected) | 460 | void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected) |
461 | { | 461 | { |
462 | if (selected && row==currentRow() && col==currentColumn()) selected=FALSE; | 462 | if (selected && row==currentRow() && col==currentColumn()) selected=FALSE; |
463 | 463 | ||
464 | int sheetDataCurrent=sheetData.at(); | 464 | int sheetDataCurrent=sheetData.at(); |
465 | typeCellData *cellData=findCellData(row, col); | 465 | typeCellData *cellData=findCellData(row, col); |
466 | if (sheetDataCurrent>=0) sheetData.at(sheetDataCurrent); | 466 | if (sheetDataCurrent>=0) sheetData.at(sheetDataCurrent); |
467 | if (!cellData) cellData=&defaultCellData; | 467 | if (!cellData) cellData=&defaultCellData; |
@@ -727,72 +727,72 @@ void Sheet::editCopy() | |||
727 | newCellData->col-=col1; | 727 | newCellData->col-=col1; |
728 | clipboardData.append(newCellData); | 728 | clipboardData.append(newCellData); |
729 | } | 729 | } |
730 | } | 730 | } |
731 | } | 731 | } |
732 | 732 | ||
733 | void Sheet::editCut() | 733 | void Sheet::editCut() |
734 | { | 734 | { |
735 | editCopy(); | 735 | editCopy(); |
736 | editClear(); | 736 | editClear(); |
737 | } | 737 | } |
738 | 738 | ||
739 | void Sheet::editPaste(bool onlyContents=FALSE) | 739 | void Sheet::editPaste(bool onlyContents) |
740 | { | 740 | { |
741 | int row1=currentRow(), col1=currentColumn(); | 741 | int row1=currentRow(), col1=currentColumn(); |
742 | typeCellData *cellData, *tempCellData; | 742 | typeCellData *cellData, *tempCellData; |
743 | 743 | ||
744 | for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next()) | 744 | for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next()) |
745 | { | 745 | { |
746 | cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1); | 746 | cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1); |
747 | if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1); | 747 | if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1); |
748 | if (cellData) | 748 | if (cellData) |
749 | { | 749 | { |
750 | if (onlyContents) | 750 | if (onlyContents) |
751 | cellData->data=tempCellData->data; | 751 | cellData->data=tempCellData->data; |
752 | else | 752 | else |
753 | { | 753 | { |
754 | *cellData=*tempCellData; | 754 | *cellData=*tempCellData; |
755 | cellData->row+=row1; | 755 | cellData->row+=row1; |
756 | cellData->col+=col1; | 756 | cellData->col+=col1; |
757 | } | 757 | } |
758 | setText(cellData->row, cellData->col, dataParser(cellData->data)); | 758 | setText(cellData->row, cellData->col, dataParser(cellData->data)); |
759 | emit sheetModified(); | 759 | emit sheetModified(); |
760 | } | 760 | } |
761 | } | 761 | } |
762 | } | 762 | } |
763 | 763 | ||
764 | void Sheet::insertRows(int no=1, bool allColumns=TRUE) | 764 | void Sheet::insertRows(int no, bool allColumns) |
765 | { | 765 | { |
766 | setNumRows(numRows()+no); | 766 | setNumRows(numRows()+no); |
767 | 767 | ||
768 | typeCellData *tempCellData; | 768 | typeCellData *tempCellData; |
769 | int row=currentRow(), col=currentColumn(); | 769 | int row=currentRow(), col=currentColumn(); |
770 | 770 | ||
771 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 771 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
772 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) | 772 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) |
773 | { | 773 | { |
774 | clearCell(tempCellData->row, tempCellData->col); | 774 | clearCell(tempCellData->row, tempCellData->col); |
775 | tempCellData->row+=no; | 775 | tempCellData->row+=no; |
776 | } | 776 | } |
777 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 777 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
778 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) | 778 | if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) |
779 | { | 779 | { |
780 | updateCell(tempCellData->row-no, tempCellData->col); | 780 | updateCell(tempCellData->row-no, tempCellData->col); |
781 | setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); | 781 | setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); |
782 | } | 782 | } |
783 | emit sheetModified(); | 783 | emit sheetModified(); |
784 | } | 784 | } |
785 | 785 | ||
786 | void Sheet::insertColumns(int no=1, bool allRows=TRUE) | 786 | void Sheet::insertColumns(int no, bool allRows) |
787 | { | 787 | { |
788 | int noCols=numCols(); | 788 | int noCols=numCols(); |
789 | int newCols=noCols+no; | 789 | int newCols=noCols+no; |
790 | setNumCols(newCols); | 790 | setNumCols(newCols); |
791 | for (int i=noCols; i<newCols; ++i) | 791 | for (int i=noCols; i<newCols; ++i) |
792 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); | 792 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); |
793 | 793 | ||
794 | typeCellData *tempCellData; | 794 | typeCellData *tempCellData; |
795 | int col=currentColumn(), row=currentRow(); | 795 | int col=currentColumn(), row=currentRow(); |
796 | 796 | ||
797 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 797 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
798 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) | 798 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) |
@@ -800,25 +800,25 @@ void Sheet::insertColumns(int no=1, bool allRows=TRUE) | |||
800 | clearCell(tempCellData->row, tempCellData->col); | 800 | clearCell(tempCellData->row, tempCellData->col); |
801 | tempCellData->col+=no; | 801 | tempCellData->col+=no; |
802 | } | 802 | } |
803 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 803 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
804 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) | 804 | if (tempCellData->col>=col && (allRows || tempCellData->row==row)) |
805 | { | 805 | { |
806 | updateCell(tempCellData->row, tempCellData->col-no); | 806 | updateCell(tempCellData->row, tempCellData->col-no); |
807 | setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); | 807 | setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); |
808 | } | 808 | } |
809 | emit sheetModified(); | 809 | emit sheetModified(); |
810 | } | 810 | } |
811 | 811 | ||
812 | void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase=TRUE, bool allCells=TRUE, bool entireCell=FALSE, bool replace=FALSE, bool replaceAll=FALSE) | 812 | void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase, bool allCells, bool entireCell, bool replace, bool replaceAll) |
813 | { | 813 | { |
814 | typeCellData *tempCellData; | 814 | typeCellData *tempCellData; |
815 | int row1, col1, row2, col2; | 815 | int row1, col1, row2, col2; |
816 | getSelection(&row1, &col1, &row2, &col2); | 816 | getSelection(&row1, &col1, &row2, &col2); |
817 | bool found=FALSE; | 817 | bool found=FALSE; |
818 | 818 | ||
819 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 819 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
820 | if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2)) | 820 | if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2)) |
821 | { | 821 | { |
822 | QTableItem *cellItem=item(tempCellData->row, tempCellData->col); | 822 | QTableItem *cellItem=item(tempCellData->row, tempCellData->col); |
823 | if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0)) | 823 | if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0)) |
824 | { | 824 | { |