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.h93
1 files changed, 84 insertions, 9 deletions
diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h
index f4e9d38..41f1b86 100644
--- a/noncore/apps/opie-sheet/sheet.h
+++ b/noncore/apps/opie-sheet/sheet.h
@@ -25,77 +25,152 @@ typedef struct typeCellBorders
25 25
26typedef struct typeCellData 26typedef struct typeCellData
27{ 27{
28 int col, row; 28 int col, row;
29 typeCellBorders borders; 29 typeCellBorders borders;
30 QBrush background; 30 QBrush background;
31 Qt::AlignmentFlags alignment; 31 Qt::AlignmentFlags alignment;
32 QColor fontColor; 32 QColor fontColor;
33 QFont font; 33 QFont font;
34 QString data; 34 QString data;
35}; 35};
36 36
37
38#define NONE_TOKEN 0
39#define NUMBER_TOKEN 1
40#define VARIABLE_TOKEN 2
41#define FUNCTION_TOKEN 3
42#define SYMBOL_TOKEN 4
43#define STRING_TOKEN 5
44
45class Expression
46{
47public:
48 QString Body;
49 QList<QString> CompiledBody;
50 QList<int> CompiledBodyType;
51 QString SYMBOL;
52 QString MATHSYMBOL;
53 QArray<int> ArgsOfFunc;
54 int FuncDepth;
55 bool ErrorFound;
56 int n; // holds the current parser position
57 QString chunk; // the piece in the parser we are on
58 int SymbGroup; // the current type
59
60 QString InExpr;
61
62 QChar chunk0(void); // retunrs the first char of expression;
63 Expression(QString expr1);// constructor
64
65 bool isSymbol(QChar ch);
66 bool isMathSymbol(QChar ch);
67 void GetNext();
68 void First();
69 void Third();
70 void Fourth();
71 void Fifth();
72 void Sixth();
73 void Seventh();
74 void Eighth();
75 void Ninth();
76
77 bool Expression::Parse(); //parses the expression in RPN format;
78
79};
80
81
82
37class Sheet: public QTable 83class Sheet: public QTable
38{ 84{
39 Q_OBJECT 85 Q_OBJECT
40 86
41 // Variables 87 // Variables
42 bool clicksLocked; 88 bool clicksLocked;
43 int selectionNo; 89 int selectionNo;
44 typeCellBorders defaultBorders; 90 typeCellBorders defaultBorders;
45 typeCellData defaultCellData; 91 typeCellData defaultCellData;
46 92
47 // QT objects 93 // QT objects
48 QList<typeCellData> sheetData, clipboardData; 94 QList<typeCellData> sheetData, clipboardData;
49 QString pressedCell, releasedCell, sheetName; 95 QString pressedCell, releasedCell, sheetName;
50 QStringList listDataParser; 96 QStringList listDataParser;
51 97
52 // Private functions 98 // Private functions
53 int getOperatorPriority(char oper);
54 bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); 99 bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE);
55 QString findCellName(int row, int col); 100 QString findCellName(int row, int col);
56 bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); 101 bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2);
57 double calculateVariable(const QString &variable); 102 QString calculateVariable(const QString &variable);
58 double calculateFunction(const QString &function, const QString &parameters); 103 QString calculateFunction(const QString &function, const QString &parameters, int NumOfParams);
59 QChar popCharStack(QStack<QChar> *stackChars);
60 QString popStringStack(QStack<QString> *stackStrings);
61 QString getParameter(const QString &parameters, int paramNo, bool giveError=FALSE, const QString funcName=""); 104 QString getParameter(const QString &parameters, int paramNo, bool giveError=FALSE, const QString funcName="");
62 QString dataParser(const QString &cell, const QString &data); 105 QString dataParser(const QString &cell, const QString &data);
63 QString dataParserHelper(const QString &data); 106 QString dataParserHelper(const QString &data);
64 typeCellData *createCellData(int row, int col); 107 typeCellData *createCellData(int row, int col);
65 typeCellData *findCellData(int row, int col); 108 typeCellData *findCellData(int row, int col);
66 void pushCharStack(QStack<QChar> *stackChars, const QChar &character); 109
67 void pushStringStack(QStack<QString> *stackStrings, const QString &string); 110
111//LOGICAL / INFO
112 double functionCountIf(const QString &param1, const QString &param2, const QString &param3);
113 double functionSumSQ(const QString &param1, const QString &param2); //sum of squares
114 QString functionIndex(const QString &param1, const QString &param2, int indx);
115//math functions computations
116 double BesselI0(double x);
117 double BesselI(int n, double x);
118 double BesselK0(double x);
119 double BesselI1(double x);
120 double BesselK1(double x);
121 double BesselK(int n, double x);
122 double BesselJ0(double x);
123 double BesselY0(double x);
124 double BesselJ1(double x);
125 double BesselY1(double x);
126 double BesselY(int n, double x);
127 double BesselJ(int n, double x);
128 double GammaLn(double xx);
129 double Factorial(double n);
130 double GammaP(double a, double x);
131 double GammaQ(double a,double x);
132 void GammaSeries(double *gamser, double a, double x, double *gln);
133 void GammaContinuedFraction(double *gammcf, double a, double x, double *gln);
134 double ErrorFunction(double x);
135 double ErrorFunctionComplementary(double x);
136 double Beta(double z, double w);
137 double BetaContinuedFraction(double a, double b, double x);
138 double BetaIncomplete(double a, double b, double x);
139 double functionVariance(const QString &param1, const QString &param2);
140 double functionVariancePopulation(const QString &param1, const QString &param2);
141 double functionSkew(const QString &param1, const QString &param2);
142 double functionKurt(const QString &param1, const QString &param2);
68 143
69 // Sheet/Qt parser functions 144 // Sheet/Qt parser functions
70 double functionSum(const QString &param1, const QString &param2); 145 double functionSum(const QString &param1, const QString &param2);
71 double functionAvg(const QString &param1, const QString &param2); 146 double functionAvg(const QString &param1, const QString &param2);
72 double functionMax(const QString &param1, const QString &param2); 147 double functionMax(const QString &param1, const QString &param2);
73 double functionMin(const QString &param1, const QString &param2); 148 double functionMin(const QString &param1, const QString &param2);
74 double functionCount(const QString &param1, const QString &param2); 149 double functionCount(const QString &param1, const QString &param2);
75 150
76 // Reimplemented QTable functions 151 // Reimplemented QTable functions
77 void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected); 152 void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected);
78 void viewportMousePressEvent(QMouseEvent *e); 153 void viewportMousePressEvent(QMouseEvent *e);
79 void viewportMouseMoveEvent(QMouseEvent *e); 154 void viewportMouseMoveEvent(QMouseEvent *e);
80 void viewportMouseReleaseEvent(QMouseEvent *e); 155 void viewportMouseReleaseEvent(QMouseEvent *e);
81 156
82 private slots: 157 public slots:
83 void slotCellSelected(int row, int col); 158 void slotCellSelected(int row, int col);
84 void slotCellChanged(int row, int col); 159 void slotCellChanged(int row, int col);
85 160
86 public: 161 public:
87 Sheet(int numRows, int numCols, QWidget *parent); 162 Sheet(int numRows, int numCols, QWidget *parent);
88 ~Sheet(); 163 ~Sheet();
89 164 void ReCalc(void);
90 void setData(const QString &data); 165 void setData(const QString &data);
91 QString getData(); 166 QString getData();
92 167
93 void setName(const QString &data); 168 void setName(const QString &data);
94 QString getName(); 169 QString getName();
95 170
96 void setPen(int row, int col, int vertical, const QPen &pen); 171 void setPen(int row, int col, int vertical, const QPen &pen);
97 QPen getPen(int row, int col, int vertical); 172 QPen getPen(int row, int col, int vertical);
98 173
99 void setBrush(int row, int col, const QBrush &brush); 174 void setBrush(int row, int col, const QBrush &brush);
100 QBrush getBrush(int row, int col); 175 QBrush getBrush(int row, int col);
101 176