ImportASCIIDialog.h
Go to the documentation of this file.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 Matrix;
00044 class MatrixModel;
00045
00046 #include <q3table.h>
00047 #include <q3header.h>
00048
00049 class PreviewTable : public Q3Table
00050 {
00051 Q_OBJECT
00052
00053 public:
00054 PreviewTable(int numRows, int numCols, QWidget * parent = 0, const char * name = 0);
00055
00056 void importASCII(const QString &fname, const QString &sep, int ignoredLines, bool renameCols,
00057 bool stripSpaces, bool simplifySpaces, bool importComments, const QString& commentString,
00058 int importMode, int endLine, int maxRows);
00059
00060 void resetHeader();
00061 void clear();
00062 void updateDecimalSeparators(const QLocale& oldSeparators);
00063 void setNumericPrecision(int prec) {d_numeric_precision = prec;};
00064
00065 private slots:
00066 void setHeader();
00067
00068 private:
00069 void addColumns(int c);
00070 QStringList comments, col_label;
00071 int d_numeric_precision;
00072 };
00073
00074 class PreviewMatrix : public QTableView
00075 {
00076 public:
00077 PreviewMatrix(QWidget *parent, Matrix * m = 0);
00078
00079 void importASCII(const QString &fname, const QString &sep, int ignoredLines,
00080 bool stripSpaces, bool simplifySpaces, const QString& commentString,
00081 int importAs, const QLocale& locale, int endLine, int maxRows);
00082
00083 void clear();
00084
00085 private:
00086 MatrixModel *d_matrix_model;
00087 };
00088
00090 class ImportASCIIDialog: public ExtensibleFileDialog
00091 {
00092 Q_OBJECT
00093
00094 public:
00096
00099 enum ImportMode {
00100 NewTables,
00101 NewMatrices,
00102 NewColumns,
00103 NewRows,
00104 Overwrite
00105 };
00106
00108
00114 ImportASCIIDialog(bool new_windows_only, QWidget * parent = 0, bool extended = true, Qt::WFlags flags = 0 );
00115
00117
00120 ImportMode importMode() const { return (ImportMode) d_import_mode->currentIndex(); }
00122 const QString columnSeparator() const;
00124 int ignoredLines() const { return d_ignored_lines->value(); }
00126 bool renameColumns() const { return d_rename_columns->isChecked() && !d_first_line_role->currentIndex(); };
00127 bool useFirstRow() const { return d_rename_columns->isChecked();};
00129 bool simplifySpaces() const { return d_simplify_spaces->isChecked(); };
00131 bool stripSpaces() const { return d_strip_spaces->isChecked(); };
00133 bool readOnly() const {return d_read_only->isChecked(); };
00134
00136 void setColumnSeparator(const QString &sep);
00137
00139 QLocale decimalSeparators();
00140
00142 QString commentString(){return d_comment_string->text();};
00143
00145 bool importComments();
00146 bool useSecondRow() const { return d_import_comments->isChecked();};
00147
00149 inline int endLineChar(){return boxEndLine->currentIndex();};
00150
00151 private slots:
00153 void displayHelp();
00155 void updateImportMode(int mode);
00156 void preview();
00157 void changePreviewFile(const QString& path);
00159 void enableTableOptions(bool on);
00160 void enableComments();
00161
00162 private:
00163 void initPreview(int previewMode);
00164 void previewTable();
00165 void previewMatrix();
00166
00167 void closeEvent(QCloseEvent*);
00169 void initAdvancedOptions();
00170 void setNewWindowsOnly(bool on);
00171
00173 QGroupBox *d_advanced_options;
00174 QCheckBox *d_read_only, *d_omit_thousands_sep;
00175 QPushButton *d_help_button;
00176
00177 QComboBox *d_import_mode, *d_column_separator, *boxDecimalSeparator, *boxEndLine;
00178 QSpinBox *d_ignored_lines, *d_preview_lines_box;
00179 QCheckBox *d_rename_columns, *d_simplify_spaces, *d_strip_spaces, *d_import_comments;
00180 QLineEdit *d_comment_string;
00181 PreviewTable *d_preview_table;
00182 PreviewMatrix *d_preview_matrix;
00183 QCheckBox *d_preview_button;
00184 QStackedWidget *d_preview_stack;
00185 QString d_current_path;
00186 QComboBox *d_first_line_role;
00187 };
00188
00189 #endif