void LightingPresets::OnCopyLightingPreset(wxCommandEvent &WXUNUSED(event)) { wxASSERT_MSG(presets.size() != 0, _T("presets have not been initialized")); wxCHECK_RET(ProfileProxy::GetProxy()->HasLightingPreset(), _T("copy lighting preset button pressed with no preset stored in profile")); wxString presetName(ProfileProxy::GetProxy()->GetLightingPresetName()); wxCHECK_RET(presetName != presets[ID_PRESETS_OFF].GetName(), _T("copy lighting preset button pressed when 'presets off' is selected")); wxLogDebug(_T("attempting to copy preset named %s to custom flags"), presetName.c_str()); ProfileProxy::GetProxy()->CopyPresetToCustomFlags(); this->Reset(); }
void DlgPrefController::slotPresetLoaded(ControllerPresetPointer preset) { m_ui.labelLoadedPreset->setText(presetName(preset)); m_ui.labelLoadedPresetDescription->setText(presetDescription(preset)); m_ui.labelLoadedPresetAuthor->setText(presetAuthor(preset)); QStringList supportLinks; QString forumLink = presetForumLink(preset); if (forumLink.length() > 0) { supportLinks << forumLink; } QString wikiLink = presetWikiLink(preset); if (wikiLink.length() > 0) { supportLinks << wikiLink; } // There is always at least one support link. // TODO(rryan): This is a horrible general support link for MIDI! QString troubleShooting = QString( "<a href=\"http://mixxx.org/wiki/doku.php/midi_scripting\">%1</a>") .arg(tr("Troubleshooting")); supportLinks << troubleShooting; QString support = supportLinks.join(" "); m_ui.labelLoadedPresetSupportLinks->setText(support); // We mutate this preset so keep a reference to it while we are using it. // TODO(rryan): Clone it? Technically a waste since nothing else uses this // copy but if someone did they might not expect it to change. m_pPreset = preset; ControllerInputMappingTableModel* pInputModel = new ControllerInputMappingTableModel(this); // If the model reports changes, mark ourselves as dirty. connect(pInputModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(slotDirty())); connect(pInputModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(slotDirty())); connect(pInputModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(slotDirty())); pInputModel->setPreset(preset); QSortFilterProxyModel* pInputProxyModel = new QSortFilterProxyModel(this); pInputProxyModel->setSortRole(Qt::UserRole); pInputProxyModel->setSourceModel(pInputModel); m_ui.m_pInputMappingTableView->setModel(pInputProxyModel); for (int i = 0; i < pInputModel->columnCount(); ++i) { QAbstractItemDelegate* pDelegate = pInputModel->delegateForColumn( i, m_ui.m_pInputMappingTableView); if (pDelegate != NULL) { qDebug() << "Setting input delegate for column" << i << pDelegate; m_ui.m_pInputMappingTableView->setItemDelegateForColumn(i, pDelegate); } } // Now that we have set the new model our old model can be deleted. delete m_pInputProxyModel; m_pInputProxyModel = pInputProxyModel; delete m_pInputTableModel; m_pInputTableModel = pInputModel; ControllerOutputMappingTableModel* pOutputModel = new ControllerOutputMappingTableModel(this); pOutputModel->setPreset(preset); QSortFilterProxyModel* pOutputProxyModel = new QSortFilterProxyModel(this); pOutputProxyModel->setSortRole(Qt::UserRole); pOutputProxyModel->setSourceModel(pOutputModel); m_ui.m_pOutputMappingTableView->setModel(pOutputProxyModel); for (int i = 0; i < pOutputModel->columnCount(); ++i) { QAbstractItemDelegate* pDelegate = pOutputModel->delegateForColumn( i, m_ui.m_pOutputMappingTableView); if (pDelegate != NULL) { qDebug() << "Setting output delegate for column" << i << pDelegate; m_ui.m_pOutputMappingTableView->setItemDelegateForColumn(i, pDelegate); } } // Now that we have set the new model our old model can be deleted. delete m_pOutputProxyModel; m_pOutputProxyModel = pOutputProxyModel; delete m_pOutputTableModel; m_pOutputTableModel = pOutputModel; // Populate the script tab with the scripts this preset uses. m_ui.m_pScriptsTableWidget->setRowCount(preset->scripts.length()); m_ui.m_pScriptsTableWidget->setColumnCount(3); m_ui.m_pScriptsTableWidget->setHorizontalHeaderItem( 0, new QTableWidgetItem(tr("Filename"))); m_ui.m_pScriptsTableWidget->setHorizontalHeaderItem( 1, new QTableWidgetItem(tr("Function Prefix"))); m_ui.m_pScriptsTableWidget->setHorizontalHeaderItem( 2, new QTableWidgetItem(tr("Built-in"))); m_ui.m_pScriptsTableWidget->horizontalHeader() ->setResizeMode(QHeaderView::Stretch); for (int i = 0; i < preset->scripts.length(); ++i) { const ControllerPreset::ScriptFileInfo& script = preset->scripts.at(i); QTableWidgetItem* pScriptName = new QTableWidgetItem(script.name); m_ui.m_pScriptsTableWidget->setItem(i, 0, pScriptName); pScriptName->setFlags(pScriptName->flags() & ~Qt::ItemIsEditable); QTableWidgetItem* pScriptPrefix = new QTableWidgetItem( script.functionPrefix); m_ui.m_pScriptsTableWidget->setItem(i, 1, pScriptPrefix); // If the script is built-in don't allow editing of the prefix. if (script.builtin) { pScriptPrefix->setFlags(pScriptPrefix->flags() & ~Qt::ItemIsEditable); } QTableWidgetItem* pScriptBuiltin = new QTableWidgetItem(); pScriptBuiltin->setCheckState(script.builtin ? Qt::Checked : Qt::Unchecked); pScriptBuiltin->setFlags(pScriptBuiltin->flags() & ~(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsUserCheckable)); m_ui.m_pScriptsTableWidget->setItem(i, 2, pScriptBuiltin); } }