summaryrefslogtreecommitdiff
path: root/src/field-styles/FieldStyle.cpp
blob: 4e710f8ff3262d7407d2cf0f8c1b7ee1fdc4343c (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
#include "FieldStyle.h"

FieldStyle::FieldStyle():
    FieldStyle("", 0) {}

FieldStyle::FieldStyle(const QString& family, int size,
    bool bold, bool italic, const QString& colorName,
    const QString& prefix, const QString& suffix,
    bool hasKeyword, const QString& keywordColorName):
        color(Qt::black),
        prefix(prefix), suffix(suffix),
        hasKeyword(hasKeyword),
        keywordBold(false),
        keywordItalic(false)
{
    font.setFamily("Times New Roman");
    font.setPointSize(18);
    if(!family.isEmpty())
        font.setFamily(family);
    if(size > 0)
        font.setPointSize(size);
    font.setBold(bold);
    font.setItalic(italic);
    if(!colorName.isEmpty())
        color.setNamedColor(colorName);
    keywordColor.setNamedColor(keywordColorName);
}

FieldStyle FieldStyle::getKeywordStyle() const
{
    if(!hasKeyword)
        return *this;
    FieldStyle keywordStyle = *this;
    keywordStyle.font.setBold(keywordBold);
    keywordStyle.font.setItalic(keywordItalic);
    keywordStyle.color = keywordColor;
    return keywordStyle;
}