forked from KDE/ghostwriter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentStatisticsWidget.cpp
More file actions
129 lines (108 loc) · 3.74 KB
/
Copy pathDocumentStatisticsWidget.cpp
File metadata and controls
129 lines (108 loc) · 3.74 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/***********************************************************************
*
* Copyright (C) 2016 wereturtle
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***********************************************************************/
#include <QHBoxLayout>
#include <QLabel>
#include "DocumentStatisticsWidget.h"
DocumentStatisticsWidget::DocumentStatisticsWidget(QWidget* parent)
: AbstractStatisticsWidget(parent),
VERY_EASY_READING_EASE_STR(tr("Very Easy")),
EASY_READING_EASE_STR(tr("Easy")),
MEDIUM_READING_EASE_STR(tr("Standard")),
DIFFICULT_READING_EASE_STR(tr("Difficult")),
VERY_DIFFICULT_READING_EASE_STR(tr("Very Difficult"))
{
wordCountLabel = addStatisticLabel(tr("Words:"), "0");
characterCountLabel = addStatisticLabel(tr("Characters:"), "0");
sentenceCountLabel = addStatisticLabel(tr("Sentences:"), "0");
paragraphCountLabel = addStatisticLabel(tr("Paragraphs:"), "0");
pageCountLabel = addStatisticLabel(tr("Pages:"), LESS_THAN_ONE_STR, PAGE_STATISTIC_INFO_TOOLTIP_STR);
complexWordsLabel = addStatisticLabel(tr("Complex Words:"), "0%");
readingTimeLabel = addStatisticLabel(tr("Reading Time:"), LESS_THAN_ONE_MINUTE_STR);
lixReadingEaseLabel = addStatisticLabel(tr("Reading Ease:"), VERY_EASY_READING_EASE_STR, tr("LIX Reading Ease"));
cliLabel = addStatisticLabel(tr("Grade Level:"), "0", tr("Coleman-Liau Readability Index (CLI)"));
}
DocumentStatisticsWidget::~DocumentStatisticsWidget()
{
}
void DocumentStatisticsWidget::setWordCount(int value)
{
setIntegerValueForLabel(wordCountLabel, value);
}
void DocumentStatisticsWidget::setCharacterCount(int value)
{
setIntegerValueForLabel(characterCountLabel, value);
}
void DocumentStatisticsWidget::setParagraphCount(int value)
{
setIntegerValueForLabel(paragraphCountLabel, value);
}
void DocumentStatisticsWidget::setSentenceCount(int value)
{
setIntegerValueForLabel(sentenceCountLabel, value);
}
void DocumentStatisticsWidget::setPageCount(int value)
{
setPageValueForLabel(pageCountLabel, value);
}
void DocumentStatisticsWidget::setComplexWords(int percentage)
{
setPercentageValueForLabel(complexWordsLabel, percentage);
}
void DocumentStatisticsWidget::setReadingTime(int minutes)
{
setTimeValueForLabel(readingTimeLabel, minutes);
}
void DocumentStatisticsWidget::setLixReadingEase(int value)
{
QString readingEaseStr = VERY_DIFFICULT_READING_EASE_STR;
if (value <= 25)
{
readingEaseStr = VERY_EASY_READING_EASE_STR;
}
else if (value <= 35)
{
readingEaseStr = EASY_READING_EASE_STR;
}
else if (value <= 45)
{
readingEaseStr = MEDIUM_READING_EASE_STR;
}
else if (value <= 55)
{
readingEaseStr = DIFFICULT_READING_EASE_STR;
}
setStringValueForLabel(lixReadingEaseLabel, readingEaseStr);
}
void DocumentStatisticsWidget::setReadabilityIndex(int value)
{
QString cliStr = tr("Kindergarten");
if (value > 16)
{
cliStr = tr("Rocket Science");
}
else if (value > 12)
{
cliStr = tr("College");
}
else if (value > 0)
{
cliStr.setNum(value);
}
setStringValueForLabel(cliLabel, cliStr);
}