korganizer Library API Documentation

kohelper.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2005 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
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(); //Default invalid color
00040   //FIXME: dynamic_cast are dirty, Better We implements interface to get the color
00041   // from the calendar
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     {
00049       QString identifier = resourceCalendar->identifier();
00050       resourceColor = *KOPrefs::instance()->resourceColor( identifier );
00051 
00052       if ( !resourceCalendar->subresources().isEmpty() ) {
00053        identifier = resourceCalendar->subresourceIdentifier( incidence );
00054        if ( identifier.isEmpty() )
00055         identifier = resourceCalendar->identifier();
00056         QColor subrescolor( *KOPrefs::instance()->resourceColor( identifier ) );
00057         if ( subrescolor.isValid() )
00058          resourceColor = subrescolor;
00059       }
00060     }
00061 //   } else {
00062 //     kdDebug(5850) << "resourceColor: Calendar is not a CalendarResources" <<endl;
00063   }
00064   return resourceColor;
00065 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 23 18:22:14 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003