23 #include <QGridLayout> 24 #include <QPushButton> 25 #include <QHBoxLayout> 26 #include <QVBoxLayout> 27 #include <QTableWidget> 30 #include <QDialogButtonBox> 34 #include "base/Debug.h" 40 m_maxDisplayCols(maxDisplayCols),
44 setWindowTitle(tr(
"Select Data Format"));
46 QGridLayout *layout =
new QGridLayout;
50 layout->addWidget(
new QLabel(tr(
"Please select the correct data format for this file.")),
53 QFrame *exampleFrame =
new QFrame;
54 exampleFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
55 exampleFrame->setLineWidth(2);
56 QGridLayout *exampleLayout =
new QGridLayout;
57 exampleLayout->setSpacing(4);
58 exampleFrame->setLayout(exampleLayout);
60 QPalette palette = exampleFrame->palette();
61 palette.setColor(QPalette::Window, palette.color(QPalette::Base));
62 exampleFrame->setPalette(palette);
65 fp.setPointSize(fp.pointSize() * 0.9);
70 int columns = format.getColumnCount();
71 QList<QStringList> example =
m_format.getExample();
73 for (
int i = 0; i < columns; ++i) {
75 QComboBox *cpc =
new QComboBox;
77 exampleLayout->addWidget(cpc, 0, i);
82 cpc->addItem(tr(
"<ignore>"));
83 cpc->addItem(tr(
"Values"));
85 (
m_format.getColumnPurpose(i-1) == CSVFormat::ColumnUnknown ? 0 : 1);
86 exampleLayout->addWidget(
new QLabel(tr(
"(%1 more)").arg(columns - i)),
92 cpc->addItem(tr(
"<ignore>"));
93 cpc->addItem(tr(
"Time"));
94 cpc->addItem(tr(
"End time"));
95 cpc->addItem(tr(
"Duration"));
96 cpc->addItem(tr(
"Value"));
97 cpc->addItem(tr(
"Pitch"));
98 cpc->addItem(tr(
"Label"));
99 cpc->setCurrentIndex(
int(
m_format.getColumnPurpose(i)));
101 for (
int j = 0; j < example.size() && j < 6; ++j) {
102 QLabel *label =
new QLabel;
103 label->setTextFormat(Qt::PlainText);
105 label->setText(text);
107 label->setPalette(palette);
109 exampleLayout->addWidget(label, j+1, i);
113 layout->addWidget(exampleFrame, row, 0, 1, 4);
114 layout->setColumnStretch(3, 10);
115 layout->setRowStretch(row++, 10);
117 layout->addWidget(
new QLabel(tr(
"Timing is specified:")), row, 0);
127 (
m_format.getTimingType() == CSVFormat::ExplicitTiming ?
128 m_format.getTimeUnits() == CSVFormat::TimeSeconds ? 0 : 1 : 2);
133 int sampleRates[] = {
134 8000, 11025, 12000, 22050, 24000, 32000,
135 44100, 48000, 88200, 96000, 176400, 192000
139 for (
int i = 0; i < int(
sizeof(sampleRates) /
sizeof(sampleRates[0])); ++i) {
141 if (sampleRates[i] ==
m_format.getSampleRate()) {
157 for (
int i = 0; i <= 16; ++i) {
160 if (value ==
int(
m_format.getWindowSize())) {
178 QDialogButtonBox *bb =
new QDialogButtonBox(QDialogButtonBox::Ok |
179 QDialogButtonBox::Cancel);
180 layout->addWidget(bb, row++, 0, 1, 4);
181 connect(bb, SIGNAL(accepted()),
this, SLOT(accept()));
182 connect(bb, SIGNAL(rejected()),
this, SLOT(reject()));
207 case CSVFormat::OneDimensionalModel:
210 case CSVFormat::TwoDimensionalModel:
213 case CSVFormat::TwoDimensionalModelWithDuration:
216 case CSVFormat::TwoDimensionalModelWithDurationAndPitch:
219 case CSVFormat::ThreeDimensionalModel:
224 m_modelLabel->setText(
"\n" + tr(
"Data will be displayed in a %1 layer.").arg(s));
233 m_format.setTimingType(CSVFormat::ExplicitTiming);
234 m_format.setTimeUnits(CSVFormat::TimeSeconds);
242 m_format.setTimingType(CSVFormat::ExplicitTiming);
243 m_format.setTimeUnits(CSVFormat::TimeAudioFrames);
251 m_format.setTimingType(CSVFormat::ImplicitTiming);
252 m_format.setTimeUnits(CSVFormat::TimeWindows);
265 int sampleRate = rateString.toInt(&ok);
266 if (ok)
m_format.setSampleRate(sampleRate);
273 int size = sizeString.toInt(&ok);
274 if (ok)
m_format.setWindowSize(size);
280 QObject *o = sender();
282 QComboBox *cb = qobject_cast<QComboBox *>(o);
285 CSVFormat::ColumnPurpose purpose = (CSVFormat::ColumnPurpose)p;
287 bool haveStartTime =
false;
288 bool haveDuration =
false;
289 bool havePitch =
false;
294 CSVFormat::ColumnPurpose cp =
m_format.getColumnPurpose(i);
301 <<
", p == " << p << endl;
304 for (
int j = i; j <
m_format.getColumnCount(); ++j) {
306 m_format.setColumnPurpose(j, CSVFormat::ColumnUnknown);
308 m_format.setColumnPurpose(j, CSVFormat::ColumnValue);
324 if (purpose == CSVFormat::ColumnStartTime) {
326 cp = CSVFormat::ColumnValue;
328 }
else if (purpose == CSVFormat::ColumnDuration ||
329 purpose == CSVFormat::ColumnEndTime) {
330 if (cp == CSVFormat::ColumnDuration ||
331 cp == CSVFormat::ColumnEndTime) {
332 cp = CSVFormat::ColumnValue;
337 if (purpose == CSVFormat::ColumnLabel) {
339 cp = CSVFormat::ColumnUnknown;
344 if (cp == CSVFormat::ColumnStartTime) {
345 haveStartTime =
true;
347 if (cp == CSVFormat::ColumnEndTime ||
348 cp == CSVFormat::ColumnDuration) {
351 if (cp == CSVFormat::ColumnPitch) {
354 if (cp == CSVFormat::ColumnValue) {
362 if (!haveStartTime) {
367 if (haveStartTime && haveDuration) {
369 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDurationAndPitch);
371 m_format.setModelType(CSVFormat::TwoDimensionalModelWithDuration);
374 if (valueCount > 1) {
375 m_format.setModelType(CSVFormat::ThreeDimensionalModel);
376 }
else if (valueCount > 0) {
377 m_format.setModelType(CSVFormat::TwoDimensionalModel);
379 m_format.setModelType(CSVFormat::OneDimensionalModel);
static LayerFactory * getInstance()
static QString abbreviate(QString text, int maxLength, Policy policy=ElideEnd, bool fuzzy=true, QString ellipsis="")
Abbreviate the given text to the given maximum length (including ellipsis), using the given abbreviat...
QString getLayerPresentationName(LayerType type)