Merge remote-tracking branch 'origin/4.10'

Change-Id: Idfe86eb91c7a9a16f15d528a2a03beecca1cb208
This commit is contained in:
Eike Ziller
2019-08-27 09:47:14 +02:00
23 changed files with 239 additions and 78 deletions

View File

@@ -442,7 +442,7 @@ def qdump__std__set(d, value):
d.putSubItem(i, val)
if node["_M_right"].pointer() == 0:
parent = node["_M_parent"]
while node == parent["_M_right"]:
while node.pointer() == parent["_M_right"].pointer():
node = parent
parent = parent["_M_parent"]
if node["_M_right"] != parent:

View File

@@ -247,8 +247,11 @@ Rectangle {
active = true
}
property int loaderHeight: specificsOne.item.height + tabView.extraHeight
onLoaderHeightChanged: tabView.specficsOneHeight = loaderHeight
onLoaded: {
tabView.specficsTwoHeight = specificsTwo.item.height + tabView.extraHeight
tabView.specficsTwoHeight = loaderHeight
}
}
@@ -259,8 +262,11 @@ Rectangle {
id: specificsOne;
source: specificsUrl;
property int loaderHeight: specificsOne.item.height + tabView.extraHeight
onLoaderHeightChanged: tabView.specficsOneHeight = loaderHeight
onLoaded: {
tabView.specficsOneHeight = specificsOne.item.height + tabView.extraHeight
tabView.specficsOneHeight = loaderHeight
}
}
}

View File

@@ -427,7 +427,7 @@ void TaskWindow::loadSettings()
if (value.isValid()) {
bool includeWarnings = value.toBool();
d->m_filter->setFilterIncludesWarnings(includeWarnings);
d->m_filterWarningsButton->setDown(d->m_filter->filterIncludesWarnings());
d->m_filterWarningsButton->setChecked(d->m_filter->filterIncludesWarnings());
}
}

View File

@@ -61,12 +61,12 @@ AnimationCurve::AnimationCurve(const QEasingCurve &easing, const QPointF &start,
};
QVector<QPointF> points = easing.toCubicSpline();
int numSegments = points.count() / 3;
int numSegments = points.size() / 3;
Keyframe current;
Keyframe tmp(start);
current.setInterpolation(Keyframe::Interpolation::Bezier);
current.setInterpolation(Keyframe::Interpolation::Linear);
tmp.setInterpolation(Keyframe::Interpolation::Bezier);
for (int i = 0; i < numSegments; i++) {
@@ -80,6 +80,8 @@ AnimationCurve::AnimationCurve(const QEasingCurve &easing, const QPointF &start,
m_frames.push_back(current);
current.setInterpolation(tmp.interpolation());
tmp.setLeftHandle(p2);
tmp.setPosition(p3);
}
@@ -189,6 +191,14 @@ QPainterPath AnimationCurve::intersectionPath() const
return path;
}
Keyframe AnimationCurve::keyframeAt(size_t id) const
{
if (id >= m_frames.size())
return Keyframe();
return m_frames.at(id);
}
std::vector<Keyframe> AnimationCurve::keyframes() const
{
return m_frames;

View File

@@ -66,6 +66,8 @@ public:
QPainterPath intersectionPath() const;
Keyframe keyframeAt(size_t id) const;
std::vector<Keyframe> keyframes() const;
std::vector<QPointF> extrema() const;

View File

@@ -35,7 +35,6 @@ CurveEditorModel::CurveEditorModel(QObject *parent)
CurveEditorModel::~CurveEditorModel() {}
void CurveEditorModel::setCurrentFrame(int frame)
{
if (graphicsView())
@@ -54,6 +53,8 @@ void CurveEditorModel::setCurve(unsigned int id, const AnimationCurve &curve)
void CurveEditorModel::reset(const std::vector<TreeItem *> &items)
{
std::vector<TreeItem::Path> sel = selection();
beginResetModel();
initialize();
@@ -65,6 +66,8 @@ void CurveEditorModel::reset(const std::vector<TreeItem *> &items)
}
endResetModel();
select(sel);
}
} // End namespace DesignTools.

