File indexing completed on 2024-12-22 04:48:18

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2024 Louis Schul <schul9louis@gmail.com>
0004 */
0005 
0006 #pragma once
0007 
0008 #include <QObject>
0009 #include <QSet>
0010 
0011 class Parser;
0012 
0013 class NoteMapperParserUtils
0014 {
0015 public:
0016     explicit NoteMapperParserUtils(Parser *parser);
0017 
0018     void setPathsInfo(const QString &path);
0019     QPair<QString, bool> sanitizePath(const QString &_path) const;
0020     void setHeaderInfo(const QStringList &headerInfo);
0021     QString headerLevel() const;
0022     void addToLinkedNoteInfos(const QStringList &infos);
0023     void addToNoteHeaders(const QString &header);
0024     void checkHeaderFound(const QString &header, const QString &level);
0025     bool headerFound() const;
0026     void postTok();
0027     void clearInfo();
0028     void clearPreviousInfo();
0029 
0030 private:
0031     QString m_mapperNotePath;
0032     QString m_groupPath;
0033     QString m_categPath;
0034     QString m_header;
0035 
0036     QString m_headerLevel;
0037     bool m_headerFound = false;
0038     bool m_emptyHeadersSent = false;
0039 
0040     // Valid to use QSet since, in any case, linking will be done on the first instance of a duplicated header
0041     QSet<QString> m_noteHeaders;
0042     QSet<QString> m_previousNoteHeaders;
0043     bool m_noteHeadersChanged = false;
0044 
0045     QSet<QStringList> m_linkedNotesInfos;
0046     QSet<QStringList> m_previousLinkedNotesInfos;
0047     bool m_linkedNotesChanged = false;
0048     bool m_notePathChanged = true;
0049 
0050     Parser *m_parser = nullptr;
0051 };