changeset 1030:920699b6989d

Use filename as object name when reading data file to model (so it shows in the resulting layer name)
author Chris Cannam
date Fri, 13 Feb 2015 13:30:28 +0000
parents 1ecd533a9977
children 344c9ea90181 3a48b22fed48
files data/fileio/CSVFileReader.cpp data/fileio/CSVFileReader.h data/fileio/MIDIFileReader.cpp
diffstat 3 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/CSVFileReader.cpp	Fri Feb 13 13:29:44 2015 +0000
+++ b/data/fileio/CSVFileReader.cpp	Fri Feb 13 13:30:28 2015 +0000
@@ -26,6 +26,7 @@
 #include "DataFileReaderFactory.h"
 
 #include <QFile>
+#include <QFileInfo>
 #include <QString>
 #include <QRegExp>
 #include <QStringList>
@@ -55,6 +56,7 @@
 
     if (good) {
         m_device = file;
+        m_filename = QFileInfo(path).fileName();
     } else {
 	delete file;
     }
@@ -263,6 +265,12 @@
                     model = model3;
                     break;
                 }
+
+                if (model) {
+                    if (m_filename != "") {
+                        model->setObjectName(m_filename);
+                    }
+                }
             }
 
             float value = 0.f;
--- a/data/fileio/CSVFileReader.h	Fri Feb 13 13:29:44 2015 +0000
+++ b/data/fileio/CSVFileReader.h	Fri Feb 13 13:30:28 2015 +0000
@@ -53,6 +53,7 @@
     CSVFormat m_format;
     QIODevice *m_device;
     bool m_ownDevice;
+    QString m_filename;
     QString m_error;
     mutable int m_warnings;
     int m_mainModelSampleRate;
--- a/data/fileio/MIDIFileReader.cpp	Fri Feb 13 13:29:44 2015 +0000
+++ b/data/fileio/MIDIFileReader.cpp	Fri Feb 13 13:30:28 2015 +0000
@@ -36,6 +36,7 @@
 #include "model/NoteModel.h"
 
 #include <QString>
+#include <QFileInfo>
 
 #include <sstream>
 
@@ -932,6 +933,7 @@
     if (!model) {
 	model = new NoteModel(m_mainModelSampleRate, 1, 0.0, 0.0, false);
 	model->setValueQuantization(1.0);
+        model->setObjectName(QFileInfo(m_path).fileName());
     }
 
     const MIDITrack &track = m_midiComposition.find(trackToLoad)->second;