File indexing completed on 2024-05-12 05:40:25
0001 /*************************************************************************** 0002 * Copyright (C) 2019 by Renaud Guezennec * 0003 * http://www.rolisteam.org/contact * 0004 * * 0005 * This software is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #include "mindmap/data/mindnode.h" 0021 0022 #include <QDebug> 0023 #include <QFontMetricsF> 0024 #include <QRectF> 0025 #include <QUuid> 0026 0027 //"link.h" 0028 namespace mindmap 0029 { 0030 0031 MindNode::MindNode(QObject* parent) : PositionedItem(MindItem::NodeType, parent) {} 0032 MindNode::~MindNode()= default; 0033 0034 int MindNode::styleIndex() const 0035 { 0036 return m_styleIndex; 0037 } 0038 0039 QString MindNode::description() const 0040 { 0041 return m_description; 0042 } 0043 0044 void MindNode::setStyleIndex(int idx) 0045 { 0046 if(idx == m_styleIndex) 0047 return; 0048 m_styleIndex= idx; 0049 emit styleIndexChanged(); 0050 } 0051 0052 QString MindNode::imageUri() const 0053 { 0054 return m_imageUri; 0055 } 0056 0057 void MindNode::setImageUri(const QString& uri) 0058 { 0059 if(uri == m_imageUri) 0060 return; 0061 m_imageUri= uri; 0062 emit imageUriChanged(); 0063 } 0064 0065 void MindNode::setDescription(const QString& newDescription) 0066 { 0067 if(m_description == newDescription) 0068 return; 0069 m_description= newDescription; 0070 emit descriptionChanged(); 0071 } 0072 0073 const QStringList& MindNode::tags() const 0074 { 0075 return m_tags; 0076 } 0077 0078 void MindNode::setTags(const QStringList& newTags) 0079 { 0080 if(m_tags == newTags) 0081 return; 0082 m_tags= newTags; 0083 emit tagsChanged(); 0084 } 0085 0086 const QString MindNode::tagsText() const 0087 { 0088 return m_tags.join(", "); 0089 } 0090 0091 void MindNode::setTagsText(const QString& newTagsText) 0092 { 0093 auto list= newTagsText.split(","); 0094 QStringList trimmed; 0095 std::transform(std::begin(list), std::end(list), std::back_inserter(trimmed), 0096 [](const QString& text) { return text.trimmed(); }); 0097 setTags(trimmed); 0098 } 0099 } // namespace mindmap