-rw-r--r-- | korganizer/navigatorbar.cpp | 22 | ||||
-rw-r--r-- | korganizer/navigatorbar.h | 4 |
2 files changed, 26 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 @@ -144,60 +144,82 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam 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 { diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h index 0b2f60b..5d5aff4 100644 --- a/korganizer/navigatorbar.h +++ b/korganizer/navigatorbar.h @@ -27,45 +27,49 @@ #include <libkcal/incidencebase.h> #include <qwidget.h> class QPushButton; class QFrame; class QLabel; class NavigatorBar: public QWidget { Q_OBJECT public: NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); ~NavigatorBar(); void showButtons( bool left, bool right ); void resetFont ( QFont fo ); + QSize sizeHint() const; public slots: void selectDates( const KCal::DateList & ); void selectMonth(); signals: void goNextMonth(); void goPrevMonth(); void goNextWeek(); void goPrevWeek(); void goNextYear(); void goPrevYear(); void monthSelected( int ); private: + int mCurrentHei; + int mCurrentMinWid; + int mCurrentButtonMinWid; QFrame *mCtrlFrame; QPushButton *mPrevYear; QPushButton *mPrevMonth; QPushButton *mNextMonth; QPushButton *mPrevWeek; QPushButton *mNextWeek; QPushButton *mNextYear; QPushButton *mSelectMonth; //QLabel *mDateLabel; }; #endif |