summaryrefslogtreecommitdiff
path: root/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
authoralwin <alwin>2005-03-19 13:44:30 (UTC)
committer alwin <alwin>2005-03-19 13:44:30 (UTC)
commit34e42590a8ef21c1377f89c7b82f25bcf0aec3cb (patch) (unidiff)
treef5afdae31945ca2bac7339a339499fa87ece50d9 /core/pim/datebook/modules/weeklst/datebookweeklst.cpp
parentd9e8b9e797e3162ab564bb3b0f04663ef1167541 (diff)
downloadopie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.zip
opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.gz
opie-34e42590a8ef21c1377f89c7b82f25bcf0aec3cb.tar.bz2
so....
I looked for a problem. could not found due the kind of code structure. so I had reorganized the code into a more sensefull structure so every one should be able to find some code sequences when searching for a bug. yes - now I found the problem and can thinking about resolving it.
Diffstat (limited to 'core/pim/datebook/modules/weeklst/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.cpp138
1 files changed, 138 insertions, 0 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
new file mode 100644
index 0000000..47bc597
--- a/dev/null
+++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
@@ -0,0 +1,138 @@
1#include "namespace_hack.h"
2#include "datebookweeklst.h"
3#include "datebookweeklstheader.h"
4#include "datebookweeklstview.h"
5#include "datebookweeklstdblview.h"
6
7#include "datebook.h"
8
9#include <opie2/odebug.h>
10
11#include <qpe/datebookmonth.h>
12#include <qpe/config.h>
13#include <qpe/resource.h>
14
15#include <qlayout.h>
16#include <qtoolbutton.h>
17
18using namespace Opie::Ui;
19
20DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
21 QWidget *parent,
22 const char *name )
23 : QWidget( parent, name ),
24 db( newDB ),
25 startTime( 0 ),
26 ampm( ap ),
27 bStartOnMonday(onM)
28{
29 setFocusPolicy(StrongFocus);
30 layout = new QVBoxLayout( this );
31 layout->setMargin(0);
32
33 header=new DateBookWeekLstHeader(onM, this);
34 layout->addWidget( header );
35 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
36 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
37
38 scroll=new QScrollView(this);
39 scroll->setResizePolicy(QScrollView::AutoOneFit);
40 layout->addWidget(scroll);
41
42 view=NULL;
43 Config config("DateBook");
44 config.setGroup("Main");
45 dbl=config.readBoolEntry("weeklst_dbl", false);
46 header->dbl->setOn(dbl);
47}
48DateBookWeekLst::~DateBookWeekLst(){
49 Config config("DateBook");
50 config.setGroup("Main");
51 config.writeEntry("weeklst_dbl", dbl);
52}
53
54void DateBookWeekLst::setDate(const QDate &d) {
55 bdate=d;
56 header->setDate(d);
57}
58
59void DateBookWeekLst::setDbl(bool on) {
60 dbl=on;
61 redraw();
62}
63void DateBookWeekLst::redraw() {getEvents();}
64
65QDate DateBookWeekLst::date() {
66 return bdate;
67}
68
69// return the date at the beginning of the week...
70// copied from DateBookWeek
71QDate DateBookWeekLst::weekDate() const
72{
73 QDate d=bdate;
74
75 // Calculate offset to first day of week.
76 int dayoffset=d.dayOfWeek();
77 if(bStartOnMonday) dayoffset--;
78 else if( dayoffset == 7 )
79 dayoffset = 0;
80
81 return d.addDays(-dayoffset);
82}
83
84void DateBookWeekLst::getEvents() {
85 QDate start = weekDate(); //date();
86 QDate stop = start.addDays(6);
87 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
88
89 setUpdatesEnabled(false);
90 if (view) delete view;
91 if (dbl) {
92 QDate start2=start.addDays(7);
93 stop=start2.addDays(6);
94 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
95 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
96 } else {
97 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
98 }
99
100 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
101 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
102 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
103 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
104 connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
105 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
106 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
107 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
108
109 scroll->addChild(view);
110 view->show();
111 scroll->updateScrollBars();
112 setUpdatesEnabled(true);
113}
114
115void DateBookWeekLst::dateChanged(QDate &newdate) {
116 bdate=newdate;
117 getEvents();
118}
119
120void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
121{
122 switch(e->key()) {
123 case Key_Up:
124 scroll->scrollBy(0, -20);
125 break;
126 case Key_Down:
127 scroll->scrollBy(0, 20);
128 break;
129 case Key_Left:
130 header->prevWeek();
131 break;
132 case Key_Right:
133 header->nextWeek();
134 break;
135 default:
136 e->ignore();
137 }
138}