QColor KOHelper::resourceColor( KCal::Calendar *calendar,
                                KCal::Incidence *incidence )
{
  QColor resourceColor = QColor(); //Default invalid color
  //FIXME: dynamic_cast are dirty, Better We implements interface to get
  // the color from the calendar
  KCal::CalendarResources *calendarResource =
    dynamic_cast<KCal::CalendarResources*>( calendar );

  if ( calendarResource ) {
    KCal::ResourceCalendar *resourceCalendar =
      calendarResource->resource( incidence );

    if ( resourceCalendar ) {
      QString identifier = resourceCalendar->identifier();
      resourceColor = KOPrefs::instance()->resourceColor( identifier );

      if ( !resourceCalendar->subresources().isEmpty() ) {
        identifier = resourceCalendar->subresourceIdentifier( incidence );
        if ( identifier.isEmpty() ) {
          identifier = resourceCalendar->identifier();
        }
        QColor subrescolor( KOPrefs::instance()->resourceColor( identifier ) );
        if ( subrescolor.isValid() ) {
          resourceColor = subrescolor;
        }
      }
    }
  }
  return resourceColor;
}
Beispiel #2
0
QColor KOHelper::resourceColor( KCal::Calendar*calendar, KCal::Incidence*incidence )
{
  QColor resourceColor = QColor(); //Default invalid color
  //FIXME: dynamic_cast are dirty, Better We implements interface to get the color
  // from the calendar
  KCal::CalendarResources *calendarResource = dynamic_cast<KCal::CalendarResources*>( calendar );

  if ( calendarResource ) {
    KCal::ResourceCalendar *resourceCalendar = calendarResource->resource( incidence );

    if( resourceCalendar ) {
      QString identifier = resourceCalendar->identifier();
      resourceColor = *KOPrefs::instance()->resourceColor( identifier );

      if ( !resourceCalendar->subresources().isEmpty() ) {
        identifier = resourceCalendar->subresourceIdentifier( incidence );
       if ( identifier.isEmpty() )
         identifier = resourceCalendar->identifier();
       QColor subrescolor( *KOPrefs::instance()->resourceColor( identifier ) );
       if ( subrescolor.isValid() )
         resourceColor = subrescolor;
      }
    }
//   } else {
//     kdDebug(5850) << "resourceColor: Calendar is not a CalendarResources" <<endl;
  }
  return resourceColor;
}
Beispiel #3
0
void ResourceView::assignColor()
{
    ResourceItem *item = currentItem();
    if(!item)
        return;
    // A color without initialized is a color invalid
    QColor myColor;
    KCal::ResourceCalendar *cal = item->resource();

    QString identifier = cal->identifier();
    if(item->isSubresource())
        identifier = item->resourceIdentifier();

    QColor defaultColor = *KOPrefs::instance()->resourceColor(identifier);

    int result = KColorDialog::getColor(myColor, defaultColor);

    if(result == KColorDialog::Accepted)
    {
        KOPrefs::instance()->setResourceColor(identifier, myColor);
        item->setResourceColor(myColor);
        item->update();
        emitResourcesChanged();
    }
}
Beispiel #4
0
void ResourceView::disableColor()
{
  ResourceItem *item = currentItem();
  if ( !item )
    return;
  QColor colorInvalid;
  KCal::ResourceCalendar *cal = item->resource();
  QString identifier = cal->identifier();
  if ( item->isSubresource() )
    identifier = item->resourceIdentifier();
  KOPrefs::instance()->setResourceColor( identifier, colorInvalid );
  item->setResourceColor( colorInvalid );
  item->update();
  emitResourcesChanged();
}