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 #ifndef COMPOSITE_FORMATTED_STRING_H
21 #define COMPOSITE_FORMATTED_STRING_H
22 
23 #include <QtCore/QVector>
24 #include <QtGui/QColor>
25 #include <memory>
26 
27 #include "exports.h"
28 
29 #include "formatted-string.h"
30 
31 /**
32  * @addtogroup FormattedString
33  * @{
34  */
35 
36 /**
37  * @class CompositeFormattedString
38  * @short This class represents FormattedString that is composed of other FormattedString instances.
39  * @author Rafał 'Vogel' Malinowski
40  */
41 class KADUAPI CompositeFormattedString : public FormattedString
42 {
43 	Q_DISABLE_COPY(CompositeFormattedString)
44 
45 	std::vector<std::unique_ptr<FormattedString>> Items;
46 
47 public:
48 	/**
49 	 * @short Create new instance of CompositeFormattedString.
50 	 * @author Rafał 'Vogel' Malinowski
51 	 * @param items items of composite FormattedString
52 	 */
53 	explicit CompositeFormattedString(std::vector<std::unique_ptr<FormattedString>> &&items);
54 	virtual ~CompositeFormattedString();
55 
56 	virtual bool operator == (const FormattedString &compareTo);
57 
58 	/**
59 	 * @short Accept a visitor.
60 	 * @author Rafał 'Vogel' Malinowski
61 	 * @param visitor visitor to accept
62 	 *
63 	 * This method executes visit() method of passed visitor on itself and then on all items.
64 	 */
65 	virtual void accept(FormattedStringVisitor *visitor) const;
66 
67 	/**
68 	 * @short Return true if his FormattedString is empty or consists only of empty items.
69 	 * @author Rafał 'Vogel' Malinowski
70 	 * @return true if his FormattedString is empty or consists only of empty items
71 	 */
72 	virtual bool isEmpty() const;
73 
74 	/**
75 	 * @short Return all items that compose this CompositeFormattedString.
76 	 * @author Rafał 'Vogel' Malinowski
77 	 * @return all items that compose this CompositeFormattedString
78 	 */
79 	const std::vector<std::unique_ptr<FormattedString>> & items() const;
80 
81 };
82 
83 #endif // COMPOSITE_FORMATTED_STRING_H
84