23 #include <QGridLayout> 24 #include <QPushButton> 25 #include <QHBoxLayout> 26 #include <QVBoxLayout> 27 #include <QTableWidget> 30 #include <QDialogButtonBox> 35 #include "base/Debug.h" 41 m_maxDisplayCols(maxDisplayCols),
45 setWindowTitle(tr(
"Select Audio Data Format"));
47 QGridLayout *layout =
new QGridLayout;
52 (
new QLabel(tr(
"Please select the correct data format for this file.")),
55 QFrame *exampleFrame =
new QFrame;
56 exampleFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
57 exampleFrame->setLineWidth(2);
58 QGridLayout *exampleLayout =
new QGridLayout;
59 exampleLayout->setSpacing(4);
60 exampleFrame->setLayout(exampleLayout);
62 QPalette palette = exampleFrame->palette();
63 palette.setColor(QPalette::Window, palette.color(QPalette::Base));
64 exampleFrame->setPalette(palette);
67 fp.setPointSize(
int(floor(fp.pointSize() * 0.9)));
69 int columns = format.getColumnCount();
70 QList<QStringList> example =
m_format.getExample();
72 for (
int i = 0; i < columns; ++i) {
74 QComboBox *cpc =
new QComboBox;
76 exampleLayout->addWidget(cpc, 0, i);
82 cpc->addItem(tr(
"<ignore>"));
83 cpc->addItem(tr(
"Audio channels"));
85 (
m_format.getColumnPurpose(i-1) == CSVFormat::ColumnValue ?
88 exampleLayout->addWidget
89 (
new QLabel(tr(
"(%1 more)").arg(columns - i)), 1, i);
93 cpc->addItem(tr(
"<ignore>"));
94 cpc->addItem(tr(
"Audio channel"));
96 (
m_format.getColumnPurpose(i) == CSVFormat::ColumnValue ? 1 : 0);
98 for (
int j = 0; j < example.size() && j < 6; ++j) {
99 if (i >= example[j].size()) {
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(
"Audio sample rate (Hz):")), row, 0);
120 8000, 11025, 12000, 22050, 24000, 32000,
121 44100, 48000, 88200, 96000, 176400, 192000
125 for (
int i = 0; i < int(
sizeof(sampleRates) /
sizeof(sampleRates[0])); ++i) {
127 if (sampleRates[i] ==
m_format.getSampleRate()) {
139 layout->addWidget(
new QLabel(tr(
"Sample values are:")), row, 0);
153 QDialogButtonBox *bb =
new QDialogButtonBox(QDialogButtonBox::Ok |
154 QDialogButtonBox::Cancel);
155 layout->addWidget(bb, row++, 0, 1, 4);
156 connect(bb, SIGNAL(accepted()),
this, SLOT(accept()));
157 connect(bb, SIGNAL(rejected()),
this, SLOT(reject()));
178 int sampleRate = rateString.toInt(&ok);
179 if (ok)
m_format.setSampleRate(sampleRate);
185 m_format.setAudioSampleRange((CSVFormat::AudioSampleRange)range);
197 m_format.setModelType(CSVFormat::WaveFileModel);
198 m_format.setTimingType(CSVFormat::ImplicitTiming);
199 m_format.setTimeUnits(CSVFormat::TimeAudioFrames);
205 CSVFormat::ColumnPurpose purpose = (thisCombo->currentIndex() == 1 ?
206 CSVFormat::ColumnValue :
207 CSVFormat::ColumnUnknown);
210 for (
int j = i; j <
m_format.getColumnCount(); ++j) {
211 m_format.setColumnPurpose(j, purpose);
214 m_format.setColumnPurpose(i, purpose);
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...