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 public:
00052 PreviewTable(int numRows, int numCols, QWidget * parent = 0, const char * name = 0);
00053
00054 void importASCII(const QString &fname, const QString &sep, int ignoredLines, bool renameCols,
00055 bool stripSpaces, bool simplifySpaces, bool importComments, const QString& commentString,
00056 int importMode, int endLine, int maxRows);
00057
00058 void resetHeader();
00059 void clear();
00060 void updateDecimalSeparators(const QLocale& oldSeparators);
00061 void setNumericPrecision(int prec) {d_numeric_precision = prec;};
00062
00063 private:
00064 void setHeader();
00065 void addColumns(int c);
00066 QStringList comments, col_label;
00067 int d_numeric_precision;
00068 };
00069
00070 class PreviewMatrix : public QTableView
00071 {
00072 public:
00073 PreviewMatrix(QWidget *parent, Matrix * m = 0);
00074
00075 void importASCII(const QString &fname, const QString &sep, int ignoredLines,
00076 bool stripSpaces, bool simplifySpaces, const QString& commentString,
00077 int importAs, const QLocale& locale, int endLine, int maxRows);
00078
00079 void clear();
00080
00081 private:
00082 MatrixModel *d_matrix_model;
00083 };
00084
00086 class ImportASCIIDialog: public ExtensibleFileDialog
00087 {
00088 Q_OBJECT
00089
00090 public:
00092
00095 enum ImportMode {
00096 NewTables,
00097 NewMatrices,
00098 NewColumns,
00099 NewRows,
00100 Overwrite
00101 };
00102
00104
00110 ImportASCIIDialog(bool new_windows_only, QWidget * parent = 0, bool extended = true, Qt::WFlags flags = 0 );
00111
00113
00116 ImportMode importMode() const { return (ImportMode) d_import_mode->currentIndex(); }
00118 const QString columnSeparator() const;
00120 int ignoredLines() const { return d_ignored_lines->value(); }
00122 bool renameColumns() const { return d_rename_columns->isChecked(); }
00124 bool simplifySpaces() const { return d_simplify_spaces->isChecked(); }
00126 bool stripSpaces() const { return d_strip_spaces->isChecked(); }
00128 bool readOnly() const {return d_read_only->isChecked(); }
00129
00131 void setColumnSeparator(const QString &sep);
00132
00134 QLocale decimalSeparators();
00135
00137 QString commentString(){return d_comment_string->text();};
00138
00140 bool importComments(){return d_import_comments->isChecked();};
00141
00143 inline int endLineChar(){return boxEndLine->currentIndex();};
00144
00145 private slots:
00147 void displayHelp();
00149 void updateImportMode(int mode);
00150 void preview();
00151 void changePreviewFile(const QString& path);
00153 void enableTableOptions(bool on);
00154
00155 private:
00156 void initPreview(int previewMode);
00157 void previewTable();
00158 void previewMatrix();
00159
00160 void closeEvent(QCloseEvent*);
00162 void initAdvancedOptions();
00163 void setNewWindowsOnly(bool on);
00164
00166 QGroupBox *d_advanced_options;
00167 QCheckBox *d_read_only, *d_omit_thousands_sep;
00168 QPushButton *d_help_button;
00169
00170 QComboBox *d_import_mode, *d_column_separator, *boxDecimalSeparator, *boxEndLine;
00171 QSpinBox *d_ignored_lines, *d_preview_lines_box;
00172 QCheckBox *d_rename_columns, *d_simplify_spaces, *d_strip_spaces, *d_import_comments;
00173 QLineEdit *d_comment_string;
00174 PreviewTable *d_preview_table;
00175 PreviewMatrix *d_preview_matrix;
00176 QCheckBox *d_preview_button;
00177 QStackedWidget *d_preview_stack;
00178 QString d_current_path;
00179 };
00180
00181 #endif