File indexing completed on 2024-04-21 05:45:47

0001 /*******************************************************************************
0002  * Copyright (C) 2008-2013 Konstantinos Smanis <konstantinos.smanis@gmail.com> *
0003  *                                                                             *
0004  * This program is free software: you can redistribute it and/or modify it     *
0005  * under the terms of the GNU General Public License as published by the Free  *
0006  * Software Foundation, either version 3 of the License, or (at your option)   *
0007  * any later version.                                                          *
0008  *                                                                             *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT *
0010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
0011  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    *
0012  * more details.                                                               *
0013  *                                                                             *
0014  * You should have received a copy of the GNU General Public License along     *
0015  * with this program. If not, see <http://www.gnu.org/licenses/>.              *
0016  *******************************************************************************/
0017 
0018 //Own
0019 #include "entry.h"
0020 
0021 //Project
0022 #include "common.h"
0023 
0024 Entry::Entry(const QString &strTitle, int numTitle, Entry::Type type, int level)
0025 {
0026     m_title.str = strTitle;
0027     m_title.num = numTitle;
0028     m_type = type;
0029     m_level = level;
0030 }
0031 
0032 Entry::Title Entry::title() const
0033 {
0034     return m_title;
0035 }
0036 QString Entry::prettyTitle() const
0037 {
0038     return unquoteWord(m_title.str);
0039 }
0040 QString Entry::fullTitle() const
0041 {
0042     QString fullTitle;
0043     for (const Entry::Title &ancestor : qAsConst(m_ancestors)) {
0044         fullTitle += unquoteWord(ancestor.str) += QLatin1Char('>');
0045     }
0046     return fullTitle + unquoteWord(m_title.str);
0047 }
0048 QString Entry::fullNumTitle() const
0049 {
0050     QString fullNumTitle;
0051     for (const Entry::Title &ancestor : qAsConst(m_ancestors)) {
0052         fullNumTitle += QString::number(ancestor.num) += QLatin1Char('>');
0053     }
0054     return fullNumTitle + QString::number(m_title.num);
0055 }
0056 Entry::Type Entry::type() const
0057 {
0058     return m_type;
0059 }
0060 int Entry::level() const
0061 {
0062     return m_level;
0063 }
0064 QList<Entry::Title> Entry::ancestors() const
0065 {
0066     return m_ancestors;
0067 }
0068 QString Entry::kernel() const
0069 {
0070     return m_kernel;
0071 }
0072 
0073 void Entry::setTitle(const Entry::Title &title)
0074 {
0075     m_title = title;
0076 }
0077 void Entry::setTitle(const QString &strTitle, int numTitle)
0078 {
0079     m_title.str = strTitle;
0080     m_title.num = numTitle;
0081 }
0082 void Entry::setType(Entry::Type type)
0083 {
0084     m_type = type;
0085 }
0086 void Entry::setLevel(int level)
0087 {
0088     m_level = level;
0089 }
0090 void Entry::setAncestors(const QList<Entry::Title> &ancestors)
0091 {
0092     m_ancestors = ancestors;
0093 }
0094 void Entry::setKernel(const QString &kernel)
0095 {
0096     m_kernel = kernel;
0097 }
0098 
0099 void Entry::clear()
0100 {
0101     m_title.str.clear();
0102     m_title.num = -1;
0103     m_type = Entry::Invalid;
0104     m_level = -1;
0105     m_ancestors.clear();
0106     m_kernel.clear();
0107 }