/*
  Copyright (c) 2008 Bruno Virlet <bruno.virlet@gmail.com>

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along
  with this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

  As a special exception, permission is given to link this program
  with any edition of Qt, and distribute the resulting executable,
  without including the source code for Qt in the source distribution.
*/

#include "monthitem.h"
#include "helper.h"
#include "monthgraphicsitems.h"
#include "monthscene.h"
#include "monthview.h"
#include "prefs.h"
#include "prefs_base.h" // Ugly, but needed for the Enums

#include <calendarsupport/calendar.h>
#include <calendarsupport/incidencechanger.h>
#include <calendarsupport/kcalprefs.h>
#include <calendarsupport/utils.h>

#include <KCalUtils/IncidenceFormatter>

#include <KMessageBox>

using namespace EventViews;
using namespace KCalCore;

MonthItem::MonthItem( MonthScene *monthScene )
  : mMonthScene( monthScene ),
    mSelected( false ),
    mMoving( false ),
    mResizing( false )
{
}

MonthItem::~MonthItem()
{
  deleteAll();
}

void MonthItem::deleteAll()
{
  qDeleteAll( mMonthGraphicsItemList );
  mMonthGraphicsItemList.clear();
}

QWidget *MonthItem::parentWidget() const
{
  return mMonthScene ? mMonthScene->monthView() : 0;
}

void MonthItem::updateMonthGraphicsItems()
{
  // Remove all items
  qDeleteAll( mMonthGraphicsItemList );
  mMonthGraphicsItemList.clear();

  const QDate monthStartDate = startDate();
  const QDate monthEndDate = endDate();

  // For each row of the month view, create an item to build the whole
  // MonthItem's MonthGraphicsItems.
  for ( QDate d = mMonthScene->mMonthView->actualStartDateTime().date();
        d < mMonthScene->mMonthView->actualEndDateTime().date(); d = d.addDays( 7 ) ) {
    QDate end = d.addDays( 6 );

    int span;
    QDate start;
    if ( monthStartDate <= d && monthEndDate >= end ) { // MonthItem takes the whole line
      span = 6;
      start = d;
    } else if ( monthStartDate >= d && monthEndDate <= end ) { // starts and ends on this line
      start = monthStartDate;
      span = daySpan();
    } else if ( d <= monthEndDate && monthEndDate <= end ) { // MonthItem ends on this line
      span = mMonthScene->getLeftSpan( monthEndDate );
      start = d;
    } else if ( d <= monthStartDate && monthStartDate <= end ) { // MonthItem begins on this line
      span = mMonthScene->getRightSpan( monthStartDate );
      start = monthStartDate;
    } else { // MonthItem is not on the line
      continue;
    }

    // A new item needs to be created
    MonthGraphicsItem *newItem = new MonthGraphicsItem( this );
    mMonthGraphicsItemList << newItem;
    newItem->setStartDate( start );
    newItem->setDaySpan( span );
  }

  if ( isMoving() || isResizing() ) {
    setZValue( 100 );
  } else {
    setZValue( 0 );
  }
}

void MonthItem::beginResize()
{
  mOverrideDaySpan = daySpan();
  mOverrideStartDate = startDate();
  mResizing = true;
  setZValue( 100 );
}

void MonthItem::endResize()
{
  setZValue( 0 );
  mResizing = false; // startDate() and daySpan() return real values again

  if ( mOverrideStartDate != startDate() || mOverrideDaySpan != daySpan() ) {
    finalizeResize( mOverrideStartDate, mOverrideStartDate.addDays( mOverrideDaySpan ) );
  }
}

void MonthItem::beginMove()
{
  mOverrideDaySpan = daySpan();
  mOverrideStartDate = startDate();
  mMoving = true;
  setZValue( 100 );
}

void MonthItem::endMove()
{
  setZValue( 0 );
  mMoving = false; // startDate() and daySpan() return real values again

  if ( mOverrideStartDate != startDate() ) {
    finalizeMove( mOverrideStartDate );
  }
}

bool MonthItem::resizeBy( int offsetToPreviousDate )
{
  bool ret = false;
  if ( mMonthScene->resizeType() == MonthScene::ResizeLeft ) {
    if ( mOverrideDaySpan - offsetToPreviousDate >= 0 ) {
      mOverrideStartDate = mOverrideStartDate.addDays( offsetToPreviousDate );
      mOverrideDaySpan = mOverrideDaySpan - offsetToPreviousDate;
      ret = true;
    }
  } else if ( mMonthScene->resizeType() == MonthScene::ResizeRight ) {
    if ( mOverrideDaySpan + offsetToPreviousDate >= 0 ) {
      mOverrideDaySpan = mOverrideDaySpan + offsetToPreviousDate;
      ret = true;
    }
  }

  if ( ret ) {
    updateMonthGraphicsItems();
  }
  return ret;
}

void MonthItem::moveBy( int offsetToPreviousDate )
{
  mOverrideStartDate = mOverrideStartDate.addDays( offsetToPreviousDate );
  updateMonthGraphicsItems();
}

void MonthItem::updateGeometry()
{
  foreach ( MonthGraphicsItem *item, mMonthGraphicsItemList ) {
      item->updateGeometry();
  }
}

void MonthItem::setZValue( qreal z )
{
  foreach ( MonthGraphicsItem *item, mMonthGraphicsItemList ) {
    item->setZValue( z );
  }
}

QDate MonthItem::startDate() const
{
  if ( isMoving() || isResizing() ) {
    return mOverrideStartDate;
  }

  return realStartDate();
}

QDate MonthItem::endDate() const
{
  if ( isMoving() || isResizing() ) {
    return mOverrideStartDate.addDays( mOverrideDaySpan );
  }

  return realEndDate();
}

int MonthItem::daySpan() const
{
  if ( isMoving() || isResizing() ) {
    return mOverrideDaySpan;
  }

  QDateTime start( startDate() );
  QDateTime end( endDate() );

  if ( start.isValid() && end.isValid() ) {
    return start.daysTo( end );
  }

  return 0;
}

bool MonthItem::greaterThan( const MonthItem *e1, const MonthItem *e2 )
{
  const QDate leftStartDate = e1->startDate();
  const QDate rightStartDate = e2->startDate();

  if ( !leftStartDate.isValid() || !rightStartDate.isValid() ) {
    return false;
  }

  if ( leftStartDate == rightStartDate ) {
    const int leftDaySpan = e1->daySpan();
    const int rightDaySpan = e2->daySpan();
    if ( leftDaySpan == rightDaySpan ) {
      if ( e1->allDay() && !e2->allDay() ) {
        return true;
      }
      if ( !e1->allDay() && e2->allDay() ) {
        return false;
      }
      return e1->greaterThanFallback( e2 );
    } else {
      return leftDaySpan >  rightDaySpan;
    }
  }

  return leftStartDate < rightStartDate;
}

bool MonthItem::greaterThanFallback( const MonthItem *other ) const
{
  // Yeah, pointer comparison if there is nothing else to compare...
  return this < other;
}

void MonthItem::updatePosition()
{
  if ( !startDate().isValid() || !endDate().isValid() ) {
    return;
  }

  int firstFreeSpace = 0;
  for ( QDate d = startDate(); d <= endDate(); d = d.addDays( 1 ) ) {
    MonthCell *cell = mMonthScene->mMonthCellMap.value( d );
    if ( !cell ) {
      continue; // cell can be null if the item begins outside the month
    }
    int firstFreeSpaceTmp = cell->firstFreeSpace();
    if ( firstFreeSpaceTmp > firstFreeSpace ) {
      firstFreeSpace = firstFreeSpaceTmp;
    }
  }

  for ( QDate d = startDate(); d <= endDate(); d = d.addDays( 1 ) ) {
    MonthCell *cell = mMonthScene->mMonthCellMap.value( d );
    if ( !cell ) {
      continue;
    }
    cell->addMonthItem( this, firstFreeSpace );
  }

  mPosition = firstFreeSpace;
}

QList<MonthGraphicsItem *> EventViews::MonthItem::monthGraphicsItems() const
{
  return mMonthGraphicsItemList;
}

