-rw-r--r-- | libkdepim/kdatepicker.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp index 6cb432b..5d83511 100644 --- a/libkdepim/kdatepicker.cpp +++ b/libkdepim/kdatepicker.cpp | |||
@@ -1,325 +1,325 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | 3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) |
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | 4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) |
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "kdatepicker.h" | 21 | #include "kdatepicker.h" |
22 | #include <kglobal.h> | 22 | #include <kglobal.h> |
23 | #include <kapplication.h> | 23 | #include <kapplication.h> |
24 | #include <klocale.h> | 24 | #include <klocale.h> |
25 | #include <kiconloader.h> | 25 | #include <kiconloader.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qfont.h> | 30 | #include <qfont.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qvalidator.h> | 33 | #include <qvalidator.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <knotifyclient.h> | 35 | #include <knotifyclient.h> |
36 | #include <kglobalsettings.h> | 36 | #include <kglobalsettings.h> |
37 | #include "kdatetbl.h" | 37 | #include "kdatetbl.h" |
38 | #include "kdateedit.h" | 38 | #include "kdateedit.h" |
39 | //#include "kdatepicker.moc" | 39 | //#include "kdatepicker.moc" |
40 | 40 | ||
41 | 41 | ||
42 | KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) | 42 | KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) |
43 | : QFrame(parent,name), | 43 | : QFrame(parent,name), |
44 | yearForward(new QToolButton(this)), | 44 | yearForward(new QToolButton(this)), |
45 | yearBackward(new QToolButton(this)), | 45 | yearBackward(new QToolButton(this)), |
46 | monthForward(new QToolButton(this)), | 46 | monthForward(new QToolButton(this)), |
47 | monthBackward(new QToolButton(this)), | 47 | monthBackward(new QToolButton(this)), |
48 | selectMonth(new QToolButton(this)), | 48 | selectMonth(new QToolButton(this)), |
49 | selectYear(new QToolButton(this)), | 49 | selectYear(new QToolButton(this)), |
50 | todayBut(new QToolButton(this)), | 50 | todayBut(new QToolButton(this)), |
51 | //line(new QLineEdit(this)), | 51 | //line(new QLineEdit(this)), |
52 | val(new KDateValidator(this)) | 52 | val(new KDateValidator(this)) |
53 | //table(new KDateTable(this)), | 53 | //table(new KDateTable(this)), |
54 | //fontsize(1) | 54 | //fontsize(1) |
55 | { | 55 | { |
56 | QFont fo = KGlobalSettings::generalFont(); | 56 | QFont fo = KGlobalSettings::generalFont(); |
57 | int add = 2; | 57 | int add = 2; |
58 | if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) | 58 | if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) |
59 | add += 4; | 59 | add += 4; |
60 | fo.setPointSize(fo.pointSize()+add ); | 60 | fo.setPointSize(fo.pointSize()+add ); |
61 | setFont( fo ); | 61 | setFont( fo ); |
62 | table = new KDateTable(this); | 62 | table = new KDateTable(this); |
63 | setFontSize(font().pointSize()); | 63 | setFontSize(font().pointSize()); |
64 | //line->setValidator(val); | 64 | //line->setValidator(val); |
65 | lineDate = new KDateEdit( this, "dateediipicker", true ); | 65 | lineDate = new KDateEdit( this, "dateediipicker", true ); |
66 | yearForward->setPixmap(SmallIcon("2rightarrowB")); | 66 | yearForward->setPixmap(SmallIcon("3rightarrowB")); |
67 | yearBackward->setPixmap(SmallIcon("2leftarrowB")); | 67 | yearBackward->setPixmap(SmallIcon("3leftarrowB")); |
68 | monthForward->setPixmap(SmallIcon("1rightarrowB")); | 68 | monthForward->setPixmap(SmallIcon("2rightarrowB")); |
69 | monthBackward->setPixmap(SmallIcon("1leftarrowB")); | 69 | monthBackward->setPixmap(SmallIcon("2leftarrowB")); |
70 | todayBut->setPixmap(SmallIcon("today")); | 70 | todayBut->setPixmap(SmallIcon("today")); |
71 | setDate(dt); // set button texts | 71 | setDate(dt); // set button texts |
72 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); | 72 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); |
73 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); | 73 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); |
74 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); | 74 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); |
75 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); | 75 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); |
76 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); | 76 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); |
77 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); | 77 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); |
78 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); | 78 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); |
79 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); | 79 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); |
80 | connect(todayBut, SIGNAL(clicked()), SLOT(goToday())); | 80 | connect(todayBut, SIGNAL(clicked()), SLOT(goToday())); |
81 | //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | 81 | //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); |
82 | connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); | 82 | connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); |
83 | connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | 83 | connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); |
84 | table->setFocus(); | 84 | table->setFocus(); |
85 | 85 | ||
86 | } | 86 | } |
87 | 87 | ||
88 | KDatePicker::~KDatePicker() | 88 | KDatePicker::~KDatePicker() |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | void | 92 | void |
93 | KDatePicker::resizeEvent(QResizeEvent*) | 93 | KDatePicker::resizeEvent(QResizeEvent*) |
94 | { | 94 | { |
95 | QWidget *buttons[] = { | 95 | QWidget *buttons[] = { |
96 | yearBackward, | 96 | yearBackward, |
97 | monthBackward, | 97 | monthBackward, |
98 | selectMonth, | 98 | selectMonth, |
99 | selectYear, | 99 | selectYear, |
100 | monthForward, | 100 | monthForward, |
101 | yearForward }; | 101 | yearForward }; |
102 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | 102 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); |
103 | QSize sizes[NoOfButtons]; | 103 | QSize sizes[NoOfButtons]; |
104 | int buttonHeight=0; | 104 | int buttonHeight=0; |
105 | int count; | 105 | int count; |
106 | int w; | 106 | int w; |
107 | int x=0; | 107 | int x=0; |
108 | // ----- calculate button row height: | 108 | // ----- calculate button row height: |
109 | for(count=0; count<NoOfButtons; ++count) { | 109 | for(count=0; count<NoOfButtons; ++count) { |
110 | int xS = buttons[count]->sizeHint().width(); | 110 | int xS = buttons[count]->sizeHint().width(); |
111 | int yS = buttons[count]->sizeHint().height(); | 111 | int yS = buttons[count]->sizeHint().height(); |
112 | if ( QApplication::desktop()->width() < 320 ) | 112 | if ( QApplication::desktop()->width() < 320 ) |
113 | sizes[count]=QSize ( xS+4, yS ); | 113 | sizes[count]=QSize ( xS+4, yS ); |
114 | else | 114 | else |
115 | sizes[count]=QSize ( xS+10, yS ); | 115 | sizes[count]=QSize ( xS+10, yS ); |
116 | 116 | ||
117 | buttonHeight=QMAX(buttonHeight, sizes[count].height()); | 117 | buttonHeight=QMAX(buttonHeight, sizes[count].height()); |
118 | } | 118 | } |
119 | buttonHeight += 10; | 119 | buttonHeight += 10; |
120 | // ----- calculate size of the month button: | 120 | // ----- calculate size of the month button: |
121 | w=0; | 121 | w=0; |
122 | for(count=0; count<NoOfButtons; ++count) { | 122 | for(count=0; count<NoOfButtons; ++count) { |
123 | if(buttons[count]!=selectMonth) | 123 | if(buttons[count]!=selectMonth) |
124 | { | 124 | { |
125 | w+=sizes[count].width(); | 125 | w+=sizes[count].width(); |
126 | } else { | 126 | } else { |
127 | x=count; | 127 | x=count; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | sizes[x].setWidth(width()-w); // stretch the month button | 130 | sizes[x].setWidth(width()-w); // stretch the month button |
131 | // ----- place the buttons: | 131 | // ----- place the buttons: |
132 | x=0; | 132 | x=0; |
133 | for(count=0; count<NoOfButtons; ++count) | 133 | for(count=0; count<NoOfButtons; ++count) |
134 | { | 134 | { |
135 | w=sizes[count].width(); | 135 | w=sizes[count].width(); |
136 | buttons[count]->setGeometry(x, 0, w, buttonHeight); | 136 | buttons[count]->setGeometry(x, 0, w, buttonHeight); |
137 | x+=w; | 137 | x+=w; |
138 | } | 138 | } |
139 | // ----- place the line edit for direct input: | 139 | // ----- place the line edit for direct input: |
140 | sizes[0]=lineDate->sizeHint(); | 140 | sizes[0]=lineDate->sizeHint(); |
141 | //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); | 141 | //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); |
142 | int todaywid = todayBut->sizeHint().width(); | 142 | int todaywid = todayBut->sizeHint().width(); |
143 | todayBut->setGeometry(0, height()-sizes[0].height(),todaywid, sizes[0].height()); | 143 | todayBut->setGeometry(0, height()-sizes[0].height(),todaywid, sizes[0].height()); |
144 | lineDate->setGeometry(0+todaywid, height()-sizes[0].height(), width()-todaywid, sizes[0].height()); | 144 | lineDate->setGeometry(0+todaywid, height()-sizes[0].height(), width()-todaywid, sizes[0].height()); |
145 | // ----- adjust the table: | 145 | // ----- adjust the table: |
146 | table->setGeometry(0, buttonHeight, width(), | 146 | table->setGeometry(0, buttonHeight, width(), |
147 | height()-buttonHeight-sizes[0].height()); | 147 | height()-buttonHeight-sizes[0].height()); |
148 | } | 148 | } |
149 | 149 | ||
150 | void | 150 | void |
151 | KDatePicker::dateChangedSlot(QDate date) | 151 | KDatePicker::dateChangedSlot(QDate date) |
152 | { | 152 | { |
153 | lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true)); | 153 | lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true)); |
154 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 154 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
155 | emit(dateChanged(date)); | 155 | emit(dateChanged(date)); |
156 | } | 156 | } |
157 | 157 | ||
158 | void | 158 | void |
159 | KDatePicker::tableClickedSlot() | 159 | KDatePicker::tableClickedSlot() |
160 | { | 160 | { |
161 | 161 | ||
162 | emit(dateSelected(table->getDate())); | 162 | emit(dateSelected(table->getDate())); |
163 | emit(tableClicked()); | 163 | emit(tableClicked()); |
164 | } | 164 | } |
165 | 165 | ||
166 | const QDate& | 166 | const QDate& |
167 | KDatePicker::getDate() const | 167 | KDatePicker::getDate() const |
168 | { | 168 | { |
169 | return table->getDate(); | 169 | return table->getDate(); |
170 | } | 170 | } |
171 | 171 | ||
172 | const QDate & | 172 | const QDate & |
173 | KDatePicker::date() const | 173 | KDatePicker::date() const |
174 | { | 174 | { |
175 | return table->getDate(); | 175 | return table->getDate(); |
176 | } | 176 | } |
177 | 177 | ||
178 | void KDatePicker::goToday() | 178 | void KDatePicker::goToday() |
179 | { | 179 | { |
180 | slotSetDate( QDate::currentDate() ); | 180 | slotSetDate( QDate::currentDate() ); |
181 | 181 | ||
182 | } | 182 | } |
183 | void KDatePicker::slotSetDate( QDate date ) | 183 | void KDatePicker::slotSetDate( QDate date ) |
184 | { | 184 | { |
185 | 185 | ||
186 | if(date.isValid()) { | 186 | if(date.isValid()) { |
187 | QString temp; | 187 | QString temp; |
188 | // ----- | 188 | // ----- |
189 | table->setDate(date); | 189 | table->setDate(date); |
190 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); | 190 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); |
191 | temp.setNum(date.year()); | 191 | temp.setNum(date.year()); |
192 | selectYear->setText(temp); | 192 | selectYear->setText(temp); |
193 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 193 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
194 | lineDate->setDate( date ); | 194 | lineDate->setDate( date ); |
195 | } | 195 | } |
196 | 196 | ||
197 | } | 197 | } |
198 | bool | 198 | bool |
199 | KDatePicker::setDate(const QDate& date) | 199 | KDatePicker::setDate(const QDate& date) |
200 | { | 200 | { |
201 | table->setFocus(); | 201 | table->setFocus(); |
202 | if(date.isValid()) { | 202 | if(date.isValid()) { |
203 | QString temp; | 203 | QString temp; |
204 | // ----- | 204 | // ----- |
205 | table->setDate(date); | 205 | table->setDate(date); |
206 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); | 206 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); |
207 | temp.setNum(date.year()); | 207 | temp.setNum(date.year()); |
208 | selectYear->setText(temp); | 208 | selectYear->setText(temp); |
209 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 209 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
210 | lineDate->setDate( date ); | 210 | lineDate->setDate( date ); |
211 | return true; | 211 | return true; |
212 | } else { | 212 | } else { |
213 | 213 | ||
214 | return false; | 214 | return false; |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | } | 218 | } |
219 | 219 | ||
220 | void | 220 | void |
221 | KDatePicker::monthForwardClicked() | 221 | KDatePicker::monthForwardClicked() |
222 | { | 222 | { |
223 | QDate temp=table->getDate(); | 223 | QDate temp=table->getDate(); |
224 | int day=temp.day(); | 224 | int day=temp.day(); |
225 | // ----- | 225 | // ----- |
226 | if(temp.month()==12) { | 226 | if(temp.month()==12) { |
227 | temp.setYMD(temp.year()+1, 1, 1); | 227 | temp.setYMD(temp.year()+1, 1, 1); |
228 | } else { | 228 | } else { |
229 | temp.setYMD(temp.year(), temp.month()+1, 1); | 229 | temp.setYMD(temp.year(), temp.month()+1, 1); |
230 | } | 230 | } |
231 | if(temp.daysInMonth()<day) { | 231 | if(temp.daysInMonth()<day) { |
232 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 232 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
233 | } else { | 233 | } else { |
234 | temp.setYMD(temp.year(), temp.month(), day); | 234 | temp.setYMD(temp.year(), temp.month(), day); |
235 | } | 235 | } |
236 | // assert(temp.isValid()); | 236 | // assert(temp.isValid()); |
237 | setDate(temp); | 237 | setDate(temp); |
238 | } | 238 | } |
239 | 239 | ||
240 | void | 240 | void |
241 | KDatePicker::monthBackwardClicked() | 241 | KDatePicker::monthBackwardClicked() |
242 | { | 242 | { |
243 | QDate temp=table->getDate(); | 243 | QDate temp=table->getDate(); |
244 | int day=temp.day(); | 244 | int day=temp.day(); |
245 | // ----- | 245 | // ----- |
246 | if(temp.month()==1) | 246 | if(temp.month()==1) |
247 | { | 247 | { |
248 | temp.setYMD(temp.year()-1, 12, 1); | 248 | temp.setYMD(temp.year()-1, 12, 1); |
249 | } else { | 249 | } else { |
250 | temp.setYMD(temp.year(), temp.month()-1, 1); | 250 | temp.setYMD(temp.year(), temp.month()-1, 1); |
251 | } | 251 | } |
252 | if(temp.daysInMonth()<day) | 252 | if(temp.daysInMonth()<day) |
253 | { | 253 | { |
254 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 254 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
255 | } else { | 255 | } else { |
256 | temp.setYMD(temp.year(), temp.month(), day); | 256 | temp.setYMD(temp.year(), temp.month(), day); |
257 | } | 257 | } |
258 | // assert(temp.isValid()); | 258 | // assert(temp.isValid()); |
259 | setDate(temp); | 259 | setDate(temp); |
260 | } | 260 | } |
261 | 261 | ||
262 | void | 262 | void |
263 | KDatePicker::yearForwardClicked() | 263 | KDatePicker::yearForwardClicked() |
264 | { | 264 | { |
265 | QDate temp=table->getDate(); | 265 | QDate temp=table->getDate(); |
266 | int day=temp.day(); | 266 | int day=temp.day(); |
267 | // ----- | 267 | // ----- |
268 | temp.setYMD(temp.year()+1, temp.month(), 1); | 268 | temp.setYMD(temp.year()+1, temp.month(), 1); |
269 | if(temp.daysInMonth()<day) | 269 | if(temp.daysInMonth()<day) |
270 | { | 270 | { |
271 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 271 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
272 | } else { | 272 | } else { |
273 | temp.setYMD(temp.year(), temp.month(), day); | 273 | temp.setYMD(temp.year(), temp.month(), day); |
274 | } | 274 | } |
275 | // assert(temp.isValid()); | 275 | // assert(temp.isValid()); |
276 | setDate(temp); | 276 | setDate(temp); |
277 | } | 277 | } |
278 | 278 | ||
279 | void | 279 | void |
280 | KDatePicker::yearBackwardClicked() | 280 | KDatePicker::yearBackwardClicked() |
281 | { | 281 | { |
282 | QDate temp=table->getDate(); | 282 | QDate temp=table->getDate(); |
283 | int day=temp.day(); | 283 | int day=temp.day(); |
284 | // ----- | 284 | // ----- |
285 | temp.setYMD(temp.year()-1, temp.month(), 1); | 285 | temp.setYMD(temp.year()-1, temp.month(), 1); |
286 | if(temp.daysInMonth()<day) | 286 | if(temp.daysInMonth()<day) |
287 | { | 287 | { |
288 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 288 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
289 | } else { | 289 | } else { |
290 | temp.setYMD(temp.year(), temp.month(), day); | 290 | temp.setYMD(temp.year(), temp.month(), day); |
291 | } | 291 | } |
292 | // assert(temp.isValid()); | 292 | // assert(temp.isValid()); |
293 | setDate(temp); | 293 | setDate(temp); |
294 | } | 294 | } |
295 | 295 | ||
296 | void | 296 | void |
297 | KDatePicker::selectMonthClicked() | 297 | KDatePicker::selectMonthClicked() |
298 | { | 298 | { |
299 | int month; | 299 | int month; |
300 | KPopupFrame* popup = new KPopupFrame(this); | 300 | KPopupFrame* popup = new KPopupFrame(this); |
301 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 301 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
302 | // ----- | 302 | // ----- |
303 | picker->resize(picker->sizeHint()); | 303 | picker->resize(picker->sizeHint()); |
304 | popup->setMainWidget(picker); | 304 | popup->setMainWidget(picker); |
305 | picker->setFocus(); | 305 | picker->setFocus(); |
306 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 306 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
307 | if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) | 307 | if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) |
308 | { | 308 | { |
309 | QDate date; | 309 | QDate date; |
310 | int day; | 310 | int day; |
311 | // ----- | 311 | // ----- |
312 | month=picker->getResult(); | 312 | month=picker->getResult(); |
313 | date=table->getDate(); | 313 | date=table->getDate(); |
314 | day=date.day(); | 314 | day=date.day(); |
315 | // ----- construct a valid date in this month: | 315 | // ----- construct a valid date in this month: |
316 | date.setYMD(date.year(), month, 1); | 316 | date.setYMD(date.year(), month, 1); |
317 | date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); | 317 | date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); |
318 | // ----- set this month | 318 | // ----- set this month |
319 | setDate(date); | 319 | setDate(date); |
320 | } else { | 320 | } else { |
321 | KNotifyClient::beep(); | 321 | KNotifyClient::beep(); |
322 | } | 322 | } |
323 | delete popup; | 323 | delete popup; |
324 | } | 324 | } |
325 | 325 | ||