author | zautrix <zautrix> | 2005-01-29 15:23:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-29 15:23:10 (UTC) |
commit | c6548bb194a5e73b9b72505c2e952ef6346dec46 (patch) (side-by-side diff) | |
tree | 74039fb5cd5f1a64f6a7844c9ece030e6d76de87 /korganizer | |
parent | f542fb5846520683e6241a522921e3d5eb24b833 (diff) | |
download | kdepimpi-c6548bb194a5e73b9b72505c2e952ef6346dec46.zip kdepimpi-c6548bb194a5e73b9b72505c2e952ef6346dec46.tar.gz kdepimpi-c6548bb194a5e73b9b72505c2e952ef6346dec46.tar.bz2 |
todo
-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 60 | ||||
-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 | 13 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 9 |
8 files changed, 114 insertions, 17 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 257a4dd..035d630 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -2641,17 +2641,20 @@ void CalendarView::newEvent(QDateTime fh) QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); } 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() ) { CalFilter *filter = mFilterView->selectedFilter(); if (filter && filter->showCategories()) { @@ -2679,32 +2682,36 @@ void CalendarView::todoToBeDeleted(Todo *) } 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 ); } void CalendarView::newSubTodo(Todo *parentEvent) { diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index c8d6bdd..7c59a8d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -220,17 +220,18 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void deleteIncidence(); void cloneIncidence(); 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(); /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ @@ -255,16 +256,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void showJournal(Journal *); void deleteJournal(Journal *); /** 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 @@ -163,16 +163,27 @@ 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 ); #endif @@ -182,17 +193,26 @@ 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; #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); @@ -413,19 +433,35 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) startY = viewportPos.y(); block = true; } } } } else { selectItem(0); mActionItem = 0; + 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 ) { if (object != viewport()) { mClickedItem = (KOAgendaItem *)object; if (mActionItem ) { @@ -451,17 +487,21 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) setCursor( arrowCursor ); mActionItem = 0; 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; //qDebug("moveItem %d ",moveItem ); if (!moveItem->incidence()->isReadOnly() /*&& @@ -515,16 +555,26 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) default: 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; int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); @@ -604,23 +654,25 @@ void KOAgenda::performSelectAction(QPoint viewportPos) mGridSpacingX, selectionHeight,false ); 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); int gx,gy; contentsToGrid(x,y,gx,gy); @@ -1655,17 +1707,17 @@ void KOAgenda::scrollUp() 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()) { alarm->toggleAlarm(); } diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 111242f..12943d7 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -121,16 +121,17 @@ class KOAgenda : public QScrollView void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); void finishUpdate(); 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(); void checkScrollBoundaries(int); @@ -140,16 +141,17 @@ class KOAgenda : public QScrollView deselected. This function emits the itemSelected(bool) signal to inform about selection/deseelction of events. */ 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 *); void showIncidencePopupSignal(Incidence *); @@ -175,17 +177,17 @@ class KOAgenda : public QScrollView /** Start selecting time span. */ 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); /** End moving/resizing agenda item */ @@ -202,16 +204,17 @@ class KOAgenda : public QScrollView */ void keyPressEvent( QKeyEvent * ); void calculateWorkingHours(); virtual void contentsMousePressEvent ( QMouseEvent * ); private: + bool blockNewEvent; void init(); void marcus_bains(); bool mAllDayMode; bool blockResize; QTimer mResizeTimer; double mContentPosition; // Width and height of agenda cells @@ -269,16 +272,17 @@ class KOAgenda : public QScrollView bool mItemMoved; // 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; int mCurPixHei; }; diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f54f7bc..60ae41f 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -483,20 +483,24 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), mTimeLabels, SLOT(positionChanged())); 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))); connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); @@ -1278,16 +1282,31 @@ void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 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); else mEventIndicatorTop->enableColumn(i,false); } diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index 3cf938f..01d74a1 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -157,34 +157,37 @@ class KOAgendaView : public KOEventView { virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); 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 *); void setContentsPos(int y); 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: bool mBlockUpdating; int mUpcomingWidth; diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 158a7d3..b9a028b 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp @@ -190,30 +190,35 @@ void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) if(mTimeButton->isChecked()) { mTimeButton->setEnabled(true); } else { mTimeButton->setEnabled(false); } enableTimeEdits( !allDay ); - + 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); } void KOEditorGeneralTodo::readTodo(Todo *todo) { diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index e8d5ab1..a88276e 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -302,20 +302,25 @@ void KOViewManager::showAgendaView( bool fullScreen ) addView(mAgendaView); #ifndef DESKTOP_VERSION 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 *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |