qse  0.5.4
Public Types | Signals | Public Member Functions | Static Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
QseDataExport Class Reference

#include <qsedataexport.h>

Inheritance diagram for QseDataExport:
Inheritance graph

Public Types

enum  Option {
  NoOptions = 0, SaveHeader = 0x01, BriefHeader = 0x02, SingleFile = 0x04,
  FileHeaderInEach = 0x08, ColumnHeaderLine = 0x10, AutoRename = 0x20
}
 

Signals

void dataChanged ()
 

Public Member Functions

 QseDataExport (const QString &id, QseDataSet *data, QList< int > selections, QWidget *parent=0)
 
 Q_DECLARE_FLAGS (Options, Option)
 

Static Public Member Functions

static void exportSelectedData (const QString &id, QseDataSet *data, QList< int > selections)
 

Private Slots

void newDirectory ()
 
void upDirectory ()
 
void homeDirectory ()
 
void directoryChanged (const QModelIndex &index)
 
void directoryChanged (const QString &newdir)
 
void scanSelectAll ()
 
void scanSelectNone ()
 
void scanRevert ()
 
void exportPressed ()
 
void cancelPressed ()
 
void previewPressed ()
 
void newOutputPattern (const QString &patt)
 
void saveHeaderOptionChanged (bool opt)
 
void briefHeaderOptionChanged (bool opt)
 
void singleFileOptionChanged (bool opt)
 
void fileHeaderInEachOptionChanged (bool opt)
 
void columnHeaderLineOptionChanged (bool opt)
 
void autoRenameOptionChanged (bool opt)
 

Private Member Functions

void setupConnections ()
 
void updateNewDirectory ()
 
void readSettings ()
 
void writeSettings ()
 
QList< int > selectedScans () const
 
bool checkForOverwriting ()
 
QString substituteFilenamePatterns (const QString &patt, int index, const QseDataSet *ds)
 
void autoRenameFiles ()
 
void updatePreview ()
 
void writePreview ()
 

Private Attributes

Ui::QseDataExport ui
 
QString m_Identifier
 
QList< int > m_Selections
 
QseDataSetm_DataSet
 
int m_Options
 
QDir m_OutputDir
 
QString m_OutputPattern
 
QDirModel m_DirModel
 
QPushButton * m_PreviewButton
 
QseDataExportPreviewm_Preview
 
QseDataExportPreviewUIm_PreviewUI
 

Detailed Description

Definition at line 15 of file qsedataexport.h.

Member Enumeration Documentation

Enumerator
NoOptions 
SaveHeader 
BriefHeader 
SingleFile 
FileHeaderInEach 
ColumnHeaderLine 
AutoRename 

Definition at line 25 of file qsedataexport.h.

Constructor & Destructor Documentation

QseDataExport::QseDataExport ( const QString &  id,
QseDataSet data,
QList< int >  selections,
QWidget *  parent = 0 
)

Definition at line 12 of file qsedataexport.cpp.

References AutoRename, BriefHeader, ColumnHeaderLine, FileHeaderInEach, QseDataSet::fileName(), m_DirModel, m_Options, m_OutputPattern, m_Preview, QseScan::name(), readSettings(), SaveHeader, QseDataSet::scan(), QseDataSet::scanCount(), scanRevert(), setupConnections(), SingleFile, ui, and updateNewDirectory().

