Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 597 |
1 files changed, 299 insertions, 298 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 771aa00..0555bc7 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -3,4 +3,5 @@ | |||
3 | 3 | ||
4 | #include "datebook.h" | 4 | #include "datebook.h" |
5 | #include "datebooktypes.h" | ||
5 | 6 | ||
6 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
@@ -21,126 +22,126 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const ch | |||
21 | : DateBookWeekLstHeaderBase(parent, name, fl) | 22 | : DateBookWeekLstHeaderBase(parent, name, fl) |
22 | { | 23 | { |
23 | setBackgroundMode( PaletteButton ); | 24 | setBackgroundMode( PaletteButton ); |
24 | labelDate->setBackgroundMode( PaletteButton ); | 25 | labelDate->setBackgroundMode( PaletteButton ); |
25 | forwardweek->setBackgroundMode( PaletteButton ); | 26 | forwardweek->setBackgroundMode( PaletteButton ); |
26 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | 27 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); |
27 | forwardmonth->setBackgroundMode( PaletteButton ); | 28 | forwardmonth->setBackgroundMode( PaletteButton ); |
28 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | 29 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); |
29 | backweek->setBackgroundMode( PaletteButton ); | 30 | backweek->setBackgroundMode( PaletteButton ); |
30 | backweek->setPixmap( Resource::loadPixmap("back") ); | 31 | backweek->setPixmap( Resource::loadPixmap("back") ); |
31 | backmonth->setBackgroundMode( PaletteButton ); | 32 | backmonth->setBackgroundMode( PaletteButton ); |
32 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | 33 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); |
33 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | 34 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); |
34 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | 35 | DateBookWeekLstHeaderBaseLayout->setMargin(0); |
35 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | 36 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); |
36 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 37 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
37 | 38 | ||
38 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); | 39 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); |
39 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); | 40 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); |
40 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | 41 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); |
41 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | 42 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); |
42 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | 43 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); |
43 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | 44 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); |
44 | bStartOnMonday=onM; | 45 | bStartOnMonday=onM; |
45 | } | 46 | } |
46 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 47 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
47 | 48 | ||
48 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 49 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
49 | int year,week,dayofweek; | 50 | int year,week,dayofweek; |
50 | date=d; | 51 | date=d; |
51 | dayofweek=d.dayOfWeek(); | 52 | dayofweek=d.dayOfWeek(); |
52 | if(bStartOnMonday) | 53 | if(bStartOnMonday) |
53 | dayofweek--; | 54 | dayofweek--; |
54 | else if( dayofweek == 7 ) | 55 | else if( dayofweek == 7 ) |
55 | /* we already have the right day -7 would lead to the same week */ | 56 | /* we already have the right day -7 would lead to the same week */ |
56 | dayofweek = 0; | 57 | dayofweek = 0; |
57 | 58 | ||
58 | date=date.addDays(-dayofweek); | 59 | date=date.addDays(-dayofweek); |
59 | 60 | ||
60 | calcWeek(date,week,year,bStartOnMonday); | 61 | calcWeek(date,week,year,bStartOnMonday); |
61 | QDate start=date; | 62 | QDate start=date; |
62 | QDate stop=start.addDays(6); | 63 | QDate stop=start.addDays(6); |
63 | labelDate->setText( QString::number(start.day()) + "." + | 64 | labelDate->setText( QString::number(start.day()) + "." + |
64 | Calendar::nameOfMonth( start.month() ) + "-" + | 65 | Calendar::nameOfMonth( start.month() ) + "-" + |
65 | QString::number(stop.day()) + "." + | 66 | QString::number(stop.day()) + "." + |
66 | Calendar::nameOfMonth( stop.month()) +" ("+ | 67 | Calendar::nameOfMonth( stop.month()) +" ("+ |
67 | tr("w")+":"+QString::number( week ) +")"); | 68 | tr("w")+":"+QString::number( week ) +")"); |
68 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | 69 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! |
69 | emit dateChanged(date); | 70 | emit dateChanged(date); |
70 | } | 71 | } |
71 | 72 | ||
72 | void DateBookWeekLstHeader::pickDate() { | 73 | void DateBookWeekLstHeader::pickDate() { |
73 | static QPopupMenu *m1 = 0; | 74 | static QPopupMenu *m1 = 0; |
74 | static DateBookMonth *picker = 0; | 75 | static DateBookMonth *picker = 0; |
75 | if ( !m1 ) { | 76 | if ( !m1 ) { |
76 | m1 = new QPopupMenu( this ); | 77 | m1 = new QPopupMenu( this ); |
77 | picker = new DateBookMonth( m1, 0, TRUE ); | 78 | picker = new DateBookMonth( m1, 0, TRUE ); |
78 | m1->insertItem( picker ); | 79 | m1->insertItem( picker ); |
79 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); | 80 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); |
80 | //connect( m1, SIGNAL( aboutToHide() ), | 81 | //connect( m1, SIGNAL( aboutToHide() ), |
81 | //this, SLOT( gotHide() ) ); | 82 | //this, SLOT( gotHide() ) ); |
82 | } | 83 | } |
83 | picker->setDate( date.year(), date.month(), date.day() ); | 84 | picker->setDate( date.year(), date.month(), date.day() ); |
84 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | 85 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
85 | picker->setFocus(); | 86 | picker->setFocus(); |
86 | } | 87 | } |
87 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 88 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { |
88 | setDate(QDate(y,m,d)); | 89 | setDate(QDate(y,m,d)); |
89 | } | 90 | } |
90 | 91 | ||
91 | void DateBookWeekLstHeader::nextWeek() { | 92 | void DateBookWeekLstHeader::nextWeek() { |
92 | setDate(date.addDays(7)); | 93 | setDate(date.addDays(7)); |
93 | } | 94 | } |
94 | void DateBookWeekLstHeader::prevWeek() { | 95 | void DateBookWeekLstHeader::prevWeek() { |
95 | setDate(date.addDays(-7)); | 96 | setDate(date.addDays(-7)); |
96 | } | 97 | } |
97 | void DateBookWeekLstHeader::nextMonth() | 98 | void DateBookWeekLstHeader::nextMonth() |
98 | { | 99 | { |
99 | setDate(date.addDays(28)); | 100 | setDate(date.addDays(28)); |
100 | } | 101 | } |
101 | void DateBookWeekLstHeader::prevMonth() | 102 | void DateBookWeekLstHeader::prevMonth() |
102 | { | 103 | { |
103 | setDate(date.addDays(-28)); | 104 | setDate(date.addDays(-28)); |
104 | } | 105 | } |
105 | 106 | ||
106 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | 107 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, |
107 | QWidget* parent, | 108 | QWidget* parent, |
108 | const char* name, | 109 | const char* name, |
109 | WFlags fl ) | 110 | WFlags fl ) |
110 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 111 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
111 | 112 | ||
112 | date=d; | 113 | date=d; |
113 | 114 | ||
114 | static const QString wdays=tr("MTWTFSSM", "Week days"); | 115 | static const QString wdays=tr("MTWTFSSM", "Week days"); |
115 | char day=wdays[d.dayOfWeek()-1]; | 116 | char day=wdays[d.dayOfWeek()-1]; |
116 | 117 | ||
117 | //dont use dayOfWeek() to save space ! | 118 | //dont use dayOfWeek() to save space ! |
118 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | 119 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
119 | 120 | ||
120 | add->setText("+"); | 121 | add->setText("+"); |
121 | 122 | ||
122 | if (d == QDate::currentDate()) { | 123 | if (d == QDate::currentDate()) { |
123 | QPalette pal=label->palette(); | 124 | QPalette pal=label->palette(); |
124 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | 125 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); |
125 | label->setPalette(pal); | 126 | label->setPalette(pal); |
126 | 127 | ||
127 | /* | 128 | /* |
128 | QFont f=label->font(); | 129 | QFont f=label->font(); |
129 | f.setItalic(true); | 130 | f.setItalic(true); |
130 | label->setFont(f); | 131 | label->setFont(f); |
131 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); | 132 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); |
132 | */ | 133 | */ |
133 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday | 134 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday |
134 | QPalette pal=label->palette(); | 135 | QPalette pal=label->palette(); |
135 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); | 136 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); |
136 | label->setPalette(pal); | 137 | label->setPalette(pal); |
137 | } | 138 | } |
138 | 139 | ||
139 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); | 140 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); |
140 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); | 141 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); |
141 | } | 142 | } |
142 | 143 | ||
143 | void DateBookWeekLstDayHdr::showDay() { | 144 | void DateBookWeekLstDayHdr::showDay() { |
144 | emit showDate(date.year(), date.month(), date.day()); | 145 | emit showDate(date.year(), date.month(), date.day()); |
145 | } | 146 | } |
146 | 147 | ||
@@ -154,49 +155,49 @@ void DateBookWeekLstDayHdr::newEvent() { | |||
154 | } | 155 | } |
155 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 156 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, |
156 | int weeklistviewconfig, | 157 | int weeklistviewconfig, |
157 | QWidget* parent, | 158 | QWidget* parent, |
158 | const char* name, | 159 | const char* name, |
159 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | 160 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) |
160 | { | 161 | { |
161 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | 162 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", |
162 | QString s,start,middle,end,day; | 163 | QString s,start,middle,end,day; |
163 | 164 | ||
164 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; | 165 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; |
165 | if(weeklistviewconfig==NONE) {// No times displayed. | 166 | if(weeklistviewconfig==NONE) { // No times displayed. |
166 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 167 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
167 | // middle.sprintf("<--->"); | 168 | // middle.sprintf("<--->"); |
168 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 169 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); |
169 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 170 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); |
170 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. | 171 | } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. |
171 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 172 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
172 | middle.sprintf(" |---"); | 173 | middle.sprintf(" |---"); |
173 | end.sprintf("__|__"); | 174 | end.sprintf("__|__"); |
174 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 175 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
175 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. | 176 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. |
176 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 177 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
177 | middle.sprintf("<--->"); | 178 | middle.sprintf("<--->"); |
178 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 179 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); |
179 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 180 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); |
180 | } | 181 | } |
181 | 182 | ||
182 | if(ev.event().type() == Event::Normal) { | 183 | if(ev.event().type() == Event::Normal) { |
183 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. | 184 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. |
184 | s=day; | 185 | s=day; |
185 | } else if(ev.startDate()==ev.date()) {// start event. | 186 | } else if(ev.startDate()==ev.date()) { // start event. |
186 | s=start; | 187 | s=start; |
187 | } else if(ev.endDate()==ev.date()) { // end event. | 188 | } else if(ev.endDate()==ev.date()) { // end event. |
188 | s=end; | 189 | s=end; |
189 | } else {// middle day. | 190 | } else { // middle day. |
190 | s=middle; | 191 | s=middle; |
191 | } | 192 | } |
192 | } else { | 193 | } else { |
193 | s=""; | 194 | s=""; |
194 | } | 195 | } |
195 | setText(QString(s) + " " + ev.description()); | 196 | setText(QString(s) + " " + ev.description()); |
196 | //connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 197 | // connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
197 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 198 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
198 | } | 199 | } |
199 | void DateBookWeekLstEvent::editMe() { | 200 | void DateBookWeekLstEvent::editMe() { |
200 | emit editEvent(event.event()); | 201 | emit editEvent(event.event()); |
201 | } | 202 | } |
202 | void DateBookWeekLstEvent::duplicateMe() | 203 | void DateBookWeekLstEvent::duplicateMe() |
@@ -211,73 +212,73 @@ void DateBookWeekLstEvent::deleteMe() | |||
211 | void DateBookWeekLstEvent::beamMe() | 212 | void DateBookWeekLstEvent::beamMe() |
212 | { | 213 | { |
213 | emit beamEvent( event.event() ); | 214 | emit beamEvent( event.event() ); |
214 | } | 215 | } |
215 | void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) | 216 | void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) |
216 | { | 217 | { |
217 | popmenue = new QPopupMenu; | 218 | popmenue = new QPopupMenu; |
218 | popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); | 219 | popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); |
219 | popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); | 220 | popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); |
220 | popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); | 221 | popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); |
221 | if(Ir::supported()) | 222 | if(Ir::supported()) |
222 | popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); | 223 | popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); |
223 | popmenue->popup( mapToGlobal( e->pos() )); | 224 | popmenue->popup( mapToGlobal( e->pos() )); |
224 | } | 225 | } |
225 | 226 | ||
226 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 227 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
227 | const QDate &d, bool onM, | 228 | const QDate &d, bool onM, |
228 | QWidget* parent, | 229 | QWidget* parent, |
229 | const char* name, WFlags fl) | 230 | const char* name, WFlags fl) |
230 | : QWidget( parent, name, fl ) | 231 | : QWidget( parent, name, fl ) |
231 | { | 232 | { |
232 | Config config("DateBook"); | 233 | Config config("DateBook"); |
233 | config.setGroup("Main"); | 234 | config.setGroup("Main"); |
234 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 235 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
235 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; | 236 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; |
236 | 237 | ||
237 | bStartOnMonday=onM; | 238 | bStartOnMonday=onM; |
238 | setPalette(white); | 239 | setPalette(white); |
239 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 240 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
240 | 241 | ||
241 | QVBoxLayout *layout = new QVBoxLayout( this ); | 242 | QVBoxLayout *layout = new QVBoxLayout( this ); |
242 | 243 | ||
243 | qBubbleSort(ev); | 244 | qBubbleSort(ev); |
244 | QValueListIterator<EffectiveEvent> it; | 245 | QValueListIterator<EffectiveEvent> it; |
245 | it=ev.begin(); | 246 | it=ev.begin(); |
246 | 247 | ||
247 | int dayOrder[7]; | 248 | int dayOrder[7]; |
248 | if (bStartOnMonday) { | 249 | if (bStartOnMonday) { |
249 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 250 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
250 | } else { | 251 | } else { |
251 | for (int d=0; d<7; d++) dayOrder[d]=d; | 252 | for (int d=0; d<7; d++) dayOrder[d]=d; |
252 | dayOrder[0]=7; | 253 | dayOrder[0]=7; |
253 | } | 254 | } |
254 | 255 | ||
255 | // Calculate offset to first day of week. | 256 | // Calculate offset to first day of week. |
256 | int dayoffset=d.dayOfWeek(); | 257 | int dayoffset=d.dayOfWeek(); |
257 | if(bStartOnMonday) dayoffset--; | 258 | if(bStartOnMonday) dayoffset--; |
258 | else if( dayoffset == 7 ) dayoffset = 0; | 259 | else if( dayoffset == 7 ) dayoffset = 0; |
259 | 260 | ||
260 | for (int i=0; i<7; i++) { | 261 | for (int i=0; i<7; i++) { |
261 | // Header | 262 | // Header |
262 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | 263 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); |
263 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 264 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
264 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 265 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
265 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 266 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
266 | layout->addWidget(hdr); | 267 | layout->addWidget(hdr); |
267 | 268 | ||
268 | // Events | 269 | // Events |
269 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 270 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
270 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 271 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. |
271 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | 272 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
272 | layout->addWidget(l); | 273 | layout->addWidget(l); |
273 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 274 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
274 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 275 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
275 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 276 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
276 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 277 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
277 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); | 278 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); |
278 | } | 279 | } |
279 | it++; | 280 | it++; |
280 | } | 281 | } |
281 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 282 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
282 | } | 283 | } |
283 | } | 284 | } |
@@ -286,39 +287,39 @@ void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | |||
286 | 287 | ||
287 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 288 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
288 | QValueList<EffectiveEvent> &ev2, | 289 | QValueList<EffectiveEvent> &ev2, |
289 | QDate &d, bool onM, | 290 | QDate &d, bool onM, |
290 | QWidget* parent, | 291 | QWidget* parent, |
291 | const char* name, WFlags fl) | 292 | const char* name, WFlags fl) |
292 | : QWidget( parent, name, fl ) | 293 | : QWidget( parent, name, fl ) |
293 | { | 294 | { |
294 | QHBoxLayout *layout = new QHBoxLayout( this ); | 295 | QHBoxLayout *layout = new QHBoxLayout( this ); |
295 | 296 | ||
296 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 297 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
297 | layout->addWidget(w); | 298 | layout->addWidget(w); |
298 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 299 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
299 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 300 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
300 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 301 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
301 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 302 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
302 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | 303 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); |
303 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 304 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
304 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 305 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
305 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 306 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
306 | 307 | ||
307 | 308 | ||
308 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 309 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
309 | layout->addWidget(w); | 310 | layout->addWidget(w); |
310 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 311 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
311 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 312 | connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
312 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 313 | connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
313 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 314 | connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
314 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); | 315 | connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); |
315 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 316 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
316 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 317 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
317 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 318 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
318 | } | 319 | } |
319 | 320 | ||
320 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 321 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, |
321 | QWidget *parent, | 322 | QWidget *parent, |
322 | const char *name ) | 323 | const char *name ) |
323 | : QWidget( parent, name ), | 324 | : QWidget( parent, name ), |
324 | db( newDB ), | 325 | db( newDB ), |
@@ -327,42 +328,42 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | |||
327 | bStartOnMonday(onM) | 328 | bStartOnMonday(onM) |
328 | { | 329 | { |
329 | setFocusPolicy(StrongFocus); | 330 | setFocusPolicy(StrongFocus); |
330 | layout = new QVBoxLayout( this ); | 331 | layout = new QVBoxLayout( this ); |
331 | layout->setMargin(0); | 332 | layout->setMargin(0); |
332 | 333 | ||
333 | header=new DateBookWeekLstHeader(onM, this); | 334 | header=new DateBookWeekLstHeader(onM, this); |
334 | layout->addWidget( header ); | 335 | layout->addWidget( header ); |
335 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); | 336 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); |
336 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | 337 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
337 | 338 | ||
338 | scroll=new QScrollView(this); | 339 | scroll=new QScrollView(this); |
339 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 340 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
340 | layout->addWidget(scroll); | 341 | layout->addWidget(scroll); |
341 | 342 | ||
342 | view=NULL; | 343 | view=NULL; |
343 | Config config("DateBook"); | 344 | Config config("DateBook"); |
344 | config.setGroup("Main"); | 345 | config.setGroup("Main"); |
345 | dbl=config.readBoolEntry("weeklst_dbl", false); | 346 | dbl=config.readBoolEntry("weeklst_dbl", false); |
346 | header->dbl->setOn(dbl); | 347 | header->dbl->setOn(dbl); |
347 | } | 348 | } |
348 | DateBookWeekLst::~DateBookWeekLst(){ | 349 | DateBookWeekLst::~DateBookWeekLst(){ |
349 | Config config("DateBook"); | 350 | Config config("DateBook"); |
350 | config.setGroup("Main"); | 351 | config.setGroup("Main"); |
351 | config.writeEntry("weeklst_dbl", dbl); | 352 | config.writeEntry("weeklst_dbl", dbl); |
352 | } | 353 | } |
353 | 354 | ||
354 | void DateBookWeekLst::setDate(const QDate &d) { | 355 | void DateBookWeekLst::setDate(const QDate &d) { |
355 | bdate=d; | 356 | bdate=d; |
356 | header->setDate(d); | 357 | header->setDate(d); |
357 | } | 358 | } |
358 | 359 | ||
359 | void DateBookWeekLst::setDbl(bool on) { | 360 | void DateBookWeekLst::setDbl(bool on) { |
360 | dbl=on; | 361 | dbl=on; |
361 | redraw(); | 362 | redraw(); |
362 | } | 363 | } |
363 | void DateBookWeekLst::redraw() {getEvents();} | 364 | void DateBookWeekLst::redraw() {getEvents();} |
364 | 365 | ||
365 | QDate DateBookWeekLst::date() { | 366 | QDate DateBookWeekLst::date() { |
366 | return bdate; | 367 | return bdate; |
367 | } | 368 | } |
368 | 369 | ||
@@ -371,66 +372,66 @@ QDate DateBookWeekLst::date() { | |||
371 | QDate DateBookWeekLst::weekDate() const | 372 | QDate DateBookWeekLst::weekDate() const |
372 | { | 373 | { |
373 | QDate d=bdate; | 374 | QDate d=bdate; |
374 | 375 | ||
375 | // Calculate offset to first day of week. | 376 | // Calculate offset to first day of week. |
376 | int dayoffset=d.dayOfWeek(); | 377 | int dayoffset=d.dayOfWeek(); |
377 | if(bStartOnMonday) dayoffset--; | 378 | if(bStartOnMonday) dayoffset--; |
378 | else if( dayoffset == 7 ) | 379 | else if( dayoffset == 7 ) |
379 | dayoffset = 0; | 380 | dayoffset = 0; |
380 | 381 | ||
381 | return d.addDays(-dayoffset); | 382 | return d.addDays(-dayoffset); |
382 | } | 383 | } |
383 | 384 | ||
384 | void DateBookWeekLst::getEvents() { | 385 | void DateBookWeekLst::getEvents() { |
385 | QDate start = weekDate(); //date(); | 386 | QDate start = weekDate(); //date(); |
386 | QDate stop = start.addDays(6); | 387 | QDate stop = start.addDays(7); |
387 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 388 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
388 | 389 | ||
389 | if (view) delete view; | 390 | if (view) delete view; |
390 | if (dbl) { | 391 | if (dbl) { |
391 | QDate start2=start.addDays(7); | 392 | QDate start2=start.addDays(8); |
392 | stop=start2.addDays(6); | 393 | stop=start2.addDays(7); |
393 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 394 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
394 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 395 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
395 | } else { | 396 | } else { |
396 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | 397 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); |
397 | } | 398 | } |
398 | 399 | ||
399 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 400 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
400 | connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 401 | connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
401 | connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 402 | connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
402 | connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 403 | connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
403 | connect (view, SIGNAL(redraw()), this, SLOT(redraw())); | 404 | connect (view, SIGNAL(redraw()), this, SLOT(redraw())); |
404 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 405 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
405 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 406 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
406 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 407 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
407 | 408 | ||
408 | scroll->addChild(view); | 409 | scroll->addChild(view); |
409 | view->show(); | 410 | view->show(); |
410 | scroll->updateScrollBars(); | 411 | scroll->updateScrollBars(); |
411 | } | 412 | } |
412 | 413 | ||
413 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 414 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
414 | bdate=newdate; | 415 | bdate=newdate; |
415 | getEvents(); | 416 | getEvents(); |
416 | } | 417 | } |
417 | 418 | ||
418 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 419 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
419 | { | 420 | { |
420 | switch(e->key()) { | 421 | switch(e->key()) { |
421 | case Key_Up: | 422 | case Key_Up: |
422 | scroll->scrollBy(0, -20); | 423 | scroll->scrollBy(0, -20); |
423 | break; | 424 | break; |
424 | case Key_Down: | 425 | case Key_Down: |
425 | scroll->scrollBy(0, 20); | 426 | scroll->scrollBy(0, 20); |
426 | break; | 427 | break; |
427 | case Key_Left: | 428 | case Key_Left: |
428 | header->prevWeek(); | 429 | header->prevWeek(); |
429 | break; | 430 | break; |
430 | case Key_Right: | 431 | case Key_Right: |
431 | header->nextWeek(); | 432 | header->nextWeek(); |
432 | break; | 433 | break; |
433 | default: | 434 | default: |
434 | e->ignore(); | 435 | e->ignore(); |
435 | } | 436 | } |
436 | } | 437 | } |