summaryrefslogtreecommitdiffabout
path: root/korganizer/navigatorbar.cpp
Unidiff
Diffstat (limited to 'korganizer/navigatorbar.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/navigatorbar.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index f6a1a6a..59c3e45 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -1,255 +1,258 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qframe.h> 29#include <q3frame.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpopupmenu.h> 31#include <q3popupmenu.h>
32#include <qapplication.h> 32#include <qapplication.h>
33#include <QDesktopWidget>
34//Added by qt3to4:
35#include <Q3HBoxLayout>
33 36
34#include <kdebug.h> 37#include <kdebug.h>
35#include <klocale.h> 38#include <klocale.h>
36#include <kglobal.h> 39#include <kglobal.h>
37#include <kiconloader.h> 40#include <kiconloader.h>
38#include "libkdepim/kdatepicker.h" 41#include "libkdepim/kdatepicker.h"
39#include <knotifyclient.h> 42#include <knotifyclient.h>
40#include "kdatetbl.h" 43#include "kdatetbl.h"
41 44
42#include "koglobals.h" 45#include "koglobals.h"
43#include <kglobalsettings.h> 46#include <kglobalsettings.h>
44#include "koprefs.h" 47#include "koprefs.h"
45#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
46#include "kocore.h" 49#include "kocore.h"
47#endif 50#endif
48 51
49#include <kcalendarsystem.h> 52#include <kcalendarsystem.h>
50 53
51#include "navigatorbar.h" 54#include "navigatorbar.h"
52 55
53NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) 56NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
54 : QWidget( parent, name ) 57 : QWidget( parent, name )
55{ 58{
56 QBoxLayout *topLayout = new QHBoxLayout( this ); 59 Q3BoxLayout *topLayout = new Q3HBoxLayout( this );
57 60
58 // Set up the control buttons and date label 61 // Set up the control buttons and date label
59 mCtrlFrame = new QFrame( this ); 62 mCtrlFrame = new Q3Frame( this );
60 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); 63 mCtrlFrame->setFrameStyle(Q3Frame::Panel|Q3Frame::Raised);
61 mCtrlFrame->setLineWidth(1); 64 mCtrlFrame->setLineWidth(1);
62 65
63 topLayout->addWidget( mCtrlFrame ); 66 topLayout->addWidget( mCtrlFrame );
64 67
65 68
66 69
67 bool isRTL = KOGlobals::self()->reverseLayout(); 70 bool isRTL = KOGlobals::self()->reverseLayout();
68#ifndef DESKTOP_VERSION 71#ifndef DESKTOP_VERSION
69 bool isDesktop = false; 72 bool isDesktop = false;
70#else 73#else
71 bool isDesktop = true; 74 bool isDesktop = true;
72#endif 75#endif
73 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 76 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
74 isDesktop = true; 77 isDesktop = true;
75 // Create backward navigation buttons 78 // Create backward navigation buttons
76 mPrevYear = new QPushButton( mCtrlFrame ); 79 mPrevYear = new QPushButton( mCtrlFrame );
77 mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); 80 mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) );
78 QToolTip::add( mPrevYear, i18n("Previous Year") ); 81 QToolTip::add( mPrevYear, i18n("Previous Year") );
79 82
80 mPrevMonth = new QPushButton( mCtrlFrame ); 83 mPrevMonth = new QPushButton( mCtrlFrame );
81 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); 84 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") );
82 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 85 QToolTip::add( mPrevMonth, i18n("Previous Month") );
83 86
84 // Create forward navigation buttons 87 // Create forward navigation buttons
85 mNextMonth = new QPushButton( mCtrlFrame ); 88 mNextMonth = new QPushButton( mCtrlFrame );
86 mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); 89 mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") );
87 QToolTip::add( mNextMonth, i18n("Next Month") ); 90 QToolTip::add( mNextMonth, i18n("Next Month") );
88 91
89 mPrevWeek = new QPushButton( mCtrlFrame ); 92 mPrevWeek = new QPushButton( mCtrlFrame );
90 mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 93 mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
91 QToolTip::add( mPrevWeek, i18n("Previous Week") ); 94 QToolTip::add( mPrevWeek, i18n("Previous Week") );
92 95
93 // Create forward navigation buttons 96 // Create forward navigation buttons
94 mNextWeek = new QPushButton( mCtrlFrame ); 97 mNextWeek = new QPushButton( mCtrlFrame );
95 mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 98 mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
96 QToolTip::add( mNextWeek, i18n("Next Week") ); 99 QToolTip::add( mNextWeek, i18n("Next Week") );
97 100
98 mNextYear = new QPushButton( mCtrlFrame ); 101 mNextYear = new QPushButton( mCtrlFrame );
99 mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); 102 mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") );
100 QToolTip::add( mNextYear, i18n("Next Year") ); 103 QToolTip::add( mNextYear, i18n("Next Year") );
101 mSelectMonth = new QPushButton( mCtrlFrame ); 104 mSelectMonth = new QPushButton( mCtrlFrame );
102 // Create month name label 105 // Create month name label
103 //selectMonth->setFont( tfont ); 106 //selectMonth->setFont( tfont );
104 // selectMonth->setAlignment( AlignCenter ); 107 // selectMonth->setAlignment( AlignCenter );
105 //mDateLabel = new QLabel( selectMonth ); 108 //mDateLabel = new QLabel( selectMonth );
106 //mDateLabel->setFont( tfont ); 109 //mDateLabel->setFont( tfont );
107 //mDateLabel->setAlignment( AlignCenter ); 110 //mDateLabel->setAlignment( AlignCenter );
108 if ( QString ( name ) == QString("useBigPixmaps") ) { 111 if ( QString ( name ) == QString("useBigPixmaps") ) {
109 mNextMonth->setFlat( true); 112 mNextMonth->setFlat( true);
110 mNextWeek->setFlat( true); 113 mNextWeek->setFlat( true);
111 mNextYear->setFlat( true); 114 mNextYear->setFlat( true);
112 mSelectMonth->setFlat( true); 115 mSelectMonth->setFlat( true);
113 mPrevYear->setFlat( true); 116 mPrevYear->setFlat( true);
114 mPrevMonth->setFlat( true); 117 mPrevMonth->setFlat( true);
115 mPrevWeek->setFlat( true); 118 mPrevWeek->setFlat( true);
116 119
117 mPrevYear->setAutoRepeat( true ); 120 mPrevYear->setAutoRepeat( true );
118 mPrevMonth->setAutoRepeat( true ); 121 mPrevMonth->setAutoRepeat( true );
119 mNextMonth->setAutoRepeat( true ); 122 mNextMonth->setAutoRepeat( true );
120 mPrevWeek->setAutoRepeat( true ); 123 mPrevWeek->setAutoRepeat( true );
121 mNextWeek->setAutoRepeat( true ); 124 mNextWeek->setAutoRepeat( true );
122 mNextYear->setAutoRepeat( true ); 125 mNextYear->setAutoRepeat( true );
123 } else { 126 } else {
124 mPrevWeek->hide(); 127 mPrevWeek->hide();
125 mNextWeek->hide(); 128 mNextWeek->hide();
126 } 129 }
127 130
128 resetFont( font() ); 131 resetFont( font() );
129 132
130 133
131 // set up control frame layout 134 // set up control frame layout
132 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 135 Q3BoxLayout *ctrlLayout = new Q3HBoxLayout( mCtrlFrame, 1 );
133 ctrlLayout->addWidget( mPrevYear, 3 ); 136 ctrlLayout->addWidget( mPrevYear, 3 );
134 ctrlLayout->addWidget( mPrevMonth, 3 ); 137 ctrlLayout->addWidget( mPrevMonth, 3 );
135 ctrlLayout->addWidget( mPrevWeek, 3 ); 138 ctrlLayout->addWidget( mPrevWeek, 3 );
136 //ctrlLayout->addStretch( 1 ); 139 //ctrlLayout->addStretch( 1 );
137 // ctrlLayout->addSpacing( 1 ); 140 // ctrlLayout->addSpacing( 1 );
138 // ctrlLayout->addWidget( mDateLabel ); 141 // ctrlLayout->addWidget( mDateLabel );
139 ctrlLayout->addWidget( mSelectMonth ); 142 ctrlLayout->addWidget( mSelectMonth );
140 // ctrlLayout->addSpacing( 1 ); 143 // ctrlLayout->addSpacing( 1 );
141 // ctrlLayout->addStretch( 1 ); 144 // ctrlLayout->addStretch( 1 );
142 ctrlLayout->addWidget( mNextWeek, 3 ); 145 ctrlLayout->addWidget( mNextWeek, 3 );
143 ctrlLayout->addWidget( mNextMonth, 3 ); 146 ctrlLayout->addWidget( mNextMonth, 3 );
144 ctrlLayout->addWidget( mNextYear, 3 ); 147 ctrlLayout->addWidget( mNextYear, 3 );
145 148
146 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 149 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
147 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 150 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
148 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 151 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
149 connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); 152 connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) );
150 connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); 153 connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) );
151 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 154 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
152 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 155 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
153 mPrevYear->setFocusPolicy(NoFocus); 156 mPrevYear->setFocusPolicy(Qt::NoFocus);
154 mPrevMonth->setFocusPolicy(NoFocus); 157 mPrevMonth->setFocusPolicy(Qt::NoFocus);
155 mNextMonth->setFocusPolicy(NoFocus); 158 mNextMonth->setFocusPolicy(Qt::NoFocus);
156 mPrevWeek->setFocusPolicy(NoFocus); 159 mPrevWeek->setFocusPolicy(Qt::NoFocus);
157 mNextWeek->setFocusPolicy(NoFocus); 160 mNextWeek->setFocusPolicy(Qt::NoFocus);
158 mNextYear->setFocusPolicy(NoFocus); 161 mNextYear->setFocusPolicy(Qt::NoFocus);
159 mSelectMonth->setFocusPolicy(NoFocus); 162 mSelectMonth->setFocusPolicy(Qt::NoFocus);
160 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 163 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
161 164
162} 165}
163 166
164NavigatorBar::~NavigatorBar() 167NavigatorBar::~NavigatorBar()
165{ 168{
166} 169}
167QSize NavigatorBar::sizeHint() const 170QSize NavigatorBar::sizeHint() const
168{ 171{
169 int wid = mCurrentMinWid ; 172 int wid = mCurrentMinWid ;
170 if ( mPrevYear->isVisible() ) 173 if ( mPrevYear->isVisible() )
171 wid += mCurrentButtonMinWid; 174 wid += mCurrentButtonMinWid;
172 if ( mPrevMonth->isVisible() ) 175 if ( mPrevMonth->isVisible() )
173 wid += mCurrentButtonMinWid; 176 wid += mCurrentButtonMinWid;
174 if ( mPrevWeek->isVisible() ) 177 if ( mPrevWeek->isVisible() )
175 wid += mCurrentButtonMinWid; 178 wid += mCurrentButtonMinWid;
176 if ( mNextMonth->isVisible() ) 179 if ( mNextMonth->isVisible() )
177 wid += mCurrentButtonMinWid; 180 wid += mCurrentButtonMinWid;
178 if ( mNextWeek->isVisible() ) 181 if ( mNextWeek->isVisible() )
179 wid += mCurrentButtonMinWid; 182 wid += mCurrentButtonMinWid;
180 if ( mNextYear->isVisible() ) 183 if ( mNextYear->isVisible() )
181 wid += mCurrentButtonMinWid; 184 wid += mCurrentButtonMinWid;
182 //qDebug("ret %d %d ", wid, mCurrentHei); 185 //qDebug("ret %d %d ", wid, mCurrentHei);
183 return QSize ( wid, mCurrentHei ); 186 return QSize ( wid, mCurrentHei );
184} 187}
185QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const 188QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const
186{ 189{
187 return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); 190 return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei );
188} 191}
189void NavigatorBar::resetFont ( QFont fo ) 192void NavigatorBar::resetFont ( QFont fo )
190{ 193{
191 194
192 QFont tfont = fo; 195 QFont tfont = fo;
193 if ( QApplication::desktop()->width() >= 480 ) 196 if ( QApplication::desktop()->width() >= 480 )
194 tfont.setPointSize(tfont.pointSize()+2); 197 tfont.setPointSize(tfont.pointSize()+2);
195 tfont.setBold(true); 198 tfont.setBold(true);
196 199
197 mSelectMonth->setFont( tfont ); 200 mSelectMonth->setFont( tfont );
198 // Set minimum width to width of widest month name label 201 // Set minimum width to width of widest month name label
199 int i; 202 int i;
200 int maxwidth = 0; 203 int maxwidth = 0;
201 QFontMetrics fm ( mSelectMonth->font() ); 204 QFontMetrics fm ( mSelectMonth->font() );
202 int width = fm.width("September '00" ); 205 int width = fm.width("September '00" );
203 maxwidth = width+2; 206 maxwidth = width+2;
204 int size = fm.height()+2; 207 int size = fm.height()+2;
205 if ( QApplication::desktop()->width() >= 480 ) { 208 if ( QApplication::desktop()->width() >= 480 ) {
206 size += 6; 209 size += 6;
207 maxwidth+= 6; 210 maxwidth+= 6;
208 } 211 }
209 mSelectMonth->setMinimumWidth( maxwidth ); 212 mSelectMonth->setMinimumWidth( maxwidth );
210 mSelectMonth->setFixedHeight( size ); 213 mSelectMonth->setFixedHeight( size );
211 mPrevYear->setFixedHeight( size ); 214 mPrevYear->setFixedHeight( size );
212 mPrevMonth->setFixedHeight( size ); 215 mPrevMonth->setFixedHeight( size );
213 mPrevWeek->setFixedHeight( size ); 216 mPrevWeek->setFixedHeight( size );
214 mNextMonth->setFixedHeight( size ); 217 mNextMonth->setFixedHeight( size );
215 mNextWeek->setFixedHeight( size ); 218 mNextWeek->setFixedHeight( size );
216 mNextYear->setFixedHeight ( size ); 219 mNextYear->setFixedHeight ( size );
217 mCurrentHei = size +2; 220 mCurrentHei = size +2;
218 mCurrentMinWid = maxwidth+2; 221 mCurrentMinWid = maxwidth+2;
219 mCurrentButtonMinWid = mPrevYear->sizeHint().width(); 222 mCurrentButtonMinWid = mPrevYear->sizeHint().width();
220} 223}
221 224
222void NavigatorBar::showButtons( bool left, bool right ) 225void NavigatorBar::showButtons( bool left, bool right )
223{ 226{
224 if ( left ) { 227 if ( left ) {
225 mPrevYear->show(); 228 mPrevYear->show();
226 mPrevMonth->show(); 229 mPrevMonth->show();
227 } else { 230 } else {
228 mPrevYear->hide(); 231 mPrevYear->hide();
229 mPrevMonth->hide(); 232 mPrevMonth->hide();
230 } 233 }
231 234
232 if ( right ) { 235 if ( right ) {
233 mNextYear->show(); 236 mNextYear->show();
234 mNextMonth->show(); 237 mNextMonth->show();
235 } else { 238 } else {
236 mNextYear->hide(); 239 mNextYear->hide();
237 mNextMonth->hide(); 240 mNextMonth->hide();
238 } 241 }
239 if ( !left && !right ) { 242 if ( !left && !right ) {
240 //mSelectMonth->setMaximumWidth( 1024 ); 243 //mSelectMonth->setMaximumWidth( 1024 );
241 mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 244 mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
242 } 245 }
243} 246}
244 247
245void NavigatorBar::selectMonth() 248void NavigatorBar::selectMonth()
246{ 249{
247 250
248 int month; 251 int month;
249 KPopupFrame* popup = new KPopupFrame(this); 252 KPopupFrame* popup = new KPopupFrame(this);
250 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); 253 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup);
251 // ----- 254 // -----
252 picker->resize(picker->sizeHint()); 255 picker->resize(picker->sizeHint());
253 popup->setMainWidget(picker); 256 popup->setMainWidget(picker);
254 picker->setFocus(); 257 picker->setFocus();
255 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 258 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));