author | thufir <thufir> | 2002-07-04 17:55:16 (UTC) |
---|---|---|
committer | thufir <thufir> | 2002-07-04 17:55:16 (UTC) |
commit | f3eaec3a60e32af8abad6563df32499a096b7e70 (patch) (unidiff) | |
tree | 996220ef5b11b20c6482e21b2cdb928ce6a9c6c3 | |
parent | 3fc06dce797f62393bab41f4ea520bdbeb31eb9f (diff) | |
download | opie-f3eaec3a60e32af8abad6563df32499a096b7e70.zip opie-f3eaec3a60e32af8abad6563df32499a096b7e70.tar.gz opie-f3eaec3a60e32af8abad6563df32499a096b7e70.tar.bz2 |
fixed bugs
-rw-r--r-- | noncore/apps/opie-sheet/opie-sheet.control | 2 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sortdlg.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/opie-sheet/opie-sheet.control b/noncore/apps/opie-sheet/opie-sheet.control index f772247..38f9083 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/html/sheetqt.html help/html/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.1 |
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/sortdlg.cpp b/noncore/apps/opie-sheet/sortdlg.cpp index 4f18fd3..c60be0d 100644 --- a/noncore/apps/opie-sheet/sortdlg.cpp +++ b/noncore/apps/opie-sheet/sortdlg.cpp | |||
@@ -93,99 +93,99 @@ void SortDialog::fillFieldCombo(QComboBox *combo) | |||
93 | for (int row=row1; row<=row2; ++row) | 93 | for (int row=row1; row<=row2; ++row) |
94 | combo->insertItem("Row "+QString::number(row+1)); | 94 | combo->insertItem("Row "+QString::number(row+1)); |
95 | else | 95 | else |
96 | for (int col=col1; col<=col2; ++col) | 96 | for (int col=col1; col<=col2; ++col) |
97 | combo->insertItem("Column "+Sheet::getHeaderString(col+1)); | 97 | combo->insertItem("Column "+Sheet::getHeaderString(col+1)); |
98 | } | 98 | } |
99 | 99 | ||
100 | int SortDialog::exec(Sheet *s) | 100 | int SortDialog::exec(Sheet *s) |
101 | { | 101 | { |
102 | sheet=s; | 102 | sheet=s; |
103 | sheet->getSelection(&row1, &col1, &row2, &col2); | 103 | sheet->getSelection(&row1, &col1, &row2, &col2); |
104 | 104 | ||
105 | direction=0; | 105 | direction=0; |
106 | fillFieldCombo(comboFieldA); | 106 | fillFieldCombo(comboFieldA); |
107 | fillFieldCombo(comboFieldB); | 107 | fillFieldCombo(comboFieldB); |
108 | fillFieldCombo(comboFieldC); | 108 | fillFieldCombo(comboFieldC); |
109 | 109 | ||
110 | if (row1==row2 && col1==col2) | 110 | if (row1==row2 && col1==col2) |
111 | { | 111 | { |
112 | QMessageBox::warning(this, tr("Error"), tr("One cell cannot be sorted!")); | 112 | QMessageBox::warning(this, tr("Error"), tr("One cell cannot be sorted!")); |
113 | return QDialog::Rejected; | 113 | return QDialog::Rejected; |
114 | } | 114 | } |
115 | if (QDialog::exec()==QDialog::Accepted) | 115 | if (QDialog::exec()==QDialog::Accepted) |
116 | { | 116 | { |
117 | QString field1S=comboFieldA->currentText(), field2S=comboFieldA->currentText(), field3S=comboFieldA->currentText(); | 117 | QString field1S=comboFieldA->currentText(), field2S=comboFieldB->currentText(), field3S=comboFieldC->currentText(); |
118 | field1S=field1S.mid(field1S.find(' ')+1); | 118 | field1S=field1S.mid(field1S.find(' ')+1); |
119 | field2S=field2S.mid(field2S.find(' ')+1); | 119 | field2S=field2S.mid(field2S.find(' ')+1); |
120 | field3S=field3S.mid(field3S.find(' ')+1); | 120 | field3S=field3S.mid(field3S.find(' ')+1); |
121 | int field1, field2, field3; | 121 | int field1, field2, field3; |
122 | if (direction) | 122 | if (direction) |
123 | { | 123 | { |
124 | field1=field1S.toInt()-1; | 124 | field1=field1S.toInt()-1; |
125 | field2=field2S.toInt()-1; | 125 | field2=field2S.toInt()-1; |
126 | field3=field3S.toInt()-1; | 126 | field3=field3S.toInt()-1; |
127 | int i, j; | 127 | int i, j; |
128 | for (i=col2; i>=col1; --i) | 128 | for (i=col2; i>=col1; --i) |
129 | for (j=col1+1; j<=i; ++j) | 129 | for (j=col1+1; j<=i; ++j) |
130 | { | 130 | { |
131 | bool swap=FALSE; | 131 | bool swap=FALSE; |
132 | int compareResult=compareItems(s->item(field1, j-1), s->item(field1, j), groupOrderA->id(groupOrderA->selected()), checkCase->isChecked()); | 132 | int compareResult=compareItems(s->item(field1, j-1), s->item(field1, j), groupOrderA->id(groupOrderA->selected()), checkCase->isChecked()); |
133 | if (compareResult>0) swap=TRUE; | 133 | if (compareResult>0) swap=TRUE; |
134 | else if (compareResult==0) | 134 | else if (compareResult==0) |
135 | { | 135 | { |
136 | compareResult=compareItems(s->item(field2, j-1), s->item(field2, j), groupOrderA->id(groupOrderB->selected()), checkCase->isChecked()); | 136 | compareResult=compareItems(s->item(field2, j-1), s->item(field2, j), groupOrderB->id(groupOrderB->selected()), checkCase->isChecked()); |
137 | if (compareResult>0) swap=TRUE; | 137 | if (compareResult>0) swap=TRUE; |
138 | else if (compareResult==0) | 138 | else if (compareResult==0) |
139 | { | 139 | { |
140 | compareResult=compareItems(s->item(field3, j-1), s->item(field3, j), groupOrderA->id(groupOrderC->selected()), checkCase->isChecked()); | 140 | compareResult=compareItems(s->item(field3, j-1), s->item(field3, j), groupOrderC->id(groupOrderC->selected()), checkCase->isChecked()); |
141 | if (compareResult>0) swap=TRUE; | 141 | if (compareResult>0) swap=TRUE; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | if (swap) | 144 | if (swap) |
145 | for (int row=row1; row<=row2; ++row) | 145 | for (int row=row1; row<=row2; ++row) |
146 | s->swapCells(row, j-1, row, j); | 146 | s->swapCells(row, j-1, row, j); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | else | 149 | else |
150 | { | 150 | { |
151 | field1=Sheet::getHeaderColumn(field1S)-1; | 151 | field1=Sheet::getHeaderColumn(field1S)-1; |
152 | field2=Sheet::getHeaderColumn(field2S)-1; | 152 | field2=Sheet::getHeaderColumn(field2S)-1; |
153 | field3=Sheet::getHeaderColumn(field3S)-1; | 153 | field3=Sheet::getHeaderColumn(field3S)-1; |
154 | int i, j; | 154 | int i, j; |
155 | for (i=row2; i>=row1; --i) | 155 | for (i=row2; i>=row1; --i) |
156 | for (j=row1+1; j<=i; ++j) | 156 | for (j=row1+1; j<=i; ++j) |
157 | { | 157 | { |
158 | bool swap=FALSE; | 158 | bool swap=FALSE; |
159 | int compareResult=compareItems(s->item(j-1, field1), s->item(j, field1), groupOrderA->id(groupOrderA->selected()), checkCase->isChecked()); | 159 | int compareResult=compareItems(s->item(j-1, field1), s->item(j, field1), groupOrderA->id(groupOrderA->selected()), checkCase->isChecked()); |
160 | if (compareResult>0) swap=TRUE; | 160 | if (compareResult>0) swap=TRUE; |
161 | else if (compareResult==0) | 161 | else if (compareResult==0) |
162 | { | 162 | { |
163 | compareResult=compareItems(s->item(j-1, field2), s->item(j, field2), groupOrderA->id(groupOrderB->selected()), checkCase->isChecked()); | 163 | compareResult=compareItems(s->item(j-1, field2), s->item(j, field2), groupOrderB->id(groupOrderB->selected()), checkCase->isChecked()); |
164 | if (compareResult>0) swap=TRUE; | 164 | if (compareResult>0) swap=TRUE; |
165 | else if (compareResult==0) | 165 | else if (compareResult==0) |
166 | { | 166 | { |
167 | compareResult=compareItems(s->item(j-1, field3), s->item(j, field3), groupOrderA->id(groupOrderC->selected()), checkCase->isChecked()); | 167 | compareResult=compareItems(s->item(j-1, field3), s->item(j, field3), groupOrderC->id(groupOrderC->selected()), checkCase->isChecked()); |
168 | if (compareResult>0) swap=TRUE; | 168 | if (compareResult>0) swap=TRUE; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | if (swap) | 171 | if (swap) |
172 | for (int col=col1; col<=col2; ++col) | 172 | for (int col=col1; col<=col2; ++col) |
173 | s->swapCells(j-1, col, j, col); | 173 | s->swapCells(j-1, col, j, col); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | return QDialog::Accepted; | 176 | return QDialog::Accepted; |
177 | } | 177 | } |
178 | return QDialog::Rejected; | 178 | return QDialog::Rejected; |
179 | } | 179 | } |
180 | 180 | ||
181 | int SortDialog::compareItems(QTableItem *item1, QTableItem *item2, int descending=0, bool caseSensitive=TRUE) | 181 | int SortDialog::compareItems(QTableItem *item1, QTableItem *item2, int descending=0, bool caseSensitive=TRUE) |
182 | { | 182 | { |
183 | int result=0; | 183 | int result=0; |
184 | if (item1) | 184 | if (item1) |
185 | { | 185 | { |
186 | if (item2) result=(caseSensitive ? item1->text().compare(item2->text()) : item1->text().upper().compare(item2->text().upper())); | 186 | if (item2) result=(caseSensitive ? item1->text().compare(item2->text()) : item1->text().upper().compare(item2->text().upper())); |
187 | else result=-1; | 187 | else result=-1; |
188 | } | 188 | } |
189 | else | 189 | else |
190 | if (item2) result=1; | 190 | if (item2) result=1; |
191 | return (descending ? -result : result); | 191 | return (descending ? -result : result); |