File indexing completed on 2024-05-12 04:38:06
0001 /* 0002 SPDX-FileCopyrightText: 2010 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "persistentmovingrange.h" 0008 #include "persistentmovingrangeprivate.h" 0009 #include <interfaces/icore.h> 0010 #include <util/foregroundlock.h> 0011 0012 KDevelop::PersistentMovingRange::PersistentMovingRange(const KTextEditor::Range& range, const IndexedString& document, 0013 bool shouldExpand) 0014 : m_p(new PersistentMovingRangePrivate) 0015 { 0016 VERIFY_FOREGROUND_LOCKED; 0017 m_p->m_range = range; 0018 m_p->m_document = document; 0019 m_p->m_shouldExpand = shouldExpand; 0020 0021 m_p->connectTracker(); 0022 } 0023 0024 KDevelop::IndexedString KDevelop::PersistentMovingRange::document() const 0025 { 0026 return m_p->m_document; 0027 } 0028 0029 void KDevelop::PersistentMovingRange::setZDepth(float depth) const 0030 { 0031 VERIFY_FOREGROUND_LOCKED; 0032 m_p->m_zDepth = depth; 0033 0034 if (m_p->m_movingRange) 0035 m_p->m_movingRange->setZDepth(depth); 0036 } 0037 0038 KDevelop::PersistentMovingRange::~PersistentMovingRange() 0039 { 0040 VERIFY_FOREGROUND_LOCKED; 0041 if (m_p->m_movingRange) 0042 delete m_p->m_movingRange; 0043 delete m_p; 0044 } 0045 0046 KTextEditor::Range KDevelop::PersistentMovingRange::range() const 0047 { 0048 VERIFY_FOREGROUND_LOCKED; 0049 0050 m_p->updateRangeFromMoving(); 0051 return m_p->m_range; 0052 } 0053 0054 QString KDevelop::PersistentMovingRange::text() const 0055 { 0056 VERIFY_FOREGROUND_LOCKED; 0057 0058 if (m_p->m_movingRange) 0059 return m_p->m_movingRange->document()->text(m_p->m_movingRange->toRange()); 0060 0061 return QString(); 0062 } 0063 0064 bool KDevelop::PersistentMovingRange::valid() const 0065 { 0066 VERIFY_FOREGROUND_LOCKED; 0067 return m_p->m_valid; 0068 } 0069 0070 void KDevelop::PersistentMovingRange::setAttribute(const KTextEditor::Attribute::Ptr& attribute) 0071 { 0072 VERIFY_FOREGROUND_LOCKED; 0073 if (m_p->m_movingRange) 0074 m_p->m_movingRange->setAttribute(attribute); 0075 }