DeviceClass* Doc::searchDeviceClass(const QString &manufacturer, const QString &model) { for (DeviceClass* d = m_deviceClassList.first(); d != NULL; d = m_deviceClassList.next()) { if (d->manufacturer() == manufacturer && d->model() == model) { return d; } } return NULL; }
void NewDevice::fillTree() { QListViewItem* parent = NULL; QListViewItem* newItem = NULL; QPtrList <DeviceClass> *dl = _app->deviceClassList(); QPixmap pm(PIXMAPS + QString("/dmx.xpm")); QString config; bool treeOpen = false; if (_app->settings()->get("NewDeviceTreeOpen", config) != -1 && config == Settings::trueValue()) { treeOpen = true; } else { treeOpen = false; } m_tree->clear(); for (DeviceClass* dc = dl->first(); dc != NULL; dc = dl->next()) { bool alreadyAdded = false; for (QListViewItem* i = m_tree->firstChild(); i != NULL; i = i->nextSibling()) { if (i->text(0) == dc->manufacturer()) { alreadyAdded = true; parent = i; break; } } if (alreadyAdded == false) { parent = new QListViewItem(m_tree, dc->manufacturer()); parent->setOpen(treeOpen); } parent->setPixmap(0, QPixmap(PIXMAPS + QString("/global.xpm"))); newItem = new QListViewItem(parent, dc->model()); newItem->setPixmap(0, pm); newItem->setText(1,dc->type()); } }
void NewDevice::showModels(QString mfg) { m_model->clear(); QList <DeviceClass> dclist(_app->doc()->deviceClassList()); for (DeviceClass* dc = dclist.first(); dc != NULL; dc = dclist.next()) { if (mfg == dc->manufacturer()) { if (dc->protocol() == DeviceClass::DMX512) { QPixmap pm(_app->settings()->getPixmapPath() + QString("dmx.xpm")); m_model->insertItem(pm, dc->model()); } else { m_model->insertItem(dc->model()); } } } slotModelActivated(m_model->currentItem()); }
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; }
void NewDevice::fillTree() { QListViewItem* parent = NULL; QListViewItem* newItem = NULL; QPtrList <DeviceClass> *dl = _app->deviceClassList(); QString path; _app->settings()->get("SystemPath", path); path += QString("/") + PIXMAPPATH; QPixmap pm(path + QString("/dmx.xpm")); QString tree; _app->settings()->get("NewDeviceTreeOpen", tree); bool treeOpen = (tree == Settings::trueValue()) ? true : false; m_tree->clear(); for (DeviceClass* dc = dl->first(); dc != NULL; dc = dl->next()) { bool alreadyAdded = false; for (QListViewItem* i = m_tree->firstChild(); i != NULL; i = i->nextSibling()) { if (i->text(0) == dc->manufacturer()) { alreadyAdded = true; parent = i; break; } } if (alreadyAdded == false) { parent = new QListViewItem(m_tree, dc->manufacturer()); parent->setOpen(treeOpen); } parent->setPixmap(0, QPixmap(path + QString("/global.xpm"))); newItem = new QListViewItem(parent, dc->model()); newItem->setPixmap(0, pm); newItem->setText(1,dc->type()); } }
void NewDevice::fillTree() { QListViewItem* parent = NULL; QListViewItem* newItem = NULL; QList <DeviceClass> dclist(_app->doc()->deviceClassList()); QPixmap pm(_app->settings()->pixmapPath() + QString("dmx.xpm")); m_tree->clear(); for (DeviceClass* dc = dclist.first(); dc != NULL; dc = dclist.next()) { bool alreadyAdded = false; for (QListViewItem* i = m_tree->firstChild(); i != NULL; i = i->nextSibling()) { if (i->text(0) == dc->manufacturer()) { alreadyAdded = true; parent = i; break; } } if (alreadyAdded == false) { parent = new QListViewItem(m_tree, dc->manufacturer()); if (_app->settings()->newDeviceTreeOpen() == true) { parent->setOpen(true); } } parent->setPixmap(0, QPixmap(_app->settings()->pixmapPath() + QString("global.xpm"))); newItem = new QListViewItem(parent, dc->model()); newItem->setPixmap(0, pm); newItem->setText(1,dc->type()); } }
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; } } } }