From b75ad66b441f89489ce4d33571921586d784dde4 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Mon, 19 Aug 2019 14:25:39 +0300 Subject: Fix timeline row renaming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Row renaming broke after this commit: 1e49aba7070e8eeff8b0cc35113ccab2f37941e0 This commit fixes it. Also some relevant tweaks. Change-Id: Ib8d4fc28e351881ed87287124e57b11f760b098f Reviewed-by: Miikka Heikkinen Reviewed-by: Tomi Korpipää --- .../ClientDataModelBridge.cpp | 14 ++ .../ClientDataModelBridge/ClientDataModelBridge.h | 1 + .../Palettes/Inspector/InspectorControlModel.cpp | 12 +- .../TimelineGraphicsView/TimelineGraphicsScene.cpp | 39 +++-- .../Palettes/TimelineGraphicsView/ui/RowTree.cpp | 4 +- .../Palettes/TimelineGraphicsView/ui/RowTree.h | 4 +- .../TimelineGraphicsView/ui/RowTreeLabel.cpp | 173 ++++++++++++++++++++ .../TimelineGraphicsView/ui/RowTreeLabel.h | 76 +++++++++ .../TimelineGraphicsView/ui/RowTreeLabelItem.cpp | 175 --------------------- .../TimelineGraphicsView/ui/RowTreeLabelItem.h | 76 --------- .../TimelineGraphicsView/ui/TimelineItem.h | 2 +- .../TimelineGraphicsView/ui/TreeHeaderView.cpp | 15 +- src/Authoring/Qt3DStudio/Qt3DStudio.pro | 4 +- 13 files changed, 298 insertions(+), 297 deletions(-) create mode 100644 src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp create mode 100644 src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h delete mode 100644 src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp delete mode 100644 src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h 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 GetSourcePathList() const; std::set 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(item); - if (treeItem->isProperty()) - treeItem->togglePropertyExpanded(scenePos); - } else if (item->type() == TimelineItem::TypeRowTreeLabelItem) { - RowTreeLabelItem *treeLabelItem = static_cast(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(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(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 @@ -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 m_childRows; diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp new file mode 100644 index 00000000..de148af2 --- /dev/null +++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt 3D Studio. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "RowTreeLabel.h" +#include "TimelineConstants.h" +#include "TimelineItem.h" +#include "RowTree.h" +#include "StudioPreferences.h" + +#include +#include +#include + +RowTreeLabel::RowTreeLabel(QGraphicsItem *parent) + : QGraphicsTextItem(parent) + , m_locked(false) + , m_master(false) + , m_acceptOnFocusOut(true) +{ + setTextInteractionFlags(Qt::TextEditorInteraction); + setEnabled(false); + updateLabelColor(); +} + +QString RowTreeLabel::label() const +{ + return m_label; +} + +void RowTreeLabel::setLabel(const QString &label) +{ + setPlainText(label); + if (m_label != label) { + m_label = label; + emit labelChanged(m_label); + } +} + +void RowTreeLabel::setMaster(bool isMaster) { + if (m_master != isMaster) { + m_master = isMaster; + updateLabelColor(); + } +} + +void RowTreeLabel::setLocked(bool isLocked) { + if (m_locked != isLocked) { + m_locked = isLocked; + updateLabelColor(); + } +} + +RowTree *RowTreeLabel::rowTree() const +{ + return m_rowTree; +} + +void RowTreeLabel::setRowTree(RowTree *row) +{ + m_rowTree = row; +} + +int RowTreeLabel::type() const +{ + // Enable the use of qgraphicsitem_cast with this item. + return TimelineItem::TypeRowTreeLabel; +} + +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; + + // Remove the HasFocus style state, to prevent the dotted line from being drawn. + QStyleOptionGraphicsItem *style = const_cast(option); + style->state &= ~QStyle::State_HasFocus; + + QGraphicsTextItem::paint(painter, option, widget); +} + +void RowTreeLabel::focusOutEvent(QFocusEvent *event) +{ + if (m_acceptOnFocusOut) + validateLabel(); + else + setPlainText(m_label); + + // Remove possible selection and make disabled again + QTextCursor cursor = textCursor(); + cursor.clearSelection(); + setTextCursor(cursor); + setEnabled(false); + QGraphicsTextItem::focusOutEvent(event); + // Next time default to accepting + m_acceptOnFocusOut = true; +} + +void RowTreeLabel::keyPressEvent(QKeyEvent *event) +{ + int key = event->key(); + if (key == Qt::Key_Return || key == Qt::Key_Enter) { + m_acceptOnFocusOut = true; + clearFocus(); + event->accept(); + return; + } else if (key == Qt::Key_Escape) { + m_acceptOnFocusOut = false; + clearFocus(); + event->accept(); + return; + } + + QGraphicsTextItem::keyPressEvent(event); +} + +QRectF RowTreeLabel::boundingRect() const +{ + if (!m_rowTree) + return QGraphicsTextItem::boundingRect(); + + double w = m_rowTree->clipX() - x(); + // Bounding rect width must be at least 1 + w = std::max(w, 1.0); + return QRectF(0, 0, w, TimelineConstants::ROW_H); +} + +void RowTreeLabel::validateLabel() +{ + QString text = toPlainText().trimmed(); + if (text.isEmpty()) { + // Inform label was empty and return previous label + emit labelChanged(""); + setLabel(m_label); + return; + } + + setLabel(text); +} + +void RowTreeLabel::updateLabelColor() +{ + if (m_locked) + setDefaultTextColor(CStudioPreferences::GetDisabledTextColor()); + else if (m_master) + setDefaultTextColor(CStudioPreferences::GetMasterColor()); + else + setDefaultTextColor(CStudioPreferences::GetNormalColor()); +} diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h new file mode 100644 index 00000000..980591f6 --- /dev/null +++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt 3D Studio. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ROWTREELABELITEM_H +#define ROWTREELABELITEM_H + +#include "StudioObjectTypes.h" +#include +#include +#include +#include + +class RowTree; + +class RowTreeLabel : public QGraphicsTextItem +{ + Q_OBJECT +public: + explicit RowTreeLabel(QGraphicsItem *parent = nullptr); + + QString label() const; + void setLabel(const QString &label); + void setLocked(bool isLocked); + void setMaster(bool isMaster); + RowTree *rowTree() const; + void setRowTree(RowTree *row); + int type() const override; + bool isLocked() const { return m_locked; } + +protected: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; + void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + QRectF boundingRect() const override; + +signals: + void labelChanged(const QString label); + +private: + void validateLabel(); + void updateLabelColor(); + + RowTree *m_rowTree = nullptr; + QString m_label; + bool m_locked; + bool m_master; + bool m_acceptOnFocusOut; + +}; + +#endif // ROWTREELABELITEM_H diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp deleted file mode 100644 index 21b57aaa..00000000 --- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "RowTreeLabelItem.h" -#include "TimelineConstants.h" -#include "TimelineItem.h" -#include "RowTree.h" -#include "StudioPreferences.h" - -#include -#include -#include - -RowTreeLabelItem::RowTreeLabelItem(QGraphicsItem *parent) - : QGraphicsTextItem(parent) - , m_locked(false) - , m_master(false) - , m_acceptOnFocusOut(true) -{ - setTextInteractionFlags(Qt::TextEditorInteraction); - setEnabled(false); - updateLabelColor(); -} - -QString RowTreeLabelItem::label() const -{ - return m_label; -} - -void RowTreeLabelItem::setLabel(const QString &label) -{ - setPlainText(label); - if (m_label != label) { - m_label = label; - emit labelChanged(m_label); - } -} - -void RowTreeLabelItem::setMaster(bool isMaster) { - if (m_master != isMaster) { - m_master = isMaster; - updateLabelColor(); - } -} - -void RowTreeLabelItem::setLocked(bool isLocked) { - if (m_locked != isLocked) { - m_locked = isLocked; - updateLabelColor(); - } -} - -RowTree *RowTreeLabelItem::parentRow() const -{ - return m_rowTree; -} - -void RowTreeLabelItem::setParentRow(RowTree *row) -{ - m_rowTree = row; -} - -int RowTreeLabelItem::type() const -{ - // Enable the use of qgraphicsitem_cast with this item. - return TimelineItem::TypeRowTreeLabelItem; -} - -void RowTreeLabelItem::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - if (!m_rowTree->y()) // prevents flickering when the row is just inserted to the layout - return; - - // Remove the HasFocus style state, to prevent the dotted line from being drawn. - QStyleOptionGraphicsItem *style = const_cast(option); - style->state &= ~QStyle::State_HasFocus; - - QGraphicsTextItem::paint(painter, option, widget); -} - -void RowTreeLabelItem::focusOutEvent(QFocusEvent *event) -{ - if (m_acceptOnFocusOut) - validateLabel(); - else - setPlainText(m_label); - - // Remove possible selection and make disabled again - QTextCursor cursor = textCursor(); - cursor.clearSelection(); - setTextCursor(cursor); - setEnabled(false); - QGraphicsTextItem::focusOutEvent(event); - // Next time default to accepting - m_acceptOnFocusOut = true; -} - -void RowTreeLabelItem::keyPressEvent(QKeyEvent *event) -{ - int key = event->key(); - if (key == Qt::Key_Return || key == Qt::Key_Enter) { - m_acceptOnFocusOut = true; - clearFocus(); - event->accept(); - return; - } else if (key == Qt::Key_Escape) { - m_acceptOnFocusOut = false; - clearFocus(); - event->accept(); - return; - } - - QGraphicsTextItem::keyPressEvent(event); -} - -QRectF RowTreeLabelItem::boundingRect() const -{ - if (!m_rowTree) - return QGraphicsTextItem::boundingRect(); - - double w = m_rowTree->clipX() - x(); - // Bounding rect width must be at least 1 - w = std::max(w, 1.0); - return QRectF(0, 0, w, TimelineConstants::ROW_H); -} - -void RowTreeLabelItem::validateLabel() -{ - QString text = toPlainText().trimmed(); - if (text.isEmpty()) { - // Inform label was empty and return previous label - emit labelChanged(""); - setLabel(m_label); - return; - } - - setLabel(text); -} - -void RowTreeLabelItem::updateLabelColor() -{ - if (m_locked) - setDefaultTextColor(CStudioPreferences::GetDisabledTextColor()); - else if (m_master) - setDefaultTextColor(CStudioPreferences::GetMasterColor()); - else - setDefaultTextColor(CStudioPreferences::GetNormalColor()); -} diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h deleted file mode 100644 index edffbef5..00000000 --- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ROWTREELABELITEM_H -#define ROWTREELABELITEM_H - -#include "StudioObjectTypes.h" -#include -#include -#include -#include - -class RowTree; - -class RowTreeLabelItem : public QGraphicsTextItem -{ - Q_OBJECT -public: - explicit RowTreeLabelItem(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; - bool isLocked() const { return m_locked; } - -protected: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; - void focusOutEvent(QFocusEvent *event) override; - void keyPressEvent(QKeyEvent *event) override; - QRectF boundingRect() const override; - -signals: - void labelChanged(const QString label); - -private: - void validateLabel(); - void updateLabelColor(); - - RowTree *m_rowTree = nullptr; - QString m_label; - bool m_locked; - bool m_master; - bool m_acceptOnFocusOut; - -}; - -#endif // ROWTREELABELITEM_H 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 \ -- cgit v1.2.3