Commit 4ae52813 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent cd17e57e
......@@ -8,12 +8,12 @@
#include "conflictresolvertest.h"
#include "conflictresolver.h"
#include <KCalendarCore/Duration>
#include <KCalendarCore/Event>
#include <KCalendarCore/Period>
#include <KCalendarCore/Duration>
#include <QWidget>
#include <QTest>
#include <QWidget>
using namespace IncidenceEditorNG;
......@@ -27,9 +27,8 @@ void ConflictResolverTest::insertAttendees()
void ConflictResolverTest::addAttendee(const QString &email, const KCalendarCore::FreeBusy::Ptr &fb, KCalendarCore::Attendee::Role role)
{
QString name = QStringLiteral("attendee %1").arg(attendees.count());
CalendarSupport::FreeBusyItem::Ptr item(new CalendarSupport::FreeBusyItem(KCalendarCore::Attendee(name, email, false,
KCalendarCore::Attendee::Accepted,
role), nullptr));
CalendarSupport::FreeBusyItem::Ptr item(
new CalendarSupport::FreeBusyItem(KCalendarCore::Attendee(name, email, false, KCalendarCore::Attendee::Accepted, role), nullptr));
item->setFreeBusy(KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(*fb.data())));
attendees << item;
}
......@@ -57,9 +56,7 @@ void ConflictResolverTest::cleanup()
void ConflictResolverTest::simpleTest()
{
KCalendarCore::Period meeting(end.addSecs(-3 * 60 * 60), KCalendarCore::Duration(2 * 60 * 60));
addAttendee(QStringLiteral("albert@einstein.net"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< meeting)));
addAttendee(QStringLiteral("albert@einstein.net"), KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << meeting)));
insertAttendees();
......@@ -77,9 +74,9 @@ void ConflictResolverTest::simpleTest()
KCalendarCore::Period second = resolver->availableSlots().at(1);
QEXPECT_FAIL("", "Got broken in revision f17b9a8c975588ad7cf4ce8b94ab8e32ac193ed8", Continue);
QCOMPARE(second.start(), meeting.end().addSecs(resolution)); //add 15 minutes because the
//free block doesn't start until
//the next timeslot
QCOMPARE(second.start(), meeting.end().addSecs(resolution)); // add 15 minutes because the
// free block doesn't start until
// the next timeslot
QCOMPARE(second.end(), end);
}
......@@ -89,14 +86,10 @@ void ConflictResolverTest::stillPrettySimpleTest()
KCalendarCore::Period meeting2(base.addSecs(60 * 60), KCalendarCore::Duration(2 * 60 * 60));
KCalendarCore::Period meeting3(end.addSecs(-3 * 60 * 60), KCalendarCore::Duration(2 * 60 * 60));
addAttendee(QStringLiteral("john.f@kennedy.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< meeting1 << meeting3)));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << meeting1 << meeting3)));
addAttendee(QStringLiteral("elvis@rock.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< meeting2 << meeting3)));
addAttendee(QStringLiteral("albert@einstein.net"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< meeting3)));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << meeting2 << meeting3)));
addAttendee(QStringLiteral("albert@einstein.net"), KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << meeting3)));
insertAttendees();
......@@ -115,9 +108,9 @@ void ConflictResolverTest::stillPrettySimpleTest()
KCalendarCore::Period second = resolver->availableSlots().at(1);
QEXPECT_FAIL("", "Got broken in revision f17b9a8c975588ad7cf4ce8b94ab8e32ac193ed8", Continue);
QCOMPARE(second.start(), meeting3.end().addSecs(resolution)); //add 15 minutes because the
//free block doesn't start until
//the next timeslot
QCOMPARE(second.start(), meeting3.end().addSecs(resolution)); // add 15 minutes because the
// free block doesn't start until
// the next timeslot
QCOMPARE(second.end(), end);
}
......@@ -155,46 +148,29 @@ void ConflictResolverTest::akademy2010()
KCalendarCore::Period blurr(_time(15, 15), _time(16, 00));
KCalendarCore::Period plasma(_time(15, 15), _time(16, 00));
// for ( int i = 1; i < 80; ++i ) {
// for ( int i = 1; i < 80; ++i ) {
// adds 80 people (adds the same 8 people 10 times)
addAttendee(QStringLiteral("akademyattendee1@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< opening << keynote
<< oviStore << wikimedia
<< direction)));
addAttendee(QStringLiteral("akademyattendee2@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< opening << keynote
<< commAsService << highlights
<< pimp)));
addAttendee(
QStringLiteral("akademyattendee1@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << opening << keynote << oviStore << wikimedia << direction)));
addAttendee(
QStringLiteral("akademyattendee2@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << opening << keynote << commAsService << highlights << pimp)));
addAttendee(QStringLiteral("akademyattendee3@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< opening << kdeForums
<< styles << pimp << plasma)));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << opening << kdeForums << styles << pimp << plasma)));
addAttendee(QStringLiteral("akademyattendee4@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< opening << keynote
<< oviStore << pimp << blurr)));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << opening << keynote << oviStore << pimp << blurr)));
addAttendee(QStringLiteral("akademyattendee5@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< keynote << oviStore
<< highlights << avalanche)));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << keynote << oviStore << highlights << avalanche)));
addAttendee(QStringLiteral("akademyattendee6@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< opening << keynote
<< commAsService
<< highlights)));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << opening << keynote << commAsService << highlights)));
addAttendee(QStringLiteral("akademyattendee7@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< opening << kdeForums
<< styles << avalanche
<< pimp << plasma)));
addAttendee(QStringLiteral("akademyattendee8@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< opening << keynote
<< oviStore << wikimedia
<< blurr)));
// }
KCalendarCore::FreeBusy::Ptr(
new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << opening << kdeForums << styles << avalanche << pimp << plasma)));
addAttendee(
QStringLiteral("akademyattendee8@email.com"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << opening << keynote << oviStore << wikimedia << blurr)));
// }
insertAttendees();
......@@ -202,16 +178,14 @@ void ConflictResolverTest::akademy2010()
resolver->setResolution(resolution);
resolver->setEarliestDateTime(base);
resolver->setLatestDateTime(end);
// QBENCHMARK {
// QBENCHMARK {
resolver->findAllFreeSlots();
// }
// }
QVERIFY(resolver->availableSlots().size() == 3);
QEXPECT_FAIL("", "Got broken in revision f17b9a8c975588ad7cf4ce8b94ab8e32ac193ed8", Abort);
QCOMPARE(resolver->availableSlots().at(0).duration(),
KCalendarCore::Duration(10 * 60));
QCOMPARE(resolver->availableSlots().at(1).duration(),
KCalendarCore::Duration(1 * 60 * 60 + 25 * 60));
QCOMPARE(resolver->availableSlots().at(0).duration(), KCalendarCore::Duration(10 * 60));
QCOMPARE(resolver->availableSlots().at(1).duration(), KCalendarCore::Duration(1 * 60 * 60 + 25 * 60));
QVERIFY(resolver->availableSlots().at(2).start() > plasma.end());
}
......@@ -226,10 +200,8 @@ void ConflictResolverTest::testPeriodIsLargerThenTimeframe()
KCalendarCore::Period testEvent(_time(5, 45), _time(8, 45));
addAttendee(QStringLiteral("kdabtest1@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"), KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
insertAttendees();
resolver->setEarliestDateTime(base);
......@@ -250,10 +222,8 @@ void ConflictResolverTest::testPeriodBeginsBeforeTimeframeBegins()
KCalendarCore::Period testEvent(_time(5, 45), _time(8, 45));
addAttendee(QStringLiteral("kdabtest1@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"), KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
insertAttendees();
resolver->setEarliestDateTime(base);
......@@ -277,10 +247,8 @@ void ConflictResolverTest::testPeriodEndsAfterTimeframeEnds()
KCalendarCore::Period testEvent(_time(8, 00), _time(9, 45));
addAttendee(QStringLiteral("kdabtest1@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"), KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
insertAttendees();
resolver->setEarliestDateTime(base);
......@@ -305,10 +273,8 @@ void ConflictResolverTest::testPeriodEndsAtSametimeAsTimeframe()
KCalendarCore::Period testEvent(_time(5, 45), _time(8, 45));
addAttendee(QStringLiteral("kdabtest1@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List()
<< testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"),
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List() << testEvent)));
addAttendee(QStringLiteral("kdabtest2@demo.kolab.org"), KCalendarCore::FreeBusy::Ptr(new KCalendarCore::FreeBusy(KCalendarCore::Period::List())));
insertAttendees();
resolver->setEarliestDateTime(base);
......
......@@ -10,12 +10,13 @@
#include <CalendarSupport/FreeBusyItem>
#include <KCalendarCore/FreeBusy>
#include <KCalendarCore/Attendee>
#include <KCalendarCore/FreeBusy>
#include <QObject>
namespace IncidenceEditorNG {
namespace IncidenceEditorNG
{
class ConflictResolver;
}
......@@ -36,7 +37,8 @@ private Q_SLOTS:
private:
void insertAttendees();
void addAttendee(const QString &email, const KCalendarCore::FreeBusy::Ptr &fb, KCalendarCore::Attendee::Role role = KCalendarCore::Attendee::ReqParticipant);
void
addAttendee(const QString &email, const KCalendarCore::FreeBusy::Ptr &fb, KCalendarCore::Attendee::Role role = KCalendarCore::Attendee::ReqParticipant);
QList<CalendarSupport::FreeBusyItem::Ptr> attendees;
QWidget *parent;
IncidenceEditorNG::ConflictResolver *resolver;
......
......@@ -11,12 +11,12 @@
#include <CalendarSupport/FreeBusyItem>
#include <CalendarSupport/FreeBusyItemModel>
#include <KGantt/KGanttGraphicsView>
#include <KCalendarCore/Attendee>
#include <KGantt/KGanttGraphicsView>
#include <QAbstractItemModelTester>
#include <QTest>
#include <QStandardPaths>
#include <QTest>
QTEST_MAIN(FreeBusyGanttProxyModelTest)
using namespace IncidenceEditorNG;
......
......@@ -36,12 +36,9 @@ private Q_SLOTS:
// Just make sure, that the QCombobox is sorted like we think
QComboBox *first = dialog.mAttendeeDecision[0].second;
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(0, Qt::UserRole).toInt(),
IndividualMailDialog::Update);
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(1, Qt::UserRole).toInt(),
IndividualMailDialog::NoUpdate);
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(2, Qt::UserRole).toInt(),
IndividualMailDialog::Edit);
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(0, Qt::UserRole).toInt(), IndividualMailDialog::Update);
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(1, Qt::UserRole).toInt(), IndividualMailDialog::NoUpdate);
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(2, Qt::UserRole).toInt(), IndividualMailDialog::Edit);
// No update for first attendee, other default
first->setCurrentIndex(1);
......
......@@ -11,9 +11,9 @@
#include <KEmailAddress>
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
using namespace IncidenceEditorNG;
......@@ -24,8 +24,7 @@ AlarmDialog::AlarmDialog(KCalendarCore::Incidence::IncidenceType incidenceType,
{
setWindowTitle(i18nc("@title:window", "Create a new reminder"));
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......@@ -90,10 +89,10 @@ void AlarmDialog::load(const KCalendarCore::Alarm::Ptr &alarm)
offset = offset / 60; // make minutes
int useoffset = offset;
if (offset % (24 * 60) == 0 && offset > 0) { // divides evenly into days?
if (offset % (24 * 60) == 0 && offset > 0) { // divides evenly into days?
useoffset = offset / (24 * 60);
mUi->mOffsetUnit->setCurrentIndex(2);
} else if (offset % 60 == 0 && offset > 0) { // divides evenly into hours?
} else if (offset % 60 == 0 && offset > 0) { // divides evenly into hours?
useoffset = offset / 60;
mUi->mOffsetUnit->setCurrentIndex(1);
} else {
......@@ -106,7 +105,7 @@ void AlarmDialog::load(const KCalendarCore::Alarm::Ptr &alarm)
mUi->mRepeats->setChecked(alarm->repeatCount() > 0);
if (alarm->repeatCount() > 0) {
mUi->mRepeatCount->setValue(alarm->repeatCount());
mUi->mRepeatInterval->setValue(alarm->snoozeTime().asSeconds() / 60); // show as minutes
mUi->mRepeatInterval->setValue(alarm->snoozeTime().asSeconds() / 60); // show as minutes
}
int id = 0;
......@@ -122,15 +121,13 @@ void AlarmDialog::load(const KCalendarCore::Alarm::Ptr &alarm)
mUi->mAppArguments->setText(alarm->programArguments());
id = 2;
break;
case KCalendarCore::Alarm::Email:
{
case KCalendarCore::Alarm::Email: {
mUi->mTypeCombo->setCurrentIndex(3);
KCalendarCore::Person::List addresses = alarm->mailAddresses();
QStringList add;
add.reserve(addresses.count());
const KCalendarCore::Person::List::ConstIterator end(addresses.constEnd());
for (KCalendarCore::Person::List::ConstIterator it = addresses.constBegin();
it != end; ++it) {
for (KCalendarCore::Person::List::ConstIterator it = addresses.constBegin(); it != end; ++it) {
add << (*it).fullName();
}
mUi->mEmailAddress->setText(add.join(QLatin1String(", ")));
......@@ -147,8 +144,7 @@ void AlarmDialog::load(const KCalendarCore::Alarm::Ptr &alarm)
}
mUi->mTypeStack->setCurrentIndex(id);
if (alarm->audioFile().isEmpty()
&& IncidenceEditorNG::EditorConfig::instance()->defaultAudioFileReminders()) {
if (alarm->audioFile().isEmpty() && IncidenceEditorNG::EditorConfig::instance()->defaultAudioFileReminders()) {
mUi->mSoundFile->setUrl(IncidenceEditorNG::EditorConfig::instance()->audioFilePath());
}
}
......@@ -169,7 +165,7 @@ void AlarmDialog::save(const KCalendarCore::Alarm::Ptr &alarm) const
}
const int beforeafterpos = mUi->mBeforeAfter->currentIndex();
if (beforeafterpos % 2 == 0) { // before -> negative
if (beforeafterpos % 2 == 0) { // before -> negative
offset = -offset;
}
......@@ -181,28 +177,27 @@ void AlarmDialog::save(const KCalendarCore::Alarm::Ptr &alarm) const
// We assume that if mAllowBeginReminders is not set, that mAllowBeginReminders
// is set.
if (!mAllowBeginReminders) { // before or after DTDUE
if (!mAllowBeginReminders) { // before or after DTDUE
alarm->setEndOffset(KCalendarCore::Duration(offset));
} else if (beforeafterpos == 0 || beforeafterpos == 1) { // before or after DTSTART
} else if (beforeafterpos == 0 || beforeafterpos == 1) { // before or after DTSTART
alarm->setStartOffset(KCalendarCore::Duration(offset));
} else if (beforeafterpos == 2 || beforeafterpos == 3) { // before or after DTEND/DTDUE
} else if (beforeafterpos == 2 || beforeafterpos == 3) { // before or after DTEND/DTDUE
alarm->setEndOffset(KCalendarCore::Duration(offset));
}
// Repeating
if (mUi->mRepeats->isChecked()) {
alarm->setRepeatCount(mUi->mRepeatCount->value());
alarm->setSnoozeTime(mUi->mRepeatInterval->value() * 60); // convert back to seconds
alarm->setSnoozeTime(mUi->mRepeatInterval->value() * 60); // convert back to seconds
} else {
alarm->setRepeatCount(0);
}
if (mUi->mTypeCombo->currentIndex() == 1) { // Audio
if (mUi->mTypeCombo->currentIndex() == 1) { // Audio
alarm->setAudioAlarm(mUi->mSoundFile->url().toLocalFile());
} else if (mUi->mTypeCombo->currentIndex() == 2) { // Application / script
alarm->setProcedureAlarm(mUi->mApplication->url().toLocalFile(),
mUi->mAppArguments->text());
} else if (mUi->mTypeCombo->currentIndex() == 3) { // Email
} else if (mUi->mTypeCombo->currentIndex() == 2) { // Application / script
alarm->setProcedureAlarm(mUi->mApplication->url().toLocalFile(), mUi->mAppArguments->text());
} else if (mUi->mTypeCombo->currentIndex() == 3) { // Email
QStringList addresses = KEmailAddress::splitAddressList(mUi->mEmailAddress->text());
KCalendarCore::Person::List add;
add.reserve(addresses.count());
......
......@@ -12,27 +12,20 @@
#include <QDialog>
namespace Ui {
namespace Ui
{
class AlarmDialog;
}
namespace IncidenceEditorNG {
namespace IncidenceEditorNG
{
class AlarmDialog : public QDialog
{
Q_OBJECT
public:
enum Unit {
Minutes,
Hours,
Days
};
enum When {
BeforeStart = 0,
AfterStart,
BeforeEnd,
AfterEnd
};
enum Unit { Minutes, Hours, Days };
enum When { BeforeStart = 0, AfterStart, BeforeEnd, AfterEnd };
public:
/**
......
......@@ -9,7 +9,6 @@
#include <CalendarSupport/KCalPrefs>
#include <KLocalizedString>
#include "incidenceeditor_debug.h"
......@@ -17,8 +16,10 @@
using namespace CalendarSupport;
using namespace KCalendarCore;
namespace IncidenceEditorNG {
namespace AlarmPresets {
namespace IncidenceEditorNG
{
namespace AlarmPresets
{
// Don't use a map, because order matters
Q_GLOBAL_STATIC(QStringList, sBeforeStartPresetNames)
Q_GLOBAL_STATIC(QStringList, sBeforeEndPresetNames)
......@@ -37,9 +38,7 @@ int configuredReminderTimeInMinutes()
const int unitsToUse = configuredUnits >= 0 && configuredUnits <= 2 ? configuredUnits : 0;
const int configuredReminderTime = KCalPrefs::instance()->reminderTime();
const int reminderTimeToUse = configuredReminderTime >= 0
? configuredReminderTime
: DEFAULT_REMINDER_OFFSET;
const int reminderTimeToUse = configuredReminderTime >= 0 ? configuredReminderTime : DEFAULT_REMINDER_OFFSET;
return reminderTimeToUse * units[unitsToUse];
}
......@@ -47,17 +46,13 @@ int configuredReminderTimeInMinutes()
void initPresets(AlarmPresets::When when)
{
QList<int> hardcodedPresets;
hardcodedPresets << 0 // at start/due
<< 5 // 5 minutes
<< 10
<< 15
<< 30
<< 45
<< 60 // 1 hour
<< 2 * 60 // 2 hours
<< 24 * 60 // 1 day
hardcodedPresets << 0 // at start/due
<< 5 // 5 minutes
<< 10 << 15 << 30 << 45 << 60 // 1 hour
<< 2 * 60 // 2 hours
<< 24 * 60 // 1 day
<< 2 * 24 * 60 // 2 days
<< 5 * 24 * 60;// 5 days
<< 5 * 24 * 60; // 5 days
sDefaultAlarmOffset = configuredReminderTimeInMinutes();
......@@ -85,21 +80,13 @@ void initPresets(AlarmPresets::When when)
alarm->setStartOffset(-minutes * 60);
alarm->setEnabled(true);
if (minutes == 0) {
sBeforeStartPresetNames->append(i18nc("@item:inlistbox",
"At start"));
sBeforeStartPresetNames->append(i18nc("@item:inlistbox", "At start"));
} else if (minutes < 60) {
sBeforeStartPresetNames->append(i18ncp("@item:inlistbox",
"%1 minute before start",
"%1 minutes before start", minutes));
sBeforeStartPresetNames->append(i18ncp("@item:inlistbox", "%1 minute before start", "%1 minutes before start", minutes));
} else if (minutes < 24 * 60) {
sBeforeStartPresetNames->append(i18ncp("@item:inlistbox",
"%1 hour before start",
"%1 hours before start", minutes / 60));
sBeforeStartPresetNames->append(i18ncp("@item:inlistbox", "%1 hour before start", "%1 hours before start", minutes / 60));
} else {
sBeforeStartPresetNames->append(i18ncp("@item:inlistbox",
"%1 day before start",
"%1 days before start",
minutes / (24 * 60)));
sBeforeStartPresetNames->append(i18ncp("@item:inlistbox", "%1 day before start", "%1 days before start", minutes / (24 * 60)));
}
sBeforeStartPresets->append(alarm);
}
......@@ -115,17 +102,11 @@ void initPresets(AlarmPresets::When when)
if (minutes == 0) {
sBeforeEndPresetNames->append(i18nc("@item:inlistbox", "When due"));
} else if (minutes < 60) {
sBeforeEndPresetNames->append(i18ncp("@item:inlistbox",
"%1 minute before due",
"%1 minutes before due", minutes));
sBeforeEndPresetNames->append(i18ncp("@item:inlistbox", "%1 minute before due", "%1 minutes before due", minutes));
} else if (minutes < 24 * 60) {
sBeforeEndPresetNames->append(i18ncp("@item:inlistbox",
"%1 hour before due",
"%1 hours before due", minutes / 60));
sBeforeEndPresetNames->append(i18ncp("@item:inlistbox", "%1 hour before due", "%1 hours before due", minutes / 60));
} else {
sBeforeEndPresetNames->append(i18ncp("@item:inlistbox",
"%1 day before due",
"%1 days before due", minutes / (24 * 60)));
sBeforeEndPresetNames->append(i18ncp("@item:inlistbox", "%1 day before due", "%1 days before due", minutes / (24 * 60)));
}
sBeforeEndPresets->append(alarm);
}
......@@ -180,21 +161,16 @@ KCalendarCore::Alarm::Ptr preset(When when, const QString &name)
// The name should exists and only once
if (sBeforeStartPresetNames->count(name) != 1) {
// print some debug info before crashing
qCDebug(INCIDENCEEDITOR_LOG) << " name = " << name << "; when = " << when
<< "; count for name = " << sBeforeStartPresetNames->count(
name)
<< "; global count = "
<< sBeforeStartPresetNames->count();
qCDebug(INCIDENCEEDITOR_LOG) << " name = " << name << "; when = " << when << "; count for name = " << sBeforeStartPresetNames->count(name)
<< "; global count = " << sBeforeStartPresetNames->count();
Q_ASSERT_X(false, "preset", "Number of presets should be one");
}
return KCalendarCore::Alarm::Ptr(
new KCalendarCore::Alarm(*sBeforeStartPresets->at(sBeforeStartPresetNames->indexOf(name))));
return KCalendarCore::Alarm::Ptr(new KCalendarCore::Alarm(*sBeforeStartPresets->at(sBeforeStartPresetNames->indexOf(name))));
case AlarmPresets::BeforeEnd:
Q_ASSERT(sBeforeEndPresetNames->count(name) == 1); // The name should exists and only once
Q_ASSERT(sBeforeEndPresetNames->count(name) == 1); // The name should exists and only once
return KCalendarCore::Alarm::Ptr(
new KCalendarCore::Alarm(*sBeforeEndPresets->at(sBeforeEndPresetNames->indexOf(name))));
return KCalendarCore::Alarm::Ptr(new KCalendarCore::Alarm(*sBeforeEndPresets->at(sBeforeEndPresetNames->indexOf(name))));
}
return KCalendarCore::Alarm::Ptr();
}
......
......@@ -12,17 +12,16 @@
#include <QStringList>
namespace IncidenceEditorNG {
namespace IncidenceEditorNG
{
enum {
// Fallback in case config is invalid
DEFAULT_REMINDER_OFFSET = 15 // minutes
};
namespace AlarmPresets {
enum When {
BeforeStart,
BeforeEnd
};
namespace AlarmPresets
{
enum When { BeforeStart, BeforeEnd };
/**
* Returns the available presets.
......
......@@ -11,13 +11,13 @@
#include "attachmenteditdialog.h"
#include "attachmenticonview.h"
#include "ui_attachmenteditdialog.h"
#include <KLocalizedString>
#include <KIO/StoredTransferJob>
#include <KJobWidgets>
#include <QLocale>
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QLocale>
#include <QMimeDatabase>
#include <QPushButton>
using namespace IncidenceEditorNG;
......@@ -26,8 +26,8 @@ AttachmentEditDialog::AttachmentEditDialog(AttachmentIconItem *item, QWidget *pa
,