13  : QDialog(parent),
14  m_Identifier(id),
15  m_Selections(selections),
16  m_DataSet(data),
17  m_Preview(NULL),
18  m_PreviewUI(NULL)
19 {
20  ui.setupUi(this);
21 
22  m_Preview = new QseDataExportPreview(this, this);
23 
24  readSettings();
25 
26  int i;
27  int nscans = data->scanCount();
28 
29  for (i = 0; i<nscans; i++) {
30  QString scanname = data->scan(i)->name();
31 
32  ui.m_ScanList->addItem(scanname);
33  }
34 
35  scanRevert();
36 
37  ui.m_DirectoryView->setModel(&m_DirModel);
38  ui.m_DirectoryView->hideColumn(1);
39  ui.m_DirectoryView->hideColumn(2);
40  ui.m_DirectoryView->hideColumn(3);
41 
43 
44  ui.m_OutputPatternEdit -> setText(m_OutputPattern);
45 
46  ui.m_SaveHeaderOption -> setChecked(m_Options & SaveHeader);
47  ui.m_BriefHeaderOption -> setChecked(m_Options & BriefHeader);
48  ui.m_SingleFileOption -> setChecked(m_Options & SingleFile);
49  ui.m_FileHeaderInEachOption -> setChecked(m_Options & FileHeaderInEach);
50  ui.m_ColumnHeaderLineOption -> setChecked(m_Options & ColumnHeaderLine);
51  ui.m_AutoRenameOption -> setChecked(m_Options & AutoRename);
52 
53  setWindowTitle(QString("Export Data from %1").arg(data->fileName()));
54 
56 }
int scanCount() const
Definition: qsedataset.cpp:31
QseScan * scan(int n) const
Definition: qsedataset.cpp:70
QseDataExportPreview * m_Preview
Definition: qsedataexport.h:85
void updateNewDirectory()
QList< int > m_Selections
Definition: qsedataexport.h:78
Ui::QseDataExport ui
Definition: qsedataexport.h:76
QDirModel m_DirModel
Definition: qsedataexport.h:83
QseDataSet * m_DataSet
Definition: qsedataexport.h:79
QString fileName() const
Definition: qsedataset.cpp:186
QString m_OutputPattern
Definition: qsedataexport.h:82
QString m_Identifier
Definition: qsedataexport.h:77
QseDataExportPreviewUI * m_PreviewUI
Definition: qsedataexport.h:86
void setupConnections()
QString name() const
Definition: qsescan.cpp:31

Member Function Documentation

void QseDataExport::autoRenameFiles ( )
private

Definition at line 249 of file qsedataexport.cpp.

References m_OutputDir, and m_Preview.

Referenced by checkForOverwriting(), and updatePreview().

250 {
251  QList<QString> dups;
252  QList<QString> files;
253 
254  int nscans = m_Preview -> countFiles();
255 
256  for(int i=0; i<nscans; i++) {
257  QString fnam = m_Preview -> getFile(i);
258 
259  if (QFile::exists(m_OutputDir.filePath(fnam)) ||
260  files.contains(fnam)) {
261 
262  for (int n=1; ; n++) {
263  QString fnam2 = fnam+QString("_%1").arg(n,5,10,QLatin1Char('0'));
264 
265  if ((!QFile::exists(m_OutputDir.filePath(fnam2))) &&
266  (!files.contains(fnam2))) {
267  files.append(fnam2);
268  m_Preview -> setFile(i, fnam2);
269  break;
270  }
271  }
272  }
273  }
274 }
QseDataExportPreview * m_Preview
Definition: qsedataexport.h:85
void QseDataExport::autoRenameOptionChanged ( bool  opt)
privateslot

Definition at line 138 of file qsedataexport.cpp.

References AutoRename, and m_Options.

Referenced by setupConnections().

139 {
140  if (opt) {
142  } else {
143  m_Options &= ~AutoRename;
144  }
145 }
void QseDataExport::briefHeaderOptionChanged ( bool  opt)
privateslot

Definition at line 102 of file qsedataexport.cpp.

References BriefHeader, and m_Options.

Referenced by setupConnections().

103 {
104  if (opt) {
106  } else {
108  }
109 }
void QseDataExport::cancelPressed ( )
privateslot

Definition at line 366 of file qsedataexport.cpp.

Referenced by setupConnections().

367 {
368  done(0);
369 }
bool QseDataExport::checkForOverwriting ( )
private

Definition at line 276 of file qsedataexport.cpp.

