aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/result/stringresult.cpp
blob: a44e24ef5bf416ee254ca0fb4c014a7c1d5cc1b4 (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "stringresult.h"

StringResult::StringResult()
{
    m_highlight= true;
    m_resultTypes= Result::STRING;
}
void StringResult::setText(QString text)
{
    m_value= text;
}
StringResult::~StringResult() {}
bool StringResult::hasResultOfType(RESULT_TYPE resultType) const
{
    if(resultType & Result::STRING)
    {
        return true;
    }
    else if(resultType & Result::SCALAR)
    {
        bool ok= false;
        getText().toInt(&ok);
        return ok;
    }
    return false;
}
QString StringResult::getText() const
{
    return m_value;
}
QVariant StringResult::getResult(RESULT_TYPE type)
{
    switch(type)
    {
    case STRING:
        return getText();
    case SCALAR:
        return getText().toInt();
    default:
        return QVariant();
    }
}
QString StringResult::toString(bool wl)
{
    if(wl)
    {
        return QString("%2 [label=\"StringResult_value_%1\"]").arg(getText().replace("%", "_"), m_id);
    }
    else
    {
        return m_id;
    }
}
void StringResult::setHighLight(bool b)
{
    m_highlight= b;
}

bool StringResult::hasHighLight() const
{
    return m_highlight;
}
Result* StringResult::getCopy() const
{
    auto copy= new StringResult();
    copy->setHighLight(m_highlight);
    copy->setText(m_value);
    return copy;
}