本文整理汇总了C++中QLCChannel::addCapability方法的典型用法代码示例。如果您正苦于以下问题:C++ QLCChannel::addCapability方法的具体用法?C++ QLCChannel::addCapability怎么用?C++ QLCChannel::addCapability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLCChannel
的用法示例。
在下文中一共展示了QLCChannel::addCapability方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeCapability
void QLCChannel_Test::removeCapability()
{
QLCChannel* channel = new QLCChannel();
QVERIFY(channel->capabilities().size() == 0);
QLCCapability* cap1 = new QLCCapability(10, 20, "10-20");
QVERIFY(channel->addCapability(cap1) == true);
QVERIFY(channel->capabilities().size() == 1);
QLCCapability* cap2 = new QLCCapability(0, 9, "0-9");
QVERIFY(channel->addCapability(cap2) == true);
QVERIFY(channel->capabilities().size() == 2);
QVERIFY(channel->removeCapability(cap2) == true);
QVERIFY(channel->capabilities().size() == 1);
/* cap2 is deleted by QLCChannel::removeCapability() */
QVERIFY(channel->removeCapability(cap2) == false);
QVERIFY(channel->capabilities().size() == 1);
QVERIFY(channel->removeCapability(cap1) == true);
QVERIFY(channel->capabilities().size() == 0);
/* cap1 is deleted by QLCChannel::removeCapability() */
delete channel;
}
示例2: addCapability
void QLCChannel_Test::addCapability()
{
QLCChannel* channel = new QLCChannel();
QVERIFY(channel->capabilities().size() == 0);
QLCCapability* cap1 = new QLCCapability(15, 19, "15-19");
QVERIFY(channel->addCapability(cap1) == true);
QVERIFY(channel->capabilities().size() == 1);
QVERIFY(channel->capabilities()[0] == cap1);
QLCCapability* cap2 = new QLCCapability(0, 9, "0-9");
QVERIFY(channel->addCapability(cap2) == true);
QVERIFY(channel->capabilities().size() == 2);
QVERIFY(channel->capabilities()[0] == cap1);
QVERIFY(channel->capabilities()[1] == cap2);
/* Completely overlapping with cap2 */
QLCCapability* cap3 = new QLCCapability(5, 6, "5-6");
QVERIFY(channel->addCapability(cap3) == false);
delete cap3;
cap3 = NULL;
/* Partially overlapping from low-end with cap1 */
QLCCapability* cap4 = new QLCCapability(19, 25, "19-25");
QVERIFY(channel->addCapability(cap4) == false);
delete cap4;
cap4 = NULL;
/* Partially overlapping from high end with cap1 */
QLCCapability* cap5 = new QLCCapability(10, 15, "10-15");
QVERIFY(channel->addCapability(cap5) == false);
delete cap5;
cap5 = NULL;
/* Partially overlapping with two ranges at both ends (cap1 & cap2) */
QLCCapability* cap6 = new QLCCapability(8, 16, "8-16");
QVERIFY(channel->addCapability(cap6) == false);
delete cap6;
cap6 = NULL;
/* Completely containing cap1 */
QLCCapability* cap7 = new QLCCapability(14, 20, "14-20");
QVERIFY(channel->addCapability(cap7) == false);
delete cap7;
cap7 = NULL;
/* Non-overlapping, between cap1 & cap2*/
QLCCapability* cap8 = new QLCCapability(10, 14, "10-14");
QVERIFY(channel->addCapability(cap8) == true);
/* Don't delete cap8 because it's now a member of the channel and gets
deleted from the channel's destructor. */
delete channel;
}
示例3: sortCapabilities
void QLCChannel_Test::sortCapabilities()
{
QLCChannel* channel = new QLCChannel();
QVERIFY(channel->capabilities().size() == 0);
QLCCapability* cap1 = new QLCCapability(10, 19, "10-19");
QVERIFY(channel->addCapability(cap1) == true);
QLCCapability* cap2 = new QLCCapability(50, 59, "50-59");
QVERIFY(channel->addCapability(cap2) == true);
QLCCapability* cap3 = new QLCCapability(40, 49, "40-49");
QVERIFY(channel->addCapability(cap3) == true);
QLCCapability* cap4 = new QLCCapability(0, 9, "0-9");
QVERIFY(channel->addCapability(cap4) == true);
QLCCapability* cap5 = new QLCCapability(200, 209, "200-209");
QVERIFY(channel->addCapability(cap5) == true);
QLCCapability* cap6 = new QLCCapability(30, 39, "30-39");
QVERIFY(channel->addCapability(cap6) == true);
QLCCapability* cap7 = new QLCCapability(26, 29, "26-29");
QVERIFY(channel->addCapability(cap7) == true);
QLCCapability* cap8 = new QLCCapability(20, 25, "20-25");
QVERIFY(channel->addCapability(cap8) == true);
QList <QLCCapability*> orig(channel->capabilities());
QVERIFY(orig.at(0) == cap1);
QVERIFY(orig.at(1) == cap2);
QVERIFY(orig.at(2) == cap3);
QVERIFY(orig.at(3) == cap4);
QVERIFY(orig.at(4) == cap5);
QVERIFY(orig.at(5) == cap6);
QVERIFY(orig.at(6) == cap7);
QVERIFY(orig.at(7) == cap8);
channel->sortCapabilities();
QList <QLCCapability*> sorted(channel->capabilities());
QVERIFY(sorted.at(0) == cap4);
QVERIFY(sorted.at(1) == cap1);
QVERIFY(sorted.at(2) == cap8);
QVERIFY(sorted.at(3) == cap7);
QVERIFY(sorted.at(4) == cap6);
QVERIFY(sorted.at(5) == cap3);
QVERIFY(sorted.at(6) == cap2);
QVERIFY(sorted.at(7) == cap5);
delete channel;
}
示例4: searchCapabilityByValue
void QLCChannel_Test::searchCapabilityByValue()
{
QLCChannel* channel = new QLCChannel();
QVERIFY(channel->capabilities().size() == 0);
QLCCapability* cap1 = new QLCCapability(0, 9, "0-9");
QVERIFY(channel->addCapability(cap1) == true);
QVERIFY(channel->capabilities().size() == 1);
QLCCapability* cap2 = new QLCCapability(10, 19, "10-19");
QVERIFY(channel->addCapability(cap2) == true);
QVERIFY(channel->capabilities().size() == 2);
QLCCapability* cap3 = new QLCCapability(20, 29, "20-29");
QVERIFY(channel->addCapability(cap3) == true);
QVERIFY(channel->capabilities().size() == 3);
QVERIFY(channel->searchCapability(0) == cap1);
QVERIFY(channel->searchCapability(1) == cap1);
QVERIFY(channel->searchCapability(2) == cap1);
QVERIFY(channel->searchCapability(3) == cap1);
QVERIFY(channel->searchCapability(4) == cap1);
QVERIFY(channel->searchCapability(5) == cap1);
QVERIFY(channel->searchCapability(6) == cap1);
QVERIFY(channel->searchCapability(7) == cap1);
QVERIFY(channel->searchCapability(8) == cap1);
QVERIFY(channel->searchCapability(9) == cap1);
QVERIFY(channel->searchCapability(10) == cap2);
QVERIFY(channel->searchCapability(11) == cap2);
QVERIFY(channel->searchCapability(12) == cap2);
QVERIFY(channel->searchCapability(13) == cap2);
QVERIFY(channel->searchCapability(14) == cap2);
QVERIFY(channel->searchCapability(15) == cap2);
QVERIFY(channel->searchCapability(16) == cap2);
QVERIFY(channel->searchCapability(17) == cap2);
QVERIFY(channel->searchCapability(18) == cap2);
QVERIFY(channel->searchCapability(19) == cap2);
QVERIFY(channel->searchCapability(30) == NULL);
delete channel;
}
示例5: searchCapabilityByName
void QLCChannel_Test::searchCapabilityByName()
{
QLCChannel* channel = new QLCChannel();
QVERIFY(channel->capabilities().size() == 0);
QLCCapability* cap1 = new QLCCapability(0, 9, "0-9");
QVERIFY(channel->addCapability(cap1) == true);
QLCCapability* cap2 = new QLCCapability(10, 19, "10-19");
QVERIFY(channel->addCapability(cap2) == true);
QLCCapability* cap3 = new QLCCapability(20, 29, "20-29");
QVERIFY(channel->addCapability(cap3) == true);
QVERIFY(channel->searchCapability("0-9") == cap1);
QVERIFY(channel->searchCapability("10-19") == cap2);
QVERIFY(channel->searchCapability("20-29") == cap3);
QVERIFY(channel->searchCapability("foo") == NULL);
delete channel;
}
示例6: QLCFixtureDef
QLCFixtureDef *Fixture::genericDimmerDef(int channels)
{
QLCFixtureDef *def = new QLCFixtureDef();
def->setManufacturer(KXMLFixtureGeneric);
def->setModel(KXMLFixtureGeneric);
def->setType(QLCFixtureDef::Dimmer);
def->setAuthor("QLC+");
for (int i = 0; i < channels; i++)
{
QLCChannel *intensity = new QLCChannel();
intensity->setGroup(QLCChannel::Intensity);
intensity->setName(tr("Dimmer #%1").arg(i + 1));
intensity->addCapability(new QLCCapability(0, UCHAR_MAX, tr("Intensity")));
def->addChannel(intensity);
}
return def;
}
示例7: save
void QLCChannel_Test::save()
{
QLCChannel* channel = new QLCChannel();
channel->setName("Foobar");
channel->setGroup(QLCChannel::Shutter);
channel->setControlByte(QLCChannel::LSB);
QLCCapability* cap1 = new QLCCapability(0, 9, "One");
QVERIFY(channel->addCapability(cap1) == true);
QLCCapability* cap2 = new QLCCapability(10, 19, "Two");
QVERIFY(channel->addCapability(cap2) == true);
QLCCapability* cap3 = new QLCCapability(20, 29, "Three");
QVERIFY(channel->addCapability(cap3) == true);
QLCCapability* cap4 = new QLCCapability(30, 39, "Four");
QVERIFY(channel->addCapability(cap4) == true);
QDomDocument doc;
QDomElement root = doc.createElement("TestRoot");
QVERIFY(channel->saveXML(&doc, &root) == true);
QVERIFY(root.firstChild().toElement().tagName() == "Channel");
QVERIFY(root.firstChild().toElement().attribute("Name") == "Foobar");
bool group = false;
bool capOne = false, capTwo = false, capThree = false, capFour = false;
QDomNode node = root.firstChild().firstChild();
while (node.isNull() == false)
{
QDomElement e = node.toElement();
if (e.tagName() == "Group")
{
group = true;
QVERIFY(e.attribute("Byte") == "1");
QVERIFY(e.text() == "Shutter");
}
else if (e.tagName() == "Capability")
{
if (e.text() == "One" && capOne == false)
capOne = true;
else if (e.text() == "Two" && capTwo == false)
capTwo = true;
else if (e.text() == "Three" && capThree == false)
capThree = true;
else if (e.text() == "Four" && capFour == false)
capFour = true;
else
QFAIL("Same capability saved multiple times");
}
else
{
QFAIL(QString("Unexpected tag: %1").arg(e.tagName())
.toAscii());
}
node = node.nextSibling();
}
QVERIFY(group == true);
QVERIFY(capOne == true);
QVERIFY(capTwo == true);
QVERIFY(capThree == true);
QVERIFY(capFour == true);
delete channel;
}
示例8: copy
void QLCChannel_Test::copy()
{
QLCChannel* channel = new QLCChannel();
QVERIFY(channel->capabilities().size() == 0);
channel->setName("Foobar");
channel->setGroup(QLCChannel::Tilt);
channel->setControlByte(QLCChannel::ControlByte(3));
channel->setColour(QLCChannel::Yellow);
QLCCapability* cap1 = new QLCCapability(10, 19, "10-19");
QVERIFY(channel->addCapability(cap1) == true);
QLCCapability* cap2 = new QLCCapability(50, 59, "50-59");
QVERIFY(channel->addCapability(cap2) == true);
QLCCapability* cap3 = new QLCCapability(40, 49, "40-49");
QVERIFY(channel->addCapability(cap3) == true);
QLCCapability* cap4 = new QLCCapability(0, 9, "0-9");
QVERIFY(channel->addCapability(cap4) == true);
QLCCapability* cap5 = new QLCCapability(200, 209, "200-209");
QVERIFY(channel->addCapability(cap5) == true);
QLCCapability* cap6 = new QLCCapability(30, 39, "30-39");
QVERIFY(channel->addCapability(cap6) == true);
QLCCapability* cap7 = new QLCCapability(26, 29, "26-29");
QVERIFY(channel->addCapability(cap7) == true);
QLCCapability* cap8 = new QLCCapability(20, 25, "20-25");
QVERIFY(channel->addCapability(cap8) == true);
/* Create a copy of the original channel */
QLCChannel* copy = new QLCChannel(channel);
QVERIFY(copy->name() == "Foobar");
QVERIFY(copy->group() == QLCChannel::Tilt);
QVERIFY(copy->controlByte() == QLCChannel::ControlByte(3));
QVERIFY(copy->colour() == QLCChannel::Yellow);
/* Verify that the capabilities in the copied channel are also
copies i.e. their pointers are not the same as the originals. */
QList <QLCCapability*> caps(copy->capabilities());
QVERIFY(caps.size() == 8);
QVERIFY(caps.at(0) != cap1);
QVERIFY(caps.at(0)->name() == cap1->name());
QVERIFY(caps.at(0)->min() == cap1->min());
QVERIFY(caps.at(0)->max() == cap1->max());
QVERIFY(caps.at(1) != cap2);
QVERIFY(caps.at(1)->name() == cap2->name());
QVERIFY(caps.at(1)->min() == cap2->min());
QVERIFY(caps.at(1)->max() == cap2->max());
QVERIFY(caps.at(2) != cap3);
QVERIFY(caps.at(2)->name() == cap3->name());
QVERIFY(caps.at(2)->min() == cap3->min());
QVERIFY(caps.at(2)->max() == cap3->max());
QVERIFY(caps.at(3) != cap4);
QVERIFY(caps.at(3)->name() == cap4->name());
QVERIFY(caps.at(3)->min() == cap4->min());
QVERIFY(caps.at(3)->max() == cap4->max());
QVERIFY(caps.at(4) != cap5);
QVERIFY(caps.at(4)->name() == cap5->name());
QVERIFY(caps.at(4)->min() == cap5->min());
QVERIFY(caps.at(4)->max() == cap5->max());
QVERIFY(caps.at(5) != cap6);
QVERIFY(caps.at(5)->name() == cap6->name());
QVERIFY(caps.at(5)->min() == cap6->min());
QVERIFY(caps.at(5)->max() == cap6->max());
QVERIFY(caps.at(6) != cap7);
QVERIFY(caps.at(6)->name() == cap7->name());
QVERIFY(caps.at(6)->min() == cap7->min());
QVERIFY(caps.at(6)->max() == cap7->max());
QVERIFY(caps.at(7) != cap8);
QVERIFY(caps.at(7)->name() == cap8->name());
QVERIFY(caps.at(7)->min() == cap8->min());
QVERIFY(caps.at(7)->max() == cap8->max());
}
示例9: save
void QLCChannel_Test::save()
{
QLCChannel* channel = new QLCChannel();
channel->setName("Foobar");
channel->setGroup(QLCChannel::Shutter);
channel->setControlByte(QLCChannel::LSB);
QLCCapability* cap1 = new QLCCapability(0, 9, "One");
QVERIFY(channel->addCapability(cap1) == true);
QLCCapability* cap2 = new QLCCapability(10, 19, "Two");
QVERIFY(channel->addCapability(cap2) == true);
QLCCapability* cap3 = new QLCCapability(20, 29, "Three");
QVERIFY(channel->addCapability(cap3) == true);
QLCCapability* cap4 = new QLCCapability(30, 39, "Four");
QVERIFY(channel->addCapability(cap4) == true);
QBuffer buffer;
buffer.open(QIODevice::WriteOnly | QIODevice::Text);
QXmlStreamWriter xmlWriter(&buffer);
QVERIFY(channel->saveXML(&xmlWriter) == true);
xmlWriter.setDevice(NULL);
buffer.close();
buffer.open(QIODevice::ReadOnly | QIODevice::Text);
QXmlStreamReader xmlReader(&buffer);
xmlReader.readNextStartElement();
QVERIFY(xmlReader.name().toString() == "Channel");
QVERIFY(xmlReader.attributes().value("Name").toString() == "Foobar");
bool group = false;
bool capOne = false, capTwo = false, capThree = false, capFour = false;
while (xmlReader.readNextStartElement())
{
if (xmlReader.name() == "Group")
{
group = true;
QVERIFY(xmlReader.attributes().value("Byte").toString() == "1");
QVERIFY(xmlReader.readElementText() == "Shutter");
}
else if (xmlReader.name() == "Capability")
{
QString capName = xmlReader.readElementText();
if (capName == "One" && capOne == false)
capOne = true;
else if (capName == "Two" && capTwo == false)
capTwo = true;
else if (capName == "Three" && capThree == false)
capThree = true;
else if (capName == "Four" && capFour == false)
capFour = true;
else
QFAIL("Same capability saved multiple times");
}
else
{
QFAIL(QString("Unexpected tag: %1").arg(xmlReader.name().toString())
.toLatin1());
xmlReader.skipCurrentElement();
}
}
QVERIFY(group == true);
QVERIFY(capOne == true);
QVERIFY(capTwo == true);
QVERIFY(capThree == true);
QVERIFY(capFour == true);
delete channel;
}