ui->table->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
ui->table->horizontalHeader()->setSectionsClickable(false);
- ui->table->setRowCount(mapping.inputs.size());
- for (unsigned row = 0; row < mapping.inputs.size(); ++row) {
- fill_row_from_input(row, mapping.inputs[row]);
+ ui->table->setRowCount(mapping.buses.size());
+ for (unsigned row = 0; row < mapping.buses.size(); ++row) {
+ fill_row_from_bus(row, mapping.buses[row]);
}
}
-void InputMappingDialog::fill_row_from_input(unsigned row, const InputMapping::Input &input)
+void InputMappingDialog::fill_row_from_bus(unsigned row, const InputMapping::Bus &bus)
{
- QString name(QString::fromStdString(input.name));
+ QString name(QString::fromStdString(bus.name));
ui->table->setItem(row, 0, new QTableWidgetItem(name));
// Card choices.
for (const string &name : card_names) {
card_combo->addItem(QString::fromStdString(name + " "));
}
- switch (input.input_source_type) {
+ switch (bus.input_source_type) {
case InputSourceType::SILENCE:
card_combo->setCurrentIndex(0);
break;
case InputSourceType::CAPTURE_CARD:
- card_combo->setCurrentIndex(mapping.inputs[row].input_source_index + 1);
+ card_combo->setCurrentIndex(mapping.buses[row].input_source_index + 1);
break;
default:
assert(false);
bind(&InputMappingDialog::card_selected, this, row, _1));
ui->table->setCellWidget(row, 1, card_combo);
- setup_channel_choices_from_input(row, input);
+ setup_channel_choices_from_bus(row, bus);
}
-void InputMappingDialog::setup_channel_choices_from_input(unsigned row, const InputMapping::Input &input)
+void InputMappingDialog::setup_channel_choices_from_bus(unsigned row, const InputMapping::Bus &bus)
{
// Left and right channel.
for (unsigned channel = 0; channel < 2; ++channel) {
QComboBox *channel_combo = new QComboBox;
channel_combo->addItem(QString("(none)"));
- if (input.input_source_type == InputSourceType::CAPTURE_CARD) {
+ if (bus.input_source_type == InputSourceType::CAPTURE_CARD) {
for (unsigned source = 0; source < 8; ++source) { // TODO: Ask the card about number of channels, and names.
char buf[256];
snprintf(buf, sizeof(buf), "Channel %u ", source + 1);
channel_combo->addItem(QString(buf));
}
- channel_combo->setCurrentIndex(input.source_channel[channel] + 1);
+ channel_combo->setCurrentIndex(bus.source_channel[channel] + 1);
} else {
channel_combo->setCurrentIndex(0);
}
// Spurious; only really the name column should fire these.
return;
}
- mapping.inputs[row].name = ui->table->item(row, column)->text().toStdString();
+ mapping.buses[row].name = ui->table->item(row, column)->text().toStdString();
}
void InputMappingDialog::card_selected(unsigned row, int index)
{
if (index == 0) {
- mapping.inputs[row].input_source_type = InputSourceType::SILENCE;
+ mapping.buses[row].input_source_type = InputSourceType::SILENCE;
} else {
- mapping.inputs[row].input_source_type = InputSourceType::CAPTURE_CARD;
- mapping.inputs[row].input_source_index = index - 1;
+ mapping.buses[row].input_source_type = InputSourceType::CAPTURE_CARD;
+ mapping.buses[row].input_source_index = index - 1;
}
- setup_channel_choices_from_input(row, mapping.inputs[row]);
+ setup_channel_choices_from_bus(row, mapping.buses[row]);
}
void InputMappingDialog::channel_selected(unsigned row, unsigned channel, int index)
{
- mapping.inputs[row].source_channel[channel] = index - 1;
+ mapping.buses[row].source_channel[channel] = index - 1;
}
void InputMappingDialog::add_clicked()
{
- InputMapping::Input new_input;
- new_input.name = "New input";
- new_input.input_source_type = InputSourceType::SILENCE;
- mapping.inputs.push_back(new_input);
- ui->table->setRowCount(mapping.inputs.size());
-
- unsigned row = mapping.inputs.size() - 1;
- fill_row_from_input(row, new_input);
+ InputMapping::Bus new_bus;
+ new_bus.name = "New input";
+ new_bus.input_source_type = InputSourceType::SILENCE;
+ mapping.buses.push_back(new_bus);
+ ui->table->setRowCount(mapping.buses.size());
+
+ unsigned row = mapping.buses.size() - 1;
+ fill_row_from_bus(row, new_bus);
ui->table->editItem(ui->table->item(row, 0)); // Start editing the name.
}