Mercurial > hg > svgui
comparison widgets/CSVFormatDialog.cpp @ 763:cdafb1a438e8
Make it possible to import CSV files directly into Note layers
author | Chris Cannam |
---|---|
date | Mon, 07 Apr 2014 10:47:15 +0100 |
parents | 1a0dfcbffaf1 |
children | e4773943c9c1 |
comparison
equal
deleted
inserted
replaced
742:d7e8cefedbbc | 763:cdafb1a438e8 |
---|---|
92 cpc->addItem(tr("<ignore>")); // ColumnUnknown | 92 cpc->addItem(tr("<ignore>")); // ColumnUnknown |
93 cpc->addItem(tr("Time")); // ColumnStartTime | 93 cpc->addItem(tr("Time")); // ColumnStartTime |
94 cpc->addItem(tr("End time")); // ColumnEndTime | 94 cpc->addItem(tr("End time")); // ColumnEndTime |
95 cpc->addItem(tr("Duration")); // ColumnDuration | 95 cpc->addItem(tr("Duration")); // ColumnDuration |
96 cpc->addItem(tr("Value")); // ColumnValue | 96 cpc->addItem(tr("Value")); // ColumnValue |
97 cpc->addItem(tr("Pitch")); // ColumnPitch | |
97 cpc->addItem(tr("Label")); // ColumnLabel | 98 cpc->addItem(tr("Label")); // ColumnLabel |
98 cpc->setCurrentIndex(int(m_format.getColumnPurpose(i))); | 99 cpc->setCurrentIndex(int(m_format.getColumnPurpose(i))); |
99 | 100 |
100 for (int j = 0; j < example.size() && j < 6; ++j) { | 101 for (int j = 0; j < example.size() && j < 6; ++j) { |
101 QLabel *label = new QLabel; | 102 QLabel *label = new QLabel; |
210 s = f->getLayerPresentationName(LayerFactory::TimeValues); | 211 s = f->getLayerPresentationName(LayerFactory::TimeValues); |
211 break; | 212 break; |
212 case CSVFormat::TwoDimensionalModelWithDuration: | 213 case CSVFormat::TwoDimensionalModelWithDuration: |
213 s = f->getLayerPresentationName(LayerFactory::Regions); | 214 s = f->getLayerPresentationName(LayerFactory::Regions); |
214 break; | 215 break; |
216 case CSVFormat::TwoDimensionalModelWithDurationAndPitch: | |
217 s = f->getLayerPresentationName(LayerFactory::Notes); | |
218 break; | |
215 case CSVFormat::ThreeDimensionalModel: | 219 case CSVFormat::ThreeDimensionalModel: |
216 s = f->getLayerPresentationName(LayerFactory::Colour3DPlot); | 220 s = f->getLayerPresentationName(LayerFactory::Colour3DPlot); |
217 break; | 221 break; |
218 } | 222 } |
219 | 223 |
280 | 284 |
281 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose)p; | 285 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose)p; |
282 | 286 |
283 bool haveStartTime = false; | 287 bool haveStartTime = false; |
284 bool haveDuration = false; | 288 bool haveDuration = false; |
289 bool havePitch = false; | |
285 int valueCount = 0; | 290 int valueCount = 0; |
286 | 291 |
287 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) { | 292 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) { |
288 | 293 |
289 CSVFormat::ColumnPurpose cp = m_format.getColumnPurpose(i); | 294 CSVFormat::ColumnPurpose cp = m_format.getColumnPurpose(i); |
341 } | 346 } |
342 if (cp == CSVFormat::ColumnEndTime || | 347 if (cp == CSVFormat::ColumnEndTime || |
343 cp == CSVFormat::ColumnDuration) { | 348 cp == CSVFormat::ColumnDuration) { |
344 haveDuration = true; | 349 haveDuration = true; |
345 } | 350 } |
351 if (cp == CSVFormat::ColumnPitch) { | |
352 havePitch = true; | |
353 } | |
346 if (cp == CSVFormat::ColumnValue) { | 354 if (cp == CSVFormat::ColumnValue) { |
347 ++valueCount; | 355 ++valueCount; |
348 } | 356 } |
349 | 357 |
350 m_columnPurposeCombos[i]->setCurrentIndex(int(cp)); | 358 m_columnPurposeCombos[i]->setCurrentIndex(int(cp)); |
355 m_timingTypeCombo->setCurrentIndex(2); | 363 m_timingTypeCombo->setCurrentIndex(2); |
356 timingTypeChanged(2); | 364 timingTypeChanged(2); |
357 } | 365 } |
358 | 366 |
359 if (haveStartTime && haveDuration) { | 367 if (haveStartTime && haveDuration) { |
360 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDuration); | 368 if (havePitch) { |
369 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDurationAndPitch); | |
370 } else { | |
371 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDuration); | |
372 } | |
361 } else { | 373 } else { |
362 if (valueCount > 1) { | 374 if (valueCount > 1) { |
363 m_format.setModelType(CSVFormat::ThreeDimensionalModel); | 375 m_format.setModelType(CSVFormat::ThreeDimensionalModel); |
364 } else if (valueCount > 0) { | 376 } else if (valueCount > 0) { |
365 m_format.setModelType(CSVFormat::TwoDimensionalModel); | 377 m_format.setModelType(CSVFormat::TwoDimensionalModel); |