summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.pro2
-rw-r--r--core/pim/datebook/datebookweeklst.cpp4
2 files changed, 2 insertions, 4 deletions
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index 2edbf99..088ae3e 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -1,62 +1,60 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on release 2 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 4
5 HEADERS= datebookday.h \ 5 HEADERS= datebookday.h \
6 datebook.h \ 6 datebook.h \
7 dateentryimpl.h \ 7 dateentryimpl.h \
8 datebookdayheaderimpl.h \ 8 datebookdayheaderimpl.h \
9 datebooksettings.h \ 9 datebooksettings.h \
10 datebooksettingsbase.h \
11 datebookweek.h \ 10 datebookweek.h \
12 datebookweeklst.h \ 11 datebookweeklst.h \
13 datebookweekheaderimpl.h \ 12 datebookweekheaderimpl.h \
14 repeatentry.h \ 13 repeatentry.h \
15 timepicker.h \ 14 timepicker.h \
16 noteentryimpl.h \ 15 noteentryimpl.h \
17 onoteedit.h 16 onoteedit.h
18 17
19 SOURCES= main.cpp \ 18 SOURCES= main.cpp \
20 datebookday.cpp \ 19 datebookday.cpp \
21 datebook.cpp \ 20 datebook.cpp \
22 dateentryimpl.cpp \ 21 dateentryimpl.cpp \
23 datebookdayheaderimpl.cpp \ 22 datebookdayheaderimpl.cpp \
24 datebooksettingsbase.cpp \
25 datebooksettings.cpp \ 23 datebooksettings.cpp \
26 datebookweek.cpp \ 24 datebookweek.cpp \
27 datebookweeklst.cpp \ 25 datebookweeklst.cpp \
28 datebookweekheaderimpl.cpp \ 26 datebookweekheaderimpl.cpp \
29 repeatentry.cpp \ 27 repeatentry.cpp \
30 timepicker.cpp \ 28 timepicker.cpp \
31 noteentryimpl.cpp \ 29 noteentryimpl.cpp \
32 onoteedit.cpp 30 onoteedit.cpp
33 31
34 INTERFACES= dateentry.ui \ 32 INTERFACES= dateentry.ui \
35 datebookdayheader.ui \ 33 datebookdayheader.ui \
36 datebookweekheader.ui \ 34 datebookweekheader.ui \
37 datebookweeklstheader.ui \ 35 datebookweeklstheader.ui \
38 datebookweeklstdayhdr.ui \ 36 datebookweeklstdayhdr.ui \
39 repeatentrybase.ui \ 37 repeatentrybase.ui \
40 datebooksettingsbase.ui \ 38 datebooksettingsbase.ui \
41 noteentry.ui 39 noteentry.ui
42 40
43INCLUDEPATH += $(OPIEDIR)/include 41INCLUDEPATH += $(OPIEDIR)/include
44 DEPENDPATH+= $(OPIEDIR)/include 42 DEPENDPATH+= $(OPIEDIR)/include
45LIBS += -lqpe -lopie 43LIBS += -lqpe -lopie
46 44
47 TARGET = datebook 45 TARGET = datebook
48 46
49TRANSLATIONS = ../i18n/pt_BR/datebook.ts 47TRANSLATIONS = ../i18n/pt_BR/datebook.ts
50TRANSLATIONS += ../i18n/pt/datebook.ts 48TRANSLATIONS += ../i18n/pt/datebook.ts
51TRANSLATIONS += ../i18n/de/datebook.ts 49TRANSLATIONS += ../i18n/de/datebook.ts
52TRANSLATIONS += ../i18n/en/datebook.ts 50TRANSLATIONS += ../i18n/en/datebook.ts
53TRANSLATIONS += ../i18n/hu/datebook.ts 51TRANSLATIONS += ../i18n/hu/datebook.ts
54TRANSLATIONS += ../i18n/pl/datebook.ts 52TRANSLATIONS += ../i18n/pl/datebook.ts
55TRANSLATIONS += ../i18n/sl/datebook.ts 53TRANSLATIONS += ../i18n/sl/datebook.ts
56TRANSLATIONS += ../i18n/ja/datebook.ts 54TRANSLATIONS += ../i18n/ja/datebook.ts
57TRANSLATIONS += ../i18n/ko/datebook.ts 55TRANSLATIONS += ../i18n/ko/datebook.ts
58TRANSLATIONS += ../i18n/no/datebook.ts 56TRANSLATIONS += ../i18n/no/datebook.ts
59TRANSLATIONS += ../i18n/zh_CN/datebook.ts 57TRANSLATIONS += ../i18n/zh_CN/datebook.ts
60TRANSLATIONS += ../i18n/zh_TW/datebook.ts 58TRANSLATIONS += ../i18n/zh_TW/datebook.ts
61TRANSLATIONS += ../i18n/fr/datebook.ts 59TRANSLATIONS += ../i18n/fr/datebook.ts
62TRANSLATIONS += ../i18n/es/datebook.ts 60TRANSLATIONS += ../i18n/es/datebook.ts
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 58a9c53..29519c1 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,373 +1,373 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3#include "datebookweekheaderimpl.h" 3#include "datebookweekheaderimpl.h"
4 4
5#include <qpe/calendar.h> 5#include <qpe/calendar.h>
6#include <qpe/datebookdb.h> 6#include <qpe/datebookdb.h>
7#include <qpe/event.h> 7#include <qpe/event.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/timestring.h> 9#include <qpe/timestring.h>
10#include <qpe/datebookmonth.h> 10#include <qpe/datebookmonth.h>
11#include <qpe/config.h> 11#include <qpe/config.h>
12 12
13#include <qdatetime.h> 13#include <qdatetime.h>
14#include <qheader.h> 14#include <qheader.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qlayout.h> 16#include <qlayout.h>
17#include <qpainter.h> 17#include <qpainter.h>
18#include <qpopupmenu.h> 18#include <qpopupmenu.h>
19#include <qtimer.h> 19#include <qtimer.h>
20#include <qstyle.h> 20#include <qstyle.h>
21#include <qtoolbutton.h> 21#include <qtoolbutton.h>
22#include <qvbox.h> 22#include <qvbox.h>
23#include <qsizepolicy.h> 23#include <qsizepolicy.h>
24#include <qabstractlayout.h> 24#include <qabstractlayout.h>
25#include <qtl.h> 25#include <qtl.h>
26 26
27bool calcWeek(const QDate &d, int &week, int &year, 27bool calcWeek(const QDate &d, int &week, int &year,
28 bool startOnMonday = false); 28 bool startOnMonday = false);
29 29
30DateBookWeekLstHeader::DateBookWeekLstHeader(bool /*onM*/, QWidget* parent, 30DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
31 const char* name, WFlags fl) 31 const char* name, WFlags fl)
32 : DateBookWeekLstHeaderBase(parent, name, fl) 32 : DateBookWeekLstHeaderBase(parent, name, fl)
33{ 33{
34 setBackgroundMode( PaletteButton ); 34 setBackgroundMode( PaletteButton );
35 labelDate->setBackgroundMode( PaletteButton ); 35 labelDate->setBackgroundMode( PaletteButton );
36 labelWeek->setBackgroundMode( PaletteButton ); 36 labelWeek->setBackgroundMode( PaletteButton );
37 forward->setBackgroundMode( PaletteButton ); 37 forward->setBackgroundMode( PaletteButton );
38 back->setBackgroundMode( PaletteButton ); 38 back->setBackgroundMode( PaletteButton );
39 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 39 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
40 DateBookWeekLstHeaderBaseLayout->setMargin(0); 40 DateBookWeekLstHeaderBaseLayout->setMargin(0);
41 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 41 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
42 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 42 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
43 43
44 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); 44 connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
45 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); 45 connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
46 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); 46 connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
47 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 47 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
48 onMonday=onM; 48 onMonday=onM;
49} 49}
50DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 50DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
51void DateBookWeekLstHeader::setDate(const QDate &d) { 51void DateBookWeekLstHeader::setDate(const QDate &d) {
52 date=d; 52 date=d;
53 53
54 int year,week; 54 int year,week;
55 calcWeek(d,week,year,onMonday); 55 calcWeek(d,week,year,onMonday);
56 labelWeek->setText("W: " + QString::number(week)); 56 labelWeek->setText("W: " + QString::number(week));
57 57
58 QDate start=date; 58 QDate start=date;
59 QDate stop=start.addDays(6); 59 QDate stop=start.addDays(6);
60 labelDate->setText( QString::number(start.day()) + " " + 60 labelDate->setText( QString::number(start.day()) + " " +
61 start.monthName(start.month()) + " - " + 61 start.monthName(start.month()) + " - " +
62 QString::number(stop.day()) + " " + 62 QString::number(stop.day()) + " " +
63 start.monthName(stop.month()) ); 63 start.monthName(stop.month()) );
64 emit dateChanged(year,week); 64 emit dateChanged(year,week);
65} 65}
66void DateBookWeekLstHeader::pickDate() { 66void DateBookWeekLstHeader::pickDate() {
67 static QPopupMenu *m1 = 0; 67 static QPopupMenu *m1 = 0;
68 static DateBookMonth *picker = 0; 68 static DateBookMonth *picker = 0;
69 if ( !m1 ) { 69 if ( !m1 ) {
70 m1 = new QPopupMenu( this ); 70 m1 = new QPopupMenu( this );
71 picker = new DateBookMonth( m1, 0, TRUE ); 71 picker = new DateBookMonth( m1, 0, TRUE );
72 m1->insertItem( picker ); 72 m1->insertItem( picker );
73 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 73 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
74 this, SLOT( setDate( int, int, int ) ) ); 74 this, SLOT( setDate( int, int, int ) ) );
75 //connect( m1, SIGNAL( aboutToHide() ), 75 //connect( m1, SIGNAL( aboutToHide() ),
76 //this, SLOT( gotHide() ) ); 76 //this, SLOT( gotHide() ) );
77 } 77 }
78 picker->setDate( date.year(), date.month(), date.day() ); 78 picker->setDate( date.year(), date.month(), date.day() );
79 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); 79 m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height())));
80 picker->setFocus(); 80 picker->setFocus();
81} 81}
82void DateBookWeekLstHeader::setDate(int y, int m, int d) { 82void DateBookWeekLstHeader::setDate(int y, int m, int d) {
83 QDate new_date(y,m,d); 83 QDate new_date(y,m,d);
84 setDate(new_date); 84 setDate(new_date);
85} 85}
86 86
87void DateBookWeekLstHeader::nextWeek() { 87void DateBookWeekLstHeader::nextWeek() {
88 setDate(date.addDays(7)); 88 setDate(date.addDays(7));
89} 89}
90void DateBookWeekLstHeader::prevWeek() { 90void DateBookWeekLstHeader::prevWeek() {
91 setDate(date.addDays(-7)); 91 setDate(date.addDays(-7));
92} 92}
93 93
94DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM, 94DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
95 QWidget* parent, 95 QWidget* parent,
96 const char* name, 96 const char* name,
97 WFlags fl ) 97 WFlags fl )
98 : DateBookWeekLstDayHdrBase(parent, name, fl) { 98 : DateBookWeekLstDayHdrBase(parent, name, fl) {
99 99
100 date=d; 100 date=d;
101 101
102 static const char *wdays="MTWTFSS"; 102 static const char *wdays="MTWTFSS";
103 char day=wdays[d.dayOfWeek()-1]; 103 char day=wdays[d.dayOfWeek()-1];
104 104
105 label->setText( QString(QChar(day)) + " " + 105 label->setText( QString(QChar(day)) + " " +
106 QString::number(d.day()) ); 106 QString::number(d.day()) );
107 add->setText("+"); 107 add->setText("+");
108 108
109 if (d == QDate::currentDate()) { 109 if (d == QDate::currentDate()) {
110 QPalette pal=label->palette(); 110 QPalette pal=label->palette();
111 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 111 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
112 label->setPalette(pal); 112 label->setPalette(pal);
113 113
114 /* 114 /*
115 QFont f=label->font(); 115 QFont f=label->font();
116 f.setItalic(true); 116 f.setItalic(true);
117 label->setFont(f); 117 label->setFont(f);
118 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 118 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
119 */ 119 */
120 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 120 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
121 QPalette pal=label->palette(); 121 QPalette pal=label->palette();
122 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 122 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
123 label->setPalette(pal); 123 label->setPalette(pal);
124 } 124 }
125 125
126 126
127 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 127 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
129} 129}
130 130
131void DateBookWeekLstDayHdr::showDay() { 131void DateBookWeekLstDayHdr::showDay() {
132 emit showDate(date.year(), date.month(), date.day()); 132 emit showDate(date.year(), date.month(), date.day());
133} 133}
134void DateBookWeekLstDayHdr::newEvent() { 134void DateBookWeekLstDayHdr::newEvent() {
135 QDateTime start, stop; 135 QDateTime start, stop;
136 start=stop=date; 136 start=stop=date;
137 start.setTime(QTime(10,0)); 137 start.setTime(QTime(10,0));
138 stop.setTime(QTime(12,0)); 138 stop.setTime(QTime(12,0));
139 139
140 emit addEvent(start,stop,""); 140 emit addEvent(start,stop,"");
141} 141}
142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
143 QWidget* parent, 143 QWidget* parent,
144 const char* name, 144 const char* name,
145 WFlags fl) : 145 WFlags fl) :
146 OClickableLabel(parent,name,fl), 146 OClickableLabel(parent,name,fl),
147 event(ev) 147 event(ev)
148{ 148{
149 char s[10]; 149 char s[10];
150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
151 if ( ev.endDate() == ev.date() ) { // last day 151 if ( ev.endDate() == ev.date() ) { // last day
152 strcpy(s, "__|__"); 152 strcpy(s, "__|__");
153 } else { 153 } else {
154 strcpy(s, " |---"); 154 strcpy(s, " |---");
155 } 155 }
156 } else { 156 } else {
157 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); 157 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
158 } 158 }
159 setText(QString(s) + " " + ev.description()); 159 setText(QString(s) + " " + ev.description());
160 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 160 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
161 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 161 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
162} 162}
163void DateBookWeekLstEvent::editMe() { 163void DateBookWeekLstEvent::editMe() {
164 emit editEvent(event.event()); 164 emit editEvent(event.event());
165} 165}
166 166
167 167
168DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 168DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
169 const QDate &d, bool onM, 169 const QDate &d, bool onM,
170 QWidget* parent, 170 QWidget* parent,
171 const char* name, WFlags fl) 171 const char* name, WFlags fl)
172 : QWidget( parent, name, fl ) 172 : QWidget( parent, name, fl )
173{ 173{
174 onMonday=onM; 174 onMonday=onM;
175 setPalette(white); 175 setPalette(white);
176 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 176 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
177 177
178 QVBoxLayout *layout = new QVBoxLayout( this ); 178 QVBoxLayout *layout = new QVBoxLayout( this );
179 179
180 qBubbleSort(ev); 180 qBubbleSort(ev);
181 QValueListIterator<EffectiveEvent> it; 181 QValueListIterator<EffectiveEvent> it;
182 it=ev.begin(); 182 it=ev.begin();
183 183
184 int dayOrder[7]; 184 int dayOrder[7];
185 if (onMonday) 185 if (onMonday)
186 for (int d=0; d<7; d++) dayOrder[d]=d+1; 186 for (int d=0; d<7; d++) dayOrder[d]=d+1;
187 else { 187 else {
188 for (int d=0; d<7; d++) dayOrder[d]=d; 188 for (int d=0; d<7; d++) dayOrder[d]=d;
189 dayOrder[0]=7; 189 dayOrder[0]=7;
190 } 190 }
191 191
192 for (int i=0; i<7; i++) { 192 for (int i=0; i<7; i++) {
193 // Header 193 // Header
194 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 194 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i),
195 onMonday,this); 195 onMonday,this);
196 connect(hdr, SIGNAL(showDate(int,int,int)), 196 connect(hdr, SIGNAL(showDate(int,int,int)),
197 this, SIGNAL(showDate(int,int,int))); 197 this, SIGNAL(showDate(int,int,int)));
198 connect(hdr, SIGNAL(addEvent(const QDateTime &, 198 connect(hdr, SIGNAL(addEvent(const QDateTime &,
199 const QDateTime &, 199 const QDateTime &,
200 const QString &)), 200 const QString &)),
201 this, SIGNAL(addEvent(const QDateTime &, 201 this, SIGNAL(addEvent(const QDateTime &,
202 const QDateTime &, 202 const QDateTime &,
203 const QString &))); 203 const QString &)));
204 layout->addWidget(hdr); 204 layout->addWidget(hdr);
205 205
206 // Events 206 // Events
207 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 207 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
208 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 208 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this);
209 layout->addWidget(l); 209 layout->addWidget(l);
210 connect (l, SIGNAL(editEvent(const Event &)), 210 connect (l, SIGNAL(editEvent(const Event &)),
211 this, SIGNAL(editEvent(const Event &))); 211 this, SIGNAL(editEvent(const Event &)));
212 it++; 212 it++;
213 } 213 }
214 214
215 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 215 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
216 } 216 }
217} 217}
218DateBookWeekLstView::~DateBookWeekLstView(){} 218DateBookWeekLstView::~DateBookWeekLstView(){}
219void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 219void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
220 220
221DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 221DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
222 QValueList<EffectiveEvent> &ev2, 222 QValueList<EffectiveEvent> &ev2,
223 QDate &d, bool onM, 223 QDate &d, bool onM,
224 QWidget* parent, 224 QWidget* parent,
225 const char* name, WFlags fl) 225 const char* name, WFlags fl)
226 : QWidget( parent, name, fl ) 226 : QWidget( parent, name, fl )
227{ 227{
228 QHBoxLayout *layout = new QHBoxLayout( this ); 228 QHBoxLayout *layout = new QHBoxLayout( this );
229 229
230 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 230 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
231 layout->addWidget(w); 231 layout->addWidget(w);
232 connect (w, SIGNAL(editEvent(const Event &)), 232 connect (w, SIGNAL(editEvent(const Event &)),
233 this, SIGNAL(editEvent(const Event &))); 233 this, SIGNAL(editEvent(const Event &)));
234 connect (w, SIGNAL(showDate(int,int,int)), 234 connect (w, SIGNAL(showDate(int,int,int)),
235 this, SIGNAL(showDate(int,int,int))); 235 this, SIGNAL(showDate(int,int,int)));
236 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 236 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
237 const QString &)), 237 const QString &)),
238 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 238 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
239 const QString &))); 239 const QString &)));
240 240
241 241
242 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 242 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
243 layout->addWidget(w); 243 layout->addWidget(w);
244 connect (w, SIGNAL(editEvent(const Event &)), 244 connect (w, SIGNAL(editEvent(const Event &)),
245 this, SIGNAL(editEvent(const Event &))); 245 this, SIGNAL(editEvent(const Event &)));
246 connect (w, SIGNAL(showDate(int,int,int)), 246 connect (w, SIGNAL(showDate(int,int,int)),
247 this, SIGNAL(showDate(int,int,int))); 247 this, SIGNAL(showDate(int,int,int)));
248 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 248 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
249 const QString &)), 249 const QString &)),
250 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 250 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
251 const QString &))); 251 const QString &)));
252} 252}
253 253
254DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 254DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
255 QWidget *parent, 255 QWidget *parent,
256 const char *name ) 256 const char *name )
257 : QWidget( parent, name ), 257 : QWidget( parent, name ),
258 db( newDB ), 258 db( newDB ),
259 startTime( 0 ), 259 startTime( 0 ),
260 ampm( ap ), 260 ampm( ap ),
261 onMonday(onM) 261 onMonday(onM)
262{ 262{
263 setFocusPolicy(StrongFocus); 263 setFocusPolicy(StrongFocus);
264 layout = new QVBoxLayout( this ); 264 layout = new QVBoxLayout( this );
265 layout->setMargin(0); 265 layout->setMargin(0);
266 266
267 header=new DateBookWeekLstHeader(onM, this); 267 header=new DateBookWeekLstHeader(onM, this);
268 layout->addWidget( header ); 268 layout->addWidget( header );
269 connect(header, SIGNAL(dateChanged(int,int)), 269 connect(header, SIGNAL(dateChanged(int,int)),
270 this, SLOT(dateChanged(int,int))); 270 this, SLOT(dateChanged(int,int)));
271 connect(header, SIGNAL(setDbl(bool)), 271 connect(header, SIGNAL(setDbl(bool)),
272 this, SLOT(setDbl(bool))); 272 this, SLOT(setDbl(bool)));
273 273
274 scroll=new QScrollView(this); 274 scroll=new QScrollView(this);
275 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 275 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
276 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 276 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
277 scroll->setResizePolicy(QScrollView::AutoOneFit); 277 scroll->setResizePolicy(QScrollView::AutoOneFit);
278 layout->addWidget(scroll); 278 layout->addWidget(scroll);
279 279
280 view=NULL; 280 view=NULL;
281 Config config("DateBook"); 281 Config config("DateBook");
282 config.setGroup("Main"); 282 config.setGroup("Main");
283 dbl=config.readBoolEntry("weeklst_dbl", false); 283 dbl=config.readBoolEntry("weeklst_dbl", false);
284 header->dbl->setOn(dbl); 284 header->dbl->setOn(dbl);
285} 285}
286DateBookWeekLst::~DateBookWeekLst(){ 286DateBookWeekLst::~DateBookWeekLst(){
287 Config config("DateBook"); 287 Config config("DateBook");
288 config.setGroup("Main"); 288 config.setGroup("Main");
289 config.writeEntry("weeklst_dbl", dbl); 289 config.writeEntry("weeklst_dbl", dbl);
290} 290}
291 291
292void DateBookWeekLst::setDate(const QDate &d) { 292void DateBookWeekLst::setDate(const QDate &d) {
293 int w,y; 293 int w,y;
294 calcWeek(d,w,y,onMonday); 294 calcWeek(d,w,y,onMonday);
295 year=y; 295 year=y;
296 _week=w; 296 _week=w;
297 header->setDate(date()); 297 header->setDate(date());
298} 298}
299void DateBookWeekLst::setDbl(bool on) { 299void DateBookWeekLst::setDbl(bool on) {
300 dbl=on; 300 dbl=on;
301 redraw(); 301 redraw();
302} 302}
303void DateBookWeekLst::redraw() {getEvents();} 303void DateBookWeekLst::redraw() {getEvents();}
304 304
305QDate DateBookWeekLst::date() const { 305QDate DateBookWeekLst::date() const {
306 QDate d; 306 QDate d;
307 d.setYMD(year,1,1); 307 d.setYMD(year,1,1);
308 308
309 int dow= d.dayOfWeek(); 309 int dow= d.dayOfWeek();
310 if (!onMonday) 310 if (!onMonday)
311 if (dow==7) dow=1; 311 if (dow==7) dow=1;
312 else dow++; 312 else dow++;
313 313
314 d=d.addDays( (_week-1)*7 - dow + 1 ); 314 d=d.addDays( (_week-1)*7 - dow + 1 );
315 return d; 315 return d;
316} 316}
317 317
318void DateBookWeekLst::getEvents() { 318void DateBookWeekLst::getEvents() {
319 QDate start = date(); 319 QDate start = date();
320 QDate stop = start.addDays(6); 320 QDate stop = start.addDays(6);
321 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 321 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
322 322
323 if (view) delete view; 323 if (view) delete view;
324 if (dbl) { 324 if (dbl) {
325 QDate start2=start.addDays(7); 325 QDate start2=start.addDays(7);
326 stop=start2.addDays(6); 326 stop=start2.addDays(6);
327 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 327 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
328 328
329 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); 329 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll);
330 } else { 330 } else {
331 view=new DateBookWeekLstView(el,start,onMonday,scroll); 331 view=new DateBookWeekLstView(el,start,onMonday,scroll);
332 } 332 }
333 333
334 connect (view, SIGNAL(editEvent(const Event &)), 334 connect (view, SIGNAL(editEvent(const Event &)),
335 this, SIGNAL(editEvent(const Event &))); 335 this, SIGNAL(editEvent(const Event &)));
336 connect (view, SIGNAL(showDate(int,int,int)), 336 connect (view, SIGNAL(showDate(int,int,int)),
337 this, SIGNAL(showDate(int,int,int))); 337 this, SIGNAL(showDate(int,int,int)));
338 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 338 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
339 const QString &)), 339 const QString &)),
340 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 340 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
341 const QString &))); 341 const QString &)));
342 342
343 scroll->addChild(view); 343 scroll->addChild(view);
344 view->show(); 344 view->show();
345 scroll->updateScrollBars(); 345 scroll->updateScrollBars();
346} 346}
347 347
348void DateBookWeekLst::dateChanged(int y, int w) { 348void DateBookWeekLst::dateChanged(int y, int w) {
349 year=y; 349 year=y;
350 _week=w; 350 _week=w;
351 getEvents(); 351 getEvents();
352} 352}
353 353
354void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 354void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
355{ 355{
356 switch(e->key()) { 356 switch(e->key()) {
357 case Key_Up: 357 case Key_Up:
358 scroll->scrollBy(0, -20); 358 scroll->scrollBy(0, -20);
359 break; 359 break;
360 case Key_Down: 360 case Key_Down:
361 scroll->scrollBy(0, 20); 361 scroll->scrollBy(0, 20);
362 break; 362 break;
363 case Key_Left: 363 case Key_Left:
364 header->prevWeek(); 364 header->prevWeek();
365 break; 365 break;
366 case Key_Right: 366 case Key_Right:
367 header->nextWeek(); 367 header->nextWeek();
368 break; 368 break;
369 default: 369 default:
370 e->ignore(); 370 e->ignore();
371 } 371 }
372} 372}
373 373