00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef IMPORTFILESDIALOG_H
00030 #define IMPORTFILESDIALOG_H
00031
00032 #include <ExtensibleFileDialog.h>
00033
00034 #include <QComboBox>
00035 #include <QCheckBox>
00036 #include <QSpinBox>
00037 #include <QLineEdit>
00038 #include <QTableView>
00039
00040 class QGroupBox;
00041 class QPushButton;
00042 class QStackedWidget;
00043 class QLabel;
00044 class Matrix;
00045 class MatrixModel;
00046
00047 #include <q3table.h>
00048 #include <q3header.h>
00049
00050 class PreviewTable : public Q3Table
00051 {
00052 Q_OBJECT
00053
00054 public:
00055 PreviewTable(int numRows, int numCols, QWidget * parent = 0, const char * name = 0);
00056
00057 void importASCII(const QString &fname, const QString &sep, int ignoredLines, bool renameCols,
00058 bool stripSpaces, bool simplifySpaces, bool importComments, const QString& commentString,
00059 int importMode, const QLocale& importLocale, int endLine, int maxRows);
00060
00061 void resetHeader();
00062 void clear();
00063 void setNumericPrecision(int prec) {d_numeric_precision = prec;};
00064 QList<int> columnTypes(){return colTypes;};
00065 QStringList columnFormats(){return d_col_format;};
00066 void showColTypeDialog();
00067 void setSelectedColumn(int col);
00068
00069 signals:
00070 void modifiedColumnType();
00071
00072 private slots:
00073 void setColumnType(int);
00074 void setColumnFormat(const QString&);
00075 void setHeader();
00076 void prevColumn();
00077 void nextColumn();
00078 void updateColumn(int sc);
00079 bool eventFilter(QObject *object, QEvent *e);
00080
00081 private:
00082 void addColumns(int c);
00083 QStringList comments, col_label;
00084 int d_numeric_precision, d_start_col;
00085 QList<int> colTypes;
00086 QStringList d_col_format;
00087 int d_selected_column;
00088
00089 QComboBox *formatBox, *typesBox;
00090 QLabel *formatLabel;
00091 QPushButton *buttonNext, *buttonPrev;
00092 QGroupBox *gb1;
00093 };
00094
00095 class PreviewMatrix : public QTableView
00096 {
00097 public:
00098 PreviewMatrix(QWidget *parent, Matrix * m = 0);
00099
00100 void importASCII(const QString &fname, const QString &sep, int ignoredLines,
00101 bool stripSpaces, bool simplifySpaces, const QString& commentString,
00102 int importAs, const QLocale& locale, int endLine, int maxRows);
00103
00104 void clear();
00105
00106 private:
00107 MatrixModel *d_matrix_model;
00108 };
00109
00111 class ImportASCIIDialog: public ExtensibleFileDialog
00112 {
00113 Q_OBJECT
00114
00115 public:
00117
00120 enum ImportMode {
00121 NewTables,
00122 NewMatrices,
00123 NewColumns,
00124 NewRows,
00125 Overwrite
00126 };
00127
00129
00135 ImportASCIIDialog(bool new_windows_only, QWidget * parent = 0, bool extended = true, Qt::WFlags flags = 0 );
00136
00138
00141 ImportMode importMode() const { return (ImportMode) d_import_mode->currentIndex(); }
00143 const QString columnSeparator() const;
00145 int ignoredLines() const { return d_ignored_lines->value(); }
00147 bool renameColumns() const { return d_rename_columns->isChecked() && !d_first_line_role->currentIndex(); };
00148 bool useFirstRow() const { return d_rename_columns->isChecked();};
00150 bool simplifySpaces() const { return d_simplify_spaces->isChecked(); };
00152 bool stripSpaces() const { return d_strip_spaces->isChecked(); };
00154 bool readOnly() const {return d_read_only->isChecked(); };
00155
00157 void setColumnSeparator(const QString &sep);
00158
00160 QLocale decimalSeparators();
00161
00163 QString commentString(){return d_comment_string->text();};
00164
00166 bool importComments();
00167 bool useSecondRow() const { return d_import_comments->isChecked();};
00168
00170 inline int endLineChar(){return boxEndLine->currentIndex();};
00171
00172 void selectFilter(const QString & filter);
00173
00174 QList<int> columnTypes(){if (d_preview_table) return d_preview_table->columnTypes(); return QList<int>();};
00175 QStringList columnFormats(){if (d_preview_table) return d_preview_table->columnFormats(); return QStringList();};
00176
00177 private slots:
00179 void displayHelp();
00180 void showColTypeDialog();
00182 void updateImportMode(int mode);
00183 void preview();
00184 void changePreviewFile(const QString& path);
00186 void enableTableOptions(bool on);
00187 void enableComments();
00188
00189 private:
00190 void initPreview(int previewMode);
00191 void previewTable();
00192 void previewMatrix();
00193
00194 void closeEvent(QCloseEvent*);
00196 void initAdvancedOptions();
00197 void setNewWindowsOnly(bool on);
00198
00200 QGroupBox *d_advanced_options;
00201 QCheckBox *d_read_only, *d_omit_thousands_sep;
00202 QPushButton *d_help_button, *d_col_types_button;
00203
00204 QComboBox *d_import_mode, *d_column_separator, *boxDecimalSeparator, *boxEndLine;
00205 QSpinBox *d_ignored_lines, *d_preview_lines_box;
00206 QCheckBox *d_rename_columns, *d_simplify_spaces, *d_strip_spaces, *d_import_comments;
00207 QLineEdit *d_comment_string;
00208 PreviewTable *d_preview_table;
00209 PreviewMatrix *d_preview_matrix;
00210 QCheckBox *d_preview_button;
00211 QStackedWidget *d_preview_stack;
00212 QString d_current_path;
00213 QComboBox *d_first_line_role;
00214 };
00215
00216 #endif