-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 66 | ||||
-rw-r--r-- | korganizer/koagenda.h | 6 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 19 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 3 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 17 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 9 |
8 files changed, 119 insertions, 22 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 257a4dd..035d630 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -2648,3 +2648,6 @@ void CalendarView::newEvent(QDate dt) } - +void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) +{ + newEvent(fromHint, toHint, false); +} void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) @@ -2686,8 +2689,7 @@ void CalendarView::todoDeleted() - -void CalendarView::newTodo() +void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) { - + qDebug("datetime "); showTodoEditor(); - mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); + mTodoEditor->newTodo(dt,0,allday); if ( mFilterView->filtersEnabled() ) { @@ -2702,2 +2704,7 @@ void CalendarView::newTodo() +void CalendarView::newTodo() +{ + newTodoDateTime( QDateTime(),true ); +} + void CalendarView::newSubTodo() diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index c8d6bdd..7c59a8d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -227,3 +227,4 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser * make the event take all day. */ - void newEvent(QDateTime, QDateTime, bool allDay = false); + void newEvent(QDateTime, QDateTime, bool allDay ); + void newEvent(QDateTime, QDateTime); void newEvent(QDateTime fh); @@ -262,2 +263,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void newTodo(); + void newTodoDateTime(QDateTime, bool allday); /** create new todo with a parent todo */ diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 7e0b216..73ee5cb 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -170,3 +170,14 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, { - + mNewItemPopup = new QPopupMenu( this ); + connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); + QString pathString = ""; + if ( !KOPrefs::instance()->mToolBarMiniIcons ) { + if ( QApplication::desktop()->width() < 480 ) + pathString += "icons16/"; + } else + pathString += "iconsmini/"; + + mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); + mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); + mColumns = columns; @@ -189,3 +200,12 @@ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : { - + mNewItemPopup = new QPopupMenu( this ); + connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); + QString pathString = ""; + if ( !KOPrefs::instance()->mToolBarMiniIcons ) { + if ( QApplication::desktop()->width() < 480 ) + pathString += "icons16/"; + } else + pathString += "iconsmini/"; + mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."),1 ); + mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); blockResize = false; @@ -420,4 +440,20 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) mActionItem = 0; - setCursor(arrowCursor); - startSelectAction(viewportPos); + if (me->button() == RightButton ) { + blockNewEvent = true; + qDebug("right "); + int x,y; + viewportToContents(viewportPos.x(),viewportPos.y(),x,y); + int gx,gy; + contentsToGrid(x,y,gx,gy); + mStartCellX = gx; + mStartCellY = gy; + mCurrentCellX = gx; + mCurrentCellY = gy; + mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); + + } else { + blockNewEvent = false; + setCursor(arrowCursor); + startSelectAction(viewportPos); + } } @@ -458,3 +494,7 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) } else if ( mActionType == SELECT ) { - endSelectAction(); + if (me->button() == RightButton ) { + + } else { + endSelectAction( !blockNewEvent ); + } } @@ -522,2 +562,12 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) +void KOAgenda::newItem( int item ) +{ + qDebug("new %d ", item); + if ( item == 1 ) { //new event + newEventSignal(mStartCellX ,mStartCellY ); + } + if ( item == 2 ) { //new event + newTodoSignal(mStartCellX ,mStartCellY ); + } +} void KOAgenda::startSelectAction(QPoint viewportPos) @@ -611,3 +661,3 @@ void KOAgenda::performSelectAction(QPoint viewportPos) -void KOAgenda::endSelectAction() +void KOAgenda::endSelectAction( bool emitNewEvent ) { @@ -618,2 +668,4 @@ void KOAgenda::endSelectAction() emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); + if ( emitNewEvent && mStartCellY < mCurrentCellY ) + emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); } @@ -1662,3 +1714,3 @@ void KOAgenda::popupAlarm() if (!mClickedItem) { - kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; + qDebug("KOAgenda::popupAlarm() called without having a clicked item "); return; diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 111242f..12943d7 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -128,2 +128,3 @@ class KOAgenda : public QScrollView public slots: + void newItem( int ); void moveChild( QWidget *, int, int ); @@ -147,2 +148,3 @@ class KOAgenda : public QScrollView void newEventSignal(int gx,int gy); + void newTodoSignal(int gx,int gy); void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); @@ -182,3 +184,3 @@ class KOAgenda : public QScrollView /** Emd selecting time span. */ - void endSelectAction(); + void endSelectAction( bool emitNewEvent = false ); @@ -209,2 +211,3 @@ class KOAgenda : public QScrollView private: + bool blockNewEvent; void init(); @@ -276,2 +279,3 @@ class KOAgenda : public QScrollView QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems + QPopupMenu *mNewItemPopup; diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f54f7bc..60ae41f 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -490,2 +490,4 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : SLOT(newEvent(int,int))); + connect(mAgenda,SIGNAL(newTodoSignal(int,int)), + SLOT(newTodo(int,int))); connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), @@ -494,2 +496,4 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : SLOT(newEventAllDay(int,int))); + connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), + SLOT(newTodoAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), @@ -1285,2 +1289,17 @@ void KOAgendaView::newEventAllDay(int gx, int ) } +void KOAgendaView::newTodoAllDay(int gx, int ) +{ + if (!mSelectedDates.count()) return; + + QDateTime day (mSelectedDates[gx] ); + emit newTodoSignal(day, true); +} +void KOAgendaView::newTodo(int gx, int gy ) +{ + if (!mSelectedDates.count()) return; + QDate dayStart = mSelectedDates[gx]; + QTime timeStart = mAgenda->gyToTime(gy); + QDateTime dt (dayStart,timeStart); + emit newTodoSignal( dt, false ); +} diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index 3cf938f..01d74a1 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -164,2 +164,3 @@ class KOAgendaView : public KOEventView { + void newTodo(int gx,int gy); void newEvent(int gx,int gy); @@ -167,2 +168,3 @@ class KOAgendaView : public KOEventView { void newEventAllDay(int gx, int gy); + void newTodoAllDay(int gx, int gy); @@ -182,2 +184,3 @@ class KOAgendaView : public KOEventView { signals: + void newTodoSignal( QDateTime ,bool ); void toggleExpand(); diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 158a7d3..b9a028b 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp @@ -197,5 +197,10 @@ void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) enableTimeEdits( !allDay ); - - mDueCheck->setChecked(false); - enableDueEdit(false); + if ( due.isValid() ) { + mDueCheck->setChecked(true); + enableDueEdit(true); + } else { + mDueCheck->setChecked(false); + enableDueEdit(false); + due = QDateTime::currentDateTime().addDays(7); + } @@ -208,5 +213,5 @@ void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) mDueTimeEdit->setTime(due.time()); - - mStartDateEdit->setDate(QDate::currentDate()); - mStartTimeEdit->setTime(QTime::currentTime()); + due = due.addDays(-7); + mStartDateEdit->setDate(due.date()); + mStartTimeEdit->setTime(due.time()); diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index e8d5ab1..a88276e 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -309,6 +309,11 @@ void KOViewManager::showAgendaView( bool fullScreen ) // SIGNALS/SLOTS FOR DAY/WEEK VIEW + + + + connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), + mMainView, SLOT(newTodoDateTime(QDateTime,bool))); connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), mMainView, SLOT(newEvent(QDateTime))); - // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), - // mMainView, SLOT(newEvent(QDateTime,QDateTime))); + connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), + mMainView, SLOT(newEvent(QDateTime,QDateTime))); connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |