00001 /* Copyright (C) 2006 P.L. Lucas 00002 * 00003 * This program is free software; you can redistribute it and/or modify 00004 * it under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation; either version 2 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place, Suite 330, 00016 * Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef __TABLE_H__ 00020 #define __TABLE_H__ 00021 00022 #include <QTableWidget> 00023 #include <QContextMenuEvent> 00024 #include "octave_connection.h" 00025 #include "ui_table_ui.h" 00026 #include "basewidget.h" 00027 00028 using namespace Ui; 00029 00030 /** Shows QTable with spreadsheet. Spreadsheet's data are from given matrix. 00031 When spreadsheet is modificated, matrix is modificated. 00032 */ 00033 00034 class Table:public BaseWidget 00035 { 00036 Q_OBJECT 00037 public: 00038 Table( QWidget * parent = 0 ); 00039 void setOctaveConnection(OctaveConnection *octave_connection); 00040 void setMatrix(QString matrix); 00041 QString getMatrix(); 00042 private: 00043 TableForm *table_form; 00044 OctaveConnection *octave_connection; 00045 QString matrix; 00046 void change_rows(); 00047 void change_cols(); 00048 void build_menu(); 00049 QMenu *menu; 00050 protected: 00051 void contextMenuEvent ( QContextMenuEvent * event ); 00052 public slots: 00053 void windowActivated ( QWidget * w ); 00054 void windowActivated(); 00055 /** Callback to line_ready signal from OctaveConnection. 00056 * @param line line from Octave. 00057 */ 00058 void line_ready(QString line); 00059 void cellChanged ( int row, int col ); 00060 void rows_changed(); 00061 void cols_changed(); 00062 void order_changed(); 00063 void copy_cb(); 00064 void copy_matrix_cb(); 00065 void paste_cb(); 00066 void delete_rows_cb(); 00067 void delete_columns_cb(); 00068 void insert_column_right_cb(); 00069 void insert_column_left_cb(); 00070 void insert_row_down_cb(); 00071 void insert_row_up_cb(); 00072 }; 00073 00074 00075 #endif