author | umopapisdn <umopapisdn> | 2003-05-05 21:44:39 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-05-05 21:44:39 (UTC) |
commit | 3b193b852133a82b5c1708b68a7e460c63629768 (patch) (unidiff) | |
tree | 8cd0ff3adc14f0b937d24ab99fca327fb3f16875 /core/pim/datebook/datebookweeklst.cpp | |
parent | 12a700f8903eedeba03d3aba7990b9d660410045 (diff) | |
download | opie-3b193b852133a82b5c1708b68a7e460c63629768.zip opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.gz opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.bz2 |
UI and code cleanup. Both UI and code is now more consistent. Also removed menus in favor of toolbuttons. (why were they even available as menus in the first place?)
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 212 |
1 files changed, 110 insertions, 102 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 3c8fc89..a39ff40 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -6,157 +6,169 @@ | |||
6 | 6 | ||
7 | #include <qpe/calendar.h> | 7 | #include <qpe/calendar.h> |
8 | #include <qpe/datebookdb.h> | 8 | #include <qpe/datebookdb.h> |
9 | #include <qpe/event.h> | 9 | #include <qpe/event.h> |
10 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
11 | #include <qpe/timestring.h> | 11 | #include <qpe/timestring.h> |
12 | #include <qpe/datebookmonth.h> | 12 | #include <qpe/datebookmonth.h> |
13 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | #include <qdatetime.h> | 16 | #include <qdatetime.h> |
17 | #include <qheader.h> | 17 | #include <qheader.h> |
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qpainter.h> | 20 | #include <qpainter.h> |
21 | #include <qpopupmenu.h> | 21 | #include <qpopupmenu.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qstyle.h> | 23 | #include <qstyle.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qsizepolicy.h> | 26 | #include <qsizepolicy.h> |
27 | #include <qabstractlayout.h> | 27 | #include <qabstractlayout.h> |
28 | #include <qtl.h> | 28 | #include <qtl.h> |
29 | 29 | ||
30 | bool calcWeek(const QDate &d, int &week, int &year, | 30 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); |
31 | bool startOnMonday = false); | ||
32 | 31 | ||
33 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, | 32 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) |
34 | const char* name, WFlags fl) | ||
35 | : DateBookWeekLstHeaderBase(parent, name, fl) | 33 | : DateBookWeekLstHeaderBase(parent, name, fl) |
36 | { | 34 | { |
37 | setBackgroundMode( PaletteButton ); | 35 | setBackgroundMode( PaletteButton ); |
38 | labelDate->setBackgroundMode( PaletteButton ); | 36 | labelDate->setBackgroundMode( PaletteButton ); |
39 | labelWeek->setBackgroundMode( PaletteButton ); | 37 | forwardweek->setBackgroundMode( PaletteButton ); |
40 | forward->setBackgroundMode( PaletteButton ); | 38 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); |
41 | forward->setPixmap( Resource::loadPixmap("forward") ); | 39 | forwardmonth->setBackgroundMode( PaletteButton ); |
42 | back->setBackgroundMode( PaletteButton ); | 40 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); |
43 | back->setPixmap( Resource::loadPixmap("back") ); | 41 | backweek->setBackgroundMode( PaletteButton ); |
44 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | 42 | backweek->setPixmap( Resource::loadPixmap("back") ); |
45 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | 43 | backmonth->setBackgroundMode( PaletteButton ); |
46 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | 44 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); |
47 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 45 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); |
48 | 46 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | |
49 | connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); | 47 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); |
50 | connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); | 48 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
51 | connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); | 49 | |
52 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | 50 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); |
53 | onMonday=onM; | 51 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); |
52 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | ||
53 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | ||
54 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | ||
55 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | ||
56 | bStartOnMonday=onM; | ||
54 | } | 57 | } |
55 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 58 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
59 | |||
56 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 60 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
57 | date=d; | 61 | int year,week,dayofweek; |
58 | 62 | date=d; | |
59 | int year,week; | 63 | dayofweek=d.dayOfWeek(); |
60 | calcWeek(d,week,year,onMonday); | 64 | if(bStartOnMonday) dayofweek--; |
61 | labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) ); | 65 | date=date.addDays(-dayofweek); |
62 | 66 | ||
63 | QDate start=date; | 67 | calcWeek(date,week,year,bStartOnMonday); |
64 | QDate stop=start.addDays(6); | 68 | QDate start=date; |
65 | labelDate->setText( QString::number(start.day()) + " " + | 69 | QDate stop=start.addDays(6); |
66 | start.monthName(start.month()) + " - " + | 70 | labelDate->setText( QString::number(start.day()) + "." + |
67 | QString::number(stop.day()) + " " + | 71 | start.monthName(start.month()) + "-" + |
68 | start.monthName(stop.month()) ); | 72 | QString::number(stop.day()) + "." + |
69 | emit dateChanged(year,week); | 73 | start.monthName(stop.month()) +" ("+ |
74 | tr("w")+":"+QString::number( week ) +")"); | ||
75 | emit dateChanged(year,week); | ||
70 | } | 76 | } |
77 | |||
71 | void DateBookWeekLstHeader::pickDate() { | 78 | void DateBookWeekLstHeader::pickDate() { |
72 | static QPopupMenu *m1 = 0; | 79 | static QPopupMenu *m1 = 0; |
73 | static DateBookMonth *picker = 0; | 80 | static DateBookMonth *picker = 0; |
74 | if ( !m1 ) { | 81 | if ( !m1 ) { |
75 | m1 = new QPopupMenu( this ); | 82 | m1 = new QPopupMenu( this ); |
76 | picker = new DateBookMonth( m1, 0, TRUE ); | 83 | picker = new DateBookMonth( m1, 0, TRUE ); |
77 | m1->insertItem( picker ); | 84 | m1->insertItem( picker ); |
78 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 85 | connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); |
79 | this, SLOT( setDate( int, int, int ) ) ); | 86 | //connect( m1, SIGNAL( aboutToHide() ), |
80 | //connect( m1, SIGNAL( aboutToHide() ), | 87 | //this, SLOT( gotHide() ) ); |
81 | //this, SLOT( gotHide() ) ); | 88 | } |
82 | } | 89 | picker->setDate( date.year(), date.month(), date.day() ); |
83 | picker->setDate( date.year(), date.month(), date.day() ); | 90 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
84 | m1->popup(mapToGlobal(labelWeek->pos()+QPoint(0,labelWeek->height()))); | 91 | picker->setFocus(); |
85 | picker->setFocus(); | ||
86 | } | 92 | } |
87 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 93 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { |
88 | QDate new_date(y,m,d); | 94 | setDate(QDate(y,m,d)); |
89 | setDate(new_date); | ||
90 | } | 95 | } |
91 | 96 | ||
92 | void DateBookWeekLstHeader::nextWeek() { | 97 | void DateBookWeekLstHeader::nextWeek() { |
93 | setDate(date.addDays(7)); | 98 | setDate(date.addDays(7)); |
94 | } | 99 | } |
95 | void DateBookWeekLstHeader::prevWeek() { | 100 | void DateBookWeekLstHeader::prevWeek() { |
96 | setDate(date.addDays(-7)); | 101 | setDate(date.addDays(-7)); |
102 | } | ||
103 | void DateBookWeekLstHeader::nextMonth() | ||
104 | { | ||
105 | setDate(date.addDays(28)); | ||
106 | } | ||
107 | void DateBookWeekLstHeader::prevMonth() | ||
108 | { | ||
109 | setDate(date.addDays(-28)); | ||
97 | } | 110 | } |
98 | 111 | ||
99 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, | 112 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, |
100 | QWidget* parent, | 113 | QWidget* parent, |
101 | const char* name, | 114 | const char* name, |
102 | WFlags fl ) | 115 | WFlags fl ) |
103 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 116 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
104 | 117 | ||
105 | date=d; | 118 | date=d; |
106 | 119 | ||
107 | static const char *wdays={"MTWTFSS"}; | 120 | static const char *wdays={"MTWTFSS"}; |
108 | char day=wdays[d.dayOfWeek()-1]; | 121 | char day=wdays[d.dayOfWeek()-1]; |
109 | 122 | ||
110 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " + | 123 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
111 | QString::number(d.day()) ); | 124 | add->setText("+"); |
112 | add->setText("+"); | 125 | |
113 | 126 | if (d == QDate::currentDate()) { | |
114 | if (d == QDate::currentDate()) { | 127 | QPalette pal=label->palette(); |
115 | QPalette pal=label->palette(); | 128 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); |
116 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | 129 | label->setPalette(pal); |
117 | label->setPalette(pal); | 130 | |
118 | 131 | /* | |
119 | /* | 132 | QFont f=label->font(); |
120 | QFont f=label->font(); | 133 | f.setItalic(true); |
121 | f.setItalic(true); | 134 | label->setFont(f); |
122 | label->setFont(f); | 135 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); |
123 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); | 136 | */ |
124 | */ | 137 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday |
125 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday | 138 | QPalette pal=label->palette(); |
126 | QPalette pal=label->palette(); | 139 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); |
127 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); | 140 | label->setPalette(pal); |
128 | label->setPalette(pal); | 141 | } |
129 | } | ||
130 | |||
131 | 142 | ||
132 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); | 143 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); |
133 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); | 144 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); |
134 | } | 145 | } |
135 | 146 | ||
136 | void DateBookWeekLstDayHdr::showDay() { | 147 | void DateBookWeekLstDayHdr::showDay() { |
137 | emit showDate(date.year(), date.month(), date.day()); | 148 | emit showDate(date.year(), date.month(), date.day()); |
138 | } | 149 | } |
150 | |||
139 | void DateBookWeekLstDayHdr::newEvent() { | 151 | void DateBookWeekLstDayHdr::newEvent() { |
140 | QDateTime start, stop; | 152 | QDateTime start, stop; |
141 | start=stop=date; | 153 | start=stop=date; |
142 | start.setTime(QTime(10,0)); | 154 | start.setTime(QTime(10,0)); |
143 | stop.setTime(QTime(12,0)); | 155 | stop.setTime(QTime(12,0)); |
144 | 156 | ||
145 | emit addEvent(start,stop,"",0); | 157 | emit addEvent(start,stop,"",0); |
146 | } | 158 | } |
147 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 159 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, |
148 | int weeklistviewconfig, | 160 | int weeklistviewconfig, |
149 | QWidget* parent, | 161 | QWidget* parent, |
150 | const char* name, | 162 | const char* name, |
151 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | 163 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) |
152 | { | 164 | { |
153 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | 165 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", |
154 | QString s,start,middle,end,day; | 166 | QString s,start,middle,end,day; |
155 | 167 | ||
156 | qDebug("weeklistviewconfig=%d",weeklistviewconfig); | 168 | qDebug("weeklistviewconfig=%d",weeklistviewconfig); |
157 | if(weeklistviewconfig==NONE) {// No times displayed. | 169 | if(weeklistviewconfig==NONE) {// No times displayed. |
158 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 170 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
159 | // middle.sprintf("<--->"); | 171 | // middle.sprintf("<--->"); |
160 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 172 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); |
161 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 173 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); |
162 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. | 174 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. |
@@ -183,71 +195,70 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | |||
183 | } | 195 | } |
184 | } else { | 196 | } else { |
185 | s=""; | 197 | s=""; |
186 | } | 198 | } |
187 | setText(QString(s) + " " + ev.description()); | 199 | setText(QString(s) + " " + ev.description()); |
188 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 200 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
189 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 201 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
190 | } | 202 | } |
191 | void DateBookWeekLstEvent::editMe() { | 203 | void DateBookWeekLstEvent::editMe() { |
192 | emit editEvent(event.event()); | 204 | emit editEvent(event.event()); |
193 | } | 205 | } |
194 | 206 | ||
195 | 207 | ||
196 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 208 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
197 | const QDate &d, bool onM, | 209 | const QDate &d, bool onM, |
198 | QWidget* parent, | 210 | QWidget* parent, |
199 | const char* name, WFlags fl) | 211 | const char* name, WFlags fl) |
200 | : QWidget( parent, name, fl ) | 212 | : QWidget( parent, name, fl ) |
201 | { | 213 | { |
202 | Config config("DateBook"); | 214 | Config config("DateBook"); |
203 | config.setGroup("Main"); | 215 | config.setGroup("Main"); |
204 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 216 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
205 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); | 217 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); |
206 | 218 | ||
207 | onMonday=onM; | 219 | bStartOnMonday=onM; |
208 | setPalette(white); | 220 | setPalette(white); |
209 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 221 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
210 | 222 | ||
211 | QVBoxLayout *layout = new QVBoxLayout( this ); | 223 | QVBoxLayout *layout = new QVBoxLayout( this ); |
212 | 224 | ||
213 | qBubbleSort(ev); | 225 | qBubbleSort(ev); |
214 | QValueListIterator<EffectiveEvent> it; | 226 | QValueListIterator<EffectiveEvent> it; |
215 | it=ev.begin(); | 227 | it=ev.begin(); |
216 | 228 | ||
217 | int dayOrder[7]; | 229 | int dayOrder[7]; |
218 | if (onMonday) { | 230 | if (bStartOnMonday) { |
219 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 231 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
220 | } else { | 232 | } else { |
221 | for (int d=0; d<7; d++) dayOrder[d]=d; | 233 | for (int d=0; d<7; d++) dayOrder[d]=d; |
222 | dayOrder[0]=7; | 234 | dayOrder[0]=7; |
223 | } | 235 | } |
224 | 236 | ||
225 | for (int i=0; i<7; i++) { | 237 | for (int i=0; i<7; i++) { |
226 | // Header | 238 | // Header |
227 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this); | 239 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this); |
228 | connect(hdr, SIGNAL(showDate(int,int,int)), | 240 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
229 | this, SIGNAL(showDate(int,int,int))); | ||
230 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 241 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
231 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 242 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
232 | layout->addWidget(hdr); | 243 | layout->addWidget(hdr); |
233 | 244 | ||
234 | // Events | 245 | // Events |
235 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 246 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
236 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 247 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |
237 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | 248 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
238 | layout->addWidget(l); | 249 | layout->addWidget(l); |
239 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 250 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
240 | } | 251 | } |
241 | it++; | 252 | it++; |
242 | } | 253 | } |
243 | 254 | ||
244 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 255 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
245 | } | 256 | } |
246 | } | 257 | } |
247 | DateBookWeekLstView::~DateBookWeekLstView(){} | 258 | DateBookWeekLstView::~DateBookWeekLstView(){} |
248 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 259 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
249 | 260 | ||
250 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 261 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
251 | QValueList<EffectiveEvent> &ev2, | 262 | QValueList<EffectiveEvent> &ev2, |
252 | QDate &d, bool onM, | 263 | QDate &d, bool onM, |
253 | QWidget* parent, | 264 | QWidget* parent, |
@@ -258,133 +269,130 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | |||
258 | 269 | ||
259 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 270 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
260 | layout->addWidget(w); | 271 | layout->addWidget(w); |
261 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 272 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
262 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 273 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
263 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), | 274 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), |
264 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 275 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
265 | 276 | ||
266 | 277 | ||
267 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 278 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
268 | layout->addWidget(w); | 279 | layout->addWidget(w); |
269 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 280 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
270 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 281 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
271 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 282 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
272 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 283 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
273 | } | 284 | } |
274 | 285 | ||
275 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 286 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
276 | QWidget *parent, | 287 | QWidget *parent, |
277 | const char *name ) | 288 | const char *name ) |
278 | : QWidget( parent, name ), | 289 | : QWidget( parent, name ), |
279 | db( newDB ), | 290 | db( newDB ), |
280 | startTime( 0 ), | 291 | startTime( 0 ), |
281 | ampm( ap ), | 292 | ampm( ap ), |
282 | onMonday(onM) | 293 | bStartOnMonday(onM) |
283 | { | 294 | { |
284 | setFocusPolicy(StrongFocus); | 295 | setFocusPolicy(StrongFocus); |
285 | layout = new QVBoxLayout( this ); | 296 | layout = new QVBoxLayout( this ); |
286 | layout->setMargin(0); | 297 | layout->setMargin(0); |
287 | 298 | ||
288 | header=new DateBookWeekLstHeader(onM, this); | 299 | header=new DateBookWeekLstHeader(onM, this); |
289 | layout->addWidget( header ); | 300 | layout->addWidget( header ); |
290 | connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); | 301 | connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); |
291 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | 302 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
292 | 303 | ||
293 | scroll=new QScrollView(this); | 304 | scroll=new QScrollView(this); |
294 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); | ||
295 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); | ||
296 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 305 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
297 | layout->addWidget(scroll); | 306 | layout->addWidget(scroll); |
298 | 307 | ||
299 | view=NULL; | 308 | view=NULL; |
300 | Config config("DateBook"); | 309 | Config config("DateBook"); |
301 | config.setGroup("Main"); | 310 | config.setGroup("Main"); |
302 | dbl=config.readBoolEntry("weeklst_dbl", false); | 311 | dbl=config.readBoolEntry("weeklst_dbl", false); |
303 | header->dbl->setOn(dbl); | 312 | header->dbl->setOn(dbl); |
304 | } | 313 | } |
305 | DateBookWeekLst::~DateBookWeekLst(){ | 314 | DateBookWeekLst::~DateBookWeekLst(){ |
306 | Config config("DateBook"); | 315 | Config config("DateBook"); |
307 | config.setGroup("Main"); | 316 | config.setGroup("Main"); |
308 | config.writeEntry("weeklst_dbl", dbl); | 317 | config.writeEntry("weeklst_dbl", dbl); |
309 | } | 318 | } |
310 | 319 | ||
311 | void DateBookWeekLst::setDate(const QDate &d) { | 320 | void DateBookWeekLst::setDate(const QDate &d) { |
312 | int w,y; | 321 | int w,y; |
313 | calcWeek(d,w,y,onMonday); | 322 | calcWeek(d,w,y,bStartOnMonday); |
314 | year=y; | 323 | year=y; |
315 | _week=w; | 324 | _week=w; |
316 | header->setDate(date()); | 325 | header->setDate(date()); |
317 | } | 326 | } |
318 | void DateBookWeekLst::setDbl(bool on) { | 327 | void DateBookWeekLst::setDbl(bool on) { |
319 | dbl=on; | 328 | dbl=on; |
320 | redraw(); | 329 | redraw(); |
321 | } | 330 | } |
322 | void DateBookWeekLst::redraw() {getEvents();} | 331 | void DateBookWeekLst::redraw() {getEvents();} |
323 | 332 | ||
324 | QDate DateBookWeekLst::date() const { | 333 | QDate DateBookWeekLst::date() const { |
325 | QDate d; | 334 | QDate d; |
326 | d.setYMD(year,1,1); | 335 | d.setYMD(year,1,1); |
327 | 336 | ||
328 | int dow= d.dayOfWeek(); | 337 | int dow= d.dayOfWeek(); |
329 | if (!onMonday) | 338 | if (!bStartOnMonday) |
330 | if (dow==7) { | 339 | if (dow==7) { |
331 | dow=1; | 340 | dow=1; |
332 | } else { | 341 | } else { |
333 | dow++; | 342 | dow++; |
334 | } | 343 | } |
335 | 344 | ||
336 | d=d.addDays( (_week-1)*7 - dow + 1 ); | 345 | d=d.addDays( (_week-1)*7 - dow + 1 ); |
337 | return d; | 346 | return d; |
338 | } | 347 | } |
339 | 348 | ||
340 | void DateBookWeekLst::getEvents() { | 349 | void DateBookWeekLst::getEvents() { |
341 | QDate start = date(); | 350 | QDate start = date(); |
342 | QDate stop = start.addDays(6); | 351 | QDate stop = start.addDays(6); |
343 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 352 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
344 | 353 | ||
345 | if (view) delete view; | 354 | if (view) delete view; |
346 | if (dbl) { | 355 | if (dbl) { |
347 | QDate start2=start.addDays(7); | 356 | QDate start2=start.addDays(7); |
348 | stop=start2.addDays(6); | 357 | stop=start2.addDays(6); |
349 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 358 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
350 | view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); | 359 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
351 | } else { | 360 | } else { |
352 | view=new DateBookWeekLstView(el,start,onMonday,scroll); | 361 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); |
353 | } | 362 | } |
354 | 363 | ||
355 | connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 364 | connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
356 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 365 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
357 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 366 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
358 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 367 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
359 | 368 | ||
360 | scroll->addChild(view); | 369 | scroll->addChild(view); |
361 | view->show(); | 370 | view->show(); |
362 | scroll->updateScrollBars(); | 371 | scroll->updateScrollBars(); |
363 | } | 372 | } |
364 | 373 | ||
365 | void DateBookWeekLst::dateChanged(int y, int w) { | 374 | void DateBookWeekLst::dateChanged(int y, int w) { |
366 | year=y; | 375 | year=y; |
367 | _week=w; | 376 | _week=w; |
368 | getEvents(); | 377 | getEvents(); |
369 | } | 378 | } |
370 | 379 | ||
371 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 380 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
372 | { | 381 | { |
373 | switch(e->key()) { | 382 | switch(e->key()) { |
374 | case Key_Up: | 383 | case Key_Up: |
375 | scroll->scrollBy(0, -20); | 384 | scroll->scrollBy(0, -20); |
376 | break; | 385 | break; |
377 | case Key_Down: | 386 | case Key_Down: |
378 | scroll->scrollBy(0, 20); | 387 | scroll->scrollBy(0, 20); |
379 | break; | 388 | break; |
380 | case Key_Left: | 389 | case Key_Left: |
381 | header->prevWeek(); | 390 | header->prevWeek(); |
382 | break; | 391 | break; |
383 | case Key_Right: | 392 | case Key_Right: |
384 | header->nextWeek(); | 393 | header->nextWeek(); |
385 | break; | 394 | break; |
386 | default: | 395 | default: |
387 | e->ignore(); | 396 | e->ignore(); |
388 | } | 397 | } |
389 | } | 398 | } \ No newline at end of file |
390 | |||