void QLCCapability_Test::min()
{
    QLCCapability cap;
    QVERIFY(cap.min() == 0);

    QFETCH(uchar, value);

    cap.setMin(value);
    QCOMPARE(cap.min(), value);
}
Beispiel #2
0
void ConsoleChannel::initCapabilityMenu(const QLCChannel* ch)
{
    QLCCapability* cap;
    QMenu* valueMenu;
    QAction* action;
    QString s;
    QString t;

    QListIterator <QLCCapability*> it(ch->capabilities());
    while (it.hasNext() == true)
    {
        cap = it.next();

        // Set the value range and name as the menu item's name
        s = QString("%1: %2 - %3").arg(cap->name())
            .arg(cap->min()).arg(cap->max());

        if (cap->max() - cap->min() > 0)
        {
            // Create submenu for ranges of more than one value
            valueMenu = new QMenu(m_menu);
            valueMenu->setTitle(s);

            /* Add a color icon */
            if (ch->group() == QLCChannel::Colour)
                valueMenu->setIcon(colorIcon(cap->name()));

            for (int i = cap->min(); i <= cap->max(); i++)
            {
                action = valueMenu->addAction(
                             t.sprintf("%.3d", i));
                action->setData(i);
            }

            m_menu->addMenu(valueMenu);
        }
        else
        {
            // Just one value in this range, put that into the menu
            action = m_menu->addAction(s);
            action->setData(cap->min());

            /* Add a color icon */
            if (ch->group() == QLCChannel::Colour)
                action->setIcon(colorIcon(cap->name()));
        }
    }

    // Connect menu item activation signal to this
    connect(m_menu, SIGNAL(triggered(QAction*)),
            this, SLOT(slotContextMenuTriggered(QAction*)));

    // Set the menu also as the preset button's popup menu
    m_presetButton->setMenu(m_menu);
}
Beispiel #3
0
void CapabilityWizard::slotCreateCapabilities()
{
	int start = m_startSpin->value();
	int gap = m_gapSpin->value();
	int amount = m_amountSpin->value();
	QString name = m_nameEdit->text();
	t_value min = start;
	t_value max = min + gap;
	QLCCapability* cap;

	/* Destroy existing capabilities */
	foreach (QLCCapability* cap, m_caps)
		delete cap;
	m_caps.clear();

	/* Create new capabilities */
	for (int i = 0; i < amount; i++)
	{
		/* Create a name with the optional hash mark */
		QString modname(name);
		modname.replace("#", QString("%1").arg(i + 1));

		/* Create a new capability and add it to our list */
		cap = new QLCCapability(min, max, modname);
		m_caps << cap;

		/* Bail out when the maximum DMX value has been reached */
		if (max == 255)
			break;

		/* Increment for the next round */
		min = max + 1;
		max = min + gap;

		/* Bail out if next round would overflow */
		if (max < min)
			break;
	}

	/* Replace capabilities in the list widget */
	m_list->clear();
	foreach (cap, m_caps)
	{
		QListWidgetItem* item;
		item = new QListWidgetItem(m_list);
		item->setText(QString("[%1 - %2] %3").arg(cap->min())
				.arg(cap->max()).arg(cap->name()));

		if (m_channel->searchCapability(cap->min()) != NULL ||
		    m_channel->searchCapability(cap->max()) != NULL)
		{
			/* Disable the item to indicate overlapping */
			item->setFlags(0);
		}
	}
Beispiel #4
0
bool QLCCapability::overlaps(const QLCCapability& cap)
{
    if (m_min >= cap.min() && m_min <= cap.max())
        return true;
    else if (m_max >= cap.min() && m_max <= cap.max())
        return true;
    else if (m_min <= cap.min() && m_max >= cap.min())
        return true;
    else
        return false;
}
Beispiel #5
0
void QLCFixtureEditor::updateChannelItem(const QLCChannel* channel, QTreeWidgetItem* item)
{
    QString str;

    Q_ASSERT(channel != NULL);
    Q_ASSERT(item != NULL);

    item->setText(CH_COL_NAME, channel->name());
    item->setIcon(CH_COL_NAME, channel->getIcon());
    item->setText(CH_COL_GRP, QLCChannel::groupToString(channel->group()));
    item->setData(CH_COL_NAME, PROP_PTR, (qulonglong) channel);

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

    /* Put all capabilities as non-selectable sub items */
    QListIterator <QLCCapability*> capit(channel->capabilities());
    while (capit.hasNext() == true)
    {
        QLCCapability* cap = capit.next();
        Q_ASSERT(cap != NULL);

        QTreeWidgetItem* capitem = new QTreeWidgetItem(item);
        capitem->setText(CH_COL_NAME,
                         QString("[%1-%2]: %3").arg(cap->min())
                         .arg(cap->max()).arg(cap->name()));
        capitem->setFlags(0); /* No selection etc. */
    }
}
Beispiel #6
0
void EditChannel::refreshCapabilities()
{
	QPtrListIterator<QLCCapability> it(*m_channel->capabilities());
	QLCCapability* cap = NULL;
	QListViewItem* item = NULL;
	QString str;
	
	m_capabilityList->clear();
	
	/* Fill capabilities */
	while ( (cap = it.current()) != 0)
	{
		++it;

		item = new QListViewItem(m_capabilityList);
		
		// Min
		str.sprintf("%.3d", cap->min());
		item->setText(KColumnMin, str);

		// Max
		str.sprintf("%.3d", cap->max());
		item->setText(KColumnMax, str);
		
		// Name
		item->setText(KColumnName, cap->name());
		
		// Store the capability pointer to the listview as a string
		str.sprintf("%d", (unsigned long) cap);
		item->setText(KColumnPointer, str);
	}
	
	slotCapabilityListSelectionChanged(m_capabilityList->currentItem());
}
void QLCCapability_Test::initial()
{
    QLCCapability cap;
    QVERIFY(cap.min() == 0);
    QVERIFY(cap.max() == UCHAR_MAX);
    QVERIFY(cap.name().isEmpty());
}
Beispiel #8
0
QLCCapability* QLCChannel::searchCapability(uchar value) const
{
    QListIterator <QLCCapability*> it(m_capabilities);
    while (it.hasNext() == true)
    {
        QLCCapability* capability = it.next();
        if (capability->min() <= value && capability->max() >= value)
            return capability;
    }

    return NULL;
}
Beispiel #9
0
bool QLCChannel::addCapability(QLCCapability* cap)
{
	QListIterator <QLCCapability*> it(m_capabilities);
	QLCCapability* temp = NULL;

	Q_ASSERT(cap != NULL);

	/* Check for overlapping values */
	while (it.hasNext() == true)
	{
		temp = it.next();
		if ((temp->min() <= cap->min() && temp->max() > cap->min()) ||
		    (temp->min() < cap->max() && temp->max() >= cap->max()) ||
		    (temp->min() >= cap->min() && temp->max() <= cap->max()))
		{
			return false;
		}
	}

	m_capabilities.append(cap);
	return true;
}
Beispiel #10
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
}
void QLCCapability_Test::loadNoMax()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Capability");
    doc.appendChild(root);

    root.setAttribute("Min", 13);

    QDomText name = doc.createTextNode("Test1");
    root.appendChild(name);

    QLCCapability cap;
    QVERIFY(cap.loadXML(root) == false);
    QVERIFY(cap.name().isEmpty());
    QVERIFY(cap.min() == 0);
    QVERIFY(cap.max() == UCHAR_MAX);
}
void QLCCapability_Test::load()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Capability");
    doc.appendChild(root);

    root.setAttribute("Min", 13);
    root.setAttribute("Max", 19);

    QDomText name = doc.createTextNode("Test1");
    root.appendChild(name);

    QLCCapability cap;
    QVERIFY(cap.loadXML(root) == true);
    QVERIFY(cap.name() == "Test1");
    QVERIFY(cap.min() == 13);
    QVERIFY(cap.max() == 19);
}
Beispiel #13
0
void EditChannel::refreshCapabilities()
{
	QListIterator <QLCCapability*> it(*m_channel->capabilities());
	QLCCapability* cap = NULL;
	QTreeWidgetItem* item = NULL;
	QString str;
	
	m_capabilityList->clear();
	
	/* Fill capabilities */
	while (it.hasNext() == true)
	{
		cap = it.next();

		item = new QTreeWidgetItem(m_capabilityList);
		
		// Min
		str.sprintf("%.3d", cap->min());
		item->setText(KColumnMin, str);

		// Max
		str.sprintf("%.3d", cap->max());
		item->setText(KColumnMax, str);
		
		// Name
		item->setText(KColumnName, cap->name());
		
		// Store the capability pointer to the listview as a string
		str.sprintf("%lu", (unsigned long) cap);
		item->setText(KColumnPointer, str);
	}
	
	m_capabilityList->sortItems(KColumnMin, Qt::AscendingOrder);
	
	slotCapabilityListSelectionChanged(m_capabilityList->currentItem());
}