alarmdialog.h 3.83 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
2
3
/*
  This file is part of the KDE reminder agent.

4
  SPDX-FileCopyrightText: 2000 Cornelius Schumacher <schumacher@kde.org>
Laurent Montel's avatar
Laurent Montel committed
5

6
  SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
Laurent Montel's avatar
Laurent Montel committed
7
8
9
10
11
*/
#ifndef KORGAC_ALARMDIALOG_H
#define KORGAC_ALARMDIALOG_H

#include <Akonadi/Calendar/ETMCalendar>
12
13

#include <QDialog>
Laurent Montel's avatar
Laurent Montel committed
14
15
#include <QTimer>

Allen Winter's avatar
Allen Winter committed
16
class ReminderTreeItem;
Laurent Montel's avatar
Laurent Montel committed
17

Laurent Montel's avatar
Laurent Montel committed
18
namespace KIdentityManagement {
Laurent Montel's avatar
Laurent Montel committed
19
20
21
class IdentityManager;
}

Allen Winter's avatar
Allen Winter committed
22
23
24
25
namespace Akonadi {
class Item;
}

Laurent Montel's avatar
Laurent Montel committed
26
namespace CalendarSupport {
Laurent Montel's avatar
Laurent Montel committed
27
28
29
class IncidenceViewer;
}

30
class QComboBox;
Laurent Montel's avatar
Laurent Montel committed
31

Allen Winter's avatar
Allen Winter committed
32
class QSpinBox;
Laurent Montel's avatar
Laurent Montel committed
33
34
class QTreeWidget;
class QTreeWidgetItem;
Allen Winter's avatar
Allen Winter committed
35

Laurent Montel's avatar
Laurent Montel committed
36
37
38
class AlarmDialog : public QDialog
{
    Q_OBJECT
39

Laurent Montel's avatar
Laurent Montel committed
40
public:
41
42
43
44
45
    /**
     * The suspend time unit.
     */
    enum SuspendUnit {
        SuspendInMinutes = 0,  ///< Suspend time is in minutes
Laurent Montel's avatar
Laurent Montel committed
46
47
48
        SuspendInHours = 1,    ///< Suspend time is in hours
        SuspendInDays = 2,     ///< Suspend time is in days
        SuspendInWeeks = 3     ///< Suspend time is in weeks
49
    };
50
    Q_ENUM(SuspendUnit)
51

Laurent Montel's avatar
Laurent Montel committed
52
    explicit AlarmDialog(const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent = nullptr);
53
    ~AlarmDialog() override;
Laurent Montel's avatar
Laurent Montel committed
54

Laurent Montel's avatar
Laurent Montel committed
55
    void addIncidence(const Akonadi::Item &incidence, const QDateTime &reminderAt, const QString &displayText);
Laurent Montel's avatar
Laurent Montel committed
56
57
58
59
60
61
62
    void eventNotification();

public Q_SLOTS:
    void slotOk();    // suspend
    void slotUser1(); // edit
    void slotUser2(); // dismiss all
    void slotUser3(); // dismiss selected
63
64
    void resetSuspend(); //reset the suspend value to the default
    void setDefaultSuspend(); //set current suspend value as the default
Laurent Montel's avatar
Laurent Montel committed
65
66
67
68
69
70
71
72
73
    void slotSave();
    void wakeUp();
    void show();
    void edit();
    void suspend();
    void suspendAll();
    void dismissAll();
    void dismissCurrent();
    /*reimp*/
74
    void accept() override;
Laurent Montel's avatar
Laurent Montel committed
75
    void reject() override;
Laurent Montel's avatar
Laurent Montel committed
76
77
78
79
80
81
82
83
84
85
86

    /**
       If an incidence changed, for example in korg, we must update
       the date and summary shown in the list view.
    */
    void slotCalendarChanged();

Q_SIGNALS:
    void reminderCount(int count);

protected:
87
88
    void keyPressEvent(QKeyEvent *e) override;
    void closeEvent(QCloseEvent *) override;
89
    void showEvent(QShowEvent *event) override;
Laurent Montel's avatar
Laurent Montel committed
90

91
private Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
92
    void slotDBusNotificationsPropertiesChanged(const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidatedProperties);
93

Laurent Montel's avatar
Laurent Montel committed
94
private:
Laurent Montel's avatar
Laurent Montel committed
95
96
    void update();
    void updateButtons();
Laurent Montel's avatar
Laurent Montel committed
97
    using ReminderList = QList<ReminderTreeItem *>;
Laurent Montel's avatar
Laurent Montel committed
98

Laurent Montel's avatar
Laurent Montel committed
99
    static Q_REQUIRED_RESULT QDateTime triggerDateForIncidence(const KCalendarCore::Incidence::Ptr &inc, const QDateTime &reminderAt, QString &displayStr);
Laurent Montel's avatar
Laurent Montel committed
100
101
102
103
104

    // Removes each Incidence-X group that has one of the specified uids
    void removeFromConfig(const QList<Akonadi::Item::Id> &);

    // Opens through dbus, @deprecated
Laurent Montel's avatar
Laurent Montel committed
105
    Q_REQUIRED_RESULT bool openIncidenceEditorThroughKOrganizer(const KCalendarCore::Incidence::Ptr &incidence);
Laurent Montel's avatar
Laurent Montel committed
106
107

    // opens directly
Laurent Montel's avatar
Laurent Montel committed
108
    Q_REQUIRED_RESULT bool openIncidenceEditorNG(const Akonadi::Item &incidence);
Laurent Montel's avatar
Laurent Montel committed
109
110
111

    ReminderTreeItem *searchByItem(const Akonadi::Item &incidence);
    void setTimer();
Laurent Montel's avatar
Laurent Montel committed
112
    void dismiss(const ReminderList &selections);
Laurent Montel's avatar
Laurent Montel committed
113
114
    Q_REQUIRED_RESULT int activeCount();
    Q_REQUIRED_RESULT ReminderList selectedItems() const;
Laurent Montel's avatar
Laurent Montel committed
115
116
    void toggleDetails(QTreeWidgetItem *item);
    void showDetails(QTreeWidgetItem *item);
Laurent Montel's avatar
Laurent Montel committed
117
    static Q_REQUIRED_RESULT bool grabFocus();
Laurent Montel's avatar
Laurent Montel committed
118
119

    Akonadi::ETMCalendar::Ptr mCalendar;
Laurent Montel's avatar
Laurent Montel committed
120
121
122
    QTreeWidget *mIncidenceTree = nullptr;
    CalendarSupport::IncidenceViewer *mDetailView = nullptr;
    KIdentityManagement::IdentityManager *mIdentityManager = nullptr;
Laurent Montel's avatar
Laurent Montel committed
123

Laurent Montel's avatar
Laurent Montel committed
124
    QRect mRect;
Laurent Montel's avatar
Laurent Montel committed
125
    QSpinBox *mSuspendSpin = nullptr;
126
    QComboBox *mSuspendUnit = nullptr;
Laurent Montel's avatar
Laurent Montel committed
127
    QTimer mSuspendTimer;
Laurent Montel's avatar
Laurent Montel committed
128
129
130
131
    QTreeWidgetItem *mLastItem = nullptr;
    QPushButton *mUser1Button = nullptr;
    QPushButton *mUser2Button = nullptr;
    QPushButton *mUser3Button = nullptr;
132
    QPushButton *mOkButton = nullptr;
Laurent Montel's avatar
Laurent Montel committed
133
134
135
};

#endif