Exemplo n.º 1
0
void QLCInputProfile_Test::name()
{
	QLCInputProfile ip;
	QVERIFY(ip.name() == " ");
	ip.setManufacturer("Behringer");
	QVERIFY(ip.name() == "Behringer ");
	ip.setModel("BCF2000");
	QVERIFY(ip.name() == "Behringer BCF2000");
}
Exemplo n.º 2
0
void InputMap::loadProfiles(const QDir& dir)
{
    if (dir.exists() == false || dir.isReadable() == false)
        return;

    /* Go thru all found file entries and attempt to load an input
       profile from each of them. */
    QStringListIterator it(dir.entryList());
    while (it.hasNext() == true)
    {
        QLCInputProfile* prof;
        QString path;

        path = dir.absoluteFilePath(it.next());
        prof = QLCInputProfile::loader(path);
        if (prof != NULL)
        {
            /* Check for duplicates */
            if (profile(prof->name()) == NULL)
                addProfile(prof);
            else
                delete prof;
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unable to find an input profile from" << path;
        }
    }
}
Exemplo n.º 3
0
void QLCInputProfile_Test::save()
{
    QLCInputProfile ip;
    ip.setManufacturer("TestManufacturer");
    ip.setModel("TestModel");

    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);

    QString path("test.qxi");
    QVERIFY(ip.saveXML(path) == true);

#if !defined(WIN32) && !defined(Q_OS_WIN)
    QFile::Permissions perm = QFile::permissions(path);
    QFile::setPermissions(path, 0);
    QVERIFY(ip.saveXML(path) == false);
    QFile::setPermissions(path, perm);