References autoRenameFiles(), m_OutputDir, and m_Preview.

Referenced by exportPressed().

277 {
278  QList<QString> dups;
279  QList<QString> files;
280  int i, nd=0, nid=0;
281  int nscans = m_Preview -> countFiles();
282 
283  for(int i=0; i<nscans; i++) {
284  QString fnam = m_Preview -> getFile(i);
285 
286  if (QFile::exists(m_OutputDir.filePath(fnam))) {
287  dups.append(fnam);
288  }
289 
290  if (files.contains(fnam)) {
291  nid++;
292  } else {
293  files.append(fnam);
294  }
295  }
296 
297  nd = dups.count();
298  QString msg;
299 
300  if (nd) {
301  msg.append(QString("%1 files will be overwritten by this operation").arg(nd));
302  for (i = 0; i < qMin(5, nd); i++) {
303  msg.append("\n");
304  msg.append(dups[i]);
305  }
306 
307  if (nd > 5) {
308  msg.append("\n...");
309  }
310  }
311 
312  if (nid) {
313  msg.append(QString("%1 of the output file names are duplicated").arg(nd));
314  }
315 
316  if (nd || nid) {
317  msg.append("\nHow do you want to proceed?");
318  QMessageBox msgBox;
319  QPushButton *goAheadButton = msgBox.addButton("Overwrite", QMessageBox::ActionRole);
320  QPushButton *renameButton = msgBox.addButton("Rename", QMessageBox::ActionRole);
321  QPushButton *cancelButton = msgBox.addButton("Cancel", QMessageBox::ActionRole);
322 
323  msgBox.setWindowTitle("Overwrite...");
324  msgBox.setText("Some of the filenames to be used for output are either duplicated or already exist. What do you want to do?");
325  msgBox.setDetailedText(msg);
326  msgBox.setIcon(QMessageBox::Question);
327 
328  msgBox.exec();
329 
330  if (msgBox.clickedButton() == goAheadButton) {
331  return true;
332  } else if (msgBox.clickedButton() == renameButton) {
333  autoRenameFiles();
334  return true;
335  } else {
336  return false;
337  }
338  }
339 
340  return true;
341 }
QseDataExportPreview * m_Preview
Definition: qsedataexport.h:85
void autoRenameFiles()
void QseDataExport::columnHeaderLineOptionChanged ( bool  opt)
privateslot

Definition at line 129 of file qsedataexport.cpp.

References ColumnHeaderLine, and m_Options.

Referenced by setupConnections().

130 {
131  if (opt) {
133  } else {
135  }
136 }
void QseDataExport::dataChanged ( )
signal

Referenced by previewPressed(), and setupConnections().

void QseDataExport::directoryChanged ( const QModelIndex &  index)
privateslot

Definition at line 196 of file qsedataexport.cpp.

References m_DirModel.

Referenced by setupConnections().

197 {
198  QString fp = m_DirModel.filePath(index);
199 
200  directoryChanged(fp);
201 }
QDirModel m_DirModel
Definition: qsedataexport.h:83
void directoryChanged(const QModelIndex &index)
void QseDataExport::directoryChanged ( const QString &  newdir)
privateslot

Definition at line 203 of file qsedataexport.cpp.

References m_OutputDir, and updateNewDirectory().

204 {
205  QDir qd(newdir);
206 
207  if (qd.exists()) {
208  m_OutputDir.cd(newdir);
209 
211  }
212 }
void updateNewDirectory()
void QseDataExport::exportPressed ( )
privateslot

Definition at line 356 of file qsedataexport.cpp.

References checkForOverwriting(), updatePreview(), and writePreview().

Referenced by setupConnections().

357 {
358  updatePreview();
359 
360  if (checkForOverwriting()) {
361  writePreview();
362  done(0);
363  }
364 }
bool checkForOverwriting()
void QseDataExport::exportSelectedData ( const QString &  id,
QseDataSet data,
QList< int >  selections 
)
static