//-----------------------------------------------------------------
// INCIDENCEMONTHITEM
IncidenceMonthItem::IncidenceMonthItem( MonthScene *monthScene,
                                        const Akonadi::Item &aitem,
                                        const QDate &recurStartDate )
  : MonthItem( monthScene ), mIncidence( aitem.payload<Incidence::Ptr>() ),
    mAkonadiItemId( aitem.id() )
{
  mIsEvent = CalendarSupport::hasEvent( aitem );
  mIsJournal = CalendarSupport::hasJournal( aitem );
  mIsTodo = CalendarSupport::hasTodo( aitem );

  KCalCore::Incidence::Ptr inc = mIncidence;
  if ( inc->customProperty( "KABC", "BIRTHDAY" ) == "YES" ||
       inc->customProperty( "KABC", "ANNIVERSARY" ) == "YES" ) {
    const int years = EventViews::yearDiff( inc->dtStart().date(), recurStartDate );
    if ( years > 0 ) {
      inc = KCalCore::Incidence::Ptr( inc->clone() );
      inc->setReadOnly( false );
      inc->setDescription( i18np( "%2 1 year", "%2 %1 years", years, i18n( "Age:" ) ) );
      inc->setReadOnly( true );
      mIncidence = inc;
    }
  }

  connect( monthScene, SIGNAL(incidenceSelected(Akonadi::Item,QDate)),
           this, SLOT(updateSelection(Akonadi::Item,QDate)) );

  // first set to 0, because it's used in startDate()
  mRecurDayOffset = 0;
  if ( startDate().isValid() && recurStartDate.isValid() ) {
    mRecurDayOffset = startDate().daysTo( recurStartDate );
  }
}

IncidenceMonthItem::~IncidenceMonthItem()
{
}

bool IncidenceMonthItem::greaterThanFallback( const MonthItem *other ) const
{

  const IncidenceMonthItem *o = qobject_cast<const IncidenceMonthItem *>( other );
  if ( !o ) {
    return MonthItem::greaterThanFallback( other );
  }

  if ( allDay() != o->allDay() ) {
    return allDay();
  }
  const KCalCore::Incidence::Ptr otherIncidence = o->mIncidence;

  if ( mIncidence->dtStart().time() != otherIncidence->dtStart().time() ) {
    return mIncidence->dtStart().time() < otherIncidence->dtStart().time();
  }

  // as a last resort, compare uids
  return mIncidence->uid() < otherIncidence->uid();
}

QDate IncidenceMonthItem::realStartDate() const
{
  if ( !mIncidence ) {
    return QDate();
  }

  const KDateTime dt = mIncidence->dateTime( Incidence::RoleDisplayStart );
  const QDate start = dt.isDateOnly() ?
                        dt.date() :
                        dt.toTimeSpec( CalendarSupport::KCalPrefs::instance()->timeSpec() ).date();

  return start.addDays( mRecurDayOffset );
}
QDate IncidenceMonthItem::realEndDate() const
{
  if ( !mIncidence ) {
    return QDate();
  }

  const KDateTime dt = mIncidence->dateTime( KCalCore::Incidence::RoleDisplayEnd );
  const QDate end = dt.isDateOnly() ?
                      dt.date() :
                    dt.toTimeSpec( CalendarSupport::KCalPrefs::instance()->timeSpec() ).date();

  return end.addDays( mRecurDayOffset );
}
bool IncidenceMonthItem::allDay() const
{
  return mIncidence->allDay();
}

bool IncidenceMonthItem::isMoveable() const
{
  return monthScene()->mMonthView->calendar()->hasChangeRights( akonadiItem() );
}
bool IncidenceMonthItem::isResizable() const
{
  return mIsEvent && monthScene()->mMonthView->calendar()->hasChangeRights( akonadiItem() );
}

void IncidenceMonthItem::finalizeMove( const QDate &newStartDate )
{
  Q_ASSERT( isMoveable() );

  if ( startDate().isValid() && newStartDate.isValid() ) {
    updateDates( startDate().daysTo( newStartDate ),
                 startDate().daysTo( newStartDate ) );
  }
}
void IncidenceMonthItem::finalizeResize( const QDate &newStartDate,
                                         const QDate &newEndDate )
{
  Q_ASSERT( isResizable() );

  if ( startDate().isValid() && endDate().isValid() &&
       newStartDate.isValid() && newEndDate.isValid() ) {
    updateDates( startDate().daysTo( newStartDate ),
                 endDate().daysTo( newEndDate ) );
  }
}

