author | cniehaus <cniehaus> | 2002-11-22 11:29:36 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-11-22 11:29:36 (UTC) |
commit | c185c4f9788a1e3882711efa1b1c11b17fb7ef1d (patch) (unidiff) | |
tree | 9f7858cefd87420f50478796239ad3e36414e6bf | |
parent | 480284c491e26427c630131a25e56f9ed1d129b2 (diff) | |
download | opie-c185c4f9788a1e3882711efa1b1c11b17fb7ef1d.zip opie-c185c4f9788a1e3882711efa1b1c11b17fb7ef1d.tar.gz opie-c185c4f9788a1e3882711efa1b1c11b17fb7ef1d.tar.bz2 |
This is the way tr() should be used. Now even RTL-languages and such
are supported
@@ -53,7 +53,7 @@ void DateBookWeekLstHeader::setDate(cons
int year,week;
calcWeek(d,week,year,onMonday);
- labelWeek->setText("W: " + QString::number(week));
+ labelWeek->setText(tr( "W: %1" ).arg( ( QString::number(week)) ) );
QDate start=date;
QDate stop=start.addDays(6);
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 5eefc27..7451abc 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -1,376 +1,376 @@ | |||
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 | ||
27 | bool calcWeek(const QDate &d, int &week, int &year, | 27 | bool calcWeek(const QDate &d, int &week, int &year, |
28 | bool startOnMonday = false); | 28 | bool startOnMonday = false); |
29 | 29 | ||
30 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, | 30 | DateBookWeekLstHeader::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 | } |
50 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 50 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
51 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 51 | void 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(tr( "W: %1" ).arg( ( 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 | } |
66 | void DateBookWeekLstHeader::pickDate() { | 66 | void 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 | } |
82 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 82 | void 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 | ||
87 | void DateBookWeekLstHeader::nextWeek() { | 87 | void DateBookWeekLstHeader::nextWeek() { |
88 | setDate(date.addDays(7)); | 88 | setDate(date.addDays(7)); |
89 | } | 89 | } |
90 | void DateBookWeekLstHeader::prevWeek() { | 90 | void DateBookWeekLstHeader::prevWeek() { |
91 | setDate(date.addDays(-7)); | 91 | setDate(date.addDays(-7)); |
92 | } | 92 | } |
93 | 93 | ||
94 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, | 94 | DateBookWeekLstDayHdr::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 | ||
131 | void DateBookWeekLstDayHdr::showDay() { | 131 | void DateBookWeekLstDayHdr::showDay() { |
132 | emit showDate(date.year(), date.month(), date.day()); | 132 | emit showDate(date.year(), date.month(), date.day()); |
133 | } | 133 | } |
134 | void DateBookWeekLstDayHdr::newEvent() { | 134 | void 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 | } |
142 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 142 | DateBookWeekLstEvent::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 | if(ev.event().type() == Event::Normal ) | 157 | if(ev.event().type() == Event::Normal ) |
158 | sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 158 | sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
159 | else | 159 | else |
160 | sprintf(s," "); | 160 | sprintf(s," "); |
161 | } | 161 | } |
162 | setText(QString(s) + " " + ev.description()); | 162 | setText(QString(s) + " " + ev.description()); |
163 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 163 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
164 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 164 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
165 | } | 165 | } |
166 | void DateBookWeekLstEvent::editMe() { | 166 | void DateBookWeekLstEvent::editMe() { |
167 | emit editEvent(event.event()); | 167 | emit editEvent(event.event()); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 171 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
172 | const QDate &d, bool onM, | 172 | const QDate &d, bool onM, |
173 | QWidget* parent, | 173 | QWidget* parent, |
174 | const char* name, WFlags fl) | 174 | const char* name, WFlags fl) |
175 | : QWidget( parent, name, fl ) | 175 | : QWidget( parent, name, fl ) |
176 | { | 176 | { |
177 | onMonday=onM; | 177 | onMonday=onM; |
178 | setPalette(white); | 178 | setPalette(white); |
179 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 179 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
180 | 180 | ||
181 | QVBoxLayout *layout = new QVBoxLayout( this ); | 181 | QVBoxLayout *layout = new QVBoxLayout( this ); |
182 | 182 | ||
183 | qBubbleSort(ev); | 183 | qBubbleSort(ev); |
184 | QValueListIterator<EffectiveEvent> it; | 184 | QValueListIterator<EffectiveEvent> it; |
185 | it=ev.begin(); | 185 | it=ev.begin(); |
186 | 186 | ||
187 | int dayOrder[7]; | 187 | int dayOrder[7]; |
188 | if (onMonday) | 188 | if (onMonday) |
189 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 189 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
190 | else { | 190 | else { |
191 | for (int d=0; d<7; d++) dayOrder[d]=d; | 191 | for (int d=0; d<7; d++) dayOrder[d]=d; |
192 | dayOrder[0]=7; | 192 | dayOrder[0]=7; |
193 | } | 193 | } |
194 | 194 | ||
195 | for (int i=0; i<7; i++) { | 195 | for (int i=0; i<7; i++) { |
196 | // Header | 196 | // Header |
197 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), | 197 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), |
198 | onMonday,this); | 198 | onMonday,this); |
199 | connect(hdr, SIGNAL(showDate(int,int,int)), | 199 | connect(hdr, SIGNAL(showDate(int,int,int)), |
200 | this, SIGNAL(showDate(int,int,int))); | 200 | this, SIGNAL(showDate(int,int,int))); |
201 | connect(hdr, SIGNAL(addEvent(const QDateTime &, | 201 | connect(hdr, SIGNAL(addEvent(const QDateTime &, |
202 | const QDateTime &, | 202 | const QDateTime &, |
203 | const QString &)), | 203 | const QString &)), |
204 | this, SIGNAL(addEvent(const QDateTime &, | 204 | this, SIGNAL(addEvent(const QDateTime &, |
205 | const QDateTime &, | 205 | const QDateTime &, |
206 | const QString &))); | 206 | const QString &))); |
207 | layout->addWidget(hdr); | 207 | layout->addWidget(hdr); |
208 | 208 | ||
209 | // Events | 209 | // Events |
210 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 210 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
211 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); | 211 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); |
212 | layout->addWidget(l); | 212 | layout->addWidget(l); |
213 | connect (l, SIGNAL(editEvent(const Event &)), | 213 | connect (l, SIGNAL(editEvent(const Event &)), |
214 | this, SIGNAL(editEvent(const Event &))); | 214 | this, SIGNAL(editEvent(const Event &))); |
215 | it++; | 215 | it++; |
216 | } | 216 | } |
217 | 217 | ||
218 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 218 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | DateBookWeekLstView::~DateBookWeekLstView(){} | 221 | DateBookWeekLstView::~DateBookWeekLstView(){} |
222 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 222 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
223 | 223 | ||
224 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 224 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
225 | QValueList<EffectiveEvent> &ev2, | 225 | QValueList<EffectiveEvent> &ev2, |
226 | QDate &d, bool onM, | 226 | QDate &d, bool onM, |
227 | QWidget* parent, | 227 | QWidget* parent, |
228 | const char* name, WFlags fl) | 228 | const char* name, WFlags fl) |
229 | : QWidget( parent, name, fl ) | 229 | : QWidget( parent, name, fl ) |
230 | { | 230 | { |
231 | QHBoxLayout *layout = new QHBoxLayout( this ); | 231 | QHBoxLayout *layout = new QHBoxLayout( this ); |
232 | 232 | ||
233 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 233 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
234 | layout->addWidget(w); | 234 | layout->addWidget(w); |
235 | connect (w, SIGNAL(editEvent(const Event &)), | 235 | connect (w, SIGNAL(editEvent(const Event &)), |
236 | this, SIGNAL(editEvent(const Event &))); | 236 | this, SIGNAL(editEvent(const Event &))); |
237 | connect (w, SIGNAL(showDate(int,int,int)), | 237 | connect (w, SIGNAL(showDate(int,int,int)), |
238 | this, SIGNAL(showDate(int,int,int))); | 238 | this, SIGNAL(showDate(int,int,int))); |
239 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 239 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, |
240 | const QString &)), | 240 | const QString &)), |
241 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 241 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, |
242 | const QString &))); | 242 | const QString &))); |
243 | 243 | ||
244 | 244 | ||
245 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 245 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
246 | layout->addWidget(w); | 246 | layout->addWidget(w); |
247 | connect (w, SIGNAL(editEvent(const Event &)), | 247 | connect (w, SIGNAL(editEvent(const Event &)), |
248 | this, SIGNAL(editEvent(const Event &))); | 248 | this, SIGNAL(editEvent(const Event &))); |
249 | connect (w, SIGNAL(showDate(int,int,int)), | 249 | connect (w, SIGNAL(showDate(int,int,int)), |
250 | this, SIGNAL(showDate(int,int,int))); | 250 | this, SIGNAL(showDate(int,int,int))); |
251 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 251 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, |
252 | const QString &)), | 252 | const QString &)), |
253 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 253 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, |
254 | const QString &))); | 254 | const QString &))); |
255 | } | 255 | } |
256 | 256 | ||
257 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 257 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
258 | QWidget *parent, | 258 | QWidget *parent, |
259 | const char *name ) | 259 | const char *name ) |
260 | : QWidget( parent, name ), | 260 | : QWidget( parent, name ), |
261 | db( newDB ), | 261 | db( newDB ), |
262 | startTime( 0 ), | 262 | startTime( 0 ), |
263 | ampm( ap ), | 263 | ampm( ap ), |
264 | onMonday(onM) | 264 | onMonday(onM) |
265 | { | 265 | { |
266 | setFocusPolicy(StrongFocus); | 266 | setFocusPolicy(StrongFocus); |
267 | layout = new QVBoxLayout( this ); | 267 | layout = new QVBoxLayout( this ); |
268 | layout->setMargin(0); | 268 | layout->setMargin(0); |
269 | 269 | ||
270 | header=new DateBookWeekLstHeader(onM, this); | 270 | header=new DateBookWeekLstHeader(onM, this); |
271 | layout->addWidget( header ); | 271 | layout->addWidget( header ); |
272 | connect(header, SIGNAL(dateChanged(int,int)), | 272 | connect(header, SIGNAL(dateChanged(int,int)), |
273 | this, SLOT(dateChanged(int,int))); | 273 | this, SLOT(dateChanged(int,int))); |
274 | connect(header, SIGNAL(setDbl(bool)), | 274 | connect(header, SIGNAL(setDbl(bool)), |
275 | this, SLOT(setDbl(bool))); | 275 | this, SLOT(setDbl(bool))); |
276 | 276 | ||
277 | scroll=new QScrollView(this); | 277 | scroll=new QScrollView(this); |
278 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); | 278 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); |
279 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); | 279 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); |
280 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 280 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
281 | layout->addWidget(scroll); | 281 | layout->addWidget(scroll); |
282 | 282 | ||
283 | view=NULL; | 283 | view=NULL; |
284 | Config config("DateBook"); | 284 | Config config("DateBook"); |
285 | config.setGroup("Main"); | 285 | config.setGroup("Main"); |
286 | dbl=config.readBoolEntry("weeklst_dbl", false); | 286 | dbl=config.readBoolEntry("weeklst_dbl", false); |
287 | header->dbl->setOn(dbl); | 287 | header->dbl->setOn(dbl); |
288 | } | 288 | } |
289 | DateBookWeekLst::~DateBookWeekLst(){ | 289 | DateBookWeekLst::~DateBookWeekLst(){ |
290 | Config config("DateBook"); | 290 | Config config("DateBook"); |
291 | config.setGroup("Main"); | 291 | config.setGroup("Main"); |
292 | config.writeEntry("weeklst_dbl", dbl); | 292 | config.writeEntry("weeklst_dbl", dbl); |
293 | } | 293 | } |
294 | 294 | ||
295 | void DateBookWeekLst::setDate(const QDate &d) { | 295 | void DateBookWeekLst::setDate(const QDate &d) { |
296 | int w,y; | 296 | int w,y; |
297 | calcWeek(d,w,y,onMonday); | 297 | calcWeek(d,w,y,onMonday); |
298 | year=y; | 298 | year=y; |
299 | _week=w; | 299 | _week=w; |
300 | header->setDate(date()); | 300 | header->setDate(date()); |
301 | } | 301 | } |
302 | void DateBookWeekLst::setDbl(bool on) { | 302 | void DateBookWeekLst::setDbl(bool on) { |
303 | dbl=on; | 303 | dbl=on; |
304 | redraw(); | 304 | redraw(); |
305 | } | 305 | } |
306 | void DateBookWeekLst::redraw() {getEvents();} | 306 | void DateBookWeekLst::redraw() {getEvents();} |
307 | 307 | ||
308 | QDate DateBookWeekLst::date() const { | 308 | QDate DateBookWeekLst::date() const { |
309 | QDate d; | 309 | QDate d; |
310 | d.setYMD(year,1,1); | 310 | d.setYMD(year,1,1); |
311 | 311 | ||
312 | int dow= d.dayOfWeek(); | 312 | int dow= d.dayOfWeek(); |
313 | if (!onMonday) | 313 | if (!onMonday) |
314 | if (dow==7) dow=1; | 314 | if (dow==7) dow=1; |
315 | else dow++; | 315 | else dow++; |
316 | 316 | ||
317 | d=d.addDays( (_week-1)*7 - dow + 1 ); | 317 | d=d.addDays( (_week-1)*7 - dow + 1 ); |
318 | return d; | 318 | return d; |
319 | } | 319 | } |
320 | 320 | ||
321 | void DateBookWeekLst::getEvents() { | 321 | void DateBookWeekLst::getEvents() { |
322 | QDate start = date(); | 322 | QDate start = date(); |
323 | QDate stop = start.addDays(6); | 323 | QDate stop = start.addDays(6); |
324 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 324 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
325 | 325 | ||
326 | if (view) delete view; | 326 | if (view) delete view; |
327 | if (dbl) { | 327 | if (dbl) { |
328 | QDate start2=start.addDays(7); | 328 | QDate start2=start.addDays(7); |
329 | stop=start2.addDays(6); | 329 | stop=start2.addDays(6); |
330 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 330 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
331 | 331 | ||
332 | view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); | 332 | view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); |
333 | } else { | 333 | } else { |
334 | view=new DateBookWeekLstView(el,start,onMonday,scroll); | 334 | view=new DateBookWeekLstView(el,start,onMonday,scroll); |
335 | } | 335 | } |
336 | 336 | ||
337 | connect (view, SIGNAL(editEvent(const Event &)), | 337 | connect (view, SIGNAL(editEvent(const Event &)), |
338 | this, SIGNAL(editEvent(const Event &))); | 338 | this, SIGNAL(editEvent(const Event &))); |
339 | connect (view, SIGNAL(showDate(int,int,int)), | 339 | connect (view, SIGNAL(showDate(int,int,int)), |
340 | this, SIGNAL(showDate(int,int,int))); | 340 | this, SIGNAL(showDate(int,int,int))); |
341 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 341 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, |
342 | const QString &)), | 342 | const QString &)), |
343 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 343 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, |
344 | const QString &))); | 344 | const QString &))); |
345 | 345 | ||
346 | scroll->addChild(view); | 346 | scroll->addChild(view); |
347 | view->show(); | 347 | view->show(); |
348 | scroll->updateScrollBars(); | 348 | scroll->updateScrollBars(); |
349 | } | 349 | } |
350 | 350 | ||
351 | void DateBookWeekLst::dateChanged(int y, int w) { | 351 | void DateBookWeekLst::dateChanged(int y, int w) { |
352 | year=y; | 352 | year=y; |
353 | _week=w; | 353 | _week=w; |
354 | getEvents(); | 354 | getEvents(); |
355 | } | 355 | } |
356 | 356 | ||
357 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 357 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
358 | { | 358 | { |
359 | switch(e->key()) { | 359 | switch(e->key()) { |
360 | case Key_Up: | 360 | case Key_Up: |
361 | scroll->scrollBy(0, -20); | 361 | scroll->scrollBy(0, -20); |
362 | break; | 362 | break; |
363 | case Key_Down: | 363 | case Key_Down: |
364 | scroll->scrollBy(0, 20); | 364 | scroll->scrollBy(0, 20); |
365 | break; | 365 | break; |
366 | case Key_Left: | 366 | case Key_Left: |
367 | header->prevWeek(); | 367 | header->prevWeek(); |
368 | break; | 368 | break; |
369 | case Key_Right: | 369 | case Key_Right: |
370 | header->nextWeek(); | 370 | header->nextWeek(); |
371 | break; | 371 | break; |
372 | default: | 372 | default: |
373 | e->ignore(); | 373 | e->ignore(); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | 376 | ||