1 /* 2 This file is part of Kontact. 3 4 SPDX-FileCopyrightText: 2003 Tobias Koenig <tokoe@kde.org> 5 SPDX-FileCopyrightText: 2005-2006, 2009 Allen Winter <winter@kde.org> 6 7 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 8 */ 9 10 #pragma once 11 12 #include <Akonadi/Item> 13 14 #include <KCalendarCore/Todo> 15 16 #include <Akonadi/Calendar/ETMCalendar> 17 #include <KontactInterface/Summary> 18 19 class TodoPlugin; 20 21 namespace Akonadi 22 { 23 class IncidenceChanger; 24 } 25 26 class QGridLayout; 27 class QLabel; 28 29 class TodoSummaryWidget : public KontactInterface::Summary 30 { 31 Q_OBJECT 32 33 public: 34 explicit TodoSummaryWidget(TodoPlugin *plugin, QWidget *parent); 35 ~TodoSummaryWidget() override; 36 summaryHeight()37 int summaryHeight() const override 38 { 39 return 3; 40 } 41 42 public Q_SLOTS: 43 void updateSummary(bool force = false) override 44 { 45 Q_UNUSED(force) 46 updateView(); 47 } 48 49 protected: 50 bool eventFilter(QObject *obj, QEvent *e) override; 51 52 private Q_SLOTS: 53 void updateView(); 54 void popupMenu(const QString &uid); 55 void viewTodo(const QString &uid); 56 void removeTodo(const Akonadi::Item &item); 57 void completeTodo(Akonadi::Item::Id id); 58 59 private: 60 TodoPlugin *mPlugin = nullptr; 61 QGridLayout *mLayout = nullptr; 62 63 bool mDaysToGo = false; 64 bool mHideInProgress = false; 65 bool mHideOverdue = false; 66 bool mHideCompleted = false; 67 bool mHideOpenEnded = false; 68 bool mHideNotStarted = false; 69 bool mShowMineOnly = false; 70 71 QList<QLabel *> mLabels; 72 Akonadi::ETMCalendar::Ptr mCalendar; 73 Akonadi::IncidenceChanger *mChanger = nullptr; 74 75 /** 76 Test if the To-do starts today. 77 @param todo is a pointer to a To-do object to test. 78 @return if the To-do starts on the current date. 79 */ 80 bool startsToday(const KCalendarCore::Todo::Ptr &todo); 81 82 /** 83 Create a text string containing the states of the To-do. 84 @param todo is a pointer to a To-do object to test. 85 @return a QString containing a comma-separated list of To-do states. 86 */ 87 const QString stateStr(const KCalendarCore::Todo::Ptr &todo); 88 }; 89 90