Definition at line 147 of file qsedataexport.cpp.

Referenced by QseGraphController::saveSelectedScans().

148 {
149  QseDataExport dialog(id, data, selections);
150 
151  dialog.exec();
152 }
void QseDataExport::fileHeaderInEachOptionChanged ( bool  opt)
privateslot

Definition at line 120 of file qsedataexport.cpp.

References FileHeaderInEach, and m_Options.

Referenced by setupConnections().

121 {
122  if (opt) {
124  } else {
126  }
127 }
void QseDataExport::homeDirectory ( )
privateslot

Definition at line 189 of file qsedataexport.cpp.

References m_OutputDir, and updateNewDirectory().

Referenced by setupConnections().

190 {
191  m_OutputDir.cd(QDir::currentPath());
192 
194 }
void updateNewDirectory()
void QseDataExport::newDirectory ( )
privateslot

Definition at line 171 of file qsedataexport.cpp.

References m_OutputDir, and updateNewDirectory().

Referenced by setupConnections().

172 {
173  QString newdir = QFileDialog::getExistingDirectory(this);
174 
175  if (newdir.length()) {
176  m_OutputDir.cd(newdir);
177  }
178 
180 }
void updateNewDirectory()
void QseDataExport::newOutputPattern ( const QString &  patt)
privateslot

Definition at line 88 of file qsedataexport.cpp.

References m_OutputPattern.

Referenced by setupConnections().

89 {
90  m_OutputPattern = patt;
91 }
QString m_OutputPattern
Definition: qsedataexport.h:82
void QseDataExport::previewPressed ( )
privateslot

Definition at line 343 of file qsedataexport.cpp.

References dataChanged(), m_Preview, m_PreviewUI, and updatePreview().

Referenced by setupConnections().

344 {
345  updatePreview();
346 
347  if (m_PreviewUI == NULL) {
349  }
350 
351  m_PreviewUI -> show();
352 
353  emit dataChanged();
354 }
QseDataExportPreview * m_Preview
Definition: qsedataexport.h:85
void dataChanged()
QseDataExportPreviewUI * m_PreviewUI
Definition: qsedataexport.h:86
QseDataExport::Q_DECLARE_FLAGS ( Options  ,
Option   
)
void QseDataExport::readSettings ( )
private

Definition at line 520 of file qsedataexport.cpp.

References m_Identifier, m_Options, m_OutputDir, and m_OutputPattern.

Referenced by QseDataExport().

521 {
522  QseSettings settings;
523 
524  m_Options = settings.value(QString("%1/options").arg(m_Identifier),0).toInt();
525  m_OutputDir.cd(settings.value(QString("%1/outputdir").arg(m_Identifier),QDir::currentPath()).toString());
526  m_OutputPattern = settings.value(QString("%1/outputpattern").arg(m_Identifier),"%f_%d_%n").toString();
527 }
QString m_OutputPattern
Definition: qsedataexport.h:82
QString m_Identifier
Definition: qsedataexport.h:77
void QseDataExport::saveHeaderOptionChanged ( bool  opt)
privateslot

Definition at line 93 of file qsedataexport.cpp.

References m_Options, and SaveHeader.

Referenced by setupConnections().

94 {
95  if (opt) {
97  } else {
99  }
100 }
void QseDataExport::scanRevert ( )
privateslot

Definition at line 224 of file qsedataexport.cpp.

References m_Selections, and ui.

Referenced by QseDataExport(), and setupConnections().

225 {
226  int i;
227  ui.m_ScanList->clearSelection();
228 
229  foreach(i, m_Selections) {
230  QModelIndex sel = ui.m_ScanList->model()->index(i,0);
231 
232  ui.m_ScanList->selectionModel()->select(sel, QItemSelectionModel::Select);
233  }
234 }
QList< int > m_Selections
Definition: qsedataexport.h:78
Ui::QseDataExport ui
Definition: qsedataexport.h:76
void QseDataExport::scanSelectAll ( )
privateslot

