author | zautrix <zautrix> | 2005-04-17 10:42:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-17 10:42:07 (UTC) |
commit | ff7743ec82aa6d70325e613d0a1054c7de83a76c (patch) (side-by-side diff) | |
tree | e6d4c46a26e120817acd5ab7e47ef41b1428700b /korganizer/komonthview.cpp | |
parent | fd67a473a94c5a3d63a89c52fb8f612cb19b5363 (diff) | |
download | kdepimpi-ff7743ec82aa6d70325e613d0a1054c7de83a76c.zip kdepimpi-ff7743ec82aa6d70325e613d0a1054c7de83a76c.tar.gz kdepimpi-ff7743ec82aa6d70325e613d0a1054c7de83a76c.tar.bz2 |
fixes
-rw-r--r-- | korganizer/komonthview.cpp | 95 |
1 files changed, 85 insertions, 10 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index b175f9a..2b7e41f 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -406,12 +406,22 @@ void MonthViewItem::paint(QPainter *p) yPos = pmheight/2 - fm.height()/2 + fm.ascent(); p->setPen( palette().color( QPalette::Normal, sel ? \ QColorGroup::HighlightedText : QColorGroup::Foreground ) ); - p->drawText( x, yPos, text() ); - if ( mIncidence->cancelled() ) { - int wid = fm.width( text() ); - p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); - } - + 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(); + if( pText.mid(2,1) == ":" ) + pText = pText.mid( 6 ); + p->drawText( x, yPos, pText ); + if ( mIncidence->cancelled() ) { + int wid = fm.width( pText ); + p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); + } + } } int MonthViewItem::height(const QListBox *lb) const @@ -1042,6 +1052,7 @@ void MonthViewCell::newEvent() } void MonthViewCell::cellClicked( QListBoxItem *item ) { + mMonthView->setSelectedCell( this ); qDebug("CELL "); if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); @@ -1053,8 +1064,11 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) void MonthViewCell::contextMenu( QListBoxItem *item ) { - if ( !item ) return; - + mMonthView->setPopupCell( this ); + if ( !item ) { + mMonthView->showContextMenu( 0 ); + return; + } MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->showContextMenu( incidence ); @@ -1083,6 +1097,7 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) mShortDayLabelsW = false; skipResize = false; clPending = true; + mPopupCell = 0; mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); mWidStack = new QWidgetStack( this ); QVBoxLayout* hb = new QVBoxLayout( this ); @@ -1200,6 +1215,29 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) //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()); @@ -1893,7 +1931,12 @@ void KOMonthView::computeLayout() void KOMonthView::showContextMenu( Incidence *incidence ) { - mContextMenu->showIncidencePopup(incidence); + if( incidence ) + mContextMenu->showIncidencePopup(incidence); + else { + //qDebug("KOMonthView::showContextMenu "); + mNewItemMenu->popup(QCursor::pos()); + } /* if( incidence && incidence->type() == "Event" ) { Event *event = static_cast<Event *>(incidence); @@ -1909,7 +1952,7 @@ MonthViewCell * KOMonthView::selectedCell( ) } void KOMonthView::setSelectedCell( MonthViewCell *cell ) { - //qDebug("KOMonthView::setSelectedCell "); + //qDebug("KOMonthView::setSelectedCell %d", cell); if ( mSelectedCell && mSelectedCell != cell ) { MonthViewCell * mvc = mSelectedCell; mSelectedCell = cell; @@ -2014,3 +2057,35 @@ void KOMonthView::prevCell() { focusNextPrevChild ( false ); } + +void KOMonthView::slotNewTodo() +{ + //qDebug("KOMonthView::slotNewTodo() "); + if ( mPopupCell ){ + QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); + emit newTodoSignal(dt,true); + } + mPopupCell = 0; +} +void KOMonthView::slotNewEvent() +{ + if ( mPopupCell ) { + QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); + emit newEventSignal( dt ); + } + //qDebug("KOMonthView::slotNewEvent() "); + mPopupCell = 0; +} + +void KOMonthView::slotEditJournal() +{ + if ( mPopupCell ) + emit showJournalSignal( 7, mPopupCell->date() ); + //qDebug("KOMonthView::slotEditJournal() "); + mPopupCell = 0; +} + +void KOMonthView::setPopupCell( MonthViewCell * c) +{ + mPopupCell = c; +} |