1 /*
2  * %kadu copyright begin%
3  * Copyright 2010, 2011 Piotr Galiszewski (piotr.galiszewski@kadu.im)
4  * Copyright 2010 Piotr Dąbrowski (ultr@ultr.pl)
5  * Copyright 2010, 2011 Bartosz Brachaczek (b.brachaczek@gmail.com)
6  * Copyright 2009, 2010, 2011 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com)
7  * %kadu copyright end%
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef STATUS_H
24 #define STATUS_H
25 
26 #include <QtCore/QMetaType>
27 #include <QtCore/QString>
28 
29 #include "status/status-type-group.h"
30 #include "status/status-type.h"
31 
32 #include "exports.h"
33 
34 /**
35  * @addtogroup Status
36  * @{
37  */
38 
39 /**
40  * @class Status
41  * @author Rafał 'Vogel' Malinowski
42  * @short Class representing current status of user.
43  * @see StatusType
44  * @see StatusTypeGroup
45  *
46  * This class describes current status of any user. Status contains two values - status type and description.
47  * Statuses can be ordered using StatusType enum (smaller value means greater availability).
48  */
49 class KADUAPI Status
50 {
51 	StatusType Type;
52 	QString Description;
53 
54 public:
55 	/**
56 	 * @author Rafał 'Vogel' Malinowski
57 	 * @short Creates new status with given type and description.
58 	 * @param statusType type of new status
59 	 * @param description description of new status.
60 	 *
61 	 * Creates new status with given type and description.
62 	 */
63 	explicit Status(StatusType statusType = StatusType::Offline, const QString &description = QString());
64 	Status(const Status &copyme);
65 	~Status();
66 
67 	/**
68 	 * @author Rafał 'Vogel' Malinowski
69 	 * @short Returns this status type.
70 	 * @return this status type
71 	 *
72 	 * Returns this status type.
73 	 */
type()74 	StatusType type() const { return Type; }
75 
76 	/**
77 	 * @author Rafał 'Vogel' Malinowski
78 	 * @short Updates this status type.
79 	 * @param type new status type
80 	 *
81 	 * Updates this status type. Values of displayName and group are also updated.
82 	 */
83 	void setType(StatusType type);
84 
85 	/**
86 	 * @author Rafał 'Vogel' Malinowski
87 	 * @short Returns this status description.
88 	 * @return this status description
89 	 *
90 	 * Returns this status description.
91 	 */
description()92 	const QString & description() const { return Description; }
93 
94 	/**
95 	 * @author Rafał 'Vogel' Malinowski
96 	 * @short Updates this status description.
97 	 * @param escription new status description
98 	 *
99 	 * Updates this status description.
100 	 */
setDescription(const QString & description)101 	void setDescription(const QString &description) { Description = description; }
102 
103 	/**
104 	 * @author Rafał 'Vogel' Malinowski
105 	 * @short Returns true if this status description is not empty.
106 	 * @return true if this status description is not empty
107 	 *
108 	 * Returns true if this status description is not empty.
109 	 */
110 	bool hasDescription() const;
111 
112 	/**
113 	 * @author Rafał 'Vogel' Malinowski
114 	 * @short Returns true if this status if not connected (offline).
115 	 * @return true if this status if not connected (offline)
116 	 *
117 	 * Returns true if this status if not connected (offline).
118 	 */
119 	bool isDisconnected() const;
120 
121 	/**
122 	 * @author Rafał 'Vogel' Malinowski
123 	 * @short Compares two statuses.
124 	 * @return true if left status is more available than right one
125 	 *
126 	 * This method compares two statuses. Status which is more available is considered 'less', so it returns
127 	 * true when left status is more available than right one.
128 	 */
129 	bool operator < (const Status &compare) const;
130 
131 	/**
132 	 * @author Rafał 'Vogel' Malinowski
133 	 * @short Compares two statuses.
134 	 * @return true if both statuses are equal
135 	 *
136 	 * This method compares two statuses. Statuses are equal when its types and description are equal.
137 	 */
138 	bool operator == (const Status &compare) const;
139 
140 	/**
141 	 * @author Rafał 'Vogel' Malinowski
142 	 * @short Compares two statuses.
143 	 * @return true if statuses are not equal
144 	 *
145 	 * This method compares two statuses. Statuses are not equal when its types or description are not equal.
146 	 */
147 	bool operator != (const Status &compare) const;
148 
149 };
150 
151 /**
152  * @addtogroup Status
153  * @}
154  */
155 
156 Q_DECLARE_METATYPE(Status)
157 
158 #endif // STATUS_H
159