View File

@@ -64,11 +64,7 @@ CurveItem::CurveItem(unsigned int id, const AnimationCurve &curve, QGraphicsItem
setFlag(QGraphicsItem::ItemIsMovable, false);
for (auto frame : curve.keyframes()) {
auto *item = new KeyframeItem(frame, this);
QObject::connect(item, &KeyframeItem::redrawCurve, this, &CurveItem::emitCurveChanged);
m_keyframes.push_back(item);
}
setCurve(curve);
}
CurveItem::~CurveItem() {}
@@ -334,7 +330,7 @@ void CurveItem::setInterpolation(Keyframe::Interpolation interpolation)
prevItem->setKeyframe(segment.left());
currItem->setKeyframe(segment.right());
m_itemDirty = true;
setDirty(true);
}
prevItem = currItem;
@@ -380,7 +376,7 @@ void CurveItem::deleteSelectedKeyframes()
void CurveItem::emitCurveChanged()
{
m_itemDirty = true;
setDirty(true);
update();
}

View File

@@ -67,6 +67,8 @@ double GraphicsScene::maximumValue() const
void GraphicsScene::addCurveItem(CurveItem *item)
{
m_dirty = true;
item->setDirty(false);
addItem(item);
item->connect(this);
}
@@ -144,13 +146,10 @@ void GraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
// CurveItems might become invalid after a keyframe-drag operation.
curveItem->restore();
if (curveItem->contains(mouseEvent->scenePos()))
curveItem->setSelected(true);
if (curveItem->isDirty()) {
emit curveChanged(curveItem->id(), curveItem->curve());
curveItem->setDirty(false);
m_dirty = true;
curveItem->setDirty(false);
emit curveChanged(curveItem->id(), curveItem->curve());
}
}
}

View File

@@ -203,7 +203,7 @@ void KeyframeItem::updatePosition(bool update)
if (m_right)
updateHandle(m_right, false);
if (update) {
if (update && position != oldPosition) {
emit redrawCurve();
emit keyframeMoved(this, position - oldPosition);
}
@@ -307,7 +307,6 @@ QVariant KeyframeItem::itemChange(QGraphicsItem::GraphicsItemChange change, cons
void KeyframeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
SelectableItem::mousePressEvent(event);
if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(parentItem()))
curveItem->setHandleVisibility(false);
}

View File

