QtiPlot  0.9.8.2
ImportASCIIDialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : ImportASCIIDialog.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006,2007 by Ion Vasilief, Knut Franke
6  Email (use @ for *) : ion_vasilief*yahoo.fr, knut.franke*gmx.de
7  Description : Import ASCII file(s) dialog
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef IMPORTFILESDIALOG_H
30 #define IMPORTFILESDIALOG_H
31 
32 #include <ExtensibleFileDialog.h>
33 
34 #include <QComboBox>
35 #include <QCheckBox>
36 #include <QSpinBox>
37 #include <QLineEdit>
38 #include <QTableView>
39 
40 class QGroupBox;
41 class QPushButton;
42 class QStackedWidget;
43 class QLabel;
44 class Matrix;
45 class MatrixModel;
46 
47 #include <q3table.h>
48 #include <q3header.h>
49 
50 class PreviewTable : public Q3Table
51 {
52  Q_OBJECT
53 
54 public:
55  PreviewTable(int numRows, int numCols, QWidget * parent = 0, const char * name = 0);
56 
57  void importASCII(const QString &fname, const QString &sep, int ignoredLines, bool renameCols,
58  bool stripSpaces, bool simplifySpaces, bool importComments, const QString& commentString,
59  int importMode, const QLocale& importLocale, int endLine, int maxRows);
60 
61  void resetHeader();
62  void clear();
63  void setNumericPrecision(int prec) {d_numeric_precision = prec;};
64  QList<int> columnTypes(){return colTypes;};
65  QStringList columnFormats(){return d_col_format;};
66  void showColTypeDialog();
67  void setSelectedColumn(int col);
68 
69 signals:
70  void modifiedColumnType();
71 
72 private slots:
73  void setColumnType(int);
74  void setColumnFormat(const QString&);
75  void setHeader();
76  void prevColumn();
77  void nextColumn();
78  void updateColumn(int sc);
79  bool eventFilter(QObject *object, QEvent *e);
80 
81 private:
82  void addColumns(int c);
83  QStringList comments, col_label;
85  QList<int> colTypes;
86  QStringList d_col_format;
88 
89  QComboBox *formatBox, *typesBox;
90  QLabel *formatLabel;
91  QPushButton *buttonNext, *buttonPrev;
92  QGroupBox *gb1;
93 };
94 
95 class PreviewMatrix : public QTableView
96 {
97 public:
98  PreviewMatrix(QWidget *parent, Matrix * m = 0);
99 
100  void importASCII(const QString &fname, const QString &sep, int ignoredLines,
101  bool stripSpaces, bool simplifySpaces, const QString& commentString,
102  int importAs, const QLocale& locale, int endLine, int maxRows);
103 
104  void clear();
105 
106 private:
108 };
109 
112 {
113  Q_OBJECT
114 
115 public:
117 
120  enum ImportMode {
126  };
127 
129 
135  ImportASCIIDialog(bool new_windows_only, QWidget * parent = 0, bool extended = true, Qt::WFlags flags = 0 );
136 
138 
141  ImportMode importMode() const { return (ImportMode) d_import_mode->currentIndex(); }
143  const QString columnSeparator() const;
145  int ignoredLines() const { return d_ignored_lines->value(); }
147  bool renameColumns() const { return d_rename_columns->isChecked() && !d_first_line_role->currentIndex(); };
148  bool useFirstRow() const { return d_rename_columns->isChecked();};
150  bool simplifySpaces() const { return d_simplify_spaces->isChecked(); };
152  bool stripSpaces() const { return d_strip_spaces->isChecked(); };
154  bool readOnly() const {return d_read_only->isChecked(); };
155 
157  void setColumnSeparator(const QString &sep);
158 
160  QLocale decimalSeparators();
161 
163  QString commentString(){return d_comment_string->text();};
164 
166  bool importComments();
167  bool useSecondRow() const { return d_import_comments->isChecked();};
168 
170  inline int endLineChar(){return boxEndLine->currentIndex();};
171 
172  QList<int> columnTypes(){if (d_preview_table) return d_preview_table->columnTypes(); return QList<int>();};
173  QStringList columnFormats(){if (d_preview_table) return d_preview_table->columnFormats(); return QStringList();};
174 
175  void setCurrentPath(const QString& path);
176 
177 public slots:
178  void selectFilter(const QString & filter);
179 
180 private slots:
182  void displayHelp();
183  void showColTypeDialog();
185  void updateImportMode(int mode);
186  void preview();
187  void changePreviewFile(const QString& path);
189  void enableTableOptions(bool on);
190  void enableComments();
191 
192 private:
193  void initPreview(int previewMode);
194  void previewTable();
195  void previewMatrix();
196 
197  void closeEvent(QCloseEvent*);
199  void initAdvancedOptions();
200  void setNewWindowsOnly(bool on);
201 
203  QGroupBox *d_advanced_options;
206  // the actual options
210  QLineEdit *d_comment_string;
213  QCheckBox *d_preview_button;
214  QStackedWidget *d_preview_stack;
215  QString d_current_path;
216  QComboBox *d_first_line_role;
217 };
218 
219 #endif