Definition at line 214 of file qsedataexport.cpp.

References ui.

Referenced by setupConnections().

215 {
216  ui.m_ScanList->selectAll();
217 }
Ui::QseDataExport ui
Definition: qsedataexport.h:76
void QseDataExport::scanSelectNone ( )
privateslot

Definition at line 219 of file qsedataexport.cpp.

References ui.

Referenced by setupConnections().

220 {
221  ui.m_ScanList->clearSelection();
222 }
Ui::QseDataExport ui
Definition: qsedataexport.h:76
QList< int > QseDataExport::selectedScans ( ) const
private

Definition at line 236 of file qsedataexport.cpp.

References ui.

Referenced by updatePreview().

237 {
238  QList<int> res;
239  QList<QListWidgetItem*> selected = ui.m_ScanList->selectedItems();
240  QListWidgetItem* w;
241 
242  foreach(w, selected) {
243  res.append(ui.m_ScanList->row(w));
244  }
245 
246  return res;
247 }
Ui::QseDataExport ui
Definition: qsedataexport.h:76
void QseDataExport::setupConnections ( )
private

Definition at line 58 of file qsedataexport.cpp.

References autoRenameOptionChanged(), briefHeaderOptionChanged(), cancelPressed(), columnHeaderLineOptionChanged(), dataChanged(), directoryChanged(), exportPressed(), fileHeaderInEachOptionChanged(), homeDirectory(), m_Preview, newDirectory(), newOutputPattern(), previewPressed(), saveHeaderOptionChanged(), scanRevert(), scanSelectAll(), scanSelectNone(), singleFileOptionChanged(), ui, and upDirectory().

Referenced by QseDataExport().

59 {
60  connect(ui.m_DirectoryCombo, SIGNAL(currentIndexChanged(const QString&)),
61  this, SLOT(directoryChanged(const QString&)));
62 
63  connect(ui.m_DirectoryNewButton, SIGNAL(clicked()), this, SLOT(newDirectory()));
64  connect(ui.m_DirectoryUpButton, SIGNAL(clicked()), this, SLOT(upDirectory()));
65  connect(ui.m_DirectoryHomeButton, SIGNAL(clicked()), this, SLOT(homeDirectory()));
66  connect(ui.m_DirectoryView, SIGNAL(doubleClicked(const QModelIndex&)),
67  this, SLOT(directoryChanged(const QModelIndex&)));
68 
69  connect(ui.m_ScanSelectAllButton, SIGNAL(clicked()), this, SLOT(scanSelectAll()));
70  connect(ui.m_ScanSelectNoneButton, SIGNAL(clicked()), this, SLOT(scanSelectNone()));
71  connect(ui.m_ScanRevertButton, SIGNAL(clicked()), this, SLOT(scanRevert()));
72 
73  connect(ui.m_OutputPatternEdit, SIGNAL(textChanged(const QString&)), this, SLOT(newOutputPattern(const QString&)));
74  connect(ui.m_SaveHeaderOption, SIGNAL(clicked(bool)), this, SLOT(saveHeaderOptionChanged(bool)));
75  connect(ui.m_BriefHeaderOption, SIGNAL(clicked(bool)), this, SLOT(briefHeaderOptionChanged(bool)));
76  connect(ui.m_SingleFileOption, SIGNAL(clicked(bool)), this, SLOT(singleFileOptionChanged(bool)));
77  connect(ui.m_FileHeaderInEachOption, SIGNAL(clicked(bool)), this, SLOT(fileHeaderInEachOptionChanged(bool)));
78  connect(ui.m_ColumnHeaderLineOption, SIGNAL(clicked(bool)), this, SLOT(columnHeaderLineOptionChanged(bool)));
79  connect(ui.m_AutoRenameOption, SIGNAL(clicked(bool)), this, SLOT(autoRenameOptionChanged(bool)));
80 
81  connect(ui.m_CancelButton, SIGNAL(clicked()), this, SLOT(cancelPressed()));
82  connect(ui.m_ExportButton, SIGNAL(clicked()), this, SLOT(exportPressed()));
83  connect(ui.m_PreviewButton, SIGNAL(clicked()), this, SLOT(previewPressed()));
84 
85  connect(this, SIGNAL(dataChanged()), m_Preview, SLOT(onDataChanged()));
86 }
void newOutputPattern(const QString &patt)
void saveHeaderOptionChanged(bool opt)
QseDataExportPreview * m_Preview
Definition: qsedataexport.h:85
void autoRenameOptionChanged(bool opt)
Ui::QseDataExport ui
Definition: qsedataexport.h:76
void singleFileOptionChanged(bool opt)
void briefHeaderOptionChanged(bool opt)
void dataChanged()
void directoryChanged(const QModelIndex &index)
void columnHeaderLineOptionChanged(bool opt)
void fileHeaderInEachOptionChanged(bool opt)
void QseDataExport::singleFileOptionChanged ( bool  opt)
privateslot

