author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/opie-sheet/mainwindow.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/apps/opie-sheet/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 1fb2a3d..061748e 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -1,142 +1,142 @@ | |||
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/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | 19 | ||
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qradiobutton.h> | 21 | #include <qradiobutton.h> |
22 | 22 | ||
23 | #include "cellformat.h" | 23 | #include "cellformat.h" |
24 | #include "numberdlg.h" | 24 | #include "numberdlg.h" |
25 | #include "textdlg.h" | 25 | #include "textdlg.h" |
26 | #include "sortdlg.h" | 26 | #include "sortdlg.h" |
27 | #include "finddlg.h" | 27 | #include "finddlg.h" |
28 | 28 | ||
29 | #define DEFAULT_NUM_ROWS 300 | 29 | #define DEFAULT_NUM_ROWS 300 |
30 | #define DEFAULT_NUM_COLS (26*3) | 30 | #define DEFAULT_NUM_COLS (26*3) |
31 | #define DEFAULT_NUM_SHEETS 3 | 31 | #define DEFAULT_NUM_SHEETS 3 |
32 | 32 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) | 33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
34 | :QMainWindow(parent, n, fl) | 34 | :QMainWindow(parent, n, fl) |
35 | { | 35 | { |
36 | // initialize variables | 36 | // initialize variables |
37 | documentModified=FALSE; | 37 | documentModified=FALSE; |
38 | 38 | ||
39 | // construct objects | 39 | // construct objects |
40 | currentDoc=0; | 40 | currentDoc=0; |
41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); | 42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); |
43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&))); |
45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&))); |
46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); | 46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&))); |
47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); | 47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); |
48 | 48 | ||
49 | 49 | ||
50 | listSheets.setAutoDelete(TRUE); | 50 | listSheets.setAutoDelete(TRUE); |
51 | 51 | ||
52 | initActions(); | 52 | initActions(); |
53 | initMenu(); | 53 | initMenu(); |
54 | initEditToolbar(); | 54 | initEditToolbar(); |
55 | initFunctionsToolbar(); | 55 | initFunctionsToolbar(); |
56 | initStandardToolbar(); | 56 | initStandardToolbar(); |
57 | initSheet(); | 57 | initSheet(); |
58 | 58 | ||
59 | // set window title | 59 | // set window title |
60 | setCaption(tr("Opie Sheet")); | 60 | setCaption(tr("Opie Sheet")); |
61 | 61 | ||
62 | // create sheets | 62 | // create sheets |
63 | selectorFileNew(DocLnk()); | 63 | selectorFileNew(DocLnk()); |
64 | } | 64 | } |
65 | 65 | ||
66 | MainWindow::~MainWindow() | 66 | MainWindow::~MainWindow() |
67 | { | 67 | { |
68 | if (currentDoc) delete currentDoc; | 68 | if (currentDoc) delete currentDoc; |
69 | } | 69 | } |
70 | 70 | ||
71 | void MainWindow::documentSave(DocLnk *lnkDoc) | 71 | void MainWindow::documentSave(DocLnk *lnkDoc) |
72 | { | 72 | { |
73 | FileManager fm; | 73 | FileManager fm; |
74 | QByteArray streamBuffer; | 74 | QByteArray streamBuffer; |
75 | QDataStream stream(streamBuffer, IO_WriteOnly); | 75 | QDataStream stream(streamBuffer, IO_WriteOnly); |
76 | 76 | ||
77 | typeSheet *currentSheet=findSheet(sheet->getName()); | 77 | typeSheet *currentSheet=findSheet(sheet->getName()); |
78 | if (!currentSheet) | 78 | if (!currentSheet) |
79 | { | 79 | { |
80 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); | 80 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); |
81 | return; | 81 | return; |
82 | } | 82 | } |
83 | sheet->copySheetData(¤tSheet->data); | 83 | sheet->copySheetData(¤tSheet->data); |
84 | stream.writeRawBytes("SQT100", 6); | 84 | stream.writeRawBytes("SQT100", 6); |
85 | stream << (Q_UINT32)listSheets.count(); | 85 | stream << (Q_UINT32)listSheets.count(); |
86 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 86 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
87 | { | 87 | { |
88 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 88 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
89 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 89 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
90 | 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; | 90 | 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 | } | 91 | } |
92 | 92 | ||
93 | lnkDoc->setType("application/sheet-qt"); | 93 | lnkDoc->setType("application/sheet-qt"); |
94 | if (!fm.saveFile(*lnkDoc, streamBuffer)) | 94 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
95 | { | 95 | { |
96 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 96 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | documentModified=FALSE; | 99 | documentModified=FALSE; |
100 | } | 100 | } |
101 | 101 | ||
102 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 102 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
103 | { | 103 | { |
104 | FileManager fm; | 104 | FileManager fm; |
105 | QByteArray streamBuffer; | 105 | QByteArray streamBuffer; |
106 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 106 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
107 | { | 107 | { |
108 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 108 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
109 | documentModified=FALSE; | 109 | documentModified=FALSE; |
110 | selectorFileNew(DocLnk()); | 110 | selectorFileNew(DocLnk()); |
111 | return; | 111 | return; |
112 | } | 112 | } |
113 | QDataStream stream(streamBuffer, IO_ReadOnly); | 113 | QDataStream stream(streamBuffer, IO_ReadOnly); |
114 | 114 | ||
115 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 115 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
116 | typeSheet *newSheet; | 116 | typeSheet *newSheet; |
117 | typeCellData *newCell; | 117 | typeCellData *newCell; |
118 | 118 | ||
119 | char fileFormat[7]; | 119 | char fileFormat[7]; |
120 | stream.readRawBytes(fileFormat, 6); | 120 | stream.readRawBytes(fileFormat, 6); |
121 | fileFormat[6]=0; | 121 | fileFormat[6]=0; |
122 | if ((QString)fileFormat!="SQT100") | 122 | if ((QString)fileFormat!="SQT100") |
123 | { | 123 | { |
124 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 124 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
125 | documentModified=FALSE; | 125 | documentModified=FALSE; |
126 | selectorFileNew(DocLnk()); | 126 | selectorFileNew(DocLnk()); |
127 | return; | 127 | return; |
128 | } | 128 | } |
129 | 129 | ||
130 | stream >> countSheet; | 130 | stream >> countSheet; |
131 | for (i=0; i<countSheet; ++i) | 131 | for (i=0; i<countSheet; ++i) |
132 | { | 132 | { |
133 | newSheet=new typeSheet; | 133 | newSheet=new typeSheet; |
134 | newSheet->data.setAutoDelete(TRUE); | 134 | newSheet->data.setAutoDelete(TRUE); |
135 | stream >> newSheet->name >> countCell; | 135 | stream >> newSheet->name >> countCell; |
136 | comboSheets->insertItem(newSheet->name); | 136 | comboSheets->insertItem(newSheet->name); |
137 | 137 | ||
138 | for (j=0; j<countCell; ++j) | 138 | for (j=0; j<countCell; ++j) |
139 | { | 139 | { |
140 | newCell=new typeCellData; | 140 | newCell=new typeCellData; |
141 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 141 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
142 | newCell->col=col; | 142 | newCell->col=col; |
@@ -487,253 +487,253 @@ void MainWindow::initMenu() | |||
487 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); | 487 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); |
488 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); | 488 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); |
489 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); | 489 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); |
490 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); | 490 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); |
491 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); | 491 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); |
492 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); | 492 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); |
493 | submenuFuncTrig->insertSeparator(); | 493 | submenuFuncTrig->insertSeparator(); |
494 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); | 494 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); |
495 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); | 495 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); |
496 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); | 496 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); |
497 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); | 497 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); |
498 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); | 498 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); |
499 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); | 499 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); |
500 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); | 500 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); |
501 | 501 | ||
502 | submenuFuncString=new QPopupMenu; | 502 | submenuFuncString=new QPopupMenu; |
503 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); | 503 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); |
504 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); | 504 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); |
505 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); | 505 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); |
506 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); | 506 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); |
507 | submenuFuncString->insertSeparator(); | 507 | submenuFuncString->insertSeparator(); |
508 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); | 508 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); |
509 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); | 509 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); |
510 | addFlyAction(tr("FIND(what,where,pos)"), | 510 | addFlyAction(tr("FIND(what,where,pos)"), |
511 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); | 511 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); |
512 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); | 512 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); |
513 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); | 513 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); |
514 | submenuFuncString->insertSeparator(); | 514 | submenuFuncString->insertSeparator(); |
515 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); | 515 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); |
516 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); | 516 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); |
517 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); | 517 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); |
518 | 518 | ||
519 | submenuFuncStat=new QPopupMenu; | 519 | submenuFuncStat=new QPopupMenu; |
520 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 520 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
521 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); | 521 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); |
522 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); | 522 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); |
523 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); | 523 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); |
524 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); | 524 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); |
525 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); | 525 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); |
526 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); | 526 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); |
527 | submenuFuncStat->insertSeparator(); | 527 | submenuFuncStat->insertSeparator(); |
528 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 528 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
529 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); | 529 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); |
530 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); | 530 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); |
531 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); | 531 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); |
532 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); | 532 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); |
533 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); | 533 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); |
534 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); | 534 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); |
535 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); | 535 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); |
536 | 536 | ||
537 | submenuFuncScientific=new QPopupMenu; | 537 | submenuFuncScientific=new QPopupMenu; |
538 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); | 538 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); |
539 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); | 539 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); |
540 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); | 540 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); |
541 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); | 541 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); |
542 | submenuFuncScientific->insertSeparator(); | 542 | submenuFuncScientific->insertSeparator(); |
543 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); | 543 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); |
544 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); | 544 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); |
545 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); | 545 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); |
546 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); | 546 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); |
547 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); | 547 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); |
548 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); | 548 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); |
549 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); | 549 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); |
550 | 550 | ||
551 | submenuFuncDistr=new QPopupMenu; | 551 | submenuFuncDistr=new QPopupMenu; |
552 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); | 552 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); |
553 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); | 553 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); |
554 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); | 554 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); |
555 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); | 555 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); |
556 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); | 556 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); |
557 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); | 557 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); |
558 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); | 558 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); |
559 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); | 559 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); |
560 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); | 560 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); |
561 | 561 | ||
562 | 562 | ||
563 | 563 | ||
564 | menuInsert->insertSeparator(); | 564 | menuInsert->insertSeparator(); |
565 | insertCells->addTo(menuInsert); | 565 | insertCells->addTo(menuInsert); |
566 | insertRows->addTo(menuInsert); | 566 | insertRows->addTo(menuInsert); |
567 | insertCols->addTo(menuInsert); | 567 | insertCols->addTo(menuInsert); |
568 | insertSheets->addTo(menuInsert); | 568 | insertSheets->addTo(menuInsert); |
569 | } | 569 | } |
570 | 570 | ||
571 | void MainWindow::initStandardToolbar() | 571 | void MainWindow::initStandardToolbar() |
572 | { | 572 | { |
573 | toolbarStandard=new QToolBar(this); | 573 | toolbarStandard=new QToolBar(this); |
574 | toolbarStandard->setHorizontalStretchable(TRUE); | 574 | toolbarStandard->setHorizontalStretchable(TRUE); |
575 | moveToolBar(toolbarStandard, Top); | 575 | moveToolBar(toolbarStandard, Top); |
576 | 576 | ||
577 | fileNew->addTo(toolbarStandard); | 577 | fileNew->addTo(toolbarStandard); |
578 | fileOpen->addTo(toolbarStandard); | 578 | fileOpen->addTo(toolbarStandard); |
579 | fileSave->addTo(toolbarStandard); | 579 | fileSave->addTo(toolbarStandard); |
580 | 580 | ||
581 | comboSheets=new QComboBox(toolbarStandard); | 581 | comboSheets=new QComboBox(toolbarStandard); |
582 | toolbarStandard->setStretchableWidget(comboSheets); | 582 | toolbarStandard->setStretchableWidget(comboSheets); |
583 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 583 | connect(comboSheets, SIGNAL(activated(const QString&)), this, SLOT(slotSheetChanged(const QString&))); |
584 | } | 584 | } |
585 | 585 | ||
586 | void MainWindow::initFunctionsToolbar() | 586 | void MainWindow::initFunctionsToolbar() |
587 | { | 587 | { |
588 | toolbarFunctions=new QToolBar(this); | 588 | toolbarFunctions=new QToolBar(this); |
589 | toolbarFunctions->setHorizontalStretchable(TRUE); | 589 | toolbarFunctions->setHorizontalStretchable(TRUE); |
590 | moveToolBar(toolbarFunctions, Bottom); | 590 | moveToolBar(toolbarFunctions, Bottom); |
591 | 591 | ||
592 | funcEqual->addTo(toolbarFunctions); | 592 | funcEqual->addTo(toolbarFunctions); |
593 | funcPlus->addTo(toolbarFunctions); | 593 | funcPlus->addTo(toolbarFunctions); |
594 | funcMinus->addTo(toolbarFunctions); | 594 | funcMinus->addTo(toolbarFunctions); |
595 | funcCross->addTo(toolbarFunctions); | 595 | funcCross->addTo(toolbarFunctions); |
596 | funcDivide->addTo(toolbarFunctions); | 596 | funcDivide->addTo(toolbarFunctions); |
597 | funcParanOpen->addTo(toolbarFunctions); | 597 | funcParanOpen->addTo(toolbarFunctions); |
598 | funcParanClose->addTo(toolbarFunctions); | 598 | funcParanClose->addTo(toolbarFunctions); |
599 | funcComma->addTo(toolbarFunctions); | 599 | funcComma->addTo(toolbarFunctions); |
600 | 600 | ||
601 | toolFunction=new QToolButton(toolbarFunctions); | 601 | toolFunction=new QToolButton(toolbarFunctions); |
602 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); | 602 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); |
603 | toolFunction->setTextLabel(tr("Functions")); | 603 | toolFunction->setTextLabel(tr("Functions")); |
604 | toolFunction->setPopup(submenuFunc); | 604 | toolFunction->setPopup(submenuFunc); |
605 | toolFunction->setPopupDelay(0); | 605 | toolFunction->setPopupDelay(0); |
606 | } | 606 | } |
607 | 607 | ||
608 | void MainWindow::initEditToolbar() | 608 | void MainWindow::initEditToolbar() |
609 | { | 609 | { |
610 | toolbarEdit=new QToolBar(this); | 610 | toolbarEdit=new QToolBar(this); |
611 | toolbarEdit->setHorizontalStretchable(TRUE); | 611 | toolbarEdit->setHorizontalStretchable(TRUE); |
612 | moveToolBar(toolbarEdit, Bottom); | 612 | moveToolBar(toolbarEdit, Bottom); |
613 | 613 | ||
614 | editAccept->addTo(toolbarEdit); | 614 | editAccept->addTo(toolbarEdit); |
615 | editCancel->addTo(toolbarEdit); | 615 | editCancel->addTo(toolbarEdit); |
616 | 616 | ||
617 | editData=new QLineEdit(toolbarEdit); | 617 | editData=new QLineEdit(toolbarEdit); |
618 | toolbarEdit->setStretchableWidget(editData); | 618 | toolbarEdit->setStretchableWidget(editData); |
619 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 619 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
620 | 620 | ||
621 | editCellSelect->addTo(toolbarEdit); | 621 | editCellSelect->addTo(toolbarEdit); |
622 | } | 622 | } |
623 | 623 | ||
624 | void MainWindow::slotHelpAbout() | 624 | void MainWindow::slotHelpAbout() |
625 | { | 625 | { |
626 | QDialog dialogAbout(this, 0, TRUE); | 626 | QDialog dialogAbout(this, 0, TRUE); |
627 | dialogAbout.resize(width()-40, height()-80); | 627 | dialogAbout.resize(width()-40, height()-80); |
628 | dialogAbout.setCaption(tr("About Opie Sheet")); | 628 | dialogAbout.setCaption(tr("About Opie Sheet")); |
629 | 629 | ||
630 | 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); | 630 | 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 | label.setGeometry(dialogAbout.rect()); | 631 | label.setGeometry(dialogAbout.rect()); |
632 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 632 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
633 | 633 | ||
634 | dialogAbout.exec(); | 634 | dialogAbout.exec(); |
635 | } | 635 | } |
636 | 636 | ||
637 | void MainWindow::initSheet() | 637 | void MainWindow::initSheet() |
638 | { | 638 | { |
639 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 639 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
640 | setCentralWidget(sheet); | 640 | setCentralWidget(sheet); |
641 | 641 | ||
642 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 642 | connect(sheet, SIGNAL(currentDataChanged(const QString&)), editData, SLOT(setText(const QString&))); |
643 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 643 | connect(sheet, SIGNAL(cellClicked(const QString&)), this, SLOT(slotCellClicked(const QString&))); |
644 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 644 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
645 | 645 | ||
646 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 646 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
647 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 647 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
648 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 648 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
649 | } | 649 | } |
650 | 650 | ||
651 | void MainWindow::slotEditAccept() | 651 | void MainWindow::slotEditAccept() |
652 | { | 652 | { |
653 | sheet->setData(editData->text()); | 653 | sheet->setData(editData->text()); |
654 | } | 654 | } |
655 | 655 | ||
656 | void MainWindow::slotEditCancel() | 656 | void MainWindow::slotEditCancel() |
657 | { | 657 | { |
658 | editData->setText(sheet->getData()); | 658 | editData->setText(sheet->getData()); |
659 | } | 659 | } |
660 | 660 | ||
661 | void MainWindow::slotCellSelect(bool lock) | 661 | void MainWindow::slotCellSelect(bool lock) |
662 | { | 662 | { |
663 | sheet->lockClicks(lock); | 663 | sheet->lockClicks(lock); |
664 | } | 664 | } |
665 | 665 | ||
666 | void MainWindow::addToData(const QString &data) | 666 | void MainWindow::addToData(const QString &data) |
667 | { | 667 | { |
668 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 668 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
669 | } | 669 | } |
670 | 670 | ||
671 | void MainWindow::slotFuncOutput() | 671 | void MainWindow::slotFuncOutput() |
672 | { | 672 | { |
673 | if (sender()->isA("QAction")) | 673 | if (sender()->isA("QAction")) |
674 | addToData(((QAction *)sender())->toolTip()); | 674 | addToData(((QAction *)sender())->toolTip()); |
675 | } | 675 | } |
676 | 676 | ||
677 | void MainWindow::slotInsertRows() | 677 | void MainWindow::slotInsertRows() |
678 | { | 678 | { |
679 | NumberDialog dialogNumber(this); | 679 | NumberDialog dialogNumber(this); |
680 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 680 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
681 | sheet->insertRows(dialogNumber.getValue()); | 681 | sheet->insertRows(dialogNumber.getValue()); |
682 | } | 682 | } |
683 | 683 | ||
684 | void MainWindow::slotInsertCols() | 684 | void MainWindow::slotInsertCols() |
685 | { | 685 | { |
686 | NumberDialog dialogNumber(this); | 686 | NumberDialog dialogNumber(this); |
687 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 687 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
688 | sheet->insertColumns(dialogNumber.getValue()); | 688 | sheet->insertColumns(dialogNumber.getValue()); |
689 | } | 689 | } |
690 | 690 | ||
691 | void MainWindow::slotInsertSheets() | 691 | void MainWindow::slotInsertSheets() |
692 | { | 692 | { |
693 | NumberDialog dialogNumber(this); | 693 | NumberDialog dialogNumber(this); |
694 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 694 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
695 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 695 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
696 | } | 696 | } |
697 | 697 | ||
698 | void MainWindow::slotCellClicked(const QString &cell) | 698 | void MainWindow::slotCellClicked(const QString &cell) |
699 | { | 699 | { |
700 | editCellSelect->setOn(FALSE); | 700 | editCellSelect->setOn(FALSE); |
701 | addToData(cell); | 701 | addToData(cell); |
702 | } | 702 | } |
703 | 703 | ||
704 | typeSheet *MainWindow::createNewSheet() | 704 | typeSheet *MainWindow::createNewSheet() |
705 | { | 705 | { |
706 | typeSheet *newSheet=new typeSheet; | 706 | typeSheet *newSheet=new typeSheet; |
707 | int currentNo=1, tempNo=0; | 707 | int currentNo=1, tempNo=0; |
708 | bool ok; | 708 | bool ok; |
709 | 709 | ||
710 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 710 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
711 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 711 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
712 | currentNo=tempNo+1; | 712 | currentNo=tempNo+1; |
713 | 713 | ||
714 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 714 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
715 | newSheet->data.setAutoDelete(TRUE); | 715 | newSheet->data.setAutoDelete(TRUE); |
716 | 716 | ||
717 | comboSheets->insertItem(newSheet->name); | 717 | comboSheets->insertItem(newSheet->name); |
718 | listSheets.append(newSheet); | 718 | listSheets.append(newSheet); |
719 | return newSheet; | 719 | return newSheet; |
720 | } | 720 | } |
721 | 721 | ||
722 | typeSheet *MainWindow::findSheet(const QString &name) | 722 | typeSheet *MainWindow::findSheet(const QString &name) |
723 | { | 723 | { |
724 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 724 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
725 | if (tempSheet->name==name) | 725 | if (tempSheet->name==name) |
726 | return tempSheet; | 726 | return tempSheet; |
727 | return NULL; | 727 | return NULL; |
728 | } | 728 | } |
729 | 729 | ||
730 | void MainWindow::slotSheetChanged(const QString &name) | 730 | void MainWindow::slotSheetChanged(const QString &name) |
731 | { | 731 | { |
732 | sheet->copySheetData(&findSheet(sheet->getName())->data); | 732 | sheet->copySheetData(&findSheet(sheet->getName())->data); |
733 | sheet->setName(name); | 733 | sheet->setName(name); |
734 | sheet->setSheetData(&findSheet(name)->data); | 734 | sheet->setSheetData(&findSheet(name)->data); |
735 | sheet->ReCalc(); | 735 | sheet->ReCalc(); |
736 | } | 736 | } |
737 | 737 | ||
738 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) | 738 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) |
739 | { | 739 | { |