Commit 0ee26a5e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use astyle-kdelibs

parent a8ed5abf
This diff is collapsed.
......@@ -28,7 +28,6 @@
#include <kcalcore/todo.h>
#include <QtCore/QString>
namespace KAlarmCal
{
......@@ -50,152 +49,151 @@ class KAEvent;
class KALARMCAL_EXPORT AlarmText
{
public:
/** Constructor which sets the alarm text.
* If @p text starts with '#!', it is flagged as a script, else plain text.
* @param text alarm text to set
*/
explicit AlarmText(const QString& text = QString());
AlarmText(const AlarmText& other);
~AlarmText();
AlarmText& operator=(const AlarmText& other);
/** Set the alarm text.
* If @p text starts with '#!', it is flagged as a script, else plain text.
* @param text alarm text to set
*/
void setText(const QString& text);
/** Set the instance contents to be a script.
* @param text text of script to set
*/
void setScript(const QString& text);
/** Set the instance contents to be an email.
* @param to 'To' header parameter
* @param from 'From' header parameter
* @param cc 'Cc' header parameter
* @param time 'Date' header parameter
* @param subject 'Subject' header parameter
* @param body email body text
*/
void setEmail(const QString& to, const QString& from, const QString& cc, const QString& time,
const QString& subject, const QString& body, unsigned long kmailSerialNumber = 0);
/** Set the instance contents to be a todo.
* @param todo Todo instance to set as the text
*/
void setTodo(const KCalCore::Todo::Ptr& todo);
/** Return the text for a text message alarm, in display format.
* - An email is returned as a sequence of headers followed by the message body.
* - A todo is returned as a subject, location and due date followed by any text.
* - A script or plain text is returned without interpretation.
*/
QString displayText() const;
/** Return the 'To' header parameter for an email alarm.
* @return 'from' value, or empty if not an email text.
*/
QString to() const;
/** Return the 'From' header parameter for an email alarm.
* @return 'from' value, or empty if not an email text.
*/
QString from() const;
/** Return the 'Cc' header parameter for an email alarm.
* @return 'cc' value, or empty if not an email text.
*/
QString cc() const;
/** Return the 'Date' header parameter for an email alarm.
* @return 'date' value, or empty if not an email text.
*/
QString time() const;
/** Return the 'Subject' header parameter for an email alarm.
* @return 'subject' value, or empty if not an email text.
*/
QString subject() const;
/** Return the email message body.
* @return message body, or empty if not an email text.
*/
QString body() const;
/** Return the summary text for a todo.
* @return summary text, or empty if not a todo.
*/
QString summary() const;
/** Return the location text for a todo.
* @return location text, or empty if not a todo.
*/
QString location() const;
/** Return the due date text for a todo.
* @return due date text, or empty if not a todo.
*/
QString due() const;
/** Return the description text for a todo.
* @return description text, or empty if not a todo.
*/
QString description() const;
/** Return whether there is any text. */
bool isEmpty() const;
/** Return whether the instance contains the text of an email. */
bool isEmail() const;
/** Return whether the instance contains the text of a script. */
bool isScript() const;
/** Return whether the instance contains the text of a todo. */
bool isTodo() const;
/** Return the kmail serial number of an email.
* @return serial number, or 0 if none.
*/
unsigned long kmailSerialNumber() const;
/** Return the alarm summary text for either single line or tooltip display.
* @param event event whose summary text is to be returned
* @param maxLines the maximum number of lines returned
* @param truncated if non-null, points to a variable which will be set true
* if the text returned has been truncated, other than to
* strip a trailing newline, or false otherwise
*/
static QString summary(const KAEvent& event, int maxLines = 1, bool* truncated = 0);
/** Return whether a text is an email, with at least To and From headers.
* @param text text to check
*/
static bool checkIfEmail(const QString& text);
/** Check whether a text is an email (with at least To and From headers),
* and if so return its headers or optionally only its subject line.
* @param text text to check
* @param subjectOnly true to only return the subject line,
* false to return all headers
* @return headers/subject line, or QString() if not the text of an email.
*/
static QString emailHeaders(const QString& text, bool subjectOnly);
/** Translate an alarm calendar text to a display text.
* Translation is needed for email texts, since the alarm calendar stores
* untranslated email prefixes.
* @param text text to translate
* @param email updated to indicate whether it is an email text
*/
static QString fromCalendarText(const QString& text, bool& email);
/** Return the text for an alarm message text, in alarm calendar format.
* (The prefix strings are untranslated in the calendar.)
* @param text alarm message text
*/
static QString toCalendarText(const QString& text);
private:
//@cond PRIVATE
class Private;
Private* const d;
//@endcond
public:
/** Constructor which sets the alarm text.
* If @p text starts with '#!', it is flagged as a script, else plain text.
* @param text alarm text to set
*/
explicit AlarmText(const QString &text = QString());
AlarmText(const AlarmText &other);
~AlarmText();
AlarmText &operator=(const AlarmText &other);
/** Set the alarm text.
* If @p text starts with '#!', it is flagged as a script, else plain text.
* @param text alarm text to set
*/
void setText(const QString &text);
/** Set the instance contents to be a script.
* @param text text of script to set
*/
void setScript(const QString &text);
/** Set the instance contents to be an email.
* @param to 'To' header parameter
* @param from 'From' header parameter
* @param cc 'Cc' header parameter
* @param time 'Date' header parameter
* @param subject 'Subject' header parameter
* @param body email body text
*/
void setEmail(const QString &to, const QString &from, const QString &cc, const QString &time,
const QString &subject, const QString &body, unsigned long kmailSerialNumber = 0);
/** Set the instance contents to be a todo.
* @param todo Todo instance to set as the text
*/
void setTodo(const KCalCore::Todo::Ptr &todo);
/** Return the text for a text message alarm, in display format.
* - An email is returned as a sequence of headers followed by the message body.
* - A todo is returned as a subject, location and due date followed by any text.
* - A script or plain text is returned without interpretation.
*/
QString displayText() const;
/** Return the 'To' header parameter for an email alarm.
* @return 'from' value, or empty if not an email text.
*/
QString to() const;
/** Return the 'From' header parameter for an email alarm.
* @return 'from' value, or empty if not an email text.
*/
QString from() const;
/** Return the 'Cc' header parameter for an email alarm.
* @return 'cc' value, or empty if not an email text.
*/
QString cc() const;
/** Return the 'Date' header parameter for an email alarm.
* @return 'date' value, or empty if not an email text.
*/
QString time() const;
/** Return the 'Subject' header parameter for an email alarm.
* @return 'subject' value, or empty if not an email text.
*/
QString subject() const;
/** Return the email message body.
* @return message body, or empty if not an email text.
*/
QString body() const;
/** Return the summary text for a todo.
* @return summary text, or empty if not a todo.
*/
QString summary() const;
/** Return the location text for a todo.
* @return location text, or empty if not a todo.
*/
QString location() const;
/** Return the due date text for a todo.
* @return due date text, or empty if not a todo.
*/
QString due() const;
/** Return the description text for a todo.
* @return description text, or empty if not a todo.
*/
QString description() const;
/** Return whether there is any text. */
bool isEmpty() const;
/** Return whether the instance contains the text of an email. */
bool isEmail() const;
/** Return whether the instance contains the text of a script. */
bool isScript() const;
/** Return whether the instance contains the text of a todo. */
bool isTodo() const;
/** Return the kmail serial number of an email.
* @return serial number, or 0 if none.
*/
unsigned long kmailSerialNumber() const;
/** Return the alarm summary text for either single line or tooltip display.
* @param event event whose summary text is to be returned
* @param maxLines the maximum number of lines returned
* @param truncated if non-null, points to a variable which will be set true
* if the text returned has been truncated, other than to
* strip a trailing newline, or false otherwise
*/
static QString summary(const KAEvent &event, int maxLines = 1, bool *truncated = 0);
/** Return whether a text is an email, with at least To and From headers.
* @param text text to check
*/
static bool checkIfEmail(const QString &text);
/** Check whether a text is an email (with at least To and From headers),
* and if so return its headers or optionally only its subject line.
* @param text text to check
* @param subjectOnly true to only return the subject line,
* false to return all headers
* @return headers/subject line, or QString() if not the text of an email.
*/
static QString emailHeaders(const QString &text, bool subjectOnly);
/** Translate an alarm calendar text to a display text.
* Translation is needed for email texts, since the alarm calendar stores
* untranslated email prefixes.
* @param text text to translate
* @param email updated to indicate whether it is an email text
*/
static QString fromCalendarText(const QString &text, bool &email);
/** Return the text for an alarm message text, in alarm calendar format.
* (The prefix strings are untranslated in the calendar.)
* @param text alarm message text
*/
static QString toCalendarText(const QString &text);
private:
//@cond PRIVATE
class Private;
Private *const d;
//@endcond
};
} // namespace KAlarmCal
#endif // ALARMTEXT_H
// vim: et sw=4:
......@@ -29,15 +29,15 @@ namespace KAlarmCal
class CollectionAttribute::Private
{
public:
Private() : mEnabled(CalEvent::EMPTY),
mStandard(CalEvent::EMPTY),
mKeepFormat(false) {}
public:
Private() : mEnabled(CalEvent::EMPTY),
mStandard(CalEvent::EMPTY),
mKeepFormat(false) {}
QColor mBackgroundColour; // background color for collection and its alarms
CalEvent::Types mEnabled; // which alarm types the collection is enabled for
CalEvent::Types mStandard; // whether the collection is a standard collection
bool mKeepFormat; // whether user has chosen to keep old calendar storage format
QColor mBackgroundColour; // background color for collection and its alarms
CalEvent::Types mEnabled; // which alarm types the collection is enabled for
CalEvent::Types mStandard; // whether the collection is a standard collection
bool mKeepFormat; // whether user has chosen to keep old calendar storage format
};
CollectionAttribute::CollectionAttribute()
......@@ -45,7 +45,7 @@ CollectionAttribute::CollectionAttribute()
{
}
CollectionAttribute::CollectionAttribute(const CollectionAttribute& rhs)
CollectionAttribute::CollectionAttribute(const CollectionAttribute &rhs)
: Akonadi::Attribute(rhs),
d(new Private(*rhs.d))
{
......@@ -56,17 +56,16 @@ CollectionAttribute::~CollectionAttribute()
delete d;
}
CollectionAttribute& CollectionAttribute::operator=(const CollectionAttribute& other)
CollectionAttribute &CollectionAttribute::operator=(const CollectionAttribute &other)
{
if (&other != this)
{
if (&other != this) {
Attribute::operator=(other);
*d = *other.d;
}
return *this;
}
CollectionAttribute* CollectionAttribute::clone() const
CollectionAttribute *CollectionAttribute::clone() const
{
return new CollectionAttribute(*this);
}
......@@ -83,19 +82,17 @@ CalEvent::Types CollectionAttribute::enabled() const
void CollectionAttribute::setEnabled(CalEvent::Type type, bool enabled)
{
switch (type)
{
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
break;
default:
return;
switch (type) {
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
break;
default:
return;
}
if (enabled)
if (enabled) {
d->mEnabled |= type;
else
{
} else {
d->mEnabled &= ~type;
d->mStandard &= ~type;
}
......@@ -109,14 +106,13 @@ void CollectionAttribute::setEnabled(CalEvent::Types types)
bool CollectionAttribute::isStandard(CalEvent::Type type) const
{
switch (type)
{
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
return d->mStandard & type;
default:
return false;
switch (type) {
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
return d->mStandard & type;
default:
return false;
}
}
......@@ -127,18 +123,18 @@ CalEvent::Types CollectionAttribute::standard() const
void CollectionAttribute::setStandard(CalEvent::Type type, bool standard)
{
switch (type)
{
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
if (standard)
d->mStandard = static_cast<CalEvent::Types>(d->mStandard | type);
else
d->mStandard = static_cast<CalEvent::Types>(d->mStandard & ~type);
break;
default:
break;
switch (type) {
case CalEvent::ACTIVE:
case CalEvent::ARCHIVED:
case CalEvent::TEMPLATE:
if (standard) {
d->mStandard = static_cast<CalEvent::Types>(d->mStandard | type);
} else {
d->mStandard = static_cast<CalEvent::Types>(d->mStandard & ~type);
}
break;
default:
break;
}
}
......@@ -152,7 +148,7 @@ QColor CollectionAttribute::backgroundColor() const
return d->mBackgroundColour;
}
void CollectionAttribute::setBackgroundColor(const QColor& c)
void CollectionAttribute::setBackgroundColor(const QColor &c)
{
d->mBackgroundColour = c;
}
......@@ -180,20 +176,20 @@ QByteArray CollectionAttribute::name()
QByteArray CollectionAttribute::serialized() const
{
QByteArray v = QByteArray::number(d->mEnabled) + ' '
+ QByteArray::number(d->mStandard) + ' '
+ QByteArray(d->mKeepFormat ? "1" : "0") + ' '
+ QByteArray(d->mBackgroundColour.isValid() ? "1" : "0");
+ QByteArray::number(d->mStandard) + ' '
+ QByteArray(d->mKeepFormat ? "1" : "0") + ' '
+ QByteArray(d->mBackgroundColour.isValid() ? "1" : "0");
if (d->mBackgroundColour.isValid())
v += ' '
+ QByteArray::number(d->mBackgroundColour.red()) + ' '
+ QByteArray::number(d->mBackgroundColour.green()) + ' '
+ QByteArray::number(d->mBackgroundColour.blue()) + ' '
+ QByteArray::number(d->mBackgroundColour.alpha());
+ QByteArray::number(d->mBackgroundColour.red()) + ' '
+ QByteArray::number(d->mBackgroundColour.green()) + ' '
+ QByteArray::number(d->mBackgroundColour.blue()) + ' '
+ QByteArray::number(d->mBackgroundColour.alpha());
qDebug() << v;
return v;
}
void CollectionAttribute::deserialize(const QByteArray& data)
void CollectionAttribute::deserialize(const QByteArray &data)
{
qDebug() << data;
......@@ -208,56 +204,51 @@ void CollectionAttribute::deserialize(const QByteArray& data)
const QList<QByteArray> items = data.simplified().split(' ');
int count = items.count();
int index = 0;
if (count > index)
{
if (count > index) {
// 0: type(s) of alarms for which the collection is enabled
c[0] = items[index++].toInt(&ok);
if (!ok || (c[0] & ~(CalEvent::ACTIVE | CalEvent::ARCHIVED | CalEvent::TEMPLATE)))
{
if (!ok || (c[0] & ~(CalEvent::ACTIVE | CalEvent::ARCHIVED | CalEvent::TEMPLATE))) {
qCritical() << "Invalid alarm types:" << c[0];
return;
}
d->mEnabled = static_cast<CalEvent::Types>(c[0]);
}
if (count > index)
{
if (count > index) {
// 1: type(s) of alarms for which the collection is the standard collection
c[0] = items[index++].toInt(&ok);
if (!ok || (c[0] & ~(CalEvent::ACTIVE | CalEvent::ARCHIVED | CalEvent::TEMPLATE)))
{
if (!ok || (c[0] & ~(CalEvent::ACTIVE | CalEvent::ARCHIVED | CalEvent::TEMPLATE))) {
qCritical() << "Invalid alarm types:" << c[0];
return;
}
if (d->mEnabled)
if (d->mEnabled) {
d->mStandard = static_cast<CalEvent::Types>(c[0]);
}
}
if (count > index)
{
if (count > index) {
// 2: keep old calendar storage format
c[0] = items[index++].toInt(&ok);
if (!ok)
if (!ok) {
return;
}
d->mKeepFormat = c[0];
}
if (count > index)
{
if (count > index) {
// 3: background color valid flag
c[0] = items[index++].toInt(&ok);
if (!ok)
if (!ok) {
return;
if (c[0])
{
if (count < index + 4)
{
}
if (c[0]) {
if (count < index + 4) {
qCritical() << "Invalid number of background color elements";
return;
}
// 4-7: background color elements
for (int i = 0; i < 4; ++i)
{
for (int i = 0; i < 4; ++i) {
c[i] = items[index++].toInt(&ok);
if (!ok)
if (!ok) {
return;
}
}
d->mBackgroundColour.setRgb(c[0], c[1], c[2], c[3]);
}
......@@ -266,4 +257,3 @@ void CollectionAttribute::deserialize(const QByteArray& data)
} // namespace KAlarmCal
// vim: et sw=4:
......@@ -50,110 +50,109 @@ namespace KAlarmCal
class KALARMCAL_EXPORT CollectionAttribute : public Akonadi::Attribute
{
public:
CollectionAttribute();
/** Copy constructor. */
CollectionAttribute(const CollectionAttribute& other);
/** Assignment operator. */
CollectionAttribute& operator=(const CollectionAttribute& other);
virtual ~CollectionAttribute();
/** Return whether the collection is enabled for a specified alarm type
* (active, archived, template or displaying).
* @param type alarm type to check for.
*/
bool isEnabled(CalEvent::Type type) const;
/** Return which alarm types (active, archived or template) the
* collection is enabled for. */
CalEvent::Types enabled() const;
/** Set the enabled/disabled state of the collection and its alarms,
* for a specified alarm type (active, archived or template). The
* enabled/disabled state for other alarm types is not affected.
* The alarms of that type in a disabled collection are ignored, and
* not displayed in the alarm list. The standard status for that type
* for a disabled collection is automatically cleared.
* @param type alarm type
* @param enabled true to set enabled, false to set disabled.
*/
void setEnabled(CalEvent::Type type, bool enabled);
/** Set which alarm types (active, archived or template) the collection
* is enabled for.
* @param types alarm types
*/
void setEnabled(CalEvent::Types types);
/** Return whether the collection is the standard collection for a specified
* alarm type (active, archived or template).
* @param type alarm type
*/
bool isStandard(CalEvent::Type type) const;
/** Set or clear the collection as the standard collection for a specified
* alarm type (active, archived or template).
* @param type alarm type
* @param standard true to set as standard, false to clear standard status.
*/
void setStandard(CalEvent::Type, bool standard);
/** Return which alarm types (active, archived or template) the
* collection is standard for.
* @return alarm types.
*/
CalEvent::Types standard() const;