1/*
2 * BluezQt - Asynchronous BlueZ wrapper library
3 *
4 * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "Comment.h"
10
11bool Comment::finalize()
12{
13 // Delete last empty lines from comment
14 while (last().isEmpty()) {
15 removeLast();
16 }
17
18 // Find indents
19 qsizetype indents = 255;
20 for (const auto &line : *this) {
21 if (line.isEmpty()) {
22 continue;
23 }
24 indents = std::min(a: indents, b: line.count(QStringLiteral("\t")));
25 }
26
27 // Remove indents
28 for (auto &line : *this) {
29 line.remove(i: 0, len: indents);
30 }
31
32 // Replace indents
33 for (auto &line : *this) {
34 line.replace(QStringLiteral("\t"), QStringLiteral(" "));
35 }
36
37 return true;
38}
39

source code of bluez-qt/tools/bluezapi2qt/Comment.cpp