korganizer
kohelper.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <qcolor.h>
00026
00027 #include <kdebug.h>
00028
00029 #include <libkcal/incidence.h>
00030 #include <libkcal/calendar.h>
00031 #include <libkcal/calendarresources.h>
00032 #include <libkcal/resourcecalendar.h>
00033
00034 #include "koprefs.h"
00035 #include "kohelper.h"
00036
00037 QColor KOHelper::resourceColor( KCal::Calendar*calendar, KCal::Incidence*incidence )
00038 {
00039 QColor resourceColor = QColor();
00040
00041
00042 KCal::CalendarResources *calendarResource = dynamic_cast<KCal::CalendarResources*>( calendar );
00043
00044 if ( calendarResource ) {
00045 KCal::ResourceCalendar *resourceCalendar = calendarResource->resource( incidence );
00046
00047 if( resourceCalendar ) {
00048 QString identifier = resourceCalendar->identifier();
00049 resourceColor = *KOPrefs::instance()->resourceColor( identifier );
00050
00051 if ( !resourceCalendar->subresources().isEmpty() ) {
00052 identifier = resourceCalendar->subresourceIdentifier( incidence );
00053 if ( identifier.isEmpty() )
00054 identifier = resourceCalendar->identifier();
00055 QColor subrescolor( *KOPrefs::instance()->resourceColor( identifier ) );
00056 if ( subrescolor.isValid() )
00057 resourceColor = subrescolor;
00058 }
00059 }
00060
00061
00062 }
00063 return resourceColor;
00064 }
|