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