Ejemplo n.º 1
0
void VirtualConsole::createContents(QList<QString> &list)
{
  QString t;

  DMXWidget::globalDMXWidgetIDReset();
  
  if (m_drawArea != NULL)
    {
      delete m_drawArea;
      m_drawArea = NULL;
    }

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.next();

	  if (*s == QString("Virtual Console"))
	    {
	      createVirtualConsole(list);
	    }
	  else if (*s == QString("Frame"))
	    {
	      list.prev();
	      createWidget(list);
	    }
	  else if (*s == QString("Button"))
	    {
	      list.prev();
	      createWidget(list);
	    }
	  else if (*s == QString("SpeedSlider"))
	    {
	      list.prev();
	      createWidget(list);
	    }
	  else
	    {
	      // Unknown keyword, skip
	      list.next();
	    }
	}
      else
	{
	  list.next();
	}
    }

  // Virtual console sometimes loses its parent (or vice versa)
  // when loading a new document... try to handle it with this.
  reparent((QWidget*) _app->workspace(), 0, pos(), isVisible());
}
Ejemplo n.º 2
0
void Scene::createContents(QList<QString> &list)
{
  int channels = 1;
  QString t;

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if(s->at(0).isNumber() == true)
	{
	  int ch = s->toInt() - 1;
	  m_values = (unsigned short*) realloc(m_values, channels * sizeof(int));
	  t = *(list.next());
	  m_values[ch] = t.toInt();
	  channels++;
	}
      else
	{
	  // Unknown keyword, skip
	  list.next();
	}
    }
}
Ejemplo n.º 3
0
void Joystick::createContents(QList <QString> &list)
{
  QString t;
  int axis = 0;

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("AxisInvert"))
	{
	  t = *(list.next());
	  Control* c = m_axesList.at(axis);
	  if (c != NULL)
	    {
	      c->invert = (t == QString("true")) ? true : false;
	    }
	  else
	    {
	      qDebug("Too many axes defined for joystick \"" + name() + "\" in workspace file!");
	    }

	  axis++;
	}
      else
	{
	  // Unknown keyword, skip
	  list.next();
	}
    }
}
Ejemplo n.º 4
0
Archivo: bus.cpp Proyecto: speakman/qlc
void Bus::createContents(QList <QString> &list)
{
  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("Name"))
	{
	  m_name = *(list.next());
	}
      else if (*s == QString("ID"))
	{
	  m_id = list.next()->toInt();
	}
      else if (*s == QString("Type"))
	{
	  m_type = (Type) list.next()->toInt();
	}
      else if (*s == QString("Value"))
	{
	  m_value = list.next()->toInt();
	}
    }
}
Ejemplo n.º 5
0
void VirtualConsole::createVirtualConsole(QList<QString>& list)
{
  QString t;
  QRect rect(10, 10, 400, 400);

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  list.prev();
	  break;
	}
      else if (*s == QString("Mode"))
	{
	  t = *(list.next());
	  if (t == QString("Design"))
	    {
	      setMode(Design);
	    }
	  else
	    {
	      setMode(Operate);
	    }
	}
      else if (*s == QString("X"))
	{
	  t = *(list.next());
	  rect.setX(t.toInt());
	}
      else if (*s == QString("Y"))
	{
	  t = *(list.next());
	  rect.setY(t.toInt());
	}
      else if (*s == QString("Width"))
	{
	  t = *(list.next());
	  rect.setWidth(t.toInt());
	}
      else if (*s == QString("Height"))
	{
	  t = *(list.next());
	  rect.setHeight(t.toInt());
	}
      else
	{
	  list.next();
	}
    }

  setGeometry(rect);
}
Ejemplo n.º 6
0
void VirtualConsole::createWidget(QList<QString> &list)
{
  QString t;
  
  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("Frame"))
	{
	  if (m_drawArea == NULL)
	    {
	      m_drawArea = new DMXWidget(this, "Bottom Frame");
	      m_drawArea->setBottomFrame(true);
	      m_drawArea->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	      
	      m_layout->addWidget(m_drawArea, 1);
	      
	      m_drawArea->createContents(list);

	      m_drawArea->show();
	    }
	  else
	    {
	      DMXWidget* w = new DMXWidget(m_drawArea);
	      w->createContents(list);
	    }
	}
      else if (*s == QString("Button"))
	{
	  DMXButton* w = new DMXButton(m_drawArea);
	  w->createContents(list);
	}
      else if (*s == QString("SpeedSlider"))
	{
	  SpeedSlider* w = new SpeedSlider(m_drawArea);
	  w->createContents(list);
	}
      else if (*s == QString("Slider"))
	{
	  list.next();
	}
      else
	{
	  // Unknown keyword, skip
	  list.next();
	}
    }
}
Ejemplo n.º 7
0
Archivo: doc.cpp Proyecto: speakman/qlc
void Doc::createJoystickContents(QList<QString> &list)
{
  QString name;
  QString fdName;

  Joystick* j = NULL;

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("FDName"))
	{
	  fdName = *(list.next());
	}
      else if (*s == QString("Name"))
	{
	  name = *(list.next());

	  j = joystickPlugin()->search(fdName);

	  if (j == NULL || j->name() != name)
	    {
	      QString text;
	      text.sprintf("Unable to find joystick \"%s\" from <%s> while loading workspace file.\n", (const char*) name, (const char*) fdName);
	      text += QString("Do you want to select another device (press Yes) or skip this joystick (press No)?");
	      if (QMessageBox::critical(NULL, QString("QLC"), text, QMessageBox::Yes,
					QMessageBox::No) == QMessageBox::Yes)
		{
		  j = joystickPlugin()->selectJoystick();
		}
	    }
	  
	  if (j != NULL)
	    {
	      j->createContents(list);
	      addInputDevice(j);
	      j->open();
	      j->start();
	    }
	}
    }
}
Ejemplo n.º 8
0
Archivo: doc.cpp Proyecto: speakman/qlc
void Doc::createJoystickContents(QList<QString> &list)
{
  QString name;
  QString fdName;

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("FDName"))
	{
	  fdName = *(list.next());
	}
      else if (*s == QString("Name"))
	{
	  name = *(list.next());
	}
    }
}
Ejemplo n.º 9
0
Archivo: doc.cpp Proyecto: speakman/qlc
void Doc::createFunctionContents(QList<QString> &list)
{
  Function* function = NULL;
  DMXDevice* device = NULL;

  unsigned long deviceId = 0;
  unsigned long functionId = ULONG_MAX;

  QString name;

  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("Type"))
	{
	  list.next();
	}
      else if (*s == QString("ID"))
	{
	  functionId = list.next()->toULong();
	}
      else if (*s == QString("Device"))
	{
	  deviceId = list.next()->toInt();
	  if (deviceId == 0)
	    {
	      device = NULL;
	    }
	  else
	    {
	      device = searchDevice(deviceId);
	    }
	  break;
	}
      else
	{
	  // Unknown keyword (at this time)
	  list.next();
	}
    }

  if (functionId == ULONG_MAX)
    {
      qDebug("Couldn't find an ID for function <" + name + ">");
    }
  else
    {
      function = searchFunction(functionId);

      if (function != NULL)
	{
	  function->setDevice(device);
	  function->createContents(list);
	}
      else
	{
	  qDebug("Couldn't find function <" + name + ">");
	}
    }
}
Ejemplo n.º 10
0
Archivo: doc.cpp Proyecto: speakman/qlc
bool Doc::loadWorkspaceAs(QString &fileName)
{
  bool success = false;

  QString buf;
  QString s;
  QString t;
  QList<QString> list;

  newDocument();

  if (FileHandler::readFileToList(fileName, list) == true)
    {
      m_workspaceFileName = QString(fileName);
      
      // Create devices and functions from the list
      for (QString* string = list.first(); string != NULL; string = list.next())
	{
	  if (*string == QString("Entry"))
	    {
	      string = list.next();
	      
	      if (*string == QString("Device"))
		{
		  DMXDevice* d = createDevice(list);
		  
		  if (d != NULL)
		    {
		      addDevice(d);
		    }
		}
	      else if (*string == QString("Function"))
		{
		  // Only create the function but don't care for
		  // its contents yet
		  Function* f = createFunction(list);

		  if (f != NULL)
		    {
		      // Add function to function pool
		      addFunction(f);
		    }
		}
	      else if (*string == QString("Bus"))
		{
		  Bus* bus = new Bus();
		  bus->createContents(list);
		  addBus(bus);

		  _app->virtualConsole()->setDefaultSpeedBus(bus);
		}
	      else if (*string == QString("Joystick"))
		{
		  createJoystickContents(list);
		}
	      else if (*string == QString("Virtual Console"))
		{
		  // Virtual console wants it all, go to "Entry"
		  list.prev();
		  list.prev();

		  _app->virtualConsole()->createContents(list);
		}
	      else
		{
		  // Unknown keyword, do nothing
		}
	    }
	}

      // Now put contents to functions
      // The functions are given their contents after every function
      // object has been created. Otherwise some functions can not
      // be created.
      for (QString* string = list.first(); string != NULL; string = list.next())
	{
	  if (*string == QString("Entry"))
	    {
	      string = list.next();
	      if (*string == QString("Function"))
		{
		  createFunctionContents(list);
		}
	      else
		{
		  // Reel back one step, it might contain the keyword
		  // "Entry"
		  string = list.prev();
		}
	    }
	}

      success = true;
    }
  else
    {
      success = false;
    }
  
  setModified(false);

  return success;
}
Ejemplo n.º 11
0
Archivo: doc.cpp Proyecto: speakman/qlc
void Doc::createFunctionContents(QList<QString> &list)
{
  Function* f = NULL;
  DMXDevice* d = NULL;

  QString name;
  QString type;
  QString device;

  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("Type"))
	{
	  type = *(list.next());
	}
      else if (*s == QString("Device"))
	{
	  device = *(list.next());
	  if (device == QString("Global"))
	    {
	      d = NULL;
	    }
	  else
	    {
	      d = searchDevice(device);
	    }
	  break;
	}
      else
	{
	  // Unknown keyword (at this time)
	  list.next();
	}
    }

  if (name != QString::null && type != QString::null)
    {
      if (d != NULL)
	{
	  f = d->searchFunction(name);
	}
      else
	{
	  f = searchFunction(name);
	}

      if (f != NULL)
	{
	  f->setDevice(d);
	  f->createContents(list);
	}
      else
	{
	  qDebug("Invalid or missing information for function <%s>", (const char*) name);
	}
    }
  else
    {
      qDebug("Invalid or missing information for function <%s>", (const char*) name);
    }
}
Ejemplo n.º 12
0
void Chaser::createContents(QList<QString> &list)
{
  QString device = QString::null;
  QString function = QString::null;
  
  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("Device"))
	{
	  device = *(list.next());
	}
      else if (*s == QString("Function"))
	{
	  function = *(list.next());
	  
	  if (device == QString("Global"))
	    {
	      Function* f = _app->doc()->searchFunction(function);
	      if (f != NULL)
		{
		  addStep(NULL, f);
		}
	      else
		{
		  qDebug("Unable to find member <" + function + "> for Function Collection <" + name() + ">");
		}
	    }
	  else
	    {
	      Device* d = _app->doc()->searchDevice(device, DeviceClass::ANY);
	      Function* f = NULL;
	      if (d != NULL)
		{
		  f = d->searchFunction(function);
		  if (f != NULL)
		    {
		      addStep(d, f);
		    }
		  else if ((f = d->deviceClass()->searchFunction(function)) != NULL)
		    {
		      addStep(d, f);
		    }
		  else
		    {
		      qDebug("Unable to find member <" + function + "> for Function Collection <" + name() + ">");
		    }
		}

	      device = QString::null;
	      function = QString::null;
	    }
	}
      else
	{
	  // Unknown keyword (at this time)
	  list.next();
	}
    }
}