RGBMatrixEditor::RGBMatrixEditor(QWidget* parent, RGBMatrix* mtx, Doc* doc) : QWidget(parent) , m_doc(doc) , m_matrix(mtx) , m_speedDials(NULL) , m_scene(new QGraphicsScene(this)) , m_previewTimer(new QTimer(this)) , m_previewIterator(0) , m_previewStep(0) { Q_ASSERT(doc != NULL); Q_ASSERT(mtx != NULL); setupUi(this); // Set a nice gradient backdrop m_scene->setBackgroundBrush(Qt::darkGray); QLinearGradient gradient(200, 200, 200, 2000); gradient.setSpread(QGradient::ReflectSpread); m_scene->setBackgroundBrush(gradient); connect(m_previewTimer, SIGNAL(timeout()), this, SLOT(slotPreviewTimeout())); connect(m_doc, SIGNAL(modeChanged(Doc::Mode)), this, SLOT(slotModeChanged(Doc::Mode))); connect(m_doc, SIGNAL(fixtureGroupAdded(quint32)), this, SLOT(slotFixtureGroupAdded())); connect(m_doc, SIGNAL(fixtureGroupRemoved(quint32)), this, SLOT(slotFixtureGroupRemoved())); connect(m_doc, SIGNAL(fixtureGroupChanged(quint32)), this, SLOT(slotFixtureGroupChanged(quint32))); init(); slotModeChanged(m_doc->mode()); // Set focus to the editor m_nameEdit->setFocus(); }
bool Doc::deleteFixtureGroup(quint32 id) { if (m_fixtureGroups.contains(id) == true) { FixtureGroup* grp = m_fixtureGroups.take(id); Q_ASSERT(grp != NULL); emit fixtureGroupRemoved(id); setModified(); delete grp; return true; } else { qWarning() << Q_FUNC_INFO << "No fixture group with id" << id; return false; } }
void Doc_Test::removeFixtureGroup() { QSignalSpy spy(m_doc, SIGNAL(fixtureGroupRemoved(quint32))); QCOMPARE(m_doc->fixtureGroups().size(), 0); QCOMPARE(m_doc->m_latestFixtureGroupId, quint32(0)); QCOMPARE(m_doc->deleteFixtureGroup(0), false); QCOMPARE(spy.size(), 0); FixtureGroup* grp = new FixtureGroup(m_doc); QCOMPARE(m_doc->addFixtureGroup(grp), true); grp = new FixtureGroup(m_doc); QCOMPARE(m_doc->addFixtureGroup(grp), true); grp = new FixtureGroup(m_doc); QCOMPARE(m_doc->addFixtureGroup(grp), true); QCOMPARE(m_doc->fixtureGroups().size(), 3); QVERIFY(m_doc->fixtureGroup(0) != NULL); QVERIFY(m_doc->fixtureGroup(1) != NULL); QVERIFY(m_doc->fixtureGroup(2) != NULL); QCOMPARE(m_doc->deleteFixtureGroup(0), true); QCOMPARE(spy.size(), 1); QCOMPARE(spy[0].size(), 1); QCOMPARE(spy[0][0].toUInt(), quint32(0)); QCOMPARE(m_doc->fixtureGroups().size(), 2); QVERIFY(m_doc->fixtureGroup(0) == NULL); QVERIFY(m_doc->fixtureGroup(1) != NULL); QVERIFY(m_doc->fixtureGroup(2) != NULL); QCOMPARE(m_doc->deleteFixtureGroup(0), false); QCOMPARE(spy.size(), 1); QCOMPARE(m_doc->deleteFixtureGroup(1), true); QCOMPARE(spy.size(), 2); QCOMPARE(spy[1].size(), 1); QCOMPARE(spy[1][0].toUInt(), quint32(1)); QCOMPARE(m_doc->fixtureGroups().size(), 1); QVERIFY(m_doc->fixtureGroup(0) == NULL); QVERIFY(m_doc->fixtureGroup(1) == NULL); QVERIFY(m_doc->fixtureGroup(2) != NULL); }
void Doc::clearContents() { emit clearing(); // Delete all function instances QListIterator <quint32> funcit(m_functions.keys()); while (funcit.hasNext() == true) { Function* func = m_functions.take(funcit.next()); emit functionRemoved(func->id()); delete func; } // Delete all fixture instances QListIterator <quint32> fxit(m_fixtures.keys()); while (fxit.hasNext() == true) { Fixture* fxi = m_fixtures.take(fxit.next()); emit fixtureRemoved(fxi->id()); delete fxi; } // Delete all fixture groups QListIterator <quint32> grpit(m_fixtureGroups.keys()); while (grpit.hasNext() == true) { FixtureGroup* grp = m_fixtureGroups.take(grpit.next()); emit fixtureGroupRemoved(grp->id()); delete grp; } m_latestFunctionId = 0; m_latestFixtureId = 0; m_latestFixtureGroupId = 0; m_addresses.clear(); emit cleared(); }
void Doc::clearContents() { emit clearing(); m_clipboard->resetContents(); if (m_monitorProps != NULL) m_monitorProps->reset(); destroyAudioCapture(); // Delete all function instances QListIterator <quint32> funcit(m_functions.keys()); while (funcit.hasNext() == true) { Function* func = m_functions.take(funcit.next()); if (func == NULL) continue; emit functionRemoved(func->id()); delete func; } // Delete all fixture groups QListIterator <quint32> grpit(m_fixtureGroups.keys()); while (grpit.hasNext() == true) { FixtureGroup* grp = m_fixtureGroups.take(grpit.next()); quint32 grpID = grp->id(); delete grp; emit fixtureGroupRemoved(grpID); } // Delete all fixture instances QListIterator <quint32> fxit(m_fixtures.keys()); while (fxit.hasNext() == true) { Fixture* fxi = m_fixtures.take(fxit.next()); quint32 fxID = fxi->id(); delete fxi; emit fixtureRemoved(fxID); } // Delete all channels groups QListIterator <quint32> grpchans(m_channelsGroups.keys()); while (grpchans.hasNext() == true) { ChannelsGroup* grp = m_channelsGroups.take(grpchans.next()); emit channelsGroupRemoved(grp->id()); delete grp; } m_orderedGroups.clear(); m_latestFunctionId = 0; m_latestFixtureId = 0; m_latestFixtureGroupId = 0; m_latestChannelsGroupId = 0; m_addresses.clear(); emit cleared(); }