diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-04-26 10:49:34 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-04-28 08:19:44 +0200 |
| commit | f6702a1bd089b4adba78d0ea4e6cc8aef7d9e885 (patch) | |
| tree | 9fec2b90f615e5da78e95a1061e83dead1c9cebb /sources/shiboken6/ApiExtractor/documentation.cpp | |
| parent | 7809a047416eacb6f245160aa018127f5b0e8e81 (diff) | |
Refactor class Documentation
Replace the map by two fields of string type for detailed/brief and
add accessors. Make the constructor explicit and fix all occurrences
of implicit conversions.
Change QtDocGenerator::writeFormattedText() to take a QString
with the format instead of an instance of Documentation and add
convencience functions writeFormattedBriefText()
and writeFormattedDetailedText().
Change-Id: I4efaecc8cffeff16873fa3926c3f3b731b96bc5b
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/documentation.cpp')
| -rw-r--r-- | sources/shiboken6/ApiExtractor/documentation.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sources/shiboken6/ApiExtractor/documentation.cpp b/sources/shiboken6/ApiExtractor/documentation.cpp index c042b3b8a..f4c016d97 100644 --- a/sources/shiboken6/ApiExtractor/documentation.cpp +++ b/sources/shiboken6/ApiExtractor/documentation.cpp @@ -28,38 +28,29 @@ #include "documentation.h" -Documentation::Documentation(const QString &value, Documentation::Type t, Documentation::Format fmt) +Documentation::Documentation(const QString &detailed, + const QString &brief, + Format fmt) : + m_detailed(detailed.trimmed()), m_brief(brief.trimmed()), m_format(fmt) { - setValue(value, t, fmt); } bool Documentation::isEmpty() const { - for (int i = 0; i < Type::Last; i++) { - if (!m_data.value(static_cast<Type>(i)).isEmpty()) - return false; - } - return true; + return m_detailed.isEmpty() && m_brief.isEmpty(); } -QString Documentation::value(Documentation::Type t) const +Documentation::Format Documentation::format() const { - return m_data.value(t); + return m_format; } -void Documentation::setValue(const QString &value, Documentation::Type t, Documentation::Format fmt) +void Documentation::setValue(const QString &value, Documentation::Type t) { - const QString v = value.trimmed(); - if (v.isEmpty()) - m_data.remove(t); + if (t == Brief) + setBrief(value); else - m_data[t] = value.trimmed(); - m_format = fmt; -} - -Documentation::Format Documentation::format() const -{ - return m_format; + setDetailed(value); } void Documentation::setFormat(Documentation::Format f) @@ -69,5 +60,16 @@ void Documentation::setFormat(Documentation::Format f) bool Documentation::equals(const Documentation &rhs) const { - return m_format == rhs.m_format && m_data == rhs.m_data; + return m_format == rhs.m_format && m_detailed == rhs.m_detailed + && m_brief == rhs.m_brief; +} + +void Documentation::setDetailed(const QString &detailed) +{ + m_detailed = detailed.trimmed(); +} + +void Documentation::setBrief(const QString &brief) +{ + m_brief = brief.trimmed(); } |
