summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/mainwindow.cpp38
-rw-r--r--noncore/apps/opie-sheet/mainwindow.h5
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,354 +1,350 @@
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
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 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
77MainWindow::~MainWindow() 78MainWindow::~MainWindow()
78{ 79{
80 if (currentDoc) delete currentDoc;
79} 81}
80 82
81void MainWindow::documentSave(DocLnk &lnkDoc) 83void 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(&currentSheet->data); 95 sheet->copySheetData(&currentSheet->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
112void MainWindow::documentOpen(const DocLnk &lnkDoc) 114void 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
167int MainWindow::saveCurrentFile(bool ask=TRUE) 169int 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
187void 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
197void MainWindow::selectorFileNew(const DocLnk &lnkDoc) 191void 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
215void MainWindow::closeEvent(QCloseEvent *e) 210void 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
221void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) 216void 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
234void MainWindow::selectorShow() 230void 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
242void MainWindow::selectorHide() 238void 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
249void MainWindow::slotFileNew() 245void MainWindow::slotFileNew()
250{ 246{
251 selectorFileNew(DocLnk()); 247 selectorFileNew(DocLnk());
252} 248}
253 249
254void MainWindow::slotFileOpen() 250void MainWindow::slotFileOpen()
255{ 251{
256 selectorShow(); 252 selectorShow();
257} 253}
258 254
259void MainWindow::slotFileSave() 255void MainWindow::slotFileSave()
260{ 256{
261 saveCurrentFile(FALSE); 257 saveCurrentFile(FALSE);
262} 258}
263 259
264void MainWindow::setDocument(const QString &applnk_filename) 260void MainWindow::setDocument(const QString &applnk_filename)
265{ 261{
266 selectorFileOpen(DocLnk(applnk_filename)); 262 selectorFileOpen(DocLnk(applnk_filename));
267} 263}
268 264
269void MainWindow::initActions() 265void 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);
@@ -629,222 +625,224 @@ typeSheet *MainWindow::createNewSheet()
629 return newSheet; 625 return newSheet;
630} 626}
631 627
632typeSheet *MainWindow::findSheet(const QString &name) 628typeSheet *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
640void MainWindow::slotSheetChanged(const QString &name) 636void 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
647void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) 643void 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
655void MainWindow::slotFormatCells() 651void 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
662void MainWindow::slotEditPaste() 658void MainWindow::slotEditPaste()
663{ 659{
664 sheet->editPaste(); 660 sheet->editPaste();
665} 661}
666 662
667void MainWindow::slotEditPasteContents() 663void MainWindow::slotEditPasteContents()
668{ 664{
669 sheet->editPaste(TRUE); 665 sheet->editPaste(TRUE);
670} 666}
671 667
672void MainWindow::slotRowHeight() 668void 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
686void MainWindow::slotRowAdjust() 682void 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
695void MainWindow::slotRowShow() 691void 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
704void MainWindow::slotRowHide() 700void 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
713void MainWindow::slotColumnWidth() 709void 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
727void MainWindow::slotColumnAdjust() 723void 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
736void MainWindow::slotColumnShow() 732void 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
745void MainWindow::slotColumnHide() 741void 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
754void MainWindow::slotFileSaveAs() 750void 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
763void MainWindow::slotSheetRename() 761void 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
787void MainWindow::slotSheetRemove() 785void 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
809void MainWindow::slotDataSort() 807void 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
816void MainWindow::slotDocModified() 814void MainWindow::slotDocModified()
817{ 815{
818 documentModified=TRUE; 816 documentModified=TRUE;
819} 817}
820 818
821void MainWindow::slotInsertCells() 819void 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
845void MainWindow::slotDataFindReplace() 843void 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
31typedef struct typeSheet 31typedef struct typeSheet
32{ 32{
33 QString name; 33 QString name;
34 QList<typeCellData> data; 34 QList<typeCellData> data;
35}; 35};
36 36
37class MainWindow: public QMainWindow 37class 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