author | zautrix <zautrix> | 2005-02-04 22:22:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-04 22:22:10 (UTC) |
commit | 936b4b2aa37e699052a2517dc2d928d717398cf6 (patch) (side-by-side diff) | |
tree | 964ac33783c2126ecbaea0a2ee72b83ae6475b52 /korganizer | |
parent | 4659ee80518c7d5108c21ba04a12a25eab783113 (diff) | |
download | kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.zip kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.tar.gz kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.tar.bz2 |
fifi
-rw-r--r-- | korganizer/kdatenavigator.cpp | 2 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 52 | ||||
-rw-r--r-- | korganizer/komonthview.h | 4 |
3 files changed, 46 insertions, 12 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index f31e50a..c08f44f 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -49,25 +49,25 @@ KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, bool show_week_nums, const char *name, QDate startDate ) : QFrame(parent, name), updateTimer(0L) { mCalendar = calendar; setFrameStyle(QFrame::NoFrame); QGridLayout *topLayout = new QGridLayout(this,8,8); if (! startDate.isValid()) { - kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl; + qDebug("KDateNavigator::invalid startdate "); startDate = QDate::currentDate(); } mSelectedDates.append(startDate); m_MthYr = startDate; m_bShowWeekNums = show_week_nums; setFont( KOPrefs::instance()->mDateNavigatorFont ); mNavigatorBar = new NavigatorBar( startDate, this ); topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); //mNavigatorBar->resize( 1,1); connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index dfa89e2..df5e060 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -91,76 +91,91 @@ QString KNoScrollListBox::getWhatsThisText(QPoint p) { QListBoxItem* item = itemAt ( p ); if ( ! item ) { return i18n("Click in the cell\nto add an event!"); } return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); } void KNoScrollListBox::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Key_Right: - // if ( e->state() == Qt::ControlButton ) + if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } - scrollBy(4,0); + scrollBy(10,0); break; case Key_Left: - // if ( e->state() == Qt::ControlButton ) + if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } - scrollBy(-4,0); + scrollBy(-10,0); break; case Key_Up: - if(count() < 2) { + if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } setCurrentItem((currentItem()+count()-1)%count()); if(!itemVisible(currentItem())) { if((unsigned int) currentItem() == (count()-1)) { setTopItem(currentItem()-numItemsVisible()+1); } else { setTopItem(topItem()-1); } } break; case Key_Down: - if(count() < 2) { + if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { setTopItem(topItem()+1); } } break; + case Key_I: + QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); + e->ignore(); + break; case Key_Shift: emit shiftDown(); break; default: e->ignore(); break; } } +void KNoScrollListBox::oneDown() +{ + setCurrentItem((currentItem()+1)%count()); + if(!itemVisible(currentItem())) { + if(currentItem() == 0) { + setTopItem(0); + } else { + setTopItem(topItem()+1); + } + } +} void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) { switch(e->key()) { case Key_Shift: emit shiftUp(); break; default: break; } } void KNoScrollListBox::mousePressEvent(QMouseEvent *e) @@ -273,24 +288,25 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) : QWidget( par ), mMonthView( parent ) { QVBoxLayout *topLayout = new QVBoxLayout( this ); // mLabel = new QLabel( this );QPushButton mLabel = new QPushButton( this ); //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); //mLabel->setLineWidth( 1 ); //mLabel->setAlignment( AlignCenter ); mLabel->setFlat( true ); + mLabel->setFocusPolicy(NoFocus); mItemList = new KNoScrollListBox( this ); mItemList->setMinimumSize( 10, 10 ); mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); mItemList->setLineWidth( 1 ); topLayout->addWidget( mItemList ); mLabel->raise(); // QColor( 0,0,255 ) QColor( 160,1600,255 ) mStandardPalette = palette(); mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); enableScrollBars( false ); updateConfig(); @@ -392,26 +408,28 @@ void MonthViewCell::keyPressEvent ( QKeyEvent * e ) } void MonthViewCell::clear() { mItemList->clear(); QApplication::removePostedEvents ( mItemList ); QApplication::removePostedEvents ( mLabel ); QApplication::removePostedEvents ( this ); } void MonthViewCell::startUpdateCell() { + mItemList->setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) return; + /* if ( !isVisible() ){ return; } */ // qDebug("MonthViewCell::updateCell() "); setPrimary( mDate.month()%2 ); setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); if ( mDate == QDate::currentDate() ) { mItemList->setLineWidth( 3 ); } else { mItemList->setLineWidth( 1 ); @@ -424,24 +442,26 @@ void MonthViewCell::startUpdateCell() mToolTip = ""; //qApp->processEvents(); if ( !mHolidayString.isEmpty() ) { MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); item->setPalette( mHolidayPalette ); mItemList->insertItem( item ); mToolTip += mHolidayString+"\n"; } } void MonthViewCell::insertEvent(Event *event) { + + mItemList->setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) return; } if ( event->categories().contains("Holiday") || event->categories().contains(i18n("Holiday"))) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) @@ -529,25 +549,25 @@ void MonthViewCell::insertEvent(Event *event) mItemList->insertItem( item ); mToolTip += "\n"; } void MonthViewCell::insertTodo(Todo *todo) { QString text; if (todo->hasDueDate()) { if (!todo->doesFloat()) { text += KGlobal::locale()->formatTime(todo->dtDue().time()); text += " "; } } - text += i18n("To-Do: %1").arg(todo->summary()); + text += i18n("Td: %1").arg(todo->summary()); MonthViewItem *item = new MonthViewItem( todo, mDate, text ); //item->setPalette( mStandardPalette ); QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = todo->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); if (cat.isEmpty()) { pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); } else { @@ -817,38 +837,40 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) label->setFont(bfont); label->setFrameStyle(QFrame::Panel|QFrame::Raised); label->setLineWidth(1); label->setAlignment(AlignCenter); mDayLabelsW.insert( i, label ); } bfont.setBold( false ); mWeekLabels.resize( mNumWeeks+1 ); mWeekLabelsW.resize( 2 ); for( i = 0; i < mNumWeeks+1; i++ ) { KOWeekButton *label = new KOWeekButton( mMonthView ); + label->setFocusPolicy(NoFocus); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //label->setAlignment(AlignCenter); mWeekLabels.insert( i, label ); } mWeekLabels[mNumWeeks]->setText( i18n("W")); QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); for( i = 0; i < 1+1; i++ ) { KOWeekButton *label = new KOWeekButton( mWeekView ); + label->setFocusPolicy(NoFocus); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //label->setAlignment(AlignCenter); mWeekLabelsW.insert( i, label ); } mWeekLabelsW[1]->setText( i18n("W")); @@ -894,34 +916,37 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) if ( mShowWeekView ) mWidStack->raiseWidget( mWeekView ); else mWidStack->raiseWidget( mMonthView ); emit incidenceSelected( 0 ); } KOMonthView::~KOMonthView() { delete mContextMenu; } -void KOMonthView::selectDateWeekNum ( int ) -{ -} void KOMonthView::selectInternalWeekNum ( int n ) { switchView(); emit selectWeekNum ( n ); } +int KOMonthView::currentWeek() +{ + if ( mShowWeekView ) + return mWeekLabelsW[0]->getWeekNum(); + return mWeekLabels[0]->getWeekNum(); +} void KOMonthView::switchView() { if ( selectedCell( ) ) selectedCell()->deselect(); mShowWeekView = !mShowWeekView; KOPrefs::instance()->mMonthViewWeek = mShowWeekView; //emit showNavigator( !mShowWeekView ); if ( clPending ) { computeLayout(); updateConfig(); } @@ -1530,17 +1555,24 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) mCells[0]->setFocus(); } e->accept(); break; case Key_Down: { emit nextMonth(); mCells[0]->setFocus(); } e->accept(); break; + case Key_Return: + case Key_Enter: + { + selectInternalWeekNum ( currentWeek() ); + } + e->accept(); + break; default: e->ignore(); break; } } diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 700f098..51eb9e6 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -45,46 +45,48 @@ class KNOWhatsThis; class KOWeekButton : public QPushButton { Q_OBJECT public: KOWeekButton( QWidget *parent=0, const char *name=0 ) : QPushButton( parent, name) { connect( this, SIGNAL( clicked() ), SLOT( bottonClicked() )); mNumber = -1; } void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} + int getWeekNum() { return mNumber;} signals: void selectWeekNum ( int ); private: int mNumber; private slots : void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } }; class KNoScrollListBox: public QListBox { Q_OBJECT public: KNoScrollListBox(QWidget *parent=0, const char *name=0); ~KNoScrollListBox(); QString getWhatsThisText(QPoint p) ; signals: void shiftDown(); void shiftUp(); void rightClick(); protected slots: + void oneDown(); void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); void mousePressEvent(QMouseEvent *); private: KNOWhatsThis * mWT; }; class MonthViewItem: public QListBoxItem { public: @@ -232,40 +234,40 @@ class KOMonthView: public KOEventView virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); void changeEventDisplay(Event *, int); void clearSelection(); void showContextMenu( Incidence * ); void setSelectedCell( MonthViewCell * ); protected slots: - void selectDateWeekNum ( int ); void selectInternalWeekNum ( int ); void switchView(); void processSelectionChange(); signals: void nextMonth(); void prevMonth(); void showNavigator( bool ); void selectWeekNum ( int ); void showDaySignal( QDate ); protected: void resizeEvent(QResizeEvent *); void viewChanged(); void updateDayLabels(); private: + int currentWeek(); bool clPending; QWidgetStack * mWidStack; QWidget* mMonthView; QWidget* mWeekView; bool mShowWeekView; bool updatePossible; int mDaysPerWeek; int mNumWeeks; int mNumCells; bool mWeekStartsMonday; bool mShowSatSunComp; void computeLayout(); |