summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2019-08-19 14:25:39 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2019-08-21 09:40:47 +0300
commitb75ad66b441f89489ce4d33571921586d784dde4 (patch)
tree9d8d9c9c62272637eef8de7518b854c550a4e485
parent4b0bfbaf222b2a732e61a13cb32ec0e8376dfd8b (diff)
Fix timeline row renaming
Row renaming broke after this commit: 1e49aba7070e8eeff8b0cc35113ccab2f37941e0 This commit fixes it. Also some relevant tweaks. Change-Id: Ib8d4fc28e351881ed87287124e57b11f760b098f Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp14
-rw-r--r--src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h1
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp12
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp39
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp4
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h4
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp (renamed from src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp)34
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h (renamed from src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h)10
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp15
-rw-r--r--src/Authoring/Qt3DStudio/Qt3DStudio.pro4
11 files changed, 70 insertions, 69 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
index 51256fe5..c487d1ae 100644
--- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
@@ -1238,6 +1238,20 @@ bool CClientDataModelBridge::isDefaultMaterial(Qt3DSDMInstanceHandle instance) c
&& GetSourcePath(instance) == getDefaultMaterialName();
}
+bool CClientDataModelBridge::isBasicMaterial(Qt3DSDMInstanceHandle instance)
+{
+ if (!instance.Valid() || !m_DataCore->IsInstance(instance))
+ return false;
+
+ if (GetObjectType(instance) == OBJTYPE_REFERENCEDMATERIAL) {
+ const auto refMaterial = getMaterialReference(instance);
+ if (refMaterial.Valid() && isInsideMaterialContainer(refMaterial))
+ return true;
+ }
+
+ return false;
+}
+
Qt3DSDMInstanceHandle CClientDataModelBridge::getMaterialContainer() const
{
IObjectReferenceHelper *objRefHelper = m_Doc->GetDataModelObjectReferenceHelper();
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h
index 10841259..3233bd42 100644
--- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h
+++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h
@@ -355,6 +355,7 @@ public:
QString getMaterialContainerParentPath() const;
QString getMaterialContainerPath() const;
bool isDefaultMaterial(qt3dsdm::Qt3DSDMInstanceHandle instance) const;
+ bool isBasicMaterial(qt3dsdm::Qt3DSDMInstanceHandle instance);
qt3dsdm::Qt3DSDMInstanceHandle getMaterialContainer() const;
std::set<QString> GetSourcePathList() const;
std::set<QString> GetFontFileList() const;
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
index f3c5fd60..b23a1f0f 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
@@ -231,17 +231,7 @@ bool InspectorControlModel::isBasicMaterial(CInspectableBase *inspectable) const
if (!inspectable)
return false;
- if (inspectable->getObjectType() == OBJTYPE_REFERENCEDMATERIAL) {
- const auto instance = inspectable->getInstance();
- if (!instance.Valid())
- return false;
-
- const auto refMaterial = getBridge()->getMaterialReference(instance);
- if (refMaterial.Valid() && getBridge()->isInsideMaterialContainer(refMaterial))
- return true;
- }
-
- return false;
+ return getBridge()->isBasicMaterial(inspectable->getInstance());
}
bool InspectorControlModel::isMaterial() const
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
index 1eba78ac..33f0eb7f 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
@@ -879,32 +879,29 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
QGraphicsItem *item = getItemAt(scenePos);
if (item) {
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
if (item->type() == TimelineItem::TypeRuler) {
- CDoc *doc = g_StudioApp.GetCore()->GetDoc();
g_StudioApp.GetDialogs()->asyncDisplayTimeEditDialog(doc->GetCurrentViewTime(),
doc, PLAYHEAD,
m_keyframeManager);
} else {
if (item->type() == TimelineItem::TypeRowTree) {
- RowTree *treeItem = static_cast<RowTree *>(item);
- if (treeItem->isProperty())
- treeItem->togglePropertyExpanded(scenePos);
- } else if (item->type() == TimelineItem::TypeRowTreeLabelItem) {
- RowTreeLabelItem *treeLabelItem = static_cast<RowTreeLabelItem *>(item);
- if (treeLabelItem->parentRow()->isProperty()) {
- treeLabelItem->parentRow()->togglePropertyExpanded();
- } else if (!treeLabelItem->isLocked()
- && treeLabelItem->parentRow()->objectType() != OBJTYPE_SCENE
- && treeLabelItem->parentRow()->objectType() != OBJTYPE_IMAGE) {
- int instance = treeLabelItem->parentRow()->instance();
- const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()
- ->GetClientDataModelBridge();
- if (bridge->GetObjectType(instance) != OBJTYPE_REFERENCEDMATERIAL
- || bridge->GetSourcePath(instance).isEmpty()) {
- // Tree labels text can be edited with double-click,
- // except for Scene label and basic materials
- treeLabelItem->setEnabled(true);
- treeLabelItem->setFocus();
+ RowTree *rowTree = static_cast<RowTree *>(item);
+ if (rowTree->isProperty()) { // toggle property graph
+ rowTree->togglePropertyExpanded(scenePos);
+ } else {
+ // check label edit
+ QGraphicsItem *topItem = itemAt(scenePos, {});
+ if (topItem->type() == TimelineItem::TypeRowTreeLabel) {
+ RowTreeLabel *rowTreeLabel = static_cast<RowTreeLabel *>(topItem);
+ const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ EStudioObjectType rowObjType = rowTreeLabel->rowTree()->objectType();
+ int instance = rowTreeLabel->rowTree()->instance();
+ if (!rowTreeLabel->isLocked() && !bridge->isBasicMaterial(instance)
+ && rowObjType & ~(OBJTYPE_SCENE | OBJTYPE_IMAGE)) {
+ rowTreeLabel->setEnabled(true);
+ rowTreeLabel->setFocus();
+ }
}
}
} else if (item->type() == TimelineItem::TypeRowTimeline) {
@@ -1109,7 +1106,7 @@ QGraphicsItem *TimelineGraphicsScene::getItemAt(const QPointF &scenePos) const
if (!hoverItems.empty()) {
QGraphicsItem *item = hoverItems.at(0);
- int typeMask = TimelineItem::TypePlayHead | TimelineItem::TypeRowTreeLabelItem;
+ int typeMask = TimelineItem::TypePlayHead | TimelineItem::TypeRowTreeLabel;
if (item->type() & typeMask && hoverItems.size() > 1)
item = hoverItems.at(1);
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
index 3d2e2c57..7c50ee0d 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
@@ -113,7 +113,7 @@ void RowTree::initialize()
initializeAnimations();
m_labelItem.setParentItem(this);
- m_labelItem.setParentRow(this);
+ m_labelItem.setRowTree(this);
m_labelItem.setLabel(m_label);
updateLabelPosition();
@@ -121,7 +121,7 @@ void RowTree::initialize()
setRowVisible(false);
m_expandState = ExpandState::HiddenCollapsed;
- connect(&m_labelItem, &RowTreeLabelItem::labelChanged, this,
+ connect(&m_labelItem, &RowTreeLabel::labelChanged, this,
[this](const QString &label) {
// Update label on timeline and on model
m_label = label;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
index eeeb93e3..9bed666a 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
@@ -33,7 +33,7 @@
#include "TimelineConstants.h"
#include "RowTypes.h"
#include "StudioObjectTypes.h"
-#include "RowTreeLabelItem.h"
+#include "RowTreeLabel.h"
#include "Qt3DSDMHandles.h"
#include <QtCore/qpropertyanimation.h>
@@ -201,7 +201,7 @@ private:
int m_numDescendantSubpresentations = 0;
ExpandState m_expandState = ExpandState::HiddenCollapsed;
TimelineGraphicsScene *m_scene;
- RowTreeLabelItem m_labelItem;
+ RowTreeLabel m_labelItem;
EStudioObjectType m_objectType = OBJTYPE_UNKNOWN;
QString m_label;
QList<RowTree *> m_childRows;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp
index 21b57aaa..de148af2 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "RowTreeLabelItem.h"
+#include "RowTreeLabel.h"
#include "TimelineConstants.h"
#include "TimelineItem.h"
#include "RowTree.h"
@@ -36,7 +36,7 @@
#include <QtGui/qevent.h>
#include <QtGui/qtextcursor.h>
-RowTreeLabelItem::RowTreeLabelItem(QGraphicsItem *parent)
+RowTreeLabel::RowTreeLabel(QGraphicsItem *parent)
: QGraphicsTextItem(parent)
, m_locked(false)
, m_master(false)
@@ -47,12 +47,12 @@ RowTreeLabelItem::RowTreeLabelItem(QGraphicsItem *parent)
updateLabelColor();
}
-QString RowTreeLabelItem::label() const
+QString RowTreeLabel::label() const
{
return m_label;
}
-void RowTreeLabelItem::setLabel(const QString &label)
+void RowTreeLabel::setLabel(const QString &label)
{
setPlainText(label);
if (m_label != label) {
@@ -61,39 +61,37 @@ void RowTreeLabelItem::setLabel(const QString &label)
}
}
-void RowTreeLabelItem::setMaster(bool isMaster) {
+void RowTreeLabel::setMaster(bool isMaster) {
if (m_master != isMaster) {
m_master = isMaster;
updateLabelColor();
}
}
-void RowTreeLabelItem::setLocked(bool isLocked) {
+void RowTreeLabel::setLocked(bool isLocked) {
if (m_locked != isLocked) {
m_locked = isLocked;
updateLabelColor();
}
}
-RowTree *RowTreeLabelItem::parentRow() const
+RowTree *RowTreeLabel::rowTree() const
{
return m_rowTree;
}
-void RowTreeLabelItem::setParentRow(RowTree *row)
+void RowTreeLabel::setRowTree(RowTree *row)
{
m_rowTree = row;
}
-int RowTreeLabelItem::type() const
+int RowTreeLabel::type() const
{
// Enable the use of qgraphicsitem_cast with this item.
- return TimelineItem::TypeRowTreeLabelItem;
+ return TimelineItem::TypeRowTreeLabel;
}
-void RowTreeLabelItem::paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option,
- QWidget *widget)
+void RowTreeLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (!m_rowTree->y()) // prevents flickering when the row is just inserted to the layout
return;
@@ -105,7 +103,7 @@ void RowTreeLabelItem::paint(QPainter *painter,
QGraphicsTextItem::paint(painter, option, widget);
}
-void RowTreeLabelItem::focusOutEvent(QFocusEvent *event)
+void RowTreeLabel::focusOutEvent(QFocusEvent *event)
{
if (m_acceptOnFocusOut)
validateLabel();
@@ -122,7 +120,7 @@ void RowTreeLabelItem::focusOutEvent(QFocusEvent *event)
m_acceptOnFocusOut = true;
}
-void RowTreeLabelItem::keyPressEvent(QKeyEvent *event)
+void RowTreeLabel::keyPressEvent(QKeyEvent *event)
{
int key = event->key();
if (key == Qt::Key_Return || key == Qt::Key_Enter) {
@@ -140,7 +138,7 @@ void RowTreeLabelItem::keyPressEvent(QKeyEvent *event)
QGraphicsTextItem::keyPressEvent(event);
}
-QRectF RowTreeLabelItem::boundingRect() const
+QRectF RowTreeLabel::boundingRect() const
{
if (!m_rowTree)
return QGraphicsTextItem::boundingRect();
@@ -151,7 +149,7 @@ QRectF RowTreeLabelItem::boundingRect() const
return QRectF(0, 0, w, TimelineConstants::ROW_H);
}
-void RowTreeLabelItem::validateLabel()
+void RowTreeLabel::validateLabel()
{
QString text = toPlainText().trimmed();
if (text.isEmpty()) {
@@ -164,7 +162,7 @@ void RowTreeLabelItem::validateLabel()
setLabel(text);
}
-void RowTreeLabelItem::updateLabelColor()
+void RowTreeLabel::updateLabelColor()
{
if (m_locked)
setDefaultTextColor(CStudioPreferences::GetDisabledTextColor());
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h
index edffbef5..980591f6 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h
@@ -37,19 +37,19 @@
class RowTree;
-class RowTreeLabelItem : public QGraphicsTextItem
+class RowTreeLabel : public QGraphicsTextItem
{
Q_OBJECT
public:
- explicit RowTreeLabelItem(QGraphicsItem *parent = nullptr);
+ explicit RowTreeLabel(QGraphicsItem *parent = nullptr);
QString label() const;
void setLabel(const QString &label);
void setLocked(bool isLocked);
void setMaster(bool isMaster);
- RowTree *parentRow() const;
- void setParentRow(RowTree *row);
- int type() const;
+ RowTree *rowTree() const;
+ void setRowTree(RowTree *row);
+ int type() const override;
bool isLocked() const { return m_locked; }
protected:
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h
index 71fb5ec2..e84eb73b 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h
@@ -43,7 +43,7 @@ public:
TypeInteractiveTimelineItem = UserType << 2,
TypeTreeHeader = UserType << 3,
TypeRowTree = UserType << 4,
- TypeRowTreeLabelItem = UserType << 5,
+ TypeRowTreeLabel = UserType << 5,
TypeRowTimeline = UserType << 6,
TypeRowTimelineCommentItem = UserType << 7,
TypePlayHead = UserType << 8,
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp
index df784418..3efc033d 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp
@@ -33,14 +33,15 @@ TreeHeaderView::TreeHeaderView(QWidget *parent)
{
}
-void TreeHeaderView::scrollContentsBy(int dx, int dy)
+/**
+ * Overridden to ignore scrolling after initial show related scrolling has been finished
+ *
+ * When RowTreeLabel (QGraphicsTextItem) gets focus for text editing, it forces views to scroll
+ * themselves so that editable text item is always visible. We don't want tree header view to move.
+ * @see QGraphicsTextItemPrivate::textControl() and _q_ensureVisible()
+ */
+void TreeHeaderView::scrollContentsBy(int dx, int dy)
{
- // Overridden to ignore scrolling after initial show related scrolling has been finished
- //
- // Longer explanation: When RowTreeLabelItem (QGraphicsTextItem) gets focus
- // for text editing, it forces views to scroll themselves so that editable
- // text item is always visible. But we don't want tree header view to move.
- // See QGraphicsTextItemPrivate::textControl() and _q_ensureVisible()
if (m_allowScrolling)
QGraphicsView::scrollContentsBy(dx, dy);
}
diff --git a/src/Authoring/Qt3DStudio/Qt3DStudio.pro b/src/Authoring/Qt3DStudio/Qt3DStudio.pro
index 152d9f27..93faf19c 100644
--- a/src/Authoring/Qt3DStudio/Qt3DStudio.pro
+++ b/src/Authoring/Qt3DStudio/Qt3DStudio.pro
@@ -213,7 +213,7 @@ HEADERS += \
Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.h \
Palettes/TimelineGraphicsView/ui/RowTree.h \
Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.h \
- Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h \
+ Palettes/TimelineGraphicsView/ui/RowTreeLabel.h \
Palettes/TimelineGraphicsView/ui/Ruler.h \
Palettes/TimelineGraphicsView/ui/TimelineItem.h \
Palettes/TimelineGraphicsView/ui/TimelineToolbar.h \
@@ -379,7 +379,7 @@ SOURCES += \
Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.cpp \
Palettes/TimelineGraphicsView/ui/RowTree.cpp \
Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp \
- Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp \
+ Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp \
Palettes/TimelineGraphicsView/ui/Ruler.cpp \
Palettes/TimelineGraphicsView/ui/TimelineItem.cpp \
Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp \