Ejemplo n.º 1
0
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();
    }
}
Ejemplo n.º 2
0
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();
    }
}
Ejemplo n.º 3
0
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());
}
Ejemplo n.º 4
0
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. */
    }
}
Ejemplo n.º 5
0
void QLCFixtureEditor::slotChannelListContextMenuRequested()
{
    QAction editAction(QIcon(":/edit.png"), tr("Edit"), this);
    QAction copyAction(QIcon(":/editcopy.png"), tr("Copy"), this);
    QAction pasteAction(QIcon(":/editpaste.png"), tr("Paste"), this);
    QAction removeAction(QIcon(":/editdelete.png"), tr("Remove"), this);

    /* Group menu */
    QMenu groupMenu;
    groupMenu.setTitle("Set group");
    QStringListIterator it(QLCChannel::groupList());
    while (it.hasNext() == true)
        groupMenu.addAction(it.next());

    /* Master edit menu */
    QMenu menu;
    menu.setTitle(tr("Channels"));
    menu.addAction(&editAction);
    menu.addAction(&copyAction);
    menu.addAction(&pasteAction);
    menu.addSeparator();
    menu.addAction(&removeAction);
    menu.addSeparator();
    menu.addMenu(&groupMenu);

    if (m_channelList->currentItem() == NULL)
    {
        copyAction.setEnabled(false);
        removeAction.setEnabled(false);
    }

    if (_app->copyChannel() == NULL)
        pasteAction.setEnabled(false);

    QAction* selectedAction = menu.exec(QCursor::pos());
    if (selectedAction == NULL)
        return;
    else if (selectedAction->text() == tr("Edit"))
        slotEditChannel();
    else if (selectedAction->text() == tr("Copy"))
        slotCopyChannel();
    else if (selectedAction->text() == tr("Paste"))
        slotPasteChannel();
    else if (selectedAction->text() == tr("Remove"))
        slotRemoveChannel();
    else
    {
        /* Group menu hook */
        QLCChannel* ch = NULL;
        QTreeWidgetItem* node = NULL;

        ch = currentChannel();
        if (ch != NULL)
            ch->setGroup(QLCChannel::stringToGroup(selectedAction->text()));
        node = m_channelList->currentItem();
        if (node != NULL)
            node->setText(CH_COL_GRP, selectedAction->text());
        setModified();
    }
}
Ejemplo n.º 6
0
void QLCChannel_Test::defaultValue()
{
    QLCChannel* channel = new QLCChannel();
    QVERIFY(channel->defaultValue() == 0);

    channel->setDefaultValue(137);
    QVERIFY(channel->defaultValue() == 137);
}
Ejemplo n.º 7
0
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);
}
Ejemplo n.º 8
0
void QLCChannel_Test::group()
{
	QLCChannel* channel = new QLCChannel();
	QVERIFY(channel->group() == KQLCChannelGroupIntensity);

	channel->setGroup("TestGroup");
	QVERIFY(channel->group() == "TestGroup");

	delete channel;
}
Ejemplo n.º 9
0
void QLCChannel_Test::controlByte()
{
	QLCChannel* channel = new QLCChannel();
	QVERIFY(channel->controlByte() == 0);

	channel->setControlByte(1);
	QVERIFY(channel->controlByte() == 1);

	delete channel;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
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);
}
Ejemplo n.º 12
0
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;
}
Ejemplo n.º 13
0
void QLCChannel_Test::controlByte()
{
    QCOMPARE(int(QLCChannel::MSB), 0);
    QCOMPARE(int(QLCChannel::LSB), 1);

    QLCChannel* channel = new QLCChannel();
    QVERIFY(channel->controlByte() == QLCChannel::MSB);

    channel->setControlByte(QLCChannel::LSB);
    QVERIFY(channel->controlByte() == QLCChannel::LSB);

    delete channel;
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
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());
	}
}
Ejemplo n.º 16
0
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
}
Ejemplo n.º 17
0
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."));
	}
}
Ejemplo n.º 18
0
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;
}
Ejemplo n.º 19
0
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);
}
Ejemplo n.º 20
0
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);
	}
}
Ejemplo n.º 21
0
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());
}
Ejemplo n.º 22
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);
}
Ejemplo n.º 23
0
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);
	}
}
Ejemplo n.º 24
0
void QLCFixtureMode_Test::insertChannel()
{
    QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef);
    mode->setName("Test");

    QVERIFY(mode->insertChannel(NULL, 0) == false);
    QVERIFY(mode->channels().size() == 0);

    /* Channel that doesn't belong to mode->fixtureDef() */
    QLCChannel* ch = new QLCChannel();
    ch->setName("Rogue");
    mode->insertChannel(ch, 0);
    QVERIFY(mode->channels().size() == 0);
    delete ch;

    /* First channel */
    mode->insertChannel(m_ch1, 0);
    QVERIFY(mode->channel(0) == m_ch1);

    /* Second prepended */
    mode->insertChannel(m_ch2, 0);
    QVERIFY(mode->channel(0) == m_ch2);
    QVERIFY(mode->channel(1) == m_ch1);

    /* Third appended way over the end */
    mode->insertChannel(m_ch3, 10);
    QVERIFY(mode->channel(0) == m_ch2);
    QVERIFY(mode->channel(1) == m_ch1);
    QVERIFY(mode->channel(2) == m_ch3);

    /* Fourth inserted in-between */
    mode->insertChannel(m_ch4, 1);
    QVERIFY(mode->channel(0) == m_ch2);
    QVERIFY(mode->channel(1) == m_ch4);
    QVERIFY(mode->channel(2) == m_ch1);
    QVERIFY(mode->channel(3) == m_ch3);

    delete mode;
}
Ejemplo n.º 25
0
void VCXYPadFixture::arm()
{
	Fixture* fxi = NULL;

	fxi = _app->doc()->fixture(m_fixture);
	if (fxi == NULL)
	{
		m_xLSB = KChannelInvalid;
		m_xMSB = KChannelInvalid;
		m_yLSB = KChannelInvalid;
		m_yMSB = KChannelInvalid;
	}
	else
	{
		const QLCFixtureMode* mode = NULL;
		QLCChannel* ch = NULL;

		/* If this fixture has no mode, it's a generic dimmer that
		   can't do pan&tilt anyway. */
		mode = fxi->fixtureMode();
		if (mode == NULL)
		{
			m_xLSB = KChannelInvalid;
			m_xMSB = KChannelInvalid;
			m_yLSB = KChannelInvalid;
			m_yMSB = KChannelInvalid;
			
			return;
		}

		/* Find exact channel numbers for MSB/LSB pan and tilt */
		for (t_channel i = 0; i < mode->channels().size(); i++)
		{
			ch = mode->channel(i);
			Q_ASSERT(ch != NULL);

			if (ch->group() == KQLCChannelGroupPan)
			{
				if (ch->controlByte() == 0)
					m_xMSB = fxi->universeAddress() + i;
				else if (ch->controlByte() == 1)
					m_xLSB = fxi->universeAddress() + i;
			}
			else if (ch->group() == KQLCChannelGroupTilt)
			{
				if (ch->controlByte() == 0)
					m_yMSB = fxi->universeAddress() + i;
				else if (ch->controlByte() == 1)
					m_yLSB = fxi->universeAddress() + i;
			}
		}
	}
}
Ejemplo n.º 26
0
void QLCFixtureDef_Test::copy()
{
    QLCFixtureDef* fd = new QLCFixtureDef();
    fd->setManufacturer("Martin");
    fd->setModel("MAC600");
    fd->setType("Moving Head");

    QLCChannel* ch = new QLCChannel();
    ch->setName("TestChannel");
    fd->addChannel(ch);

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

    QLCFixtureDef* copy = new QLCFixtureDef(fd);
    QVERIFY(copy->manufacturer() == "Martin");
    QVERIFY(copy->model() == "MAC600");
    QVERIFY(copy->type() == "Moving Head");

    /* Verify that modes and channels get copied and that the channels in
       the copied mode are from the copied fixtureDef and not the one that
       the copy is taken FROM. */
    QVERIFY(copy->channels().at(0)->name() == "TestChannel");
    QVERIFY(copy->modes().at(0)->name() == "TestMode");
    QVERIFY(copy->modes().at(0)->channels().size() == 1);
    QVERIFY(copy->modes().size() == 1);
    QVERIFY(copy->modes().at(0)->channel(0) != ch);
    QVERIFY(copy->modes().at(0)->channel(0) == copy->channels().at(0));
    QVERIFY(copy->channels().at(0)->name() == "TestChannel");
    QVERIFY(copy->modes().at(0)->channel(0)->name() == "TestChannel");

    delete fd;
    delete copy;
}
Ejemplo n.º 27
0
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();
	}
}
Ejemplo n.º 28
0
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;
}
Ejemplo n.º 29
0
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);
}
Ejemplo n.º 30
0
void QLCChannel_Test::group()
{
    QLCChannel* channel = new QLCChannel();
    QVERIFY(channel->group() == QLCChannel::Intensity);

    channel->setGroup(QLCChannel::Beam);
    QVERIFY(channel->group() == QLCChannel::Beam);

    channel->setGroup(QLCChannel::Group(31337));
    QVERIFY(channel->group() == QLCChannel::Group(31337));

    delete channel;
}