void KeyframeEdit::addParameter(const QDomElement &e, int activeKeyframe) { keyframe_list->blockSignals(true); m_params.append(e.cloneNode().toElement()); QDomElement na = e.firstChildElement(QStringLiteral("name")); QString paramName = i18n(na.text().toUtf8().data()); QDomElement commentElem = e.firstChildElement(QStringLiteral("comment")); QString comment; if (!commentElem.isNull()) comment = i18n(commentElem.text().toUtf8().data()); int columnId = keyframe_list->columnCount(); keyframe_list->insertColumn(columnId); keyframe_list->setHorizontalHeaderItem(columnId, new QTableWidgetItem(paramName)); DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, 0, m_params.at(columnId).attribute(QStringLiteral("min")).toDouble(), m_params.at(columnId).attribute(QStringLiteral("max")).toDouble(), m_params.at(columnId).attribute(QStringLiteral("default")).toDouble(), comment, columnId, m_params.at(columnId).attribute(QStringLiteral("suffix")), m_params.at(columnId).attribute(QStringLiteral("decimals")).toInt(), this); connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotAdjustKeyframeValue(double))); connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool))); connect(doubleparam, SIGNAL(setInTimeline(int)), this, SLOT(slotUpdateVisibleParameter(int))); m_slidersLayout->addWidget(doubleparam, columnId, 0); if (e.attribute(QStringLiteral("intimeline")) == QLatin1String("1")) { doubleparam->setInTimelineProperty(true); } QStringList frames = e.attribute(QStringLiteral("keyframes")).split(';', QString::SkipEmptyParts); for (int i = 0; i < frames.count(); ++i) { int frame = frames.at(i).section('=', 0, 0).toInt(); bool found = false; int j; for (j = 0; j < keyframe_list->rowCount(); ++j) { int currentPos = getPos(j); if (frame == currentPos) { keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1))); found = true; break; } else if (currentPos > frame) { break; } } if (!found) { keyframe_list->insertRow(j); keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(getPosString(frame))); keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1))); keyframe_list->resizeRowToContents(j); } if ((activeKeyframe > -1) && (activeKeyframe == frame)) { keyframe_list->setCurrentCell(i, columnId); keyframe_list->selectRow(i); } } keyframe_list->resizeColumnsToContents(); keyframe_list->blockSignals(false); keyframe_list->horizontalHeader()->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); keyframe_list->verticalHeader()->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); slotAdjustKeyframeInfo(false); button_delete->setEnabled(keyframe_list->rowCount() > 1); }
void KeyframeEdit::slotUpdateVisibleParameter(int id, bool update) { for (int i = 0; i < m_params.count(); ++i) { m_params[i].setAttribute(QStringLiteral("intimeline"), (i == id ? "1" : "0")); } for (int col = 0; col < keyframe_list->columnCount(); ++col) { DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget()); if (!doubleparam) continue; doubleparam->setInTimelineProperty(col == id); ////qDebug()<<"// PARAM: "<<col<<" Set TO: "<<(bool) (col == id); } if (update) emit parameterChanged(); }