-rw-r--r-- | korganizer/calendarview.cpp | 16 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 88 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 3 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 |
6 files changed, 109 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index e4a11f5..1f8ad5b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -326,192 +326,194 @@ void CalendarView::init() QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mNavigatorBar ); rightLayout->addWidget( mRightFrame, 10 ); mLeftFrame = leftFrame; if ( KOPrefs::instance()->mVerticalScreen ) { mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); } else { mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); } //qDebug("Calendarview Size %d %d ", width(), height()); #endif connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( showDates( const KCal::DateList & ) ) ); connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mNavigatorBar, SIGNAL( goPrevYear() ), mNavigator, SLOT( selectPreviousYear() ) ); connect( mNavigatorBar, SIGNAL( goNextYear() ), mNavigator, SLOT( selectNextYear() ) ); connect( mNavigatorBar, SIGNAL( goPrevMonth() ), mNavigator, SLOT( selectPreviousMonth() ) ); connect( mNavigatorBar, SIGNAL( goNextMonth() ), mNavigator, SLOT( selectNextMonth() ) ); connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), mNavigator, SLOT( selectWeek( const QDate & ) ) ); connect( mDateNavigator, SIGNAL( goPrevYear() ), mNavigator, SLOT( selectPreviousYear() ) ); connect( mDateNavigator, SIGNAL( goNextYear() ), mNavigator, SLOT( selectNextYear() ) ); connect( mDateNavigator, SIGNAL( goPrevMonth() ), mNavigator, SLOT( selectPreviousMonth() ) ); connect( mDateNavigator, SIGNAL( goNextMonth() ), mNavigator, SLOT( selectNextMonth() ) ); connect( mDateNavigator, SIGNAL( goPrevious() ), mNavigator, SLOT( selectPrevious() ) ); connect( mDateNavigator, SIGNAL( goNext() ), mNavigator, SLOT( selectNext() ) ); connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), mNavigator, SLOT( slotMonthSelect( int ) ) ); connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), mNavigator, SLOT( slotMonthSelect( int ) ) ); connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), SLOT( eventAdded( Event *) ) ); connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); connect( this, SIGNAL( configChanged() ), mDateNavigator, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( newTodoSignal() ), SLOT( newTodo() ) ); connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), SLOT( newSubTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), SLOT( editTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), SLOT( showTodo( Todo *) ) ); connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), SLOT( deleteTodo( Todo *) ) ); connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( purgeCompletedSignal() ), SLOT( purgeCompleted() ) ); connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), SIGNAL( todoModified( Todo *, int ) ) ); connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), this, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), this, SLOT (cancelIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), this, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), this, SLOT ( beamIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), this, SLOT ( todo_unsub( Todo * ) ) ); + connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), + this, SLOT ( todo_resub( Todo *,Todo * ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, SLOT( updateTodo( Todo *, int ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), this, SLOT( changeTodoDisplay( Todo *, int ) ) ); connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); connect(QApplication::clipboard(),SIGNAL(dataChanged()), SLOT(checkClipboard())); connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processTodoListSelection( Incidence * ) ) ); connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); // kdDebug() << "CalendarView::CalendarView() done" << endl; mDateFrame = new QVBox(0,0,WType_Popup); //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); mDateFrame->setLineWidth(3); mDateFrame->hide(); mDateFrame->setCaption( i18n( "Pick a date to display")); mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); mEventEditor = mDialogManager->getEventEditor(); mTodoEditor = mDialogManager->getTodoEditor(); mFlagEditDescription = false; mSuspendTimer = new QTimer( this ); mAlarmTimer = new QTimer( this ); mRecheckAlarmTimer = new QTimer( this ); connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); mAlarmDialog = new AlarmDialog( this ); connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); mAlarmDialog->setServerNotification( false ); mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); #ifndef DESKTOP_VERSION //US listen for arriving address resultsets connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); #endif } CalendarView::~CalendarView() { // kdDebug() << "~CalendarView()" << endl; //qDebug("CalendarView::~CalendarView() "); delete mDialogManager; delete mViewManager; delete mStorage; delete mDateFrame ; delete beamDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::timerAlarm() { //qDebug("CalendarView::timerAlarm() "); computeAlarm(mAlarmNotification ); } void CalendarView::suspendAlarm() { //qDebug(" CalendarView::suspendAlarm() "); computeAlarm(mSuspendAlarmNotification ); } void CalendarView::startAlarm( QString mess , QString filename) { mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); } void CalendarView::checkNextTimerAlarm() { mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::computeAlarm( QString msg ) @@ -2653,192 +2655,206 @@ KOEventViewerDialog* CalendarView::getEventViewerDialog() connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), viewManager(), SLOT( showAgendaView( bool ) ) ); mEventViewerDialog->resize( 640, 480 ); } return mEventViewerDialog; } void CalendarView::showEvent(Event *event) { getEventViewerDialog()->setEvent(event); getEventViewerDialog()->showMe(); } void CalendarView::showTodo(Todo *event) { getEventViewerDialog()->setTodo(event); getEventViewerDialog()->showMe(); } void CalendarView::showJournal( Journal *jour ) { getEventViewerDialog()->setJournal(jour); getEventViewerDialog()->showMe(); } // void CalendarView::todoModified (Todo *event, int changed) // { // // if (mDialogList.find (event) != mDialogList.end ()) { // // kdDebug() << "Todo modified and open" << endl; // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; // // temp->modified (changed); // // } // mViewManager->updateView(); // } void CalendarView::appointment_show() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } showEvent(anEvent); } void CalendarView::appointment_edit() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } editEvent(anEvent); } void CalendarView::appointment_delete() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } deleteEvent(anEvent); } +void CalendarView::todo_resub( Todo * parent, Todo * sub ) +{ + if (!sub) return; + if (!parent) return; + if ( sub->relatedTo() ) + sub->relatedTo()->removeRelation(sub); + sub->setRelatedTo(parent); + sub->setRelatedToUid(parent->uid()); + parent->addRelation(sub); + sub->updated(); + parent->updated(); + setModified(true); + updateView(); +} void CalendarView::todo_unsub(Todo *anTodo ) { // Todo *anTodo = selectedTodo(); if (!anTodo) return; if (!anTodo->relatedTo()) return; anTodo->relatedTo()->removeRelation(anTodo); anTodo->setRelatedTo(0); anTodo->updated(); anTodo->setRelatedToUid(""); setModified(true); updateView(); } void CalendarView::deleteTodo(Todo *todo) { if (!todo) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { switch (msgItemDelete()) { case KMessageBox::Continue: // OK if (!todo->relations().isEmpty()) { KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), i18n("Delete To-Do")); } else { checkExternalId( todo ); calendar()->deleteTodo(todo); changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); updateView(); } break; } // switch } else { if (!todo->relations().isEmpty()) { KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), i18n("Delete To-Do")); } else { checkExternalId( todo ); mCalendar->deleteTodo(todo); changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); updateView(); } } emit updateSearchDialog(); } void CalendarView::deleteJournal(Journal *jour) { if (!jour) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { switch (msgItemDelete()) { case KMessageBox::Continue: // OK calendar()->deleteJournal(jour); updateView(); break; } // switch } else { calendar()->deleteJournal(jour);; updateView(); } emit updateSearchDialog(); } void CalendarView::deleteEvent(Event *anEvent) { if (!anEvent) { KNotifyClient::beep(); return; } if (anEvent->recurrence()->doesRecur()) { QDate itemDate = mViewManager->currentSelectionDate(); int km; if (!itemDate.isValid()) { //kdDebug() << "Date Not Valid" << endl; if (KOPrefs::instance()->mConfirm) { km = KMessageBox::warningContinueCancel(this,anEvent->summary() + i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), i18n("KO/Pi Confirmation"),i18n("Delete All")); if ( km == KMessageBox::Continue ) km = KMessageBox::No; // No = all below } else km = KMessageBox::No; } else { km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), i18n("KO/Pi Confirmation"),i18n("Current"), i18n("All")); } switch(km) { case KMessageBox::No: // Continue // all diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 660cce7..9f56cc8 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -261,192 +261,193 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void newTodo(); /** create new todo with a parent todo */ void newSubTodo(); /** create new todo with a parent todo */ void newSubTodo(Todo *); /** Delete todo */ void deleteTodo(Todo *); /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is * emitted as result. */ void checkClipboard(); /** using the KConfig associated with the kapp variable, read in the * settings from the config file. */ void readSettings(); /** write current state to config file. */ void writeSettings(); /** read settings for calendar filters */ void readFilterSettings(KConfig *config); /** write settings for calendar filters */ void writeFilterSettings(KConfig *config); /** passes on the message that an event has changed to the currently * activated view so that it can make appropriate display changes. */ void changeEventDisplay(Event *, int); void changeIncidenceDisplay(Incidence *, int); void changeTodoDisplay(Todo *, int); void eventAdded(Event *); void eventChanged(Event *); void eventToBeDeleted(Event *); void eventDeleted(); void todoAdded(Todo *); void todoChanged(Todo *); void todoToBeDeleted(Todo *); void todoDeleted(); void updateView(const QDate &start, const QDate &end); void updateView(); /** Full update of visible todo views */ void updateTodoViews(); void updateUnmanagedViews(); /** cut the current appointment to the clipboard */ void edit_cut(); /** copy the current appointment(s) to the clipboard */ void edit_copy(); /** paste the current vobject(s) in the clipboard buffer into calendar */ void edit_paste(); /** edit viewing and configuration options. */ void edit_options(); /** Functions for printing, previewing a print, and setting up printing parameters. */ void print(); void printSetup(); void printPreview(); /** Export as iCalendar file */ void exportICalendar(); /** Export as vCalendar file */ bool exportVCalendar( QString fn); /** pop up a dialog to show an existing appointment. */ void appointment_show(); /** * pop up an Appointment Dialog to edit an existing appointment. Get * information on the appointment from the list of unique IDs that is * currently in the View, called currIds. */ void appointment_edit(); /** * pop up dialog confirming deletion of currently selected event in the * View. */ void appointment_delete(); /** mails the currently selected event to a particular user as a vCalendar attachment. */ void action_mail(); /* frees a subtodo from it's relation */ void todo_unsub( Todo * ); + void todo_resub( Todo * parent, Todo * sub ); /** Take ownership of selected event. */ void takeOverEvent(); /** Take ownership of all events in calendar. */ void takeOverCalendar(); /** query whether or not the calendar is "dirty". */ bool isModified(); /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ void setModified(bool modified=true); /** query if the calendar is read-only. */ bool isReadOnly(); /** set state of calendar to read-only */ void setReadOnly(bool readOnly=true); void eventUpdated(Incidence *); /* iTIP scheduling actions */ void schedule_publish(Incidence *incidence = 0); void schedule_request(Incidence *incidence = 0); void schedule_refresh(Incidence *incidence = 0); void schedule_cancel(Incidence *incidence = 0); void schedule_add(Incidence *incidence = 0); void schedule_reply(Incidence *incidence = 0); void schedule_counter(Incidence *incidence = 0); void schedule_declinecounter(Incidence *incidence = 0); void schedule_publish_freebusy(int daysToPublish = 30); void openAddressbook(); void editFilters(); void toggleFilerEnabled(); QPtrList<CalFilter> filters(); void toggleFilter(); void showFilter(bool visible); void updateFilter(); void filterEdited(); void selectFilter( int ); KOFilterView *filterView(); void showIntro(); /** Move the curdatepient view date to today */ void goToday(); /** Move to the next date(s) in the current view */ void goNext(); /** Move to the previous date(s) in the current view */ void goPrevious(); /** Move to the next date(s) in the current view */ void goNextMonth(); /** Move to the previous date(s) in the current view */ void goPreviousMonth(); void toggleExpand(); void toggleDateNavigatorWidget(); void toggleAllDaySize(); void dialogClosing(Incidence *); /** Look for new messages in the inbox */ void lookForIncomingMessages(); /** Look for new messages in the outbox */ void lookForOutgoingMessages(); void processMainViewSelection( Incidence * ); void processTodoListSelection( Incidence * ); void processIncidenceSelection( Incidence * ); void purgeCompleted(); bool removeCompletedSubTodos( Todo* ); void slotCalendarChanged(); bool importBday(); bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); bool importQtopia( const QString &categoriesFile, const QString &datebookFile, const QString &tasklistFile ); void syncExternal( int mode ); void slotSelectPickerDate( QDate ) ; void showDatePicker( ) ; void moveIncidence(Incidence *) ; void beamIncidence(Incidence *) ; void beamCalendar() ; void beamFilteredCalendar() ; void beamIncidenceList(QPtrList<Incidence>) ; void manageCategories(); int addCategories(); void removeCategories(); void setSyncDevice( QString ); void setSyncName( QString ); protected slots: void timerAlarm(); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index ca5eadd..a8143a0 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -118,423 +118,433 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) { #ifndef KORG_NODND // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && !QTextDrag::canDecode( e ) ) { e->ignore(); return; } DndFactory factory( mCalendar ); Todo *todo = factory.createDropTodo(e); if (todo) { e->acceptAction(); KOTodoViewItem *destination = (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); Todo *destinationEvent = 0; if (destination) destinationEvent = destination->todo(); Todo *existingTodo = mCalendar->todo(todo->uid()); if(existingTodo) { // kdDebug() << "Drop existing Todo" << endl; Incidence *to = destinationEvent; while(to) { if (to->uid() == todo->uid()) { KMessageBox::sorry(this, i18n("Cannot move To-Do to itself or a child of itself"), i18n("Drop To-Do")); delete todo; return; } to = to->relatedTo(); } existingTodo->setRelatedTo(destinationEvent); emit todoDropped(todo); delete todo; } else { // kdDebug() << "Drop new Todo" << endl; todo->setRelatedTo(destinationEvent); mCalendar->addTodo(todo); emit todoDropped(todo); } } else { QString text; if (QTextDrag::decode(e,text)) { //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); kdDebug() << "Dropped : " << text << endl; QStringList emails = QStringList::split(",",text); for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { kdDebug() << " Email: " << (*it) << endl; int pos = (*it).find("<"); QString name = (*it).left(pos); QString email = (*it).mid(pos); if (!email.isEmpty() && todoi) { todoi->todo()->addAttendee(new Attendee(name,email)); } } } else { kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; e->ignore(); } } #endif } void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) { QListView::contentsMousePressEvent(e); #ifndef KORG_NODND QPoint p(contentsToViewport(e->pos())); QListViewItem *i = itemAt(p); if (i) { // if the user clicked into the root decoration of the item, don't // try to start a drag! if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() || p.x() < header()->sectionPos(header()->mapToIndex(0))) { if (e->button()==Qt::LeftButton) { mPressPos = e->pos(); mMousePressed = true; } } } #endif } void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) { + #ifndef KORG_NODND // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; QListView::contentsMouseMoveEvent(e); if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { mMousePressed = false; QListViewItem *item = itemAt(contentsToViewport(mPressPos)); if (item) { // kdDebug() << "Start Drag for item " << item->text(0) << endl; DndFactory factory( mCalendar ); ICalDrag *vd = factory.createDragTodo( ((KOTodoViewItem *)item)->todo(),viewport()); if (vd->drag()) { kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; } /* QString source = fullPath(item); if ( QFile::exists(source) ) { QUriDrag* ud = new QUriDrag(viewport()); ud->setFilenames( source ); if ( ud->drag() ) QMessageBox::information( this, "Drag source", QString("Delete ")+source, "Not implemented" ); */ } } #endif } void KOTodoListView::keyPressEvent ( QKeyEvent * e ) { QListViewItem* cn; if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { cn = currentItem(); if ( cn ) { KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); if ( ci ){ if ( e->state() == ShiftButton ) ci->setOn( false ); else ci->setOn( true ); cn = cn->nextSibling(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } } } return; } // qDebug("KOTodoListView::keyPressEvent "); if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { switch ( e->key() ) { case Qt::Key_Down: case Qt::Key_Up: QListView::keyPressEvent ( e ); break; case Qt::Key_Left: case Qt::Key_Right: QListView::keyPressEvent ( e ); + e->accept(); + return; break; default: e->ignore(); break; } return; } e->ignore(); } void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) { QListView::contentsMouseReleaseEvent(e); mMousePressed = false; } void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt(vp); emit double_Clicked(item); if (!item) return; emit doubleClicked(item,vp,0); } ///////////////////////////////////////////////////////////////////////////// KOQuickTodo::KOQuickTodo(QWidget *parent) : QLineEdit(parent) { setText(i18n("Click to add a new Todo")); } void KOQuickTodo::focusInEvent(QFocusEvent *ev) { if ( text()==i18n("Click to add a new Todo") ) setText(""); QLineEdit::focusInEvent(ev); } void KOQuickTodo::focusOutEvent(QFocusEvent *ev) { setText(i18n("Click to add a new Todo")); QLineEdit::focusOutEvent(ev); } ///////////////////////////////////////////////////////////////////////////// KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : KOrg::BaseView(calendar,parent,name) { QBoxLayout *topLayout = new QVBoxLayout(this); mName = QString ( name ); mBlockUpdate = false; mQuickAdd = new KOQuickTodo(this); topLayout->addWidget(mQuickAdd); if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); mTodoListView = new KOTodoListView(calendar,this, name ); topLayout->addWidget(mTodoListView); //mTodoListView->header()->setMaximumHeight(30); mTodoListView->setRootIsDecorated(true); mTodoListView->setAllColumnsShowFocus(true); mTodoListView->setShowSortIndicator(true); mTodoListView->addColumn(i18n("Todo")); mTodoListView->addColumn(i18n("Prio")); mTodoListView->setColumnAlignment(1,AlignHCenter); mTodoListView->addColumn(i18n("Complete")); mTodoListView->setColumnAlignment(2,AlignHCenter); mTodoListView->addColumn(i18n("Due Date")); mTodoListView->setColumnAlignment(3,AlignLeft); mTodoListView->addColumn(i18n("Due Time")); mTodoListView->setColumnAlignment(4,AlignHCenter); mTodoListView->addColumn(i18n("Cancelled")); mTodoListView->addColumn(i18n("Categories")); #if 0 mTodoListView->addColumn(i18n("Sort Id")); mTodoListView->setColumnAlignment(4,AlignHCenter); #endif mTodoListView->setMinimumHeight( 60 ); mTodoListView->setItemsRenameable( true ); mTodoListView->setRenameable( 0 ); mTodoListView->setColumnWidth( 0, 120 ); mTodoListView->setColumnWidthMode(0, QListView::Manual); mTodoListView->setColumnWidthMode(1, QListView::Manual); mTodoListView->setColumnWidthMode(2, QListView::Manual); mTodoListView->setColumnWidthMode(3, QListView::Manual); mTodoListView->setColumnWidthMode(4, QListView::Manual); mTodoListView->setColumnWidthMode(5, QListView::Manual); mTodoListView->setColumnAlignment( 2, AlignCenter ); #if 0 mTodoListView->setColumnWidthMode(6, QListView::Manual); #endif mPriorityPopupMenu = new QPopupMenu(this); for (int i = 1; i <= 5; i++) { QString label = QString ("%1").arg (i); mPriority[mPriorityPopupMenu->insertItem (label)] = i; } connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); mPercentageCompletedPopupMenu = new QPopupMenu(this); for (int i = 0; i <= 100; i+=20) { QString label = QString ("%1 %").arg (i); mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; } connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); mItemPopupMenu = new QPopupMenu(this); mItemPopupMenu->insertItem(i18n("Show..."), this, SLOT (showTodo())); mItemPopupMenu->insertItem(i18n("Edit..."), this, SLOT (editTodo())); mItemPopupMenu->insertItem( i18n("Delete"), this, SLOT (deleteTodo())); mItemPopupMenu->insertItem( i18n("Clone..."), this, SLOT (cloneTodo())); mItemPopupMenu->insertItem( i18n("Move..."), this, SLOT (moveTodo())); mItemPopupMenu->insertItem( i18n("Beam..."), this, SLOT (beamTodo())); mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, SLOT (cancelTodo())); mItemPopupMenu->insertSeparator(); mItemPopupMenu->insertItem( i18n("New Todo..."), this, SLOT (newTodo())); mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, SLOT (newSubTodo())); mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, - SLOT (unparentTodo())); + SLOT (unparentTodo()),0,21); + mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, + SLOT (reparentTodo()),0,22); mItemPopupMenu->insertSeparator(); mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), this, SLOT( purgeCompleted() ) ); mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), this, SLOT( toggleCompleted() ),0, 33 ); mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), this, SLOT( toggleQuickTodo() ),0, 34 ); mPopupMenu = new QPopupMenu(this); mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, SLOT (newTodo()),0,1); mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), this, SLOT(purgeCompleted()),0,2); mPopupMenu->insertItem(i18n("Show Completed"), this, SLOT( toggleCompleted() ),0,3 ); mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), this, SLOT( toggleQuickTodo() ),0,4 ); mDocPrefs = new DocPrefs( name ); mPopupMenu->setCheckable( true ); mItemPopupMenu->setCheckable( true ); // Double clicking conflicts with opening/closing the subtree connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), SLOT( editItem( QListViewItem *) ) ); + /* connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, const QPoint &,int ) ), SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); + */ + connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, + const QPoint &,int ) ), + SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), SLOT( itemClicked( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), SLOT( itemDoubleClicked( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), SLOT( updateView() ) ); connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), SLOT( itemStateChanged( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), SLOT( itemStateChanged( QListViewItem * ) ) ); #if 0 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); #endif connect( mTodoListView, SIGNAL(selectionChanged() ), SLOT( processSelectionChange() ) ); connect( mQuickAdd, SIGNAL( returnPressed () ), SLOT( addQuickTodo() ) ); // if ( QApplication::desktop()->width() < 480 ) { // setNarrow(); // mTodoListView->setColumnWidth( 0, 100 ); // } } KOTodoView::~KOTodoView() { delete mDocPrefs; } void KOTodoView::jumpToDate () { // if (mActiveItem) { // mActiveItem->todo()); // if ( mActiveItem->todo()->hasDueDate() ) // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); } void KOTodoView::setNarrow() { //mTodoListView->setColumnWidth( 0, 120 ); mTodoListView->setColumnWidth( 1, 35 ); mTodoListView->setColumnWidth( 2, 40 ); mTodoListView->setColumnWidth( 3, 80 ); mTodoListView->setColumnWidth( 4, 40 ); mTodoListView->setColumnWidth( 5, 90 ); } void KOTodoView::updateView() { if ( mBlockUpdate ) { //qDebug("blocked "); return; } //qDebug("update "); // kdDebug() << "KOTodoView::updateView()" << endl; QFont fo = KOPrefs::instance()->mTodoViewFont; mTodoListView->clear(); if ( mName == "todolistsmall" ) { if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { int ps = fo.pointSize() -2; if ( ps > 12 ) ps -= 2; fo.setPointSize( ps ); } } mTodoListView->setFont( fo ); // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); //mTodoListView->header()->setMaximumHeight(fm.height()); QPtrList<Todo> todoList = calendar()->todos(); /* kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; Event *t; for(t = todoList.first(); t; t = todoList.next()) { kdDebug() << " " << t->getSummary() << endl; if (t->getRelatedTo()) { kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; } QPtrList<Event> l = t->getRelations(); Event *c; for(c=l.first();c;c=l.next()) { kdDebug() << " - relation: " << c->getSummary() << endl; } } */ @@ -602,435 +612,505 @@ void KOTodoView::restoreItemState( QListViewItem *item ) QMap<Todo *,KOTodoViewItem *>::ConstIterator KOTodoView::insertTodoItem(Todo *todo) { // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; // TODO: Check, if dynmaic cast is necessary Incidence *incidence = todo->relatedTo(); if (incidence && incidence->type() == "Todo") { Todo *relatedTodo = static_cast<Todo *>(incidence); // kdDebug() << " has Related" << endl; QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; itemIterator = mTodoMap.find(relatedTodo); if (itemIterator == mTodoMap.end()) { // kdDebug() << " related not yet in list" << endl; itemIterator = insertTodoItem (relatedTodo); } // isn't this pretty stupid? We give one Todo to the KOTodoViewItem // and one into the map. Sure finding is more easy but why? -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); return mTodoMap.insert(todo,todoItem); } else { // kdDebug() << " no Related" << endl; // see above -zecke KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); return mTodoMap.insert(todo,todoItem); } } void KOTodoView::updateConfig() { updateView(); mTodoListView->repaintContents(); } QPtrList<Incidence> KOTodoView::selectedIncidences() { QPtrList<Incidence> selected; KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); // if (!item) item = mActiveItem; if (item) selected.append(item->todo()); return selected; } QPtrList<Todo> KOTodoView::selectedTodos() { QPtrList<Todo> selected; KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); // if (!item) item = mActiveItem; if (item) selected.append(item->todo()); return selected; } void KOTodoView::changeEventDisplay(Event *, int) { updateView(); } void KOTodoView::showDates(const QDate &, const QDate &) { } void KOTodoView::showEvents(QPtrList<Event>) { kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; } void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Todolist, fd, td); #endif } void KOTodoView::editItem(QListViewItem *item ) { // qDebug("editItem(QListViewItem *item ) "); emit editTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) { emit showTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) { - mActiveItem = (KOTodoViewItem *)item; if (item) { switch (column){ case 1: mPriorityPopupMenu->popup(QCursor::pos ()); break; case 2: mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; case 3: moveTodo(); break; case 6: getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; default: mItemPopupMenu->popup(QCursor::pos()); } } else mPopupMenu->popup(QCursor::pos()); } void KOTodoView::newTodo() { emit newTodoSignal(); } void KOTodoView::newSubTodo() { if (mActiveItem) { emit newSubTodoSignal(mActiveItem->todo()); } } void KOTodoView::unparentTodo() { if (mActiveItem) { emit unparentTodoSignal(mActiveItem->todo()); } } + +void KOTodoView::reparentTodo() +{ + if (mActiveItem) { + qDebug("KOTodoView::reparentTodo() "); + topLevelWidget()->setCaption(i18n("Click on new parent item")); + pendingSubtodo = mActiveItem; + } +} void KOTodoView::editTodo() { if (mActiveItem) { emit editTodoSignal(mActiveItem->todo()); } } void KOTodoView::cloneTodo() { if (mActiveItem) { emit cloneTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::cancelTodo() { if (mActiveItem) { emit cancelTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::moveTodo() { if (mActiveItem) { emit moveTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::beamTodo() { if (mActiveItem) { emit beamTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::showTodo() { if (mActiveItem) { emit showTodoSignal(mActiveItem->todo()); } } void KOTodoView::deleteTodo() { if (mActiveItem) { if (mActiveItem->childCount()) { KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), i18n("Delete To-Do")); } else { emit deleteTodoSignal(mActiveItem->todo()); } } } void KOTodoView::setNewPriority(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { mActiveItem->todo()->setPriority(mPriority[index]); mActiveItem->construct(); todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); } } void KOTodoView::setNewPercentage(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { if (mPercentage[index] == 100) { mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); } else { mActiveItem->todo()->setCompleted(false); } mActiveItem->todo()->setPercentComplete(mPercentage[index]); mActiveItem->construct(); todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); } } QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) { QPopupMenu* tempMenu = new QPopupMenu (this); QStringList checkedCategories = todoItem->todo()->categories (); tempMenu->setCheckable (true); for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); it != KOPrefs::instance()->mCustomCategories.end (); ++it) { int index = tempMenu->insertItem (*it); mCategory[index] = *it; if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); } connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); return tempMenu; } void KOTodoView::changedCategories(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { QStringList categories = mActiveItem->todo()->categories (); if (categories.find (mCategory[index]) != categories.end ()) categories.remove (mCategory[index]); else categories.insert (categories.end(), mCategory[index]); categories.sort (); mActiveItem->todo()->setCategories (categories); mActiveItem->construct(); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); } } void KOTodoView::itemDoubleClicked(QListViewItem *item) { + if ( pendingSubtodo != 0 ) { + topLevelWidget()->setCaption(i18n("Reparenting aborted!")); + } + pendingSubtodo = 0; if (!item) { newTodo(); return; } if ( KOPrefs::instance()->mEditOnDoubleClick ) editItem( item ); else showItem( item , QPoint(), 0 ); } void KOTodoView::itemClicked(QListViewItem *item) { + if (!item) { + if ( pendingSubtodo != 0 ) { + topLevelWidget()->setCaption(i18n("Reparenting aborted!")); + } + pendingSubtodo = 0; return; } - KOTodoViewItem *todoItem = (KOTodoViewItem *)item; + if ( pendingSubtodo != 0 ) { + bool allowReparent = true; + QListViewItem *par = item; + while ( par ) { + if ( par == pendingSubtodo ) { + allowReparent = false; + break; + } + par = par->parent(); + } + if ( !allowReparent ) { + topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); + qDebug("Recursive reparenting not possible "); + pendingSubtodo = 0; + } else { + Todo* newParent = todoItem->todo(); + Todo* newSub = pendingSubtodo->todo(); + pendingSubtodo = 0; + emit reparentTodoSignal( newParent,newSub ); + return; + } + } int completed = todoItem->todo()->isCompleted(); // Completed or not? if (todoItem->isOn()) { if (!completed) { todoItem->todo()->setCompleted(QDateTime::currentDateTime()); } } else { if (completed) { todoItem->todo()->setCompleted(false); } } } void KOTodoView::setDocumentId( const QString &id ) { kdDebug() << "KOTodoView::setDocumentId()" << endl; mDocPrefs->setDoc( id ); } void KOTodoView::itemStateChanged( QListViewItem *item ) { if (!item) return; KOTodoViewItem *todoItem = (KOTodoViewItem *)item; // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); } void KOTodoView::saveLayout(KConfig *config, const QString &group) const { mTodoListView->saveLayout(config,group); } void KOTodoView::restoreLayout(KConfig *config, const QString &group) { mTodoListView->restoreLayout(config,group); } void KOTodoView::processSelectionChange() { // kdDebug() << "KOTodoView::processSelectionChange()" << endl; KOTodoViewItem *item = static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); if ( !item ) { emit incidenceSelected( 0 ); } else { emit incidenceSelected( item->todo() ); } } void KOTodoView::modified(bool b) { emit isModified(b); } void KOTodoView::setTodoModified( Todo* todo ) { todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); } void KOTodoView::clearSelection() { mTodoListView->selectAll( false ); } void KOTodoView::purgeCompleted() { emit purgeCompletedSignal(); } void KOTodoView::toggleQuickTodo() { if ( mQuickAdd->isVisible() ) { mQuickAdd->hide(); KOPrefs::instance()->mEnableQuickTodo = false; } else { mQuickAdd->show(); KOPrefs::instance()->mEnableQuickTodo = true; } mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); } void KOTodoView::toggleCompleted() { KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); updateView(); } void KOTodoView::addQuickTodo() { Todo *todo = new Todo(); todo->setSummary(mQuickAdd->text()); todo->setOrganizer(KOPrefs::instance()->email()); CalFilter * cf = mCalendar->filter(); if ( cf ) { if ( cf->isEnabled()&& cf->showCategories()) { todo->setCategories(cf->categoryList()); } if ( cf->isEnabled() ) todo->setSecrecy( cf->getSecrecy()); } mCalendar->addTodo(todo); mQuickAdd->setText(""); todoModified (todo, KOGlobals::EVENTADDED ); updateView(); } void KOTodoView::keyPressEvent ( QKeyEvent * e ) { // e->ignore(); //return; + //qDebug("KOTodoView::keyPressEvent "); switch ( e->key() ) { case Qt::Key_Down: case Qt::Key_Up: QWidget::keyPressEvent ( e ); break; case Qt::Key_Q: toggleQuickTodo(); break; - + case Qt::Key_U: + if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + unparentTodo(); + e->accept(); + } else + e->ignore(); + break; + case Qt::Key_S: + if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + reparentTodo(); + e->accept(); + } else + e->ignore(); + break; + case Qt::Key_P: + if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + if ( pendingSubtodo ) + itemClicked(mActiveItem); + e->accept(); + } else + e->ignore(); + break; + case Qt::Key_Escape: + if ( pendingSubtodo ) { + itemClicked(0); + e->accept(); + } else + e->ignore(); + break; default: e->ignore(); } if ( true ) { if ( e->key() == Qt::Key_I ) { KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); if ( cn ) { mActiveItem = cn; KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); if ( ci ){ showTodo(); cn = (KOTodoViewItem*)cn->itemBelow(); if ( cn ) { mTodoListView->setCurrentItem ( cn ); mTodoListView->ensureItemVisible ( cn ); } } } e->accept(); } } } void KOTodoView::updateTodo( Todo * t, int type ) { if ( mBlockUpdate) return; QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; itemIterator = mTodoMap.find(t); if (itemIterator != mTodoMap.end()) { (*itemIterator)->construct(); } else { if ( type == KOGlobals::EVENTADDED ) { insertTodoItem( t ); } } } void KOTodoView::todoModified(Todo * t , int p ) { mBlockUpdate = true; emit todoModifiedSignal ( t, p ); mBlockUpdate = false; } diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 6bf0203..0c08677 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -54,178 +54,181 @@ class DocPrefs; class KOTodoListView : public KListView { Q_OBJECT public: KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); virtual ~KOTodoListView() {} signals: void todoDropped(Todo *); void double_Clicked(QListViewItem *item); protected: void contentsDragEnterEvent(QDragEnterEvent *); void contentsDragMoveEvent(QDragMoveEvent *); void contentsDragLeaveEvent(QDragLeaveEvent *); void contentsDropEvent(QDropEvent *); void contentsMousePressEvent(QMouseEvent *); void contentsMouseMoveEvent(QMouseEvent *); void contentsMouseReleaseEvent(QMouseEvent *); void contentsMouseDoubleClickEvent(QMouseEvent *); private: QString mName; Calendar *mCalendar; QPoint mPressPos; bool mMousePressed; QListViewItem *mOldCurrent; void keyPressEvent ( QKeyEvent * ) ; }; /** This is the line-edit on top of the todoview for fast addition of new todos */ class KOQuickTodo : public QLineEdit { public: KOQuickTodo(QWidget *parent=0); protected: void focusInEvent(QFocusEvent *ev); void focusOutEvent(QFocusEvent *ev); }; /** This class provides a multi-column list view of todo events. @short multi-column list view of todo events. @author Cornelius Schumacher <schumacher@kde.org> */ class KOTodoView : public KOrg::BaseView { Q_OBJECT public: KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); ~KOTodoView(); QPtrList<Incidence> selectedIncidences(); QPtrList<Todo> selectedTodos(); DateList selectedDates() {DateList q; return q;} /** Return number of shown dates. TodoView does not show dates, */ int currentDateCount() { return 0; } void setNarrow(); void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); void setDocumentId( const QString & ); void saveLayout(KConfig *config, const QString &group) const; void restoreLayout(KConfig *config, const QString &group); /** Create a popup menu to set categories */ QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); public slots: void updateView(); void updateConfig(); void changeEventDisplay(Event *, int); void showDates(const QDate &start, const QDate &end); void showEvents(QPtrList<Event> eventList); void clearSelection(); void jumpToDate (); void editItem(QListViewItem *item); void showItem(QListViewItem *item,const QPoint &,int); void popupMenu(QListViewItem *item,const QPoint &,int); void newTodo(); void newSubTodo(); void unparentTodo(); + void reparentTodo(); void showTodo(); void editTodo(); void cloneTodo(); void cancelTodo(); void moveTodo(); void beamTodo(); void deleteTodo(); void setNewPriority(int); void setNewPercentage(int); void changedCategories(int); void purgeCompleted(); void toggleCompleted(); void toggleQuickTodo(); void updateTodo( Todo *, int ); void itemClicked(QListViewItem *); void itemStateChanged(QListViewItem *); void modified(bool); void itemDoubleClicked(QListViewItem *item); signals: void newTodoSignal(); void newSubTodoSignal(Todo *); void unparentTodoSignal(Todo *); + void reparentTodoSignal( Todo *,Todo * ); void showTodoSignal(Todo *); void editTodoSignal(Todo *); void deleteTodoSignal(Todo *); void todoModifiedSignal (Todo *, int); void isModified(bool); void cloneTodoSignal( Incidence * ); void cancelTodoSignal( Incidence * ); void moveTodoSignal( Incidence * ); void beamTodoSignal( Incidence * ); void purgeCompletedSignal(); protected slots: void processSelectionChange(); void addQuickTodo(); private: /* * the TodoEditor approach is rather unscaling in the long * run. * Korganizer keeps it in memory and we need to update * 1. make KOTodoViewItem a QObject again? * 2. add a public method for setting one todo modified? * 3. add a private method for setting a todo modified + friend here? * -- zecke 2002-07-08 */ friend class KOTodoViewItem; void setTodoModified( Todo* ); QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); void restoreItemState( QListViewItem * ); KOTodoListView *mTodoListView; QPopupMenu *mItemPopupMenu; QPopupMenu *mPopupMenu; QPopupMenu *mPriorityPopupMenu; QPopupMenu *mPercentageCompletedPopupMenu; QPopupMenu *mCategoryPopupMenu; QMap<int, int> mPercentage; QMap<int, int> mPriority; QMap<int, QString> mCategory; KOTodoViewItem *mActiveItem; QMap<Todo *,KOTodoViewItem *> mTodoMap; QString mName; DocPrefs *mDocPrefs; QString mCurrentDoc; KOQuickTodo *mQuickAdd; bool mBlockUpdate; void todoModified(Todo *, int ); void keyPressEvent ( QKeyEvent * ) ; + KOTodoViewItem * pendingSubtodo; }; #endif diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 8e6cc53..391f98c 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -405,171 +405,173 @@ void KOViewManager::showNextXView() showAgendaView(KOPrefs::instance()->mFullViewMonth); globalFlagBlockAgenda = 2; mMainView->dateNavigator()->selectDates( QDate::currentDate(), KOPrefs::instance()->mNextXDays ); mFlagShowNextxDays = true; mCurrentAgendaView = 3 ; } bool KOViewManager::showsNextDays() { return mFlagShowNextxDays; } void KOViewManager::showMonthView() { if (!mMonthView) { mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); addView(mMonthView); // mMonthView->show(); // SIGNALS/SLOTS FOR MONTH VIEW connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), mMainView, SLOT(newEvent(QDateTime))); connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), mMainView, SLOT(editIncidence(Incidence *))); connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *))); connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( selectWeekNum( int ) ), mMainView, SLOT ( selectWeekNum( int ) ) ); connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); mMonthView->updateConfig(); } globalFlagBlockAgenda = 1; //mFlagShowNextxDays = false; // if(mMonthView == mCurrentView) return; mMainView->dateNavigator()->selectMonth(); // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); //mMonthView->showDates(tmpList.first(), tmpList.last()); showView(mMonthView, true ); } void KOViewManager::showTodoView() { //mFlagShowNextxDays = false; if ( !mTodoView ) { mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), "KOViewManager::TodoView" ); addView( mTodoView ); // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); // SIGNALS/SLOTS FOR TODO VIEW connect( mTodoView, SIGNAL( newTodoSignal() ), mMainView, SLOT( newTodo() ) ); connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), mMainView, SLOT( newSubTodo( Todo *) ) ); connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), mMainView, SLOT( showTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), mMainView, SLOT( editTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), mMainView, SLOT( deleteTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( purgeCompletedSignal() ), mMainView, SLOT( purgeCompleted() ) ); connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mMainView, SIGNAL( configChanged() ), mTodoView, SLOT( updateConfig() ) ); connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, SLOT( updateTodo( Todo *, int ) ) ); connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), mMainView, SLOT ( todo_unsub( Todo * ) ) ); + connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), + mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); KConfig *config = KOGlobals::config(); mTodoView->restoreLayout(config,"Todo View"); } globalFlagBlockAgenda = 1; showView( mTodoView, true ); } void KOViewManager::showJournalView() { //mFlagShowNextxDays = false; if (!mJournalView) { mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::JournalView"); connect( mMainView, SIGNAL( configChanged() ), mJournalView, SLOT( updateConfig() ) ); connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); addView(mJournalView); } showView(mJournalView); } void KOViewManager::showTimeSpanView() { //mFlagShowNextxDays = false; if (!mTimeSpanView) { mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::TimeSpanView"); addView(mTimeSpanView); mTimeSpanView->readSettings(); } showView(mTimeSpanView); } Incidence *KOViewManager::currentSelection() { if (!mCurrentView) return 0; if ( mCurrentView == mListView ) { if ( mListView->currentItem() ) return mListView->currentItem(); } return mCurrentView->selectedIncidences().first(); } QDate KOViewManager::currentSelectionDate() { QDate qd; if (mCurrentView) { DateList qvl = mCurrentView->selectedDates(); if (!qvl.isEmpty()) qd = qvl.first(); } return qd; } void KOViewManager::addView(KOrg::BaseView *view) { #if QT_VERSION >= 300 mMainView->viewStack()->addWidget( view ); #else mMainView->viewStack()->addWidget( view, 1 ); #endif } void KOViewManager::setDocumentId( const QString &id ) { if (mTodoView) mTodoView->setDocumentId( id ); } diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 8daacc7..06470b8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1054,192 +1054,195 @@ void MainWindow::displayText( QString text ,QString cap ) tb.setText( text ); #ifdef DESKTOP_VERSION dia.resize( 640, 480); #else dia.showMaximized(); #endif dia.exec(); } void MainWindow::displayFile( QString fn, QString cap ) { QString fileName = resourcePath() + fn; QString text; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return ; } QTextStream ts( &file ); text = ts.read(); file.close(); displayText( text, cap); } void MainWindow::features() { displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); } void MainWindow::usertrans() { displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); } void MainWindow::synchowto() { KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); } void MainWindow::faq() { displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); } void MainWindow::whatsNew() { KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); } void MainWindow::licence() { KApplication::showLicence(); } void MainWindow::about() { QString version; #include <../version> QMessageBox::about( this, i18n("About KOrganizer/Pi"), i18n("KOrganizer/Platform-independent\n") + "(KO/Pi) " + version + " - " + #ifdef DESKTOP_VERSION i18n("Desktop Edition\n") + #else i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + #endif i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); } void MainWindow::keyBindings() { QString cap = i18n("Key bindings KOrganizer/Pi"); QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ i18n("<p><h3>In agenda view:</h3></p>\n") + i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ i18n("<p><h3>In todo view:</h3></p>\n") + + i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ + i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ + i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ i18n("<p><h3>In list view:</h3></p>\n") + i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ i18n("<p><b>return</b>: Select item+one step down</p>\n")+ i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ i18n("<p><h3>In event/todo viewer:</h3></p>\n") + i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ i18n("<p><b>A</b>: Show agenda view.</p>\n")+ i18n("<p><b>E</b>: Edit item</p>\n") + i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + i18n("<p><b>White</b>: Item readonly</p>\n"); displayText( text, cap); } void MainWindow::aboutAutoSaving() { QMessageBox* msg; msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); msg->exec(); delete msg; } void MainWindow::aboutKnownBugs() { QMessageBox* msg; msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + i18n("\nor report them in the bugtracker on\n") + i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); msg->exec(); delete msg; } QString MainWindow::defaultFileName() { return locateLocal( "data", "korganizer/mycalendar.ics" ); } QString MainWindow::syncFileName() { #ifdef _WIN32_ return locateLocal( "tmp", "synccalendar.ics" ); #else return QString( "/tmp/kopitempfile.ics" ); #endif } void MainWindow::processIncidenceSelection( Incidence *incidence ) { if ( !incidence ) { enableIncidenceActions( false ); mNewSubTodoAction->setEnabled( false ); setCaptionToDates(); return; } //KGlobal::locale()->formatDateTime(nextA, true); QString startString = ""; if ( incidence->type() != "Todo" ) { if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { if ( incidence->doesFloat() ) { startString += ": "+incidence->dtStartDateStr( true ); startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); } else { startString = ": "+incidence->dtStartStr(true); startString += " --- "+((Event*)incidence)->dtEndStr(true); } |