kpilot
kcalRecord.ccGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "options.h"
00031
00032 #include <libkcal/calendar.h>
00033 #include <libkcal/calendarlocal.h>
00034 #include <libkcal/recurrence.h>
00035 #include <libkcal/vcalformat.h>
00036
00037 #include "pilot.h"
00038 #include "pilotRecord.h"
00039 #include "kcalRecord.h"
00040
00041 void KCalSync::setCategory(PilotRecordBase *de,
00042 const KCal::Incidence *e,
00043 const CategoryAppInfo &info)
00044 {
00045 FUNCTIONSETUP;
00046
00047 if (!de || !e)
00048 {
00049 return;
00050 }
00051
00052 QString deCategory;
00053 QStringList eventCategories = e->categories();
00054 if (eventCategories.size() < 1)
00055 {
00056
00057 de->setCategory(Pilot::Unfiled);
00058 return;
00059 }
00060
00061
00062
00063 if (de->category() != Pilot::Unfiled)
00064 {
00065 deCategory = Pilot::categoryName(&info,de->category());
00066 if (eventCategories.contains(deCategory))
00067 {
00068
00069 return;
00070 }
00071 }
00072
00073 QStringList availableHandheldCategories = Pilot::categoryNames(&info);
00074
00075
00076
00077
00078
00079
00080 for ( QStringList::ConstIterator it = eventCategories.begin();
00081 it != eventCategories.end(); ++it )
00082 {
00083
00084 if ( (*it).isEmpty() )
00085 {
00086 continue;
00087 }
00088
00089 if (availableHandheldCategories.contains(*it))
00090 {
00091
00092
00093 int c = Pilot::findCategory(&info,*it,false);
00094 Q_ASSERT( Pilot::validCategory(c) );
00095 de->setCategory(c);
00096 return;
00097 }
00098 }
00099
00100 de->setCategory(Pilot::Unfiled);
00101 }
00102
00103 void KCalSync::setCategory(KCal::Incidence *e,
00104 const PilotRecordBase *de,
00105 const CategoryAppInfo &info)
00106 {
00107 FUNCTIONSETUP;
00108
00109 if (!e || !de)
00110 {
00111 DEBUGKPILOT << fname << ": error. unable to set kcal category. e: ["
00112 << (void *)e << "], de: [" << (void *)de << "]" << endl;
00113 return;
00114 }
00115
00116 QStringList cats=e->categories();
00117 int cat = de->category();
00118 QString newcat = Pilot::categoryName(&info,cat);
00119
00120 DEBUGKPILOT << fname << ": palm category id: [" << cat <<
00121 "], label: [" << newcat << "]" << endl;
00122
00123 if ( Pilot::validCategory(cat) && (cat != Pilot::Unfiled))
00124 {
00125 if (!cats.contains(newcat))
00126 {
00127
00128
00129
00130
00131
00132 if (cats.count() <=1)
00133 {
00134 cats.clear();
00135 }
00136
00137 cats.append( newcat );
00138 e->setCategories(cats);
00139 }
00140 }
00141
00142 DEBUGKPILOT << fname << ": kcal categories now: [" << cats.join(",") << "]" << endl;
00143 }
|