void IncidenceMonthItem::updateDates( int startOffset, int endOffset )
{
  if ( startOffset == 0 && endOffset == 0 ) {
    return;
  }

  CalendarSupport::IncidenceChanger *changer = monthScene()->incidenceChanger();
  if ( !changer ) {
    KMessageBox::sorry( parentWidget(), i18n( "Unable to save %1 \"%2\".",
                        i18n( mIncidence->typeStr() ), mIncidence->summary() ) );
    kDebug() << "No incidence changer is set";
    return;
  }

  bool modify = true;

  Akonadi::Item item = akonadiItem();
  item.setPayload( mIncidence );
  if ( mIncidence->recurs() ) {
    const int res = monthScene()->mMonthView->showMoveRecurDialog( mIncidence, startDate() );
    switch ( res ) {
      case KMessageBox::Ok: // All occurrences
        modify = true;
        break;
      case KMessageBox::Yes: // Just this occurrence
      {
        modify = true;
        KCalCore::Incidence::Ptr oldIncSaved( mIncidence->clone() );
        KCalCore::Incidence::Ptr newInc(
          monthScene()->mMonthView->calendar()->dissociateOccurrence(
            item, startDate(), CalendarSupport::KCalPrefs::instance()->timeSpec() ) );
        if ( newInc ) {
           //TODO check return values
          changer->changeIncidence(
            oldIncSaved, item,
            CalendarSupport::IncidenceChanger::RECURRENCE_MODIFIED_ONE_ONLY, 0 );

          changer->addIncidence( newInc, item.parentCollection(), parentWidget() );
        } else {
          KMessageBox::sorry(
            parentWidget(),
            i18n( "Unable to add the exception item to the calendar. "
                  "No change will be done." ),
            i18n( "Error Occurred" ) );
          modify = false;
        }
        break;
      }
      case KMessageBox::No: // All future occurrences
      {
        modify = true;
        KCalCore::Incidence::Ptr oldIncSaved( mIncidence->clone() );
        KCalCore::Incidence::Ptr newInc(
          monthScene()->mMonthView->calendar()->dissociateOccurrence(
            item, startDate(), CalendarSupport::KCalPrefs::instance()->timeSpec(), false ) );
        if ( newInc ) {
           //TODO check return values
          changer->changeIncidence(
            oldIncSaved, item,
            CalendarSupport::IncidenceChanger::RECURRENCE_MODIFIED_ALL_FUTURE, 0 );

          changer->addIncidence( newInc, item.parentCollection(), parentWidget() );
        } else {
          KMessageBox::sorry(
            parentWidget(),
            i18n( "Unable to add the future items to the calendar. "
                  "No change will be done." ),
            i18n( "Error Occurred" ) );
          modify = false;
        }
        break;
      }
      default:
        modify = false;
    }
  }

  if ( modify ) {
    KCalCore::Incidence::Ptr oldInc( mIncidence->clone() );

    if ( !mIsTodo ) {
      mIncidence->setDtStart( mIncidence->dtStart().addDays( startOffset ) );

      if ( mIsEvent ) {
        KCalCore::Event::Ptr event = mIncidence.staticCast<Event>();
        event->setDtEnd( event->dtEnd().addDays( endOffset ) );
      }
    } else {
      KCalCore::Todo::Ptr todo = mIncidence.staticCast<Todo>();
      todo->setDtDue( todo->dtDue().addDays( startOffset ) );
    }

    changer->changeIncidence( oldInc, item,
                              CalendarSupport::IncidenceChanger::DATE_MODIFIED, 0 );
  }

}

void IncidenceMonthItem::updateSelection( const Akonadi::Item &incidence, const QDate &date )
{
  Q_UNUSED( date );
  setSelected( incidence == akonadiItem() );
}

QString IncidenceMonthItem::text( bool end ) const
{
  QString ret = mIncidence->summary();
  if ( !allDay() && monthScene()->monthView()->preferences()->showTimeInMonthView() ) {
    // Prepend the time str to the text
    QString timeStr;
    if ( mIsTodo ) {
      KCalCore::Todo::Ptr todo = mIncidence.staticCast<Todo>();
      timeStr = KCalUtils::IncidenceFormatter::timeToString(
        todo->dtDue(), true, CalendarSupport::KCalPrefs::instance()->timeSpec() );
    } else {
      if ( !end ) {
        timeStr = KCalUtils::IncidenceFormatter::timeToString(
          mIncidence->dtStart(), true, CalendarSupport::KCalPrefs::instance()->timeSpec() );
      } else {
        KCalCore::Event::Ptr event = mIncidence.staticCast<Event>();
        timeStr = KCalUtils::IncidenceFormatter::timeToString(
          event->dtEnd(), true, CalendarSupport::KCalPrefs::instance()->timeSpec() );
      }
    }
    if ( !timeStr.isEmpty() ) {
      if ( !end ) {
        ret = timeStr + ' ' + ret;
      } else {
        ret = ret + ' ' + timeStr;
      }
    }
  }

  return ret;
}

