Beispiel #1
0
void NewDevice::slotSelectionChanged(QListViewItem* item)
{
    if (item->parent() != NULL)
    {
        m_selectionOK = true;
        m_modelValue = item->text(0);
        m_manufacturerValue = item->parent()->text(0);
        if (m_nameEdit->text() == QString::null)
        {
            m_nameEdit->setText("New device");
        }

        m_nameEdit->setSelection(0, m_nameEdit->text().length());
        m_nameEdit->setFocus();

        DeviceClass* dc = _app->searchDeviceClass(m_manufacturerValue,
                          m_modelValue);
        assert(dc);
        m_addressSpin->setRange(1, 513 - dc->channels()->count());
        m_channelsSpin->setValue(dc->channels()->count());
        m_ok->setEnabled(true);
    }
    else
    {
        m_ok->setEnabled(false);
        m_selectionOK = false;
        m_manufacturerValue = QString("");
        m_modelValue = QString("");
        m_nameEdit->setText(QString(""));
        m_channelsSpin->setValue(0);
    }
}
Beispiel #2
0
DeviceClass* Doc::createDeviceClass(QList<QString> &list)
{
  QString entry;
  QString manufacturer;
  QString model;
  QString t;
  
  DeviceClass* dc = new DeviceClass();

  for (QString *s = list.first(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  entry = *(list.next());
	  if (entry == QString("Device Class"))
	    {
	      dc->createInfo(list);
	    }
	  else if (entry == QString("Channel"))
	    {
	      dc->createChannel(list);
	    }
	  else if (entry == QString("Function"))
	    {
	      list.next();
	      // dc->createFunction(list);
	    }
	}
      else
	{
	  // Unknown keyword (at this time)
	  list.next();
	}
    }

  if (dc->channels()->count() == 0)
    {
      QString msg;
      msg.sprintf("No channels specified for device class \"" + dc->manufacturer() +
		  QString(" ") + dc->model() + QString("\".\n") +
		  "Use the device class editor to add one or more channels.");
      QMessageBox::warning(_app, IDS_APP_NAME_SHORT, msg);
    }

  return dc;
}
Beispiel #3
0
DMXDevice* Doc::createDevice(QList<QString> &list)
{
  QString name = QString::null;
  QString manufacturer = QString::null;
  QString model = QString::null;
  QString t = QString::null;
  int address = 0;
  unsigned long id = 0;

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("Name"))
	{
	  name = *(list.next());
	}		      
      else if (*s == QString("Manufacturer"))
	{
	  manufacturer = *(list.next());
	}
      else if (*s == QString("Model"))
	{
	  model = *(list.next());
	}
      else if (*s == QString("ID"))
	{
	  id = list.next()->toULong();
	}
      else if (*s == QString("Address"))
	{
	  t = *(list.next());
	  address = t.toInt();
	}
      else
	{
	  // Unknown keyword
	  list.next();
	}
    }

  if (id == 0 || manufacturer == QString::null || manufacturer == QString::null)
    {
      QString msg;
      msg = QString("Unable to add device \"" + name +
		    QString("\" because device (class) information is missing."));
      QMessageBox::critical(_app, IDS_APP_NAME_SHORT, msg);

      return NULL;
    }
  else
    {
      DeviceClass* dc = searchDeviceClass(manufacturer, model);
      if (dc == NULL)
	{
	  QString msg;
	  msg = QString("Unable to add device \"" + name + "\"." + 
			"\nNo device class description found for " +
			manufacturer + QString(" ") + model);
	  QMessageBox::critical(_app, IDS_APP_NAME_SHORT, msg);
	  return NULL;
	}
      else
	{
	  if (dc->channels()->count() == 0)
	    {
	      QString msg;
	      msg = QString("No channels specified for device class \"" + dc->manufacturer() +
			    QString(" ") + dc->model() + QString("\".\n") +
			    QString("Unable to load device \"") + name + QString("\" to workspace"));

	      QMessageBox::warning(_app, IDS_APP_NAME_SHORT, msg);
	      return NULL;
	    }
	  else
	    {
	      DMXDevice* d = new DMXDevice(address, dc, name, id);
	      return d;
	    }
	}
    }
}