aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp')
-rw-r--r--src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp61
1 files changed, 11 insertions, 50 deletions
diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp
index f2fe2eda4e..2aa66b0f80 100644
--- a/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp
+++ b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp
@@ -30,7 +30,6 @@
#include <QEasingCurve>
#include <QPainter>
-#include <QPainterPath>
#include <algorithm>
#include <cmath>
@@ -39,46 +38,32 @@
namespace DesignTools {
CurveItem::CurveItem(QGraphicsItem *parent)
- : QGraphicsObject(parent)
+ : CurveEditorItem(parent)
, m_id(0)
, m_style()
, m_type(ValueType::Undefined)
, m_component(PropertyTreeItem::Component::Generic)
, m_transform()
, m_keyframes()
- , m_locked(false)
- , m_pinned(false)
- , m_underMouse(false)
, m_itemDirty(false)
{}
CurveItem::CurveItem(unsigned int id, const AnimationCurve &curve, QGraphicsItem *parent)
- : QGraphicsObject(parent)
+ : CurveEditorItem(parent)
, m_id(id)
, m_style()
, m_type(ValueType::Undefined)
, m_component(PropertyTreeItem::Component::Generic)
, m_transform()
, m_keyframes()
- , m_locked(false)
- , m_pinned(false)
- , m_underMouse(false)
, m_itemDirty(false)
{
- setAcceptHoverEvents(true);
-
setFlag(QGraphicsItem::ItemIsMovable, false);
-
setCurve(curve);
}
CurveItem::~CurveItem() {}
-bool CurveItem::isUnderMouse() const
-{
- return m_underMouse;
-}
-
int CurveItem::type() const
{
return Type;
@@ -132,9 +117,9 @@ void CurveItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidg
if (segment.interpolation() == Keyframe::Interpolation::Easing) {
pen.setColor(m_style.easingCurveColor);
} else {
- if (m_locked)
+ if (locked())
pen.setColor(Qt::black);
- else if (m_underMouse)
+ else if (isUnderMouse())
pen.setColor(Qt::red);
else if (hasSelection())
pen.setColor(m_style.selectionColor);
@@ -148,19 +133,17 @@ void CurveItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidg
}
}
-bool CurveItem::isDirty() const
+void CurveItem::lockedCallback()
{
- return m_itemDirty;
-}
+ for (auto frame : m_keyframes)
+ frame->setLocked(locked());
-bool CurveItem::locked() const
-{
- return m_locked;
+ setHandleVisibility(!locked());
}
-bool CurveItem::pinned() const
+bool CurveItem::isDirty() const
{
- return m_pinned;
+ return m_itemDirty;
}
bool CurveItem::hasSelection() const
@@ -283,20 +266,6 @@ void CurveItem::restore()
}
}
-void CurveItem::setLocked(bool locked)
-{
- m_locked = locked;
- for (auto frame : m_keyframes)
- frame->setLocked(locked);
-
- setHandleVisibility(!m_locked);
-}
-
-void CurveItem::setPinned(bool pinned)
-{
- m_pinned = pinned;
-}
-
void CurveItem::setDirty(bool dirty)
{
m_itemDirty = dirty;
@@ -324,7 +293,7 @@ void CurveItem::setCurve(const AnimationCurve &curve)
for (auto frame : curve.keyframes()) {
auto *item = new KeyframeItem(frame, this);
- item->setLocked(m_locked);
+ item->setLocked(locked());
item->setComponentTransform(m_transform);
m_keyframes.push_back(item);
QObject::connect(item, &KeyframeItem::redrawCurve, this, &CurveItem::emitCurveChanged);
@@ -385,14 +354,6 @@ void CurveItem::connect(GraphicsScene *scene)
}
}
-void CurveItem::setIsUnderMouse(bool under)
-{
- if (under != m_underMouse) {
- m_underMouse = under;
- update();
- }
-}
-
void CurveItem::insertKeyframeByTime(double time)
{
AnimationCurve acurve = curve();