QString IncidenceMonthItem::toolTipText( const QDate &date ) const
{
  return KCalUtils::IncidenceFormatter::toolTipStr(
    CalendarSupport::displayName( akonadiItem().parentCollection() ),
    mIncidence,
    date, true, CalendarSupport::KCalPrefs::instance()->timeSpec() );
}

QList<QPixmap *> IncidenceMonthItem::icons() const
{
  QList<QPixmap *> ret;

  if ( !mIncidence ) {
    return ret;
  }

  bool specialEvent = false;
  Akonadi::Item item = akonadiItem();

  const QSet<EventView::ItemIcon> icons =
    monthScene()->monthView()->preferences()->monthViewIcons();

  if ( icons.contains( EventViews::EventView::CalendarCustomIcon ) ) {
    const QString iconName = EventView::iconForItem( item );
    if ( !iconName.isEmpty() && iconName != "view-calendar" && iconName != "office-calendar" ) {
      ret << new QPixmap( cachedSmallIcon( iconName ) );
    }
  }

  if ( mIsEvent ) {
    if ( mIncidence->customProperty( "KABC", "ANNIVERSARY" ) == "YES" ) {
      specialEvent = true;
      ret << monthScene()->anniversaryPixmap();
    } else if ( mIncidence->customProperty( "KABC", "BIRTHDAY" ) == "YES" ) {
      specialEvent = true;
       // Disabling birthday icon because it's the birthday agent's icon
       // and we allow to display the agent's icon now.
      //ret << monthScene()->birthdayPixmap();
    }

    // smartins: Disabling the event Pixmap because:
    // 1. Save precious space so we can read the event's title better.
    // 2. We don't need a pixmap to tell us an item is an event we
    //    only need one to tell us it's not, as month view was designed for events.
    // 3. If only to-dos and journals have a pixmap they will be distinguished
    //    from event's much easier.

    // ret << monthScene()->eventPixmap();

  } else if ( ( mIsTodo || mIsJournal ) && icons.contains( mIsTodo ?
                                                             EventView::TaskIcon :
                                                             EventView::JournalIcon ) ) {
    KDateTime occurrenceDateTime = mIncidence->dateTime( Incidence::RoleRecurrenceStart );
    occurrenceDateTime.setDate( realStartDate() );
    ret << new QPixmap( cachedSmallIcon( mIncidence->iconName( occurrenceDateTime ) ) );
  }

  if ( icons.contains( EventView::ReadOnlyIcon ) &&
       !monthScene()->mMonthView->calendar()->hasChangeRights( item ) &&
       !specialEvent ) {
    ret << monthScene()->readonlyPixmap();
  }

  /* sorry, this looks too cluttered. disable until we can
     make something prettier; no idea at this time -- allen */
  if ( icons.contains( EventView::ReminderIcon ) &&
       mIncidence->hasEnabledAlarms() && !specialEvent ) {
    ret << monthScene()->alarmPixmap();
  }
  if ( icons.contains( EventView::RecurringIcon ) &&
       mIncidence->recurs() && !specialEvent ) {
    ret << monthScene()->recurPixmap();
  }
  //TODO: check what to do with Reply

  return ret;
}

QColor IncidenceMonthItem::catColor() const
{
  Q_ASSERT( mIncidence );
  const QStringList categories = mIncidence->categories();
  QString cat;
  if ( !categories.isEmpty() ) {
    cat = categories.first();
  }

  return cat.isEmpty() ? CalendarSupport::KCalPrefs::instance()->unsetCategoryColor() :
                         CalendarSupport::KCalPrefs::instance()->categoryColor( cat );
}

