summaryrefslogtreecommitdiff
path: root/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp
blob: 5182df15f26f01f54e2117974b6ca004bbc6673c (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
#include "datebookweeklstdblview.h"
#include "datebookweeklstview.h"

#include <qlayout.h>

DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
                           QValueList<EffectiveEvent> &ev2,
                           QDate &d, bool onM, bool showAmPm,
                           QWidget* parent,
                           const char* name, WFlags fl)
    : QWidget( parent, name, fl ), ampm( showAmPm )
{
    m_MainLayout = new QHBoxLayout( this );

    leftView = 0;
    rightView = 0;
    setEvents(ev1,ev2,d,onM);
}

DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
                           QDate &d, bool onM, bool showAmPm,
                           QWidget* parent,
                           const char* name, WFlags fl)
    : QWidget( parent, name, fl ), ampm( showAmPm )
{
    m_MainLayout = new QHBoxLayout( this );

    leftView = 0;
    rightView = 0;
    setEvents(ev1,d,onM);
}

/* setting the variant with both views */
void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM)
{
    setUpdatesEnabled(false);
    if (!leftView) {
        leftView=new DateBookWeekLstView(ev1, d, onM, ampm, this);
        m_MainLayout->addWidget(leftView);
        connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
        connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
        connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
        connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
        connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
        connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
        connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
        this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));

    } else {
        leftView->hide();
        leftView->setEvents(ev1,d,onM);
    }

    if (!rightView) {
        rightView=new DateBookWeekLstView(ev2, d.addDays(7), onM, ampm, this);
        m_MainLayout->addWidget(rightView);
        connect (rightView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
        connect (rightView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
        connect (rightView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
        connect (rightView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
        connect (rightView, SIGNAL(redraw()), this, SIGNAL(redraw()));
        connect (rightView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
        connect (rightView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
            this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
    } else {
        rightView->hide();
        rightView->setEvents(ev2,d.addDays(7),onM);
    }

    leftView->show();
    rightView->show();
    setUpdatesEnabled(true);
}

void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
{
    if (!leftView) {
        leftView=new DateBookWeekLstView(ev1, d, onM, ampm, this);
        m_MainLayout->addWidget(leftView);
        connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
        connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
        connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
        connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
        connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
        connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
        connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
            this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
    } else {
        leftView->hide();
        leftView->setEvents(ev1,d,onM);
    }
    leftView->show();

    if (rightView) {
        rightView->hide();
    }
}

void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
{
    if (!rightView) {
        rightView=new DateBookWeekLstView(ev1, d, onM, ampm, this);
        m_MainLayout->addWidget(rightView);
        connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
        connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
        connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
        connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
        connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
        connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
        connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
            this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
    } else {
        rightView->hide();
        rightView->setEvents(ev1,d,onM);
    }
    rightView->show();
}

bool DateBookWeekLstDblView::toggleDoubleView(bool how)
{
    if (rightView) {
        if (how) rightView->show();
        else rightView->hide();
        return true;
    }
    return false;
}

DateBookWeekLstDblView::~DateBookWeekLstDblView()
{
}