summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-sheet/sheet.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-sheet/sheet.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/sheet.h264
1 files changed, 142 insertions, 122 deletions
diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h
index f705cd0..92c8061 100644
--- a/noncore/apps/opie-sheet/sheet.h
+++ b/noncore/apps/opie-sheet/sheet.h
@@ -1,11 +1,30 @@
1/*************************************************************************** 1/*
2 * * 2 =. This file is part of the Opie Project
3 * This program is free software; you can redistribute it and/or modify * 3 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
4 * it under the terms of the GNU General Public License as published by * 4 .>+-=
5 * the Free Software Foundation; either version 2 of the License, or * 5 _;:, .> :=|. This program is free software; you can
6 * (at your option) any later version. * 6.> <`_, > . <= redistribute it and/or modify it under
7 * * 7:`=1 )Y*s>-.-- : the terms of the GNU General Public
8 ***************************************************************************/ 8.="- .-=="i, .._ License as published by the Free Software
9 - . .-<_> .<> Foundation; either version 2 of the License,
10 ._= =} : or (at your option) any later version.
11 .%`+i> _;_.
12 .i_,=:_. -<s. This program is distributed in the hope that
13 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
14 : .. .:, . . . without even the implied warranty of
15 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
16 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.= = ; Library General Public License for more
18++= -. .` .: details.
19 : = ...= . :.=-
20 -. .:....=;==+<; You should have received a copy of the GNU
21 -_. . . )=. = Library General Public License along with
22 -- :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
9 28
10/* 29/*
11 * Opie Sheet (formerly Sheet/Qt) 30 * Opie Sheet (formerly Sheet/Qt)
@@ -15,23 +34,24 @@
15#ifndef SHEET_H 34#ifndef SHEET_H
16#define SHEET_H 35#define SHEET_H
17 36
37/* QT */
18#include <qtable.h> 38#include <qtable.h>
19#include <qstack.h> 39#include <qstack.h>
20 40
21typedef struct typeCellBorders 41typedef struct typeCellBorders
22{ 42{
23 QPen right, bottom; 43 QPen right, bottom;
24}; 44};
25 45
26typedef struct typeCellData 46typedef struct typeCellData
27{ 47{
28 int col, row; 48 int col, row;
29 typeCellBorders borders; 49 typeCellBorders borders;
30 QBrush background; 50 QBrush background;
31 Qt::AlignmentFlags alignment; 51 Qt::AlignmentFlags alignment;
32 QColor fontColor; 52 QColor fontColor;
33 QFont font; 53 QFont font;
34 QString data; 54 QString data;
35}; 55};
36 56
37 57
@@ -45,36 +65,36 @@ typedef struct typeCellData
45class Expression 65class Expression
46{ 66{
47public: 67public:
48 QString Body; 68 QString Body;
49 QList<QString> CompiledBody; 69 QList<QString> CompiledBody;
50 QList<int> CompiledBodyType; 70 QList<int> CompiledBodyType;
51 QString SYMBOL; 71 QString SYMBOL;
52 QString MATHSYMBOL; 72 QString MATHSYMBOL;
53 QArray<int> ArgsOfFunc; 73 QArray<int> ArgsOfFunc;
54 int FuncDepth; 74 int FuncDepth;
55 bool ErrorFound; 75 bool ErrorFound;
56 int n; // holds the current parser position 76 int n; // holds the current parser position
57 QString chunk; // the piece in the parser we are on 77 QString chunk; // the piece in the parser we are on
58 int SymbGroup; // the current type 78 int SymbGroup; // the current type
59 79
60 QString InExpr; 80 QString InExpr;
61 81
62 QChar chunk0(void); // retunrs the first char of expression; 82 QChar chunk0(void); // retunrs the first char of expression;
63 Expression(QString expr1);// constructor 83 Expression(QString expr1);// constructor
64 84
65 bool isSymbol(QChar ch); 85 bool isSymbol(QChar ch);
66 bool isMathSymbol(QChar ch); 86 bool isMathSymbol(QChar ch);
67 void GetNext(); 87 void GetNext();
68 void First(); 88 void First();
69 void Third(); 89 void Third();
70 void Fourth(); 90 void Fourth();
71 void Fifth(); 91 void Fifth();
72 void Sixth(); 92 void Sixth();
73 void Seventh(); 93 void Seventh();
74 void Eighth(); 94 void Eighth();
75 void Ninth(); 95 void Ninth();
76 96
77 bool Expression::Parse(); //parses the expression in RPN format; 97 bool Expression::Parse(); //parses the expression in RPN format;
78 98
79}; 99};
80 100
@@ -82,83 +102,83 @@ public:
82 102
83class Sheet: public QTable 103class Sheet: public QTable
84{ 104{
85 Q_OBJECT 105 Q_OBJECT
86 106
87 // Variables 107 // Variables
88 bool clicksLocked; 108 bool clicksLocked;
89 int selectionNo; 109 int selectionNo;
90 typeCellBorders defaultBorders; 110 typeCellBorders defaultBorders;
91 typeCellData defaultCellData; 111 typeCellData defaultCellData;
92 112
93 // QT objects 113 // QT objects
94 QList<typeCellData> sheetData, clipboardData; 114 QList<typeCellData> sheetData, clipboardData;
95 QString pressedCell, releasedCell, sheetName; 115 QString pressedCell, releasedCell, sheetName;
96 QStringList listDataParser; 116 QStringList listDataParser;
97 117
98 // Private functions 118 // Private functions
99 bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); 119 bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE);
100 QString findCellName(int row, int col); 120 QString findCellName(int row, int col);
101 bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); 121 bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2);
102 QString calculateVariable(const QString &variable); 122 QString calculateVariable(const QString &variable);
103 QString calculateFunction(const QString &func, const QString &parameters, int NumOfParams); 123 QString calculateFunction(const QString &func, const QString &parameters, int NumOfParams);
104 QString getParameter(const QString &parameters, int paramNo, bool giveError=FALSE, const QString funcName=""); 124 QString getParameter(const QString &parameters, int paramNo, bool giveError=FALSE, const QString funcName="");
105 QString dataParser(const QString &cell, const QString &data); 125 QString dataParser(const QString &cell, const QString &data);
106 QString dataParserHelper(const QString &data); 126 QString dataParserHelper(const QString &data);
107 typeCellData *createCellData(int row, int col); 127 typeCellData *createCellData(int row, int col);
108 typeCellData *findCellData(int row, int col); 128 typeCellData *findCellData(int row, int col);
109 129
110 130
111//LOGICAL / INFO 131 //LOGICAL / INFO
112 double functionCountIf(const QString &param1, const QString &param2, const QString &param3); 132 double functionCountIf(const QString &param1, const QString &param2, const QString &param3);
113 double functionSumSQ(const QString &param1, const QString &param2); //sum of squares 133 double functionSumSQ(const QString &param1, const QString &param2); //sum of squares
114 QString functionIndex(const QString &param1, const QString &param2, int indx); 134 QString functionIndex(const QString &param1, const QString &param2, int indx);
115//math functions computations 135 //math functions computations
116 double BesselI0(double x); 136 double BesselI0(double x);
117 double BesselI(int n, double x); 137 double BesselI(int n, double x);
118 double BesselK0(double x); 138 double BesselK0(double x);
119 double BesselI1(double x); 139 double BesselI1(double x);
120 double BesselK1(double x); 140 double BesselK1(double x);
121 double BesselK(int n, double x); 141 double BesselK(int n, double x);
122 double BesselJ0(double x); 142 double BesselJ0(double x);
123 double BesselY0(double x); 143 double BesselY0(double x);
124 double BesselJ1(double x); 144 double BesselJ1(double x);
125 double BesselY1(double x); 145 double BesselY1(double x);
126 double BesselY(int n, double x); 146 double BesselY(int n, double x);
127 double BesselJ(int n, double x); 147 double BesselJ(int n, double x);
128 double GammaLn(double xx); 148 double GammaLn(double xx);
129 double Factorial(double n); 149 double Factorial(double n);
130 double GammaP(double a, double x); 150 double GammaP(double a, double x);
131 double GammaQ(double a,double x); 151 double GammaQ(double a,double x);
132 void GammaSeries(double *gamser, double a, double x, double *gln); 152 void GammaSeries(double *gamser, double a, double x, double *gln);
133 void GammaContinuedFraction(double *gammcf, double a, double x, double *gln); 153 void GammaContinuedFraction(double *gammcf, double a, double x, double *gln);
134 double ErrorFunction(double x); 154 double ErrorFunction(double x);
135 double ErrorFunctionComplementary(double x); 155 double ErrorFunctionComplementary(double x);
136 double Beta(double z, double w); 156 double Beta(double z, double w);
137 double BetaContinuedFraction(double a, double b, double x); 157 double BetaContinuedFraction(double a, double b, double x);
138 double BetaIncomplete(double a, double b, double x); 158 double BetaIncomplete(double a, double b, double x);
139 double functionVariance(const QString &param1, const QString &param2); 159 double functionVariance(const QString &param1, const QString &param2);
140 double functionVariancePopulation(const QString &param1, const QString &param2); 160 double functionVariancePopulation(const QString &param1, const QString &param2);
141 double functionSkew(const QString &param1, const QString &param2); 161 double functionSkew(const QString &param1, const QString &param2);
142 double functionKurt(const QString &param1, const QString &param2); 162 double functionKurt(const QString &param1, const QString &param2);
143 163
144 // Sheet/Qt parser functions 164 // Sheet/Qt parser functions
145 double functionSum(const QString &param1, const QString &param2); 165 double functionSum(const QString &param1, const QString &param2);
146 double functionAvg(const QString &param1, const QString &param2); 166 double functionAvg(const QString &param1, const QString &param2);
147 double functionMax(const QString &param1, const QString &param2); 167 double functionMax(const QString &param1, const QString &param2);
148 double functionMin(const QString &param1, const QString &param2); 168 double functionMin(const QString &param1, const QString &param2);
149 double functionCount(const QString &param1, const QString &param2); 169 double functionCount(const QString &param1, const QString &param2);
150 170
151 // Reimplemented QTable functions 171 // Reimplemented QTable functions
152 void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected); 172 void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected);
153 void viewportMousePressEvent(QMouseEvent *e); 173 void viewportMousePressEvent(QMouseEvent *e);
154 void viewportMouseMoveEvent(QMouseEvent *e); 174 void viewportMouseMoveEvent(QMouseEvent *e);
155 void viewportMouseReleaseEvent(QMouseEvent *e); 175 void viewportMouseReleaseEvent(QMouseEvent *e);
156 176
157 public slots: 177public slots:
158 void slotCellSelected(int row, int col); 178 void slotCellSelected(int row, int col);
159 void slotCellChanged(int row, int col); 179 void slotCellChanged(int row, int col);
160 180
161 public: 181public:
162 Sheet(int numRows, int numCols, QWidget *parent); 182 Sheet(int numRows, int numCols, QWidget *parent);
163 ~Sheet(); 183 ~Sheet();
164 void ReCalc(void); 184 void ReCalc(void);
@@ -195,14 +215,14 @@ class Sheet: public QTable
195 static int getHeaderColumn(const QString &section); 215 static int getHeaderColumn(const QString &section);
196 static QString getHeaderString(int section); 216 static QString getHeaderString(int section);
197 217
198 public slots: 218public slots:
199 void editCut(); 219 void editCut();
200 void editCopy(); 220 void editCopy();
201 void editPaste(bool onlyContents=FALSE); 221 void editPaste(bool onlyContents=FALSE);
202 void editClear(); 222 void editClear();
203 void swapCells(int row1, int col1, int row2, int col2); 223 void swapCells(int row1, int col1, int row2, int col2);
204 224
205 signals: 225signals:
206 void currentDataChanged(const QString &data); 226 void currentDataChanged(const QString &data);
207 void cellClicked(const QString &cell); 227 void cellClicked(const QString &cell);
208 void sheetModified(); 228 void sheetModified();