author | leseb <leseb> | 2002-07-06 20:45:39 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-07-06 20:45:39 (UTC) |
commit | 7c069ad1b76c681282499b157ef9b23ec000947d (patch) (unidiff) | |
tree | 677ae3903f6448a4f761e3a1245c7e4a746b8a1a | |
parent | 2517236d77e1f2a3d255c4c540a39f1661caaff9 (diff) | |
download | opie-7c069ad1b76c681282499b157ef9b23ec000947d.zip opie-7c069ad1b76c681282499b157ef9b23ec000947d.tar.gz opie-7c069ad1b76c681282499b157ef9b23ec000947d.tar.bz2 |
Fix DocLnk management to save documents correctly
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.h | 5 |
2 files changed, 20 insertions, 23 deletions
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index efbcc20..09ee68b 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -1,482 +1,478 @@ | |||
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 "mainwindow.h" | 15 | #include "mainwindow.h" |
16 | 16 | ||
17 | #include <qpe/filemanager.h> | 17 | #include <qpe/filemanager.h> |
18 | #include <qpe/qcopenvelope_qws.h> | 18 | #include <qpe/qcopenvelope_qws.h> |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qradiobutton.h> | 21 | #include <qradiobutton.h> |
22 | #include "cellformat.h" | 22 | #include "cellformat.h" |
23 | #include "numberdlg.h" | 23 | #include "numberdlg.h" |
24 | #include "textdlg.h" | 24 | #include "textdlg.h" |
25 | #include "sortdlg.h" | 25 | #include "sortdlg.h" |
26 | #include "finddlg.h" | 26 | #include "finddlg.h" |
27 | 27 | ||
28 | #include "file-new.xpm" | 28 | #include "file-new.xpm" |
29 | #include "file-open.xpm" | 29 | #include "file-open.xpm" |
30 | #include "file-save.xpm" | 30 | #include "file-save.xpm" |
31 | #include "edit-cancel.xpm" | 31 | #include "edit-cancel.xpm" |
32 | #include "edit-accept.xpm" | 32 | #include "edit-accept.xpm" |
33 | #include "help-general.xpm" | 33 | #include "help-general.xpm" |
34 | #include "func-plus.xpm" | 34 | #include "func-plus.xpm" |
35 | #include "func-minus.xpm" | 35 | #include "func-minus.xpm" |
36 | #include "func-cross.xpm" | 36 | #include "func-cross.xpm" |
37 | #include "func-divide.xpm" | 37 | #include "func-divide.xpm" |
38 | #include "func-paran-open.xpm" | 38 | #include "func-paran-open.xpm" |
39 | #include "func-paran-close.xpm" | 39 | #include "func-paran-close.xpm" |
40 | #include "func-comma.xpm" | 40 | #include "func-comma.xpm" |
41 | #include "func-func.xpm" | 41 | #include "func-func.xpm" |
42 | #include "func-equal.xpm" | 42 | #include "func-equal.xpm" |
43 | #include "cell-select.xpm" | 43 | #include "cell-select.xpm" |
44 | 44 | ||
45 | #define DEFAULT_NUM_ROWS 199 | 45 | #define DEFAULT_NUM_ROWS 199 |
46 | #define DEFAULT_NUM_COLS (26*3) | 46 | #define DEFAULT_NUM_COLS (26*3) |
47 | #define DEFAULT_NUM_SHEETS 3 | 47 | #define DEFAULT_NUM_SHEETS 3 |
48 | 48 | ||
49 | MainWindow::MainWindow() | 49 | MainWindow::MainWindow() |
50 | :QMainWindow() | 50 | :QMainWindow() |
51 | { | 51 | { |
52 | // initialize variables | 52 | // initialize variables |
53 | documentModified=FALSE; | 53 | documentModified=FALSE; |
54 | 54 | ||
55 | // construct objects | 55 | // construct objects |
56 | currentDoc=0; | ||
56 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 57 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
57 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 58 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
58 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 59 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); |
59 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 60 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); |
60 | 61 | ||
61 | listSheets.setAutoDelete(TRUE); | 62 | listSheets.setAutoDelete(TRUE); |
62 | 63 | ||
63 | initActions(); | 64 | initActions(); |
64 | initMenu(); | 65 | initMenu(); |
65 | initEditToolbar(); | 66 | initEditToolbar(); |
66 | initFunctionsToolbar(); | 67 | initFunctionsToolbar(); |
67 | initStandardToolbar(); | 68 | initStandardToolbar(); |
68 | initSheet(); | 69 | initSheet(); |
69 | 70 | ||
70 | // set window title | 71 | // set window title |
71 | setCaption(tr("Opie Sheet")); | 72 | setCaption(tr("Opie Sheet")); |
72 | 73 | ||
73 | // create sheets | 74 | // create sheets |
74 | selectorFileNew(currentDoc); | 75 | selectorFileNew(DocLnk()); |
75 | } | 76 | } |
76 | 77 | ||
77 | MainWindow::~MainWindow() | 78 | MainWindow::~MainWindow() |
78 | { | 79 | { |
80 | if (currentDoc) delete currentDoc; | ||
79 | } | 81 | } |
80 | 82 | ||
81 | void MainWindow::documentSave(DocLnk &lnkDoc) | 83 | void MainWindow::documentSave(DocLnk *lnkDoc) |
82 | { | 84 | { |
83 | FileManager fm; | 85 | FileManager fm; |
84 | QByteArray streamBuffer; | 86 | QByteArray streamBuffer; |
85 | QDataStream stream(streamBuffer, IO_WriteOnly); | 87 | QDataStream stream(streamBuffer, IO_WriteOnly); |
86 | 88 | ||
87 | typeSheet *currentSheet=findSheet(sheet->getName()); | 89 | typeSheet *currentSheet=findSheet(sheet->getName()); |
88 | if (!currentSheet) | 90 | if (!currentSheet) |
89 | { | 91 | { |
90 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); | 92 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); |
91 | return; | 93 | return; |
92 | } | 94 | } |
93 | sheet->copySheetData(¤tSheet->data); | 95 | sheet->copySheetData(¤tSheet->data); |
94 | stream.writeRawBytes("SQT100", 6); | 96 | stream.writeRawBytes("SQT100", 6); |
95 | stream << (Q_UINT32)listSheets.count(); | 97 | stream << (Q_UINT32)listSheets.count(); |
96 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 98 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
97 | { | 99 | { |
98 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 100 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
99 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 101 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
100 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; | 102 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; |
101 | } | 103 | } |
102 | 104 | ||
103 | lnkDoc.setType("application/sheet-qt"); | 105 | lnkDoc->setType("application/sheet-qt"); |
104 | if (!fm.saveFile(lnkDoc, streamBuffer)) | 106 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
105 | { | 107 | { |
106 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 108 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
107 | return; | 109 | return; |
108 | } | 110 | } |
109 | documentModified=FALSE; | 111 | documentModified=FALSE; |
110 | } | 112 | } |
111 | 113 | ||
112 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 114 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
113 | { | 115 | { |
114 | FileManager fm; | 116 | FileManager fm; |
115 | QByteArray streamBuffer; | 117 | QByteArray streamBuffer; |
116 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 118 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
117 | { | 119 | { |
118 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 120 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
119 | documentModified=FALSE; | 121 | documentModified=FALSE; |
120 | selectorFileNew(DocLnk()); | 122 | selectorFileNew(DocLnk()); |
121 | return; | 123 | return; |
122 | } | 124 | } |
123 | QDataStream stream(streamBuffer, IO_ReadOnly); | 125 | QDataStream stream(streamBuffer, IO_ReadOnly); |
124 | 126 | ||
125 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 127 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
126 | typeSheet *newSheet; | 128 | typeSheet *newSheet; |
127 | typeCellData *newCell; | 129 | typeCellData *newCell; |
128 | 130 | ||
129 | char fileFormat[7]; | 131 | char fileFormat[7]; |
130 | stream.readRawBytes(fileFormat, 6); | 132 | stream.readRawBytes(fileFormat, 6); |
131 | fileFormat[6]=0; | 133 | fileFormat[6]=0; |
132 | if ((QString)fileFormat!="SQT100") | 134 | if ((QString)fileFormat!="SQT100") |
133 | { | 135 | { |
134 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 136 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
135 | documentModified=FALSE; | 137 | documentModified=FALSE; |
136 | selectorFileNew(DocLnk()); | 138 | selectorFileNew(DocLnk()); |
137 | return; | 139 | return; |
138 | } | 140 | } |
139 | 141 | ||
140 | stream >> countSheet; | 142 | stream >> countSheet; |
141 | for (i=0; i<countSheet; ++i) | 143 | for (i=0; i<countSheet; ++i) |
142 | { | 144 | { |
143 | newSheet=new typeSheet; | 145 | newSheet=new typeSheet; |
144 | newSheet->data.setAutoDelete(TRUE); | 146 | newSheet->data.setAutoDelete(TRUE); |
145 | stream >> newSheet->name >> countCell; | 147 | stream >> newSheet->name >> countCell; |
146 | comboSheets->insertItem(newSheet->name); | 148 | comboSheets->insertItem(newSheet->name); |
147 | 149 | ||
148 | for (j=0; j<countCell; ++j) | 150 | for (j=0; j<countCell; ++j) |
149 | { | 151 | { |
150 | newCell=new typeCellData; | 152 | newCell=new typeCellData; |
151 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 153 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
152 | newCell->col=col; | 154 | newCell->col=col; |
153 | newCell->row=row; | 155 | newCell->row=row; |
154 | newCell->alignment=(Qt::AlignmentFlags)alignment; | 156 | newCell->alignment=(Qt::AlignmentFlags)alignment; |
155 | newSheet->data.append(newCell); | 157 | newSheet->data.append(newCell); |
156 | } | 158 | } |
157 | listSheets.append(newSheet); | 159 | listSheets.append(newSheet); |
158 | 160 | ||
159 | if (i==0) | 161 | if (i==0) |
160 | { | 162 | { |
161 | sheet->setName(newSheet->name); | 163 | sheet->setName(newSheet->name); |
162 | sheet->setSheetData(&newSheet->data); | 164 | sheet->setSheetData(&newSheet->data); |
163 | } | 165 | } |
164 | } | 166 | } |
165 | } | 167 | } |
166 | 168 | ||
167 | int MainWindow::saveCurrentFile(bool ask=TRUE) | 169 | int MainWindow::saveCurrentFile(bool ask=TRUE) |
168 | { | 170 | { |
169 | if (ask) | 171 | if (ask) |
170 | { | 172 | { |
171 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); | 173 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); |
172 | if (result!=QMessageBox::Yes) return result; | 174 | if (result!=QMessageBox::Yes) return result; |
173 | } | 175 | } |
174 | 176 | ||
175 | if (currentDoc.name().isEmpty() || !currentDoc.isValid()) | 177 | if (!currentDoc->isValid()) |
176 | { | 178 | { |
177 | TextDialog dialogText(this); | 179 | TextDialog dialogText(this); |
178 | 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; |
179 | 181 | ||
180 | currentDoc.setName(dialogText.getValue()); | 182 | currentDoc->setName(dialogText.getValue()); |
183 | currentDoc->setFile(QString::null); | ||
184 | currentDoc->setLinkFile(QString::null); | ||
181 | } | 185 | } |
182 | 186 | ||
183 | documentSave(currentDoc); | 187 | documentSave(currentDoc); |
184 | return QMessageBox::Yes; | 188 | return QMessageBox::Yes; |
185 | } | 189 | } |
186 | 190 | ||
187 | void MainWindow::copyDocLnk(const DocLnk &source, DocLnk &target) | ||
188 | { | ||
189 | target.setName(source.name()); | ||
190 | target.setFile(source.file()); | ||
191 | target.setLinkFile(source.linkFile()); | ||
192 | target.setComment(source.comment()); | ||
193 | target.setType(source.type()); | ||
194 | target.setCategories(source.categories()); | ||
195 | } | ||
196 | |||
197 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) | 191 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) |
198 | { | 192 | { |
199 | selectorHide(); | 193 | selectorHide(); |
200 | 194 | ||
201 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 195 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
202 | copyDocLnk(lnkDoc, currentDoc); | 196 | if (currentDoc) delete currentDoc; |
197 | currentDoc = new DocLnk(lnkDoc); | ||
203 | listSheets.clear(); | 198 | listSheets.clear(); |
204 | comboSheets->clear(); | 199 | comboSheets->clear(); |
205 | 200 | ||
206 | typeSheet *newSheet=createNewSheet(); | 201 | typeSheet *newSheet=createNewSheet(); |
207 | newSheet->data.setAutoDelete(TRUE); | 202 | newSheet->data.setAutoDelete(TRUE); |
208 | sheet->setName(newSheet->name); | 203 | sheet->setName(newSheet->name); |
209 | sheet->setSheetData(&newSheet->data); | 204 | sheet->setSheetData(&newSheet->data); |
210 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) | 205 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) |
211 | createNewSheet(); | 206 | createNewSheet(); |
212 | documentModified=FALSE; | 207 | documentModified=FALSE; |
213 | } | 208 | } |
214 | 209 | ||
215 | void MainWindow::closeEvent(QCloseEvent *e) | 210 | void MainWindow::closeEvent(QCloseEvent *e) |
216 | { | 211 | { |
217 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); | 212 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); |
218 | else e->accept(); | 213 | else e->accept(); |
219 | } | 214 | } |
220 | 215 | ||
221 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) | 216 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) |
222 | { | 217 | { |
223 | selectorHide(); | 218 | selectorHide(); |
224 | 219 | ||
225 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 220 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
226 | copyDocLnk(lnkDoc, currentDoc); | 221 | if (currentDoc) delete currentDoc; |
222 | currentDoc = new DocLnk(lnkDoc); | ||
227 | listSheets.clear(); | 223 | listSheets.clear(); |
228 | comboSheets->clear(); | 224 | comboSheets->clear(); |
229 | 225 | ||
230 | documentOpen(lnkDoc); | 226 | documentOpen(lnkDoc); |
231 | documentModified=FALSE; | 227 | documentModified=FALSE; |
232 | } | 228 | } |
233 | 229 | ||
234 | void MainWindow::selectorShow() | 230 | void MainWindow::selectorShow() |
235 | { | 231 | { |
236 | sheet->hide(); | 232 | sheet->hide(); |
237 | setCentralWidget(fileSelector); | 233 | setCentralWidget(fileSelector); |
238 | fileSelector->show(); | 234 | fileSelector->show(); |
239 | fileSelector->reread(); | 235 | fileSelector->reread(); |
240 | } | 236 | } |
241 | 237 | ||
242 | void MainWindow::selectorHide() | 238 | void MainWindow::selectorHide() |
243 | { | 239 | { |
244 | fileSelector->hide(); | 240 | fileSelector->hide(); |
245 | setCentralWidget(sheet); | 241 | setCentralWidget(sheet); |
246 | sheet->show(); | 242 | sheet->show(); |
247 | } | 243 | } |
248 | 244 | ||
249 | void MainWindow::slotFileNew() | 245 | void MainWindow::slotFileNew() |
250 | { | 246 | { |
251 | selectorFileNew(DocLnk()); | 247 | selectorFileNew(DocLnk()); |
252 | } | 248 | } |
253 | 249 | ||
254 | void MainWindow::slotFileOpen() | 250 | void MainWindow::slotFileOpen() |
255 | { | 251 | { |
256 | selectorShow(); | 252 | selectorShow(); |
257 | } | 253 | } |
258 | 254 | ||
259 | void MainWindow::slotFileSave() | 255 | void MainWindow::slotFileSave() |
260 | { | 256 | { |
261 | saveCurrentFile(FALSE); | 257 | saveCurrentFile(FALSE); |
262 | } | 258 | } |
263 | 259 | ||
264 | void MainWindow::setDocument(const QString &applnk_filename) | 260 | void MainWindow::setDocument(const QString &applnk_filename) |
265 | { | 261 | { |
266 | selectorFileOpen(DocLnk(applnk_filename)); | 262 | selectorFileOpen(DocLnk(applnk_filename)); |
267 | } | 263 | } |
268 | 264 | ||
269 | void MainWindow::initActions() | 265 | void MainWindow::initActions() |
270 | { | 266 | { |
271 | fileNew=new QAction(tr("New File"), QPixmap(file_new_xpm), tr("&New"), 0, this); | 267 | fileNew=new QAction(tr("New File"), QPixmap(file_new_xpm), tr("&New"), 0, this); |
272 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); | 268 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); |
273 | fileOpen=new QAction(tr("Open File"), QPixmap(file_open_xpm), tr("&Open"), 0, this); | 269 | fileOpen=new QAction(tr("Open File"), QPixmap(file_open_xpm), tr("&Open"), 0, this); |
274 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); | 270 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); |
275 | fileSave=new QAction(tr("Save File"), QPixmap(file_save_xpm), tr("&Save"), 0, this); | 271 | fileSave=new QAction(tr("Save File"), QPixmap(file_save_xpm), tr("&Save"), 0, this); |
276 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); | 272 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); |
277 | fileSaveAs=new QAction(tr("Save File As"), QPixmap(file_save_xpm), tr("Save &As"), 0, this); | 273 | fileSaveAs=new QAction(tr("Save File As"), QPixmap(file_save_xpm), tr("Save &As"), 0, this); |
278 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); | 274 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); |
279 | fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); | 275 | fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); |
280 | connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); | 276 | connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); |
281 | 277 | ||
282 | helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); | 278 | helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); |
283 | connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); | 279 | connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); |
284 | helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); | 280 | helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); |
285 | connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); | 281 | connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); |
286 | 282 | ||
287 | editAccept=new QAction(tr("Accept"), QPixmap(edit_accept_xpm), tr("&Accept"), 0, this); | 283 | editAccept=new QAction(tr("Accept"), QPixmap(edit_accept_xpm), tr("&Accept"), 0, this); |
288 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); | 284 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); |
289 | editCancel=new QAction(tr("Cancel"), QPixmap(edit_cancel_xpm), tr("&Cancel"), 0, this); | 285 | editCancel=new QAction(tr("Cancel"), QPixmap(edit_cancel_xpm), tr("&Cancel"), 0, this); |
290 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); | 286 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); |
291 | editCellSelect=new QAction(tr("Cell Selector"), QPixmap(cell_select_xpm), tr("Cell &Selector"), 0, this); | 287 | editCellSelect=new QAction(tr("Cell Selector"), QPixmap(cell_select_xpm), tr("Cell &Selector"), 0, this); |
292 | editCellSelect->setToggleAction(TRUE); | 288 | editCellSelect->setToggleAction(TRUE); |
293 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); | 289 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); |
294 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); | 290 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); |
295 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); | 291 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); |
296 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); | 292 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); |
297 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); | 293 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); |
298 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); | 294 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); |
299 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); | 295 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); |
300 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); | 296 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); |
301 | 297 | ||
302 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); | 298 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); |
303 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); | 299 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); |
304 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); | 300 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); |
305 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); | 301 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); |
306 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); | 302 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); |
307 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); | 303 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); |
308 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); | 304 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); |
309 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); | 305 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); |
310 | 306 | ||
311 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); | 307 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); |
312 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); | 308 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); |
313 | 309 | ||
314 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); | 310 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); |
315 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); | 311 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); |
316 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); | 312 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); |
317 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); | 313 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); |
318 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); | 314 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); |
319 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); | 315 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); |
320 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); | 316 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); |
321 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); | 317 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); |
322 | 318 | ||
323 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); | 319 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); |
324 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); | 320 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); |
325 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); | 321 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); |
326 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); | 322 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); |
327 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); | 323 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); |
328 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); | 324 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); |
329 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); | 325 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); |
330 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); | 326 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); |
331 | 327 | ||
332 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); | 328 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); |
333 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); | 329 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); |
334 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); | 330 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); |
335 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); | 331 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); |
336 | 332 | ||
337 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); | 333 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); |
338 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); | 334 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); |
339 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); | 335 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); |
340 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); | 336 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); |
341 | 337 | ||
342 | funcEqual=new QAction(tr("Equal To"), QPixmap(func_equal_xpm), tr("&Equal To"), 0, this); | 338 | funcEqual=new QAction(tr("Equal To"), QPixmap(func_equal_xpm), tr("&Equal To"), 0, this); |
343 | funcEqual->setToolTip("="); | 339 | funcEqual->setToolTip("="); |
344 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 340 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
345 | funcPlus=new QAction(tr("Addition"), QPixmap(func_plus_xpm), tr("&Addition"), 0, this); | 341 | funcPlus=new QAction(tr("Addition"), QPixmap(func_plus_xpm), tr("&Addition"), 0, this); |
346 | funcPlus->setToolTip("+"); | 342 | funcPlus->setToolTip("+"); |
347 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 343 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
348 | funcMinus=new QAction(tr("Subtraction"), QPixmap(func_minus_xpm), tr("&Subtraction"), 0, this); | 344 | funcMinus=new QAction(tr("Subtraction"), QPixmap(func_minus_xpm), tr("&Subtraction"), 0, this); |
349 | funcMinus->setToolTip("-"); | 345 | funcMinus->setToolTip("-"); |
350 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 346 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
351 | funcCross=new QAction(tr("Multiplication"), QPixmap(func_cross_xpm), tr("&Multiplication"), 0, this); | 347 | funcCross=new QAction(tr("Multiplication"), QPixmap(func_cross_xpm), tr("&Multiplication"), 0, this); |
352 | funcCross->setToolTip("*"); | 348 | funcCross->setToolTip("*"); |
353 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 349 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
354 | funcDivide=new QAction(tr("Division"), QPixmap(func_divide_xpm), tr("&Division"), 0, this); | 350 | funcDivide=new QAction(tr("Division"), QPixmap(func_divide_xpm), tr("&Division"), 0, this); |
355 | funcDivide->setToolTip("/"); | 351 | funcDivide->setToolTip("/"); |
356 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 352 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
357 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), QPixmap(func_paran_open_xpm), tr("&Open Paranthesis"), 0, this); | 353 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), QPixmap(func_paran_open_xpm), tr("&Open Paranthesis"), 0, this); |
358 | funcParanOpen->setToolTip("("); | 354 | funcParanOpen->setToolTip("("); |
359 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 355 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
360 | funcParanClose=new QAction(tr("Close Paranthesis"), QPixmap(func_paran_close_xpm), tr("&Close Paranthesis"), 0, this); | 356 | funcParanClose=new QAction(tr("Close Paranthesis"), QPixmap(func_paran_close_xpm), tr("&Close Paranthesis"), 0, this); |
361 | funcParanClose->setToolTip(")"); | 357 | funcParanClose->setToolTip(")"); |
362 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 358 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
363 | funcComma=new QAction(tr("Comma"), QPixmap(func_comma_xpm), tr("&Comma"), 0, this); | 359 | funcComma=new QAction(tr("Comma"), QPixmap(func_comma_xpm), tr("&Comma"), 0, this); |
364 | funcComma->setToolTip(","); | 360 | funcComma->setToolTip(","); |
365 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 361 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
366 | } | 362 | } |
367 | 363 | ||
368 | void MainWindow::initMenu() | 364 | void MainWindow::initMenu() |
369 | { | 365 | { |
370 | menu=new QPEMenuBar(this); | 366 | menu=new QPEMenuBar(this); |
371 | 367 | ||
372 | menuFile=new QPopupMenu; | 368 | menuFile=new QPopupMenu; |
373 | fileNew->addTo(menuFile); | 369 | fileNew->addTo(menuFile); |
374 | fileOpen->addTo(menuFile); | 370 | fileOpen->addTo(menuFile); |
375 | fileSave->addTo(menuFile); | 371 | fileSave->addTo(menuFile); |
376 | fileSaveAs->addTo(menuFile); | 372 | fileSaveAs->addTo(menuFile); |
377 | menuFile->insertSeparator(); | 373 | menuFile->insertSeparator(); |
378 | fileQuit->addTo(menuFile); | 374 | fileQuit->addTo(menuFile); |
379 | menu->insertItem(tr("&File"), menuFile); | 375 | menu->insertItem(tr("&File"), menuFile); |
380 | 376 | ||
381 | menuEdit=new QPopupMenu; | 377 | menuEdit=new QPopupMenu; |
382 | editAccept->addTo(menuEdit); | 378 | editAccept->addTo(menuEdit); |
383 | editCancel->addTo(menuEdit); | 379 | editCancel->addTo(menuEdit); |
384 | editCellSelect->addTo(menuEdit); | 380 | editCellSelect->addTo(menuEdit); |
385 | menuEdit->insertSeparator(); | 381 | menuEdit->insertSeparator(); |
386 | editCut->addTo(menuEdit); | 382 | editCut->addTo(menuEdit); |
387 | editCopy->addTo(menuEdit); | 383 | editCopy->addTo(menuEdit); |
388 | editPaste->addTo(menuEdit); | 384 | editPaste->addTo(menuEdit); |
389 | editPasteContents->addTo(menuEdit); | 385 | editPasteContents->addTo(menuEdit); |
390 | editClear->addTo(menuEdit); | 386 | editClear->addTo(menuEdit); |
391 | menu->insertItem(tr("&Edit"), menuEdit); | 387 | menu->insertItem(tr("&Edit"), menuEdit); |
392 | 388 | ||
393 | menuInsert=new QPopupMenu; | 389 | menuInsert=new QPopupMenu; |
394 | menu->insertItem(tr("&Insert"), menuInsert); | 390 | menu->insertItem(tr("&Insert"), menuInsert); |
395 | 391 | ||
396 | menuFormat=new QPopupMenu; | 392 | menuFormat=new QPopupMenu; |
397 | formatCells->addTo(menuFormat); | 393 | formatCells->addTo(menuFormat); |
398 | menu->insertItem(tr("&Format"), menuFormat); | 394 | menu->insertItem(tr("&Format"), menuFormat); |
399 | 395 | ||
400 | menuData=new QPopupMenu; | 396 | menuData=new QPopupMenu; |
401 | dataSort->addTo(menuData); | 397 | dataSort->addTo(menuData); |
402 | dataFindReplace->addTo(menuData); | 398 | dataFindReplace->addTo(menuData); |
403 | menu->insertItem(tr("&Data"), menuData); | 399 | menu->insertItem(tr("&Data"), menuData); |
404 | 400 | ||
405 | menuHelp=new QPopupMenu; | 401 | menuHelp=new QPopupMenu; |
406 | helpGeneral->addTo(menuHelp); | 402 | helpGeneral->addTo(menuHelp); |
407 | helpAbout->addTo(menuHelp); | 403 | helpAbout->addTo(menuHelp); |
408 | menu->insertItem(tr("&Help"), menuHelp); | 404 | menu->insertItem(tr("&Help"), menuHelp); |
409 | 405 | ||
410 | submenuRow=new QPopupMenu; | 406 | submenuRow=new QPopupMenu; |
411 | rowHeight->addTo(submenuRow); | 407 | rowHeight->addTo(submenuRow); |
412 | rowAdjust->addTo(submenuRow); | 408 | rowAdjust->addTo(submenuRow); |
413 | rowShow->addTo(submenuRow); | 409 | rowShow->addTo(submenuRow); |
414 | rowHide->addTo(submenuRow); | 410 | rowHide->addTo(submenuRow); |
415 | menuFormat->insertItem(tr("&Row"), submenuRow); | 411 | menuFormat->insertItem(tr("&Row"), submenuRow); |
416 | 412 | ||
417 | submenuCol=new QPopupMenu; | 413 | submenuCol=new QPopupMenu; |
418 | colWidth->addTo(submenuCol); | 414 | colWidth->addTo(submenuCol); |
419 | colAdjust->addTo(submenuCol); | 415 | colAdjust->addTo(submenuCol); |
420 | colShow->addTo(submenuCol); | 416 | colShow->addTo(submenuCol); |
421 | colHide->addTo(submenuCol); | 417 | colHide->addTo(submenuCol); |
422 | menuFormat->insertItem(tr("Colum&n"), submenuCol); | 418 | menuFormat->insertItem(tr("Colum&n"), submenuCol); |
423 | 419 | ||
424 | submenuSheet=new QPopupMenu; | 420 | submenuSheet=new QPopupMenu; |
425 | sheetRename->addTo(submenuSheet); | 421 | sheetRename->addTo(submenuSheet); |
426 | sheetRemove->addTo(submenuSheet); | 422 | sheetRemove->addTo(submenuSheet); |
427 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); | 423 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); |
428 | 424 | ||
429 | submenuFunc=new QPopupMenu; | 425 | submenuFunc=new QPopupMenu; |
430 | menuInsert->insertItem(tr("&Function"), submenuFunc); | 426 | menuInsert->insertItem(tr("&Function"), submenuFunc); |
431 | 427 | ||
432 | submenuFuncStd=new QPopupMenu; | 428 | submenuFuncStd=new QPopupMenu; |
433 | funcPlus->addTo(submenuFuncStd); | 429 | funcPlus->addTo(submenuFuncStd); |
434 | funcMinus->addTo(submenuFuncStd); | 430 | funcMinus->addTo(submenuFuncStd); |
435 | funcCross->addTo(submenuFuncStd); | 431 | funcCross->addTo(submenuFuncStd); |
436 | funcDivide->addTo(submenuFuncStd); | 432 | funcDivide->addTo(submenuFuncStd); |
437 | submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); | 433 | submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); |
438 | 434 | ||
439 | submenuFuncMath=new QPopupMenu; | 435 | submenuFuncMath=new QPopupMenu; |
440 | addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); | 436 | addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); |
441 | addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); | 437 | addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); |
442 | submenuFuncMath->insertSeparator(); | 438 | submenuFuncMath->insertSeparator(); |
443 | addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); | 439 | addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); |
444 | addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); | 440 | addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); |
445 | addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); | 441 | addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); |
446 | addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); | 442 | addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); |
447 | addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); | 443 | addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); |
448 | addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); | 444 | addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); |
449 | addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); | 445 | addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); |
450 | submenuFuncMath->insertSeparator(); | 446 | submenuFuncMath->insertSeparator(); |
451 | addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); | 447 | addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); |
452 | addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); | 448 | addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); |
453 | addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); | 449 | addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); |
454 | submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); | 450 | submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); |
455 | 451 | ||
456 | submenuFuncStat=new QPopupMenu; | 452 | submenuFuncStat=new QPopupMenu; |
457 | addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); | 453 | addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); |
458 | addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); | 454 | addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); |
459 | addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); | 455 | addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); |
460 | addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); | 456 | addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); |
461 | submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); | 457 | submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); |
462 | 458 | ||
463 | menuInsert->insertSeparator(); | 459 | menuInsert->insertSeparator(); |
464 | insertCells->addTo(menuInsert); | 460 | insertCells->addTo(menuInsert); |
465 | insertRows->addTo(menuInsert); | 461 | insertRows->addTo(menuInsert); |
466 | insertCols->addTo(menuInsert); | 462 | insertCols->addTo(menuInsert); |
467 | insertSheets->addTo(menuInsert); | 463 | insertSheets->addTo(menuInsert); |
468 | } | 464 | } |
469 | 465 | ||
470 | void MainWindow::initStandardToolbar() | 466 | void MainWindow::initStandardToolbar() |
471 | { | 467 | { |
472 | toolbarStandard=new QPEToolBar(this); | 468 | toolbarStandard=new QPEToolBar(this); |
473 | toolbarStandard->setHorizontalStretchable(TRUE); | 469 | toolbarStandard->setHorizontalStretchable(TRUE); |
474 | moveToolBar(toolbarStandard, Top); | 470 | moveToolBar(toolbarStandard, Top); |
475 | 471 | ||
476 | fileNew->addTo(toolbarStandard); | 472 | fileNew->addTo(toolbarStandard); |
477 | fileOpen->addTo(toolbarStandard); | 473 | fileOpen->addTo(toolbarStandard); |
478 | fileSave->addTo(toolbarStandard); | 474 | fileSave->addTo(toolbarStandard); |
479 | 475 | ||
480 | comboSheets=new QComboBox(toolbarStandard); | 476 | comboSheets=new QComboBox(toolbarStandard); |
481 | toolbarStandard->setStretchableWidget(comboSheets); | 477 | toolbarStandard->setStretchableWidget(comboSheets); |
482 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 478 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); |
@@ -501,350 +497,352 @@ void MainWindow::initFunctionsToolbar() | |||
501 | toolFunction->setPixmap(func_func_xpm); | 497 | toolFunction->setPixmap(func_func_xpm); |
502 | toolFunction->setTextLabel(tr("Functions")); | 498 | toolFunction->setTextLabel(tr("Functions")); |
503 | toolFunction->setPopup(submenuFunc); | 499 | toolFunction->setPopup(submenuFunc); |
504 | toolFunction->setPopupDelay(0); | 500 | toolFunction->setPopupDelay(0); |
505 | } | 501 | } |
506 | 502 | ||
507 | void MainWindow::initEditToolbar() | 503 | void MainWindow::initEditToolbar() |
508 | { | 504 | { |
509 | toolbarEdit=new QPEToolBar(this); | 505 | toolbarEdit=new QPEToolBar(this); |
510 | toolbarEdit->setHorizontalStretchable(TRUE); | 506 | toolbarEdit->setHorizontalStretchable(TRUE); |
511 | moveToolBar(toolbarEdit, Bottom); | 507 | moveToolBar(toolbarEdit, Bottom); |
512 | 508 | ||
513 | editAccept->addTo(toolbarEdit); | 509 | editAccept->addTo(toolbarEdit); |
514 | editCancel->addTo(toolbarEdit); | 510 | editCancel->addTo(toolbarEdit); |
515 | 511 | ||
516 | editData=new QLineEdit(toolbarEdit); | 512 | editData=new QLineEdit(toolbarEdit); |
517 | toolbarEdit->setStretchableWidget(editData); | 513 | toolbarEdit->setStretchableWidget(editData); |
518 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 514 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
519 | 515 | ||
520 | editCellSelect->addTo(toolbarEdit); | 516 | editCellSelect->addTo(toolbarEdit); |
521 | } | 517 | } |
522 | 518 | ||
523 | void MainWindow::slotHelpGeneral() | 519 | void MainWindow::slotHelpGeneral() |
524 | { | 520 | { |
525 | if (QFile::exists(helpFile)) | 521 | if (QFile::exists(helpFile)) |
526 | { | 522 | { |
527 | QCopEnvelope e("QPE/Application/helpbrowser", "showFile(QString)"); | 523 | QCopEnvelope e("QPE/Application/helpbrowser", "showFile(QString)"); |
528 | e << helpFile; | 524 | e << helpFile; |
529 | } | 525 | } |
530 | else | 526 | else |
531 | QMessageBox::critical(this, tr("Error"), tr("Help file not found!")); | 527 | QMessageBox::critical(this, tr("Error"), tr("Help file not found!")); |
532 | } | 528 | } |
533 | 529 | ||
534 | void MainWindow::slotHelpAbout() | 530 | void MainWindow::slotHelpAbout() |
535 | { | 531 | { |
536 | QDialog dialogAbout(this, 0, TRUE); | 532 | QDialog dialogAbout(this, 0, TRUE); |
537 | dialogAbout.resize(width()-40, height()-80); | 533 | dialogAbout.resize(width()-40, height()-80); |
538 | dialogAbout.setCaption(tr("About Opie Sheet")); | 534 | dialogAbout.setCaption(tr("About Opie Sheet")); |
539 | 535 | ||
540 | 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); | 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); |
541 | label.setGeometry(dialogAbout.rect()); | 537 | label.setGeometry(dialogAbout.rect()); |
542 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 538 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
543 | 539 | ||
544 | dialogAbout.exec(); | 540 | dialogAbout.exec(); |
545 | } | 541 | } |
546 | 542 | ||
547 | void MainWindow::initSheet() | 543 | void MainWindow::initSheet() |
548 | { | 544 | { |
549 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 545 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
550 | setCentralWidget(sheet); | 546 | setCentralWidget(sheet); |
551 | 547 | ||
552 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 548 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); |
553 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 549 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); |
554 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 550 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
555 | 551 | ||
556 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 552 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
557 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 553 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
558 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 554 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
559 | } | 555 | } |
560 | 556 | ||
561 | void MainWindow::slotEditAccept() | 557 | void MainWindow::slotEditAccept() |
562 | { | 558 | { |
563 | sheet->setData(editData->text()); | 559 | sheet->setData(editData->text()); |
564 | } | 560 | } |
565 | 561 | ||
566 | void MainWindow::slotEditCancel() | 562 | void MainWindow::slotEditCancel() |
567 | { | 563 | { |
568 | editData->setText(sheet->getData()); | 564 | editData->setText(sheet->getData()); |
569 | } | 565 | } |
570 | 566 | ||
571 | void MainWindow::slotCellSelect(bool lock) | 567 | void MainWindow::slotCellSelect(bool lock) |
572 | { | 568 | { |
573 | sheet->lockClicks(lock); | 569 | sheet->lockClicks(lock); |
574 | } | 570 | } |
575 | 571 | ||
576 | void MainWindow::addToData(const QString &data) | 572 | void MainWindow::addToData(const QString &data) |
577 | { | 573 | { |
578 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 574 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
579 | } | 575 | } |
580 | 576 | ||
581 | void MainWindow::slotFuncOutput() | 577 | void MainWindow::slotFuncOutput() |
582 | { | 578 | { |
583 | if (sender()->isA("QAction")) | 579 | if (sender()->isA("QAction")) |
584 | addToData(((QAction *)sender())->toolTip()); | 580 | addToData(((QAction *)sender())->toolTip()); |
585 | } | 581 | } |
586 | 582 | ||
587 | void MainWindow::slotInsertRows() | 583 | void MainWindow::slotInsertRows() |
588 | { | 584 | { |
589 | NumberDialog dialogNumber(this); | 585 | NumberDialog dialogNumber(this); |
590 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 586 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
591 | sheet->insertRows(dialogNumber.getValue()); | 587 | sheet->insertRows(dialogNumber.getValue()); |
592 | } | 588 | } |
593 | 589 | ||
594 | void MainWindow::slotInsertCols() | 590 | void MainWindow::slotInsertCols() |
595 | { | 591 | { |
596 | NumberDialog dialogNumber(this); | 592 | NumberDialog dialogNumber(this); |
597 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 593 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
598 | sheet->insertColumns(dialogNumber.getValue()); | 594 | sheet->insertColumns(dialogNumber.getValue()); |
599 | } | 595 | } |
600 | 596 | ||
601 | void MainWindow::slotInsertSheets() | 597 | void MainWindow::slotInsertSheets() |
602 | { | 598 | { |
603 | NumberDialog dialogNumber(this); | 599 | NumberDialog dialogNumber(this); |
604 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 600 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
605 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 601 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
606 | } | 602 | } |
607 | 603 | ||
608 | void MainWindow::slotCellClicked(const QString &cell) | 604 | void MainWindow::slotCellClicked(const QString &cell) |
609 | { | 605 | { |
610 | editCellSelect->setOn(FALSE); | 606 | editCellSelect->setOn(FALSE); |
611 | addToData(cell); | 607 | addToData(cell); |
612 | } | 608 | } |
613 | 609 | ||
614 | typeSheet *MainWindow::createNewSheet() | 610 | typeSheet *MainWindow::createNewSheet() |
615 | { | 611 | { |
616 | typeSheet *newSheet=new typeSheet; | 612 | typeSheet *newSheet=new typeSheet; |
617 | int currentNo=1, tempNo; | 613 | int currentNo=1, tempNo; |
618 | bool ok; | 614 | bool ok; |
619 | 615 | ||
620 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 616 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
621 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 617 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
622 | currentNo=tempNo+1; | 618 | currentNo=tempNo+1; |
623 | 619 | ||
624 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 620 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
625 | newSheet->data.setAutoDelete(TRUE); | 621 | newSheet->data.setAutoDelete(TRUE); |
626 | 622 | ||
627 | comboSheets->insertItem(newSheet->name); | 623 | comboSheets->insertItem(newSheet->name); |
628 | listSheets.append(newSheet); | 624 | listSheets.append(newSheet); |
629 | return newSheet; | 625 | return newSheet; |
630 | } | 626 | } |
631 | 627 | ||
632 | typeSheet *MainWindow::findSheet(const QString &name) | 628 | typeSheet *MainWindow::findSheet(const QString &name) |
633 | { | 629 | { |
634 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 630 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
635 | if (tempSheet->name==name) | 631 | if (tempSheet->name==name) |
636 | return tempSheet; | 632 | return tempSheet; |
637 | return NULL; | 633 | return NULL; |
638 | } | 634 | } |
639 | 635 | ||
640 | void MainWindow::slotSheetChanged(const QString &name) | 636 | void MainWindow::slotSheetChanged(const QString &name) |
641 | { | 637 | { |
642 | sheet->copySheetData(&findSheet(sheet->getName())->data); | 638 | sheet->copySheetData(&findSheet(sheet->getName())->data); |
643 | sheet->setName(name); | 639 | sheet->setName(name); |
644 | sheet->setSheetData(&findSheet(name)->data); | 640 | sheet->setSheetData(&findSheet(name)->data); |
645 | } | 641 | } |
646 | 642 | ||
647 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) | 643 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) |
648 | { | 644 | { |
649 | QAction *action=new QAction(text, menuText, 0, this); | 645 | QAction *action=new QAction(text, menuText, 0, this); |
650 | action->setToolTip(tip); | 646 | action->setToolTip(tip); |
651 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 647 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
652 | action->addTo(w); | 648 | action->addTo(w); |
653 | } | 649 | } |
654 | 650 | ||
655 | void MainWindow::slotFormatCells() | 651 | void MainWindow::slotFormatCells() |
656 | { | 652 | { |
657 | CellFormat dialogCellFormat(this); | 653 | CellFormat dialogCellFormat(this); |
658 | dialogCellFormat.showMaximized(); | 654 | dialogCellFormat.showMaximized(); |
659 | dialogCellFormat.exec(sheet); | 655 | dialogCellFormat.exec(sheet); |
660 | } | 656 | } |
661 | 657 | ||
662 | void MainWindow::slotEditPaste() | 658 | void MainWindow::slotEditPaste() |
663 | { | 659 | { |
664 | sheet->editPaste(); | 660 | sheet->editPaste(); |
665 | } | 661 | } |
666 | 662 | ||
667 | void MainWindow::slotEditPasteContents() | 663 | void MainWindow::slotEditPasteContents() |
668 | { | 664 | { |
669 | sheet->editPaste(TRUE); | 665 | sheet->editPaste(TRUE); |
670 | } | 666 | } |
671 | 667 | ||
672 | void MainWindow::slotRowHeight() | 668 | void MainWindow::slotRowHeight() |
673 | { | 669 | { |
674 | int row1, row2, col1, col2; | 670 | int row1, row2, col1, col2; |
675 | sheet->getSelection(&row1, &col1, &row2, &col2); | 671 | sheet->getSelection(&row1, &col1, &row2, &col2); |
676 | 672 | ||
677 | NumberDialog dialogNumber(this); | 673 | NumberDialog dialogNumber(this); |
678 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) | 674 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) |
679 | { | 675 | { |
680 | int newHeight=dialogNumber.getValue(), row; | 676 | int newHeight=dialogNumber.getValue(), row; |
681 | for (row=row1; row<=row2; ++row) | 677 | for (row=row1; row<=row2; ++row) |
682 | sheet->setRowHeight(row, newHeight); | 678 | sheet->setRowHeight(row, newHeight); |
683 | } | 679 | } |
684 | } | 680 | } |
685 | 681 | ||
686 | void MainWindow::slotRowAdjust() | 682 | void MainWindow::slotRowAdjust() |
687 | { | 683 | { |
688 | int row1, row2, col1, col2; | 684 | int row1, row2, col1, col2; |
689 | sheet->getSelection(&row1, &col1, &row2, &col2); | 685 | sheet->getSelection(&row1, &col1, &row2, &col2); |
690 | 686 | ||
691 | for (int row=row1; row<=row2; ++row) | 687 | for (int row=row1; row<=row2; ++row) |
692 | sheet->adjustRow(row); | 688 | sheet->adjustRow(row); |
693 | } | 689 | } |
694 | 690 | ||
695 | void MainWindow::slotRowShow() | 691 | void MainWindow::slotRowShow() |
696 | { | 692 | { |
697 | int row1, row2, col1, col2; | 693 | int row1, row2, col1, col2; |
698 | sheet->getSelection(&row1, &col1, &row2, &col2); | 694 | sheet->getSelection(&row1, &col1, &row2, &col2); |
699 | 695 | ||
700 | for (int row=row1; row<=row2; ++row) | 696 | for (int row=row1; row<=row2; ++row) |
701 | sheet->showRow(row); | 697 | sheet->showRow(row); |
702 | } | 698 | } |
703 | 699 | ||
704 | void MainWindow::slotRowHide() | 700 | void MainWindow::slotRowHide() |
705 | { | 701 | { |
706 | int row1, row2, col1, col2; | 702 | int row1, row2, col1, col2; |
707 | sheet->getSelection(&row1, &col1, &row2, &col2); | 703 | sheet->getSelection(&row1, &col1, &row2, &col2); |
708 | 704 | ||
709 | for (int row=row1; row<=row2; ++row) | 705 | for (int row=row1; row<=row2; ++row) |
710 | sheet->hideRow(row); | 706 | sheet->hideRow(row); |
711 | } | 707 | } |
712 | 708 | ||
713 | void MainWindow::slotColumnWidth() | 709 | void MainWindow::slotColumnWidth() |
714 | { | 710 | { |
715 | int row1, row2, col1, col2; | 711 | int row1, row2, col1, col2; |
716 | sheet->getSelection(&row1, &col1, &row2, &col2); | 712 | sheet->getSelection(&row1, &col1, &row2, &col2); |
717 | 713 | ||
718 | NumberDialog dialogNumber(this); | 714 | NumberDialog dialogNumber(this); |
719 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) | 715 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) |
720 | { | 716 | { |
721 | int newWidth=dialogNumber.getValue(), col; | 717 | int newWidth=dialogNumber.getValue(), col; |
722 | for (col=col1; col<=col2; ++col) | 718 | for (col=col1; col<=col2; ++col) |
723 | sheet->setColumnWidth(col, newWidth); | 719 | sheet->setColumnWidth(col, newWidth); |
724 | } | 720 | } |
725 | } | 721 | } |
726 | 722 | ||
727 | void MainWindow::slotColumnAdjust() | 723 | void MainWindow::slotColumnAdjust() |
728 | { | 724 | { |
729 | int row1, row2, col1, col2; | 725 | int row1, row2, col1, col2; |
730 | sheet->getSelection(&row1, &col1, &row2, &col2); | 726 | sheet->getSelection(&row1, &col1, &row2, &col2); |
731 | 727 | ||
732 | for (int col=col1; col<=col2; ++col) | 728 | for (int col=col1; col<=col2; ++col) |
733 | sheet->adjustColumn(col); | 729 | sheet->adjustColumn(col); |
734 | } | 730 | } |
735 | 731 | ||
736 | void MainWindow::slotColumnShow() | 732 | void MainWindow::slotColumnShow() |
737 | { | 733 | { |
738 | int row1, row2, col1, col2; | 734 | int row1, row2, col1, col2; |
739 | sheet->getSelection(&row1, &col1, &row2, &col2); | 735 | sheet->getSelection(&row1, &col1, &row2, &col2); |
740 | 736 | ||
741 | for (int col=col1; col<=col2; ++col) | 737 | for (int col=col1; col<=col2; ++col) |
742 | sheet->showColumn(col); | 738 | sheet->showColumn(col); |
743 | } | 739 | } |
744 | 740 | ||
745 | void MainWindow::slotColumnHide() | 741 | void MainWindow::slotColumnHide() |
746 | { | 742 | { |
747 | int row1, row2, col1, col2; | 743 | int row1, row2, col1, col2; |
748 | sheet->getSelection(&row1, &col1, &row2, &col2); | 744 | sheet->getSelection(&row1, &col1, &row2, &col2); |
749 | 745 | ||
750 | for (int col=col1; col<=col2; ++col) | 746 | for (int col=col1; col<=col2; ++col) |
751 | sheet->hideColumn(col); | 747 | sheet->hideColumn(col); |
752 | } | 748 | } |
753 | 749 | ||
754 | void MainWindow::slotFileSaveAs() | 750 | void MainWindow::slotFileSaveAs() |
755 | { | 751 | { |
756 | TextDialog dialogText(this); | 752 | TextDialog dialogText(this); |
757 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc.name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 753 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
758 | 754 | ||
759 | currentDoc.setName(dialogText.getValue()); | 755 | currentDoc->setName(dialogText.getValue()); |
756 | currentDoc->setFile(QString::null); | ||
757 | currentDoc->setLinkFile(QString::null); | ||
760 | documentSave(currentDoc); | 758 | documentSave(currentDoc); |
761 | } | 759 | } |
762 | 760 | ||
763 | void MainWindow::slotSheetRename() | 761 | void MainWindow::slotSheetRename() |
764 | { | 762 | { |
765 | TextDialog dialogText(this); | 763 | TextDialog dialogText(this); |
766 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 764 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
767 | QString newName=dialogText.getValue(); | 765 | QString newName=dialogText.getValue(); |
768 | 766 | ||
769 | typeSheet *tempSheet=findSheet(newName); | 767 | typeSheet *tempSheet=findSheet(newName); |
770 | if (tempSheet) | 768 | if (tempSheet) |
771 | { | 769 | { |
772 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); | 770 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); |
773 | return; | 771 | return; |
774 | } | 772 | } |
775 | 773 | ||
776 | tempSheet=findSheet(sheet->getName()); | 774 | tempSheet=findSheet(sheet->getName()); |
777 | for (int i=0; i<comboSheets->count(); ++i) | 775 | for (int i=0; i<comboSheets->count(); ++i) |
778 | if (comboSheets->text(i)==tempSheet->name) | 776 | if (comboSheets->text(i)==tempSheet->name) |
779 | { | 777 | { |
780 | comboSheets->changeItem(newName, i); | 778 | comboSheets->changeItem(newName, i); |
781 | break; | 779 | break; |
782 | } | 780 | } |
783 | tempSheet->name=newName; | 781 | tempSheet->name=newName; |
784 | sheet->setName(newName); | 782 | sheet->setName(newName); |
785 | } | 783 | } |
786 | 784 | ||
787 | void MainWindow::slotSheetRemove() | 785 | void MainWindow::slotSheetRemove() |
788 | { | 786 | { |
789 | if (comboSheets->count()<2) | 787 | if (comboSheets->count()<2) |
790 | { | 788 | { |
791 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); | 789 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); |
792 | return; | 790 | return; |
793 | } | 791 | } |
794 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) | 792 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) |
795 | { | 793 | { |
796 | typeSheet *tempSheet=findSheet(sheet->getName()); | 794 | typeSheet *tempSheet=findSheet(sheet->getName()); |
797 | for (int i=0; i<comboSheets->count(); ++i) | 795 | for (int i=0; i<comboSheets->count(); ++i) |
798 | if (comboSheets->text(i)==tempSheet->name) | 796 | if (comboSheets->text(i)==tempSheet->name) |
799 | { | 797 | { |
800 | comboSheets->removeItem(i); | 798 | comboSheets->removeItem(i); |
801 | break; | 799 | break; |
802 | } | 800 | } |
803 | comboSheets->setCurrentItem(0); | 801 | comboSheets->setCurrentItem(0); |
804 | slotSheetChanged(comboSheets->currentText()); | 802 | slotSheetChanged(comboSheets->currentText()); |
805 | listSheets.remove(tempSheet); | 803 | listSheets.remove(tempSheet); |
806 | } | 804 | } |
807 | } | 805 | } |
808 | 806 | ||
809 | void MainWindow::slotDataSort() | 807 | void MainWindow::slotDataSort() |
810 | { | 808 | { |
811 | SortDialog dialogSort(this); | 809 | SortDialog dialogSort(this); |
812 | dialogSort.showMaximized(); | 810 | dialogSort.showMaximized(); |
813 | dialogSort.exec(sheet); | 811 | dialogSort.exec(sheet); |
814 | } | 812 | } |
815 | 813 | ||
816 | void MainWindow::slotDocModified() | 814 | void MainWindow::slotDocModified() |
817 | { | 815 | { |
818 | documentModified=TRUE; | 816 | documentModified=TRUE; |
819 | } | 817 | } |
820 | 818 | ||
821 | void MainWindow::slotInsertCells() | 819 | void MainWindow::slotInsertCells() |
822 | { | 820 | { |
823 | QDialog dialogInsert(this, 0, TRUE); | 821 | QDialog dialogInsert(this, 0, TRUE); |
824 | dialogInsert.resize(180, 130); | 822 | dialogInsert.resize(180, 130); |
825 | dialogInsert.setCaption(tr("Insert Cells")); | 823 | dialogInsert.setCaption(tr("Insert Cells")); |
826 | 824 | ||
827 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); | 825 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); |
828 | group->setGeometry(10, 10, 160, 110); | 826 | group->setGeometry(10, 10, 160, 110); |
829 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); | 827 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); |
830 | radio=new QRadioButton(tr("Shift cells &right"), group); | 828 | radio=new QRadioButton(tr("Shift cells &right"), group); |
831 | radio=new QRadioButton(tr("Entire ro&w"), group); | 829 | radio=new QRadioButton(tr("Entire ro&w"), group); |
832 | radio=new QRadioButton(tr("Entire &column"), group); | 830 | radio=new QRadioButton(tr("Entire &column"), group); |
833 | group->setButton(0); | 831 | group->setButton(0); |
834 | 832 | ||
835 | if (dialogInsert.exec()==QDialog::Accepted) | 833 | if (dialogInsert.exec()==QDialog::Accepted) |
836 | switch (group->id(group->selected())) | 834 | switch (group->id(group->selected())) |
837 | { | 835 | { |
838 | case 0: sheet->insertRows(1, FALSE); break; | 836 | case 0: sheet->insertRows(1, FALSE); break; |
839 | case 1: sheet->insertColumns(1, FALSE); break; | 837 | case 1: sheet->insertColumns(1, FALSE); break; |
840 | case 2: sheet->insertRows(1, TRUE); break; | 838 | case 2: sheet->insertRows(1, TRUE); break; |
841 | case 3: sheet->insertColumns(1, TRUE); break; | 839 | case 3: sheet->insertColumns(1, TRUE); break; |
842 | } | 840 | } |
843 | } | 841 | } |
844 | 842 | ||
845 | void MainWindow::slotDataFindReplace() | 843 | void MainWindow::slotDataFindReplace() |
846 | { | 844 | { |
847 | FindDialog dialogFind(this); | 845 | FindDialog dialogFind(this); |
848 | dialogFind.showMaximized(); | 846 | dialogFind.showMaximized(); |
849 | dialogFind.exec(sheet); | 847 | dialogFind.exec(sheet); |
850 | } | 848 | } |
diff --git a/noncore/apps/opie-sheet/mainwindow.h b/noncore/apps/opie-sheet/mainwindow.h index 554e6f6..d68e25c 100644 --- a/noncore/apps/opie-sheet/mainwindow.h +++ b/noncore/apps/opie-sheet/mainwindow.h | |||
@@ -1,134 +1,133 @@ | |||
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 | #ifndef MAINWINDOW_H | 15 | #ifndef MAINWINDOW_H |
16 | #define MAINWINDOW_H | 16 | #define MAINWINDOW_H |
17 | 17 | ||
18 | #include <qpe/applnk.h> | 18 | #include <qpe/applnk.h> |
19 | #include <qpe/fileselector.h> | 19 | #include <qpe/fileselector.h> |
20 | #include <qpe/qpemenubar.h> | 20 | #include <qpe/qpemenubar.h> |
21 | #include <qpe/qpetoolbar.h> | 21 | #include <qpe/qpetoolbar.h> |
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | #include <qbutton.h> | 25 | #include <qbutton.h> |
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | 28 | ||
29 | #include "sheet.h" | 29 | #include "sheet.h" |
30 | 30 | ||
31 | typedef struct typeSheet | 31 | typedef struct typeSheet |
32 | { | 32 | { |
33 | QString name; | 33 | QString name; |
34 | QList<typeCellData> data; | 34 | QList<typeCellData> data; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | class MainWindow: public QMainWindow | 37 | class MainWindow: public QMainWindow |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | // QPE objects | 41 | // QPE objects |
42 | DocLnk currentDoc; | 42 | DocLnk* currentDoc; |
43 | QPEMenuBar *menu; | 43 | QPEMenuBar *menu; |
44 | QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; | 44 | QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; |
45 | FileSelector *fileSelector; | 45 | FileSelector *fileSelector; |
46 | 46 | ||
47 | // QT objects | 47 | // QT objects |
48 | QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, | 48 | QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, |
49 | *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, | 49 | *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, |
50 | *submenuRow, *submenuCol, *submenuSheet; | 50 | *submenuRow, *submenuCol, *submenuSheet; |
51 | QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, | 51 | QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, |
52 | *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, | 52 | *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, |
53 | *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, | 53 | *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, |
54 | *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, | 54 | *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, |
55 | *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; | 55 | *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; |
56 | QLineEdit *editData; | 56 | QLineEdit *editData; |
57 | QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; | 57 | QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; |
58 | QComboBox *comboSheets; | 58 | QComboBox *comboSheets; |
59 | QToolButton *toolFunction; | 59 | QToolButton *toolFunction; |
60 | QList<typeSheet> listSheets; | 60 | QList<typeSheet> listSheets; |
61 | QString helpFile; | 61 | QString helpFile; |
62 | 62 | ||
63 | // Other objects | 63 | // Other objects |
64 | Sheet *sheet; | 64 | Sheet *sheet; |
65 | 65 | ||
66 | // Variables | 66 | // Variables |
67 | bool documentModified; | 67 | bool documentModified; |
68 | 68 | ||
69 | // Private functions | 69 | // Private functions |
70 | void initMenu(); | 70 | void initMenu(); |
71 | void initActions(); | 71 | void initActions(); |
72 | void initFunctionsToolbar(); | 72 | void initFunctionsToolbar(); |
73 | void initEditToolbar(); | 73 | void initEditToolbar(); |
74 | void initStandardToolbar(); | 74 | void initStandardToolbar(); |
75 | void initSheet(); | 75 | void initSheet(); |
76 | void addToData(const QString &data); | 76 | void addToData(const QString &data); |
77 | int saveCurrentFile(bool ask=TRUE); | 77 | int saveCurrentFile(bool ask=TRUE); |
78 | void documentOpen(const DocLnk &lnkDoc); | 78 | void documentOpen(const DocLnk &lnkDoc); |
79 | void copyDocLnk(const DocLnk &source, DocLnk &target); | 79 | void documentSave(DocLnk *lnkDoc); |
80 | void documentSave(DocLnk &lnkDoc); | ||
81 | void closeEvent(QCloseEvent *e); | 80 | void closeEvent(QCloseEvent *e); |
82 | void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); | 81 | void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); |
83 | typeSheet *createNewSheet(); | 82 | typeSheet *createNewSheet(); |
84 | typeSheet *findSheet(const QString &name); | 83 | typeSheet *findSheet(const QString &name); |
85 | 84 | ||
86 | private slots: | 85 | private slots: |
87 | void slotFileNew(); | 86 | void slotFileNew(); |
88 | void slotFileOpen(); | 87 | void slotFileOpen(); |
89 | void slotFileSave(); | 88 | void slotFileSave(); |
90 | void slotFileSaveAs(); | 89 | void slotFileSaveAs(); |
91 | void slotHelpAbout(); | 90 | void slotHelpAbout(); |
92 | void slotHelpGeneral(); | 91 | void slotHelpGeneral(); |
93 | void slotEditAccept(); | 92 | void slotEditAccept(); |
94 | void slotEditCancel(); | 93 | void slotEditCancel(); |
95 | void slotEditPaste(); | 94 | void slotEditPaste(); |
96 | void slotEditPasteContents(); | 95 | void slotEditPasteContents(); |
97 | void slotFormatCells(); | 96 | void slotFormatCells(); |
98 | void slotInsertCells(); | 97 | void slotInsertCells(); |
99 | void slotInsertRows(); | 98 | void slotInsertRows(); |
100 | void slotInsertCols(); | 99 | void slotInsertCols(); |
101 | void slotInsertSheets(); | 100 | void slotInsertSheets(); |
102 | void slotDataSort(); | 101 | void slotDataSort(); |
103 | void slotDataFindReplace(); | 102 | void slotDataFindReplace(); |
104 | void slotRowHeight(); | 103 | void slotRowHeight(); |
105 | void slotRowAdjust(); | 104 | void slotRowAdjust(); |
106 | void slotRowShow(); | 105 | void slotRowShow(); |
107 | void slotRowHide(); | 106 | void slotRowHide(); |
108 | void slotColumnWidth(); | 107 | void slotColumnWidth(); |
109 | void slotColumnAdjust(); | 108 | void slotColumnAdjust(); |
110 | void slotColumnShow(); | 109 | void slotColumnShow(); |
111 | void slotColumnHide(); | 110 | void slotColumnHide(); |
112 | void slotSheetRename(); | 111 | void slotSheetRename(); |
113 | void slotSheetRemove(); | 112 | void slotSheetRemove(); |
114 | void slotFuncOutput(); | 113 | void slotFuncOutput(); |
115 | void slotCellSelect(bool lock); | 114 | void slotCellSelect(bool lock); |
116 | void slotCellClicked(const QString &cell); | 115 | void slotCellClicked(const QString &cell); |
117 | void slotSheetChanged(const QString &name); | 116 | void slotSheetChanged(const QString &name); |
118 | void slotDocModified(); | 117 | void slotDocModified(); |
119 | void selectorShow(); | 118 | void selectorShow(); |
120 | void selectorHide(); | 119 | void selectorHide(); |
121 | void selectorFileNew(const DocLnk &lnkDoc); | 120 | void selectorFileNew(const DocLnk &lnkDoc); |
122 | void selectorFileOpen(const DocLnk &lnkDoc); | 121 | void selectorFileOpen(const DocLnk &lnkDoc); |
123 | 122 | ||
124 | public: | 123 | public: |
125 | MainWindow(); | 124 | MainWindow(); |
126 | ~MainWindow(); | 125 | ~MainWindow(); |
127 | 126 | ||
128 | void setHelpFile(const QString &help_filename) { helpFile=help_filename; } | 127 | void setHelpFile(const QString &help_filename) { helpFile=help_filename; } |
129 | 128 | ||
130 | public slots: | 129 | public slots: |
131 | void setDocument(const QString &applnk_filename); | 130 | void setDocument(const QString &applnk_filename); |
132 | }; | 131 | }; |
133 | 132 | ||
134 | #endif | 133 | #endif |