コード例 #1
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
void QLCChannel_Test::name()
{
    /* Verify that a name can be set & get for the channel */
    QLCChannel* channel = new QLCChannel();
    QVERIFY(channel->name().isEmpty());

    channel->setName("Channel");
    QVERIFY(channel->name() == "Channel");

    delete channel;
}
コード例 #2
0
ファイル: editmode.cpp プロジェクト: speakman/qlc
void EditMode::slotAddChannelClicked()
{
	QPtrListIterator<QLCChannel> it(*m_mode->fixtureDef()->channels());
	QLCChannel* ch = NULL;
	QStringList list;
	bool ok = false;
	QString name;
	int index = 0;

	/* Create a list of channels that have not been added to this mode yet */
	while ( (ch = it.current()) != 0 )
	{
		++it;
		if (m_mode->searchChannel(ch->name()) != NULL)
			continue;
		else
			list.append(ch->name());
	}
	
	name = QInputDialog::getItem("Add channel to mode", 
				     "Select a channel to add",
				     list, 0, false, &ok, this);
	
	if (ok == true && name.isEmpty() == false)
	{
		QListViewItem* item = NULL;
		int insertat = 0;
		
		ch = m_mode->fixtureDef()->channel(name);

		// Find out the current channel number
		item = m_channelList->currentItem();
		if (item != NULL)
			insertat = item->text(KChannelsColumnNumber).toInt() - 1;
		else
			insertat = 0;
		
		// Insert the item at current selection
		m_mode->insertChannel(ch, insertat);
		
		// Easier to refresh the whole list than to increment all
		// channel numbers after the inserted item
		refreshChannelList();
		
		// Select the new channel
		selectChannel(ch->name());
	}
}
コード例 #3
0
ファイル: fixtureeditor.cpp プロジェクト: ChrisLaurie/qlcplus
void QLCFixtureEditor::slotRemoveChannel()
{
    QLCChannel* channel = currentChannel();
    Q_ASSERT(channel != NULL);

    if (QMessageBox::question(this, "Remove Channel",
                              tr("Are you sure you wish to remove channel: %1 ?")
                              .arg(channel->name()),
                              QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
    {
        QTreeWidgetItem* item;
        QTreeWidgetItem* next;

        item = m_channelList->currentItem();
        if (m_channelList->itemBelow(item) != NULL)
            next = m_channelList->itemBelow(item);
        else if (m_channelList->itemAbove(item) != NULL)
            next = m_channelList->itemAbove(item);
        else
            next = NULL;

        // Remove the selected channel from the fixture (also deleted)
        m_fixtureDef->removeChannel(currentChannel());
        delete item;

        m_channelList->setCurrentItem(next);
        setModified();
    }
}
コード例 #4
0
ファイル: fixtureeditor.cpp プロジェクト: speakman/qlc
void QLCFixtureEditor::refreshChannelList()
{
	QLCChannel* ch = NULL;
	QTreeWidgetItem* item = NULL;
	QString str;

	m_channelList->clear();

	// Fill channels list
	QListIterator <QLCChannel*> it(*m_fixtureDef->channels());
	while (it.hasNext() == true)
	{
		ch = it.next();

		item = new QTreeWidgetItem(m_channelList);
		item->setText(KChannelsColumnName, ch->name());
		item->setText(KChannelsColumnGroup, ch->group());

		// Store the channel pointer to the listview as a string
		str.sprintf("%lu", (unsigned long) ch);
		item->setText(KChannelsColumnPointer, str);
	}
	
	slotChannelListSelectionChanged(m_channelList->currentItem());
}
コード例 #5
0
ファイル: fixtureeditor.cpp プロジェクト: ChrisLaurie/qlcplus
void QLCFixtureEditor::slotPasteChannel()
{
    QLCChannel* ch = _app->copyChannel();
    if (ch != NULL && m_fixtureDef != NULL)
    {
        /* Create new mode and an item for it */
        QTreeWidgetItem* item;
        QLCChannel* copy;

        copy = new QLCChannel(ch);
        item = new QTreeWidgetItem(m_channelList);

        int cpIdx = 1;
        QString copyName;
        do
        {
            copyName = QString("%1 %2").arg(ch->name()).arg(cpIdx);
            cpIdx++;
        } while (m_fixtureDef->channel(copyName) != NULL);

        copy->setName(copyName);

        m_fixtureDef->addChannel(copy);
        updateChannelItem(copy, item);
        m_channelList->setCurrentItem(item);
        m_channelList->resizeColumnToContents(CH_COL_NAME);

        setModified();
    }
}
コード例 #6
0
ファイル: fixtureeditor.cpp プロジェクト: ChrisLaurie/qlcplus
void QLCFixtureEditor::updateModeItem(const QLCFixtureMode* mode,
                                      QTreeWidgetItem* item)
{
    Q_ASSERT(mode != NULL);
    Q_ASSERT(item != NULL);

    item->setText(MODE_COL_NAME, mode->name());
    item->setData(MODE_COL_NAME, PROP_PTR, (qulonglong) mode);
    item->setText(MODE_COL_CHS, QString::number(mode->channels().size()));
    if (mode->heads().size() > 0)
        item->setText(MODE_COL_HEAD, QString::number(mode->heads().size()));
    else
        item->setText(MODE_COL_HEAD, QString());

    /* Destroy the existing list of children */
    QList <QTreeWidgetItem*> children(item->takeChildren());
    foreach (QTreeWidgetItem* child, children)
    delete child;

    /* Put all mode channels as non-selectable sub items */
    for (int i = 0; i < mode->channels().size(); i++)
    {
        QLCChannel* ch = mode->channel(i);
        Q_ASSERT(ch != NULL);

        QTreeWidgetItem* chitem = new QTreeWidgetItem(item);
        chitem->setText(MODE_COL_NAME, ch->name());
        chitem->setIcon(MODE_COL_NAME, ch->getIcon());
        chitem->setText(MODE_COL_CHS, QString("%1").arg(i + 1));
        chitem->setFlags(0); /* No selection etc. */
    }
}
コード例 #7
0
ファイル: fixturelist.cpp プロジェクト: speakman/qlc
void FixtureList::init()
{
	QTreeWidgetItem* item;
	
	m_listView->clear();

	connect(m_listView, SIGNAL(itemSelectionChanged()),
		this, SLOT(slotSelectionChanged()));
	connect(m_listView, SIGNAL(itemDoubleClicked(QTreeWidgetItem*)),
		this, SLOT(slotItemDoubleClicked()));
	
	for (t_fixture_id fxi_id = 0; fxi_id < KFixtureArraySize; fxi_id++)
	{
		Fixture* fxi = _app->doc()->fixture(fxi_id);
		if (fxi == NULL)
			continue;

		for (unsigned int n = 0; n < fxi->channels(); n++)
		{
			QLCChannel* channel;
			QString s;

			// Create a new item for a channel
			item = new QTreeWidgetItem(m_listView);

			// Fixture name
			item->setText(KColumnFixtureName, fxi->name());
			
			// Channel name
			channel = fxi->channel(n);
			if (channel != NULL)
			{
				s.sprintf("%.3d: ", n + 1);
				s += channel->name();
				item->setText(KColumnChannelName, s);
			}
			else
			{
				delete item;
				break;
			}
			
			// Relative channel number (not shown)
			s.sprintf("%.3d", n);
			item->setText(KColumnChannelNum, s);
			
			// Fixture ID (not shown)
			item->setText(KColumnFixtureID,
				      QString("%1").arg(fxi_id));
		}   
	}
	
	/* Select the first item */
	item = m_listView->topLevelItem(0);
	if (item != NULL)
		item->setSelected(true);
}
コード例 #8
0
ファイル: editmode.cpp プロジェクト: speakman/qlc
void EditMode::slotAddChannelClicked()
{
	QLCChannel* ch;

	/* Create a list of channels that haven't been added to this mode yet */
	QStringList chlist;
	QListIterator <QLCChannel*> it(m_mode->fixtureDef()->channels());
	while (it.hasNext() == true)
	{
		ch = it.next();
		if (m_mode->channel(ch->name()) != NULL)
			continue;
		else
			chlist << ch->name();
	}

	if (chlist.size() > 0)
	{
		bool ok = false;
		QString name = QInputDialog::getItem(this,
						tr("Add channel to mode"), 
						tr("Select a channel to add"),
						chlist, 0, false, &ok);

		if (ok == true && name.isEmpty() == false)
		{
			ch = m_mode->fixtureDef()->channel(name);

			// Append the channel
			m_mode->insertChannel(ch, m_mode->channels().size());

			// Easier to refresh the whole list
			refreshChannelList();

			// Select the new channel
			selectChannel(ch->name());
		}
	}
	else
	{
		QMessageBox::information(this, tr("No more available channels"),
			tr("All available channels are present in the mode."));
	}
}
コード例 #9
0
ファイル: fixturelist.cpp プロジェクト: speakman/qlc
void FixtureList::init()
{
	QListViewItem* item = NULL;
	QLCChannel* channel = NULL;
	Fixture* fxi = NULL;
	unsigned int n = 0;
	QString fxi_id;
	QString s;
	
	m_listView->clear();
	
	for (t_fixture_id i = 0; i < KFixtureArraySize; i++)
	{
		fxi = _app->doc()->fixture(i);
		if (fxi == NULL)
			continue;

		fxi_id.setNum(fxi->id());
		
		for (n = 0; n < fxi->channels(); n++)
		{
			// Create a new item for a channel
			item = new QListViewItem(m_listView);

			// Fixture name
			item->setText(KColumnFixtureName, fxi->name());
			
			// Channel name
			channel = fxi->channel(n);
			if (channel != NULL)
			{
				s.sprintf("%.3d: ", n + 1);
				s += channel->name();
				item->setText(KColumnChannelName, s);
			}
			else
			{
				delete item;
				break;
			}
			
			// Relative channel number (not shown)
			s.sprintf("%.3d", n);
			item->setText(KColumnChannelNum, s);
			
			// Fixture ID (not shown)
			item->setText(KColumnFixtureID, fxi_id);
		}   
	}
	
	m_listView->setSelected(m_listView->firstChild(), true);
}
コード例 #10
0
ファイル: qlcfixturemode.cpp プロジェクト: PML369/qlcplus
QLCChannel* QLCFixtureMode::channel(const QString& name) const
{
    QVectorIterator <QLCChannel*> it(m_channels);
    while (it.hasNext() == true)
    {
        QLCChannel* ch = it.next();
        Q_ASSERT(ch != NULL);
        if (ch->name() == name)
            return ch;
    }

    return NULL;
}
コード例 #11
0
ファイル: qlcfixturedef.cpp プロジェクト: PML369/qlcplus
QLCChannel* QLCFixtureDef::channel(const QString& name)
{
    QListIterator <QLCChannel*> it(m_channels);
    QLCChannel* ch = NULL;

    while (it.hasNext() == true)
    {
        ch = it.next();
        if (ch->name() == name)
            return ch;
    }

    return NULL;
}
コード例 #12
0
ファイル: qlcfixturemode.cpp プロジェクト: PML369/qlcplus
QLCFixtureMode& QLCFixtureMode::operator=(const QLCFixtureMode& mode)
{
    if (this != &mode)
    {
        m_name = mode.m_name;
        m_physical = mode.m_physical;
        m_heads = mode.m_heads;

        /* Clear the existing list of channels */
        m_channels.clear();

        Q_ASSERT(m_fixtureDef != NULL);

        quint32 i = 0;
        QVectorIterator <QLCChannel*> it(mode.m_channels);
        while (it.hasNext() == true)
        {
            /* Since m_fixtureDef might not be the same as
               mode.m_fixtureDef, we need to search for a
               channel with the same name from m_fixtureDef and
               not from mode.m_fixtureDef. If the channel in the
               other mode is deleted, the one in this copied mode
               will be invalid and we end up in a crash. */
            QLCChannel* ch = it.next();
            QLCChannel* actual = m_fixtureDef->channel(ch->name());
            if (actual != NULL)
                insertChannel(actual, i++);
            else
                qWarning() << Q_FUNC_INFO << "Unable to find channel"
                           << ch->name() << "for mode"
                           << m_name << "from its fixture definition";
        }
    }

    return *this;
}
コード例 #13
0
void QLCChannel_Test::loadWrongRoot()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("Chanel");
    xmlWriter.writeAttribute("Name", "Channel1");

    xmlWriter.writeStartElement("Group");
    xmlWriter.writeAttribute("Byte", "1");
    xmlWriter.writeCharacters("Tilt");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "0");
    xmlWriter.writeAttribute("Max", "10");
    xmlWriter.writeCharacters("Cap1");
    xmlWriter.writeEndElement();

    /* Overlaps with cap1, shouldn't appear in the channel */
    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "5");
    xmlWriter.writeAttribute("Max", "15");
    xmlWriter.writeCharacters("Cap2");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "11");
    xmlWriter.writeAttribute("Max", "20");
    xmlWriter.writeCharacters("Cap3");
    xmlWriter.writeEndElement();

    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);
    xmlReader.readNextStartElement();

    QLCChannel ch;
    QVERIFY(ch.loadXML(xmlReader) == false);
    QVERIFY(ch.name().isEmpty());
    QVERIFY(ch.group() == QLCChannel::Intensity);
    QVERIFY(ch.controlByte() == QLCChannel::MSB);
    QVERIFY(ch.capabilities().size() == 0);
}
コード例 #14
0
ファイル: fixturemanager.cpp プロジェクト: speakman/qlc
void FixtureManager::slotAutoFunction()
{
#if 0
	QTreeWidgetItem* item;
	t_fixture_id fxi_id;
	Fixture* fxi;

	item = m_tree->currentItem();
	if (item == NULL)
		return;

	fxi_id = item->text(KColumnID).toInt();
	fxi = _app->doc()->fixture(fxi_id);
	Q_ASSERT(fxi != NULL);

	// Loop over all channels
	for (int i = 0; i < fxi->channels(); i++)
	{
		QLCChannel* channel = fxi->channel(i);
		Q_ASSERT(channel != NULL);

		QListIterator <QLCCapability*> 
			cap_it(*channel->capabilities());

		// Loop over all capabilities
		while (cap_it.hasNext() == true)
		{
			QLCCapability* cap = cap_it.next();
			Q_ASSERT(cap != NULL);

			Scene* sc = static_cast<Scene*> 
				(_app->doc()->newFunction(Function::Scene,
							  fxi_id));
			sc->setName(channel->name() + " - " + cap->name());

			// Set the unused channels to NoSet and zero.
			for (int j = 0; j < fxi->channels(); j++)
				sc->set(j, 0, Scene::NoSet);

			// Set only the capability
			sc->set(i, (t_value) ((cap->min() + cap->max()) / 2),
				Scene::Set);
		}
	}
#endif
}
コード例 #15
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
void QLCChannel_Test::loadWrongRoot()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Chanel");
    root.setAttribute("Name", "Channel1");
    doc.appendChild(root);

    QDomElement group = doc.createElement("Group");
    root.appendChild(group);
    group.setAttribute("Byte", 1);
    QDomText groupName = doc.createTextNode("Tilt");
    group.appendChild(groupName);

    QDomElement cap1 = doc.createElement("Capability");
    root.appendChild(cap1);
    cap1.setAttribute("Min", 0);
    cap1.setAttribute("Max", 10);
    QDomText cap1name = doc.createTextNode("Cap1");
    cap1.appendChild(cap1name);

    /* Overlaps with cap1, shouldn't appear in the channel */
    QDomElement cap2 = doc.createElement("Capability");
    root.appendChild(cap2);
    cap2.setAttribute("Min", 5);
    cap2.setAttribute("Max", 15);
    QDomText cap2name = doc.createTextNode("Cap2");
    cap2.appendChild(cap2name);

    QDomElement cap3 = doc.createElement("Capability");
    root.appendChild(cap3);
    cap3.setAttribute("Min", 11);
    cap3.setAttribute("Max", 20);
    QDomText cap3name = doc.createTextNode("Cap3");
    cap3.appendChild(cap3name);

    QLCChannel ch;
    QVERIFY(ch.loadXML(&root) == false);
    QVERIFY(ch.name().isEmpty());
    QVERIFY(ch.group() == QLCChannel::Intensity);
    QVERIFY(ch.controlByte() == QLCChannel::MSB);
    QVERIFY(ch.capabilities().size() == 0);
}
コード例 #16
0
ファイル: editmode.cpp プロジェクト: jeromelebleu/qlcplus
void EditMode::refreshChannelList()
{
    m_channelList->clear();

    for (int i = 0; i < m_mode->channels().size(); i++)
    {
        QTreeWidgetItem* item = new QTreeWidgetItem(m_channelList);
        QLCChannel* ch = m_mode->channel(i);
        Q_ASSERT(ch != NULL);

        QString str;
        str.sprintf("%.3d", (i + 1));
        item->setText(COL_NUM, str);
        item->setText(COL_NAME, ch->name());
        item->setIcon(COL_NAME, ch->getIcon());
        item->setData(COL_NAME, PROP_PTR, (qulonglong) ch);
    }
    m_channelList->header()->resizeSections(QHeaderView::ResizeToContents);
}
コード例 #17
0
ファイル: editmode.cpp プロジェクト: speakman/qlc
void EditMode::refreshChannelList()
{
	m_channelList->clear();

	for (int i = 0; i < m_mode->channels().size(); i++)
	{
		QTreeWidgetItem* item = new QTreeWidgetItem(m_channelList);
		QLCChannel* ch = m_mode->channel(i);
		Q_ASSERT(ch != NULL);

		QString str;
		str.sprintf("%.3d", (i + 1));
		item->setText(KChannelsColumnNumber, str);
		item->setText(KChannelsColumnName, ch->name());

		// Store the channel pointer to the listview as a string
		str.sprintf("%lu", (unsigned long) ch);
		item->setText(KChannelsColumnPointer, str);
	}
}
コード例 #18
0
ファイル: editmode.cpp プロジェクト: speakman/qlc
void EditMode::slotLowerChannelClicked()
{
	QLCChannel* ch = currentChannel();
	int index = 0;
	
	if (ch == NULL)
		return;
	
	index = m_mode->channelNumber(ch) + 1;
	
	// Don't move beyond the end of the list
	if (index >= m_mode->channels())
		return;
	
	m_mode->removeChannel(ch);
	m_mode->insertChannel(ch, index);
	
	refreshChannelList();
	selectChannel(ch->name());
}
コード例 #19
0
void QLCFixtureDef_Test::saveLoadXML()
{
    const QString path("qlcfixturedef_test_saveXML.qxf");

    QLCFixtureDef* def = new QLCFixtureDef;
    def->setManufacturer("Foobar");
    def->setModel("Xyzzy");
    def->setType("Blinder");

    QLCChannel* ch = new QLCChannel;
    ch->setName("Whatever");
    def->addChannel(ch);

    QLCFixtureMode* mode = new QLCFixtureMode(def);
    mode->setName("Barfoo");
    def->addMode(mode);
    mode->insertChannel(ch, 0);

    QVERIFY(def->saveXML(QString("zxcvb:/path/to/nowhere") + path) != QFile::NoError);
    QCOMPARE(def->saveXML(path), QFile::NoError);

    // Test only QLCFixtureDef's doings and don't go into channel/mode details
    // since they are tested in their individual unit tests.
    QLCFixtureDef* def2 = new QLCFixtureDef;
    QCOMPARE(def2->loadXML(QString()), QFile::OpenError);
    QCOMPARE(def2->loadXML("/path/beyond/this/universe/foo.qxf"), QFile::ReadError);
    QCOMPARE(def2->loadXML("readonly.xml"), QFile::ReadError);

    QCOMPARE(def2->loadXML(path), QFile::NoError);
    QCOMPARE(def2->manufacturer(), def->manufacturer());
    QCOMPARE(def2->model(), def->model());
    QCOMPARE(def2->channels().size(), 1);
    QCOMPARE(def2->channels().at(0)->name(), ch->name());
    QCOMPARE(def2->modes().size(), 1);
    QCOMPARE(def2->modes().at(0)->name(), mode->name());

    delete def;
    delete def2;
    QFile::remove(path);
    QVERIFY(QFile::exists(path) == false);
}
コード例 #20
0
ファイル: editmode.cpp プロジェクト: speakman/qlc
void EditMode::refreshChannelList()
{
	QListViewItem* item = NULL;
	QLCChannel* ch = NULL;
	QString str;
	
	m_channelList->clear();
	
	for (int i = 0; i < m_mode->channels(); i++)
	{
		ch = m_mode->channel(i);
		item = new QListViewItem(m_channelList);
		str.sprintf("%.3d", i + 1);
		item->setText(KChannelsColumnNumber, str);
		item->setText(KChannelsColumnName, ch->name());
		
		// Store the channel pointer to the listview as a string
		str.sprintf("%d", (unsigned long) ch);
		item->setText(KChannelsColumnPointer, str);
	}
}
コード例 #21
0
ファイル: vcsliderproperties.cpp プロジェクト: speakman/qlc
void VCSliderProperties::levelUpdateChannelNode(QCheckListItem* parent,
						Fixture* fxi,
						t_channel ch)
{
	QCheckListItem* item = NULL;
	QLCChannel* channel = NULL;
	QString str;

	Q_ASSERT(parent != NULL);

	channel = fxi->channel(ch);
	Q_ASSERT(channel != NULL);

	item = levelChannelNode(parent, ch);
	if (item == NULL)
		item = new QCheckListItem(parent, channel->name(),
					  QCheckListItem::CheckBox);

	item->setText(KColumnType, channel->group());
	str.setNum(ch);
	item->setText(KColumnID, str);

	levelUpdateCapabilities(item, channel);
}
コード例 #22
0
ファイル: fixtureeditor.cpp プロジェクト: speakman/qlc
void QLCFixtureEditor::slotEditChannel()
{
	QLCChannel* real = NULL;
	QTreeWidgetItem* item = NULL;

	// Initialize the dialog with the selected logical channel or
	// bail out if there is no current selection
	real = currentChannel();
	if (real == NULL)
		return;
	
	EditChannel ec(this, real);
	if (ec.exec() == QDialog::Accepted)
	{
		// Copy the channel's contents to the real channel
		*real = *(ec.channel());

		item = m_channelList->currentItem();
		item->setText(KChannelsColumnName, real->name());
		item->setText(KChannelsColumnGroup, real->group());
		
		setModified();
	}
}
コード例 #23
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
void QLCChannel_Test::load()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Channel");
    root.setAttribute("Name", "Channel1");
    doc.appendChild(root);

    QDomElement group = doc.createElement("Group");
    root.appendChild(group);
    group.setAttribute("Byte", 1);
    QDomText groupName = doc.createTextNode("Tilt");
    group.appendChild(groupName);

    QDomElement colour = doc.createElement("Colour");
    QDomText colourText = doc.createTextNode(QLCChannel::colourToString(QLCChannel::Cyan));
    colour.appendChild(colourText);
    root.appendChild(colour);

    QDomElement cap1 = doc.createElement("Capability");
    root.appendChild(cap1);
    cap1.setAttribute("Min", 0);
    cap1.setAttribute("Max", 10);
    QDomText cap1name = doc.createTextNode("Cap1");
    cap1.appendChild(cap1name);

    /* Overlaps with cap1, shouldn't appear in the channel */
    QDomElement cap2 = doc.createElement("Capability");
    root.appendChild(cap2);
    cap2.setAttribute("Min", 5);
    cap2.setAttribute("Max", 15);
    QDomText cap2name = doc.createTextNode("Cap2");
    cap2.appendChild(cap2name);

    QDomElement cap3 = doc.createElement("Capability");
    root.appendChild(cap3);
    cap3.setAttribute("Min", 11);
    cap3.setAttribute("Max", 20);
    QDomText cap3name = doc.createTextNode("Cap3");
    cap3.appendChild(cap3name);

    /* Invalid capability tag, shouldn't appear in the channel, since it
       is not recognized by the channel. */
    QDomElement cap4 = doc.createElement("apability");
    root.appendChild(cap4);
    cap4.setAttribute("Min", 21);
    cap4.setAttribute("Max", 30);
    QDomText cap4name = doc.createTextNode("Cap4");
    cap4.appendChild(cap4name);

    /* Missing minimum value, shouldn't appear in the channel, because
       loadXML() fails. */
    QDomElement cap5 = doc.createElement("Capability");
    root.appendChild(cap5);
    cap5.setAttribute("Max", 30);
    QDomText cap5name = doc.createTextNode("Cap5");
    cap5.appendChild(cap5name);

    QLCChannel ch;
    QVERIFY(ch.loadXML(&root) == true);
    qDebug() << int(ch.colour());
    QVERIFY(ch.name() == "Channel1");
    QVERIFY(ch.group() == QLCChannel::Tilt);
    QVERIFY(ch.controlByte() == QLCChannel::LSB);
    QVERIFY(ch.colour() == QLCChannel::Cyan);
    QVERIFY(ch.capabilities().size() == 2);
    QVERIFY(ch.capabilities()[0]->name() == "Cap1");
    QVERIFY(ch.capabilities()[1]->name() == "Cap3");
}
コード例 #24
0
ファイル: qlcchannel_test.cpp プロジェクト: alexpaulzor/qlc
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());
}
コード例 #25
0
ファイル: fixtureeditor.cpp プロジェクト: ChrisLaurie/qlcplus
void QLCFixtureEditor::slotEditChannel()
{
    QLCChannel* real = NULL;
    QTreeWidgetItem* item = NULL;

    // Initialize the dialog with the selected logical channel or
    // bail out if there is no current selection
    real = currentChannel();
    if (real == NULL)
        return;

    EditChannel ec(this, real);
    if (ec.exec() == QDialog::Accepted)
    {
        if (m_fixtureDef->channel(ec.channel()->name()) != NULL && ec.channel()->name() != real->name())
        {
            QMessageBox::warning(this,
                                 tr("Channel already exists"),
                                 tr("A channel by the name \"%1\" already exists!")
                                 .arg(ec.channel()->name()));
        }
        else if (ec.channel()->name().length() == 0)
        {
            QMessageBox::warning(this,
                                 tr("Channel has no name"),
                                 tr("You must give the channel a descriptive name!"));
        }
        else
        {
            // Copy the channel's contents to the real channel
            *real = *(ec.channel());

            item = m_channelList->currentItem();
            updateChannelItem(real, item);
            m_channelList->resizeColumnToContents(CH_COL_NAME);

            setModified();
        }
    }
}
コード例 #26
0
void QLCChannel_Test::load()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("Channel");
    xmlWriter.writeAttribute("Name", "Channel1");

    xmlWriter.writeStartElement("Group");
    xmlWriter.writeAttribute("Byte", "1");
    xmlWriter.writeCharacters("Tilt");
    xmlWriter.writeEndElement();

    xmlWriter.writeTextElement("Colour", QLCChannel::colourToString(QLCChannel::Cyan));

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "0");
    xmlWriter.writeAttribute("Max", "10");
    xmlWriter.writeCharacters("Cap1");
    xmlWriter.writeEndElement();

    /* Overlaps with cap1, shouldn't appear in the channel */
    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "5");
    xmlWriter.writeAttribute("Max", "15");
    xmlWriter.writeCharacters("Cap2");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Min", "11");
    xmlWriter.writeAttribute("Max", "20");
    xmlWriter.writeCharacters("Cap3");
    xmlWriter.writeEndElement();

    /* Invalid capability tag, shouldn't appear in the channel, since it
       is not recognized by the channel. */
    xmlWriter.writeStartElement("apability");
    xmlWriter.writeAttribute("Min", "21");
    xmlWriter.writeAttribute("Max", "30");
    xmlWriter.writeCharacters("Cap4");
    xmlWriter.writeEndElement();

    /* Missing minimum value, shouldn't appear in the channel, because
       loadXML() fails. */
    xmlWriter.writeStartElement("Capability");
    xmlWriter.writeAttribute("Max", "30");
    xmlWriter.writeCharacters("Cap5");
    xmlWriter.writeEndElement();

    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);
    xmlReader.readNextStartElement();

    QLCChannel ch;
    QVERIFY(ch.loadXML(xmlReader) == true);
    qDebug() << int(ch.colour());
    QVERIFY(ch.name() == "Channel1");
    QVERIFY(ch.group() == QLCChannel::Tilt);
    QVERIFY(ch.controlByte() == QLCChannel::LSB);
    QVERIFY(ch.colour() == QLCChannel::Cyan);
    QVERIFY(ch.capabilities().size() == 2);
    QVERIFY(ch.capabilities()[0]->name() == "Cap1");
    QVERIFY(ch.capabilities()[1]->name() == "Cap3");
}