Definition at line 111 of file qsedataexport.cpp.

References m_Options, and SingleFile.

Referenced by setupConnections().

112 {
113  if (opt) {
115  } else {
116  m_Options &= ~SingleFile;
117  }
118 }
QString QseDataExport::substituteFilenamePatterns ( const QString &  patt,
int  index,
const QseDataSet ds 
)
private

Definition at line 501 of file qsedataexport.cpp.

References QseDataSet::fileName(), and QseDataSet::scan().

Referenced by updatePreview().

502 {
503  QseScan *scan = ds->scan(index);
504  QString fnam = ds->fileName();
505  int scannum = scan -> scanNumber();
506  QDateTime dt = scan -> scanDateTime();
507 
508  QString res = patt;
509 
510  res.replace("%i", QString("%1").arg(index+1));
511  res.replace("%n", QString("%1").arg(scannum));
512  res.replace("%f", QFileInfo(fnam).completeBaseName());
513  res.replace("%x", QFileInfo(fnam).suffix());
514  res.replace("%d", dt.toString("yyyyMMdd_hhmmss"));
515  res.replace("%t", dt.toString("yyyyMMdd"));
516 
517  return res;
518 }
QseScan * scan(int n) const
Definition: qsedataset.cpp:70
QString fileName() const
Definition: qsedataset.cpp:186
void QseDataExport::updateNewDirectory ( )
private

Definition at line 154 of file qsedataexport.cpp.

References m_DirModel, m_OutputDir, and ui.

Referenced by directoryChanged(), homeDirectory(), newDirectory(), QseDataExport(), and upDirectory().

155 {
156  ui.m_DirectoryView->setRootIndex(m_DirModel.index(m_OutputDir.path()));
157 
158  ui.m_DirectoryCombo->blockSignals(true);
159 
160  ui.m_DirectoryCombo->clear();
161 
162  QDir qd = m_OutputDir;
163 
164  do {
165  if (qd.exists()) ui.m_DirectoryCombo->addItem(qd.absolutePath());
166  } while(qd.cdUp());
167 
168  ui.m_DirectoryCombo->blockSignals(false);
169 }
Ui::QseDataExport ui
Definition: qsedataexport.h:76
QDirModel m_DirModel
Definition: qsedataexport.h:83
void QseDataExport::updatePreview ( )
private

Definition at line 387 of file qsedataexport.cpp.

References AutoRename, autoRenameFiles(), BriefHeader, QseScan::column(), ColumnHeaderLine, QseColumn::data(), FileHeaderInEach, QseDataSet::header(), QseScan::header(), m_DataSet, m_Options, m_Preview, QseColumn::name(), SaveHeader, QseScan::scanColumnCountLine(), QseScan::scanColumnNamesLine(), QseScan::scanCommand(), QseScan::scanDateLine(), selectedScans(), SingleFile, substituteFilenamePatterns(), ui, and writeSettings().

