-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 @@ -2643,13 +2643,16 @@ void CalendarView::newEvent(QDateTime fh) void CalendarView::newEvent(QDate dt) { newEvent(QDateTime(dt, QTime(0,0,0)), QDateTime(dt, QTime(0,0,0)), true); } - +void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) +{ + newEvent(fromHint, toHint, false); +} void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) { showEventEditor(); mEventEditor->newEvent(fromHint,toHint,allDay); if ( mFilterView->filtersEnabled() ) { @@ -2681,28 +2684,32 @@ void CalendarView::todoDeleted() { //qDebug(" todoDeleted()"); updateTodoViews(); } - -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() ) { CalFilter *filter = mFilterView->selectedFilter(); if (filter && filter->showCategories()) { mTodoEditor->setCategories(filter->categoryList().join(",") ); } if ( filter ) mTodoEditor->setSecrecy( filter->getSecrecy() ); } } +void CalendarView::newTodo() +{ + newTodoDateTime( QDateTime(),true ); +} + void CalendarView::newSubTodo() { Todo *todo = selectedTodo(); if ( todo ) newSubTodo( todo ); } diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index c8d6bdd..7c59a8d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -222,13 +222,14 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void moveIncidence(); void beamIncidence(); void toggleCancelIncidence(); /** create an editeventwin with supplied date/time, and if bool is true, * 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); void newEvent(QDate dt); /** create new event without having a date hint. Takes current date as default hint. */ void newEvent(); void newFloatingEvent(); @@ -257,12 +258,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser /** Create an editor dialog for a todo */ void editTodo(Todo *); /** Create a read-only viewer dialog for the supplied todo */ void showTodo(Todo *); /** create new todo */ void newTodo(); + void newTodoDateTime(QDateTime, bool allday); /** create new todo with a parent todo */ void newSubTodo(); /** create new todo with a parent todo */ void newSubTodo(Todo *); /** Delete todo */ void deleteTodo(Todo *); diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 7e0b216..73ee5cb 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -165,13 +165,24 @@ void MarcusBains::updateLocation(bool recalculate) Create an agenda widget with rows rows and columns columns. */ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, const char *name,WFlags f) : QScrollView(parent,name,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 ); + mColumns = columns; mRows = rows; mGridSpacingY = rowSize; mAllDayMode = false; #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); @@ -184,13 +195,22 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, Create an agenda widget with columns columns and one row. This is used for all-day events. */ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,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; mColumns = columns; mRows = 1; //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); mGridSpacingY = KOPrefs::instance()->mAllDaySize; mAllDayMode = true; @@ -415,14 +435,30 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) } } } } else { selectItem(0); 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); + } } break; case QEvent::MouseButtonRelease: //qDebug("QEvent::MouseButtonRelease: "); if (me->button() == RightButton && block ) { @@ -453,13 +489,17 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) mActionType = NOP; mItemMoved = 0; return true; } endItemAction(); } else if ( mActionType == SELECT ) { - endSelectAction(); + if (me->button() == RightButton ) { + + } else { + endSelectAction( !blockNewEvent ); + } } break; case QEvent::MouseMove: if (object != viewport()) { KOAgendaItem *moveItem = (KOAgendaItem *)object; @@ -517,12 +557,22 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) break; } return true; } +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) { //emit newStartSelectSignal(); mActionType = SELECT; @@ -606,19 +656,21 @@ void KOAgenda::performSelectAction(QPoint viewportPos) mCurrentCellY = gy; } else { } } } -void KOAgenda::endSelectAction() +void KOAgenda::endSelectAction( bool emitNewEvent ) { mActionType = NOP; mScrollUpTimer.stop(); mScrollDownTimer.stop(); emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); + if ( emitNewEvent && mStartCellY < mCurrentCellY ) + emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); } void KOAgenda::startItemAction(QPoint viewportPos) { int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); @@ -1657,13 +1709,13 @@ void KOAgenda::scrollDown() scrollBy(0,mScrollOffset); } 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; } // TODO: deal correctly with multiple alarms Alarm* alarm; QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); for(alarm=list.first();alarm;alarm=list.next()) { diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 111242f..12943d7 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -123,12 +123,13 @@ class KOAgenda : public QScrollView void printSelection(); void storePosition(); void restorePosition(); public slots: + void newItem( int ); void moveChild( QWidget *, int, int ); void scrollUp(); void scrollDown(); void updateTodo( Todo * t, int , bool ); void popupAlarm(); @@ -142,12 +143,13 @@ class KOAgenda : public QScrollView void selectItem(KOAgendaItem *); void finishResize(); signals: void newEventSignal(); void newEventSignal(int gx,int gy); + void newTodoSignal(int gx,int gy); void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); void newStartSelectSignal(); void showIncidenceSignal(Incidence *); void editIncidenceSignal(Incidence *); void deleteIncidenceSignal(Incidence *); @@ -177,13 +179,13 @@ class KOAgenda : public QScrollView void startSelectAction(QPoint viewportPos); /** Select time span. */ void performSelectAction(QPoint viewportPos); /** Emd selecting time span. */ - void endSelectAction(); + void endSelectAction( bool emitNewEvent = false ); /** Start moving/resizing agenda item */ void startItemAction(QPoint viewportPos); /** Move/resize agenda item */ void performItemAction(QPoint viewportPos); @@ -204,12 +206,13 @@ class KOAgenda : public QScrollView void calculateWorkingHours(); virtual void contentsMousePressEvent ( QMouseEvent * ); private: + bool blockNewEvent; void init(); void marcus_bains(); bool mAllDayMode; bool blockResize; QTimer mResizeTimer; double mContentPosition; @@ -271,12 +274,13 @@ class KOAgenda : public QScrollView // List of all Items contained in agenda QPtrList<KOAgendaItem> mItems; QPtrList<KOAgendaItem> mUnusedItems; KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems + QPopupMenu *mNewItemPopup; int mOldLowerScrollValue; int mOldUpperScrollValue; KOAgendaItem * getItemForTodo ( Todo * todo ); QMemArray<bool> *mHolidayMask; int mCurPixWid; diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f54f7bc..60ae41f 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -485,16 +485,20 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), SLOT(setContentsPos(int))); // Create/Show/Edit/Delete Event connect(mAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEvent(int,int))); + connect(mAgenda,SIGNAL(newTodoSignal(int,int)), + SLOT(newTodo(int,int))); connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEvent(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEventAllDay(int,int))); + connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), + SLOT(newTodoAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEventAllDay(int,int))); connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelected(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); @@ -1280,12 +1284,27 @@ void KOAgendaView::newEventAllDay(int gx, int ) if (!mSelectedDates.count()) return; QDate day = mSelectedDates[gx]; emit newEventSignal(day); } +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 ); +} void KOAgendaView::updateEventIndicatorTop(int newY) { uint i; for(i=0;i<mMinY.size();++i) { if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index 3cf938f..01d74a1 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -159,15 +159,17 @@ class KOAgendaView : public KOEventView { void updateTodo( Todo *, int ); void changeEventDisplay(Event *, int); void clearSelection(); + void newTodo(int gx,int gy); void newEvent(int gx,int gy); void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); void newEventAllDay(int gx, int gy); + void newTodoAllDay(int gx, int gy); void startDrag(Event *); void readSettings(); void readSettings(KConfig *); void writeSettings(KConfig *); @@ -177,12 +179,13 @@ class KOAgendaView : public KOEventView { void setExpandedButton( bool expanded ); void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); signals: + void newTodoSignal( QDateTime ,bool ); void toggleExpand(); void todoMoved( Todo *, int ); void incidenceChanged(Incidence * , int ); // void cloneIncidenceSignal(Incidence *); protected: diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 158a7d3..b9a028b 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp @@ -192,26 +192,31 @@ void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) } else { mTimeButton->setEnabled(false); } 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); + } alarmDisable(true); mStartCheck->setChecked(false); enableStartEdit(false); mDueDateEdit->setDate(due.date()); mDueTimeEdit->setTime(due.time()); - - mStartDateEdit->setDate(QDate::currentDate()); - mStartTimeEdit->setTime(QTime::currentTime()); + due = due.addDays(-7); + mStartDateEdit->setDate(due.date()); + mStartTimeEdit->setTime(due.time()); mPriorityCombo->setCurrentItem(2); mCompletedLabel->setText(i18n("completed"));; mCompletedCombo->setCurrentItem(0); } diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index e8d5ab1..a88276e 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -304,16 +304,21 @@ void KOViewManager::showAgendaView( bool fullScreen ) QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); #endif connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); // 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)), mMainView, SLOT(newEvent(QDate))); connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), mMainView, SLOT(editIncidence(Incidence *))); connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |