28 #include <KCalendarSystem>
29 #include <KIconLoader>
31 #include <QHBoxLayout>
33 #include <QToolButton>
38 tfont.setPointSize( 10 );
39 tfont.setBold(
false );
44 isRTL ? QLatin1String(
"arrow-right-double") : QLatin1String(
"arrow-left-double"),
45 i18n(
"Scroll backward to the previous year" ),
46 i18n(
"Click this button to scroll the display to the "
47 "same approximate day of the previous year" ) );
50 isRTL ? QLatin1String(
"arrow-right") : QLatin1String(
"arrow-left"),
51 i18n(
"Scroll backward to the previous month" ),
52 i18n(
"Click this button to scroll the display to the "
53 "same approximate date of the previous month" ) );
56 isRTL ?QLatin1String(
"arrow-left") : QLatin1String(
"arrow-right"),
57 i18n(
"Scroll forward to the next month" ),
58 i18n(
"Click this button to scroll the display to the "
59 "same approximate date of the next month" ) );
62 isRTL ? QLatin1String(
"arrow-left-double") : QLatin1String(
"arrow-right-double"),
63 i18n(
"Scroll forward to the next year" ),
64 i18n(
"Click this button to scroll the display to the "
65 "same approximate day of the next year" ) );
68 mMonth =
new QToolButton(
this );
69 mMonth->setPopupMode( QToolButton::InstantPopup );
70 mMonth->setAutoRaise(
true );
71 mMonth->setFont( tfont );
72 mMonth->setToolTip( i18n(
"Select a month" ) );
75 mYear =
new QToolButton(
this );
76 mYear->setPopupMode( QToolButton::InstantPopup );
77 mYear->setAutoRaise(
true );
78 mYear->setFont( tfont );
79 mYear->setToolTip( i18n(
"Select a year" ) );
82 QHBoxLayout *ctrlLayout =
new QHBoxLayout(
this );
83 ctrlLayout->setMargin( 0 );
84 ctrlLayout->addWidget( mPrevYear );
85 ctrlLayout->addWidget( mPrevMonth );
86 ctrlLayout->addStretch();
87 ctrlLayout->addWidget( mMonth );
88 ctrlLayout->addWidget( mYear );
89 ctrlLayout->addStretch();
90 ctrlLayout->addWidget( mNextMonth );
91 ctrlLayout->addWidget( mNextYear );
97 connect( mMonth, SIGNAL(clicked()), SLOT(selectMonthFromMenu()) );
98 connect( mYear, SIGNAL(clicked()), SLOT(selectYearFromMenu()) );
126 if ( dateList.count() > 0 ) {
127 mDate = dateList.first();
132 mMonth->setText( i18nc(
"monthname",
"%1", calSys->monthName( mDate ) ) );
133 mYear->setText( i18nc(
"4 digit year",
"%1",
134 calSys->formatDate( mDate, KLocale::Year, KLocale::LongNumber ) ) );
138 void NavigatorBar::selectMonthFromMenu()
143 int month = calSys->month( mDate );
144 int year = calSys->year( mDate );
145 int months = calSys->monthsInYear( mDate );
150 QAction *activateAction = 0;
151 for (
int i=1; i <= months; ++i ) {
152 QAction *monthAction = menu->addAction( calSys->monthName( i, year ) );
153 act.append( monthAction );
155 activateAction = monthAction;
158 if ( activateAction ) {
159 menu->setActiveAction( activateAction );
162 QAction *selectedAct = menu->exec( mMonth->mapToGlobal( QPoint( 0, 0 ) ) );
163 if ( selectedAct && ( selectedAct != activateAction ) ) {
164 for (
int i=0; i < months; ++i ) {
165 if ( act[i] == selectedAct ) {
179 void NavigatorBar::selectYearFromMenu()
183 int year = calSys->year( mDate );
185 int minYear = year - ( years / 3 );
191 QAction *activateAction = 0;
193 for (
int i=0; i < years; ++i ) {
194 QAction *yearAction = menu->addAction( yearStr.setNum( y ) );
195 act.append( yearAction );
197 activateAction = yearAction;
201 if ( activateAction ) {
202 menu->setActiveAction( activateAction );
205 QAction *selectedAct = menu->exec( mYear->mapToGlobal( QPoint( 0, 0 ) ) );
206 if ( selectedAct && ( selectedAct != activateAction ) ) {
208 for (
int i=0; i < years; ++i ) {
209 if ( act[i] == selectedAct ) {
225 const QString &toolTip,
226 const QString &whatsThis )
228 QToolButton *button =
new QToolButton(
this );
231 KIconLoader::global()->loadIcon( icon, KIconLoader::Desktop, KIconLoader::SizeSmall ) );
232 button->setIconSize( QSize( KIconLoader::SizeSmall, KIconLoader::SizeSmall ) );
233 button->setToolButtonStyle( Qt::ToolButtonIconOnly );
234 button->setAutoRaise(
true );
235 button->setToolTip( toolTip );
236 button->setWhatsThis( whatsThis );
241 #include "navigatorbar.moc"
void yearSelected(int year)
NavigatorBar(QWidget *parent=0)
void selectDates(const KCalCore::DateList &)
QToolButton * createNavigationButton(const QString &icon, const QString &toolTip, const QString &whatsThis)
const KCalendarSystem * calendarSystem() const
static KOGlobals * self()
static bool reverseLayout()
void showButtons(bool left, bool right)
void monthSelected(int month)