void QLCInputProfile_Test::load() { QBuffer buffer; buffer.open(QIODevice::WriteOnly | QIODevice::Text); QXmlStreamWriter xmlWriter(&buffer); xmlWriter.writeStartDocument(); xmlWriter.writeDTD("<!DOCTYPE InputProfile>"); xmlWriter.writeStartElement("InputProfile"); xmlWriter.writeTextElement("Manufacturer", "Behringer"); xmlWriter.writeTextElement("Model", "BCF2000"); xmlWriter.writeStartElement("Channel"); xmlWriter.writeAttribute("Number", "492"); xmlWriter.writeTextElement("Name", "Foobar"); xmlWriter.writeTextElement("Type", "Slider"); xmlWriter.writeEndDocument(); xmlWriter.setDevice(NULL); buffer.close(); buffer.open(QIODevice::ReadOnly | QIODevice::Text); QXmlStreamReader xmlReader(&buffer); QLCInputProfile ip; QVERIFY(ip.loadXML(xmlReader) == true); QVERIFY(ip.manufacturer() == "Behringer"); QVERIFY(ip.model() == "BCF2000"); QVERIFY(ip.channels().size() == 1); QVERIFY(ip.channel(492) != NULL); QVERIFY(ip.channel(492)->name() == "Foobar"); QVERIFY(ip.channel(492)->type() == QLCInputChannel::Slider); }
void QLCInputProfile_Test::removeChannel() { QLCInputProfile ip; QLCInputChannel* ich1 = new QLCInputChannel(); ip.insertChannel(0, ich1); QVERIFY(ip.channel(0) == ich1); QLCInputChannel* ich2 = new QLCInputChannel(); ip.insertChannel(5, ich2); QVERIFY(ip.channel(0) == ich1); QVERIFY(ip.channel(5) == ich2); QVERIFY(ip.removeChannel(1) == false); QVERIFY(ip.removeChannel(2) == false); QVERIFY(ip.removeChannel(3) == false); QVERIFY(ip.removeChannel(4) == false); QVERIFY(ip.channel(0) == ich1); QVERIFY(ip.channel(5) == ich2); QVERIFY(ip.removeChannel(0) == true); QVERIFY(ip.channel(0) == NULL); QVERIFY(ip.channel(5) == ich2); QVERIFY(ip.removeChannel(5) == true); QVERIFY(ip.channel(0) == NULL); QVERIFY(ip.channel(5) == NULL); }
void QLCInputProfile_Test::assign() { QLCInputProfile ip; ip.setManufacturer("Behringer"); ip.setModel("BCF2000"); QLCInputChannel* ich1 = new QLCInputChannel; ich1->setName("Channel 1"); ip.insertChannel(0, ich1); QLCInputChannel* ich2 = new QLCInputChannel; ich2->setName("Channel 2"); ip.insertChannel(5, ich2); QLCInputChannel* ich3 = new QLCInputChannel; ich3->setName("Channel 3"); ip.insertChannel(2, ich3); QLCInputChannel* ich4 = new QLCInputChannel; ich4->setName("Channel 4"); ip.insertChannel(9000, ich4); QLCInputProfile ip2; QLCInputChannel* ich5 = new QLCInputChannel; ich5->setName("First channel"); ip2.insertChannel(0, ich5); QCOMPARE(ip2.channels().size(), 1); /* Test the assignment operator */ ip2 = ip; QCOMPARE(ip2.channels().size(), 4); QVERIFY(ip2.channel(0) != NULL); QVERIFY(ip2.channel(0) != ich1); QVERIFY(ip2.channel(0) != ip.channel(0)); QCOMPARE(ip2.channel(0)->name(), QString("Channel 1")); QVERIFY(ip2.channel(5) != NULL); QVERIFY(ip2.channel(5) != ich2); QVERIFY(ip2.channel(5) != ip.channel(5)); QCOMPARE(ip2.channel(5)->name(), QString("Channel 2")); QVERIFY(ip2.channel(2) != NULL); QVERIFY(ip2.channel(2) != ich3); QVERIFY(ip2.channel(2) != ip.channel(2)); QCOMPARE(ip2.channel(2)->name(), QString("Channel 3")); QVERIFY(ip2.channel(9000) != NULL); QVERIFY(ip2.channel(9000) != ich4); QVERIFY(ip2.channel(9000) != ip.channel(9000)); QCOMPARE(ip2.channel(9000)->name(), QString("Channel 4")); }
void GrandMasterSlider::sendFeedback() { quint32 universe = VirtualConsole::instance()->properties().grandMasterInputUniverse(); quint32 channel = VirtualConsole::instance()->properties().grandMasterInputChannel(); QString chName; if (universe == InputOutputMap::invalidUniverse() || channel == QLCChannel::invalid()) return; InputPatch* pat = m_ioMap->inputPatch(universe); if (pat != NULL) { QLCInputProfile* profile = pat->profile(); if (profile != NULL) { QLCInputChannel* ich = profile->channel(channel); if (ich != NULL) chName = ich->name(); } } if (m_slider->invertedAppearance()) m_ioMap->sendFeedBack(universe, channel, UCHAR_MAX - m_slider->value(), chName); else m_ioMap->sendFeedBack(universe, channel, m_slider->value(), chName); }
void QLCInputProfile_Test::addChannel() { QLCInputProfile ip; QLCInputChannel* ich1 = new QLCInputChannel(); ip.insertChannel(0, ich1); QVERIFY(ip.channel(0) == ich1); QVERIFY(ip.channels().size() == 1); /* Shouldn't overwrite the existing mapping */ QLCInputChannel* ich2 = new QLCInputChannel(); ip.insertChannel(0, ich2); QVERIFY(ip.channel(0) == ich1); ip.insertChannel(5, ich2); QVERIFY(ip.channel(0) == ich1); QVERIFY(ip.channel(1) == NULL); QVERIFY(ip.channel(2) == NULL); QVERIFY(ip.channel(3) == NULL); QVERIFY(ip.channel(4) == NULL); QVERIFY(ip.channel(5) == ich2); }
void QLCInputProfile_Test::load() { QDomDocument doc; QDomElement profile = doc.createElement("InputProfile"); QDomElement manuf = doc.createElement("Manufacturer"); QDomText manufText = doc.createTextNode("Behringer"); manuf.appendChild(manufText); profile.appendChild(manuf); QDomElement model = doc.createElement("Model"); QDomText modelText = doc.createTextNode("BCF2000"); model.appendChild(modelText); profile.appendChild(model); doc.appendChild(profile); QDomElement ch = doc.createElement("Channel"); ch.setAttribute("Number", 492); profile.appendChild(ch); QDomElement name = doc.createElement("Name"); QDomText nameText = doc.createTextNode("Foobar"); name.appendChild(nameText); ch.appendChild(name); QDomElement type = doc.createElement("Type"); QDomText typeText = doc.createTextNode("Slider"); type.appendChild(typeText); ch.appendChild(type); QLCInputProfile ip; QVERIFY(ip.loadXML(&doc) == true); QVERIFY(ip.manufacturer() == "Behringer"); QVERIFY(ip.model() == "BCF2000"); QVERIFY(ip.channels().size() == 1); QVERIFY(ip.channel(492) != NULL); QVERIFY(ip.channel(492)->name() == "Foobar"); QVERIFY(ip.channel(492)->type() == QLCInputChannel::Slider); }
void QLCInputProfile_Test::copy() { QLCInputProfile ip; ip.setManufacturer("Behringer"); ip.setModel("BCF2000"); QLCInputChannel* ich1 = new QLCInputChannel(); ich1->setName("Channel 1"); ip.insertChannel(0, ich1); QLCInputChannel* ich2 = new QLCInputChannel(); ich2->setName("Channel 2"); ip.insertChannel(5, ich2); QLCInputChannel* ich3 = new QLCInputChannel(); ich3->setName("Channel 3"); ip.insertChannel(2, ich3); QLCInputChannel* ich4 = new QLCInputChannel(); ich4->setName("Channel 4"); ip.insertChannel(9000, ich4); QLCInputProfile copy = ip; QVERIFY(copy.manufacturer() == "Behringer"); QVERIFY(copy.model() == "BCF2000"); QVERIFY(copy.channels().size() == 4); /* Verify that it's a deep copy */ QVERIFY(copy.channel(0) != ich1); QVERIFY(copy.channel(0) != NULL); QVERIFY(copy.channel(0)->name() == "Channel 1"); QVERIFY(copy.channel(5) != ich2); QVERIFY(copy.channel(5) != NULL); QVERIFY(copy.channel(5)->name() == "Channel 2"); QVERIFY(copy.channel(2) != ich3); QVERIFY(copy.channel(2) != NULL); QVERIFY(copy.channel(2)->name() == "Channel 3"); QVERIFY(copy.channel(9000) != ich4); QVERIFY(copy.channel(9000) != NULL); QVERIFY(copy.channel(9000)->name() == "Channel 4"); }
bool VCPropertiesEditor::inputSourceNames(quint32 universe, quint32 channel, QString& uniName, QString& chName) const { if (universe == InputMap::invalidUniverse() || channel == InputMap::invalidChannel()) { /* Nothing selected for input universe and/or channel */ return false; } InputPatch* patch = m_inputMap->patch(universe); if (patch == NULL || patch->plugin() == NULL) { /* There is no patch for the given universe */ return false; } QLCInputProfile* profile = patch->profile(); if (profile == NULL) { /* There is no profile. Display plugin name and channel number. Boring. */ uniName = patch->plugin()->name(); chName = tr("%1: Unknown").arg(channel + 1); } else { QLCInputChannel* ich; QString name; /* Display profile name for universe */ uniName = QString("%1: %2").arg(universe + 1).arg(profile->name()); /* User can input the channel number by hand, so put something rational to the channel name in those cases as well. */ ich = profile->channel(channel); if (ich != NULL) name = ich->name(); else name = tr("Unknown"); /* Display channel name */ chName = QString("%1: %2").arg(channel + 1).arg(name); } return true; }
bool InputMap::inputSourceNames(const QLCInputSource& src, QString& uniName, QString& chName) const { if (src.isValid() == false) return false; InputPatch* pat = this->patch(src.universe()); if (pat == NULL) { /* There is no patch for the given universe */ return false; } QLCInputProfile* profile = pat->profile(); if (profile == NULL) { /* There is no profile. Display plugin name and channel number. */ if (pat->plugin() != NULL) uniName = QString("%1: %2").arg(src.universe() + 1).arg(pat->plugin()->name()); else uniName = QString("%1: ??").arg(src.universe() + 1); chName = QString("%1: ?").arg(src.channel() + 1); } else { QLCInputChannel* ich; QString name; /* Display profile name for universe */ uniName = QString("%1: %2").arg(src.universe() + 1).arg(profile->name()); /* User can input the channel number by hand, so put something rational to the channel name in those cases as well. */ ich = profile->channel(src.channel()); if (ich != NULL) name = ich->name(); else name = QString("?"); /* Display channel name */ chName = QString("%1: %2").arg(src.channel() + 1).arg(name); } return true; }
void VCSliderProperties::updateInputSource() { QLCInputProfile* profile; InputPatch* patch; QString uniName; QString chName; if (m_inputUniverse == InputMap::invalidUniverse() || m_inputChannel == InputMap::invalidChannel()) { /* Nothing selected for input universe and/or channel */ uniName = KInputNone; chName = KInputNone; } else { patch = m_inputMap->patch(m_inputUniverse); if (patch == NULL || patch->plugin() == NULL) { /* There is no patch for the given universe */ uniName = KInputNone; chName = KInputNone; } else { profile = patch->profile(); if (profile == NULL) { /* There is no profile. Display plugin name and channel number. Boring. */ uniName = patch->plugin()->name(); chName = tr("%1: Unknown") .arg(m_inputChannel + 1); } else { QLCInputChannel* ich; QString name; /* Display profile name for universe */ uniName = QString("%1: %2") .arg(m_inputUniverse + 1) .arg(profile->name()); /* User can input the channel number by hand, so put something rational to the channel name in those cases as well. */ ich = profile->channel(m_inputChannel); if (ich != NULL) name = ich->name(); else name = tr("Unknown"); /* Display channel name */ chName = QString("%1: %2") .arg(m_inputChannel + 1).arg(name); } } } /* Display the gathered information */ m_inputUniverseEdit->setText(uniName); m_inputChannelEdit->setText(chName); }
void QLCInputProfile_Test::remapChannel() { QLCInputProfile ip; QLCInputChannel* ich1 = new QLCInputChannel(); ich1->setName("Foobar"); ip.insertChannel(0, ich1); QVERIFY(ip.channel(0) == ich1); QLCInputChannel* ich2 = new QLCInputChannel(); ip.insertChannel(5, ich2); QVERIFY(ip.channel(0) == ich1); QVERIFY(ip.channel(5) == ich2); QVERIFY(ip.remapChannel(ich1, 9000) == true); QVERIFY(ip.channel(0) == NULL); QVERIFY(ip.channel(5) == ich2); QVERIFY(ip.channel(9000) == ich1); QVERIFY(ip.channel(9000)->name() == "Foobar"); QVERIFY(ip.remapChannel(NULL, 9000) == false); QVERIFY(ip.channels().size() == 2); QVERIFY(ip.channel(0) == NULL); QVERIFY(ip.channel(5) == ich2); QVERIFY(ip.channel(9000) == ich1); QVERIFY(ip.channel(9000)->name() == "Foobar"); QLCInputChannel* ich3 = new QLCInputChannel(); QVERIFY(ip.remapChannel(ich3, 5) == false); QVERIFY(ip.channels().size() == 2); QVERIFY(ip.channel(0) == NULL); QVERIFY(ip.channel(5) == ich2); QVERIFY(ip.channel(9000) == ich1); QVERIFY(ip.channel(9000)->name() == "Foobar"); delete ich3; }