summaryrefslogtreecommitdiff
path: root/core/pim/datebook2/view.h
blob: 2236aad87b9c1de2b24a5dfc18eabdc6587d53f4 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef OPIE_DATE_BOOK_VIEW_H
#define OPIE_DATE_BOOK_VIEW_H

#include <qpixmap.h>
#include <qwidget.h>

#include <opie/oevent.h>
#include <opie/odatebookaccess.h>

class Config;
namespace Datebook {
    class MainWindow;
    class View {
    public:
        View( MainWindow* window,  QWidget* parent );
        virtual ~View();

        static QDate dateFromWeek( int week, int year, bool startOnMonda );
        static bool calcWeek( const QDate& d, int &week, int &year, bool startOnMonday = false );

        virtual QPixmap pixmap()const = 0;

        /**
         * non translatable name or type
         */
        virtual QCString type()const = 0;

        /**
         * shown to the user
         */
        virtual QString name()const = 0;
        virtual QString description()const = 0;

        /**
         * return the uid of the current item or 0
         */
        virtual int currentItem()const = 0;

        /**
         * loadConfig
         * saveConfig
         */
        void loadConfig( Config* );
        void saveConfig( Config* );

        /**
         * the current range
         * @param src Where to write the start datetime
         * @param dest Where to write the end datetime
         */
        virtual void currentRange( const QDateTime& src, const QDateTime& from) = 0;

        /**
         * the clock format changed
         */
        virtual void clockChanged() = 0;

        /**
         * the day change means that either
         * monday or sunday is the week start
         */
        virtual void dayChanged() = 0;

        /**
         * show date in your view!!
         * make the date visible in the current view
         */
        virtual void showDay( const QDate& date ) = 0;

        /**
         * return the widget
         */
        virtual QWidget* widget() = 0;

        /**
         * the view needs an update!
         */
        virtual void reschedule() = 0;
    protected:
        void popup( int uid);
        QString toShortText(const OEffectiveEvent& eff)const;
        QString toText(const OEffectiveEvent& eff)const;
        virtual void doLoadConfig( Config* ) = 0;
        virtual void doSaveConfig( Config* ) = 0;

        /**
         * create a new event starting
         * on start
         */
        void add( const QDate& start );

        /**
         * create a new event in a given range
         */
        void add( const QDateTime& start, const QDateTime& end );

        /**
         * will make the MainWindow to open the editor
         */
        void edit( int uid );

        /**
         * remove item with uid
         */
        void remove( int uid );

        /**
         * give access to all events
         */
        ODateBookAccess::List allEvents()const;

        /**
         * return events
         */
        OEffectiveEvent::ValueList events( const QDate& start, const QDate& end );

        /**
         * return an Event
         */
        OEvent event( int uid )const;

        /**
         * Is the clock AP/PM or 24h?
         */
        bool isAP()const;

        /**
         * if the week starts on monday?
         */
        bool weekStartOnMonday()const;

        /**
         * return related records for days
         */
        QList<OPimRecord> records( const QDate& on );
        QList<OPimRecord> records( const QDate& start, const QDate& to );

    private:
        MainWindow* m_win;
    };
}

#endif