QColor IncidenceMonthItem::bgColor() const
{
  QColor bgColor = QColor(); // Default invalid color;

  PrefsPtr prefs = monthScene()->monthView()->preferences();
  if ( mIsTodo && !prefs->todosUseCategoryColors() ) {
    Todo::Ptr todo = CalendarSupport::todo( akonadiItem() );
    Q_ASSERT( todo );
    const QDate dueDate =
      todo->dtDue().toTimeSpec( CalendarSupport::KCalPrefs::instance()->timeSpec() ).date();
    const QDate today =
      KDateTime::currentDateTime( CalendarSupport::KCalPrefs::instance()->timeSpec() ).date();
    if ( todo->isOverdue() && today >= startDate() ) {
      bgColor = prefs->todoOverdueColor();
    } else if ( dueDate == today && dueDate == startDate() ) {
      bgColor = prefs->todoDueTodayColor();
    }
  }

  if ( !bgColor.isValid() ) {
    if ( prefs->monthViewColors() == PrefsBase::MonthItemResourceOnly ||
         prefs->monthViewColors() == PrefsBase::MonthItemResourceInsideCategoryOutside ) {

      const QString id = QString::number( akonadiItem().storageCollectionId() );
      if ( id.isEmpty() ) {
        // item got removed from calendar, give up.
        return QColor();
      }

      bgColor = monthScene()->monthView()->preferences()->resourceColor( id );
    } else {
      bgColor = catColor();
    }
  }

  if ( !bgColor.isValid() ) {
    bgColor = Qt::white;
  }

  return bgColor;
}

QColor IncidenceMonthItem::frameColor() const
{
  QColor frameColor;

  PrefsPtr prefs = monthScene()->monthView()->preferences();
  if ( prefs->monthViewColors() == PrefsBase::MonthItemResourceOnly ||
       prefs->monthViewColors() == PrefsBase::MonthItemCategoryInsideResourceOutside ||
       ( mIncidence->categories().isEmpty() && prefs->monthViewColors() ==
         PrefsBase::MonthItemResourceInsideCategoryOutside ) ) {
    Q_ASSERT( mIncidence );
    const QString id = QString::number( akonadiItem().storageCollectionId() );
    if ( !id.isEmpty() ) {
      frameColor = prefs->resourceColor( id );
    }
  } else {
    frameColor = catColor();
  }

  return EventView::itemFrameColor( frameColor, selected() );
}

Akonadi::Item IncidenceMonthItem::akonadiItem() const
{
  if ( mIncidence ) {
    return monthScene()->mMonthView->calendar()->itemForIncidenceUid( mIncidence->uid() );
  } else {
    return Akonadi::Item();
  }
}

Akonadi::Item::Id IncidenceMonthItem::akonadiItemId() const
{
  return mAkonadiItemId;
}
//-----------------------------------------------------------------
// HOLIDAYMONTHITEM
HolidayMonthItem::HolidayMonthItem( MonthScene *monthScene, const QDate &date,
                                    const QString &name )
  : MonthItem( monthScene ), mDate( date ), mName( name )
{
}

HolidayMonthItem::~HolidayMonthItem()
{
}

bool HolidayMonthItem::greaterThanFallback( const MonthItem *other ) const
{
  const HolidayMonthItem *o = qobject_cast<const HolidayMonthItem *>( other );
  if ( o ) {
    return MonthItem::greaterThanFallback( other );
  }

  // always put holidays on top
  return false;
}

void HolidayMonthItem::finalizeMove( const QDate &newStartDate )
{
  Q_UNUSED( newStartDate );
  Q_ASSERT( false );
}
void HolidayMonthItem::finalizeResize( const QDate &newStartDate,
                                       const QDate &newEndDate )
{
  Q_UNUSED( newStartDate );
  Q_UNUSED( newEndDate );
  Q_ASSERT( false );
}

QList<QPixmap *> HolidayMonthItem::icons() const
{
  QList<QPixmap *> ret;
  ret << monthScene()->holidayPixmap();

  return ret;
}

QColor HolidayMonthItem::bgColor() const
{
  // FIXME: Currently, only this value is settable in the options.
  // There is a monthHolidaysBackgroundColor() option too. Maybe it would be
  // wise to merge those two.
  return monthScene()->monthView()->preferences()->agendaHolidaysBackgroundColor();
}

QColor HolidayMonthItem::frameColor() const
{
  return Qt::black;
}
