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, 5 insertions, 3 deletions
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp
index d6e9b51..c13734f 100644
--- a/libkdepim/kdatepicker.cpp
+++ b/libkdepim/kdatepicker.cpp
@@ -7,102 +7,104 @@
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
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 QFont fo = KGlobalSettings::generalFont();
56 table = new KDateTable(this);
57 int add = 2; 56 int add = 2;
58 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 57 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
59 add += 4; 58 add += 4;
60 setFontSize(font().pointSize()+add); 59 fo.setPointSize(fo.pointSize()+add );
60 setFont( fo );
61 table = new KDateTable(this);
62 setFontSize(font().pointSize());
61 //line->setValidator(val); 63 //line->setValidator(val);
62 lineDate = new KDateEdit( this, "dateediipicker", true ); 64 lineDate = new KDateEdit( this, "dateediipicker", true );
63 yearForward->setPixmap(SmallIcon("2rightarrowB")); 65 yearForward->setPixmap(SmallIcon("2rightarrowB"));
64 yearBackward->setPixmap(SmallIcon("2leftarrowB")); 66 yearBackward->setPixmap(SmallIcon("2leftarrowB"));
65 monthForward->setPixmap(SmallIcon("1rightarrowB")); 67 monthForward->setPixmap(SmallIcon("1rightarrowB"));
66 monthBackward->setPixmap(SmallIcon("1leftarrowB")); 68 monthBackward->setPixmap(SmallIcon("1leftarrowB"));
67 setDate(dt); // set button texts 69 setDate(dt); // set button texts
68 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); 70 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
69 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); 71 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
70 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); 72 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()));
71 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); 73 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()));
72 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); 74 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()));
73 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); 75 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
74 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); 76 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
75 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); 77 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
76 //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); 78 //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
77 connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); 79 connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate)));
78 connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); 80 connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
79 table->setFocus(); 81 table->setFocus();
80 82
81} 83}
82 84
83KDatePicker::~KDatePicker() 85KDatePicker::~KDatePicker()
84{ 86{
85} 87}
86 88
87void 89void
88KDatePicker::resizeEvent(QResizeEvent*) 90KDatePicker::resizeEvent(QResizeEvent*)
89{ 91{
90 QWidget *buttons[] = { 92 QWidget *buttons[] = {
91 yearBackward, 93 yearBackward,
92 monthBackward, 94 monthBackward,
93 selectMonth, 95 selectMonth,
94 selectYear, 96 selectYear,
95 monthForward, 97 monthForward,
96 yearForward }; 98 yearForward };
97 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); 99 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
98 QSize sizes[NoOfButtons]; 100 QSize sizes[NoOfButtons];
99 int buttonHeight=0; 101 int buttonHeight=0;
100 int count; 102 int count;
101 int w; 103 int w;
102 int x=0; 104 int x=0;
103 // ----- calculate button row height: 105 // ----- calculate button row height:
104 for(count=0; count<NoOfButtons; ++count) { 106 for(count=0; count<NoOfButtons; ++count) {
105 int xS = buttons[count]->sizeHint().width(); 107 int xS = buttons[count]->sizeHint().width();
106 int yS = buttons[count]->sizeHint().height(); 108 int yS = buttons[count]->sizeHint().height();
107 if ( QApplication::desktop()->width() < 320 ) 109 if ( QApplication::desktop()->width() < 320 )
108 sizes[count]=QSize ( xS+4, yS ); 110 sizes[count]=QSize ( xS+4, yS );