summaryrefslogtreecommitdiffabout
path: root/korganizer/navigatorbar.cpp
Unidiff
Diffstat (limited to 'korganizer/navigatorbar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/navigatorbar.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index f339c67..2406bb5 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -25,12 +25,13 @@
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 <qapplication.h> 32#include <qapplication.h>
32 33
33#include <kdebug.h> 34#include <kdebug.h>
34#include <klocale.h> 35#include <klocale.h>
35#include <kglobal.h> 36#include <kglobal.h>
36#include <kiconloader.h> 37#include <kiconloader.h>
@@ -68,13 +69,14 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
68 bool isRTL = KOGlobals::self()->reverseLayout(); 69 bool isRTL = KOGlobals::self()->reverseLayout();
69#ifndef DESKTOP_VERSION 70#ifndef DESKTOP_VERSION
70 bool isDesktop = false; 71 bool isDesktop = false;
71#else 72#else
72 bool isDesktop = true; 73 bool isDesktop = true;
73#endif 74#endif
74 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 75 bool insertWeek = (QString ( name ) == QString("useBigPixmaps")) ;
76 if ( insertWeek && QApplication::desktop()->width() > 320 )
75 isDesktop = true; 77 isDesktop = true;
76 // Create backward navigation buttons 78 // Create backward navigation buttons
77 mPrevYear = new QPushButton( mCtrlFrame ); 79 mPrevYear = new QPushButton( mCtrlFrame );
78 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 80 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
79 QToolTip::add( mPrevYear, i18n("Previous Year") ); 81 QToolTip::add( mPrevYear, i18n("Previous Year") );
80 82
@@ -84,12 +86,19 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
84 86
85 // Create forward navigation buttons 87 // Create forward navigation buttons
86 mNextMonth = new QPushButton( mCtrlFrame ); 88 mNextMonth = new QPushButton( mCtrlFrame );
87 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 89 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
88 QToolTip::add( mNextMonth, i18n("Next Month") ); 90 QToolTip::add( mNextMonth, i18n("Next Month") );
89 91
92 QPushButton * selWeek = 0;
93 if ( insertWeek ) {
94 selWeek = new QPushButton( mCtrlFrame );
95 QToolTip::add( selWeek, i18n("Select Week") );
96 selWeek->setFocusPolicy(NoFocus);
97 }
98
90 mNextYear = new QPushButton( mCtrlFrame ); 99 mNextYear = new QPushButton( mCtrlFrame );
91 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 100 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
92 QToolTip::add( mNextYear, i18n("Next Year") ); 101 QToolTip::add( mNextYear, i18n("Next Year") );
93 mSelectMonth = new QPushButton( mCtrlFrame ); 102 mSelectMonth = new QPushButton( mCtrlFrame );
94 // Create month name label 103 // Create month name label
95 //selectMonth->setFont( tfont ); 104 //selectMonth->setFont( tfont );
@@ -99,13 +108,15 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
99 //mDateLabel->setAlignment( AlignCenter ); 108 //mDateLabel->setAlignment( AlignCenter );
100 if ( QString ( name ) == QString("useBigPixmaps") ) { 109 if ( QString ( name ) == QString("useBigPixmaps") ) {
101 mNextMonth->setFlat( true); 110 mNextMonth->setFlat( true);
102 mNextYear->setFlat( true); 111 mNextYear->setFlat( true);
103 mSelectMonth->setFlat( true); 112 mSelectMonth->setFlat( true);
104 mPrevYear->setFlat( true); 113 mPrevYear->setFlat( true);
105 mPrevMonth->setFlat( true); 114 mPrevMonth->setFlat( true);
115 if ( insertWeek )
116 selWeek->setFlat( true);
106 } 117 }
107 mSelectMonth->setFont( tfont ); 118 mSelectMonth->setFont( tfont );
108 // Set minimum width to width of widest month name label 119 // Set minimum width to width of widest month name label
109 int i; 120 int i;
110 int maxwidth = 0; 121 int maxwidth = 0;
111 QFontMetrics fm ( mSelectMonth->font() ); 122 QFontMetrics fm ( mSelectMonth->font() );
@@ -120,12 +131,28 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
120 maxwidth = width+2; 131 maxwidth = width+2;
121 int size = fm.height()+2; 132 int size = fm.height()+2;
122 if ( QApplication::desktop()->width() >= 480 ) { 133 if ( QApplication::desktop()->width() >= 480 ) {
123 size += 6; 134 size += 6;
124 maxwidth+= 6; 135 maxwidth+= 6;
125 } 136 }
137
138 if ( insertWeek ) {
139 //shit : bug in Qt. after inserting 53 item, only 51 are shown...
140 QPopupMenu * wpo = new QPopupMenu (this);
141 wpo->insertItem( i18n("W#"), 0 );
142 for ( i = 1; i < 53; ++i ) {
143 wpo->insertItem( QString::number(i), i );
144 }
145 for ( i = 53; i < 54; ++i ) {
146 wpo->insertItem( "", 52 );
147 }
148 selWeek->setPopup( wpo );
149 selWeek->setFixedWidth( (size/4)*3 );
150 selWeek->setFixedHeight( size );
151 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) );
152 }
126 mSelectMonth->setFixedWidth( maxwidth ); 153 mSelectMonth->setFixedWidth( maxwidth );
127 mSelectMonth->setFixedHeight( size ); 154 mSelectMonth->setFixedHeight( size );
128 mPrevYear->setFixedHeight( size ); 155 mPrevYear->setFixedHeight( size );
129 mPrevMonth->setFixedHeight( size ); 156 mPrevMonth->setFixedHeight( size );
130 mNextMonth->setFixedHeight( size ); 157 mNextMonth->setFixedHeight( size );
131 mNextYear->setFixedHeight ( size ); 158 mNextYear->setFixedHeight ( size );
@@ -138,23 +165,26 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
138 // ctrlLayout->addWidget( mDateLabel ); 165 // ctrlLayout->addWidget( mDateLabel );
139 ctrlLayout->addWidget( mSelectMonth ); 166 ctrlLayout->addWidget( mSelectMonth );
140 // ctrlLayout->addSpacing( 1 ); 167 // ctrlLayout->addSpacing( 1 );
141 // ctrlLayout->addStretch( 1 ); 168 // ctrlLayout->addStretch( 1 );
142 ctrlLayout->addWidget( mNextMonth, 3 ); 169 ctrlLayout->addWidget( mNextMonth, 3 );
143 ctrlLayout->addWidget( mNextYear, 3 ); 170 ctrlLayout->addWidget( mNextYear, 3 );
171 if ( insertWeek )
172 ctrlLayout->addWidget( selWeek );
144 173
145 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 174 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
146 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 175 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
147 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 176 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
148 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 177 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
149 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 178 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
150 mPrevYear->setFocusPolicy(NoFocus); 179 mPrevYear->setFocusPolicy(NoFocus);
151 mPrevMonth->setFocusPolicy(NoFocus); 180 mPrevMonth->setFocusPolicy(NoFocus);
152 mNextMonth->setFocusPolicy(NoFocus); 181 mNextMonth->setFocusPolicy(NoFocus);
153 mNextYear->setFocusPolicy(NoFocus); 182 mNextYear->setFocusPolicy(NoFocus);
154 mSelectMonth->setFocusPolicy(NoFocus); 183 mSelectMonth->setFocusPolicy(NoFocus);
184
155} 185}
156 186
157NavigatorBar::~NavigatorBar() 187NavigatorBar::~NavigatorBar()
158{ 188{
159} 189}
160 190