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 class MainWin;
00018 class ListDialog;
00019
00020 class Spreadsheet: public QWidget
00021 {
00022 Q_OBJECT
00023
00024
00025 public:
00026 Spreadsheet(QWidget *parent, MainWin *mw, const char *name);
00027 WidgetType getWidgetType() { return widgettype; }
00028 QStringList Info();
00029 #ifdef USE_NEW_TABLE
00030 LTable *Table() { return table; }
00031 #else
00032 QTable *Table() { return table; }
00033 #endif
00034 void save(QTextStream *t);
00035 void open(QTextStream *t, int version);
00036 QString columnTitle(int col);
00037 bool eventFilter(QObject *object, QEvent *e);
00038 QString Title() const { return title; }
00039 public slots:
00040 void Menu(QPopupMenu *menu);
00041 void setTitle(QString t="");
00042 void setListDialog(ListDialog *l) {ld=l; setCaption(i18n("Spreadsheet")+QString(" : ")+i18n("Edit data") ); }
00043 void setGraph(Graph *graph) { g=graph; }
00044 void setColumnTitle(int col, QString name=0);
00045 void setColumnType(int col, QString type=0);
00046 void Clear();
00047 int filledRows(int col=1);
00048
00049 void plot2DSimple() { plot2D(P2D,false); }
00050 void plot2DPie() { plot2D(PPIE,false); }
00051 void plot2DPolar() { plot2D(PPOLAR,false); }
00052 void plot3DXYPX() { plot3DXYDY(I2DXYPX); }
00053 void plot3DXYPY() { plot3DXYDY(I2DXYPY); }
00054 void plot2DLine() { plot2D(P2D,true); }
00055 void plotMSurface() { plotMatrix(PSURFACE); }
00056 void plot3DSurface() { plot3D(PSURFACE); }
00057 void plotM3D() { plotMatrix(P3D); }
00058 void plotQWT3D() { plot3D(PQWT3D); }
00059 void plotMQWT3D() { plotMatrix(PQWT3D); }
00060 void plot3DXYDY(Input2D mode=I2DXYDY);
00061 void plot4DXYDXDY();
00062 void plot4DXYDYDY();
00063 void plot3DSimple() { plot3D(P3D); }
00064 void plot3DTernary() { plot3D(PTERNARY); }
00065
00066 void selectDestination();
00067 int Destination() { return destination; }
00068 void setDestination(int d) { destination=d; }
00069
00070 void addGraph2D(Graph2D *g);
00071 void addGraph3D(Graph3D *g);
00072 void addGraph4D(Graph4D *g);
00073 void addGraphM(GraphM *g);
00074 Graph2D* getGraph2D();
00075 Graph3D* getGraph3D();
00076 Graph4D* getGraph4D();
00077 GraphM* getGraphM();
00078
00079 void cutSelection();
00080 void copySelection();
00081 void pasteSelection();
00082 void clearSelection();
00083
00084 void fillRowNumber();
00085 void fillRandom(double max=1.0);
00086 void setCurrentColumn(int i);
00087
00088 void selectAll();
00089 void selectNone();
00090 void selectInvert();
00091
00092 void normSum();
00093 void normMax(double max=1.0);
00094 void transposeMatrix();
00095 void convertMatrixtoXYZ();
00096 void convertXYZtoMatrix();
00097 void convertColumntoMatrix();
00098 void exportData();
00099 void addColumn();
00100 void toggleMask();
00101 void maskSelection();
00102 void unMask();
00103 void maskNthRow();
00104 void maskFirstRow();
00105 void sortAscending();
00106 void sortDescending();
00107 void selectColumns(int left, int right=-1);
00108 void selectRows(int top, int bottom=-1);
00109 void deleteRows();
00110 void deleteColumns();
00111 void setValues(int srow=1, int erow=0, QString expr=0);
00112 void setProperties(QString label=0, int type=1, int format=1, int rows=100);
00114 private slots:
00115 void plot2D(PType type,bool line);
00116 void plot3D(PType type);
00117 void plotMatrix(PType type);
00118 void editEditor(int editor);
00119 void readfile(KProcess *process);
00120 void editVI() { editEditor(0); }
00121 void editKVIM() { editEditor(1); }
00122 void editGVIM() { editEditor(2); }
00123 void editKATE() { editEditor(3); }
00124 void editKWRITE() { editEditor(4); }
00125 void editEMACS() { editEditor(5); }
00126 void editXEMACS() { editEditor(6); }
00127 void editKWORD() { editEditor(7); }
00128 void editSOFFICE() { editEditor(8); }
00129 private:
00130 int formatItem(int col);
00131 void sort();
00132 void qsort(int s, int e);
00133 void updateGraphList();
00134 void contextMenuEvent(QContextMenuEvent *);
00135 void mousePressEvent ( QMouseEvent *);
00136 void resizeEvent(QResizeEvent *);
00137 void closeEvent(QCloseEvent *);
00138 Style *defaultStyle();
00139 Symbol *defaultSymbol();
00140 MainWin *mw;
00141 WidgetType widgettype;
00142 QString title;
00143 #ifdef USE_NEW_TABLE
00144 LTable *table;
00145 #else
00146 QTable *table;
00147 #endif
00148 ListDialog *ld;
00149 Graph *g;
00150 QString tmpfilename;
00151 bool ascending;
00152 int destination;
00153 QPopupMenu *plotmenu, *destmenu, *selmenu, *fillmenu, *normmenu;
00154 QPopupMenu *editmenu, *convertmenu, *sortmenu, *maskmenu;
00155 };
00156
00157 #endif //SPREADSHEET