summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp95
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
@@ -403,18 +403,28 @@ void MonthViewItem::paint(QPainter *p)
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 ) );
- 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
{
int ret = 10;
if ( lb )
@@ -1039,25 +1049,29 @@ void MonthViewCell::newEvent()
{
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
}
void MonthViewCell::cellClicked( QListBoxItem *item )
{
+ mMonthView->setSelectedCell( this );
qDebug("CELL ");
if ( item == 0 ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
return;
}
}
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 );
}
void MonthViewCell::selection( QListBoxItem *item )
@@ -1080,12 +1094,13 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
{
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
@@ -1197,12 +1212,35 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
SLOT( prevCell() ) );
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));
@@ -1890,13 +1928,18 @@ void KOMonthView::computeLayout()
updatePossible = true;
//mWeekLabels[mNumWeeks]->setText( i18n("W"));
}
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);
mContextMenu->showEventPopup(event);
} else {
kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
@@ -1906,13 +1949,13 @@ void KOMonthView::showContextMenu( Incidence *incidence )
MonthViewCell * KOMonthView::selectedCell( )
{
return mSelectedCell;
}
void KOMonthView::setSelectedCell( MonthViewCell *cell )
{
- //qDebug("KOMonthView::setSelectedCell ");
+ //qDebug("KOMonthView::setSelectedCell %d", cell);
if ( mSelectedCell && mSelectedCell != cell ) {
MonthViewCell * mvc = mSelectedCell;
mSelectedCell = cell;
mvc->deselect();
} else
mSelectedCell = cell;
@@ -2011,6 +2054,38 @@ void KOMonthView::nextCell()
bool res = focusNextPrevChild ( true );
}
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;
+}