15 m_Selections(selections),
29 for (i = 0; i<nscans; i++) {
30 QString scanname = data->
scan(i)->
name();
32 ui.m_ScanList->addItem(scanname);
38 ui.m_DirectoryView->hideColumn(1);
39 ui.m_DirectoryView->hideColumn(2);
40 ui.m_DirectoryView->hideColumn(3);
53 setWindowTitle(QString(
"Export Data from %1").arg(data->
fileName()));
60 connect(
ui.m_DirectoryCombo, SIGNAL(currentIndexChanged(
const QString&)),
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&)),
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()));
73 connect(
ui.m_OutputPatternEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
newOutputPattern(
const QString&)));
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()));
158 ui.m_DirectoryCombo->blockSignals(
true);
160 ui.m_DirectoryCombo->clear();
165 if (qd.exists())
ui.m_DirectoryCombo->addItem(qd.absolutePath());
168 ui.m_DirectoryCombo->blockSignals(
false);
173 QString newdir = QFileDialog::getExistingDirectory(
this);
175 if (newdir.length()) {
216 ui.m_ScanList->selectAll();
221 ui.m_ScanList->clearSelection();
227 ui.m_ScanList->clearSelection();
230 QModelIndex sel =
ui.m_ScanList->model()->index(i,0);
232 ui.m_ScanList->selectionModel()->select(sel, QItemSelectionModel::Select);
239 QList<QListWidgetItem*> selected =
ui.m_ScanList->selectedItems();
242 foreach(w, selected) {
243 res.append(
ui.m_ScanList->row(w));
252 QList<QString> files;
256 for(
int i=0; i<nscans; i++) {
260 files.contains(fnam)) {
262 for (
int n=1; ; n++) {
263 QString fnam2 = fnam+QString(
"_%1").arg(n,5,10,QLatin1Char(
'0'));
265 if ((!QFile::exists(
m_OutputDir.filePath(fnam2))) &&
266 (!files.contains(fnam2))) {
279 QList<QString> files;
283 for(
int i=0; i<nscans; i++) {
290 if (files.contains(fnam)) {
301 msg.append(QString(
"%1 files will be overwritten by this operation").arg(nd));
302 for (i = 0; i < qMin(5, nd); i++) {
313 msg.append(QString(
"%1 of the output file names are duplicated").arg(nd));
317 msg.append(
"\nHow do you want to proceed?");
319 QPushButton *goAheadButton = msgBox.addButton(
"Overwrite", QMessageBox::ActionRole);
320 QPushButton *renameButton = msgBox.addButton(
"Rename", QMessageBox::ActionRole);
321 QPushButton *cancelButton = msgBox.addButton(
"Cancel", QMessageBox::ActionRole);
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);
330 if (msgBox.clickedButton() == goAheadButton) {
332 }
else if (msgBox.clickedButton() == renameButton) {
375 for (
int i=0; i<nfiles; i++) {
379 FILE* f = fopen(qPrintable(path),
"w");
381 fputs(qPrintable(
m_Preview -> getLines(i)), f);
389 printf(
"Export Options = %d\n",
m_Options);
391 QString patt =
ui.m_OutputPatternEdit -> text();
399 foreach(i, selected) {
401 int nrows = scan -> maxRowCount();
402 int ncols = scan -> columnCount();
445 QStringList hdr = scan->
header();
462 for (
int i=0; i<ncols; i++) {
465 colnames = col->
name();
468 colnames += col->
name();
475 for (
int r=0; r<nrows; r++) {
477 for (
int c=0; c<ncols; c++) {
479 dataline = tr(
"%1").arg(scan->
column(c)->
data(r));
482 dataline += tr(
"%1").arg(scan->
column(c)->
data(r));
505 int scannum = scan -> scanNumber();
506 QDateTime dt = scan -> scanDateTime();
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"));
QseScan * scan(int n) const
void newOutputPattern(const QString &patt)
void saveHeaderOptionChanged(bool opt)
const double * data() const
QStringList header() const
QseDataExportPreview * m_Preview
void updateNewDirectory()
QseDataExport(const QString &id, QseDataSet *data, QList< int > selections, QWidget *parent=0)
void autoRenameOptionChanged(bool opt)
QList< int > m_Selections
QList< int > selectedScans() const
void singleFileOptionChanged(bool opt)
void briefHeaderOptionChanged(bool opt)
QString scanDateLine() const
QString substituteFilenamePatterns(const QString &patt, int index, const QseDataSet *ds)
QString scanCommand() const
QString scanColumnNamesLine() const
bool checkForOverwriting()
static void exportSelectedData(const QString &id, QseDataSet *data, QList< int > selections)
void directoryChanged(const QModelIndex &index)
void columnHeaderLineOptionChanged(bool opt)
QseColumn * column(int n) const
QseDataExportPreviewUI * m_PreviewUI
void fileHeaderInEachOptionChanged(bool opt)
QString scanColumnCountLine() const
QStringList header() const