1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #ifndef OPENEDLIST_H |
5 | #define OPENEDLIST_H |
6 | |
7 | #include "location.h" |
8 | |
9 | #include <QtCore/qstring.h> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | class OpenedList |
14 | { |
15 | public: |
16 | enum ListStyle { Bullet, Tag, Value, Numeric, UpperAlpha, LowerAlpha, UpperRoman, LowerRoman }; |
17 | |
18 | OpenedList() : sty(Bullet), ini(1), nex(0) {} |
19 | explicit OpenedList(ListStyle style); |
20 | OpenedList(const Location &location, const QString &hint); |
21 | |
22 | void next() { nex++; } |
23 | |
24 | [[nodiscard]] bool isStarted() const { return nex >= ini; } |
25 | [[nodiscard]] ListStyle style() const { return sty; } |
26 | [[nodiscard]] QString styleString() const; |
27 | [[nodiscard]] int number() const { return nex; } |
28 | [[nodiscard]] QString numberString() const; |
29 | [[nodiscard]] QString prefix() const { return pref; } |
30 | [[nodiscard]] QString suffix() const { return suff; } |
31 | |
32 | private: |
33 | static int fromAlpha(const QString &str); |
34 | static QString toRoman(int n); |
35 | static int fromRoman(const QString &str); |
36 | |
37 | ListStyle sty; |
38 | int ini; |
39 | int nex; |
40 | QString pref; |
41 | QString suff; |
42 | }; |
43 | Q_DECLARE_TYPEINFO(OpenedList, Q_RELOCATABLE_TYPE); |
44 | |
45 | QT_END_NAMESPACE |
46 | |
47 | #endif |
48 | |