author | thufir <thufir> | 2002-07-04 16:58:16 (UTC) |
---|---|---|
committer | thufir <thufir> | 2002-07-04 16:58:16 (UTC) |
commit | d2b982a38091cbc7cd4eba0994ab6c5e3c7f7189 (patch) (unidiff) | |
tree | d1e0a5fa80a12717b46257936ee3f8bb1b3ef89e /noncore/apps/opie-sheet/sheet.h | |
parent | a53847b7d27938551bb4f1c8891e7bacc93143ee (diff) | |
download | opie-d2b982a38091cbc7cd4eba0994ab6c5e3c7f7189.zip opie-d2b982a38091cbc7cd4eba0994ab6c5e3c7f7189.tar.gz opie-d2b982a38091cbc7cd4eba0994ab6c5e3c7f7189.tar.bz2 |
added opie-sheet
Diffstat (limited to 'noncore/apps/opie-sheet/sheet.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/sheet.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h new file mode 100644 index 0000000..02899a0 --- a/dev/null +++ b/noncore/apps/opie-sheet/sheet.h | |||
@@ -0,0 +1,120 @@ | |||
1 | #ifndef SHEET_H | ||
2 | #define SHEET_H | ||
3 | |||
4 | #include <qtable.h> | ||
5 | #include <qstack.h> | ||
6 | |||
7 | typedef struct typeCellBorders | ||
8 | { | ||
9 | QPen right, bottom; | ||
10 | }; | ||
11 | |||
12 | typedef struct typeCellData | ||
13 | { | ||
14 | int col, row; | ||
15 | typeCellBorders borders; | ||
16 | QBrush background; | ||
17 | Qt::AlignmentFlags alignment; | ||
18 | QColor fontColor; | ||
19 | QFont font; | ||
20 | QString data; | ||
21 | }; | ||
22 | |||
23 | class Sheet: public QTable | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | |||
27 | // Variables | ||
28 | bool clicksLocked; | ||
29 | int selectionNo; | ||
30 | typeCellBorders defaultBorders; | ||
31 | typeCellData defaultCellData; | ||
32 | |||
33 | // QT objects | ||
34 | QList<typeCellData> sheetData, clipboardData; | ||
35 | QString pressedCell, releasedCell, sheetName; | ||
36 | |||
37 | // Private functions | ||
38 | int getOperatorPriority(char oper); | ||
39 | bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); | ||
40 | bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); | ||
41 | double calculateVariable(const QString &variable); | ||
42 | double calculateFunction(const QString &function, const QString ¶meters); | ||
43 | QChar popCharStack(QStack<QChar> *stackChars); | ||
44 | QString popStringStack(QStack<QString> *stackStrings); | ||
45 | QString getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName=""); | ||
46 | QString dataParser(const QString &data); | ||
47 | QString dataParserHelper(const QString &data); | ||
48 | typeCellData *createCellData(int row, int col); | ||
49 | typeCellData *findCellData(int row, int col); | ||
50 | void pushCharStack(QStack<QChar> *stackChars, const QChar &character); | ||
51 | void pushStringStack(QStack<QString> *stackStrings, const QString &string); | ||
52 | |||
53 | // Sheet/Qt parser functions | ||
54 | double functionSum(const QString ¶m1, const QString ¶m2); | ||
55 | double functionAvg(const QString ¶m1, const QString ¶m2); | ||
56 | double functionMax(const QString ¶m1, const QString ¶m2); | ||
57 | double functionMin(const QString ¶m1, const QString ¶m2); | ||
58 | double functionCount(const QString ¶m1, const QString ¶m2); | ||
59 | |||
60 | // Reimplemented QTable functions | ||
61 | void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected); | ||
62 | void viewportMousePressEvent(QMouseEvent *e); | ||
63 | void viewportMouseMoveEvent(QMouseEvent *e); | ||
64 | void viewportMouseReleaseEvent(QMouseEvent *e); | ||
65 | |||
66 | private slots: | ||
67 | void slotCellSelected(int row, int col); | ||
68 | void slotCellChanged(int row, int col); | ||
69 | |||
70 | public: | ||
71 | Sheet(int numRows, int numCols, QWidget *parent); | ||
72 | ~Sheet(); | ||
73 | |||
74 | void setData(const QString &data); | ||
75 | QString getData(); | ||
76 | |||
77 | void setName(const QString &data); | ||
78 | QString getName(); | ||
79 | |||
80 | void setPen(int row, int col, int vertical, const QPen &pen); | ||
81 | QPen getPen(int row, int col, int vertical); | ||
82 | |||
83 | void setBrush(int row, int col, const QBrush &brush); | ||
84 | QBrush getBrush(int row, int col); | ||
85 | |||
86 | void setTextAlign(int row, int col, Qt::AlignmentFlags flags); | ||
87 | Qt::AlignmentFlags getAlignment(int row, int col); | ||
88 | |||
89 | void setTextFont(int row, int col, const QFont &font, const QColor &color); | ||
90 | QFont getFont(int row, int col); | ||
91 | QColor getFontColor(int row, int col); | ||
92 | |||
93 | void lockClicks(bool lock=TRUE); | ||
94 | void copySheetData(QList<typeCellData> *destSheetData); | ||
95 | void setSheetData(QList<typeCellData> *srcSheetData); | ||
96 | void getSelection(int *row1, int *col1, int *row2, int *col2); | ||
97 | |||
98 | void insertRows(int no=1, bool allColumns=TRUE); | ||
99 | void insertColumns(int no=1, bool allRows=TRUE); | ||
100 | |||
101 | void dataFindReplace(const QString &find, const QString &replace, bool matchCase=TRUE, bool allCells=TRUE, bool entireCell=FALSE, bool replace=FALSE, bool replaceAll=FALSE); | ||
102 | |||
103 | // Static functions | ||
104 | static int getHeaderColumn(const QString §ion); | ||
105 | static QString getHeaderString(int section); | ||
106 | |||
107 | public slots: | ||
108 | void editCut(); | ||
109 | void editCopy(); | ||
110 | void editPaste(bool onlyContents=FALSE); | ||
111 | void editClear(); | ||
112 | void swapCells(int row1, int col1, int row2, int col2); | ||
113 | |||
114 | signals: | ||
115 | void currentDataChanged(const QString &data); | ||
116 | void cellClicked(const QString &cell); | ||
117 | void sheetModified(); | ||
118 | }; | ||
119 | |||
120 | #endif | ||