annotate widgets/CSVFormatDialog.cpp @ 1312:fcc1f45f7bd5 import-audio-data

Handle additional case
author Chris Cannam
date Thu, 28 Jun 2018 14:49:00 +0100
parents a34a2a25907c
children b149b53df365
rev   line source
Chris@378 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@378 2
Chris@378 3 /*
Chris@378 4 Sonic Visualiser
Chris@378 5 An audio file viewer and annotation editor.
Chris@378 6 Centre for Digital Music, Queen Mary, University of London.
Chris@378 7 This file copyright 2006 Chris Cannam.
Chris@378 8
Chris@378 9 This program is free software; you can redistribute it and/or
Chris@378 10 modify it under the terms of the GNU General Public License as
Chris@378 11 published by the Free Software Foundation; either version 2 of the
Chris@378 12 License, or (at your option) any later version. See the file
Chris@378 13 COPYING included with this distribution for more information.
Chris@378 14 */
Chris@378 15
Chris@378 16 #include "CSVFormatDialog.h"
Chris@378 17
Chris@561 18 #include "layer/LayerFactory.h"
Chris@561 19
Chris@674 20 #include "TextAbbrev.h"
Chris@674 21
Chris@378 22 #include <QFrame>
Chris@378 23 #include <QGridLayout>
Chris@378 24 #include <QPushButton>
Chris@378 25 #include <QHBoxLayout>
Chris@378 26 #include <QVBoxLayout>
Chris@378 27 #include <QTableWidget>
Chris@378 28 #include <QComboBox>
Chris@378 29 #include <QLabel>
Chris@512 30 #include <QDialogButtonBox>
Chris@378 31
Chris@560 32 #include <iostream>
Chris@913 33 #include <cmath>
Chris@378 34
Chris@682 35 #include "base/Debug.h"
Chris@682 36
Chris@581 37 CSVFormatDialog::CSVFormatDialog(QWidget *parent, CSVFormat format,
Chris@581 38 int maxDisplayCols) :
Chris@378 39 QDialog(parent),
Chris@581 40 m_format(format),
Chris@581 41 m_maxDisplayCols(maxDisplayCols),
Chris@581 42 m_fuzzyColumn(-1)
Chris@378 43 {
Chris@378 44 setModal(true);
Chris@378 45 setWindowTitle(tr("Select Data Format"));
Chris@378 46
Chris@378 47 QGridLayout *layout = new QGridLayout;
Chris@378 48
Chris@560 49 int row = 0;
Chris@378 50
Chris@560 51 layout->addWidget(new QLabel(tr("Please select the correct data format for this file.")),
Chris@1266 52 row++, 0, 1, 4);
Chris@560 53
Chris@560 54 QFrame *exampleFrame = new QFrame;
Chris@560 55 exampleFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
Chris@560 56 exampleFrame->setLineWidth(2);
Chris@560 57 QGridLayout *exampleLayout = new QGridLayout;
Chris@561 58 exampleLayout->setSpacing(4);
Chris@560 59 exampleFrame->setLayout(exampleLayout);
Chris@560 60
Chris@560 61 QPalette palette = exampleFrame->palette();
Chris@560 62 palette.setColor(QPalette::Window, palette.color(QPalette::Base));
Chris@560 63 exampleFrame->setPalette(palette);
Chris@560 64
Chris@560 65 QFont fp;
Chris@908 66 fp.setPointSize(int(floor(fp.pointSize() * 0.9)));
Chris@561 67 // fp.setFixedPitch(true);
Chris@561 68 // fp.setStyleHint(QFont::TypeWriter);
Chris@561 69 // fp.setFamily("Monospaced");
Chris@560 70
Chris@560 71 int columns = format.getColumnCount();
Chris@560 72 QList<QStringList> example = m_format.getExample();
Chris@560 73
Chris@560 74 for (int i = 0; i < columns; ++i) {
Chris@581 75
Chris@560 76 QComboBox *cpc = new QComboBox;
Chris@560 77 m_columnPurposeCombos.push_back(cpc);
Chris@560 78 exampleLayout->addWidget(cpc, 0, i);
Chris@581 79 connect(cpc, SIGNAL(activated(int)), this, SLOT(columnPurposeChanged(int)));
Chris@581 80
Chris@581 81 if (i == m_maxDisplayCols && columns > i + 2) {
Chris@581 82 m_fuzzyColumn = i;
Chris@581 83 cpc->addItem(tr("<ignore>"));
Chris@581 84 cpc->addItem(tr("Values"));
Chris@581 85 cpc->setCurrentIndex
Chris@581 86 (m_format.getColumnPurpose(i-1) == CSVFormat::ColumnUnknown ? 0 : 1);
Chris@581 87 exampleLayout->addWidget(new QLabel(tr("(%1 more)").arg(columns - i)),
Chris@581 88 1, i);
Chris@581 89 break;
Chris@581 90 }
Chris@560 91
Chris@560 92 // NB must be in the same order as the CSVFormat::ColumnPurpose enum
Chris@560 93 cpc->addItem(tr("<ignore>")); // ColumnUnknown
Chris@560 94 cpc->addItem(tr("Time")); // ColumnStartTime
Chris@560 95 cpc->addItem(tr("End time")); // ColumnEndTime
Chris@560 96 cpc->addItem(tr("Duration")); // ColumnDuration
Chris@560 97 cpc->addItem(tr("Value")); // ColumnValue
Chris@763 98 cpc->addItem(tr("Pitch")); // ColumnPitch
Chris@560 99 cpc->addItem(tr("Label")); // ColumnLabel
Chris@560 100 cpc->setCurrentIndex(int(m_format.getColumnPurpose(i)));
Chris@560 101
Chris@581 102 for (int j = 0; j < example.size() && j < 6; ++j) {
Chris@866 103 if (i >= example[j].size()) {
Chris@866 104 continue;
Chris@866 105 }
Chris@581 106 QLabel *label = new QLabel;
Chris@581 107 label->setTextFormat(Qt::PlainText);
Chris@674 108 QString text = TextAbbrev::abbreviate(example[j][i], 35);
Chris@674 109 label->setText(text);
Chris@581 110 label->setFont(fp);
Chris@581 111 label->setPalette(palette);
Chris@581 112 label->setIndent(8);
Chris@581 113 exampleLayout->addWidget(label, j+1, i);
Chris@560 114 }
Chris@560 115 }
Chris@560 116
Chris@560 117 layout->addWidget(exampleFrame, row, 0, 1, 4);
Chris@560 118 layout->setColumnStretch(3, 10);
Chris@560 119 layout->setRowStretch(row++, 10);
Chris@560 120
Chris@560 121 layout->addWidget(new QLabel(tr("Timing is specified:")), row, 0);
Chris@378 122
Chris@378 123 m_timingTypeCombo = new QComboBox;
Chris@959 124
Chris@959 125 m_timingLabels = {
Chris@959 126 { TimingExplicitSeconds, tr("Explicitly, in seconds") },
Chris@959 127 { TimingExplicitMsec, tr("Explicitly, in milliseconds") },
Chris@959 128 { TimingExplicitSamples, tr("Explicitly, in audio sample frames") },
Chris@959 129 { TimingImplicit, tr("Implicitly: rows are equally spaced in time") }
Chris@959 130 };
Chris@959 131
Chris@959 132 for (auto &l: m_timingLabels) {
Chris@959 133 m_timingTypeCombo->addItem(l.second);
Chris@959 134 }
Chris@959 135
Chris@560 136 layout->addWidget(m_timingTypeCombo, row++, 1, 1, 2);
Chris@959 137
Chris@378 138 connect(m_timingTypeCombo, SIGNAL(activated(int)),
Chris@1266 139 this, SLOT(timingTypeChanged(int)));
Chris@959 140
Chris@959 141 m_initialTimingOption = TimingImplicit;
Chris@959 142 if (m_format.getTimingType() == CSVFormat::ExplicitTiming) {
Chris@959 143 switch (m_format.getTimeUnits()) {
Chris@959 144 case CSVFormat::TimeSeconds:
Chris@959 145 m_initialTimingOption = TimingExplicitSeconds; break;
Chris@959 146 case CSVFormat::TimeMilliseconds:
Chris@959 147 m_initialTimingOption = TimingExplicitMsec; break;
Chris@959 148 case CSVFormat::TimeAudioFrames:
Chris@959 149 m_initialTimingOption = TimingExplicitSamples; break;
Chris@959 150 case CSVFormat::TimeWindows:
Chris@959 151 m_initialTimingOption = TimingImplicit; break;
Chris@959 152 }
Chris@959 153 }
Chris@959 154 m_timingTypeCombo->setCurrentIndex(int(m_initialTimingOption));
Chris@559 155
Chris@378 156 m_sampleRateLabel = new QLabel(tr("Audio sample rate (Hz):"));
Chris@560 157 layout->addWidget(m_sampleRateLabel, row, 0);
Chris@378 158
Chris@807 159 int sampleRates[] = {
Chris@1266 160 8000, 11025, 12000, 22050, 24000, 32000,
Chris@1266 161 44100, 48000, 88200, 96000, 176400, 192000
Chris@378 162 };
Chris@378 163
Chris@378 164 m_sampleRateCombo = new QComboBox;
Chris@807 165 for (int i = 0; i < int(sizeof(sampleRates) / sizeof(sampleRates[0])); ++i) {
Chris@1266 166 m_sampleRateCombo->addItem(QString("%1").arg(sampleRates[i]));
Chris@1266 167 if (sampleRates[i] == m_format.getSampleRate()) {
Chris@560 168 m_sampleRateCombo->setCurrentIndex(i);
Chris@560 169 }
Chris@378 170 }
Chris@378 171 m_sampleRateCombo->setEditable(true);
Chris@378 172
Chris@560 173 layout->addWidget(m_sampleRateCombo, row++, 1);
Chris@378 174 connect(m_sampleRateCombo, SIGNAL(activated(QString)),
Chris@1266 175 this, SLOT(sampleRateChanged(QString)));
Chris@378 176 connect(m_sampleRateCombo, SIGNAL(editTextChanged(QString)),
Chris@1266 177 this, SLOT(sampleRateChanged(QString)));
Chris@378 178
Chris@378 179 m_windowSizeLabel = new QLabel(tr("Frame increment between rows:"));
Chris@560 180 layout->addWidget(m_windowSizeLabel, row, 0);
Chris@378 181
Chris@378 182 m_windowSizeCombo = new QComboBox;
Chris@378 183 for (int i = 0; i <= 16; ++i) {
Chris@1266 184 int value = 1 << i;
Chris@1266 185 m_windowSizeCombo->addItem(QString("%1").arg(value));
Chris@1266 186 if (value == int(m_format.getWindowSize())) {
Chris@560 187 m_windowSizeCombo->setCurrentIndex(i);
Chris@560 188 }
Chris@378 189 }
Chris@378 190 m_windowSizeCombo->setEditable(true);
Chris@378 191
Chris@560 192 layout->addWidget(m_windowSizeCombo, row++, 1);
Chris@378 193 connect(m_windowSizeCombo, SIGNAL(activated(QString)),
Chris@1266 194 this, SLOT(windowSizeChanged(QString)));
Chris@378 195 connect(m_windowSizeCombo, SIGNAL(editTextChanged(QString)),
Chris@1266 196 this, SLOT(windowSizeChanged(QString)));
Chris@378 197
Chris@561 198 m_modelLabel = new QLabel;
Chris@561 199 QFont f(m_modelLabel->font());
Chris@561 200 f.setItalic(true);
Chris@561 201 m_modelLabel->setFont(f);
Chris@561 202 layout->addWidget(m_modelLabel, row++, 0, 1, 4);
Chris@561 203
Chris@512 204 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
Chris@512 205 QDialogButtonBox::Cancel);
Chris@560 206 layout->addWidget(bb, row++, 0, 1, 4);
Chris@512 207 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
Chris@512 208 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
Chris@378 209
Chris@512 210 setLayout(layout);
Chris@378 211
Chris@378 212 timingTypeChanged(m_timingTypeCombo->currentIndex());
Chris@378 213 }
Chris@378 214
Chris@378 215 CSVFormatDialog::~CSVFormatDialog()
Chris@378 216 {
Chris@378 217 }
Chris@378 218
Chris@378 219 CSVFormat
Chris@378 220 CSVFormatDialog::getFormat() const
Chris@378 221 {
Chris@560 222 return m_format;
Chris@378 223 }
Chris@378 224
Chris@378 225 void
Chris@561 226 CSVFormatDialog::updateModelLabel()
Chris@378 227 {
Chris@561 228 LayerFactory *f = LayerFactory::getInstance();
Chris@561 229
Chris@561 230 QString s;
Chris@561 231 switch (m_format.getModelType()) {
Chris@561 232 case CSVFormat::OneDimensionalModel:
Chris@561 233 s = f->getLayerPresentationName(LayerFactory::TimeInstants);
Chris@561 234 break;
Chris@561 235 case CSVFormat::TwoDimensionalModel:
Chris@561 236 s = f->getLayerPresentationName(LayerFactory::TimeValues);
Chris@561 237 break;
Chris@561 238 case CSVFormat::TwoDimensionalModelWithDuration:
Chris@561 239 s = f->getLayerPresentationName(LayerFactory::Regions);
Chris@561 240 break;
Chris@763 241 case CSVFormat::TwoDimensionalModelWithDurationAndPitch:
Chris@763 242 s = f->getLayerPresentationName(LayerFactory::Notes);
Chris@763 243 break;
Chris@561 244 case CSVFormat::ThreeDimensionalModel:
Chris@561 245 s = f->getLayerPresentationName(LayerFactory::Colour3DPlot);
Chris@561 246 break;
Chris@1312 247 case CSVFormat::WaveFileModel:
Chris@1312 248 s = f->getLayerPresentationName(LayerFactory::Waveform);
Chris@1312 249 break;
Chris@561 250 }
Chris@561 251
Chris@578 252 m_modelLabel->setText("\n" + tr("Data will be displayed in a %1 layer.").arg(s));
Chris@378 253 }
Chris@378 254
Chris@378 255 void
Chris@959 256 CSVFormatDialog::applyStartTimePurpose()
Chris@959 257 {
Chris@971 258 // First check if we already have any. NB there may be fewer than
Chris@971 259 // m_format.getColumnCount() elements in m_columnPurposeCombos
Chris@992 260 // (because of the fuzzy column behaviour). Note also that the
Chris@992 261 // fuzzy column (which is the one just showing how many more
Chris@992 262 // columns there are) has a different combo with only two items
Chris@992 263 // (ignore or Values)
Chris@971 264 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
Chris@992 265 if (i == m_fuzzyColumn) continue;
Chris@959 266 QComboBox *cb = m_columnPurposeCombos[i];
Chris@959 267 if (cb->currentIndex() == int(CSVFormat::ColumnStartTime)) {
Chris@959 268 return;
Chris@959 269 }
Chris@959 270 }
Chris@959 271 // and if not, select one
Chris@971 272 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
Chris@992 273 if (i == m_fuzzyColumn) continue;
Chris@959 274 QComboBox *cb = m_columnPurposeCombos[i];
Chris@959 275 if (cb->currentIndex() == int(CSVFormat::ColumnValue)) {
Chris@959 276 cb->setCurrentIndex(int(CSVFormat::ColumnStartTime));
Chris@959 277 return;
Chris@959 278 }
Chris@959 279 }
Chris@959 280 }
Chris@959 281
Chris@959 282 void
Chris@959 283 CSVFormatDialog::removeStartTimePurpose()
Chris@959 284 {
Chris@971 285 // NB there may be fewer than m_format.getColumnCount() elements
Chris@971 286 // in m_columnPurposeCombos (because of the fuzzy column
Chris@971 287 // behaviour)
Chris@971 288 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
Chris@992 289 if (i == m_fuzzyColumn) continue;
Chris@959 290 QComboBox *cb = m_columnPurposeCombos[i];
Chris@959 291 if (cb->currentIndex() == int(CSVFormat::ColumnStartTime)) {
Chris@959 292 cb->setCurrentIndex(int(CSVFormat::ColumnValue));
Chris@959 293 }
Chris@959 294 }
Chris@959 295 }
Chris@959 296
Chris@959 297 void
Chris@959 298 CSVFormatDialog::updateComboVisibility()
Chris@959 299 {
Chris@959 300 bool wantRate = (m_format.getTimingType() == CSVFormat::ImplicitTiming ||
Chris@959 301 m_format.getTimeUnits() == CSVFormat::TimeAudioFrames);
Chris@959 302 bool wantWindow = (m_format.getTimingType() == CSVFormat::ImplicitTiming);
Chris@959 303
Chris@959 304 m_sampleRateCombo->setEnabled(wantRate);
Chris@959 305 m_sampleRateLabel->setEnabled(wantRate);
Chris@959 306
Chris@959 307 m_windowSizeCombo->setEnabled(wantWindow);
Chris@959 308 m_windowSizeLabel->setEnabled(wantWindow);
Chris@959 309 }
Chris@959 310
Chris@959 311 void
Chris@378 312 CSVFormatDialog::timingTypeChanged(int type)
Chris@378 313 {
Chris@959 314 // Update any column purpose combos
Chris@959 315 if (TimingOption(type) == TimingImplicit) {
Chris@959 316 removeStartTimePurpose();
Chris@959 317 } else {
Chris@959 318 applyStartTimePurpose();
Chris@378 319 }
Chris@959 320 updateFormatFromDialog();
Chris@959 321 updateComboVisibility();
Chris@559 322 }
Chris@559 323
Chris@559 324 void
Chris@378 325 CSVFormatDialog::sampleRateChanged(QString rateString)
Chris@378 326 {
Chris@378 327 bool ok = false;
Chris@378 328 int sampleRate = rateString.toInt(&ok);
Chris@560 329 if (ok) m_format.setSampleRate(sampleRate);
Chris@378 330 }
Chris@378 331
Chris@378 332 void
Chris@378 333 CSVFormatDialog::windowSizeChanged(QString sizeString)
Chris@378 334 {
Chris@378 335 bool ok = false;
Chris@378 336 int size = sizeString.toInt(&ok);
Chris@560 337 if (ok) m_format.setWindowSize(size);
Chris@378 338 }
Chris@560 339
Chris@560 340 void
Chris@561 341 CSVFormatDialog::columnPurposeChanged(int p)
Chris@560 342 {
Chris@560 343 QObject *o = sender();
Chris@560 344 QComboBox *cb = qobject_cast<QComboBox *>(o);
Chris@560 345 if (!cb) return;
Chris@561 346
Chris@561 347 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose)p;
Chris@561 348
Chris@959 349 bool haveStartTime = false; // so as to update timing type combo appropriately
Chris@959 350
Chris@959 351 // Ensure the column purpose combos are consistent with one
Chris@959 352 // another, without reference to m_format (which we'll update
Chris@959 353 // separately)
Chris@959 354
Chris@560 355 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
Chris@561 356
Chris@992 357 // The fuzzy column combo only has the entries <ignore> or
Chris@992 358 // Values, so it can't affect the timing type and none of this
Chris@992 359 // logic affects it
Chris@992 360 if (i == m_fuzzyColumn) continue;
Chris@992 361
Chris@959 362 QComboBox *thisCombo = m_columnPurposeCombos[i];
Chris@561 363
Chris@959 364 CSVFormat::ColumnPurpose cp = (CSVFormat::ColumnPurpose)
Chris@959 365 (thisCombo->currentIndex());
Chris@959 366 bool thisChanged = (cb == thisCombo);
Chris@959 367
Chris@959 368 if (!thisChanged) {
Chris@561 369
Chris@561 370 // We can only have one ColumnStartTime column, and only
Chris@561 371 // one of either ColumnDuration or ColumnEndTime
Chris@561 372
Chris@561 373 if (purpose == CSVFormat::ColumnStartTime) {
Chris@561 374 if (cp == purpose) {
Chris@561 375 cp = CSVFormat::ColumnValue;
Chris@561 376 }
Chris@561 377 } else if (purpose == CSVFormat::ColumnDuration ||
Chris@561 378 purpose == CSVFormat::ColumnEndTime) {
Chris@561 379 if (cp == CSVFormat::ColumnDuration ||
Chris@561 380 cp == CSVFormat::ColumnEndTime) {
Chris@561 381 cp = CSVFormat::ColumnValue;
Chris@561 382 }
Chris@561 383 }
Chris@561 384
Chris@561 385 // And we can only have one label
Chris@561 386 if (purpose == CSVFormat::ColumnLabel) {
Chris@561 387 if (cp == purpose) {
Chris@561 388 cp = CSVFormat::ColumnUnknown;
Chris@561 389 }
Chris@561 390 }
Chris@959 391
Chris@959 392 if (cp == CSVFormat::ColumnStartTime) {
Chris@959 393 haveStartTime = true;
Chris@959 394 }
Chris@959 395
Chris@959 396 thisCombo->setCurrentIndex(int(cp));
Chris@959 397
Chris@959 398 } else {
Chris@959 399 if (purpose == CSVFormat::ColumnStartTime) {
Chris@959 400 haveStartTime = true;
Chris@959 401 }
Chris@561 402 }
Chris@959 403 }
Chris@561 404
Chris@959 405 if (!haveStartTime) {
Chris@959 406 m_timingTypeCombo->setCurrentIndex(int(TimingImplicit));
Chris@959 407 } else if (m_timingTypeCombo->currentIndex() == int(TimingImplicit)) {
Chris@959 408 if (m_initialTimingOption == TimingImplicit) {
Chris@959 409 m_timingTypeCombo->setCurrentIndex(TimingExplicitSeconds);
Chris@959 410 } else {
Chris@959 411 m_timingTypeCombo->setCurrentIndex(m_initialTimingOption);
Chris@959 412 }
Chris@959 413 }
Chris@959 414
Chris@959 415 updateFormatFromDialog();
Chris@959 416 updateComboVisibility();
Chris@959 417 }
Chris@959 418
Chris@959 419 void
Chris@959 420 CSVFormatDialog::updateFormatFromDialog()
Chris@959 421 {
Chris@959 422 switch (TimingOption(m_timingTypeCombo->currentIndex())) {
Chris@959 423
Chris@959 424 case TimingExplicitSeconds:
Chris@1266 425 m_format.setTimingType(CSVFormat::ExplicitTiming);
Chris@1266 426 m_format.setTimeUnits(CSVFormat::TimeSeconds);
Chris@1266 427 break;
Chris@959 428
Chris@959 429 case TimingExplicitMsec:
Chris@1266 430 m_format.setTimingType(CSVFormat::ExplicitTiming);
Chris@1266 431 m_format.setTimeUnits(CSVFormat::TimeMilliseconds);
Chris@1266 432 break;
Chris@959 433
Chris@959 434 case TimingExplicitSamples:
Chris@1266 435 m_format.setTimingType(CSVFormat::ExplicitTiming);
Chris@1266 436 m_format.setTimeUnits(CSVFormat::TimeAudioFrames);
Chris@1266 437 break;
Chris@959 438
Chris@959 439 case TimingImplicit:
Chris@1266 440 m_format.setTimingType(CSVFormat::ImplicitTiming);
Chris@1266 441 m_format.setTimeUnits(CSVFormat::TimeWindows);
Chris@1266 442 break;
Chris@959 443 }
Chris@959 444
Chris@959 445 bool haveStartTime = false;
Chris@959 446 bool haveDuration = false;
Chris@959 447 bool havePitch = false;
Chris@959 448 int valueCount = 0;
Chris@959 449
Chris@959 450 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
Chris@959 451
Chris@959 452 QComboBox *thisCombo = m_columnPurposeCombos[i];
Chris@959 453
Chris@959 454 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose)
Chris@959 455 (thisCombo->currentIndex());
Chris@959 456
Chris@959 457 if (i == m_fuzzyColumn) {
Chris@992 458 for (int j = i; j < m_format.getColumnCount(); ++j) {
Chris@959 459 if (purpose == CSVFormat::ColumnUnknown) {
Chris@959 460 m_format.setColumnPurpose(j, CSVFormat::ColumnUnknown);
Chris@959 461 } else { // Value
Chris@959 462 m_format.setColumnPurpose(j, CSVFormat::ColumnValue);
Chris@959 463 ++valueCount;
Chris@959 464 }
Chris@959 465 }
Chris@992 466 } else {
Chris@992 467
Chris@992 468 if (purpose == CSVFormat::ColumnStartTime) {
Chris@992 469 haveStartTime = true;
Chris@992 470 }
Chris@992 471 if (purpose == CSVFormat::ColumnEndTime ||
Chris@992 472 purpose == CSVFormat::ColumnDuration) {
Chris@992 473 haveDuration = true;
Chris@992 474 }
Chris@992 475 if (purpose == CSVFormat::ColumnPitch) {
Chris@992 476 havePitch = true;
Chris@992 477 }
Chris@992 478 if (purpose == CSVFormat::ColumnValue) {
Chris@992 479 ++valueCount;
Chris@992 480 }
Chris@992 481
Chris@992 482 m_format.setColumnPurpose(i, purpose);
Chris@959 483 }
Chris@561 484 }
Chris@561 485
Chris@561 486 if (haveStartTime && haveDuration) {
Chris@763 487 if (havePitch) {
Chris@763 488 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDurationAndPitch);
Chris@763 489 } else {
Chris@763 490 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDuration);
Chris@763 491 }
Chris@561 492 } else {
Chris@561 493 if (valueCount > 1) {
Chris@561 494 m_format.setModelType(CSVFormat::ThreeDimensionalModel);
Chris@561 495 } else if (valueCount > 0) {
Chris@561 496 m_format.setModelType(CSVFormat::TwoDimensionalModel);
Chris@561 497 } else {
Chris@561 498 m_format.setModelType(CSVFormat::OneDimensionalModel);
Chris@560 499 }
Chris@560 500 }
Chris@561 501
Chris@561 502 updateModelLabel();
Chris@560 503 }
Chris@560 504
Chris@560 505
Chris@959 506