00001 #ifndef SPREADSHEET_H
00002 #define SPREADSHEET_H
00003
00004 #include <qwidget.h>
00005 #include <qtable.h>
00006 #include <kprocess.h>
00007 #include "MainWin.h"
00008 #include "widgettype.h"
00009 #include "input.h"
00010
00011
00012
00013 #ifdef USE_NEW_TABLE
00014 #include <LTable.h>
00015 #endif
00016
00017
00018
00019
00020
00021
00022
00023 #include <new>
00024
00025 class MainWin;
00026 class ListDialog;
00027 class ExportDialog;
00028 class SpreadsheetValuesDialog;
00029
00030 #define MAX_COLS 676
00031
00032 class Spreadsheet: public QWidget
00033 {
00034 Q_OBJECT
00035
00036
00037 public:
00038 Spreadsheet(QWidget *parent, MainWin *mw, const char *name);
00039 void update();
00040 void closeNow();
00041 WidgetType getWidgetType() { return widgettype; }
00042 QStringList Info();
00043 MainWin *getMainWin() { return mw; }
00044 #ifdef USE_NEW_TABLE
00045 LTable *Table() { return table; }
00046 #else
00047 QTable *Table() { return table; }
00048 #endif
00049 void setText(int i, int j, QString text);
00050 void save(QTextStream *t);
00051 void open(QTextStream *t, int version);
00052 QDomElement saveXML(QDomDocument doc);
00053 void openXML(QDomNode node);
00054 bool eventFilter(QObject *object, QEvent *e);
00055 public slots:
00056 void Menu(QPopupMenu *menu);
00057 void updateValuesDialog();
00058 void selectionChanged();
00059 QString Title() const { return title; }
00060 void setTitle(QString t="");
00061 QString Notes() const { return notes; }
00062 void setNotes(QString notes="");
00063 void setListDialog(ListDialog *l) {ld=l; setCaption(i18n("Spreadsheet")+QString(" : ")+i18n("Edit data") ); }
00064 void setGraph(Graph *g) { graph=g; }
00065 QStringList columnInfo(int col);
00066 QString columnTitle(int col);
00067 void setColumnTitle(int col, QString name=0);
00068 QString columnType(int col);
00069 void setColumnType(int col, QString type=0);
00070 QString columnFormat(int col);
00071 void setColumnFormat(int col, QString format=0);
00072 void Clear();
00073 int filledRows(int col=1);
00074 int selectedColumns();
00075 int selectedRows();
00076 int getColumnIndex(QString title);
00077
00078 void plot2DSimple() { plot2D(P2D,false); }
00079 void plot2DPie() { plot2D(PPIE,false); }
00080 void plotLPie() { plotL(PPIE); }
00081 void plot2DPolar() { plot2D(PPOLAR,false); }
00082 void plot3DXYPX() { plot3DXYDY(I2DXYPX); }
00083 void plot3DXYPY() { plot3DXYDY(I2DXYPY); }
00084 void plot2DLine() { plot2D(P2D,true); }
00085 void plotMSurface() { plotMatrix(PSURFACE); }
00086 void plot3DSurface() { plot3D(PSURFACE); }
00087 void plotM3D() { plotMatrix(P3D); }
00088 void plotQWT3D() { plot3D(PQWT3D); }
00089 void plotMQWT3D() { plotMatrix(PQWT3D); }
00090 void plot3DXYDY(Input2D mode=I2DXYDY);
00091 void plot4DXYDXDY();
00092 void plot4DXYDYDY();
00093 void plot3DSimple() { plot3D(P3D); }
00094 void plot3DTernary() { plot3D(PTERNARY); }
00095
00096 void selectDestination();
00097 int Destination() { return destination; }
00098 void setDestination(int v) { destination=v; }
00099
00100 void addGraph2D(Graph2D *g);
00101 void addGraph3D(Graph3D *g);
00102 void addGraph4D(Graph4D *g);
00103 void addGraphM(GraphM *g);
00104 void addGraphL(GraphL *g);
00105 Graph2D* getGraph2D();
00106 Graph3D* getGraph3D();
00107 Graph4D* getGraph4D();
00108 GraphM* getGraphM();
00109 GraphL* getGraphL();
00110
00111 void cutSelection();
00112 void copySelection();
00113 void pasteSelection();
00114 void clearSelection();
00115
00116 void fillRowNumber();
00117 void fillRandom(double max=1.0);
00118 void setCurrentColumn(int i);
00119
00120 void selectAll();
00121 void selectNone();
00122 void selectInvert();
00123
00124 void normSum();
00125 void normMax(double max=1.0);
00126 void convertComma();
00127 void convertFORTRAN();
00128 void transposeMatrix();
00129 void convertMatrixtoXYZ();
00130 void convertXYZtoMatrix();
00131 void convertColumntoMatrix();
00132 ExportDialog* exportData();
00133 void addColumn();
00134 void toggleMask();
00135 void maskSelection();
00136 void unMask();
00137 void maskNthRow();
00138 void maskFirstRow();
00139 void sortAscending();
00140 void sortDescending();
00141 void rowStatistics() { Statistics(false); }
00142 void Statistics(bool col=true);
00143 void selectColumns(int left, int right=-1);
00144 void selectRows(int top, int bottom=-1);
00145 void deleteRows();
00146 void deleteColumns();
00147 void setValues(int srow=1, int erow=0, QString expr=0);
00148 void setProperties(QString label=0, int type=1, int format=0, int rows=100);
00150 private slots:
00151 void plot2D(PType type,bool line);
00152 void plot3D(PType type);
00153 void plotL(PType type);
00154 void plotMatrix(PType type);
00155 void editEditor(int editor);
00156 void readfile(KProcess *process);
00157 void editVI() { editEditor(0); }
00158 void editKVIM() { editEditor(1); }
00159 void editGVIM() { editEditor(2); }
00160 void editKATE() { editEditor(3); }
00161 void editKWRITE() { editEditor(4); }
00162 void editEMACS() { editEditor(5); }
00163 void editXEMACS() { editEditor(6); }
00164 void editKWORD() { editEditor(7); }
00165 void editSOFFICE() { editEditor(8); }
00166 private:
00167 int formatItem(int col);
00168 void sort();
00169 void qsort(int s, int e);
00170 void updateGraphList();
00171 void setColumnNames(int nrcols);
00172 void contextMenuEvent(QContextMenuEvent *);
00173 void mousePressEvent ( QMouseEvent *);
00174 void resizeEvent(QResizeEvent *);
00175 void closeEvent(QCloseEvent *);
00176 MainWin *mw;
00177 WidgetType widgettype;
00178 QString title;
00179 QString notes;
00180 #ifdef USE_NEW_TABLE
00181 LTable *table;
00182 #else
00183 QTable *table;
00184 #endif
00185 ListDialog *ld;
00186 SpreadsheetValuesDialog *values_dialog;
00187 Graph *graph;
00188 GRAPHType gtype;
00189 QString datafile;
00190 QString tmpfilename;
00191 bool ascending;
00192 int destination;
00193 QPopupMenu *plotmenu, *destmenu, *selmenu, *fillmenu, *normmenu;
00194 QPopupMenu *editmenu, *convertmenu, *sortmenu, *maskmenu;
00195 };
00196
00197 #endif //SPREADSHEET