summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-02-08 16:24:18 (UTC)
committer zautrix <zautrix>2005-02-08 16:24:18 (UTC)
commit78c70cfbbe79243d8b0ec40f8f6438c99046e12b (patch) (unidiff)
tree382bc11ad3b56f72b8f84414e1da5e5ea871204b /libkdepim
parent584ed7893497b2adad5ba6c3e914d90b76973b92 (diff)
downloadkdepimpi-78c70cfbbe79243d8b0ec40f8f6438c99046e12b.zip
kdepimpi-78c70cfbbe79243d8b0ec40f8f6438c99046e12b.tar.gz
kdepimpi-78c70cfbbe79243d8b0ec40f8f6438c99046e12b.tar.bz2
fix
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kdatepicker.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp
index 2be9c9e..d6e9b51 100644
--- a/libkdepim/kdatepicker.cpp
+++ b/libkdepim/kdatepicker.cpp
@@ -25,65 +25,68 @@
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
42KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) 42KDatePicker::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 //line(new QLineEdit(this)), 50 //line(new QLineEdit(this)),
51 val(new KDateValidator(this)) 51 val(new KDateValidator(this))
52 //table(new KDateTable(this)), 52 //table(new KDateTable(this)),
53 //fontsize(1) 53 //fontsize(1)
54{ 54{
55 setFont ( KGlobalSettings::generalFont() ); 55 setFont ( KGlobalSettings::generalFont() );
56 table = new KDateTable(this); 56 table = new KDateTable(this);
57 setFontSize(font().pointSize()+2); 57 int add = 2;
58 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
59 add += 4;
60 setFontSize(font().pointSize()+add);
58 //line->setValidator(val); 61 //line->setValidator(val);
59 lineDate = new KDateEdit( this, "dateediipicker", true ); 62 lineDate = new KDateEdit( this, "dateediipicker", true );
60 yearForward->setPixmap(SmallIcon("2rightarrowB")); 63 yearForward->setPixmap(SmallIcon("2rightarrowB"));
61 yearBackward->setPixmap(SmallIcon("2leftarrowB")); 64 yearBackward->setPixmap(SmallIcon("2leftarrowB"));
62 monthForward->setPixmap(SmallIcon("1rightarrowB")); 65 monthForward->setPixmap(SmallIcon("1rightarrowB"));
63 monthBackward->setPixmap(SmallIcon("1leftarrowB")); 66 monthBackward->setPixmap(SmallIcon("1leftarrowB"));
64 setDate(dt); // set button texts 67 setDate(dt); // set button texts
65 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); 68 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
66 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); 69 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
67 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); 70 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()));
68 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); 71 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()));
69 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); 72 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()));
70 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); 73 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
71 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); 74 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
72 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); 75 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
73 //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); 76 //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
74 connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); 77 connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate)));
75 connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); 78 connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
76 table->setFocus(); 79 table->setFocus();
77 80
78} 81}
79 82
80KDatePicker::~KDatePicker() 83KDatePicker::~KDatePicker()
81{ 84{
82} 85}
83 86
84void 87void
85KDatePicker::resizeEvent(QResizeEvent*) 88KDatePicker::resizeEvent(QResizeEvent*)
86{ 89{
87 QWidget *buttons[] = { 90 QWidget *buttons[] = {
88 yearBackward, 91 yearBackward,
89 monthBackward, 92 monthBackward,
@@ -254,65 +257,65 @@ KDatePicker::yearForwardClicked()
254 if(temp.daysInMonth()<day) 257 if(temp.daysInMonth()<day)
255 { 258 {
256 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); 259 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
257 } else { 260 } else {
258 temp.setYMD(temp.year(), temp.month(), day); 261 temp.setYMD(temp.year(), temp.month(), day);
259 } 262 }
260 // assert(temp.isValid()); 263 // assert(temp.isValid());
261 setDate(temp); 264 setDate(temp);
262} 265}
263 266
264void 267void
265KDatePicker::yearBackwardClicked() 268KDatePicker::yearBackwardClicked()
266{ 269{
267 QDate temp=table->getDate(); 270 QDate temp=table->getDate();
268 int day=temp.day(); 271 int day=temp.day();
269 // ----- 272 // -----
270 temp.setYMD(temp.year()-1, temp.month(), 1); 273 temp.setYMD(temp.year()-1, temp.month(), 1);
271 if(temp.daysInMonth()<day) 274 if(temp.daysInMonth()<day)
272 { 275 {
273 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); 276 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
274 } else { 277 } else {
275 temp.setYMD(temp.year(), temp.month(), day); 278 temp.setYMD(temp.year(), temp.month(), day);
276 } 279 }
277 // assert(temp.isValid()); 280 // assert(temp.isValid());
278 setDate(temp); 281 setDate(temp);
279} 282}
280 283
281void 284void
282KDatePicker::selectMonthClicked() 285KDatePicker::selectMonthClicked()
283{ 286{
284 int month; 287 int month;
285 KPopupFrame* popup = new KPopupFrame(this); 288 KPopupFrame* popup = new KPopupFrame(this);
286 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(fontsize, popup); 289 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup);
287 // ----- 290 // -----
288 picker->resize(picker->sizeHint()); 291 picker->resize(picker->sizeHint());
289 popup->setMainWidget(picker); 292 popup->setMainWidget(picker);
290 picker->setFocus(); 293 picker->setFocus();
291 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 294 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
292 if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) 295 if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height()))))
293 { 296 {
294 QDate date; 297 QDate date;
295 int day; 298 int day;
296 // ----- 299 // -----
297 month=picker->getResult(); 300 month=picker->getResult();
298 date=table->getDate(); 301 date=table->getDate();
299 day=date.day(); 302 day=date.day();
300 // ----- construct a valid date in this month: 303 // ----- construct a valid date in this month:
301 date.setYMD(date.year(), month, 1); 304 date.setYMD(date.year(), month, 1);
302 date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); 305 date.setYMD(date.year(), month, QMIN(day, date.daysInMonth()));
303 // ----- set this month 306 // ----- set this month
304 setDate(date); 307 setDate(date);
305 } else { 308 } else {
306 KNotifyClient::beep(); 309 KNotifyClient::beep();
307 } 310 }
308 delete popup; 311 delete popup;
309} 312}
310 313
311void 314void
312KDatePicker::selectYearClicked() 315KDatePicker::selectYearClicked()
313{ 316{
314 int year; 317 int year;
315 KPopupFrame* popup = new KPopupFrame(this); 318 KPopupFrame* popup = new KPopupFrame(this);
316 KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); 319 KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup);
317 // ----- 320 // -----
318 picker->resize(picker->sizeHint()); 321 picker->resize(picker->sizeHint());