#endif

    QLCInputProfile* prof = QLCInputProfile::loader(path);
    QVERIFY(prof != NULL);
    QCOMPARE(prof->manufacturer(), ip.manufacturer());
    QCOMPARE(prof->model(), ip.model());
    QCOMPARE(prof->name(), ip.name());
    QCOMPARE(prof->channels().size(), ip.channels().size());
    QCOMPARE(prof->channels()[0]->name(), ich1->name());
    QCOMPARE(prof->channels()[2]->name(), ich3->name());
    QCOMPARE(prof->channels()[5]->name(), ich2->name());

    QVERIFY(QFile::remove(path) == true);
    delete prof;
}
Exemplo n.º 4
0
QLCInputProfile* InputMap::profile(const QString& name)
{
	QListIterator <QLCInputProfile*> it(m_profiles);
	while (it.hasNext() == true)
	{
		QLCInputProfile* profile = it.next();
		if (profile->name() == name)
			return profile;
	}

	return NULL;
}
Exemplo n.º 5
0
void InputMap_Test::profiles()
{
    InputMap im(m_doc, 4);
    QVERIFY(im.m_profiles.size() == 0);

    QLCInputProfile* prof = new QLCInputProfile();
    prof->setManufacturer("Foo");
    prof->setModel("Bar");

    QVERIFY(im.addProfile(prof) == true);
    QVERIFY(im.m_profiles.size() == 1);
    QVERIFY(im.addProfile(prof) == false);
    QVERIFY(im.m_profiles.size() == 1);

    QVERIFY(im.profileNames().size() == 1);
    QVERIFY(im.profileNames().at(0) == prof->name());
    QVERIFY(im.profile(prof->name()) == prof);
    QVERIFY(im.profile("Foobar") == NULL);

    QVERIFY(im.removeProfile("Foobar") == false);
    QVERIFY(im.m_profiles.size() == 1);
    QVERIFY(im.removeProfile(prof->name()) == true);
    QVERIFY(im.m_profiles.size() == 0);
}
Exemplo n.º 6
0
void QLCInputProfile_Test::loader()
{
    QLCInputProfile* prof = QLCInputProfile::loader("foobar");
    QVERIFY(prof == NULL);

    prof = QLCInputProfile::loader("broken.xml");
    QVERIFY(prof == NULL);

    QString path(PROFILEDIR "Generic-MIDI.qxi");
    prof = QLCInputProfile::loader(path);
    QVERIFY(prof != NULL);
    QCOMPARE(prof->path(), path);
    QCOMPARE(prof->name(), QString("Generic MIDI"));
    QCOMPARE(prof->channels().size(), 256);
}
Exemplo n.º 7
0
void InputMap::removeProfile(const QString& name)
{
	QLCInputProfile* profile;
	QMutableListIterator <QLCInputProfile*> it(m_profiles);
	while (it.hasNext() == true)
	{
		profile = it.next();
		if (profile->name() == name)
		{
			it.remove();
			delete profile;
			break;
		}
	}
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
0
void InputMap::loadProfiles(const QString& profilePath)
{
	/* Find *.qxi from profilePath, sort by name, get regular files */
	QDir dir(profilePath, QString("*%1").arg(KExtInputProfile),
		 QDir::Name, QDir::Files);
	if (dir.exists() == false || dir.isReadable() == false)
	{
		qWarning() << "Unable to load input profiles from"
			   << profilePath;
		return;
	}

	/* Go thru all found file entries and attempt to load an input
	   profile from each of them. */
	QStringListIterator it(dir.entryList());
	while (it.hasNext() == true)
	{
		QLCInputProfile* prof;
		QString path;

		path = dir.absoluteFilePath(it.next());
		prof = QLCInputProfile::loader(path);
		if (prof != NULL)
		{
			/* Check for duplicates */
			if (profile(prof->name()) == NULL)
				addProfile(prof);
			else
				delete prof;
		}
		else
		{
			qWarning() << "Unable to find an input profile from"
				   << path;
		}
	}
}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
0
void InputMap_Test::setPatch()
{
    InputMap im(m_doc, 4);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QLCInputProfile* prof = new QLCInputProfile();
    prof->setManufacturer("Foo");
    prof->setModel("Bar");
    im.addProfile(prof);

    QVERIFY(im.patch(0)->plugin() == NULL);
    QVERIFY(im.patch(0)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(0)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 0) == InputMap::invalidUniverse());

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == NULL);
    QVERIFY(im.patch(2)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(2)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == InputMap::invalidUniverse());

    QVERIFY(im.setPatch(0, "Foobar", 0, prof->name()) == true);
    QVERIFY(im.patch(0)->plugin() == NULL);
    QVERIFY(im.patch(0)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(0)->profile() == prof);
    QVERIFY(im.mapping(stub->name(), 0) == InputMap::invalidUniverse());

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == NULL);
    QVERIFY(im.patch(2)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(2)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == InputMap::invalidUniverse());

    QVERIFY(im.setPatch(0, stub->name(), 0) == true);
    QVERIFY(im.patch(0)->plugin() == stub);
    QVERIFY(im.patch(0)->input() == 0);
    QVERIFY(im.patch(0)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 0) == 0);

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == NULL);
    QVERIFY(im.patch(2)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(2)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == InputMap::invalidUniverse());

    QVERIFY(im.setPatch(2, stub->name(), 3, prof->name()) == true);
    QVERIFY(im.patch(0)->plugin() == stub);
    QVERIFY(im.patch(0)->input() == 0);
    QVERIFY(im.patch(0)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 0) == 0);

    QVERIFY(im.patch(1)->plugin() == NULL);
    QVERIFY(im.patch(1)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(1)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 1) == InputMap::invalidUniverse());

    QVERIFY(im.patch(2)->plugin() == stub);
    QVERIFY(im.patch(2)->input() == 3);
    QVERIFY(im.patch(2)->profile() == prof);
    QVERIFY(im.mapping(stub->name(), 2) == InputMap::invalidUniverse());

    QVERIFY(im.patch(3)->plugin() == NULL);
    QVERIFY(im.patch(3)->input() == QLCIOPlugin::invalidLine());
    QVERIFY(im.patch(3)->profile() == NULL);
    QVERIFY(im.mapping(stub->name(), 3) == 2);

    // Universe out of bounds
    QVERIFY(im.setPatch(im.universes(), stub->name(), 0) == false);
}
Exemplo n.º 13
0
void VCPropertiesEditor::updateHoldInputSource()
{
	QLCInputProfile* profile;
	InputPatch* patch;
	QString uniName;
	QString chName;

	if (m_properties.holdInputUniverse() == KInputUniverseInvalid ||
	    m_properties.holdInputChannel() == KInputChannelInvalid)
	{
		/* Nothing selected for input universe and/or channel */
		uniName = KInputNone;
		chName = KInputNone;

		/* Display the gathered information */
		m_holdInputUniverseEdit->setText(uniName);
		m_holdInputChannelEdit->setText(chName);
		
		return;
	}

	patch = _app->inputMap()->patch(m_properties.holdInputUniverse());
	if (patch == NULL || patch->plugin() == NULL)
	{
		/* There is no patch for the given universe */
		uniName = KInputNone;
		chName = KInputNone;

		/* Display the gathered information */
		m_holdInputUniverseEdit->setText(uniName);
		m_holdInputChannelEdit->setText(chName);
		
		return;
	}

	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_properties.holdInputChannel() + 1);
	}
	else
	{
		QString name;

		/* Display profile name for universe */
		uniName = QString("%1: %2")
				.arg(m_properties.holdInputUniverse() + 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. */
		name = profile->channelName(m_properties.holdInputChannel());
		if (name == QString::null)
			name = tr("Unknown");

		/* Display channel name */
		chName = QString("%1: %2")
			.arg(m_properties.holdInputChannel() + 1).arg(name);
	}

	/* Display the gathered information */
	m_holdInputUniverseEdit->setText(uniName);
	m_holdInputChannelEdit->setText(chName);
}