File: Comment.cpp

package info (click to toggle)
bluez-qt 5.116.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,932 kB
  • sloc: cpp: 16,676; xml: 554; ansic: 337; sh: 13; makefile: 8
file content (38 lines) | stat: -rw-r--r-- 839 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * BluezQt - Asynchronous BlueZ wrapper library
 *
 * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de>
 *
 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
 */

#include "Comment.h"

bool Comment::finalize()
{
    // Delete last empty lines from comment
    while (last().isEmpty()) {
        removeLast();
    }

    // Find indents
    int indents = 255;
    for (const auto &line : *this) {
        if (line.isEmpty()) {
            continue;
        }
        indents = std::min(indents, line.count(QStringLiteral("\t")));
    }

    // Remove indents
    for (auto &line : *this) {
        line.remove(0, indents);
    }

    // Replace indents
    for (auto &line : *this) {
        line.replace(QStringLiteral("\t"), QStringLiteral("    "));
    }

    return true;
}