author | zautrix <zautrix> | 2005-07-06 11:17:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-06 11:17:00 (UTC) |
commit | 7e22293b1ec1ee190ca8db6c8ecd079bafdae520 (patch) (unidiff) | |
tree | aed67fbbd844480e3dc0a7b5587edca766b51a5f | |
parent | 3b77a857e17e04e47d22ba6017dd723ed922e3fc (diff) | |
download | kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.zip kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.tar.gz kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.tar.bz2 |
fixes
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 8 | ||||
-rw-r--r-- | microkde/ofileselector_p.cpp | 4 |
5 files changed, 12 insertions, 8 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 7566c6f..4b3f806 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2464,2155 +2464,2153 @@ void CalendarView::writeSettings() | |||
2464 | list << QString::number( x ); | 2464 | list << QString::number( x ); |
2465 | list << QString::number( y ); | 2465 | list << QString::number( y ); |
2466 | list << QString::number( w ); | 2466 | list << QString::number( w ); |
2467 | list << QString::number( h ); | 2467 | list << QString::number( h ); |
2468 | config->writeEntry("SearchLayout",list ); | 2468 | config->writeEntry("SearchLayout",list ); |
2469 | } | 2469 | } |
2470 | #endif | 2470 | #endif |
2471 | 2471 | ||
2472 | 2472 | ||
2473 | config->sync(); | 2473 | config->sync(); |
2474 | } | 2474 | } |
2475 | 2475 | ||
2476 | void CalendarView::readFilterSettings(KConfig *config) | 2476 | void CalendarView::readFilterSettings(KConfig *config) |
2477 | { | 2477 | { |
2478 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2478 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2479 | 2479 | ||
2480 | mFilters.clear(); | 2480 | mFilters.clear(); |
2481 | 2481 | ||
2482 | config->setGroup("General"); | 2482 | config->setGroup("General"); |
2483 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2483 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2484 | 2484 | ||
2485 | QStringList::ConstIterator it = filterList.begin(); | 2485 | QStringList::ConstIterator it = filterList.begin(); |
2486 | QStringList::ConstIterator end = filterList.end(); | 2486 | QStringList::ConstIterator end = filterList.end(); |
2487 | while(it != end) { | 2487 | while(it != end) { |
2488 | // kdDebug() << " filter: " << (*it) << endl; | 2488 | // kdDebug() << " filter: " << (*it) << endl; |
2489 | 2489 | ||
2490 | CalFilter *filter; | 2490 | CalFilter *filter; |
2491 | filter = new CalFilter(*it); | 2491 | filter = new CalFilter(*it); |
2492 | config->setGroup("Filter_" + (*it).utf8()); | 2492 | config->setGroup("Filter_" + (*it).utf8()); |
2493 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2493 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2494 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2494 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2495 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2495 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2496 | mFilters.append(filter); | 2496 | mFilters.append(filter); |
2497 | 2497 | ||
2498 | ++it; | 2498 | ++it; |
2499 | } | 2499 | } |
2500 | 2500 | ||
2501 | if (mFilters.count() == 0) { | 2501 | if (mFilters.count() == 0) { |
2502 | CalFilter *filter = new CalFilter(i18n("Default")); | 2502 | CalFilter *filter = new CalFilter(i18n("Default")); |
2503 | mFilters.append(filter); | 2503 | mFilters.append(filter); |
2504 | } | 2504 | } |
2505 | mFilterView->updateFilters(); | 2505 | mFilterView->updateFilters(); |
2506 | config->setGroup("FilterView"); | 2506 | config->setGroup("FilterView"); |
2507 | 2507 | ||
2508 | mFilterView->blockSignals(true); | 2508 | mFilterView->blockSignals(true); |
2509 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2509 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2510 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2510 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2511 | mFilterView->blockSignals(false); | 2511 | mFilterView->blockSignals(false); |
2512 | // We do it manually to avoid it being done twice by the above calls | 2512 | // We do it manually to avoid it being done twice by the above calls |
2513 | updateFilter(); | 2513 | updateFilter(); |
2514 | } | 2514 | } |
2515 | 2515 | ||
2516 | void CalendarView::writeFilterSettings(KConfig *config) | 2516 | void CalendarView::writeFilterSettings(KConfig *config) |
2517 | { | 2517 | { |
2518 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2518 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2519 | 2519 | ||
2520 | QStringList filterList; | 2520 | QStringList filterList; |
2521 | 2521 | ||
2522 | CalFilter *filter = mFilters.first(); | 2522 | CalFilter *filter = mFilters.first(); |
2523 | while(filter) { | 2523 | while(filter) { |
2524 | // kdDebug() << " fn: " << filter->name() << endl; | 2524 | // kdDebug() << " fn: " << filter->name() << endl; |
2525 | filterList << filter->name(); | 2525 | filterList << filter->name(); |
2526 | config->setGroup("Filter_" + filter->name().utf8()); | 2526 | config->setGroup("Filter_" + filter->name().utf8()); |
2527 | config->writeEntry("Criteria",filter->criteria()); | 2527 | config->writeEntry("Criteria",filter->criteria()); |
2528 | config->writeEntry("CategoryList",filter->categoryList()); | 2528 | config->writeEntry("CategoryList",filter->categoryList()); |
2529 | filter = mFilters.next(); | 2529 | filter = mFilters.next(); |
2530 | } | 2530 | } |
2531 | config->setGroup("General"); | 2531 | config->setGroup("General"); |
2532 | config->writeEntry("CalendarFilters",filterList); | 2532 | config->writeEntry("CalendarFilters",filterList); |
2533 | 2533 | ||
2534 | config->setGroup("FilterView"); | 2534 | config->setGroup("FilterView"); |
2535 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2535 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2536 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2536 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2537 | } | 2537 | } |
2538 | 2538 | ||
2539 | 2539 | ||
2540 | void CalendarView::goToday() | 2540 | void CalendarView::goToday() |
2541 | { | 2541 | { |
2542 | if ( mViewManager->currentView()->isMonthView() ) | 2542 | if ( mViewManager->currentView()->isMonthView() ) |
2543 | mNavigator->selectTodayMonth(); | 2543 | mNavigator->selectTodayMonth(); |
2544 | else | 2544 | else |
2545 | mNavigator->selectToday(); | 2545 | mNavigator->selectToday(); |
2546 | } | 2546 | } |
2547 | 2547 | ||
2548 | void CalendarView::goNext() | 2548 | void CalendarView::goNext() |
2549 | { | 2549 | { |
2550 | mNavigator->selectNext(); | 2550 | mNavigator->selectNext(); |
2551 | } | 2551 | } |
2552 | 2552 | ||
2553 | void CalendarView::goPrevious() | 2553 | void CalendarView::goPrevious() |
2554 | { | 2554 | { |
2555 | mNavigator->selectPrevious(); | 2555 | mNavigator->selectPrevious(); |
2556 | } | 2556 | } |
2557 | void CalendarView::goNextMonth() | 2557 | void CalendarView::goNextMonth() |
2558 | { | 2558 | { |
2559 | mNavigator->selectNextMonth(); | 2559 | mNavigator->selectNextMonth(); |
2560 | } | 2560 | } |
2561 | 2561 | ||
2562 | void CalendarView::goPreviousMonth() | 2562 | void CalendarView::goPreviousMonth() |
2563 | { | 2563 | { |
2564 | mNavigator->selectPreviousMonth(); | 2564 | mNavigator->selectPreviousMonth(); |
2565 | } | 2565 | } |
2566 | 2566 | ||
2567 | void CalendarView::updateConfig() | 2567 | void CalendarView::updateConfig() |
2568 | { | 2568 | { |
2569 | if ( KOPrefs::instance()->mUseAppColors ) | 2569 | if ( KOPrefs::instance()->mUseAppColors ) |
2570 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2570 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2571 | emit configChanged(); | 2571 | emit configChanged(); |
2572 | mTodoList->updateConfig(); | 2572 | mTodoList->updateConfig(); |
2573 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2573 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2574 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2574 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2575 | // To make the "fill window" configurations work | 2575 | // To make the "fill window" configurations work |
2576 | //mViewManager->raiseCurrentView(); | 2576 | //mViewManager->raiseCurrentView(); |
2577 | } | 2577 | } |
2578 | 2578 | ||
2579 | 2579 | ||
2580 | void CalendarView::eventChanged(Event *event) | 2580 | void CalendarView::eventChanged(Event *event) |
2581 | { | 2581 | { |
2582 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2582 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2583 | //updateUnmanagedViews(); | 2583 | //updateUnmanagedViews(); |
2584 | } | 2584 | } |
2585 | 2585 | ||
2586 | void CalendarView::eventAdded(Event *event) | 2586 | void CalendarView::eventAdded(Event *event) |
2587 | { | 2587 | { |
2588 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2588 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2589 | } | 2589 | } |
2590 | 2590 | ||
2591 | void CalendarView::eventToBeDeleted(Event *) | 2591 | void CalendarView::eventToBeDeleted(Event *) |
2592 | { | 2592 | { |
2593 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2593 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | void CalendarView::eventDeleted() | 2596 | void CalendarView::eventDeleted() |
2597 | { | 2597 | { |
2598 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2598 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2599 | } | 2599 | } |
2600 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2600 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2601 | { | 2601 | { |
2602 | changeIncidenceDisplay((Incidence *)which, action); | 2602 | changeIncidenceDisplay((Incidence *)which, action); |
2603 | mDateNavigator->updateView(); //LR | 2603 | mDateNavigator->updateView(); //LR |
2604 | //mDialogManager->updateSearchDialog(); | 2604 | //mDialogManager->updateSearchDialog(); |
2605 | 2605 | ||
2606 | if (which) { | 2606 | if (which) { |
2607 | mViewManager->updateWNview(); | 2607 | mViewManager->updateWNview(); |
2608 | //mTodoList->updateView(); | 2608 | //mTodoList->updateView(); |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | } | 2611 | } |
2612 | 2612 | ||
2613 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2613 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2614 | { | 2614 | { |
2615 | updateUnmanagedViews(); | 2615 | updateUnmanagedViews(); |
2616 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2616 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2617 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2617 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2618 | mCalendar->checkAlarmForIncidence( 0, true ); | 2618 | mCalendar->checkAlarmForIncidence( 0, true ); |
2619 | if ( mEventViewerDialog ) | 2619 | if ( mEventViewerDialog ) |
2620 | mEventViewerDialog->hide(); | 2620 | mEventViewerDialog->hide(); |
2621 | } | 2621 | } |
2622 | else | 2622 | else |
2623 | mCalendar->checkAlarmForIncidence( which , false ); | 2623 | mCalendar->checkAlarmForIncidence( which , false ); |
2624 | } | 2624 | } |
2625 | 2625 | ||
2626 | // most of the changeEventDisplays() right now just call the view's | 2626 | // most of the changeEventDisplays() right now just call the view's |
2627 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2627 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2628 | void CalendarView::changeEventDisplay(Event *which, int action) | 2628 | void CalendarView::changeEventDisplay(Event *which, int action) |
2629 | { | 2629 | { |
2630 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2630 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2631 | changeIncidenceDisplay((Incidence *)which, action); | 2631 | changeIncidenceDisplay((Incidence *)which, action); |
2632 | mDateNavigator->updateView(); | 2632 | mDateNavigator->updateView(); |
2633 | //mDialogManager->updateSearchDialog(); | 2633 | //mDialogManager->updateSearchDialog(); |
2634 | 2634 | ||
2635 | if (which) { | 2635 | if (which) { |
2636 | // If there is an event view visible update the display | 2636 | // If there is an event view visible update the display |
2637 | mViewManager->currentView()->changeEventDisplay(which,action); | 2637 | mViewManager->currentView()->changeEventDisplay(which,action); |
2638 | // TODO: check, if update needed | 2638 | // TODO: check, if update needed |
2639 | // if (which->getTodoStatus()) { | 2639 | // if (which->getTodoStatus()) { |
2640 | mTodoList->updateView(); | 2640 | mTodoList->updateView(); |
2641 | // } | 2641 | // } |
2642 | } else { | 2642 | } else { |
2643 | mViewManager->currentView()->updateView(); | 2643 | mViewManager->currentView()->updateView(); |
2644 | } | 2644 | } |
2645 | } | 2645 | } |
2646 | 2646 | ||
2647 | 2647 | ||
2648 | void CalendarView::updateTodoViews() | 2648 | void CalendarView::updateTodoViews() |
2649 | { | 2649 | { |
2650 | mTodoList->updateView(); | 2650 | mTodoList->updateView(); |
2651 | mViewManager->currentView()->updateView(); | 2651 | mViewManager->currentView()->updateView(); |
2652 | 2652 | ||
2653 | } | 2653 | } |
2654 | 2654 | ||
2655 | 2655 | ||
2656 | 2656 | ||
2657 | void CalendarView::clearAllViews() | 2657 | void CalendarView::clearAllViews() |
2658 | { | 2658 | { |
2659 | mTodoList->clearList(); | 2659 | mTodoList->clearList(); |
2660 | mViewManager->clearAllViews(); | 2660 | mViewManager->clearAllViews(); |
2661 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2661 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2662 | if ( sd ) { | 2662 | if ( sd ) { |
2663 | KOListView* kol = sd->listview(); | 2663 | KOListView* kol = sd->listview(); |
2664 | if ( kol ) | 2664 | if ( kol ) |
2665 | kol->clearList(); | 2665 | kol->clearList(); |
2666 | } | 2666 | } |
2667 | } | 2667 | } |
2668 | void CalendarView::updateView() | 2668 | void CalendarView::updateView() |
2669 | { | 2669 | { |
2670 | DateList tmpList = mNavigator->selectedDates(); | 2670 | DateList tmpList = mNavigator->selectedDates(); |
2671 | 2671 | ||
2672 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2672 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2673 | mTodoList->updateView(); | 2673 | mTodoList->updateView(); |
2674 | // We assume that the navigator only selects consecutive days. | 2674 | // We assume that the navigator only selects consecutive days. |
2675 | updateView( tmpList.first(), tmpList.last() ); | 2675 | updateView( tmpList.first(), tmpList.last() ); |
2676 | } | 2676 | } |
2677 | 2677 | ||
2678 | void CalendarView::updateUnmanagedViews() | 2678 | void CalendarView::updateUnmanagedViews() |
2679 | { | 2679 | { |
2680 | mDateNavigator->updateDayMatrix(); | 2680 | mDateNavigator->updateDayMatrix(); |
2681 | } | 2681 | } |
2682 | 2682 | ||
2683 | int CalendarView::msgItemDelete(const QString name) | 2683 | int CalendarView::msgItemDelete(const QString name) |
2684 | { | 2684 | { |
2685 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2685 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2686 | i18n("This item will be\npermanently deleted."), | 2686 | i18n("This item will be\npermanently deleted."), |
2687 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2687 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2688 | } | 2688 | } |
2689 | 2689 | ||
2690 | 2690 | ||
2691 | void CalendarView::edit_cut() | 2691 | void CalendarView::edit_cut() |
2692 | { | 2692 | { |
2693 | Event *anEvent=0; | 2693 | Event *anEvent=0; |
2694 | 2694 | ||
2695 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2695 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2696 | 2696 | ||
2697 | if (mViewManager->currentView()->isEventView()) { | 2697 | if (mViewManager->currentView()->isEventView()) { |
2698 | if ( incidence && incidence->typeID() == eventID ) { | 2698 | if ( incidence && incidence->typeID() == eventID ) { |
2699 | anEvent = static_cast<Event *>(incidence); | 2699 | anEvent = static_cast<Event *>(incidence); |
2700 | } | 2700 | } |
2701 | } | 2701 | } |
2702 | 2702 | ||
2703 | if (!anEvent) { | 2703 | if (!anEvent) { |
2704 | KNotifyClient::beep(); | 2704 | KNotifyClient::beep(); |
2705 | return; | 2705 | return; |
2706 | } | 2706 | } |
2707 | DndFactory factory( mCalendar ); | 2707 | DndFactory factory( mCalendar ); |
2708 | factory.cutIncidence(anEvent); | 2708 | factory.cutIncidence(anEvent); |
2709 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2709 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2710 | } | 2710 | } |
2711 | 2711 | ||
2712 | void CalendarView::edit_copy() | 2712 | void CalendarView::edit_copy() |
2713 | { | 2713 | { |
2714 | Event *anEvent=0; | 2714 | Event *anEvent=0; |
2715 | 2715 | ||
2716 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2716 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2717 | 2717 | ||
2718 | if (mViewManager->currentView()->isEventView()) { | 2718 | if (mViewManager->currentView()->isEventView()) { |
2719 | if ( incidence && incidence->typeID() == eventID ) { | 2719 | if ( incidence && incidence->typeID() == eventID ) { |
2720 | anEvent = static_cast<Event *>(incidence); | 2720 | anEvent = static_cast<Event *>(incidence); |
2721 | } | 2721 | } |
2722 | } | 2722 | } |
2723 | 2723 | ||
2724 | if (!anEvent) { | 2724 | if (!anEvent) { |
2725 | KNotifyClient::beep(); | 2725 | KNotifyClient::beep(); |
2726 | return; | 2726 | return; |
2727 | } | 2727 | } |
2728 | DndFactory factory( mCalendar ); | 2728 | DndFactory factory( mCalendar ); |
2729 | factory.copyIncidence(anEvent); | 2729 | factory.copyIncidence(anEvent); |
2730 | } | 2730 | } |
2731 | 2731 | ||
2732 | void CalendarView::edit_paste() | 2732 | void CalendarView::edit_paste() |
2733 | { | 2733 | { |
2734 | QDate date = mNavigator->selectedDates().first(); | 2734 | QDate date = mNavigator->selectedDates().first(); |
2735 | 2735 | ||
2736 | DndFactory factory( mCalendar ); | 2736 | DndFactory factory( mCalendar ); |
2737 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2737 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2738 | 2738 | ||
2739 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2739 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2740 | } | 2740 | } |
2741 | void CalendarView::edit_global_options() | 2741 | void CalendarView::edit_global_options() |
2742 | { | 2742 | { |
2743 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2743 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2744 | emit save(); | 2744 | emit save(); |
2745 | emit saveStopTimer(); | 2745 | emit saveStopTimer(); |
2746 | mDialogManager->showGlobalOptionsDialog(); | 2746 | mDialogManager->showGlobalOptionsDialog(); |
2747 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2747 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2748 | emit saveStopTimer(); | 2748 | emit saveStopTimer(); |
2749 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2749 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2750 | i18n("Timezone settings"),i18n("Reload"))) { | 2750 | i18n("Timezone settings"),i18n("Reload"))) { |
2751 | qDebug("KO: TZ reload cancelled "); | 2751 | qDebug("KO: TZ reload cancelled "); |
2752 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2752 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2753 | return; | 2753 | return; |
2754 | } | 2754 | } |
2755 | qDebug("KO: Timezone change "); | 2755 | qDebug("KO: Timezone change "); |
2756 | loadCalendars(); | 2756 | loadCalendars(); |
2757 | setModified(true); | 2757 | setModified(true); |
2758 | } | 2758 | } |
2759 | else | 2759 | else |
2760 | qDebug("KO: No tz change "); | 2760 | qDebug("KO: No tz change "); |
2761 | } | 2761 | } |
2762 | void CalendarView::edit_options() | 2762 | void CalendarView::edit_options() |
2763 | { | 2763 | { |
2764 | mDialogManager->showOptionsDialog(); | 2764 | mDialogManager->showOptionsDialog(); |
2765 | } | 2765 | } |
2766 | 2766 | ||
2767 | 2767 | ||
2768 | void CalendarView::slotSelectPickerDate( QDate d) | 2768 | void CalendarView::slotSelectPickerDate( QDate d) |
2769 | { | 2769 | { |
2770 | mDateFrame->hide(); | 2770 | mDateFrame->hide(); |
2771 | if ( mDatePickerMode == 1 ) { | 2771 | if ( mDatePickerMode == 1 ) { |
2772 | mNavigator->slotDaySelect( d ); | 2772 | mNavigator->slotDaySelect( d ); |
2773 | } else if ( mDatePickerMode == 2 ) { | 2773 | } else if ( mDatePickerMode == 2 ) { |
2774 | if ( mMoveIncidence->typeID() == todoID ) { | 2774 | if ( mMoveIncidence->typeID() == todoID ) { |
2775 | Todo * to = (Todo *) mMoveIncidence; | 2775 | Todo * to = (Todo *) mMoveIncidence; |
2776 | QTime tim; | 2776 | QTime tim; |
2777 | int len = 0; | 2777 | int len = 0; |
2778 | if ( to->hasStartDate() && to->hasDueDate() ) | 2778 | if ( to->hasStartDate() && to->hasDueDate() ) |
2779 | len = to->dtStart().secsTo( to->dtDue()); | 2779 | len = to->dtStart().secsTo( to->dtDue()); |
2780 | if ( to->hasDueDate() ) | 2780 | if ( to->hasDueDate() ) |
2781 | tim = to->dtDue().time(); | 2781 | tim = to->dtDue().time(); |
2782 | else { | 2782 | else { |
2783 | tim = QTime ( 0,0,0 ); | 2783 | tim = QTime ( 0,0,0 ); |
2784 | to->setFloats( true ); | 2784 | to->setFloats( true ); |
2785 | to->setHasDueDate( true ); | 2785 | to->setHasDueDate( true ); |
2786 | } | 2786 | } |
2787 | QDateTime dt ( d,tim ); | 2787 | QDateTime dt ( d,tim ); |
2788 | to->setDtDue( dt ); | 2788 | to->setDtDue( dt ); |
2789 | 2789 | ||
2790 | if ( to->hasStartDate() ) { | 2790 | if ( to->hasStartDate() ) { |
2791 | if ( len>0 ) | 2791 | if ( len>0 ) |
2792 | to->setDtStart(to->dtDue().addSecs( -len )); | 2792 | to->setDtStart(to->dtDue().addSecs( -len )); |
2793 | else | 2793 | else |
2794 | if (to->dtStart() > to->dtDue() ) | 2794 | if (to->dtStart() > to->dtDue() ) |
2795 | to->setDtStart(to->dtDue().addDays( -3 )); | 2795 | to->setDtStart(to->dtDue().addDays( -3 )); |
2796 | } | 2796 | } |
2797 | 2797 | ||
2798 | todoChanged( to ); | 2798 | todoChanged( to ); |
2799 | } else { | 2799 | } else { |
2800 | if ( mMoveIncidence->doesRecur() ) { | 2800 | if ( mMoveIncidence->doesRecur() ) { |
2801 | #if 0 | 2801 | #if 0 |
2802 | // PENDING implement this | 2802 | // PENDING implement this |
2803 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2803 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2804 | mCalendar()->addIncidence( newInc ); | 2804 | mCalendar()->addIncidence( newInc ); |
2805 | if ( mMoveIncidence->typeID() == todoID ) | 2805 | if ( mMoveIncidence->typeID() == todoID ) |
2806 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2806 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2807 | else | 2807 | else |
2808 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2808 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2809 | mMoveIncidence = newInc; | 2809 | mMoveIncidence = newInc; |
2810 | 2810 | ||
2811 | #endif | 2811 | #endif |
2812 | } | 2812 | } |
2813 | QTime tim = mMoveIncidence->dtStart().time(); | 2813 | QTime tim = mMoveIncidence->dtStart().time(); |
2814 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2814 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2815 | QDateTime dt ( d,tim ); | 2815 | QDateTime dt ( d,tim ); |
2816 | mMoveIncidence->setDtStart( dt ); | 2816 | mMoveIncidence->setDtStart( dt ); |
2817 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2817 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2818 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2818 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2819 | } | 2819 | } |
2820 | 2820 | ||
2821 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2821 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2822 | } | 2822 | } |
2823 | } | 2823 | } |
2824 | 2824 | ||
2825 | void CalendarView::removeCategories() | 2825 | void CalendarView::removeCategories() |
2826 | { | 2826 | { |
2827 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2827 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2828 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2828 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2829 | QStringList catIncList; | 2829 | QStringList catIncList; |
2830 | QStringList newCatList; | 2830 | QStringList newCatList; |
2831 | Incidence* inc = incList.first(); | 2831 | Incidence* inc = incList.first(); |
2832 | uint i; | 2832 | uint i; |
2833 | while ( inc ) { | 2833 | while ( inc ) { |
2834 | newCatList.clear(); | 2834 | newCatList.clear(); |
2835 | catIncList = inc->categories() ; | 2835 | catIncList = inc->categories() ; |
2836 | for( i = 0; i< catIncList.count(); ++i ) { | 2836 | for( i = 0; i< catIncList.count(); ++i ) { |
2837 | if ( catList.contains (catIncList[i])) | 2837 | if ( catList.contains (catIncList[i])) |
2838 | newCatList.append( catIncList[i] ); | 2838 | newCatList.append( catIncList[i] ); |
2839 | } | 2839 | } |
2840 | newCatList.sort(); | 2840 | newCatList.sort(); |
2841 | inc->setCategories( newCatList.join(",") ); | 2841 | inc->setCategories( newCatList.join(",") ); |
2842 | inc = incList.next(); | 2842 | inc = incList.next(); |
2843 | } | 2843 | } |
2844 | } | 2844 | } |
2845 | 2845 | ||
2846 | int CalendarView::addCategories() | 2846 | int CalendarView::addCategories() |
2847 | { | 2847 | { |
2848 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2848 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2849 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2849 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2850 | QStringList catIncList; | 2850 | QStringList catIncList; |
2851 | Incidence* inc = incList.first(); | 2851 | Incidence* inc = incList.first(); |
2852 | uint i; | 2852 | uint i; |
2853 | int count = 0; | 2853 | int count = 0; |
2854 | while ( inc ) { | 2854 | while ( inc ) { |
2855 | catIncList = inc->categories() ; | 2855 | catIncList = inc->categories() ; |
2856 | for( i = 0; i< catIncList.count(); ++i ) { | 2856 | for( i = 0; i< catIncList.count(); ++i ) { |
2857 | if ( !catList.contains (catIncList[i])) { | 2857 | if ( !catList.contains (catIncList[i])) { |
2858 | catList.append( catIncList[i] ); | 2858 | catList.append( catIncList[i] ); |
2859 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2859 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2860 | ++count; | 2860 | ++count; |
2861 | } | 2861 | } |
2862 | } | 2862 | } |
2863 | inc = incList.next(); | 2863 | inc = incList.next(); |
2864 | } | 2864 | } |
2865 | catList.sort(); | 2865 | catList.sort(); |
2866 | KOPrefs::instance()->mCustomCategories = catList; | 2866 | KOPrefs::instance()->mCustomCategories = catList; |
2867 | return count; | 2867 | return count; |
2868 | } | 2868 | } |
2869 | 2869 | ||
2870 | void CalendarView::editCategories() | 2870 | void CalendarView::editCategories() |
2871 | { | 2871 | { |
2872 | qDebug("CalendarView::editCategories() "); | 2872 | qDebug("CalendarView::editCategories() "); |
2873 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 2873 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
2874 | ced.exec(); | 2874 | ced.exec(); |
2875 | } | 2875 | } |
2876 | void CalendarView::manageCategories() | 2876 | void CalendarView::manageCategories() |
2877 | { | 2877 | { |
2878 | KOCatPrefs* cp = new KOCatPrefs(); | 2878 | KOCatPrefs* cp = new KOCatPrefs(); |
2879 | cp->show(); | 2879 | cp->show(); |
2880 | int w =cp->sizeHint().width() ; | 2880 | int w =cp->sizeHint().width() ; |
2881 | int h = cp->sizeHint().height() ; | 2881 | int h = cp->sizeHint().height() ; |
2882 | int dw = QApplication::desktop()->width(); | 2882 | int dw = QApplication::desktop()->width(); |
2883 | int dh = QApplication::desktop()->height(); | 2883 | int dh = QApplication::desktop()->height(); |
2884 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2884 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2885 | if ( !cp->exec() ) { | 2885 | if ( !cp->exec() ) { |
2886 | delete cp; | 2886 | delete cp; |
2887 | return; | 2887 | return; |
2888 | } | 2888 | } |
2889 | int count = 0; | 2889 | int count = 0; |
2890 | if ( cp->addCat() ) { | 2890 | if ( cp->addCat() ) { |
2891 | count = addCategories(); | 2891 | count = addCategories(); |
2892 | if ( count ) { | 2892 | if ( count ) { |
2893 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2893 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2894 | writeSettings(); | 2894 | writeSettings(); |
2895 | } else | 2895 | } else |
2896 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2896 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2897 | } else { | 2897 | } else { |
2898 | removeCategories(); | 2898 | removeCategories(); |
2899 | updateView(); | 2899 | updateView(); |
2900 | } | 2900 | } |
2901 | delete cp; | 2901 | delete cp; |
2902 | } | 2902 | } |
2903 | 2903 | ||
2904 | void CalendarView::beamIncidence(Incidence * Inc) | 2904 | void CalendarView::beamIncidence(Incidence * Inc) |
2905 | { | 2905 | { |
2906 | QPtrList<Incidence> delSel ; | 2906 | QPtrList<Incidence> delSel ; |
2907 | delSel.append(Inc); | 2907 | delSel.append(Inc); |
2908 | beamIncidenceList( delSel ); | 2908 | beamIncidenceList( delSel ); |
2909 | } | 2909 | } |
2910 | void CalendarView::beamCalendar() | 2910 | void CalendarView::beamCalendar() |
2911 | { | 2911 | { |
2912 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2912 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2913 | //qDebug("beamCalendar() "); | 2913 | //qDebug("beamCalendar() "); |
2914 | beamIncidenceList( delSel ); | 2914 | beamIncidenceList( delSel ); |
2915 | } | 2915 | } |
2916 | void CalendarView::beamFilteredCalendar() | 2916 | void CalendarView::beamFilteredCalendar() |
2917 | { | 2917 | { |
2918 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2918 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2919 | //qDebug("beamFilteredCalendar() "); | 2919 | //qDebug("beamFilteredCalendar() "); |
2920 | beamIncidenceList( delSel ); | 2920 | beamIncidenceList( delSel ); |
2921 | } | 2921 | } |
2922 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2922 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2923 | { | 2923 | { |
2924 | 2924 | ||
2925 | KOBeamPrefs beamDialog; | 2925 | KOBeamPrefs beamDialog; |
2926 | if ( beamDialog.exec () == QDialog::Rejected ) | 2926 | if ( beamDialog.exec () == QDialog::Rejected ) |
2927 | return; | 2927 | return; |
2928 | #ifdef DESKTOP_VERSION | 2928 | #ifdef DESKTOP_VERSION |
2929 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2929 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2930 | #else | 2930 | #else |
2931 | QString fn = "/tmp/kopibeamfile"; | 2931 | QString fn = "/tmp/kopibeamfile"; |
2932 | #endif | 2932 | #endif |
2933 | QString mes; | 2933 | QString mes; |
2934 | bool createbup = true; | 2934 | bool createbup = true; |
2935 | if ( createbup ) { | 2935 | if ( createbup ) { |
2936 | QString description = "\n"; | 2936 | QString description = "\n"; |
2937 | CalendarLocal* cal = new CalendarLocal(); | 2937 | CalendarLocal* cal = new CalendarLocal(); |
2938 | if ( beamDialog.beamLocal() ) | 2938 | if ( beamDialog.beamLocal() ) |
2939 | cal->setLocalTime(); | 2939 | cal->setLocalTime(); |
2940 | else | 2940 | else |
2941 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2941 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2942 | Incidence *incidence = delSel.first(); | 2942 | Incidence *incidence = delSel.first(); |
2943 | bool addText = false; | 2943 | bool addText = false; |
2944 | if ( delSel.count() < 10 ) | 2944 | if ( delSel.count() < 10 ) |
2945 | addText = true; | 2945 | addText = true; |
2946 | else { | 2946 | else { |
2947 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2947 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2948 | } | 2948 | } |
2949 | while ( incidence ) { | 2949 | while ( incidence ) { |
2950 | Incidence *in = incidence->clone(); | 2950 | Incidence *in = incidence->clone(); |
2951 | if ( ! in->summary().isEmpty() ) { | 2951 | if ( ! in->summary().isEmpty() ) { |
2952 | in->setDescription(""); | 2952 | in->setDescription(""); |
2953 | } else { | 2953 | } else { |
2954 | in->setSummary( in->description().left(20)); | 2954 | in->setSummary( in->description().left(20)); |
2955 | in->setDescription(""); | 2955 | in->setDescription(""); |
2956 | } | 2956 | } |
2957 | if ( addText ) | 2957 | if ( addText ) |
2958 | description += in->summary() + "\n"; | 2958 | description += in->summary() + "\n"; |
2959 | cal->addIncidence( in ); | 2959 | cal->addIncidence( in ); |
2960 | incidence = delSel.next(); | 2960 | incidence = delSel.next(); |
2961 | } | 2961 | } |
2962 | if ( beamDialog.beamVcal() ) { | 2962 | if ( beamDialog.beamVcal() ) { |
2963 | fn += ".vcs"; | 2963 | fn += ".vcs"; |
2964 | FileStorage storage( cal, fn, new VCalFormat ); | 2964 | FileStorage storage( cal, fn, new VCalFormat ); |
2965 | storage.save(); | 2965 | storage.save(); |
2966 | } else { | 2966 | } else { |
2967 | fn += ".ics"; | 2967 | fn += ".ics"; |
2968 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2968 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2969 | storage.save(); | 2969 | storage.save(); |
2970 | } | 2970 | } |
2971 | delete cal; | 2971 | delete cal; |
2972 | mes = i18n("KO/Pi: Ready for beaming"); | 2972 | mes = i18n("KO/Pi: Ready for beaming"); |
2973 | topLevelWidget()->setCaption(mes); | 2973 | topLevelWidget()->setCaption(mes); |
2974 | KApplication::convert2latin1( fn ); | 2974 | KApplication::convert2latin1( fn ); |
2975 | #ifndef DESKTOP_VERSION | 2975 | #ifndef DESKTOP_VERSION |
2976 | Ir *ir = new Ir( this ); | 2976 | Ir *ir = new Ir( this ); |
2977 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2977 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2978 | ir->send( fn, description, "text/x-vCalendar" ); | 2978 | ir->send( fn, description, "text/x-vCalendar" ); |
2979 | #endif | 2979 | #endif |
2980 | } | 2980 | } |
2981 | } | 2981 | } |
2982 | 2982 | ||
2983 | #ifndef DESKTOP_VERSION | 2983 | #ifndef DESKTOP_VERSION |
2984 | void CalendarView::beamDone( Ir *ir ) | 2984 | void CalendarView::beamDone( Ir *ir ) |
2985 | { | 2985 | { |
2986 | delete ir; | 2986 | delete ir; |
2987 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2987 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2988 | topLevelWidget()->raise(); | 2988 | topLevelWidget()->raise(); |
2989 | } | 2989 | } |
2990 | #else | 2990 | #else |
2991 | void CalendarView::beamDone( Ir *){;} | 2991 | void CalendarView::beamDone( Ir *){;} |
2992 | #endif | 2992 | #endif |
2993 | void CalendarView::moveIncidence(Incidence * inc ) | 2993 | void CalendarView::moveIncidence(Incidence * inc ) |
2994 | { | 2994 | { |
2995 | if ( !inc ) return; | 2995 | if ( !inc ) return; |
2996 | showDatePickerPopup(); | 2996 | showDatePickerPopup(); |
2997 | mDatePickerMode = 2; | 2997 | mDatePickerMode = 2; |
2998 | mMoveIncidence = inc ; | 2998 | mMoveIncidence = inc ; |
2999 | QDate da; | 2999 | QDate da; |
3000 | if ( mMoveIncidence->typeID() == todoID ) { | 3000 | if ( mMoveIncidence->typeID() == todoID ) { |
3001 | Todo * to = (Todo *) mMoveIncidence; | 3001 | Todo * to = (Todo *) mMoveIncidence; |
3002 | if ( to->hasDueDate() ) | 3002 | if ( to->hasDueDate() ) |
3003 | da = to->dtDue().date(); | 3003 | da = to->dtDue().date(); |
3004 | else | 3004 | else |
3005 | da = QDate::currentDate(); | 3005 | da = QDate::currentDate(); |
3006 | } else { | 3006 | } else { |
3007 | da = mMoveIncidence->dtStart().date(); | 3007 | da = mMoveIncidence->dtStart().date(); |
3008 | } | 3008 | } |
3009 | //PENDING set date for recurring incidence to date of recurrence | 3009 | //PENDING set date for recurring incidence to date of recurrence |
3010 | //mMoveIncidenceOldDate; | 3010 | //mMoveIncidenceOldDate; |
3011 | mDatePicker->setDate( da ); | 3011 | mDatePicker->setDate( da ); |
3012 | } | 3012 | } |
3013 | void CalendarView::showDatePickerPopup() | 3013 | void CalendarView::showDatePickerPopup() |
3014 | { | 3014 | { |
3015 | if ( mDateFrame->isVisible() ) | 3015 | if ( mDateFrame->isVisible() ) |
3016 | mDateFrame->hide(); | 3016 | mDateFrame->hide(); |
3017 | else { | 3017 | else { |
3018 | int offX = 0, offY = 0; | 3018 | int offX = 0, offY = 0; |
3019 | #ifdef DESKTOP_VERSION | 3019 | #ifdef DESKTOP_VERSION |
3020 | int w =mDatePicker->sizeHint().width() ; | 3020 | int w =mDatePicker->sizeHint().width() ; |
3021 | int h = mDatePicker->sizeHint().height() ; | 3021 | int h = mDatePicker->sizeHint().height() ; |
3022 | int dw = topLevelWidget()->width(); | 3022 | int dw = topLevelWidget()->width(); |
3023 | int dh = topLevelWidget()->height(); | 3023 | int dh = topLevelWidget()->height(); |
3024 | offX = topLevelWidget()->x(); | 3024 | offX = topLevelWidget()->x(); |
3025 | offY = topLevelWidget()->y(); | 3025 | offY = topLevelWidget()->y(); |
3026 | #else | 3026 | #else |
3027 | int w =mDatePicker->sizeHint().width() ; | 3027 | int w =mDatePicker->sizeHint().width() ; |
3028 | int h = mDatePicker->sizeHint().height() ; | 3028 | int h = mDatePicker->sizeHint().height() ; |
3029 | int dw = QApplication::desktop()->width(); | 3029 | int dw = QApplication::desktop()->width(); |
3030 | int dh = QApplication::desktop()->height(); | 3030 | int dh = QApplication::desktop()->height(); |
3031 | #endif | 3031 | #endif |
3032 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3032 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3033 | mDateFrame->show(); | 3033 | mDateFrame->show(); |
3034 | } | 3034 | } |
3035 | } | 3035 | } |
3036 | void CalendarView::showDatePicker( ) | 3036 | void CalendarView::showDatePicker( ) |
3037 | { | 3037 | { |
3038 | showDatePickerPopup(); | 3038 | showDatePickerPopup(); |
3039 | mDatePickerMode = 1; | 3039 | mDatePickerMode = 1; |
3040 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3040 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3041 | } | 3041 | } |
3042 | 3042 | ||
3043 | void CalendarView::showEventEditor() | 3043 | void CalendarView::showEventEditor() |
3044 | { | 3044 | { |
3045 | #ifdef DESKTOP_VERSION | 3045 | #ifdef DESKTOP_VERSION |
3046 | int x,y,w,h; | 3046 | int x,y,w,h; |
3047 | x = mEventEditor->geometry().x(); | 3047 | x = mEventEditor->geometry().x(); |
3048 | y = mEventEditor->geometry().y(); | 3048 | y = mEventEditor->geometry().y(); |
3049 | w = mEventEditor->width(); | 3049 | w = mEventEditor->width(); |
3050 | h = mEventEditor->height(); | 3050 | h = mEventEditor->height(); |
3051 | mEventEditor->show(); | 3051 | mEventEditor->show(); |
3052 | mEventEditor->setGeometry(x,y,w,h); | 3052 | mEventEditor->setGeometry(x,y,w,h); |
3053 | #else | 3053 | #else |
3054 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3054 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3055 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3055 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3056 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3056 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3057 | qApp->processEvents(); | 3057 | qApp->processEvents(); |
3058 | delete mEventEditor; | 3058 | delete mEventEditor; |
3059 | mEventEditor = mDialogManager->getEventEditor(); | 3059 | mEventEditor = mDialogManager->getEventEditor(); |
3060 | topLevelWidget()->setCaption( i18n("") ); | 3060 | topLevelWidget()->setCaption( i18n("") ); |
3061 | } | 3061 | } |
3062 | mEventEditor->showMaximized(); | 3062 | mEventEditor->showMaximized(); |
3063 | #endif | 3063 | #endif |
3064 | } | 3064 | } |
3065 | void CalendarView::showTodoEditor() | 3065 | void CalendarView::showTodoEditor() |
3066 | { | 3066 | { |
3067 | #ifdef DESKTOP_VERSION | 3067 | #ifdef DESKTOP_VERSION |
3068 | int x,y,w,h; | 3068 | int x,y,w,h; |
3069 | x = mTodoEditor->geometry().x(); | 3069 | x = mTodoEditor->geometry().x(); |
3070 | y = mTodoEditor->geometry().y(); | 3070 | y = mTodoEditor->geometry().y(); |
3071 | w = mTodoEditor->width(); | 3071 | w = mTodoEditor->width(); |
3072 | h = mTodoEditor->height(); | 3072 | h = mTodoEditor->height(); |
3073 | mTodoEditor->show(); | 3073 | mTodoEditor->show(); |
3074 | mTodoEditor->setGeometry(x,y,w,h); | 3074 | mTodoEditor->setGeometry(x,y,w,h); |
3075 | #else | 3075 | #else |
3076 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3076 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3077 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3077 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3078 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3078 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3079 | qApp->processEvents(); | 3079 | qApp->processEvents(); |
3080 | delete mTodoEditor; | 3080 | delete mTodoEditor; |
3081 | mTodoEditor = mDialogManager->getTodoEditor(); | 3081 | mTodoEditor = mDialogManager->getTodoEditor(); |
3082 | topLevelWidget()->setCaption( i18n("") ); | 3082 | topLevelWidget()->setCaption( i18n("") ); |
3083 | } | 3083 | } |
3084 | mTodoEditor->showMaximized(); | 3084 | mTodoEditor->showMaximized(); |
3085 | #endif | 3085 | #endif |
3086 | } | 3086 | } |
3087 | 3087 | ||
3088 | void CalendarView::cloneIncidence() | 3088 | void CalendarView::cloneIncidence() |
3089 | { | 3089 | { |
3090 | Incidence *incidence = currentSelection(); | 3090 | Incidence *incidence = currentSelection(); |
3091 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3091 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3092 | if ( incidence ) { | 3092 | if ( incidence ) { |
3093 | cloneIncidence(incidence); | 3093 | cloneIncidence(incidence); |
3094 | } | 3094 | } |
3095 | } | 3095 | } |
3096 | void CalendarView::moveIncidence() | 3096 | void CalendarView::moveIncidence() |
3097 | { | 3097 | { |
3098 | Incidence *incidence = currentSelection(); | 3098 | Incidence *incidence = currentSelection(); |
3099 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3099 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3100 | if ( incidence ) { | 3100 | if ( incidence ) { |
3101 | moveIncidence(incidence); | 3101 | moveIncidence(incidence); |
3102 | } | 3102 | } |
3103 | } | 3103 | } |
3104 | void CalendarView::beamIncidence() | 3104 | void CalendarView::beamIncidence() |
3105 | { | 3105 | { |
3106 | Incidence *incidence = currentSelection(); | 3106 | Incidence *incidence = currentSelection(); |
3107 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3107 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3108 | if ( incidence ) { | 3108 | if ( incidence ) { |
3109 | beamIncidence(incidence); | 3109 | beamIncidence(incidence); |
3110 | } | 3110 | } |
3111 | } | 3111 | } |
3112 | void CalendarView::toggleCancelIncidence() | 3112 | void CalendarView::toggleCancelIncidence() |
3113 | { | 3113 | { |
3114 | Incidence *incidence = currentSelection(); | 3114 | Incidence *incidence = currentSelection(); |
3115 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3115 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3116 | if ( incidence ) { | 3116 | if ( incidence ) { |
3117 | cancelIncidence(incidence); | 3117 | cancelIncidence(incidence); |
3118 | } | 3118 | } |
3119 | } | 3119 | } |
3120 | 3120 | ||
3121 | 3121 | ||
3122 | void CalendarView::cancelIncidence(Incidence * inc ) | 3122 | void CalendarView::cancelIncidence(Incidence * inc ) |
3123 | { | 3123 | { |
3124 | inc->setCancelled( ! inc->cancelled() ); | 3124 | inc->setCancelled( ! inc->cancelled() ); |
3125 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3125 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3126 | updateView(); | 3126 | updateView(); |
3127 | } | 3127 | } |
3128 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3128 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3129 | { | 3129 | { |
3130 | Incidence * newInc = orgInc->clone(); | 3130 | Incidence * newInc = orgInc->clone(); |
3131 | newInc->recreate(); | 3131 | newInc->recreate(); |
3132 | 3132 | ||
3133 | if ( newInc->typeID() == todoID ) { | 3133 | if ( newInc->typeID() == todoID ) { |
3134 | Todo* t = (Todo*) newInc; | 3134 | Todo* t = (Todo*) newInc; |
3135 | bool cloneSub = false; | 3135 | bool cloneSub = false; |
3136 | if ( orgInc->relations().count() ) { | 3136 | if ( orgInc->relations().count() ) { |
3137 | int result = KMessageBox::warningYesNoCancel(this, | 3137 | int result = KMessageBox::warningYesNoCancel(this, |
3138 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 3138 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), |
3139 | i18n("Todo has subtodos"), | 3139 | i18n("Todo has subtodos"), |
3140 | i18n("Yes"), | 3140 | i18n("Yes"), |
3141 | i18n("No")); | 3141 | i18n("No")); |
3142 | 3142 | ||
3143 | if ( result == KMessageBox::Cancel ) { | 3143 | if ( result == KMessageBox::Cancel ) { |
3144 | delete t; | 3144 | delete t; |
3145 | return; | 3145 | return; |
3146 | } | 3146 | } |
3147 | if (result == KMessageBox::Yes) cloneSub = true; | 3147 | if (result == KMessageBox::Yes) cloneSub = true; |
3148 | } | 3148 | } |
3149 | showTodoEditor(); | 3149 | showTodoEditor(); |
3150 | mTodoEditor->editTodo( t ); | 3150 | mTodoEditor->editTodo( t ); |
3151 | if ( mTodoEditor->exec() ) { | 3151 | if ( mTodoEditor->exec() ) { |
3152 | if ( cloneSub ) { | 3152 | if ( cloneSub ) { |
3153 | orgInc->cloneRelations( t ); | 3153 | orgInc->cloneRelations( t ); |
3154 | mCalendar->addIncidenceBranch( t ); | 3154 | mCalendar->addIncidenceBranch( t ); |
3155 | updateView(); | 3155 | updateView(); |
3156 | 3156 | ||
3157 | } else { | 3157 | } else { |
3158 | mCalendar->addTodo( t ); | 3158 | mCalendar->addTodo( t ); |
3159 | updateView(); | 3159 | updateView(); |
3160 | } | 3160 | } |
3161 | } else { | 3161 | } else { |
3162 | delete t; | 3162 | delete t; |
3163 | } | 3163 | } |
3164 | } | 3164 | } |
3165 | else { | 3165 | else { |
3166 | Event* e = (Event*) newInc; | 3166 | Event* e = (Event*) newInc; |
3167 | showEventEditor(); | 3167 | showEventEditor(); |
3168 | mEventEditor->editEvent( e ); | 3168 | mEventEditor->editEvent( e ); |
3169 | if ( mEventEditor->exec() ) { | 3169 | if ( mEventEditor->exec() ) { |
3170 | mCalendar->addEvent( e ); | 3170 | mCalendar->addEvent( e ); |
3171 | updateView(); | 3171 | updateView(); |
3172 | } else { | 3172 | } else { |
3173 | delete e; | 3173 | delete e; |
3174 | } | 3174 | } |
3175 | } | 3175 | } |
3176 | setActiveWindow(); | 3176 | setActiveWindow(); |
3177 | } | 3177 | } |
3178 | 3178 | ||
3179 | void CalendarView::newEvent() | 3179 | void CalendarView::newEvent() |
3180 | { | 3180 | { |
3181 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3181 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3182 | KOAgendaView *aView = mViewManager->agendaView(); | 3182 | KOAgendaView *aView = mViewManager->agendaView(); |
3183 | if (aView) { | 3183 | if (aView) { |
3184 | if (aView->selectionStart().isValid()) { | 3184 | if (aView->selectionStart().isValid()) { |
3185 | if (aView->selectedIsAllDay()) { | 3185 | if (aView->selectedIsAllDay()) { |
3186 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3186 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3187 | } else { | 3187 | } else { |
3188 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3188 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3189 | } | 3189 | } |
3190 | return; | 3190 | return; |
3191 | } | 3191 | } |
3192 | } | 3192 | } |
3193 | 3193 | ||
3194 | QDate date = mNavigator->selectedDates().first(); | 3194 | QDate date = mNavigator->selectedDates().first(); |
3195 | QDateTime current = QDateTime::currentDateTime(); | 3195 | QDateTime current = QDateTime::currentDateTime(); |
3196 | if ( date <= current.date() ) { | 3196 | if ( date <= current.date() ) { |
3197 | int hour = current.time().hour() +1; | 3197 | int hour = current.time().hour() +1; |
3198 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3198 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3199 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3199 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3200 | } else | 3200 | } else |
3201 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3201 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3202 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3202 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3203 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3203 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3204 | } | 3204 | } |
3205 | 3205 | ||
3206 | void CalendarView::newEvent(QDateTime fh) | 3206 | void CalendarView::newEvent(QDateTime fh) |
3207 | { | 3207 | { |
3208 | newEvent(fh, | 3208 | newEvent(fh, |
3209 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3209 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3210 | } | 3210 | } |
3211 | 3211 | ||
3212 | void CalendarView::newEvent(QDate dt) | 3212 | void CalendarView::newEvent(QDate dt) |
3213 | { | 3213 | { |
3214 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3214 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3215 | QDateTime(dt, QTime(0,0,0)), true); | 3215 | QDateTime(dt, QTime(0,0,0)), true); |
3216 | } | 3216 | } |
3217 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3217 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3218 | { | 3218 | { |
3219 | newEvent(fromHint, toHint, false); | 3219 | newEvent(fromHint, toHint, false); |
3220 | } | 3220 | } |
3221 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3221 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3222 | { | 3222 | { |
3223 | 3223 | ||
3224 | showEventEditor(); | 3224 | showEventEditor(); |
3225 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3225 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3226 | if ( mFilterView->filtersEnabled() ) { | 3226 | if ( mFilterView->filtersEnabled() ) { |
3227 | CalFilter *filter = mFilterView->selectedFilter(); | 3227 | CalFilter *filter = mFilterView->selectedFilter(); |
3228 | if (filter && filter->showCategories()) { | 3228 | if (filter && filter->showCategories()) { |
3229 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3229 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3230 | } | 3230 | } |
3231 | if ( filter ) | 3231 | if ( filter ) |
3232 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3232 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3233 | } | 3233 | } |
3234 | mEventEditor->exec(); | 3234 | mEventEditor->exec(); |
3235 | setActiveWindow(); | 3235 | setActiveWindow(); |
3236 | } | 3236 | } |
3237 | void CalendarView::todoAdded(Todo * t) | 3237 | void CalendarView::todoAdded(Todo * t) |
3238 | { | 3238 | { |
3239 | 3239 | ||
3240 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3240 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3241 | updateTodoViews(); | 3241 | updateTodoViews(); |
3242 | } | 3242 | } |
3243 | void CalendarView::todoChanged(Todo * t) | 3243 | void CalendarView::todoChanged(Todo * t) |
3244 | { | 3244 | { |
3245 | emit todoModified( t, 4 ); | 3245 | emit todoModified( t, 4 ); |
3246 | // updateTodoViews(); | 3246 | // updateTodoViews(); |
3247 | } | 3247 | } |
3248 | void CalendarView::todoToBeDeleted(Todo *) | 3248 | void CalendarView::todoToBeDeleted(Todo *) |
3249 | { | 3249 | { |
3250 | //qDebug("todoToBeDeleted(Todo *) "); | 3250 | //qDebug("todoToBeDeleted(Todo *) "); |
3251 | updateTodoViews(); | 3251 | updateTodoViews(); |
3252 | } | 3252 | } |
3253 | void CalendarView::todoDeleted() | 3253 | void CalendarView::todoDeleted() |
3254 | { | 3254 | { |
3255 | //qDebug(" todoDeleted()"); | 3255 | //qDebug(" todoDeleted()"); |
3256 | updateTodoViews(); | 3256 | updateTodoViews(); |
3257 | } | 3257 | } |
3258 | 3258 | ||
3259 | 3259 | ||
3260 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3260 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3261 | { | 3261 | { |
3262 | showTodoEditor(); | 3262 | showTodoEditor(); |
3263 | mTodoEditor->newTodo(dt,0,allday); | 3263 | mTodoEditor->newTodo(dt,0,allday); |
3264 | if ( mFilterView->filtersEnabled() ) { | 3264 | if ( mFilterView->filtersEnabled() ) { |
3265 | CalFilter *filter = mFilterView->selectedFilter(); | 3265 | CalFilter *filter = mFilterView->selectedFilter(); |
3266 | if (filter && filter->showCategories()) { | 3266 | if (filter && filter->showCategories()) { |
3267 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3267 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3268 | } | 3268 | } |
3269 | if ( filter ) | 3269 | if ( filter ) |
3270 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3270 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3271 | } | 3271 | } |
3272 | mTodoEditor->exec(); | 3272 | mTodoEditor->exec(); |
3273 | setActiveWindow(); | 3273 | setActiveWindow(); |
3274 | } | 3274 | } |
3275 | 3275 | ||
3276 | void CalendarView::newTodo() | 3276 | void CalendarView::newTodo() |
3277 | { | 3277 | { |
3278 | newTodoDateTime( QDateTime(),true ); | 3278 | newTodoDateTime( QDateTime(),true ); |
3279 | } | 3279 | } |
3280 | 3280 | ||
3281 | void CalendarView::newSubTodo() | 3281 | void CalendarView::newSubTodo() |
3282 | { | 3282 | { |
3283 | Todo *todo = selectedTodo(); | 3283 | Todo *todo = selectedTodo(); |
3284 | if ( todo ) newSubTodo( todo ); | 3284 | if ( todo ) newSubTodo( todo ); |
3285 | } | 3285 | } |
3286 | 3286 | ||
3287 | void CalendarView::newSubTodo(Todo *parentEvent) | 3287 | void CalendarView::newSubTodo(Todo *parentEvent) |
3288 | { | 3288 | { |
3289 | 3289 | ||
3290 | showTodoEditor(); | 3290 | showTodoEditor(); |
3291 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3291 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3292 | mTodoEditor->exec(); | 3292 | mTodoEditor->exec(); |
3293 | setActiveWindow(); | 3293 | setActiveWindow(); |
3294 | } | 3294 | } |
3295 | 3295 | ||
3296 | void CalendarView::newFloatingEvent() | 3296 | void CalendarView::newFloatingEvent() |
3297 | { | 3297 | { |
3298 | DateList tmpList = mNavigator->selectedDates(); | 3298 | DateList tmpList = mNavigator->selectedDates(); |
3299 | QDate date = tmpList.first(); | 3299 | QDate date = tmpList.first(); |
3300 | 3300 | ||
3301 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3301 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3302 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3302 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3303 | } | 3303 | } |
3304 | 3304 | ||
3305 | 3305 | ||
3306 | void CalendarView::editEvent( Event *event ) | 3306 | void CalendarView::editEvent( Event *event ) |
3307 | { | 3307 | { |
3308 | 3308 | ||
3309 | if ( !event ) return; | 3309 | if ( !event ) return; |
3310 | if ( event->isReadOnly() ) { | 3310 | if ( event->isReadOnly() ) { |
3311 | showEvent( event ); | 3311 | showEvent( event ); |
3312 | return; | 3312 | return; |
3313 | } | 3313 | } |
3314 | showEventEditor(); | 3314 | showEventEditor(); |
3315 | mEventEditor->editEvent( event , mFlagEditDescription); | 3315 | mEventEditor->editEvent( event , mFlagEditDescription); |
3316 | mEventEditor->exec(); | 3316 | mEventEditor->exec(); |
3317 | setActiveWindow(); | 3317 | setActiveWindow(); |
3318 | 3318 | ||
3319 | } | 3319 | } |
3320 | void CalendarView::editJournal( Journal *jour ) | 3320 | void CalendarView::editJournal( Journal *jour ) |
3321 | { | 3321 | { |
3322 | if ( !jour ) return; | 3322 | if ( !jour ) return; |
3323 | mDialogManager->hideSearchDialog(); | 3323 | mDialogManager->hideSearchDialog(); |
3324 | mViewManager->showJournalView(); | 3324 | mViewManager->showJournalView(); |
3325 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3325 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3326 | } | 3326 | } |
3327 | void CalendarView::editTodo( Todo *todo ) | 3327 | void CalendarView::editTodo( Todo *todo ) |
3328 | { | 3328 | { |
3329 | if ( !todo ) return; | 3329 | if ( !todo ) return; |
3330 | 3330 | ||
3331 | if ( todo->isReadOnly() ) { | 3331 | if ( todo->isReadOnly() ) { |
3332 | showTodo( todo ); | 3332 | showTodo( todo ); |
3333 | return; | 3333 | return; |
3334 | } | 3334 | } |
3335 | showTodoEditor(); | 3335 | showTodoEditor(); |
3336 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3336 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3337 | mTodoEditor->exec(); | 3337 | mTodoEditor->exec(); |
3338 | setActiveWindow(); | 3338 | setActiveWindow(); |
3339 | 3339 | ||
3340 | } | 3340 | } |
3341 | 3341 | ||
3342 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3342 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3343 | { | 3343 | { |
3344 | if ( !mEventViewerDialog ) { | 3344 | if ( !mEventViewerDialog ) { |
3345 | mEventViewerDialog = new KOEventViewerDialog(0); | 3345 | mEventViewerDialog = new KOEventViewerDialog(0); |
3346 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3346 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3347 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3347 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3348 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3348 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3349 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3349 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3350 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3350 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3351 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3351 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3352 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3352 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3353 | this, SLOT( slotViewerClosed() ) ); | 3353 | this, SLOT( slotViewerClosed() ) ); |
3354 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3354 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3355 | this, SLOT( todoChanged(Todo *) ) ); | 3355 | this, SLOT( todoChanged(Todo *) ) ); |
3356 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3356 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3357 | mEventViewerDialog->resize( 640, 480 ); | 3357 | mEventViewerDialog->resize( 640, 480 ); |
3358 | 3358 | ||
3359 | } | 3359 | } |
3360 | return mEventViewerDialog; | 3360 | return mEventViewerDialog; |
3361 | } | 3361 | } |
3362 | void CalendarView::showEvent(Event *event) | 3362 | void CalendarView::showEvent(Event *event) |
3363 | { | 3363 | { |
3364 | getEventViewerDialog()->setEvent(event); | 3364 | getEventViewerDialog()->setEvent(event); |
3365 | getEventViewerDialog()->showMe(); | 3365 | getEventViewerDialog()->showMe(); |
3366 | } | 3366 | } |
3367 | 3367 | ||
3368 | void CalendarView::showTodo(Todo *event) | 3368 | void CalendarView::showTodo(Todo *event) |
3369 | { | 3369 | { |
3370 | getEventViewerDialog()->setTodo(event); | 3370 | getEventViewerDialog()->setTodo(event); |
3371 | getEventViewerDialog()->showMe(); | 3371 | getEventViewerDialog()->showMe(); |
3372 | } | 3372 | } |
3373 | void CalendarView::showJournal( Journal *jour ) | 3373 | void CalendarView::showJournal( Journal *jour ) |
3374 | { | 3374 | { |
3375 | getEventViewerDialog()->setJournal(jour); | 3375 | getEventViewerDialog()->setJournal(jour); |
3376 | getEventViewerDialog()->showMe(); | 3376 | getEventViewerDialog()->showMe(); |
3377 | 3377 | ||
3378 | } | 3378 | } |
3379 | // void CalendarView::todoModified (Todo *event, int changed) | 3379 | // void CalendarView::todoModified (Todo *event, int changed) |
3380 | // { | 3380 | // { |
3381 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3381 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3382 | // // kdDebug() << "Todo modified and open" << endl; | 3382 | // // kdDebug() << "Todo modified and open" << endl; |
3383 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3383 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3384 | // // temp->modified (changed); | 3384 | // // temp->modified (changed); |
3385 | 3385 | ||
3386 | // // } | 3386 | // // } |
3387 | 3387 | ||
3388 | // mViewManager->updateView(); | 3388 | // mViewManager->updateView(); |
3389 | // } | 3389 | // } |
3390 | 3390 | ||
3391 | void CalendarView::appointment_show() | 3391 | void CalendarView::appointment_show() |
3392 | { | 3392 | { |
3393 | Event *anEvent = 0; | 3393 | Event *anEvent = 0; |
3394 | 3394 | ||
3395 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3395 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3396 | 3396 | ||
3397 | if (mViewManager->currentView()->isEventView()) { | 3397 | if (mViewManager->currentView()->isEventView()) { |
3398 | if ( incidence && incidence->typeID() == eventID ) { | 3398 | if ( incidence && incidence->typeID() == eventID ) { |
3399 | anEvent = static_cast<Event *>(incidence); | 3399 | anEvent = static_cast<Event *>(incidence); |
3400 | } | 3400 | } |
3401 | } | 3401 | } |
3402 | 3402 | ||
3403 | if (!anEvent) { | 3403 | if (!anEvent) { |
3404 | KNotifyClient::beep(); | 3404 | KNotifyClient::beep(); |
3405 | return; | 3405 | return; |
3406 | } | 3406 | } |
3407 | 3407 | ||
3408 | showEvent(anEvent); | 3408 | showEvent(anEvent); |
3409 | } | 3409 | } |
3410 | 3410 | ||
3411 | void CalendarView::appointment_edit() | 3411 | void CalendarView::appointment_edit() |
3412 | { | 3412 | { |
3413 | Event *anEvent = 0; | 3413 | Event *anEvent = 0; |
3414 | 3414 | ||
3415 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3415 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3416 | 3416 | ||
3417 | if (mViewManager->currentView()->isEventView()) { | 3417 | if (mViewManager->currentView()->isEventView()) { |
3418 | if ( incidence && incidence->typeID() == eventID ) { | 3418 | if ( incidence && incidence->typeID() == eventID ) { |
3419 | anEvent = static_cast<Event *>(incidence); | 3419 | anEvent = static_cast<Event *>(incidence); |
3420 | } | 3420 | } |
3421 | } | 3421 | } |
3422 | 3422 | ||
3423 | if (!anEvent) { | 3423 | if (!anEvent) { |
3424 | KNotifyClient::beep(); | 3424 | KNotifyClient::beep(); |
3425 | return; | 3425 | return; |
3426 | } | 3426 | } |
3427 | 3427 | ||
3428 | editEvent(anEvent); | 3428 | editEvent(anEvent); |
3429 | } | 3429 | } |
3430 | 3430 | ||
3431 | void CalendarView::appointment_delete() | 3431 | void CalendarView::appointment_delete() |
3432 | { | 3432 | { |
3433 | Event *anEvent = 0; | 3433 | Event *anEvent = 0; |
3434 | 3434 | ||
3435 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3435 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3436 | 3436 | ||
3437 | if (mViewManager->currentView()->isEventView()) { | 3437 | if (mViewManager->currentView()->isEventView()) { |
3438 | if ( incidence && incidence->typeID() == eventID ) { | 3438 | if ( incidence && incidence->typeID() == eventID ) { |
3439 | anEvent = static_cast<Event *>(incidence); | 3439 | anEvent = static_cast<Event *>(incidence); |
3440 | } | 3440 | } |
3441 | } | 3441 | } |
3442 | 3442 | ||
3443 | if (!anEvent) { | 3443 | if (!anEvent) { |
3444 | KNotifyClient::beep(); | 3444 | KNotifyClient::beep(); |
3445 | return; | 3445 | return; |
3446 | } | 3446 | } |
3447 | 3447 | ||
3448 | deleteEvent(anEvent); | 3448 | deleteEvent(anEvent); |
3449 | } | 3449 | } |
3450 | 3450 | ||
3451 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3451 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3452 | { | 3452 | { |
3453 | if (!sub) return; | 3453 | if (!sub) return; |
3454 | if ( sub->relatedTo() == parent ) | 3454 | if ( sub->relatedTo() == parent ) |
3455 | return; | 3455 | return; |
3456 | sub->setRelatedTo(parent); | 3456 | sub->setRelatedTo(parent); |
3457 | sub->updated(); | 3457 | sub->updated(); |
3458 | setModified(true); | 3458 | setModified(true); |
3459 | updateView(); | 3459 | updateView(); |
3460 | } | 3460 | } |
3461 | void CalendarView::todo_unsub(Todo *anTodo ) | 3461 | void CalendarView::todo_unsub(Todo *anTodo ) |
3462 | { | 3462 | { |
3463 | todo_resub( 0, anTodo ); | 3463 | todo_resub( 0, anTodo ); |
3464 | } | 3464 | } |
3465 | 3465 | ||
3466 | void CalendarView::deleteTodo(Todo *todo) | 3466 | void CalendarView::deleteTodo(Todo *todo) |
3467 | { | 3467 | { |
3468 | if (!todo) { | 3468 | if (!todo) { |
3469 | KNotifyClient::beep(); | 3469 | KNotifyClient::beep(); |
3470 | return; | 3470 | return; |
3471 | } | 3471 | } |
3472 | if (KOPrefs::instance()->mConfirm) { | 3472 | if (KOPrefs::instance()->mConfirm) { |
3473 | QString text = todo->summary().left(20); | 3473 | QString text = todo->summary().left(20); |
3474 | if (!todo->relations().isEmpty()) { | 3474 | if (!todo->relations().isEmpty()) { |
3475 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3475 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3476 | 3476 | ||
3477 | } | 3477 | } |
3478 | switch (msgItemDelete(text)) { | 3478 | switch (msgItemDelete(text)) { |
3479 | case KMessageBox::Continue: // OK | 3479 | case KMessageBox::Continue: // OK |
3480 | bool deleteT = false; | 3480 | bool deleteT = false; |
3481 | if (!todo->relations().isEmpty()) { | 3481 | if (!todo->relations().isEmpty()) { |
3482 | deleteT = removeCompletedSubTodos( todo ); | 3482 | deleteT = removeCompletedSubTodos( todo ); |
3483 | } | 3483 | } |
3484 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3484 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3485 | if ( !deleteT ) { | 3485 | if ( !deleteT ) { |
3486 | checkExternalId( todo ); | 3486 | checkExternalId( todo ); |
3487 | calendar()->deleteTodo(todo); | 3487 | calendar()->deleteTodo(todo); |
3488 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3488 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3489 | updateView(); | 3489 | updateView(); |
3490 | } | 3490 | } |
3491 | break; | 3491 | break; |
3492 | } // switch | 3492 | } // switch |
3493 | } else { | 3493 | } else { |
3494 | checkExternalId( todo ); | 3494 | checkExternalId( todo ); |
3495 | mCalendar->deleteTodo(todo); | 3495 | mCalendar->deleteTodo(todo); |
3496 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3496 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3497 | updateView(); | 3497 | updateView(); |
3498 | } | 3498 | } |
3499 | 3499 | ||
3500 | emit updateSearchDialog(); | 3500 | emit updateSearchDialog(); |
3501 | } | 3501 | } |
3502 | void CalendarView::deleteJournal(Journal *jour) | 3502 | void CalendarView::deleteJournal(Journal *jour) |
3503 | { | 3503 | { |
3504 | if (!jour) { | 3504 | if (!jour) { |
3505 | KNotifyClient::beep(); | 3505 | KNotifyClient::beep(); |
3506 | return; | 3506 | return; |
3507 | } | 3507 | } |
3508 | if (KOPrefs::instance()->mConfirm) { | 3508 | if (KOPrefs::instance()->mConfirm) { |
3509 | switch (msgItemDelete( jour->description().left(20))) { | 3509 | switch (msgItemDelete( jour->description().left(20))) { |
3510 | case KMessageBox::Continue: // OK | 3510 | case KMessageBox::Continue: // OK |
3511 | calendar()->deleteJournal(jour); | 3511 | calendar()->deleteJournal(jour); |
3512 | updateView(); | 3512 | updateView(); |
3513 | break; | 3513 | break; |
3514 | } // switch | 3514 | } // switch |
3515 | } else { | 3515 | } else { |
3516 | calendar()->deleteJournal(jour);; | 3516 | calendar()->deleteJournal(jour);; |
3517 | updateView(); | 3517 | updateView(); |
3518 | } | 3518 | } |
3519 | emit updateSearchDialog(); | 3519 | emit updateSearchDialog(); |
3520 | } | 3520 | } |
3521 | 3521 | ||
3522 | void CalendarView::deleteEvent(Event *anEvent) | 3522 | void CalendarView::deleteEvent(Event *anEvent) |
3523 | { | 3523 | { |
3524 | if (!anEvent) { | 3524 | if (!anEvent) { |
3525 | KNotifyClient::beep(); | 3525 | KNotifyClient::beep(); |
3526 | return; | 3526 | return; |
3527 | } | 3527 | } |
3528 | 3528 | ||
3529 | if (anEvent->recurrence()->doesRecur()) { | 3529 | if (anEvent->recurrence()->doesRecur()) { |
3530 | QDate itemDate = mViewManager->currentSelectionDate(); | 3530 | QDate itemDate = mViewManager->currentSelectionDate(); |
3531 | int km; | 3531 | int km; |
3532 | if (!itemDate.isValid()) { | 3532 | if (!itemDate.isValid()) { |
3533 | //kdDebug() << "Date Not Valid" << endl; | 3533 | //kdDebug() << "Date Not Valid" << endl; |
3534 | if (KOPrefs::instance()->mConfirm) { | 3534 | if (KOPrefs::instance()->mConfirm) { |
3535 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3535 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3536 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3536 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3537 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3537 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3538 | if ( km == KMessageBox::Continue ) | 3538 | if ( km == KMessageBox::Continue ) |
3539 | km = KMessageBox::No; // No = all below | 3539 | km = KMessageBox::No; // No = all below |
3540 | } else | 3540 | } else |
3541 | km = KMessageBox::No; | 3541 | km = KMessageBox::No; |
3542 | } else { | 3542 | } else { |
3543 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3543 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3544 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3544 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3545 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3545 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3546 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3546 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3547 | i18n("All")); | 3547 | i18n("All")); |
3548 | } | 3548 | } |
3549 | switch(km) { | 3549 | switch(km) { |
3550 | 3550 | ||
3551 | case KMessageBox::No: // Continue // all | 3551 | case KMessageBox::No: // Continue // all |
3552 | //qDebug("KMessageBox::No "); | 3552 | //qDebug("KMessageBox::No "); |
3553 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3553 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3554 | schedule(Scheduler::Cancel,anEvent); | 3554 | schedule(Scheduler::Cancel,anEvent); |
3555 | 3555 | ||
3556 | checkExternalId( anEvent); | 3556 | checkExternalId( anEvent); |
3557 | mCalendar->deleteEvent(anEvent); | 3557 | mCalendar->deleteEvent(anEvent); |
3558 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3558 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3559 | break; | 3559 | break; |
3560 | 3560 | ||
3561 | // Disabled because it does not work | 3561 | // Disabled because it does not work |
3562 | //#if 0 | 3562 | //#if 0 |
3563 | case KMessageBox::Yes: // just this one | 3563 | case KMessageBox::Yes: // just this one |
3564 | //QDate qd = mNavigator->selectedDates().first(); | 3564 | //QDate qd = mNavigator->selectedDates().first(); |
3565 | //if (!qd.isValid()) { | 3565 | //if (!qd.isValid()) { |
3566 | // kdDebug() << "no date selected, or invalid date" << endl; | 3566 | // kdDebug() << "no date selected, or invalid date" << endl; |
3567 | // KNotifyClient::beep(); | 3567 | // KNotifyClient::beep(); |
3568 | // return; | 3568 | // return; |
3569 | //} | 3569 | //} |
3570 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3570 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3571 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3571 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3572 | anEvent->addExDate(itemDate); | 3572 | anEvent->addExDate(itemDate); |
3573 | int duration = anEvent->recurrence()->duration(); | 3573 | int duration = anEvent->recurrence()->duration(); |
3574 | if ( duration > 0 ) { | 3574 | if ( duration > 0 ) { |
3575 | anEvent->recurrence()->setDuration( duration - 1 ); | 3575 | anEvent->recurrence()->setDuration( duration - 1 ); |
3576 | } | 3576 | } |
3577 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3577 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3578 | } | 3578 | } |
3579 | break; | 3579 | break; |
3580 | //#endif | 3580 | //#endif |
3581 | } // switch | 3581 | } // switch |
3582 | } else { | 3582 | } else { |
3583 | if (KOPrefs::instance()->mConfirm) { | 3583 | if (KOPrefs::instance()->mConfirm) { |
3584 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3584 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3585 | i18n("\nAre you sure you want\nto delete this event?"), | 3585 | i18n("\nAre you sure you want\nto delete this event?"), |
3586 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3586 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3587 | case KMessageBox::Continue: // OK | 3587 | case KMessageBox::Continue: // OK |
3588 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3588 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3589 | schedule(Scheduler::Cancel,anEvent); | 3589 | schedule(Scheduler::Cancel,anEvent); |
3590 | checkExternalId( anEvent); | 3590 | checkExternalId( anEvent); |
3591 | mCalendar->deleteEvent(anEvent); | 3591 | mCalendar->deleteEvent(anEvent); |
3592 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3592 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3593 | break; | 3593 | break; |
3594 | } // switch | 3594 | } // switch |
3595 | } else { | 3595 | } else { |
3596 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3596 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3597 | schedule(Scheduler::Cancel,anEvent); | 3597 | schedule(Scheduler::Cancel,anEvent); |
3598 | checkExternalId( anEvent); | 3598 | checkExternalId( anEvent); |
3599 | mCalendar->deleteEvent(anEvent); | 3599 | mCalendar->deleteEvent(anEvent); |
3600 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3600 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3601 | } | 3601 | } |
3602 | } // if-else | 3602 | } // if-else |
3603 | emit updateSearchDialog(); | 3603 | emit updateSearchDialog(); |
3604 | } | 3604 | } |
3605 | 3605 | ||
3606 | bool CalendarView::deleteEvent(const QString &uid) | 3606 | bool CalendarView::deleteEvent(const QString &uid) |
3607 | { | 3607 | { |
3608 | Event *ev = mCalendar->event(uid); | 3608 | Event *ev = mCalendar->event(uid); |
3609 | if (ev) { | 3609 | if (ev) { |
3610 | deleteEvent(ev); | 3610 | deleteEvent(ev); |
3611 | return true; | 3611 | return true; |
3612 | } else { | 3612 | } else { |
3613 | return false; | 3613 | return false; |
3614 | } | 3614 | } |
3615 | } | 3615 | } |
3616 | 3616 | ||
3617 | /*****************************************************************************/ | 3617 | /*****************************************************************************/ |
3618 | 3618 | ||
3619 | void CalendarView::action_mail() | 3619 | void CalendarView::action_mail() |
3620 | { | 3620 | { |
3621 | #ifndef KORG_NOMAIL | 3621 | #ifndef KORG_NOMAIL |
3622 | KOMailClient mailClient; | 3622 | KOMailClient mailClient; |
3623 | 3623 | ||
3624 | Incidence *incidence = currentSelection(); | 3624 | Incidence *incidence = currentSelection(); |
3625 | 3625 | ||
3626 | if (!incidence) { | 3626 | if (!incidence) { |
3627 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3627 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3628 | return; | 3628 | return; |
3629 | } | 3629 | } |
3630 | if(incidence->attendeeCount() == 0 ) { | 3630 | if(incidence->attendeeCount() == 0 ) { |
3631 | KMessageBox::sorry(this, | 3631 | KMessageBox::sorry(this, |
3632 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3632 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3633 | return; | 3633 | return; |
3634 | } | 3634 | } |
3635 | 3635 | ||
3636 | CalendarLocal cal_tmp; | 3636 | CalendarLocal cal_tmp; |
3637 | Event *event = 0; | 3637 | Event *event = 0; |
3638 | Event *ev = 0; | 3638 | Event *ev = 0; |
3639 | if ( incidence && incidence->typeID() == eventID ) { | 3639 | if ( incidence && incidence->typeID() == eventID ) { |
3640 | event = static_cast<Event *>(incidence); | 3640 | event = static_cast<Event *>(incidence); |
3641 | ev = new Event(*event); | 3641 | ev = new Event(*event); |
3642 | cal_tmp.addEvent(ev); | 3642 | cal_tmp.addEvent(ev); |
3643 | } | 3643 | } |
3644 | ICalFormat mForm(); | 3644 | ICalFormat mForm(); |
3645 | QString attachment = mForm.toString( &cal_tmp ); | 3645 | QString attachment = mForm.toString( &cal_tmp ); |
3646 | if (ev) delete(ev); | 3646 | if (ev) delete(ev); |
3647 | 3647 | ||
3648 | mailClient.mailAttendees(currentSelection(), attachment); | 3648 | mailClient.mailAttendees(currentSelection(), attachment); |
3649 | 3649 | ||
3650 | #endif | 3650 | #endif |
3651 | 3651 | ||
3652 | #if 0 | 3652 | #if 0 |
3653 | Event *anEvent = 0; | 3653 | Event *anEvent = 0; |
3654 | if (mViewManager->currentView()->isEventView()) { | 3654 | if (mViewManager->currentView()->isEventView()) { |
3655 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3655 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3656 | } | 3656 | } |
3657 | 3657 | ||
3658 | if (!anEvent) { | 3658 | if (!anEvent) { |
3659 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3659 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3660 | return; | 3660 | return; |
3661 | } | 3661 | } |
3662 | if(anEvent->attendeeCount() == 0 ) { | 3662 | if(anEvent->attendeeCount() == 0 ) { |
3663 | KMessageBox::sorry(this, | 3663 | KMessageBox::sorry(this, |
3664 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3664 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3665 | return; | 3665 | return; |
3666 | } | 3666 | } |
3667 | 3667 | ||
3668 | mailobject.emailEvent(anEvent); | 3668 | mailobject.emailEvent(anEvent); |
3669 | #endif | 3669 | #endif |
3670 | } | 3670 | } |
3671 | 3671 | ||
3672 | 3672 | ||
3673 | void CalendarView::schedule_publish(Incidence *incidence) | 3673 | void CalendarView::schedule_publish(Incidence *incidence) |
3674 | { | 3674 | { |
3675 | Event *event = 0; | 3675 | Event *event = 0; |
3676 | Todo *todo = 0; | 3676 | Todo *todo = 0; |
3677 | 3677 | ||
3678 | if (incidence == 0) { | 3678 | if (incidence == 0) { |
3679 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3679 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3680 | if (incidence == 0) { | 3680 | if (incidence == 0) { |
3681 | incidence = mTodoList->selectedIncidences().first(); | 3681 | incidence = mTodoList->selectedIncidences().first(); |
3682 | } | 3682 | } |
3683 | } | 3683 | } |
3684 | if ( incidence && incidence->typeID() == eventID ) { | 3684 | if ( incidence && incidence->typeID() == eventID ) { |
3685 | event = static_cast<Event *>(incidence); | 3685 | event = static_cast<Event *>(incidence); |
3686 | } else { | 3686 | } else { |
3687 | if ( incidence && incidence->typeID() == todoID ) { | 3687 | if ( incidence && incidence->typeID() == todoID ) { |
3688 | todo = static_cast<Todo *>(incidence); | 3688 | todo = static_cast<Todo *>(incidence); |
3689 | } | 3689 | } |
3690 | } | 3690 | } |
3691 | 3691 | ||
3692 | if (!event && !todo) { | 3692 | if (!event && !todo) { |
3693 | KMessageBox::sorry(this,i18n("No event selected.")); | 3693 | KMessageBox::sorry(this,i18n("No event selected.")); |
3694 | return; | 3694 | return; |
3695 | } | 3695 | } |
3696 | 3696 | ||
3697 | PublishDialog *publishdlg = new PublishDialog(); | 3697 | PublishDialog *publishdlg = new PublishDialog(); |
3698 | if (incidence->attendeeCount()>0) { | 3698 | if (incidence->attendeeCount()>0) { |
3699 | QPtrList<Attendee> attendees = incidence->attendees(); | 3699 | QPtrList<Attendee> attendees = incidence->attendees(); |
3700 | attendees.first(); | 3700 | attendees.first(); |
3701 | while ( attendees.current()!=0 ) { | 3701 | while ( attendees.current()!=0 ) { |
3702 | publishdlg->addAttendee(attendees.current()); | 3702 | publishdlg->addAttendee(attendees.current()); |
3703 | attendees.next(); | 3703 | attendees.next(); |
3704 | } | 3704 | } |
3705 | } | 3705 | } |
3706 | bool send = true; | 3706 | bool send = true; |
3707 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3707 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3708 | if ( publishdlg->exec() != QDialog::Accepted ) | 3708 | if ( publishdlg->exec() != QDialog::Accepted ) |
3709 | send = false; | 3709 | send = false; |
3710 | } | 3710 | } |
3711 | if ( send ) { | 3711 | if ( send ) { |
3712 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3712 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3713 | if ( event ) { | 3713 | if ( event ) { |
3714 | Event *ev = new Event(*event); | 3714 | Event *ev = new Event(*event); |
3715 | ev->registerObserver(0); | 3715 | ev->registerObserver(0); |
3716 | ev->clearAttendees(); | 3716 | ev->clearAttendees(); |
3717 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3717 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3718 | delete(ev); | 3718 | delete(ev); |
3719 | } | 3719 | } |
3720 | } else { | 3720 | } else { |
3721 | if ( todo ) { | 3721 | if ( todo ) { |
3722 | Todo *ev = new Todo(*todo); | 3722 | Todo *ev = new Todo(*todo); |
3723 | ev->registerObserver(0); | 3723 | ev->registerObserver(0); |
3724 | ev->clearAttendees(); | 3724 | ev->clearAttendees(); |
3725 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3725 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3726 | delete(ev); | 3726 | delete(ev); |
3727 | } | 3727 | } |
3728 | } | 3728 | } |
3729 | } | 3729 | } |
3730 | } | 3730 | } |
3731 | delete publishdlg; | 3731 | delete publishdlg; |
3732 | } | 3732 | } |
3733 | 3733 | ||
3734 | void CalendarView::schedule_request(Incidence *incidence) | 3734 | void CalendarView::schedule_request(Incidence *incidence) |
3735 | { | 3735 | { |
3736 | schedule(Scheduler::Request,incidence); | 3736 | schedule(Scheduler::Request,incidence); |
3737 | } | 3737 | } |
3738 | 3738 | ||
3739 | void CalendarView::schedule_refresh(Incidence *incidence) | 3739 | void CalendarView::schedule_refresh(Incidence *incidence) |
3740 | { | 3740 | { |
3741 | schedule(Scheduler::Refresh,incidence); | 3741 | schedule(Scheduler::Refresh,incidence); |
3742 | } | 3742 | } |
3743 | 3743 | ||
3744 | void CalendarView::schedule_cancel(Incidence *incidence) | 3744 | void CalendarView::schedule_cancel(Incidence *incidence) |
3745 | { | 3745 | { |
3746 | schedule(Scheduler::Cancel,incidence); | 3746 | schedule(Scheduler::Cancel,incidence); |
3747 | } | 3747 | } |
3748 | 3748 | ||
3749 | void CalendarView::schedule_add(Incidence *incidence) | 3749 | void CalendarView::schedule_add(Incidence *incidence) |
3750 | { | 3750 | { |
3751 | schedule(Scheduler::Add,incidence); | 3751 | schedule(Scheduler::Add,incidence); |
3752 | } | 3752 | } |
3753 | 3753 | ||
3754 | void CalendarView::schedule_reply(Incidence *incidence) | 3754 | void CalendarView::schedule_reply(Incidence *incidence) |
3755 | { | 3755 | { |
3756 | schedule(Scheduler::Reply,incidence); | 3756 | schedule(Scheduler::Reply,incidence); |
3757 | } | 3757 | } |
3758 | 3758 | ||
3759 | void CalendarView::schedule_counter(Incidence *incidence) | 3759 | void CalendarView::schedule_counter(Incidence *incidence) |
3760 | { | 3760 | { |
3761 | schedule(Scheduler::Counter,incidence); | 3761 | schedule(Scheduler::Counter,incidence); |
3762 | } | 3762 | } |
3763 | 3763 | ||
3764 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3764 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3765 | { | 3765 | { |
3766 | schedule(Scheduler::Declinecounter,incidence); | 3766 | schedule(Scheduler::Declinecounter,incidence); |
3767 | } | 3767 | } |
3768 | 3768 | ||
3769 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3769 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3770 | { | 3770 | { |
3771 | QDateTime start = QDateTime::currentDateTime(); | 3771 | QDateTime start = QDateTime::currentDateTime(); |
3772 | QDateTime end = start.addDays(daysToPublish); | 3772 | QDateTime end = start.addDays(daysToPublish); |
3773 | 3773 | ||
3774 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3774 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3775 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3775 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3776 | 3776 | ||
3777 | 3777 | ||
3778 | PublishDialog *publishdlg = new PublishDialog(); | 3778 | PublishDialog *publishdlg = new PublishDialog(); |
3779 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3779 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3780 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3780 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3781 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3781 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3782 | delete(freebusy); | 3782 | delete(freebusy); |
3783 | } | 3783 | } |
3784 | } | 3784 | } |
3785 | delete publishdlg; | 3785 | delete publishdlg; |
3786 | } | 3786 | } |
3787 | 3787 | ||
3788 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3788 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3789 | { | 3789 | { |
3790 | Event *event = 0; | 3790 | Event *event = 0; |
3791 | Todo *todo = 0; | 3791 | Todo *todo = 0; |
3792 | 3792 | ||
3793 | if (incidence == 0) { | 3793 | if (incidence == 0) { |
3794 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3794 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3795 | if (incidence == 0) { | 3795 | if (incidence == 0) { |
3796 | incidence = mTodoList->selectedIncidences().first(); | 3796 | incidence = mTodoList->selectedIncidences().first(); |
3797 | } | 3797 | } |
3798 | } | 3798 | } |
3799 | if ( incidence && incidence->typeID() == eventID ) { | 3799 | if ( incidence && incidence->typeID() == eventID ) { |
3800 | event = static_cast<Event *>(incidence); | 3800 | event = static_cast<Event *>(incidence); |
3801 | } | 3801 | } |
3802 | if ( incidence && incidence->typeID() == todoID ) { | 3802 | if ( incidence && incidence->typeID() == todoID ) { |
3803 | todo = static_cast<Todo *>(incidence); | 3803 | todo = static_cast<Todo *>(incidence); |
3804 | } | 3804 | } |
3805 | 3805 | ||
3806 | if (!event && !todo) { | 3806 | if (!event && !todo) { |
3807 | KMessageBox::sorry(this,i18n("No event selected.")); | 3807 | KMessageBox::sorry(this,i18n("No event selected.")); |
3808 | return; | 3808 | return; |
3809 | } | 3809 | } |
3810 | 3810 | ||
3811 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3811 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3812 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3812 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3813 | return; | 3813 | return; |
3814 | } | 3814 | } |
3815 | 3815 | ||
3816 | Event *ev = 0; | 3816 | Event *ev = 0; |
3817 | if (event) ev = new Event(*event); | 3817 | if (event) ev = new Event(*event); |
3818 | Todo *to = 0; | 3818 | Todo *to = 0; |
3819 | if (todo) to = new Todo(*todo); | 3819 | if (todo) to = new Todo(*todo); |
3820 | 3820 | ||
3821 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3821 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3822 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3822 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3823 | if (!me) { | 3823 | if (!me) { |
3824 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3824 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3825 | return; | 3825 | return; |
3826 | } | 3826 | } |
3827 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3827 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3828 | StatusDialog *statdlg = new StatusDialog(this); | 3828 | StatusDialog *statdlg = new StatusDialog(this); |
3829 | if (!statdlg->exec()==QDialog::Accepted) return; | 3829 | if (!statdlg->exec()==QDialog::Accepted) return; |
3830 | me->setStatus( statdlg->status() ); | 3830 | me->setStatus( statdlg->status() ); |
3831 | delete(statdlg); | 3831 | delete(statdlg); |
3832 | } | 3832 | } |
3833 | Attendee *menew = new Attendee(*me); | 3833 | Attendee *menew = new Attendee(*me); |
3834 | if (ev) { | 3834 | if (ev) { |
3835 | ev->clearAttendees(); | 3835 | ev->clearAttendees(); |
3836 | ev->addAttendee(menew,false); | 3836 | ev->addAttendee(menew,false); |
3837 | } else { | 3837 | } else { |
3838 | if (to) { | 3838 | if (to) { |
3839 | todo->clearAttendees(); | 3839 | todo->clearAttendees(); |
3840 | todo->addAttendee(menew,false); | 3840 | todo->addAttendee(menew,false); |
3841 | } | 3841 | } |
3842 | } | 3842 | } |
3843 | } | 3843 | } |
3844 | 3844 | ||
3845 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3845 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3846 | if (ev) { | 3846 | if (ev) { |
3847 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3847 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3848 | } else { | 3848 | } else { |
3849 | if (to) { | 3849 | if (to) { |
3850 | if ( !dlg->addMessage(to,method) ) delete(to); | 3850 | if ( !dlg->addMessage(to,method) ) delete(to); |
3851 | } | 3851 | } |
3852 | } | 3852 | } |
3853 | } | 3853 | } |
3854 | 3854 | ||
3855 | void CalendarView::openAddressbook() | 3855 | void CalendarView::openAddressbook() |
3856 | { | 3856 | { |
3857 | KRun::runCommand("kaddressbook"); | 3857 | KRun::runCommand("kaddressbook"); |
3858 | } | 3858 | } |
3859 | 3859 | ||
3860 | void CalendarView::setModified(bool modified) | 3860 | void CalendarView::setModified(bool modified) |
3861 | { | 3861 | { |
3862 | if ( modified ) | 3862 | if ( modified ) |
3863 | emit signalmodified(); | 3863 | emit signalmodified(); |
3864 | if (mModified != modified) { | 3864 | if (mModified != modified) { |
3865 | mModified = modified; | 3865 | mModified = modified; |
3866 | emit modifiedChanged(mModified); | 3866 | emit modifiedChanged(mModified); |
3867 | } | 3867 | } |
3868 | } | 3868 | } |
3869 | 3869 | ||
3870 | bool CalendarView::isReadOnly() | 3870 | bool CalendarView::isReadOnly() |
3871 | { | 3871 | { |
3872 | return mReadOnly; | 3872 | return mReadOnly; |
3873 | } | 3873 | } |
3874 | 3874 | ||
3875 | void CalendarView::setReadOnly(bool readOnly) | 3875 | void CalendarView::setReadOnly(bool readOnly) |
3876 | { | 3876 | { |
3877 | if (mReadOnly != readOnly) { | 3877 | if (mReadOnly != readOnly) { |
3878 | mReadOnly = readOnly; | 3878 | mReadOnly = readOnly; |
3879 | emit readOnlyChanged(mReadOnly); | 3879 | emit readOnlyChanged(mReadOnly); |
3880 | } | 3880 | } |
3881 | } | 3881 | } |
3882 | 3882 | ||
3883 | bool CalendarView::isModified() | 3883 | bool CalendarView::isModified() |
3884 | { | 3884 | { |
3885 | return mModified; | 3885 | return mModified; |
3886 | } | 3886 | } |
3887 | void CalendarView::slotprintSelInc() | 3887 | void CalendarView::slotprintSelInc() |
3888 | { | 3888 | { |
3889 | if ( currentSelection() == 0 ) { | 3889 | if ( currentSelection() == 0 ) { |
3890 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3890 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3891 | return; | 3891 | return; |
3892 | } | 3892 | } |
3893 | showIncidence(); | 3893 | showIncidence(); |
3894 | getEventViewerDialog()->print(); | 3894 | getEventViewerDialog()->print(); |
3895 | 3895 | ||
3896 | } | 3896 | } |
3897 | void CalendarView::printSetup() | 3897 | void CalendarView::printSetup() |
3898 | { | 3898 | { |
3899 | #ifndef KORG_NOPRINTER | 3899 | #ifndef KORG_NOPRINTER |
3900 | createPrinter(); | 3900 | createPrinter(); |
3901 | 3901 | ||
3902 | mCalPrinter->setupPrinter(); | 3902 | mCalPrinter->setupPrinter(); |
3903 | #endif | 3903 | #endif |
3904 | } | 3904 | } |
3905 | 3905 | ||
3906 | void CalendarView::print() | 3906 | void CalendarView::print() |
3907 | { | 3907 | { |
3908 | #ifndef KORG_NOPRINTER | 3908 | #ifndef KORG_NOPRINTER |
3909 | createPrinter(); | 3909 | createPrinter(); |
3910 | 3910 | ||
3911 | DateList tmpDateList = mNavigator->selectedDates(); | 3911 | DateList tmpDateList = mNavigator->selectedDates(); |
3912 | mCalPrinter->print(CalPrinter::Month, | 3912 | mCalPrinter->print(CalPrinter::Month, |
3913 | tmpDateList.first(), tmpDateList.last()); | 3913 | tmpDateList.first(), tmpDateList.last()); |
3914 | #endif | 3914 | #endif |
3915 | } | 3915 | } |
3916 | 3916 | ||
3917 | void CalendarView::printPreview() | 3917 | void CalendarView::printPreview() |
3918 | { | 3918 | { |
3919 | #ifndef KORG_NOPRINTER | 3919 | #ifndef KORG_NOPRINTER |
3920 | kdDebug() << "CalendarView::printPreview()" << endl; | 3920 | kdDebug() << "CalendarView::printPreview()" << endl; |
3921 | 3921 | ||
3922 | createPrinter(); | 3922 | createPrinter(); |
3923 | 3923 | ||
3924 | DateList tmpDateList = mNavigator->selectedDates(); | 3924 | DateList tmpDateList = mNavigator->selectedDates(); |
3925 | 3925 | ||
3926 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3926 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3927 | tmpDateList.last()); | 3927 | tmpDateList.last()); |
3928 | #endif | 3928 | #endif |
3929 | } | 3929 | } |
3930 | 3930 | ||
3931 | void CalendarView::exportICalendar() | 3931 | void CalendarView::exportICalendar() |
3932 | { | 3932 | { |
3933 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3933 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3934 | 3934 | ||
3935 | // Force correct extension | 3935 | // Force correct extension |
3936 | if (filename.right(4) != ".ics") filename += ".ics"; | 3936 | if (filename.right(4) != ".ics") filename += ".ics"; |
3937 | 3937 | ||
3938 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3938 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3939 | storage.save(); | 3939 | storage.save(); |
3940 | } | 3940 | } |
3941 | 3941 | ||
3942 | bool CalendarView::exportVCalendar( QString filename ) | 3942 | bool CalendarView::exportVCalendar( QString filename ) |
3943 | { | 3943 | { |
3944 | if (mCalendar->journals().count() > 0) { | 3944 | if (mCalendar->journals().count() > 0) { |
3945 | int result = KMessageBox::warningContinueCancel(this, | 3945 | int result = KMessageBox::warningContinueCancel(this, |
3946 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3946 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3947 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3947 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3948 | true); | 3948 | true); |
3949 | if (result != KMessageBox::Continue) return false; | 3949 | if (result != KMessageBox::Continue) return false; |
3950 | } | 3950 | } |
3951 | 3951 | ||
3952 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3952 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3953 | 3953 | ||
3954 | // Force correct extension | 3954 | // Force correct extension |
3955 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3955 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3956 | 3956 | ||
3957 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3957 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3958 | return storage.save(); | 3958 | return storage.save(); |
3959 | 3959 | ||
3960 | } | 3960 | } |
3961 | 3961 | ||
3962 | void CalendarView::eventUpdated(Incidence *) | 3962 | void CalendarView::eventUpdated(Incidence *) |
3963 | { | 3963 | { |
3964 | setModified(); | 3964 | setModified(); |
3965 | // Don't call updateView here. The code, which has caused the update of the | 3965 | // Don't call updateView here. The code, which has caused the update of the |
3966 | // event is responsible for updating the view. | 3966 | // event is responsible for updating the view. |
3967 | // updateView(); | 3967 | // updateView(); |
3968 | } | 3968 | } |
3969 | 3969 | ||
3970 | void CalendarView::adaptNavigationUnits() | 3970 | void CalendarView::adaptNavigationUnits() |
3971 | { | 3971 | { |
3972 | if (mViewManager->currentView()->isEventView()) { | 3972 | if (mViewManager->currentView()->isEventView()) { |
3973 | int days = mViewManager->currentView()->currentDateCount(); | 3973 | int days = mViewManager->currentView()->currentDateCount(); |
3974 | if (days == 1) { | 3974 | if (days == 1) { |
3975 | emit changeNavStringPrev(i18n("&Previous Day")); | 3975 | emit changeNavStringPrev(i18n("&Previous Day")); |
3976 | emit changeNavStringNext(i18n("&Next Day")); | 3976 | emit changeNavStringNext(i18n("&Next Day")); |
3977 | } else { | 3977 | } else { |
3978 | emit changeNavStringPrev(i18n("&Previous Week")); | 3978 | emit changeNavStringPrev(i18n("&Previous Week")); |
3979 | emit changeNavStringNext(i18n("&Next Week")); | 3979 | emit changeNavStringNext(i18n("&Next Week")); |
3980 | } | 3980 | } |
3981 | } | 3981 | } |
3982 | } | 3982 | } |
3983 | 3983 | ||
3984 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3984 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3985 | { | 3985 | { |
3986 | if ( incidence ) mTodoList->clearSelection(); | 3986 | if ( incidence ) mTodoList->clearSelection(); |
3987 | processIncidenceSelection( incidence ); | 3987 | processIncidenceSelection( incidence ); |
3988 | } | 3988 | } |
3989 | 3989 | ||
3990 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3990 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3991 | { | 3991 | { |
3992 | if ( incidence && mViewManager->currentView() ) { | 3992 | if ( incidence && mViewManager->currentView() ) { |
3993 | mViewManager->currentView()->clearSelection(); | 3993 | mViewManager->currentView()->clearSelection(); |
3994 | } | 3994 | } |
3995 | processIncidenceSelection( incidence ); | 3995 | processIncidenceSelection( incidence ); |
3996 | } | 3996 | } |
3997 | 3997 | ||
3998 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3998 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3999 | { | 3999 | { |
4000 | emit incidenceSelected( incidence ); | ||
4000 | if ( incidence == mSelectedIncidence ) return; | 4001 | if ( incidence == mSelectedIncidence ) return; |
4001 | |||
4002 | mSelectedIncidence = incidence; | 4002 | mSelectedIncidence = incidence; |
4003 | 4003 | ||
4004 | emit incidenceSelected( mSelectedIncidence ); | ||
4005 | |||
4006 | if ( incidence && incidence->typeID() == eventID ) { | 4004 | if ( incidence && incidence->typeID() == eventID ) { |
4007 | Event *event = static_cast<Event *>( incidence ); | 4005 | Event *event = static_cast<Event *>( incidence ); |
4008 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4006 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4009 | emit organizerEventsSelected( true ); | 4007 | emit organizerEventsSelected( true ); |
4010 | } else { | 4008 | } else { |
4011 | emit organizerEventsSelected(false); | 4009 | emit organizerEventsSelected(false); |
4012 | } | 4010 | } |
4013 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4011 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4014 | KOPrefs::instance()->email() ) ) { | 4012 | KOPrefs::instance()->email() ) ) { |
4015 | emit groupEventsSelected( true ); | 4013 | emit groupEventsSelected( true ); |
4016 | } else { | 4014 | } else { |
4017 | emit groupEventsSelected(false); | 4015 | emit groupEventsSelected(false); |
4018 | } | 4016 | } |
4019 | return; | 4017 | return; |
4020 | } else { | 4018 | } else { |
4021 | if ( incidence && incidence->typeID() == todoID ) { | 4019 | if ( incidence && incidence->typeID() == todoID ) { |
4022 | emit todoSelected( true ); | 4020 | emit todoSelected( true ); |
4023 | Todo *event = static_cast<Todo *>( incidence ); | 4021 | Todo *event = static_cast<Todo *>( incidence ); |
4024 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4022 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4025 | emit organizerEventsSelected( true ); | 4023 | emit organizerEventsSelected( true ); |
4026 | } else { | 4024 | } else { |
4027 | emit organizerEventsSelected(false); | 4025 | emit organizerEventsSelected(false); |
4028 | } | 4026 | } |
4029 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4027 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4030 | KOPrefs::instance()->email() ) ) { | 4028 | KOPrefs::instance()->email() ) ) { |
4031 | emit groupEventsSelected( true ); | 4029 | emit groupEventsSelected( true ); |
4032 | } else { | 4030 | } else { |
4033 | emit groupEventsSelected(false); | 4031 | emit groupEventsSelected(false); |
4034 | } | 4032 | } |
4035 | return; | 4033 | return; |
4036 | } else { | 4034 | } else { |
4037 | emit todoSelected( false ); | 4035 | emit todoSelected( false ); |
4038 | emit organizerEventsSelected(false); | 4036 | emit organizerEventsSelected(false); |
4039 | emit groupEventsSelected(false); | 4037 | emit groupEventsSelected(false); |
4040 | } | 4038 | } |
4041 | return; | 4039 | return; |
4042 | } | 4040 | } |
4043 | 4041 | ||
4044 | /* if ( incidence && incidence->typeID() == todoID ) { | 4042 | /* if ( incidence && incidence->typeID() == todoID ) { |
4045 | emit todoSelected( true ); | 4043 | emit todoSelected( true ); |
4046 | } else { | 4044 | } else { |
4047 | emit todoSelected( false ); | 4045 | emit todoSelected( false ); |
4048 | }*/ | 4046 | }*/ |
4049 | } | 4047 | } |
4050 | 4048 | ||
4051 | 4049 | ||
4052 | void CalendarView::checkClipboard() | 4050 | void CalendarView::checkClipboard() |
4053 | { | 4051 | { |
4054 | #ifndef KORG_NODND | 4052 | #ifndef KORG_NODND |
4055 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4053 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4056 | emit pasteEnabled(true); | 4054 | emit pasteEnabled(true); |
4057 | } else { | 4055 | } else { |
4058 | emit pasteEnabled(false); | 4056 | emit pasteEnabled(false); |
4059 | } | 4057 | } |
4060 | #endif | 4058 | #endif |
4061 | } | 4059 | } |
4062 | 4060 | ||
4063 | void CalendarView::showDates(const DateList &selectedDates) | 4061 | void CalendarView::showDates(const DateList &selectedDates) |
4064 | { | 4062 | { |
4065 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4063 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4066 | 4064 | ||
4067 | 4065 | ||
4068 | if ( !mBlockShowDates ) { | 4066 | if ( !mBlockShowDates ) { |
4069 | if ( mViewManager->currentView() ) { | 4067 | if ( mViewManager->currentView() ) { |
4070 | updateView( selectedDates.first(), selectedDates.last() ); | 4068 | updateView( selectedDates.first(), selectedDates.last() ); |
4071 | } else { | 4069 | } else { |
4072 | mViewManager->showAgendaView(); | 4070 | mViewManager->showAgendaView(); |
4073 | } | 4071 | } |
4074 | } | 4072 | } |
4075 | 4073 | ||
4076 | QDate date = selectedDates.first(); | 4074 | QDate date = selectedDates.first(); |
4077 | if ( ! date.isValid() ) { | 4075 | if ( ! date.isValid() ) { |
4078 | topLevelWidget()->setCaption(""); | 4076 | topLevelWidget()->setCaption(""); |
4079 | return; | 4077 | return; |
4080 | } | 4078 | } |
4081 | 4079 | ||
4082 | QString selDates; | 4080 | QString selDates; |
4083 | selDates = KGlobal::locale()->formatDate( date, true); | 4081 | selDates = KGlobal::locale()->formatDate( date, true); |
4084 | if (selectedDates.first() < selectedDates.last() ) | 4082 | if (selectedDates.first() < selectedDates.last() ) |
4085 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4083 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4086 | else { | 4084 | else { |
4087 | QString addString; | 4085 | QString addString; |
4088 | if ( date == QDateTime::currentDateTime().date() ) | 4086 | if ( date == QDateTime::currentDateTime().date() ) |
4089 | addString = i18n("Today"); | 4087 | addString = i18n("Today"); |
4090 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4088 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4091 | addString = i18n("Tomorrow"); | 4089 | addString = i18n("Tomorrow"); |
4092 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4090 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4093 | addString = i18n("Yesterday"); | 4091 | addString = i18n("Yesterday"); |
4094 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4092 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4095 | addString = i18n("Day before yesterday"); | 4093 | addString = i18n("Day before yesterday"); |
4096 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4094 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4097 | addString = i18n("Day after tomorrow"); | 4095 | addString = i18n("Day after tomorrow"); |
4098 | if ( !addString.isEmpty() ) { | 4096 | if ( !addString.isEmpty() ) { |
4099 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4097 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4100 | return; | 4098 | return; |
4101 | } | 4099 | } |
4102 | } | 4100 | } |
4103 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4101 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4104 | 4102 | ||
4105 | } | 4103 | } |
4106 | 4104 | ||
4107 | QPtrList<CalFilter> CalendarView::filters() | 4105 | QPtrList<CalFilter> CalendarView::filters() |
4108 | { | 4106 | { |
4109 | return mFilters; | 4107 | return mFilters; |
4110 | 4108 | ||
4111 | } | 4109 | } |
4112 | void CalendarView::editFilters() | 4110 | void CalendarView::editFilters() |
4113 | { | 4111 | { |
4114 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4112 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4115 | 4113 | ||
4116 | CalFilter *filter = mFilters.first(); | 4114 | CalFilter *filter = mFilters.first(); |
4117 | while(filter) { | 4115 | while(filter) { |
4118 | filter = mFilters.next(); | 4116 | filter = mFilters.next(); |
4119 | } | 4117 | } |
4120 | 4118 | ||
4121 | mDialogManager->showFilterEditDialog(&mFilters); | 4119 | mDialogManager->showFilterEditDialog(&mFilters); |
4122 | updateFilter(); | 4120 | updateFilter(); |
4123 | } | 4121 | } |
4124 | void CalendarView::toggleFilter() | 4122 | void CalendarView::toggleFilter() |
4125 | { | 4123 | { |
4126 | if ( mLeftFrame->isHidden() ) { | 4124 | if ( mLeftFrame->isHidden() ) { |
4127 | toggleExpand(); | 4125 | toggleExpand(); |
4128 | showFilter( true ); | 4126 | showFilter( true ); |
4129 | } else | 4127 | } else |
4130 | showFilter(! mCalEditView->isVisible()); | 4128 | showFilter(! mCalEditView->isVisible()); |
4131 | } | 4129 | } |
4132 | 4130 | ||
4133 | KOFilterView *CalendarView::filterView() | 4131 | KOFilterView *CalendarView::filterView() |
4134 | { | 4132 | { |
4135 | return mFilterView; | 4133 | return mFilterView; |
4136 | } | 4134 | } |
4137 | void CalendarView::selectFilter( int fil ) | 4135 | void CalendarView::selectFilter( int fil ) |
4138 | { | 4136 | { |
4139 | mFilterView->setSelectedFilter( fil ); | 4137 | mFilterView->setSelectedFilter( fil ); |
4140 | updateUnmanagedViews(); | 4138 | updateUnmanagedViews(); |
4141 | } | 4139 | } |
4142 | void CalendarView::showFilter(bool visible) | 4140 | void CalendarView::showFilter(bool visible) |
4143 | { | 4141 | { |
4144 | #if 1 | 4142 | #if 1 |
4145 | if (visible) { | 4143 | if (visible) { |
4146 | mCalEditView->readConfig(); | 4144 | mCalEditView->readConfig(); |
4147 | mCalEditView->show(); | 4145 | mCalEditView->show(); |
4148 | QValueList<int> sizes; | 4146 | QValueList<int> sizes; |
4149 | sizes = mLeftFrame->sizes(); | 4147 | sizes = mLeftFrame->sizes(); |
4150 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4148 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4151 | sizes.clear(); | 4149 | sizes.clear(); |
4152 | sizes << 100; | 4150 | sizes << 100; |
4153 | sizes << 0; | 4151 | sizes << 0; |
4154 | sizes << 0; | 4152 | sizes << 0; |
4155 | sizes << 100; | 4153 | sizes << 100; |
4156 | mLeftFrame->setSizes(sizes); | 4154 | mLeftFrame->setSizes(sizes); |
4157 | } | 4155 | } |
4158 | #if 0 | 4156 | #if 0 |
4159 | sizes = mLeftFrame->sizes(); | 4157 | sizes = mLeftFrame->sizes(); |
4160 | int ccc = 0; | 4158 | int ccc = 0; |
4161 | while ( ccc < sizes.count()) { | 4159 | while ( ccc < sizes.count()) { |
4162 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4160 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4163 | ++ccc; | 4161 | ++ccc; |
4164 | } | 4162 | } |
4165 | #endif | 4163 | #endif |
4166 | 4164 | ||
4167 | } | 4165 | } |
4168 | else { | 4166 | else { |
4169 | mCalEditView->hide(); | 4167 | mCalEditView->hide(); |
4170 | } | 4168 | } |
4171 | #else | 4169 | #else |
4172 | if (visible) mFilterView->show(); | 4170 | if (visible) mFilterView->show(); |
4173 | else mFilterView->hide(); | 4171 | else mFilterView->hide(); |
4174 | #endif | 4172 | #endif |
4175 | } | 4173 | } |
4176 | void CalendarView::toggleFilerEnabled( ) | 4174 | void CalendarView::toggleFilerEnabled( ) |
4177 | { | 4175 | { |
4178 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4176 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4179 | if ( !mFilterView->filtersEnabled() ) | 4177 | if ( !mFilterView->filtersEnabled() ) |
4180 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4178 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4181 | updateUnmanagedViews(); | 4179 | updateUnmanagedViews(); |
4182 | 4180 | ||
4183 | } | 4181 | } |
4184 | void CalendarView::updateFilter() | 4182 | void CalendarView::updateFilter() |
4185 | { | 4183 | { |
4186 | CalFilter *filter = mFilterView->selectedFilter(); | 4184 | CalFilter *filter = mFilterView->selectedFilter(); |
4187 | if (filter) { | 4185 | if (filter) { |
4188 | QString mess; | 4186 | QString mess; |
4189 | if (mFilterView->filtersEnabled()) { | 4187 | if (mFilterView->filtersEnabled()) { |
4190 | mess = i18n("Filter selected: ")+filter->name(); | 4188 | mess = i18n("Filter selected: ")+filter->name(); |
4191 | filter->setEnabled(true); | 4189 | filter->setEnabled(true); |
4192 | } | 4190 | } |
4193 | else filter->setEnabled(false); | 4191 | else filter->setEnabled(false); |
4194 | mCalendar->setFilter(filter); | 4192 | mCalendar->setFilter(filter); |
4195 | updateView(); | 4193 | updateView(); |
4196 | if ( !mess.isEmpty() ) | 4194 | if ( !mess.isEmpty() ) |
4197 | topLevelWidget()->setCaption( mess ); | 4195 | topLevelWidget()->setCaption( mess ); |
4198 | 4196 | ||
4199 | } | 4197 | } |
4200 | emit filtersUpdated(); | 4198 | emit filtersUpdated(); |
4201 | } | 4199 | } |
4202 | 4200 | ||
4203 | void CalendarView::filterEdited() | 4201 | void CalendarView::filterEdited() |
4204 | { | 4202 | { |
4205 | mFilterView->updateFilters(); | 4203 | mFilterView->updateFilters(); |
4206 | updateFilter(); | 4204 | updateFilter(); |
4207 | writeSettings(); | 4205 | writeSettings(); |
4208 | } | 4206 | } |
4209 | 4207 | ||
4210 | 4208 | ||
4211 | void CalendarView::takeOverEvent() | 4209 | void CalendarView::takeOverEvent() |
4212 | { | 4210 | { |
4213 | Incidence *incidence = currentSelection(); | 4211 | Incidence *incidence = currentSelection(); |
4214 | 4212 | ||
4215 | if (!incidence) return; | 4213 | if (!incidence) return; |
4216 | 4214 | ||
4217 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4215 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4218 | incidence->recreate(); | 4216 | incidence->recreate(); |
4219 | incidence->setReadOnly(false); | 4217 | incidence->setReadOnly(false); |
4220 | 4218 | ||
4221 | updateView(); | 4219 | updateView(); |
4222 | } | 4220 | } |
4223 | 4221 | ||
4224 | void CalendarView::takeOverCalendar() | 4222 | void CalendarView::takeOverCalendar() |
4225 | { | 4223 | { |
4226 | // TODO: Create Calendar::allIncidences() function and use it here | 4224 | // TODO: Create Calendar::allIncidences() function and use it here |
4227 | 4225 | ||
4228 | clearAllViews(); | 4226 | clearAllViews(); |
4229 | QPtrList<Event> events = mCalendar->events(); | 4227 | QPtrList<Event> events = mCalendar->events(); |
4230 | for(uint i=0; i<events.count(); ++i) { | 4228 | for(uint i=0; i<events.count(); ++i) { |
4231 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4229 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4232 | events.at(i)->recreate(); | 4230 | events.at(i)->recreate(); |
4233 | events.at(i)->setReadOnly(false); | 4231 | events.at(i)->setReadOnly(false); |
4234 | } | 4232 | } |
4235 | 4233 | ||
4236 | QPtrList<Todo> todos = mCalendar->todos(); | 4234 | QPtrList<Todo> todos = mCalendar->todos(); |
4237 | for(uint i=0; i<todos.count(); ++i) { | 4235 | for(uint i=0; i<todos.count(); ++i) { |
4238 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4236 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4239 | todos.at(i)->recreate(); | 4237 | todos.at(i)->recreate(); |
4240 | todos.at(i)->setReadOnly(false); | 4238 | todos.at(i)->setReadOnly(false); |
4241 | } | 4239 | } |
4242 | 4240 | ||
4243 | QPtrList<Journal> journals = mCalendar->journals(); | 4241 | QPtrList<Journal> journals = mCalendar->journals(); |
4244 | for(uint i=0; i<journals.count(); ++i) { | 4242 | for(uint i=0; i<journals.count(); ++i) { |
4245 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4243 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4246 | journals.at(i)->recreate(); | 4244 | journals.at(i)->recreate(); |
4247 | journals.at(i)->setReadOnly(false); | 4245 | journals.at(i)->setReadOnly(false); |
4248 | } | 4246 | } |
4249 | 4247 | ||
4250 | updateView(); | 4248 | updateView(); |
4251 | } | 4249 | } |
4252 | 4250 | ||
4253 | void CalendarView::showIntro() | 4251 | void CalendarView::showIntro() |
4254 | { | 4252 | { |
4255 | kdDebug() << "To be implemented." << endl; | 4253 | kdDebug() << "To be implemented." << endl; |
4256 | } | 4254 | } |
4257 | 4255 | ||
4258 | QWidgetStack *CalendarView::viewStack() | 4256 | QWidgetStack *CalendarView::viewStack() |
4259 | { | 4257 | { |
4260 | return mRightFrame; | 4258 | return mRightFrame; |
4261 | } | 4259 | } |
4262 | 4260 | ||
4263 | QWidget *CalendarView::leftFrame() | 4261 | QWidget *CalendarView::leftFrame() |
4264 | { | 4262 | { |
4265 | return ( QWidget *)mLeftFrame; | 4263 | return ( QWidget *)mLeftFrame; |
4266 | } | 4264 | } |
4267 | 4265 | ||
4268 | DateNavigator *CalendarView::dateNavigator() | 4266 | DateNavigator *CalendarView::dateNavigator() |
4269 | { | 4267 | { |
4270 | return mNavigator; | 4268 | return mNavigator; |
4271 | } | 4269 | } |
4272 | 4270 | ||
4273 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4271 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4274 | { | 4272 | { |
4275 | return mDateNavigator->navigatorView(); | 4273 | return mDateNavigator->navigatorView(); |
4276 | } | 4274 | } |
4277 | void CalendarView::toggleDateNavigatorWidget() | 4275 | void CalendarView::toggleDateNavigatorWidget() |
4278 | { | 4276 | { |
4279 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4277 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4280 | 4278 | ||
4281 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4279 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4282 | mDateNavigator->hide(); | 4280 | mDateNavigator->hide(); |
4283 | else | 4281 | else |
4284 | mDateNavigator->show(); | 4282 | mDateNavigator->show(); |
4285 | } | 4283 | } |
4286 | void CalendarView::addView(KOrg::BaseView *view) | 4284 | void CalendarView::addView(KOrg::BaseView *view) |
4287 | { | 4285 | { |
4288 | mViewManager->addView(view); | 4286 | mViewManager->addView(view); |
4289 | } | 4287 | } |
4290 | 4288 | ||
4291 | void CalendarView::showView(KOrg::BaseView *view) | 4289 | void CalendarView::showView(KOrg::BaseView *view) |
4292 | { | 4290 | { |
4293 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4291 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4294 | } | 4292 | } |
4295 | 4293 | ||
4296 | Incidence *CalendarView::currentSelection() | 4294 | Incidence *CalendarView::currentSelection() |
4297 | { | 4295 | { |
4298 | return mViewManager->currentSelection(); | 4296 | return mViewManager->currentSelection(); |
4299 | } | 4297 | } |
4300 | void CalendarView::toggleAllDaySize() | 4298 | void CalendarView::toggleAllDaySize() |
4301 | { | 4299 | { |
4302 | /* | 4300 | /* |
4303 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4301 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4304 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4302 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4305 | else | 4303 | else |
4306 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4304 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4307 | */ | 4305 | */ |
4308 | viewManager()->agendaView()->toggleAllDay(); | 4306 | viewManager()->agendaView()->toggleAllDay(); |
4309 | } | 4307 | } |
4310 | void CalendarView::toggleExpand() | 4308 | void CalendarView::toggleExpand() |
4311 | { | 4309 | { |
4312 | // if ( mLeftFrame->isHidden() ) { | 4310 | // if ( mLeftFrame->isHidden() ) { |
4313 | // mLeftFrame->show(); | 4311 | // mLeftFrame->show(); |
4314 | // emit calendarViewExpanded( false ); | 4312 | // emit calendarViewExpanded( false ); |
4315 | // } else { | 4313 | // } else { |
4316 | // mLeftFrame->hide(); | 4314 | // mLeftFrame->hide(); |
4317 | // emit calendarViewExpanded( true ); | 4315 | // emit calendarViewExpanded( true ); |
4318 | // } | 4316 | // } |
4319 | //qDebug(" CalendarView::toggleExpand()"); | 4317 | //qDebug(" CalendarView::toggleExpand()"); |
4320 | globalFlagBlockAgenda = 1; | 4318 | globalFlagBlockAgenda = 1; |
4321 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4319 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4322 | globalFlagBlockAgenda = 5; | 4320 | globalFlagBlockAgenda = 5; |
4323 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4321 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4324 | //mViewManager->showView( 0, true ); | 4322 | //mViewManager->showView( 0, true ); |
4325 | } | 4323 | } |
4326 | 4324 | ||
4327 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4325 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4328 | { | 4326 | { |
4329 | setModified( modified ); | 4327 | setModified( modified ); |
4330 | } | 4328 | } |
4331 | 4329 | ||
4332 | Todo *CalendarView::selectedTodo() | 4330 | Todo *CalendarView::selectedTodo() |
4333 | { | 4331 | { |
4334 | Incidence *incidence = currentSelection(); | 4332 | Incidence *incidence = currentSelection(); |
4335 | if ( incidence && incidence->typeID() == todoID ) { | 4333 | if ( incidence && incidence->typeID() == todoID ) { |
4336 | return static_cast<Todo *>( incidence ); | 4334 | return static_cast<Todo *>( incidence ); |
4337 | } | 4335 | } |
4338 | 4336 | ||
4339 | incidence = mTodoList->selectedIncidences().first(); | 4337 | incidence = mTodoList->selectedIncidences().first(); |
4340 | if ( incidence && incidence->typeID() == todoID ) { | 4338 | if ( incidence && incidence->typeID() == todoID ) { |
4341 | return static_cast<Todo *>( incidence ); | 4339 | return static_cast<Todo *>( incidence ); |
4342 | } | 4340 | } |
4343 | 4341 | ||
4344 | return 0; | 4342 | return 0; |
4345 | } | 4343 | } |
4346 | 4344 | ||
4347 | void CalendarView::showIncidence() | 4345 | void CalendarView::showIncidence() |
4348 | { | 4346 | { |
4349 | mViewerCallerIsSearchDialog = false; | 4347 | mViewerCallerIsSearchDialog = false; |
4350 | Incidence *incidence = currentSelection(); | 4348 | Incidence *incidence = currentSelection(); |
4351 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4349 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4352 | if ( incidence ) { | 4350 | if ( incidence ) { |
4353 | ShowIncidenceVisitor v; | 4351 | ShowIncidenceVisitor v; |
4354 | v.act( incidence, this ); | 4352 | v.act( incidence, this ); |
4355 | } | 4353 | } |
4356 | } | 4354 | } |
4357 | void CalendarView::editIncidenceDescription() | 4355 | void CalendarView::editIncidenceDescription() |
4358 | { | 4356 | { |
4359 | mFlagEditDescription = true; | 4357 | mFlagEditDescription = true; |
4360 | editIncidence(); | 4358 | editIncidence(); |
4361 | mFlagEditDescription = false; | 4359 | mFlagEditDescription = false; |
4362 | } | 4360 | } |
4363 | void CalendarView::editIncidence() | 4361 | void CalendarView::editIncidence() |
4364 | { | 4362 | { |
4365 | // qDebug("editIncidence() "); | 4363 | // qDebug("editIncidence() "); |
4366 | Incidence *incidence = currentSelection(); | 4364 | Incidence *incidence = currentSelection(); |
4367 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4365 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4368 | if ( incidence ) { | 4366 | if ( incidence ) { |
4369 | EditIncidenceVisitor v; | 4367 | EditIncidenceVisitor v; |
4370 | v.act( incidence, this ); | 4368 | v.act( incidence, this ); |
4371 | } | 4369 | } |
4372 | } | 4370 | } |
4373 | 4371 | ||
4374 | void CalendarView::deleteIncidence() | 4372 | void CalendarView::deleteIncidence() |
4375 | { | 4373 | { |
4376 | Incidence *incidence = currentSelection(); | 4374 | Incidence *incidence = currentSelection(); |
4377 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4375 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4378 | if ( incidence ) { | 4376 | if ( incidence ) { |
4379 | deleteIncidence(incidence); | 4377 | deleteIncidence(incidence); |
4380 | } | 4378 | } |
4381 | } | 4379 | } |
4382 | void CalendarView::showIncidence(QString uid) | 4380 | void CalendarView::showIncidence(QString uid) |
4383 | { | 4381 | { |
4384 | Incidence *inc = mCalendar->incidence( uid ); | 4382 | Incidence *inc = mCalendar->incidence( uid ); |
4385 | if ( inc ) | 4383 | if ( inc ) |
4386 | showIncidence( inc ); | 4384 | showIncidence( inc ); |
4387 | } | 4385 | } |
4388 | void CalendarView::showIncidence(Incidence *incidence) | 4386 | void CalendarView::showIncidence(Incidence *incidence) |
4389 | { | 4387 | { |
4390 | mViewerCallerIsSearchDialog = false; | 4388 | mViewerCallerIsSearchDialog = false; |
4391 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4389 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4392 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4390 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4393 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4391 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4394 | mViewerCallerIsSearchDialog = true; | 4392 | mViewerCallerIsSearchDialog = true; |
4395 | } | 4393 | } |
4396 | } | 4394 | } |
4397 | if ( incidence ) { | 4395 | if ( incidence ) { |
4398 | ShowIncidenceVisitor v; | 4396 | ShowIncidenceVisitor v; |
4399 | v.act( incidence, this ); | 4397 | v.act( incidence, this ); |
4400 | } | 4398 | } |
4401 | } | 4399 | } |
4402 | 4400 | ||
4403 | void CalendarView::editIncidence(Incidence *incidence) | 4401 | void CalendarView::editIncidence(Incidence *incidence) |
4404 | { | 4402 | { |
4405 | if ( incidence ) { | 4403 | if ( incidence ) { |
4406 | 4404 | ||
4407 | EditIncidenceVisitor v; | 4405 | EditIncidenceVisitor v; |
4408 | v.act( incidence, this ); | 4406 | v.act( incidence, this ); |
4409 | 4407 | ||
4410 | } | 4408 | } |
4411 | } | 4409 | } |
4412 | 4410 | ||
4413 | void CalendarView::deleteIncidence(Incidence *incidence) | 4411 | void CalendarView::deleteIncidence(Incidence *incidence) |
4414 | { | 4412 | { |
4415 | //qDebug(" CalendarView::deleteIncidence "); | 4413 | //qDebug(" CalendarView::deleteIncidence "); |
4416 | if ( incidence ) { | 4414 | if ( incidence ) { |
4417 | DeleteIncidenceVisitor v; | 4415 | DeleteIncidenceVisitor v; |
4418 | v.act( incidence, this ); | 4416 | v.act( incidence, this ); |
4419 | } | 4417 | } |
4420 | } | 4418 | } |
4421 | 4419 | ||
4422 | 4420 | ||
4423 | void CalendarView::lookForOutgoingMessages() | 4421 | void CalendarView::lookForOutgoingMessages() |
4424 | { | 4422 | { |
4425 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4423 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4426 | ogd->loadMessages(); | 4424 | ogd->loadMessages(); |
4427 | } | 4425 | } |
4428 | 4426 | ||
4429 | void CalendarView::lookForIncomingMessages() | 4427 | void CalendarView::lookForIncomingMessages() |
4430 | { | 4428 | { |
4431 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4429 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4432 | icd->retrieve(); | 4430 | icd->retrieve(); |
4433 | } | 4431 | } |
4434 | 4432 | ||
4435 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4433 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4436 | { | 4434 | { |
4437 | bool deleteTodo = true; | 4435 | bool deleteTodo = true; |
4438 | QPtrList<Incidence> subTodos; | 4436 | QPtrList<Incidence> subTodos; |
4439 | Incidence *aTodo; | 4437 | Incidence *aTodo; |
4440 | subTodos = t->relations(); | 4438 | subTodos = t->relations(); |
4441 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4439 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4442 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4440 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4443 | deleteTodo = false; | 4441 | deleteTodo = false; |
4444 | } | 4442 | } |
4445 | if ( deleteTodo ) { | 4443 | if ( deleteTodo ) { |
4446 | if ( t->isCompleted() && !t->doesRecur()) { | 4444 | if ( t->isCompleted() && !t->doesRecur()) { |
4447 | checkExternalId( t ); | 4445 | checkExternalId( t ); |
4448 | mCalendar->deleteTodo( t ); | 4446 | mCalendar->deleteTodo( t ); |
4449 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4447 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4450 | } | 4448 | } |
4451 | else | 4449 | else |
4452 | deleteTodo = false; | 4450 | deleteTodo = false; |
4453 | } | 4451 | } |
4454 | return deleteTodo; | 4452 | return deleteTodo; |
4455 | 4453 | ||
4456 | } | 4454 | } |
4457 | void CalendarView::purgeCompleted() | 4455 | void CalendarView::purgeCompleted() |
4458 | { | 4456 | { |
4459 | int result = KMessageBox::warningContinueCancel(this, | 4457 | int result = KMessageBox::warningContinueCancel(this, |
4460 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4458 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4461 | 4459 | ||
4462 | if (result == KMessageBox::Continue) { | 4460 | if (result == KMessageBox::Continue) { |
4463 | 4461 | ||
4464 | QPtrList<Todo> todoCal; | 4462 | QPtrList<Todo> todoCal; |
4465 | QPtrList<Todo> rootTodos; | 4463 | QPtrList<Todo> rootTodos; |
4466 | //QPtrList<Incidence> rel; | 4464 | //QPtrList<Incidence> rel; |
4467 | Todo *aTodo; | 4465 | Todo *aTodo; |
4468 | todoCal = calendar()->todos(); | 4466 | todoCal = calendar()->todos(); |
4469 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4467 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4470 | if ( !aTodo->relatedTo() ) | 4468 | if ( !aTodo->relatedTo() ) |
4471 | rootTodos.append( aTodo ); | 4469 | rootTodos.append( aTodo ); |
4472 | } | 4470 | } |
4473 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4471 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4474 | removeCompletedSubTodos( aTodo ); | 4472 | removeCompletedSubTodos( aTodo ); |
4475 | } | 4473 | } |
4476 | 4474 | ||
4477 | updateView(); | 4475 | updateView(); |
4478 | } | 4476 | } |
4479 | } | 4477 | } |
4480 | 4478 | ||
4481 | void CalendarView::slotCalendarChanged() | 4479 | void CalendarView::slotCalendarChanged() |
4482 | { | 4480 | { |
4483 | ; | 4481 | ; |
4484 | } | 4482 | } |
4485 | 4483 | ||
4486 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4484 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4487 | { | 4485 | { |
4488 | //qDebug(" alendarView::keyPressEvent "); | 4486 | //qDebug(" alendarView::keyPressEvent "); |
4489 | e->ignore(); | 4487 | e->ignore(); |
4490 | } | 4488 | } |
4491 | 4489 | ||
4492 | 4490 | ||
4493 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4491 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4494 | { | 4492 | { |
4495 | 4493 | ||
4496 | if ( manager != mSyncManager) | 4494 | if ( manager != mSyncManager) |
4497 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4495 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4498 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4496 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4499 | qDebug("KO: SyncKDE request detected!"); | 4497 | qDebug("KO: SyncKDE request detected!"); |
4500 | } | 4498 | } |
4501 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4499 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4502 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4500 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4503 | return syncCalendar( filename, mode ); | 4501 | return syncCalendar( filename, mode ); |
4504 | } | 4502 | } |
4505 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4503 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4506 | { | 4504 | { |
4507 | //mSyncManager = manager; | 4505 | //mSyncManager = manager; |
4508 | if ( manager != mSyncManager) | 4506 | if ( manager != mSyncManager) |
4509 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4507 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4510 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4508 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4511 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4509 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4512 | if ( resource == "sharp" ) | 4510 | if ( resource == "sharp" ) |
4513 | syncExternal( 0 ); | 4511 | syncExternal( 0 ); |
4514 | if ( resource == "phone" ) | 4512 | if ( resource == "phone" ) |
4515 | syncExternal( 1 ); | 4513 | syncExternal( 1 ); |
4516 | // pending setmodified | 4514 | // pending setmodified |
4517 | return true; | 4515 | return true; |
4518 | } | 4516 | } |
4519 | void CalendarView::setSyncManager(KSyncManager* manager) | 4517 | void CalendarView::setSyncManager(KSyncManager* manager) |
4520 | { | 4518 | { |
4521 | mSyncManager = manager; | 4519 | mSyncManager = manager; |
4522 | } | 4520 | } |
4523 | 4521 | ||
4524 | void CalendarView::removeSyncInfo( QString syncProfile) | 4522 | void CalendarView::removeSyncInfo( QString syncProfile) |
4525 | { | 4523 | { |
4526 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4524 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4527 | mCalendar->removeSyncInfo( syncProfile ); | 4525 | mCalendar->removeSyncInfo( syncProfile ); |
4528 | 4526 | ||
4529 | } | 4527 | } |
4530 | 4528 | ||
4531 | void CalendarView::undo_delete() | 4529 | void CalendarView::undo_delete() |
4532 | { | 4530 | { |
4533 | //qDebug("undo_delete() "); | 4531 | //qDebug("undo_delete() "); |
4534 | Incidence* undo = mCalendar->undoIncidence(); | 4532 | Incidence* undo = mCalendar->undoIncidence(); |
4535 | if ( !undo ) { | 4533 | if ( !undo ) { |
4536 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4534 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4537 | i18n("KO/Pi")); | 4535 | i18n("KO/Pi")); |
4538 | return; | 4536 | return; |
4539 | } | 4537 | } |
4540 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4538 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4541 | i18n("\nAre you sure you want\nto restore this?"), | 4539 | i18n("\nAre you sure you want\nto restore this?"), |
4542 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4540 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4543 | mCalendar->undoDeleteIncidence(); | 4541 | mCalendar->undoDeleteIncidence(); |
4544 | updateView(); | 4542 | updateView(); |
4545 | } | 4543 | } |
4546 | } | 4544 | } |
4547 | 4545 | ||
4548 | void CalendarView::slotViewerClosed() | 4546 | void CalendarView::slotViewerClosed() |
4549 | { | 4547 | { |
4550 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4548 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4551 | } | 4549 | } |
4552 | 4550 | ||
4553 | void CalendarView::resetFocus() | 4551 | void CalendarView::resetFocus() |
4554 | { | 4552 | { |
4555 | if ( mViewerCallerIsSearchDialog ) { | 4553 | if ( mViewerCallerIsSearchDialog ) { |
4556 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4554 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4557 | mDialogManager->getSearchDialog()->raise(); | 4555 | mDialogManager->getSearchDialog()->raise(); |
4558 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4556 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4559 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4557 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4560 | } else | 4558 | } else |
4561 | mViewerCallerIsSearchDialog = false; | 4559 | mViewerCallerIsSearchDialog = false; |
4562 | } | 4560 | } |
4563 | if ( !mViewerCallerIsSearchDialog ) { | 4561 | if ( !mViewerCallerIsSearchDialog ) { |
4564 | //mViewManager->currentView()->setFocus(); | 4562 | //mViewManager->currentView()->setFocus(); |
4565 | //qDebug("sssssssssssssssset focus "); | 4563 | //qDebug("sssssssssssssssset focus "); |
4566 | topLevelWidget()->raise(); | 4564 | topLevelWidget()->raise(); |
4567 | setActiveWindow(); | 4565 | setActiveWindow(); |
4568 | //setFocus(); | 4566 | //setFocus(); |
4569 | } | 4567 | } |
4570 | mViewerCallerIsSearchDialog = false; | 4568 | mViewerCallerIsSearchDialog = false; |
4571 | } | 4569 | } |
4572 | 4570 | ||
4573 | void CalendarView::showNextAlarms() | 4571 | void CalendarView::showNextAlarms() |
4574 | { | 4572 | { |
4575 | QString message; | 4573 | QString message; |
4576 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4574 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4577 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4575 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4578 | QString sum = mCalendar->nextSummary(); | 4576 | QString sum = mCalendar->nextSummary(); |
4579 | QDateTime nextA = mNextAlarmDateTime; | 4577 | QDateTime nextA = mNextAlarmDateTime; |
4580 | QDateTime cur = QDateTime::currentDateTime(); | 4578 | QDateTime cur = QDateTime::currentDateTime(); |
4581 | int secs = cur.secsTo( nextA ); | 4579 | int secs = cur.secsTo( nextA ); |
4582 | int min = secs /60; | 4580 | int min = secs /60; |
4583 | int hours = min /60; | 4581 | int hours = min /60; |
4584 | min = min % 60; | 4582 | min = min % 60; |
4585 | int days = hours /24; | 4583 | int days = hours /24; |
4586 | hours = hours % 24; | 4584 | hours = hours % 24; |
4587 | 4585 | ||
4588 | //message = i18n("The next alarm is in:\n"); | 4586 | //message = i18n("The next alarm is in:\n"); |
4589 | if ( days > 1 ) | 4587 | if ( days > 1 ) |
4590 | message += i18n("%1 days\n").arg( days ); | 4588 | message += i18n("%1 days\n").arg( days ); |
4591 | else if ( days == 1 ) | 4589 | else if ( days == 1 ) |
4592 | message += i18n("1 day\n"); | 4590 | message += i18n("1 day\n"); |
4593 | if ( hours > 1 ) | 4591 | if ( hours > 1 ) |
4594 | message += i18n("%1 hours\n").arg( hours ); | 4592 | message += i18n("%1 hours\n").arg( hours ); |
4595 | else if ( hours == 1 ) | 4593 | else if ( hours == 1 ) |
4596 | message += i18n("1 hour\n"); | 4594 | message += i18n("1 hour\n"); |
4597 | if ( min > 1 ) | 4595 | if ( min > 1 ) |
4598 | message += i18n("%1 minutes\n").arg( min ); | 4596 | message += i18n("%1 minutes\n").arg( min ); |
4599 | else if ( min == 1 ) | 4597 | else if ( min == 1 ) |
4600 | message += i18n("1 minute\n"); | 4598 | message += i18n("1 minute\n"); |
4601 | if ( message.isEmpty() ) | 4599 | if ( message.isEmpty() ) |
4602 | message = i18n("The next alarm is in\nless than one minute!"); | 4600 | message = i18n("The next alarm is in\nless than one minute!"); |
4603 | else | 4601 | else |
4604 | message = i18n("The next alarm is in:\n") + message; | 4602 | message = i18n("The next alarm is in:\n") + message; |
4605 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4603 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4606 | } else { | 4604 | } else { |
4607 | message = i18n("There is no next alarm."); | 4605 | message = i18n("There is no next alarm."); |
4608 | 4606 | ||
4609 | } | 4607 | } |
4610 | #ifdef DESKTOP_VERSION | 4608 | #ifdef DESKTOP_VERSION |
4611 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4609 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4612 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4610 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4613 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4611 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4614 | } | 4612 | } |
4615 | 4613 | ||
4616 | #endif | 4614 | #endif |
4617 | KMessageBox::information( this, message); | 4615 | KMessageBox::information( this, message); |
4618 | } | 4616 | } |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 92c1cd6..acdf5a0 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,1693 +1,1692 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | 63 | ||
64 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | //delete minutes; | 88 | //delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | int secs = QTime::currentTime().second(); | 156 | int secs = QTime::currentTime().second(); |
157 | qDebug("second %d ", secs ); | ||
158 | minutes->start( (60 - secs +1)*1000 ,true); | 157 | minutes->start( (60 - secs +1)*1000 ,true); |
159 | } | 158 | } |
160 | 159 | ||
161 | 160 | ||
162 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
163 | 162 | ||
164 | 163 | ||
165 | /* | 164 | /* |
166 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
167 | */ | 166 | */ |
168 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
169 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
170 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
171 | { | 170 | { |
172 | 171 | ||
173 | mAllAgendaPopup = 0; | 172 | mAllAgendaPopup = 0; |
174 | mColumns = columns; | 173 | mColumns = columns; |
175 | mRows = rows; | 174 | mRows = rows; |
176 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
177 | mAllDayMode = false; | 176 | mAllDayMode = false; |
178 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
179 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
180 | #endif | 179 | #endif |
181 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
182 | init(); | 181 | init(); |
183 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
184 | } | 183 | } |
185 | 184 | ||
186 | /* | 185 | /* |
187 | Create an agenda widget with columns columns and one row. This is used for | 186 | Create an agenda widget with columns columns and one row. This is used for |
188 | all-day events. | 187 | all-day events. |
189 | */ | 188 | */ |
190 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
191 | QScrollView(parent,name,f) | 190 | QScrollView(parent,name,f) |
192 | { | 191 | { |
193 | mAllAgendaPopup = 0; | 192 | mAllAgendaPopup = 0; |
194 | blockResize = false; | 193 | blockResize = false; |
195 | mColumns = columns; | 194 | mColumns = columns; |
196 | mRows = 1; | 195 | mRows = 1; |
197 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
198 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
199 | mAllDayMode = true; | 198 | mAllDayMode = true; |
200 | #ifndef DESKTOP_VERSION | 199 | #ifndef DESKTOP_VERSION |
201 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
202 | #endif | 201 | #endif |
203 | mHolidayMask = 0; | 202 | mHolidayMask = 0; |
204 | init(); | 203 | init(); |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
208 | KOAgenda::~KOAgenda() | 207 | KOAgenda::~KOAgenda() |
209 | { | 208 | { |
210 | if(mMarcusBains) delete mMarcusBains; | 209 | if(mMarcusBains) delete mMarcusBains; |
211 | 210 | ||
212 | } | 211 | } |
213 | 212 | ||
214 | Incidence *KOAgenda::selectedIncidence() const | 213 | Incidence *KOAgenda::selectedIncidence() const |
215 | { | 214 | { |
216 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
217 | } | 216 | } |
218 | 217 | ||
219 | 218 | ||
220 | QDate KOAgenda::selectedIncidenceDate() const | 219 | QDate KOAgenda::selectedIncidenceDate() const |
221 | { | 220 | { |
222 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
223 | } | 222 | } |
224 | 223 | ||
225 | 224 | ||
226 | void KOAgenda::init() | 225 | void KOAgenda::init() |
227 | { | 226 | { |
228 | mPopupTimer = new QTimer(this); | 227 | mPopupTimer = new QTimer(this); |
229 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
230 | 229 | ||
231 | mNewItemPopup = new QPopupMenu( this ); | 230 | mNewItemPopup = new QPopupMenu( this ); |
232 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
233 | QString pathString = ""; | 232 | QString pathString = ""; |
234 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
235 | if ( QApplication::desktop()->width() < 480 ) | 234 | if ( QApplication::desktop()->width() < 480 ) |
236 | pathString += "icons16/"; | 235 | pathString += "icons16/"; |
237 | } else | 236 | } else |
238 | pathString += "iconsmini/"; | 237 | pathString += "iconsmini/"; |
239 | 238 | ||
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
242 | mNewItemPopup->insertSeparator ( ); | 241 | mNewItemPopup->insertSeparator ( ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
248 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
249 | #ifndef _WIN32_ | 248 | #ifndef _WIN32_ |
250 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
251 | viewport()->setWFlags ( wflags); | 250 | viewport()->setWFlags ( wflags); |
252 | #endif | 251 | #endif |
253 | mGridSpacingX = 80; | 252 | mGridSpacingX = 80; |
254 | mResizeBorderWidth = 8; | 253 | mResizeBorderWidth = 8; |
255 | mScrollBorderWidth = 8; | 254 | mScrollBorderWidth = 8; |
256 | mScrollDelay = 30; | 255 | mScrollDelay = 30; |
257 | mScrollOffset = 10; | 256 | mScrollOffset = 10; |
258 | mPaintPixmap.resize( 20,20); | 257 | mPaintPixmap.resize( 20,20); |
259 | //enableClipper(true); | 258 | //enableClipper(true); |
260 | 259 | ||
261 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
262 | // effect. Has to be fixed. | 261 | // effect. Has to be fixed. |
263 | setFocusPolicy(WheelFocus); | 262 | setFocusPolicy(WheelFocus); |
264 | 263 | ||
265 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
266 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
267 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
268 | 267 | ||
269 | mStartCellX = 0; | 268 | mStartCellX = 0; |
270 | mStartCellY = 0; | 269 | mStartCellY = 0; |
271 | mCurrentCellX = 0; | 270 | mCurrentCellX = 0; |
272 | mCurrentCellY = 0; | 271 | mCurrentCellY = 0; |
273 | 272 | ||
274 | mSelectionCellX = 0; | 273 | mSelectionCellX = 0; |
275 | mSelectionYTop = 0; | 274 | mSelectionYTop = 0; |
276 | mSelectionHeight = 0; | 275 | mSelectionHeight = 0; |
277 | 276 | ||
278 | mOldLowerScrollValue = -1; | 277 | mOldLowerScrollValue = -1; |
279 | mOldUpperScrollValue = -1; | 278 | mOldUpperScrollValue = -1; |
280 | 279 | ||
281 | mClickedItem = 0; | 280 | mClickedItem = 0; |
282 | 281 | ||
283 | mActionItem = 0; | 282 | mActionItem = 0; |
284 | mActionType = NOP; | 283 | mActionType = NOP; |
285 | mItemMoved = false; | 284 | mItemMoved = false; |
286 | 285 | ||
287 | mSelectedItem = 0; | 286 | mSelectedItem = 0; |
288 | 287 | ||
289 | // mItems.setAutoDelete(true); | 288 | // mItems.setAutoDelete(true); |
290 | 289 | ||
291 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
292 | 291 | ||
293 | viewport()->update(); | 292 | viewport()->update(); |
294 | 293 | ||
295 | setMinimumSize(30, 1); | 294 | setMinimumSize(30, 1); |
296 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 295 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
297 | 296 | ||
298 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 297 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
299 | // controlled in a way that the contents horizontally always fits. Then it is | 298 | // controlled in a way that the contents horizontally always fits. Then it is |
300 | // not necessary to turn off the scrollbar. | 299 | // not necessary to turn off the scrollbar. |
301 | setHScrollBarMode(AlwaysOff); | 300 | setHScrollBarMode(AlwaysOff); |
302 | if ( ! mAllDayMode ) | 301 | if ( ! mAllDayMode ) |
303 | setVScrollBarMode(AlwaysOn); | 302 | setVScrollBarMode(AlwaysOn); |
304 | else | 303 | else |
305 | setVScrollBarMode(AlwaysOff); | 304 | setVScrollBarMode(AlwaysOff); |
306 | 305 | ||
307 | setStartHour(KOPrefs::instance()->mDayBegins); | 306 | setStartHour(KOPrefs::instance()->mDayBegins); |
308 | 307 | ||
309 | calculateWorkingHours(); | 308 | calculateWorkingHours(); |
310 | 309 | ||
311 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
312 | SLOT(checkScrollBoundaries(int))); | 311 | SLOT(checkScrollBoundaries(int))); |
313 | 312 | ||
314 | // Create the Marcus Bains line. | 313 | // Create the Marcus Bains line. |
315 | if(mAllDayMode) | 314 | if(mAllDayMode) |
316 | mMarcusBains = 0; | 315 | mMarcusBains = 0; |
317 | else { | 316 | else { |
318 | mMarcusBains = new MarcusBains(this); | 317 | mMarcusBains = new MarcusBains(this); |
319 | addChild(mMarcusBains); | 318 | addChild(mMarcusBains); |
320 | } | 319 | } |
321 | mPopupKind = 0; | 320 | mPopupKind = 0; |
322 | mPopupItem = 0; | 321 | mPopupItem = 0; |
323 | mInvalidPixmap = false; | 322 | mInvalidPixmap = false; |
324 | 323 | ||
325 | } | 324 | } |
326 | 325 | ||
327 | void KOAgenda::shrinkPixmap() | 326 | void KOAgenda::shrinkPixmap() |
328 | { | 327 | { |
329 | mPaintPixmap.resize( 20,20); | 328 | mPaintPixmap.resize( 20,20); |
330 | mInvalidPixmap = true; | 329 | mInvalidPixmap = true; |
331 | } | 330 | } |
332 | void KOAgenda::slotContentMove(int,int) | 331 | void KOAgenda::slotContentMove(int,int) |
333 | { | 332 | { |
334 | emit sendPing(); | 333 | emit sendPing(); |
335 | if ( mActionType == NOP ) | 334 | if ( mActionType == NOP ) |
336 | slotClearSelection(); | 335 | slotClearSelection(); |
337 | if ( mSelectedItem && !mActionItem ) { | 336 | if ( mSelectedItem && !mActionItem ) { |
338 | deselectItem(); | 337 | deselectItem(); |
339 | emit incidenceSelected( 0 ); | 338 | emit incidenceSelected( 0 ); |
340 | } | 339 | } |
341 | } | 340 | } |
342 | void KOAgenda::clear() | 341 | void KOAgenda::clear() |
343 | { | 342 | { |
344 | KOAgendaItem *item; | 343 | KOAgendaItem *item; |
345 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
346 | mUnusedItems.append( item ); | 345 | mUnusedItems.append( item ); |
347 | //item->hide(); | 346 | //item->hide(); |
348 | } | 347 | } |
349 | mItems.clear(); | 348 | mItems.clear(); |
350 | mSelectedItem = 0; | 349 | mSelectedItem = 0; |
351 | clearSelection(); | 350 | clearSelection(); |
352 | } | 351 | } |
353 | 352 | ||
354 | void KOAgenda::clearSelection() | 353 | void KOAgenda::clearSelection() |
355 | { | 354 | { |
356 | mSelectionCellX = 0; | 355 | mSelectionCellX = 0; |
357 | mSelectionYTop = 0; | 356 | mSelectionYTop = 0; |
358 | mSelectionHeight = 0; | 357 | mSelectionHeight = 0; |
359 | } | 358 | } |
360 | 359 | ||
361 | void KOAgenda::marcus_bains() | 360 | void KOAgenda::marcus_bains() |
362 | { | 361 | { |
363 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 362 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
364 | } | 363 | } |
365 | 364 | ||
366 | 365 | ||
367 | void KOAgenda::changeColumns(int columns) | 366 | void KOAgenda::changeColumns(int columns) |
368 | { | 367 | { |
369 | if (columns == 0) { | 368 | if (columns == 0) { |
370 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
371 | return; | 370 | return; |
372 | } | 371 | } |
373 | clear(); | 372 | clear(); |
374 | mColumns = columns; | 373 | mColumns = columns; |
375 | computeSizes(); | 374 | computeSizes(); |
376 | } | 375 | } |
377 | 376 | ||
378 | /* | 377 | /* |
379 | This is the eventFilter function, which gets all events from the KOAgendaItems | 378 | This is the eventFilter function, which gets all events from the KOAgendaItems |
380 | contained in the agenda. It has to handle moving and resizing for all items. | 379 | contained in the agenda. It has to handle moving and resizing for all items. |
381 | */ | 380 | */ |
382 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
383 | { | 382 | { |
384 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 383 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
385 | switch(event->type()) { | 384 | switch(event->type()) { |
386 | case QEvent::MouseButtonPress: | 385 | case QEvent::MouseButtonPress: |
387 | case QEvent::MouseButtonDblClick: | 386 | case QEvent::MouseButtonDblClick: |
388 | case QEvent::MouseButtonRelease: | 387 | case QEvent::MouseButtonRelease: |
389 | case QEvent::MouseMove: | 388 | case QEvent::MouseMove: |
390 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
391 | 390 | ||
392 | case (QEvent::Leave): | 391 | case (QEvent::Leave): |
393 | if (!mActionItem) | 392 | if (!mActionItem) |
394 | setCursor(arrowCursor); | 393 | setCursor(arrowCursor); |
395 | return true; | 394 | return true; |
396 | 395 | ||
397 | default: | 396 | default: |
398 | return QScrollView::eventFilter(object,event); | 397 | return QScrollView::eventFilter(object,event); |
399 | } | 398 | } |
400 | } | 399 | } |
401 | void KOAgenda::popupMenu() | 400 | void KOAgenda::popupMenu() |
402 | { | 401 | { |
403 | mPopupTimer->stop(); | 402 | mPopupTimer->stop(); |
404 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
405 | if (mActionItem ) { | 404 | if (mActionItem ) { |
406 | endItemAction(); | 405 | endItemAction(); |
407 | } | 406 | } |
408 | mLeftMouseDown = false; // no more leftMouse computation | 407 | mLeftMouseDown = false; // no more leftMouse computation |
409 | if (mPopupItem) { | 408 | if (mPopupItem) { |
410 | //mClickedItem = mPopupItem; | 409 | //mClickedItem = mPopupItem; |
411 | selectItem(mPopupItem); | 410 | selectItem(mPopupItem); |
412 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
413 | mAllAgendaPopup->installEventFilter( this ); | 412 | mAllAgendaPopup->installEventFilter( this ); |
414 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 413 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
415 | 414 | ||
416 | } | 415 | } |
417 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
418 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
419 | endSelectAction( false ); // do not emit new event signal | 418 | endSelectAction( false ); // do not emit new event signal |
420 | mLeftMouseDown = false; // no more leftMouse computation | 419 | mLeftMouseDown = false; // no more leftMouse computation |
421 | } | 420 | } |
422 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
423 | mNewItemPopup->installEventFilter( this ); | 422 | mNewItemPopup->installEventFilter( this ); |
424 | mNewItemPopup->popup( mPopupPos); | 423 | mNewItemPopup->popup( mPopupPos); |
425 | 424 | ||
426 | } | 425 | } |
427 | mLeftMouseDown = false; | 426 | mLeftMouseDown = false; |
428 | mPopupItem = 0; | 427 | mPopupItem = 0; |
429 | mPopupKind = 0; | 428 | mPopupKind = 0; |
430 | } | 429 | } |
431 | void KOAgenda::categoryChanged(Incidence * inc) | 430 | void KOAgenda::categoryChanged(Incidence * inc) |
432 | { | 431 | { |
433 | KOAgendaItem *item; | 432 | KOAgendaItem *item; |
434 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
435 | if ( item->incidence() == inc ) { | 434 | if ( item->incidence() == inc ) { |
436 | item->initColor (); | 435 | item->initColor (); |
437 | item->updateItem(); | 436 | item->updateItem(); |
438 | } | 437 | } |
439 | } | 438 | } |
440 | } | 439 | } |
441 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
442 | { | 441 | { |
443 | 442 | ||
444 | if ( mInvalidPixmap ) { | 443 | if ( mInvalidPixmap ) { |
445 | mInvalidPixmap = false; | 444 | mInvalidPixmap = false; |
446 | qDebug("KO: Upsizing Pixmaps "); | 445 | qDebug("KO: Upsizing Pixmaps "); |
447 | computeSizes(); | 446 | computeSizes(); |
448 | emit updateViewSignal(); | 447 | emit updateViewSignal(); |
449 | return true; | 448 | return true; |
450 | } | 449 | } |
451 | emit sendPing(); | 450 | emit sendPing(); |
452 | static int startX = 0; | 451 | static int startX = 0; |
453 | static int startY = 0; | 452 | static int startY = 0; |
454 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
455 | static bool blockMoving = true; | 454 | static bool blockMoving = true; |
456 | 455 | ||
457 | //qDebug("KOAgenda::eventFilter_mous "); | 456 | //qDebug("KOAgenda::eventFilter_mous "); |
458 | if ( object == mNewItemPopup ) { | 457 | if ( object == mNewItemPopup ) { |
459 | //qDebug("mNewItemPopup "); | 458 | //qDebug("mNewItemPopup "); |
460 | if ( me->type() == QEvent::MouseButtonRelease ) { | 459 | if ( me->type() == QEvent::MouseButtonRelease ) { |
461 | mNewItemPopup->removeEventFilter( this ); | 460 | mNewItemPopup->removeEventFilter( this ); |
462 | int dX = me->globalPos().x() - mPopupPos.x();; | 461 | int dX = me->globalPos().x() - mPopupPos.x();; |
463 | if ( dX < 0 ) | 462 | if ( dX < 0 ) |
464 | dX = -dX; | 463 | dX = -dX; |
465 | int dY = me->globalPos().y() - mPopupPos.y(); | 464 | int dY = me->globalPos().y() - mPopupPos.y(); |
466 | if ( dY < 0 ) | 465 | if ( dY < 0 ) |
467 | dY = -dY; | 466 | dY = -dY; |
468 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
469 | mNewItemPopup->hide(); | 468 | mNewItemPopup->hide(); |
470 | } | 469 | } |
471 | } | 470 | } |
472 | return true; | 471 | return true; |
473 | } | 472 | } |
474 | if ( object == mAllAgendaPopup ) { | 473 | if ( object == mAllAgendaPopup ) { |
475 | //qDebug(" mAllAgendaPopup "); | 474 | //qDebug(" mAllAgendaPopup "); |
476 | if ( me->type() == QEvent::MouseButtonRelease ) { | 475 | if ( me->type() == QEvent::MouseButtonRelease ) { |
477 | mAllAgendaPopup->removeEventFilter( this ); | 476 | mAllAgendaPopup->removeEventFilter( this ); |
478 | int dX = me->globalPos().x() - mPopupPos.x();; | 477 | int dX = me->globalPos().x() - mPopupPos.x();; |
479 | if ( dX < 0 ) | 478 | if ( dX < 0 ) |
480 | dX = -dX; | 479 | dX = -dX; |
481 | int dY = me->globalPos().y() - mPopupPos.y(); | 480 | int dY = me->globalPos().y() - mPopupPos.y(); |
482 | if ( dY < 0 ) | 481 | if ( dY < 0 ) |
483 | dY = -dY; | 482 | dY = -dY; |
484 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
485 | mAllAgendaPopup->hide(); | 484 | mAllAgendaPopup->hide(); |
486 | } | 485 | } |
487 | } | 486 | } |
488 | return true; | 487 | return true; |
489 | } | 488 | } |
490 | QPoint viewportPos; | 489 | QPoint viewportPos; |
491 | if (object != viewport()) { | 490 | if (object != viewport()) { |
492 | blockmoveDist = blockmoveDist*2; | 491 | blockmoveDist = blockmoveDist*2; |
493 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
494 | } else { | 493 | } else { |
495 | viewportPos = me->pos(); | 494 | viewportPos = me->pos(); |
496 | } | 495 | } |
497 | bool objIsNotViewport = (object != viewport()); | 496 | bool objIsNotViewport = (object != viewport()); |
498 | bool leftButt = false; | 497 | bool leftButt = false; |
499 | #ifdef DESKTOP_VERSION | 498 | #ifdef DESKTOP_VERSION |
500 | leftButt = (me->button() == LeftButton); | 499 | leftButt = (me->button() == LeftButton); |
501 | #endif | 500 | #endif |
502 | switch (me->type()) { | 501 | switch (me->type()) { |
503 | case QEvent::MouseButtonPress: | 502 | case QEvent::MouseButtonPress: |
504 | if (me->button() == LeftButton) { | 503 | if (me->button() == LeftButton) { |
505 | mPopupTimer->start( 600 ); | 504 | mPopupTimer->start( 600 ); |
506 | mLeftMouseDown = true; | 505 | mLeftMouseDown = true; |
507 | } | 506 | } |
508 | blockMoving = true; | 507 | blockMoving = true; |
509 | startX = viewportPos.x(); | 508 | startX = viewportPos.x(); |
510 | startY = viewportPos.y(); | 509 | startY = viewportPos.y(); |
511 | mPopupPos = me->globalPos(); | 510 | mPopupPos = me->globalPos(); |
512 | if ( objIsNotViewport && !leftButt ) { | 511 | if ( objIsNotViewport && !leftButt ) { |
513 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
514 | if (mAllDayMode) { | 513 | if (mAllDayMode) { |
515 | if ( tempItem->height() > 10 ) { | 514 | if ( tempItem->height() > 10 ) { |
516 | int minV = tempItem->height()/4; | 515 | int minV = tempItem->height()/4; |
517 | if ( minV > (blockmoveDist/2)-2 ) { | 516 | if ( minV > (blockmoveDist/2)-2 ) { |
518 | if ( minV > blockmoveDist ) | 517 | if ( minV > blockmoveDist ) |
519 | minV = blockmoveDist; | 518 | minV = blockmoveDist; |
520 | else | 519 | else |
521 | minV = (blockmoveDist/2); | 520 | minV = (blockmoveDist/2); |
522 | } | 521 | } |
523 | bool border = false; | 522 | bool border = false; |
524 | int diff = tempItem->y() - viewportPos.y(); | 523 | int diff = tempItem->y() - viewportPos.y(); |
525 | if ( diff < 0 ) | 524 | if ( diff < 0 ) |
526 | diff *= -1; | 525 | diff *= -1; |
527 | if ( diff < minV ) { | 526 | if ( diff < minV ) { |
528 | border = true; | 527 | border = true; |
529 | objIsNotViewport = false; | 528 | objIsNotViewport = false; |
530 | } | 529 | } |
531 | if ( ! border ) { | 530 | if ( ! border ) { |
532 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
533 | if ( diff < 0 ) | 532 | if ( diff < 0 ) |
534 | diff *= -1; | 533 | diff *= -1; |
535 | if ( diff < minV ) { | 534 | if ( diff < minV ) { |
536 | border = true; | 535 | border = true; |
537 | objIsNotViewport = false; | 536 | objIsNotViewport = false; |
538 | } | 537 | } |
539 | } | 538 | } |
540 | } | 539 | } |
541 | } else { // not allday | 540 | } else { // not allday |
542 | if ( tempItem->width() > 10 ) { | 541 | if ( tempItem->width() > 10 ) { |
543 | int minH = tempItem->width()/4; | 542 | int minH = tempItem->width()/4; |
544 | if ( minH > (blockmoveDist/2)-2 ) { | 543 | if ( minH > (blockmoveDist/2)-2 ) { |
545 | if ( minH > blockmoveDist ) | 544 | if ( minH > blockmoveDist ) |
546 | minH = blockmoveDist; | 545 | minH = blockmoveDist; |
547 | else | 546 | else |
548 | minH = (blockmoveDist/2); | 547 | minH = (blockmoveDist/2); |
549 | } | 548 | } |
550 | bool border = false; | 549 | bool border = false; |
551 | int diff = tempItem->x() - viewportPos.x(); | 550 | int diff = tempItem->x() - viewportPos.x(); |
552 | if ( diff < 0 ) | 551 | if ( diff < 0 ) |
553 | diff *= -1; | 552 | diff *= -1; |
554 | if ( diff < minH ) { | 553 | if ( diff < minH ) { |
555 | border = true; | 554 | border = true; |
556 | objIsNotViewport = false; | 555 | objIsNotViewport = false; |
557 | } | 556 | } |
558 | if ( ! border ) { | 557 | if ( ! border ) { |
559 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
560 | if ( diff < 0 ) | 559 | if ( diff < 0 ) |
561 | diff *= -1; | 560 | diff *= -1; |
562 | if ( diff < minH ) { | 561 | if ( diff < minH ) { |
563 | border = true; | 562 | border = true; |
564 | objIsNotViewport = false; | 563 | objIsNotViewport = false; |
565 | } | 564 | } |
566 | } | 565 | } |
567 | } | 566 | } |
568 | } | 567 | } |
569 | } | 568 | } |
570 | if ( objIsNotViewport ) { | 569 | if ( objIsNotViewport ) { |
571 | mPopupItem = (KOAgendaItem *)object; | 570 | mPopupItem = (KOAgendaItem *)object; |
572 | mPopupKind = 1; | 571 | mPopupKind = 1; |
573 | if (me->button() == RightButton) { | 572 | if (me->button() == RightButton) { |
574 | mPopupKind = 3; | 573 | mPopupKind = 3; |
575 | popupMenu(); | 574 | popupMenu(); |
576 | } else if (me->button() == LeftButton) { | 575 | } else if (me->button() == LeftButton) { |
577 | mActionItem = (KOAgendaItem *)object; | 576 | mActionItem = (KOAgendaItem *)object; |
578 | if (mActionItem) { | 577 | if (mActionItem) { |
579 | emit signalClearSelection(); | 578 | emit signalClearSelection(); |
580 | slotClearSelection(); | 579 | slotClearSelection(); |
581 | selectItem(mActionItem); | 580 | selectItem(mActionItem); |
582 | Incidence *incidence = mActionItem->incidence(); | 581 | Incidence *incidence = mActionItem->incidence(); |
583 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
584 | mActionItem = 0; | 583 | mActionItem = 0; |
585 | } else { | 584 | } else { |
586 | startItemAction(viewportPos); | 585 | startItemAction(viewportPos); |
587 | } | 586 | } |
588 | } | 587 | } |
589 | } | 588 | } |
590 | } else { // ---------- viewport() | 589 | } else { // ---------- viewport() |
591 | mPopupItem = 0; | 590 | mPopupItem = 0; |
592 | mPopupKind = 2; | 591 | mPopupKind = 2; |
593 | selectItem(0); | 592 | selectItem(0); |
594 | mActionItem = 0; | 593 | mActionItem = 0; |
595 | if (me->button() == RightButton) { | 594 | if (me->button() == RightButton) { |
596 | int x,y; | 595 | int x,y; |
597 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
598 | int gx,gy; | 597 | int gx,gy; |
599 | contentsToGrid(x,y,gx,gy); | 598 | contentsToGrid(x,y,gx,gy); |
600 | mCurrentCellX = gx; | 599 | mCurrentCellX = gx; |
601 | mCurrentCellY = gy; | 600 | mCurrentCellY = gy; |
602 | mStartCellX = gx; | 601 | mStartCellX = gx; |
603 | mStartCellY = gy; | 602 | mStartCellY = gy; |
604 | mPopupKind = 4; | 603 | mPopupKind = 4; |
605 | popupMenu(); | 604 | popupMenu(); |
606 | } else if (me->button() == LeftButton) { | 605 | } else if (me->button() == LeftButton) { |
607 | setCursor(arrowCursor); | 606 | setCursor(arrowCursor); |
608 | startSelectAction(viewportPos); | 607 | startSelectAction(viewportPos); |
609 | } | 608 | } |
610 | } | 609 | } |
611 | break; | 610 | break; |
612 | 611 | ||
613 | case QEvent::MouseButtonRelease: | 612 | case QEvent::MouseButtonRelease: |
614 | if (me->button() == LeftButton ) { | 613 | if (me->button() == LeftButton ) { |
615 | mPopupTimer->stop(); | 614 | mPopupTimer->stop(); |
616 | } | 615 | } |
617 | if (object != viewport()) { | 616 | if (object != viewport()) { |
618 | if (me->button() == LeftButton && mLeftMouseDown) { | 617 | if (me->button() == LeftButton && mLeftMouseDown) { |
619 | if (mActionItem) { | 618 | if (mActionItem) { |
620 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
621 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
622 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
623 | mScrollUpTimer.stop(); | 622 | mScrollUpTimer.stop(); |
624 | mScrollDownTimer.stop(); | 623 | mScrollDownTimer.stop(); |
625 | mActionItem->resetMove(); | 624 | mActionItem->resetMove(); |
626 | placeSubCells( mActionItem ); | 625 | placeSubCells( mActionItem ); |
627 | // emit startDragSignal( mActionItem->incidence() ); | 626 | // emit startDragSignal( mActionItem->incidence() ); |
628 | setCursor( arrowCursor ); | 627 | setCursor( arrowCursor ); |
629 | mActionItem = 0; | 628 | mActionItem = 0; |
630 | mActionType = NOP; | 629 | mActionType = NOP; |
631 | mItemMoved = 0; | 630 | mItemMoved = 0; |
632 | mLeftMouseDown = false; | 631 | mLeftMouseDown = false; |
633 | return true; | 632 | return true; |
634 | } | 633 | } |
635 | endItemAction(); | 634 | endItemAction(); |
636 | } | 635 | } |
637 | } | 636 | } |
638 | 637 | ||
639 | } else { // ---------- viewport() | 638 | } else { // ---------- viewport() |
640 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
641 | endSelectAction( true ); // emit new event signal | 640 | endSelectAction( true ); // emit new event signal |
642 | } | 641 | } |
643 | } | 642 | } |
644 | if (me->button() == LeftButton) | 643 | if (me->button() == LeftButton) |
645 | mLeftMouseDown = false; | 644 | mLeftMouseDown = false; |
646 | 645 | ||
647 | break; | 646 | break; |
648 | 647 | ||
649 | case QEvent::MouseMove: | 648 | case QEvent::MouseMove: |
650 | //qDebug("mm "); | 649 | //qDebug("mm "); |
651 | if ( !mLeftMouseDown ) | 650 | if ( !mLeftMouseDown ) |
652 | return false; | 651 | return false; |
653 | if ( blockMoving ) { | 652 | if ( blockMoving ) { |
654 | int dX, dY; | 653 | int dX, dY; |
655 | dX = startX - viewportPos.x(); | 654 | dX = startX - viewportPos.x(); |
656 | if ( dX < 0 ) | 655 | if ( dX < 0 ) |
657 | dX = -dX; | 656 | dX = -dX; |
658 | dY = viewportPos.y() - startY; | 657 | dY = viewportPos.y() - startY; |
659 | if ( dY < 0 ) | 658 | if ( dY < 0 ) |
660 | dY = -dY; | 659 | dY = -dY; |
661 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
662 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
663 | blockMoving = false; | 662 | blockMoving = false; |
664 | } | 663 | } |
665 | } | 664 | } |
666 | if ( ! blockMoving ) | 665 | if ( ! blockMoving ) |
667 | mPopupTimer->stop(); | 666 | mPopupTimer->stop(); |
668 | if (object != viewport()) { | 667 | if (object != viewport()) { |
669 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
670 | if (!moveItem->incidence()->isReadOnly() ) { | 669 | if (!moveItem->incidence()->isReadOnly() ) { |
671 | if (!mActionItem) | 670 | if (!mActionItem) |
672 | setNoActionCursor(moveItem,viewportPos); | 671 | setNoActionCursor(moveItem,viewportPos); |
673 | else { | 672 | else { |
674 | if ( !blockMoving ) | 673 | if ( !blockMoving ) |
675 | performItemAction(viewportPos); | 674 | performItemAction(viewportPos); |
676 | } | 675 | } |
677 | } | 676 | } |
678 | } else { // ---------- viewport() | 677 | } else { // ---------- viewport() |
679 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
680 | if ( mActionType == SELECT ) { | 679 | if ( mActionType == SELECT ) { |
681 | performSelectAction( viewportPos ); | 680 | performSelectAction( viewportPos ); |
682 | } | 681 | } |
683 | } | 682 | } |
684 | break; | 683 | break; |
685 | 684 | ||
686 | case QEvent::MouseButtonDblClick: | 685 | case QEvent::MouseButtonDblClick: |
687 | mPopupTimer->stop(); | 686 | mPopupTimer->stop(); |
688 | if (object == viewport()) { | 687 | if (object == viewport()) { |
689 | selectItem(0); | 688 | selectItem(0); |
690 | int x,y; | 689 | int x,y; |
691 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
692 | int gx,gy; | 691 | int gx,gy; |
693 | contentsToGrid(x,y,gx,gy); | 692 | contentsToGrid(x,y,gx,gy); |
694 | emit newEventSignal(gx,gy); | 693 | emit newEventSignal(gx,gy); |
695 | } else { | 694 | } else { |
696 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
697 | selectItem(doubleClickedItem); | 696 | selectItem(doubleClickedItem); |
698 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
699 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 698 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
700 | else | 699 | else |
701 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 700 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
702 | } | 701 | } |
703 | break; | 702 | break; |
704 | 703 | ||
705 | default: | 704 | default: |
706 | break; | 705 | break; |
707 | } | 706 | } |
708 | return true; | 707 | return true; |
709 | 708 | ||
710 | } | 709 | } |
711 | 710 | ||
712 | void KOAgenda::newItem( int item ) | 711 | void KOAgenda::newItem( int item ) |
713 | { | 712 | { |
714 | if ( item == 1 ) { //new event | 713 | if ( item == 1 ) { //new event |
715 | newEventSignal(mStartCellX ,mStartCellY ); | 714 | newEventSignal(mStartCellX ,mStartCellY ); |
716 | } else | 715 | } else |
717 | if ( item == 2 ) { //new event | 716 | if ( item == 2 ) { //new event |
718 | newTodoSignal(mStartCellX ,mStartCellY ); | 717 | newTodoSignal(mStartCellX ,mStartCellY ); |
719 | } else | 718 | } else |
720 | { | 719 | { |
721 | emit showDateView( item, mStartCellX ); | 720 | emit showDateView( item, mStartCellX ); |
722 | // 3Day view | 721 | // 3Day view |
723 | // 4Week view | 722 | // 4Week view |
724 | // 5Month view | 723 | // 5Month view |
725 | // 6Journal view | 724 | // 6Journal view |
726 | } | 725 | } |
727 | } | 726 | } |
728 | void KOAgenda::slotClearSelection() | 727 | void KOAgenda::slotClearSelection() |
729 | { | 728 | { |
730 | if (mSelectionHeight) { | 729 | if (mSelectionHeight) { |
731 | int selectionX = mSelectionCellX * mGridSpacingX; | 730 | int selectionX = mSelectionCellX * mGridSpacingX; |
732 | int top = mSelectionYTop - 2 *mGridSpacingY; | 731 | int top = mSelectionYTop - 2 *mGridSpacingY; |
733 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 732 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
734 | clearSelection(); | 733 | clearSelection(); |
735 | repaintContents( selectionX, top, | 734 | repaintContents( selectionX, top, |
736 | mGridSpacingX, hei ,false ); | 735 | mGridSpacingX, hei ,false ); |
737 | } | 736 | } |
738 | 737 | ||
739 | } | 738 | } |
740 | void KOAgenda::startSelectAction(QPoint viewportPos) | 739 | void KOAgenda::startSelectAction(QPoint viewportPos) |
741 | { | 740 | { |
742 | 741 | ||
743 | emit signalClearSelection(); | 742 | emit signalClearSelection(); |
744 | slotClearSelection(); | 743 | slotClearSelection(); |
745 | 744 | ||
746 | mActionType = SELECT; | 745 | mActionType = SELECT; |
747 | 746 | ||
748 | int x,y; | 747 | int x,y; |
749 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
750 | int gx,gy; | 749 | int gx,gy; |
751 | contentsToGrid(x,y,gx,gy); | 750 | contentsToGrid(x,y,gx,gy); |
752 | 751 | ||
753 | mStartCellX = gx; | 752 | mStartCellX = gx; |
754 | mStartCellY = gy; | 753 | mStartCellY = gy; |
755 | mCurrentCellX = gx; | 754 | mCurrentCellX = gx; |
756 | mCurrentCellY = gy; | 755 | mCurrentCellY = gy; |
757 | 756 | ||
758 | // Store new selection | 757 | // Store new selection |
759 | mSelectionCellX = gx; | 758 | mSelectionCellX = gx; |
760 | mSelectionYTop = gy * mGridSpacingY; | 759 | mSelectionYTop = gy * mGridSpacingY; |
761 | mSelectionHeight = mGridSpacingY; | 760 | mSelectionHeight = mGridSpacingY; |
762 | 761 | ||
763 | // Paint new selection | 762 | // Paint new selection |
764 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
765 | mGridSpacingX-1, mSelectionHeight ); | 764 | mGridSpacingX-1, mSelectionHeight ); |
766 | } | 765 | } |
767 | 766 | ||
768 | void KOAgenda::performSelectAction(QPoint viewportPos) | 767 | void KOAgenda::performSelectAction(QPoint viewportPos) |
769 | { | 768 | { |
770 | int x,y; | 769 | int x,y; |
771 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
772 | int gx,gy; | 771 | int gx,gy; |
773 | contentsToGrid(x,y,gx,gy); | 772 | contentsToGrid(x,y,gx,gy); |
774 | 773 | ||
775 | QPoint clipperPos = clipper()-> | 774 | QPoint clipperPos = clipper()-> |
776 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
777 | 776 | ||
778 | // Scroll if cursor was moved to upper or lower end of agenda. | 777 | // Scroll if cursor was moved to upper or lower end of agenda. |
779 | if (clipperPos.y() < mScrollBorderWidth) { | 778 | if (clipperPos.y() < mScrollBorderWidth) { |
780 | mScrollUpTimer.start(mScrollDelay); | 779 | mScrollUpTimer.start(mScrollDelay); |
781 | } else if (visibleHeight() - clipperPos.y() < | 780 | } else if (visibleHeight() - clipperPos.y() < |
782 | mScrollBorderWidth) { | 781 | mScrollBorderWidth) { |
783 | mScrollDownTimer.start(mScrollDelay); | 782 | mScrollDownTimer.start(mScrollDelay); |
784 | } else { | 783 | } else { |
785 | mScrollUpTimer.stop(); | 784 | mScrollUpTimer.stop(); |
786 | mScrollDownTimer.stop(); | 785 | mScrollDownTimer.stop(); |
787 | } | 786 | } |
788 | 787 | ||
789 | if ( gy > mCurrentCellY ) { | 788 | if ( gy > mCurrentCellY ) { |
790 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
791 | 790 | ||
792 | 791 | ||
793 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 792 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
794 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
795 | mGridSpacingX, mSelectionYTop, | 794 | mGridSpacingX, mSelectionYTop, |
796 | mGridSpacingX, mSelectionHeight , false); | 795 | mGridSpacingX, mSelectionHeight , false); |
797 | 796 | ||
798 | mCurrentCellY = gy; | 797 | mCurrentCellY = gy; |
799 | } else if ( gy < mCurrentCellY ) { | 798 | } else if ( gy < mCurrentCellY ) { |
800 | if ( gy >= mStartCellY ) { | 799 | if ( gy >= mStartCellY ) { |
801 | int selectionHeight = mSelectionHeight; | 800 | int selectionHeight = mSelectionHeight; |
802 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
803 | 802 | ||
804 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 803 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
805 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
806 | mGridSpacingX, mSelectionYTop, | 805 | mGridSpacingX, mSelectionYTop, |
807 | mGridSpacingX, selectionHeight,false ); | 806 | mGridSpacingX, selectionHeight,false ); |
808 | 807 | ||
809 | mCurrentCellY = gy; | 808 | mCurrentCellY = gy; |
810 | } else { | 809 | } else { |
811 | } | 810 | } |
812 | } | 811 | } |
813 | } | 812 | } |
814 | 813 | ||
815 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 814 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
816 | { | 815 | { |
817 | mActionType = NOP; | 816 | mActionType = NOP; |
818 | mScrollUpTimer.stop(); | 817 | mScrollUpTimer.stop(); |
819 | mScrollDownTimer.stop(); | 818 | mScrollDownTimer.stop(); |
820 | 819 | ||
821 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
822 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
823 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
824 | } | 823 | } |
825 | } | 824 | } |
826 | 825 | ||
827 | void KOAgenda::startItemAction(QPoint viewportPos) | 826 | void KOAgenda::startItemAction(QPoint viewportPos) |
828 | { | 827 | { |
829 | int x,y; | 828 | int x,y; |
830 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
831 | int gx,gy; | 830 | int gx,gy; |
832 | contentsToGrid(x,y,gx,gy); | 831 | contentsToGrid(x,y,gx,gy); |
833 | 832 | ||
834 | mStartCellX = gx; | 833 | mStartCellX = gx; |
835 | mStartCellY = gy; | 834 | mStartCellY = gy; |
836 | mCurrentCellX = gx; | 835 | mCurrentCellX = gx; |
837 | mCurrentCellY = gy; | 836 | mCurrentCellY = gy; |
838 | 837 | ||
839 | if (mAllDayMode) { | 838 | if (mAllDayMode) { |
840 | int gridDistanceX = (x - gx * mGridSpacingX); | 839 | int gridDistanceX = (x - gx * mGridSpacingX); |
841 | if (gridDistanceX < mResizeBorderWidth && | 840 | if (gridDistanceX < mResizeBorderWidth && |
842 | mActionItem->cellX() == mCurrentCellX) { | 841 | mActionItem->cellX() == mCurrentCellX) { |
843 | mActionType = RESIZELEFT; | 842 | mActionType = RESIZELEFT; |
844 | setCursor(sizeHorCursor); | 843 | setCursor(sizeHorCursor); |
845 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
846 | mActionItem->cellXWidth() == mCurrentCellX) { | 845 | mActionItem->cellXWidth() == mCurrentCellX) { |
847 | mActionType = RESIZERIGHT; | 846 | mActionType = RESIZERIGHT; |
848 | setCursor(sizeHorCursor); | 847 | setCursor(sizeHorCursor); |
849 | } else { | 848 | } else { |
850 | mActionType = MOVE; | 849 | mActionType = MOVE; |
851 | mActionItem->startMove(); | 850 | mActionItem->startMove(); |
852 | setCursor(sizeAllCursor); | 851 | setCursor(sizeAllCursor); |
853 | } | 852 | } |
854 | } else { | 853 | } else { |
855 | int gridDistanceY = (y - gy * mGridSpacingY); | 854 | int gridDistanceY = (y - gy * mGridSpacingY); |
856 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
857 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 856 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
858 | mActionItem->cellYTop() == mCurrentCellY && | 857 | mActionItem->cellYTop() == mCurrentCellY && |
859 | !mActionItem->firstMultiItem()) { | 858 | !mActionItem->firstMultiItem()) { |
860 | mActionType = RESIZETOP; | 859 | mActionType = RESIZETOP; |
861 | setCursor(sizeVerCursor); | 860 | setCursor(sizeVerCursor); |
862 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
863 | mActionItem->cellYBottom() == mCurrentCellY && | 862 | mActionItem->cellYBottom() == mCurrentCellY && |
864 | !mActionItem->lastMultiItem()) { | 863 | !mActionItem->lastMultiItem()) { |
865 | mActionType = RESIZEBOTTOM; | 864 | mActionType = RESIZEBOTTOM; |
866 | setCursor(sizeVerCursor); | 865 | setCursor(sizeVerCursor); |
867 | } else { | 866 | } else { |
868 | mActionType = MOVE; | 867 | mActionType = MOVE; |
869 | mActionItem->startMove(); | 868 | mActionItem->startMove(); |
870 | setCursor(sizeAllCursor); | 869 | setCursor(sizeAllCursor); |
871 | } | 870 | } |
872 | } | 871 | } |
873 | } | 872 | } |
874 | 873 | ||
875 | void KOAgenda::performItemAction(QPoint viewportPos) | 874 | void KOAgenda::performItemAction(QPoint viewportPos) |
876 | { | 875 | { |
877 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
878 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 877 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
879 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
880 | // point = clipper()->mapFromGlobal(point); | 879 | // point = clipper()->mapFromGlobal(point); |
881 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
882 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 881 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
883 | int x,y; | 882 | int x,y; |
884 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
885 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
886 | int gx,gy; | 885 | int gx,gy; |
887 | contentsToGrid(x,y,gx,gy); | 886 | contentsToGrid(x,y,gx,gy); |
888 | QPoint clipperPos = clipper()-> | 887 | QPoint clipperPos = clipper()-> |
889 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
890 | 889 | ||
891 | // Cursor left active agenda area. | 890 | // Cursor left active agenda area. |
892 | // This starts a drag. | 891 | // This starts a drag. |
893 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
894 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
895 | if ( mActionType == MOVE ) { | 894 | if ( mActionType == MOVE ) { |
896 | mScrollUpTimer.stop(); | 895 | mScrollUpTimer.stop(); |
897 | mScrollDownTimer.stop(); | 896 | mScrollDownTimer.stop(); |
898 | mActionItem->resetMove(); | 897 | mActionItem->resetMove(); |
899 | placeSubCells( mActionItem ); | 898 | placeSubCells( mActionItem ); |
900 | // emit startDragSignal( mActionItem->incidence() ); | 899 | // emit startDragSignal( mActionItem->incidence() ); |
901 | setCursor( arrowCursor ); | 900 | setCursor( arrowCursor ); |
902 | mActionItem = 0; | 901 | mActionItem = 0; |
903 | mActionType = NOP; | 902 | mActionType = NOP; |
904 | mItemMoved = 0; | 903 | mItemMoved = 0; |
905 | return; | 904 | return; |
906 | } | 905 | } |
907 | } else { | 906 | } else { |
908 | switch ( mActionType ) { | 907 | switch ( mActionType ) { |
909 | case MOVE: | 908 | case MOVE: |
910 | setCursor( sizeAllCursor ); | 909 | setCursor( sizeAllCursor ); |
911 | break; | 910 | break; |
912 | case RESIZETOP: | 911 | case RESIZETOP: |
913 | case RESIZEBOTTOM: | 912 | case RESIZEBOTTOM: |
914 | setCursor( sizeVerCursor ); | 913 | setCursor( sizeVerCursor ); |
915 | break; | 914 | break; |
916 | case RESIZELEFT: | 915 | case RESIZELEFT: |
917 | case RESIZERIGHT: | 916 | case RESIZERIGHT: |
918 | setCursor( sizeHorCursor ); | 917 | setCursor( sizeHorCursor ); |
919 | break; | 918 | break; |
920 | default: | 919 | default: |
921 | setCursor( arrowCursor ); | 920 | setCursor( arrowCursor ); |
922 | } | 921 | } |
923 | } | 922 | } |
924 | 923 | ||
925 | // Scroll if item was moved to upper or lower end of agenda. | 924 | // Scroll if item was moved to upper or lower end of agenda. |
926 | if (clipperPos.y() < mScrollBorderWidth) { | 925 | if (clipperPos.y() < mScrollBorderWidth) { |
927 | mScrollUpTimer.start(mScrollDelay); | 926 | mScrollUpTimer.start(mScrollDelay); |
928 | } else if (visibleHeight() - clipperPos.y() < | 927 | } else if (visibleHeight() - clipperPos.y() < |
929 | mScrollBorderWidth) { | 928 | mScrollBorderWidth) { |
930 | mScrollDownTimer.start(mScrollDelay); | 929 | mScrollDownTimer.start(mScrollDelay); |
931 | } else { | 930 | } else { |
932 | mScrollUpTimer.stop(); | 931 | mScrollUpTimer.stop(); |
933 | mScrollDownTimer.stop(); | 932 | mScrollDownTimer.stop(); |
934 | } | 933 | } |
935 | 934 | ||
936 | // Move or resize item if necessary | 935 | // Move or resize item if necessary |
937 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
938 | mItemMoved = true; | 937 | mItemMoved = true; |
939 | mActionItem->raise(); | 938 | mActionItem->raise(); |
940 | if (mActionType == MOVE) { | 939 | if (mActionType == MOVE) { |
941 | // Move all items belonging to a multi item | 940 | // Move all items belonging to a multi item |
942 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
943 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
944 | if (!moveItem) moveItem = mActionItem; | 943 | if (!moveItem) moveItem = mActionItem; |
945 | while (moveItem) { | 944 | while (moveItem) { |
946 | int dy; | 945 | int dy; |
947 | if (isMultiItem) dy = 0; | 946 | if (isMultiItem) dy = 0; |
948 | else dy = gy - mCurrentCellY; | 947 | else dy = gy - mCurrentCellY; |
949 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 948 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
950 | int x,y; | 949 | int x,y; |
951 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
952 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
953 | mGridSpacingY * moveItem->cellHeight()); | 952 | mGridSpacingY * moveItem->cellHeight()); |
954 | moveItem->raise(); | 953 | moveItem->raise(); |
955 | moveChild(moveItem,x,y); | 954 | moveChild(moveItem,x,y); |
956 | moveItem = moveItem->nextMultiItem(); | 955 | moveItem = moveItem->nextMultiItem(); |
957 | } | 956 | } |
958 | } else if (mActionType == RESIZETOP) { | 957 | } else if (mActionType == RESIZETOP) { |
959 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
960 | mActionItem->expandTop(gy - mCurrentCellY); | 959 | mActionItem->expandTop(gy - mCurrentCellY); |
961 | mActionItem->resize(mActionItem->width(), | 960 | mActionItem->resize(mActionItem->width(), |
962 | mGridSpacingY * mActionItem->cellHeight()); | 961 | mGridSpacingY * mActionItem->cellHeight()); |
963 | int x,y; | 962 | int x,y; |
964 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
965 | //moveChild(mActionItem,childX(mActionItem),y); | 964 | //moveChild(mActionItem,childX(mActionItem),y); |
966 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
967 | } | 966 | } |
968 | } else if (mActionType == RESIZEBOTTOM) { | 967 | } else if (mActionType == RESIZEBOTTOM) { |
969 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 968 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
970 | mActionItem->expandBottom(gy - mCurrentCellY); | 969 | mActionItem->expandBottom(gy - mCurrentCellY); |
971 | mActionItem->resize(mActionItem->width(), | 970 | mActionItem->resize(mActionItem->width(), |
972 | mGridSpacingY * mActionItem->cellHeight()); | 971 | mGridSpacingY * mActionItem->cellHeight()); |
973 | } | 972 | } |
974 | } else if (mActionType == RESIZELEFT) { | 973 | } else if (mActionType == RESIZELEFT) { |
975 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
976 | mActionItem->expandLeft(gx - mCurrentCellX); | 975 | mActionItem->expandLeft(gx - mCurrentCellX); |
977 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
978 | mActionItem->height()); | 977 | mActionItem->height()); |
979 | int x,y; | 978 | int x,y; |
980 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
981 | moveChild(mActionItem,x,childY(mActionItem)); | 980 | moveChild(mActionItem,x,childY(mActionItem)); |
982 | } | 981 | } |
983 | } else if (mActionType == RESIZERIGHT) { | 982 | } else if (mActionType == RESIZERIGHT) { |
984 | if (mCurrentCellX >= mActionItem->cellX()) { | 983 | if (mCurrentCellX >= mActionItem->cellX()) { |
985 | mActionItem->expandRight(gx - mCurrentCellX); | 984 | mActionItem->expandRight(gx - mCurrentCellX); |
986 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
987 | mActionItem->height()); | 986 | mActionItem->height()); |
988 | } | 987 | } |
989 | } | 988 | } |
990 | mCurrentCellX = gx; | 989 | mCurrentCellX = gx; |
991 | mCurrentCellY = gy; | 990 | mCurrentCellY = gy; |
992 | } | 991 | } |
993 | } | 992 | } |
994 | 993 | ||
995 | void KOAgenda::endItemAction() | 994 | void KOAgenda::endItemAction() |
996 | { | 995 | { |
997 | 996 | ||
998 | if ( mItemMoved ) { | 997 | if ( mItemMoved ) { |
999 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
1000 | if ( !placeItem ) { | 999 | if ( !placeItem ) { |
1001 | placeItem = mActionItem; | 1000 | placeItem = mActionItem; |
1002 | } | 1001 | } |
1003 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
1004 | Incidence* oldInc = placeItem->incidence(); | 1003 | Incidence* oldInc = placeItem->incidence(); |
1005 | placeItem->recreateIncidence(); | 1004 | placeItem->recreateIncidence(); |
1006 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1007 | } | 1006 | } |
1008 | int type = mActionType; | 1007 | int type = mActionType; |
1009 | if ( mAllDayMode ) | 1008 | if ( mAllDayMode ) |
1010 | type = -1; | 1009 | type = -1; |
1011 | KOAgendaItem *modifiedItem = placeItem; | 1010 | KOAgendaItem *modifiedItem = placeItem; |
1012 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1013 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1014 | KOAgendaItem *item; | 1013 | KOAgendaItem *item; |
1015 | 1014 | ||
1016 | if ( placeItem->incidence()->typeID() == todoID ) { | 1015 | if ( placeItem->incidence()->typeID() == todoID ) { |
1017 | mSelectedItem = 0; | 1016 | mSelectedItem = 0; |
1018 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1019 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1020 | emit itemModified( modifiedItem, mActionType ); | 1019 | emit itemModified( modifiedItem, mActionType ); |
1021 | } | 1020 | } |
1022 | else { | 1021 | else { |
1023 | 1022 | ||
1024 | 1023 | ||
1025 | globalFlagBlockAgendaItemPaint = 1; | 1024 | globalFlagBlockAgendaItemPaint = 1; |
1026 | for ( item=oldconflictItems.first(); item != 0; | 1025 | for ( item=oldconflictItems.first(); item != 0; |
1027 | item=oldconflictItems.next() ) { | 1026 | item=oldconflictItems.next() ) { |
1028 | placeSubCells(item); | 1027 | placeSubCells(item); |
1029 | } | 1028 | } |
1030 | while ( placeItem ) { | 1029 | while ( placeItem ) { |
1031 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1032 | oldconflictItems = placeItem->conflictItems(); | 1031 | oldconflictItems = placeItem->conflictItems(); |
1033 | for ( item=oldconflictItems.first(); item != 0; | 1032 | for ( item=oldconflictItems.first(); item != 0; |
1034 | item=oldconflictItems.next() ) { | 1033 | item=oldconflictItems.next() ) { |
1035 | placeSubCells(item); | 1034 | placeSubCells(item); |
1036 | } | 1035 | } |
1037 | placeSubCells( placeItem ); | 1036 | placeSubCells( placeItem ); |
1038 | placeItem = placeItem->nextMultiItem(); | 1037 | placeItem = placeItem->nextMultiItem(); |
1039 | } | 1038 | } |
1040 | globalFlagBlockAgendaItemPaint = 0; | 1039 | globalFlagBlockAgendaItemPaint = 0; |
1041 | for ( item=oldconflictItems.first(); item != 0; | 1040 | for ( item=oldconflictItems.first(); item != 0; |
1042 | item=oldconflictItems.next() ) { | 1041 | item=oldconflictItems.next() ) { |
1043 | globalFlagBlockAgendaItemUpdate = 0; | 1042 | globalFlagBlockAgendaItemUpdate = 0; |
1044 | item->repaintMe(); | 1043 | item->repaintMe(); |
1045 | globalFlagBlockAgendaItemUpdate = 1; | 1044 | globalFlagBlockAgendaItemUpdate = 1; |
1046 | item->repaint( false ); | 1045 | item->repaint( false ); |
1047 | } | 1046 | } |
1048 | placeItem = modifiedItem; | 1047 | placeItem = modifiedItem; |
1049 | 1048 | ||
1050 | while ( placeItem ) { | 1049 | while ( placeItem ) { |
1051 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1052 | globalFlagBlockAgendaItemUpdate = 0; | 1051 | globalFlagBlockAgendaItemUpdate = 0; |
1053 | placeItem->repaintMe(); | 1052 | placeItem->repaintMe(); |
1054 | globalFlagBlockAgendaItemUpdate = 1; | 1053 | globalFlagBlockAgendaItemUpdate = 1; |
1055 | placeItem->repaint(false); | 1054 | placeItem->repaint(false); |
1056 | placeItem = placeItem->nextMultiItem(); | 1055 | placeItem = placeItem->nextMultiItem(); |
1057 | } | 1056 | } |
1058 | emit itemModified( modifiedItem, mActionType ); | 1057 | emit itemModified( modifiedItem, mActionType ); |
1059 | 1058 | ||
1060 | 1059 | ||
1061 | placeItem = modifiedItem; | 1060 | placeItem = modifiedItem; |
1062 | while ( placeItem ) { | 1061 | while ( placeItem ) { |
1063 | oldconflictItems = placeItem->conflictItems(); | 1062 | oldconflictItems = placeItem->conflictItems(); |
1064 | for ( item=oldconflictItems.first(); item != 0; | 1063 | for ( item=oldconflictItems.first(); item != 0; |
1065 | item=oldconflictItems.next() ) { | 1064 | item=oldconflictItems.next() ) { |
1066 | placeSubCells(item); | 1065 | placeSubCells(item); |
1067 | } | 1066 | } |
1068 | placeSubCells( placeItem ); | 1067 | placeSubCells( placeItem ); |
1069 | placeItem = placeItem->nextMultiItem(); | 1068 | placeItem = placeItem->nextMultiItem(); |
1070 | 1069 | ||
1071 | } | 1070 | } |
1072 | placeItem = modifiedItem; | 1071 | placeItem = modifiedItem; |
1073 | while ( placeItem ) { | 1072 | while ( placeItem ) { |
1074 | oldconflictItems = placeItem->conflictItems(); | 1073 | oldconflictItems = placeItem->conflictItems(); |
1075 | for ( item=oldconflictItems.first(); item != 0; | 1074 | for ( item=oldconflictItems.first(); item != 0; |
1076 | item=oldconflictItems.next() ) { | 1075 | item=oldconflictItems.next() ) { |
1077 | globalFlagBlockAgendaItemUpdate = 0; | 1076 | globalFlagBlockAgendaItemUpdate = 0; |
1078 | item->repaintMe(); | 1077 | item->repaintMe(); |
1079 | globalFlagBlockAgendaItemUpdate = 1; | 1078 | globalFlagBlockAgendaItemUpdate = 1; |
1080 | item->repaint(false); | 1079 | item->repaint(false); |
1081 | } | 1080 | } |
1082 | placeItem = placeItem->nextMultiItem(); | 1081 | placeItem = placeItem->nextMultiItem(); |
1083 | } | 1082 | } |
1084 | /* | 1083 | /* |
1085 | 1084 | ||
1086 | oldconflictItems = modifiedItem->conflictItems(); | 1085 | oldconflictItems = modifiedItem->conflictItems(); |
1087 | for ( item=oldconflictItems.first(); item != 0; | 1086 | for ( item=oldconflictItems.first(); item != 0; |
1088 | item=oldconflictItems.next() ) { | 1087 | item=oldconflictItems.next() ) { |
1089 | globalFlagBlockAgendaItemUpdate = 0; | 1088 | globalFlagBlockAgendaItemUpdate = 0; |
1090 | item->paintMe(false); | 1089 | item->paintMe(false); |
1091 | globalFlagBlockAgendaItemUpdate = 1; | 1090 | globalFlagBlockAgendaItemUpdate = 1; |
1092 | item->repaint(false); | 1091 | item->repaint(false); |
1093 | } | 1092 | } |
1094 | */ | 1093 | */ |
1095 | 1094 | ||
1096 | 1095 | ||
1097 | } | 1096 | } |
1098 | 1097 | ||
1099 | } | 1098 | } |
1100 | 1099 | ||
1101 | mScrollUpTimer.stop(); | 1100 | mScrollUpTimer.stop(); |
1102 | mScrollDownTimer.stop(); | 1101 | mScrollDownTimer.stop(); |
1103 | setCursor( arrowCursor ); | 1102 | setCursor( arrowCursor ); |
1104 | mActionItem = 0; | 1103 | mActionItem = 0; |
1105 | mActionType = NOP; | 1104 | mActionType = NOP; |
1106 | mItemMoved = 0; | 1105 | mItemMoved = 0; |
1107 | 1106 | ||
1108 | } | 1107 | } |
1109 | 1108 | ||
1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1109 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1111 | { | 1110 | { |
1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1111 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1112 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1113 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1115 | // point = clipper()->mapFromGlobal(point); | 1114 | // point = clipper()->mapFromGlobal(point); |
1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1115 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1117 | 1116 | ||
1118 | int x,y; | 1117 | int x,y; |
1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1118 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1119 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1121 | int gx,gy; | 1120 | int gx,gy; |
1122 | contentsToGrid(x,y,gx,gy); | 1121 | contentsToGrid(x,y,gx,gy); |
1123 | 1122 | ||
1124 | // Change cursor to resize cursor if appropriate | 1123 | // Change cursor to resize cursor if appropriate |
1125 | if (mAllDayMode) { | 1124 | if (mAllDayMode) { |
1126 | int gridDistanceX = (x - gx * mGridSpacingX); | 1125 | int gridDistanceX = (x - gx * mGridSpacingX); |
1127 | if (gridDistanceX < mResizeBorderWidth && | 1126 | if (gridDistanceX < mResizeBorderWidth && |
1128 | moveItem->cellX() == gx) { | 1127 | moveItem->cellX() == gx) { |
1129 | setCursor(sizeHorCursor); | 1128 | setCursor(sizeHorCursor); |
1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1129 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1131 | moveItem->cellXWidth() == gx) { | 1130 | moveItem->cellXWidth() == gx) { |
1132 | setCursor(sizeHorCursor); | 1131 | setCursor(sizeHorCursor); |
1133 | } else { | 1132 | } else { |
1134 | setCursor(arrowCursor); | 1133 | setCursor(arrowCursor); |
1135 | } | 1134 | } |
1136 | } else { | 1135 | } else { |
1137 | int gridDistanceY = (y - gy * mGridSpacingY); | 1136 | int gridDistanceY = (y - gy * mGridSpacingY); |
1138 | if (gridDistanceY < mResizeBorderWidth && | 1137 | if (gridDistanceY < mResizeBorderWidth && |
1139 | moveItem->cellYTop() == gy && | 1138 | moveItem->cellYTop() == gy && |
1140 | !moveItem->firstMultiItem()) { | 1139 | !moveItem->firstMultiItem()) { |
1141 | setCursor(sizeVerCursor); | 1140 | setCursor(sizeVerCursor); |
1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1141 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1143 | moveItem->cellYBottom() == gy && | 1142 | moveItem->cellYBottom() == gy && |
1144 | !moveItem->lastMultiItem()) { | 1143 | !moveItem->lastMultiItem()) { |
1145 | setCursor(sizeVerCursor); | 1144 | setCursor(sizeVerCursor); |
1146 | } else { | 1145 | } else { |
1147 | setCursor(arrowCursor); | 1146 | setCursor(arrowCursor); |
1148 | } | 1147 | } |
1149 | } | 1148 | } |
1150 | } | 1149 | } |
1151 | 1150 | ||
1152 | 1151 | ||
1153 | /* | 1152 | /* |
1154 | Place item in cell and take care that multiple items using the same cell do | 1153 | Place item in cell and take care that multiple items using the same cell do |
1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1154 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1156 | it can get in all cases. | 1155 | it can get in all cases. |
1157 | At the moment the method has a bug: When an item is placed only the sub cell | 1156 | At the moment the method has a bug: When an item is placed only the sub cell |
1158 | widths of the items are changed, which are within the Y region the item to | 1157 | widths of the items are changed, which are within the Y region the item to |
1159 | place spans. When the sub cell width change of one of this items affects a | 1158 | place spans. When the sub cell width change of one of this items affects a |
1160 | cell, where other items are, which do not overlap in Y with the item to place, | 1159 | cell, where other items are, which do not overlap in Y with the item to place, |
1161 | the display gets corrupted, although the corruption looks quite nice. | 1160 | the display gets corrupted, although the corruption looks quite nice. |
1162 | */ | 1161 | */ |
1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1162 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1164 | { | 1163 | { |
1165 | 1164 | ||
1166 | QPtrList<KOAgendaItem> conflictItems; | 1165 | QPtrList<KOAgendaItem> conflictItems; |
1167 | int maxSubCells = 0; | 1166 | int maxSubCells = 0; |
1168 | QIntDict<KOAgendaItem> subCellDict(7); | 1167 | QIntDict<KOAgendaItem> subCellDict(7); |
1169 | 1168 | ||
1170 | KOAgendaItem *item; | 1169 | KOAgendaItem *item; |
1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1170 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1172 | if (item != placeItem) { | 1171 | if (item != placeItem) { |
1173 | if (placeItem->cellX() <= item->cellXWidth() && | 1172 | if (placeItem->cellX() <= item->cellXWidth() && |
1174 | placeItem->cellXWidth() >= item->cellX()) { | 1173 | placeItem->cellXWidth() >= item->cellX()) { |
1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1174 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1176 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1175 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1177 | conflictItems.append(item); | 1176 | conflictItems.append(item); |
1178 | if (item->subCells() > maxSubCells) | 1177 | if (item->subCells() > maxSubCells) |
1179 | maxSubCells = item->subCells(); | 1178 | maxSubCells = item->subCells(); |
1180 | subCellDict.insert(item->subCell(),item); | 1179 | subCellDict.insert(item->subCell(),item); |
1181 | } | 1180 | } |
1182 | } | 1181 | } |
1183 | } | 1182 | } |
1184 | } | 1183 | } |
1185 | 1184 | ||
1186 | if (conflictItems.count() > 0) { | 1185 | if (conflictItems.count() > 0) { |
1187 | // Look for unused sub cell and insert item | 1186 | // Look for unused sub cell and insert item |
1188 | int i; | 1187 | int i; |
1189 | for(i=0;i<maxSubCells;++i) { | 1188 | for(i=0;i<maxSubCells;++i) { |
1190 | if (!subCellDict.find(i)) { | 1189 | if (!subCellDict.find(i)) { |
1191 | placeItem->setSubCell(i); | 1190 | placeItem->setSubCell(i); |
1192 | break; | 1191 | break; |
1193 | } | 1192 | } |
1194 | } | 1193 | } |
1195 | if (i == maxSubCells) { | 1194 | if (i == maxSubCells) { |
1196 | placeItem->setSubCell(maxSubCells); | 1195 | placeItem->setSubCell(maxSubCells); |
1197 | maxSubCells++; // add new item to number of sub cells | 1196 | maxSubCells++; // add new item to number of sub cells |
1198 | } | 1197 | } |
1199 | 1198 | ||
1200 | // Prepare for sub cell geometry adjustment | 1199 | // Prepare for sub cell geometry adjustment |
1201 | int newSubCellWidth; | 1200 | int newSubCellWidth; |
1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1201 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1202 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1204 | conflictItems.append(placeItem); | 1203 | conflictItems.append(placeItem); |
1205 | 1204 | ||
1206 | 1205 | ||
1207 | // Adjust sub cell geometry of all direct conflict items | 1206 | // Adjust sub cell geometry of all direct conflict items |
1208 | for ( item=conflictItems.first(); item != 0; | 1207 | for ( item=conflictItems.first(); item != 0; |
1209 | item=conflictItems.next() ) { | 1208 | item=conflictItems.next() ) { |
1210 | item->setSubCells(maxSubCells); | 1209 | item->setSubCells(maxSubCells); |
1211 | if (mAllDayMode) { | 1210 | if (mAllDayMode) { |
1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1211 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1213 | } else { | 1212 | } else { |
1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1213 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1215 | } | 1214 | } |
1216 | int x,y; | 1215 | int x,y; |
1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1216 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1218 | if (mAllDayMode) { | 1217 | if (mAllDayMode) { |
1219 | y += item->subCell() * newSubCellWidth; | 1218 | y += item->subCell() * newSubCellWidth; |
1220 | } else { | 1219 | } else { |
1221 | x += item->subCell() * newSubCellWidth; | 1220 | x += item->subCell() * newSubCellWidth; |
1222 | } | 1221 | } |
1223 | moveChild(item,x,y); | 1222 | moveChild(item,x,y); |
1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1223 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1225 | //item->updateItem(); | 1224 | //item->updateItem(); |
1226 | } | 1225 | } |
1227 | // Adjust sub cell geometry of all conflict items of all conflict items | 1226 | // Adjust sub cell geometry of all conflict items of all conflict items |
1228 | for ( item=conflictItems.first(); item != 0; | 1227 | for ( item=conflictItems.first(); item != 0; |
1229 | item=conflictItems.next() ) { | 1228 | item=conflictItems.next() ) { |
1230 | if ( placeItem != item ) { | 1229 | if ( placeItem != item ) { |
1231 | KOAgendaItem *item2; | 1230 | KOAgendaItem *item2; |
1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1231 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1233 | for ( item2=conflictItems2.first(); item2 != 0; | 1232 | for ( item2=conflictItems2.first(); item2 != 0; |
1234 | item2=conflictItems2.next() ) { | 1233 | item2=conflictItems2.next() ) { |
1235 | if ( item2->subCells() != maxSubCells) { | 1234 | if ( item2->subCells() != maxSubCells) { |
1236 | item2->setSubCells(maxSubCells); | 1235 | item2->setSubCells(maxSubCells); |
1237 | if (mAllDayMode) { | 1236 | if (mAllDayMode) { |
1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1237 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1239 | } else { | 1238 | } else { |
1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1239 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1241 | } | 1240 | } |
1242 | int x,y; | 1241 | int x,y; |
1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1242 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1244 | if (mAllDayMode) { | 1243 | if (mAllDayMode) { |
1245 | y += item2->subCell() * newSubCellWidth; | 1244 | y += item2->subCell() * newSubCellWidth; |
1246 | } else { | 1245 | } else { |
1247 | x += item2->subCell() * newSubCellWidth; | 1246 | x += item2->subCell() * newSubCellWidth; |
1248 | } | 1247 | } |
1249 | moveChild(item2,x,y); | 1248 | moveChild(item2,x,y); |
1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1249 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1251 | } | 1250 | } |
1252 | } | 1251 | } |
1253 | } | 1252 | } |
1254 | } | 1253 | } |
1255 | } else { | 1254 | } else { |
1256 | placeItem->setSubCell(0); | 1255 | placeItem->setSubCell(0); |
1257 | placeItem->setSubCells(1); | 1256 | placeItem->setSubCells(1); |
1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1257 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1258 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1260 | int x,y; | 1259 | int x,y; |
1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1260 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1262 | moveChild(placeItem,x,y); | 1261 | moveChild(placeItem,x,y); |
1263 | } | 1262 | } |
1264 | placeItem->setConflictItems(conflictItems); | 1263 | placeItem->setConflictItems(conflictItems); |
1265 | // for ( item=conflictItems.first(); item != 0; | 1264 | // for ( item=conflictItems.first(); item != 0; |
1266 | // item=conflictItems.next() ) { | 1265 | // item=conflictItems.next() ) { |
1267 | // //item->updateItem(); | 1266 | // //item->updateItem(); |
1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1267 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1269 | // } | 1268 | // } |
1270 | // placeItem->updateItem(); | 1269 | // placeItem->updateItem(); |
1271 | } | 1270 | } |
1272 | 1271 | ||
1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1272 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1274 | { | 1273 | { |
1275 | if ( globalFlagBlockAgenda ) | 1274 | if ( globalFlagBlockAgenda ) |
1276 | return; | 1275 | return; |
1277 | 1276 | ||
1278 | if ( mInvalidPixmap ) { | 1277 | if ( mInvalidPixmap ) { |
1279 | mInvalidPixmap = false; | 1278 | mInvalidPixmap = false; |
1280 | qDebug("KO: Upsizing Pixmaps "); | 1279 | qDebug("KO: Upsizing Pixmaps "); |
1281 | computeSizes(); | 1280 | computeSizes(); |
1282 | emit updateViewSignal(); | 1281 | emit updateViewSignal(); |
1283 | return; | 1282 | return; |
1284 | } | 1283 | } |
1285 | if ( ! mAllDayMode ) { | 1284 | if ( ! mAllDayMode ) { |
1286 | // currently not working for | 1285 | // currently not working for |
1287 | 1286 | ||
1288 | //qDebug("KOAgenda::drawContents "); | 1287 | //qDebug("KOAgenda::drawContents "); |
1289 | #if 0 | 1288 | #if 0 |
1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1289 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1291 | qDebug("WAU "); | 1290 | qDebug("WAU "); |
1292 | drawContentsToPainter(); | 1291 | drawContentsToPainter(); |
1293 | } | 1292 | } |
1294 | #endif | 1293 | #endif |
1295 | QPaintDevice* pd = p->device(); | 1294 | QPaintDevice* pd = p->device(); |
1296 | p->end(); | 1295 | p->end(); |
1297 | int vx, vy; | 1296 | int vx, vy; |
1298 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1297 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1298 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1300 | mSelectionCellX * mGridSpacingX; | 1299 | mSelectionCellX * mGridSpacingX; |
1301 | contentsToViewport ( cx, cy, vx,vy); | 1300 | contentsToViewport ( cx, cy, vx,vy); |
1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1301 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1303 | 1302 | ||
1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1303 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1304 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1305 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1307 | 1306 | ||
1308 | int vxSel, vySel; | 1307 | int vxSel, vySel; |
1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1308 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1310 | int off = mSelectionHeight; | 1309 | int off = mSelectionHeight; |
1311 | if ( vySel < 0 ) | 1310 | if ( vySel < 0 ) |
1312 | off += vySel; | 1311 | off += vySel; |
1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1312 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1313 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1315 | } else { | 1314 | } else { |
1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1315 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1317 | } | 1316 | } |
1318 | } | 1317 | } |
1319 | if ( mSelectionHeight > 0 ) { | 1318 | if ( mSelectionHeight > 0 ) { |
1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1319 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1320 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1321 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1322 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1323 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1325 | int hei = mSelectionHeight; | 1324 | int hei = mSelectionHeight; |
1326 | int offset = 0; | 1325 | int offset = 0; |
1327 | while ( hei > 0 ) { | 1326 | while ( hei > 0 ) { |
1328 | int p_hei = 5; | 1327 | int p_hei = 5; |
1329 | if ( hei < 5 ) p_hei = hei; | 1328 | if ( hei < 5 ) p_hei = hei; |
1330 | hei -= 5; | 1329 | hei -= 5; |
1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1330 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1332 | offset += 5; | 1331 | offset += 5; |
1333 | } | 1332 | } |
1334 | } | 1333 | } |
1335 | } | 1334 | } |
1336 | p->begin( pd ); | 1335 | p->begin( pd ); |
1337 | } else { | 1336 | } else { |
1338 | #if 0 | 1337 | #if 0 |
1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1338 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1339 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1341 | qDebug("WAUWAU "); | 1340 | qDebug("WAUWAU "); |
1342 | drawContentsToPainter(); | 1341 | drawContentsToPainter(); |
1343 | } | 1342 | } |
1344 | #endif | 1343 | #endif |
1345 | QPaintDevice* pd = p->device(); | 1344 | QPaintDevice* pd = p->device(); |
1346 | p->end(); | 1345 | p->end(); |
1347 | int vx, vy; | 1346 | int vx, vy; |
1348 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1347 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1348 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1350 | mSelectionCellX * mGridSpacingX; | 1349 | mSelectionCellX * mGridSpacingX; |
1351 | contentsToViewport ( cx, cy, vx,vy); | 1350 | contentsToViewport ( cx, cy, vx,vy); |
1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1351 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1352 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1353 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1355 | 1354 | ||
1356 | if ( mSelectionHeight > 0 ) { | 1355 | if ( mSelectionHeight > 0 ) { |
1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1356 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1357 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1358 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1359 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1360 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1362 | int hei = mSelectionHeight; | 1361 | int hei = mSelectionHeight; |
1363 | int offset = 0; | 1362 | int offset = 0; |
1364 | while ( hei > 0 ) { | 1363 | while ( hei > 0 ) { |
1365 | int p_hei = 5; | 1364 | int p_hei = 5; |
1366 | if ( hei < 5 ) p_hei = hei; | 1365 | if ( hei < 5 ) p_hei = hei; |
1367 | hei -= 5; | 1366 | hei -= 5; |
1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1367 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1369 | offset += 5; | 1368 | offset += 5; |
1370 | } | 1369 | } |
1371 | } | 1370 | } |
1372 | } | 1371 | } |
1373 | p->begin( pd ); | 1372 | p->begin( pd ); |
1374 | } | 1373 | } |
1375 | 1374 | ||
1376 | } | 1375 | } |
1377 | 1376 | ||
1378 | void KOAgenda::finishUpdate() | 1377 | void KOAgenda::finishUpdate() |
1379 | { | 1378 | { |
1380 | 1379 | ||
1381 | KOAgendaItem *item; | 1380 | KOAgendaItem *item; |
1382 | globalFlagBlockAgendaItemPaint = 1; | 1381 | globalFlagBlockAgendaItemPaint = 1; |
1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1382 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1383 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1385 | if ( !item->checkLayout() ) { | 1384 | if ( !item->checkLayout() ) { |
1386 | //qDebug(" conflictitem found "); | 1385 | //qDebug(" conflictitem found "); |
1387 | int newSubCellWidth; | 1386 | int newSubCellWidth; |
1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1387 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1388 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1390 | 1389 | ||
1391 | if (mAllDayMode) { | 1390 | if (mAllDayMode) { |
1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1391 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1393 | } else { | 1392 | } else { |
1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1393 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1395 | } | 1394 | } |
1396 | int x,y; | 1395 | int x,y; |
1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1396 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1398 | if (mAllDayMode) { | 1397 | if (mAllDayMode) { |
1399 | y += item->subCell() * newSubCellWidth; | 1398 | y += item->subCell() * newSubCellWidth; |
1400 | } else { | 1399 | } else { |
1401 | x += item->subCell() * newSubCellWidth; | 1400 | x += item->subCell() * newSubCellWidth; |
1402 | } | 1401 | } |
1403 | moveChild(item,x,y); | 1402 | moveChild(item,x,y); |
1404 | } | 1403 | } |
1405 | } | 1404 | } |
1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1405 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1407 | if ( !item->isVisible() ) | 1406 | if ( !item->isVisible() ) |
1408 | item->show(); | 1407 | item->show(); |
1409 | 1408 | ||
1410 | } | 1409 | } |
1411 | globalFlagBlockAgendaItemUpdate = 0; | 1410 | globalFlagBlockAgendaItemUpdate = 0; |
1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1411 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1413 | item->repaintMe( ); | 1412 | item->repaintMe( ); |
1414 | } | 1413 | } |
1415 | globalFlagBlockAgendaItemUpdate = 1; | 1414 | globalFlagBlockAgendaItemUpdate = 1; |
1416 | qApp->processEvents(); | 1415 | qApp->processEvents(); |
1417 | globalFlagBlockAgendaItemPaint = 0; | 1416 | globalFlagBlockAgendaItemPaint = 0; |
1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1417 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1419 | item->repaint( false ); | 1418 | item->repaint( false ); |
1420 | } | 1419 | } |
1421 | marcus_bains(); | 1420 | marcus_bains(); |
1422 | } | 1421 | } |
1423 | 1422 | ||
1424 | /* | 1423 | /* |
1425 | Draw grid in the background of the agenda. | 1424 | Draw grid in the background of the agenda. |
1426 | */ | 1425 | */ |
1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1426 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1428 | { | 1427 | { |
1429 | 1428 | ||
1430 | 1429 | ||
1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1430 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1432 | return; | 1431 | return; |
1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1432 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1434 | return; | 1433 | return; |
1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1434 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1436 | if ( ch < 1 ) | 1435 | if ( ch < 1 ) |
1437 | ch = 1; | 1436 | ch = 1; |
1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1437 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1438 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1440 | } | 1439 | } |
1441 | mCurPixWid = contentsWidth(); | 1440 | mCurPixWid = contentsWidth(); |
1442 | mCurPixHei = ch; | 1441 | mCurPixHei = ch; |
1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1442 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1443 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1444 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1446 | } | 1445 | } |
1447 | mPixPainter.begin( &mPaintPixmap) ; | 1446 | mPixPainter.begin( &mPaintPixmap) ; |
1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1447 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1449 | QPainter * p ; | 1448 | QPainter * p ; |
1450 | if (paint == 0) { | 1449 | if (paint == 0) { |
1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1450 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1452 | p = &mPixPainter; | 1451 | p = &mPixPainter; |
1453 | } | 1452 | } |
1454 | else | 1453 | else |
1455 | p = paint ; | 1454 | p = paint ; |
1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1455 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1457 | 1456 | ||
1458 | //--cx;++cw; | 1457 | //--cx;++cw; |
1459 | int lGridSpacingY = mGridSpacingY*2; | 1458 | int lGridSpacingY = mGridSpacingY*2; |
1460 | int selDay; | 1459 | int selDay; |
1461 | QDate curDate = QDate::currentDate(); | 1460 | QDate curDate = QDate::currentDate(); |
1462 | if ( !backgroundOnly ) { | 1461 | if ( !backgroundOnly ) { |
1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1462 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1464 | { | 1463 | { |
1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1464 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1466 | int x1 = cx; | 1465 | int x1 = cx; |
1467 | int y1 = 0; | 1466 | int y1 = 0; |
1468 | if (y1 < cy) y1 = cy; | 1467 | if (y1 < cy) y1 = cy; |
1469 | int x2 = cx+cw-1; | 1468 | int x2 = cx+cw-1; |
1470 | int y2 = contentsHeight(); | 1469 | int y2 = contentsHeight(); |
1471 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1470 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1472 | if (x2 >= x1 && y2 >= y1) { | 1471 | if (x2 >= x1 && y2 >= y1) { |
1473 | int gxStart = selDay; | 1472 | int gxStart = selDay; |
1474 | int gxEnd = gxStart ; | 1473 | int gxEnd = gxStart ; |
1475 | int xStart = KOGlobals::self()->reverseLayout() ? | 1474 | int xStart = KOGlobals::self()->reverseLayout() ? |
1476 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1475 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1477 | gxStart*mGridSpacingX; | 1476 | gxStart*mGridSpacingX; |
1478 | if (xStart < x1) xStart = x1; | 1477 | if (xStart < x1) xStart = x1; |
1479 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1478 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1480 | (mColumns - gxStart)*mGridSpacingX-1 : | 1479 | (mColumns - gxStart)*mGridSpacingX-1 : |
1481 | (gxStart+1)*mGridSpacingX-1; | 1480 | (gxStart+1)*mGridSpacingX-1; |
1482 | if (xEnd > x2) xEnd = x2; | 1481 | if (xEnd > x2) xEnd = x2; |
1483 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1482 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1483 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1485 | KOPrefs::instance()->mAgendaBgColor.light()); | 1484 | KOPrefs::instance()->mAgendaBgColor.light()); |
1486 | else | 1485 | else |
1487 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1486 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1488 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1487 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1489 | 1488 | ||
1490 | } | 1489 | } |
1491 | } | 1490 | } |
1492 | } | 1491 | } |
1493 | } | 1492 | } |
1494 | // Highlight working hours | 1493 | // Highlight working hours |
1495 | 1494 | ||
1496 | if ( !backgroundOnly ) | 1495 | if ( !backgroundOnly ) |
1497 | if (mWorkingHoursEnable) { | 1496 | if (mWorkingHoursEnable) { |
1498 | int x1 = cx; | 1497 | int x1 = cx; |
1499 | int y1 = mWorkingHoursYTop; | 1498 | int y1 = mWorkingHoursYTop; |
1500 | if (y1 < cy) y1 = cy; | 1499 | if (y1 < cy) y1 = cy; |
1501 | int x2 = cx+cw-1; | 1500 | int x2 = cx+cw-1; |
1502 | // int x2 = mGridSpacingX * 5 - 1; | 1501 | // int x2 = mGridSpacingX * 5 - 1; |
1503 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1502 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1504 | int y2 = mWorkingHoursYBottom; | 1503 | int y2 = mWorkingHoursYBottom; |
1505 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1504 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1506 | 1505 | ||
1507 | if (x2 >= x1 && y2 >= y1) { | 1506 | if (x2 >= x1 && y2 >= y1) { |
1508 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1507 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1509 | int gxStart = x1/mGridSpacingX; | 1508 | int gxStart = x1/mGridSpacingX; |
1510 | int gxEnd = x2/mGridSpacingX; | 1509 | int gxEnd = x2/mGridSpacingX; |
1511 | while(gxStart <= gxEnd) { | 1510 | while(gxStart <= gxEnd) { |
1512 | if (gxStart < int(mHolidayMask->count()) && | 1511 | if (gxStart < int(mHolidayMask->count()) && |
1513 | !mHolidayMask->at(gxStart)) { | 1512 | !mHolidayMask->at(gxStart)) { |
1514 | int xStart = KOGlobals::self()->reverseLayout() ? | 1513 | int xStart = KOGlobals::self()->reverseLayout() ? |
1515 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1514 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1516 | gxStart*mGridSpacingX; | 1515 | gxStart*mGridSpacingX; |
1517 | if (xStart < x1) xStart = x1; | 1516 | if (xStart < x1) xStart = x1; |
1518 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1517 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1519 | (mColumns - gxStart)*mGridSpacingX-1 : | 1518 | (mColumns - gxStart)*mGridSpacingX-1 : |
1520 | (gxStart+1)*mGridSpacingX-1; | 1519 | (gxStart+1)*mGridSpacingX-1; |
1521 | if (xEnd > x2) xEnd = x2; | 1520 | if (xEnd > x2) xEnd = x2; |
1522 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1521 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1523 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1522 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1524 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1523 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1525 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1524 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1526 | else | 1525 | else |
1527 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1526 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1528 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1527 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1529 | } else { | 1528 | } else { |
1530 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1529 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1531 | KOPrefs::instance()->mWorkingHoursColor); | 1530 | KOPrefs::instance()->mWorkingHoursColor); |
1532 | } | 1531 | } |
1533 | } | 1532 | } |
1534 | ++gxStart; | 1533 | ++gxStart; |
1535 | } | 1534 | } |
1536 | } | 1535 | } |
1537 | } | 1536 | } |
1538 | /* | 1537 | /* |
1539 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1538 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1540 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1539 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1541 | mSelectionCellX * mGridSpacingX; | 1540 | mSelectionCellX * mGridSpacingX; |
1542 | 1541 | ||
1543 | // Draw selection | 1542 | // Draw selection |
1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1543 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1544 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1546 | // TODO: paint only part within cx,cy,cw,ch | 1545 | // TODO: paint only part within cx,cy,cw,ch |
1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1546 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1547 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1549 | } | 1548 | } |
1550 | */ | 1549 | */ |
1551 | // Draw vertical lines of grid | 1550 | // Draw vertical lines of grid |
1552 | 1551 | ||
1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1552 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1554 | if ( mGridSpacingX > 0 ) { | 1553 | if ( mGridSpacingX > 0 ) { |
1555 | while (x < cx + cw) { | 1554 | while (x < cx + cw) { |
1556 | p->drawLine(x,cy,x,cy+ch); | 1555 | p->drawLine(x,cy,x,cy+ch); |
1557 | x+=mGridSpacingX; | 1556 | x+=mGridSpacingX; |
1558 | } | 1557 | } |
1559 | } | 1558 | } |
1560 | // Draw horizontal lines of grid | 1559 | // Draw horizontal lines of grid |
1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1560 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1562 | if ( lGridSpacingY > 0 ) { | 1561 | if ( lGridSpacingY > 0 ) { |
1563 | while (y < cy + ch) { | 1562 | while (y < cy + ch) { |
1564 | p->setPen( SolidLine ); | 1563 | p->setPen( SolidLine ); |
1565 | p->drawLine(cx,y,cx+cw,y); | 1564 | p->drawLine(cx,y,cx+cw,y); |
1566 | y+=lGridSpacingY; | 1565 | y+=lGridSpacingY; |
1567 | p->setPen( DotLine ); | 1566 | p->setPen( DotLine ); |
1568 | p->drawLine(cx,y,cx+cw,y); | 1567 | p->drawLine(cx,y,cx+cw,y); |
1569 | y+=lGridSpacingY; | 1568 | y+=lGridSpacingY; |
1570 | } | 1569 | } |
1571 | p->setPen( SolidLine ); | 1570 | p->setPen( SolidLine ); |
1572 | } | 1571 | } |
1573 | mPixPainter.end() ; | 1572 | mPixPainter.end() ; |
1574 | } | 1573 | } |
1575 | 1574 | ||
1576 | /* | 1575 | /* |
1577 | Convert srcollview contents coordinates to agenda grid coordinates. | 1576 | Convert srcollview contents coordinates to agenda grid coordinates. |
1578 | */ | 1577 | */ |
1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1578 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1580 | { | 1579 | { |
1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1580 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1582 | x/mGridSpacingX; | 1581 | x/mGridSpacingX; |
1583 | gy = y/mGridSpacingY; | 1582 | gy = y/mGridSpacingY; |
1584 | } | 1583 | } |
1585 | 1584 | ||
1586 | /* | 1585 | /* |
1587 | Convert agenda grid coordinates to scrollview contents coordinates. | 1586 | Convert agenda grid coordinates to scrollview contents coordinates. |
1588 | */ | 1587 | */ |
1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1588 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1590 | { | 1589 | { |
1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1590 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1592 | gx*mGridSpacingX; | 1591 | gx*mGridSpacingX; |
1593 | y = gy*mGridSpacingY; | 1592 | y = gy*mGridSpacingY; |
1594 | } | 1593 | } |
1595 | 1594 | ||
1596 | 1595 | ||
1597 | /* | 1596 | /* |
1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1597 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1599 | the grid. | 1598 | the grid. |
1600 | */ | 1599 | */ |
1601 | int KOAgenda::timeToY(const QTime &time) | 1600 | int KOAgenda::timeToY(const QTime &time) |
1602 | { | 1601 | { |
1603 | int minutesPerCell = 24 * 60 / mRows; | 1602 | int minutesPerCell = 24 * 60 / mRows; |
1604 | int timeMinutes = time.hour() * 60 + time.minute(); | 1603 | int timeMinutes = time.hour() * 60 + time.minute(); |
1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1604 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1606 | return Y; | 1605 | return Y; |
1607 | } | 1606 | } |
1608 | 1607 | ||
1609 | 1608 | ||
1610 | /* | 1609 | /* |
1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1610 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1612 | fit into the grid. | 1611 | fit into the grid. |
1613 | */ | 1612 | */ |
1614 | QTime KOAgenda::gyToTime(int gy) | 1613 | QTime KOAgenda::gyToTime(int gy) |
1615 | { | 1614 | { |
1616 | 1615 | ||
1617 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1616 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1618 | 1617 | ||
1619 | int timeSeconds = secondsPerCell * gy; | 1618 | int timeSeconds = secondsPerCell * gy; |
1620 | 1619 | ||
1621 | QTime time( 0, 0, 0 ); | 1620 | QTime time( 0, 0, 0 ); |
1622 | if ( timeSeconds < 24 * 60 * 60 ) { | 1621 | if ( timeSeconds < 24 * 60 * 60 ) { |
1623 | time = time.addSecs(timeSeconds); | 1622 | time = time.addSecs(timeSeconds); |
1624 | } else { | 1623 | } else { |
1625 | time.setHMS( 23, 59, 59 ); | 1624 | time.setHMS( 23, 59, 59 ); |
1626 | } | 1625 | } |
1627 | 1626 | ||
1628 | return time; | 1627 | return time; |
1629 | } | 1628 | } |
1630 | 1629 | ||
1631 | void KOAgenda::setStartHour(int startHour) | 1630 | void KOAgenda::setStartHour(int startHour) |
1632 | { | 1631 | { |
1633 | int startCell = startHour * mRows / 24; | 1632 | int startCell = startHour * mRows / 24; |
1634 | setContentsPos(0,startCell * gridSpacingY()); | 1633 | setContentsPos(0,startCell * gridSpacingY()); |
1635 | } | 1634 | } |
1636 | void KOAgenda::hideUnused() | 1635 | void KOAgenda::hideUnused() |
1637 | { | 1636 | { |
1638 | // experimental only | 1637 | // experimental only |
1639 | // return; | 1638 | // return; |
1640 | KOAgendaItem *item; | 1639 | KOAgendaItem *item; |
1641 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1640 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1642 | item->hide(); | 1641 | item->hide(); |
1643 | } | 1642 | } |
1644 | } | 1643 | } |
1645 | 1644 | ||
1646 | 1645 | ||
1647 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1646 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1648 | { | 1647 | { |
1649 | 1648 | ||
1650 | KOAgendaItem *fi; | 1649 | KOAgendaItem *fi; |
1651 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1650 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1652 | if ( fi->incidence() == event ) { | 1651 | if ( fi->incidence() == event ) { |
1653 | mUnusedItems.remove(); | 1652 | mUnusedItems.remove(); |
1654 | fi->init( event, qd ); | 1653 | fi->init( event, qd ); |
1655 | return fi; | 1654 | return fi; |
1656 | } | 1655 | } |
1657 | } | 1656 | } |
1658 | fi=mUnusedItems.first(); | 1657 | fi=mUnusedItems.first(); |
1659 | if ( fi ) { | 1658 | if ( fi ) { |
1660 | mUnusedItems.remove(); | 1659 | mUnusedItems.remove(); |
1661 | fi->init( event, qd ); | 1660 | fi->init( event, qd ); |
1662 | return fi; | 1661 | return fi; |
1663 | } | 1662 | } |
1664 | // qDebug("new KOAgendaItem "); | 1663 | // qDebug("new KOAgendaItem "); |
1665 | 1664 | ||
1666 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1665 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1667 | agendaItem->installEventFilter(this); | 1666 | agendaItem->installEventFilter(this); |
1668 | addChild(agendaItem,0,0); | 1667 | addChild(agendaItem,0,0); |
1669 | return agendaItem; | 1668 | return agendaItem; |
1670 | } | 1669 | } |
1671 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1670 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1672 | { | 1671 | { |
1673 | KOAgendaItem *item; | 1672 | KOAgendaItem *item; |
1674 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1673 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1675 | if ( item->incidence() == todo ) { | 1674 | if ( item->incidence() == todo ) { |
1676 | mItems.remove(); | 1675 | mItems.remove(); |
1677 | return item; | 1676 | return item; |
1678 | } | 1677 | } |
1679 | } | 1678 | } |
1680 | return 0; | 1679 | return 0; |
1681 | } | 1680 | } |
1682 | 1681 | ||
1683 | 1682 | ||
1684 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1683 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1685 | { | 1684 | { |
1686 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1685 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1687 | KOAgendaItem *item; | 1686 | KOAgendaItem *item; |
1688 | item = getItemForTodo ( todo ); | 1687 | item = getItemForTodo ( todo ); |
1689 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1688 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1690 | if ( item ) { | 1689 | if ( item ) { |
1691 | blockSignals( true ); | 1690 | blockSignals( true ); |
1692 | //qDebug("item found "); | 1691 | //qDebug("item found "); |
1693 | item->hide(); | 1692 | item->hide(); |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 86e1bd9..a87e6fc 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1626 +1,1629 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | 31 | ||
32 | #include <qinputdialog.h> | 32 | #include <qinputdialog.h> |
33 | 33 | ||
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kdateedit.h> | 39 | #include <kdateedit.h> |
40 | #include "ktimeedit.h" | 40 | #include "ktimeedit.h" |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | #include <libkcal/icaldrag.h> | 44 | #include <libkcal/icaldrag.h> |
45 | #include <libkcal/vcaldrag.h> | 45 | #include <libkcal/vcaldrag.h> |
46 | #include <libkcal/calfilter.h> | 46 | #include <libkcal/calfilter.h> |
47 | #include <libkcal/dndfactory.h> | 47 | #include <libkcal/dndfactory.h> |
48 | #include <libkcal/calendarresources.h> | 48 | #include <libkcal/calendarresources.h> |
49 | #include <libkcal/resourcecalendar.h> | 49 | #include <libkcal/resourcecalendar.h> |
50 | #include <kresources/resourceselectdialog.h> | 50 | #include <kresources/resourceselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | #ifndef KORG_NOPRINTER | 57 | #ifndef KORG_NOPRINTER |
58 | #include "calprinter.h" | 58 | #include "calprinter.h" |
59 | #endif | 59 | #endif |
60 | #include "docprefs.h" | 60 | #include "docprefs.h" |
61 | 61 | ||
62 | #include "kotodoview.h" | 62 | #include "kotodoview.h" |
63 | using namespace KOrg; | 63 | using namespace KOrg; |
64 | 64 | ||
65 | 65 | ||
66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : | 66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : |
67 | QDialog( parent, name, true ) | 67 | QDialog( parent, name, true ) |
68 | { | 68 | { |
69 | mStopAll = true; | 69 | mStopAll = true; |
70 | setCaption( i18n("Start todo") ); | 70 | setCaption( i18n("Start todo") ); |
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | 71 | QVBoxLayout* lay = new QVBoxLayout( this ); |
72 | lay->setSpacing( 3 ); | 72 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 73 | lay->setMargin( 3 ); |
74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); | 74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); |
75 | lay->addWidget( lab ); | 75 | lay->addWidget( lab ); |
76 | lab->setAlignment( AlignCenter ); | 76 | lab->setAlignment( AlignCenter ); |
77 | 77 | ||
78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); | 78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); |
79 | lay->addWidget( ok ); | 79 | lay->addWidget( ok ); |
80 | ok->setDefault( true ); | 80 | ok->setDefault( true ); |
81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); | 81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); |
82 | lay->addWidget( start ); | 82 | lay->addWidget( start ); |
83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); | 83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); |
84 | lay->addWidget( cancel ); | 84 | lay->addWidget( cancel ); |
85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); | 86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); |
87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
88 | resize( sizeHint() ); | 88 | resize( sizeHint() ); |
89 | 89 | ||
90 | } | 90 | } |
91 | void KOStartTodoPrefs::doStop() | 91 | void KOStartTodoPrefs::doStop() |
92 | { | 92 | { |
93 | mStopAll = false; | 93 | mStopAll = false; |
94 | accept(); | 94 | accept(); |
95 | } | 95 | } |
96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : | 96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : |
97 | QDialog( parent, name, true ) | 97 | QDialog( parent, name, true ) |
98 | { | 98 | { |
99 | mTodo = todo; | 99 | mTodo = todo; |
100 | setCaption( i18n("Stop todo") ); | 100 | setCaption( i18n("Stop todo") ); |
101 | QVBoxLayout* lay = new QVBoxLayout( this ); | 101 | QVBoxLayout* lay = new QVBoxLayout( this ); |
102 | lay->setSpacing( 3 ); | 102 | lay->setSpacing( 3 ); |
103 | lay->setMargin( 3 ); | 103 | lay->setMargin( 3 ); |
104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); | 104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); |
105 | lay->addWidget( lab ); | 105 | lay->addWidget( lab ); |
106 | lab->setAlignment( AlignHCenter ); | 106 | lab->setAlignment( AlignHCenter ); |
107 | lab = new QLabel( i18n("Additional Comment:"), this ); | 107 | lab = new QLabel( i18n("Additional Comment:"), this ); |
108 | lay->addWidget( lab ); | 108 | lay->addWidget( lab ); |
109 | mComment = new QLineEdit( this ); | 109 | mComment = new QLineEdit( this ); |
110 | lay->addWidget( mComment ); | 110 | lay->addWidget( mComment ); |
111 | QHBox * start = new QHBox ( this ); | 111 | QHBox * start = new QHBox ( this ); |
112 | lay->addWidget( start ); | 112 | lay->addWidget( start ); |
113 | lab = new QLabel( i18n("Start:"), start ); | 113 | lab = new QLabel( i18n("Start:"), start ); |
114 | QHBox * end = new QHBox ( this ); | 114 | QHBox * end = new QHBox ( this ); |
115 | lay->addWidget( end ); | 115 | lay->addWidget( end ); |
116 | lab = new QLabel( i18n("End:"), end ); | 116 | lab = new QLabel( i18n("End:"), end ); |
117 | sde = new KDateEdit( start ); | 117 | sde = new KDateEdit( start ); |
118 | ste = new KOTimeEdit( start ); | 118 | ste = new KOTimeEdit( start ); |
119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); | 119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); |
120 | ede = new KDateEdit( end ); | 120 | ede = new KDateEdit( end ); |
121 | ete = new KOTimeEdit(end ); | 121 | ete = new KOTimeEdit(end ); |
122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); | 122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); |
123 | sde->setDate( mTodo->runStart().date() ); | 123 | sde->setDate( mTodo->runStart().date() ); |
124 | ste->setTime( mTodo->runStart().time() ); | 124 | ste->setTime( mTodo->runStart().time() ); |
125 | ede->setDate( QDate::currentDate()); | 125 | ede->setDate( QDate::currentDate()); |
126 | ete->setTime( QTime::currentTime() ); | 126 | ete->setTime( QTime::currentTime() ); |
127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
128 | lay->addWidget( ok ); | 128 | lay->addWidget( ok ); |
129 | ok->setDefault( true ); | 129 | ok->setDefault( true ); |
130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
131 | lay->addWidget( cancel ); | 131 | lay->addWidget( cancel ); |
132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
134 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 134 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
136 | lay->addWidget( ok ); | 136 | lay->addWidget( ok ); |
137 | if (QApplication::desktop()->width() < 320 ) | 137 | if (QApplication::desktop()->width() < 320 ) |
138 | resize( 240, sizeHint().height() ); | 138 | resize( 240, sizeHint().height() ); |
139 | else | 139 | else |
140 | resize( 320, sizeHint().height() ); | 140 | resize( 320, sizeHint().height() ); |
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | void KOStopTodoPrefs::accept() | 144 | void KOStopTodoPrefs::accept() |
145 | { | 145 | { |
146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
148 | if ( start > stop ) { | 148 | if ( start > stop ) { |
149 | KMessageBox::sorry(this, | 149 | KMessageBox::sorry(this, |
150 | i18n("The start time is\nafter the end time!"), | 150 | i18n("The start time is\nafter the end time!"), |
151 | i18n("Time mismatch!")); | 151 | i18n("Time mismatch!")); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
155 | QDialog::accept(); | 155 | QDialog::accept(); |
156 | } | 156 | } |
157 | void KOStopTodoPrefs::doNotSave() | 157 | void KOStopTodoPrefs::doNotSave() |
158 | { | 158 | { |
159 | int result = KMessageBox::warningContinueCancel(this, | 159 | int result = KMessageBox::warningContinueCancel(this, |
160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); | 160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); |
161 | if (result != KMessageBox::Continue) return; | 161 | if (result != KMessageBox::Continue) return; |
162 | mTodo->stopRunning(); | 162 | mTodo->stopRunning(); |
163 | QDialog::accept(); | 163 | QDialog::accept(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | class KOTodoViewWhatsThis :public QWhatsThis | 167 | class KOTodoViewWhatsThis :public QWhatsThis |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
171 | 171 | ||
172 | protected: | 172 | protected: |
173 | virtual QString text( const QPoint& p) | 173 | virtual QString text( const QPoint& p) |
174 | { | 174 | { |
175 | return _view->getWhatsThisText(p) ; | 175 | return _view->getWhatsThisText(p) ; |
176 | } | 176 | } |
177 | private: | 177 | private: |
178 | QWidget* _wid; | 178 | QWidget* _wid; |
179 | KOTodoView * _view; | 179 | KOTodoView * _view; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
183 | const char *name) : | 183 | const char *name) : |
184 | KListView(parent,name) | 184 | KListView(parent,name) |
185 | { | 185 | { |
186 | mName = QString ( name ); | 186 | mName = QString ( name ); |
187 | mCalendar = calendar; | 187 | mCalendar = calendar; |
188 | #ifndef DESKTOP_VERSION | 188 | #ifndef DESKTOP_VERSION |
189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
190 | #endif | 190 | #endif |
191 | mOldCurrent = 0; | 191 | mOldCurrent = 0; |
192 | mMousePressed = false; | 192 | mMousePressed = false; |
193 | 193 | ||
194 | setAcceptDrops(true); | 194 | setAcceptDrops(true); |
195 | viewport()->setAcceptDrops(true); | 195 | viewport()->setAcceptDrops(true); |
196 | int size = 16; | 196 | int size = 16; |
197 | if (qApp->desktop()->width() < 300 ) | 197 | if (qApp->desktop()->width() < 300 ) |
198 | size = 12; | 198 | size = 12; |
199 | setTreeStepSize( size + 6 ); | 199 | setTreeStepSize( size + 6 ); |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 208 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 209 | e->ignore(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | mOldCurrent = currentItem(); | 213 | mOldCurrent = currentItem(); |
214 | #endif | 214 | #endif |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 219 | { |
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 222 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 224 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | e->accept(); | 229 | e->accept(); |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | 232 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 234 | { |
235 | #ifndef KORG_NODND | 235 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 237 | ||
238 | setCurrentItem(mOldCurrent); | 238 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 239 | setSelected(mOldCurrent,true); |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 244 | { |
245 | #ifndef KORG_NODND | 245 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 247 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 249 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 250 | e->ignore(); |
251 | return; | 251 | return; |
252 | } | 252 | } |
253 | 253 | ||
254 | DndFactory factory( mCalendar ); | 254 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 255 | Todo *todo = factory.createDropTodo(e); |
256 | 256 | ||
257 | if (todo) { | 257 | if (todo) { |
258 | e->acceptAction(); | 258 | e->acceptAction(); |
259 | 259 | ||
260 | KOTodoViewItem *destination = | 260 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 262 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 263 | if (destination) destinationEvent = destination->todo(); |
264 | 264 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 265 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 266 | ||
267 | if(existingTodo) { | 267 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 268 | Incidence *to = destinationEvent; |
269 | while(to) { | 269 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 270 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 271 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 272 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 273 | i18n("Drop Todo")); |
274 | delete todo; | 274 | delete todo; |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | to = to->relatedTo(); | 277 | to = to->relatedTo(); |
278 | } | 278 | } |
279 | internalDrop = true; | 279 | internalDrop = true; |
280 | if ( destinationEvent ) | 280 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 281 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 282 | else |
283 | unparentTodoSignal(existingTodo); | 283 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 284 | delete todo; |
285 | } else { | 285 | } else { |
286 | mCalendar->addTodo(todo); | 286 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 287 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 288 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 289 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else { | 292 | else { |
293 | QString text; | 293 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 294 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 297 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 298 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 300 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 301 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 302 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 303 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 304 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else { | 308 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 310 | e->ignore(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | } | 314 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 315 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 316 | { |
317 | QListView::wheelEvent (e); | 317 | QListView::wheelEvent (e); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 321 | { |
322 | 322 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 323 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 324 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 325 | bool rootClicked = true; |
326 | if (i) { | 326 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 327 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 328 | // try to start a drag! |
329 | int X = p.x(); | 329 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 331 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 333 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 334 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 335 | rootClicked = false; |
336 | } | 336 | } |
337 | } else { | 337 | } else { |
338 | rootClicked = false; | 338 | rootClicked = false; |
339 | } | 339 | } |
340 | #ifndef KORG_NODND | 340 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 341 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 342 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 343 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 344 | mMousePressed = true; |
345 | } else { | 345 | } else { |
346 | mMousePressed = false; | 346 | mMousePressed = false; |
347 | } | 347 | } |
348 | #endif | 348 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 351 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 352 | QListView::contentsMousePressEvent(e); |
353 | #else | 353 | #else |
354 | QListView::contentsMousePressEvent(e); | 354 | QListView::contentsMousePressEvent(e); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 357 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 358 | { |
359 | emit paintNeeded(); | 359 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 360 | QListView::paintEvent( e); |
361 | } | 361 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 363 | { |
364 | 364 | ||
365 | #ifndef KORG_NODND | 365 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 366 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 368 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 369 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 371 | if (item) { |
372 | DndFactory factory( mCalendar ); | 372 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 373 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 374 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 375 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 376 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 377 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 378 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 380 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 381 | } else |
382 | qDebug("Dnd: Internal move "); | 382 | qDebug("Dnd: Internal move "); |
383 | 383 | ||
384 | } else { | 384 | } else { |
385 | if ( !internalDrop ) { | 385 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 386 | qDebug("Dnd: External Copy"); |
387 | } else | 387 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 388 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | #endif | 392 | #endif |
393 | } | 393 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 395 | { |
396 | if ( !e->isAutoRepeat() ) { | 396 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 397 | mFlagKeyPressed = false; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 403 | { |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 405 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 407 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | if (! e->isAutoRepeat() ) | 410 | if (! e->isAutoRepeat() ) |
411 | mFlagKeyPressed = true; | 411 | mFlagKeyPressed = true; |
412 | QListViewItem* cn; | 412 | QListViewItem* cn; |
413 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 413 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
414 | cn = currentItem(); | 414 | cn = currentItem(); |
415 | if ( cn ) { | 415 | if ( cn ) { |
416 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 416 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
417 | if ( ci ){ | 417 | if ( ci ){ |
418 | if ( e->state() == ShiftButton ) | 418 | if ( e->state() == ShiftButton ) |
419 | ci->setOn( false ); | 419 | ci->setOn( false ); |
420 | else | 420 | else |
421 | ci->setOn( true ); | 421 | ci->setOn( true ); |
422 | cn = cn->itemBelow(); | 422 | cn = cn->itemBelow(); |
423 | if ( cn ) { | 423 | if ( cn ) { |
424 | setCurrentItem ( cn ); | 424 | setCurrentItem ( cn ); |
425 | ensureItemVisible ( cn ); | 425 | ensureItemVisible ( cn ); |
426 | } | 426 | } |
427 | 427 | ||
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | return; | 431 | return; |
432 | } | 432 | } |
433 | 433 | ||
434 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 434 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
435 | switch ( e->key() ) { | 435 | switch ( e->key() ) { |
436 | case Qt::Key_Down: | 436 | case Qt::Key_Down: |
437 | case Qt::Key_Up: | 437 | case Qt::Key_Up: |
438 | QListView::keyPressEvent ( e ); | 438 | QListView::keyPressEvent ( e ); |
439 | break; | 439 | break; |
440 | case Qt::Key_Left: | 440 | case Qt::Key_Left: |
441 | case Qt::Key_Right: | 441 | case Qt::Key_Right: |
442 | QListView::keyPressEvent ( e ); | 442 | QListView::keyPressEvent ( e ); |
443 | e->accept(); | 443 | e->accept(); |
444 | return; | 444 | return; |
445 | break; | 445 | break; |
446 | default: | 446 | default: |
447 | e->ignore(); | 447 | e->ignore(); |
448 | break; | 448 | break; |
449 | } | 449 | } |
450 | return; | 450 | return; |
451 | } | 451 | } |
452 | e->ignore(); | 452 | e->ignore(); |
453 | } | 453 | } |
454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
455 | { | 455 | { |
456 | QListView::contentsMouseReleaseEvent(e); | 456 | QListView::contentsMouseReleaseEvent(e); |
457 | mMousePressed = false; | 457 | mMousePressed = false; |
458 | } | 458 | } |
459 | 459 | ||
460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | if (!e) return; | 462 | if (!e) return; |
463 | 463 | ||
464 | QPoint vp = contentsToViewport(e->pos()); | 464 | QPoint vp = contentsToViewport(e->pos()); |
465 | 465 | ||
466 | QListViewItem *item = itemAt(vp); | 466 | QListViewItem *item = itemAt(vp); |
467 | 467 | ||
468 | emit double_Clicked(item); | 468 | emit double_Clicked(item); |
469 | if (!item) return; | 469 | if (!item) return; |
470 | 470 | ||
471 | emit doubleClicked(item,vp,0); | 471 | emit doubleClicked(item,vp,0); |
472 | } | 472 | } |
473 | 473 | ||
474 | ///////////////////////////////////////////////////////////////////////////// | 474 | ///////////////////////////////////////////////////////////////////////////// |
475 | 475 | ||
476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
477 | QLineEdit(parent) | 477 | QLineEdit(parent) |
478 | { | 478 | { |
479 | setText(i18n("Click to add a new Todo")); | 479 | setText(i18n("Click to add a new Todo")); |
480 | } | 480 | } |
481 | 481 | ||
482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
483 | { | 483 | { |
484 | if ( text()==i18n("Click to add a new Todo") ) | 484 | if ( text()==i18n("Click to add a new Todo") ) |
485 | setText(""); | 485 | setText(""); |
486 | QLineEdit::focusInEvent(ev); | 486 | QLineEdit::focusInEvent(ev); |
487 | } | 487 | } |
488 | 488 | ||
489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
490 | { | 490 | { |
491 | setText(i18n("Click to add a new Todo")); | 491 | setText(i18n("Click to add a new Todo")); |
492 | QLineEdit::focusOutEvent(ev); | 492 | QLineEdit::focusOutEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | ///////////////////////////////////////////////////////////////////////////// | 495 | ///////////////////////////////////////////////////////////////////////////// |
496 | 496 | ||
497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
498 | KOrg::BaseView(calendar,parent,name) | 498 | KOrg::BaseView(calendar,parent,name) |
499 | { | 499 | { |
500 | mCategoryPopupMenu = 0; | 500 | mCategoryPopupMenu = 0; |
501 | mPendingUpdateBeforeRepaint = false; | 501 | mPendingUpdateBeforeRepaint = false; |
502 | isFlatDisplay = false; | 502 | isFlatDisplay = false; |
503 | mNavigator = 0; | 503 | mNavigator = 0; |
504 | QBoxLayout *topLayout = new QVBoxLayout(this); | 504 | QBoxLayout *topLayout = new QVBoxLayout(this); |
505 | mName = QString ( name ); | 505 | mName = QString ( name ); |
506 | mBlockUpdate = false; | 506 | mBlockUpdate = false; |
507 | mQuickAdd = new KOQuickTodo(this); | 507 | mQuickAdd = new KOQuickTodo(this); |
508 | topLayout->addWidget(mQuickAdd); | 508 | topLayout->addWidget(mQuickAdd); |
509 | 509 | ||
510 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 510 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
511 | 511 | ||
512 | mTodoListView = new KOTodoListView(calendar,this, name ); | 512 | mTodoListView = new KOTodoListView(calendar,this, name ); |
513 | topLayout->addWidget(mTodoListView); | 513 | topLayout->addWidget(mTodoListView); |
514 | //mTodoListView->header()->setMaximumHeight(30); | 514 | //mTodoListView->header()->setMaximumHeight(30); |
515 | mTodoListView->setRootIsDecorated(true); | 515 | mTodoListView->setRootIsDecorated(true); |
516 | mTodoListView->setAllColumnsShowFocus(true); | 516 | mTodoListView->setAllColumnsShowFocus(true); |
517 | 517 | ||
518 | mTodoListView->setShowSortIndicator(true); | 518 | mTodoListView->setShowSortIndicator(true); |
519 | 519 | ||
520 | mTodoListView->addColumn(i18n("Todo")); | 520 | mTodoListView->addColumn(i18n("Todo")); |
521 | mTodoListView->addColumn(i18n("Prio")); | 521 | mTodoListView->addColumn(i18n("Prio")); |
522 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 522 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
523 | mTodoListView->addColumn(i18n("Complete")); | 523 | mTodoListView->addColumn(i18n("Complete")); |
524 | mTodoListView->setColumnAlignment(2,AlignCenter); | 524 | mTodoListView->setColumnAlignment(2,AlignCenter); |
525 | 525 | ||
526 | mTodoListView->addColumn(i18n("Due Date")); | 526 | mTodoListView->addColumn(i18n("Due Date")); |
527 | mTodoListView->setColumnAlignment(3,AlignLeft); | 527 | mTodoListView->setColumnAlignment(3,AlignLeft); |
528 | mTodoListView->addColumn(i18n("Due Time")); | 528 | mTodoListView->addColumn(i18n("Due Time")); |
529 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 529 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
530 | 530 | ||
531 | mTodoListView->addColumn(i18n("Start Date")); | 531 | mTodoListView->addColumn(i18n("Start Date")); |
532 | mTodoListView->setColumnAlignment(5,AlignLeft); | 532 | mTodoListView->setColumnAlignment(5,AlignLeft); |
533 | mTodoListView->addColumn(i18n("Start Time")); | 533 | mTodoListView->addColumn(i18n("Start Time")); |
534 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 534 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
535 | 535 | ||
536 | mTodoListView->addColumn(i18n("Cancelled")); | 536 | mTodoListView->addColumn(i18n("Cancelled")); |
537 | mTodoListView->addColumn(i18n("Categories")); | 537 | mTodoListView->addColumn(i18n("Categories")); |
538 | mTodoListView->addColumn(i18n("Calendar")); | 538 | mTodoListView->addColumn(i18n("Calendar")); |
539 | #if 0 | 539 | #if 0 |
540 | mTodoListView->addColumn(i18n("Sort Id")); | 540 | mTodoListView->addColumn(i18n("Sort Id")); |
541 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 541 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
542 | #endif | 542 | #endif |
543 | 543 | ||
544 | mTodoListView->setMinimumHeight( 60 ); | 544 | mTodoListView->setMinimumHeight( 60 ); |
545 | mTodoListView->setItemsRenameable( true ); | 545 | mTodoListView->setItemsRenameable( true ); |
546 | mTodoListView->setRenameable( 0 ); | 546 | mTodoListView->setRenameable( 0 ); |
547 | mTodoListView->setColumnWidth( 0, 120 ); | 547 | mTodoListView->setColumnWidth( 0, 120 ); |
548 | int iii = 0; | 548 | int iii = 0; |
549 | for ( iii = 0; iii< 10 ; ++iii ) | 549 | for ( iii = 0; iii< 10 ; ++iii ) |
550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
551 | 551 | ||
552 | 552 | ||
553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
554 | 554 | ||
555 | mPriorityPopupMenu = new QPopupMenu(this); | 555 | mPriorityPopupMenu = new QPopupMenu(this); |
556 | for (int i = 1; i <= 5; i++) { | 556 | for (int i = 1; i <= 5; i++) { |
557 | QString label = QString ("%1").arg (i); | 557 | QString label = QString ("%1").arg (i); |
558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
559 | } | 559 | } |
560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
561 | 561 | ||
562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
563 | for (int i = 0; i <= 100; i+=20) { | 563 | for (int i = 0; i <= 100; i+=20) { |
564 | QString label = QString ("%1 %").arg (i); | 564 | QString label = QString ("%1 %").arg (i); |
565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
566 | } | 566 | } |
567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
568 | 568 | ||
569 | 569 | ||
570 | mCategoryPopupMenu = new QPopupMenu (this); | 570 | mCategoryPopupMenu = new QPopupMenu (this); |
571 | mCategoryPopupMenu->setCheckable (true); | 571 | mCategoryPopupMenu->setCheckable (true); |
572 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 572 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
573 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 573 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
574 | 574 | ||
575 | mCalPopupMenu = new QPopupMenu (this); | 575 | mCalPopupMenu = new QPopupMenu (this); |
576 | mCalPopupMenu->setCheckable (true); | 576 | mCalPopupMenu->setCheckable (true); |
577 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 577 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
578 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 578 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
579 | 579 | ||
580 | 580 | ||
581 | 581 | ||
582 | 582 | ||
583 | mItemPopupMenu = new QPopupMenu(this); | 583 | mItemPopupMenu = new QPopupMenu(this); |
584 | mItemPopupMenu->insertItem(i18n("Show"), this, | 584 | mItemPopupMenu->insertItem(i18n("Show"), this, |
585 | SLOT (showTodo())); | 585 | SLOT (showTodo())); |
586 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 586 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
587 | SLOT (editTodo())); | 587 | SLOT (editTodo())); |
588 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 588 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
589 | SLOT (deleteTodo())); | 589 | SLOT (deleteTodo())); |
590 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 590 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
591 | SLOT (cloneTodo())); | 591 | SLOT (cloneTodo())); |
592 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 592 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
593 | SLOT (moveTodo())); | 593 | SLOT (moveTodo())); |
594 | #ifndef DESKTOP_VERSION | 594 | #ifndef DESKTOP_VERSION |
595 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 595 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
596 | SLOT (beamTodo())); | 596 | SLOT (beamTodo())); |
597 | #endif | 597 | #endif |
598 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 598 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
599 | SLOT (cancelTodo())); | 599 | SLOT (cancelTodo())); |
600 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 600 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
601 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 601 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
602 | mItemPopupMenu->insertSeparator(); | 602 | mItemPopupMenu->insertSeparator(); |
603 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 603 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
604 | SLOT (toggleRunningItem())); | 604 | SLOT (toggleRunningItem())); |
605 | mItemPopupMenu->insertSeparator(); | 605 | mItemPopupMenu->insertSeparator(); |
606 | /* | 606 | /* |
607 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 607 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
608 | SLOT (newTodo())); | 608 | SLOT (newTodo())); |
609 | */ | 609 | */ |
610 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 610 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
611 | SLOT (newSubTodo())); | 611 | SLOT (newSubTodo())); |
612 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 612 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
613 | SLOT (unparentTodo()),0,21); | 613 | SLOT (unparentTodo()),0,21); |
614 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 614 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
615 | SLOT (reparentTodo()),0,22); | 615 | SLOT (reparentTodo()),0,22); |
616 | mItemPopupMenu->insertSeparator(); | 616 | mItemPopupMenu->insertSeparator(); |
617 | #if 0 | 617 | #if 0 |
618 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 618 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
619 | this, SLOT( purgeCompleted() ) ); | 619 | this, SLOT( purgeCompleted() ) ); |
620 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 620 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
621 | this, SLOT( toggleCompleted() ),0, 33 ); | 621 | this, SLOT( toggleCompleted() ),0, 33 ); |
622 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 622 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
623 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 623 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
624 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 624 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
625 | this, SLOT( toggleRunning() ),0, 35 ); | 625 | this, SLOT( toggleRunning() ),0, 35 ); |
626 | 626 | ||
627 | #endif | 627 | #endif |
628 | mPopupMenu = new QPopupMenu(this); | 628 | mPopupMenu = new QPopupMenu(this); |
629 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 629 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
630 | SLOT (newTodo()),0,1); | 630 | SLOT (newTodo()),0,1); |
631 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 631 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
632 | this, SLOT(purgeCompleted()),0,2); | 632 | this, SLOT(purgeCompleted()),0,2); |
633 | mPopupMenu->insertItem(i18n("Show Completed"), | 633 | mPopupMenu->insertItem(i18n("Show Completed"), |
634 | this, SLOT( toggleCompleted() ),0,3 ); | 634 | this, SLOT( toggleCompleted() ),0,3 ); |
635 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 635 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
636 | this, SLOT( toggleRunning() ),0,5 ); | 636 | this, SLOT( toggleRunning() ),0,5 ); |
637 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 637 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
638 | this, SLOT( setAllOpen() ),0,6 ); | 638 | this, SLOT( setAllOpen() ),0,6 ); |
639 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 639 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
640 | this, SLOT( setAllClose() ),0,7 ); | 640 | this, SLOT( setAllClose() ),0,7 ); |
641 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 641 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
642 | this, SLOT( setAllFlat() ),0,8 ); | 642 | this, SLOT( setAllFlat() ),0,8 ); |
643 | mPopupMenu->insertSeparator(); | 643 | mPopupMenu->insertSeparator(); |
644 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 644 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
645 | this, SLOT( toggleQuickTodo() ),0,4 ); | 645 | this, SLOT( toggleQuickTodo() ),0,4 ); |
646 | mDocPrefs = new DocPrefs( name ); | 646 | mDocPrefs = new DocPrefs( name ); |
647 | 647 | ||
648 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 648 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
649 | mPopupMenu->setCheckable( true ); | 649 | mPopupMenu->setCheckable( true ); |
650 | mItemPopupMenu->setCheckable( true ); | 650 | mItemPopupMenu->setCheckable( true ); |
651 | 651 | ||
652 | 652 | ||
653 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 653 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
654 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 654 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
655 | 655 | ||
656 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 656 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
657 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 657 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
658 | 658 | ||
659 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 659 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
660 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 660 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
661 | 661 | ||
662 | 662 | ||
663 | // Double clicking conflicts with opening/closing the subtree | 663 | // Double clicking conflicts with opening/closing the subtree |
664 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 664 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
665 | SLOT( editItem( QListViewItem *) ) ); | 665 | SLOT( editItem( QListViewItem *) ) ); |
666 | /* | 666 | /* |
667 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 667 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
668 | const QPoint &,int ) ), | 668 | const QPoint &,int ) ), |
669 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 669 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
670 | */ | 670 | */ |
671 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 671 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
672 | const QPoint &,int ) ), | 672 | const QPoint &,int ) ), |
673 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 673 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
674 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 674 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
675 | SLOT( itemClicked( QListViewItem * ) ) ); | 675 | SLOT( itemClicked( QListViewItem * ) ) ); |
676 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 676 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
677 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 677 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
678 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 678 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
679 | SLOT( updateView() ) ); | 679 | SLOT( updateView() ) ); |
680 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 680 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
681 | SLOT( todoModified(Todo *, int) ) ); | 681 | SLOT( todoModified(Todo *, int) ) ); |
682 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 682 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
683 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 683 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
684 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 684 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
685 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 685 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
686 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 686 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
687 | SLOT( paintNeeded()) ); | 687 | SLOT( paintNeeded()) ); |
688 | 688 | ||
689 | #if 0 | 689 | #if 0 |
690 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 690 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
691 | SLOT(selectionChanged(QListViewItem *))); | 691 | SLOT(selectionChanged(QListViewItem *))); |
692 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 692 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
693 | SLOT(selectionChanged(QListViewItem *))); | 693 | SLOT(selectionChanged(QListViewItem *))); |
694 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 694 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
695 | SLOT(selectionChanged(QListViewItem *))); | 695 | SLOT(selectionChanged(QListViewItem *))); |
696 | #endif | 696 | #endif |
697 | 697 | ||
698 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 698 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
699 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 699 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
700 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 700 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
701 | 701 | ||
702 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 702 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
703 | SLOT( processSelectionChange() ) ); | 703 | SLOT( processSelectionChange() ) ); |
704 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 704 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
705 | SLOT( addQuickTodo() ) ); | 705 | SLOT( addQuickTodo() ) ); |
706 | 706 | ||
707 | } | 707 | } |
708 | 708 | ||
709 | KOTodoView::~KOTodoView() | 709 | KOTodoView::~KOTodoView() |
710 | { | 710 | { |
711 | 711 | ||
712 | #if QT_VERSION >= 0x030000 | 712 | #if QT_VERSION >= 0x030000 |
713 | 713 | ||
714 | #else | 714 | #else |
715 | delete mKOTodoViewWhatsThis; | 715 | delete mKOTodoViewWhatsThis; |
716 | #endif | 716 | #endif |
717 | 717 | ||
718 | delete mDocPrefs; | 718 | delete mDocPrefs; |
719 | } | 719 | } |
720 | QString KOTodoView::getWhatsThisText(QPoint p) | 720 | QString KOTodoView::getWhatsThisText(QPoint p) |
721 | { | 721 | { |
722 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 722 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
723 | if ( item ) | 723 | if ( item ) |
724 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 724 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
725 | KOPrefs::instance()->mWTshowDetails, | 725 | KOPrefs::instance()->mWTshowDetails, |
726 | KOPrefs::instance()->mWTshowCreated, | 726 | KOPrefs::instance()->mWTshowCreated, |
727 | KOPrefs::instance()->mWTshowChanged); | 727 | KOPrefs::instance()->mWTshowChanged); |
728 | return i18n("That is the todo view" ); | 728 | return i18n("That is the todo view" ); |
729 | 729 | ||
730 | } | 730 | } |
731 | 731 | ||
732 | void KOTodoView::jumpToDate () | 732 | void KOTodoView::jumpToDate () |
733 | { | 733 | { |
734 | // if (mActiveItem) { | 734 | // if (mActiveItem) { |
735 | // mActiveItem->todo()); | 735 | // mActiveItem->todo()); |
736 | // if ( mActiveItem->todo()->hasDueDate() ) | 736 | // if ( mActiveItem->todo()->hasDueDate() ) |
737 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 737 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
738 | } | 738 | } |
739 | void KOTodoView::paintNeeded() | 739 | void KOTodoView::paintNeeded() |
740 | { | 740 | { |
741 | if ( mPendingUpdateBeforeRepaint ) { | 741 | if ( mPendingUpdateBeforeRepaint ) { |
742 | updateView(); | 742 | updateView(); |
743 | mPendingUpdateBeforeRepaint = false; | 743 | mPendingUpdateBeforeRepaint = false; |
744 | } | 744 | } |
745 | } | 745 | } |
746 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 746 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
747 | { | 747 | { |
748 | if ( mPendingUpdateBeforeRepaint ) { | 748 | if ( mPendingUpdateBeforeRepaint ) { |
749 | updateView(); | 749 | updateView(); |
750 | mPendingUpdateBeforeRepaint = false; | 750 | mPendingUpdateBeforeRepaint = false; |
751 | } | 751 | } |
752 | KOrg::BaseView::paintEvent( pevent); | 752 | KOrg::BaseView::paintEvent( pevent); |
753 | } | 753 | } |
754 | 754 | ||
755 | void KOTodoView::updateView() | 755 | void KOTodoView::updateView() |
756 | { | 756 | { |
757 | pendingSubtodo = 0; | 757 | pendingSubtodo = 0; |
758 | if ( mBlockUpdate ) { | 758 | if ( mBlockUpdate ) { |
759 | return; | 759 | return; |
760 | } | 760 | } |
761 | if ( !isVisible() ) { | 761 | if ( !isVisible() ) { |
762 | mPendingUpdateBeforeRepaint = true; | 762 | mPendingUpdateBeforeRepaint = true; |
763 | return; | 763 | return; |
764 | } | 764 | } |
765 | //qDebug("KOTodoView::updateView() %x", this); | 765 | //qDebug("KOTodoView::updateView() %x", this); |
766 | if ( isFlatDisplay ) { | 766 | if ( isFlatDisplay ) { |
767 | displayAllFlat(); | 767 | displayAllFlat(); |
768 | return; | 768 | return; |
769 | } | 769 | } |
770 | storeCurrentItem(); | 770 | storeCurrentItem(); |
771 | //qDebug("update "); | 771 | //qDebug("update "); |
772 | // kdDebug() << "KOTodoView::updateView()" << endl; | 772 | // kdDebug() << "KOTodoView::updateView()" << endl; |
773 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 773 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
774 | 774 | ||
775 | 775 | ||
776 | mTodoListView->clear(); | 776 | mTodoListView->clear(); |
777 | if ( mName == "todolistsmall" ) { | 777 | if ( mName == "todolistsmall" ) { |
778 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 778 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
779 | int ps = fo.pointSize() -2; | 779 | int ps = fo.pointSize() -2; |
780 | if ( ps > 12 ) | 780 | if ( ps > 12 ) |
781 | ps -= 2; | 781 | ps -= 2; |
782 | fo.setPointSize( ps ); | 782 | fo.setPointSize( ps ); |
783 | } | 783 | } |
784 | } | 784 | } |
785 | 785 | ||
786 | mTodoListView->setFont( fo ); | 786 | mTodoListView->setFont( fo ); |
787 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 787 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
788 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 788 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
789 | QPtrList<Todo> todoList = calendar()->todos(); | 789 | QPtrList<Todo> todoList = calendar()->todos(); |
790 | 790 | ||
791 | /* | 791 | /* |
792 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 792 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
793 | Event *t; | 793 | Event *t; |
794 | for(t = todoList.first(); t; t = todoList.next()) { | 794 | for(t = todoList.first(); t; t = todoList.next()) { |
795 | kdDebug() << " " << t->getSummary() << endl; | 795 | kdDebug() << " " << t->getSummary() << endl; |
796 | 796 | ||
797 | if (t->getRelatedTo()) { | 797 | if (t->getRelatedTo()) { |
798 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 798 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
799 | } | 799 | } |
800 | 800 | ||
801 | QPtrList<Event> l = t->getRelations(); | 801 | QPtrList<Event> l = t->getRelations(); |
802 | Event *c; | 802 | Event *c; |
803 | for(c=l.first();c;c=l.next()) { | 803 | for(c=l.first();c;c=l.next()) { |
804 | kdDebug() << " - relation: " << c->getSummary() << endl; | 804 | kdDebug() << " - relation: " << c->getSummary() << endl; |
805 | } | 805 | } |
806 | } | 806 | } |
807 | */ | 807 | */ |
808 | 808 | ||
809 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 809 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
810 | // specific order of events. That means that we have to generate parent items | 810 | // specific order of events. That means that we have to generate parent items |
811 | // recursively for proper hierarchical display of Todos. | 811 | // recursively for proper hierarchical display of Todos. |
812 | mTodoMap.clear(); | 812 | mTodoMap.clear(); |
813 | Todo *todo; | 813 | Todo *todo; |
814 | todo = todoList.first();// todo; todo = todoList.next()) { | 814 | todo = todoList.first();// todo; todo = todoList.next()) { |
815 | while ( todo ) { | 815 | while ( todo ) { |
816 | bool next = true; | 816 | bool next = true; |
817 | // qDebug("todo %s ", todo->summary().latin1()); | 817 | // qDebug("todo %s ", todo->summary().latin1()); |
818 | Incidence *incidence = todo->relatedTo(); | 818 | Incidence *incidence = todo->relatedTo(); |
819 | while ( incidence ) { | 819 | while ( incidence ) { |
820 | if ( incidence->typeID() == todoID ) { | 820 | if ( incidence->typeID() == todoID ) { |
821 | //qDebug("related %s ",incidence->summary().latin1() ); | 821 | //qDebug("related %s ",incidence->summary().latin1() ); |
822 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 822 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
823 | //qDebug("related not found "); | 823 | //qDebug("related not found "); |
824 | todoList.remove( ); | 824 | todoList.remove( ); |
825 | todo = todoList.current(); | 825 | todo = todoList.current(); |
826 | next = false; | 826 | next = false; |
827 | incidence = 0; | 827 | incidence = 0; |
828 | 828 | ||
829 | } else { | 829 | } else { |
830 | //qDebug("related found "); | 830 | //qDebug("related found "); |
831 | incidence = incidence->relatedTo(); | 831 | incidence = incidence->relatedTo(); |
832 | } | 832 | } |
833 | } else | 833 | } else |
834 | incidence = 0; | 834 | incidence = 0; |
835 | } | 835 | } |
836 | if ( next ) | 836 | if ( next ) |
837 | todo = todoList.next(); | 837 | todo = todoList.next(); |
838 | } | 838 | } |
839 | 839 | ||
840 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 840 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
841 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 841 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
842 | { | 842 | { |
843 | insertTodoItem(todo); | 843 | insertTodoItem(todo); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | // Restore opened/closed state | 846 | // Restore opened/closed state |
847 | mTodoListView->blockSignals( true ); | 847 | mTodoListView->blockSignals( true ); |
848 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 848 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
849 | mTodoListView->blockSignals( false ); | 849 | mTodoListView->blockSignals( false ); |
850 | resetCurrentItem(); | 850 | resetCurrentItem(); |
851 | } | 851 | } |
852 | 852 | ||
853 | void KOTodoView::storeCurrentItem() | 853 | void KOTodoView::storeCurrentItem() |
854 | { | 854 | { |
855 | mCurItem = 0; | 855 | mCurItem = 0; |
856 | mCurItemRootParent = 0; | 856 | mCurItemRootParent = 0; |
857 | mCurItemParent = 0; | 857 | mCurItemParent = 0; |
858 | mCurItemAbove = 0; | 858 | mCurItemAbove = 0; |
859 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 859 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
860 | if (mActiveItem) { | 860 | if (mActiveItem) { |
861 | mCurItem = mActiveItem->todo(); | 861 | mCurItem = mActiveItem->todo(); |
862 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 862 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
863 | if ( activeItemAbove ) | 863 | if ( activeItemAbove ) |
864 | mCurItemAbove = activeItemAbove->todo(); | 864 | mCurItemAbove = activeItemAbove->todo(); |
865 | mCurItemRootParent = mCurItem; | 865 | mCurItemRootParent = mCurItem; |
866 | mCurItemParent = mCurItemRootParent->relatedTo(); | 866 | mCurItemParent = mCurItemRootParent->relatedTo(); |
867 | while ( mCurItemRootParent->relatedTo() != 0 ) | 867 | while ( mCurItemRootParent->relatedTo() != 0 ) |
868 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 868 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
869 | } | 869 | } |
870 | mActiveItem = 0; | 870 | mActiveItem = 0; |
871 | } | 871 | } |
872 | 872 | ||
873 | void KOTodoView::resetCurrentItem() | 873 | void KOTodoView::resetCurrentItem() |
874 | { | 874 | { |
875 | //mTodoListView->setFocus(); | 875 | //mTodoListView->setFocus(); |
876 | KOTodoViewItem* foundItem = 0; | 876 | KOTodoViewItem* foundItem = 0; |
877 | KOTodoViewItem* foundItemRoot = 0; | 877 | KOTodoViewItem* foundItemRoot = 0; |
878 | KOTodoViewItem* foundItemParent = 0; | 878 | KOTodoViewItem* foundItemParent = 0; |
879 | KOTodoViewItem* foundItemAbove = 0; | 879 | KOTodoViewItem* foundItemAbove = 0; |
880 | if ( mTodoListView->firstChild () ) { | 880 | if ( mTodoListView->firstChild () ) { |
881 | if ( mCurItem ) { | 881 | if ( mCurItem ) { |
882 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 882 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
883 | while ( item ) { | 883 | while ( item ) { |
884 | if ( item->todo() == mCurItem ) { | 884 | if ( item->todo() == mCurItem ) { |
885 | foundItem = item; | 885 | foundItem = item; |
886 | break; | 886 | break; |
887 | } else if ( item->todo() == mCurItemAbove ) { | 887 | } else if ( item->todo() == mCurItemAbove ) { |
888 | foundItemAbove = item; | 888 | foundItemAbove = item; |
889 | 889 | ||
890 | } | 890 | } |
891 | if ( item->todo() == mCurItemRootParent ) { | 891 | if ( item->todo() == mCurItemRootParent ) { |
892 | foundItemRoot = item; | 892 | foundItemRoot = item; |
893 | } | 893 | } |
894 | if ( item->todo() == mCurItemParent ) { | 894 | if ( item->todo() == mCurItemParent ) { |
895 | foundItemParent = item; | 895 | foundItemParent = item; |
896 | } | 896 | } |
897 | item = (KOTodoViewItem*)item->itemBelow(); | 897 | item = (KOTodoViewItem*)item->itemBelow(); |
898 | } | 898 | } |
899 | if ( ! foundItem ) { | 899 | if ( ! foundItem ) { |
900 | if ( foundItemParent ) { | 900 | if ( foundItemParent ) { |
901 | foundItem = foundItemParent; | 901 | foundItem = foundItemParent; |
902 | } else { | 902 | } else { |
903 | if ( foundItemRoot ) | 903 | if ( foundItemRoot ) |
904 | foundItem = foundItemRoot; | 904 | foundItem = foundItemRoot; |
905 | else | 905 | else |
906 | foundItem = foundItemAbove; | 906 | foundItem = foundItemAbove; |
907 | } | 907 | } |
908 | } | 908 | } |
909 | } | 909 | } |
910 | if ( foundItem ) { | 910 | if ( foundItem ) { |
911 | mTodoListView->setSelected ( foundItem, true ); | 911 | mTodoListView->setSelected ( foundItem, true ); |
912 | mTodoListView->setCurrentItem( foundItem ); | 912 | mTodoListView->setCurrentItem( foundItem ); |
913 | mTodoListView->ensureItemVisible( foundItem ); | 913 | mTodoListView->ensureItemVisible( foundItem ); |
914 | } else { | 914 | } else { |
915 | if ( mTodoListView->firstChild () ) { | 915 | if ( mTodoListView->firstChild () ) { |
916 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 916 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
917 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 917 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
918 | } | 918 | } |
919 | } | 919 | } |
920 | } | 920 | } |
921 | processSelectionChange(); | 921 | processSelectionChange(); |
922 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 922 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
923 | } | 923 | } |
924 | void KOTodoView::resetFocusToList() | 924 | void KOTodoView::resetFocusToList() |
925 | { | 925 | { |
926 | topLevelWidget()->setActiveWindow(); | 926 | topLevelWidget()->setActiveWindow(); |
927 | mTodoListView->setFocus(); | 927 | mTodoListView->setFocus(); |
928 | } | 928 | } |
929 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 929 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
930 | bool KOTodoView::checkTodo( Todo * todo ) | 930 | bool KOTodoView::checkTodo( Todo * todo ) |
931 | { | 931 | { |
932 | 932 | ||
933 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 933 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
934 | return false; | 934 | return false; |
935 | if ( !todo->isCompleted() ) { | 935 | if ( !todo->isCompleted() ) { |
936 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 936 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
937 | return true; | 937 | return true; |
938 | } | 938 | } |
939 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 939 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
940 | if ( todo->hasStartDate() ) | 940 | if ( todo->hasStartDate() ) |
941 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 941 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
942 | return false; | 942 | return false; |
943 | if ( todo->hasDueDate() ) | 943 | if ( todo->hasDueDate() ) |
944 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 944 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
945 | return false; | 945 | return false; |
946 | } | 946 | } |
947 | return true; | 947 | return true; |
948 | } | 948 | } |
949 | 949 | ||
950 | void KOTodoView::restoreItemState( QListViewItem *item ) | 950 | void KOTodoView::restoreItemState( QListViewItem *item ) |
951 | { | 951 | { |
952 | pendingSubtodo = 0; | 952 | pendingSubtodo = 0; |
953 | while( item ) { | 953 | while( item ) { |
954 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 954 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
955 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 955 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
956 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 956 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
957 | item = item->nextSibling(); | 957 | item = item->nextSibling(); |
958 | } | 958 | } |
959 | } | 959 | } |
960 | 960 | ||
961 | 961 | ||
962 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 962 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
963 | KOTodoView::insertTodoItem(Todo *todo) | 963 | KOTodoView::insertTodoItem(Todo *todo) |
964 | { | 964 | { |
965 | 965 | ||
966 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 966 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
967 | // TODO: Check, if dynmaic cast is necessary | 967 | // TODO: Check, if dynmaic cast is necessary |
968 | 968 | ||
969 | pendingSubtodo = 0; | 969 | pendingSubtodo = 0; |
970 | Incidence *incidence = todo->relatedTo(); | 970 | Incidence *incidence = todo->relatedTo(); |
971 | while ( incidence && !incidence->calEnabled() ) | 971 | while ( incidence && !incidence->calEnabled() ) |
972 | incidence = incidence->relatedTo(); | 972 | incidence = incidence->relatedTo(); |
973 | if (incidence && incidence->typeID() == todoID ) { | 973 | if (incidence && incidence->typeID() == todoID ) { |
974 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 974 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
975 | 975 | ||
976 | // kdDebug() << " has Related" << endl; | 976 | // kdDebug() << " has Related" << endl; |
977 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 977 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
978 | itemIterator = mTodoMap.find(relatedTodo); | 978 | itemIterator = mTodoMap.find(relatedTodo); |
979 | if (itemIterator == mTodoMap.end()) { | 979 | if (itemIterator == mTodoMap.end()) { |
980 | // kdDebug() << " related not yet in list" << endl; | 980 | // kdDebug() << " related not yet in list" << endl; |
981 | itemIterator = insertTodoItem (relatedTodo); | 981 | itemIterator = insertTodoItem (relatedTodo); |
982 | } | 982 | } |
983 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 983 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
984 | // and one into the map. Sure finding is more easy but why? -zecke | 984 | // and one into the map. Sure finding is more easy but why? -zecke |
985 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 985 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
986 | return mTodoMap.insert(todo,todoItem); | 986 | return mTodoMap.insert(todo,todoItem); |
987 | } else { | 987 | } else { |
988 | // kdDebug() << " no Related" << endl; | 988 | // kdDebug() << " no Related" << endl; |
989 | // see above -zecke | 989 | // see above -zecke |
990 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 990 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
991 | return mTodoMap.insert(todo,todoItem); | 991 | return mTodoMap.insert(todo,todoItem); |
992 | } | 992 | } |
993 | } | 993 | } |
994 | 994 | ||
995 | 995 | ||
996 | void KOTodoView::updateConfig() | 996 | void KOTodoView::updateConfig() |
997 | { | 997 | { |
998 | updateView(); | 998 | updateView(); |
999 | mTodoListView->repaintContents(); | 999 | mTodoListView->repaintContents(); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1002 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1003 | { | 1003 | { |
1004 | QPtrList<Incidence> selected; | 1004 | QPtrList<Incidence> selected; |
1005 | 1005 | ||
1006 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1006 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1007 | // if (!item) item = mActiveItem; | 1007 | // if (!item) item = mActiveItem; |
1008 | if (item) selected.append(item->todo()); | 1008 | if (item) selected.append(item->todo()); |
1009 | 1009 | ||
1010 | return selected; | 1010 | return selected; |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | QPtrList<Todo> KOTodoView::selectedTodos() | 1013 | QPtrList<Todo> KOTodoView::selectedTodos() |
1014 | { | 1014 | { |
1015 | QPtrList<Todo> selected; | 1015 | QPtrList<Todo> selected; |
1016 | 1016 | ||
1017 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1017 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1018 | // if (!item) item = mActiveItem; | 1018 | // if (!item) item = mActiveItem; |
1019 | if (item) selected.append(item->todo()); | 1019 | if (item) selected.append(item->todo()); |
1020 | 1020 | ||
1021 | return selected; | 1021 | return selected; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | void KOTodoView::changeEventDisplay(Event *, int) | 1024 | void KOTodoView::changeEventDisplay(Event *, int) |
1025 | { | 1025 | { |
1026 | updateView(); | 1026 | updateView(); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void KOTodoView::showDates(const QDate &, const QDate &) | 1029 | void KOTodoView::showDates(const QDate &, const QDate &) |
1030 | { | 1030 | { |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | void KOTodoView::showEvents(QPtrList<Event>) | 1033 | void KOTodoView::showEvents(QPtrList<Event>) |
1034 | { | 1034 | { |
1035 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1035 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1038 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1039 | const QDate &td) | 1039 | const QDate &td) |
1040 | { | 1040 | { |
1041 | #ifndef KORG_NOPRINTER | 1041 | #ifndef KORG_NOPRINTER |
1042 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1042 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1043 | #endif | 1043 | #endif |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | void KOTodoView::editItem(QListViewItem *item ) | 1046 | void KOTodoView::editItem(QListViewItem *item ) |
1047 | { | 1047 | { |
1048 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1048 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1051 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1052 | { | 1052 | { |
1053 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1053 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1056 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1057 | { | 1057 | { |
1058 | pendingSubtodo = 0; | 1058 | pendingSubtodo = 0; |
1059 | mActiveItem = (KOTodoViewItem *)item; | 1059 | mActiveItem = (KOTodoViewItem *)item; |
1060 | if (item) { | 1060 | if (item) { |
1061 | switch (column){ | 1061 | switch (column){ |
1062 | case 1: | 1062 | case 1: |
1063 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1063 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1064 | case 2: | 1064 | case 2: |
1065 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1065 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1066 | case 3: | 1066 | case 3: |
1067 | moveTodo(); | 1067 | moveTodo(); |
1068 | break; | 1068 | break; |
1069 | case 8: | 1069 | case 8: |
1070 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1070 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1071 | case 9: | 1071 | case 9: |
1072 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1072 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1073 | default: | 1073 | default: |
1074 | mItemPopupMenu->popup(QCursor::pos()); | 1074 | mItemPopupMenu->popup(QCursor::pos()); |
1075 | } | 1075 | } |
1076 | } else mPopupMenu->popup(QCursor::pos()); | 1076 | } else mPopupMenu->popup(QCursor::pos()); |
1077 | } | 1077 | } |
1078 | void KOTodoView::newTodo() | 1078 | void KOTodoView::newTodo() |
1079 | { | 1079 | { |
1080 | emit newTodoSignal(); | 1080 | emit newTodoSignal(); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | void KOTodoView::newSubTodo() | 1083 | void KOTodoView::newSubTodo() |
1084 | { | 1084 | { |
1085 | if (mActiveItem) { | 1085 | if (mActiveItem) { |
1086 | emit newSubTodoSignal(mActiveItem->todo()); | 1086 | emit newSubTodoSignal(mActiveItem->todo()); |
1087 | } | 1087 | } |
1088 | } | 1088 | } |
1089 | void KOTodoView::unparentTodo() | 1089 | void KOTodoView::unparentTodo() |
1090 | { | 1090 | { |
1091 | if (mActiveItem) { | 1091 | if (mActiveItem) { |
1092 | emit unparentTodoSignal(mActiveItem->todo()); | 1092 | emit unparentTodoSignal(mActiveItem->todo()); |
1093 | } | 1093 | } |
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | void KOTodoView::reparentTodo() | 1096 | void KOTodoView::reparentTodo() |
1097 | { | 1097 | { |
1098 | if (mActiveItem) { | 1098 | if (mActiveItem) { |
1099 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1099 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1100 | pendingSubtodo = mActiveItem; | 1100 | pendingSubtodo = mActiveItem; |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | void KOTodoView::editTodo() | 1103 | void KOTodoView::editTodo() |
1104 | { | 1104 | { |
1105 | if (mActiveItem) { | 1105 | if (mActiveItem) { |
1106 | emit editTodoSignal(mActiveItem->todo()); | 1106 | emit editTodoSignal(mActiveItem->todo()); |
1107 | } | 1107 | } |
1108 | } | 1108 | } |
1109 | void KOTodoView::cloneTodo() | 1109 | void KOTodoView::cloneTodo() |
1110 | { | 1110 | { |
1111 | if (mActiveItem) { | 1111 | if (mActiveItem) { |
1112 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1112 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | void KOTodoView::cancelTodo() | 1115 | void KOTodoView::cancelTodo() |
1116 | { | 1116 | { |
1117 | if (mActiveItem) { | 1117 | if (mActiveItem) { |
1118 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1118 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | void KOTodoView::moveTodo() | 1121 | void KOTodoView::moveTodo() |
1122 | { | 1122 | { |
1123 | if (mActiveItem) { | 1123 | if (mActiveItem) { |
1124 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1124 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | void KOTodoView::beamTodo() | 1127 | void KOTodoView::beamTodo() |
1128 | { | 1128 | { |
1129 | if (mActiveItem) { | 1129 | if (mActiveItem) { |
1130 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1130 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | 1134 | ||
1135 | void KOTodoView::showTodo() | 1135 | void KOTodoView::showTodo() |
1136 | { | 1136 | { |
1137 | if (mActiveItem) { | 1137 | if (mActiveItem) { |
1138 | emit showTodoSignal(mActiveItem->todo()); | 1138 | emit showTodoSignal(mActiveItem->todo()); |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | void KOTodoView::deleteTodo() | 1142 | void KOTodoView::deleteTodo() |
1143 | { | 1143 | { |
1144 | if (mActiveItem) { | 1144 | if (mActiveItem) { |
1145 | emit deleteTodoSignal(mActiveItem->todo()); | 1145 | emit deleteTodoSignal(mActiveItem->todo()); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | void KOTodoView::setNewPriority(int index) | 1149 | void KOTodoView::setNewPriority(int index) |
1150 | { | 1150 | { |
1151 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1151 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1152 | mActiveItem->todo()->setPriority(mPriority[index]); | 1152 | mActiveItem->todo()->setPriority(mPriority[index]); |
1153 | mActiveItem->construct(); | 1153 | mActiveItem->construct(); |
1154 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1154 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1155 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1155 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1156 | } | 1156 | } |
1157 | processSelectionChange(); | ||
1157 | } | 1158 | } |
1158 | 1159 | ||
1159 | void KOTodoView::setNewPercentage(int index) | 1160 | void KOTodoView::setNewPercentage(int index) |
1160 | { | 1161 | { |
1161 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1162 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1162 | 1163 | ||
1163 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1164 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1164 | mActiveItem->setOn( true ); | 1165 | mActiveItem->setOn( true ); |
1166 | processSelectionChange(); | ||
1165 | return; | 1167 | return; |
1166 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1168 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1167 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1169 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1168 | if ( par && par->isOn() ) | 1170 | if ( par && par->isOn() ) |
1169 | par->setOn( false ); | 1171 | par->setOn( false ); |
1170 | } | 1172 | } |
1171 | if (mPercentage[index] == 100) { | 1173 | if (mPercentage[index] == 100) { |
1172 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1174 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1173 | } else { | 1175 | } else { |
1174 | mActiveItem->todo()->setCompleted(false); | 1176 | mActiveItem->todo()->setCompleted(false); |
1175 | } | 1177 | } |
1176 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1178 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1177 | mActiveItem->construct(); | 1179 | mActiveItem->construct(); |
1178 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1180 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1179 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1181 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1180 | } | 1182 | } |
1183 | processSelectionChange(); | ||
1181 | } | 1184 | } |
1182 | 1185 | ||
1183 | void KOTodoView::fillCategories () | 1186 | void KOTodoView::fillCategories () |
1184 | { | 1187 | { |
1185 | mCategoryPopupMenu->clear(); | 1188 | mCategoryPopupMenu->clear(); |
1186 | if ( ! mActiveItem ) return; | 1189 | if ( ! mActiveItem ) return; |
1187 | QStringList checkedCategories = mActiveItem->todo()->categories (); | 1190 | QStringList checkedCategories = mActiveItem->todo()->categories (); |
1188 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1191 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1189 | it != KOPrefs::instance()->mCustomCategories.end (); | 1192 | it != KOPrefs::instance()->mCustomCategories.end (); |
1190 | ++it) { | 1193 | ++it) { |
1191 | int index = mCategoryPopupMenu->insertItem (*it); | 1194 | int index = mCategoryPopupMenu->insertItem (*it); |
1192 | mCategory[index] = *it; | 1195 | mCategory[index] = *it; |
1193 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1196 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1194 | } | 1197 | } |
1195 | } | 1198 | } |
1196 | void KOTodoView::fillCal () | 1199 | void KOTodoView::fillCal () |
1197 | { | 1200 | { |
1198 | mCalPopupMenu->clear(); | 1201 | mCalPopupMenu->clear(); |
1199 | if (!mActiveItem) return; | 1202 | if (!mActiveItem) return; |
1200 | bool readO = mActiveItem->todo()->isReadOnly(); | 1203 | bool readO = mActiveItem->todo()->isReadOnly(); |
1201 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 1204 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
1202 | while ( kkf ) { | 1205 | while ( kkf ) { |
1203 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | 1206 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); |
1204 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | 1207 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) |
1205 | mCalPopupMenu->setItemEnabled( index, false ); | 1208 | mCalPopupMenu->setItemEnabled( index, false ); |
1206 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | 1209 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); |
1207 | kkf = KOPrefs::instance()->mCalendars.next(); | 1210 | kkf = KOPrefs::instance()->mCalendars.next(); |
1208 | } | 1211 | } |
1209 | } | 1212 | } |
1210 | void KOTodoView::changedCal (int index ) | 1213 | void KOTodoView::changedCal (int index ) |
1211 | { | 1214 | { |
1212 | if (!mActiveItem) return; | 1215 | if (!mActiveItem) return; |
1213 | mActiveItem->todo()->setCalID( index ); | 1216 | mActiveItem->todo()->setCalID( index ); |
1214 | mActiveItem->construct(); | 1217 | mActiveItem->construct(); |
1215 | } | 1218 | } |
1216 | void KOTodoView::changedCategories(int index) | 1219 | void KOTodoView::changedCategories(int index) |
1217 | { | 1220 | { |
1218 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1221 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1219 | QStringList categories = mActiveItem->todo()->categories (); | 1222 | QStringList categories = mActiveItem->todo()->categories (); |
1220 | QString colcat = categories.first(); | 1223 | QString colcat = categories.first(); |
1221 | if (categories.find (mCategory[index]) != categories.end ()) | 1224 | if (categories.find (mCategory[index]) != categories.end ()) |
1222 | categories.remove (mCategory[index]); | 1225 | categories.remove (mCategory[index]); |
1223 | else | 1226 | else |
1224 | categories.insert (categories.end(), mCategory[index]); | 1227 | categories.insert (categories.end(), mCategory[index]); |
1225 | categories.sort (); | 1228 | categories.sort (); |
1226 | if ( !colcat.isEmpty() ) { | 1229 | if ( !colcat.isEmpty() ) { |
1227 | if ( categories.find ( colcat ) != categories.end () ) { | 1230 | if ( categories.find ( colcat ) != categories.end () ) { |
1228 | categories.remove( colcat ); | 1231 | categories.remove( colcat ); |
1229 | categories.prepend( colcat ); | 1232 | categories.prepend( colcat ); |
1230 | } | 1233 | } |
1231 | } | 1234 | } |
1232 | mActiveItem->todo()->setCategories (categories); | 1235 | mActiveItem->todo()->setCategories (categories); |
1233 | mActiveItem->construct(); | 1236 | mActiveItem->construct(); |
1234 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1237 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1235 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1238 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1236 | } | 1239 | } |
1237 | } | 1240 | } |
1238 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1241 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1239 | { | 1242 | { |
1240 | if ( pendingSubtodo != 0 ) { | 1243 | if ( pendingSubtodo != 0 ) { |
1241 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1244 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1242 | } | 1245 | } |
1243 | pendingSubtodo = 0; | 1246 | pendingSubtodo = 0; |
1244 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1247 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1245 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1248 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1246 | //qDebug("ROW %d ", row); | 1249 | //qDebug("ROW %d ", row); |
1247 | if (!item) { | 1250 | if (!item) { |
1248 | newTodo(); | 1251 | newTodo(); |
1249 | return; | 1252 | return; |
1250 | } else { | 1253 | } else { |
1251 | if ( row == 1 ) { | 1254 | if ( row == 1 ) { |
1252 | mActiveItem = (KOTodoViewItem *) item; | 1255 | mActiveItem = (KOTodoViewItem *) item; |
1253 | newSubTodo(); | 1256 | newSubTodo(); |
1254 | return; | 1257 | return; |
1255 | } | 1258 | } |
1256 | if ( row == 5 || row == 6 || row == 2) { | 1259 | if ( row == 5 || row == 6 || row == 2) { |
1257 | mActiveItem = (KOTodoViewItem *) item; | 1260 | mActiveItem = (KOTodoViewItem *) item; |
1258 | Todo * t = mActiveItem->todo(); | 1261 | Todo * t = mActiveItem->todo(); |
1259 | if ( t->isRunning() ) { | 1262 | if ( t->isRunning() ) { |
1260 | if ( t->runTime() < 15) { | 1263 | if ( t->runTime() < 15) { |
1261 | t->stopRunning(); | 1264 | t->stopRunning(); |
1262 | mActiveItem->construct(); | 1265 | mActiveItem->construct(); |
1263 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1266 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1264 | return; | 1267 | return; |
1265 | } | 1268 | } |
1266 | else | 1269 | else |
1267 | toggleRunningItem(); | 1270 | toggleRunningItem(); |
1268 | return; | 1271 | return; |
1269 | } else { | 1272 | } else { |
1270 | t->setRunning( true ); | 1273 | t->setRunning( true ); |
1271 | mActiveItem->construct(); | 1274 | mActiveItem->construct(); |
1272 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1275 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1273 | return; | 1276 | return; |
1274 | } | 1277 | } |
1275 | } | 1278 | } |
1276 | } | 1279 | } |
1277 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1280 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1278 | editItem( item ); | 1281 | editItem( item ); |
1279 | else | 1282 | else |
1280 | showItem( item , QPoint(), 0 ); | 1283 | showItem( item , QPoint(), 0 ); |
1281 | } | 1284 | } |
1282 | void KOTodoView::toggleRunningItem() | 1285 | void KOTodoView::toggleRunningItem() |
1283 | { | 1286 | { |
1284 | // qDebug("KOTodoView::toggleRunning() "); | 1287 | // qDebug("KOTodoView::toggleRunning() "); |
1285 | if ( ! mActiveItem ) | 1288 | if ( ! mActiveItem ) |
1286 | return; | 1289 | return; |
1287 | Todo * t = mActiveItem->todo(); | 1290 | Todo * t = mActiveItem->todo(); |
1288 | if ( t->isRunning() ) { | 1291 | if ( t->isRunning() ) { |
1289 | KOStopTodoPrefs tp ( t, this ); | 1292 | KOStopTodoPrefs tp ( t, this ); |
1290 | if (QApplication::desktop()->width() <= 800 ){ | 1293 | if (QApplication::desktop()->width() <= 800 ){ |
1291 | int wid = tp.width(); | 1294 | int wid = tp.width(); |
1292 | int hei = tp.height(); | 1295 | int hei = tp.height(); |
1293 | int xx = (QApplication::desktop()->width()-wid)/2; | 1296 | int xx = (QApplication::desktop()->width()-wid)/2; |
1294 | int yy = (QApplication::desktop()->height()-hei)/2; | 1297 | int yy = (QApplication::desktop()->height()-hei)/2; |
1295 | tp.setGeometry( xx,yy,wid,hei ); | 1298 | tp.setGeometry( xx,yy,wid,hei ); |
1296 | } | 1299 | } |
1297 | tp.exec(); | 1300 | tp.exec(); |
1298 | mActiveItem->construct(); | 1301 | mActiveItem->construct(); |
1299 | } else { | 1302 | } else { |
1300 | KOStartTodoPrefs tp ( t->summary(), this ); | 1303 | KOStartTodoPrefs tp ( t->summary(), this ); |
1301 | if (QApplication::desktop()->width() <= 800 ){ | 1304 | if (QApplication::desktop()->width() <= 800 ){ |
1302 | int wid = tp.width(); | 1305 | int wid = tp.width(); |
1303 | int hei = tp.height(); | 1306 | int hei = tp.height(); |
1304 | int xx = (QApplication::desktop()->width()-wid)/2; | 1307 | int xx = (QApplication::desktop()->width()-wid)/2; |
1305 | int yy = (QApplication::desktop()->height()-hei)/2; | 1308 | int yy = (QApplication::desktop()->height()-hei)/2; |
1306 | tp.setGeometry( xx,yy,wid,hei ); | 1309 | tp.setGeometry( xx,yy,wid,hei ); |
1307 | } | 1310 | } |
1308 | if ( !tp.exec() ) return; | 1311 | if ( !tp.exec() ) return; |
1309 | if ( tp.stopAll() ) { | 1312 | if ( tp.stopAll() ) { |
1310 | mCalendar->stopAllTodos(); | 1313 | mCalendar->stopAllTodos(); |
1311 | t->setRunning( true ); | 1314 | t->setRunning( true ); |
1312 | updateView(); | 1315 | updateView(); |
1313 | } else { | 1316 | } else { |
1314 | t->setRunning( true ); | 1317 | t->setRunning( true ); |
1315 | mActiveItem->construct(); | 1318 | mActiveItem->construct(); |
1316 | } | 1319 | } |
1317 | } | 1320 | } |
1318 | } | 1321 | } |
1319 | 1322 | ||
1320 | void KOTodoView::itemClicked(QListViewItem *item) | 1323 | void KOTodoView::itemClicked(QListViewItem *item) |
1321 | { | 1324 | { |
1322 | //qDebug("KOTodoView::itemClicked %d", item); | 1325 | //qDebug("KOTodoView::itemClicked %d", item); |
1323 | if (!item) { | 1326 | if (!item) { |
1324 | if ( pendingSubtodo != 0 ) { | 1327 | if ( pendingSubtodo != 0 ) { |
1325 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1328 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1326 | } | 1329 | } |
1327 | pendingSubtodo = 0; | 1330 | pendingSubtodo = 0; |
1328 | return; | 1331 | return; |
1329 | } | 1332 | } |
1330 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1333 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1331 | if ( pendingSubtodo != 0 ) { | 1334 | if ( pendingSubtodo != 0 ) { |
1332 | bool allowReparent = true; | 1335 | bool allowReparent = true; |
1333 | QListViewItem *par = item; | 1336 | QListViewItem *par = item; |
1334 | while ( par ) { | 1337 | while ( par ) { |
1335 | if ( par == pendingSubtodo ) { | 1338 | if ( par == pendingSubtodo ) { |
1336 | allowReparent = false; | 1339 | allowReparent = false; |
1337 | break; | 1340 | break; |
1338 | } | 1341 | } |
1339 | par = par->parent(); | 1342 | par = par->parent(); |
1340 | } | 1343 | } |
1341 | if ( !allowReparent ) { | 1344 | if ( !allowReparent ) { |
1342 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1345 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1343 | pendingSubtodo = 0; | 1346 | pendingSubtodo = 0; |
1344 | } else { | 1347 | } else { |
1345 | Todo* newParent = todoItem->todo(); | 1348 | Todo* newParent = todoItem->todo(); |
1346 | Todo* newSub = pendingSubtodo->todo(); | 1349 | Todo* newSub = pendingSubtodo->todo(); |
1347 | pendingSubtodo = 0; | 1350 | pendingSubtodo = 0; |
1348 | emit reparentTodoSignal( newParent,newSub ); | 1351 | emit reparentTodoSignal( newParent,newSub ); |
1349 | return; | 1352 | return; |
1350 | } | 1353 | } |
1351 | } | 1354 | } |
1352 | 1355 | ||
1353 | } | 1356 | } |
1354 | 1357 | ||
1355 | void KOTodoView::setDocumentId( const QString &id ) | 1358 | void KOTodoView::setDocumentId( const QString &id ) |
1356 | { | 1359 | { |
1357 | 1360 | ||
1358 | mDocPrefs->setDoc( id ); | 1361 | mDocPrefs->setDoc( id ); |
1359 | } | 1362 | } |
1360 | 1363 | ||
1361 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1364 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1362 | { | 1365 | { |
1363 | if (!item) return; | 1366 | if (!item) return; |
1364 | 1367 | ||
1365 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1368 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1366 | 1369 | ||
1367 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1370 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1368 | 1371 | ||
1369 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1372 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1370 | } | 1373 | } |
1371 | 1374 | ||
1372 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1375 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1373 | { | 1376 | { |
1374 | mTodoListView->saveLayout(config,group); | 1377 | mTodoListView->saveLayout(config,group); |
1375 | } | 1378 | } |
1376 | 1379 | ||
1377 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1380 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1378 | { | 1381 | { |
1379 | mTodoListView->restoreLayout(config,group); | 1382 | mTodoListView->restoreLayout(config,group); |
1380 | } | 1383 | } |
1381 | 1384 | ||
1382 | void KOTodoView::processSelectionChange() | 1385 | void KOTodoView::processSelectionChange() |
1383 | { | 1386 | { |
1384 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1387 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1385 | 1388 | ||
1386 | KOTodoViewItem *item = | 1389 | KOTodoViewItem *item = |
1387 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1390 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1388 | 1391 | ||
1389 | if ( !item ) { | 1392 | if ( !item ) { |
1390 | emit incidenceSelected( 0 ); | 1393 | emit incidenceSelected( 0 ); |
1391 | } else { | 1394 | } else { |
1392 | emit incidenceSelected( item->todo() ); | 1395 | emit incidenceSelected( item->todo() ); |
1393 | } | 1396 | } |
1394 | } | 1397 | } |
1395 | 1398 | ||
1396 | void KOTodoView::modified(bool b) | 1399 | void KOTodoView::modified(bool b) |
1397 | { | 1400 | { |
1398 | emit isModified(b); | 1401 | emit isModified(b); |
1399 | } | 1402 | } |
1400 | void KOTodoView::setTodoModified( Todo* todo ) | 1403 | void KOTodoView::setTodoModified( Todo* todo ) |
1401 | { | 1404 | { |
1402 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1405 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1403 | } | 1406 | } |
1404 | void KOTodoView::clearSelection() | 1407 | void KOTodoView::clearSelection() |
1405 | { | 1408 | { |
1406 | mTodoListView->selectAll( false ); | 1409 | mTodoListView->selectAll( false ); |
1407 | } | 1410 | } |
1408 | void KOTodoView::setAllOpen() | 1411 | void KOTodoView::setAllOpen() |
1409 | { | 1412 | { |
1410 | if ( isFlatDisplay ) { | 1413 | if ( isFlatDisplay ) { |
1411 | isFlatDisplay = false; | 1414 | isFlatDisplay = false; |
1412 | mPopupMenu->setItemChecked( 8,false ); | 1415 | mPopupMenu->setItemChecked( 8,false ); |
1413 | updateView(); | 1416 | updateView(); |
1414 | } else { | 1417 | } else { |
1415 | storeCurrentItem(); | 1418 | storeCurrentItem(); |
1416 | } | 1419 | } |
1417 | setOpen(mTodoListView->firstChild(), true); | 1420 | setOpen(mTodoListView->firstChild(), true); |
1418 | resetCurrentItem(); | 1421 | resetCurrentItem(); |
1419 | } | 1422 | } |
1420 | void KOTodoView::setAllClose() | 1423 | void KOTodoView::setAllClose() |
1421 | { | 1424 | { |
1422 | if ( isFlatDisplay ) { | 1425 | if ( isFlatDisplay ) { |
1423 | isFlatDisplay = false; | 1426 | isFlatDisplay = false; |
1424 | mPopupMenu->setItemChecked( 8,false ); | 1427 | mPopupMenu->setItemChecked( 8,false ); |
1425 | updateView(); | 1428 | updateView(); |
1426 | } else { | 1429 | } else { |
1427 | storeCurrentItem(); | 1430 | storeCurrentItem(); |
1428 | } | 1431 | } |
1429 | setOpen(mTodoListView->firstChild(), false); | 1432 | setOpen(mTodoListView->firstChild(), false); |
1430 | resetCurrentItem(); | 1433 | resetCurrentItem(); |
1431 | } | 1434 | } |
1432 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1435 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1433 | { | 1436 | { |
1434 | 1437 | ||
1435 | while ( item ) { | 1438 | while ( item ) { |
1436 | setOpen( item->firstChild(), setOpenI ); | 1439 | setOpen( item->firstChild(), setOpenI ); |
1437 | item->setOpen( setOpenI ); | 1440 | item->setOpen( setOpenI ); |
1438 | item = item->nextSibling(); | 1441 | item = item->nextSibling(); |
1439 | } | 1442 | } |
1440 | } | 1443 | } |
1441 | 1444 | ||
1442 | void KOTodoView::displayAllFlat() | 1445 | void KOTodoView::displayAllFlat() |
1443 | { | 1446 | { |
1444 | storeCurrentItem(); | 1447 | storeCurrentItem(); |
1445 | pendingSubtodo = 0; | 1448 | pendingSubtodo = 0; |
1446 | if ( mBlockUpdate ) { | 1449 | if ( mBlockUpdate ) { |
1447 | return; | 1450 | return; |
1448 | } | 1451 | } |
1449 | mPopupMenu->setItemChecked( 8,true ); | 1452 | mPopupMenu->setItemChecked( 8,true ); |
1450 | isFlatDisplay = true; | 1453 | isFlatDisplay = true; |
1451 | QPtrList<Todo> todoList = calendar()->todos(); | 1454 | QPtrList<Todo> todoList = calendar()->todos(); |
1452 | mTodoMap.clear(); | 1455 | mTodoMap.clear(); |
1453 | mTodoListView->clear(); | 1456 | mTodoListView->clear(); |
1454 | Todo *todo; | 1457 | Todo *todo; |
1455 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1458 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1456 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1459 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1457 | mTodoMap.insert(todo,todoItem); | 1460 | mTodoMap.insert(todo,todoItem); |
1458 | } | 1461 | } |
1459 | resetCurrentItem(); | 1462 | resetCurrentItem(); |
1460 | } | 1463 | } |
1461 | 1464 | ||
1462 | void KOTodoView::setAllFlat() | 1465 | void KOTodoView::setAllFlat() |
1463 | { | 1466 | { |
1464 | if ( isFlatDisplay ) { | 1467 | if ( isFlatDisplay ) { |
1465 | isFlatDisplay = false; | 1468 | isFlatDisplay = false; |
1466 | mPopupMenu->setItemChecked( 8,false ); | 1469 | mPopupMenu->setItemChecked( 8,false ); |
1467 | updateView(); | 1470 | updateView(); |
1468 | return; | 1471 | return; |
1469 | } | 1472 | } |
1470 | displayAllFlat(); | 1473 | displayAllFlat(); |
1471 | } | 1474 | } |
1472 | 1475 | ||
1473 | void KOTodoView::purgeCompleted() | 1476 | void KOTodoView::purgeCompleted() |
1474 | { | 1477 | { |
1475 | emit purgeCompletedSignal(); | 1478 | emit purgeCompletedSignal(); |
1476 | 1479 | ||
1477 | } | 1480 | } |
1478 | void KOTodoView::toggleQuickTodo() | 1481 | void KOTodoView::toggleQuickTodo() |
1479 | { | 1482 | { |
1480 | if ( mQuickAdd->isVisible() ) { | 1483 | if ( mQuickAdd->isVisible() ) { |
1481 | mQuickAdd->hide(); | 1484 | mQuickAdd->hide(); |
1482 | KOPrefs::instance()->mEnableQuickTodo = false; | 1485 | KOPrefs::instance()->mEnableQuickTodo = false; |
1483 | } | 1486 | } |
1484 | else { | 1487 | else { |
1485 | mQuickAdd->show(); | 1488 | mQuickAdd->show(); |
1486 | KOPrefs::instance()->mEnableQuickTodo = true; | 1489 | KOPrefs::instance()->mEnableQuickTodo = true; |
1487 | } | 1490 | } |
1488 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1491 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1489 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1492 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1490 | } | 1493 | } |
1491 | 1494 | ||
1492 | void KOTodoView::toggleRunning() | 1495 | void KOTodoView::toggleRunning() |
1493 | { | 1496 | { |
1494 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1497 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1495 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1498 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1496 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1499 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1497 | updateView(); | 1500 | updateView(); |
1498 | } | 1501 | } |
1499 | 1502 | ||
1500 | void KOTodoView::toggleCompleted() | 1503 | void KOTodoView::toggleCompleted() |
1501 | { | 1504 | { |
1502 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1505 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1503 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1506 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1504 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1507 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1505 | updateView(); | 1508 | updateView(); |
1506 | } | 1509 | } |
1507 | 1510 | ||
1508 | void KOTodoView::addQuickTodo() | 1511 | void KOTodoView::addQuickTodo() |
1509 | { | 1512 | { |
1510 | Todo *todo = new Todo(); | 1513 | Todo *todo = new Todo(); |
1511 | todo->setSummary(mQuickAdd->text()); | 1514 | todo->setSummary(mQuickAdd->text()); |
1512 | todo->setOrganizer(KOPrefs::instance()->email()); | 1515 | todo->setOrganizer(KOPrefs::instance()->email()); |
1513 | CalFilter * cf = mCalendar->filter(); | 1516 | CalFilter * cf = mCalendar->filter(); |
1514 | if ( cf ) { | 1517 | if ( cf ) { |
1515 | if ( cf->isEnabled()&& cf->showCategories()) { | 1518 | if ( cf->isEnabled()&& cf->showCategories()) { |
1516 | todo->setCategories(cf->categoryList()); | 1519 | todo->setCategories(cf->categoryList()); |
1517 | } | 1520 | } |
1518 | if ( cf->isEnabled() ) | 1521 | if ( cf->isEnabled() ) |
1519 | todo->setSecrecy( cf->getSecrecy()); | 1522 | todo->setSecrecy( cf->getSecrecy()); |
1520 | } | 1523 | } |
1521 | mCalendar->addTodo(todo); | 1524 | mCalendar->addTodo(todo); |
1522 | mQuickAdd->setText(""); | 1525 | mQuickAdd->setText(""); |
1523 | todoModified (todo, KOGlobals::EVENTADDED ); | 1526 | todoModified (todo, KOGlobals::EVENTADDED ); |
1524 | updateView(); | 1527 | updateView(); |
1525 | } | 1528 | } |
1526 | 1529 | ||
1527 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1530 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1528 | { | 1531 | { |
1529 | // e->ignore(); | 1532 | // e->ignore(); |
1530 | //return; | 1533 | //return; |
1531 | //qDebug("KOTodoView::keyPressEvent "); | 1534 | //qDebug("KOTodoView::keyPressEvent "); |
1532 | switch ( e->key() ) { | 1535 | switch ( e->key() ) { |
1533 | case Qt::Key_Down: | 1536 | case Qt::Key_Down: |
1534 | case Qt::Key_Up: | 1537 | case Qt::Key_Up: |
1535 | QWidget::keyPressEvent ( e ); | 1538 | QWidget::keyPressEvent ( e ); |
1536 | break; | 1539 | break; |
1537 | 1540 | ||
1538 | case Qt::Key_Q: | 1541 | case Qt::Key_Q: |
1539 | toggleQuickTodo(); | 1542 | toggleQuickTodo(); |
1540 | break; | 1543 | break; |
1541 | case Qt::Key_U: | 1544 | case Qt::Key_U: |
1542 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1545 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1543 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1546 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1544 | unparentTodo(); | 1547 | unparentTodo(); |
1545 | e->accept(); | 1548 | e->accept(); |
1546 | } else | 1549 | } else |
1547 | e->ignore(); | 1550 | e->ignore(); |
1548 | break; | 1551 | break; |
1549 | case Qt::Key_S: | 1552 | case Qt::Key_S: |
1550 | if ( e->state() == Qt::ControlButton ) { | 1553 | if ( e->state() == Qt::ControlButton ) { |
1551 | e->ignore(); | 1554 | e->ignore(); |
1552 | break; | 1555 | break; |
1553 | } | 1556 | } |
1554 | if ( e->state() == Qt::ShiftButton ) { | 1557 | if ( e->state() == Qt::ShiftButton ) { |
1555 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1558 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1556 | reparentTodo(); | 1559 | reparentTodo(); |
1557 | e->accept(); | 1560 | e->accept(); |
1558 | } else | 1561 | } else |
1559 | e->ignore(); | 1562 | e->ignore(); |
1560 | break; | 1563 | break; |
1561 | case Qt::Key_P: | 1564 | case Qt::Key_P: |
1562 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1565 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1563 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1566 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1564 | if ( pendingSubtodo ) | 1567 | if ( pendingSubtodo ) |
1565 | itemClicked(mActiveItem); | 1568 | itemClicked(mActiveItem); |
1566 | e->accept(); | 1569 | e->accept(); |
1567 | } else | 1570 | } else |
1568 | e->ignore(); | 1571 | e->ignore(); |
1569 | break; | 1572 | break; |
1570 | case Qt::Key_Escape: | 1573 | case Qt::Key_Escape: |
1571 | if ( pendingSubtodo ) { | 1574 | if ( pendingSubtodo ) { |
1572 | itemClicked(0); | 1575 | itemClicked(0); |
1573 | e->accept(); | 1576 | e->accept(); |
1574 | } else | 1577 | } else |
1575 | e->ignore(); | 1578 | e->ignore(); |
1576 | break; | 1579 | break; |
1577 | default: | 1580 | default: |
1578 | e->ignore(); | 1581 | e->ignore(); |
1579 | } | 1582 | } |
1580 | 1583 | ||
1581 | if ( true ) { | 1584 | if ( true ) { |
1582 | if ( e->key() == Qt::Key_I ) { | 1585 | if ( e->key() == Qt::Key_I ) { |
1583 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1586 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1584 | if ( cn ) { | 1587 | if ( cn ) { |
1585 | mActiveItem = cn; | 1588 | mActiveItem = cn; |
1586 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1589 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1587 | if ( ci ){ | 1590 | if ( ci ){ |
1588 | showTodo(); | 1591 | showTodo(); |
1589 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1592 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1590 | if ( cn ) { | 1593 | if ( cn ) { |
1591 | mTodoListView->setCurrentItem ( cn ); | 1594 | mTodoListView->setCurrentItem ( cn ); |
1592 | mTodoListView->ensureItemVisible ( cn ); | 1595 | mTodoListView->ensureItemVisible ( cn ); |
1593 | } | 1596 | } |
1594 | 1597 | ||
1595 | } | 1598 | } |
1596 | } | 1599 | } |
1597 | e->accept(); | 1600 | e->accept(); |
1598 | 1601 | ||
1599 | } | 1602 | } |
1600 | 1603 | ||
1601 | } | 1604 | } |
1602 | 1605 | ||
1603 | } | 1606 | } |
1604 | void KOTodoView::updateTodo( Todo * t, int type ) | 1607 | void KOTodoView::updateTodo( Todo * t, int type ) |
1605 | { | 1608 | { |
1606 | if ( mBlockUpdate) | 1609 | if ( mBlockUpdate) |
1607 | return; | 1610 | return; |
1608 | 1611 | ||
1609 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1612 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1610 | itemIterator = mTodoMap.find(t); | 1613 | itemIterator = mTodoMap.find(t); |
1611 | if (itemIterator != mTodoMap.end()) { | 1614 | if (itemIterator != mTodoMap.end()) { |
1612 | (*itemIterator)->construct(); | 1615 | (*itemIterator)->construct(); |
1613 | } else { | 1616 | } else { |
1614 | if ( type == KOGlobals::EVENTADDED ) { | 1617 | if ( type == KOGlobals::EVENTADDED ) { |
1615 | insertTodoItem( t ); | 1618 | insertTodoItem( t ); |
1616 | } | 1619 | } |
1617 | } | 1620 | } |
1618 | 1621 | ||
1619 | } | 1622 | } |
1620 | 1623 | ||
1621 | void KOTodoView::todoModified(Todo * t , int p ) | 1624 | void KOTodoView::todoModified(Todo * t , int p ) |
1622 | { | 1625 | { |
1623 | mBlockUpdate = true; | 1626 | mBlockUpdate = true; |
1624 | emit todoModifiedSignal ( t, p ); | 1627 | emit todoModifiedSignal ( t, p ); |
1625 | mBlockUpdate = false; | 1628 | mBlockUpdate = false; |
1626 | } | 1629 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 88dbd4f..cbf6096 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -149,2420 +149,2424 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : | |||
149 | sgListViewCompletedPix[5]->fill( Qt::white ); | 149 | sgListViewCompletedPix[5]->fill( Qt::white ); |
150 | QPainter p ( sgListViewCompletedPix[5] ); | 150 | QPainter p ( sgListViewCompletedPix[5] ); |
151 | p.drawRect( 0,0,11,11); | 151 | p.drawRect( 0,0,11,11); |
152 | p.drawLine ( 2, 5, 4 , 7 ) ; | 152 | p.drawLine ( 2, 5, 4 , 7 ) ; |
153 | p.drawLine ( 4 , 7 , 8, 3) ; | 153 | p.drawLine ( 4 , 7 , 8, 3) ; |
154 | int iii = 0; | 154 | int iii = 0; |
155 | for ( iii = 0; iii < 5; ++iii ) { | 155 | for ( iii = 0; iii < 5; ++iii ) { |
156 | sgListViewCompletedPix[iii]->resize( 11, 11 ); | 156 | sgListViewCompletedPix[iii]->resize( 11, 11 ); |
157 | sgListViewCompletedPix[iii]->fill( Qt::white ); | 157 | sgListViewCompletedPix[iii]->fill( Qt::white ); |
158 | QPainter p ( sgListViewCompletedPix[iii] ); | 158 | QPainter p ( sgListViewCompletedPix[iii] ); |
159 | p.drawRect( 0,0,11,11); | 159 | p.drawRect( 0,0,11,11); |
160 | if ( iii ) | 160 | if ( iii ) |
161 | p.fillRect( 1,1,iii*2,9,Qt::gray ); | 161 | p.fillRect( 1,1,iii*2,9,Qt::gray ); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | mClosed = false; | 164 | mClosed = false; |
165 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 165 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
166 | QString confFile = locateLocal("config","korganizerrc"); | 166 | QString confFile = locateLocal("config","korganizerrc"); |
167 | QFileInfo finf ( confFile ); | 167 | QFileInfo finf ( confFile ); |
168 | bool showWarning = !finf.exists(); | 168 | bool showWarning = !finf.exists(); |
169 | setIcon(SmallIcon( "ko24" ) ); | 169 | setIcon(SmallIcon( "ko24" ) ); |
170 | mBlockAtStartup = true; | 170 | mBlockAtStartup = true; |
171 | mFlagKeyPressed = false; | 171 | mFlagKeyPressed = false; |
172 | setCaption("KO/Pi"); | 172 | setCaption("KO/Pi"); |
173 | KOPrefs *p = KOPrefs::instance(); | 173 | KOPrefs *p = KOPrefs::instance(); |
174 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 174 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
175 | p->mCurrentDisplayedView = 0; | 175 | p->mCurrentDisplayedView = 0; |
176 | if ( p->mHourSize > 22 ) | 176 | if ( p->mHourSize > 22 ) |
177 | p->mHourSize = 22; | 177 | p->mHourSize = 22; |
178 | QMainWindow::ToolBarDock tbd; | 178 | QMainWindow::ToolBarDock tbd; |
179 | if ( p->mToolBarHor ) { | 179 | if ( p->mToolBarHor ) { |
180 | if ( p->mToolBarUp ) | 180 | if ( p->mToolBarUp ) |
181 | tbd = Bottom; | 181 | tbd = Bottom; |
182 | else | 182 | else |
183 | tbd = Top; | 183 | tbd = Top; |
184 | } | 184 | } |
185 | else { | 185 | else { |
186 | if ( p->mToolBarUp ) | 186 | if ( p->mToolBarUp ) |
187 | tbd = Right; | 187 | tbd = Right; |
188 | else | 188 | else |
189 | tbd = Left; | 189 | tbd = Left; |
190 | } | 190 | } |
191 | if ( KOPrefs::instance()->mUseAppColors ) | 191 | if ( KOPrefs::instance()->mUseAppColors ) |
192 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 192 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
193 | globalFlagBlockStartup = 1; | 193 | globalFlagBlockStartup = 1; |
194 | iconToolBar = new QPEToolBar( this ); | 194 | iconToolBar = new QPEToolBar( this ); |
195 | addToolBar (iconToolBar , tbd ); | 195 | addToolBar (iconToolBar , tbd ); |
196 | 196 | ||
197 | #ifdef DESKTOP_VERSION | 197 | #ifdef DESKTOP_VERSION |
198 | if ( KOPrefs::instance()->mShowIconFilter ) | 198 | if ( KOPrefs::instance()->mShowIconFilter ) |
199 | #else | 199 | #else |
200 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) | 200 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) |
201 | #endif | 201 | #endif |
202 | 202 | ||
203 | { | 203 | { |
204 | if ( p->mToolBarHorF ) { | 204 | if ( p->mToolBarHorF ) { |
205 | if ( p->mToolBarUpF ) | 205 | if ( p->mToolBarUpF ) |
206 | tbd = Bottom; | 206 | tbd = Bottom; |
207 | else | 207 | else |
208 | tbd = Top; | 208 | tbd = Top; |
209 | } | 209 | } |
210 | else { | 210 | else { |
211 | if ( p->mToolBarUpF ) | 211 | if ( p->mToolBarUpF ) |
212 | tbd = Right; | 212 | tbd = Right; |
213 | else | 213 | else |
214 | tbd = Left; | 214 | tbd = Left; |
215 | } | 215 | } |
216 | filterToolBar = new QPEToolBar ( this ); | 216 | filterToolBar = new QPEToolBar ( this ); |
217 | filterMenubar = new QMenuBar( 0 ); | 217 | filterMenubar = new QMenuBar( 0 ); |
218 | QFontMetrics fm ( filterMenubar->font() ); | 218 | QFontMetrics fm ( filterMenubar->font() ); |
219 | 219 | ||
220 | filterPopupMenu = new QPopupMenu( this ); | 220 | filterPopupMenu = new QPopupMenu( this ); |
221 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 221 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
222 | QString addTest = "A"; | 222 | QString addTest = "A"; |
223 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); | 223 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); |
224 | #ifdef DESKTOP_VERSION | 224 | #ifdef DESKTOP_VERSION |
225 | addTest = "AAABBBCCCx"; | 225 | addTest = "AAABBBCCCx"; |
226 | #else | 226 | #else |
227 | addTest = "AAx"; | 227 | addTest = "AAx"; |
228 | #endif | 228 | #endif |
229 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); | 229 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); |
230 | addToolBar (filterToolBar , tbd ); | 230 | addToolBar (filterToolBar , tbd ); |
231 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 231 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
232 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 232 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
233 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 233 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
234 | filterToolBar->hide(); | 234 | filterToolBar->hide(); |
235 | } else { | 235 | } else { |
236 | filterToolBar = 0; | 236 | filterToolBar = 0; |
237 | filterMenubar = 0; | 237 | filterMenubar = 0; |
238 | filterPopupMenu = 0; | 238 | filterPopupMenu = 0; |
239 | } | 239 | } |
240 | if ( p->mShowIconOnetoolbar ) { | 240 | if ( p->mShowIconOnetoolbar ) { |
241 | viewToolBar = iconToolBar ; | 241 | viewToolBar = iconToolBar ; |
242 | navigatorToolBar = iconToolBar ; | 242 | navigatorToolBar = iconToolBar ; |
243 | } else { | 243 | } else { |
244 | #ifndef DESKTOP_VERSION | 244 | #ifndef DESKTOP_VERSION |
245 | setToolBarsMovable( false ); | 245 | setToolBarsMovable( false ); |
246 | #endif | 246 | #endif |
247 | if ( p->mToolBarHorV ) { | 247 | if ( p->mToolBarHorV ) { |
248 | if ( p->mToolBarUpV ) | 248 | if ( p->mToolBarUpV ) |
249 | tbd = Bottom; | 249 | tbd = Bottom; |
250 | else | 250 | else |
251 | tbd = Top; | 251 | tbd = Top; |
252 | } | 252 | } |
253 | else { | 253 | else { |
254 | if ( p->mToolBarUpV ) | 254 | if ( p->mToolBarUpV ) |
255 | tbd = Right; | 255 | tbd = Right; |
256 | else | 256 | else |
257 | tbd = Left; | 257 | tbd = Left; |
258 | } | 258 | } |
259 | viewToolBar = new QPEToolBar( this ); | 259 | viewToolBar = new QPEToolBar( this ); |
260 | addToolBar (viewToolBar , tbd ); | 260 | addToolBar (viewToolBar , tbd ); |
261 | if ( p->mToolBarHorN ) { | 261 | if ( p->mToolBarHorN ) { |
262 | if ( p->mToolBarUpN ) | 262 | if ( p->mToolBarUpN ) |
263 | tbd = Bottom; | 263 | tbd = Bottom; |
264 | else | 264 | else |
265 | tbd = Top; | 265 | tbd = Top; |
266 | } | 266 | } |
267 | else { | 267 | else { |
268 | if ( p->mToolBarUpN ) | 268 | if ( p->mToolBarUpN ) |
269 | tbd = Right; | 269 | tbd = Right; |
270 | else | 270 | else |
271 | tbd = Left; | 271 | tbd = Left; |
272 | } | 272 | } |
273 | navigatorToolBar = new QPEToolBar( this ); | 273 | navigatorToolBar = new QPEToolBar( this ); |
274 | addToolBar (navigatorToolBar , tbd ); | 274 | addToolBar (navigatorToolBar , tbd ); |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | 278 | ||
279 | mCalendarModifiedFlag = false; | 279 | mCalendarModifiedFlag = false; |
280 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 280 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
281 | splash->setAlignment ( AlignCenter ); | 281 | splash->setAlignment ( AlignCenter ); |
282 | setCentralWidget( splash ); | 282 | setCentralWidget( splash ); |
283 | #ifndef DESKTOP_VERSION | 283 | #ifndef DESKTOP_VERSION |
284 | showMaximized(); | 284 | showMaximized(); |
285 | #endif | 285 | #endif |
286 | 286 | ||
287 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 287 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
288 | setDefaultPreferences(); | 288 | setDefaultPreferences(); |
289 | mCalendar = new CalendarLocal(); | 289 | mCalendar = new CalendarLocal(); |
290 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 290 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
291 | mView->hide(); | 291 | mView->hide(); |
292 | //mView->resize(splash->size() ); | 292 | //mView->resize(splash->size() ); |
293 | initActions(); | 293 | initActions(); |
294 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 294 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
295 | mSyncManager->setBlockSave(false); | 295 | mSyncManager->setBlockSave(false); |
296 | mView->setSyncManager(mSyncManager); | 296 | mView->setSyncManager(mSyncManager); |
297 | #ifndef DESKTOP_VERSION | 297 | #ifndef DESKTOP_VERSION |
298 | iconToolBar->show(); | 298 | iconToolBar->show(); |
299 | qApp->processEvents(); | 299 | qApp->processEvents(); |
300 | #endif | 300 | #endif |
301 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 301 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
302 | int vh = height() ; | 302 | int vh = height() ; |
303 | int vw = width(); | 303 | int vw = width(); |
304 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 304 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
305 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 305 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
306 | vh -= iconToolBar->height(); | 306 | vh -= iconToolBar->height(); |
307 | } else { | 307 | } else { |
308 | vw -= iconToolBar->height(); | 308 | vw -= iconToolBar->height(); |
309 | } | 309 | } |
310 | //mView->setMaximumSize( splash->size() ); | 310 | //mView->setMaximumSize( splash->size() ); |
311 | //mView->resize( splash->size() ); | 311 | //mView->resize( splash->size() ); |
312 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 312 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
313 | mView->readSettings(); | 313 | mView->readSettings(); |
314 | bool newFile = false; | 314 | bool newFile = false; |
315 | if( !QFile::exists( defaultFileName() ) ) { | 315 | if( !QFile::exists( defaultFileName() ) ) { |
316 | QFileInfo finfo ( defaultFileName() ); | 316 | QFileInfo finfo ( defaultFileName() ); |
317 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 317 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
318 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 318 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
319 | finfo.setFile( oldFile ); | 319 | finfo.setFile( oldFile ); |
320 | if (finfo.exists() ) { | 320 | if (finfo.exists() ) { |
321 | KMessageBox::information( this, message); | 321 | KMessageBox::information( this, message); |
322 | mView->openCalendar( oldFile ); | 322 | mView->openCalendar( oldFile ); |
323 | qApp->processEvents(); | 323 | qApp->processEvents(); |
324 | } else { | 324 | } else { |
325 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 325 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
326 | finfo.setFile( oldFile ); | 326 | finfo.setFile( oldFile ); |
327 | if (finfo.exists() ) { | 327 | if (finfo.exists() ) { |
328 | KMessageBox::information( this, message); | 328 | KMessageBox::information( this, message); |
329 | mView->openCalendar( oldFile ); | 329 | mView->openCalendar( oldFile ); |
330 | qApp->processEvents(); | 330 | qApp->processEvents(); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | mView->saveCalendar( defaultFileName() ); | 333 | mView->saveCalendar( defaultFileName() ); |
334 | newFile = true; | 334 | newFile = true; |
335 | } | 335 | } |
336 | 336 | ||
337 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 337 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
338 | mView->loadCalendars(); | 338 | mView->loadCalendars(); |
339 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 339 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
340 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 340 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
341 | 341 | ||
342 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 342 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
343 | KOPrefs::instance()->setAllDefaults(); | 343 | KOPrefs::instance()->setAllDefaults(); |
344 | } | 344 | } |
345 | processIncidenceSelection( 0 ); | 345 | processIncidenceSelection( 0 ); |
346 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 346 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
347 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 347 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
348 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 348 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
349 | SLOT( slotModifiedChanged( bool ) ) ); | 349 | SLOT( slotModifiedChanged( bool ) ) ); |
350 | 350 | ||
351 | 351 | ||
352 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 352 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
353 | SLOT( disableBR(bool) ) ); | 353 | SLOT( disableBR(bool) ) ); |
354 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 354 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
355 | mView->setModified( false ); | 355 | mView->setModified( false ); |
356 | mBlockAtStartup = false; | 356 | mBlockAtStartup = false; |
357 | mView->setModified( false ); | 357 | mView->setModified( false ); |
358 | setCentralWidget( mView ); | 358 | setCentralWidget( mView ); |
359 | globalFlagBlockStartup = 0; | 359 | globalFlagBlockStartup = 0; |
360 | mView->show(); | 360 | mView->show(); |
361 | delete splash; | 361 | delete splash; |
362 | if ( newFile ) | 362 | if ( newFile ) |
363 | mView->updateConfig(); | 363 | mView->updateConfig(); |
364 | // qApp->processEvents(); | 364 | // qApp->processEvents(); |
365 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 365 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
366 | //fillSyncMenu(); | 366 | //fillSyncMenu(); |
367 | 367 | ||
368 | 368 | ||
369 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 369 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
370 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 370 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
371 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 371 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
372 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 372 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
373 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 373 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
374 | mSyncManager->setDefaultFileName( sentSyncFile()); | 374 | mSyncManager->setDefaultFileName( sentSyncFile()); |
375 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 375 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
376 | mSyncManager->fillSyncMenu(); | 376 | mSyncManager->fillSyncMenu(); |
377 | 377 | ||
378 | 378 | ||
379 | 379 | ||
380 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 380 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
381 | if ( showWarning ) { | 381 | if ( showWarning ) { |
382 | KMessageBox::information( this, | 382 | KMessageBox::information( this, |
383 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 383 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
384 | qApp->processEvents(); | 384 | qApp->processEvents(); |
385 | mView->dialogManager()->showSyncOptions(); | 385 | mView->dialogManager()->showSyncOptions(); |
386 | } | 386 | } |
387 | 387 | ||
388 | //US listen for result adressed from Ka/Pi | 388 | //US listen for result adressed from Ka/Pi |
389 | #ifndef DESKTOP_VERSION | 389 | #ifndef DESKTOP_VERSION |
390 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 390 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
391 | #endif | 391 | #endif |
392 | #ifndef DESKTOP_VERSION | 392 | #ifndef DESKTOP_VERSION |
393 | infrared = 0; | 393 | infrared = 0; |
394 | #endif | 394 | #endif |
395 | updateFilterToolbar(); | 395 | updateFilterToolbar(); |
396 | updateWeek( mView->startDate() ); | 396 | updateWeek( mView->startDate() ); |
397 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 397 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
398 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 398 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
399 | mBRdisabled = false; | 399 | mBRdisabled = false; |
400 | //toggleBeamReceive(); | 400 | //toggleBeamReceive(); |
401 | 401 | ||
402 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 402 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); |
403 | } | 403 | } |
404 | MainWindow::~MainWindow() | 404 | MainWindow::~MainWindow() |
405 | { | 405 | { |
406 | //qDebug("MainWindow::~MainWindow() "); | 406 | //qDebug("MainWindow::~MainWindow() "); |
407 | //save toolbar location | 407 | //save toolbar location |
408 | delete mCalendar; | 408 | delete mCalendar; |
409 | delete mSyncManager; | 409 | delete mSyncManager; |
410 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
411 | if ( infrared ) | 411 | if ( infrared ) |
412 | delete infrared; | 412 | delete infrared; |
413 | #endif | 413 | #endif |
414 | 414 | ||
415 | 415 | ||
416 | } | 416 | } |
417 | 417 | ||
418 | void MainWindow::disableBR(bool b) | 418 | void MainWindow::disableBR(bool b) |
419 | { | 419 | { |
420 | #ifndef DESKTOP_VERSION | 420 | #ifndef DESKTOP_VERSION |
421 | if ( b ) { | 421 | if ( b ) { |
422 | if ( infrared ) { | 422 | if ( infrared ) { |
423 | toggleBeamReceive(); | 423 | toggleBeamReceive(); |
424 | mBRdisabled = true; | 424 | mBRdisabled = true; |
425 | } | 425 | } |
426 | mBRdisabled = true; | 426 | mBRdisabled = true; |
427 | } else { | 427 | } else { |
428 | if ( mBRdisabled ) { | 428 | if ( mBRdisabled ) { |
429 | mBRdisabled = false; | 429 | mBRdisabled = false; |
430 | //makes no sense,because other cal ap is probably running | 430 | //makes no sense,because other cal ap is probably running |
431 | // toggleBeamReceive(); | 431 | // toggleBeamReceive(); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | #endif | 434 | #endif |
435 | 435 | ||
436 | } | 436 | } |
437 | bool MainWindow::beamReceiveEnabled() | 437 | bool MainWindow::beamReceiveEnabled() |
438 | { | 438 | { |
439 | #ifndef DESKTOP_VERSION | 439 | #ifndef DESKTOP_VERSION |
440 | return ( infrared != 0 ); | 440 | return ( infrared != 0 ); |
441 | #endif | 441 | #endif |
442 | return false; | 442 | return false; |
443 | } | 443 | } |
444 | 444 | ||
445 | void MainWindow::toggleBeamReceive() | 445 | void MainWindow::toggleBeamReceive() |
446 | { | 446 | { |
447 | if ( mBRdisabled ) | 447 | if ( mBRdisabled ) |
448 | return; | 448 | return; |
449 | #ifndef DESKTOP_VERSION | 449 | #ifndef DESKTOP_VERSION |
450 | if ( infrared ) { | 450 | if ( infrared ) { |
451 | qDebug("KO: Disable BeamReceive "); | 451 | qDebug("KO: Disable BeamReceive "); |
452 | delete infrared; | 452 | delete infrared; |
453 | infrared = 0; | 453 | infrared = 0; |
454 | brAction->setOn(false); | 454 | brAction->setOn(false); |
455 | return; | 455 | return; |
456 | } | 456 | } |
457 | qDebug("KO: Enable BeamReceive "); | 457 | qDebug("KO: Enable BeamReceive "); |
458 | brAction->setOn(true); | 458 | brAction->setOn(true); |
459 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 459 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
460 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 460 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
461 | #endif | 461 | #endif |
462 | } | 462 | } |
463 | void MainWindow::showMaximized () | 463 | void MainWindow::showMaximized () |
464 | { | 464 | { |
465 | #ifndef DESKTOP_VERSION | 465 | #ifndef DESKTOP_VERSION |
466 | if ( ! globalFlagBlockStartup ) | 466 | if ( ! globalFlagBlockStartup ) |
467 | if ( mClosed ) | 467 | if ( mClosed ) |
468 | mView->goToday(); | 468 | mView->goToday(); |
469 | #endif | 469 | #endif |
470 | QWidget::showMaximized () ; | 470 | QWidget::showMaximized () ; |
471 | mClosed = false; | 471 | mClosed = false; |
472 | } | 472 | } |
473 | void MainWindow::closeEvent( QCloseEvent* ce ) | 473 | void MainWindow::closeEvent( QCloseEvent* ce ) |
474 | { | 474 | { |
475 | 475 | ||
476 | 476 | ||
477 | 477 | ||
478 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 478 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
479 | saveOnClose(); | 479 | saveOnClose(); |
480 | mClosed = true; | 480 | mClosed = true; |
481 | ce->accept(); | 481 | ce->accept(); |
482 | return; | 482 | return; |
483 | 483 | ||
484 | } | 484 | } |
485 | 485 | ||
486 | switch( QMessageBox::information( this, "KO/Pi", | 486 | switch( QMessageBox::information( this, "KO/Pi", |
487 | i18n("Do you really want\nto close KO/Pi?"), | 487 | i18n("Do you really want\nto close KO/Pi?"), |
488 | i18n("Close"), i18n("No"), | 488 | i18n("Close"), i18n("No"), |
489 | 0, 0 ) ) { | 489 | 0, 0 ) ) { |
490 | case 0: | 490 | case 0: |
491 | saveOnClose(); | 491 | saveOnClose(); |
492 | mClosed = true; | 492 | mClosed = true; |
493 | ce->accept(); | 493 | ce->accept(); |
494 | break; | 494 | break; |
495 | case 1: | 495 | case 1: |
496 | ce->ignore(); | 496 | ce->ignore(); |
497 | break; | 497 | break; |
498 | case 2: | 498 | case 2: |
499 | 499 | ||
500 | default: | 500 | default: |
501 | break; | 501 | break; |
502 | } | 502 | } |
503 | 503 | ||
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 507 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
508 | { | 508 | { |
509 | QDataStream stream( data, IO_ReadOnly ); | 509 | QDataStream stream( data, IO_ReadOnly ); |
510 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 510 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
511 | //QString datamess; | 511 | //QString datamess; |
512 | //qDebug("message "); | 512 | //qDebug("message "); |
513 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 513 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
514 | 514 | ||
515 | if ( cmsg == "setDocument(QString)" ) { | 515 | if ( cmsg == "setDocument(QString)" ) { |
516 | QDataStream stream( data, IO_ReadOnly ); | 516 | QDataStream stream( data, IO_ReadOnly ); |
517 | QString fileName; | 517 | QString fileName; |
518 | stream >> fileName; | 518 | stream >> fileName; |
519 | //qDebug("filename %s ", fileName.latin1()); | 519 | //qDebug("filename %s ", fileName.latin1()); |
520 | showMaximized(); | 520 | showMaximized(); |
521 | raise(); | 521 | raise(); |
522 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 522 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
523 | mSyncManager->slotSyncMenu( 1002 ); | 523 | mSyncManager->slotSyncMenu( 1002 ); |
524 | return; | 524 | return; |
525 | } | 525 | } |
526 | 526 | ||
527 | if ( cmsg == "-writeFile" ) { | 527 | if ( cmsg == "-writeFile" ) { |
528 | // I made from the "-writeFile" an "-writeAlarm" | 528 | // I made from the "-writeFile" an "-writeAlarm" |
529 | mView->viewManager()->showWhatsNextView(); | 529 | mView->viewManager()->showWhatsNextView(); |
530 | mCalendar->checkAlarmForIncidence( 0, true); | 530 | mCalendar->checkAlarmForIncidence( 0, true); |
531 | showMaximized(); | 531 | showMaximized(); |
532 | raise(); | 532 | raise(); |
533 | return; | 533 | return; |
534 | 534 | ||
535 | } | 535 | } |
536 | if ( cmsg == "-writeFileSilent" ) { | 536 | if ( cmsg == "-writeFileSilent" ) { |
537 | // I made from the "-writeFile" an "-writeAlarm" | 537 | // I made from the "-writeFile" an "-writeAlarm" |
538 | // mView->viewManager()->showWhatsNextView(); | 538 | // mView->viewManager()->showWhatsNextView(); |
539 | mCalendar->checkAlarmForIncidence( 0, true); | 539 | mCalendar->checkAlarmForIncidence( 0, true); |
540 | //showMaximized(); | 540 | //showMaximized(); |
541 | //raise(); | 541 | //raise(); |
542 | hide(); | 542 | hide(); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( cmsg == "-newCountdown" ) { | 545 | if ( cmsg == "-newCountdown" ) { |
546 | qDebug("newCountdown "); | 546 | qDebug("newCountdown "); |
547 | 547 | ||
548 | } | 548 | } |
549 | QString msg ; | 549 | QString msg ; |
550 | QString allmsg = cmsg; | 550 | QString allmsg = cmsg; |
551 | while ( allmsg.length() > 0 ) { | 551 | while ( allmsg.length() > 0 ) { |
552 | int nextC = allmsg.find( "-", 1 ); | 552 | int nextC = allmsg.find( "-", 1 ); |
553 | if ( nextC == -1 ) { | 553 | if ( nextC == -1 ) { |
554 | msg = allmsg; | 554 | msg = allmsg; |
555 | allmsg = ""; | 555 | allmsg = ""; |
556 | } else{ | 556 | } else{ |
557 | msg = allmsg.left( nextC ); | 557 | msg = allmsg.left( nextC ); |
558 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 558 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
559 | } | 559 | } |
560 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 560 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
561 | if ( msg == "-newEvent" ) { | 561 | if ( msg == "-newEvent" ) { |
562 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); | 562 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); |
563 | } | 563 | } |
564 | if ( msg == "-newTodo" ) { | 564 | if ( msg == "-newTodo" ) { |
565 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); | 565 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); |
566 | } | 566 | } |
567 | if ( msg == "-showWN" ) { | 567 | if ( msg == "-showWN" ) { |
568 | mView->viewManager()->showWhatsNextView(); | 568 | mView->viewManager()->showWhatsNextView(); |
569 | } | 569 | } |
570 | if ( msg == "-showTodo" ) { | 570 | if ( msg == "-showTodo" ) { |
571 | mView->viewManager()->showTodoView(); | 571 | mView->viewManager()->showTodoView(); |
572 | } | 572 | } |
573 | if ( msg == "-showList" ) { | 573 | if ( msg == "-showList" ) { |
574 | mView->viewManager()->showListView(); | 574 | mView->viewManager()->showListView(); |
575 | } | 575 | } |
576 | else if ( msg == "-showDay" ) { | 576 | else if ( msg == "-showDay" ) { |
577 | mView->viewManager()->showDayView(); | 577 | mView->viewManager()->showDayView(); |
578 | } | 578 | } |
579 | else if ( msg == "-showWWeek" ) { | 579 | else if ( msg == "-showWWeek" ) { |
580 | mView->viewManager()->showWorkWeekView(); | 580 | mView->viewManager()->showWorkWeekView(); |
581 | } | 581 | } |
582 | else if ( msg == "-ringSync" ) { | 582 | else if ( msg == "-ringSync" ) { |
583 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); | 583 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); |
584 | } | 584 | } |
585 | else if ( msg == "-showWeek" ) { | 585 | else if ( msg == "-showWeek" ) { |
586 | mView->viewManager()->showWeekView(); | 586 | mView->viewManager()->showWeekView(); |
587 | } | 587 | } |
588 | else if ( msg == "-showTodo" ) { | 588 | else if ( msg == "-showTodo" ) { |
589 | mView->viewManager()->showTodoView(); | 589 | mView->viewManager()->showTodoView(); |
590 | } | 590 | } |
591 | else if ( msg == "-showJournal" ) { | 591 | else if ( msg == "-showJournal" ) { |
592 | mView->dateNavigator()->selectDates( 1 ); | 592 | mView->dateNavigator()->selectDates( 1 ); |
593 | mView->dateNavigator()->selectToday(); | 593 | mView->dateNavigator()->selectToday(); |
594 | mView->viewManager()->showJournalView(); | 594 | mView->viewManager()->showJournalView(); |
595 | } | 595 | } |
596 | else if ( msg == "-showKO" ) { | 596 | else if ( msg == "-showKO" ) { |
597 | mView->viewManager()->showNextXView(); | 597 | mView->viewManager()->showNextXView(); |
598 | } | 598 | } |
599 | else if ( msg == "-showWNext" ) { | 599 | else if ( msg == "-showWNext" ) { |
600 | mView->viewManager()->showWhatsNextView(); | 600 | mView->viewManager()->showWhatsNextView(); |
601 | } | 601 | } |
602 | else if ( msg == "nextView()" ) { | 602 | else if ( msg == "nextView()" ) { |
603 | mView->viewManager()->showNextView(); | 603 | mView->viewManager()->showNextView(); |
604 | } | 604 | } |
605 | else if ( msg == "-showNextXView" ) { | 605 | else if ( msg == "-showNextXView" ) { |
606 | mView->viewManager()->showNextXView(); | 606 | mView->viewManager()->showNextXView(); |
607 | } | 607 | } |
608 | 608 | ||
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | showMaximized(); | 612 | showMaximized(); |
613 | raise(); | 613 | raise(); |
614 | } | 614 | } |
615 | void MainWindow::startMultiSync() | 615 | void MainWindow::startMultiSync() |
616 | { | 616 | { |
617 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 617 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
618 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), | 618 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), |
619 | question, | 619 | question, |
620 | i18n("Yes"), i18n("No"), | 620 | i18n("Yes"), i18n("No"), |
621 | 0, 0 ) != 0 ) { | 621 | 0, 0 ) != 0 ) { |
622 | setCaption(i18n("Aborted! Nothing synced!")); | 622 | setCaption(i18n("Aborted! Nothing synced!")); |
623 | return; | 623 | return; |
624 | } | 624 | } |
625 | mSyncManager->multiSync( false ); | 625 | mSyncManager->multiSync( false ); |
626 | #ifndef DESKTOP_VERSION | 626 | #ifndef DESKTOP_VERSION |
627 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); | 627 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); |
628 | #endif | 628 | #endif |
629 | } | 629 | } |
630 | QPixmap MainWindow::loadPixmap( QString name ) | 630 | QPixmap MainWindow::loadPixmap( QString name ) |
631 | { | 631 | { |
632 | return SmallIcon( name ); | 632 | return SmallIcon( name ); |
633 | 633 | ||
634 | } | 634 | } |
635 | void MainWindow::setUsesBigPixmaps ( bool b ) | 635 | void MainWindow::setUsesBigPixmaps ( bool b ) |
636 | { | 636 | { |
637 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); | 637 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); |
638 | if ( b ) | 638 | if ( b ) |
639 | qDebug("KO: BigPixmaps are not supported "); | 639 | qDebug("KO: BigPixmaps are not supported "); |
640 | } | 640 | } |
641 | void MainWindow::initActions() | 641 | void MainWindow::initActions() |
642 | { | 642 | { |
643 | //KOPrefs::instance()->mShowFullMenu | 643 | //KOPrefs::instance()->mShowFullMenu |
644 | iconToolBar->clear(); | 644 | iconToolBar->clear(); |
645 | KOPrefs *p = KOPrefs::instance(); | 645 | KOPrefs *p = KOPrefs::instance(); |
646 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 646 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
647 | 647 | ||
648 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 648 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
649 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 649 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
650 | mCurrentItemMenu = new QPopupMenu ( this ); | 650 | mCurrentItemMenu = new QPopupMenu ( this ); |
651 | QPopupMenu *importMenu = new QPopupMenu( this ); | 651 | QPopupMenu *importMenu = new QPopupMenu( this ); |
652 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 652 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
653 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 653 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
654 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 654 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
655 | selectFilterMenu = new QPopupMenu( this ); | 655 | selectFilterMenu = new QPopupMenu( this ); |
656 | selectFilterMenu->setCheckable( true ); | 656 | selectFilterMenu->setCheckable( true ); |
657 | syncMenu = new QPopupMenu( this ); | 657 | syncMenu = new QPopupMenu( this ); |
658 | configureAgendaMenu = new QPopupMenu( this ); | 658 | configureAgendaMenu = new QPopupMenu( this ); |
659 | configureToolBarMenu = new QPopupMenu( this ); | 659 | configureToolBarMenu = new QPopupMenu( this ); |
660 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 660 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
661 | QIconSet icon; | 661 | QIconSet icon; |
662 | int pixWid = 22, pixHei = 22; | 662 | int pixWid = 22, pixHei = 22; |
663 | QString pathString = ""; | 663 | QString pathString = ""; |
664 | if ( !p->mToolBarMiniIcons ) { | 664 | if ( !p->mToolBarMiniIcons ) { |
665 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { | 665 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { |
666 | pathString += "icons16/"; | 666 | pathString += "icons16/"; |
667 | pixWid = 18; pixHei = 16; | 667 | pixWid = 18; pixHei = 16; |
668 | } | 668 | } |
669 | } else { | 669 | } else { |
670 | pathString += "iconsmini/"; | 670 | pathString += "iconsmini/"; |
671 | pixWid = 18; pixHei = 16; | 671 | pixWid = 18; pixHei = 16; |
672 | } | 672 | } |
673 | if ( KOPrefs::instance()->mShowFullMenu ) { | 673 | if ( KOPrefs::instance()->mShowFullMenu ) { |
674 | QMenuBar *menuBar1; | 674 | QMenuBar *menuBar1; |
675 | menuBar1 = menuBar(); | 675 | menuBar1 = menuBar(); |
676 | menuBar1->insertItem( i18n("File"), importMenu ); | 676 | menuBar1->insertItem( i18n("File"), importMenu ); |
677 | menuBar1->insertItem( i18n("View"), viewMenu ); | 677 | menuBar1->insertItem( i18n("View"), viewMenu ); |
678 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); | 678 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); |
679 | menuBar1->insertItem( i18n("Action"), actionMenu ); | 679 | menuBar1->insertItem( i18n("Action"), actionMenu ); |
680 | #ifdef DESKTOP_VERSION | 680 | #ifdef DESKTOP_VERSION |
681 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 681 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
682 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 682 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
683 | #else | 683 | #else |
684 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 684 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
685 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 685 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
686 | #endif | 686 | #endif |
687 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 687 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
688 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 688 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
689 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 689 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
690 | } else { | 690 | } else { |
691 | QPEMenuBar *menuBar1; | 691 | QPEMenuBar *menuBar1; |
692 | menuBar1 = new QPEMenuBar( iconToolBar ); | 692 | menuBar1 = new QPEMenuBar( iconToolBar ); |
693 | QPopupMenu *menuBar = new QPopupMenu( this ); | 693 | QPopupMenu *menuBar = new QPopupMenu( this ); |
694 | icon = loadPixmap( pathString + "z_menu" ); | 694 | icon = loadPixmap( pathString + "z_menu" ); |
695 | menuBar1->insertItem( icon.pixmap(), menuBar); | 695 | menuBar1->insertItem( icon.pixmap(), menuBar); |
696 | //menuBar1->insertItem( i18n("ME"), menuBar); | 696 | //menuBar1->insertItem( i18n("ME"), menuBar); |
697 | menuBar->insertItem( i18n("File"), importMenu ); | 697 | menuBar->insertItem( i18n("File"), importMenu ); |
698 | menuBar->insertItem( i18n("View"), viewMenu ); | 698 | menuBar->insertItem( i18n("View"), viewMenu ); |
699 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); | 699 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); |
700 | menuBar->insertItem( i18n("Action"), actionMenu ); | 700 | menuBar->insertItem( i18n("Action"), actionMenu ); |
701 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 701 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
702 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 702 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
703 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 703 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
704 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 704 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
705 | menuBar->insertItem( i18n("Help"), helpMenu ); | 705 | menuBar->insertItem( i18n("Help"), helpMenu ); |
706 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 706 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
707 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 707 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
708 | } | 708 | } |
709 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 709 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
710 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 710 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
711 | 711 | ||
712 | 712 | ||
713 | mWeekBgColor = iconToolBar->backgroundColor(); | 713 | mWeekBgColor = iconToolBar->backgroundColor(); |
714 | mWeekPixmap.resize( pixWid , pixHei ); | 714 | mWeekPixmap.resize( pixWid , pixHei ); |
715 | mWeekPixmap.fill( mWeekBgColor ); | 715 | mWeekPixmap.fill( mWeekBgColor ); |
716 | icon = mWeekPixmap; | 716 | icon = mWeekPixmap; |
717 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 717 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
718 | if ( p-> mShowIconWeekNum ) | 718 | if ( p-> mShowIconWeekNum ) |
719 | mWeekAction->addTo( iconToolBar ); | 719 | mWeekAction->addTo( iconToolBar ); |
720 | mWeekFont = font(); | 720 | mWeekFont = font(); |
721 | 721 | ||
722 | int fontPoint = mWeekFont.pointSize(); | 722 | int fontPoint = mWeekFont.pointSize(); |
723 | QFontMetrics f( mWeekFont ); | 723 | QFontMetrics f( mWeekFont ); |
724 | int fontWid = f.width( "30" ); | 724 | int fontWid = f.width( "30" ); |
725 | while ( fontWid > pixWid ) { | 725 | while ( fontWid > pixWid ) { |
726 | --fontPoint; | 726 | --fontPoint; |
727 | mWeekFont.setPointSize( fontPoint ); | 727 | mWeekFont.setPointSize( fontPoint ); |
728 | QFontMetrics f( mWeekFont ); | 728 | QFontMetrics f( mWeekFont ); |
729 | fontWid = f.width( "30" ); | 729 | fontWid = f.width( "30" ); |
730 | //qDebug("dec-- "); | 730 | //qDebug("dec-- "); |
731 | } | 731 | } |
732 | 732 | ||
733 | connect( mWeekAction, SIGNAL( activated() ), | 733 | connect( mWeekAction, SIGNAL( activated() ), |
734 | this, SLOT( weekAction() ) ); | 734 | this, SLOT( weekAction() ) ); |
735 | 735 | ||
736 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 736 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
737 | if ( p->mShowIconFilterview ) { | 737 | if ( p->mShowIconFilterview ) { |
738 | icon = loadPixmap( pathString + "filter" ); | 738 | icon = loadPixmap( pathString + "filter" ); |
739 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); | 739 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); |
740 | connect( actionFilterMenuTB, SIGNAL( activated() ), | 740 | connect( actionFilterMenuTB, SIGNAL( activated() ), |
741 | this, SLOT( fillFilterMenuTB() ) ); | 741 | this, SLOT( fillFilterMenuTB() ) ); |
742 | actionFilterMenuTB->addTo( iconToolBar ); | 742 | actionFilterMenuTB->addTo( iconToolBar ); |
743 | selectFilterMenuTB = new QPopupMenu( this ); | 743 | selectFilterMenuTB = new QPopupMenu( this ); |
744 | selectFilterMenuTB->setCheckable( true ); | 744 | selectFilterMenuTB->setCheckable( true ); |
745 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 745 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
746 | } | 746 | } |
747 | 747 | ||
748 | //#endif | 748 | //#endif |
749 | // ****************** | 749 | // ****************** |
750 | QAction *action; | 750 | QAction *action; |
751 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 751 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
752 | configureToolBarMenu->setCheckable( true ); | 752 | configureToolBarMenu->setCheckable( true ); |
753 | 753 | ||
754 | 754 | ||
755 | configureAgendaMenu->setCheckable( true ); | 755 | configureAgendaMenu->setCheckable( true ); |
756 | int iii ; | 756 | int iii ; |
757 | for ( iii = 1;iii<= 10 ;++iii ){ | 757 | for ( iii = 1;iii<= 10 ;++iii ){ |
758 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 758 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
759 | } | 759 | } |
760 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 760 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
761 | 761 | ||
762 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 762 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
763 | this, SLOT( showConfigureAgenda( ) ) ); | 763 | this, SLOT( showConfigureAgenda( ) ) ); |
764 | icon = loadPixmap( pathString + "today" ); | 764 | icon = loadPixmap( pathString + "today" ); |
765 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 765 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
766 | today_action->addTo( actionMenu ); | 766 | today_action->addTo( actionMenu ); |
767 | connect( today_action, SIGNAL( activated() ), | 767 | connect( today_action, SIGNAL( activated() ), |
768 | mView, SLOT( goToday() ) ); | 768 | mView, SLOT( goToday() ) ); |
769 | 769 | ||
770 | icon = loadPixmap( pathString + "picker" ); | 770 | icon = loadPixmap( pathString + "picker" ); |
771 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); | 771 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); |
772 | dPickerAction->addTo( actionMenu ); | 772 | dPickerAction->addTo( actionMenu ); |
773 | connect( dPickerAction, SIGNAL( activated() ), | 773 | connect( dPickerAction, SIGNAL( activated() ), |
774 | mView, SLOT( showDatePicker() ) ); | 774 | mView, SLOT( showDatePicker() ) ); |
775 | 775 | ||
776 | icon = loadPixmap( pathString + "search" ); | 776 | icon = loadPixmap( pathString + "search" ); |
777 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 777 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
778 | search_action->addTo( actionMenu ); | 778 | search_action->addTo( actionMenu ); |
779 | connect( search_action, SIGNAL( activated() ), | 779 | connect( search_action, SIGNAL( activated() ), |
780 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 780 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
781 | 781 | ||
782 | actionMenu->insertSeparator(); | 782 | actionMenu->insertSeparator(); |
783 | 783 | ||
784 | 784 | ||
785 | 785 | ||
786 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 786 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
787 | action->addTo( mCurrentItemMenu ); | 787 | action->addTo( mCurrentItemMenu ); |
788 | connect( action, SIGNAL( activated() ), | 788 | connect( action, SIGNAL( activated() ), |
789 | mView, SLOT( undo_delete() ) ); | 789 | mView, SLOT( undo_delete() ) ); |
790 | mCurrentItemMenu->insertSeparator(); | 790 | mCurrentItemMenu->insertSeparator(); |
791 | icon = loadPixmap( pathString + "newevent" ); | 791 | icon = loadPixmap( pathString + "newevent" ); |
792 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 792 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
793 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 793 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
794 | configureToolBarMenu->insertSeparator(); | 794 | configureToolBarMenu->insertSeparator(); |
795 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 795 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
796 | configureToolBarMenu->insertSeparator(); | 796 | configureToolBarMenu->insertSeparator(); |
797 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 797 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
798 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 798 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
799 | 799 | ||
800 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); | 800 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); |
801 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); | 801 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); |
802 | mShowAction->addTo( mCurrentItemMenu ); | 802 | mShowAction->addTo( mCurrentItemMenu ); |
803 | connect( mShowAction, SIGNAL( activated() ), | 803 | connect( mShowAction, SIGNAL( activated() ), |
804 | mView, SLOT( showIncidence() ) ); | 804 | mView, SLOT( showIncidence() ) ); |
805 | 805 | ||
806 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 806 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
807 | mEditAction->addTo( mCurrentItemMenu ); | 807 | mEditAction->addTo( mCurrentItemMenu ); |
808 | connect( mEditAction, SIGNAL( activated() ), | 808 | connect( mEditAction, SIGNAL( activated() ), |
809 | mView, SLOT( editIncidence() ) ); | 809 | mView, SLOT( editIncidence() ) ); |
810 | 810 | ||
811 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 811 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
812 | mDeleteAction->addTo( mCurrentItemMenu ); | 812 | mDeleteAction->addTo( mCurrentItemMenu ); |
813 | connect( mDeleteAction, SIGNAL( activated() ), | 813 | connect( mDeleteAction, SIGNAL( activated() ), |
814 | mView, SLOT( deleteIncidence() ) ); | 814 | mView, SLOT( deleteIncidence() ) ); |
815 | 815 | ||
816 | 816 | ||
817 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 817 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
818 | mCloneAction->addTo( mCurrentItemMenu ); | 818 | mCloneAction->addTo( mCurrentItemMenu ); |
819 | connect( mCloneAction, SIGNAL( activated() ), | 819 | connect( mCloneAction, SIGNAL( activated() ), |
820 | mView, SLOT( cloneIncidence() ) ); | 820 | mView, SLOT( cloneIncidence() ) ); |
821 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 821 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
822 | mMoveAction->addTo( mCurrentItemMenu ); | 822 | mMoveAction->addTo( mCurrentItemMenu ); |
823 | connect( mMoveAction, SIGNAL( activated() ), | 823 | connect( mMoveAction, SIGNAL( activated() ), |
824 | mView, SLOT( moveIncidence() ) ); | 824 | mView, SLOT( moveIncidence() ) ); |
825 | #ifndef DESKTOP_VERSION | 825 | #ifndef DESKTOP_VERSION |
826 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 826 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
827 | mBeamAction->addTo(mCurrentItemMenu ); | 827 | mBeamAction->addTo(mCurrentItemMenu ); |
828 | connect( mBeamAction, SIGNAL( activated() ), | 828 | connect( mBeamAction, SIGNAL( activated() ), |
829 | mView, SLOT( beamIncidence() ) ); | 829 | mView, SLOT( beamIncidence() ) ); |
830 | #endif | 830 | #endif |
831 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 831 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
832 | mCancelAction->addTo( mCurrentItemMenu ); | 832 | mCancelAction->addTo( mCurrentItemMenu ); |
833 | connect( mCancelAction, SIGNAL( activated() ), | 833 | connect( mCancelAction, SIGNAL( activated() ), |
834 | mView, SLOT( toggleCancelIncidence() ) ); | 834 | mView, SLOT( toggleCancelIncidence() ) ); |
835 | 835 | ||
836 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 836 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
837 | ne_action->addTo( actionMenu ); | 837 | ne_action->addTo( actionMenu ); |
838 | connect( ne_action, SIGNAL( activated() ), | 838 | connect( ne_action, SIGNAL( activated() ), |
839 | mView, SLOT( newEvent() ) ); | 839 | mView, SLOT( newEvent() ) ); |
840 | icon = loadPixmap( pathString + "newtodo" ); | 840 | icon = loadPixmap( pathString + "newtodo" ); |
841 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 841 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
842 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 842 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
843 | nt_action->addTo( actionMenu ); | 843 | nt_action->addTo( actionMenu ); |
844 | connect( nt_action, SIGNAL( activated() ), | 844 | connect( nt_action, SIGNAL( activated() ), |
845 | mView, SLOT( newTodo() ) ); | 845 | mView, SLOT( newTodo() ) ); |
846 | 846 | ||
847 | 847 | ||
848 | 848 | ||
849 | // *********************** | 849 | // *********************** |
850 | if ( KOPrefs::instance()->mVerticalScreen ) { | 850 | if ( KOPrefs::instance()->mVerticalScreen ) { |
851 | icon = SmallIcon( "1updownarrow" ); | 851 | icon = SmallIcon( "1updownarrow" ); |
852 | } else { | 852 | } else { |
853 | icon = SmallIcon("1leftrightarrow" ); | 853 | icon = SmallIcon("1leftrightarrow" ); |
854 | } | 854 | } |
855 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); | 855 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); |
856 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); | 856 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); |
857 | FSaction->addTo( viewMenu ); | 857 | FSaction->addTo( viewMenu ); |
858 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); | 858 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); |
859 | 859 | ||
860 | 860 | ||
861 | icon = loadPixmap( pathString + "filter" ); | 861 | icon = loadPixmap( pathString + "filter" ); |
862 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); | 862 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); |
863 | icon = loadPixmap( pathString + "configure" ); | 863 | icon = loadPixmap( pathString + "configure" ); |
864 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); | 864 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); |
865 | action->addTo( viewMenu ); | 865 | action->addTo( viewMenu ); |
866 | connect( action, SIGNAL( activated() ), | 866 | connect( action, SIGNAL( activated() ), |
867 | mView, SLOT( toggleFilter() ) ); | 867 | mView, SLOT( toggleFilter() ) ); |
868 | mToggleFilter = action; | 868 | mToggleFilter = action; |
869 | icon = loadPixmap( pathString + "navi" ); | 869 | icon = loadPixmap( pathString + "navi" ); |
870 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); | 870 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); |
871 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 871 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
872 | action->addTo( viewMenu ); | 872 | action->addTo( viewMenu ); |
873 | connect( action, SIGNAL( activated() ), | 873 | connect( action, SIGNAL( activated() ), |
874 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 874 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
875 | mToggleNav = action ; | 875 | mToggleNav = action ; |
876 | icon = loadPixmap( pathString + "allday" ); | 876 | icon = loadPixmap( pathString + "allday" ); |
877 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); | 877 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); |
878 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 878 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
879 | action->addTo( viewMenu ); | 879 | action->addTo( viewMenu ); |
880 | connect( action, SIGNAL( activated() ), | 880 | connect( action, SIGNAL( activated() ), |
881 | mView, SLOT( toggleAllDaySize() ) ); | 881 | mView, SLOT( toggleAllDaySize() ) ); |
882 | mToggleAllday = action; | 882 | mToggleAllday = action; |
883 | 883 | ||
884 | 884 | ||
885 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 885 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
886 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 886 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
887 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 887 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
888 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 888 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
889 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 889 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
890 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 890 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
891 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 891 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
892 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); | 892 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); |
893 | 893 | ||
894 | 894 | ||
895 | dPickerAction->addTo( iconToolBar ); | 895 | dPickerAction->addTo( iconToolBar ); |
896 | viewMenu->insertSeparator(); | 896 | viewMenu->insertSeparator(); |
897 | 897 | ||
898 | if ( p-> mShowIconToggleFull ) | 898 | if ( p-> mShowIconToggleFull ) |
899 | FSaction->addTo( iconToolBar ); | 899 | FSaction->addTo( iconToolBar ); |
900 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); | 900 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); |
901 | 901 | ||
902 | //******************** | 902 | //******************** |
903 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); | 903 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); |
904 | 904 | ||
905 | 905 | ||
906 | icon = loadPixmap( pathString + "whatsnext" ); | 906 | icon = loadPixmap( pathString + "whatsnext" ); |
907 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 907 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
908 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 908 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
909 | whatsnext_action->addTo( viewMenu ); | 909 | whatsnext_action->addTo( viewMenu ); |
910 | connect( whatsnext_action, SIGNAL( activated() ), | 910 | connect( whatsnext_action, SIGNAL( activated() ), |
911 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 911 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
912 | 912 | ||
913 | icon = loadPixmap( pathString + "xdays" ); | 913 | icon = loadPixmap( pathString + "xdays" ); |
914 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 914 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
915 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 915 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
916 | xdays_action->addTo( viewMenu ); | 916 | xdays_action->addTo( viewMenu ); |
917 | connect( xdays_action, SIGNAL( activated() ), | 917 | connect( xdays_action, SIGNAL( activated() ), |
918 | mView->viewManager(), SLOT( showNextXView() ) ); | 918 | mView->viewManager(), SLOT( showNextXView() ) ); |
919 | 919 | ||
920 | 920 | ||
921 | icon = loadPixmap( pathString + "journal" ); | 921 | icon = loadPixmap( pathString + "journal" ); |
922 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 922 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
923 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 923 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
924 | viewjournal_action->addTo( viewMenu ); | 924 | viewjournal_action->addTo( viewMenu ); |
925 | connect( viewjournal_action, SIGNAL( activated() ), | 925 | connect( viewjournal_action, SIGNAL( activated() ), |
926 | mView->viewManager(), SLOT( showJournalView() ) ); | 926 | mView->viewManager(), SLOT( showJournalView() ) ); |
927 | 927 | ||
928 | 928 | ||
929 | icon = loadPixmap( pathString + "day" ); | 929 | icon = loadPixmap( pathString + "day" ); |
930 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 930 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
931 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 931 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
932 | day1_action->addTo( viewMenu ); | 932 | day1_action->addTo( viewMenu ); |
933 | // action->addTo( toolBar ); | 933 | // action->addTo( toolBar ); |
934 | connect( day1_action, SIGNAL( activated() ), | 934 | connect( day1_action, SIGNAL( activated() ), |
935 | mView->viewManager(), SLOT( showDayView() ) ); | 935 | mView->viewManager(), SLOT( showDayView() ) ); |
936 | 936 | ||
937 | icon = loadPixmap( pathString + "workweek" ); | 937 | icon = loadPixmap( pathString + "workweek" ); |
938 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 938 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
939 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 939 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
940 | day5_action->addTo( viewMenu ); | 940 | day5_action->addTo( viewMenu ); |
941 | connect( day5_action, SIGNAL( activated() ), | 941 | connect( day5_action, SIGNAL( activated() ), |
942 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 942 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
943 | 943 | ||
944 | icon = loadPixmap( pathString + "week" ); | 944 | icon = loadPixmap( pathString + "week" ); |
945 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 945 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
946 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 946 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
947 | day7_action->addTo( viewMenu ); | 947 | day7_action->addTo( viewMenu ); |
948 | connect( day7_action, SIGNAL( activated() ), | 948 | connect( day7_action, SIGNAL( activated() ), |
949 | mView->viewManager(), SLOT( showWeekView() ) ); | 949 | mView->viewManager(), SLOT( showWeekView() ) ); |
950 | 950 | ||
951 | icon = loadPixmap( pathString + "workweek2" ); | 951 | icon = loadPixmap( pathString + "workweek2" ); |
952 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 952 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
953 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 953 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
954 | day6_action->addTo( viewMenu ); | 954 | day6_action->addTo( viewMenu ); |
955 | connect( day6_action, SIGNAL( activated() ), | 955 | connect( day6_action, SIGNAL( activated() ), |
956 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 956 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
957 | 957 | ||
958 | icon = loadPixmap( pathString + "month" ); | 958 | icon = loadPixmap( pathString + "month" ); |
959 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 959 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
960 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 960 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
961 | month_action->addTo( viewMenu ); | 961 | month_action->addTo( viewMenu ); |
962 | connect( month_action, SIGNAL( activated() ), | 962 | connect( month_action, SIGNAL( activated() ), |
963 | mView->viewManager(), SLOT( showMonthView() ) ); | 963 | mView->viewManager(), SLOT( showMonthView() ) ); |
964 | 964 | ||
965 | icon = loadPixmap( pathString + "list" ); | 965 | icon = loadPixmap( pathString + "list" ); |
966 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 966 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
967 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 967 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
968 | showlist_action->addTo( viewMenu ); | 968 | showlist_action->addTo( viewMenu ); |
969 | connect( showlist_action, SIGNAL( activated() ), | 969 | connect( showlist_action, SIGNAL( activated() ), |
970 | mView->viewManager(), SLOT( showListView() ) ); | 970 | mView->viewManager(), SLOT( showListView() ) ); |
971 | 971 | ||
972 | icon = loadPixmap( pathString + "todo" ); | 972 | icon = loadPixmap( pathString + "todo" ); |
973 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 973 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
974 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 974 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
975 | todoview_action->addTo( viewMenu ); | 975 | todoview_action->addTo( viewMenu ); |
976 | connect( todoview_action, SIGNAL( activated() ), | 976 | connect( todoview_action, SIGNAL( activated() ), |
977 | mView->viewManager(), SLOT( showTodoView() ) ); | 977 | mView->viewManager(), SLOT( showTodoView() ) ); |
978 | 978 | ||
979 | 979 | ||
980 | 980 | ||
981 | #if 0 | 981 | #if 0 |
982 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 982 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
983 | action->addTo( viewMenu ); | 983 | action->addTo( viewMenu ); |
984 | connect( action, SIGNAL( activated() ), | 984 | connect( action, SIGNAL( activated() ), |
985 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 985 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
986 | #endif | 986 | #endif |
987 | 987 | ||
988 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 988 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
989 | this ); | 989 | this ); |
990 | mNewSubTodoAction->addTo( actionMenu ); | 990 | mNewSubTodoAction->addTo( actionMenu ); |
991 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 991 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
992 | mView, SLOT( newSubTodo() ) ); | 992 | mView, SLOT( newSubTodo() ) ); |
993 | 993 | ||
994 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, | 994 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, |
995 | this ); | 995 | this ); |
996 | action->addTo( actionMenu ); | 996 | action->addTo( actionMenu ); |
997 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 997 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
998 | 998 | ||
999 | 999 | ||
1000 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); | 1000 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); |
1001 | 1001 | ||
1002 | 1002 | ||
1003 | 1003 | ||
1004 | actionMenu->insertSeparator(); | 1004 | actionMenu->insertSeparator(); |
1005 | action = new QAction( "manage cat", i18n("Edit category list..."), 0, | 1005 | action = new QAction( "manage cat", i18n("Edit category list..."), 0, |
1006 | this ); | 1006 | this ); |
1007 | action->addTo( actionMenu ); | 1007 | action->addTo( actionMenu ); |
1008 | connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); | 1008 | connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); |
1009 | 1009 | ||
1010 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 1010 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
1011 | this ); | 1011 | this ); |
1012 | action->addTo( actionMenu ); | 1012 | action->addTo( actionMenu ); |
1013 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 1013 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
1014 | 1014 | ||
1015 | 1015 | ||
1016 | actionMenu->insertSeparator(); | 1016 | actionMenu->insertSeparator(); |
1017 | icon = loadPixmap( pathString + "configure" ); | 1017 | icon = loadPixmap( pathString + "configure" ); |
1018 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); | 1018 | action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); |
1019 | action->addTo( actionMenu ); | 1019 | action->addTo( actionMenu ); |
1020 | connect( action, SIGNAL( activated() ), | 1020 | connect( action, SIGNAL( activated() ), |
1021 | mView, SLOT( edit_options() ) ); | 1021 | mView, SLOT( edit_options() ) ); |
1022 | icon = loadPixmap( pathString + "configure" ); | 1022 | icon = loadPixmap( pathString + "configure" ); |
1023 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); | 1023 | action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); |
1024 | action->addTo( actionMenu ); | 1024 | action->addTo( actionMenu ); |
1025 | connect( action, SIGNAL( activated() ), | 1025 | connect( action, SIGNAL( activated() ), |
1026 | mView, SLOT( edit_global_options() ) ); | 1026 | mView, SLOT( edit_global_options() ) ); |
1027 | if ( KOPrefs::instance()->mShowFullMenu ) { | 1027 | if ( KOPrefs::instance()->mShowFullMenu ) { |
1028 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 1028 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
1029 | 1029 | ||
1030 | } | 1030 | } |
1031 | // actionMenu->insertSeparator(); | 1031 | // actionMenu->insertSeparator(); |
1032 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 1032 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
1033 | this ); | 1033 | this ); |
1034 | action->addTo( importMenu_X ); | 1034 | action->addTo( importMenu_X ); |
1035 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 1035 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
1036 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 1036 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
1037 | this ); | 1037 | this ); |
1038 | action->addTo( importMenu_X ); | 1038 | action->addTo( importMenu_X ); |
1039 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 1039 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
1040 | importMenu_X->insertSeparator(); | 1040 | importMenu_X->insertSeparator(); |
1041 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 1041 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
1042 | this ); | 1042 | this ); |
1043 | action->addTo( importMenu_X ); | 1043 | action->addTo( importMenu_X ); |
1044 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 1044 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
1045 | //#ifndef DESKTOP_VERSION | 1045 | //#ifndef DESKTOP_VERSION |
1046 | importMenu_X->insertSeparator(); | 1046 | importMenu_X->insertSeparator(); |
1047 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 1047 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
1048 | this ); | 1048 | this ); |
1049 | action->addTo( importMenu_X ); | 1049 | action->addTo( importMenu_X ); |
1050 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 1050 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
1051 | //#else | 1051 | //#else |
1052 | #ifdef _OL_IMPORT_ | 1052 | #ifdef _OL_IMPORT_ |
1053 | importMenu_X->insertSeparator(); | 1053 | importMenu_X->insertSeparator(); |
1054 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 1054 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
1055 | this ); | 1055 | this ); |
1056 | action->addTo( importMenu_X ); | 1056 | action->addTo( importMenu_X ); |
1057 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 1057 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
1058 | #endif | 1058 | #endif |
1059 | //#endif | 1059 | //#endif |
1060 | 1060 | ||
1061 | //importMenu->insertSeparator(); | 1061 | //importMenu->insertSeparator(); |
1062 | #if 0 | 1062 | #if 0 |
1063 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 1063 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
1064 | this ); | 1064 | this ); |
1065 | action->addTo( importMenu ); | 1065 | action->addTo( importMenu ); |
1066 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 1066 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
1067 | #endif | 1067 | #endif |
1068 | action = new QAction( "save_cal", i18n("Save Backup..."), 0, | 1068 | action = new QAction( "save_cal", i18n("Save Backup..."), 0, |
1069 | this ); | 1069 | this ); |
1070 | action->addTo( importMenu ); | 1070 | action->addTo( importMenu ); |
1071 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 1071 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
1072 | importMenu->insertSeparator(); | 1072 | importMenu->insertSeparator(); |
1073 | importMenu->insertItem( i18n("Import"), importMenu_X ); | 1073 | importMenu->insertItem( i18n("Import"), importMenu_X ); |
1074 | //importMenu->insertSeparator(); | 1074 | //importMenu->insertSeparator(); |
1075 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 1075 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
1076 | this ); | 1076 | this ); |
1077 | action->addTo( exportMenu_X ); | 1077 | action->addTo( exportMenu_X ); |
1078 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 1078 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
1079 | 1079 | ||
1080 | 1080 | ||
1081 | //LR | 1081 | //LR |
1082 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 1082 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
1083 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1083 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1084 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1084 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1085 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 1085 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
1086 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); | 1086 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); |
1087 | 1087 | ||
1088 | importMenu->insertItem( i18n("Export"), exportMenu_X ); | 1088 | importMenu->insertItem( i18n("Export"), exportMenu_X ); |
1089 | #ifndef DESKTOP_VERSION | 1089 | #ifndef DESKTOP_VERSION |
1090 | //importMenu->insertSeparator(); | 1090 | //importMenu->insertSeparator(); |
1091 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 1091 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
1092 | this ); | 1092 | this ); |
1093 | brAction->addTo( beamMenu_X ); | 1093 | brAction->addTo( beamMenu_X ); |
1094 | brAction->setToggleAction (true ) ; | 1094 | brAction->setToggleAction (true ) ; |
1095 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 1095 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
1096 | 1096 | ||
1097 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 1097 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
1098 | this ); | 1098 | this ); |
1099 | action->addTo( beamMenu_X ); | 1099 | action->addTo( beamMenu_X ); |
1100 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 1100 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
1101 | 1101 | ||
1102 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 1102 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
1103 | this ); | 1103 | this ); |
1104 | action->addTo( beamMenu_X ); | 1104 | action->addTo( beamMenu_X ); |
1105 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 1105 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
1106 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); | 1106 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); |
1107 | #else | 1107 | #else |
1108 | //importMenu->insertSeparator(); | 1108 | //importMenu->insertSeparator(); |
1109 | icon = loadPixmap( pathString + "print" ); | 1109 | icon = loadPixmap( pathString + "print" ); |
1110 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 1110 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
1111 | action->addTo( beamMenu_X ); | 1111 | action->addTo( beamMenu_X ); |
1112 | connect( action, SIGNAL( activated() ), | 1112 | connect( action, SIGNAL( activated() ), |
1113 | this, SLOT( printCal() ) ); | 1113 | this, SLOT( printCal() ) ); |
1114 | 1114 | ||
1115 | icon = loadPixmap( pathString + "print" ); | 1115 | icon = loadPixmap( pathString + "print" ); |
1116 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 1116 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
1117 | action->addTo( beamMenu_X ); | 1117 | action->addTo( beamMenu_X ); |
1118 | connect( action, SIGNAL( activated() ), | 1118 | connect( action, SIGNAL( activated() ), |
1119 | this, SLOT( printSel() ) ); | 1119 | this, SLOT( printSel() ) ); |
1120 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 1120 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
1121 | action->addTo( beamMenu_X ); | 1121 | action->addTo( beamMenu_X ); |
1122 | connect( action, SIGNAL( activated() ), | 1122 | connect( action, SIGNAL( activated() ), |
1123 | mView->viewManager(), SLOT( slotprintWNV() ) ); | 1123 | mView->viewManager(), SLOT( slotprintWNV() ) ); |
1124 | 1124 | ||
1125 | 1125 | ||
1126 | icon = loadPixmap( pathString + "print" ); | 1126 | icon = loadPixmap( pathString + "print" ); |
1127 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); | 1127 | action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); |
1128 | action->addTo( beamMenu_X ); | 1128 | action->addTo( beamMenu_X ); |
1129 | connect( action, SIGNAL( activated() ), | 1129 | connect( action, SIGNAL( activated() ), |
1130 | this, SLOT( printListView() ) ); | 1130 | this, SLOT( printListView() ) ); |
1131 | 1131 | ||
1132 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); | 1132 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); |
1133 | action->addTo( beamMenu_X ); | 1133 | action->addTo( beamMenu_X ); |
1134 | connect( action, SIGNAL( activated() ), | 1134 | connect( action, SIGNAL( activated() ), |
1135 | mView, SLOT( slotprintSelInc() ) ); | 1135 | mView, SLOT( slotprintSelInc() ) ); |
1136 | 1136 | ||
1137 | importMenu->insertItem( i18n("Print"), beamMenu_X ); | 1137 | importMenu->insertItem( i18n("Print"), beamMenu_X ); |
1138 | #endif | 1138 | #endif |
1139 | 1139 | ||
1140 | importMenu->insertSeparator(); | 1140 | importMenu->insertSeparator(); |
1141 | action = new QAction( "beam all", i18n("Save"), 0, | 1141 | action = new QAction( "beam all", i18n("Save"), 0, |
1142 | this ); | 1142 | this ); |
1143 | action->addTo( importMenu ); | 1143 | action->addTo( importMenu ); |
1144 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 1144 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
1145 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 1145 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
1146 | this ); | 1146 | this ); |
1147 | action->addTo( importMenu ); | 1147 | action->addTo( importMenu ); |
1148 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 1148 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
1149 | 1149 | ||
1150 | //menuBar->insertItem( "Configure",configureMenu ); | 1150 | //menuBar->insertItem( "Configure",configureMenu ); |
1151 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 1151 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
1152 | icon = loadPixmap( "korganizer/korganizer" ); | 1152 | icon = loadPixmap( "korganizer/korganizer" ); |
1153 | 1153 | ||
1154 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 1154 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
1155 | action->addTo( helpMenu ); | 1155 | action->addTo( helpMenu ); |
1156 | connect( action, SIGNAL( activated() ), | 1156 | connect( action, SIGNAL( activated() ), |
1157 | SLOT( whatsNew() ) ); | 1157 | SLOT( whatsNew() ) ); |
1158 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 1158 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
1159 | action->addTo( helpMenu ); | 1159 | action->addTo( helpMenu ); |
1160 | connect( action, SIGNAL( activated() ), | 1160 | connect( action, SIGNAL( activated() ), |
1161 | SLOT( features() ) ); | 1161 | SLOT( features() ) ); |
1162 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 1162 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
1163 | action->addTo( helpMenu ); | 1163 | action->addTo( helpMenu ); |
1164 | connect( action, SIGNAL( activated() ), | 1164 | connect( action, SIGNAL( activated() ), |
1165 | SLOT( keyBindings() ) ); | 1165 | SLOT( keyBindings() ) ); |
1166 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); | 1166 | action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); |
1167 | action->addTo( helpMenu ); | 1167 | action->addTo( helpMenu ); |
1168 | connect( action, SIGNAL( activated() ), | 1168 | connect( action, SIGNAL( activated() ), |
1169 | SLOT( storagehowto() ) ); | 1169 | SLOT( storagehowto() ) ); |
1170 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); | 1170 | action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); |
1171 | action->addTo( helpMenu ); | 1171 | action->addTo( helpMenu ); |
1172 | connect( action, SIGNAL( activated() ), | 1172 | connect( action, SIGNAL( activated() ), |
1173 | SLOT( timetrackinghowto() ) ); | 1173 | SLOT( timetrackinghowto() ) ); |
1174 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 1174 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
1175 | action->addTo( helpMenu ); | 1175 | action->addTo( helpMenu ); |
1176 | connect( action, SIGNAL( activated() ), | 1176 | connect( action, SIGNAL( activated() ), |
1177 | SLOT( synchowto() ) ); | 1177 | SLOT( synchowto() ) ); |
1178 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 1178 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
1179 | action->addTo( helpMenu ); | 1179 | action->addTo( helpMenu ); |
1180 | connect( action, SIGNAL( activated() ), | 1180 | connect( action, SIGNAL( activated() ), |
1181 | SLOT( kdesynchowto() ) ); | 1181 | SLOT( kdesynchowto() ) ); |
1182 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 1182 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
1183 | action->addTo( helpMenu ); | 1183 | action->addTo( helpMenu ); |
1184 | connect( action, SIGNAL( activated() ), | 1184 | connect( action, SIGNAL( activated() ), |
1185 | SLOT( multisynchowto() ) ); | 1185 | SLOT( multisynchowto() ) ); |
1186 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 1186 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
1187 | action->addTo( helpMenu ); | 1187 | action->addTo( helpMenu ); |
1188 | connect( action, SIGNAL( activated() ), | 1188 | connect( action, SIGNAL( activated() ), |
1189 | SLOT( aboutAutoSaving() ) ); | 1189 | SLOT( aboutAutoSaving() ) ); |
1190 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 1190 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
1191 | action->addTo( helpMenu ); | 1191 | action->addTo( helpMenu ); |
1192 | connect( action, SIGNAL( activated() ), | 1192 | connect( action, SIGNAL( activated() ), |
1193 | SLOT( aboutKnownBugs() ) ); | 1193 | SLOT( aboutKnownBugs() ) ); |
1194 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 1194 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
1195 | action->addTo( helpMenu ); | 1195 | action->addTo( helpMenu ); |
1196 | connect( action, SIGNAL( activated() ), | 1196 | connect( action, SIGNAL( activated() ), |
1197 | SLOT( usertrans() ) ); | 1197 | SLOT( usertrans() ) ); |
1198 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 1198 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
1199 | action->addTo( helpMenu ); | 1199 | action->addTo( helpMenu ); |
1200 | connect( action, SIGNAL( activated() ), | 1200 | connect( action, SIGNAL( activated() ), |
1201 | SLOT( faq() ) ); | 1201 | SLOT( faq() ) ); |
1202 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 1202 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
1203 | action->addTo( helpMenu ); | 1203 | action->addTo( helpMenu ); |
1204 | connect( action, SIGNAL( activated() ), | 1204 | connect( action, SIGNAL( activated() ), |
1205 | SLOT( licence() ) ); | 1205 | SLOT( licence() ) ); |
1206 | action = new QAction( "about", i18n("About..."), 0, this ); | 1206 | action = new QAction( "about", i18n("About..."), 0, this ); |
1207 | action->addTo( helpMenu ); | 1207 | action->addTo( helpMenu ); |
1208 | connect( action, SIGNAL( activated() ), | 1208 | connect( action, SIGNAL( activated() ), |
1209 | SLOT( about() ) ); | 1209 | SLOT( about() ) ); |
1210 | //menuBar->insertSeparator(); | 1210 | //menuBar->insertSeparator(); |
1211 | 1211 | ||
1212 | // ****************************************************** | 1212 | // ****************************************************** |
1213 | // menubar icons | 1213 | // menubar icons |
1214 | 1214 | ||
1215 | 1215 | ||
1216 | 1216 | ||
1217 | //menuBar->insertItem( iconToolBar ); | 1217 | //menuBar->insertItem( iconToolBar ); |
1218 | //xdays_action | 1218 | //xdays_action |
1219 | if (p-> mShowIconNewEvent) | 1219 | if (p-> mShowIconNewEvent) |
1220 | ne_action->addTo( iconToolBar ); | 1220 | ne_action->addTo( iconToolBar ); |
1221 | if (p->mShowIconNewTodo ) | 1221 | if (p->mShowIconNewTodo ) |
1222 | nt_action->addTo( iconToolBar ); | 1222 | nt_action->addTo( iconToolBar ); |
1223 | if (p-> mShowIconSearch) | 1223 | if (p-> mShowIconSearch) |
1224 | search_action->addTo( iconToolBar ); | 1224 | search_action->addTo( iconToolBar ); |
1225 | if (p-> mShowIconWhatsThis) | 1225 | if (p-> mShowIconWhatsThis) |
1226 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1226 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1227 | if (p-> mShowIconNext) | 1227 | if (p-> mShowIconNext) |
1228 | whatsnext_action->addTo( viewToolBar ); | 1228 | whatsnext_action->addTo( viewToolBar ); |
1229 | if (p-> mShowIconNextDays) | 1229 | if (p-> mShowIconNextDays) |
1230 | xdays_action->addTo( viewToolBar ); | 1230 | xdays_action->addTo( viewToolBar ); |
1231 | if (p-> mShowIconJournal) | 1231 | if (p-> mShowIconJournal) |
1232 | viewjournal_action->addTo( viewToolBar ); | 1232 | viewjournal_action->addTo( viewToolBar ); |
1233 | if (p-> mShowIconDay1) | 1233 | if (p-> mShowIconDay1) |
1234 | day1_action->addTo( viewToolBar ); | 1234 | day1_action->addTo( viewToolBar ); |
1235 | if (p-> mShowIconDay5) | 1235 | if (p-> mShowIconDay5) |
1236 | day5_action->addTo( viewToolBar ); | 1236 | day5_action->addTo( viewToolBar ); |
1237 | if (p-> mShowIconDay7) | 1237 | if (p-> mShowIconDay7) |
1238 | day7_action->addTo( viewToolBar ); | 1238 | day7_action->addTo( viewToolBar ); |
1239 | if (p-> mShowIconDay6) | 1239 | if (p-> mShowIconDay6) |
1240 | day6_action->addTo( viewToolBar ); | 1240 | day6_action->addTo( viewToolBar ); |
1241 | if (p-> mShowIconMonth) | 1241 | if (p-> mShowIconMonth) |
1242 | month_action->addTo( viewToolBar ); | 1242 | month_action->addTo( viewToolBar ); |
1243 | if (p-> mShowIconList) | 1243 | if (p-> mShowIconList) |
1244 | showlist_action->addTo( viewToolBar ); | 1244 | showlist_action->addTo( viewToolBar ); |
1245 | if (p-> mShowIconTodoview) | 1245 | if (p-> mShowIconTodoview) |
1246 | todoview_action->addTo( viewToolBar ); | 1246 | todoview_action->addTo( viewToolBar ); |
1247 | 1247 | ||
1248 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1248 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1249 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); | 1249 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); |
1250 | if (p-> mShowIconBackFast) { | 1250 | if (p-> mShowIconBackFast) { |
1251 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1251 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1252 | connect( action, SIGNAL( activated() ), | 1252 | connect( action, SIGNAL( activated() ), |
1253 | mView, SLOT( goPreviousMonth() ) ); | 1253 | mView, SLOT( goPreviousMonth() ) ); |
1254 | action->addTo( navigatorToolBar ); | 1254 | action->addTo( navigatorToolBar ); |
1255 | } | 1255 | } |
1256 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1256 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1257 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); | 1257 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); |
1258 | if (p-> mShowIconBack) { | 1258 | if (p-> mShowIconBack) { |
1259 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1259 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1260 | connect( action, SIGNAL( activated() ), | 1260 | connect( action, SIGNAL( activated() ), |
1261 | mView, SLOT( goPrevious() ) ); | 1261 | mView, SLOT( goPrevious() ) ); |
1262 | action->addTo( navigatorToolBar ); | 1262 | action->addTo( navigatorToolBar ); |
1263 | } | 1263 | } |
1264 | icon = loadPixmap( pathString + "today" ); | 1264 | icon = loadPixmap( pathString + "today" ); |
1265 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1265 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1266 | if (p-> mShowIconToday) | 1266 | if (p-> mShowIconToday) |
1267 | today_action->addTo( navigatorToolBar ); | 1267 | today_action->addTo( navigatorToolBar ); |
1268 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1268 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1269 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1269 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1270 | if (p-> mShowIconForward) { | 1270 | if (p-> mShowIconForward) { |
1271 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1271 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1272 | connect( action, SIGNAL( activated() ), | 1272 | connect( action, SIGNAL( activated() ), |
1273 | mView, SLOT( goNext() ) ); | 1273 | mView, SLOT( goNext() ) ); |
1274 | action->addTo( navigatorToolBar ); | 1274 | action->addTo( navigatorToolBar ); |
1275 | } | 1275 | } |
1276 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1276 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1277 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1277 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1278 | if (p-> mShowIconForwardFast) { | 1278 | if (p-> mShowIconForwardFast) { |
1279 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1279 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1280 | connect( action, SIGNAL( activated() ), | 1280 | connect( action, SIGNAL( activated() ), |
1281 | mView, SLOT( goNextMonth() ) ); | 1281 | mView, SLOT( goNextMonth() ) ); |
1282 | action->addTo( navigatorToolBar ); | 1282 | action->addTo( navigatorToolBar ); |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | 1285 | ||
1286 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); | 1286 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); |
1287 | 1287 | ||
1288 | 1288 | ||
1289 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); | 1289 | if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); |
1290 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); | 1290 | if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); |
1291 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); | 1291 | if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); |
1292 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); | 1292 | if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); |
1293 | 1293 | ||
1294 | if (p-> mShowIconNewEvent) | 1294 | if (p-> mShowIconNewEvent) |
1295 | configureToolBarMenu->setItemChecked( 10, true ); | 1295 | configureToolBarMenu->setItemChecked( 10, true ); |
1296 | if (p->mShowIconNewTodo ) | 1296 | if (p->mShowIconNewTodo ) |
1297 | configureToolBarMenu->setItemChecked( 20, true ); | 1297 | configureToolBarMenu->setItemChecked( 20, true ); |
1298 | if (p-> mShowIconSearch) | 1298 | if (p-> mShowIconSearch) |
1299 | configureToolBarMenu->setItemChecked( 120, true ); | 1299 | configureToolBarMenu->setItemChecked( 120, true ); |
1300 | if (p-> mShowIconList) | 1300 | if (p-> mShowIconList) |
1301 | configureToolBarMenu->setItemChecked( 30, true ); | 1301 | configureToolBarMenu->setItemChecked( 30, true ); |
1302 | if (p-> mShowIconDay1) | 1302 | if (p-> mShowIconDay1) |
1303 | configureToolBarMenu->setItemChecked( 40, true ); | 1303 | configureToolBarMenu->setItemChecked( 40, true ); |
1304 | if (p-> mShowIconDay5) | 1304 | if (p-> mShowIconDay5) |
1305 | configureToolBarMenu->setItemChecked( 50, true ); | 1305 | configureToolBarMenu->setItemChecked( 50, true ); |
1306 | if (p-> mShowIconDay6) | 1306 | if (p-> mShowIconDay6) |
1307 | configureToolBarMenu->setItemChecked( 75, true ); | 1307 | configureToolBarMenu->setItemChecked( 75, true ); |
1308 | if (p-> mShowIconDay7) | 1308 | if (p-> mShowIconDay7) |
1309 | configureToolBarMenu->setItemChecked( 60, true ); | 1309 | configureToolBarMenu->setItemChecked( 60, true ); |
1310 | if (p-> mShowIconMonth) | 1310 | if (p-> mShowIconMonth) |
1311 | configureToolBarMenu->setItemChecked( 70, true ); | 1311 | configureToolBarMenu->setItemChecked( 70, true ); |
1312 | if (p-> mShowIconTodoview) | 1312 | if (p-> mShowIconTodoview) |
1313 | configureToolBarMenu->setItemChecked( 80, true ); | 1313 | configureToolBarMenu->setItemChecked( 80, true ); |
1314 | if (p-> mShowIconBackFast) | 1314 | if (p-> mShowIconBackFast) |
1315 | configureToolBarMenu->setItemChecked( 200, true ); | 1315 | configureToolBarMenu->setItemChecked( 200, true ); |
1316 | if (p-> mShowIconBack) | 1316 | if (p-> mShowIconBack) |
1317 | configureToolBarMenu->setItemChecked( 210, true ); | 1317 | configureToolBarMenu->setItemChecked( 210, true ); |
1318 | if (p-> mShowIconToday) | 1318 | if (p-> mShowIconToday) |
1319 | configureToolBarMenu->setItemChecked( 130, true ); | 1319 | configureToolBarMenu->setItemChecked( 130, true ); |
1320 | if (p-> mShowIconForward) | 1320 | if (p-> mShowIconForward) |
1321 | configureToolBarMenu->setItemChecked( 220, true ); | 1321 | configureToolBarMenu->setItemChecked( 220, true ); |
1322 | if (p-> mShowIconForwardFast) | 1322 | if (p-> mShowIconForwardFast) |
1323 | configureToolBarMenu->setItemChecked( 230, true ); | 1323 | configureToolBarMenu->setItemChecked( 230, true ); |
1324 | if (p-> mShowIconNextDays) | 1324 | if (p-> mShowIconNextDays) |
1325 | configureToolBarMenu->setItemChecked( 100, true ); | 1325 | configureToolBarMenu->setItemChecked( 100, true ); |
1326 | if (p-> mShowIconNext) | 1326 | if (p-> mShowIconNext) |
1327 | configureToolBarMenu->setItemChecked( 110, true ); | 1327 | configureToolBarMenu->setItemChecked( 110, true ); |
1328 | if (p-> mShowIconJournal) | 1328 | if (p-> mShowIconJournal) |
1329 | configureToolBarMenu->setItemChecked( 90, true ); | 1329 | configureToolBarMenu->setItemChecked( 90, true ); |
1330 | if (p-> mShowIconWhatsThis) | 1330 | if (p-> mShowIconWhatsThis) |
1331 | configureToolBarMenu->setItemChecked( 300, true ); | 1331 | configureToolBarMenu->setItemChecked( 300, true ); |
1332 | if (p-> mShowIconWeekNum) | 1332 | if (p-> mShowIconWeekNum) |
1333 | configureToolBarMenu->setItemChecked( 400, true ); | 1333 | configureToolBarMenu->setItemChecked( 400, true ); |
1334 | if (!p-> mShowIconStretch) { | 1334 | if (!p-> mShowIconStretch) { |
1335 | QLabel* dummy = new QLabel( iconToolBar ); | 1335 | QLabel* dummy = new QLabel( iconToolBar ); |
1336 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1336 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1337 | dummy->setMinimumWidth( 0 ); | 1337 | dummy->setMinimumWidth( 0 ); |
1338 | iconToolBar->setStretchableWidget ( dummy ) ; | 1338 | iconToolBar->setStretchableWidget ( dummy ) ; |
1339 | } | 1339 | } |
1340 | else { | 1340 | else { |
1341 | iconToolBar->setHorizontalStretchable (true ); | 1341 | iconToolBar->setHorizontalStretchable (true ); |
1342 | viewToolBar->setHorizontalStretchable (true ); | 1342 | viewToolBar->setHorizontalStretchable (true ); |
1343 | navigatorToolBar->setHorizontalStretchable (true ); | 1343 | navigatorToolBar->setHorizontalStretchable (true ); |
1344 | iconToolBar->setVerticalStretchable (true ); | 1344 | iconToolBar->setVerticalStretchable (true ); |
1345 | viewToolBar->setVerticalStretchable (true ); | 1345 | viewToolBar->setVerticalStretchable (true ); |
1346 | navigatorToolBar->setVerticalStretchable (true ); | 1346 | navigatorToolBar->setVerticalStretchable (true ); |
1347 | configureToolBarMenu->setItemChecked( 5, true ); | 1347 | configureToolBarMenu->setItemChecked( 5, true ); |
1348 | } | 1348 | } |
1349 | if (p-> mShowIconFilter) | 1349 | if (p-> mShowIconFilter) |
1350 | configureToolBarMenu->setItemChecked( 7, true ); | 1350 | configureToolBarMenu->setItemChecked( 7, true ); |
1351 | if (p-> mShowIconOnetoolbar) | 1351 | if (p-> mShowIconOnetoolbar) |
1352 | configureToolBarMenu->setItemChecked( 6, true ); | 1352 | configureToolBarMenu->setItemChecked( 6, true ); |
1353 | 1353 | ||
1354 | 1354 | ||
1355 | if ( filterMenubar ) { | 1355 | if ( filterMenubar ) { |
1356 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); | 1356 | filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); |
1357 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); | 1357 | connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); |
1358 | } | 1358 | } |
1359 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1359 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1360 | configureAgenda( p->mHourSize ); | 1360 | configureAgenda( p->mHourSize ); |
1361 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1361 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | void MainWindow::exportToPhone( int mode ) | 1364 | void MainWindow::exportToPhone( int mode ) |
1365 | { | 1365 | { |
1366 | 1366 | ||
1367 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1367 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1368 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1368 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1369 | KOex2phonePrefs ex2phone; | 1369 | KOex2phonePrefs ex2phone; |
1370 | 1370 | ||
1371 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1371 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1372 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1372 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1373 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1373 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1374 | if ( mode == 1 ) | 1374 | if ( mode == 1 ) |
1375 | ex2phone.setCaption(i18n("Export complete calendar")); | 1375 | ex2phone.setCaption(i18n("Export complete calendar")); |
1376 | if ( mode == 2 ) | 1376 | if ( mode == 2 ) |
1377 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1377 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1378 | 1378 | ||
1379 | if ( !ex2phone.exec() ) { | 1379 | if ( !ex2phone.exec() ) { |
1380 | return; | 1380 | return; |
1381 | } | 1381 | } |
1382 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1382 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1383 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1383 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1384 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1384 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1385 | 1385 | ||
1386 | int inFuture = 0; | 1386 | int inFuture = 0; |
1387 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1387 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1388 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1388 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1389 | QPtrList<Incidence> delSel; | 1389 | QPtrList<Incidence> delSel; |
1390 | if ( mode == 1 ) | 1390 | if ( mode == 1 ) |
1391 | delSel = mCalendar->rawIncidences(); | 1391 | delSel = mCalendar->rawIncidences(); |
1392 | if ( mode == 2 ) | 1392 | if ( mode == 2 ) |
1393 | delSel = mCalendar->incidences(); | 1393 | delSel = mCalendar->incidences(); |
1394 | CalendarLocal* cal = new CalendarLocal(); | 1394 | CalendarLocal* cal = new CalendarLocal(); |
1395 | cal->setLocalTime(); | 1395 | cal->setLocalTime(); |
1396 | Incidence *incidence = delSel.first(); | 1396 | Incidence *incidence = delSel.first(); |
1397 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1397 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1398 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1398 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1399 | while ( incidence ) { | 1399 | while ( incidence ) { |
1400 | if ( incidence->typeID() != journalID ) { | 1400 | if ( incidence->typeID() != journalID ) { |
1401 | bool add = true; | 1401 | bool add = true; |
1402 | if ( inFuture ) { | 1402 | if ( inFuture ) { |
1403 | QDateTime dt; | 1403 | QDateTime dt; |
1404 | if ( incidence->typeID() == todoID ) { | 1404 | if ( incidence->typeID() == todoID ) { |
1405 | Todo * t = (Todo*)incidence; | 1405 | Todo * t = (Todo*)incidence; |
1406 | if ( t->hasDueDate() ) | 1406 | if ( t->hasDueDate() ) |
1407 | dt = t->dtDue(); | 1407 | dt = t->dtDue(); |
1408 | else | 1408 | else |
1409 | dt = cur.addSecs( 62 ); | 1409 | dt = cur.addSecs( 62 ); |
1410 | } | 1410 | } |
1411 | else { | 1411 | else { |
1412 | bool ok; | 1412 | bool ok; |
1413 | dt = incidence->getNextOccurence( cur, &ok ); | 1413 | dt = incidence->getNextOccurence( cur, &ok ); |
1414 | if ( !ok ) | 1414 | if ( !ok ) |
1415 | dt = cur.addSecs( -62 ); | 1415 | dt = cur.addSecs( -62 ); |
1416 | } | 1416 | } |
1417 | if ( dt < cur || dt > end ) { | 1417 | if ( dt < cur || dt > end ) { |
1418 | add = false; | 1418 | add = false; |
1419 | } | 1419 | } |
1420 | } | 1420 | } |
1421 | if ( add ) { | 1421 | if ( add ) { |
1422 | Incidence *in = incidence->clone(); | 1422 | Incidence *in = incidence->clone(); |
1423 | cal->addIncidence( in ); | 1423 | cal->addIncidence( in ); |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
1426 | incidence = delSel.next(); | 1426 | incidence = delSel.next(); |
1427 | } | 1427 | } |
1428 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1428 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1429 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1429 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1430 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1430 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1431 | 1431 | ||
1432 | setCaption( i18n("Writing to phone...")); | 1432 | setCaption( i18n("Writing to phone...")); |
1433 | if ( PhoneFormat::writeToPhone( cal ) ) | 1433 | if ( PhoneFormat::writeToPhone( cal ) ) |
1434 | setCaption( i18n("Export to phone successful!")); | 1434 | setCaption( i18n("Export to phone successful!")); |
1435 | else | 1435 | else |
1436 | setCaption( i18n("Error exporting to phone!")); | 1436 | setCaption( i18n("Error exporting to phone!")); |
1437 | delete cal; | 1437 | delete cal; |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | 1440 | ||
1441 | void MainWindow::setDefaultPreferences() | 1441 | void MainWindow::setDefaultPreferences() |
1442 | { | 1442 | { |
1443 | KOPrefs *p = KOPrefs::instance(); | 1443 | KOPrefs *p = KOPrefs::instance(); |
1444 | 1444 | ||
1445 | p->mCompactDialogs = true; | 1445 | p->mCompactDialogs = true; |
1446 | p->mConfirm = true; | 1446 | p->mConfirm = true; |
1447 | // p->mEnableQuickTodo = false; | 1447 | // p->mEnableQuickTodo = false; |
1448 | 1448 | ||
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | QString MainWindow::resourcePath() | 1451 | QString MainWindow::resourcePath() |
1452 | { | 1452 | { |
1453 | return KGlobal::iconLoader()->iconPath(); | 1453 | return KGlobal::iconLoader()->iconPath(); |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | void MainWindow::displayText( QString text ,QString cap ) | 1456 | void MainWindow::displayText( QString text ,QString cap ) |
1457 | { | 1457 | { |
1458 | QDialog dia( this, "name", true ); ; | 1458 | QDialog dia( this, "name", true ); ; |
1459 | dia.setCaption( cap ); | 1459 | dia.setCaption( cap ); |
1460 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1460 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1461 | lay->setSpacing( 3 ); | 1461 | lay->setSpacing( 3 ); |
1462 | lay->setMargin( 3 ); | 1462 | lay->setMargin( 3 ); |
1463 | QTextBrowser tb ( &dia ); | 1463 | QTextBrowser tb ( &dia ); |
1464 | lay->addWidget( &tb ); | 1464 | lay->addWidget( &tb ); |
1465 | tb.setText( text ); | 1465 | tb.setText( text ); |
1466 | #ifdef DESKTOP_VERSION | 1466 | #ifdef DESKTOP_VERSION |
1467 | dia.resize( 640, 480); | 1467 | dia.resize( 640, 480); |
1468 | #else | 1468 | #else |
1469 | dia.showMaximized(); | 1469 | dia.showMaximized(); |
1470 | #endif | 1470 | #endif |
1471 | dia.exec(); | 1471 | dia.exec(); |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void MainWindow::features() | 1474 | void MainWindow::features() |
1475 | { | 1475 | { |
1476 | 1476 | ||
1477 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1477 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1478 | } | 1478 | } |
1479 | 1479 | ||
1480 | void MainWindow::usertrans() | 1480 | void MainWindow::usertrans() |
1481 | { | 1481 | { |
1482 | 1482 | ||
1483 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1483 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1484 | } | 1484 | } |
1485 | 1485 | ||
1486 | void MainWindow::storagehowto() | 1486 | void MainWindow::storagehowto() |
1487 | { | 1487 | { |
1488 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 1488 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
1489 | } | 1489 | } |
1490 | void MainWindow::timetrackinghowto() | 1490 | void MainWindow::timetrackinghowto() |
1491 | { | 1491 | { |
1492 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); | 1492 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); |
1493 | } | 1493 | } |
1494 | void MainWindow::kdesynchowto() | 1494 | void MainWindow::kdesynchowto() |
1495 | { | 1495 | { |
1496 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1496 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1497 | } | 1497 | } |
1498 | void MainWindow::multisynchowto() | 1498 | void MainWindow::multisynchowto() |
1499 | { | 1499 | { |
1500 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1500 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1501 | } | 1501 | } |
1502 | void MainWindow::synchowto() | 1502 | void MainWindow::synchowto() |
1503 | { | 1503 | { |
1504 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1504 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1505 | } | 1505 | } |
1506 | void MainWindow::faq() | 1506 | void MainWindow::faq() |
1507 | { | 1507 | { |
1508 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1508 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1509 | 1509 | ||
1510 | } | 1510 | } |
1511 | void MainWindow::whatsNew() | 1511 | void MainWindow::whatsNew() |
1512 | { | 1512 | { |
1513 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1513 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1514 | 1514 | ||
1515 | } | 1515 | } |
1516 | void MainWindow::licence() | 1516 | void MainWindow::licence() |
1517 | { | 1517 | { |
1518 | KApplication::showLicence(); | 1518 | KApplication::showLicence(); |
1519 | 1519 | ||
1520 | } | 1520 | } |
1521 | void MainWindow::about() | 1521 | void MainWindow::about() |
1522 | { | 1522 | { |
1523 | QString version; | 1523 | QString version; |
1524 | #include <../version> | 1524 | #include <../version> |
1525 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1525 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1526 | i18n("KOrganizer/Platform-independent\n") + | 1526 | i18n("KOrganizer/Platform-independent\n") + |
1527 | "(KO/Pi) " + version + " - " + | 1527 | "(KO/Pi) " + version + " - " + |
1528 | 1528 | ||
1529 | #ifdef DESKTOP_VERSION | 1529 | #ifdef DESKTOP_VERSION |
1530 | i18n("Desktop Edition\n") + | 1530 | i18n("Desktop Edition\n") + |
1531 | #else | 1531 | #else |
1532 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1532 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1533 | #endif | 1533 | #endif |
1534 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); | 1534 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); |
1535 | } | 1535 | } |
1536 | void MainWindow::keyBindings() | 1536 | void MainWindow::keyBindings() |
1537 | { | 1537 | { |
1538 | QString cap = i18n("KO/Pi Keys + Colors"); | 1538 | QString cap = i18n("KO/Pi Keys + Colors"); |
1539 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1539 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1540 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1540 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1541 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + | 1541 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + |
1542 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + | 1542 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + |
1543 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1543 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1544 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1544 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1545 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ | 1545 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ |
1546 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1546 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1547 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1547 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1548 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ | 1548 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ |
1549 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1549 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1550 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1550 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1551 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1551 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1552 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1552 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1553 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1553 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1554 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1554 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1555 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ | 1555 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ |
1556 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1556 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1557 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1557 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1558 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1558 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1559 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1559 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1560 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1560 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1561 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1561 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1562 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1562 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1563 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1563 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1564 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1564 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1565 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1565 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1566 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1566 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1567 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1567 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1568 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1568 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1569 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1569 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1570 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1570 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1571 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1571 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1572 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1572 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1573 | i18n("<p><h3>In list view:</h3></p>\n") + | 1573 | i18n("<p><h3>In list view:</h3></p>\n") + |
1574 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1574 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1575 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1575 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1576 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1576 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1577 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1577 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1578 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1578 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1579 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1579 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1580 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1580 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1581 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1581 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1582 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1582 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1583 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1583 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1584 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1584 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1585 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1585 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1586 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1586 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1587 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1587 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1588 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1588 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1589 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1589 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1590 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1590 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1591 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1591 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1592 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1592 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1593 | displayText( text, cap); | 1593 | displayText( text, cap); |
1594 | } | 1594 | } |
1595 | void MainWindow::aboutAutoSaving() | 1595 | void MainWindow::aboutAutoSaving() |
1596 | { | 1596 | { |
1597 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) 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"); | 1597 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) 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"); |
1598 | 1598 | ||
1599 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1599 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1600 | 1600 | ||
1601 | } | 1601 | } |
1602 | void MainWindow::aboutKnownBugs() | 1602 | void MainWindow::aboutKnownBugs() |
1603 | { | 1603 | { |
1604 | QMessageBox* msg; | 1604 | QMessageBox* msg; |
1605 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1605 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1606 | 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")+ | 1606 | 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")+ |
1607 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1607 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1608 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1608 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1609 | i18n("\nor report them in the bugtracker on\n") + | 1609 | i18n("\nor report them in the bugtracker on\n") + |
1610 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1610 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1611 | QMessageBox::NoIcon, | 1611 | QMessageBox::NoIcon, |
1612 | QMessageBox::Ok, | 1612 | QMessageBox::Ok, |
1613 | QMessageBox::NoButton, | 1613 | QMessageBox::NoButton, |
1614 | QMessageBox::NoButton); | 1614 | QMessageBox::NoButton); |
1615 | msg->exec(); | 1615 | msg->exec(); |
1616 | delete msg; | 1616 | delete msg; |
1617 | 1617 | ||
1618 | } | 1618 | } |
1619 | 1619 | ||
1620 | QString MainWindow::defaultFileName() | 1620 | QString MainWindow::defaultFileName() |
1621 | { | 1621 | { |
1622 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1622 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1623 | } | 1623 | } |
1624 | QString MainWindow::syncFileName() | 1624 | QString MainWindow::syncFileName() |
1625 | { | 1625 | { |
1626 | #ifdef DESKTOP_VERSION | 1626 | #ifdef DESKTOP_VERSION |
1627 | return locateLocal( "tmp", "synccalendar.ics" ); | 1627 | return locateLocal( "tmp", "synccalendar.ics" ); |
1628 | #else | 1628 | #else |
1629 | return QString( "/tmp/synccalendar.ics" ); | 1629 | return QString( "/tmp/synccalendar.ics" ); |
1630 | #endif | 1630 | #endif |
1631 | } | 1631 | } |
1632 | #include "koglobals.h" | 1632 | #include "koglobals.h" |
1633 | #include <kcalendarsystem.h> | 1633 | #include <kcalendarsystem.h> |
1634 | void MainWindow::updateWeek(QDate seda) | 1634 | void MainWindow::updateWeek(QDate seda) |
1635 | { | 1635 | { |
1636 | int weekNum = KGlobal::locale()->weekNum ( seda ); | 1636 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1637 | mWeekPixmap.fill( mWeekBgColor ); | 1637 | mWeekPixmap.fill( mWeekBgColor ); |
1638 | QPainter p ( &mWeekPixmap ); | 1638 | QPainter p ( &mWeekPixmap ); |
1639 | p.setFont( mWeekFont ); | 1639 | p.setFont( mWeekFont ); |
1640 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1640 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1641 | p.end(); | 1641 | p.end(); |
1642 | QIconSet icon3 ( mWeekPixmap ); | 1642 | QIconSet icon3 ( mWeekPixmap ); |
1643 | mWeekAction->setIconSet ( icon3 ); | 1643 | mWeekAction->setIconSet ( icon3 ); |
1644 | 1644 | ||
1645 | } | 1645 | } |
1646 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1646 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1647 | { | 1647 | { |
1648 | updateWeek( selectedDates.first() ); | 1648 | updateWeek( selectedDates.first() ); |
1649 | } | 1649 | } |
1650 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1650 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1651 | { | 1651 | { |
1652 | if ( !incidence ) { | 1652 | if ( !incidence ) { |
1653 | mShowAction->setMenuText( i18n("Show") ); | 1653 | mShowAction->setMenuText( i18n("Show") ); |
1654 | enableIncidenceActions( false ); | 1654 | enableIncidenceActions( false ); |
1655 | mNewSubTodoAction->setEnabled( false ); | 1655 | mNewSubTodoAction->setEnabled( false ); |
1656 | setCaptionToDates(); | 1656 | setCaptionToDates(); |
1657 | return; | 1657 | return; |
1658 | } | 1658 | } |
1659 | QString startString = ""; | 1659 | QString startString = ""; |
1660 | if ( incidence->typeID() != todoID ) { | 1660 | if ( incidence->typeID() != todoID ) { |
1661 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1661 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1662 | if ( incidence->doesFloat() ) { | 1662 | if ( incidence->doesFloat() ) { |
1663 | startString += ": "+incidence->dtStartDateStr( true ); | 1663 | startString += ": "+incidence->dtStartDateStr( true ); |
1664 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1664 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1665 | } else { | 1665 | } else { |
1666 | startString = ": "+incidence->dtStartStr(true); | 1666 | startString = ": "+incidence->dtStartStr(true); |
1667 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1667 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1668 | } | 1668 | } |
1669 | } else { | 1669 | } else { |
1670 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1670 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1671 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1671 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1672 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1672 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1673 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { | 1673 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { |
1674 | bool ok; | 1674 | bool ok; |
1675 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1675 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1676 | if ( ok ) { | 1676 | if ( ok ) { |
1677 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1677 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1678 | startString += i18n(" (%1 y.)"). arg( years ); | 1678 | startString += i18n(" (%1 y.)"). arg( years ); |
1679 | } | 1679 | } |
1680 | } | 1680 | } |
1681 | else | 1681 | else |
1682 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1682 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1683 | } | 1683 | } |
1684 | } | 1684 | } |
1685 | else | 1685 | else { |
1686 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1686 | if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) |
1687 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); | ||
1688 | else | ||
1689 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | ||
1690 | } | ||
1687 | if ( !incidence->location().isEmpty() ) | 1691 | if ( !incidence->location().isEmpty() ) |
1688 | startString += " (" +incidence->location()+")"; | 1692 | startString += " (" +incidence->location()+")"; |
1689 | setCaption( incidence->summary()+startString); | 1693 | setCaption( incidence->summary()+startString); |
1690 | enableIncidenceActions( true ); | 1694 | enableIncidenceActions( true ); |
1691 | if ( incidence->typeID() == eventID ) { | 1695 | if ( incidence->typeID() == eventID ) { |
1692 | mShowAction->setMenuText( i18n("Show Event") ); | 1696 | mShowAction->setMenuText( i18n("Show Event") ); |
1693 | mNewSubTodoAction->setEnabled( false ); | 1697 | mNewSubTodoAction->setEnabled( false ); |
1694 | } else if ( incidence->typeID() == todoID ) { | 1698 | } else if ( incidence->typeID() == todoID ) { |
1695 | mShowAction->setMenuText( i18n("Show Todo") ); | 1699 | mShowAction->setMenuText( i18n("Show Todo") ); |
1696 | mNewSubTodoAction->setEnabled( true ); | 1700 | mNewSubTodoAction->setEnabled( true ); |
1697 | } else { | 1701 | } else { |
1698 | mShowAction->setMenuText( i18n("Show") ); | 1702 | mShowAction->setMenuText( i18n("Show") ); |
1699 | mNewSubTodoAction->setEnabled( false ); | 1703 | mNewSubTodoAction->setEnabled( false ); |
1700 | } | 1704 | } |
1701 | } | 1705 | } |
1702 | 1706 | ||
1703 | void MainWindow::enableIncidenceActions( bool enabled ) | 1707 | void MainWindow::enableIncidenceActions( bool enabled ) |
1704 | { | 1708 | { |
1705 | mShowAction->setEnabled( enabled ); | 1709 | mShowAction->setEnabled( enabled ); |
1706 | mEditAction->setEnabled( enabled ); | 1710 | mEditAction->setEnabled( enabled ); |
1707 | mDeleteAction->setEnabled( enabled ); | 1711 | mDeleteAction->setEnabled( enabled ); |
1708 | 1712 | ||
1709 | mCloneAction->setEnabled( enabled ); | 1713 | mCloneAction->setEnabled( enabled ); |
1710 | mMoveAction->setEnabled( enabled ); | 1714 | mMoveAction->setEnabled( enabled ); |
1711 | #ifndef DESKTOP_VERSION | 1715 | #ifndef DESKTOP_VERSION |
1712 | mBeamAction->setEnabled( enabled ); | 1716 | mBeamAction->setEnabled( enabled ); |
1713 | #endif | 1717 | #endif |
1714 | mCancelAction->setEnabled( enabled ); | 1718 | mCancelAction->setEnabled( enabled ); |
1715 | } | 1719 | } |
1716 | 1720 | ||
1717 | void MainWindow::importOL() | 1721 | void MainWindow::importOL() |
1718 | { | 1722 | { |
1719 | #ifdef _OL_IMPORT_ | 1723 | #ifdef _OL_IMPORT_ |
1720 | mView->clearAllViews(); | 1724 | mView->clearAllViews(); |
1721 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1725 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1722 | id->exec(); | 1726 | id->exec(); |
1723 | delete id; | 1727 | delete id; |
1724 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1728 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1725 | mView->updateView(); | 1729 | mView->updateView(); |
1726 | #endif | 1730 | #endif |
1727 | } | 1731 | } |
1728 | void MainWindow::importBday() | 1732 | void MainWindow::importBday() |
1729 | { | 1733 | { |
1730 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), | 1734 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), |
1731 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1735 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1732 | i18n("Import!"), i18n("Cancel"), 0, | 1736 | i18n("Import!"), i18n("Cancel"), 0, |
1733 | 0, 1 ); | 1737 | 0, 1 ); |
1734 | if ( result == 0 ) { | 1738 | if ( result == 0 ) { |
1735 | mView->importBday(); | 1739 | mView->importBday(); |
1736 | 1740 | ||
1737 | } | 1741 | } |
1738 | 1742 | ||
1739 | 1743 | ||
1740 | } | 1744 | } |
1741 | void MainWindow::importQtopia() | 1745 | void MainWindow::importQtopia() |
1742 | { | 1746 | { |
1743 | //#ifndef DESKTOP_VERSION | 1747 | //#ifndef DESKTOP_VERSION |
1744 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); | 1748 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); |
1745 | #ifdef DESKTOP_VERSION | 1749 | #ifdef DESKTOP_VERSION |
1746 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); | 1750 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); |
1747 | #endif | 1751 | #endif |
1748 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1752 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1749 | i18n("Import!"), i18n("Cancel"), 0, | 1753 | i18n("Import!"), i18n("Cancel"), 0, |
1750 | 0, 1 ); | 1754 | 0, 1 ); |
1751 | if ( result == 0 ) { | 1755 | if ( result == 0 ) { |
1752 | #ifndef DESKTOP_VERSION | 1756 | #ifndef DESKTOP_VERSION |
1753 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1757 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1754 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1758 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1755 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1759 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1756 | #else | 1760 | #else |
1757 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1761 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1758 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1762 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1759 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1763 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1760 | #endif | 1764 | #endif |
1761 | mView->importQtopia( categories, datebook, todolist ); | 1765 | mView->importQtopia( categories, datebook, todolist ); |
1762 | } | 1766 | } |
1763 | mView->calendar()->reInitAlarmSettings(); | 1767 | mView->calendar()->reInitAlarmSettings(); |
1764 | #if 0 | 1768 | #if 0 |
1765 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1769 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1766 | i18n("Not supported \non desktop!\n"), | 1770 | i18n("Not supported \non desktop!\n"), |
1767 | i18n("Ok"), i18n("Cancel"), 0, | 1771 | i18n("Ok"), i18n("Cancel"), 0, |
1768 | 0, 1 ); | 1772 | 0, 1 ); |
1769 | 1773 | ||
1770 | #endif | 1774 | #endif |
1771 | } | 1775 | } |
1772 | 1776 | ||
1773 | void MainWindow::saveOnClose() | 1777 | void MainWindow::saveOnClose() |
1774 | { | 1778 | { |
1775 | KOPrefs *p = KOPrefs::instance(); | 1779 | KOPrefs *p = KOPrefs::instance(); |
1776 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1780 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1777 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1781 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1778 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1782 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1779 | if ( filterToolBar ) { | 1783 | if ( filterToolBar ) { |
1780 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1784 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1781 | } | 1785 | } |
1782 | #ifdef DESKTOP_VERSION | 1786 | #ifdef DESKTOP_VERSION |
1783 | 1787 | ||
1784 | QPoint myP; | 1788 | QPoint myP; |
1785 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1789 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1786 | if ( p->mToolBarHor ) | 1790 | if ( p->mToolBarHor ) |
1787 | p->mToolBarUp = myP.y() > height()/2; | 1791 | p->mToolBarUp = myP.y() > height()/2; |
1788 | else | 1792 | else |
1789 | p->mToolBarUp = myP.x() > width()/2; | 1793 | p->mToolBarUp = myP.x() > width()/2; |
1790 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1794 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1791 | if ( p->mToolBarHorV ) | 1795 | if ( p->mToolBarHorV ) |
1792 | p->mToolBarUpV = myP.y() > height()/2; | 1796 | p->mToolBarUpV = myP.y() > height()/2; |
1793 | else | 1797 | else |
1794 | p->mToolBarUpV = myP.x() > width()/2 ; | 1798 | p->mToolBarUpV = myP.x() > width()/2 ; |
1795 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1799 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1796 | if ( p->mToolBarHorN ) | 1800 | if ( p->mToolBarHorN ) |
1797 | p->mToolBarUpN = myP.y() > height()/2; | 1801 | p->mToolBarUpN = myP.y() > height()/2; |
1798 | else | 1802 | else |
1799 | p->mToolBarUpN = myP.x() > width()/2 ; | 1803 | p->mToolBarUpN = myP.x() > width()/2 ; |
1800 | if ( filterToolBar ) { | 1804 | if ( filterToolBar ) { |
1801 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1805 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1802 | if ( p->mToolBarHorF ) | 1806 | if ( p->mToolBarHorF ) |
1803 | p->mToolBarUpF = myP.y() > height()/2; | 1807 | p->mToolBarUpF = myP.y() > height()/2; |
1804 | else | 1808 | else |
1805 | p->mToolBarUpF = myP.x() > width()/2 ; | 1809 | p->mToolBarUpF = myP.x() > width()/2 ; |
1806 | } | 1810 | } |
1807 | #else | 1811 | #else |
1808 | if ( p->mToolBarHor ) | 1812 | if ( p->mToolBarHor ) |
1809 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1813 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1810 | else | 1814 | else |
1811 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1815 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1812 | if ( p->mToolBarHorV ) | 1816 | if ( p->mToolBarHorV ) |
1813 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1817 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1814 | else | 1818 | else |
1815 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1819 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1816 | 1820 | ||
1817 | if ( p->mToolBarHorN ) | 1821 | if ( p->mToolBarHorN ) |
1818 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1822 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1819 | else | 1823 | else |
1820 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1824 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1821 | if ( filterToolBar ) { | 1825 | if ( filterToolBar ) { |
1822 | if ( p->mToolBarHorF ) | 1826 | if ( p->mToolBarHorF ) |
1823 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1827 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1824 | else | 1828 | else |
1825 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1829 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1826 | } | 1830 | } |
1827 | #endif | 1831 | #endif |
1828 | save(); | 1832 | save(); |
1829 | mView->writeSettings(); | 1833 | mView->writeSettings(); |
1830 | mView->checkSuspendAlarm(); | 1834 | mView->checkSuspendAlarm(); |
1831 | } | 1835 | } |
1832 | void MainWindow::slotModifiedChanged( bool ) | 1836 | void MainWindow::slotModifiedChanged( bool ) |
1833 | { | 1837 | { |
1834 | if ( mBlockAtStartup ) | 1838 | if ( mBlockAtStartup ) |
1835 | return; | 1839 | return; |
1836 | 1840 | ||
1837 | int msec; | 1841 | int msec; |
1838 | // we store the changes after 1 minute, | 1842 | // we store the changes after 1 minute, |
1839 | // and for safety reasons after 10 minutes again | 1843 | // and for safety reasons after 10 minutes again |
1840 | if ( !mSyncManager->blockSave() ) | 1844 | if ( !mSyncManager->blockSave() ) |
1841 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1845 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1842 | else | 1846 | else |
1843 | msec = 1000 * 600; | 1847 | msec = 1000 * 600; |
1844 | mSaveTimer.start( msec, true ); // 1 minute | 1848 | mSaveTimer.start( msec, true ); // 1 minute |
1845 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1849 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1846 | mCalendarModifiedFlag = true; | 1850 | mCalendarModifiedFlag = true; |
1847 | } | 1851 | } |
1848 | void MainWindow::saveStopTimer() | 1852 | void MainWindow::saveStopTimer() |
1849 | { | 1853 | { |
1850 | mSaveTimer.stop(); | 1854 | mSaveTimer.stop(); |
1851 | } | 1855 | } |
1852 | void MainWindow::backupAllFiles() | 1856 | void MainWindow::backupAllFiles() |
1853 | { | 1857 | { |
1854 | QDate reference ( 2000,1,1); | 1858 | QDate reference ( 2000,1,1); |
1855 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1859 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1856 | setCaption(i18n("Creating backup ... please wait ..." )); | 1860 | setCaption(i18n("Creating backup ... please wait ..." )); |
1857 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 1861 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
1858 | // we need the file path, the backup dir and the number of bups as param | 1862 | // we need the file path, the backup dir and the number of bups as param |
1859 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 1863 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
1860 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 1864 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
1861 | bupDir = KGlobalSettings::backupDataDir(); | 1865 | bupDir = KGlobalSettings::backupDataDir(); |
1862 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1866 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1863 | if ( retval == 0 ) { | 1867 | if ( retval == 0 ) { |
1864 | setCaption(i18n("Backup cancelled" )); | 1868 | setCaption(i18n("Backup cancelled" )); |
1865 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 1869 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
1866 | // retval == 0 : backup skipped for today, try again tomorrow | 1870 | // retval == 0 : backup skipped for today, try again tomorrow |
1867 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 1871 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
1868 | } else if ( retval == 1 ){ | 1872 | } else if ( retval == 1 ){ |
1869 | qDebug("KO: Backup created."); | 1873 | qDebug("KO: Backup created."); |
1870 | // backup ok | 1874 | // backup ok |
1871 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1875 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1872 | KopiCalendarFile * cal = calendars.first(); | 1876 | KopiCalendarFile * cal = calendars.first(); |
1873 | cal = calendars.next(); | 1877 | cal = calendars.next(); |
1874 | while ( cal ) { | 1878 | while ( cal ) { |
1875 | if ( !cal->mErrorOnLoad ) { | 1879 | if ( !cal->mErrorOnLoad ) { |
1876 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1880 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1877 | } | 1881 | } |
1878 | cal = calendars.next(); | 1882 | cal = calendars.next(); |
1879 | } | 1883 | } |
1880 | KOPrefs::instance()->mLastBackupDate = daysTo; | 1884 | KOPrefs::instance()->mLastBackupDate = daysTo; |
1881 | setCaption(i18n("Backup succesfully finished" )); | 1885 | setCaption(i18n("Backup succesfully finished" )); |
1882 | } else if ( retval == 2 ){ | 1886 | } else if ( retval == 2 ){ |
1883 | setCaption(i18n("Backup globally disabled" )); | 1887 | setCaption(i18n("Backup globally disabled" )); |
1884 | qDebug("KO: Backup globally cancelled."); | 1888 | qDebug("KO: Backup globally cancelled."); |
1885 | // backup globally cancelled | 1889 | // backup globally cancelled |
1886 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 1890 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
1887 | } | 1891 | } |
1888 | // retval == 3: do nothing, try again later | 1892 | // retval == 3: do nothing, try again later |
1889 | } | 1893 | } |
1890 | void MainWindow::save() | 1894 | void MainWindow::save() |
1891 | { | 1895 | { |
1892 | 1896 | ||
1893 | if ( mView->viewManager()->journalView() ) | 1897 | if ( mView->viewManager()->journalView() ) |
1894 | mView->viewManager()->journalView()->checkModified(); | 1898 | mView->viewManager()->journalView()->checkModified(); |
1895 | if ( !mCalendarModifiedFlag ) { | 1899 | if ( !mCalendarModifiedFlag ) { |
1896 | qDebug("KO: Calendar not modified. Nothing saved."); | 1900 | qDebug("KO: Calendar not modified. Nothing saved."); |
1897 | return; | 1901 | return; |
1898 | } | 1902 | } |
1899 | if ( mSyncManager->blockSave() ) | 1903 | if ( mSyncManager->blockSave() ) |
1900 | return; | 1904 | return; |
1901 | mSyncManager->setBlockSave(true); | 1905 | mSyncManager->setBlockSave(true); |
1902 | if ( mView->checkAllFileVersions() ) { | 1906 | if ( mView->checkAllFileVersions() ) { |
1903 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 1907 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
1904 | QDate reference ( 2000,1,1); | 1908 | QDate reference ( 2000,1,1); |
1905 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1909 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1906 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 1910 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
1907 | backupAllFiles(); | 1911 | backupAllFiles(); |
1908 | } | 1912 | } |
1909 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 1913 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
1910 | } | 1914 | } |
1911 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1915 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1912 | if ( !isMinimized () ) | 1916 | if ( !isMinimized () ) |
1913 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1917 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1914 | qDebug("KO: Start saving data to file!"); | 1918 | qDebug("KO: Start saving data to file!"); |
1915 | mView->saveCalendars(); | 1919 | mView->saveCalendars(); |
1916 | mCalendarModifiedFlag = false; | 1920 | mCalendarModifiedFlag = false; |
1917 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1921 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1918 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1922 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1919 | QString savemes; | 1923 | QString savemes; |
1920 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1924 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1921 | if ( !isMinimized () ) | 1925 | if ( !isMinimized () ) |
1922 | setCaption(savemes); | 1926 | setCaption(savemes); |
1923 | else | 1927 | else |
1924 | qDebug(savemes); | 1928 | qDebug(savemes); |
1925 | } else | 1929 | } else |
1926 | setCaption(i18n("Saving cancelled!")); | 1930 | setCaption(i18n("Saving cancelled!")); |
1927 | mSyncManager->setBlockSave( false ); | 1931 | mSyncManager->setBlockSave( false ); |
1928 | } | 1932 | } |
1929 | 1933 | ||
1930 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1934 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1931 | { | 1935 | { |
1932 | if ( !e->isAutoRepeat() ) { | 1936 | if ( !e->isAutoRepeat() ) { |
1933 | mFlagKeyPressed = false; | 1937 | mFlagKeyPressed = false; |
1934 | } | 1938 | } |
1935 | } | 1939 | } |
1936 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1940 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1937 | { | 1941 | { |
1938 | qApp->processEvents(); | 1942 | qApp->processEvents(); |
1939 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1943 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1940 | e->ignore(); | 1944 | e->ignore(); |
1941 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1945 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1942 | return; | 1946 | return; |
1943 | } | 1947 | } |
1944 | if (! e->isAutoRepeat() ) | 1948 | if (! e->isAutoRepeat() ) |
1945 | mFlagKeyPressed = true; | 1949 | mFlagKeyPressed = true; |
1946 | KOPrefs *p = KOPrefs::instance(); | 1950 | KOPrefs *p = KOPrefs::instance(); |
1947 | bool showSelectedDates = false; | 1951 | bool showSelectedDates = false; |
1948 | int size; | 1952 | int size; |
1949 | int pro = 0; | 1953 | int pro = 0; |
1950 | //qDebug("MainWindow::keyPressEvent "); | 1954 | //qDebug("MainWindow::keyPressEvent "); |
1951 | switch ( e->key() ) { | 1955 | switch ( e->key() ) { |
1952 | case Qt::Key_Right: | 1956 | case Qt::Key_Right: |
1953 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1957 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1954 | mView->goNextMonth(); | 1958 | mView->goNextMonth(); |
1955 | else | 1959 | else |
1956 | mView->goNext(); | 1960 | mView->goNext(); |
1957 | showSelectedDates = true; | 1961 | showSelectedDates = true; |
1958 | break; | 1962 | break; |
1959 | case Qt::Key_Left: | 1963 | case Qt::Key_Left: |
1960 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1964 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1961 | mView->goPreviousMonth(); | 1965 | mView->goPreviousMonth(); |
1962 | else | 1966 | else |
1963 | mView->goPrevious(); | 1967 | mView->goPrevious(); |
1964 | showSelectedDates = true; | 1968 | showSelectedDates = true; |
1965 | break; | 1969 | break; |
1966 | case Qt::Key_Down: | 1970 | case Qt::Key_Down: |
1967 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1971 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1968 | break; | 1972 | break; |
1969 | case Qt::Key_Up: | 1973 | case Qt::Key_Up: |
1970 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1974 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1971 | break; | 1975 | break; |
1972 | case Qt::Key_K: | 1976 | case Qt::Key_K: |
1973 | mView->viewManager()->showMonthViewWeek(); | 1977 | mView->viewManager()->showMonthViewWeek(); |
1974 | break; | 1978 | break; |
1975 | case Qt::Key_I: | 1979 | case Qt::Key_I: |
1976 | mView->showIncidence(); | 1980 | mView->showIncidence(); |
1977 | break; | 1981 | break; |
1978 | case Qt::Key_Delete: | 1982 | case Qt::Key_Delete: |
1979 | case Qt::Key_Backspace: | 1983 | case Qt::Key_Backspace: |
1980 | mView->deleteIncidence(); | 1984 | mView->deleteIncidence(); |
1981 | break; | 1985 | break; |
1982 | case Qt::Key_D: | 1986 | case Qt::Key_D: |
1983 | mView->viewManager()->showDayView(); | 1987 | mView->viewManager()->showDayView(); |
1984 | showSelectedDates = true; | 1988 | showSelectedDates = true; |
1985 | break; | 1989 | break; |
1986 | case Qt::Key_O: | 1990 | case Qt::Key_O: |
1987 | mView->toggleFilerEnabled( ); | 1991 | mView->toggleFilerEnabled( ); |
1988 | break; | 1992 | break; |
1989 | case Qt::Key_0: | 1993 | case Qt::Key_0: |
1990 | case Qt::Key_1: | 1994 | case Qt::Key_1: |
1991 | case Qt::Key_2: | 1995 | case Qt::Key_2: |
1992 | case Qt::Key_3: | 1996 | case Qt::Key_3: |
1993 | case Qt::Key_4: | 1997 | case Qt::Key_4: |
1994 | case Qt::Key_5: | 1998 | case Qt::Key_5: |
1995 | case Qt::Key_6: | 1999 | case Qt::Key_6: |
1996 | case Qt::Key_7: | 2000 | case Qt::Key_7: |
1997 | case Qt::Key_8: | 2001 | case Qt::Key_8: |
1998 | case Qt::Key_9: | 2002 | case Qt::Key_9: |
1999 | pro = e->key()-48; | 2003 | pro = e->key()-48; |
2000 | if ( pro == 0 ) | 2004 | if ( pro == 0 ) |
2001 | pro = 10; | 2005 | pro = 10; |
2002 | if ( e->state() == Qt::ControlButton) | 2006 | if ( e->state() == Qt::ControlButton) |
2003 | pro += 10; | 2007 | pro += 10; |
2004 | break; | 2008 | break; |
2005 | case Qt::Key_M: | 2009 | case Qt::Key_M: |
2006 | mView->viewManager()->showMonthView(); | 2010 | mView->viewManager()->showMonthView(); |
2007 | showSelectedDates = true; | 2011 | showSelectedDates = true; |
2008 | break; | 2012 | break; |
2009 | case Qt::Key_Insert: | 2013 | case Qt::Key_Insert: |
2010 | mView->newEvent(); | 2014 | mView->newEvent(); |
2011 | break; | 2015 | break; |
2012 | case Qt::Key_S : | 2016 | case Qt::Key_S : |
2013 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2017 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2014 | mView->newSubTodo(); | 2018 | mView->newSubTodo(); |
2015 | else | 2019 | else |
2016 | mView->dialogManager()->showSearchDialog(); | 2020 | mView->dialogManager()->showSearchDialog(); |
2017 | break; | 2021 | break; |
2018 | case Qt::Key_Y : | 2022 | case Qt::Key_Y : |
2019 | case Qt::Key_Z : | 2023 | case Qt::Key_Z : |
2020 | mView->viewManager()->showWorkWeekView(); | 2024 | mView->viewManager()->showWorkWeekView(); |
2021 | showSelectedDates = true; | 2025 | showSelectedDates = true; |
2022 | break; | 2026 | break; |
2023 | case Qt::Key_U : | 2027 | case Qt::Key_U : |
2024 | mView->viewManager()->showWeekView(); | 2028 | mView->viewManager()->showWeekView(); |
2025 | showSelectedDates = true; | 2029 | showSelectedDates = true; |
2026 | break; | 2030 | break; |
2027 | case Qt::Key_H : | 2031 | case Qt::Key_H : |
2028 | keyBindings(); | 2032 | keyBindings(); |
2029 | break; | 2033 | break; |
2030 | case Qt::Key_W: | 2034 | case Qt::Key_W: |
2031 | mView->viewManager()->showWhatsNextView(); | 2035 | mView->viewManager()->showWhatsNextView(); |
2032 | break; | 2036 | break; |
2033 | case Qt::Key_L: | 2037 | case Qt::Key_L: |
2034 | mView->viewManager()->showListView(); | 2038 | mView->viewManager()->showListView(); |
2035 | break; | 2039 | break; |
2036 | case Qt::Key_N: | 2040 | case Qt::Key_N: |
2037 | mView->viewManager()->showNextView(); | 2041 | mView->viewManager()->showNextView(); |
2038 | break; | 2042 | break; |
2039 | case Qt::Key_V: | 2043 | case Qt::Key_V: |
2040 | mView->viewManager()->showTodoView(); | 2044 | mView->viewManager()->showTodoView(); |
2041 | break; | 2045 | break; |
2042 | case Qt::Key_C: | 2046 | case Qt::Key_C: |
2043 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 2047 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
2044 | break; | 2048 | break; |
2045 | case Qt::Key_P: | 2049 | case Qt::Key_P: |
2046 | mView->showDatePicker( ); | 2050 | mView->showDatePicker( ); |
2047 | break; | 2051 | break; |
2048 | case Qt::Key_F: | 2052 | case Qt::Key_F: |
2049 | mView->editFilters(); | 2053 | mView->editFilters(); |
2050 | break; | 2054 | break; |
2051 | case Qt::Key_R: | 2055 | case Qt::Key_R: |
2052 | mView->toggleFilter(); | 2056 | mView->toggleFilter(); |
2053 | break; | 2057 | break; |
2054 | case Qt::Key_X: | 2058 | case Qt::Key_X: |
2055 | if ( e->state() == Qt::ControlButton ) | 2059 | if ( e->state() == Qt::ControlButton ) |
2056 | mView->toggleDateNavigatorWidget(); | 2060 | mView->toggleDateNavigatorWidget(); |
2057 | else { | 2061 | else { |
2058 | mView->viewManager()->showNextXView(); | 2062 | mView->viewManager()->showNextXView(); |
2059 | showSelectedDates = true; | 2063 | showSelectedDates = true; |
2060 | } | 2064 | } |
2061 | break; | 2065 | break; |
2062 | case Qt::Key_Space: | 2066 | case Qt::Key_Space: |
2063 | mView->toggleExpand(); | 2067 | mView->toggleExpand(); |
2064 | break; | 2068 | break; |
2065 | case Qt::Key_A: | 2069 | case Qt::Key_A: |
2066 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2070 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2067 | mView->showNextAlarms(); | 2071 | mView->showNextAlarms(); |
2068 | else | 2072 | else |
2069 | mView->toggleAllDaySize(); | 2073 | mView->toggleAllDaySize(); |
2070 | break; | 2074 | break; |
2071 | case Qt::Key_T: | 2075 | case Qt::Key_T: |
2072 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2076 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2073 | mView->newTodo(); | 2077 | mView->newTodo(); |
2074 | else { | 2078 | else { |
2075 | mView->goToday(); | 2079 | mView->goToday(); |
2076 | showSelectedDates = true; | 2080 | showSelectedDates = true; |
2077 | } | 2081 | } |
2078 | break; | 2082 | break; |
2079 | case Qt::Key_J: | 2083 | case Qt::Key_J: |
2080 | mView->viewManager()->showJournalView(); | 2084 | mView->viewManager()->showJournalView(); |
2081 | break; | 2085 | break; |
2082 | case Qt::Key_B: | 2086 | case Qt::Key_B: |
2083 | mView->editIncidenceDescription();; | 2087 | mView->editIncidenceDescription();; |
2084 | break; | 2088 | break; |
2085 | // case Qt::Key_Return: | 2089 | // case Qt::Key_Return: |
2086 | case Qt::Key_E: | 2090 | case Qt::Key_E: |
2087 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2091 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2088 | mView->newEvent(); | 2092 | mView->newEvent(); |
2089 | else | 2093 | else |
2090 | mView->editIncidence(); | 2094 | mView->editIncidence(); |
2091 | break; | 2095 | break; |
2092 | case Qt::Key_Plus: | 2096 | case Qt::Key_Plus: |
2093 | size = p->mHourSize +2; | 2097 | size = p->mHourSize +2; |
2094 | if ( size <= 22 ) | 2098 | if ( size <= 22 ) |
2095 | configureAgenda( size ); | 2099 | configureAgenda( size ); |
2096 | break; | 2100 | break; |
2097 | case Qt::Key_Minus: | 2101 | case Qt::Key_Minus: |
2098 | size = p->mHourSize - 2; | 2102 | size = p->mHourSize - 2; |
2099 | if ( size >= 4 ) | 2103 | if ( size >= 4 ) |
2100 | configureAgenda( size ); | 2104 | configureAgenda( size ); |
2101 | break; | 2105 | break; |
2102 | 2106 | ||
2103 | 2107 | ||
2104 | default: | 2108 | default: |
2105 | e->ignore(); | 2109 | e->ignore(); |
2106 | } | 2110 | } |
2107 | if ( pro > 0 ) { | 2111 | if ( pro > 0 ) { |
2108 | selectFilter( pro+1 ); | 2112 | selectFilter( pro+1 ); |
2109 | } | 2113 | } |
2110 | if ( showSelectedDates ) { | 2114 | if ( showSelectedDates ) { |
2111 | ;// setCaptionToDates(); | 2115 | ;// setCaptionToDates(); |
2112 | } | 2116 | } |
2113 | 2117 | ||
2114 | } | 2118 | } |
2115 | void MainWindow::fillFilterMenuTB() | 2119 | void MainWindow::fillFilterMenuTB() |
2116 | { | 2120 | { |
2117 | selectFilterMenuTB->clear(); | 2121 | selectFilterMenuTB->clear(); |
2118 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); | 2122 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); |
2119 | selectFilterMenuTB->insertSeparator(); | 2123 | selectFilterMenuTB->insertSeparator(); |
2120 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); | 2124 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); |
2121 | 2125 | ||
2122 | selectFilterMenuTB->insertSeparator(); | 2126 | selectFilterMenuTB->insertSeparator(); |
2123 | QPtrList<CalFilter> fili = mView->filters(); | 2127 | QPtrList<CalFilter> fili = mView->filters(); |
2124 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2128 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2125 | CalFilter *filter = fili.first(); | 2129 | CalFilter *filter = fili.first(); |
2126 | int iii = 2; | 2130 | int iii = 2; |
2127 | bool checkitem = mView->filterView()->filtersEnabled(); | 2131 | bool checkitem = mView->filterView()->filtersEnabled(); |
2128 | while(filter) { | 2132 | while(filter) { |
2129 | selectFilterMenuTB->insertItem( filter->name(), iii ); | 2133 | selectFilterMenuTB->insertItem( filter->name(), iii ); |
2130 | if ( filter == curfilter) | 2134 | if ( filter == curfilter) |
2131 | selectFilterMenuTB->setItemChecked( iii, checkitem ); | 2135 | selectFilterMenuTB->setItemChecked( iii, checkitem ); |
2132 | filter = fili.next(); | 2136 | filter = fili.next(); |
2133 | ++iii; | 2137 | ++iii; |
2134 | } | 2138 | } |
2135 | if ( !checkitem ) | 2139 | if ( !checkitem ) |
2136 | selectFilterMenuTB->setItemChecked( 1, true ); | 2140 | selectFilterMenuTB->setItemChecked( 1, true ); |
2137 | 2141 | ||
2138 | int x = 0; | 2142 | int x = 0; |
2139 | int y = iconToolBar->height(); | 2143 | int y = iconToolBar->height(); |
2140 | int dX = 0; | 2144 | int dX = 0; |
2141 | int dY = 0; | 2145 | int dY = 0; |
2142 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2146 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2143 | if ( iconToolBar->y() > height()/2 ) { | 2147 | if ( iconToolBar->y() > height()/2 ) { |
2144 | dY = selectFilterMenuTB->sizeHint().height()+8; | 2148 | dY = selectFilterMenuTB->sizeHint().height()+8; |
2145 | y = 0; | 2149 | y = 0; |
2146 | } | 2150 | } |
2147 | } else { | 2151 | } else { |
2148 | if ( iconToolBar->x() > width()/2 ) { // right side | 2152 | if ( iconToolBar->x() > width()/2 ) { // right side |
2149 | x=0; | 2153 | x=0; |
2150 | dX= selectFilterMenuTB->sizeHint().width()+8; | 2154 | dX= selectFilterMenuTB->sizeHint().width()+8; |
2151 | y = 0; | 2155 | y = 0; |
2152 | } else { | 2156 | } else { |
2153 | x= iconToolBar->width(); | 2157 | x= iconToolBar->width(); |
2154 | y = 0; | 2158 | y = 0; |
2155 | } | 2159 | } |
2156 | } | 2160 | } |
2157 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2161 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2158 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); | 2162 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); |
2159 | } | 2163 | } |
2160 | void MainWindow::fillFilterMenu() | 2164 | void MainWindow::fillFilterMenu() |
2161 | { | 2165 | { |
2162 | selectFilterMenu->clear(); | 2166 | selectFilterMenu->clear(); |
2163 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 2167 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
2164 | selectFilterMenu->insertSeparator(); | 2168 | selectFilterMenu->insertSeparator(); |
2165 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 2169 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
2166 | 2170 | ||
2167 | selectFilterMenu->insertSeparator(); | 2171 | selectFilterMenu->insertSeparator(); |
2168 | QPtrList<CalFilter> fili = mView->filters(); | 2172 | QPtrList<CalFilter> fili = mView->filters(); |
2169 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2173 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2170 | CalFilter *filter = fili.first(); | 2174 | CalFilter *filter = fili.first(); |
2171 | int iii = 2; | 2175 | int iii = 2; |
2172 | bool checkitem = mView->filterView()->filtersEnabled(); | 2176 | bool checkitem = mView->filterView()->filtersEnabled(); |
2173 | while(filter) { | 2177 | while(filter) { |
2174 | selectFilterMenu->insertItem( filter->name(), iii ); | 2178 | selectFilterMenu->insertItem( filter->name(), iii ); |
2175 | if ( filter == curfilter) | 2179 | if ( filter == curfilter) |
2176 | selectFilterMenu->setItemChecked( iii, checkitem ); | 2180 | selectFilterMenu->setItemChecked( iii, checkitem ); |
2177 | filter = fili.next(); | 2181 | filter = fili.next(); |
2178 | ++iii; | 2182 | ++iii; |
2179 | } | 2183 | } |
2180 | if ( !checkitem ) | 2184 | if ( !checkitem ) |
2181 | selectFilterMenu->setItemChecked( 1, true ); | 2185 | selectFilterMenu->setItemChecked( 1, true ); |
2182 | } | 2186 | } |
2183 | void MainWindow::fillFilterMenuPopup() | 2187 | void MainWindow::fillFilterMenuPopup() |
2184 | { | 2188 | { |
2185 | filterPopupMenu->clear(); | 2189 | filterPopupMenu->clear(); |
2186 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 2190 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
2187 | 2191 | ||
2188 | filterPopupMenu->insertSeparator(); | 2192 | filterPopupMenu->insertSeparator(); |
2189 | QPtrList<CalFilter> fili = mView->filters(); | 2193 | QPtrList<CalFilter> fili = mView->filters(); |
2190 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2194 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2191 | CalFilter *filter = fili.first(); | 2195 | CalFilter *filter = fili.first(); |
2192 | int iii = 1; | 2196 | int iii = 1; |
2193 | bool checkitem = mView->filterView()->filtersEnabled(); | 2197 | bool checkitem = mView->filterView()->filtersEnabled(); |
2194 | while(filter) { | 2198 | while(filter) { |
2195 | filterPopupMenu->insertItem( filter->name(), iii ); | 2199 | filterPopupMenu->insertItem( filter->name(), iii ); |
2196 | if ( filter == curfilter) | 2200 | if ( filter == curfilter) |
2197 | filterPopupMenu->setItemChecked( iii, checkitem ); | 2201 | filterPopupMenu->setItemChecked( iii, checkitem ); |
2198 | filter = fili.next(); | 2202 | filter = fili.next(); |
2199 | ++iii; | 2203 | ++iii; |
2200 | } | 2204 | } |
2201 | if ( !checkitem ) | 2205 | if ( !checkitem ) |
2202 | filterPopupMenu->setItemChecked( 0, true ); | 2206 | filterPopupMenu->setItemChecked( 0, true ); |
2203 | } | 2207 | } |
2204 | void MainWindow::selectFilter( int fil ) | 2208 | void MainWindow::selectFilter( int fil ) |
2205 | { | 2209 | { |
2206 | 2210 | ||
2207 | if ( fil == 0 ) { | 2211 | if ( fil == 0 ) { |
2208 | mView->editFilters( ); | 2212 | mView->editFilters( ); |
2209 | } else if ( fil == 1 ){ | 2213 | } else if ( fil == 1 ){ |
2210 | if ( mView->filterView()->filtersEnabled() ) | 2214 | if ( mView->filterView()->filtersEnabled() ) |
2211 | mView->toggleFilerEnabled( ); | 2215 | mView->toggleFilerEnabled( ); |
2212 | } else { | 2216 | } else { |
2213 | if ( !mView->filterView()->filtersEnabled() ) { | 2217 | if ( !mView->filterView()->filtersEnabled() ) { |
2214 | mView->filterView()->blockSignals( true ); | 2218 | mView->filterView()->blockSignals( true ); |
2215 | mView->toggleFilerEnabled( ); | 2219 | mView->toggleFilerEnabled( ); |
2216 | mView->filterView()->blockSignals( false ); | 2220 | mView->filterView()->blockSignals( false ); |
2217 | } | 2221 | } |
2218 | mView->selectFilter( fil-2 ); | 2222 | mView->selectFilter( fil-2 ); |
2219 | } | 2223 | } |
2220 | } | 2224 | } |
2221 | void MainWindow::updateFilterToolbar() | 2225 | void MainWindow::updateFilterToolbar() |
2222 | { | 2226 | { |
2223 | if ( filterMenubar ) { | 2227 | if ( filterMenubar ) { |
2224 | if ( !mView->filterView()->filtersEnabled() ) { | 2228 | if ( !mView->filterView()->filtersEnabled() ) { |
2225 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 2229 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2226 | } else { | 2230 | } else { |
2227 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2231 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2228 | if ( curfilter ) { | 2232 | if ( curfilter ) { |
2229 | filterMenubar->changeItem( 0, curfilter->name() ); | 2233 | filterMenubar->changeItem( 0, curfilter->name() ); |
2230 | } | 2234 | } |
2231 | } | 2235 | } |
2232 | } | 2236 | } |
2233 | } | 2237 | } |
2234 | void MainWindow::selectFilterPopup( int fil ) | 2238 | void MainWindow::selectFilterPopup( int fil ) |
2235 | { | 2239 | { |
2236 | selectFilter( fil + 1 ); | 2240 | selectFilter( fil + 1 ); |
2237 | 2241 | ||
2238 | } | 2242 | } |
2239 | void MainWindow::configureToolBar( int item ) | 2243 | void MainWindow::configureToolBar( int item ) |
2240 | { | 2244 | { |
2241 | 2245 | ||
2242 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2246 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2243 | KOPrefs *p = KOPrefs::instance(); | 2247 | KOPrefs *p = KOPrefs::instance(); |
2244 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2248 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2245 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2249 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2246 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2250 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2247 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2251 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2248 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2252 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2249 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2253 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2250 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2254 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2251 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2255 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2252 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2256 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2253 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2257 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2254 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2258 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2255 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2259 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2256 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2260 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2257 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2261 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2258 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2262 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2259 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2263 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2260 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2264 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2261 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2265 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2262 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2266 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2263 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2267 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2264 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2268 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2265 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2269 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2266 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2270 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2267 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2271 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2268 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2272 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2269 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2273 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2270 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2274 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2271 | // initActions(); | 2275 | // initActions(); |
2272 | setCaption ( i18n("Toolbar changes needs a restart!") ); | 2276 | setCaption ( i18n("Toolbar changes needs a restart!") ); |
2273 | } | 2277 | } |
2274 | void MainWindow::setCaption ( const QString & c ) | 2278 | void MainWindow::setCaption ( const QString & c ) |
2275 | { | 2279 | { |
2276 | QString cap = c; | 2280 | QString cap = c; |
2277 | cap.replace( QRegExp("\n"), " " ); | 2281 | cap.replace( QRegExp("\n"), " " ); |
2278 | cap = cap.stripWhiteSpace(); | 2282 | cap = cap.stripWhiteSpace(); |
2279 | if ( cap.isEmpty() ) | 2283 | if ( cap.isEmpty() ) |
2280 | cap = "KO/Pi"; | 2284 | cap = "KO/Pi"; |
2281 | QWidget::setCaption( cap ); | 2285 | QWidget::setCaption( cap ); |
2282 | } | 2286 | } |
2283 | void MainWindow::setCaptionToDates() | 2287 | void MainWindow::setCaptionToDates() |
2284 | { | 2288 | { |
2285 | QString selDates; | 2289 | QString selDates; |
2286 | QDate date = mView->startDate(); | 2290 | QDate date = mView->startDate(); |
2287 | if ( ! date.isValid() ) { | 2291 | if ( ! date.isValid() ) { |
2288 | setCaption(""); | 2292 | setCaption(""); |
2289 | return; | 2293 | return; |
2290 | } | 2294 | } |
2291 | selDates = KGlobal::locale()->formatDate( date, true); | 2295 | selDates = KGlobal::locale()->formatDate( date, true); |
2292 | if (mView->startDate() < mView->endDate() ) | 2296 | if (mView->startDate() < mView->endDate() ) |
2293 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2297 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2294 | else { | 2298 | else { |
2295 | QString addString; | 2299 | QString addString; |
2296 | if ( date == QDateTime::currentDateTime().date() ) | 2300 | if ( date == QDateTime::currentDateTime().date() ) |
2297 | addString = i18n("Today"); | 2301 | addString = i18n("Today"); |
2298 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2302 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2299 | addString = i18n("Tomorrow"); | 2303 | addString = i18n("Tomorrow"); |
2300 | if ( !addString.isEmpty() ) | 2304 | if ( !addString.isEmpty() ) |
2301 | selDates = addString+", "+selDates ; | 2305 | selDates = addString+", "+selDates ; |
2302 | } | 2306 | } |
2303 | setCaption( i18n("Dates: ") + selDates ); | 2307 | setCaption( i18n("Dates: ") + selDates ); |
2304 | 2308 | ||
2305 | } | 2309 | } |
2306 | void MainWindow::showConfigureAgenda( ) | 2310 | void MainWindow::showConfigureAgenda( ) |
2307 | { | 2311 | { |
2308 | int iii; | 2312 | int iii; |
2309 | for ( iii = 1;iii<= 10 ;++iii ){ | 2313 | for ( iii = 1;iii<= 10 ;++iii ){ |
2310 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2314 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2311 | } | 2315 | } |
2312 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2316 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2313 | } | 2317 | } |
2314 | void MainWindow::configureAgenda( int item ) | 2318 | void MainWindow::configureAgenda( int item ) |
2315 | { | 2319 | { |
2316 | if ( KOPrefs::instance()->mHourSize == item ) | 2320 | if ( KOPrefs::instance()->mHourSize == item ) |
2317 | return; | 2321 | return; |
2318 | KOPrefs::instance()->mHourSize=item; | 2322 | KOPrefs::instance()->mHourSize=item; |
2319 | mView->viewManager()->agendaView()->updateConfig(); | 2323 | mView->viewManager()->agendaView()->updateConfig(); |
2320 | } | 2324 | } |
2321 | 2325 | ||
2322 | void MainWindow::saveCalendar() | 2326 | void MainWindow::saveCalendar() |
2323 | { | 2327 | { |
2324 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2328 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2325 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2329 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2326 | bupDir = KGlobalSettings::backupDataDir(); | 2330 | bupDir = KGlobalSettings::backupDataDir(); |
2327 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); | 2331 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); |
2328 | QString bupHint; | 2332 | QString bupHint; |
2329 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) | 2333 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) |
2330 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); | 2334 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); |
2331 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; | 2335 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; |
2332 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; | 2336 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; |
2333 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2337 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2334 | save(); | 2338 | save(); |
2335 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; | 2339 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; |
2336 | backupAllFiles(); | 2340 | backupAllFiles(); |
2337 | } | 2341 | } |
2338 | void MainWindow::loadCalendar() | 2342 | void MainWindow::loadCalendar() |
2339 | { | 2343 | { |
2340 | 2344 | ||
2341 | 2345 | ||
2342 | #if 0 | 2346 | #if 0 |
2343 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2347 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2344 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2348 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2345 | 2349 | ||
2346 | if ( fn == "" ) | 2350 | if ( fn == "" ) |
2347 | return; | 2351 | return; |
2348 | QFileInfo info; | 2352 | QFileInfo info; |
2349 | info.setFile( fn ); | 2353 | info.setFile( fn ); |
2350 | QString mess; | 2354 | QString mess; |
2351 | bool loadbup = true; | 2355 | bool loadbup = true; |
2352 | if ( info. exists() ) { | 2356 | if ( info. exists() ) { |
2353 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2357 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2354 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2358 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2355 | mess, | 2359 | mess, |
2356 | i18n("Load!"), i18n("Cancel"), 0, | 2360 | i18n("Load!"), i18n("Cancel"), 0, |
2357 | 0, 1 ); | 2361 | 0, 1 ); |
2358 | if ( result != 0 ) { | 2362 | if ( result != 0 ) { |
2359 | loadbup = false; | 2363 | loadbup = false; |
2360 | } | 2364 | } |
2361 | } else { | 2365 | } else { |
2362 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2366 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2363 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2367 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2364 | 0, 1 ); | 2368 | 0, 1 ); |
2365 | 2369 | ||
2366 | return; | 2370 | return; |
2367 | } | 2371 | } |
2368 | if ( loadbup ) { | 2372 | if ( loadbup ) { |
2369 | mView->openCalendar( fn ); | 2373 | mView->openCalendar( fn ); |
2370 | KOPrefs::instance()->mLastLoadFile = fn; | 2374 | KOPrefs::instance()->mLastLoadFile = fn; |
2371 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2375 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2372 | setCaption(mess); | 2376 | setCaption(mess); |
2373 | } | 2377 | } |
2374 | #endif | 2378 | #endif |
2375 | 2379 | ||
2376 | } | 2380 | } |
2377 | void MainWindow::quickImportIcal() | 2381 | void MainWindow::quickImportIcal() |
2378 | { | 2382 | { |
2379 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2383 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2380 | } | 2384 | } |
2381 | void MainWindow::importFile( QString fn, bool quick ) | 2385 | void MainWindow::importFile( QString fn, bool quick ) |
2382 | { | 2386 | { |
2383 | QFileInfo info; | 2387 | QFileInfo info; |
2384 | info.setFile( fn ); | 2388 | info.setFile( fn ); |
2385 | QString mess; | 2389 | QString mess; |
2386 | if ( !info. exists() ) { | 2390 | if ( !info. exists() ) { |
2387 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2391 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2388 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2392 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2389 | mess ); | 2393 | mess ); |
2390 | return; | 2394 | return; |
2391 | } | 2395 | } |
2392 | int result = 0; | 2396 | int result = 0; |
2393 | if ( !quick ) { | 2397 | if ( !quick ) { |
2394 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2398 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2395 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2399 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2396 | mess, | 2400 | mess, |
2397 | "Import", "Cancel", 0, | 2401 | "Import", "Cancel", 0, |
2398 | 0, 1 ); | 2402 | 0, 1 ); |
2399 | } | 2403 | } |
2400 | if ( result == 0 ) { | 2404 | if ( result == 0 ) { |
2401 | if ( mView->openCalendar( fn, true )) { | 2405 | if ( mView->openCalendar( fn, true )) { |
2402 | KOPrefs::instance()->mLastImportFile = fn; | 2406 | KOPrefs::instance()->mLastImportFile = fn; |
2403 | setCaption(i18n("Imported file successfully")); | 2407 | setCaption(i18n("Imported file successfully")); |
2404 | } else { | 2408 | } else { |
2405 | setCaption(i18n("Error importing file")); | 2409 | setCaption(i18n("Error importing file")); |
2406 | } | 2410 | } |
2407 | } | 2411 | } |
2408 | } | 2412 | } |
2409 | 2413 | ||
2410 | void MainWindow::importIcal() | 2414 | void MainWindow::importIcal() |
2411 | { | 2415 | { |
2412 | 2416 | ||
2413 | QString fn =KOPrefs::instance()->mLastImportFile; | 2417 | QString fn =KOPrefs::instance()->mLastImportFile; |
2414 | 2418 | ||
2415 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2419 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2416 | if ( fn == "" ) | 2420 | if ( fn == "" ) |
2417 | return; | 2421 | return; |
2418 | importFile( fn, true ); | 2422 | importFile( fn, true ); |
2419 | 2423 | ||
2420 | } | 2424 | } |
2421 | 2425 | ||
2422 | void MainWindow::exportVCalendar() | 2426 | void MainWindow::exportVCalendar() |
2423 | { | 2427 | { |
2424 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2428 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2425 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2429 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2426 | if ( fn == "" ) | 2430 | if ( fn == "" ) |
2427 | return; | 2431 | return; |
2428 | QFileInfo info; | 2432 | QFileInfo info; |
2429 | info.setFile( fn ); | 2433 | info.setFile( fn ); |
2430 | QString mes; | 2434 | QString mes; |
2431 | bool createbup = true; | 2435 | bool createbup = true; |
2432 | if ( info. exists() ) { | 2436 | if ( info. exists() ) { |
2433 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2437 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2434 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2438 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2435 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2439 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2436 | 0, 1 ); | 2440 | 0, 1 ); |
2437 | if ( result != 0 ) { | 2441 | if ( result != 0 ) { |
2438 | createbup = false; | 2442 | createbup = false; |
2439 | } | 2443 | } |
2440 | } | 2444 | } |
2441 | if ( createbup ) { | 2445 | if ( createbup ) { |
2442 | if ( mView->exportVCalendar( fn ) ) { | 2446 | if ( mView->exportVCalendar( fn ) ) { |
2443 | KOPrefs::instance()->mLastVcalFile = fn; | 2447 | KOPrefs::instance()->mLastVcalFile = fn; |
2444 | if ( fn.length() > 20 ) | 2448 | if ( fn.length() > 20 ) |
2445 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2449 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2446 | else | 2450 | else |
2447 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2451 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2448 | setCaption(mes); | 2452 | setCaption(mes); |
2449 | } | 2453 | } |
2450 | } | 2454 | } |
2451 | 2455 | ||
2452 | } | 2456 | } |
2453 | QString MainWindow::sentSyncFile() | 2457 | QString MainWindow::sentSyncFile() |
2454 | { | 2458 | { |
2455 | #ifdef DESKTOP_VERSION | 2459 | #ifdef DESKTOP_VERSION |
2456 | return locateLocal( "tmp", "copysynccal.ics" ); | 2460 | return locateLocal( "tmp", "copysynccal.ics" ); |
2457 | #else | 2461 | #else |
2458 | return QString( "/tmp/copysynccal.ics" ); | 2462 | return QString( "/tmp/copysynccal.ics" ); |
2459 | #endif | 2463 | #endif |
2460 | } | 2464 | } |
2461 | 2465 | ||
2462 | void MainWindow::syncFileRequest() | 2466 | void MainWindow::syncFileRequest() |
2463 | { | 2467 | { |
2464 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2468 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2465 | mSyncManager->slotSyncMenu( 999 ); | 2469 | mSyncManager->slotSyncMenu( 999 ); |
2466 | } | 2470 | } |
2467 | 2471 | ||
2468 | setCaption(i18n("Saving Data to temp file ..." )); | 2472 | setCaption(i18n("Saving Data to temp file ..." )); |
2469 | mView->saveCalendar( sentSyncFile() ); | 2473 | mView->saveCalendar( sentSyncFile() ); |
2470 | setCaption(i18n("Data saved to temp file!" )); | 2474 | setCaption(i18n("Data saved to temp file!" )); |
2471 | 2475 | ||
2472 | } | 2476 | } |
2473 | void MainWindow::getFile( bool success ) | 2477 | void MainWindow::getFile( bool success ) |
2474 | { | 2478 | { |
2475 | if ( ! success ) { | 2479 | if ( ! success ) { |
2476 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2480 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2477 | return; | 2481 | return; |
2478 | } | 2482 | } |
2479 | mView->openCalendar( sentSyncFile() ); | 2483 | mView->openCalendar( sentSyncFile() ); |
2480 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2484 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2481 | mSyncManager->slotSyncMenu( 999 ); | 2485 | mSyncManager->slotSyncMenu( 999 ); |
2482 | } | 2486 | } |
2483 | setCaption( i18n("Pi-Sync successful!") ); | 2487 | setCaption( i18n("Pi-Sync successful!") ); |
2484 | } | 2488 | } |
2485 | void MainWindow::printListView() | 2489 | void MainWindow::printListView() |
2486 | { | 2490 | { |
2487 | 2491 | ||
2488 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); | 2492 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); |
2489 | 2493 | ||
2490 | KMessageBox::information( this, message); | 2494 | KMessageBox::information( this, message); |
2491 | } | 2495 | } |
2492 | void MainWindow::printSel( ) | 2496 | void MainWindow::printSel( ) |
2493 | { | 2497 | { |
2494 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2498 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2495 | } | 2499 | } |
2496 | 2500 | ||
2497 | void MainWindow::printCal() | 2501 | void MainWindow::printCal() |
2498 | { | 2502 | { |
2499 | mView->print();//mCp->showDialog(); | 2503 | mView->print();//mCp->showDialog(); |
2500 | } | 2504 | } |
2501 | 2505 | ||
2502 | 2506 | ||
2503 | #include "libkdepim/kdatepicker.h" | 2507 | #include "libkdepim/kdatepicker.h" |
2504 | #include <kdatetbl.h> | 2508 | #include <kdatetbl.h> |
2505 | 2509 | ||
2506 | void MainWindow::weekAction() | 2510 | void MainWindow::weekAction() |
2507 | { | 2511 | { |
2508 | int month; | 2512 | int month; |
2509 | KPopupFrame* popup = new KPopupFrame(this); | 2513 | KPopupFrame* popup = new KPopupFrame(this); |
2510 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2514 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2511 | // ----- | 2515 | // ----- |
2512 | picker->resize(picker->sizeHint()); | 2516 | picker->resize(picker->sizeHint()); |
2513 | popup->setMainWidget(picker); | 2517 | popup->setMainWidget(picker); |
2514 | picker->setFocus(); | 2518 | picker->setFocus(); |
2515 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2519 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2516 | int x = 0; | 2520 | int x = 0; |
2517 | int y = iconToolBar->height(); | 2521 | int y = iconToolBar->height(); |
2518 | int dX = 0; | 2522 | int dX = 0; |
2519 | int dY = 0; | 2523 | int dY = 0; |
2520 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2524 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2521 | if ( iconToolBar->y() > height()/2 ) { | 2525 | if ( iconToolBar->y() > height()/2 ) { |
2522 | dY = picker->sizeHint().height()+8; | 2526 | dY = picker->sizeHint().height()+8; |
2523 | y = 0; | 2527 | y = 0; |
2524 | } | 2528 | } |
2525 | } else { | 2529 | } else { |
2526 | if ( iconToolBar->x() > width()/2 ) { // right side | 2530 | if ( iconToolBar->x() > width()/2 ) { // right side |
2527 | x=0; | 2531 | x=0; |
2528 | dX= picker->sizeHint().width()+8; | 2532 | dX= picker->sizeHint().width()+8; |
2529 | y = 0; | 2533 | y = 0; |
2530 | } else { | 2534 | } else { |
2531 | x= iconToolBar->width(); | 2535 | x= iconToolBar->width(); |
2532 | y = 0; | 2536 | y = 0; |
2533 | } | 2537 | } |
2534 | } | 2538 | } |
2535 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2539 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2536 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2540 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2537 | { | 2541 | { |
2538 | month = picker->getResult(); | 2542 | month = picker->getResult(); |
2539 | emit selectWeek ( month ); | 2543 | emit selectWeek ( month ); |
2540 | //qDebug("weekSelected %d ", month); | 2544 | //qDebug("weekSelected %d ", month); |
2541 | } | 2545 | } |
2542 | delete popup; | 2546 | delete popup; |
2543 | } | 2547 | } |
2544 | 2548 | ||
2545 | void MainWindow::hideEvent ( QHideEvent * ) | 2549 | void MainWindow::hideEvent ( QHideEvent * ) |
2546 | { | 2550 | { |
2547 | QString message; | 2551 | QString message; |
2548 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2552 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2549 | if ( nextA.isValid() ) { | 2553 | if ( nextA.isValid() ) { |
2550 | QString sum = mCalendar->nextSummary(); | 2554 | QString sum = mCalendar->nextSummary(); |
2551 | 2555 | ||
2552 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); | 2556 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); |
2553 | setCaption( message ); | 2557 | setCaption( message ); |
2554 | } | 2558 | } |
2555 | } | 2559 | } |
2556 | 2560 | ||
2557 | void MainWindow::resizeEvent( QResizeEvent* e) | 2561 | void MainWindow::resizeEvent( QResizeEvent* e) |
2558 | { | 2562 | { |
2559 | #ifndef DESKTOP_VERSION | 2563 | #ifndef DESKTOP_VERSION |
2560 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { | 2564 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { |
2561 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) | 2565 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) |
2562 | filterToolBar->hide(); | 2566 | filterToolBar->hide(); |
2563 | else | 2567 | else |
2564 | filterToolBar->show(); | 2568 | filterToolBar->show(); |
2565 | } | 2569 | } |
2566 | #endif | 2570 | #endif |
2567 | QMainWindow::resizeEvent( e); | 2571 | QMainWindow::resizeEvent( e); |
2568 | } | 2572 | } |
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index 488dee2..f4f112e 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp | |||
@@ -1,913 +1,913 @@ | |||
1 | #include <qcombobox.h> | 1 | #include <qcombobox.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | #include <qhbox.h> | 3 | #include <qhbox.h> |
4 | #include <qheader.h> | 4 | #include <qheader.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
8 | #include <qlistview.h> | 8 | #include <qlistview.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | #include <qwidgetstack.h> | 10 | #include <qwidgetstack.h> |
11 | #include <qregexp.h> | 11 | #include <qregexp.h> |
12 | #include <qobjectlist.h> | 12 | #include <qobjectlist.h> |
13 | 13 | ||
14 | /* hacky but we need to get FileSelector::filter */ | 14 | /* hacky but we need to get FileSelector::filter */ |
15 | #define private public | 15 | #define private public |
16 | #include <qpe/fileselector.h> | 16 | #include <qpe/fileselector.h> |
17 | #undef private | 17 | #undef private |
18 | 18 | ||
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/mimetype.h> | 20 | #include <qpe/mimetype.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/storage.h> | 22 | #include <qpe/storage.h> |
23 | #include <kglobal.h> | 23 | #include <kglobal.h> |
24 | #include <klocale.h> | 24 | #include <klocale.h> |
25 | 25 | ||
26 | #include "ofileselector_p.h" | 26 | #include "ofileselector_p.h" |
27 | //US#include "ofileselector.h" | 27 | //US#include "ofileselector.h" |
28 | 28 | ||
29 | #include "klocale.h" | 29 | #include "klocale.h" |
30 | 30 | ||
31 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | 31 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) |
32 | : m_selector( selector ) { | 32 | : m_selector( selector ) { |
33 | } | 33 | } |
34 | OFileViewInterface::~OFileViewInterface() { | 34 | OFileViewInterface::~OFileViewInterface() { |
35 | } | 35 | } |
36 | QString OFileViewInterface::name()const{ | 36 | QString OFileViewInterface::name()const{ |
37 | return m_name; | 37 | return m_name; |
38 | } | 38 | } |
39 | void OFileViewInterface::setName( const QString& name ) { | 39 | void OFileViewInterface::setName( const QString& name ) { |
40 | m_name = name; | 40 | m_name = name; |
41 | } | 41 | } |
42 | OFileSelector* OFileViewInterface::selector()const { | 42 | OFileSelector* OFileViewInterface::selector()const { |
43 | return m_selector; | 43 | return m_selector; |
44 | } | 44 | } |
45 | 45 | ||
46 | DocLnk OFileViewInterface::selectedDocument()const { | 46 | DocLnk OFileViewInterface::selectedDocument()const { |
47 | return DocLnk( selectedName() ); | 47 | return DocLnk( selectedName() ); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool OFileViewInterface::showNew()const { | 50 | bool OFileViewInterface::showNew()const { |
51 | return selector()->showNew(); | 51 | return selector()->showNew(); |
52 | } | 52 | } |
53 | bool OFileViewInterface::showClose()const { | 53 | bool OFileViewInterface::showClose()const { |
54 | return selector()->showClose(); | 54 | return selector()->showClose(); |
55 | } | 55 | } |
56 | MimeTypes OFileViewInterface::mimeTypes()const { | 56 | MimeTypes OFileViewInterface::mimeTypes()const { |
57 | return selector()->mimeTypes(); | 57 | return selector()->mimeTypes(); |
58 | } | 58 | } |
59 | QStringList OFileViewInterface::currentMimeType()const { | 59 | QStringList OFileViewInterface::currentMimeType()const { |
60 | return selector()->currentMimeType(); | 60 | return selector()->currentMimeType(); |
61 | } | 61 | } |
62 | void OFileViewInterface::activate( const QString& ) { | 62 | void OFileViewInterface::activate( const QString& ) { |
63 | // not implemented here | 63 | // not implemented here |
64 | } | 64 | } |
65 | void OFileViewInterface::ok() { | 65 | void OFileViewInterface::ok() { |
66 | emit selector()->ok(); | 66 | emit selector()->ok(); |
67 | } | 67 | } |
68 | void OFileViewInterface::cancel() { | 68 | void OFileViewInterface::cancel() { |
69 | emit selector()->cancel(); | 69 | emit selector()->cancel(); |
70 | } | 70 | } |
71 | void OFileViewInterface::closeMe() { | 71 | void OFileViewInterface::closeMe() { |
72 | emit selector()->closeMe(); | 72 | emit selector()->closeMe(); |
73 | } | 73 | } |
74 | void OFileViewInterface::fileSelected( const QString& str) { | 74 | void OFileViewInterface::fileSelected( const QString& str) { |
75 | emit selector()->fileSelected( str); | 75 | emit selector()->fileSelected( str); |
76 | } | 76 | } |
77 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { | 77 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { |
78 | emit selector()->fileSelected( lnk ); | 78 | emit selector()->fileSelected( lnk ); |
79 | } | 79 | } |
80 | void OFileViewInterface::setCurrentFileName( const QString& str ) { | 80 | void OFileViewInterface::setCurrentFileName( const QString& str ) { |
81 | selector()->m_lneEdit->setText( str ); | 81 | selector()->m_lneEdit->setText( str ); |
82 | } | 82 | } |
83 | QString OFileViewInterface::currentFileName()const{ | 83 | QString OFileViewInterface::currentFileName()const{ |
84 | return selector()->m_lneEdit->text(); | 84 | return selector()->m_lneEdit->text(); |
85 | } | 85 | } |
86 | QString OFileViewInterface::startDirectory()const{ | 86 | QString OFileViewInterface::startDirectory()const{ |
87 | return selector()->m_startDir; | 87 | return selector()->m_startDir; |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 91 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
92 | : OFileViewInterface( selector ) { | 92 | : OFileViewInterface( selector ) { |
93 | m_selector = 0; | 93 | m_selector = 0; |
94 | setName( i18n("Documents") ); | 94 | setName( i18n("Documents") ); |
95 | } | 95 | } |
96 | ODocumentFileView::~ODocumentFileView() { | 96 | ODocumentFileView::~ODocumentFileView() { |
97 | 97 | ||
98 | } | 98 | } |
99 | QString ODocumentFileView::selectedName()const { | 99 | QString ODocumentFileView::selectedName()const { |
100 | if (!m_selector) | 100 | if (!m_selector) |
101 | return QString::null; | 101 | return QString::null; |
102 | 102 | ||
103 | return m_selector->selected()->file(); | 103 | return m_selector->selected()->file(); |
104 | } | 104 | } |
105 | QString ODocumentFileView::selectedPath()const { | 105 | QString ODocumentFileView::selectedPath()const { |
106 | return QPEApplication::documentDir(); | 106 | return QPEApplication::documentDir(); |
107 | } | 107 | } |
108 | QString ODocumentFileView::directory()const { | 108 | QString ODocumentFileView::directory()const { |
109 | return selectedPath(); | 109 | return selectedPath(); |
110 | } | 110 | } |
111 | void ODocumentFileView::reread() { | 111 | void ODocumentFileView::reread() { |
112 | if (!m_selector) | 112 | if (!m_selector) |
113 | return; | 113 | return; |
114 | 114 | ||
115 | m_selector->setNewVisible( showNew() ); | 115 | m_selector->setNewVisible( showNew() ); |
116 | m_selector->setCloseVisible( showClose() ); | 116 | m_selector->setCloseVisible( showClose() ); |
117 | m_selector->filter = currentMimeType().join(";"); | 117 | m_selector->filter = currentMimeType().join(";"); |
118 | m_selector->reread(); | 118 | m_selector->reread(); |
119 | } | 119 | } |
120 | int ODocumentFileView::fileCount()const { | 120 | int ODocumentFileView::fileCount()const { |
121 | if (!m_selector) | 121 | if (!m_selector) |
122 | return -1; | 122 | return -1; |
123 | 123 | ||
124 | return m_selector->fileCount(); | 124 | return m_selector->fileCount(); |
125 | } | 125 | } |
126 | 126 | ||
127 | DocLnk ODocumentFileView::selectedDocument()const { | 127 | DocLnk ODocumentFileView::selectedDocument()const { |
128 | if (!m_selector) | 128 | if (!m_selector) |
129 | return DocLnk(); | 129 | return DocLnk(); |
130 | DocLnk lnk = *m_selector->selected(); | 130 | DocLnk lnk = *m_selector->selected(); |
131 | return lnk; | 131 | return lnk; |
132 | } | 132 | } |
133 | 133 | ||
134 | QWidget* ODocumentFileView::widget( QWidget* parent ) { | 134 | QWidget* ODocumentFileView::widget( QWidget* parent ) { |
135 | if (!m_selector ) { | 135 | if (!m_selector ) { |
136 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 136 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
137 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), | 137 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), |
138 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 138 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
139 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 139 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
140 | selector(), SIGNAL(closeMe() ) ); | 140 | selector(), SIGNAL(closeMe() ) ); |
141 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), | 141 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), |
142 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); | 142 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); |
143 | } | 143 | } |
144 | 144 | ||
145 | return m_selector; | 145 | return m_selector; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* | 148 | /* |
149 | * This is the file system view used | 149 | * This is the file system view used |
150 | * we use a QListView + QListViewItems for it | 150 | * we use a QListView + QListViewItems for it |
151 | */ | 151 | */ |
152 | 152 | ||
153 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 153 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
154 | const QString& path, const QString& date, | 154 | const QString& path, const QString& date, |
155 | const QString& size, const QString& dir, | 155 | const QString& size, const QString& dir, |
156 | bool isLocked, bool isDir ) | 156 | bool isLocked, bool isDir ) |
157 | : QListViewItem( view ) | 157 | : QListViewItem( view ) |
158 | { | 158 | { |
159 | 159 | ||
160 | QString kind = "dir";; | 160 | QString kind = "dir";; |
161 | QString _path = path; | 161 | QString _path = path; |
162 | if ( !isDir ){ | 162 | if ( !isDir ){ |
163 | int arrow = path.findRev( "." ,-1); | 163 | int arrow = path.findRev( "." ,-1); |
164 | if (arrow > 0 ) { | 164 | if (arrow > 0 ) { |
165 | kind = path.mid(arrow+1); | 165 | kind = path.mid(arrow+1); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | setPixmap(0, pixmap ); | 168 | setPixmap(0, pixmap ); |
169 | int arrow = path.find( "->" ); | 169 | int arrow = path.find( "->" ); |
170 | if (arrow > 0 ) { | 170 | if (arrow > 0 ) { |
171 | _path = path.left(arrow); | 171 | _path = path.left(arrow); |
172 | } | 172 | } |
173 | setText(1, _path ); | 173 | setText(1, _path ); |
174 | setText(2, size ); | 174 | setText(2, size ); |
175 | setText(3, date ); | 175 | setText(3, date ); |
176 | setText(4, kind ); | 176 | setText(4, kind ); |
177 | m_isDir = isDir; | 177 | m_isDir = isDir; |
178 | m_dir = dir; | 178 | m_dir = dir; |
179 | m_locked = isLocked; | 179 | m_locked = isLocked; |
180 | } | 180 | } |
181 | OFileSelectorItem::~OFileSelectorItem() { | 181 | OFileSelectorItem::~OFileSelectorItem() { |
182 | 182 | ||
183 | } | 183 | } |
184 | bool OFileSelectorItem::isLocked()const { | 184 | bool OFileSelectorItem::isLocked()const { |
185 | return m_locked; | 185 | return m_locked; |
186 | } | 186 | } |
187 | QString OFileSelectorItem::directory()const { | 187 | QString OFileSelectorItem::directory()const { |
188 | return m_dir; | 188 | return m_dir; |
189 | } | 189 | } |
190 | bool OFileSelectorItem::isDir()const { | 190 | bool OFileSelectorItem::isDir()const { |
191 | return m_isDir; | 191 | return m_isDir; |
192 | } | 192 | } |
193 | QString OFileSelectorItem::path()const { | 193 | QString OFileSelectorItem::path()const { |
194 | return text( 1 ); | 194 | return text( 1 ); |
195 | } | 195 | } |
196 | QString OFileSelectorItem::key( int id, bool )const { | 196 | QString OFileSelectorItem::key( int id, bool )const { |
197 | QString ke; | 197 | QString ke; |
198 | if( id == 0 || id == 1 ){ // name | 198 | if( id == 0 || id == 1 ){ // name |
199 | if( m_isDir ){ | 199 | if( m_isDir ){ |
200 | ke.append("0" ); | 200 | ke.append("0" ); |
201 | ke.append( text(1) ); | 201 | ke.append( text(1) ); |
202 | }else{ | 202 | }else{ |
203 | ke.append("1" ); | 203 | ke.append("1" ); |
204 | ke.append( text(1) ); | 204 | ke.append( text(1) ); |
205 | } | 205 | } |
206 | return ke; | 206 | return ke; |
207 | } else if ( id == 2 ) { | 207 | } else if ( id == 2 ) { |
208 | QString sort = "00000000"; | 208 | QString sort = "00000000"; |
209 | sort = sort.left( 9-text( 2 ).length()) + text( 2 ); | 209 | sort = sort.left( 9-text( 2 ).length()) + text( 2 ); |
210 | return sort; | 210 | return sort; |
211 | 211 | ||
212 | } else | 212 | } else |
213 | return text( id ); | 213 | return text( id ); |
214 | 214 | ||
215 | } | 215 | } |
216 | 216 | ||
217 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, | 217 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, |
218 | OFileSelector* sel) | 218 | OFileSelector* sel) |
219 | : QWidget( parent ), m_sel( sel ) { | 219 | : QWidget( parent ), m_sel( sel ) { |
220 | m_all = false; | 220 | m_all = false; |
221 | QVBoxLayout* lay = new QVBoxLayout( this ); | 221 | QVBoxLayout* lay = new QVBoxLayout( this ); |
222 | m_currentDir = startDir; | 222 | m_currentDir = startDir; |
223 | 223 | ||
224 | /* | 224 | /* |
225 | * now we add a special bar | 225 | * now we add a special bar |
226 | * One Button For Up | 226 | * One Button For Up |
227 | * Home | 227 | * Home |
228 | * Doc | 228 | * Doc |
229 | * And a dropdown menu with FileSystems | 229 | * And a dropdown menu with FileSystems |
230 | * FUTURE: one to change dir with lineedit | 230 | * FUTURE: one to change dir with lineedit |
231 | * Bookmarks | 231 | * Bookmarks |
232 | * Create Dir | 232 | * Create Dir |
233 | */ | 233 | */ |
234 | QHBox* box = new QHBox(this ); | 234 | QHBox* box = new QHBox(this ); |
235 | box->setBackgroundMode( PaletteButton ); | 235 | box->setBackgroundMode( PaletteButton ); |
236 | box->setSpacing( 0 ); | 236 | box->setSpacing( 0 ); |
237 | 237 | ||
238 | QToolButton *btn = new QToolButton( box ); | 238 | QToolButton *btn = new QToolButton( box ); |
239 | btn->setIconSet( Resource::loadPixmap("up") ); | 239 | btn->setIconSet( Resource::loadPixmap("up") ); |
240 | connect(btn, SIGNAL(clicked() ), | 240 | connect(btn, SIGNAL(clicked() ), |
241 | this, SLOT( cdUP() ) ); | 241 | this, SLOT( cdUP() ) ); |
242 | 242 | ||
243 | btn = new QToolButton( box ); | 243 | btn = new QToolButton( box ); |
244 | btn->setIconSet( Resource::loadPixmap("home") ); | 244 | btn->setIconSet( Resource::loadPixmap("home") ); |
245 | connect(btn, SIGNAL(clicked() ), | 245 | connect(btn, SIGNAL(clicked() ), |
246 | this, SLOT( cdHome() ) ); | 246 | this, SLOT( cdHome() ) ); |
247 | 247 | ||
248 | btn = new QToolButton( box ); | 248 | btn = new QToolButton( box ); |
249 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); | 249 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); |
250 | connect(btn, SIGNAL(clicked() ), | 250 | connect(btn, SIGNAL(clicked() ), |
251 | this, SLOT(cdDoc() ) ); | 251 | this, SLOT(cdDoc() ) ); |
252 | 252 | ||
253 | m_btnNew = new QToolButton( box ); | 253 | m_btnNew = new QToolButton( box ); |
254 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); | 254 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); |
255 | connect(m_btnNew, SIGNAL(clicked() ), | 255 | connect(m_btnNew, SIGNAL(clicked() ), |
256 | this, SLOT(slotNew() ) ); | 256 | this, SLOT(slotNew() ) ); |
257 | 257 | ||
258 | 258 | ||
259 | m_btnClose = new QToolButton( box ); | 259 | m_btnClose = new QToolButton( box ); |
260 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); | 260 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); |
261 | connect(m_btnClose, SIGNAL(clicked() ), | 261 | connect(m_btnClose, SIGNAL(clicked() ), |
262 | selector(), SIGNAL(closeMe() ) ); | 262 | selector(), SIGNAL(closeMe() ) ); |
263 | 263 | ||
264 | btn = new QToolButton( box ); | 264 | btn = new QToolButton( box ); |
265 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); | 265 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); |
266 | 266 | ||
267 | /* let's fill device parts */ | 267 | /* let's fill device parts */ |
268 | QPopupMenu* pop = new QPopupMenu(this); | 268 | QPopupMenu* pop = new QPopupMenu(this); |
269 | connect(pop, SIGNAL( activated(int) ), | 269 | connect(pop, SIGNAL( activated(int) ), |
270 | this, SLOT(slotFSActivated(int) ) ); | 270 | this, SLOT(slotFSActivated(int) ) ); |
271 | 271 | ||
272 | StorageInfo storage; | 272 | StorageInfo storage; |
273 | const QList<FileSystem> &fs = storage.fileSystems(); | 273 | const QList<FileSystem> &fs = storage.fileSystems(); |
274 | QListIterator<FileSystem> it(fs); | 274 | QListIterator<FileSystem> it(fs); |
275 | for ( ; it.current(); ++it ) { | 275 | for ( ; it.current(); ++it ) { |
276 | const QString disk = (*it)->name(); | 276 | const QString disk = (*it)->name(); |
277 | const QString path = (*it)->path(); | 277 | const QString path = (*it)->path(); |
278 | m_dev.insert( disk, path ); | 278 | m_dev.insert( disk, path ); |
279 | pop->insertItem( disk ); | 279 | pop->insertItem( disk ); |
280 | } | 280 | } |
281 | m_fsPop = pop; | 281 | m_fsPop = pop; |
282 | 282 | ||
283 | 283 | ||
284 | btn->setPopup( pop ); | 284 | btn->setPopup( pop ); |
285 | btn->setPopupDelay ( 0 ); | 285 | btn->setPopupDelay ( 0 ); |
286 | lay->addWidget( box ); | 286 | lay->addWidget( box ); |
287 | 287 | ||
288 | m_view = new QListView( this ); | 288 | m_view = new QListView( this ); |
289 | 289 | ||
290 | m_view->installEventFilter(this); | 290 | m_view->installEventFilter(this); |
291 | 291 | ||
292 | QPEApplication::setStylusOperation( m_view->viewport(), | 292 | QPEApplication::setStylusOperation( m_view->viewport(), |
293 | QPEApplication::RightOnHold); | 293 | QPEApplication::RightOnHold); |
294 | m_view->addColumn(" " ); | 294 | m_view->addColumn(" " ); |
295 | m_view->addColumn(i18n("Name"), 150 ); | 295 | m_view->addColumn(i18n("Name"), 150 ); |
296 | m_view->addColumn(i18n("Size"), -1 ); | 296 | m_view->addColumn(i18n("Size"), -1 ); |
297 | m_view->addColumn(i18n("Date"), -1 ); | 297 | m_view->addColumn(i18n("Date"), -1 ); |
298 | m_view->addColumn(i18n("Mime Type"), -1 ); | 298 | m_view->addColumn(i18n("Mime Type"), -1 ); |
299 | 299 | ||
300 | 300 | ||
301 | m_view->setSorting( 1 ); | 301 | m_view->setSorting( 1 ); |
302 | m_view->setAllColumnsShowFocus( TRUE ); | 302 | m_view->setAllColumnsShowFocus( TRUE ); |
303 | 303 | ||
304 | lay->addWidget( m_view, 1000 ); | 304 | lay->addWidget( m_view, 1000 ); |
305 | connectSlots(); | 305 | connectSlots(); |
306 | } | 306 | } |
307 | OFileViewFileListView::~OFileViewFileListView() { | 307 | OFileViewFileListView::~OFileViewFileListView() { |
308 | } | 308 | } |
309 | void OFileViewFileListView::slotNew() { | 309 | void OFileViewFileListView::slotNew() { |
310 | DocLnk lnk; | 310 | DocLnk lnk; |
311 | emit selector()->newSelected( lnk ); | 311 | emit selector()->newSelected( lnk ); |
312 | } | 312 | } |
313 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | 313 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ |
314 | QListViewItem* item = m_view->currentItem(); | 314 | QListViewItem* item = m_view->currentItem(); |
315 | if (!item ) | 315 | if (!item ) |
316 | return 0l; | 316 | return 0l; |
317 | 317 | ||
318 | return static_cast<OFileSelectorItem*>(item); | 318 | return static_cast<OFileSelectorItem*>(item); |
319 | } | 319 | } |
320 | void OFileViewFileListView::reread( bool all ) { | 320 | void OFileViewFileListView::reread( bool all ) { |
321 | m_view->clear(); | 321 | m_view->clear(); |
322 | 322 | ||
323 | if (selector()->showClose() ) | 323 | if (selector()->showClose() ) |
324 | m_btnClose->show(); | 324 | m_btnClose->show(); |
325 | else | 325 | else |
326 | m_btnClose->hide(); | 326 | m_btnClose->hide(); |
327 | 327 | ||
328 | if (selector()->showNew() ) | 328 | if (selector()->showNew() ) |
329 | m_btnNew->show(); | 329 | m_btnNew->show(); |
330 | else | 330 | else |
331 | m_btnNew->hide(); | 331 | m_btnNew->hide(); |
332 | 332 | ||
333 | m_mimes = selector()->currentMimeType(); | 333 | m_mimes = selector()->currentMimeType(); |
334 | m_all = all; | 334 | m_all = all; |
335 | 335 | ||
336 | QDir dir( m_currentDir ); | 336 | QDir dir( m_currentDir ); |
337 | if (!dir.exists() ) | 337 | if (!dir.exists() ) |
338 | return; | 338 | return; |
339 | topLevelWidget()->setCaption( dir.path() ); | 339 | topLevelWidget()->setCaption( dir.path() ); |
340 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 340 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
341 | int filter; | 341 | int filter; |
342 | if (m_all ) | 342 | if (m_all ) |
343 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 343 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
344 | else | 344 | else |
345 | filter = QDir::Files | QDir::Dirs | QDir::All; | 345 | filter = QDir::Files | QDir::Dirs | QDir::All; |
346 | dir.setFilter( filter ); | 346 | dir.setFilter( filter ); |
347 | 347 | ||
348 | // now go through all files | 348 | // now go through all files |
349 | const QFileInfoList *list = dir.entryInfoList(); | 349 | const QFileInfoList *list = dir.entryInfoList(); |
350 | if (!list) { | 350 | if (!list) { |
351 | cdUP(); | 351 | cdUP(); |
352 | return; | 352 | return; |
353 | } | 353 | } |
354 | QFileInfoListIterator it( *list ); | 354 | QFileInfoListIterator it( *list ); |
355 | QFileInfo *fi; | 355 | QFileInfo *fi; |
356 | while( (fi=it.current() ) ){ | 356 | while( (fi=it.current() ) ){ |
357 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 357 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
358 | ++it; | 358 | ++it; |
359 | continue; | 359 | continue; |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 363 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
364 | * | 364 | * |
365 | */ | 365 | */ |
366 | if( fi->isSymLink() ){ | 366 | if( fi->isSymLink() ){ |
367 | qDebug("SYMLINK "); | 367 | //qDebug("SYMLINK "); |
368 | QString file = fi->readLink(); | 368 | QString file = fi->readLink(); |
369 | for( int i = 0; i<=5; i++) { // 5 tries to prevent dos | 369 | for( int i = 0; i<=5; i++) { // 5 tries to prevent dos |
370 | QFileInfo info( file ); | 370 | QFileInfo info( file ); |
371 | qDebug("FILE %s ", file.latin1()); | 371 | //qDebug("FILE %s ", file.latin1()); |
372 | if( !info.exists() ){ | 372 | if( !info.exists() ){ |
373 | addSymlink( fi, TRUE ); | 373 | addSymlink( fi, TRUE ); |
374 | break; | 374 | break; |
375 | }else if( info.isDir() ){ | 375 | }else if( info.isDir() ){ |
376 | addDir( fi, TRUE ); | 376 | addDir( fi, TRUE ); |
377 | break; | 377 | break; |
378 | }else if( info.isFile() ){ | 378 | }else if( info.isFile() ){ |
379 | addFile( fi, TRUE ); | 379 | addFile( fi, TRUE ); |
380 | break; | 380 | break; |
381 | }else if( info.isSymLink() ){ | 381 | }else if( info.isSymLink() ){ |
382 | file = info.readLink() ; | 382 | file = info.readLink() ; |
383 | break; | 383 | break; |
384 | }else if( i == 4){ // couldn't resolve symlink add it as symlink | 384 | }else if( i == 4){ // couldn't resolve symlink add it as symlink |
385 | addSymlink( fi ); | 385 | addSymlink( fi ); |
386 | } | 386 | } |
387 | } // off for loop for symlink resolving | 387 | } // off for loop for symlink resolving |
388 | }else if( fi->isDir() ) | 388 | }else if( fi->isDir() ) |
389 | addDir( fi ); | 389 | addDir( fi ); |
390 | else if( fi->isFile() ) | 390 | else if( fi->isFile() ) |
391 | addFile( fi ); | 391 | addFile( fi ); |
392 | 392 | ||
393 | ++it; | 393 | ++it; |
394 | } // of while loop | 394 | } // of while loop |
395 | m_view->sort(); | 395 | m_view->sort(); |
396 | 396 | ||
397 | } | 397 | } |
398 | int OFileViewFileListView::fileCount()const{ | 398 | int OFileViewFileListView::fileCount()const{ |
399 | return m_view->childCount(); | 399 | return m_view->childCount(); |
400 | } | 400 | } |
401 | QString OFileViewFileListView::currentDir()const{ | 401 | QString OFileViewFileListView::currentDir()const{ |
402 | return m_currentDir; | 402 | return m_currentDir; |
403 | } | 403 | } |
404 | OFileSelector* OFileViewFileListView::selector() { | 404 | OFileSelector* OFileViewFileListView::selector() { |
405 | return m_sel; | 405 | return m_sel; |
406 | } | 406 | } |
407 | 407 | ||
408 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { | 408 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { |
409 | #if 0 | 409 | #if 0 |
410 | if ( e->type() == QEvent::KeyPress ) { | 410 | if ( e->type() == QEvent::KeyPress ) { |
411 | QKeyEvent *k = (QKeyEvent *)e; | 411 | QKeyEvent *k = (QKeyEvent *)e; |
412 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 412 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
413 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 413 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
414 | return true; | 414 | return true; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | #endif | 417 | #endif |
418 | return false; | 418 | return false; |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void OFileViewFileListView::connectSlots() { | 422 | void OFileViewFileListView::connectSlots() { |
423 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 423 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
424 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 424 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
425 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), | 425 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), |
426 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); | 426 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); |
427 | connect(m_view, SIGNAL(doubleClicked( QListViewItem* )), | 427 | connect(m_view, SIGNAL(doubleClicked( QListViewItem* )), |
428 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); | 428 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); |
429 | connect(m_view, SIGNAL(returnPressed( QListViewItem* )), | 429 | connect(m_view, SIGNAL(returnPressed( QListViewItem* )), |
430 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); | 430 | this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); |
431 | } | 431 | } |
432 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { | 432 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { |
433 | if (!item) | 433 | if (!item) |
434 | return; | 434 | return; |
435 | #if 0 | 435 | #if 0 |
436 | 436 | ||
437 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 437 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
438 | 438 | ||
439 | if (!sel->isDir() ) { | 439 | if (!sel->isDir() ) { |
440 | selector()->m_lneEdit->setText( sel->text(1) ); | 440 | selector()->m_lneEdit->setText( sel->text(1) ); |
441 | // if in fileselector mode we will emit selected | 441 | // if in fileselector mode we will emit selected |
442 | if ( selector()->mode() == OFileSelector::FileSelector ) { | 442 | if ( selector()->mode() == OFileSelector::FileSelector ) { |
443 | qWarning("slot Current Changed"); | 443 | qWarning("slot Current Changed"); |
444 | QStringList str = QStringList::split("->", sel->text(1) ); | 444 | QStringList str = QStringList::split("->", sel->text(1) ); |
445 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 445 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
446 | emit selector()->fileSelected( path ); | 446 | emit selector()->fileSelected( path ); |
447 | DocLnk lnk( path ); | 447 | DocLnk lnk( path ); |
448 | emit selector()->fileSelected( lnk ); | 448 | emit selector()->fileSelected( lnk ); |
449 | } | 449 | } |
450 | } | 450 | } |
451 | #endif | 451 | #endif |
452 | } | 452 | } |
453 | void OFileViewFileListView::slotDoubleClicked(QListViewItem* item ) { | 453 | void OFileViewFileListView::slotDoubleClicked(QListViewItem* item ) { |
454 | if (!item ) return; | 454 | if (!item ) return; |
455 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 455 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
456 | if (!sel->isLocked() ) { | 456 | if (!sel->isLocked() ) { |
457 | QStringList str = QStringList::split("->", sel->text(1) ); | 457 | QStringList str = QStringList::split("->", sel->text(1) ); |
458 | if (sel->isDir() ) { | 458 | if (sel->isDir() ) { |
459 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 459 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
460 | emit selector()->dirSelected( m_currentDir ); | 460 | emit selector()->dirSelected( m_currentDir ); |
461 | reread( m_all ); | 461 | reread( m_all ); |
462 | }else { // file | 462 | }else { // file |
463 | //qWarning("slot Clicked"); | 463 | //qWarning("slot Clicked"); |
464 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 464 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
465 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 465 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
466 | emit selector()->fileSelected( path ); | 466 | emit selector()->fileSelected( path ); |
467 | DocLnk lnk( path ); | 467 | DocLnk lnk( path ); |
468 | emit selector()->fileSelected( lnk ); | 468 | emit selector()->fileSelected( lnk ); |
469 | emit selector()->ok(); | 469 | emit selector()->ok(); |
470 | } | 470 | } |
471 | } // not locked | 471 | } // not locked |
472 | } | 472 | } |
473 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { | 473 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { |
474 | if (!item || ( button != Qt::LeftButton) ) | 474 | if (!item || ( button != Qt::LeftButton) ) |
475 | return; | 475 | return; |
476 | 476 | ||
477 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 477 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
478 | if (!sel->isLocked() ) { | 478 | if (!sel->isLocked() ) { |
479 | QStringList str = QStringList::split("->", sel->text(1) ); | 479 | QStringList str = QStringList::split("->", sel->text(1) ); |
480 | if (sel->isDir() ) { | 480 | if (sel->isDir() ) { |
481 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 481 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
482 | emit selector()->dirSelected( m_currentDir ); | 482 | emit selector()->dirSelected( m_currentDir ); |
483 | reread( m_all ); | 483 | reread( m_all ); |
484 | }else { // file | 484 | }else { // file |
485 | //qWarning("slot Clicked"); | 485 | //qWarning("slot Clicked"); |
486 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 486 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
487 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 487 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
488 | emit selector()->fileSelected( path ); | 488 | emit selector()->fileSelected( path ); |
489 | DocLnk lnk( path ); | 489 | DocLnk lnk( path ); |
490 | emit selector()->fileSelected( lnk ); | 490 | emit selector()->fileSelected( lnk ); |
491 | } | 491 | } |
492 | } // not locked | 492 | } // not locked |
493 | } | 493 | } |
494 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { | 494 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { |
495 | MimeType type( info->absFilePath() ); | 495 | MimeType type( info->absFilePath() ); |
496 | if (!compliesMime( type.id() ) ) | 496 | if (!compliesMime( type.id() ) ) |
497 | return; | 497 | return; |
498 | 498 | ||
499 | QPixmap pix = type.pixmap(); | 499 | QPixmap pix = type.pixmap(); |
500 | QString dir, name; bool locked; | 500 | QString dir, name; bool locked; |
501 | if ( pix.isNull() ) { | 501 | if ( pix.isNull() ) { |
502 | QWMatrix matrix; | 502 | QWMatrix matrix; |
503 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 503 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
504 | matrix.scale( .4, .4 ); | 504 | matrix.scale( .4, .4 ); |
505 | pix = pixer.xForm( matrix ); | 505 | pix = pixer.xForm( matrix ); |
506 | } | 506 | } |
507 | dir = info->dirPath( true ); | 507 | dir = info->dirPath( true ); |
508 | locked = false; | 508 | locked = false; |
509 | if ( symlink ) | 509 | if ( symlink ) |
510 | name = info->fileName() + " -> " + info->readLink(); | 510 | name = info->fileName() + " -> " + info->readLink(); |
511 | else{ | 511 | else{ |
512 | name = info->fileName(); | 512 | name = info->fileName(); |
513 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 513 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
514 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { | 514 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { |
515 | locked = true; pix = Resource::loadPixmap("locked"); | 515 | locked = true; pix = Resource::loadPixmap("locked"); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | (void)new OFileSelectorItem( m_view, pix, name, | 518 | (void)new OFileSelectorItem( m_view, pix, name, |
519 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), | 519 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), |
520 | QString::number( info->size() ), | 520 | QString::number( info->size() ), |
521 | dir, locked ); | 521 | dir, locked ); |
522 | } | 522 | } |
523 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { | 523 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { |
524 | bool locked = false; QString name; QPixmap pix; | 524 | bool locked = false; QString name; QPixmap pix; |
525 | 525 | ||
526 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 526 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
527 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { | 527 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { |
528 | locked = true; | 528 | locked = true; |
529 | if ( symlink ) | 529 | if ( symlink ) |
530 | pix = Resource::loadPixmap( "symlink" ); | 530 | pix = Resource::loadPixmap( "symlink" ); |
531 | else | 531 | else |
532 | pix = Resource::loadPixmap( "lockedfolder" ); | 532 | pix = Resource::loadPixmap( "lockedfolder" ); |
533 | }else | 533 | }else |
534 | pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); | 534 | pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); |
535 | 535 | ||
536 | name = symlink ? info->fileName() + " -> " + info->readLink() : | 536 | name = symlink ? info->fileName() + " -> " + info->readLink() : |
537 | info->fileName(); | 537 | info->fileName(); |
538 | 538 | ||
539 | (void)new OFileSelectorItem( m_view, pix, name, | 539 | (void)new OFileSelectorItem( m_view, pix, name, |
540 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), | 540 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), |
541 | QString::number( info->size() ), | 541 | QString::number( info->size() ), |
542 | info->dirPath( true ), locked, true ); | 542 | info->dirPath( true ), locked, true ); |
543 | 543 | ||
544 | 544 | ||
545 | } | 545 | } |
546 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { | 546 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { |
547 | 547 | ||
548 | } | 548 | } |
549 | void OFileViewFileListView::cdUP() { | 549 | void OFileViewFileListView::cdUP() { |
550 | QDir dir( m_currentDir ); | 550 | QDir dir( m_currentDir ); |
551 | dir.cdUp(); | 551 | dir.cdUp(); |
552 | 552 | ||
553 | if (!dir.exists() ) | 553 | if (!dir.exists() ) |
554 | m_currentDir = "/"; | 554 | m_currentDir = "/"; |
555 | else | 555 | else |
556 | m_currentDir = dir.absPath(); | 556 | m_currentDir = dir.absPath(); |
557 | 557 | ||
558 | emit selector()->dirSelected( m_currentDir ); | 558 | emit selector()->dirSelected( m_currentDir ); |
559 | reread( m_all ); | 559 | reread( m_all ); |
560 | } | 560 | } |
561 | void OFileViewFileListView::cdHome() { | 561 | void OFileViewFileListView::cdHome() { |
562 | m_currentDir = QDir::homeDirPath(); | 562 | m_currentDir = QDir::homeDirPath(); |
563 | emit selector()->dirSelected( m_currentDir ); | 563 | emit selector()->dirSelected( m_currentDir ); |
564 | reread( m_all ); | 564 | reread( m_all ); |
565 | } | 565 | } |
566 | void OFileViewFileListView::cdDoc() { | 566 | void OFileViewFileListView::cdDoc() { |
567 | m_currentDir = QPEApplication::documentDir(); | 567 | m_currentDir = QPEApplication::documentDir(); |
568 | emit selector()->dirSelected( m_currentDir ); | 568 | emit selector()->dirSelected( m_currentDir ); |
569 | reread( m_all ); | 569 | reread( m_all ); |
570 | } | 570 | } |
571 | void OFileViewFileListView::changeDir( const QString& dir ) { | 571 | void OFileViewFileListView::changeDir( const QString& dir ) { |
572 | m_currentDir = dir; | 572 | m_currentDir = dir; |
573 | emit selector()->dirSelected( m_currentDir ); | 573 | emit selector()->dirSelected( m_currentDir ); |
574 | reread( m_all ); | 574 | reread( m_all ); |
575 | } | 575 | } |
576 | void OFileViewFileListView::slotFSActivated( int id ) { | 576 | void OFileViewFileListView::slotFSActivated( int id ) { |
577 | changeDir ( m_dev[m_fsPop->text(id)] ); | 577 | changeDir ( m_dev[m_fsPop->text(id)] ); |
578 | } | 578 | } |
579 | 579 | ||
580 | /* check if the mimetype in mime | 580 | /* check if the mimetype in mime |
581 | * complies with the one which is current | 581 | * complies with the one which is current |
582 | */ | 582 | */ |
583 | /* | 583 | /* |
584 | * We've the mimetype of the file | 584 | * We've the mimetype of the file |
585 | * We need to get the stringlist of the current mimetype | 585 | * We need to get the stringlist of the current mimetype |
586 | * | 586 | * |
587 | * mime = image@slashjpeg | 587 | * mime = image@slashjpeg |
588 | * QStringList = 'image@slash*' | 588 | * QStringList = 'image@slash*' |
589 | * or QStringList = image/jpeg;image/png;application/x-ogg | 589 | * or QStringList = image/jpeg;image/png;application/x-ogg |
590 | * or QStringList = application/x-ogg;image@slash*; | 590 | * or QStringList = application/x-ogg;image@slash*; |
591 | * with all these mime filters it should get acceptes | 591 | * with all these mime filters it should get acceptes |
592 | * to do so we need to look if mime is contained inside | 592 | * to do so we need to look if mime is contained inside |
593 | * the stringlist | 593 | * the stringlist |
594 | * if it's contained return true | 594 | * if it's contained return true |
595 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 595 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
596 | * is contained in the mimefilter and then we will | 596 | * is contained in the mimefilter and then we will |
597 | * look if both are equal until the '/' | 597 | * look if both are equal until the '/' |
598 | */ | 598 | */ |
599 | bool OFileViewFileListView::compliesMime( const QString& str) { | 599 | bool OFileViewFileListView::compliesMime( const QString& str) { |
600 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 600 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
601 | return true; | 601 | return true; |
602 | 602 | ||
603 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { | 603 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { |
604 | QRegExp reg( (*it) ); | 604 | QRegExp reg( (*it) ); |
605 | reg.setWildcard( true ); | 605 | reg.setWildcard( true ); |
606 | if ( str.find( reg ) != -1 ) | 606 | if ( str.find( reg ) != -1 ) |
607 | return true; | 607 | return true; |
608 | 608 | ||
609 | } | 609 | } |
610 | return false; | 610 | return false; |
611 | } | 611 | } |
612 | /* | 612 | /* |
613 | * The listView giving access to the file system! | 613 | * The listView giving access to the file system! |
614 | */ | 614 | */ |
615 | class OFileViewFileSystem : public OFileViewInterface { | 615 | class OFileViewFileSystem : public OFileViewInterface { |
616 | public: | 616 | public: |
617 | OFileViewFileSystem( OFileSelector* ); | 617 | OFileViewFileSystem( OFileSelector* ); |
618 | ~OFileViewFileSystem(); | 618 | ~OFileViewFileSystem(); |
619 | 619 | ||
620 | QString selectedName() const; | 620 | QString selectedName() const; |
621 | QString selectedPath() const; | 621 | QString selectedPath() const; |
622 | 622 | ||
623 | QString directory()const; | 623 | QString directory()const; |
624 | void reread(); | 624 | void reread(); |
625 | int fileCount()const; | 625 | int fileCount()const; |
626 | 626 | ||
627 | QWidget* widget( QWidget* parent ); | 627 | QWidget* widget( QWidget* parent ); |
628 | void activate( const QString& ); | 628 | void activate( const QString& ); |
629 | private: | 629 | private: |
630 | OFileViewFileListView* m_view; | 630 | OFileViewFileListView* m_view; |
631 | bool m_all : 1; | 631 | bool m_all : 1; |
632 | }; | 632 | }; |
633 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 633 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
634 | : OFileViewInterface( sel ) { | 634 | : OFileViewInterface( sel ) { |
635 | m_view = 0; | 635 | m_view = 0; |
636 | m_all = false; | 636 | m_all = false; |
637 | } | 637 | } |
638 | OFileViewFileSystem::~OFileViewFileSystem() { | 638 | OFileViewFileSystem::~OFileViewFileSystem() { |
639 | } | 639 | } |
640 | QString OFileViewFileSystem::selectedName()const{ | 640 | QString OFileViewFileSystem::selectedName()const{ |
641 | if (!m_view ) | 641 | if (!m_view ) |
642 | return QString::null; | 642 | return QString::null; |
643 | 643 | ||
644 | QString cFN=currentFileName(); | 644 | QString cFN=currentFileName(); |
645 | if (cFN.startsWith("/")) return cFN; | 645 | if (cFN.startsWith("/")) return cFN; |
646 | return m_view->currentDir() + "/" + cFN; | 646 | return m_view->currentDir() + "/" + cFN; |
647 | } | 647 | } |
648 | QString OFileViewFileSystem::selectedPath()const{ | 648 | QString OFileViewFileSystem::selectedPath()const{ |
649 | return QString::null; | 649 | return QString::null; |
650 | } | 650 | } |
651 | QString OFileViewFileSystem::directory()const{ | 651 | QString OFileViewFileSystem::directory()const{ |
652 | if (!m_view) | 652 | if (!m_view) |
653 | return QString::null; | 653 | return QString::null; |
654 | 654 | ||
655 | OFileSelectorItem* item = m_view->currentItem(); | 655 | OFileSelectorItem* item = m_view->currentItem(); |
656 | if (!item ) | 656 | if (!item ) |
657 | return QString::null; | 657 | return QString::null; |
658 | 658 | ||
659 | return QDir(item->directory() ).absPath(); | 659 | return QDir(item->directory() ).absPath(); |
660 | } | 660 | } |
661 | void OFileViewFileSystem::reread() { | 661 | void OFileViewFileSystem::reread() { |
662 | if (!m_view) | 662 | if (!m_view) |
663 | return; | 663 | return; |
664 | 664 | ||
665 | m_view->reread( m_all ); | 665 | m_view->reread( m_all ); |
666 | } | 666 | } |
667 | int OFileViewFileSystem::fileCount()const{ | 667 | int OFileViewFileSystem::fileCount()const{ |
668 | if (!m_view ) | 668 | if (!m_view ) |
669 | return -1; | 669 | return -1; |
670 | return m_view->fileCount(); | 670 | return m_view->fileCount(); |
671 | } | 671 | } |
672 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | 672 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { |
673 | if (!m_view ) { | 673 | if (!m_view ) { |
674 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 674 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
675 | } | 675 | } |
676 | return m_view; | 676 | return m_view; |
677 | } | 677 | } |
678 | void OFileViewFileSystem::activate( const QString& str) { | 678 | void OFileViewFileSystem::activate( const QString& str) { |
679 | m_all = (str !=i18n("Files") ); | 679 | m_all = (str !=i18n("Files") ); |
680 | 680 | ||
681 | 681 | ||
682 | } | 682 | } |
683 | 683 | ||
684 | /* Selector */ | 684 | /* Selector */ |
685 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 685 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
686 | const QString& dirName, const QString& fileName, | 686 | const QString& dirName, const QString& fileName, |
687 | const MimeTypes& mimetypes, | 687 | const MimeTypes& mimetypes, |
688 | bool showNew, bool showClose) | 688 | bool showNew, bool showClose) |
689 | : QWidget( parent, "OFileSelector" ) | 689 | : QWidget( parent, "OFileSelector" ) |
690 | { | 690 | { |
691 | m_current = 0; | 691 | m_current = 0; |
692 | m_shNew = showNew; | 692 | m_shNew = showNew; |
693 | m_shClose = showClose; | 693 | m_shClose = showClose; |
694 | m_mimeType = mimetypes; | 694 | m_mimeType = mimetypes; |
695 | m_startDir = dirName; | 695 | m_startDir = dirName; |
696 | m_mode = mode; | 696 | m_mode = mode; |
697 | m_selector = sel; | 697 | m_selector = sel; |
698 | 698 | ||
699 | initUI(); | 699 | initUI(); |
700 | m_lneEdit->setText( fileName ); | 700 | m_lneEdit->setText( fileName ); |
701 | initMime(); | 701 | initMime(); |
702 | initViews(); | 702 | initViews(); |
703 | 703 | ||
704 | QString str; | 704 | QString str; |
705 | switch ( m_selector ) { | 705 | switch ( m_selector ) { |
706 | default: | 706 | default: |
707 | case Normal: | 707 | case Normal: |
708 | str = i18n("Documents"); | 708 | str = i18n("Documents"); |
709 | m_cmbView->setCurrentItem( 0 ); | 709 | m_cmbView->setCurrentItem( 0 ); |
710 | break; | 710 | break; |
711 | case Extended: | 711 | case Extended: |
712 | str = i18n("Files"); | 712 | str = i18n("Files"); |
713 | m_cmbView->setCurrentItem( 1 ); | 713 | m_cmbView->setCurrentItem( 1 ); |
714 | break; | 714 | break; |
715 | case ExtendedAll: | 715 | case ExtendedAll: |
716 | str = i18n("All Files"); | 716 | str = i18n("All Files"); |
717 | m_cmbView->setCurrentItem( 2 ); | 717 | m_cmbView->setCurrentItem( 2 ); |
718 | break; | 718 | break; |
719 | } | 719 | } |
720 | slotViewChange( str ); | 720 | slotViewChange( str ); |
721 | 721 | ||
722 | } | 722 | } |
723 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 723 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
724 | bool showNew, bool showClose ) | 724 | bool showNew, bool showClose ) |
725 | : QWidget( parent, name ) | 725 | : QWidget( parent, name ) |
726 | { | 726 | { |
727 | m_current = 0; | 727 | m_current = 0; |
728 | m_shNew = showNew; | 728 | m_shNew = showNew; |
729 | m_shClose = showClose; | 729 | m_shClose = showClose; |
730 | m_startDir = QPEApplication::documentDir(); | 730 | m_startDir = QPEApplication::documentDir(); |
731 | 731 | ||
732 | if (!mimeFilter.isEmpty() ) | 732 | if (!mimeFilter.isEmpty() ) |
733 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 733 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
734 | 734 | ||
735 | m_mode = OFileSelector::FileSelector; | 735 | m_mode = OFileSelector::FileSelector; |
736 | m_selector = OFileSelector::Normal; | 736 | m_selector = OFileSelector::Normal; |
737 | 737 | ||
738 | initUI(); | 738 | initUI(); |
739 | initMime(); | 739 | initMime(); |
740 | initViews(); | 740 | initViews(); |
741 | m_cmbView->setCurrentItem( 0 ); | 741 | m_cmbView->setCurrentItem( 0 ); |
742 | slotViewChange( i18n("Documents") ); | 742 | slotViewChange( i18n("Documents") ); |
743 | } | 743 | } |
744 | /* | 744 | /* |
745 | * INIT UI will set up the basic GUI | 745 | * INIT UI will set up the basic GUI |
746 | * Layout: Simple VBoxLayout | 746 | * Layout: Simple VBoxLayout |
747 | * On top a WidgetStack containing the Views... | 747 | * On top a WidgetStack containing the Views... |
748 | * - List View | 748 | * - List View |
749 | * - Document View | 749 | * - Document View |
750 | * Below we will have a Label + LineEdit | 750 | * Below we will have a Label + LineEdit |
751 | * Below we will have two ComoBoxes one for choosing the view one for | 751 | * Below we will have two ComoBoxes one for choosing the view one for |
752 | * choosing the mimetype | 752 | * choosing the mimetype |
753 | */ | 753 | */ |
754 | void OFileSelector::initUI() { | 754 | void OFileSelector::initUI() { |
755 | QVBoxLayout* lay = new QVBoxLayout( this ); | 755 | QVBoxLayout* lay = new QVBoxLayout( this ); |
756 | 756 | ||
757 | m_stack = new QWidgetStack( this ); | 757 | m_stack = new QWidgetStack( this ); |
758 | lay->addWidget( m_stack, 1000 ); | 758 | lay->addWidget( m_stack, 1000 ); |
759 | 759 | ||
760 | m_nameBox = new QHBox( this ); | 760 | m_nameBox = new QHBox( this ); |
761 | (void)new QLabel( i18n("Name:"), m_nameBox ); | 761 | (void)new QLabel( i18n("Name:"), m_nameBox ); |
762 | m_lneEdit = new QLineEdit( m_nameBox ); | 762 | m_lneEdit = new QLineEdit( m_nameBox ); |
763 | m_lneEdit ->installEventFilter(this); | 763 | m_lneEdit ->installEventFilter(this); |
764 | lay->addWidget( m_nameBox ); | 764 | lay->addWidget( m_nameBox ); |
765 | 765 | ||
766 | m_cmbBox = new QHBox( this ); | 766 | m_cmbBox = new QHBox( this ); |
767 | m_cmbView = new QComboBox( m_cmbBox ); | 767 | m_cmbView = new QComboBox( m_cmbBox ); |
768 | m_cmbMime = new QComboBox( m_cmbBox ); | 768 | m_cmbMime = new QComboBox( m_cmbBox ); |
769 | lay->addWidget( m_cmbBox ); | 769 | lay->addWidget( m_cmbBox ); |
770 | } | 770 | } |
771 | 771 | ||
772 | /* | 772 | /* |
773 | * This will make sure that the return key in the name edit causes dialogs to close | 773 | * This will make sure that the return key in the name edit causes dialogs to close |
774 | */ | 774 | */ |
775 | 775 | ||
776 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { | 776 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { |
777 | if ( e->type() == QEvent::KeyPress ) { | 777 | if ( e->type() == QEvent::KeyPress ) { |
778 | QKeyEvent *k = (QKeyEvent *)e; | 778 | QKeyEvent *k = (QKeyEvent *)e; |
779 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 779 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
780 | emit ok(); | 780 | emit ok(); |
781 | return true; | 781 | return true; |
782 | } | 782 | } |
783 | } | 783 | } |
784 | return false; | 784 | return false; |
785 | } | 785 | } |
786 | 786 | ||
787 | /* | 787 | /* |
788 | * This will insert the MimeTypes into the Combo Box | 788 | * This will insert the MimeTypes into the Combo Box |
789 | * And also connect the changed signal | 789 | * And also connect the changed signal |
790 | * | 790 | * |
791 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | 791 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes |
792 | */ | 792 | */ |
793 | void OFileSelector::initMime() { | 793 | void OFileSelector::initMime() { |
794 | MimeTypes::Iterator it; | 794 | MimeTypes::Iterator it; |
795 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { | 795 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { |
796 | m_cmbMime->insertItem( it.key() ); | 796 | m_cmbMime->insertItem( it.key() ); |
797 | } | 797 | } |
798 | m_cmbMime->setCurrentItem( 0 ); | 798 | m_cmbMime->setCurrentItem( 0 ); |
799 | 799 | ||
800 | connect( m_cmbMime, SIGNAL(activated(int) ), | 800 | connect( m_cmbMime, SIGNAL(activated(int) ), |
801 | this, SLOT(slotMimeTypeChanged() ) ); | 801 | this, SLOT(slotMimeTypeChanged() ) ); |
802 | 802 | ||
803 | } | 803 | } |
804 | void OFileSelector::initViews() { | 804 | void OFileSelector::initViews() { |
805 | m_cmbView->insertItem( i18n("Documents") ); | 805 | m_cmbView->insertItem( i18n("Documents") ); |
806 | m_cmbView->insertItem( i18n("Files") ); | 806 | m_cmbView->insertItem( i18n("Files") ); |
807 | m_cmbView->insertItem( i18n("All Files") ); | 807 | m_cmbView->insertItem( i18n("All Files") ); |
808 | connect(m_cmbView, SIGNAL(activated( const QString& ) ), | 808 | connect(m_cmbView, SIGNAL(activated( const QString& ) ), |
809 | this, SLOT(slotViewChange( const QString& ) ) ); | 809 | this, SLOT(slotViewChange( const QString& ) ) ); |
810 | 810 | ||
811 | 811 | ||
812 | m_views.insert( i18n("Documents"), new ODocumentFileView(this) ); | 812 | m_views.insert( i18n("Documents"), new ODocumentFileView(this) ); |
813 | 813 | ||
814 | /* see above why add both */ | 814 | /* see above why add both */ |
815 | OFileViewInterface* in = new OFileViewFileSystem( this ); | 815 | OFileViewInterface* in = new OFileViewFileSystem( this ); |
816 | m_views.insert( i18n("Files"), in ); | 816 | m_views.insert( i18n("Files"), in ); |
817 | m_views.insert( i18n("All Files"), in ); | 817 | m_views.insert( i18n("All Files"), in ); |
818 | } | 818 | } |
819 | OFileSelector::~OFileSelector() { | 819 | OFileSelector::~OFileSelector() { |
820 | 820 | ||
821 | } | 821 | } |
822 | 822 | ||
823 | const DocLnk* OFileSelector::selected() { | 823 | const DocLnk* OFileSelector::selected() { |
824 | DocLnk* lnk = ¤tView()->selectedDocument() ; | 824 | DocLnk* lnk = ¤tView()->selectedDocument() ; |
825 | return lnk; | 825 | return lnk; |
826 | } | 826 | } |
827 | 827 | ||
828 | QString OFileSelector::selectedName()const{ | 828 | QString OFileSelector::selectedName()const{ |
829 | return currentView()->selectedName(); | 829 | return currentView()->selectedName(); |
830 | } | 830 | } |
831 | QString OFileSelector::selectedPath()const { | 831 | QString OFileSelector::selectedPath()const { |
832 | return currentView()->selectedPath(); | 832 | return currentView()->selectedPath(); |
833 | } | 833 | } |
834 | QString OFileSelector::directory()const { | 834 | QString OFileSelector::directory()const { |
835 | return currentView()->directory(); | 835 | return currentView()->directory(); |
836 | } | 836 | } |
837 | 837 | ||
838 | DocLnk OFileSelector::selectedDocument()const { | 838 | DocLnk OFileSelector::selectedDocument()const { |
839 | return currentView()->selectedDocument(); | 839 | return currentView()->selectedDocument(); |
840 | } | 840 | } |
841 | 841 | ||
842 | int OFileSelector::fileCount()const { | 842 | int OFileSelector::fileCount()const { |
843 | return currentView()->fileCount(); | 843 | return currentView()->fileCount(); |
844 | } | 844 | } |
845 | void OFileSelector::reread() { | 845 | void OFileSelector::reread() { |
846 | return currentView()->reread(); | 846 | return currentView()->reread(); |
847 | } | 847 | } |
848 | OFileViewInterface* OFileSelector::currentView()const{ | 848 | OFileViewInterface* OFileSelector::currentView()const{ |
849 | return m_current; | 849 | return m_current; |
850 | } | 850 | } |
851 | bool OFileSelector::showNew()const { | 851 | bool OFileSelector::showNew()const { |
852 | return m_shNew; | 852 | return m_shNew; |
853 | } | 853 | } |
854 | bool OFileSelector::showClose()const { | 854 | bool OFileSelector::showClose()const { |
855 | return m_shClose; | 855 | return m_shClose; |
856 | } | 856 | } |
857 | MimeTypes OFileSelector::mimeTypes()const { | 857 | MimeTypes OFileSelector::mimeTypes()const { |
858 | return m_mimeType; | 858 | return m_mimeType; |
859 | } | 859 | } |
860 | int OFileSelector::mode()const{ | 860 | int OFileSelector::mode()const{ |
861 | return m_mode; | 861 | return m_mode; |
862 | } | 862 | } |
863 | int OFileSelector::selector()const{ | 863 | int OFileSelector::selector()const{ |
864 | return m_selector; | 864 | return m_selector; |
865 | } | 865 | } |
866 | QStringList OFileSelector::currentMimeType()const { | 866 | QStringList OFileSelector::currentMimeType()const { |
867 | return m_mimeType[m_cmbMime->currentText()]; | 867 | return m_mimeType[m_cmbMime->currentText()]; |
868 | } | 868 | } |
869 | void OFileSelector::slotMimeTypeChanged() { | 869 | void OFileSelector::slotMimeTypeChanged() { |
870 | reread(); | 870 | reread(); |
871 | } | 871 | } |
872 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { | 872 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { |
873 | m_lneEdit->setText( lnk.name() ); | 873 | m_lneEdit->setText( lnk.name() ); |
874 | emit fileSelected( lnk ); | 874 | emit fileSelected( lnk ); |
875 | emit fileSelected( lnk.name() ); | 875 | emit fileSelected( lnk.name() ); |
876 | } | 876 | } |
877 | void OFileSelector::slotFileBridge( const QString& str) { | 877 | void OFileSelector::slotFileBridge( const QString& str) { |
878 | DocLnk lnk( str ); | 878 | DocLnk lnk( str ); |
879 | emit fileSelected( lnk ); | 879 | emit fileSelected( lnk ); |
880 | } | 880 | } |
881 | void OFileSelector::slotViewChange( const QString& view ) { | 881 | void OFileSelector::slotViewChange( const QString& view ) { |
882 | OFileViewInterface* interface = m_views[view]; | 882 | OFileViewInterface* interface = m_views[view]; |
883 | if (!interface) | 883 | if (!interface) |
884 | return; | 884 | return; |
885 | 885 | ||
886 | interface->activate( view ); | 886 | interface->activate( view ); |
887 | if (m_current) | 887 | if (m_current) |
888 | m_stack->removeWidget( m_current->widget( m_stack ) ); | 888 | m_stack->removeWidget( m_current->widget( m_stack ) ); |
889 | 889 | ||
890 | static int id = 1; | 890 | static int id = 1; |
891 | 891 | ||
892 | m_stack->addWidget( interface->widget(m_stack), id ); | 892 | m_stack->addWidget( interface->widget(m_stack), id ); |
893 | m_stack->raiseWidget( id ); | 893 | m_stack->raiseWidget( id ); |
894 | 894 | ||
895 | interface->reread(); | 895 | interface->reread(); |
896 | m_current = interface; | 896 | m_current = interface; |
897 | 897 | ||
898 | id++; | 898 | id++; |
899 | } | 899 | } |
900 | void OFileSelector::setNewVisible( bool b ) { | 900 | void OFileSelector::setNewVisible( bool b ) { |
901 | m_shNew = b; | 901 | m_shNew = b; |
902 | currentView()->reread(); | 902 | currentView()->reread(); |
903 | } | 903 | } |
904 | void OFileSelector::setCloseVisible( bool b ) { | 904 | void OFileSelector::setCloseVisible( bool b ) { |
905 | m_shClose = b; | 905 | m_shClose = b; |
906 | currentView()->reread(); | 906 | currentView()->reread(); |
907 | } | 907 | } |
908 | void OFileSelector::setNameVisible( bool b ) { | 908 | void OFileSelector::setNameVisible( bool b ) { |
909 | if ( b ) | 909 | if ( b ) |
910 | m_nameBox->show(); | 910 | m_nameBox->show(); |
911 | else | 911 | else |
912 | m_nameBox->hide(); | 912 | m_nameBox->hide(); |
913 | } | 913 | } |