Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

Spreadsheet.h

Go to the documentation of this file.
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 //#define USE_NEW_TABLE
00012 
00013 #ifdef USE_NEW_TABLE
00014 #include <LTable.h>
00015 #endif
00016 
00017 #ifdef HAVE_UNDO
00018 extern "C" {
00019 #include "undo.h"
00020 }
00021 #endif
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 // this leads to loops on KDE 3.4
00036 //      Q_PROPERTY(QString title READ Title WRITE setTitle)
00037 public:
00038         Spreadsheet(QWidget *parent, MainWin *mw, const char *name);
00039         static void* operator new(size_t size);
00040         static void operator delete(void *p);
00041         void update();
00042         void closeNow();
00043         WidgetType getWidgetType() { return widgettype; }
00044         QStringList Info();
00045         MainWin *getMainWin() { return mw; }
00046 #ifdef HAVE_UNDO
00047         UNDO *getUndo();
00048         void setUndo(UNDO *u);
00049 #endif
00050 #ifdef USE_NEW_TABLE
00051         LTable *Table() { return table; }
00052 #else
00053         QTable *Table() { return table; }
00054 #endif
00055         void setText(int i, int j, QString text);
00056         void save(QTextStream *t);
00057         void open(QTextStream *t, int version);
00058         QDomElement saveXML(QDomDocument doc);
00059         void openXML(QDomNode node);
00060         bool eventFilter(QObject *object, QEvent *e);
00061 public slots:
00062         void Menu(QPopupMenu *menu);                            
00063         void updateValuesDialog();
00064         QString Title() const { return title; }                 
00065         void setTitle(QString t="");                            
00066         void setListDialog(ListDialog *l) {ld=l; setCaption(i18n("Spreadsheet")+QString(" : ")+i18n("Edit data") ); }
00067         void setGraph(Graph *g) { graph=g; }
00068         QStringList columnInfo(int col);                        
00069         QString columnTitle(int col);                           
00070         void setColumnTitle(int col, QString name=0);
00071         QString columnType(int col);                            
00072         void setColumnType(int col, QString type=0);
00073         QString columnFormat(int col);                          
00074         void setColumnFormat(int col, QString format=0);
00075         void Clear();                                                           
00076         int filledRows(int col=1);
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 d) { destination=d; }
00099         
00100         void addGraph2D(Graph2D *g);                                    // add data from graph 2d
00101         void addGraph3D(Graph3D *g);                                    // add data from graph 3d
00102         void addGraph4D(Graph4D *g);                                    // add data from graph 4d
00103         void addGraphM(GraphM *g);                                      // add data from graph m
00104         void addGraphL(GraphL *g);                                      // add data from graph l
00105         Graph2D* getGraph2D();                                  // get data for graph 2d
00106         Graph3D* getGraph3D();                                  // get data for graph 3d
00107         Graph4D* getGraph4D();                                  // get data for graph 4d
00108         GraphM* getGraphM();                                    // get data for graph m
00109         GraphL* getGraphL();                                    // get data for graph l
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 transposeMatrix();                                         
00128         void convertMatrixtoXYZ();                                      
00129         void convertXYZtoMatrix();                                      
00130         void convertColumntoMatrix();                           
00131         ExportDialog* exportData();                             
00132         void addColumn();                                                       
00133         void toggleMask();
00134         void maskSelection();
00135         void unMask();
00136         void maskNthRow();
00137         void maskFirstRow();
00138         void sortAscending();                                           
00139         void sortDescending();                                          
00140         void rowStatistics() { Statistics(false); }                     
00141         void Statistics(bool col=true);                                 
00142         void selectColumns(int left, int right=-1);             
00143         void selectRows(int top, int bottom=-1);                        
00144         void deleteRows();                                                      
00145         void deleteColumns();                                           
00146         void setValues(int srow=1, int erow=0, QString expr=0); 
00147         void setProperties(QString label=0, int type=1, int format=0, int rows=100);    
00149 private slots:
00150         void plot2D(PType type,bool line);
00151         void plot3D(PType type);
00152         void plotL(PType type);
00153         void plotMatrix(PType type);
00154         void editEditor(int editor);
00155         void readfile(KProcess *process);
00156         void editVI() { editEditor(0); }
00157         void editKVIM() { editEditor(1); }
00158         void editGVIM() { editEditor(2); }
00159         void editKATE() { editEditor(3); }
00160         void editKWRITE() { editEditor(4); }
00161         void editEMACS() { editEditor(5); }
00162         void editXEMACS() { editEditor(6); }
00163         void editKWORD() { editEditor(7); }
00164         void editSOFFICE() { editEditor(8); }
00165 private:
00166         int formatItem(int col);
00167         void sort();
00168         void qsort(int s, int e);
00169         void updateGraphList();
00170         void contextMenuEvent(QContextMenuEvent *);
00171         void mousePressEvent ( QMouseEvent *);
00172         void resizeEvent(QResizeEvent *);
00173         void closeEvent(QCloseEvent *);
00174         MainWin *mw;
00175         WidgetType widgettype;
00176         QString title;
00177 #ifdef USE_NEW_TABLE
00178         LTable *table;
00179 #else
00180         QTable *table;
00181 #endif
00182 #ifdef HAVE_UNDO
00183 //      UNDO *undo;
00184 #endif
00185         ListDialog *ld;                 // used when editing data from list dialog
00186         SpreadsheetValuesDialog *values_dialog;
00187         Graph *graph;                           // used for editing
00188         GRAPHType gtype;                        // -""-
00189         QString datafile;                       // used for online data
00190         QString tmpfilename;    // tmp filename for editing with editor
00191         bool ascending;         // for sorting a column
00192         int destination;                        // for plots
00193         QPopupMenu *plotmenu, *destmenu, *selmenu, *fillmenu, *normmenu;
00194         QPopupMenu *editmenu, *convertmenu, *sortmenu, *maskmenu;
00195 };
00196 
00197 #endif //SPREADSHEET

Generated on Sun Apr 2 02:05:09 2006 for LabPlot by  doxygen 1.4.4