55#include " compatibledata.h"
66#include " units.h"
77#include " icalformat.h"
8+ #include " commondef.h"
89
910#include < QJsonObject>
1011#include < QJsonDocument>
@@ -22,6 +23,7 @@ const QMap<int, QString> mTypeMap {{1, "107c369e-b13a-4d45-9ff3-de4eb3c0475b"},
2223 */
2324QJsonObject JobToObject (const DSchedule::Ptr &job)
2425{
26+ // qCDebug(CommonLogger) << "JobToObject, job summary:" << (job ? job->summary() : "null");
2527 QJsonObject obj;
2628
2729 obj.insert (" ID" , job->compatibleID ());
@@ -48,15 +50,18 @@ QJsonObject JobToObject(const DSchedule::Ptr &job)
4850
4951QString DDE_Calendar::getNewTypeIDByOldTypeID (int oldTypeID)
5052{
53+ qCDebug (CommonLogger) << " DDE_Calendar::getNewTypeIDByOldTypeID, oldTypeID:" << oldTypeID;
5154 if (mTypeMap .contains (oldTypeID)) {
5255 return mTypeMap .value (oldTypeID);
5356 } else {
57+ qCWarning (CommonLogger) << " Old type ID not found, returning default" ;
5458 return mTypeMap .value (3 );
5559 }
5660}
5761
5862int DDE_Calendar::getOldTypeIDByNewTypeID (const QString &newTypeID)
5963{
64+ qCDebug (CommonLogger) << " DDE_Calendar::getOldTypeIDByNewTypeID, newTypeID:" << newTypeID;
6065 int oldTypeID = 0 ;
6166 QMap<int , QString>::const_iterator constIter = mTypeMap .constBegin ();
6267
@@ -66,11 +71,13 @@ int DDE_Calendar::getOldTypeIDByNewTypeID(const QString &newTypeID)
6671 break ;
6772 }
6873 }
74+ qCDebug (CommonLogger) << " DDE_Calendar::getOldTypeIDByNewTypeID, oldTypeID:" << oldTypeID;
6975 return oldTypeID == 0 ? 3 : oldTypeID;
7076}
7177
7278QString DDE_Calendar::getExternalSchedule (const DSchedule::Map &scheduleMap)
7379{
80+ qCDebug (CommonLogger) << " DDE_Calendar::getExternalSchedule, map size:" << scheduleMap.size ();
7481 QString strJson;
7582 QJsonDocument doc;
7683 QJsonArray jsonarr;
@@ -94,6 +101,7 @@ QString DDE_Calendar::getExternalSchedule(const DSchedule::Map &scheduleMap)
94101
95102void DDE_Calendar::setAlarmByOldRemind (const DSchedule::Ptr &schedule, const QString &remind)
96103{
104+ qCDebug (CommonLogger) << " DDE_Calendar::setAlarmByOldRemind, remind:" << remind;
97105 // 提醒规则
98106 QStringList strList = remind.split (" ;" , Qt::SkipEmptyParts);
99107
@@ -106,6 +114,7 @@ void DDE_Calendar::setAlarmByOldRemind(const DSchedule::Ptr &schedule, const QSt
106114 alarm->setDisplayAlarm (schedule->summary ());
107115
108116 if (schedule->allDay ()) {
117+ qCDebug (CommonLogger) << " Setting alarm for all-day event" ;
109118 // 提前多少秒
110119 int offset = 0 ;
111120 if (strList.size () > 1 ) {
@@ -115,6 +124,7 @@ void DDE_Calendar::setAlarmByOldRemind(const DSchedule::Ptr &schedule, const QSt
115124 KCalendarCore::Duration duration (-(24 * 60 * 60 * remindNum - offset));
116125 alarm->setStartOffset (duration);
117126 } else {
127+ qCDebug (CommonLogger) << " Setting alarm for timed event" ;
118128 KCalendarCore::Duration duration (-(60 * remindNum));
119129 alarm->setStartOffset (duration);
120130 }
@@ -124,6 +134,7 @@ void DDE_Calendar::setAlarmByOldRemind(const DSchedule::Ptr &schedule, const QSt
124134
125135QString DDE_Calendar::getOldRemindByAlarm (const DSchedule::AlarmType &alarmType)
126136{
137+ qCDebug (CommonLogger) << " DDE_Calendar::getOldRemindByAlarm, alarmType:" << alarmType;
127138 QString _resultStr {" " };
128139 switch (alarmType) {
129140 case DSchedule::Alarm_Begin:
@@ -171,10 +182,12 @@ QString DDE_Calendar::getOldRemindByAlarm(const DSchedule::AlarmType &alarmType)
171182
172183DSchedule::Ptr DDE_Calendar::getScheduleByExported (const QString &scheduleStr)
173184{
185+ qCDebug (CommonLogger) << " DDE_Calendar::getScheduleByExported" ;
174186 QJsonParseError json_error;
175187 QJsonDocument jsonDoc (QJsonDocument::fromJson (scheduleStr.toLocal8Bit (), &json_error));
176188
177189 if (json_error.error != QJsonParseError::NoError) {
190+ qCWarning (CommonLogger) << " JSON parse error:" << json_error.errorString ();
178191 return nullptr ;
179192 }
180193 QJsonObject rootObj = jsonDoc.object ();
@@ -225,6 +238,7 @@ DSchedule::Ptr DDE_Calendar::getScheduleByExported(const QString &scheduleStr)
225238
226239void DDE_Calendar::setRRuleByOldRRule (const DSchedule::Ptr &schedule, const QString &rrule)
227240{
241+ qCDebug (CommonLogger) << " DDE_Calendar::setRRuleByOldRRule, rrule:" << rrule;
228242 // 重复规则
229243 KCalendarCore::Recurrence *recurrence = schedule->recurrence ();
230244 KCalendarCore::ICalFormat ical;
@@ -237,6 +251,7 @@ void DDE_Calendar::setRRuleByOldRRule(const DSchedule::Ptr &schedule, const QStr
237251
238252void DDE_Calendar::setExDate (const DSchedule::Ptr &schedule, const QJsonArray &ignore)
239253{
254+ qCDebug (CommonLogger) << " DDE_Calendar::setExDate, ignore count:" << ignore.size ();
240255 KCalendarCore::Recurrence *recurrence = schedule->recurrence ();
241256
242257 foreach (auto ignoreTime, ignore) {
0 commit comments