-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspreadsheet.h
More file actions
40 lines (35 loc) · 1.74 KB
/
spreadsheet.h
File metadata and controls
40 lines (35 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef SPREADSHEET_H
#define SPREADSHEET_H
#include <QAbstractTableModel>
#include <QTableView>
#include <QMainWindow>
#include <QString>
#include "item.h"
const int MAXCELLS = 64;
enum Roles {FormulaRole = Qt::UserRole, ValueRole, DepCellAddRole, DepCellDelRole};
class Spreadsheet : public QAbstractTableModel
{
Q_OBJECT
public:
Spreadsheet(int initRows, int initCols, QObject *parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const override ;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
void setCurrentCell(const QModelIndex &index) {currentCell = index;} //saved currently used cell
const QModelIndex& getCurrentCell() {return currentCell;} //get currently used cell
void setFormula(const QString &formula); //set formula to currently used cell
void reevaluateCells(); //reevaluate cells after change
void reevaluateAllCells(); //reeavaluate all cells after macro parsed
void reevaluateRecursive(QVector<QString> &checkedCells, int row, int col); //recursivly reevaluate all dependent cells
signals:
void editCompleted(const QString &); //signal emited when edition of formula in cell completed
private:
void showCyclicDepDialog();
Item cellsData[MAXCELLS][MAXCELLS]; //all cells data
QModelIndex currentCell; //currently used cell index
int rows;
int cols;
};
#endif // SPREADSHEET_H