author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/opie-sheet/sheet.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/apps/opie-sheet/sheet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index f303d33..d4419af 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp | |||
@@ -1,143 +1,143 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "sheet.h" | 15 | #include "sheet.h" |
16 | 16 | ||
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <math.h> | 18 | #include <math.h> |
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <time.h> | 21 | #include <time.h> |
22 | 22 | ||
23 | #define DEFAULT_COL_WIDTH 50 | 23 | #define DEFAULT_COL_WIDTH 50 |
24 | 24 | ||
25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) | 25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) |
26 | :QTable(numRows, numCols, parent) | 26 | :QTable(numRows, numCols, parent) |
27 | { | 27 | { |
28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); | 28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); |
29 | defaultCellData.data=""; | 29 | defaultCellData.data=""; |
30 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); | 30 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); |
31 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); | 31 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); |
32 | defaultCellData.fontColor=Qt::black; | 32 | defaultCellData.fontColor=Qt::black; |
33 | defaultCellData.font=font(); | 33 | defaultCellData.font=font(); |
34 | defaultCellData.borders=defaultBorders; | 34 | defaultCellData.borders=defaultBorders; |
35 | 35 | ||
36 | clicksLocked=FALSE; | 36 | clicksLocked=FALSE; |
37 | selectionNo=-1; | 37 | selectionNo=-1; |
38 | setSelectionMode(QTable::Single); | 38 | setSelectionMode(QTable::Single); |
39 | 39 | ||
40 | sheetData.setAutoDelete(TRUE); | 40 | sheetData.setAutoDelete(TRUE); |
41 | clipboardData.setAutoDelete(TRUE); | 41 | clipboardData.setAutoDelete(TRUE); |
42 | for (int i=0; i<numCols; ++i) | 42 | for (int i=0; i<numCols; ++i) |
43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); | 43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); |
44 | 44 | ||
45 | 45 | ||
46 | connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int))); | 46 | connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int))); |
47 | connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int))); | 47 | connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int))); |
48 | } | 48 | } |
49 | 49 | ||
50 | Sheet::~Sheet() | 50 | Sheet::~Sheet() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | typeCellData *Sheet::findCellData(int row, int col) | 54 | typeCellData *Sheet::findCellData(int row, int col) |
55 | { | 55 | { |
56 | typeCellData *tempCellData; | 56 | typeCellData *tempCellData; |
57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
58 | { | 58 | { |
59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; | 59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; |
60 | } | 60 | } |
61 | return NULL; | 61 | return NULL; |
62 | } | 62 | } |
63 | 63 | ||
64 | void Sheet::slotCellSelected(int row, int col) | 64 | void Sheet::slotCellSelected(int row, int col) |
65 | { | 65 | { |
66 | typeCellData *cellData=findCellData(row, col); | 66 | typeCellData *cellData=findCellData(row, col); |
67 | if (cellData) | 67 | if (cellData) |
68 | { | 68 | { |
69 | emit currentDataChanged(cellData->data); | 69 | emit currentDataChanged(cellData->data); |
70 | }else | 70 | }else |
71 | emit currentDataChanged(""); | 71 | emit currentDataChanged(""); |
72 | } | 72 | } |
73 | 73 | ||
74 | typeCellData *Sheet::createCellData(int row, int col) | 74 | typeCellData *Sheet::createCellData(int row, int col) |
75 | { | 75 | { |
76 | if (row<0 || col<0) return NULL; | 76 | if (row<0 || col<0) return NULL; |
77 | typeCellData *cellData=new typeCellData; | 77 | typeCellData *cellData=new typeCellData; |
78 | cellData->row=row; | 78 | cellData->row=row; |
79 | cellData->col=col; | 79 | cellData->col=col; |
80 | cellData->data=defaultCellData.data; | 80 | cellData->data=defaultCellData.data; |
81 | cellData->borders=defaultCellData.borders; | 81 | cellData->borders=defaultCellData.borders; |
82 | cellData->alignment=defaultCellData.alignment; | 82 | cellData->alignment=defaultCellData.alignment; |
83 | cellData->font=defaultCellData.font; | 83 | cellData->font=defaultCellData.font; |
84 | cellData->fontColor=defaultCellData.fontColor; | 84 | cellData->fontColor=defaultCellData.fontColor; |
85 | cellData->background=defaultCellData.background; | 85 | cellData->background=defaultCellData.background; |
86 | sheetData.append(cellData); | 86 | sheetData.append(cellData); |
87 | return cellData; | 87 | return cellData; |
88 | } | 88 | } |
89 | 89 | ||
90 | void Sheet::slotCellChanged(int row, int col) | 90 | void Sheet::slotCellChanged(int row, int col) |
91 | { | 91 | { |
92 | typeCellData *cellData=findCellData(row, col); | 92 | typeCellData *cellData=findCellData(row, col); |
93 | if (!cellData) cellData=createCellData(row, col); | 93 | if (!cellData) cellData=createCellData(row, col); |
94 | if (cellData) cellData->data=text(row, col); | 94 | if (cellData) cellData->data=text(row, col); |
95 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 95 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
96 | { | 96 | { |
97 | // modified by Toussis Manolis koppermind@panafonet.gr | 97 | // modified by Toussis Manolis koppermind@panafonet.gr |
98 | // the parser was crashing if there were no closed parenthesis. | 98 | // the parser was crashing if there were no closed parenthesis. |
99 | int w1,ii=0; | 99 | int w1,ii=0; |
100 | for(w1=0;w1<=(int)text(row, col).length();w1++) | 100 | for(w1=0;w1<=(int)text(row, col).length();w1++) |
101 | { | 101 | { |
102 | if(text(row,col)[w1]=='(') ii++; | 102 | if(text(row,col)[w1]=='(') ii++; |
103 | if(text(row,col)[w1]==')') ii--; | 103 | if(text(row,col)[w1]==')') ii--; |
104 | }; | 104 | }; |
105 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 105 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
106 | //end of modification | 106 | //end of modification |
107 | // old was plain: | 107 | // old was plain: |
108 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 108 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
109 | }; | 109 | }; |
110 | emit sheetModified(); | 110 | emit sheetModified(); |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | void Sheet::ReCalc(void) | 114 | void Sheet::ReCalc(void) |
115 | { | 115 | { |
116 | typeCellData* cellData; | 116 | typeCellData* cellData; |
117 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 117 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
118 | { | 118 | { |
119 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); | 119 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); |
120 | 120 | ||
121 | slotCellChanged(cellData->row,cellData->col); | 121 | slotCellChanged(cellData->row,cellData->col); |
122 | }; | 122 | }; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | void Sheet::swapCells(int row1, int col1, int row2, int col2) | 128 | void Sheet::swapCells(int row1, int col1, int row2, int col2) |
129 | { | 129 | { |
130 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); | 130 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); |
131 | if (!cellData1) cellData1=createCellData(row1, col1); | 131 | if (!cellData1) cellData1=createCellData(row1, col1); |
132 | if (!cellData2) cellData2=createCellData(row2, col2); | 132 | if (!cellData2) cellData2=createCellData(row2, col2); |
133 | if (cellData1 && cellData2) | 133 | if (cellData1 && cellData2) |
134 | { | 134 | { |
135 | QString tempData(cellData1->data); | 135 | QString tempData(cellData1->data); |
136 | cellData1->data=cellData2->data; | 136 | cellData1->data=cellData2->data; |
137 | cellData2->data=tempData; | 137 | cellData2->data=tempData; |
138 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); | 138 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); |
139 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); | 139 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); |
140 | emit sheetModified(); | 140 | emit sheetModified(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||