summaryrefslogtreecommitdiffabout
path: root/libkdepim/kdatepicker.cpp
Unidiff
Diffstat (limited to 'libkdepim/kdatepicker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kdatepicker.cpp8
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
@@ -18,100 +18,100 @@
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
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 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
88KDatePicker::~KDatePicker() 88KDatePicker::~KDatePicker()
89{ 89{
90} 90}
91 91
92void 92void
93KDatePicker::resizeEvent(QResizeEvent*) 93KDatePicker::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());