alarmdialog.h 3.92 KB
Newer Older
1
/*
Allen Winter's avatar
Allen Winter committed
2
  This file is part of the KDE reminder agent.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

  Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>

  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.
*/
Allen Winter's avatar
Allen Winter committed
24 25
#ifndef KORGAC_ALARMDIALOG_H
#define KORGAC_ALARMDIALOG_H
26

Sergio Martins's avatar
Sergio Martins committed
27
#include <Akonadi/Calendar/ETMCalendar>
Laurent Montel's avatar
Laurent Montel committed
28
#include <Item>
Laurent Montel's avatar
Laurent Montel committed
29
#include <QDialog>
30 31 32
#include <KCalCore/Incidence>
#include <KDateTime>

33 34 35
#include <QPoint>
#include <QTimer>

Laurent Montel's avatar
Laurent Montel committed
36 37 38
namespace Akonadi
{
class Item;
39 40
}

Laurent Montel's avatar
Laurent Montel committed
41 42 43
namespace KIdentityManagement
{
class IdentityManager;
44 45
}

Laurent Montel's avatar
Laurent Montel committed
46 47 48
namespace CalendarSupport
{
class IncidenceViewer;
49 50 51
}

class ReminderTreeItem;
52 53 54 55 56 57 58 59

class KComboBox;

class QDateTime;
class QTreeWidget;
class QTreeWidgetItem;
class QSpinBox;

Laurent Montel's avatar
Laurent Montel committed
60
class AlarmDialog : public QDialog
61
{
Laurent Montel's avatar
Laurent Montel committed
62 63
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
64
    explicit AlarmDialog(const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent = Q_NULLPTR);
65
    ~AlarmDialog();
66

Laurent Montel's avatar
Laurent Montel committed
67 68 69
    void addIncidence(const Akonadi::Item &incidence, const QDateTime &reminderAt,
                      const QString &displayText);
    void setRemindAt(const QDateTime &dt);
70 71
    void eventNotification();

Laurent Montel's avatar
Laurent Montel committed
72
public Q_SLOTS:
73 74 75 76 77 78 79 80 81 82 83 84 85
    void slotOk();    // suspend
    void slotUser1(); // edit
    void slotUser2(); // dismiss all
    void slotUser3(); // dismiss selected
    void slotSave();
    void wakeUp();
    void show();
    void edit();
    void suspend();
    void suspendAll();
    void dismissAll();
    void dismissCurrent();
    /*reimp*/
Laurent Montel's avatar
Laurent Montel committed
86
    void accept() Q_DECL_OVERRIDE;
87

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

Laurent Montel's avatar
Laurent Montel committed
94
Q_SIGNALS:
Laurent Montel's avatar
Laurent Montel committed
95
    void reminderCount(int count);
96

Laurent Montel's avatar
Laurent Montel committed
97
private Q_SLOTS:
98
    void update();
Laurent Montel's avatar
Laurent Montel committed
99
    void updateButtons();
100

Laurent Montel's avatar
Laurent Montel committed
101
protected:
Laurent Montel's avatar
Laurent Montel committed
102 103
    void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
    void closeEvent(QCloseEvent *) Q_DECL_OVERRIDE;
Allen Winter's avatar
Allen Winter committed
104

Laurent Montel's avatar
Laurent Montel committed
105
private:
Laurent Montel's avatar
Minor  
Laurent Montel committed
106 107
    typedef QList<ReminderTreeItem *> ReminderList;

Laurent Montel's avatar
Laurent Montel committed
108 109 110
    static KDateTime triggerDateForIncidence(const KCalCore::Incidence::Ptr &inc,
            const QDateTime &reminderAt,
            QString &displayStr);
111

112
    // Removes each Incidence-X group that has one of the specified uids
Laurent Montel's avatar
Laurent Montel committed
113
    void removeFromConfig(const QList<Akonadi::Item::Id> &);
114

115
    // Opens through dbus, @deprecated
Laurent Montel's avatar
Laurent Montel committed
116
    bool openIncidenceEditorThroughKOrganizer(const KCalCore::Incidence::Ptr &incidence);
117 118

    // opens directly
Laurent Montel's avatar
Laurent Montel committed
119
    bool openIncidenceEditorNG(const Akonadi::Item &incidence);
120

121
    bool startKOrganizer();
Laurent Montel's avatar
Laurent Montel committed
122
    ReminderTreeItem *searchByItem(const Akonadi::Item &incidence);
123
    void setTimer();
Laurent Montel's avatar
Laurent Montel committed
124
    void dismiss(ReminderList selections);
125
    int activeCount();
Laurent Montel's avatar
Minor  
Laurent Montel committed
126
    ReminderList selectedItems() const;
Laurent Montel's avatar
Laurent Montel committed
127 128
    void toggleDetails(QTreeWidgetItem *item);
    void showDetails(QTreeWidgetItem *item);
129

130
    Akonadi::ETMCalendar::Ptr mCalendar;
131 132
    QTreeWidget *mIncidenceTree;
    CalendarSupport::IncidenceViewer *mDetailView;
Laurent Montel's avatar
Laurent Montel committed
133
    KIdentityManagement::IdentityManager *mIdentityManager;
134 135 136 137 138 139

    QPoint mPos;
    QSpinBox *mSuspendSpin;
    KComboBox *mSuspendUnit;
    QTimer mSuspendTimer;
    QTreeWidgetItem *mLastItem;
Laurent Montel's avatar
Laurent Montel committed
140 141 142 143 144
    QPushButton *mUser1Button;
    QPushButton *mUser2Button;
    QPushButton *mUser3Button;
    QPushButton *mOkButton;

145 146 147
};

#endif