diff --git a/incidenceeditor-ng/visualfreebusywidget.cpp b/incidenceeditor-ng/visualfreebusywidget.cpp index a127fc7900..73f55d31c7 100644 --- a/incidenceeditor-ng/visualfreebusywidget.cpp +++ b/incidenceeditor-ng/visualfreebusywidget.cpp @@ -1,142 +1,142 @@ /* Copyright (C) 2010 Casey Link Copyright (c) 2009-2010 Klarälvdalens Datakonsult AB, a KDAB Group company This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "visualfreebusywidget.h" #include #include #include #include #include #include #include #include using namespace IncidenceEditorNG; class FreebusyViewCalendar : public EventViews::ViewCalendar { public: virtual ~FreebusyViewCalendar() {}; virtual bool isValid(const KCalCore::Incidence::Ptr &incidence) const { return isValid(incidence->uid()); } virtual bool isValid(const QString &incidenceIdentifier) const { kDebug() << incidenceIdentifier; return incidenceIdentifier.startsWith("fb-"); } virtual QString displayName(const KCalCore::Incidence::Ptr &incidence) const { Q_UNUSED(incidence); return QLatin1String("Freebusy"); } virtual QColor resourceColor(const KCalCore::Incidence::Ptr &incidence) const { bool ok = false; int status = incidence->customProperty("FREEBUSY", "STATUS").toInt(&ok); if (!ok) { return QColor("#555"); } switch (status) { case KCalCore::FreeBusyPeriod::Busy: return QColor("#f00"); case KCalCore::FreeBusyPeriod::BusyTentative: case KCalCore::FreeBusyPeriod::BusyUnavailable: return QColor("#f70"); case KCalCore::FreeBusyPeriod::Free: return QColor("#0f0"); default: return QColor("#555"); } } virtual QString uid(const KCalCore::Incidence::Ptr &incidence) const { return incidence->uid(); } virtual QString iconForIncidence(const KCalCore::Incidence::Ptr &incidence) const { return QString(); } virtual KCalCore::Calendar::Ptr getCalendar() const { return mCalendar; } KCalCore::Calendar::Ptr mCalendar; }; VisualFreeBusyWidget::VisualFreeBusyWidget( FreeBusyItemModel *model, int spacing, QWidget *parent ) : QWidget( parent ), - mAgendaView(new EventViews::AgendaView(EventViews::PrefsPtr(EventViews::Prefs::instance()), QDate(), QDate(), false, false)) + mAgendaView(new EventViews::AgendaView(QDate(), QDate(), false, false)) { QVBoxLayout *topLayout = new QVBoxLayout( this ); topLayout->setSpacing( spacing ); FreeBusyCalendar *freebusyCalendar = new FreeBusyCalendar; freebusyCalendar->setModel(model); FreebusyViewCalendar *fbCalendar = new FreebusyViewCalendar(); fbCalendar->mCalendar = freebusyCalendar->calendar(); mAgendaView->addCalendar(EventViews::ViewCalendar::Ptr(fbCalendar)); //We have to call this and not pass in dates in the constructor, because otherwise everything starts to crash. mAgendaView->showDates(mDtStart.date(), mDtEnd.date(), mDtStart.date()); connect(mAgendaView, SIGNAL(timeSpanSelectionChanged()), this, SLOT(onTimeSpanSelectionChanged())); topLayout->addWidget( mAgendaView ); topLayout->setStretchFactor( mAgendaView, 100 ); } VisualFreeBusyWidget::~VisualFreeBusyWidget() { } void VisualFreeBusyWidget::setTimeRange( const KDateTime &dtFrom, const KDateTime &dtTo ) { kDebug() << "Changing date range" << dtFrom << dtTo; mDtStart = dtFrom; mDtEnd = dtTo; mAgendaView->showDates(mDtStart.date(), mDtEnd.date(), mDtStart.date()); } void VisualFreeBusyWidget::onTimeSpanSelectionChanged() { if (!mAgendaView) { return; } mDtStart = KDateTime(mAgendaView->selectionStart()); mDtEnd = KDateTime(mAgendaView->selectionEnd()); kDebug() << "TimeSpan selection chagned " << mDtStart << mDtEnd; emit dateTimesChanged( mDtStart, mDtEnd ); }