summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ui/opimrecurrencewidget.h
blob: 3f285654e921f46faf1569ffad0592aac3ea6a61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * GPL and based on the widget from TT
 */

#ifndef OPIE_PIM_RECURRENCE_WIDGET_H
#define OPIE_PIM_RECURRENCE_WIDGET_H

#include <opie2/opimrecurrence.h>

#include <qpe/datebookmonth.h>

#include <qlist.h>
#include <qtoolbutton.h>
#include <qcheckbox.h>
#include <qdatetime.h>
#include <qbuttongroup.h>

#include "opimrecurrencebase.h"

using namespace Opie;

/**
 * A widget to let the user select rules for recurrences.
 * This widget can take care of weekly, monthly, daily and yearly recurrence
 * It is used inside todolist and datebook.
 *
 *
 * @short Widget of selecting Recurrance
 * @author Trolltech, Holger Freyther
 * @version 0.9
 */
class OPimRecurrenceWidget : public OPimRecurrenceBase {
    Q_OBJECT
public:
    OPimRecurrenceWidget( bool startOnMonday,
                       const QDate& start, QWidget* parent = 0,
                       const char* name = 0,  bool modal = TRUE,
                       WFlags fl = 0 );
    OPimRecurrenceWidget( bool startOnMonday,
                       const OPimRecurrence& rp, const QDate& start,
                       QWidget* parent = 0, const char* name =0,
                       bool modal = TRUE, WFlags = 0 );
    ~OPimRecurrenceWidget();
    OPimRecurrence recurrence()const;
    QDate endDate()const;

public slots:
    void slotSetRType( int );
    /**
     * set the new end date
     */
    void endDateChanged( int, int, int );
    /**
     * enable/disable end date
     */
    void slotNoEnd( bool unused );
    void setStartDate( const QDate& );
    void setRecurrence( const OPimRecurrence& recur, const QDate& start );
    void setRecurrence( const OPimRecurrence& recur );

private slots:
    void setupRepeatLabel( const QString& );
    void setupRepeatLabel( int );
    void slotWeekLabel();
    void slotMonthLabel( int );
    void slotChangeStartOfWeek( bool onMonday );

private:
    void setupNone();
    void setupDaily();
    void setupWeekly();
    void setupMonthly();
    void setupYearly();

    enum repeatButtons { None, Day, Week, Month, Year };
    void init();
    void hideExtras();
    void showRepeatStuff();

    QList<QToolButton> listRTypeButtons;
    QList<QToolButton> listExtra;
    QDate start;    // only used in one spot...
    QDate end;
    repeatButtons currInterval;
    bool startWeekOnMonday : 1;
    DateBookMonth *repeatPicker;

    class Private;
    Private *d;

};

#endif