void MidiProgramsEditor::slotNameChanged(const QString& programName) { const LineEdit* lineEdit = dynamic_cast<const LineEdit*>(sender()); if (!lineEdit) { RG_DEBUG << "MidiProgramsEditor::slotNameChanged() : %%% ERROR - signal sender is not a Rosegarden::LineEdit\n"; return ; } QString senderName = sender()->objectName(); // "Harpsichord" in default GM bank 1:0, "Coupled Harpsichord" in bank 8:0 // if (senderName == "7") std::cout << "senderName is: " << senderName.toStdString() // << " programName is: " << programName.toStdString() << std::endl; // Adjust value back to zero rated // unsigned int id = senderName.toUInt() - 1; // std::cout << "id is: " << id << std::endl; RG_DEBUG << "MidiProgramsEditor::slotNameChanged(" << programName << ") : id = " << id << endl; MidiBank* currBank; currBank = getCurrentBank(); if (!currBank) { RG_DEBUG << "Error: currBank is NULL in MidiProgramsEditor::slotNameChanged() " << endl; return; } else { RG_DEBUG << "currBank: " << currBank << endl; } RG_DEBUG << "current bank name: " << currBank->getName() << endl; MidiProgram *program = getProgram(*currBank, id); // MidiProgram *program = getProgram(*currBank, id); if (program == 0) { // Do nothing if program name is empty if (programName.isEmpty()) return ; program = new MidiProgram(*getCurrentBank(), id); m_programList.push_back(*program); // Sort the program list by id std::sort(m_programList.begin(), m_programList.end(), ProgramCmp()); // Now, get with the program // program = getProgram(*getCurrentBank(), id); } else { // If we've found a program and the label is now empty // then remove it from the program list. // if (programName.isEmpty()) { ProgramList::iterator it = m_programList.begin(); ProgramList tmpProg; for (; it != m_programList.end(); ++it) { if (((unsigned int)it->getProgram()) == id) { m_programList.erase(it); m_bankEditor->slotApply(); RG_DEBUG << "deleting empty program (" << id << ")" << endl; return ; } } } } if (!program) { RG_DEBUG << "Error: program is NULL in MidiProgramsEditor::slotNameChanged() " << endl; return; } else { RG_DEBUG << "program: " << program << endl; } if (qstrtostr(programName) != program->getName()) { program->setName(qstrtostr(programName)); m_bankEditor->slotApply(); } }
bool MIDIInstrumentParameterPanel::hasNoName(const MidiProgram &p) { return (p.getName() == ""); }