Referenced by exportPressed(), and previewPressed().

388 {
389  printf("Export Options = %d\n", m_Options);
390 
391  QString patt = ui.m_OutputPatternEdit -> text();
392  int i;
393  QList<int> selected = selectedScans();
394  QString fnam = "";
395  int f;
396 
397  m_Preview -> clear();
398 
399  foreach(i, selected) {
400  QseScan *scan = m_DataSet -> scan(i);
401  int nrows = scan -> maxRowCount();
402  int ncols = scan -> columnCount();
403 
404  if (fnam == "") {
405  if (m_Options & SingleFile) {
406  fnam = substituteFilenamePatterns(patt, 0, m_DataSet);
407  } else {
408  fnam = substituteFilenamePatterns(patt, i, m_DataSet);
409  }
410 
411 // if (QFile::exists(m_OutputDir.filePath(fnam))) {
412 // if (m_Options & AutoRename) {
413 // int n=1;
414 
415 // while (QFile::exists(m_OutputDir.filePath(fnam+QString("_%1").arg(n,5,10,QLatin1Char('0'))))) {
416 // n += 1;
417 // }
418 
419 // fnam = fnam+QString("_%1").arg(n,5,10,QLatin1Char('0'));
420 // } else {
421 // printf("Duplicate file name %s\n", qPrintable(fnam));
422 // }
423 // }
424 
425 // printf("Scan %d : %s\n", i, qPrintable(fnam));
426 
427  f = m_Preview -> appendNewFile(fnam);
428  }
429 
430  if (f >= 0) {
431  if (m_Options & FileHeaderInEach) {
432  QString s;
433  QStringList hdr = m_DataSet->header();
434 
435  foreach(s,hdr) {
436  m_Preview -> appendLine(f, s);
437  }
438  }
439 
440  if (m_Options & SaveHeader) {
441  QString s;
442  m_Preview -> appendLine(f, scan->scanCommand());
443  m_Preview -> appendLine(f, scan->scanDateLine());
444 
445  QStringList hdr = scan->header();
446 
447  foreach(s,hdr) {
448  m_Preview -> appendLine(f, s);
449  }
450 
451  m_Preview -> appendLine(f, scan->scanColumnCountLine());
452  m_Preview -> appendLine(f, scan->scanColumnNamesLine());
453  } else if (m_Options & BriefHeader) {
454  m_Preview -> appendLine(f, scan->scanCommand());
455  m_Preview -> appendLine(f, scan->scanDateLine());
456  m_Preview -> appendLine(f, scan->scanColumnCountLine());
457  m_Preview -> appendLine(f, scan->scanColumnNamesLine());
458  }
459 
460  if (m_Options & ColumnHeaderLine) {
461  QString colnames;
462  for (int i=0; i<ncols; i++) {
463  QseColumn *col = scan->column(i);
464  if (i == 0) {
465  colnames = col->name();
466  } else{
467  colnames += "\t";
468  colnames += col->name();
469  }
470  }
471 
472  m_Preview -> appendLine(f, colnames);
473  }
474 
475  for (int r=0; r<nrows; r++) {
476  QString dataline;
477  for (int c=0; c<ncols; c++) {
478  if (c == 0) {
479  dataline = tr("%1").arg(scan->column(c)->data(r));
480  } else {
481  dataline += "\t";
482  dataline += tr("%1").arg(scan->column(c)->data(r));
483  }
484  }
485  m_Preview -> appendLine(f, dataline);
486  }
487 
488  if (!(m_Options & SingleFile)) {
489  fnam = "";
490  }
491  }
492  }
493 
494  if (m_Options & AutoRename) {
495  autoRenameFiles();
496  }
497 
498  writeSettings();
499 }
const double * data() const
Definition: qsecolumn.cpp:62
QStringList header() const
Definition: qsescan.cpp:167
QseDataExportPreview * m_Preview
Definition: qsedataexport.h:85
void autoRenameFiles()
Ui::QseDataExport ui
Definition: qsedataexport.h:76
QList< int > selectedScans() const
QseDataSet * m_DataSet
Definition: qsedataexport.h:79
QString scanDateLine() const
Definition: qsescan.cpp:321
QString substituteFilenamePatterns(const QString &patt, int index, const QseDataSet *ds)
QString scanCommand() const
Definition: qsescan.cpp:226
QString scanColumnNamesLine() const
Definition: qsescan.cpp:335
QString name() const
Definition: qsecolumn.cpp:26
QseColumn * column(int n) const
Definition: qsescan.cpp:104
QString scanColumnCountLine() const
Definition: qsescan.cpp:328
QStringList header() const
Definition: qsedataset.cpp:125
void QseDataExport::upDirectory ( )
privateslot

