-rw-r--r-- | library/datebookmonth.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp index 013ab66..2616b7b 100644 --- a/library/datebookmonth.cpp +++ b/library/datebookmonth.cpp | |||
@@ -1,127 +1,130 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "config.h" | 20 | #include "config.h" |
21 | #include "datebookmonth.h" | 21 | #include "datebookmonth.h" |
22 | #include "datebookdb.h" | 22 | #include "datebookdb.h" |
23 | #include "resource.h" | 23 | #include "resource.h" |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
27 | #include <qspinbox.h> | 27 | #include <qspinbox.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qvaluestack.h> | 29 | #include <qvaluestack.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | 31 | ||
32 | static const QColor s_colorNormalLight = QColor(255, 150, 150); | ||
33 | static const QColor s_colorRepeatLight = QColor(150, 150, 255); | ||
34 | static const QColor s_colorHolidayLight= QColor(150, 255, 150); | ||
32 | 35 | ||
33 | DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) | 36 | DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) |
34 | : QHBox( parent, name ) | 37 | : QHBox( parent, name ) |
35 | { | 38 | { |
36 | setBackgroundMode( PaletteButton ); | 39 | setBackgroundMode( PaletteButton ); |
37 | 40 | ||
38 | begin = new QToolButton( this ); | 41 | begin = new QToolButton( this ); |
39 | begin->setFocusPolicy(NoFocus); | 42 | begin->setFocusPolicy(NoFocus); |
40 | begin->setPixmap( Resource::loadPixmap( "start" ) ); | 43 | begin->setPixmap( Resource::loadPixmap( "start" ) ); |
41 | begin->setAutoRaise( TRUE ); | 44 | begin->setAutoRaise( TRUE ); |
42 | begin->setFixedSize( begin->sizeHint() ); | 45 | begin->setFixedSize( begin->sizeHint() ); |
43 | QWhatsThis::add( begin, tr("Show January in the selected year") ); | 46 | QWhatsThis::add( begin, tr("Show January in the selected year") ); |
44 | 47 | ||
45 | back = new QToolButton( this ); | 48 | back = new QToolButton( this ); |
46 | back->setFocusPolicy(NoFocus); | 49 | back->setFocusPolicy(NoFocus); |
47 | back->setPixmap( Resource::loadPixmap( "back" ) ); | 50 | back->setPixmap( Resource::loadPixmap( "back" ) ); |
48 | back->setAutoRaise( TRUE ); | 51 | back->setAutoRaise( TRUE ); |
49 | back->setFixedSize( back->sizeHint() ); | 52 | back->setFixedSize( back->sizeHint() ); |
50 | QWhatsThis::add( back, tr("Show the previous month") ); | 53 | QWhatsThis::add( back, tr("Show the previous month") ); |
51 | 54 | ||
52 | month = new QComboBox( FALSE, this ); | 55 | month = new QComboBox( FALSE, this ); |
53 | for ( int i = 0; i < 12; ++i ) | 56 | for ( int i = 0; i < 12; ++i ) |
54 | month->insertItem( Calendar::nameOfMonth( i + 1 ) ); | 57 | month->insertItem( Calendar::nameOfMonth( i + 1 ) ); |
55 | 58 | ||
56 | year = new QSpinBox( 1752, 8000, 1, this ); | 59 | year = new QSpinBox( 1752, 8000, 1, this ); |
57 | 60 | ||
58 | next = new QToolButton( this ); | 61 | next = new QToolButton( this ); |
59 | next->setFocusPolicy(NoFocus); | 62 | next->setFocusPolicy(NoFocus); |
60 | next->setPixmap( Resource::loadPixmap( "forward" ) ); | 63 | next->setPixmap( Resource::loadPixmap( "forward" ) ); |
61 | next->setAutoRaise( TRUE ); | 64 | next->setAutoRaise( TRUE ); |
62 | next->setFixedSize( next->sizeHint() ); | 65 | next->setFixedSize( next->sizeHint() ); |
63 | QWhatsThis::add( next, tr("Show the next month") ); | 66 | QWhatsThis::add( next, tr("Show the next month") ); |
64 | 67 | ||
65 | end = new QToolButton( this ); | 68 | end = new QToolButton( this ); |
66 | end->setFocusPolicy(NoFocus); | 69 | end->setFocusPolicy(NoFocus); |
67 | end->setPixmap( Resource::loadPixmap( "finish" ) ); | 70 | end->setPixmap( Resource::loadPixmap( "finish" ) ); |
68 | end->setAutoRaise( TRUE ); | 71 | end->setAutoRaise( TRUE ); |
69 | end->setFixedSize( end->sizeHint() ); | 72 | end->setFixedSize( end->sizeHint() ); |
70 | QWhatsThis::add( end, tr("Show December in the selected year") ); | 73 | QWhatsThis::add( end, tr("Show December in the selected year") ); |
71 | 74 | ||
72 | connect( month, SIGNAL( activated(int) ), | 75 | connect( month, SIGNAL( activated(int) ), |
73 | this, SLOT( updateDate() ) ); | 76 | this, SLOT( updateDate() ) ); |
74 | connect( year, SIGNAL( valueChanged(int) ), | 77 | connect( year, SIGNAL( valueChanged(int) ), |
75 | this, SLOT( updateDate() ) ); | 78 | this, SLOT( updateDate() ) ); |
76 | connect( begin, SIGNAL( clicked() ), | 79 | connect( begin, SIGNAL( clicked() ), |
77 | this, SLOT( firstMonth() ) ); | 80 | this, SLOT( firstMonth() ) ); |
78 | connect( end, SIGNAL( clicked() ), | 81 | connect( end, SIGNAL( clicked() ), |
79 | this, SLOT( lastMonth() ) ); | 82 | this, SLOT( lastMonth() ) ); |
80 | connect( back, SIGNAL( clicked() ), | 83 | connect( back, SIGNAL( clicked() ), |
81 | this, SLOT( monthBack() ) ); | 84 | this, SLOT( monthBack() ) ); |
82 | connect( next, SIGNAL( clicked() ), | 85 | connect( next, SIGNAL( clicked() ), |
83 | this, SLOT( monthForward() ) ); | 86 | this, SLOT( monthForward() ) ); |
84 | back->setAutoRepeat( TRUE ); | 87 | back->setAutoRepeat( TRUE ); |
85 | next->setAutoRepeat( TRUE ); | 88 | next->setAutoRepeat( TRUE ); |
86 | } | 89 | } |
87 | 90 | ||
88 | 91 | ||
89 | DateBookMonthHeader::~DateBookMonthHeader() | 92 | DateBookMonthHeader::~DateBookMonthHeader() |
90 | { | 93 | { |
91 | 94 | ||
92 | } | 95 | } |
93 | 96 | ||
94 | void DateBookMonthHeader::updateDate() | 97 | void DateBookMonthHeader::updateDate() |
95 | { | 98 | { |
96 | emit dateChanged( year->value(), month->currentItem() + 1 ); | 99 | emit dateChanged( year->value(), month->currentItem() + 1 ); |
97 | } | 100 | } |
98 | 101 | ||
99 | void DateBookMonthHeader::firstMonth() | 102 | void DateBookMonthHeader::firstMonth() |
100 | { | 103 | { |
101 | emit dateChanged( year->value(), 1 ); | 104 | emit dateChanged( year->value(), 1 ); |
102 | month->setCurrentItem( 0 ); | 105 | month->setCurrentItem( 0 ); |
103 | } | 106 | } |
104 | 107 | ||
105 | void DateBookMonthHeader::lastMonth() | 108 | void DateBookMonthHeader::lastMonth() |
106 | { | 109 | { |
107 | emit dateChanged( year->value(), 12 ); | 110 | emit dateChanged( year->value(), 12 ); |
108 | month->setCurrentItem( 11 ); | 111 | month->setCurrentItem( 11 ); |
109 | } | 112 | } |
110 | 113 | ||
111 | void DateBookMonthHeader::monthBack() | 114 | void DateBookMonthHeader::monthBack() |
112 | { | 115 | { |
113 | if ( month->currentItem() > 0 ) { | 116 | if ( month->currentItem() > 0 ) { |
114 | emit dateChanged( year->value(), month->currentItem() ); | 117 | emit dateChanged( year->value(), month->currentItem() ); |
115 | month->setCurrentItem( month->currentItem() - 1 ); | 118 | month->setCurrentItem( month->currentItem() - 1 ); |
116 | } else { | 119 | } else { |
117 | emit dateChanged( year->value() - 1, 12 ); | 120 | emit dateChanged( year->value() - 1, 12 ); |
118 | // we have a signal set to a changed value in year so we only need to change | 121 | // we have a signal set to a changed value in year so we only need to change |
119 | // year to get the result... | 122 | // year to get the result... |
120 | month->setCurrentItem( 11 ); | 123 | month->setCurrentItem( 11 ); |
121 | year->setValue( year->value() - 1 ); | 124 | year->setValue( year->value() - 1 ); |
122 | } | 125 | } |
123 | } | 126 | } |
124 | 127 | ||
125 | void DateBookMonthHeader::monthForward() | 128 | void DateBookMonthHeader::monthForward() |
126 | { | 129 | { |
127 | if ( month->currentItem() < 11 ) { | 130 | if ( month->currentItem() < 11 ) { |
@@ -517,206 +520,206 @@ DayItemMonth::~DayItemMonth() | |||
517 | delete d; | 520 | delete d; |
518 | } | 521 | } |
519 | 522 | ||
520 | void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv ) | 523 | void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv ) |
521 | { | 524 | { |
522 | d->mDayEvents = effEv; | 525 | d->mDayEvents = effEv; |
523 | } | 526 | } |
524 | 527 | ||
525 | void DayItemMonth::clearEffEvents() | 528 | void DayItemMonth::clearEffEvents() |
526 | { | 529 | { |
527 | d->mDayEvents.clear(); | 530 | d->mDayEvents.clear(); |
528 | } | 531 | } |
529 | 532 | ||
530 | void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, | 533 | void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, |
531 | const QRect &cr, bool selected ) | 534 | const QRect &cr, bool selected ) |
532 | { | 535 | { |
533 | p->save(); | 536 | p->save(); |
534 | 537 | ||
535 | QColorGroup g( cg ); | 538 | QColorGroup g( cg ); |
536 | g.setBrush( QColorGroup::Base, back ); | 539 | g.setBrush( QColorGroup::Base, back ); |
537 | g.setColor( QColorGroup::Text, forg ); | 540 | g.setColor( QColorGroup::Text, forg ); |
538 | if ( selected ) | 541 | if ( selected ) |
539 | p->setPen( g.highlightedText() ); | 542 | p->setPen( g.highlightedText() ); |
540 | else | 543 | else |
541 | p->setPen( g.text() ); | 544 | p->setPen( g.text() ); |
542 | 545 | ||
543 | QValueStack<int> normalLine; | 546 | QValueStack<int> normalLine; |
544 | QValueStack<int> repeatLine; | 547 | QValueStack<int> repeatLine; |
545 | QValueStack<int> travelLine; | 548 | QValueStack<int> travelLine; |
546 | 549 | ||
547 | bool normalAllDay = FALSE; | 550 | bool normalAllDay = FALSE; |
548 | bool repeatAllDay = FALSE; | 551 | bool repeatAllDay = FALSE; |
549 | bool travelAllDay = FALSE; | 552 | bool travelAllDay = FALSE; |
550 | bool holidayAllDay = FALSE; | 553 | bool holidayAllDay = FALSE; |
551 | 554 | ||
552 | QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); | 555 | QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); |
553 | 556 | ||
554 | for ( ; itDays != d->mDayEvents.end(); ++itDays ) { | 557 | for ( ; itDays != d->mDayEvents.end(); ++itDays ) { |
555 | int w = cr.width(); | 558 | int w = cr.width(); |
556 | Event ev = (*itDays).event(); | 559 | Event ev = (*itDays).event(); |
557 | 560 | ||
558 | int f = (*itDays).start().hour(); // assume Effective event | 561 | int f = (*itDays).start().hour(); // assume Effective event |
559 | int t = (*itDays).end().hour(); // is truncated. | 562 | int t = (*itDays).end().hour(); // is truncated. |
560 | 563 | ||
561 | if (ev.isAllDay()) { | 564 | if (ev.isAllDay()) { |
562 | if (!ev.hasRepeat()) { | 565 | if (!ev.hasRepeat()) { |
563 | normalAllDay = TRUE; | 566 | normalAllDay = TRUE; |
564 | if (!ev.isValidUid()) { | 567 | if (!ev.isValidUid()) { |
565 | holidayAllDay = TRUE; | 568 | holidayAllDay = TRUE; |
566 | } | 569 | } |
567 | } else { | 570 | } else { |
568 | repeatAllDay = TRUE; | 571 | repeatAllDay = TRUE; |
569 | } | 572 | } |
570 | } else { | 573 | } else { |
571 | int sLine, eLine; | 574 | int sLine, eLine; |
572 | if (f == 0) | 575 | if (f == 0) |
573 | sLine = 0; | 576 | sLine = 0; |
574 | else if (f < 8 ) | 577 | else if (f < 8 ) |
575 | sLine = 1; | 578 | sLine = 1; |
576 | else if (f >= 17) | 579 | else if (f >= 17) |
577 | sLine = w - 4; | 580 | sLine = w - 4; |
578 | else { | 581 | else { |
579 | sLine = (f - 8) * (w - 8); | 582 | sLine = (f - 8) * (w - 8); |
580 | if (sLine) | 583 | if (sLine) |
581 | sLine /= 8; | 584 | sLine /= 8; |
582 | sLine += 4; | 585 | sLine += 4; |
583 | } | 586 | } |
584 | if (t == 23) | 587 | if (t == 23) |
585 | eLine = w; | 588 | eLine = w; |
586 | else if (t < 8) | 589 | else if (t < 8) |
587 | eLine = 4; | 590 | eLine = 4; |
588 | else if (t >= 17) | 591 | else if (t >= 17) |
589 | eLine = w - 1; | 592 | eLine = w - 1; |
590 | else { | 593 | else { |
591 | eLine = (t - 8) * (w - 8); | 594 | eLine = (t - 8) * (w - 8); |
592 | if (eLine) | 595 | if (eLine) |
593 | eLine /= 8; | 596 | eLine /= 8; |
594 | eLine += 4; | 597 | eLine += 4; |
595 | } | 598 | } |
596 | if (!ev.hasRepeat()) { | 599 | if (!ev.hasRepeat()) { |
597 | normalLine.push(sLine); | 600 | normalLine.push(sLine); |
598 | normalLine.push(eLine); | 601 | normalLine.push(eLine); |
599 | } else { | 602 | } else { |
600 | repeatLine.push(sLine); | 603 | repeatLine.push(sLine); |
601 | repeatLine.push(eLine); | 604 | repeatLine.push(eLine); |
602 | } | 605 | } |
603 | } | 606 | } |
604 | } | 607 | } |
605 | 608 | ||
606 | // draw the background | 609 | // draw the background |
607 | if (normalAllDay || repeatAllDay || travelAllDay || holidayAllDay) { | 610 | if (normalAllDay || repeatAllDay || travelAllDay || holidayAllDay) { |
608 | p->save(); | 611 | p->save(); |
609 | 612 | ||
610 | if (normalAllDay) | 613 | if (normalAllDay) |
611 | if (repeatAllDay) { | 614 | if (repeatAllDay) { |
612 | p->fillRect( 0, 0, cr.width(), cr.height() / 2, | 615 | p->fillRect( 0, 0, cr.width(), cr.height() / 2, |
613 | colorNormalLight ); | 616 | s_colorNormalLight ); |
614 | p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, | 617 | p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, |
615 | colorRepeatLight ); | 618 | colorRepeatLight ); |
616 | } else { | 619 | } else { |
617 | if (!holidayAllDay) { | 620 | if (!holidayAllDay) { |
618 | p->fillRect( 0, 0, cr.width(), cr.height(), | 621 | p->fillRect( 0, 0, cr.width(), cr.height(), |
619 | colorNormalLight ); | 622 | s_colorNormalLight ); |
620 | } else { | 623 | } else { |
621 | p->fillRect( 0, 0, cr.width(), cr.height(), | 624 | p->fillRect( 0, 0, cr.width(), cr.height(), |
622 | QColor(0,220,0) ); | 625 | s_colorHolidayLight ); |
623 | } | 626 | } |
624 | } else if (repeatAllDay) { | 627 | } else if (repeatAllDay) { |
625 | p->fillRect( 0, 0, cr.width(), cr.height(), | 628 | p->fillRect( 0, 0, cr.width(), cr.height(), |
626 | colorRepeatLight ); | 629 | s_colorRepeatLight ); |
627 | } | 630 | } |
628 | } else { | 631 | } else { |
629 | p->fillRect( 0, 0, cr.width(), | 632 | p->fillRect( 0, 0, cr.width(), |
630 | cr.height(), selected | 633 | cr.height(), selected |
631 | ? g.brush( QColorGroup::Highlight ) | 634 | ? g.brush( QColorGroup::Highlight ) |
632 | : g.brush( QColorGroup::Base ) ); | 635 | : g.brush( QColorGroup::Base ) ); |
633 | } | 636 | } |
634 | 637 | ||
635 | // The lines | 638 | // The lines |
636 | // now for the lines. | 639 | // now for the lines. |
637 | int h = 5; | 640 | int h = 5; |
638 | int y = cr.height() / 2 - h; | 641 | int y = cr.height() / 2 - h; |
639 | 642 | ||
640 | while(normalLine.count() >= 2) { | 643 | while(normalLine.count() >= 2) { |
641 | int x2 = normalLine.pop(); | 644 | int x2 = normalLine.pop(); |
642 | int x1 = normalLine.pop(); | 645 | int x1 = normalLine.pop(); |
643 | if (x2 < x1 + 2) | 646 | if (x2 < x1 + 2) |
644 | x2 = x1 + 2; | 647 | x2 = x1 + 2; |
645 | p->fillRect(x1, y, x2 - x1, h, colorNormal); | 648 | p->fillRect(x1, y, x2 - x1, h, colorNormal); |
646 | } | 649 | } |
647 | 650 | ||
648 | y += h; | 651 | y += h; |
649 | 652 | ||
650 | while(repeatLine.count() >= 2) { | 653 | while(repeatLine.count() >= 2) { |
651 | int x2 = repeatLine.pop(); | 654 | int x2 = repeatLine.pop(); |
652 | int x1 = repeatLine.pop(); | 655 | int x1 = repeatLine.pop(); |
653 | if (x2 < x1 + 2) | 656 | if (x2 < x1 + 2) |
654 | x2 = x1 + 2; | 657 | x2 = x1 + 2; |
655 | p->fillRect(x1, y, x2 - x1, h, colorRepeat); | 658 | p->fillRect(x1, y, x2 - x1, h, colorRepeat); |
656 | } | 659 | } |
657 | 660 | ||
658 | 661 | ||
659 | // Finally, draw the number. | 662 | // Finally, draw the number. |
660 | QFont f = p->font(); | 663 | QFont f = p->font(); |
661 | f.setPointSize( ( f.pointSize() / 3 ) * 2 ); | 664 | f.setPointSize( ( f.pointSize() / 3 ) * 2 ); |
662 | p->setFont( f ); | 665 | p->setFont( f ); |
663 | QFontMetrics fm( f ); | 666 | QFontMetrics fm( f ); |
664 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); | 667 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); |
665 | 668 | ||
666 | p->restore(); | 669 | p->restore(); |
667 | } | 670 | } |
668 | 671 | ||
669 | 672 | ||
670 | 673 | ||
671 | void DayItemMonth::setType( Calendar::Day::Type t ) | 674 | void DayItemMonth::setType( Calendar::Day::Type t ) |
672 | { | 675 | { |
673 | switch ( t ) { | 676 | switch ( t ) { |
674 | case Calendar::Day::PrevMonth: | 677 | case Calendar::Day::PrevMonth: |
675 | case Calendar::Day::NextMonth: | 678 | case Calendar::Day::NextMonth: |
676 | back = QBrush( QColor( 224, 224, 224 ) ); | 679 | back = QBrush( QColor( 224, 224, 224 ) ); |
677 | forg = black; | 680 | forg = black; |
678 | break; | 681 | break; |
679 | case Calendar::Day::ThisMonth: | 682 | case Calendar::Day::ThisMonth: |
680 | back = QBrush( white ); | 683 | back = QBrush( white ); |
681 | forg = black; | 684 | forg = black; |
682 | break; | 685 | break; |
683 | } | 686 | } |
684 | typ = t; | 687 | typ = t; |
685 | } | 688 | } |
686 | 689 | ||
687 | 690 | ||
688 | 691 | ||
689 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) | 692 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) |
690 | :QPushButton( parent, name ) | 693 | :QPushButton( parent, name ) |
691 | { | 694 | { |
692 | longFormat = longDate; | 695 | longFormat = longDate; |
693 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); | 696 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); |
694 | setDate( QDate::currentDate() ); | 697 | setDate( QDate::currentDate() ); |
695 | 698 | ||
696 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); | 699 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); |
697 | 700 | ||
698 | 701 | ||
699 | } | 702 | } |
700 | 703 | ||
701 | 704 | ||
702 | void DateButton::pickDate() | 705 | void DateButton::pickDate() |
703 | { | 706 | { |
704 | static QPopupMenu *m1 = 0; | 707 | static QPopupMenu *m1 = 0; |
705 | static DateBookMonth *picker = 0; | 708 | static DateBookMonth *picker = 0; |
706 | if ( !m1 ) { | 709 | if ( !m1 ) { |
707 | m1 = new QPopupMenu( this ); | 710 | m1 = new QPopupMenu( this ); |
708 | picker = new DateBookMonth( m1, 0, TRUE ); | 711 | picker = new DateBookMonth( m1, 0, TRUE ); |
709 | m1->insertItem( picker ); | 712 | m1->insertItem( picker ); |
710 | connect( picker, SIGNAL( dateClicked(int,int,int) ), | 713 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
711 | this, SLOT( setDate(int,int,int) ) ); | 714 | this, SLOT( setDate(int,int,int) ) ); |
712 | connect( picker, SIGNAL( dateClicked(int,int,int) ), | 715 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
713 | this, SIGNAL( dateSelected(int,int,int) ) ); | 716 | this, SIGNAL( dateSelected(int,int,int) ) ); |
714 | connect( m1, SIGNAL( aboutToHide() ), | 717 | connect( m1, SIGNAL( aboutToHide() ), |
715 | this, SLOT( gotHide() ) ); | 718 | this, SLOT( gotHide() ) ); |
716 | } | 719 | } |
717 | picker->slotWeekChange( weekStartsMonday ); | 720 | picker->slotWeekChange( weekStartsMonday ); |
718 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | 721 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); |
719 | m1->popup(mapToGlobal(QPoint(0,height()))); | 722 | m1->popup(mapToGlobal(QPoint(0,height()))); |
720 | picker->setFocus(); | 723 | picker->setFocus(); |
721 | } | 724 | } |
722 | 725 | ||