1 /*
2  * %kadu copyright begin%
3  * Copyright 2012, 2013, 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com)
4  * %kadu copyright end%
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "formatted-string/formatted-string-text-block.h"
21 
22 #include "formatted-string-plain-text-visitor.h"
23 
FormattedStringPlainTextVisitor()24 FormattedStringPlainTextVisitor::FormattedStringPlainTextVisitor()
25 {
26 }
27 
~FormattedStringPlainTextVisitor()28 FormattedStringPlainTextVisitor::~FormattedStringPlainTextVisitor()
29 {
30 }
31 
beginVisit(const CompositeFormattedString * const compositeFormattedString)32 void FormattedStringPlainTextVisitor::beginVisit(const CompositeFormattedString * const compositeFormattedString)
33 {
34 	Q_UNUSED(compositeFormattedString);
35 }
36 
endVisit(const CompositeFormattedString * const compositeFormattedString)37 void FormattedStringPlainTextVisitor::endVisit(const CompositeFormattedString * const compositeFormattedString)
38 {
39 	Q_UNUSED(compositeFormattedString);
40 }
41 
visit(const FormattedStringImageBlock * const formattedStringImageBlock)42 void FormattedStringPlainTextVisitor::visit(const FormattedStringImageBlock * const formattedStringImageBlock)
43 {
44 	Q_UNUSED(formattedStringImageBlock);
45 
46 	Result.append(QChar(QChar::Nbsp));
47 }
48 
visit(const FormattedStringTextBlock * const formattedStringTextBlock)49 void FormattedStringPlainTextVisitor::visit(const FormattedStringTextBlock * const formattedStringTextBlock)
50 {
51 	Result.append(formattedStringTextBlock->content());
52 }
53 
result() const54 QString FormattedStringPlainTextVisitor::result() const
55 {
56 	QString fixedResult = Result;
57 	return fixedResult.replace(QChar::LineSeparator, "\n");
58 }
59