comparison widgets/CSVFormatDialog.cpp @ 1318:b149b53df365 import-audio-data

Support audio-format CSV format selection in dialog
author Chris Cannam
date Thu, 06 Sep 2018 11:49:31 +0100
parents fcc1f45f7bd5
children fbda05431ce0
comparison
equal deleted inserted replaced
1317:c2fa7bb1eca9 1318:b149b53df365
35 #include "base/Debug.h" 35 #include "base/Debug.h"
36 36
37 CSVFormatDialog::CSVFormatDialog(QWidget *parent, CSVFormat format, 37 CSVFormatDialog::CSVFormatDialog(QWidget *parent, CSVFormat format,
38 int maxDisplayCols) : 38 int maxDisplayCols) :
39 QDialog(parent), 39 QDialog(parent),
40 m_dialogType(format.getModelType() == CSVFormat::WaveFileModel ?
41 AudioDataDialog :
42 AnnotationDataDialog),
40 m_format(format), 43 m_format(format),
41 m_maxDisplayCols(maxDisplayCols), 44 m_maxDisplayCols(maxDisplayCols),
42 m_fuzzyColumn(-1) 45 m_fuzzyColumn(-1)
43 { 46 {
44 setModal(true); 47 setModal(true);
46 49
47 QGridLayout *layout = new QGridLayout; 50 QGridLayout *layout = new QGridLayout;
48 51
49 int row = 0; 52 int row = 0;
50 53
51 layout->addWidget(new QLabel(tr("Please select the correct data format for this file.")), 54 layout->addWidget
52 row++, 0, 1, 4); 55 (new QLabel(tr("Please select the correct data format for this file.")),
56 row++, 0, 1, 4);
53 57
54 QFrame *exampleFrame = new QFrame; 58 QFrame *exampleFrame = new QFrame;
55 exampleFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 59 exampleFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
56 exampleFrame->setLineWidth(2); 60 exampleFrame->setLineWidth(2);
57 QGridLayout *exampleLayout = new QGridLayout; 61 QGridLayout *exampleLayout = new QGridLayout;
62 palette.setColor(QPalette::Window, palette.color(QPalette::Base)); 66 palette.setColor(QPalette::Window, palette.color(QPalette::Base));
63 exampleFrame->setPalette(palette); 67 exampleFrame->setPalette(palette);
64 68
65 QFont fp; 69 QFont fp;
66 fp.setPointSize(int(floor(fp.pointSize() * 0.9))); 70 fp.setPointSize(int(floor(fp.pointSize() * 0.9)));
67 // fp.setFixedPitch(true);
68 // fp.setStyleHint(QFont::TypeWriter);
69 // fp.setFamily("Monospaced");
70 71
71 int columns = format.getColumnCount(); 72 int columns = format.getColumnCount();
72 QList<QStringList> example = m_format.getExample(); 73 QList<QStringList> example = m_format.getExample();
73 74
74 for (int i = 0; i < columns; ++i) { 75 for (int i = 0; i < columns; ++i) {
75 76
76 QComboBox *cpc = new QComboBox; 77 QComboBox *cpc = new QComboBox;
77 m_columnPurposeCombos.push_back(cpc); 78 m_columnPurposeCombos.push_back(cpc);
78 exampleLayout->addWidget(cpc, 0, i); 79 exampleLayout->addWidget(cpc, 0, i);
79 connect(cpc, SIGNAL(activated(int)), this, SLOT(columnPurposeChanged(int))); 80 connect(cpc, SIGNAL(activated(int)), this, SLOT(columnPurposeChanged(int)));
80 81
81 if (i == m_maxDisplayCols && columns > i + 2) { 82 if (i == m_maxDisplayCols && columns > i + 2) {
82 m_fuzzyColumn = i; 83 m_fuzzyColumn = i;
84
85 if (m_dialogType == AnnotationDataDialog) {
86 cpc->addItem(tr("<ignore>"));
87 cpc->addItem(tr("Values"));
88 cpc->setCurrentIndex
89 (m_format.getColumnPurpose(i-1) ==
90 CSVFormat::ColumnUnknown ? 0 : 1);
91 } else {
92 cpc->addItem(tr("<ignore>"));
93 cpc->addItem(tr("Audio channels"));
94 cpc->setCurrentIndex
95 (m_format.isColumnNumeric(i-1) ? 1 : 0);
96 }
97 exampleLayout->addWidget
98 (new QLabel(tr("(%1 more)").arg(columns - i)), 1, i);
99 break;
100 }
101
102 if (m_dialogType == AnnotationDataDialog) {
103
104 // NB must be in the same order as the CSVFormat::ColumnPurpose enum
105 cpc->addItem(tr("<ignore>")); // ColumnUnknown
106 cpc->addItem(tr("Time")); // ColumnStartTime
107 cpc->addItem(tr("End time")); // ColumnEndTime
108 cpc->addItem(tr("Duration")); // ColumnDuration
109 cpc->addItem(tr("Value")); // ColumnValue
110 cpc->addItem(tr("Pitch")); // ColumnPitch
111 cpc->addItem(tr("Label")); // ColumnLabel
112 cpc->setCurrentIndex(int(m_format.getColumnPurpose(i)));
113
114 } else {
83 cpc->addItem(tr("<ignore>")); 115 cpc->addItem(tr("<ignore>"));
84 cpc->addItem(tr("Values")); 116 cpc->addItem(tr("Audio channel"));
85 cpc->setCurrentIndex 117 if (m_format.isColumnNumeric(i)) {
86 (m_format.getColumnPurpose(i-1) == CSVFormat::ColumnUnknown ? 0 : 1); 118 cpc->setCurrentIndex(1);
87 exampleLayout->addWidget(new QLabel(tr("(%1 more)").arg(columns - i)), 119 } else {
88 1, i); 120 cpc->setCurrentIndex(0);
89 break; 121 }
90 } 122 }
91 123
92 // NB must be in the same order as the CSVFormat::ColumnPurpose enum
93 cpc->addItem(tr("<ignore>")); // ColumnUnknown
94 cpc->addItem(tr("Time")); // ColumnStartTime
95 cpc->addItem(tr("End time")); // ColumnEndTime
96 cpc->addItem(tr("Duration")); // ColumnDuration
97 cpc->addItem(tr("Value")); // ColumnValue
98 cpc->addItem(tr("Pitch")); // ColumnPitch
99 cpc->addItem(tr("Label")); // ColumnLabel
100 cpc->setCurrentIndex(int(m_format.getColumnPurpose(i)));
101
102 for (int j = 0; j < example.size() && j < 6; ++j) { 124 for (int j = 0; j < example.size() && j < 6; ++j) {
103 if (i >= example[j].size()) { 125 if (i >= example[j].size()) {
104 continue; 126 continue;
105 } 127 }
106 QLabel *label = new QLabel; 128 QLabel *label = new QLabel;
116 138
117 layout->addWidget(exampleFrame, row, 0, 1, 4); 139 layout->addWidget(exampleFrame, row, 0, 1, 4);
118 layout->setColumnStretch(3, 10); 140 layout->setColumnStretch(3, 10);
119 layout->setRowStretch(row++, 10); 141 layout->setRowStretch(row++, 10);
120 142
121 layout->addWidget(new QLabel(tr("Timing is specified:")), row, 0); 143 if (m_dialogType == AnnotationDataDialog) {
122 144
123 m_timingTypeCombo = new QComboBox; 145 layout->addWidget(new QLabel(tr("Timing is specified:")), row, 0);
124 146
125 m_timingLabels = { 147 m_timingTypeCombo = new QComboBox;
126 { TimingExplicitSeconds, tr("Explicitly, in seconds") }, 148
127 { TimingExplicitMsec, tr("Explicitly, in milliseconds") }, 149 m_timingLabels = {
128 { TimingExplicitSamples, tr("Explicitly, in audio sample frames") }, 150 { TimingExplicitSeconds, tr("Explicitly, in seconds") },
129 { TimingImplicit, tr("Implicitly: rows are equally spaced in time") } 151 { TimingExplicitMsec, tr("Explicitly, in milliseconds") },
130 }; 152 { TimingExplicitSamples, tr("Explicitly, in audio sample frames") },
131 153 { TimingImplicit, tr("Implicitly: rows are equally spaced in time") }
132 for (auto &l: m_timingLabels) { 154 };
133 m_timingTypeCombo->addItem(l.second); 155
134 } 156 for (auto &l: m_timingLabels) {
135 157 m_timingTypeCombo->addItem(l.second);
136 layout->addWidget(m_timingTypeCombo, row++, 1, 1, 2); 158 }
137 159
138 connect(m_timingTypeCombo, SIGNAL(activated(int)), 160 layout->addWidget(m_timingTypeCombo, row++, 1, 1, 2);
139 this, SLOT(timingTypeChanged(int))); 161
140 162 connect(m_timingTypeCombo, SIGNAL(activated(int)),
141 m_initialTimingOption = TimingImplicit; 163 this, SLOT(timingTypeChanged(int)));
142 if (m_format.getTimingType() == CSVFormat::ExplicitTiming) { 164
143 switch (m_format.getTimeUnits()) { 165 m_initialTimingOption = TimingImplicit;
144 case CSVFormat::TimeSeconds: 166 if (m_format.getTimingType() == CSVFormat::ExplicitTiming) {
145 m_initialTimingOption = TimingExplicitSeconds; break; 167 switch (m_format.getTimeUnits()) {
146 case CSVFormat::TimeMilliseconds: 168 case CSVFormat::TimeSeconds:
147 m_initialTimingOption = TimingExplicitMsec; break; 169 m_initialTimingOption = TimingExplicitSeconds; break;
148 case CSVFormat::TimeAudioFrames: 170 case CSVFormat::TimeMilliseconds:
149 m_initialTimingOption = TimingExplicitSamples; break; 171 m_initialTimingOption = TimingExplicitMsec; break;
150 case CSVFormat::TimeWindows: 172 case CSVFormat::TimeAudioFrames:
151 m_initialTimingOption = TimingImplicit; break; 173 m_initialTimingOption = TimingExplicitSamples; break;
152 } 174 case CSVFormat::TimeWindows:
153 } 175 m_initialTimingOption = TimingImplicit; break;
154 m_timingTypeCombo->setCurrentIndex(int(m_initialTimingOption)); 176 }
155 177 }
178 m_timingTypeCombo->setCurrentIndex(int(m_initialTimingOption));
179
180 } else {
181
182 m_timingTypeCombo = 0;
183 }
184
156 m_sampleRateLabel = new QLabel(tr("Audio sample rate (Hz):")); 185 m_sampleRateLabel = new QLabel(tr("Audio sample rate (Hz):"));
157 layout->addWidget(m_sampleRateLabel, row, 0); 186 layout->addWidget(m_sampleRateLabel, row, 0);
158 187
159 int sampleRates[] = { 188 int sampleRates[] = {
160 8000, 11025, 12000, 22050, 24000, 32000, 189 8000, 11025, 12000, 22050, 24000, 32000,
174 connect(m_sampleRateCombo, SIGNAL(activated(QString)), 203 connect(m_sampleRateCombo, SIGNAL(activated(QString)),
175 this, SLOT(sampleRateChanged(QString))); 204 this, SLOT(sampleRateChanged(QString)));
176 connect(m_sampleRateCombo, SIGNAL(editTextChanged(QString)), 205 connect(m_sampleRateCombo, SIGNAL(editTextChanged(QString)),
177 this, SLOT(sampleRateChanged(QString))); 206 this, SLOT(sampleRateChanged(QString)));
178 207
179 m_windowSizeLabel = new QLabel(tr("Frame increment between rows:")); 208 if (m_dialogType == AnnotationDataDialog) {
180 layout->addWidget(m_windowSizeLabel, row, 0); 209
181 210 m_windowSizeLabel = new QLabel(tr("Frame increment between rows:"));
182 m_windowSizeCombo = new QComboBox; 211 layout->addWidget(m_windowSizeLabel, row, 0);
183 for (int i = 0; i <= 16; ++i) { 212
184 int value = 1 << i; 213 m_windowSizeCombo = new QComboBox;
185 m_windowSizeCombo->addItem(QString("%1").arg(value)); 214 for (int i = 0; i <= 16; ++i) {
186 if (value == int(m_format.getWindowSize())) { 215 int value = 1 << i;
187 m_windowSizeCombo->setCurrentIndex(i); 216 m_windowSizeCombo->addItem(QString("%1").arg(value));
188 } 217 if (value == int(m_format.getWindowSize())) {
189 } 218 m_windowSizeCombo->setCurrentIndex(i);
190 m_windowSizeCombo->setEditable(true); 219 }
191 220 }
192 layout->addWidget(m_windowSizeCombo, row++, 1); 221 m_windowSizeCombo->setEditable(true);
193 connect(m_windowSizeCombo, SIGNAL(activated(QString)), 222
194 this, SLOT(windowSizeChanged(QString))); 223 layout->addWidget(m_windowSizeCombo, row++, 1);
195 connect(m_windowSizeCombo, SIGNAL(editTextChanged(QString)), 224 connect(m_windowSizeCombo, SIGNAL(activated(QString)),
196 this, SLOT(windowSizeChanged(QString))); 225 this, SLOT(windowSizeChanged(QString)));
197 226 connect(m_windowSizeCombo, SIGNAL(editTextChanged(QString)),
198 m_modelLabel = new QLabel; 227 this, SLOT(windowSizeChanged(QString)));
199 QFont f(m_modelLabel->font()); 228
200 f.setItalic(true); 229 m_modelLabel = new QLabel;
201 m_modelLabel->setFont(f); 230 QFont f(m_modelLabel->font());
202 layout->addWidget(m_modelLabel, row++, 0, 1, 4); 231 f.setItalic(true);
232 m_modelLabel->setFont(f);
233 layout->addWidget(m_modelLabel, row++, 0, 1, 4);
234
235 } else {
236 m_windowSizeLabel = 0;
237 m_windowSizeCombo = 0;
238 m_modelLabel = 0;
239 }
203 240
204 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | 241 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
205 QDialogButtonBox::Cancel); 242 QDialogButtonBox::Cancel);
206 layout->addWidget(bb, row++, 0, 1, 4); 243 layout->addWidget(bb, row++, 0, 1, 4);
207 connect(bb, SIGNAL(accepted()), this, SLOT(accept())); 244 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
208 connect(bb, SIGNAL(rejected()), this, SLOT(reject())); 245 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
209 246
210 setLayout(layout); 247 setLayout(layout);
211 248
212 timingTypeChanged(m_timingTypeCombo->currentIndex()); 249 if (m_timingTypeCombo) {
250 timingTypeChanged(m_timingTypeCombo->currentIndex());
251 } else {
252 updateFormatFromDialog();
253 updateComboVisibility();
254 }
213 } 255 }
214 256
215 CSVFormatDialog::~CSVFormatDialog() 257 CSVFormatDialog::~CSVFormatDialog()
216 { 258 {
217 } 259 }
223 } 265 }
224 266
225 void 267 void
226 CSVFormatDialog::updateModelLabel() 268 CSVFormatDialog::updateModelLabel()
227 { 269 {
270 if (!m_modelLabel) {
271 return;
272 }
273
228 LayerFactory *f = LayerFactory::getInstance(); 274 LayerFactory *f = LayerFactory::getInstance();
229 275
230 QString s; 276 QString s;
231 switch (m_format.getModelType()) { 277 switch (m_format.getModelType()) {
232 case CSVFormat::OneDimensionalModel: 278 case CSVFormat::OneDimensionalModel:
247 case CSVFormat::WaveFileModel: 293 case CSVFormat::WaveFileModel:
248 s = f->getLayerPresentationName(LayerFactory::Waveform); 294 s = f->getLayerPresentationName(LayerFactory::Waveform);
249 break; 295 break;
250 } 296 }
251 297
252 m_modelLabel->setText("\n" + tr("Data will be displayed in a %1 layer.").arg(s)); 298 m_modelLabel->setText("\n" + tr("Data will be displayed in a %1 layer.")
299 .arg(s));
253 } 300 }
254 301
255 void 302 void
256 CSVFormatDialog::applyStartTimePurpose() 303 CSVFormatDialog::applyStartTimePurpose()
257 { 304 {
305 if (m_dialogType == AudioDataDialog) {
306 return;
307 }
308
258 // First check if we already have any. NB there may be fewer than 309 // First check if we already have any. NB there may be fewer than
259 // m_format.getColumnCount() elements in m_columnPurposeCombos 310 // m_format.getColumnCount() elements in m_columnPurposeCombos
260 // (because of the fuzzy column behaviour). Note also that the 311 // (because of the fuzzy column behaviour). Note also that the
261 // fuzzy column (which is the one just showing how many more 312 // fuzzy column (which is the one just showing how many more
262 // columns there are) has a different combo with only two items 313 // columns there are) has a different combo with only two items
280 } 331 }
281 332
282 void 333 void
283 CSVFormatDialog::removeStartTimePurpose() 334 CSVFormatDialog::removeStartTimePurpose()
284 { 335 {
336 if (m_dialogType == AudioDataDialog) {
337 return;
338 }
339
285 // NB there may be fewer than m_format.getColumnCount() elements 340 // NB there may be fewer than m_format.getColumnCount() elements
286 // in m_columnPurposeCombos (because of the fuzzy column 341 // in m_columnPurposeCombos (because of the fuzzy column
287 // behaviour) 342 // behaviour)
288 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) { 343 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
289 if (i == m_fuzzyColumn) continue; 344 if (i == m_fuzzyColumn) continue;
295 } 350 }
296 351
297 void 352 void
298 CSVFormatDialog::updateComboVisibility() 353 CSVFormatDialog::updateComboVisibility()
299 { 354 {
300 bool wantRate = (m_format.getTimingType() == CSVFormat::ImplicitTiming || 355 bool wantRate = (m_dialogType == AudioDataDialog ||
356 m_format.getTimingType() == CSVFormat::ImplicitTiming ||
301 m_format.getTimeUnits() == CSVFormat::TimeAudioFrames); 357 m_format.getTimeUnits() == CSVFormat::TimeAudioFrames);
302 bool wantWindow = (m_format.getTimingType() == CSVFormat::ImplicitTiming); 358 bool wantWindow = (m_format.getTimingType() == CSVFormat::ImplicitTiming);
303 359
304 m_sampleRateCombo->setEnabled(wantRate); 360 m_sampleRateCombo->setEnabled(wantRate);
305 m_sampleRateLabel->setEnabled(wantRate); 361 m_sampleRateLabel->setEnabled(wantRate);
306 362
307 m_windowSizeCombo->setEnabled(wantWindow); 363 if (m_windowSizeCombo) {
308 m_windowSizeLabel->setEnabled(wantWindow); 364 m_windowSizeCombo->setEnabled(wantWindow);
365 m_windowSizeLabel->setEnabled(wantWindow);
366 }
309 } 367 }
310 368
311 void 369 void
312 CSVFormatDialog::timingTypeChanged(int type) 370 CSVFormatDialog::timingTypeChanged(int type)
313 { 371 {
342 { 400 {
343 QObject *o = sender(); 401 QObject *o = sender();
344 QComboBox *cb = qobject_cast<QComboBox *>(o); 402 QComboBox *cb = qobject_cast<QComboBox *>(o);
345 if (!cb) return; 403 if (!cb) return;
346 404
405 if (m_dialogType == AnnotationDataDialog) {
406 columnPurposeChangedForAnnotationType(cb, p);
407 }
408
409 updateFormatFromDialog();
410 updateComboVisibility();
411 }
412
413 void
414 CSVFormatDialog::columnPurposeChangedForAnnotationType(QComboBox *cb, int p)
415 {
416 // Ensure a consistent set of column purposes, in a situation
417 // where some combinations are contradictory. This is only
418 // relevant to annotation type formats. Only updates the UI, does
419 // not update the stored format record from the UI - that's the
420 // job of updateFormatFromDialog
421
347 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose)p; 422 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose)p;
348 423
349 bool haveStartTime = false; // so as to update timing type combo appropriately 424 bool haveStartTime = false; // so as to update timing type combo appropriately
350 425
351 // Ensure the column purpose combos are consistent with one 426 // Ensure the column purpose combos are consistent with one
400 haveStartTime = true; 475 haveStartTime = true;
401 } 476 }
402 } 477 }
403 } 478 }
404 479
405 if (!haveStartTime) { 480 if (m_timingTypeCombo) {
406 m_timingTypeCombo->setCurrentIndex(int(TimingImplicit)); 481 if (!haveStartTime) {
407 } else if (m_timingTypeCombo->currentIndex() == int(TimingImplicit)) { 482 m_timingTypeCombo->setCurrentIndex(int(TimingImplicit));
408 if (m_initialTimingOption == TimingImplicit) { 483 } else if (m_timingTypeCombo->currentIndex() == int(TimingImplicit)) {
409 m_timingTypeCombo->setCurrentIndex(TimingExplicitSeconds); 484 if (m_initialTimingOption == TimingImplicit) {
410 } else { 485 m_timingTypeCombo->setCurrentIndex(TimingExplicitSeconds);
411 m_timingTypeCombo->setCurrentIndex(m_initialTimingOption); 486 } else {
412 } 487 m_timingTypeCombo->setCurrentIndex(m_initialTimingOption);
413 } 488 }
414 489 }
415 updateFormatFromDialog(); 490 }
416 updateComboVisibility(); 491 }
417 } 492
418
419 void 493 void
420 CSVFormatDialog::updateFormatFromDialog() 494 CSVFormatDialog::updateFormatFromDialog()
421 { 495 {
422 switch (TimingOption(m_timingTypeCombo->currentIndex())) { 496 if (m_timingTypeCombo) {
423 497 switch (TimingOption(m_timingTypeCombo->currentIndex())) {
424 case TimingExplicitSeconds: 498
425 m_format.setTimingType(CSVFormat::ExplicitTiming); 499 case TimingExplicitSeconds:
426 m_format.setTimeUnits(CSVFormat::TimeSeconds); 500 m_format.setTimingType(CSVFormat::ExplicitTiming);
427 break; 501 m_format.setTimeUnits(CSVFormat::TimeSeconds);
428 502 break;
429 case TimingExplicitMsec: 503
430 m_format.setTimingType(CSVFormat::ExplicitTiming); 504 case TimingExplicitMsec:
431 m_format.setTimeUnits(CSVFormat::TimeMilliseconds); 505 m_format.setTimingType(CSVFormat::ExplicitTiming);
432 break; 506 m_format.setTimeUnits(CSVFormat::TimeMilliseconds);
433 507 break;
434 case TimingExplicitSamples: 508
435 m_format.setTimingType(CSVFormat::ExplicitTiming); 509 case TimingExplicitSamples:
510 m_format.setTimingType(CSVFormat::ExplicitTiming);
511 m_format.setTimeUnits(CSVFormat::TimeAudioFrames);
512 break;
513
514 case TimingImplicit:
515 m_format.setTimingType(CSVFormat::ImplicitTiming);
516 m_format.setTimeUnits(CSVFormat::TimeWindows);
517 break;
518 }
519 } else if (m_dialogType == AudioDataDialog) {
520 m_format.setTimingType(CSVFormat::ImplicitTiming);
436 m_format.setTimeUnits(CSVFormat::TimeAudioFrames); 521 m_format.setTimeUnits(CSVFormat::TimeAudioFrames);
437 break; 522 }
438 523
439 case TimingImplicit:
440 m_format.setTimingType(CSVFormat::ImplicitTiming);
441 m_format.setTimeUnits(CSVFormat::TimeWindows);
442 break;
443 }
444
445 bool haveStartTime = false; 524 bool haveStartTime = false;
446 bool haveDuration = false; 525 bool haveDuration = false;
447 bool havePitch = false; 526 bool havePitch = false;
448 int valueCount = 0; 527 int valueCount = 0;
449 528
450 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) { 529 for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
451 530
452 QComboBox *thisCombo = m_columnPurposeCombos[i]; 531 QComboBox *thisCombo = m_columnPurposeCombos[i];
453 532
454 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose) 533 CSVFormat::ColumnPurpose purpose;
455 (thisCombo->currentIndex()); 534
535 if (m_dialogType == AnnotationDataDialog) {
536 purpose = (CSVFormat::ColumnPurpose) (thisCombo->currentIndex());
537 } else {
538 purpose = (thisCombo->currentIndex() == 1 ?
539 CSVFormat::ColumnValue :
540 CSVFormat::ColumnUnknown);
541 }
456 542
457 if (i == m_fuzzyColumn) { 543 if (i == m_fuzzyColumn) {
458 for (int j = i; j < m_format.getColumnCount(); ++j) { 544 for (int j = i; j < m_format.getColumnCount(); ++j) {
459 if (purpose == CSVFormat::ColumnUnknown) { 545 if (purpose == CSVFormat::ColumnUnknown) {
460 m_format.setColumnPurpose(j, CSVFormat::ColumnUnknown); 546 m_format.setColumnPurpose(j, CSVFormat::ColumnUnknown);
481 567
482 m_format.setColumnPurpose(i, purpose); 568 m_format.setColumnPurpose(i, purpose);
483 } 569 }
484 } 570 }
485 571
486 if (haveStartTime && haveDuration) { 572 if (m_dialogType == AudioDataDialog) {
573 m_format.setModelType(CSVFormat::WaveFileModel);
574 } else if (haveStartTime && haveDuration) {
487 if (havePitch) { 575 if (havePitch) {
488 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDurationAndPitch); 576 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDurationAndPitch);
489 } else { 577 } else {
490 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDuration); 578 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDuration);
491 } 579 }