summaryrefslogtreecommitdiffabout
path: root/korganizer/navigatorbar.cpp
authorzautrix <zautrix>2005-02-08 16:58:16 (UTC)
committer zautrix <zautrix>2005-02-08 16:58:16 (UTC)
commit126b79abd88bb13ab41c4d987ee759eb9ba7d483 (patch) (unidiff)
tree45d26727b41c6f344152ed3f4ee1dd4bc97d58b0 /korganizer/navigatorbar.cpp
parent720510bf933a86211f8e9e2465788d141f0f1149 (diff)
downloadkdepimpi-126b79abd88bb13ab41c4d987ee759eb9ba7d483.zip
kdepimpi-126b79abd88bb13ab41c4d987ee759eb9ba7d483.tar.gz
kdepimpi-126b79abd88bb13ab41c4d987ee759eb9ba7d483.tar.bz2
ffff
Diffstat (limited to 'korganizer/navigatorbar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/navigatorbar.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index 7ba97c8..b591232 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -1,169 +1,163 @@
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 <qframe.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qapplication.h> 32#include <qapplication.h>
33 33
34#include <kdebug.h> 34#include <kdebug.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include "libkdepim/kdatepicker.h" 38#include "libkdepim/kdatepicker.h"
39#include <knotifyclient.h> 39#include <knotifyclient.h>
40#include "kdatetbl.h" 40#include "kdatetbl.h"
41 41
42#include "koglobals.h" 42#include "koglobals.h"
43#include <kglobalsettings.h> 43#include <kglobalsettings.h>
44#include "koprefs.h" 44#include "koprefs.h"
45#ifndef KORG_NOPLUGINS 45#ifndef KORG_NOPLUGINS
46#include "kocore.h" 46#include "kocore.h"
47#endif 47#endif
48 48
49#include <kcalendarsystem.h> 49#include <kcalendarsystem.h>
50 50
51#include "navigatorbar.h" 51#include "navigatorbar.h"
52 52
53NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) 53NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
54 : QWidget( parent, name ) 54 : QWidget( parent, name )
55{ 55{
56 QBoxLayout *topLayout = new QHBoxLayout( this ); 56 QBoxLayout *topLayout = new QHBoxLayout( this );
57 57
58 // Set up the control buttons and date label 58 // Set up the control buttons and date label
59 mCtrlFrame = new QFrame( this ); 59 mCtrlFrame = new QFrame( this );
60 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); 60 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
61 mCtrlFrame->setLineWidth(1); 61 mCtrlFrame->setLineWidth(1);
62 62
63 topLayout->addWidget( mCtrlFrame ); 63 topLayout->addWidget( mCtrlFrame );
64 64
65 QFont tfont = KGlobalSettings::generalFont();//font(); 65 QFont tfont = font();
66 int add = 0; 66 if ( QApplication::desktop()->width() >= 480 )
67 if ( QApplication::desktop()->width() >= 480 ) { 67 tfont.setPointSize(tfont.pointSize()+2);
68 add = 2;
69 if ( QString ( name ) == QString("useBigPixmaps") )
70 add += 2;
71 }
72 if ( add )
73 tfont.setPointSize(tfont.pointSize()+add);
74 tfont.setBold(true); 68 tfont.setBold(true);
75 69
76 bool isRTL = KOGlobals::self()->reverseLayout(); 70 bool isRTL = KOGlobals::self()->reverseLayout();
77#ifndef DESKTOP_VERSION 71#ifndef DESKTOP_VERSION
78 bool isDesktop = false; 72 bool isDesktop = false;
79#else 73#else
80 bool isDesktop = true; 74 bool isDesktop = true;
81#endif 75#endif
82 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 76 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
83 isDesktop = true; 77 isDesktop = true;
84 // Create backward navigation buttons 78 // Create backward navigation buttons
85 mPrevYear = new QPushButton( mCtrlFrame ); 79 mPrevYear = new QPushButton( mCtrlFrame );
86 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 80 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
87 QToolTip::add( mPrevYear, i18n("Previous Year") ); 81 QToolTip::add( mPrevYear, i18n("Previous Year") );
88 82
89 mPrevMonth = new QPushButton( mCtrlFrame ); 83 mPrevMonth = new QPushButton( mCtrlFrame );
90 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 84 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
91 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 85 QToolTip::add( mPrevMonth, i18n("Previous Month") );
92 86
93 // Create forward navigation buttons 87 // Create forward navigation buttons
94 mNextMonth = new QPushButton( mCtrlFrame ); 88 mNextMonth = new QPushButton( mCtrlFrame );
95 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 89 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
96 QToolTip::add( mNextMonth, i18n("Next Month") ); 90 QToolTip::add( mNextMonth, i18n("Next Month") );
97 91
98 mNextYear = new QPushButton( mCtrlFrame ); 92 mNextYear = new QPushButton( mCtrlFrame );
99 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 93 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
100 QToolTip::add( mNextYear, i18n("Next Year") ); 94 QToolTip::add( mNextYear, i18n("Next Year") );
101 mSelectMonth = new QPushButton( mCtrlFrame ); 95 mSelectMonth = new QPushButton( mCtrlFrame );
102 // Create month name label 96 // Create month name label
103 //selectMonth->setFont( tfont ); 97 //selectMonth->setFont( tfont );
104 // selectMonth->setAlignment( AlignCenter ); 98 // selectMonth->setAlignment( AlignCenter );
105 //mDateLabel = new QLabel( selectMonth ); 99 //mDateLabel = new QLabel( selectMonth );
106 //mDateLabel->setFont( tfont ); 100 //mDateLabel->setFont( tfont );
107 //mDateLabel->setAlignment( AlignCenter ); 101 //mDateLabel->setAlignment( AlignCenter );
108 if ( QString ( name ) == QString("useBigPixmaps") ) { 102 if ( QString ( name ) == QString("useBigPixmaps") ) {
109 mNextMonth->setFlat( true); 103 mNextMonth->setFlat( true);
110 mNextYear->setFlat( true); 104 mNextYear->setFlat( true);
111 mSelectMonth->setFlat( true); 105 mSelectMonth->setFlat( true);
112 mPrevYear->setFlat( true); 106 mPrevYear->setFlat( true);
113 mPrevMonth->setFlat( true); 107 mPrevMonth->setFlat( true);
114 } 108 }
115 mSelectMonth->setFont( tfont ); 109 mSelectMonth->setFont( tfont );
116 // Set minimum width to width of widest month name label 110 // Set minimum width to width of widest month name label
117 int i; 111 int i;
118 int maxwidth = 0; 112 int maxwidth = 0;
119 QFontMetrics fm ( mSelectMonth->font() ); 113 QFontMetrics fm ( mSelectMonth->font() );
120 int width = fm.width("September '00" ); 114 int width = fm.width("September '00" );
121// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); 115// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
122// ++i ) { 116// ++i ) {
123// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, 117// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
124// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); 118// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
125// int width = fm.width("September 2000" ); 119// int width = fm.width("September 2000" );
126// if ( width > maxwidth ) maxwidth = width; 120// if ( width > maxwidth ) maxwidth = width;
127// } 121// }
128 maxwidth = width+2; 122 maxwidth = width+2;
129 int size = fm.height()+2; 123 int size = fm.height()+2;
130 if ( QApplication::desktop()->width() >= 480 ) { 124 if ( QApplication::desktop()->width() >= 480 ) {
131 size += 6; 125 size += 6;
132 maxwidth+= 6; 126 maxwidth+= 6;
133 } 127 }
134 128
135 mSelectMonth->setFixedWidth( maxwidth ); 129 mSelectMonth->setFixedWidth( maxwidth );
136 mSelectMonth->setFixedHeight( size ); 130 mSelectMonth->setFixedHeight( size );
137 mPrevYear->setFixedHeight( size ); 131 mPrevYear->setFixedHeight( size );
138 mPrevMonth->setFixedHeight( size ); 132 mPrevMonth->setFixedHeight( size );
139 mNextMonth->setFixedHeight( size ); 133 mNextMonth->setFixedHeight( size );
140 mNextYear->setFixedHeight ( size ); 134 mNextYear->setFixedHeight ( size );
141 // set up control frame layout 135 // set up control frame layout
142 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 136 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
143 ctrlLayout->addWidget( mPrevYear, 3 ); 137 ctrlLayout->addWidget( mPrevYear, 3 );
144 ctrlLayout->addWidget( mPrevMonth, 3 ); 138 ctrlLayout->addWidget( mPrevMonth, 3 );
145 //ctrlLayout->addStretch( 1 ); 139 //ctrlLayout->addStretch( 1 );
146 // ctrlLayout->addSpacing( 1 ); 140 // ctrlLayout->addSpacing( 1 );
147 // ctrlLayout->addWidget( mDateLabel ); 141 // ctrlLayout->addWidget( mDateLabel );
148 ctrlLayout->addWidget( mSelectMonth ); 142 ctrlLayout->addWidget( mSelectMonth );
149 // ctrlLayout->addSpacing( 1 ); 143 // ctrlLayout->addSpacing( 1 );
150 // ctrlLayout->addStretch( 1 ); 144 // ctrlLayout->addStretch( 1 );
151 ctrlLayout->addWidget( mNextMonth, 3 ); 145 ctrlLayout->addWidget( mNextMonth, 3 );
152 ctrlLayout->addWidget( mNextYear, 3 ); 146 ctrlLayout->addWidget( mNextYear, 3 );
153 147
154 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 148 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
155 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 149 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
156 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 150 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
157 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 151 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
158 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 152 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
159 mPrevYear->setFocusPolicy(NoFocus); 153 mPrevYear->setFocusPolicy(NoFocus);
160 mPrevMonth->setFocusPolicy(NoFocus); 154 mPrevMonth->setFocusPolicy(NoFocus);
161 mNextMonth->setFocusPolicy(NoFocus); 155 mNextMonth->setFocusPolicy(NoFocus);
162 mNextYear->setFocusPolicy(NoFocus); 156 mNextYear->setFocusPolicy(NoFocus);
163 mSelectMonth->setFocusPolicy(NoFocus); 157 mSelectMonth->setFocusPolicy(NoFocus);
164 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 158 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
165 159
166} 160}
167 161
168NavigatorBar::~NavigatorBar() 162NavigatorBar::~NavigatorBar()
169{ 163{