summaryrefslogtreecommitdiffabout
path: root/korganizer/navigatorbar.cpp
Unidiff
Diffstat (limited to 'korganizer/navigatorbar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/navigatorbar.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index 4a31c77..2b8fd4f 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -75,129 +75,126 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
75#endif 75#endif
76 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 76 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
77 isDesktop = true; 77 isDesktop = true;
78 // Create backward navigation buttons 78 // Create backward navigation buttons
79 mPrevYear = new QPushButton( mCtrlFrame ); 79 mPrevYear = new QPushButton( mCtrlFrame );
80 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 80 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
81 QToolTip::add( mPrevYear, i18n("Previous Year") ); 81 QToolTip::add( mPrevYear, i18n("Previous Year") );
82 82
83 mPrevMonth = new QPushButton( mCtrlFrame ); 83 mPrevMonth = new QPushButton( mCtrlFrame );
84 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 84 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
85 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 85 QToolTip::add( mPrevMonth, i18n("Previous Month") );
86 86
87 // Create forward navigation buttons 87 // Create forward navigation buttons
88 mNextMonth = new QPushButton( mCtrlFrame ); 88 mNextMonth = new QPushButton( mCtrlFrame );
89 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 89 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
90 QToolTip::add( mNextMonth, i18n("Next Month") ); 90 QToolTip::add( mNextMonth, i18n("Next Month") );
91 91
92 mNextYear = new QPushButton( mCtrlFrame ); 92 mNextYear = new QPushButton( mCtrlFrame );
93 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 93 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
94 QToolTip::add( mNextYear, i18n("Next Year") ); 94 QToolTip::add( mNextYear, i18n("Next Year") );
95 mSelectMonth = new QPushButton( mCtrlFrame ); 95 mSelectMonth = new QPushButton( mCtrlFrame );
96 // Create month name label 96 // Create month name label
97 //selectMonth->setFont( tfont ); 97 //selectMonth->setFont( tfont );
98 // selectMonth->setAlignment( AlignCenter ); 98 // selectMonth->setAlignment( AlignCenter );
99 //mDateLabel = new QLabel( selectMonth ); 99 //mDateLabel = new QLabel( selectMonth );
100 //mDateLabel->setFont( tfont ); 100 //mDateLabel->setFont( tfont );
101 //mDateLabel->setAlignment( AlignCenter ); 101 //mDateLabel->setAlignment( AlignCenter );
102 if ( QString ( name ) == QString("useBigPixmaps") ) { 102 if ( QString ( name ) == QString("useBigPixmaps") ) {
103 mNextMonth->setFlat( true); 103 mNextMonth->setFlat( true);
104 mNextYear->setFlat( true); 104 mNextYear->setFlat( true);
105 mSelectMonth->setFlat( true); 105 mSelectMonth->setFlat( true);
106 mPrevYear->setFlat( true); 106 mPrevYear->setFlat( true);
107 mPrevMonth->setFlat( true); 107 mPrevMonth->setFlat( true);
108 } 108 }
109 mSelectMonth->setFont( tfont ); 109 mSelectMonth->setFont( tfont );
110 // Set minimum width to width of widest month name label 110 // Set minimum width to width of widest month name label
111 int i; 111 int i;
112 int maxwidth = 0; 112 int maxwidth = 0;
113 QFontMetrics fm ( mSelectMonth->font() ); 113 QFontMetrics fm ( mSelectMonth->font() );
114 int width = fm.width("September '00" ); 114 int width = fm.width("September '00" );
115// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); 115// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
116// ++i ) { 116// ++i ) {
117// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, 117// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
118// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); 118// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
119// int width = fm.width("September 2000" ); 119// int width = fm.width("September 2000" );
120// if ( width > maxwidth ) maxwidth = width; 120// if ( width > maxwidth ) maxwidth = width;
121// } 121// }
122 maxwidth = width+2; 122 maxwidth = width+2;
123 int size = fm.height()+2; 123 int size = fm.height()+2;
124 if ( QApplication::desktop()->width() >= 480 ) { 124 if ( QApplication::desktop()->width() >= 480 ) {
125 size += 6; 125 size += 6;
126 maxwidth+= 6; 126 maxwidth+= 6;
127 } 127 }
128 128
129 mSelectMonth->setFixedWidth( maxwidth ); 129 mSelectMonth->setFixedWidth( maxwidth );
130 mSelectMonth->setFixedHeight( size ); 130 mSelectMonth->setFixedHeight( size );
131 mPrevYear->setFixedHeight( size ); 131 mPrevYear->setFixedHeight( size );
132 mPrevMonth->setFixedHeight( size ); 132 mPrevMonth->setFixedHeight( size );
133 mNextMonth->setFixedHeight( size ); 133 mNextMonth->setFixedHeight( size );
134 mNextYear->setFixedHeight ( size ); 134 mNextYear->setFixedHeight ( size );
135 // set up control frame layout 135 // set up control frame layout
136 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 136 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
137 ctrlLayout->addWidget( mPrevYear, 3 ); 137 ctrlLayout->addWidget( mPrevYear, 3 );
138 ctrlLayout->addWidget( mPrevMonth, 3 ); 138 ctrlLayout->addWidget( mPrevMonth, 3 );
139 //ctrlLayout->addStretch( 1 ); 139 //ctrlLayout->addStretch( 1 );
140 // ctrlLayout->addSpacing( 1 ); 140 // ctrlLayout->addSpacing( 1 );
141 // ctrlLayout->addWidget( mDateLabel ); 141 // ctrlLayout->addWidget( mDateLabel );
142 ctrlLayout->addWidget( mSelectMonth ); 142 ctrlLayout->addWidget( mSelectMonth );
143 // ctrlLayout->addSpacing( 1 ); 143 // ctrlLayout->addSpacing( 1 );
144 // ctrlLayout->addStretch( 1 ); 144 // ctrlLayout->addStretch( 1 );
145 ctrlLayout->addWidget( mNextMonth, 3 ); 145 ctrlLayout->addWidget( mNextMonth, 3 );
146 ctrlLayout->addWidget( mNextYear, 3 ); 146 ctrlLayout->addWidget( mNextYear, 3 );
147 147
148 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 148 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
149 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 149 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
150 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 150 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
151 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 151 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
152 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 152 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
153 mPrevYear->setFocusPolicy(NoFocus); 153 mPrevYear->setFocusPolicy(NoFocus);
154 mPrevMonth->setFocusPolicy(NoFocus); 154 mPrevMonth->setFocusPolicy(NoFocus);
155 mNextMonth->setFocusPolicy(NoFocus); 155 mNextMonth->setFocusPolicy(NoFocus);
156 mNextYear->setFocusPolicy(NoFocus); 156 mNextYear->setFocusPolicy(NoFocus);
157 mSelectMonth->setFocusPolicy(NoFocus); 157 mSelectMonth->setFocusPolicy(NoFocus);
158 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 158 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
159 159
160} 160}
161 161
162NavigatorBar::~NavigatorBar() 162NavigatorBar::~NavigatorBar()
163{ 163{
164} 164}
165 165
166void NavigatorBar::selectMonth() 166void NavigatorBar::selectMonth()
167{ 167{
168 168
169 int month; 169 int month;
170 KPopupFrame* popup = new KPopupFrame(this); 170 KPopupFrame* popup = new KPopupFrame(this);
171 int size = 12; 171 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup);
172 if ( QApplication::desktop()->width() >= 480 )
173 size = 18;
174 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup);
175 // ----- 172 // -----
176 picker->resize(picker->sizeHint()); 173 picker->resize(picker->sizeHint());
177 popup->setMainWidget(picker); 174 popup->setMainWidget(picker);
178 picker->setFocus(); 175 picker->setFocus();
179 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 176 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
180 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) 177 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
181 { 178 {
182 month = picker->getResult(); 179 month = picker->getResult();
183 emit monthSelected ( month ); 180 emit monthSelected ( month );
184 } else { 181 } else {
185 KNotifyClient::beep(); 182 KNotifyClient::beep();
186 } 183 }
187 delete popup; 184 delete popup;
188} 185}
189void NavigatorBar::selectDates( const KCal::DateList &dateList ) 186void NavigatorBar::selectDates( const KCal::DateList &dateList )
190{ 187{
191 if (dateList.count() > 0) { 188 if (dateList.count() > 0) {
192 QDate date = dateList.first(); 189 QDate date = dateList.first();
193 190
194 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 191 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
195 192
196 // compute the label at the top of the navigator 193 // compute the label at the top of the navigator
197 QString dtstr = i18n(calSys->monthName( date )) + " '" + 194 QString dtstr = i18n(calSys->monthName( date )) + " '" +
198 QString::number( calSys->year( date ) ).right(2); 195 QString::number( calSys->year( date ) ).right(2);
199 196
200 mSelectMonth->setText( dtstr ); 197 mSelectMonth->setText( dtstr );
201 } 198 }
202} 199}
203 200