KSimTimeLabel::KSimTimeLabel(const KSimTimeBase * time, QWidget *parent, const char *name) : QLabel(parent,name), m_time(time), m_precision(2) { slotTimeChanged(); }
void ShowManager::setCurrentShowID(int currentShowID) { if (m_currentShow != NULL) { if (m_currentShow->id() == (quint32)currentShowID) return; disconnect(m_currentShow, SIGNAL(timeChanged(quint32)), this, SLOT(slotTimeChanged(quint32))); } m_currentShow = qobject_cast<Show*>(m_doc->function(currentShowID)); emit currentShowIDChanged(currentShowID); if (m_currentShow != NULL) { connect(m_currentShow, SIGNAL(timeChanged(quint32)), this, SLOT(slotTimeChanged(quint32))); emit showDurationChanged(m_currentShow->totalDuration()); emit showNameChanged(m_currentShow->name()); } else { emit showDurationChanged(0); emit showNameChanged(""); } emit tracksChanged(); }
void ShowManager::addItem(QQuickItem *parent, int trackIdx, int startTime, quint32 functionID) { // if no show is selected, then create a new one if (m_currentShow == NULL) { QString defaultName = QString("%1 %2").arg(tr("New Show")).arg(m_doc->nextFunctionID()); m_currentShow = new Show(m_doc); m_currentShow->setName(defaultName); Function *f = qobject_cast<Function*>(m_currentShow); if (m_doc->addFunction(f) == false) { qDebug() << "Error in creating a new Show !"; m_currentShow = NULL; return; } connect(m_currentShow, SIGNAL(timeChanged(quint32)), this, SLOT(slotTimeChanged(quint32))); emit currentShowIDChanged(m_currentShow->id()); emit showNameChanged(m_currentShow->name()); } Track *selectedTrack = NULL; // if no Track index is provided, then add a new one if (trackIdx == -1) { selectedTrack = new Track(); selectedTrack->setName(tr("Track %1").arg(m_currentShow->tracks().count() + 1)); m_currentShow->addTrack(selectedTrack); trackIdx = m_currentShow->tracks().count() - 1; emit tracksChanged(); } else { if (trackIdx >= m_currentShow->tracks().count()) { qDebug() << "Track index out of bounds !" << trackIdx; return; } selectedTrack = m_currentShow->tracks().at(trackIdx); } // and now create the actual ShowFunction and the QML item Function *func = m_doc->function(functionID); if (func == NULL) return; ShowFunction *showFunc = selectedTrack->createShowFunction(functionID); showFunc->setStartTime(startTime); showFunc->setDuration(func->totalDuration()); showFunc->setColor(ShowFunction::defaultColor(func->type())); QQuickItem *newItem = qobject_cast<QQuickItem*>(siComponent->create()); newItem->setParentItem(parent); newItem->setProperty("trackIndex", trackIdx); newItem->setProperty("sfRef", QVariant::fromValue(showFunc)); newItem->setProperty("funcRef", QVariant::fromValue(func)); quint32 itemIndex = m_itemsMap.isEmpty() ? 0 : m_itemsMap.lastKey() + 1; quint32 itemID = trackIdx << 16 | itemIndex; m_itemsMap[itemID] = newItem; emit showDurationChanged(m_currentShow->totalDuration()); }