@@ -26,6 +26,7 @@
#include "treemodel.h"
#include "detail/graphicsview.h"
#include "treeitem.h"
#include "treeview.h"
#include <QIcon>
@@ -125,6 +126,11 @@ int TreeModel::columnCount(const QModelIndex &parent) const
return m_root->columnCount();
}
void TreeModel::setTreeView(TreeView *view)
{
m_tree = view;
}
void TreeModel::setGraphicsView(GraphicsView *view)
{
m_view = view;
@@ -135,6 +141,52 @@ GraphicsView *TreeModel::graphicsView() const
return m_view;
}
std::vector<TreeItem::Path> TreeModel::selection() const
{
std::vector<TreeItem::Path> out;
for (auto &&index : m_tree->selectionModel()->selectedIndexes()) {
if (index.column() == 0) {
TreeItem *item = static_cast<TreeItem *>(index.internalPointer());
out.push_back(item->path());
}
}
return out;
}
QModelIndex TreeModel::findIdx(const QString &name, const QModelIndex &parent) const
{
for (int i = 0; i < rowCount(parent); ++i) {
QModelIndex idx = index(i, 0, parent);
if (idx.isValid()) {
TreeItem *item = static_cast<TreeItem *>(idx.internalPointer());
if (item->name() == name)
return idx;
}
}
return QModelIndex();
}
QModelIndex TreeModel::indexOf(const TreeItem::Path &path) const
{
QModelIndex parent;
for (size_t i = 0; i < path.size(); ++i) {
QModelIndex idx = findIdx(path[i], parent);
if (idx.isValid())
parent = idx;
}
return parent;
}
void TreeModel::select(const std::vector<TreeItem::Path> &selection)
{
for (auto &&sel : selection) {
QModelIndex idx = indexOf(sel);
if (idx.isValid())
m_tree->selectionModel()->select(idx, QItemSelectionModel::Select);
}
}
void TreeModel::initialize()
{
if (m_root)

View File

@@ -25,6 +25,8 @@
#pragma once
#include "treeitem.h"
#include <QAbstractItemModel>
#include <vector>
@@ -32,7 +34,7 @@
namespace DesignTools {
class GraphicsView;
class TreeItem;
class TreeView;
class TreeModel : public QAbstractItemModel
{
@@ -45,7 +47,9 @@ public:
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QVariant headerData(int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
@@ -55,20 +59,32 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
void setTreeView(TreeView *view);
void setGraphicsView(GraphicsView *view);
protected:
GraphicsView *graphicsView() const;
std::vector<TreeItem::Path> selection() const;
void select(const std::vector<TreeItem::Path> &selection);
void initialize();
TreeItem *root();
TreeItem *find(unsigned int id);
QModelIndex findIdx(const QString &name, const QModelIndex &parent) const;
QModelIndex indexOf(const TreeItem::Path &path) const;
private:
GraphicsView *m_view;
TreeView *m_tree;
TreeItem *m_root;
};

View File

@@ -36,6 +36,8 @@ namespace DesignTools {
TreeView::TreeView(CurveEditorModel *model, QWidget *parent)
: QTreeView(parent)
{
model->setTreeView(this);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setUniformRowHeights(true);
setRootIsDecorated(false);

View File

@@ -72,6 +72,25 @@ QString TreeItem::name() const
return m_name;
}
TreeItem::Path TreeItem::path() const
{
Path fullName;
fullName.push_back(name());
TreeItem *parent = this->parent();
while (parent) {
if (parent->name() == "Root")
break;
fullName.push_back(parent->name());
parent = parent->parent();
}
std::reverse(fullName.begin(), fullName.end());
return fullName;
}
bool TreeItem::hasChildren() const
{
return !m_children.empty();
@@ -87,6 +106,20 @@ bool TreeItem::pinned() const
return m_pinned;
}
bool TreeItem::compare(const std::vector<QString> &path) const
{
auto thisPath = this->path();
if (thisPath.size() != path.size())
return false;
for (size_t i = 0; i < thisPath.size(); ++i) {
if (thisPath[i] != path[i])
return false;
}
return true;
}
int TreeItem::row() const
{
if (m_parent) {

View File

@@ -45,6 +45,9 @@ class PropertyTreeItem;
class TreeItem
{
public:
using Path = std::vector<QString>;
public:
TreeItem(const QString &name);
@@ -60,12 +63,16 @@ public:
QString name() const;
Path path() const;
bool hasChildren() const;
bool locked() const;
bool pinned() const;
bool compare(const std::vector<QString> &path) const;
int row() const;
int column() const;

View File

@@ -122,9 +122,7 @@ DesignTools::ValueType typeFrom(const QmlTimelineKeyframeGroup &group)
if (group.valueType() == TypeName("integer") || group.valueType() == TypeName("int"))
return DesignTools::ValueType::Integer;
// Ignoring types:
// QColor / HAlignment / VAlignment
// Ignoring: QColor / HAlignment / VAlignment
return DesignTools::ValueType::Undefined;
}
@@ -170,48 +168,61 @@ DesignTools::AnimationCurve AnimationCurveEditorModel::createAnimationCurve(
}
}
std::vector<DesignTools::Keyframe> createKeyframes(QList<ModelNode> nodes)
{
auto byTime = [](const auto &a, const auto &b) {
return a.variantProperty("frame").value().toDouble()
< b.variantProperty("frame").value().toDouble();
};
std::sort(nodes.begin(), nodes.end(), byTime);
std::vector<DesignTools::Keyframe> frames;
for (auto &&node : nodes) {
QVariant timeVariant = node.variantProperty("frame").value();
QVariant valueVariant = node.variantProperty("value").value();
if (!timeVariant.isValid() || !valueVariant.isValid())
continue;
QPointF position(timeVariant.toDouble(), valueVariant.toDouble());
auto keyframe = DesignTools::Keyframe(position);
if (node.hasBindingProperty("easing.bezierCurve")) {
EasingCurve ecurve;
ecurve.fromString(node.bindingProperty("easing.bezierCurve").expression());
keyframe.setData(static_cast<QEasingCurve>(ecurve));
}
frames.push_back(keyframe);
}
return frames;
}
std::vector<DesignTools::Keyframe> resolveSmallCurves(
const std::vector<DesignTools::Keyframe> &frames)
{
std::vector<DesignTools::Keyframe> out;
for (auto &&frame : frames) {
if (frame.hasData() && !out.empty()) {
QEasingCurve curve = frame.data().toEasingCurve();
if (curve.toCubicSpline().count() == 3) {
DesignTools::Keyframe &previous = out.back();
DesignTools::AnimationCurve acurve(curve, previous.position(), frame.position());
previous = acurve.keyframeAt(0);
out.push_back(acurve.keyframeAt(1));
continue;
}
}
out.push_back(frame);
}
return out;
}
DesignTools::AnimationCurve AnimationCurveEditorModel::createDoubleCurve(
const QmlTimelineKeyframeGroup &group)
{
std::vector<DesignTools::Keyframe> keyframes;
for (auto &&frame : group.keyframePositions()) {
QVariant timeVariant = frame.variantProperty("frame").value();
QVariant valueVariant = frame.variantProperty("value").value();
if (timeVariant.isValid() && valueVariant.isValid()) {
QPointF position(timeVariant.toDouble(), valueFromVariant(valueVariant));
auto keyframe = DesignTools::Keyframe(position);
if (frame.hasBindingProperty("easing.bezierCurve")) {
EasingCurve ecurve;
ecurve.fromString(frame.bindingProperty("easing.bezierCurve").expression());
keyframe.setData(static_cast<QEasingCurve>(ecurve));
}
keyframes.push_back(keyframe);
}
}
std::vector<DesignTools::Keyframe> keyframes = createKeyframes(group.keyframePositions());
keyframes = resolveSmallCurves(keyframes);
return DesignTools::AnimationCurve(keyframes);
}
double AnimationCurveEditorModel::valueFromVariant(const QVariant &variant)
{
return variant.toDouble();
}
void AnimationCurveEditorModel::reset(const std::vector<DesignTools::TreeItem *> &items)
{
beginResetModel();
initialize();
unsigned int counter = 0;
for (auto *item : items) {
item->setId(++counter);
root()->addChild(item);
}
endResetModel();
}
} // namespace QmlDesigner

View File

@@ -60,10 +60,6 @@ private:
DesignTools::AnimationCurve createDoubleCurve(const QmlTimelineKeyframeGroup &group);
double valueFromVariant(const QVariant &variant);
void reset(const std::vector<DesignTools::TreeItem *> &items);
double m_minTime;
double m_maxTime;

View File

@@ -154,8 +154,16 @@ void TimelineToolBar::setCurrentState(const QString &name)
m_stateLabel->setText(name);
}
void TimelineToolBar::setBlockReflection(bool block)
{
m_blockReflection = block;
}
void TimelineToolBar::setCurrentTimeline(const QmlTimeline &timeline)
{
if (m_blockReflection)
return;
if (timeline.isValid()) {
setStartFrame(timeline.startKeyframe());
setEndFrame(timeline.endKeyframe());

View File

@@ -79,6 +79,7 @@ public:
QString currentTimelineId() const;
void setCurrentState(const QString &name);
void setBlockReflection(bool block);
void setCurrentTimeline(const QmlTimeline &timeline);
void setStartFrame(qreal frame);
void setCurrentFrame(qreal frame);
@@ -116,6 +117,7 @@ private:
QLineEdit *m_lastFrame = nullptr;
QAction *m_recording = nullptr;
bool m_blockReflection = false;
};
} // namespace QmlDesigner

View File

@@ -142,7 +142,7 @@ void TimelineView::nodeRemoved(const ModelNode & /*removedNode*/,
void TimelineView::nodeReparented(const ModelNode &node,
const NodeAbstractProperty &newPropertyParent,
const NodeAbstractProperty & /*oldPropertyParent*/,
AbstractView::PropertyChangeFlags /*propertyChange*/)
AbstractView::PropertyChangeFlags propertyChange)
{
if (newPropertyParent.isValid()
&& QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(
@@ -151,7 +151,7 @@ void TimelineView::nodeReparented(const ModelNode &node,
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
if (currentTimeline.isValid())
if (currentTimeline.isValid() && propertyChange == AbstractView::NoAdditionalChanges)
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
} else if (QmlTimelineKeyframeGroup::checkKeyframesType(
@@ -196,12 +196,26 @@ void TimelineView::variantPropertiesChanged(const QList<VariantProperty> &proper
m_timelineWidget->graphicsScene()->invalidateKeyframesForTarget(frames.target());
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
if (currentTimeline.isValid())
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
}
}
}
}
void TimelineView::bindingPropertiesChanged(const QList<BindingProperty> &propertyList,
AbstractView::PropertyChangeFlags propertyChange)
{
Q_UNUSED(propertyChange)
for (const auto &property : propertyList) {
if (property.name() == "easing.bezierCurve") {
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
if (currentTimeline.isValid())
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
}
}
}
void TimelineView::selectedNodesChanged(const QList<ModelNode> & /*selectedNodeList*/,
const QList<ModelNode> & /*lastSelectedNodeList*/)
{

View File

@@ -60,6 +60,8 @@ public:
void instancePropertyChanged(const QList<QPair<ModelNode, PropertyName>> &propertyList) override;
void variantPropertiesChanged(const QList<VariantProperty> &propertyList,
PropertyChangeFlags propertyChange) override;
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList,
PropertyChangeFlags propertyChange) override;
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList) override;

View File

@@ -328,7 +328,8 @@ void TimelineWidget::updateAnimationCurve(DesignTools::PropertyTreeItem *item)
QmlTimelineKeyframeGroup group = timelineKeyframeGroup(currentTimeline, item);
if (group.isValid()) {
auto replaceKeyframes = [&group, currentTimeline, item]() {
auto replaceKeyframes = [&group, item, this]() {
m_toolbar->setBlockReflection(true);
for (auto frame : group.keyframes())
frame.destroy();
@@ -353,6 +354,7 @@ void TimelineWidget::updateAnimationCurve(DesignTools::PropertyTreeItem *item)
previous = frame;
}
m_toolbar->setBlockReflection(false);
};
timelineView()->executeInTransaction("TimelineWidget::handleKeyframeReplacement",

View File

@@ -4692,10 +4692,7 @@ void tst_Dumpers::dumper_data()
"std::set<double> s0;\n"
"unused(&s0);\n\n"
"std::set<int> s1;\n"
"s1.insert(11);\n"
"s1.insert(22);\n"
"s1.insert(33);\n"
"std::set<int> s1{11, 22, 33, 44, 55, 66, 77, 88};\n"
"unused(&s1);\n\n"
"typedef std::set<int> Set;\n"
@@ -4716,9 +4713,13 @@ void tst_Dumpers::dumper_data()
"s3.insert(3);\n"
"s3.insert(3);\n")
+ Cxx11Profile()
+ Check("s0", "<0 items>", "std::set<double>")
+ Check("s1", "<3 items>", "std::set<int>")
+ Check("s1", "<8 items>", "std::set<int>")
+ Check("s1.0", "[0]", "11", "int")
+ Check("s1.1", "[1]", "22", "int")
+ Check("s1.5", "[5]", "66", "int")
+ Check("s2", "<3 items>", TypeDef("std::set<int>", "Set"))
+ Check("it1.value", "11", "int")