summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/copytaskhandler.cpp
blob: a75e6b328cd8a87a3101e66e520ffd294f29583b (plain)
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
39
40
41
42
43
44
45
46
47
48
49
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "copytaskhandler.h"

#include "projectexplorertr.h"

#include <coreplugin/coreconstants.h>

#include <utils/stringutils.h>

#include <QAction>

namespace ProjectExplorer::Internal {

void CopyTaskHandler::handle(const Tasks &tasks)
{
    QStringList lines;
    for (const Task &task : tasks) {
        QString type;
        switch (task.type) {
        case Task::Error:
            //: Task is of type: error
            type = Tr::tr("error:") + QLatin1Char(' ');
            break;
        case Task::Warning:
            //: Task is of type: warning
            type = Tr::tr("warning:") + QLatin1Char(' ');
            break;
        default:
            break;
        }
        lines << task.file.toUserOutput() + ':' + QString::number(task.line)
                 + ": " + type + task.description();
    }
    Utils::setClipboardAndSelection(lines.join('\n'));
}

Utils::Id CopyTaskHandler::actionManagerId() const
{
    return Utils::Id(Core::Constants::COPY);
}

QAction *CopyTaskHandler::createAction(QObject *parent) const
{
    return new QAction(parent);
}

} // ProjectExplorer::Internal