File indexing completed on 2024-05-12 15:58:29
0001 /* 0002 * Clone info stores information about clone layer's target 0003 * SPDX-FileCopyrightText: 2011 Torio Mlshi <mlshi@lavabit.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kis_node_uuid_info.h" 0009 0010 #include "kis_debug.h" 0011 0012 KisNodeUuidInfo::KisNodeUuidInfo() 0013 { 0014 } 0015 0016 KisNodeUuidInfo::KisNodeUuidInfo(const QUuid& uuid) 0017 { 0018 m_uuid = uuid; 0019 } 0020 0021 KisNodeUuidInfo::KisNodeUuidInfo(const QString& name) 0022 { 0023 m_name = name; 0024 } 0025 0026 KisNodeUuidInfo::KisNodeUuidInfo(KisNodeSP node) 0027 { 0028 m_uuid = node->uuid(); 0029 m_name = node->name(); 0030 } 0031 0032 KisNodeSP KisNodeUuidInfo::findNode(KisNodeSP rootNode) 0033 { 0034 if (check(rootNode)) 0035 return rootNode; 0036 0037 KisNodeSP child = rootNode->firstChild(); 0038 KisNodeSP node = 0; 0039 while (child && !node) 0040 { 0041 node = findNode(child); 0042 child = child->nextSibling(); 0043 } 0044 return node; 0045 } 0046 0047 bool KisNodeUuidInfo::check(KisNodeSP node) 0048 { 0049 if (m_uuid == node->uuid()) // every node has valid uuid 0050 return true; 0051 if (m_uuid.isNull() && m_name == node->name()) // but some may have empty names 0052 return true; 0053 return false; 0054 }