File indexing completed on 2024-05-12 05:13:14

0001 /*
0002   SPDX-FileCopyrightText: 2005 Rafal Rzepecki <divide@users.sourceforge.net>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "calendarsupport_export.h"
0010 
0011 #include <QVariant>
0012 
0013 class QComboBox;
0014 
0015 namespace CalendarSupport
0016 {
0017 class CALENDARSUPPORT_EXPORT CategoryHierarchyReader
0018 {
0019 public:
0020     void read(const QStringList &categories);
0021     virtual ~CategoryHierarchyReader() = default;
0022 
0023     static QStringList path(QString string);
0024 
0025 protected:
0026     CategoryHierarchyReader() = default;
0027 
0028     virtual void clear() = 0;
0029     virtual void goUp() = 0;
0030     virtual void addChild(const QString &label, const QVariant &userData = QVariant()) = 0;
0031     virtual int depth() const = 0;
0032 };
0033 
0034 class CALENDARSUPPORT_EXPORT CategoryHierarchyReaderQComboBox : public CategoryHierarchyReader
0035 {
0036 public:
0037     explicit CategoryHierarchyReaderQComboBox(QComboBox *box)
0038         : mBox(box)
0039     {
0040     }
0041 
0042     ~CategoryHierarchyReaderQComboBox() override = default;
0043 
0044 protected:
0045     void clear() override;
0046     void goUp() override;
0047     void addChild(const QString &label, const QVariant &userData = QVariant()) override;
0048     int depth() const override;
0049 
0050 private:
0051     QComboBox *const mBox;
0052     int mCurrentDepth = 0;
0053 };
0054 
0055 }