author | zautrix <zautrix> | 2005-06-28 07:40:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-28 07:40:22 (UTC) |
commit | 4385e73c51688f0b8b21bfe061c04a6c42e92701 (patch) (side-by-side diff) | |
tree | cc55a5cdfa999b9e285d37116901f4c0a2357b20 /korganizer | |
parent | 386f48c2011e49c7c145bad7754a725cabc25dd5 (diff) | |
download | kdepimpi-4385e73c51688f0b8b21bfe061c04a6c42e92701.zip kdepimpi-4385e73c51688f0b8b21bfe061c04a6c42e92701.tar.gz kdepimpi-4385e73c51688f0b8b21bfe061c04a6c42e92701.tar.bz2 |
fixx
-rw-r--r-- | korganizer/komonthview.cpp | 42 | ||||
-rw-r--r-- | korganizer/komonthview.h | 8 |
2 files changed, 25 insertions, 25 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 64b0e95..1c2d6a2 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -49,388 +49,388 @@ #include "koprefs.h" #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koglobals.h" #include <libkcal/kincidenceformatter.h> #include "komonthview.h" #define PIXMAP_SIZE 5 #ifdef DESKTOP_VERSION QToolTipGroup *MonthViewCell::mToolTipGroup = 0; #endif class KNOWhatsThis :public QWhatsThis { public: KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; protected: virtual QString text( const QPoint& p) { return _wid->getWhatsThisText(p) ; }; private: KNoScrollListBox* _wid; }; KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) : QListBox(parent, name, WRepaintNoErase) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mWT = new KNOWhatsThis(this); resetOnFocusIn = true; setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } KNoScrollListBox::~KNoScrollListBox() { #if QT_VERSION >= 0x030000 #else delete mWT; #endif } void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) { QListBox::focusInEvent ( e ); if ( count() ){ int ci = currentItem(); if ( ci < 0 ) ci = 0; setCurrentItem( ci ); setSelected ( ci, true ); emit highlighted( item ( ci ) ); resetOnFocusIn = true; if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { QListBoxItem *fi = firstItem (); if (fi ) { int ihei = fi->height( this ); int hei = numRows () * ihei; if ( hei < height() - horizontalScrollBar()->height () ) { setVScrollBarMode(QScrollView::AlwaysOff); } else setVScrollBarMode(QScrollView::Auto); if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); } else { setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } } } } void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) { int i = currentItem (); if ( i >= 0 ) { setSelected ( i, false ); } QListBox::focusOutEvent ( e ); setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); - emit highligtIncidence( 0, (MonthViewCell*)this, 0 ); + emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); } 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(), KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); } void KNoScrollListBox::keyPressEvent(QKeyEvent *e) { //qDebug("KNoScrollListBox::keyPressEvent "); switch(e->key()) { case Key_Right: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } scrollBy(10,0); break; case Key_Left: if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } scrollBy(-10,0); break; case Key_Up: if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } if ( count() ) { if ( currentItem() == 0 ) { emit prevCell(); } else { 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(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } if ( count () ) { if ( currentItem()+1 == count () ) { emit nextCell(); } else { setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { setTopItem(topItem()+1); } } } } break; case Key_I: QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); e->ignore(); break; case Key_Return: case Key_Enter: { if ( currentItem() >= 0 ) { emit doubleClicked( item( currentItem() ) ); e->accept(); } else { e->ignore(); } } break; case Key_Shift: emit shiftDown(); break; default: e->ignore(); break; } } void KNoScrollListBox::oneDown() { if ( count () ) { if ( currentItem()+1 == count () ) { emit nextCell(); } else { resetOnFocusIn = false; 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) { QListBox::mousePressEvent(e); if(e->button() == RightButton) { emit rightClick(); } } MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) : QListBoxItem() { mblockRepaint = true; isWeekItem = KOPrefs::instance()->mMonthViewWeek; recycle( incidence, s ); } void MonthViewItem::recycle( Incidence *incidence, const QString & s) { - mDisplayHightlighted = false; + mDisplayHighlighted = false; setText( s ); mMultiday = 0; mIncidence = incidence; mRecur = false; mAlarm = false; mReply = false; mInfo = false; mdayPos = 0; } bool MonthViewItem::setHighlightedFalse() { - if ( !mDisplayHightlighted ) + if ( !mDisplayHighlighted ) return false; - mDisplayHightlighted = false; + mDisplayHighlighted = false; return true; } bool MonthViewItem::setHighlighted( Incidence * inc ) { if ( inc == mIncidence ) { - if ( mDisplayHightlighted ) + if ( mDisplayHighlighted ) return false; - mDisplayHightlighted = true; + mDisplayHighlighted = true; return true; } else { - if ( !mDisplayHightlighted ) + if ( !mDisplayHighlighted ) return false; - mDisplayHightlighted = false; + mDisplayHighlighted = false; return true; } return false; } void MonthViewItem::paint(QPainter *p) { if ( mblockRepaint || !mIncidence ) { return; } #if QT_VERSION >= 0x030000 bool sel = isSelected(); #else bool sel = selected(); #endif int heihei = height( listBox () ); int x = 1; - if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel ) + if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) { p->setBackgroundColor( palette().color( QPalette::Normal, \ - sel ||mDisplayHightlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); + sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); } //int y = 3;//(height() - mRecurPixmap.height()) /2; int size = PIXMAP_SIZE; if ( QApplication::desktop()->width() < 300 ) size = 3; int y = (heihei - size -1 ) /2; if ( mIncidence->calID() > 1 ) { p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); p->drawRect ( x, y-2,size,size+4); x += size + 1; } if ( KOPrefs::instance()->mMonthShowIcons ) { if ( mInfo ) { p->fillRect ( x, y,size,size, Qt::darkGreen ); x += size + 1; } if ( mRecur ) { p->fillRect ( x, y,size,size, Qt::blue ); x += size + 1; } if ( mAlarm ) { p->fillRect ( x, y,size,size, Qt::red ); x += size + 1; } if ( mReply ) { p->fillRect ( x, y,size,size, Qt::yellow ); x += size + 1; } } if ( mMultiday ) { int yyy = y+(size/2); int sizeM = size+2; p->setBrush( QBrush( p->pen().color() ) ); p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; if ( mMultiday == 2 || mMultiday == 3 ) { QPointArray pa ( 3 ); pa.setPoint (0, x, yyy ); pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); p->drawPolygon( pa ); } if ( mMultiday == 2 || mMultiday == 1 ) { QPointArray pa ( 3 ); pa.setPoint (0, x+sizeM +sizeM/2, yyy ); pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); p->drawPolygon( pa ); } if ( mMultiday == 1 ) { // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); } if ( mMultiday == 3 ) { // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); } x += sizeM/2 + 1; x += sizeM + 1; } if ( mIncidence->typeID() == todoID ){ Todo* td = ( Todo* ) mIncidence; if ( td->isCompleted() ) { int half = size/2; p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; x += half+half + 4; } else { int val = td->percentComplete()/20; p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); p->drawRect ( x, y-2,7,size+4); x += size + 3; } } QFontMetrics fm = p->fontMetrics(); int yPos; int pmheight = size; if( pmheight < fm.height() ) yPos = fm.ascent() + fm.leading()/2; else yPos = pmheight/2 - fm.height()/2 + fm.ascent(); p->setPen( palette().color( QPalette::Normal, sel ? \ QColorGroup::HighlightedText : QColorGroup::Foreground ) ); if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { p->drawText( x, yPos, text() ); if ( mIncidence->cancelled() ) { int wid = fm.width( text() ); p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); } } else { QString pText = text(); @@ -1007,474 +1007,474 @@ QDate MonthViewCell::selectedIncidenceDate() } void MonthViewCell::deselect() { clearSelection(); enableScrollBars( false ); // updateCell(); } void MonthViewCell::select() { ;// updateCell(); } void MonthViewCell::resizeEvent ( QResizeEvent * e ) { if ( !mMonthView->isUpdatePossible() ) return; //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); deselect(); mLabel->setMaximumHeight( height() - lineWidth()*2 ); QString text; mLabel->setText( text ); bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; mLabel->resize( mLabelBigSize ); text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); } else { mLabel->resize( mLabelSize ); text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); } mLabel->setText( text ); int size = height() - mLabel->height() - lineWidth()-1; //qDebug("LW %d ", lineWidth()); if ( size > 0 ) verticalScrollBar()->setMaximumHeight( size ); size = width() - mLabel->width() -lineWidth()-1; if ( size > 0 ) horizontalScrollBar()->setMaximumWidth( size ); mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); // mItemList->resize ( width(), height () ); if ( e ) KNoScrollListBox::resizeEvent ( e ); } void MonthViewCell::defaultAction( QListBoxItem *item ) { if ( !item ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->defaultAction( incidence ); } void MonthViewCell::showDay() { emit showDaySignal( date() ); } void MonthViewCell::newEvent() { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); } void MonthViewCell::cellClicked( QListBoxItem *item ) { mMonthView->setSelectedCell( this ); if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } } void MonthViewCell::contextMenu( QListBoxItem *item ) { mMonthView->setPopupCell( this ); if ( !item ) { mMonthView->showContextMenu( 0 ); return; } MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->showContextMenu( incidence ); } void MonthViewCell::selection( QListBoxItem *item ) { if ( !item ) { - emit highligtIncidence( 0 , this, 0 ); + emit highlightIncidence( 0 , this, 0 ); return; } MonthViewItem * it = (static_cast<MonthViewItem *>( item )); - emit highligtIncidence( it->incidence(), this, it->multiDay() ); + emit highlightIncidence( it->incidence(), this, it->multiDay() ); mMonthView->setSelectedCell( this ); } -void MonthViewCell::deHightLight() +void MonthViewCell::deHighLight() { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->setHighlightedFalse() ) updateItem ( mitem ); mitem = (MonthViewItem *)mitem->next(); } } // returns true if no inc found -bool MonthViewCell::doHightLight( Incidence * inc ) +bool MonthViewCell::doHighLight( Incidence * inc ) { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->incidence() == inc ) { if ( mitem->setHighlighted( inc ) ) updateItem ( mitem ); return false; } mitem = (MonthViewItem *)mitem->next(); } return true; } // ******************************************************************************* // ******************************************************************************* // ******************************************************************************* KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) : KOEventView( calendar, parent, name ), mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) { mFlagKeyPressed = false; mShortDayLabelsM = false; mShortDayLabelsW = false; skipResize = false; clPending = true; mPopupCell = 0; mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); mWidStack = new QWidgetStack( this ); QVBoxLayout* hb = new QVBoxLayout( this ); mMonthView = new QWidget( mWidStack ); mWeekView = new QWidget( mWidStack ); #if QT_VERSION >= 0x030000 mWidStack->addWidget(mMonthView ); mWidStack->addWidget(mWeekView ); #else mWidStack->addWidget( mMonthView, 1 ); mWidStack->addWidget( mWeekView , 1 ); #endif hb->addWidget( mNavigatorBar ); hb->addWidget( mWidStack ); mShowWeekView = KOPrefs::instance()->mMonthViewWeek; updatePossible = false; //updatePossible = true; mCells.setAutoDelete( true ); mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; mDayLabels.resize( mDaysPerWeek ); mDayLabelsW.resize( mDaysPerWeek ); QFont bfont = font(); if ( QApplication::desktop()->width() < 650 ) { bfont.setPointSize( bfont.pointSize() - 2 ); } bfont.setBold( true ); int i; for( i = 0; i < mDaysPerWeek; i++ ) { QLabel *label = new QLabel( mMonthView ); label->setFont(bfont); label->setFrameStyle(QFrame::Panel|QFrame::Raised); label->setLineWidth(1); label->setAlignment(AlignCenter); mDayLabels.insert( i, label ); label = new QLabel( mWeekView ); 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")); mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 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")); mWeekLabelsW[1]->setFocusPolicy(WheelFocus); int row, col; mCells.resize( mNumCells ); for( row = 0; row < mNumWeeks; ++row ) { for( col = 0; col < mDaysPerWeek; ++col ) { MonthViewCell *cell = new MonthViewCell( this, mMonthView ); mCells.insert( row * mDaysPerWeek + col, cell ); connect( cell, SIGNAL( defaultAction( Incidence * ) ), SLOT( defaultAction( Incidence * ) ) ); connect( cell, SIGNAL( newEventSignal( QDateTime ) ), SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); connect( cell, SIGNAL( nextCell() ), SLOT( nextCell() ) ); connect( cell, SIGNAL( prevCell() ), SLOT( prevCell() ) ); - connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), + connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); } } mCellsW.resize( mDaysPerWeek ); for( col = 0; col < mDaysPerWeek; ++col ) { MonthViewCell *cell = new MonthViewCell( this, mWeekView ); mCellsW.insert( col, cell ); connect( cell, SIGNAL( defaultAction( Incidence * ) ), SLOT( defaultAction( Incidence * ) ) ); connect( cell, SIGNAL( newEventSignal( QDateTime ) ), SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); connect( cell, SIGNAL( nextCell() ), SLOT( nextCell() ) ); connect( cell, SIGNAL( prevCell() ), SLOT( prevCell() ) ); - connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), + connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); } //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); mContextMenu = eventPopup(); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("New Event..."),this, SLOT(slotNewEvent()),false); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("New Todo..."),this, SLOT(slotNewTodo()),false); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Journal"),this, SLOT(slotEditJournal()),false); QString pathString = ""; if ( !KOPrefs::instance()->mToolBarMiniIcons ) { if ( QApplication::desktop()->width() < 480 ) pathString += "icons16/"; } else pathString += "iconsmini/"; mNewItemMenu = new QPopupMenu( this ); mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); // updateConfig(); //useless here... // ... but we need mWidthLongDayLabel computed QFontMetrics fontmetric(mDayLabels[0]->font()); mWidthLongDayLabel = 0; for (int i = 0; i < 7; i++) { int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; } //mWeekLabels[mNumWeeks]->setText( i18n("W")); #if 0 if ( mShowWeekView ) mWidStack->raiseWidget( mWeekView ); else mWidStack->raiseWidget( mMonthView ); #endif emit incidenceSelected( 0 ); mComputeLayoutTimer = new QTimer( this ); connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); #ifndef DESKTOP_VERSION resize( QApplication::desktop()->size() ); #else resize(640, 480 ); updatePossible = true; #endif computeLayout(); if ( mShowWeekView ) mWidStack->raiseWidget( mWeekView ); else mWidStack->raiseWidget( mMonthView ); } KOMonthView::~KOMonthView() { delete mContextMenu; } void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) { - //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); + qDebug("11 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); static Incidence * lastInc = 0; static MonthViewCell * lastCell = 0; if ( lastInc == inc && lastCell == mc ) return; lastInc = inc; lastCell = mc; - //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); + qDebug("222 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); bool weekview = false; int index = 0; for (uint i = 0; i < mCellsW.count(); ++i) { if ( mCellsW[i] == mc ) { weekview = true; index = i; break; } } QPtrVector<MonthViewCell> *cells; if ( weekview ) cells = &mCellsW; else { for (uint i = 0; i < mCells.count(); ++i) { if ( mCells[i] == mc ) { index = i; break; } } cells = &mCells; } for (uint i = 0; i < (*cells).count(); ++i) { - (*cells)[i]->deHightLight(); + (*cells)[i]->deHighLight(); } if ( ! inc ) return; if ( mday > 1 && index > 0 ) for (int i = index-1; i >= 0; --i) { //qDebug("index %d iii %d ", index, i); - if ( (*cells)[(uint)i]->doHightLight(inc) ) + if ( (*cells)[(uint)i]->doHighLight(inc) ) break; } if ( mday < 3 && mday > 0 && index < (*cells).count()-1) for (uint i = index+1; i < (*cells).count(); ++i) { - if ( (*cells)[i]->doHightLight(inc) ) + if ( (*cells)[i]->doHighLight(inc) ) break; } } void KOMonthView::selectInternalWeekNum ( int n ) { switchView(); if ( !KOPrefs::instance()->mMonthViewWeek ) emit selectMonth (); else 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; if ( clPending ) { computeLayout(); updateConfig(); } if ( mShowWeekView ) mWidStack->raiseWidget( mWeekView ); else mWidStack->raiseWidget( mMonthView ); clPending = false; } int KOMonthView::maxDatesHint() { return mNumCells; } int KOMonthView::currentDateCount() { return mNumCells; } QPtrList<Incidence> KOMonthView::selectedIncidences() { QPtrList<Incidence> selected; if ( mSelectedCell ) { Incidence *incidence = mSelectedCell->selectedIncidence(); if ( incidence ) selected.append( incidence ); } return selected; } DateList KOMonthView::selectedDates() { DateList selected; if ( mSelectedCell ) { QDate qd = mSelectedCell->selectedIncidenceDate(); if ( qd.isValid() ) selected.append( qd ); } return selected; } void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Month, fd, td); #endif } void KOMonthView::updateConfig() { int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { mWeekStartsMonday = true; } QFontMetrics fontmetric(mDayLabels[0]->font()); mWidthLongDayLabel = 0; for (int i = 0; i < 7; i++) { int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; } bool temp = mShowSatSunComp ; mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; if ( ! mShowWeekView ) { diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 2622d10..0f3aa54 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -1,278 +1,278 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _KOMONTHVIEW_H #define _KOMONTHVIEW_H #include <qlabel.h> #include <qframe.h> #include <qdatetime.h> #include <qlistbox.h> #include <qpoint.h> #include <qwidgetstack.h> #include <qlayout.h> #include <qtimer.h> #include <qintdict.h> #include <qpushbutton.h> #include <qvaluelist.h> #include <qptrvector.h> #include <libkcal/calendar.h> #include <libkcal/event.h> #include "koeventview.h" #include "navigatorbar.h" #ifdef DESKTOP_VERSION class QToolTipGroup; #endif class KNOWhatsThis; class MonthViewCell; 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: void focusInEvent ( QFocusEvent * ){;} int mNumber; void keyPressEvent ( QKeyEvent * e ) { e->ignore(); } 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(); void nextCell(); void prevCell(); - void highligtIncidence( Incidence * , MonthViewCell*, int ); + void highlightIncidence( Incidence * , MonthViewCell*, int ); protected slots: void oneDown(); void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); void mousePressEvent(QMouseEvent *); void focusInEvent ( QFocusEvent * ); void focusOutEvent ( QFocusEvent * ); private: bool resetOnFocusIn; KNOWhatsThis * mWT; }; class MonthViewItem: public QListBoxItem { public: MonthViewItem( Incidence *,const QString & title ); void recycle( Incidence *incidence, const QString & s); void setRecur(bool on) { mRecur = on; } void setAlarm(bool on) { mAlarm = on; } void setReply(bool on) { mReply = on; } void setMoreInfo(bool on) { mInfo = on; } void setMultiDay(int type) { mMultiday = type; } int multiDay() { return mMultiday; } void setMultiDayPos(int type) { mdayPos = type; } int gettMultiDayPos() { return mdayPos; } void setBlockRepaint(bool on) { mblockRepaint = on; } bool setHighlighted( Incidence * ); void setPalette(const QPalette &p) { mPalette = p; } QPalette palette() const { return mPalette; } bool setHighlightedFalse(); Incidence *incidence() const { return mIncidence; } protected: virtual void paint(QPainter *); virtual int height(const QListBox *) const; virtual int width(const QListBox *) const; private: int mdayPos; bool isWeekItem; bool mblockRepaint; int mMultiday; bool mRecur; bool mAlarm; bool mReply; bool mInfo; - bool mDisplayHightlighted; + bool mDisplayHighlighted; QPalette mPalette; QDate mDate; Incidence *mIncidence; }; class KOMonthView; class MonthViewCell : public KNoScrollListBox { Q_OBJECT public: MonthViewCell(KOMonthView *,QWidget* ); ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} void setDate( const QDate & ); QDate date() const; void setPrimary( bool ); bool isPrimary() const; void setHoliday( bool ); void setHoliday( const QString & ); void updateCell(); void startUpdateCell(); void finishUpdateCell(); void repaintfinishUpdateCell(); int insertEvent(Event *); void insertTodo(Todo *); void updateConfig( bool bigFont = false ); void enableScrollBars( bool ); Incidence *selectedIncidence(); QDate selectedIncidenceDate(); QPushButton * dateLabel() { return mLabel; } - void deHightLight(); - bool doHightLight( Incidence *); + void deHighLight(); + bool doHighLight( Incidence *); void deselect(); void select(); #ifdef DESKTOP_VERSION static QToolTipGroup *toolTipGroup(); #endif signals: void defaultAction( Incidence * ); void newEventSignal( QDateTime ); void showDaySignal( QDate ); protected: QStringList mToolTip; void resizeEvent( QResizeEvent * ); public slots: void showDay(); protected slots: void defaultAction( QListBoxItem * ); void contextMenu( QListBoxItem * ); void selection( QListBoxItem * ); void cellClicked( QListBoxItem * ); void newEvent(); private: int mdayCount; QPtrList <MonthViewItem> mAvailItemList; KOMonthView *mMonthView; int currentPalette; QDate mDate; bool mPrimary; bool mHoliday; QString mHolidayString; //QLabel *mLabel; QPushButton *mLabel; //QListBox *mItemList; #ifdef DESKTOP_VERSION static QToolTipGroup *mToolTipGroup; #endif QSize mLabelSize; QSize mLabelBigSize; QPalette mHolidayPalette; QPalette mStandardPalette; QPalette mPrimaryPalette; QPalette mNonPrimaryPalette; void setMyPalette(); QPalette getPalette (); }; class KOMonthView: public KOEventView { Q_OBJECT public: KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); ~KOMonthView(); /** Returns maximum number of days supported by the komonthview */ virtual int maxDatesHint(); /** Returns number of currently shown dates. */ virtual int currentDateCount(); /** returns the currently selected events */ virtual QPtrList<Incidence> selectedIncidences(); /** returns dates of the currently selected events */ virtual DateList selectedDates(); virtual void printPreview(CalPrinter *calPrinter, const QDate &, const QDate &); bool isMonthView() { return !mShowWeekView; } bool isUpdatePossible() { return updatePossible; } MonthViewCell * selectedCell(); bool skipResize; NavigatorBar* navigatorBar() { return mNavigatorBar ;} void clearList(); public slots: void incidenceHighlighted( Incidence *, MonthViewCell*, int ); void nextCell(); void prevCell(); virtual void updateView(); virtual void updateConfig(); 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 * ); |