-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 4 |
2 files changed, 8 insertions, 8 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 | { |
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index f303d33..d4419af 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp | |||
@@ -1,143 +1,143 @@ | |||
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 "sheet.h" | 15 | #include "sheet.h" |
16 | 16 | ||
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <math.h> | 18 | #include <math.h> |
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <time.h> | 21 | #include <time.h> |
22 | 22 | ||
23 | #define DEFAULT_COL_WIDTH 50 | 23 | #define DEFAULT_COL_WIDTH 50 |
24 | 24 | ||
25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) | 25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) |
26 | :QTable(numRows, numCols, parent) | 26 | :QTable(numRows, numCols, parent) |
27 | { | 27 | { |
28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); | 28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); |
29 | defaultCellData.data=""; | 29 | defaultCellData.data=""; |
30 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); | 30 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); |
31 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); | 31 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); |
32 | defaultCellData.fontColor=Qt::black; | 32 | defaultCellData.fontColor=Qt::black; |
33 | defaultCellData.font=font(); | 33 | defaultCellData.font=font(); |
34 | defaultCellData.borders=defaultBorders; | 34 | defaultCellData.borders=defaultBorders; |
35 | 35 | ||
36 | clicksLocked=FALSE; | 36 | clicksLocked=FALSE; |
37 | selectionNo=-1; | 37 | selectionNo=-1; |
38 | setSelectionMode(QTable::Single); | 38 | setSelectionMode(QTable::Single); |
39 | 39 | ||
40 | sheetData.setAutoDelete(TRUE); | 40 | sheetData.setAutoDelete(TRUE); |
41 | clipboardData.setAutoDelete(TRUE); | 41 | clipboardData.setAutoDelete(TRUE); |
42 | for (int i=0; i<numCols; ++i) | 42 | for (int i=0; i<numCols; ++i) |
43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); | 43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); |
44 | 44 | ||
45 | 45 | ||
46 | connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int))); | 46 | connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int))); |
47 | connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int))); | 47 | connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int))); |
48 | } | 48 | } |
49 | 49 | ||
50 | Sheet::~Sheet() | 50 | Sheet::~Sheet() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | typeCellData *Sheet::findCellData(int row, int col) | 54 | typeCellData *Sheet::findCellData(int row, int col) |
55 | { | 55 | { |
56 | typeCellData *tempCellData; | 56 | typeCellData *tempCellData; |
57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
58 | { | 58 | { |
59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; | 59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; |
60 | } | 60 | } |
61 | return NULL; | 61 | return NULL; |
62 | } | 62 | } |
63 | 63 | ||
64 | void Sheet::slotCellSelected(int row, int col) | 64 | void Sheet::slotCellSelected(int row, int col) |
65 | { | 65 | { |
66 | typeCellData *cellData=findCellData(row, col); | 66 | typeCellData *cellData=findCellData(row, col); |
67 | if (cellData) | 67 | if (cellData) |
68 | { | 68 | { |
69 | emit currentDataChanged(cellData->data); | 69 | emit currentDataChanged(cellData->data); |
70 | }else | 70 | }else |
71 | emit currentDataChanged(""); | 71 | emit currentDataChanged(""); |
72 | } | 72 | } |
73 | 73 | ||
74 | typeCellData *Sheet::createCellData(int row, int col) | 74 | typeCellData *Sheet::createCellData(int row, int col) |
75 | { | 75 | { |
76 | if (row<0 || col<0) return NULL; | 76 | if (row<0 || col<0) return NULL; |
77 | typeCellData *cellData=new typeCellData; | 77 | typeCellData *cellData=new typeCellData; |
78 | cellData->row=row; | 78 | cellData->row=row; |
79 | cellData->col=col; | 79 | cellData->col=col; |
80 | cellData->data=defaultCellData.data; | 80 | cellData->data=defaultCellData.data; |
81 | cellData->borders=defaultCellData.borders; | 81 | cellData->borders=defaultCellData.borders; |
82 | cellData->alignment=defaultCellData.alignment; | 82 | cellData->alignment=defaultCellData.alignment; |
83 | cellData->font=defaultCellData.font; | 83 | cellData->font=defaultCellData.font; |
84 | cellData->fontColor=defaultCellData.fontColor; | 84 | cellData->fontColor=defaultCellData.fontColor; |
85 | cellData->background=defaultCellData.background; | 85 | cellData->background=defaultCellData.background; |
86 | sheetData.append(cellData); | 86 | sheetData.append(cellData); |
87 | return cellData; | 87 | return cellData; |
88 | } | 88 | } |
89 | 89 | ||
90 | void Sheet::slotCellChanged(int row, int col) | 90 | void Sheet::slotCellChanged(int row, int col) |
91 | { | 91 | { |
92 | typeCellData *cellData=findCellData(row, col); | 92 | typeCellData *cellData=findCellData(row, col); |
93 | if (!cellData) cellData=createCellData(row, col); | 93 | if (!cellData) cellData=createCellData(row, col); |
94 | if (cellData) cellData->data=text(row, col); | 94 | if (cellData) cellData->data=text(row, col); |
95 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 95 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
96 | { | 96 | { |
97 | // modified by Toussis Manolis koppermind@panafonet.gr | 97 | // modified by Toussis Manolis koppermind@panafonet.gr |
98 | // the parser was crashing if there were no closed parenthesis. | 98 | // the parser was crashing if there were no closed parenthesis. |
99 | int w1,ii=0; | 99 | int w1,ii=0; |
100 | for(w1=0;w1<=(int)text(row, col).length();w1++) | 100 | for(w1=0;w1<=(int)text(row, col).length();w1++) |
101 | { | 101 | { |
102 | if(text(row,col)[w1]=='(') ii++; | 102 | if(text(row,col)[w1]=='(') ii++; |
103 | if(text(row,col)[w1]==')') ii--; | 103 | if(text(row,col)[w1]==')') ii--; |
104 | }; | 104 | }; |
105 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 105 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
106 | //end of modification | 106 | //end of modification |
107 | // old was plain: | 107 | // old was plain: |
108 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 108 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
109 | }; | 109 | }; |
110 | emit sheetModified(); | 110 | emit sheetModified(); |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | void Sheet::ReCalc(void) | 114 | void Sheet::ReCalc(void) |
115 | { | 115 | { |
116 | typeCellData* cellData; | 116 | typeCellData* cellData; |
117 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 117 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
118 | { | 118 | { |
119 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); | 119 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); |
120 | 120 | ||
121 | slotCellChanged(cellData->row,cellData->col); | 121 | slotCellChanged(cellData->row,cellData->col); |
122 | }; | 122 | }; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | void Sheet::swapCells(int row1, int col1, int row2, int col2) | 128 | void Sheet::swapCells(int row1, int col1, int row2, int col2) |
129 | { | 129 | { |
130 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); | 130 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); |
131 | if (!cellData1) cellData1=createCellData(row1, col1); | 131 | if (!cellData1) cellData1=createCellData(row1, col1); |
132 | if (!cellData2) cellData2=createCellData(row2, col2); | 132 | if (!cellData2) cellData2=createCellData(row2, col2); |
133 | if (cellData1 && cellData2) | 133 | if (cellData1 && cellData2) |
134 | { | 134 | { |
135 | QString tempData(cellData1->data); | 135 | QString tempData(cellData1->data); |
136 | cellData1->data=cellData2->data; | 136 | cellData1->data=cellData2->data; |
137 | cellData2->data=tempData; | 137 | cellData2->data=tempData; |
138 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); | 138 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); |
139 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); | 139 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); |
140 | emit sheetModified(); | 140 | emit sheetModified(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||