summaryrefslogtreecommitdiffabout
path: root/korganizer/navigatorbar.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/navigatorbar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/navigatorbar.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index 4a51bba..e4abbf7 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -136,76 +136,98 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
ctrlLayout->addWidget( mNextMonth, 3 );
ctrlLayout->addWidget( mNextYear, 3 );
connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) );
connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) );
connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
mPrevYear->setFocusPolicy(NoFocus);
mPrevMonth->setFocusPolicy(NoFocus);
mNextMonth->setFocusPolicy(NoFocus);
mPrevWeek->setFocusPolicy(NoFocus);
mNextWeek->setFocusPolicy(NoFocus);
mNextYear->setFocusPolicy(NoFocus);
mSelectMonth->setFocusPolicy(NoFocus);
setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
}
NavigatorBar::~NavigatorBar()
{
}
+QSize NavigatorBar::sizeHint() const
+{
+ int wid = mCurrentMinWid ;
+ if ( mPrevYear->isVisible() )
+ wid += mCurrentButtonMinWid;
+ if ( mPrevMonth->isVisible() )
+ wid += mCurrentButtonMinWid;
+ if ( mPrevWeek->isVisible() )
+ wid += mCurrentButtonMinWid;
+ if ( mNextMonth->isVisible() )
+ wid += mCurrentButtonMinWid;
+ if ( mNextWeek->isVisible() )
+ wid += mCurrentButtonMinWid;
+ if ( mNextYear->isVisible() )
+ wid += mCurrentButtonMinWid;
+ //qDebug("ret %d %d ", wid, mCurrentHei);
+ int add = 2;
+ return QSize ( wid+add, mCurrentHei+add );
+}
void NavigatorBar::resetFont ( QFont fo )
{
QFont tfont = fo;
if ( QApplication::desktop()->width() >= 480 )
tfont.setPointSize(tfont.pointSize()+2);
tfont.setBold(true);
mSelectMonth->setFont( tfont );
// Set minimum width to width of widest month name label
int i;
int maxwidth = 0;
QFontMetrics fm ( mSelectMonth->font() );
int width = fm.width("September '00" );
maxwidth = width+2;
int size = fm.height()+2;
if ( QApplication::desktop()->width() >= 480 ) {
size += 6;
maxwidth+= 6;
}
mSelectMonth->setMinimumWidth( maxwidth );
mSelectMonth->setFixedHeight( size );
mPrevYear->setFixedHeight( size );
mPrevMonth->setFixedHeight( size );
mPrevWeek->setFixedHeight( size );
mNextMonth->setFixedHeight( size );
mNextWeek->setFixedHeight( size );
mNextYear->setFixedHeight ( size );
+ mCurrentHei = size;
+ mCurrentMinWid = maxwidth;
+ mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2;
}
void NavigatorBar::showButtons( bool left, bool right )
{
if ( left ) {
mPrevYear->show();
mPrevMonth->show();
} else {
mPrevYear->hide();
mPrevMonth->hide();
}
if ( right ) {
mNextYear->show();
mNextMonth->show();
} else {
mNextYear->hide();
mNextMonth->hide();
}
if ( !left && !right ) {
//mSelectMonth->setMaximumWidth( 1024 );
mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
}
}