File indexing completed on 2024-04-21 03:50:55
0001 /************************************************************************* 0002 * Copyright (C) 2020 by Caio Jordão Carvalho <caiojcarvalho@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License as * 0006 * published by the Free Software Foundation; either version 3 of * 0007 * the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program. If not, see <http://www.gnu.org/licenses/>.* 0016 *************************************************************************/ 0017 0018 #include "text/sentence.h" 0019 #include "text/sentence_p.h" 0020 0021 #include <memory> 0022 0023 Sentence::Sentence(MarkedClass* objClass, quint64 begin, quint64 end) : 0024 MarkedObject(std::make_unique<SentencePrivate>(begin, end), objClass) 0025 { 0026 } 0027 0028 bool Sentence::isValid() 0029 { 0030 auto dpointer = static_cast<SentencePrivate*>(d_p.get()); 0031 return dpointer->m_begin < dpointer->m_end; 0032 } 0033 0034 bool Sentence::hasBetween(int number) 0035 { 0036 auto dpointer = static_cast<SentencePrivate*>(d_p.get()); 0037 return number < dpointer->m_end && number > dpointer->m_begin; 0038 } 0039 0040 void Sentence::clear() 0041 { 0042 auto dpointer = static_cast<SentencePrivate*>(d_p.get()); 0043 dpointer->m_begin = 0; 0044 dpointer->m_end = 0; 0045 } 0046 0047 void Sentence::move(double begin, double end) 0048 { 0049 auto dpointer = static_cast<SentencePrivate*>(d_p.get()); 0050 dpointer->m_begin = begin; 0051 dpointer->m_end = end; 0052 } 0053 0054 QString Sentence::unitName() const 0055 { 0056 return "st"; 0057 } 0058 0059 MarkedObject::Type Sentence::type() 0060 { 0061 return MarkedObject::Type::Sentence; 0062 } 0063 0064 qreal Sentence::begin() const 0065 { 0066 auto dpointer = static_cast<SentencePrivate*>(d_p.get()); 0067 return dpointer->m_begin; 0068 } 0069 0070 qreal Sentence::end() const 0071 { 0072 auto dpointer = static_cast<SentencePrivate*>(d_p.get()); 0073 return dpointer->m_end; 0074 }