Mercurial > hg > svcore
annotate data/fileio/CSVFileWriter.cpp @ 297:c022976d18e8
* Merge from sv-match-alignment branch (excluding alignment-specific document).
- add aggregate wave model (not yet complete enough to be added as a true
model in a layer, but there's potential)
- add play solo mode
- add alignment model -- unused in plain SV
- fix two plugin leaks
- add m3u playlist support (opens all files at once, potentially hazardous)
- fix retrieval of pre-encoded URLs
- add ability to resample audio files on import, so as to match rates with
other files previously loaded; add preference for same
- add preliminary support in transform code for range and rate of transform
input
- reorganise preferences dialog, move dark-background option to preferences,
add option for temporary directory location
author | Chris Cannam |
---|---|
date | Fri, 28 Sep 2007 13:56:38 +0000 |
parents | 4b2ea82fd0ed |
children | 341e4e1a6ed3 |
rev | line source |
---|---|
Chris@148 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
Chris@148 | 2 |
Chris@148 | 3 /* |
Chris@148 | 4 Sonic Visualiser |
Chris@148 | 5 An audio file viewer and annotation editor. |
Chris@148 | 6 Centre for Digital Music, Queen Mary, University of London. |
Chris@148 | 7 This file copyright 2006 Chris Cannam. |
Chris@148 | 8 |
Chris@148 | 9 This program is free software; you can redistribute it and/or |
Chris@148 | 10 modify it under the terms of the GNU General Public License as |
Chris@148 | 11 published by the Free Software Foundation; either version 2 of the |
Chris@148 | 12 License, or (at your option) any later version. See the file |
Chris@148 | 13 COPYING included with this distribution for more information. |
Chris@148 | 14 */ |
Chris@148 | 15 |
Chris@148 | 16 #include "CSVFileWriter.h" |
Chris@148 | 17 |
Chris@150 | 18 #include "model/Model.h" |
Chris@148 | 19 #include "model/SparseOneDimensionalModel.h" |
Chris@148 | 20 #include "model/SparseTimeValueModel.h" |
Chris@148 | 21 #include "model/NoteModel.h" |
Chris@148 | 22 #include "model/TextModel.h" |
Chris@148 | 23 |
Chris@148 | 24 #include <QFile> |
Chris@148 | 25 #include <QTextStream> |
Chris@148 | 26 |
Chris@148 | 27 CSVFileWriter::CSVFileWriter(QString path, Model *model, QString delimiter) : |
Chris@148 | 28 m_path(path), |
Chris@148 | 29 m_model(model), |
Chris@148 | 30 m_error(""), |
Chris@148 | 31 m_delimiter(delimiter) |
Chris@148 | 32 { |
Chris@148 | 33 } |
Chris@148 | 34 |
Chris@148 | 35 CSVFileWriter::~CSVFileWriter() |
Chris@148 | 36 { |
Chris@148 | 37 } |
Chris@148 | 38 |
Chris@148 | 39 bool |
Chris@148 | 40 CSVFileWriter::isOK() const |
Chris@148 | 41 { |
Chris@148 | 42 return m_error == ""; |
Chris@148 | 43 } |
Chris@148 | 44 |
Chris@148 | 45 QString |
Chris@148 | 46 CSVFileWriter::getError() const |
Chris@148 | 47 { |
Chris@148 | 48 return m_error; |
Chris@148 | 49 } |
Chris@148 | 50 |
Chris@148 | 51 void |
Chris@148 | 52 CSVFileWriter::write() |
Chris@148 | 53 { |
Chris@148 | 54 QFile file(m_path); |
Chris@148 | 55 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { |
Chris@148 | 56 m_error = tr("Failed to open file %1 for writing").arg(m_path); |
Chris@148 | 57 return; |
Chris@148 | 58 } |
Chris@148 | 59 |
Chris@148 | 60 QTextStream out(&file); |
Chris@148 | 61 out << m_model->toDelimitedDataString(m_delimiter); |
Chris@148 | 62 |
Chris@148 | 63 file.close(); |
Chris@148 | 64 } |
Chris@148 | 65 |
Chris@148 | 66 |