Mercurial > hg > svcore
diff data/fileio/CSVFileWriter.cpp @ 841:226733f3cf3f tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Fri, 22 Nov 2013 10:37:28 +0000 |
parents | 38bb7c8e415d |
children | 59e7fe1b1003 |
line wrap: on
line diff
--- a/data/fileio/CSVFileWriter.cpp Wed Jul 17 16:01:28 2013 +0100 +++ b/data/fileio/CSVFileWriter.cpp Fri Nov 22 10:37:28 2013 +0000 @@ -23,6 +23,7 @@ #include "base/TempWriteFile.h" #include "base/Exceptions.h" +#include "base/Selection.h" #include <QFile> #include <QTextStream> @@ -75,4 +76,36 @@ } } +void +CSVFileWriter::writeSelection(MultiSelection *selection) +{ + try { + TempWriteFile temp(m_path); + QFile file(temp.getTemporaryFilename()); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + m_error = tr("Failed to open file %1 for writing") + .arg(temp.getTemporaryFilename()); + return; + } + + QTextStream out(&file); + + for (MultiSelection::SelectionList::iterator i = + selection->getSelections().begin(); + i != selection->getSelections().end(); ++i) { + + size_t f0(i->getStartFrame()), f1(i->getEndFrame()); + out << m_model->toDelimitedDataString(m_delimiter, f0, f1); + } + + file.close(); + temp.moveToTarget(); + + } catch (FileOperationFailed &f) { + m_error = f.what(); + } +} + + +