-rw-r--r-- | noncore/apps/opie-sheet/ChangeLog | 2 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/noncore/apps/opie-sheet/ChangeLog b/noncore/apps/opie-sheet/ChangeLog index 0370156..69c96f8 100644 --- a/noncore/apps/opie-sheet/ChangeLog +++ b/noncore/apps/opie-sheet/ChangeLog | |||
@@ -1,73 +1,75 @@ | |||
1 | January 9, 2004 corrected the names of the resource icons in mainwindow.cpp.... So now they are loaded fine. | ||
2 | |||
1 | January 8, 2004 | 3 | January 8, 2004 |
2 | - converted icons from xpm to png and moved them to $OPIEDIR/pics/opie-sheet | 4 | - converted icons from xpm to png and moved them to $OPIEDIR/pics/opie-sheet |
3 | - modified mainwindow.cpp to load pixmaps with Resource::loadPixmap(resourcename) in contrast to the old QPixmap(nameofthe_xpm_included_in_the_opie-sheet_dir) | 5 | - modified mainwindow.cpp to load pixmaps with Resource::loadPixmap(resourcename) in contrast to the old QPixmap(nameofthe_xpm_included_in_the_opie-sheet_dir) |
4 | - changed pics/opie-sheet/sheetqt.png entry in control file to pics/opie-sheet/*.png | 6 | - changed pics/opie-sheet/sheetqt.png entry in control file to pics/opie-sheet/*.png |
5 | 7 | ||
6 | January 8, 2004 | 8 | January 8, 2004 |
7 | - fixed issue : "-if someone enters directly text as parameter to a string function the text renders as uppercase due to the calculation engine that uppercases all the parsing sentence." | 9 | - fixed issue : "-if someone enters directly text as parameter to a string function the text renders as uppercase due to the calculation engine that uppercases all the parsing sentence." |
8 | now the text is handled correctly. | 10 | now the text is handled correctly. |
9 | 11 | ||
10 | January 7, 2004 | 12 | January 7, 2004 |
11 | * Release by hayzel (koppermind@panafonet.gr) | 13 | * Release by hayzel (koppermind@panafonet.gr) |
12 | This version has many valuable changes, though It may have some annoying bugs. Please if you are interested in opie-sheet try it hard, so I can fix some of them. Also If you want some other functions that must be here and are missing feel free to ask them. (no financial functions please. :) I really hate them ) | 14 | This version has many valuable changes, though It may have some annoying bugs. Please if you are interested in opie-sheet try it hard, so I can fix some of them. Also If you want some other functions that must be here and are missing feel free to ask them. (no financial functions please. :) I really hate them ) |
13 | -Fixed a bug with non closed parenthesis editing&recalculation infinite loop. | 15 | -Fixed a bug with non closed parenthesis editing&recalculation infinite loop. |
14 | -Added support for functions that can parse parameters not ONLY as numbers but also as strings. | 16 | -Added support for functions that can parse parameters not ONLY as numbers but also as strings. |
15 | -Added many functions that cover many computational topics rendering opie-sheet a computational tool-spreadsheet at last. (total 90 functions!) | 17 | -Added many functions that cover many computational topics rendering opie-sheet a computational tool-spreadsheet at last. (total 90 functions!) |
16 | -Maintained compatibility with the opie-fileformat. | 18 | -Maintained compatibility with the opie-fileformat. |
17 | -New icons. | 19 | -New icons. |
18 | -Found that the DataParser was not a real RPN compiler of the expressions. In fact it was returning faulty results in calculations, in both binary or unary operations. A1-A2-A3 was parsed as A1-(A2-A3). -A1 was parsed as A1. | 20 | -Found that the DataParser was not a real RPN compiler of the expressions. In fact it was returning faulty results in calculations, in both binary or unary operations. A1-A2-A3 was parsed as A1-(A2-A3). -A1 was parsed as A1. |
19 | -Added new class "Expression" a general Parser for spreadsheet-expression. Imported from an old C# project of mine. | 21 | -Added new class "Expression" a general Parser for spreadsheet-expression. Imported from an old C# project of mine. |
20 | -Now can also parse <>=!%&^|"" in expressions. | 22 | -Now can also parse <>=!%&^|"" in expressions. |
21 | -Added experimental Excel File format import!. The opie-sheet can import any excel file in BIFF7/BIFF8 format. These formats are used in Excel XP,2000,95. The Excel Importer class is in a good coding level.. BUT it is not complete. Only strings,numbers,formulas are imported. Not formatting rules. Not all the functions are converted in the functions of opie-sheet. Infact FEW functions are converted. | 23 | -Added experimental Excel File format import!. The opie-sheet can import any excel file in BIFF7/BIFF8 format. These formats are used in Excel XP,2000,95. The Excel Importer class is in a good coding level.. BUT it is not complete. Only strings,numbers,formulas are imported. Not formatting rules. Not all the functions are converted in the functions of opie-sheet. Infact FEW functions are converted. |
22 | -Fixed a bug with Sheet Recalculation. Added ReCalc() function. Opie-sheet was calculating wrong the values of expression in opening/importing. if a value needed was not loaded yet in the time of calculation. Solved with ReCalc() each time the active sheet is changing. | 24 | -Fixed a bug with Sheet Recalculation. Added ReCalc() function. Opie-sheet was calculating wrong the values of expression in opening/importing. if a value needed was not loaded yet in the time of calculation. Solved with ReCalc() each time the active sheet is changing. |
23 | 25 | ||
24 | 26 | ||
25 | *known issues: | 27 | *known issues: |
26 | -if someone enters directly text as parameter to a string function the text renders as uppercase due to the calculation engine that uppercases all the parsing sentence. | 28 | -if someone enters directly text as parameter to a string function the text renders as uppercase due to the calculation engine that uppercases all the parsing sentence. |
27 | -randbetween return only integer part random... if both limit numbers are integers. | 29 | -randbetween return only integer part random... if both limit numbers are integers. |
28 | -skew and kurt function give different results compared to kspread-oofice equivalents. | 30 | -skew and kurt function give different results compared to kspread-oofice equivalents. |
29 | -unstable parser Excel Class | 31 | -unstable parser Excel Class |
30 | -string vars and string functions are not correctly handled by excel importer. | 32 | -string vars and string functions are not correctly handled by excel importer. |
31 | -unicode strings are converted FINE in QString unicode format, but cannot be rendered fine if a suitable unicode font is not setuped as the default string. So the string is junked in the opie-sheet and may crash the parser. | 33 | -unicode strings are converted FINE in QString unicode format, but cannot be rendered fine if a suitable unicode font is not setuped as the default string. So the string is junked in the opie-sheet and may crash the parser. |
32 | 34 | ||
33 | *TODOs: | 35 | *TODOs: |
34 | -surelly a much full-stable excel importer. | 36 | -surelly a much full-stable excel importer. |
35 | -Cell Manipulation of many Data is really slow.... must change the QList data type. To a structure more efficient. | 37 | -Cell Manipulation of many Data is really slow.... must change the QList data type. To a structure more efficient. |
36 | -maybe some more functions. | 38 | -maybe some more functions. |
37 | -maybe some kind of charts drawing? | 39 | -maybe some kind of charts drawing? |
38 | -maybe kspread or ooffice files import/export. | 40 | -maybe kspread or ooffice files import/export. |
39 | 41 | ||
40 | October 08, 2002 | 42 | October 08, 2002 |
41 | 43 | ||
42 | * Release 1.0.2 (by thufir) | 44 | * Release 1.0.2 (by thufir) |
43 | - Fixed bug #250 (exhibiting re-calculation error in multi-level calculation). (by thufir) | 45 | - Fixed bug #250 (exhibiting re-calculation error in multi-level calculation). (by thufir) |
44 | 46 | ||
45 | October 06, 2002 | 47 | October 06, 2002 |
46 | 48 | ||
47 | - Fixed data edit box clear problem. (by thufir) | 49 | - Fixed data edit box clear problem. (by thufir) |
48 | 50 | ||
49 | October 05, 2002 | 51 | October 05, 2002 |
50 | 52 | ||
51 | - Fixed bug #252 (starting up in 'mouse button' mode). (by thufir) | 53 | - Fixed bug #252 (starting up in 'mouse button' mode). (by thufir) |
52 | 54 | ||
53 | August 31, 2002 | 55 | August 31, 2002 |
54 | 56 | ||
55 | - Fixed and updated opie-sheet.pro file. (by cniehaus) | 57 | - Fixed and updated opie-sheet.pro file. (by cniehaus) |
56 | 58 | ||
57 | August 01, 2002 | 59 | August 01, 2002 |
58 | 60 | ||
59 | - Fixed gcc3 compile problems. (by harlekin) | 61 | - Fixed gcc3 compile problems. (by harlekin) |
60 | 62 | ||
61 | July 06, 2002 | 63 | July 06, 2002 |
62 | 64 | ||
63 | - Fixed DocLnk management to save documents correctly. (by leseb) | 65 | - Fixed DocLnk management to save documents correctly. (by leseb) |
64 | 66 | ||
65 | July 04, 2002 | 67 | July 04, 2002 |
66 | 68 | ||
67 | * Release 1.0.1 (by thufir) | 69 | * Release 1.0.1 (by thufir) |
68 | - Sheet/Qt is now a part of Opie, so its name is changed to Opie Sheet. (by thufir) | 70 | - Sheet/Qt is now a part of Opie, so its name is changed to Opie Sheet. (by thufir) |
69 | - Fixed sorting bug. (by thufir) | 71 | - Fixed sorting bug. (by thufir) |
70 | 72 | ||
71 | April 14, 2002 | 73 | April 14, 2002 |
72 | 74 | ||
73 | * Release 1.0.0 (by thufir) | 75 | * Release 1.0.0 (by thufir) |
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 07e581a..bd98aca 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -1,1008 +1,1008 @@ | |||
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 <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qtranslator.h> | 22 | #include <qtranslator.h> |
23 | #include <qradiobutton.h> | 23 | #include <qradiobutton.h> |
24 | #include "cellformat.h" | 24 | #include "cellformat.h" |
25 | #include "numberdlg.h" | 25 | #include "numberdlg.h" |
26 | #include "textdlg.h" | 26 | #include "textdlg.h" |
27 | #include "sortdlg.h" | 27 | #include "sortdlg.h" |
28 | #include "finddlg.h" | 28 | #include "finddlg.h" |
29 | 29 | ||
30 | #define DEFAULT_NUM_ROWS 300 | 30 | #define DEFAULT_NUM_ROWS 300 |
31 | #define DEFAULT_NUM_COLS (26*3) | 31 | #define DEFAULT_NUM_COLS (26*3) |
32 | #define DEFAULT_NUM_SHEETS 3 | 32 | #define DEFAULT_NUM_SHEETS 3 |
33 | 33 | ||
34 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) | 34 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
35 | :QMainWindow(parent, n, fl) | 35 | :QMainWindow(parent, n, fl) |
36 | { | 36 | { |
37 | // initialize variables | 37 | // initialize variables |
38 | documentModified=FALSE; | 38 | documentModified=FALSE; |
39 | 39 | ||
40 | // construct objects | 40 | // construct objects |
41 | currentDoc=0; | 41 | currentDoc=0; |
42 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 42 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
43 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); | 43 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); |
44 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 44 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
45 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 45 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); |
46 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 46 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); |
47 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); | 47 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); |
48 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); | 48 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); |
49 | 49 | ||
50 | 50 | ||
51 | listSheets.setAutoDelete(TRUE); | 51 | listSheets.setAutoDelete(TRUE); |
52 | 52 | ||
53 | initActions(); | 53 | initActions(); |
54 | initMenu(); | 54 | initMenu(); |
55 | initEditToolbar(); | 55 | initEditToolbar(); |
56 | initFunctionsToolbar(); | 56 | initFunctionsToolbar(); |
57 | initStandardToolbar(); | 57 | initStandardToolbar(); |
58 | initSheet(); | 58 | initSheet(); |
59 | 59 | ||
60 | // set window title | 60 | // set window title |
61 | setCaption(tr("Opie Sheet")); | 61 | setCaption(tr("Opie Sheet")); |
62 | 62 | ||
63 | // create sheets | 63 | // create sheets |
64 | selectorFileNew(DocLnk()); | 64 | selectorFileNew(DocLnk()); |
65 | } | 65 | } |
66 | 66 | ||
67 | MainWindow::~MainWindow() | 67 | MainWindow::~MainWindow() |
68 | { | 68 | { |
69 | if (currentDoc) delete currentDoc; | 69 | if (currentDoc) delete currentDoc; |
70 | } | 70 | } |
71 | 71 | ||
72 | void MainWindow::documentSave(DocLnk *lnkDoc) | 72 | void MainWindow::documentSave(DocLnk *lnkDoc) |
73 | { | 73 | { |
74 | FileManager fm; | 74 | FileManager fm; |
75 | QByteArray streamBuffer; | 75 | QByteArray streamBuffer; |
76 | QDataStream stream(streamBuffer, IO_WriteOnly); | 76 | QDataStream stream(streamBuffer, IO_WriteOnly); |
77 | 77 | ||
78 | typeSheet *currentSheet=findSheet(sheet->getName()); | 78 | typeSheet *currentSheet=findSheet(sheet->getName()); |
79 | if (!currentSheet) | 79 | if (!currentSheet) |
80 | { | 80 | { |
81 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); | 81 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); |
82 | return; | 82 | return; |
83 | } | 83 | } |
84 | sheet->copySheetData(¤tSheet->data); | 84 | sheet->copySheetData(¤tSheet->data); |
85 | stream.writeRawBytes("SQT100", 6); | 85 | stream.writeRawBytes("SQT100", 6); |
86 | stream << (Q_UINT32)listSheets.count(); | 86 | stream << (Q_UINT32)listSheets.count(); |
87 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 87 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
88 | { | 88 | { |
89 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 89 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
90 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 90 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
91 | 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; | 91 | 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; |
92 | } | 92 | } |
93 | 93 | ||
94 | lnkDoc->setType("application/sheet-qt"); | 94 | lnkDoc->setType("application/sheet-qt"); |
95 | if (!fm.saveFile(*lnkDoc, streamBuffer)) | 95 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
96 | { | 96 | { |
97 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 97 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
98 | return; | 98 | return; |
99 | } | 99 | } |
100 | documentModified=FALSE; | 100 | documentModified=FALSE; |
101 | } | 101 | } |
102 | 102 | ||
103 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 103 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
104 | { | 104 | { |
105 | FileManager fm; | 105 | FileManager fm; |
106 | QByteArray streamBuffer; | 106 | QByteArray streamBuffer; |
107 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 107 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
108 | { | 108 | { |
109 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 109 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
110 | documentModified=FALSE; | 110 | documentModified=FALSE; |
111 | selectorFileNew(DocLnk()); | 111 | selectorFileNew(DocLnk()); |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | QDataStream stream(streamBuffer, IO_ReadOnly); | 114 | QDataStream stream(streamBuffer, IO_ReadOnly); |
115 | 115 | ||
116 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 116 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
117 | typeSheet *newSheet; | 117 | typeSheet *newSheet; |
118 | typeCellData *newCell; | 118 | typeCellData *newCell; |
119 | 119 | ||
120 | char fileFormat[7]; | 120 | char fileFormat[7]; |
121 | stream.readRawBytes(fileFormat, 6); | 121 | stream.readRawBytes(fileFormat, 6); |
122 | fileFormat[6]=0; | 122 | fileFormat[6]=0; |
123 | if ((QString)fileFormat!="SQT100") | 123 | if ((QString)fileFormat!="SQT100") |
124 | { | 124 | { |
125 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 125 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
126 | documentModified=FALSE; | 126 | documentModified=FALSE; |
127 | selectorFileNew(DocLnk()); | 127 | selectorFileNew(DocLnk()); |
128 | return; | 128 | return; |
129 | } | 129 | } |
130 | 130 | ||
131 | stream >> countSheet; | 131 | stream >> countSheet; |
132 | for (i=0; i<countSheet; ++i) | 132 | for (i=0; i<countSheet; ++i) |
133 | { | 133 | { |
134 | newSheet=new typeSheet; | 134 | newSheet=new typeSheet; |
135 | newSheet->data.setAutoDelete(TRUE); | 135 | newSheet->data.setAutoDelete(TRUE); |
136 | stream >> newSheet->name >> countCell; | 136 | stream >> newSheet->name >> countCell; |
137 | comboSheets->insertItem(newSheet->name); | 137 | comboSheets->insertItem(newSheet->name); |
138 | 138 | ||
139 | for (j=0; j<countCell; ++j) | 139 | for (j=0; j<countCell; ++j) |
140 | { | 140 | { |
141 | newCell=new typeCellData; | 141 | newCell=new typeCellData; |
142 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 142 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
143 | newCell->col=col; | 143 | newCell->col=col; |
144 | newCell->row=row; | 144 | newCell->row=row; |
145 | newCell->alignment=(Qt::AlignmentFlags)alignment; | 145 | newCell->alignment=(Qt::AlignmentFlags)alignment; |
146 | newSheet->data.append(newCell); | 146 | newSheet->data.append(newCell); |
147 | } | 147 | } |
148 | listSheets.append(newSheet); | 148 | listSheets.append(newSheet); |
149 | 149 | ||
150 | if (i==0) | 150 | if (i==0) |
151 | { | 151 | { |
152 | sheet->setName(newSheet->name); | 152 | sheet->setName(newSheet->name); |
153 | sheet->setSheetData(&newSheet->data); | 153 | sheet->setSheetData(&newSheet->data); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | int MainWindow::saveCurrentFile(bool ask) | 158 | int MainWindow::saveCurrentFile(bool ask) |
159 | { | 159 | { |
160 | if (ask) | 160 | if (ask) |
161 | { | 161 | { |
162 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); | 162 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); |
163 | if (result!=QMessageBox::Yes) return result; | 163 | if (result!=QMessageBox::Yes) return result; |
164 | } | 164 | } |
165 | 165 | ||
166 | if (!currentDoc->isValid()) | 166 | if (!currentDoc->isValid()) |
167 | { | 167 | { |
168 | TextDialog dialogText(this); | 168 | TextDialog dialogText(this); |
169 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; | 169 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; |
170 | 170 | ||
171 | currentDoc->setName(dialogText.getValue()); | 171 | currentDoc->setName(dialogText.getValue()); |
172 | currentDoc->setFile(QString::null); | 172 | currentDoc->setFile(QString::null); |
173 | currentDoc->setLinkFile(QString::null); | 173 | currentDoc->setLinkFile(QString::null); |
174 | } | 174 | } |
175 | 175 | ||
176 | documentSave(currentDoc); | 176 | documentSave(currentDoc); |
177 | return QMessageBox::Yes; | 177 | return QMessageBox::Yes; |
178 | } | 178 | } |
179 | 179 | ||
180 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) | 180 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) |
181 | { | 181 | { |
182 | selectorHide(); | 182 | selectorHide(); |
183 | 183 | ||
184 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 184 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
185 | if (currentDoc) delete currentDoc; | 185 | if (currentDoc) delete currentDoc; |
186 | currentDoc = new DocLnk(lnkDoc); | 186 | currentDoc = new DocLnk(lnkDoc); |
187 | editData->clear(); | 187 | editData->clear(); |
188 | listSheets.clear(); | 188 | listSheets.clear(); |
189 | comboSheets->clear(); | 189 | comboSheets->clear(); |
190 | 190 | ||
191 | typeSheet *newSheet=createNewSheet(); | 191 | typeSheet *newSheet=createNewSheet(); |
192 | newSheet->data.setAutoDelete(TRUE); | 192 | newSheet->data.setAutoDelete(TRUE); |
193 | sheet->setName(newSheet->name); | 193 | sheet->setName(newSheet->name); |
194 | sheet->setSheetData(&newSheet->data); | 194 | sheet->setSheetData(&newSheet->data); |
195 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) | 195 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) |
196 | createNewSheet(); | 196 | createNewSheet(); |
197 | documentModified=FALSE; | 197 | documentModified=FALSE; |
198 | } | 198 | } |
199 | 199 | ||
200 | void MainWindow::closeEvent(QCloseEvent *e) | 200 | void MainWindow::closeEvent(QCloseEvent *e) |
201 | { | 201 | { |
202 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); | 202 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); |
203 | else e->accept(); | 203 | else e->accept(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) | 206 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) |
207 | { | 207 | { |
208 | selectorHide(); | 208 | selectorHide(); |
209 | 209 | ||
210 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 210 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
211 | if (currentDoc) delete currentDoc; | 211 | if (currentDoc) delete currentDoc; |
212 | currentDoc = new DocLnk(); | 212 | currentDoc = new DocLnk(); |
213 | listSheets.clear(); | 213 | listSheets.clear(); |
214 | comboSheets->clear(); | 214 | comboSheets->clear(); |
215 | 215 | ||
216 | documentOpen(lnkDoc); | 216 | documentOpen(lnkDoc); |
217 | documentModified=FALSE; | 217 | documentModified=FALSE; |
218 | } | 218 | } |
219 | 219 | ||
220 | void MainWindow::selectorShow() | 220 | void MainWindow::selectorShow() |
221 | { | 221 | { |
222 | sheet->hide(); | 222 | sheet->hide(); |
223 | setCentralWidget(fileSelector); | 223 | setCentralWidget(fileSelector); |
224 | fileSelector->show(); | 224 | fileSelector->show(); |
225 | fileSelector->reread(); | 225 | fileSelector->reread(); |
226 | } | 226 | } |
227 | 227 | ||
228 | void MainWindow::selectorHide() | 228 | void MainWindow::selectorHide() |
229 | { | 229 | { |
230 | fileSelector->hide(); | 230 | fileSelector->hide(); |
231 | setCentralWidget(sheet); | 231 | setCentralWidget(sheet); |
232 | sheet->show(); | 232 | sheet->show(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void MainWindow::slotFileNew() | 235 | void MainWindow::slotFileNew() |
236 | { | 236 | { |
237 | selectorFileNew(DocLnk()); | 237 | selectorFileNew(DocLnk()); |
238 | } | 238 | } |
239 | 239 | ||
240 | void MainWindow::slotFileOpen() | 240 | void MainWindow::slotFileOpen() |
241 | { | 241 | { |
242 | selectorShow(); | 242 | selectorShow(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void MainWindow::slotImportExcelOpen() | 245 | void MainWindow::slotImportExcelOpen() |
246 | { | 246 | { |
247 | sheet->hide(); | 247 | sheet->hide(); |
248 | setCentralWidget(ExcelSelector); | 248 | setCentralWidget(ExcelSelector); |
249 | ExcelSelector->show(); | 249 | ExcelSelector->show(); |
250 | ExcelSelector->reread(); | 250 | ExcelSelector->reread(); |
251 | } | 251 | } |
252 | 252 | ||
253 | void MainWindow::ExcelSelectorHide() | 253 | void MainWindow::ExcelSelectorHide() |
254 | { | 254 | { |
255 | ExcelSelector->hide(); | 255 | ExcelSelector->hide(); |
256 | setCentralWidget(sheet); | 256 | setCentralWidget(sheet); |
257 | sheet->show(); | 257 | sheet->show(); |
258 | } | 258 | } |
259 | 259 | ||
260 | void MainWindow::slotFileSave() | 260 | void MainWindow::slotFileSave() |
261 | { | 261 | { |
262 | saveCurrentFile(FALSE); | 262 | saveCurrentFile(FALSE); |
263 | } | 263 | } |
264 | 264 | ||
265 | void MainWindow::setDocument(const QString &applnk_filename) | 265 | void MainWindow::setDocument(const QString &applnk_filename) |
266 | { | 266 | { |
267 | selectorFileOpen(DocLnk(applnk_filename)); | 267 | selectorFileOpen(DocLnk(applnk_filename)); |
268 | } | 268 | } |
269 | 269 | ||
270 | void MainWindow::initActions() | 270 | void MainWindow::initActions() |
271 | { | 271 | { |
272 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); | 272 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); |
273 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); | 273 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); |
274 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); | 274 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); |
275 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); | 275 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); |
276 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); | 276 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); |
277 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); | 277 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); |
278 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); | 278 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); |
279 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); | 279 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); |
280 | 280 | ||
281 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); | 281 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); |
282 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); | 282 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); |
283 | fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this); | 283 | fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this); |
284 | connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen())); | 284 | connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen())); |
285 | 285 | ||
286 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); | 286 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); |
287 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); | 287 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); |
288 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); | 288 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); |
289 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); | 289 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); |
290 | 290 | ||
291 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); | 291 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); |
292 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); | 292 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); |
293 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); | 293 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); |
294 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); | 294 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); |
295 | editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell_select" ), tr("Cell &Selector"), 0, this); | 295 | editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell-select" ), tr("Cell &Selector"), 0, this); |
296 | editCellSelect->setToggleAction(TRUE); | 296 | editCellSelect->setToggleAction(TRUE); |
297 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); | 297 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); |
298 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); | 298 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); |
299 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); | 299 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); |
300 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); | 300 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); |
301 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); | 301 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); |
302 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); | 302 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); |
303 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); | 303 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); |
304 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); | 304 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); |
305 | 305 | ||
306 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); | 306 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); |
307 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); | 307 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); |
308 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); | 308 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); |
309 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); | 309 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); |
310 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); | 310 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); |
311 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); | 311 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); |
312 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); | 312 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); |
313 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); | 313 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); |
314 | 314 | ||
315 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); | 315 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); |
316 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); | 316 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); |
317 | 317 | ||
318 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); | 318 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); |
319 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); | 319 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); |
320 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); | 320 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); |
321 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); | 321 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); |
322 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); | 322 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); |
323 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); | 323 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); |
324 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); | 324 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); |
325 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); | 325 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); |
326 | 326 | ||
327 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); | 327 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); |
328 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); | 328 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); |
329 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); | 329 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); |
330 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); | 330 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); |
331 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); | 331 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); |
332 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); | 332 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); |
333 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); | 333 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); |
334 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); | 334 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); |
335 | 335 | ||
336 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); | 336 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); |
337 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); | 337 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); |
338 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); | 338 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); |
339 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); | 339 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); |
340 | 340 | ||
341 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); | 341 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); |
342 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); | 342 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); |
343 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); | 343 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); |
344 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); | 344 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); |
345 | 345 | ||
346 | funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func_equal" ), tr("&Equal To"), 0, this); | 346 | funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func-equal" ), tr("&Equal To"), 0, this); |
347 | funcEqual->setToolTip("="); | 347 | funcEqual->setToolTip("="); |
348 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 348 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
349 | funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func_plus" ), tr("&Addition"), 0, this); | 349 | funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func-plus" ), tr("&Addition"), 0, this); |
350 | funcPlus->setToolTip("+"); | 350 | funcPlus->setToolTip("+"); |
351 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 351 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
352 | funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func_minus" ), tr("&Subtraction"), 0, this); | 352 | funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func-minus" ), tr("&Subtraction"), 0, this); |
353 | funcMinus->setToolTip("-"); | 353 | funcMinus->setToolTip("-"); |
354 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 354 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
355 | funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func_cross" ), tr("&Multiplication"), 0, this); | 355 | funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func-cross" ), tr("&Multiplication"), 0, this); |
356 | funcCross->setToolTip("*"); | 356 | funcCross->setToolTip("*"); |
357 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 357 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
358 | funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func_divide" ), tr("&Division"), 0, this); | 358 | funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func-divide" ), tr("&Division"), 0, this); |
359 | funcDivide->setToolTip("/"); | 359 | funcDivide->setToolTip("/"); |
360 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 360 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
361 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func_paran_open" ), tr("&Open Paranthesis"), 0, this); | 361 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func-paran-open" ), tr("&Open Paranthesis"), 0, this); |
362 | funcParanOpen->setToolTip("("); | 362 | funcParanOpen->setToolTip("("); |
363 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 363 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
364 | funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func_paran_close" ), tr("&Close Paranthesis"), 0, this); | 364 | funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func-paran-close" ), tr("&Close Paranthesis"), 0, this); |
365 | funcParanClose->setToolTip(")"); | 365 | funcParanClose->setToolTip(")"); |
366 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 366 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
367 | funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func_comma" ), tr("&Comma"), 0, this); | 367 | funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func-comma" ), tr("&Comma"), 0, this); |
368 | funcComma->setToolTip(","); | 368 | funcComma->setToolTip(","); |
369 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 369 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
370 | } | 370 | } |
371 | 371 | ||
372 | void MainWindow::initMenu() | 372 | void MainWindow::initMenu() |
373 | { | 373 | { |
374 | menu=new QMenuBar(this); | 374 | menu=new QMenuBar(this); |
375 | 375 | ||
376 | menuFile=new QPopupMenu; | 376 | menuFile=new QPopupMenu; |
377 | fileNew->addTo(menuFile); | 377 | fileNew->addTo(menuFile); |
378 | fileOpen->addTo(menuFile); | 378 | fileOpen->addTo(menuFile); |
379 | fileSave->addTo(menuFile); | 379 | fileSave->addTo(menuFile); |
380 | fileSaveAs->addTo(menuFile); | 380 | fileSaveAs->addTo(menuFile); |
381 | // menuFile->insertSeparator(); | 381 | // menuFile->insertSeparator(); |
382 | // fileQuit->addTo(menuFile); | 382 | // fileQuit->addTo(menuFile); |
383 | menuFile->insertSeparator(); | 383 | menuFile->insertSeparator(); |
384 | fileExcelImport->addTo(menuFile); | 384 | fileExcelImport->addTo(menuFile); |
385 | menu->insertItem(tr("&File"), menuFile); | 385 | menu->insertItem(tr("&File"), menuFile); |
386 | 386 | ||
387 | menuEdit=new QPopupMenu; | 387 | menuEdit=new QPopupMenu; |
388 | editAccept->addTo(menuEdit); | 388 | editAccept->addTo(menuEdit); |
389 | editCancel->addTo(menuEdit); | 389 | editCancel->addTo(menuEdit); |
390 | editCellSelect->addTo(menuEdit); | 390 | editCellSelect->addTo(menuEdit); |
391 | menuEdit->insertSeparator(); | 391 | menuEdit->insertSeparator(); |
392 | editCut->addTo(menuEdit); | 392 | editCut->addTo(menuEdit); |
393 | editCopy->addTo(menuEdit); | 393 | editCopy->addTo(menuEdit); |
394 | editPaste->addTo(menuEdit); | 394 | editPaste->addTo(menuEdit); |
395 | editPasteContents->addTo(menuEdit); | 395 | editPasteContents->addTo(menuEdit); |
396 | editClear->addTo(menuEdit); | 396 | editClear->addTo(menuEdit); |
397 | menu->insertItem(tr("&Edit"), menuEdit); | 397 | menu->insertItem(tr("&Edit"), menuEdit); |
398 | 398 | ||
399 | menuInsert=new QPopupMenu; | 399 | menuInsert=new QPopupMenu; |
400 | menu->insertItem(tr("&Insert"), menuInsert); | 400 | menu->insertItem(tr("&Insert"), menuInsert); |
401 | 401 | ||
402 | menuFormat=new QPopupMenu; | 402 | menuFormat=new QPopupMenu; |
403 | formatCells->addTo(menuFormat); | 403 | formatCells->addTo(menuFormat); |
404 | menu->insertItem(tr("&Format"), menuFormat); | 404 | menu->insertItem(tr("&Format"), menuFormat); |
405 | 405 | ||
406 | menuData=new QPopupMenu; | 406 | menuData=new QPopupMenu; |
407 | dataSort->addTo(menuData); | 407 | dataSort->addTo(menuData); |
408 | dataFindReplace->addTo(menuData); | 408 | dataFindReplace->addTo(menuData); |
409 | menu->insertItem(tr("&Data"), menuData); | 409 | menu->insertItem(tr("&Data"), menuData); |
410 | 410 | ||
411 | // menuHelp=new QPopupMenu; | 411 | // menuHelp=new QPopupMenu; |
412 | // helpGeneral->addTo(menuHelp); | 412 | // helpGeneral->addTo(menuHelp); |
413 | // helpAbout->addTo(menuHelp); | 413 | // helpAbout->addTo(menuHelp); |
414 | // menu->insertItem(tr("&Help"), menuHelp); | 414 | // menu->insertItem(tr("&Help"), menuHelp); |
415 | 415 | ||
416 | submenuRow=new QPopupMenu; | 416 | submenuRow=new QPopupMenu; |
417 | rowHeight->addTo(submenuRow); | 417 | rowHeight->addTo(submenuRow); |
418 | rowAdjust->addTo(submenuRow); | 418 | rowAdjust->addTo(submenuRow); |
419 | rowShow->addTo(submenuRow); | 419 | rowShow->addTo(submenuRow); |
420 | rowHide->addTo(submenuRow); | 420 | rowHide->addTo(submenuRow); |
421 | menuFormat->insertItem(tr("&Row"), submenuRow); | 421 | menuFormat->insertItem(tr("&Row"), submenuRow); |
422 | 422 | ||
423 | submenuCol=new QPopupMenu; | 423 | submenuCol=new QPopupMenu; |
424 | colWidth->addTo(submenuCol); | 424 | colWidth->addTo(submenuCol); |
425 | colAdjust->addTo(submenuCol); | 425 | colAdjust->addTo(submenuCol); |
426 | colShow->addTo(submenuCol); | 426 | colShow->addTo(submenuCol); |
427 | colHide->addTo(submenuCol); | 427 | colHide->addTo(submenuCol); |
428 | menuFormat->insertItem(tr("Colum&n"), submenuCol); | 428 | menuFormat->insertItem(tr("Colum&n"), submenuCol); |
429 | 429 | ||
430 | submenuSheet=new QPopupMenu; | 430 | submenuSheet=new QPopupMenu; |
431 | sheetRename->addTo(submenuSheet); | 431 | sheetRename->addTo(submenuSheet); |
432 | sheetRemove->addTo(submenuSheet); | 432 | sheetRemove->addTo(submenuSheet); |
433 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); | 433 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); |
434 | 434 | ||
435 | submenuFunc=new QPopupMenu; | 435 | submenuFunc=new QPopupMenu; |
436 | menuInsert->insertItem(tr("&Function"), submenuFunc); | 436 | menuInsert->insertItem(tr("&Function"), submenuFunc); |
437 | 437 | ||
438 | submenuFuncStd=new QPopupMenu; | 438 | submenuFuncStd=new QPopupMenu; |
439 | funcPlus->addTo(submenuFuncStd); | 439 | funcPlus->addTo(submenuFuncStd); |
440 | funcMinus->addTo(submenuFuncStd); | 440 | funcMinus->addTo(submenuFuncStd); |
441 | funcCross->addTo(submenuFuncStd); | 441 | funcCross->addTo(submenuFuncStd); |
442 | funcDivide->addTo(submenuFuncStd); | 442 | funcDivide->addTo(submenuFuncStd); |
443 | submenuFunc->insertItem(tr("&Simple"), submenuFuncStd); | 443 | submenuFunc->insertItem(tr("&Simple"), submenuFuncStd); |
444 | 444 | ||
445 | 445 | ||
446 | 446 | ||
447 | submenuFuncStandard=new QPopupMenu; | 447 | submenuFuncStandard=new QPopupMenu; |
448 | addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard); | 448 | addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard); |
449 | addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard); | 449 | addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard); |
450 | addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard); | 450 | addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard); |
451 | addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard); | 451 | addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard); |
452 | addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard); | 452 | addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard); |
453 | addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard); | 453 | addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard); |
454 | addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard); | 454 | addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard); |
455 | addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard); | 455 | addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard); |
456 | submenuFuncStandard->insertSeparator(); | 456 | submenuFuncStandard->insertSeparator(); |
457 | addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard); | 457 | addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard); |
458 | addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard); | 458 | addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard); |
459 | addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard); | 459 | addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard); |
460 | addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard); | 460 | addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard); |
461 | addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard); | 461 | addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard); |
462 | addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard); | 462 | addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard); |
463 | submenuFuncStandard->insertSeparator(); | 463 | submenuFuncStandard->insertSeparator(); |
464 | addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard); | 464 | addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard); |
465 | addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard); | 465 | addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard); |
466 | addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard); | 466 | addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard); |
467 | addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard); | 467 | addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard); |
468 | addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard); | 468 | addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard); |
469 | submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard); | 469 | submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard); |
470 | 470 | ||
471 | submenuFuncLogic=new QPopupMenu; | 471 | submenuFuncLogic=new QPopupMenu; |
472 | addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic); | 472 | addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic); |
473 | addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic); | 473 | addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic); |
474 | addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic); | 474 | addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic); |
475 | submenuFuncLogic->insertSeparator(); | 475 | submenuFuncLogic->insertSeparator(); |
476 | addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic); | 476 | addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic); |
477 | addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic); | 477 | addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic); |
478 | addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic); | 478 | addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic); |
479 | addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic); | 479 | addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic); |
480 | addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic); | 480 | addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic); |
481 | addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic); | 481 | addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic); |
482 | addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic); | 482 | addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic); |
483 | addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic); | 483 | addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic); |
484 | submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic); | 484 | submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic); |
485 | 485 | ||
486 | submenuFuncTrig=new QPopupMenu; | 486 | submenuFuncTrig=new QPopupMenu; |
487 | addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig); | 487 | addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig); |
488 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); | 488 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); |
489 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); | 489 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); |
490 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); | 490 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); |
491 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); | 491 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); |
492 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); | 492 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); |
493 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); | 493 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); |
494 | submenuFuncTrig->insertSeparator(); | 494 | submenuFuncTrig->insertSeparator(); |
495 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); | 495 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); |
496 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); | 496 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); |
497 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); | 497 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); |
498 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); | 498 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); |
499 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); | 499 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); |
500 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); | 500 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); |
501 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); | 501 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); |
502 | 502 | ||
503 | submenuFuncString=new QPopupMenu; | 503 | submenuFuncString=new QPopupMenu; |
504 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); | 504 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); |
505 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); | 505 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); |
506 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); | 506 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); |
507 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); | 507 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); |
508 | submenuFuncString->insertSeparator(); | 508 | submenuFuncString->insertSeparator(); |
509 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); | 509 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); |
510 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); | 510 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); |
511 | addFlyAction(tr("FIND(what,where,pos)"), | 511 | addFlyAction(tr("FIND(what,where,pos)"), |
512 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); | 512 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); |
513 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); | 513 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); |
514 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); | 514 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); |
515 | submenuFuncString->insertSeparator(); | 515 | submenuFuncString->insertSeparator(); |
516 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); | 516 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); |
517 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); | 517 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); |
518 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); | 518 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); |
519 | 519 | ||
520 | submenuFuncStat=new QPopupMenu; | 520 | submenuFuncStat=new QPopupMenu; |
521 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 521 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
522 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); | 522 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); |
523 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); | 523 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); |
524 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); | 524 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); |
525 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); | 525 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); |
526 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); | 526 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); |
527 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); | 527 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); |
528 | submenuFuncStat->insertSeparator(); | 528 | submenuFuncStat->insertSeparator(); |
529 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 529 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
530 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); | 530 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); |
531 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); | 531 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); |
532 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); | 532 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); |
533 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); | 533 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); |
534 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); | 534 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); |
535 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); | 535 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); |
536 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); | 536 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); |
537 | 537 | ||
538 | submenuFuncScientific=new QPopupMenu; | 538 | submenuFuncScientific=new QPopupMenu; |
539 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); | 539 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); |
540 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); | 540 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); |
541 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); | 541 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); |
542 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); | 542 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); |
543 | submenuFuncScientific->insertSeparator(); | 543 | submenuFuncScientific->insertSeparator(); |
544 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); | 544 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); |
545 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); | 545 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); |
546 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); | 546 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); |
547 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); | 547 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); |
548 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); | 548 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); |
549 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); | 549 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); |
550 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); | 550 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); |
551 | 551 | ||
552 | submenuFuncDistr=new QPopupMenu; | 552 | submenuFuncDistr=new QPopupMenu; |
553 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); | 553 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); |
554 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); | 554 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); |
555 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); | 555 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); |
556 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); | 556 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); |
557 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); | 557 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); |
558 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); | 558 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); |
559 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); | 559 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); |
560 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); | 560 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); |
561 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); | 561 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); |
562 | 562 | ||
563 | 563 | ||
564 | 564 | ||
565 | menuInsert->insertSeparator(); | 565 | menuInsert->insertSeparator(); |
566 | insertCells->addTo(menuInsert); | 566 | insertCells->addTo(menuInsert); |
567 | insertRows->addTo(menuInsert); | 567 | insertRows->addTo(menuInsert); |
568 | insertCols->addTo(menuInsert); | 568 | insertCols->addTo(menuInsert); |
569 | insertSheets->addTo(menuInsert); | 569 | insertSheets->addTo(menuInsert); |
570 | } | 570 | } |
571 | 571 | ||
572 | void MainWindow::initStandardToolbar() | 572 | void MainWindow::initStandardToolbar() |
573 | { | 573 | { |
574 | toolbarStandard=new QToolBar(this); | 574 | toolbarStandard=new QToolBar(this); |
575 | toolbarStandard->setHorizontalStretchable(TRUE); | 575 | toolbarStandard->setHorizontalStretchable(TRUE); |
576 | moveToolBar(toolbarStandard, Top); | 576 | moveToolBar(toolbarStandard, Top); |
577 | 577 | ||
578 | fileNew->addTo(toolbarStandard); | 578 | fileNew->addTo(toolbarStandard); |
579 | fileOpen->addTo(toolbarStandard); | 579 | fileOpen->addTo(toolbarStandard); |
580 | fileSave->addTo(toolbarStandard); | 580 | fileSave->addTo(toolbarStandard); |
581 | 581 | ||
582 | comboSheets=new QComboBox(toolbarStandard); | 582 | comboSheets=new QComboBox(toolbarStandard); |
583 | toolbarStandard->setStretchableWidget(comboSheets); | 583 | toolbarStandard->setStretchableWidget(comboSheets); |
584 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 584 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); |
585 | } | 585 | } |
586 | 586 | ||
587 | void MainWindow::initFunctionsToolbar() | 587 | void MainWindow::initFunctionsToolbar() |
588 | { | 588 | { |
589 | toolbarFunctions=new QToolBar(this); | 589 | toolbarFunctions=new QToolBar(this); |
590 | toolbarFunctions->setHorizontalStretchable(TRUE); | 590 | toolbarFunctions->setHorizontalStretchable(TRUE); |
591 | moveToolBar(toolbarFunctions, Bottom); | 591 | moveToolBar(toolbarFunctions, Bottom); |
592 | 592 | ||
593 | funcEqual->addTo(toolbarFunctions); | 593 | funcEqual->addTo(toolbarFunctions); |
594 | funcPlus->addTo(toolbarFunctions); | 594 | funcPlus->addTo(toolbarFunctions); |
595 | funcMinus->addTo(toolbarFunctions); | 595 | funcMinus->addTo(toolbarFunctions); |
596 | funcCross->addTo(toolbarFunctions); | 596 | funcCross->addTo(toolbarFunctions); |
597 | funcDivide->addTo(toolbarFunctions); | 597 | funcDivide->addTo(toolbarFunctions); |
598 | funcParanOpen->addTo(toolbarFunctions); | 598 | funcParanOpen->addTo(toolbarFunctions); |
599 | funcParanClose->addTo(toolbarFunctions); | 599 | funcParanClose->addTo(toolbarFunctions); |
600 | funcComma->addTo(toolbarFunctions); | 600 | funcComma->addTo(toolbarFunctions); |
601 | 601 | ||
602 | toolFunction=new QToolButton(toolbarFunctions); | 602 | toolFunction=new QToolButton(toolbarFunctions); |
603 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func_func" )); | 603 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); |
604 | toolFunction->setTextLabel(tr("Functions")); | 604 | toolFunction->setTextLabel(tr("Functions")); |
605 | toolFunction->setPopup(submenuFunc); | 605 | toolFunction->setPopup(submenuFunc); |
606 | toolFunction->setPopupDelay(0); | 606 | toolFunction->setPopupDelay(0); |
607 | } | 607 | } |
608 | 608 | ||
609 | void MainWindow::initEditToolbar() | 609 | void MainWindow::initEditToolbar() |
610 | { | 610 | { |
611 | toolbarEdit=new QToolBar(this); | 611 | toolbarEdit=new QToolBar(this); |
612 | toolbarEdit->setHorizontalStretchable(TRUE); | 612 | toolbarEdit->setHorizontalStretchable(TRUE); |
613 | moveToolBar(toolbarEdit, Bottom); | 613 | moveToolBar(toolbarEdit, Bottom); |
614 | 614 | ||
615 | editAccept->addTo(toolbarEdit); | 615 | editAccept->addTo(toolbarEdit); |
616 | editCancel->addTo(toolbarEdit); | 616 | editCancel->addTo(toolbarEdit); |
617 | 617 | ||
618 | editData=new QLineEdit(toolbarEdit); | 618 | editData=new QLineEdit(toolbarEdit); |
619 | toolbarEdit->setStretchableWidget(editData); | 619 | toolbarEdit->setStretchableWidget(editData); |
620 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 620 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
621 | 621 | ||
622 | editCellSelect->addTo(toolbarEdit); | 622 | editCellSelect->addTo(toolbarEdit); |
623 | } | 623 | } |
624 | 624 | ||
625 | void MainWindow::slotHelpAbout() | 625 | void MainWindow::slotHelpAbout() |
626 | { | 626 | { |
627 | QDialog dialogAbout(this, 0, TRUE); | 627 | QDialog dialogAbout(this, 0, TRUE); |
628 | dialogAbout.resize(width()-40, height()-80); | 628 | dialogAbout.resize(width()-40, height()-80); |
629 | dialogAbout.setCaption(tr("About Opie Sheet")); | 629 | dialogAbout.setCaption(tr("About Opie Sheet")); |
630 | 630 | ||
631 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 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); | 631 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 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); |
632 | label.setGeometry(dialogAbout.rect()); | 632 | label.setGeometry(dialogAbout.rect()); |
633 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 633 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
634 | 634 | ||
635 | dialogAbout.exec(); | 635 | dialogAbout.exec(); |
636 | } | 636 | } |
637 | 637 | ||
638 | void MainWindow::initSheet() | 638 | void MainWindow::initSheet() |
639 | { | 639 | { |
640 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 640 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
641 | setCentralWidget(sheet); | 641 | setCentralWidget(sheet); |
642 | 642 | ||
643 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 643 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); |
644 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 644 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); |
645 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 645 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
646 | 646 | ||
647 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 647 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
648 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 648 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
649 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 649 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
650 | } | 650 | } |
651 | 651 | ||
652 | void MainWindow::slotEditAccept() | 652 | void MainWindow::slotEditAccept() |
653 | { | 653 | { |
654 | sheet->setData(editData->text()); | 654 | sheet->setData(editData->text()); |
655 | } | 655 | } |
656 | 656 | ||
657 | void MainWindow::slotEditCancel() | 657 | void MainWindow::slotEditCancel() |
658 | { | 658 | { |
659 | editData->setText(sheet->getData()); | 659 | editData->setText(sheet->getData()); |
660 | } | 660 | } |
661 | 661 | ||
662 | void MainWindow::slotCellSelect(bool lock) | 662 | void MainWindow::slotCellSelect(bool lock) |
663 | { | 663 | { |
664 | sheet->lockClicks(lock); | 664 | sheet->lockClicks(lock); |
665 | } | 665 | } |
666 | 666 | ||
667 | void MainWindow::addToData(const QString &data) | 667 | void MainWindow::addToData(const QString &data) |
668 | { | 668 | { |
669 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 669 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
670 | } | 670 | } |
671 | 671 | ||
672 | void MainWindow::slotFuncOutput() | 672 | void MainWindow::slotFuncOutput() |
673 | { | 673 | { |
674 | if (sender()->isA("QAction")) | 674 | if (sender()->isA("QAction")) |
675 | addToData(((QAction *)sender())->toolTip()); | 675 | addToData(((QAction *)sender())->toolTip()); |
676 | } | 676 | } |
677 | 677 | ||
678 | void MainWindow::slotInsertRows() | 678 | void MainWindow::slotInsertRows() |
679 | { | 679 | { |
680 | NumberDialog dialogNumber(this); | 680 | NumberDialog dialogNumber(this); |
681 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 681 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
682 | sheet->insertRows(dialogNumber.getValue()); | 682 | sheet->insertRows(dialogNumber.getValue()); |
683 | } | 683 | } |
684 | 684 | ||
685 | void MainWindow::slotInsertCols() | 685 | void MainWindow::slotInsertCols() |
686 | { | 686 | { |
687 | NumberDialog dialogNumber(this); | 687 | NumberDialog dialogNumber(this); |
688 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 688 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
689 | sheet->insertColumns(dialogNumber.getValue()); | 689 | sheet->insertColumns(dialogNumber.getValue()); |
690 | } | 690 | } |
691 | 691 | ||
692 | void MainWindow::slotInsertSheets() | 692 | void MainWindow::slotInsertSheets() |
693 | { | 693 | { |
694 | NumberDialog dialogNumber(this); | 694 | NumberDialog dialogNumber(this); |
695 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 695 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
696 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 696 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
697 | } | 697 | } |
698 | 698 | ||
699 | void MainWindow::slotCellClicked(const QString &cell) | 699 | void MainWindow::slotCellClicked(const QString &cell) |
700 | { | 700 | { |
701 | editCellSelect->setOn(FALSE); | 701 | editCellSelect->setOn(FALSE); |
702 | addToData(cell); | 702 | addToData(cell); |
703 | } | 703 | } |
704 | 704 | ||
705 | typeSheet *MainWindow::createNewSheet() | 705 | typeSheet *MainWindow::createNewSheet() |
706 | { | 706 | { |
707 | typeSheet *newSheet=new typeSheet; | 707 | typeSheet *newSheet=new typeSheet; |
708 | int currentNo=1, tempNo=0; | 708 | int currentNo=1, tempNo=0; |
709 | bool ok; | 709 | bool ok; |
710 | 710 | ||
711 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 711 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
712 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 712 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
713 | currentNo=tempNo+1; | 713 | currentNo=tempNo+1; |
714 | 714 | ||
715 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 715 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
716 | newSheet->data.setAutoDelete(TRUE); | 716 | newSheet->data.setAutoDelete(TRUE); |
717 | 717 | ||
718 | comboSheets->insertItem(newSheet->name); | 718 | comboSheets->insertItem(newSheet->name); |
719 | listSheets.append(newSheet); | 719 | listSheets.append(newSheet); |
720 | return newSheet; | 720 | return newSheet; |
721 | } | 721 | } |
722 | 722 | ||
723 | typeSheet *MainWindow::findSheet(const QString &name) | 723 | typeSheet *MainWindow::findSheet(const QString &name) |
724 | { | 724 | { |
725 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 725 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
726 | if (tempSheet->name==name) | 726 | if (tempSheet->name==name) |
727 | return tempSheet; | 727 | return tempSheet; |
728 | return NULL; | 728 | return NULL; |
729 | } | 729 | } |
730 | 730 | ||
731 | void MainWindow::slotSheetChanged(const QString &name) | 731 | void MainWindow::slotSheetChanged(const QString &name) |
732 | { | 732 | { |
733 | sheet->copySheetData(&findSheet(sheet->getName())->data); | 733 | sheet->copySheetData(&findSheet(sheet->getName())->data); |
734 | sheet->setName(name); | 734 | sheet->setName(name); |
735 | sheet->setSheetData(&findSheet(name)->data); | 735 | sheet->setSheetData(&findSheet(name)->data); |
736 | sheet->ReCalc(); | 736 | sheet->ReCalc(); |
737 | } | 737 | } |
738 | 738 | ||
739 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) | 739 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) |
740 | { | 740 | { |
741 | QAction *action=new QAction(text, menuText, 0, this); | 741 | QAction *action=new QAction(text, menuText, 0, this); |
742 | action->setToolTip(tip); | 742 | action->setToolTip(tip); |
743 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 743 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
744 | action->addTo(w); | 744 | action->addTo(w); |
745 | } | 745 | } |
746 | 746 | ||
747 | void MainWindow::slotFormatCells() | 747 | void MainWindow::slotFormatCells() |
748 | { | 748 | { |
749 | CellFormat dialogCellFormat(this); | 749 | CellFormat dialogCellFormat(this); |
750 | dialogCellFormat.showMaximized(); | 750 | dialogCellFormat.showMaximized(); |
751 | dialogCellFormat.exec(sheet); | 751 | dialogCellFormat.exec(sheet); |
752 | } | 752 | } |
753 | 753 | ||
754 | void MainWindow::slotEditPaste() | 754 | void MainWindow::slotEditPaste() |
755 | { | 755 | { |
756 | sheet->editPaste(); | 756 | sheet->editPaste(); |
757 | } | 757 | } |
758 | 758 | ||
759 | void MainWindow::slotEditPasteContents() | 759 | void MainWindow::slotEditPasteContents() |
760 | { | 760 | { |
761 | sheet->editPaste(TRUE); | 761 | sheet->editPaste(TRUE); |
762 | } | 762 | } |
763 | 763 | ||
764 | void MainWindow::slotRowHeight() | 764 | void MainWindow::slotRowHeight() |
765 | { | 765 | { |
766 | int row1, row2, col1, col2; | 766 | int row1, row2, col1, col2; |
767 | sheet->getSelection(&row1, &col1, &row2, &col2); | 767 | sheet->getSelection(&row1, &col1, &row2, &col2); |
768 | 768 | ||
769 | NumberDialog dialogNumber(this); | 769 | NumberDialog dialogNumber(this); |
770 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) | 770 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) |
771 | { | 771 | { |
772 | int newHeight=dialogNumber.getValue(), row; | 772 | int newHeight=dialogNumber.getValue(), row; |
773 | for (row=row1; row<=row2; ++row) | 773 | for (row=row1; row<=row2; ++row) |
774 | sheet->setRowHeight(row, newHeight); | 774 | sheet->setRowHeight(row, newHeight); |
775 | } | 775 | } |
776 | } | 776 | } |
777 | 777 | ||
778 | void MainWindow::slotRowAdjust() | 778 | void MainWindow::slotRowAdjust() |
779 | { | 779 | { |
780 | int row1, row2, col1, col2; | 780 | int row1, row2, col1, col2; |
781 | sheet->getSelection(&row1, &col1, &row2, &col2); | 781 | sheet->getSelection(&row1, &col1, &row2, &col2); |
782 | 782 | ||
783 | for (int row=row1; row<=row2; ++row) | 783 | for (int row=row1; row<=row2; ++row) |
784 | sheet->adjustRow(row); | 784 | sheet->adjustRow(row); |
785 | } | 785 | } |
786 | 786 | ||
787 | void MainWindow::slotRowShow() | 787 | void MainWindow::slotRowShow() |
788 | { | 788 | { |
789 | int row1, row2, col1, col2; | 789 | int row1, row2, col1, col2; |
790 | sheet->getSelection(&row1, &col1, &row2, &col2); | 790 | sheet->getSelection(&row1, &col1, &row2, &col2); |
791 | 791 | ||
792 | for (int row=row1; row<=row2; ++row) | 792 | for (int row=row1; row<=row2; ++row) |
793 | sheet->showRow(row); | 793 | sheet->showRow(row); |
794 | } | 794 | } |
795 | 795 | ||
796 | void MainWindow::slotRowHide() | 796 | void MainWindow::slotRowHide() |
797 | { | 797 | { |
798 | int row1, row2, col1, col2; | 798 | int row1, row2, col1, col2; |
799 | sheet->getSelection(&row1, &col1, &row2, &col2); | 799 | sheet->getSelection(&row1, &col1, &row2, &col2); |
800 | 800 | ||
801 | for (int row=row1; row<=row2; ++row) | 801 | for (int row=row1; row<=row2; ++row) |
802 | sheet->hideRow(row); | 802 | sheet->hideRow(row); |
803 | } | 803 | } |
804 | 804 | ||
805 | void MainWindow::slotColumnWidth() | 805 | void MainWindow::slotColumnWidth() |
806 | { | 806 | { |
807 | int row1, row2, col1, col2; | 807 | int row1, row2, col1, col2; |
808 | sheet->getSelection(&row1, &col1, &row2, &col2); | 808 | sheet->getSelection(&row1, &col1, &row2, &col2); |
809 | 809 | ||
810 | NumberDialog dialogNumber(this); | 810 | NumberDialog dialogNumber(this); |
811 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) | 811 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) |
812 | { | 812 | { |
813 | int newWidth=dialogNumber.getValue(), col; | 813 | int newWidth=dialogNumber.getValue(), col; |
814 | for (col=col1; col<=col2; ++col) | 814 | for (col=col1; col<=col2; ++col) |
815 | sheet->setColumnWidth(col, newWidth); | 815 | sheet->setColumnWidth(col, newWidth); |
816 | } | 816 | } |
817 | } | 817 | } |
818 | 818 | ||
819 | void MainWindow::slotColumnAdjust() | 819 | void MainWindow::slotColumnAdjust() |
820 | { | 820 | { |
821 | int row1, row2, col1, col2; | 821 | int row1, row2, col1, col2; |
822 | sheet->getSelection(&row1, &col1, &row2, &col2); | 822 | sheet->getSelection(&row1, &col1, &row2, &col2); |
823 | 823 | ||
824 | for (int col=col1; col<=col2; ++col) | 824 | for (int col=col1; col<=col2; ++col) |
825 | sheet->adjustColumn(col); | 825 | sheet->adjustColumn(col); |
826 | } | 826 | } |
827 | 827 | ||
828 | void MainWindow::slotColumnShow() | 828 | void MainWindow::slotColumnShow() |
829 | { | 829 | { |
830 | int row1, row2, col1, col2; | 830 | int row1, row2, col1, col2; |
831 | sheet->getSelection(&row1, &col1, &row2, &col2); | 831 | sheet->getSelection(&row1, &col1, &row2, &col2); |
832 | 832 | ||
833 | for (int col=col1; col<=col2; ++col) | 833 | for (int col=col1; col<=col2; ++col) |
834 | sheet->showColumn(col); | 834 | sheet->showColumn(col); |
835 | } | 835 | } |
836 | 836 | ||
837 | void MainWindow::slotColumnHide() | 837 | void MainWindow::slotColumnHide() |
838 | { | 838 | { |
839 | int row1, row2, col1, col2; | 839 | int row1, row2, col1, col2; |
840 | sheet->getSelection(&row1, &col1, &row2, &col2); | 840 | sheet->getSelection(&row1, &col1, &row2, &col2); |
841 | 841 | ||
842 | for (int col=col1; col<=col2; ++col) | 842 | for (int col=col1; col<=col2; ++col) |
843 | sheet->hideColumn(col); | 843 | sheet->hideColumn(col); |
844 | } | 844 | } |
845 | 845 | ||
846 | void MainWindow::slotFileSaveAs() | 846 | void MainWindow::slotFileSaveAs() |
847 | { | 847 | { |
848 | TextDialog dialogText(this); | 848 | TextDialog dialogText(this); |
849 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 849 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
850 | 850 | ||
851 | currentDoc->setName(dialogText.getValue()); | 851 | currentDoc->setName(dialogText.getValue()); |
852 | currentDoc->setFile(QString::null); | 852 | currentDoc->setFile(QString::null); |
853 | currentDoc->setLinkFile(QString::null); | 853 | currentDoc->setLinkFile(QString::null); |
854 | documentSave(currentDoc); | 854 | documentSave(currentDoc); |
855 | } | 855 | } |
856 | 856 | ||
857 | void MainWindow::slotImportExcel(const DocLnk &lnkDoc) | 857 | void MainWindow::slotImportExcel(const DocLnk &lnkDoc) |
858 | { | 858 | { |
859 | ExcelBook file1; | 859 | ExcelBook file1; |
860 | file1.ParseBook((char *)lnkDoc.file().ascii()); | 860 | file1.ParseBook((char *)lnkDoc.file().ascii()); |
861 | int NumOfSheets=file1.Sheets.count(); | 861 | int NumOfSheets=file1.Sheets.count(); |
862 | printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); | 862 | printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); |
863 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 863 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
864 | if (currentDoc) delete currentDoc; | 864 | if (currentDoc) delete currentDoc; |
865 | currentDoc = new DocLnk(); | 865 | currentDoc = new DocLnk(); |
866 | listSheets.clear(); | 866 | listSheets.clear(); |
867 | comboSheets->clear(); | 867 | comboSheets->clear(); |
868 | int w1,r,c; | 868 | int w1,r,c; |
869 | ExcelSheet* sh1; | 869 | ExcelSheet* sh1; |
870 | typeSheet* newSheet; | 870 | typeSheet* newSheet; |
871 | QString* str; | 871 | QString* str; |
872 | typeCellData* newCell; | 872 | typeCellData* newCell; |
873 | for(w1=1;w1<=NumOfSheets;w1++) | 873 | for(w1=1;w1<=NumOfSheets;w1++) |
874 | { | 874 | { |
875 | sh1=file1.Sheets[w1-1]; | 875 | sh1=file1.Sheets[w1-1]; |
876 | printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); | 876 | printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); |
877 | newSheet=new typeSheet; | 877 | newSheet=new typeSheet; |
878 | newSheet->data.setAutoDelete(TRUE); | 878 | newSheet->data.setAutoDelete(TRUE); |
879 | newSheet->name=sh1->name; | 879 | newSheet->name=sh1->name; |
880 | printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii()); | 880 | printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii()); |
881 | comboSheets->insertItem(newSheet->name); | 881 | comboSheets->insertItem(newSheet->name); |
882 | for(r=1; r <= sh1->rows; r++) | 882 | for(r=1; r <= sh1->rows; r++) |
883 | { | 883 | { |
884 | for(c=1;c <= sh1->cols; c++) | 884 | for(c=1;c <= sh1->cols; c++) |
885 | { | 885 | { |
886 | str=file1.CellDataString(sh1,r-1,c-1); | 886 | str=file1.CellDataString(sh1,r-1,c-1); |
887 | if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS) | 887 | if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS) |
888 | { | 888 | { |
889 | newCell=new typeCellData; | 889 | newCell=new typeCellData; |
890 | newCell->row=r-1; | 890 | newCell->row=r-1; |
891 | newCell->col=c-1; | 891 | newCell->col=c-1; |
892 | if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString(""); | 892 | if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString(""); |
893 | newCell->background=QBrush(Qt::white, Qt::SolidPattern); | 893 | newCell->background=QBrush(Qt::white, Qt::SolidPattern); |
894 | newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); | 894 | newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); |
895 | newCell->fontColor=Qt::black; | 895 | newCell->fontColor=Qt::black; |
896 | newCell->font=font(); | 896 | newCell->font=font(); |
897 | newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine); | 897 | newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine); |
898 | newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); | 898 | newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); |
899 | newSheet->data.append(newCell); | 899 | newSheet->data.append(newCell); |
900 | //there is no format parsing at the moment or style parsing | 900 | //there is no format parsing at the moment or style parsing |
901 | //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1()); | 901 | //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1()); |
902 | }; | 902 | }; |
903 | }; | 903 | }; |
904 | }; | 904 | }; |
905 | listSheets.append(newSheet); | 905 | listSheets.append(newSheet); |
906 | if (w1==1)//if i==0 link sheet1 with sheetview | 906 | if (w1==1)//if i==0 link sheet1 with sheetview |
907 | { | 907 | { |
908 | sheet->setName(newSheet->name); | 908 | sheet->setName(newSheet->name); |
909 | sheet->setSheetData(&newSheet->data); | 909 | sheet->setSheetData(&newSheet->data); |
910 | sheet->ReCalc(); | 910 | sheet->ReCalc(); |
911 | }; | 911 | }; |
912 | 912 | ||
913 | }; | 913 | }; |
914 | file1.CloseFile(); | 914 | file1.CloseFile(); |
915 | printf("Excel FILE read OK\r\n"); | 915 | printf("Excel FILE read OK\r\n"); |
916 | documentModified=TRUE; | 916 | documentModified=TRUE; |
917 | 917 | ||
918 | 918 | ||
919 | } | 919 | } |
920 | 920 | ||
921 | void MainWindow::slotSheetRename() | 921 | void MainWindow::slotSheetRename() |
922 | { | 922 | { |
923 | TextDialog dialogText(this); | 923 | TextDialog dialogText(this); |
924 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 924 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
925 | QString newName=dialogText.getValue(); | 925 | QString newName=dialogText.getValue(); |
926 | 926 | ||
927 | typeSheet *tempSheet=findSheet(newName); | 927 | typeSheet *tempSheet=findSheet(newName); |
928 | if (tempSheet) | 928 | if (tempSheet) |
929 | { | 929 | { |
930 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); | 930 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); |
931 | return; | 931 | return; |
932 | } | 932 | } |
933 | 933 | ||
934 | tempSheet=findSheet(sheet->getName()); | 934 | tempSheet=findSheet(sheet->getName()); |
935 | for (int i=0; i<comboSheets->count(); ++i) | 935 | for (int i=0; i<comboSheets->count(); ++i) |
936 | if (comboSheets->text(i)==tempSheet->name) | 936 | if (comboSheets->text(i)==tempSheet->name) |
937 | { | 937 | { |
938 | comboSheets->changeItem(newName, i); | 938 | comboSheets->changeItem(newName, i); |
939 | break; | 939 | break; |
940 | } | 940 | } |
941 | tempSheet->name=newName; | 941 | tempSheet->name=newName; |
942 | sheet->setName(newName); | 942 | sheet->setName(newName); |
943 | } | 943 | } |
944 | 944 | ||
945 | void MainWindow::slotSheetRemove() | 945 | void MainWindow::slotSheetRemove() |
946 | { | 946 | { |
947 | if (comboSheets->count()<2) | 947 | if (comboSheets->count()<2) |
948 | { | 948 | { |
949 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); | 949 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); |
950 | return; | 950 | return; |
951 | } | 951 | } |
952 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) | 952 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) |
953 | { | 953 | { |
954 | typeSheet *tempSheet=findSheet(sheet->getName()); | 954 | typeSheet *tempSheet=findSheet(sheet->getName()); |
955 | for (int i=0; i<comboSheets->count(); ++i) | 955 | for (int i=0; i<comboSheets->count(); ++i) |
956 | if (comboSheets->text(i)==tempSheet->name) | 956 | if (comboSheets->text(i)==tempSheet->name) |
957 | { | 957 | { |
958 | comboSheets->removeItem(i); | 958 | comboSheets->removeItem(i); |
959 | break; | 959 | break; |
960 | } | 960 | } |
961 | comboSheets->setCurrentItem(0); | 961 | comboSheets->setCurrentItem(0); |
962 | slotSheetChanged(comboSheets->currentText()); | 962 | slotSheetChanged(comboSheets->currentText()); |
963 | listSheets.remove(tempSheet); | 963 | listSheets.remove(tempSheet); |
964 | } | 964 | } |
965 | } | 965 | } |
966 | 966 | ||
967 | void MainWindow::slotDataSort() | 967 | void MainWindow::slotDataSort() |
968 | { | 968 | { |
969 | SortDialog dialogSort(this); | 969 | SortDialog dialogSort(this); |
970 | dialogSort.showMaximized(); | 970 | dialogSort.showMaximized(); |
971 | dialogSort.exec(sheet); | 971 | dialogSort.exec(sheet); |
972 | } | 972 | } |
973 | 973 | ||
974 | void MainWindow::slotDocModified() | 974 | void MainWindow::slotDocModified() |
975 | { | 975 | { |
976 | documentModified=TRUE; | 976 | documentModified=TRUE; |
977 | } | 977 | } |
978 | 978 | ||
979 | void MainWindow::slotInsertCells() | 979 | void MainWindow::slotInsertCells() |
980 | { | 980 | { |
981 | QDialog dialogInsert(this, 0, TRUE); | 981 | QDialog dialogInsert(this, 0, TRUE); |
982 | dialogInsert.resize(180, 130); | 982 | dialogInsert.resize(180, 130); |
983 | dialogInsert.setCaption(tr("Insert Cells")); | 983 | dialogInsert.setCaption(tr("Insert Cells")); |
984 | 984 | ||
985 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); | 985 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); |
986 | group->setGeometry(10, 10, 160, 110); | 986 | group->setGeometry(10, 10, 160, 110); |
987 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); | 987 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); |
988 | radio=new QRadioButton(tr("Shift cells &right"), group); | 988 | radio=new QRadioButton(tr("Shift cells &right"), group); |
989 | radio=new QRadioButton(tr("Entire ro&w"), group); | 989 | radio=new QRadioButton(tr("Entire ro&w"), group); |
990 | radio=new QRadioButton(tr("Entire &column"), group); | 990 | radio=new QRadioButton(tr("Entire &column"), group); |
991 | group->setButton(0); | 991 | group->setButton(0); |
992 | 992 | ||
993 | if (dialogInsert.exec()==QDialog::Accepted) | 993 | if (dialogInsert.exec()==QDialog::Accepted) |
994 | switch (group->id(group->selected())) | 994 | switch (group->id(group->selected())) |
995 | { | 995 | { |
996 | case 0: sheet->insertRows(1, FALSE); break; | 996 | case 0: sheet->insertRows(1, FALSE); break; |
997 | case 1: sheet->insertColumns(1, FALSE); break; | 997 | case 1: sheet->insertColumns(1, FALSE); break; |
998 | case 2: sheet->insertRows(1, TRUE); break; | 998 | case 2: sheet->insertRows(1, TRUE); break; |
999 | case 3: sheet->insertColumns(1, TRUE); break; | 999 | case 3: sheet->insertColumns(1, TRUE); break; |
1000 | } | 1000 | } |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void MainWindow::slotDataFindReplace() | 1003 | void MainWindow::slotDataFindReplace() |
1004 | { | 1004 | { |
1005 | FindDialog dialogFind(this); | 1005 | FindDialog dialogFind(this); |
1006 | dialogFind.showMaximized(); | 1006 | dialogFind.showMaximized(); |
1007 | dialogFind.exec(sheet); | 1007 | dialogFind.exec(sheet); |
1008 | } | 1008 | } |