Definition at line 182 of file qsedataexport.cpp.

References m_OutputDir, and updateNewDirectory().

Referenced by setupConnections().

183 {
184  m_OutputDir.cdUp();
185 
187 }
void updateNewDirectory()
void QseDataExport::writePreview ( )
private

Definition at line 371 of file qsedataexport.cpp.

References m_OutputDir, and m_Preview.

Referenced by exportPressed().

372 {
373  int nfiles = m_Preview -> countFiles();
374 
375  for (int i=0; i<nfiles; i++) {
376  QString fnam = m_Preview -> getFile(i);
377  QString path = m_OutputDir.absoluteFilePath(fnam);
378 
379  FILE* f = fopen(qPrintable(path), "w");
380 
381  fputs(qPrintable(m_Preview -> getLines(i)), f);
382 
383  fclose(f);
384  }
385 }
QseDataExportPreview * m_Preview
Definition: qsedataexport.h:85
void QseDataExport::writeSettings ( )
private

Definition at line 529 of file qsedataexport.cpp.

References m_Identifier, m_Options, m_OutputDir, and m_OutputPattern.

Referenced by updatePreview().

530 {
531  QseSettings settings;
532 
533  settings.setValue(QString("%1/options").arg(m_Identifier), int(m_Options));
534  settings.setValue(QString("%1/outputdir").arg(m_Identifier), m_OutputDir.absolutePath());
535  settings.setValue(QString("%1/outputpattern").arg(m_Identifier), m_OutputPattern);
536 }
QString m_OutputPattern
Definition: qsedataexport.h:82
QString m_Identifier
Definition: qsedataexport.h:77

Member Data Documentation

QseDataSet* QseDataExport::m_DataSet
private

Definition at line 79 of file qsedataexport.h.

Referenced by updatePreview().

QDirModel QseDataExport::m_DirModel
private

Definition at line 83 of file qsedataexport.h.

Referenced by directoryChanged(), QseDataExport(), and updateNewDirectory().

QString QseDataExport::m_Identifier
private

Definition at line 77 of file qsedataexport.h.

Referenced by readSettings(), and writeSettings().

int QseDataExport::m_Options
private
QDir QseDataExport::m_OutputDir
private
QString QseDataExport::m_OutputPattern
private

Definition at line 82 of file qsedataexport.h.

Referenced by newOutputPattern(), QseDataExport(), readSettings(), and writeSettings().

QseDataExportPreview* QseDataExport::m_Preview
private
QPushButton* QseDataExport::m_PreviewButton
private

Definition at line 84 of file qsedataexport.h.

QseDataExportPreviewUI* QseDataExport::m_PreviewUI
private

Definition at line 86 of file qsedataexport.h.

Referenced by previewPressed().

QList<int> QseDataExport::m_Selections
private

Definition at line 78 of file qsedataexport.h.

Referenced by scanRevert().

Ui::QseDataExport QseDataExport::ui
private

The documentation for this class was generated from the following files: