***************************************************************************/
#include "keyframeedit.h"
-#include "doubleparameterwidget.h"
+#include "widgets/doubleparameterwidget.h"
#include "positionedit.h"
#include "kdenlivesettings.h"
#include <QHeaderView>
-KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, Timecode tc, int activeKeyframe, QWidget* parent) :
- QWidget(parent),
- m_min(minFrame),
- m_max(maxFrame),
- m_timecode(tc)
+KeyframeEdit::KeyframeEdit(const QDomElement &e, int minFrame, int maxFrame, const Timecode &tc, int activeKeyframe, QWidget* parent) :
+ QWidget(parent),
+ m_min(minFrame),
+ m_max(maxFrame),
+ m_timecode(tc)
{
setupUi(this);
if (m_max == -1) {
buttonResetKeyframe->setIcon(KIcon("edit-undo"));
buttonSeek->setIcon(KIcon("insert-link"));
connect(keyframe_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotAdjustKeyframeInfo()));
- connect(keyframe_list, SIGNAL(cellChanged(int, int)), this, SLOT(slotGenerateParams(int, int)));
+ connect(keyframe_list, SIGNAL(cellChanged(int,int)), this, SLOT(slotGenerateParams(int,int)));
m_position = new PositionEdit(i18n("Position"), 0, 0, 1, tc, widgetTable);
((QGridLayout*)widgetTable->layout())->addWidget(m_position, 3, 0, 1, -1);
connect(buttonResetKeyframe, SIGNAL(clicked()), this, SLOT(slotResetKeyframe()));
connect(m_position, SIGNAL(parameterChanged(int)), this, SLOT(slotAdjustKeyframePos(int)));
- //connect(keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int)));
+ //connect(keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem*,int)));
if (!keyframe_list->currentItem()) {
keyframe_list->setCurrentCell(0, 0);
}
}
-void KeyframeEdit::addParameter(QDomElement e, int activeKeyframe)
+void KeyframeEdit::addParameter(const QDomElement &e, int activeKeyframe)
{
keyframe_list->blockSignals(true);
m_params.append(e.cloneNode().toElement());
keyframe_list->setHorizontalHeaderItem(columnId, new QTableWidgetItem(paramName));
DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, 0,
- m_params.at(columnId).attribute("min").toInt(), m_params.at(columnId).attribute("max").toInt(),
- m_params.at(columnId).attribute("default").toInt(), comment, columnId, m_params.at(columnId).attribute("suffix"), this);
- connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframeValue(int)));
+ m_params.at(columnId).attribute("min").toDouble(), m_params.at(columnId).attribute("max").toDouble(),
+ m_params.at(columnId).attribute("default").toDouble(), comment, columnId, m_params.at(columnId).attribute("suffix"), m_params.at(columnId).attribute("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);
doubleparam->setInTimelineProperty(true);
}
- QStringList frames = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
- for (int i = 0; i < frames.count(); i++) {
- int frame = frames.at(i).section(':', 0, 0).toInt();
+ QStringList frames = e.attribute("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)));
+ keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1)));
found = true;
break;
} else if (currentPos > frame) {
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->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1)));
keyframe_list->resizeRowToContents(j);
}
if ((activeKeyframe > -1) && (activeKeyframe == frame)) {
keyframe_list->insertRow(newrow);
keyframe_list->setVerticalHeaderItem(newrow, new QTableWidgetItem(getPosString(result)));
- for (int i = 0; i < keyframe_list->columnCount(); i++)
+ for (int i = 0; i < keyframe_list->columnCount(); ++i)
keyframe_list->setItem(newrow, i, new QTableWidgetItem(keyframe_list->item(item->row(), i)->text()));
keyframe_list->resizeRowsToContents();
for (int col = 0; col < keyframe_list->horizontalHeader()->count(); col++) {
item = keyframe_list->item(row, col);
+ if (!item) continue;
int v = item->text().toInt();
if (v >= m_params.at(col).attribute("max").toInt())
item->setText(m_params.at(col).attribute("max"));
if (v <= m_params.at(col).attribute("min").toInt())
item->setText(m_params.at(col).attribute("min"));
QString keyframes;
- for (int i = 0; i < keyframe_list->rowCount(); i++) {
+ for (int i = 0; i < keyframe_list->rowCount(); ++i) {
if (keyframe_list->item(i, col))
- keyframes.append(QString::number(getPos(i)) + ':' + keyframe_list->item(i, col)->text() + ';');
+ keyframes.append(QString::number(getPos(i)) + '=' + keyframe_list->item(i, col)->text() + ';');
}
m_params[col].setAttribute("keyframes", keyframes);
}
slotAdjustKeyframeInfo(false);
QString keyframes;
- for (int i = 0; i < keyframe_list->rowCount(); i++) {
+ for (int i = 0; i < keyframe_list->rowCount(); ++i) {
if (keyframe_list->item(i, column))
- keyframes.append(QString::number(getPos(i)) + ':' + keyframe_list->item(i, column)->text() + ';');
+ keyframes.append(QString::number(getPos(i)) + '=' + keyframe_list->item(i, column)->text() + ';');
}
m_params[column].setAttribute("keyframes", keyframes);
emit parameterChanged();
{
for (int col = 0; col < keyframe_list->columnCount(); col++) {
QString keyframes;
- for (int i = 0; i < keyframe_list->rowCount(); i++) {
+ for (int i = 0; i < keyframe_list->rowCount(); ++i) {
if (keyframe_list->item(i, col))
- keyframes.append(QString::number(getPos(i)) + ':' + keyframe_list->item(i, col)->text() + ';');
+ keyframes.append(QString::number(getPos(i)) + '=' + keyframe_list->item(i, col)->text() + ';');
}
m_params[col].setAttribute("keyframes", keyframes);
}
max = getPos(below->row()) - 1;
m_position->blockSignals(true);
- m_position->setRange(min, max);
+ m_position->setRange(min, max, true);
m_position->setPosition(getPos(item->row()));
m_position->blockSignals(false);
continue;
doubleparam->blockSignals(true);
if (keyframe_list->item(item->row(), col)) {
- doubleparam->setValue(keyframe_list->item(item->row(), col)->text().toInt());
+ doubleparam->setValue(keyframe_list->item(item->row(), col)->text().toDouble());
} else {
kDebug() << "Null pointer exception caught: http://www.kdenlive.org/mantis/view.php?id=1771";
}
emit seekToPos(value - m_min);
}
-void KeyframeEdit::slotAdjustKeyframeValue(int value)
+void KeyframeEdit::slotAdjustKeyframeValue(double value)
{
Q_UNUSED(value)
DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget());
if (!doubleparam)
continue;
- int val = doubleparam->getValue();
+ double val = doubleparam->getValue();
QTableWidgetItem *nitem = keyframe_list->item(item->row(), col);
- if (nitem && nitem->text().toInt() != val)
+ if (nitem && nitem->text().toDouble() != val)
nitem->setText(QString::number(val));
}
//keyframe_list->item(item->row() - 1, item->column());
int KeyframeEdit::getPos(int row)
{
+ if (!keyframe_list->verticalHeaderItem(row))
+ return 0;
if (KdenliveSettings::frametimecode())
return keyframe_list->verticalHeaderItem(row)->text().toInt();
else
void KeyframeEdit::slotUpdateVisibleParameter(int id, bool update)
{
for (int i = 0; i < m_params.count(); ++i) {
- m_params[i].setAttribute("intimeline", (i == id ? "1" : "0"));
+ m_params[i].setAttribute("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 (m_params.count() == 0)
return;
- foreach(QDomElement elem, m_params) {
+ foreach(const QDomElement &elem, m_params) {
if (elem.attribute("intimeline") == "1")
return;
}
slotUpdateVisibleParameter(0);
}
+void KeyframeEdit::slotUpdateRange(int inPoint, int outPoint)
+{
+ m_min = inPoint;
+ m_max = outPoint;
+}
+
#include "keyframeedit.moc"