-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 20 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 7 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 5 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 |
5 files changed, 24 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 29c530b..9acbbb1 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1475,769 +1475,768 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd | |||
1475 | for ( int i = 0; i < count; i++) | 1475 | for ( int i = 0; i < count; i++) |
1476 | { | 1476 | { |
1477 | if ( ! bar.isVisible() ) | 1477 | if ( ! bar.isVisible() ) |
1478 | return; | 1478 | return; |
1479 | bar.setProgress( i ); | 1479 | bar.setProgress( i ); |
1480 | qApp->processEvents(); | 1480 | qApp->processEvents(); |
1481 | 1481 | ||
1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1483 | if (!ok) { | 1483 | if (!ok) { |
1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1488 | if (!ok) { | 1488 | if (!ok) { |
1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1490 | } | 1490 | } |
1491 | realName = realNameList[i]; | 1491 | realName = realNameList[i]; |
1492 | email = emailList[i]; | 1492 | email = emailList[i]; |
1493 | assembledName = assembledNameList[i]; | 1493 | assembledName = assembledNameList[i]; |
1494 | uid = uidList[i]; | 1494 | uid = uidList[i]; |
1495 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1495 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1496 | 1496 | ||
1497 | if ( birthday.isValid() ){ | 1497 | if ( birthday.isValid() ){ |
1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1499 | KCal::Attendee::ReqParticipant,uid) ; | 1499 | KCal::Attendee::ReqParticipant,uid) ; |
1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1501 | ++addCount; | 1501 | ++addCount; |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | if ( anniversary.isValid() ){ | 1504 | if ( anniversary.isValid() ){ |
1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1506 | KCal::Attendee::ReqParticipant,uid) ; | 1506 | KCal::Attendee::ReqParticipant,uid) ; |
1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1508 | ++addCount; | 1508 | ++addCount; |
1509 | } | 1509 | } |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | updateView(); | 1512 | updateView(); |
1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1514 | 1514 | ||
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | 1520 | ||
1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1522 | { | 1522 | { |
1523 | //qDebug("addAnni "); | 1523 | //qDebug("addAnni "); |
1524 | Event * ev = new Event(); | 1524 | Event * ev = new Event(); |
1525 | ev->setOrganizer(KOPrefs::instance()->email()); | 1525 | ev->setOrganizer(KOPrefs::instance()->email()); |
1526 | if ( a ) { | 1526 | if ( a ) { |
1527 | ev->addAttendee( a ); | 1527 | ev->addAttendee( a ); |
1528 | } | 1528 | } |
1529 | QString kind; | 1529 | QString kind; |
1530 | if ( birthday ) { | 1530 | if ( birthday ) { |
1531 | kind = i18n( "Birthday" ); | 1531 | kind = i18n( "Birthday" ); |
1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1533 | } | 1533 | } |
1534 | else { | 1534 | else { |
1535 | kind = i18n( "Anniversary" ); | 1535 | kind = i18n( "Anniversary" ); |
1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1537 | } | 1537 | } |
1538 | ev->setCategories( kind ); | 1538 | ev->setCategories( kind ); |
1539 | ev->setDtStart( QDateTime(date) ); | 1539 | ev->setDtStart( QDateTime(date) ); |
1540 | ev->setDtEnd( QDateTime(date) ); | 1540 | ev->setDtEnd( QDateTime(date) ); |
1541 | ev->setFloats( true ); | 1541 | ev->setFloats( true ); |
1542 | Recurrence * rec = ev->recurrence(); | 1542 | Recurrence * rec = ev->recurrence(); |
1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1544 | rec->addYearlyNum( date.month() ); | 1544 | rec->addYearlyNum( date.month() ); |
1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1546 | delete ev; | 1546 | delete ev; |
1547 | return false; | 1547 | return false; |
1548 | } | 1548 | } |
1549 | return true; | 1549 | return true; |
1550 | 1550 | ||
1551 | } | 1551 | } |
1552 | bool CalendarView::importQtopia( const QString &categories, | 1552 | bool CalendarView::importQtopia( const QString &categories, |
1553 | const QString &datebook, | 1553 | const QString &datebook, |
1554 | const QString &todolist ) | 1554 | const QString &todolist ) |
1555 | { | 1555 | { |
1556 | 1556 | ||
1557 | QtopiaFormat qtopiaFormat; | 1557 | QtopiaFormat qtopiaFormat; |
1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1562 | 1562 | ||
1563 | updateView(); | 1563 | updateView(); |
1564 | return true; | 1564 | return true; |
1565 | 1565 | ||
1566 | #if 0 | 1566 | #if 0 |
1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1568 | mCurrentSyncDevice = "qtopia-XML"; | 1568 | mCurrentSyncDevice = "qtopia-XML"; |
1569 | if ( mSyncManager->mAskForPreferences ) | 1569 | if ( mSyncManager->mAskForPreferences ) |
1570 | edit_sync_options(); | 1570 | edit_sync_options(); |
1571 | qApp->processEvents(); | 1571 | qApp->processEvents(); |
1572 | CalendarLocal* calendar = new CalendarLocal(); | 1572 | CalendarLocal* calendar = new CalendarLocal(); |
1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1574 | bool syncOK = false; | 1574 | bool syncOK = false; |
1575 | QtopiaFormat qtopiaFormat; | 1575 | QtopiaFormat qtopiaFormat; |
1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1577 | bool loadOk = true; | 1577 | bool loadOk = true; |
1578 | if ( !categories.isEmpty() ) | 1578 | if ( !categories.isEmpty() ) |
1579 | loadOk = qtopiaFormat.load( calendar, categories ); | 1579 | loadOk = qtopiaFormat.load( calendar, categories ); |
1580 | if ( loadOk && !datebook.isEmpty() ) | 1580 | if ( loadOk && !datebook.isEmpty() ) |
1581 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1581 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1582 | if ( loadOk && !todolist.isEmpty() ) | 1582 | if ( loadOk && !todolist.isEmpty() ) |
1583 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1583 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1584 | 1584 | ||
1585 | if ( loadOk ) { | 1585 | if ( loadOk ) { |
1586 | getEventViewerDialog()->setSyncMode( true ); | 1586 | getEventViewerDialog()->setSyncMode( true ); |
1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1588 | getEventViewerDialog()->setSyncMode( false ); | 1588 | getEventViewerDialog()->setSyncMode( false ); |
1589 | qApp->processEvents(); | 1589 | qApp->processEvents(); |
1590 | if ( syncOK ) { | 1590 | if ( syncOK ) { |
1591 | if ( mSyncManager->mWriteBackFile ) | 1591 | if ( mSyncManager->mWriteBackFile ) |
1592 | { | 1592 | { |
1593 | // write back XML file | 1593 | // write back XML file |
1594 | 1594 | ||
1595 | } | 1595 | } |
1596 | setModified( true ); | 1596 | setModified( true ); |
1597 | } | 1597 | } |
1598 | } else { | 1598 | } else { |
1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1601 | question, i18n("Ok")) ; | 1601 | question, i18n("Ok")) ; |
1602 | } | 1602 | } |
1603 | delete calendar; | 1603 | delete calendar; |
1604 | updateView(); | 1604 | updateView(); |
1605 | return syncOK; | 1605 | return syncOK; |
1606 | 1606 | ||
1607 | 1607 | ||
1608 | #endif | 1608 | #endif |
1609 | 1609 | ||
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | void CalendarView::setSyncEventsReadOnly() | 1612 | void CalendarView::setSyncEventsReadOnly() |
1613 | { | 1613 | { |
1614 | Event * ev; | 1614 | Event * ev; |
1615 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1615 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1616 | ev = eL.first(); | 1616 | ev = eL.first(); |
1617 | while ( ev ) { | 1617 | while ( ev ) { |
1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1619 | ev->setReadOnly( true ); | 1619 | ev->setReadOnly( true ); |
1620 | ev = eL.next(); | 1620 | ev = eL.next(); |
1621 | } | 1621 | } |
1622 | } | 1622 | } |
1623 | bool CalendarView::openCalendar(QString filename, bool merge) | 1623 | bool CalendarView::openCalendar(QString filename, bool merge) |
1624 | { | 1624 | { |
1625 | 1625 | ||
1626 | if (filename.isEmpty()) { | 1626 | if (filename.isEmpty()) { |
1627 | return false; | 1627 | return false; |
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | if (!QFile::exists(filename)) { | 1630 | if (!QFile::exists(filename)) { |
1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1632 | return false; | 1632 | return false; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | globalFlagBlockAgenda = 1; | 1635 | globalFlagBlockAgenda = 1; |
1636 | if (!merge) mCalendar->close(); | 1636 | if (!merge) mCalendar->close(); |
1637 | 1637 | ||
1638 | mStorage->setFileName( filename ); | 1638 | mStorage->setFileName( filename ); |
1639 | 1639 | ||
1640 | if ( mStorage->load() ) { | 1640 | if ( mStorage->load() ) { |
1641 | if ( merge ) ;//setModified( true ); | 1641 | if ( merge ) ;//setModified( true ); |
1642 | else { | 1642 | else { |
1643 | //setModified( true ); | 1643 | //setModified( true ); |
1644 | mViewManager->setDocumentId( filename ); | 1644 | mViewManager->setDocumentId( filename ); |
1645 | mDialogManager->setDocumentId( filename ); | 1645 | mDialogManager->setDocumentId( filename ); |
1646 | mTodoList->setDocumentId( filename ); | 1646 | mTodoList->setDocumentId( filename ); |
1647 | } | 1647 | } |
1648 | globalFlagBlockAgenda = 2; | 1648 | globalFlagBlockAgenda = 2; |
1649 | // if ( getLastSyncEvent() ) | 1649 | // if ( getLastSyncEvent() ) |
1650 | // getLastSyncEvent()->setReadOnly( true ); | 1650 | // getLastSyncEvent()->setReadOnly( true ); |
1651 | mCalendar->reInitAlarmSettings(); | 1651 | mCalendar->reInitAlarmSettings(); |
1652 | setSyncEventsReadOnly(); | 1652 | setSyncEventsReadOnly(); |
1653 | updateUnmanagedViews(); | 1653 | updateUnmanagedViews(); |
1654 | updateView(); | 1654 | updateView(); |
1655 | if ( filename != MainWindow::defaultFileName() ) { | 1655 | if ( filename != MainWindow::defaultFileName() ) { |
1656 | saveCalendar( MainWindow::defaultFileName() ); | 1656 | saveCalendar( MainWindow::defaultFileName() ); |
1657 | } else { | 1657 | } else { |
1658 | QFileInfo finf ( MainWindow::defaultFileName()); | 1658 | QFileInfo finf ( MainWindow::defaultFileName()); |
1659 | if ( finf.exists() ) { | 1659 | if ( finf.exists() ) { |
1660 | setLoadedFileVersion( finf.lastModified () ); | 1660 | setLoadedFileVersion( finf.lastModified () ); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | return true; | 1663 | return true; |
1664 | } else { | 1664 | } else { |
1665 | // while failing to load, the calendar object could | 1665 | // while failing to load, the calendar object could |
1666 | // have become partially populated. Clear it out. | 1666 | // have become partially populated. Clear it out. |
1667 | if ( !merge ) { | 1667 | if ( !merge ) { |
1668 | mCalendar->close(); | 1668 | mCalendar->close(); |
1669 | mViewManager->setDocumentId( filename ); | 1669 | mViewManager->setDocumentId( filename ); |
1670 | mDialogManager->setDocumentId( filename ); | 1670 | mDialogManager->setDocumentId( filename ); |
1671 | mTodoList->setDocumentId( filename ); | 1671 | mTodoList->setDocumentId( filename ); |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1675 | 1675 | ||
1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1677 | globalFlagBlockAgenda = 2; | 1677 | globalFlagBlockAgenda = 2; |
1678 | mCalendar->reInitAlarmSettings(); | 1678 | mCalendar->reInitAlarmSettings(); |
1679 | setSyncEventsReadOnly(); | 1679 | setSyncEventsReadOnly(); |
1680 | updateUnmanagedViews(); | 1680 | updateUnmanagedViews(); |
1681 | updateView(); | 1681 | updateView(); |
1682 | } | 1682 | } |
1683 | return false; | 1683 | return false; |
1684 | } | 1684 | } |
1685 | void CalendarView::showOpenError() | 1685 | void CalendarView::showOpenError() |
1686 | { | 1686 | { |
1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1688 | } | 1688 | } |
1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1690 | { | 1690 | { |
1691 | loadedFileVersion = dt; | 1691 | loadedFileVersion = dt; |
1692 | } | 1692 | } |
1693 | bool CalendarView::checkFileChanged(QString fn) | 1693 | bool CalendarView::checkFileChanged(QString fn) |
1694 | { | 1694 | { |
1695 | QFileInfo finf ( fn ); | 1695 | QFileInfo finf ( fn ); |
1696 | if ( !finf.exists() ) | 1696 | if ( !finf.exists() ) |
1697 | return true; | 1697 | return true; |
1698 | QDateTime dt = finf.lastModified (); | 1698 | QDateTime dt = finf.lastModified (); |
1699 | if ( dt <= loadedFileVersion ) | 1699 | if ( dt <= loadedFileVersion ) |
1700 | return false; | 1700 | return false; |
1701 | return true; | 1701 | return true; |
1702 | 1702 | ||
1703 | } | 1703 | } |
1704 | void CalendarView::watchSavedFile() | 1704 | void CalendarView::watchSavedFile() |
1705 | { | 1705 | { |
1706 | QFileInfo finf ( MainWindow::defaultFileName()); | 1706 | QFileInfo finf ( MainWindow::defaultFileName()); |
1707 | if ( !finf.exists() ) | 1707 | if ( !finf.exists() ) |
1708 | return; | 1708 | return; |
1709 | QDateTime dt = finf.lastModified (); | 1709 | QDateTime dt = finf.lastModified (); |
1710 | if ( dt < loadedFileVersion ) { | 1710 | if ( dt < loadedFileVersion ) { |
1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1713 | return; | 1713 | return; |
1714 | } | 1714 | } |
1715 | loadedFileVersion = dt; | 1715 | loadedFileVersion = dt; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | bool CalendarView::checkFileVersion(QString fn) | 1718 | bool CalendarView::checkFileVersion(QString fn) |
1719 | { | 1719 | { |
1720 | QFileInfo finf ( fn ); | 1720 | QFileInfo finf ( fn ); |
1721 | if ( !finf.exists() ) | 1721 | if ( !finf.exists() ) |
1722 | return true; | 1722 | return true; |
1723 | QDateTime dt = finf.lastModified (); | 1723 | QDateTime dt = finf.lastModified (); |
1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1725 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1725 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1726 | if ( dt <= loadedFileVersion ) | 1726 | if ( dt <= loadedFileVersion ) |
1727 | return true; | 1727 | return true; |
1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1730 | i18n("Sync+save")); | 1730 | i18n("Sync+save")); |
1731 | 1731 | ||
1732 | if ( km == KMessageBox::Cancel ) | 1732 | if ( km == KMessageBox::Cancel ) |
1733 | return false; | 1733 | return false; |
1734 | if ( km == KMessageBox::Yes ) | 1734 | if ( km == KMessageBox::Yes ) |
1735 | return true; | 1735 | return true; |
1736 | 1736 | ||
1737 | setSyncDevice("deleteaftersync" ); | 1737 | setSyncDevice("deleteaftersync" ); |
1738 | mSyncManager->mAskForPreferences = true; | 1738 | mSyncManager->mAskForPreferences = true; |
1739 | mSyncManager->mSyncAlgoPrefs = 3; | 1739 | mSyncManager->mSyncAlgoPrefs = 3; |
1740 | mSyncManager->mWriteBackFile = false; | 1740 | mSyncManager->mWriteBackFile = false; |
1741 | mSyncManager->mWriteBackExistingOnly = false; | 1741 | mSyncManager->mWriteBackExistingOnly = false; |
1742 | mSyncManager->mShowSyncSummary = false; | 1742 | mSyncManager->mShowSyncSummary = false; |
1743 | syncCalendar( fn, 3 ); | 1743 | syncCalendar( fn, 3 ); |
1744 | Event * e = getLastSyncEvent(); | 1744 | Event * e = getLastSyncEvent(); |
1745 | mCalendar->deleteEvent ( e ); | 1745 | mCalendar->deleteEvent ( e ); |
1746 | updateView(); | 1746 | updateView(); |
1747 | return true; | 1747 | return true; |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | bool CalendarView::saveCalendar( QString filename ) | 1750 | bool CalendarView::saveCalendar( QString filename ) |
1751 | { | 1751 | { |
1752 | 1752 | ||
1753 | // Store back all unsaved data into calendar object | 1753 | // Store back all unsaved data into calendar object |
1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1755 | if ( mViewManager->currentView() ) | 1755 | if ( mViewManager->currentView() ) |
1756 | mViewManager->currentView()->flushView(); | 1756 | mViewManager->currentView()->flushView(); |
1757 | 1757 | ||
1758 | 1758 | ||
1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1760 | mStorage->setSaveFormat( new ICalFormat() ); | 1760 | mStorage->setSaveFormat( new ICalFormat() ); |
1761 | mStorage->setFileName( filename ); | 1761 | mStorage->setFileName( filename ); |
1762 | bool success; | 1762 | bool success; |
1763 | success = mStorage->save(); | 1763 | success = mStorage->save(); |
1764 | if ( !success ) { | 1764 | if ( !success ) { |
1765 | return false; | 1765 | return false; |
1766 | } | 1766 | } |
1767 | if ( filename == MainWindow::defaultFileName() ) { | 1767 | if ( filename == MainWindow::defaultFileName() ) { |
1768 | setLoadedFileVersion( lfv ); | 1768 | setLoadedFileVersion( lfv ); |
1769 | watchSavedFile(); | 1769 | watchSavedFile(); |
1770 | } | 1770 | } |
1771 | return true; | 1771 | return true; |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | void CalendarView::closeCalendar() | 1774 | void CalendarView::closeCalendar() |
1775 | { | 1775 | { |
1776 | 1776 | ||
1777 | // child windows no longer valid | 1777 | // child windows no longer valid |
1778 | emit closingDown(); | 1778 | emit closingDown(); |
1779 | 1779 | ||
1780 | mCalendar->close(); | 1780 | mCalendar->close(); |
1781 | setModified(false); | 1781 | setModified(false); |
1782 | updateView(); | 1782 | updateView(); |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | void CalendarView::archiveCalendar() | 1785 | void CalendarView::archiveCalendar() |
1786 | { | 1786 | { |
1787 | mDialogManager->showArchiveDialog(); | 1787 | mDialogManager->showArchiveDialog(); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | 1790 | ||
1791 | void CalendarView::readSettings() | 1791 | void CalendarView::readSettings() |
1792 | { | 1792 | { |
1793 | 1793 | ||
1794 | 1794 | ||
1795 | // mViewManager->showAgendaView(); | 1795 | // mViewManager->showAgendaView(); |
1796 | QString str; | 1796 | QString str; |
1797 | //qDebug("CalendarView::readSettings() "); | 1797 | //qDebug("CalendarView::readSettings() "); |
1798 | // read settings from the KConfig, supplying reasonable | 1798 | // read settings from the KConfig, supplying reasonable |
1799 | // defaults where none are to be found | 1799 | // defaults where none are to be found |
1800 | KConfig *config = KOGlobals::config(); | 1800 | KConfig *config = KOGlobals::config(); |
1801 | #ifndef KORG_NOSPLITTER | 1801 | #ifndef KORG_NOSPLITTER |
1802 | config->setGroup("KOrganizer Geometry"); | 1802 | config->setGroup("KOrganizer Geometry"); |
1803 | 1803 | ||
1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1805 | if (sizes.count() != 2) { | 1805 | if (sizes.count() != 2) { |
1806 | sizes << mDateNavigator->minimumSizeHint().width(); | 1806 | sizes << mDateNavigator->minimumSizeHint().width(); |
1807 | sizes << 300; | 1807 | sizes << 300; |
1808 | } | 1808 | } |
1809 | mPanner->setSizes(sizes); | 1809 | mPanner->setSizes(sizes); |
1810 | 1810 | ||
1811 | sizes = config->readIntListEntry("Separator2"); | 1811 | sizes = config->readIntListEntry("Separator2"); |
1812 | if ( ( mResourceView && sizes.count() == 4 ) || | 1812 | if ( ( mResourceView && sizes.count() == 4 ) || |
1813 | ( !mResourceView && sizes.count() == 3 ) ) { | 1813 | ( !mResourceView && sizes.count() == 3 ) ) { |
1814 | mLeftSplitter->setSizes(sizes); | 1814 | mLeftSplitter->setSizes(sizes); |
1815 | } | 1815 | } |
1816 | #endif | 1816 | #endif |
1817 | globalFlagBlockAgenda = 1; | 1817 | globalFlagBlockAgenda = 1; |
1818 | mViewManager->showAgendaView(); | 1818 | mViewManager->showAgendaView(); |
1819 | //mViewManager->readSettings( config ); | 1819 | //mViewManager->readSettings( config ); |
1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1821 | readFilterSettings(config); | 1821 | readFilterSettings(config); |
1822 | config->setGroup( "Views" ); | 1822 | config->setGroup( "Views" ); |
1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1824 | 1824 | ||
1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1826 | 1826 | ||
1827 | int resetval = 0; | 1827 | int resetval = 0; |
1828 | int maxVal = 0; | 1828 | int maxVal = 0; |
1829 | if (sizes.count() != 3) { | 1829 | if (sizes.count() != 3) { |
1830 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1830 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1831 | resetval = mDateNavigator->sizeHint().width()+2; | 1831 | resetval = mDateNavigator->sizeHint().width()+2; |
1832 | } else { | 1832 | } else { |
1833 | resetval = mDateNavigator->sizeHint().height()+2; | 1833 | resetval = mDateNavigator->sizeHint().height()+2; |
1834 | } | 1834 | } |
1835 | } | 1835 | } |
1836 | if ( !resetval ){// i.e. sizes.count() == 3 | 1836 | if ( !resetval ){// i.e. sizes.count() == 3 |
1837 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1837 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | 1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) |
1839 | resetval = mDateNavigator->sizeHint().width()+2; | 1839 | resetval = mDateNavigator->sizeHint().width()+2; |
1840 | } else { | 1840 | } else { |
1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | 1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) |
1842 | resetval = mDateNavigator->sizeHint().height()+2; | 1842 | resetval = mDateNavigator->sizeHint().height()+2; |
1843 | } | 1843 | } |
1844 | } | 1844 | } |
1845 | if ( resetval ) { | 1845 | if ( resetval ) { |
1846 | sizes.clear(); | 1846 | sizes.clear(); |
1847 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1847 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1848 | maxVal = QApplication::desktop()->width() -10; | 1848 | maxVal = QApplication::desktop()->width() -10; |
1849 | } else { | 1849 | } else { |
1850 | maxVal = QApplication::desktop()->height()-10; | 1850 | maxVal = QApplication::desktop()->height()-10; |
1851 | } | 1851 | } |
1852 | sizes << resetval; | 1852 | sizes << resetval; |
1853 | if ( maxVal < resetval + resetval) | 1853 | if ( maxVal < resetval + resetval) |
1854 | resetval = maxVal - resetval; | 1854 | resetval = maxVal - resetval; |
1855 | sizes << resetval; | 1855 | sizes << resetval; |
1856 | sizes << 100; | 1856 | sizes << 100; |
1857 | } | 1857 | } |
1858 | mLeftFrame->setSizes(sizes); | 1858 | mLeftFrame->setSizes(sizes); |
1859 | qDebug("sizes count %d ", sizes.count()); | ||
1860 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1861 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1862 | else mNavigator->selectDates( dateCount ); | 1861 | else mNavigator->selectDates( dateCount ); |
1863 | // mViewManager->readSettings( config ); | 1862 | // mViewManager->readSettings( config ); |
1864 | updateConfig(); | 1863 | updateConfig(); |
1865 | globalFlagBlockAgenda = 2; | 1864 | globalFlagBlockAgenda = 2; |
1866 | mViewManager->readSettings( config ); | 1865 | mViewManager->readSettings( config ); |
1867 | #ifdef DESKTOP_VERSION | 1866 | #ifdef DESKTOP_VERSION |
1868 | config->setGroup("WidgetLayout"); | 1867 | config->setGroup("WidgetLayout"); |
1869 | QStringList list; | 1868 | QStringList list; |
1870 | list = config->readListEntry("MainLayout"); | 1869 | list = config->readListEntry("MainLayout"); |
1871 | int x,y,w,h; | 1870 | int x,y,w,h; |
1872 | if ( ! list.isEmpty() ) { | 1871 | if ( ! list.isEmpty() ) { |
1873 | x = list[0].toInt(); | 1872 | x = list[0].toInt(); |
1874 | y = list[1].toInt(); | 1873 | y = list[1].toInt(); |
1875 | w = list[2].toInt(); | 1874 | w = list[2].toInt(); |
1876 | h = list[3].toInt(); | 1875 | h = list[3].toInt(); |
1877 | topLevelWidget()->setGeometry(x,y,w,h); | 1876 | topLevelWidget()->setGeometry(x,y,w,h); |
1878 | 1877 | ||
1879 | } else { | 1878 | } else { |
1880 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1881 | } | 1880 | } |
1882 | list = config->readListEntry("EditEventLayout"); | 1881 | list = config->readListEntry("EditEventLayout"); |
1883 | if ( ! list.isEmpty() ) { | 1882 | if ( ! list.isEmpty() ) { |
1884 | x = list[0].toInt(); | 1883 | x = list[0].toInt(); |
1885 | y = list[1].toInt(); | 1884 | y = list[1].toInt(); |
1886 | w = list[2].toInt(); | 1885 | w = list[2].toInt(); |
1887 | h = list[3].toInt(); | 1886 | h = list[3].toInt(); |
1888 | mEventEditor->setGeometry(x,y,w,h); | 1887 | mEventEditor->setGeometry(x,y,w,h); |
1889 | 1888 | ||
1890 | } | 1889 | } |
1891 | list = config->readListEntry("EditTodoLayout"); | 1890 | list = config->readListEntry("EditTodoLayout"); |
1892 | if ( ! list.isEmpty() ) { | 1891 | if ( ! list.isEmpty() ) { |
1893 | x = list[0].toInt(); | 1892 | x = list[0].toInt(); |
1894 | y = list[1].toInt(); | 1893 | y = list[1].toInt(); |
1895 | w = list[2].toInt(); | 1894 | w = list[2].toInt(); |
1896 | h = list[3].toInt(); | 1895 | h = list[3].toInt(); |
1897 | mTodoEditor->setGeometry(x,y,w,h); | 1896 | mTodoEditor->setGeometry(x,y,w,h); |
1898 | 1897 | ||
1899 | } | 1898 | } |
1900 | list = config->readListEntry("ViewerLayout"); | 1899 | list = config->readListEntry("ViewerLayout"); |
1901 | if ( ! list.isEmpty() ) { | 1900 | if ( ! list.isEmpty() ) { |
1902 | x = list[0].toInt(); | 1901 | x = list[0].toInt(); |
1903 | y = list[1].toInt(); | 1902 | y = list[1].toInt(); |
1904 | w = list[2].toInt(); | 1903 | w = list[2].toInt(); |
1905 | h = list[3].toInt(); | 1904 | h = list[3].toInt(); |
1906 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1905 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1907 | } | 1906 | } |
1908 | #endif | 1907 | #endif |
1909 | 1908 | ||
1910 | } | 1909 | } |
1911 | 1910 | ||
1912 | 1911 | ||
1913 | void CalendarView::writeSettings() | 1912 | void CalendarView::writeSettings() |
1914 | { | 1913 | { |
1915 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1914 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1916 | 1915 | ||
1917 | KConfig *config = KOGlobals::config(); | 1916 | KConfig *config = KOGlobals::config(); |
1918 | 1917 | ||
1919 | #ifndef KORG_NOSPLITTER | 1918 | #ifndef KORG_NOSPLITTER |
1920 | config->setGroup("KOrganizer Geometry"); | 1919 | config->setGroup("KOrganizer Geometry"); |
1921 | 1920 | ||
1922 | QValueList<int> list = mPanner->sizes(); | 1921 | QValueList<int> list = mPanner->sizes(); |
1923 | config->writeEntry("Separator1",list); | 1922 | config->writeEntry("Separator1",list); |
1924 | 1923 | ||
1925 | list = mLeftSplitter->sizes(); | 1924 | list = mLeftSplitter->sizes(); |
1926 | config->writeEntry("Separator2",list); | 1925 | config->writeEntry("Separator2",list); |
1927 | #endif | 1926 | #endif |
1928 | 1927 | ||
1929 | mViewManager->writeSettings( config ); | 1928 | mViewManager->writeSettings( config ); |
1930 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1929 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1931 | mDialogManager->writeSettings( config ); | 1930 | mDialogManager->writeSettings( config ); |
1932 | //KOPrefs::instance()->usrWriteConfig(); | 1931 | //KOPrefs::instance()->usrWriteConfig(); |
1933 | KOPrefs::instance()->writeConfig(); | 1932 | KOPrefs::instance()->writeConfig(); |
1934 | 1933 | ||
1935 | writeFilterSettings(config); | 1934 | writeFilterSettings(config); |
1936 | 1935 | ||
1937 | config->setGroup( "Views" ); | 1936 | config->setGroup( "Views" ); |
1938 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1937 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1939 | 1938 | ||
1940 | QValueList<int> list = mLeftFrame->sizes(); | 1939 | QValueList<int> list = mLeftFrame->sizes(); |
1941 | config->writeEntry("Left Splitter Frame",list); | 1940 | config->writeEntry("Left Splitter Frame",list); |
1942 | 1941 | ||
1943 | #ifdef DESKTOP_VERSION | 1942 | #ifdef DESKTOP_VERSION |
1944 | config->setGroup("WidgetLayout"); | 1943 | config->setGroup("WidgetLayout"); |
1945 | QStringList list ;//= config->readListEntry("MainLayout"); | 1944 | QStringList list ;//= config->readListEntry("MainLayout"); |
1946 | int x,y,w,h; | 1945 | int x,y,w,h; |
1947 | QWidget* wid; | 1946 | QWidget* wid; |
1948 | wid = topLevelWidget(); | 1947 | wid = topLevelWidget(); |
1949 | x = wid->geometry().x(); | 1948 | x = wid->geometry().x(); |
1950 | y = wid->geometry().y(); | 1949 | y = wid->geometry().y(); |
1951 | w = wid->width(); | 1950 | w = wid->width(); |
1952 | h = wid->height(); | 1951 | h = wid->height(); |
1953 | list.clear(); | 1952 | list.clear(); |
1954 | list << QString::number( x ); | 1953 | list << QString::number( x ); |
1955 | list << QString::number( y ); | 1954 | list << QString::number( y ); |
1956 | list << QString::number( w ); | 1955 | list << QString::number( w ); |
1957 | list << QString::number( h ); | 1956 | list << QString::number( h ); |
1958 | config->writeEntry("MainLayout",list ); | 1957 | config->writeEntry("MainLayout",list ); |
1959 | 1958 | ||
1960 | wid = mEventEditor; | 1959 | wid = mEventEditor; |
1961 | x = wid->geometry().x(); | 1960 | x = wid->geometry().x(); |
1962 | y = wid->geometry().y(); | 1961 | y = wid->geometry().y(); |
1963 | w = wid->width(); | 1962 | w = wid->width(); |
1964 | h = wid->height(); | 1963 | h = wid->height(); |
1965 | list.clear(); | 1964 | list.clear(); |
1966 | list << QString::number( x ); | 1965 | list << QString::number( x ); |
1967 | list << QString::number( y ); | 1966 | list << QString::number( y ); |
1968 | list << QString::number( w ); | 1967 | list << QString::number( w ); |
1969 | list << QString::number( h ); | 1968 | list << QString::number( h ); |
1970 | config->writeEntry("EditEventLayout",list ); | 1969 | config->writeEntry("EditEventLayout",list ); |
1971 | 1970 | ||
1972 | wid = mTodoEditor; | 1971 | wid = mTodoEditor; |
1973 | x = wid->geometry().x(); | 1972 | x = wid->geometry().x(); |
1974 | y = wid->geometry().y(); | 1973 | y = wid->geometry().y(); |
1975 | w = wid->width(); | 1974 | w = wid->width(); |
1976 | h = wid->height(); | 1975 | h = wid->height(); |
1977 | list.clear(); | 1976 | list.clear(); |
1978 | list << QString::number( x ); | 1977 | list << QString::number( x ); |
1979 | list << QString::number( y ); | 1978 | list << QString::number( y ); |
1980 | list << QString::number( w ); | 1979 | list << QString::number( w ); |
1981 | list << QString::number( h ); | 1980 | list << QString::number( h ); |
1982 | config->writeEntry("EditTodoLayout",list ); | 1981 | config->writeEntry("EditTodoLayout",list ); |
1983 | wid = getEventViewerDialog(); | 1982 | wid = getEventViewerDialog(); |
1984 | x = wid->geometry().x(); | 1983 | x = wid->geometry().x(); |
1985 | y = wid->geometry().y(); | 1984 | y = wid->geometry().y(); |
1986 | w = wid->width(); | 1985 | w = wid->width(); |
1987 | h = wid->height(); | 1986 | h = wid->height(); |
1988 | list.clear(); | 1987 | list.clear(); |
1989 | list << QString::number( x ); | 1988 | list << QString::number( x ); |
1990 | list << QString::number( y ); | 1989 | list << QString::number( y ); |
1991 | list << QString::number( w ); | 1990 | list << QString::number( w ); |
1992 | list << QString::number( h ); | 1991 | list << QString::number( h ); |
1993 | config->writeEntry("ViewerLayout",list ); | 1992 | config->writeEntry("ViewerLayout",list ); |
1994 | wid = mDialogManager->getSearchDialog(); | 1993 | wid = mDialogManager->getSearchDialog(); |
1995 | if ( wid ) { | 1994 | if ( wid ) { |
1996 | x = wid->geometry().x(); | 1995 | x = wid->geometry().x(); |
1997 | y = wid->geometry().y(); | 1996 | y = wid->geometry().y(); |
1998 | w = wid->width(); | 1997 | w = wid->width(); |
1999 | h = wid->height(); | 1998 | h = wid->height(); |
2000 | list.clear(); | 1999 | list.clear(); |
2001 | list << QString::number( x ); | 2000 | list << QString::number( x ); |
2002 | list << QString::number( y ); | 2001 | list << QString::number( y ); |
2003 | list << QString::number( w ); | 2002 | list << QString::number( w ); |
2004 | list << QString::number( h ); | 2003 | list << QString::number( h ); |
2005 | config->writeEntry("SearchLayout",list ); | 2004 | config->writeEntry("SearchLayout",list ); |
2006 | } | 2005 | } |
2007 | #endif | 2006 | #endif |
2008 | 2007 | ||
2009 | 2008 | ||
2010 | config->sync(); | 2009 | config->sync(); |
2011 | } | 2010 | } |
2012 | 2011 | ||
2013 | void CalendarView::readFilterSettings(KConfig *config) | 2012 | void CalendarView::readFilterSettings(KConfig *config) |
2014 | { | 2013 | { |
2015 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2014 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2016 | 2015 | ||
2017 | mFilters.clear(); | 2016 | mFilters.clear(); |
2018 | 2017 | ||
2019 | config->setGroup("General"); | 2018 | config->setGroup("General"); |
2020 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2019 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2021 | 2020 | ||
2022 | QStringList::ConstIterator it = filterList.begin(); | 2021 | QStringList::ConstIterator it = filterList.begin(); |
2023 | QStringList::ConstIterator end = filterList.end(); | 2022 | QStringList::ConstIterator end = filterList.end(); |
2024 | while(it != end) { | 2023 | while(it != end) { |
2025 | // kdDebug() << " filter: " << (*it) << endl; | 2024 | // kdDebug() << " filter: " << (*it) << endl; |
2026 | 2025 | ||
2027 | CalFilter *filter; | 2026 | CalFilter *filter; |
2028 | filter = new CalFilter(*it); | 2027 | filter = new CalFilter(*it); |
2029 | config->setGroup("Filter_" + (*it)); | 2028 | config->setGroup("Filter_" + (*it)); |
2030 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2029 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2031 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2030 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2032 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2031 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2033 | mFilters.append(filter); | 2032 | mFilters.append(filter); |
2034 | 2033 | ||
2035 | ++it; | 2034 | ++it; |
2036 | } | 2035 | } |
2037 | 2036 | ||
2038 | if (mFilters.count() == 0) { | 2037 | if (mFilters.count() == 0) { |
2039 | CalFilter *filter = new CalFilter(i18n("Default")); | 2038 | CalFilter *filter = new CalFilter(i18n("Default")); |
2040 | mFilters.append(filter); | 2039 | mFilters.append(filter); |
2041 | } | 2040 | } |
2042 | mFilterView->updateFilters(); | 2041 | mFilterView->updateFilters(); |
2043 | config->setGroup("FilterView"); | 2042 | config->setGroup("FilterView"); |
2044 | 2043 | ||
2045 | mFilterView->blockSignals(true); | 2044 | mFilterView->blockSignals(true); |
2046 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2045 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2047 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2046 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2048 | mFilterView->blockSignals(false); | 2047 | mFilterView->blockSignals(false); |
2049 | // We do it manually to avoid it being done twice by the above calls | 2048 | // We do it manually to avoid it being done twice by the above calls |
2050 | updateFilter(); | 2049 | updateFilter(); |
2051 | } | 2050 | } |
2052 | 2051 | ||
2053 | void CalendarView::writeFilterSettings(KConfig *config) | 2052 | void CalendarView::writeFilterSettings(KConfig *config) |
2054 | { | 2053 | { |
2055 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2054 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2056 | 2055 | ||
2057 | QStringList filterList; | 2056 | QStringList filterList; |
2058 | 2057 | ||
2059 | CalFilter *filter = mFilters.first(); | 2058 | CalFilter *filter = mFilters.first(); |
2060 | while(filter) { | 2059 | while(filter) { |
2061 | // kdDebug() << " fn: " << filter->name() << endl; | 2060 | // kdDebug() << " fn: " << filter->name() << endl; |
2062 | filterList << filter->name(); | 2061 | filterList << filter->name(); |
2063 | config->setGroup("Filter_" + filter->name()); | 2062 | config->setGroup("Filter_" + filter->name()); |
2064 | config->writeEntry("Criteria",filter->criteria()); | 2063 | config->writeEntry("Criteria",filter->criteria()); |
2065 | config->writeEntry("CategoryList",filter->categoryList()); | 2064 | config->writeEntry("CategoryList",filter->categoryList()); |
2066 | filter = mFilters.next(); | 2065 | filter = mFilters.next(); |
2067 | } | 2066 | } |
2068 | config->setGroup("General"); | 2067 | config->setGroup("General"); |
2069 | config->writeEntry("CalendarFilters",filterList); | 2068 | config->writeEntry("CalendarFilters",filterList); |
2070 | 2069 | ||
2071 | config->setGroup("FilterView"); | 2070 | config->setGroup("FilterView"); |
2072 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2071 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2073 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2072 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2074 | } | 2073 | } |
2075 | 2074 | ||
2076 | 2075 | ||
2077 | void CalendarView::goToday() | 2076 | void CalendarView::goToday() |
2078 | { | 2077 | { |
2079 | if ( mViewManager->currentView()->isMonthView() ) | 2078 | if ( mViewManager->currentView()->isMonthView() ) |
2080 | mNavigator->selectTodayMonth(); | 2079 | mNavigator->selectTodayMonth(); |
2081 | else | 2080 | else |
2082 | mNavigator->selectToday(); | 2081 | mNavigator->selectToday(); |
2083 | } | 2082 | } |
2084 | 2083 | ||
2085 | void CalendarView::goNext() | 2084 | void CalendarView::goNext() |
2086 | { | 2085 | { |
2087 | mNavigator->selectNext(); | 2086 | mNavigator->selectNext(); |
2088 | } | 2087 | } |
2089 | 2088 | ||
2090 | void CalendarView::goPrevious() | 2089 | void CalendarView::goPrevious() |
2091 | { | 2090 | { |
2092 | mNavigator->selectPrevious(); | 2091 | mNavigator->selectPrevious(); |
2093 | } | 2092 | } |
2094 | void CalendarView::goNextMonth() | 2093 | void CalendarView::goNextMonth() |
2095 | { | 2094 | { |
2096 | mNavigator->selectNextMonth(); | 2095 | mNavigator->selectNextMonth(); |
2097 | } | 2096 | } |
2098 | 2097 | ||
2099 | void CalendarView::goPreviousMonth() | 2098 | void CalendarView::goPreviousMonth() |
2100 | { | 2099 | { |
2101 | mNavigator->selectPreviousMonth(); | 2100 | mNavigator->selectPreviousMonth(); |
2102 | } | 2101 | } |
2103 | void CalendarView::writeLocale() | 2102 | void CalendarView::writeLocale() |
2104 | { | 2103 | { |
2105 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2104 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2106 | #if 0 | 2105 | #if 0 |
2107 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2106 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2108 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2107 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2109 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2108 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2110 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2109 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2111 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2110 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2112 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2111 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2113 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2112 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2114 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2113 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2115 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2114 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2116 | KOPrefs::instance()->mDaylightsavingStart, | 2115 | KOPrefs::instance()->mDaylightsavingStart, |
2117 | KOPrefs::instance()->mDaylightsavingEnd ); | 2116 | KOPrefs::instance()->mDaylightsavingEnd ); |
2118 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2117 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2119 | #endif | 2118 | #endif |
2120 | } | 2119 | } |
2121 | void CalendarView::updateConfig() | 2120 | void CalendarView::updateConfig() |
2122 | { | 2121 | { |
2123 | writeLocale(); | 2122 | writeLocale(); |
2124 | if ( KOPrefs::instance()->mUseAppColors ) | 2123 | if ( KOPrefs::instance()->mUseAppColors ) |
2125 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2124 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2126 | emit configChanged(); | 2125 | emit configChanged(); |
2127 | mTodoList->updateConfig(); | 2126 | mTodoList->updateConfig(); |
2128 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2127 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2129 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2128 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2130 | // To make the "fill window" configurations work | 2129 | // To make the "fill window" configurations work |
2131 | //mViewManager->raiseCurrentView(); | 2130 | //mViewManager->raiseCurrentView(); |
2132 | } | 2131 | } |
2133 | 2132 | ||
2134 | 2133 | ||
2135 | void CalendarView::eventChanged(Event *event) | 2134 | void CalendarView::eventChanged(Event *event) |
2136 | { | 2135 | { |
2137 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2136 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2138 | //updateUnmanagedViews(); | 2137 | //updateUnmanagedViews(); |
2139 | } | 2138 | } |
2140 | 2139 | ||
2141 | void CalendarView::eventAdded(Event *event) | 2140 | void CalendarView::eventAdded(Event *event) |
2142 | { | 2141 | { |
2143 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2142 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2144 | } | 2143 | } |
2145 | 2144 | ||
2146 | void CalendarView::eventToBeDeleted(Event *) | 2145 | void CalendarView::eventToBeDeleted(Event *) |
2147 | { | 2146 | { |
2148 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2147 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2149 | } | 2148 | } |
2150 | 2149 | ||
2151 | void CalendarView::eventDeleted() | 2150 | void CalendarView::eventDeleted() |
2152 | { | 2151 | { |
2153 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2152 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2154 | } | 2153 | } |
2155 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2154 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2156 | { | 2155 | { |
2157 | changeIncidenceDisplay((Incidence *)which, action); | 2156 | changeIncidenceDisplay((Incidence *)which, action); |
2158 | mDateNavigator->updateView(); //LR | 2157 | mDateNavigator->updateView(); //LR |
2159 | //mDialogManager->updateSearchDialog(); | 2158 | //mDialogManager->updateSearchDialog(); |
2160 | 2159 | ||
2161 | if (which) { | 2160 | if (which) { |
2162 | mViewManager->updateWNview(); | 2161 | mViewManager->updateWNview(); |
2163 | //mTodoList->updateView(); | 2162 | //mTodoList->updateView(); |
2164 | } | 2163 | } |
2165 | 2164 | ||
2166 | } | 2165 | } |
2167 | 2166 | ||
2168 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2167 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2169 | { | 2168 | { |
2170 | updateUnmanagedViews(); | 2169 | updateUnmanagedViews(); |
2171 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2170 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2172 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2171 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2173 | mCalendar->checkAlarmForIncidence( 0, true ); | 2172 | mCalendar->checkAlarmForIncidence( 0, true ); |
2174 | if ( mEventViewerDialog ) | 2173 | if ( mEventViewerDialog ) |
2175 | mEventViewerDialog->hide(); | 2174 | mEventViewerDialog->hide(); |
2176 | } | 2175 | } |
2177 | else | 2176 | else |
2178 | mCalendar->checkAlarmForIncidence( which , false ); | 2177 | mCalendar->checkAlarmForIncidence( which , false ); |
2179 | } | 2178 | } |
2180 | 2179 | ||
2181 | // most of the changeEventDisplays() right now just call the view's | 2180 | // most of the changeEventDisplays() right now just call the view's |
2182 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2181 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2183 | void CalendarView::changeEventDisplay(Event *which, int action) | 2182 | void CalendarView::changeEventDisplay(Event *which, int action) |
2184 | { | 2183 | { |
2185 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2184 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2186 | changeIncidenceDisplay((Incidence *)which, action); | 2185 | changeIncidenceDisplay((Incidence *)which, action); |
2187 | mDateNavigator->updateView(); | 2186 | mDateNavigator->updateView(); |
2188 | //mDialogManager->updateSearchDialog(); | 2187 | //mDialogManager->updateSearchDialog(); |
2189 | 2188 | ||
2190 | if (which) { | 2189 | if (which) { |
2191 | // If there is an event view visible update the display | 2190 | // If there is an event view visible update the display |
2192 | mViewManager->currentView()->changeEventDisplay(which,action); | 2191 | mViewManager->currentView()->changeEventDisplay(which,action); |
2193 | // TODO: check, if update needed | 2192 | // TODO: check, if update needed |
2194 | // if (which->getTodoStatus()) { | 2193 | // if (which->getTodoStatus()) { |
2195 | mTodoList->updateView(); | 2194 | mTodoList->updateView(); |
2196 | // } | 2195 | // } |
2197 | } else { | 2196 | } else { |
2198 | mViewManager->currentView()->updateView(); | 2197 | mViewManager->currentView()->updateView(); |
2199 | } | 2198 | } |
2200 | } | 2199 | } |
2201 | 2200 | ||
2202 | 2201 | ||
2203 | void CalendarView::updateTodoViews() | 2202 | void CalendarView::updateTodoViews() |
2204 | { | 2203 | { |
2205 | mTodoList->updateView(); | 2204 | mTodoList->updateView(); |
2206 | mViewManager->currentView()->updateView(); | 2205 | mViewManager->currentView()->updateView(); |
2207 | 2206 | ||
2208 | } | 2207 | } |
2209 | 2208 | ||
2210 | 2209 | ||
2211 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2210 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2212 | { | 2211 | { |
2213 | mTodoList->updateView(); | 2212 | mTodoList->updateView(); |
2214 | mViewManager->updateView(start, end); | 2213 | mViewManager->updateView(start, end); |
2215 | //mDateNavigator->updateView(); | 2214 | //mDateNavigator->updateView(); |
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | void CalendarView::updateView() | 2217 | void CalendarView::updateView() |
2219 | { | 2218 | { |
2220 | DateList tmpList = mNavigator->selectedDates(); | 2219 | DateList tmpList = mNavigator->selectedDates(); |
2221 | 2220 | ||
2222 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2221 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2223 | mTodoList->updateView(); | 2222 | mTodoList->updateView(); |
2224 | // We assume that the navigator only selects consecutive days. | 2223 | // We assume that the navigator only selects consecutive days. |
2225 | updateView( tmpList.first(), tmpList.last() ); | 2224 | updateView( tmpList.first(), tmpList.last() ); |
2226 | } | 2225 | } |
2227 | 2226 | ||
2228 | void CalendarView::updateUnmanagedViews() | 2227 | void CalendarView::updateUnmanagedViews() |
2229 | { | 2228 | { |
2230 | mDateNavigator->updateDayMatrix(); | 2229 | mDateNavigator->updateDayMatrix(); |
2231 | } | 2230 | } |
2232 | 2231 | ||
2233 | int CalendarView::msgItemDelete(const QString name) | 2232 | int CalendarView::msgItemDelete(const QString name) |
2234 | { | 2233 | { |
2235 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2234 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2236 | i18n("This item will be\npermanently deleted."), | 2235 | i18n("This item will be\npermanently deleted."), |
2237 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2236 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2238 | } | 2237 | } |
2239 | 2238 | ||
2240 | 2239 | ||
2241 | void CalendarView::edit_cut() | 2240 | void CalendarView::edit_cut() |
2242 | { | 2241 | { |
2243 | Event *anEvent=0; | 2242 | Event *anEvent=0; |
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 3f6e29b..d09f484 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,219 +1,229 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | //#include "koglobals.h" | 29 | //#include "koglobals.h" |
30 | #include "navigatorbar.h" | 30 | #include "navigatorbar.h" |
31 | #include "kdatenavigator.h" | 31 | #include "kdatenavigator.h" |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | 36 | ||
37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
38 | const char *name ) | 38 | const char *name ) |
39 | : QWidget( parent, name ), mCalendar( 0 ), | 39 | : QWidget( parent, name ), mCalendar( 0 ), |
40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
41 | { | 41 | { |
42 | mExtraViews.setAutoDelete( true ); | 42 | mExtraViews.setAutoDelete( true ); |
43 | 43 | ||
44 | mNavigatorView = new KDateNavigator( this, name ); | 44 | mNavigatorView = new KDateNavigator( this, name ); |
45 | 45 | ||
46 | connectNavigatorView( mNavigatorView ); | 46 | connectNavigatorView( mNavigatorView ); |
47 | } | 47 | } |
48 | 48 | ||
49 | DateNavigatorContainer::~DateNavigatorContainer() | 49 | DateNavigatorContainer::~DateNavigatorContainer() |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
54 | { | 54 | { |
55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
57 | #if 0 | 57 | #if 0 |
58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
62 | #endif | 62 | #endif |
63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
64 | SIGNAL( weekClicked( const QDate & ) ) ); | 64 | SIGNAL( weekClicked( const QDate & ) ) ); |
65 | 65 | ||
66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
68 | 68 | ||
69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
73 | 73 | ||
74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
78 | { | 78 | { |
79 | mCalendar = cal; | 79 | mCalendar = cal; |
80 | mNavigatorView->setCalendar( cal ); | 80 | mNavigatorView->setCalendar( cal ); |
81 | KDateNavigator *n; | 81 | KDateNavigator *n; |
82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
83 | n->setCalendar( cal ); | 83 | n->setCalendar( cal ); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | void DateNavigatorContainer::updateDayMatrix() | 87 | void DateNavigatorContainer::updateDayMatrix() |
88 | { | 88 | { |
89 | mNavigatorView->updateDayMatrix(); | 89 | mNavigatorView->updateDayMatrix(); |
90 | KDateNavigator *n; | 90 | KDateNavigator *n; |
91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
92 | n->updateDayMatrix(); | 92 | n->updateDayMatrix(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void DateNavigatorContainer::updateToday() | 96 | void DateNavigatorContainer::updateToday() |
97 | { | 97 | { |
98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
99 | #if 0 | 99 | #if 0 |
100 | mNavigatorView->updateToday(); | 100 | mNavigatorView->updateToday(); |
101 | KDateNavigator *n; | 101 | KDateNavigator *n; |
102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
103 | n->updateToday(); | 103 | n->updateToday(); |
104 | } | 104 | } |
105 | #endif | 105 | #endif |
106 | } | 106 | } |
107 | 107 | ||
108 | void DateNavigatorContainer::updateView() | 108 | void DateNavigatorContainer::updateView() |
109 | { | 109 | { |
110 | mNavigatorView->updateView(); | 110 | mNavigatorView->updateView(); |
111 | KDateNavigator *n; | 111 | KDateNavigator *n; |
112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
113 | n->updateView(); | 113 | n->updateView(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | void DateNavigatorContainer::updateConfig() | 117 | void DateNavigatorContainer::updateConfig() |
118 | { | 118 | { |
119 | mNavigatorView->updateConfig(); | 119 | mNavigatorView->updateConfig(); |
120 | KDateNavigator *n; | 120 | KDateNavigator *n; |
121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
122 | n->updateConfig(); | 122 | n->updateConfig(); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
127 | { | 127 | { |
128 | mNavigatorView->selectDates( dateList ); | 128 | mNavigatorView->selectDates( dateList ); |
129 | setBaseDates(); | 129 | setBaseDates(); |
130 | if ( mExtraViews.count() ) { | ||
131 | KDateNavigator *view = mExtraViews.at( 0 ); | ||
132 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | ||
133 | view->dayMatrix()->repaint(); | ||
134 | } | ||
130 | } | 135 | } |
131 | 136 | ||
132 | void DateNavigatorContainer::setBaseDates() | 137 | void DateNavigatorContainer::setBaseDates() |
133 | { | 138 | { |
134 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 139 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
135 | if ( dateList.isEmpty() ) { | 140 | if ( dateList.isEmpty() ) { |
136 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 141 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
137 | } | 142 | } |
138 | QDate baseDate = dateList.first(); | 143 | QDate baseDate = dateList.first(); |
139 | KDateNavigator *n; | 144 | KDateNavigator *n; |
145 | bool doRepaint = false; // skip first repaint | ||
140 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 146 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
141 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); | 147 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); |
142 | n->setBaseDate( baseDate ); | 148 | n->setBaseDate( baseDate, doRepaint ); |
149 | doRepaint = true; | ||
143 | } | 150 | } |
144 | } | 151 | } |
145 | 152 | ||
146 | void DateNavigatorContainer::resizeEvent( QResizeEvent * ) | 153 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
147 | { | 154 | { |
148 | #if 0 | 155 | #if 0 |
149 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 156 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
150 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 157 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
151 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 158 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
152 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 159 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
153 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 160 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
154 | #endif | 161 | #endif |
155 | 162 | QSize minSize = mNavigatorView->yourSizeHint(); | |
156 | QSize minSize = mNavigatorView->minimumSizeHint(); | ||
157 | 163 | ||
158 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 164 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
159 | 165 | ||
160 | int verticalCount = size().height() / minSize.height(); | 166 | int verticalCount = size().height() / minSize.height(); |
161 | int horizontalCount = size().width() / minSize.width(); | 167 | int horizontalCount = size().width() / minSize.width(); |
168 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | ||
162 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 169 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
163 | if ( horizontalCount != mHorizontalCount || | 170 | if ( horizontalCount != mHorizontalCount || |
164 | verticalCount != mVerticalCount ) { | 171 | verticalCount != mVerticalCount ) { |
165 | uint count = horizontalCount * verticalCount; | 172 | uint count = horizontalCount * verticalCount; |
166 | if ( count == 0 ) return; | 173 | if ( count == 0 ) { |
174 | mNavigatorView->resize( minSize ); | ||
175 | return; | ||
176 | } | ||
167 | 177 | ||
168 | while ( count > ( mExtraViews.count() + 1 ) ) { | 178 | while ( count > ( mExtraViews.count() + 1 ) ) { |
169 | KDateNavigator *n = new KDateNavigator( this ); | 179 | KDateNavigator *n = new KDateNavigator( this ); |
170 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 180 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
171 | mExtraViews.append( n ); | 181 | mExtraViews.append( n ); |
172 | n->setCalendar( mCalendar ); | 182 | n->setCalendar( mCalendar ); |
173 | setBaseDates(); | 183 | setBaseDates(); |
174 | connectNavigatorView( n ); | 184 | connectNavigatorView( n ); |
175 | n->show(); | 185 | n->show(); |
176 | } | 186 | } |
177 | 187 | ||
178 | while ( count < ( mExtraViews.count() + 1 ) ) { | 188 | while ( count < ( mExtraViews.count() + 1 ) ) { |
179 | mExtraViews.removeLast(); | 189 | mExtraViews.removeLast(); |
180 | } | 190 | } |
181 | 191 | ||
182 | mHorizontalCount = horizontalCount; | 192 | mHorizontalCount = horizontalCount; |
183 | mVerticalCount = verticalCount; | 193 | mVerticalCount = verticalCount; |
184 | } | 194 | } |
185 | 195 | ||
186 | int height = size().height() / verticalCount; | 196 | int height = size().height() / verticalCount; |
187 | int width = size().width() / horizontalCount; | 197 | int width = size().width() / horizontalCount; |
188 | 198 | ||
189 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 199 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
190 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 200 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
191 | else bar->showButtons( true, true ); | 201 | else bar->showButtons( true, true ); |
192 | 202 | ||
193 | mNavigatorView->setGeometry(0, | 203 | mNavigatorView->setGeometry(0, |
194 | 0, width, height ); | 204 | 0, width, height ); |
195 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | 205 | for( uint i = 0; i < mExtraViews.count(); ++i ) { |
196 | int x = ( i + 1 ) % horizontalCount; | 206 | int x = ( i + 1 ) % horizontalCount; |
197 | int y = ( i + 1 ) / horizontalCount; | 207 | int y = ( i + 1 ) / horizontalCount; |
198 | 208 | ||
199 | KDateNavigator *view = mExtraViews.at( i ); | 209 | KDateNavigator *view = mExtraViews.at( i ); |
200 | bar = view->navigatorBar(); | 210 | bar = view->navigatorBar(); |
201 | if ( y > 0 ) bar->showButtons( false, false ); | 211 | if ( y > 0 ) bar->showButtons( false, false ); |
202 | else { | 212 | else { |
203 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 213 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
204 | else bar->showButtons( false, false ); | 214 | else bar->showButtons( false, false ); |
205 | } | 215 | } |
206 | view->setGeometry( x * width, | 216 | view->setGeometry( x * width, |
207 | y * height, width, height ); | 217 | y * height, width, height ); |
208 | } | 218 | } |
209 | } | 219 | } |
210 | 220 | ||
211 | QSize DateNavigatorContainer::minimumSizeHint() const | 221 | QSize DateNavigatorContainer::minimumSizeHint() const |
212 | { | 222 | { |
213 | return mNavigatorView->minimumSizeHint(); | 223 | return mNavigatorView->minimumSizeHint(); |
214 | } | 224 | } |
215 | 225 | ||
216 | QSize DateNavigatorContainer::sizeHint() const | 226 | QSize DateNavigatorContainer::sizeHint() const |
217 | { | 227 | { |
218 | return mNavigatorView->sizeHint(); | 228 | return mNavigatorView->sizeHint(); |
219 | } | 229 | } |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index ab9a40f..b097dc1 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,389 +1,390 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 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 <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | 64 | ||
65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
66 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
68 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
74 | 74 | ||
75 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
77 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | 80 | ||
81 | // Set up the heading fields. | 81 | // Set up the heading fields. |
82 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
83 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
85 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
86 | 86 | ||
87 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
88 | } | 88 | } |
89 | 89 | ||
90 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
91 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
92 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
93 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter); |
94 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
95 | if(!m_bShowWeekNums) { | 95 | if(!m_bShowWeekNums) { |
96 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
97 | } | 97 | } |
98 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
99 | 99 | ||
100 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
101 | } | 101 | } |
102 | 102 | ||
103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
105 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
106 | 106 | ||
107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
109 | 109 | ||
110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
111 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
112 | 112 | ||
113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
114 | 114 | ||
115 | // read settings from configuration file. | 115 | // read settings from configuration file. |
116 | updateConfig(); | 116 | updateConfig(); |
117 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
118 | //setFixedSize ( sizeHint() ); | 118 | mySizeHint = sizeHint(); |
119 | } | 119 | } |
120 | void KDateNavigator::slotMonthSelected( int m ) | 120 | void KDateNavigator::slotMonthSelected( int m ) |
121 | { | 121 | { |
122 | if ( m_MthYr.month() <= mMonthSignalOffset) | 122 | if ( m_MthYr.month() <= mMonthSignalOffset) |
123 | m += 12; | 123 | m += 12; |
124 | int mo = m - mMonthSignalOffset; | 124 | int mo = m - mMonthSignalOffset; |
125 | emit monthSelected( m - mMonthSignalOffset ); | 125 | emit monthSelected( m - mMonthSignalOffset ); |
126 | 126 | ||
127 | } | 127 | } |
128 | void KDateNavigator::setCalendar( Calendar *cal ) | 128 | void KDateNavigator::setCalendar( Calendar *cal ) |
129 | { | 129 | { |
130 | daymatrix->setCalendar( cal ); | 130 | daymatrix->setCalendar( cal ); |
131 | } | 131 | } |
132 | 132 | ||
133 | void KDateNavigator::setBaseDate( const QDate &date ) | 133 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
134 | { | 134 | { |
135 | m_MthYr = date; | 135 | m_MthYr = date; |
136 | 136 | ||
137 | updateDates(); | 137 | updateDates(); |
138 | updateView(); | 138 | updateView(); |
139 | 139 | ||
140 | KCal::DateList dates; | 140 | KCal::DateList dates; |
141 | dates.append( date ); | 141 | dates.append( date ); |
142 | mNavigatorBar->selectDates( dates ); | 142 | mNavigatorBar->selectDates( dates ); |
143 | 143 | ||
144 | daymatrix->clearSelection(); | 144 | daymatrix->clearSelection(); |
145 | daymatrix->repaint(); | 145 | if ( doRepaint ) |
146 | daymatrix->repaint(); | ||
146 | } | 147 | } |
147 | 148 | ||
148 | void KDateNavigator::enableRollover(RolloverType r) | 149 | void KDateNavigator::enableRollover(RolloverType r) |
149 | { | 150 | { |
150 | switch(r) | 151 | switch(r) |
151 | { | 152 | { |
152 | case None : | 153 | case None : |
153 | if (updateTimer) | 154 | if (updateTimer) |
154 | { | 155 | { |
155 | updateTimer->stop(); | 156 | updateTimer->stop(); |
156 | delete updateTimer; | 157 | delete updateTimer; |
157 | updateTimer=0L; | 158 | updateTimer=0L; |
158 | } | 159 | } |
159 | break; | 160 | break; |
160 | case FollowDay : | 161 | case FollowDay : |
161 | case FollowMonth : | 162 | case FollowMonth : |
162 | if (!updateTimer) | 163 | if (!updateTimer) |
163 | { | 164 | { |
164 | updateTimer = new QTimer(this); | 165 | updateTimer = new QTimer(this); |
165 | QObject::connect(updateTimer,SIGNAL(timeout()), | 166 | QObject::connect(updateTimer,SIGNAL(timeout()), |
166 | this,SLOT(possiblyPastMidnight())); | 167 | this,SLOT(possiblyPastMidnight())); |
167 | } | 168 | } |
168 | updateTimer->start(0,true); | 169 | updateTimer->start(0,true); |
169 | lastDayChecked = QDate::currentDate(); | 170 | lastDayChecked = QDate::currentDate(); |
170 | } | 171 | } |
171 | updateRollover=r; | 172 | updateRollover=r; |
172 | } | 173 | } |
173 | 174 | ||
174 | 175 | ||
175 | KDateNavigator::~KDateNavigator() | 176 | KDateNavigator::~KDateNavigator() |
176 | { | 177 | { |
177 | } | 178 | } |
178 | 179 | ||
179 | 180 | ||
180 | void KDateNavigator::passedMidnight() | 181 | void KDateNavigator::passedMidnight() |
181 | { | 182 | { |
182 | QDate today = QDate::currentDate(); | 183 | QDate today = QDate::currentDate(); |
183 | bool emitMonth = false; | 184 | bool emitMonth = false; |
184 | 185 | ||
185 | if (today.month() != lastDayChecked.month()) | 186 | if (today.month() != lastDayChecked.month()) |
186 | { | 187 | { |
187 | if (updateRollover==FollowMonth && | 188 | if (updateRollover==FollowMonth && |
188 | daymatrix->isEndOfMonth()) { | 189 | daymatrix->isEndOfMonth()) { |
189 | goNextMonth(); | 190 | goNextMonth(); |
190 | emitMonth=true; | 191 | emitMonth=true; |
191 | } | 192 | } |
192 | } | 193 | } |
193 | daymatrix->recalculateToday(); | 194 | daymatrix->recalculateToday(); |
194 | daymatrix->repaint(); | 195 | daymatrix->repaint(); |
195 | emit dayPassed(today); | 196 | emit dayPassed(today); |
196 | if (emitMonth) { emit monthPassed(today); } | 197 | if (emitMonth) { emit monthPassed(today); } |
197 | } | 198 | } |
198 | 199 | ||
199 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 200 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
200 | { | 201 | { |
201 | if (lastDayChecked!=QDate::currentDate()) | 202 | if (lastDayChecked!=QDate::currentDate()) |
202 | { | 203 | { |
203 | passedMidnight(); | 204 | passedMidnight(); |
204 | lastDayChecked=QDate::currentDate(); | 205 | lastDayChecked=QDate::currentDate(); |
205 | } | 206 | } |
206 | // Set the timer to go off 1 second after midnight | 207 | // Set the timer to go off 1 second after midnight |
207 | // or after 8 minutes, whichever comes first. | 208 | // or after 8 minutes, whichever comes first. |
208 | if (updateTimer) | 209 | if (updateTimer) |
209 | { | 210 | { |
210 | QTime now = QTime::currentTime(); | 211 | QTime now = QTime::currentTime(); |
211 | QTime midnight = QTime(23,59,59); | 212 | QTime midnight = QTime(23,59,59); |
212 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 213 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
213 | 214 | ||
214 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 215 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
215 | //.arg(now.toString()).arg(midnight.toString())); | 216 | //.arg(now.toString()).arg(midnight.toString())); |
216 | 217 | ||
217 | updateTimer->stop(); | 218 | updateTimer->stop(); |
218 | updateTimer->start(msecsWait,true); | 219 | updateTimer->start(msecsWait,true); |
219 | } | 220 | } |
220 | } | 221 | } |
221 | 222 | ||
222 | void KDateNavigator::updateDates() | 223 | void KDateNavigator::updateDates() |
223 | { | 224 | { |
224 | // Find the first day of the week of the current month. | 225 | // Find the first day of the week of the current month. |
225 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 226 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
226 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 227 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
227 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 228 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
228 | //int di = d1 - d2 + 1; | 229 | //int di = d1 - d2 + 1; |
229 | dayone = dayone.addDays( -d2 + 1 ); | 230 | dayone = dayone.addDays( -d2 + 1 ); |
230 | 231 | ||
231 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 232 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
232 | 233 | ||
233 | // If month begins on Monday and Monday is first day of week, | 234 | // If month begins on Monday and Monday is first day of week, |
234 | // month should begin on second line. Sunday doesn't have this problem. | 235 | // month should begin on second line. Sunday doesn't have this problem. |
235 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 236 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
236 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 237 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
237 | 238 | ||
238 | // update the matrix dates | 239 | // update the matrix dates |
239 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 240 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
240 | 241 | ||
241 | 242 | ||
242 | daymatrix->updateView(dayone.addDays(index)); | 243 | daymatrix->updateView(dayone.addDays(index)); |
243 | //each updateDates is followed by an updateView -> repaint is issued there ! | 244 | //each updateDates is followed by an updateView -> repaint is issued there ! |
244 | // daymatrix->repaint(); | 245 | // daymatrix->repaint(); |
245 | } | 246 | } |
246 | 247 | ||
247 | void KDateNavigator::updateDayMatrix() | 248 | void KDateNavigator::updateDayMatrix() |
248 | { | 249 | { |
249 | daymatrix->updateView(); | 250 | daymatrix->updateView(); |
250 | //daymatrix->repaint(); | 251 | //daymatrix->repaint(); |
251 | } | 252 | } |
252 | 253 | ||
253 | 254 | ||
254 | void KDateNavigator::updateView() | 255 | void KDateNavigator::updateView() |
255 | { | 256 | { |
256 | 257 | ||
257 | setUpdatesEnabled( false ); | 258 | setUpdatesEnabled( false ); |
258 | 259 | ||
259 | int i; | 260 | int i; |
260 | 261 | ||
261 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 262 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
262 | daymatrix->updateView(); | 263 | daymatrix->updateView(); |
263 | 264 | ||
264 | // set the week numbers. | 265 | // set the week numbers. |
265 | for(i = 0; i < 6; i++) { | 266 | for(i = 0; i < 6; i++) { |
266 | QString weeknum; | 267 | QString weeknum; |
267 | // remember, according to ISO 8601, the first week of the year is the | 268 | // remember, according to ISO 8601, the first week of the year is the |
268 | // first week that contains a thursday. Thus we must subtract off 4, | 269 | // first week that contains a thursday. Thus we must subtract off 4, |
269 | // not just 1. | 270 | // not just 1. |
270 | 271 | ||
271 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 272 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
272 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 273 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
273 | 274 | ||
274 | int add = 0; | 275 | int add = 0; |
275 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 276 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
276 | ++add; | 277 | ++add; |
277 | if (dayOfYear % 7 != 0) | 278 | if (dayOfYear % 7 != 0) |
278 | weeknum.setNum(dayOfYear / 7 + 1+add); | 279 | weeknum.setNum(dayOfYear / 7 + 1+add); |
279 | else | 280 | else |
280 | weeknum.setNum(dayOfYear / 7 +add); | 281 | weeknum.setNum(dayOfYear / 7 +add); |
281 | weeknos[i]->setText(weeknum); | 282 | weeknos[i]->setText(weeknum); |
282 | } | 283 | } |
283 | 284 | ||
284 | setUpdatesEnabled( true ); | 285 | setUpdatesEnabled( true ); |
285 | // kdDebug() << "updateView() -> repaint()" << endl; | 286 | // kdDebug() << "updateView() -> repaint()" << endl; |
286 | repaint(); | 287 | repaint(); |
287 | // daymatrix->repaint(); | 288 | // daymatrix->repaint(); |
288 | } | 289 | } |
289 | 290 | ||
290 | void KDateNavigator::updateConfig() | 291 | void KDateNavigator::updateConfig() |
291 | { | 292 | { |
292 | int day; | 293 | int day; |
293 | for(int i=0; i<7; i++) { | 294 | for(int i=0; i<7; i++) { |
294 | // take the first letter of the day name to be the abbreviation | 295 | // take the first letter of the day name to be the abbreviation |
295 | if (KGlobal::locale()->weekStartsMonday()) { | 296 | if (KGlobal::locale()->weekStartsMonday()) { |
296 | day = i+1; | 297 | day = i+1; |
297 | } else { | 298 | } else { |
298 | if (i==0) day = 7; | 299 | if (i==0) day = 7; |
299 | else day = i; | 300 | else day = i; |
300 | } | 301 | } |
301 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 302 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
302 | true ); | 303 | true ); |
303 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 304 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
304 | headings[i]->setText( dayName ); | 305 | headings[i]->setText( dayName ); |
305 | } | 306 | } |
306 | updateDates(); | 307 | updateDates(); |
307 | updateView(); | 308 | updateView(); |
308 | } | 309 | } |
309 | 310 | ||
310 | void KDateNavigator::setShowWeekNums(bool enabled) | 311 | void KDateNavigator::setShowWeekNums(bool enabled) |
311 | { | 312 | { |
312 | m_bShowWeekNums = enabled; | 313 | m_bShowWeekNums = enabled; |
313 | for(int i=0; i<6; i++) { | 314 | for(int i=0; i<6; i++) { |
314 | if(enabled) | 315 | if(enabled) |
315 | weeknos[i]->show(); | 316 | weeknos[i]->show(); |
316 | else | 317 | else |
317 | weeknos[i]->hide(); | 318 | weeknos[i]->hide(); |
318 | } | 319 | } |
319 | resize(size()); | 320 | resize(size()); |
320 | } | 321 | } |
321 | 322 | ||
322 | void KDateNavigator::selectDates(const DateList& dateList) | 323 | void KDateNavigator::selectDates(const DateList& dateList) |
323 | { | 324 | { |
324 | 325 | ||
325 | if (dateList.count() > 0) { | 326 | if (dateList.count() > 0) { |
326 | mNavigatorBar->selectDates( dateList ); | 327 | mNavigatorBar->selectDates( dateList ); |
327 | mSelectedDates = dateList; | 328 | mSelectedDates = dateList; |
328 | 329 | ||
329 | // set our record of the month and year that this datetbl is | 330 | // set our record of the month and year that this datetbl is |
330 | // displaying. | 331 | // displaying. |
331 | m_MthYr = mSelectedDates.first(); | 332 | m_MthYr = mSelectedDates.first(); |
332 | 333 | ||
333 | 334 | ||
334 | // set our record of the first day of the week of the current | 335 | // set our record of the first day of the week of the current |
335 | // month. This needs to be done before calling dayToIndex, since it | 336 | // month. This needs to be done before calling dayToIndex, since it |
336 | // relies on this information being up to date. | 337 | // relies on this information being up to date. |
337 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 338 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
338 | m_fstDayOfWk = dayone.dayOfWeek(); | 339 | m_fstDayOfWk = dayone.dayOfWeek(); |
339 | 340 | ||
340 | updateDates(); | 341 | updateDates(); |
341 | 342 | ||
342 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 343 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
343 | 344 | ||
344 | updateView(); | 345 | updateView(); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | 348 | ||
348 | int KDateNavigator::dayNum(int row, int col) | 349 | int KDateNavigator::dayNum(int row, int col) |
349 | { | 350 | { |
350 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 351 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
351 | } | 352 | } |
352 | 353 | ||
353 | int KDateNavigator::dayToIndex(int dayNum) | 354 | int KDateNavigator::dayToIndex(int dayNum) |
354 | { | 355 | { |
355 | int row, col; | 356 | int row, col; |
356 | 357 | ||
357 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 358 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
358 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 359 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
359 | row++; | 360 | row++; |
360 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 361 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
361 | return row * 7 + col; | 362 | return row * 7 + col; |
362 | } | 363 | } |
363 | 364 | ||
364 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 365 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
365 | { | 366 | { |
366 | if(e->delta()>0) emit goPrevious(); | 367 | if(e->delta()>0) emit goPrevious(); |
367 | else emit goNext(); | 368 | else emit goNext(); |
368 | 369 | ||
369 | e->accept(); | 370 | e->accept(); |
370 | } | 371 | } |
371 | 372 | ||
372 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 373 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
373 | { | 374 | { |
374 | if (e->type() == QEvent::MouseButtonPress) { | 375 | if (e->type() == QEvent::MouseButtonPress) { |
375 | int i; | 376 | int i; |
376 | for(i=0;i<6;++i) { | 377 | for(i=0;i<6;++i) { |
377 | if (o == weeknos[i]) { | 378 | if (o == weeknos[i]) { |
378 | QDate weekstart = daymatrix->getDate(i*7); | 379 | QDate weekstart = daymatrix->getDate(i*7); |
379 | emit weekClicked(weekstart); | 380 | emit weekClicked(weekstart); |
380 | break; | 381 | break; |
381 | } | 382 | } |
382 | } | 383 | } |
383 | return true; | 384 | return true; |
384 | } else { | 385 | } else { |
385 | return false; | 386 | return false; |
386 | } | 387 | } |
387 | } | 388 | } |
388 | 389 | ||
389 | //#include "kdatenavigator.moc" | 390 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 56822fa..292e71c 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -1,151 +1,154 @@ | |||
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 | 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 | #ifndef KDATENAVIGATOR_H | 23 | #ifndef KDATENAVIGATOR_H |
24 | #define KDATENAVIGATOR_H | 24 | #define KDATENAVIGATOR_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | #include "kodaymatrix.h" | 32 | #include "kodaymatrix.h" |
33 | 33 | ||
34 | class QPushButton; | 34 | class QPushButton; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class KCalendarSystem; | 37 | class KCalendarSystem; |
38 | 38 | ||
39 | class NavigatorBar; | 39 | class NavigatorBar; |
40 | 40 | ||
41 | class KDateNavigator: public QFrame | 41 | class KDateNavigator: public QFrame |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); | 45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); |
46 | ~KDateNavigator(); | 46 | ~KDateNavigator(); |
47 | 47 | ||
48 | /** The DateNavigator automatically checks for | 48 | /** The DateNavigator automatically checks for |
49 | * the passage of midnight. If rollover type is | 49 | * the passage of midnight. If rollover type is |
50 | * set to None, no signals are emitted and no | 50 | * set to None, no signals are emitted and no |
51 | * processing is done. With rollover set to | 51 | * processing is done. With rollover set to |
52 | * FollowDay, the day highlighter changes at | 52 | * FollowDay, the day highlighter changes at |
53 | * midnight and dayPassed() is emitted. | 53 | * midnight and dayPassed() is emitted. |
54 | * With FollowMonth, it has the same effect | 54 | * With FollowMonth, it has the same effect |
55 | * as FollowDay but also adjusts the month that is | 55 | * as FollowDay but also adjusts the month that is |
56 | * visible and emits monthPassed() when the month changes. | 56 | * visible and emits monthPassed() when the month changes. |
57 | */ | 57 | */ |
58 | enum RolloverType { None, FollowDay, FollowMonth } ; | 58 | enum RolloverType { None, FollowDay, FollowMonth } ; |
59 | void enableRollover( RolloverType ); | 59 | void enableRollover( RolloverType ); |
60 | 60 | ||
61 | void setShowWeekNums( bool enabled ); | 61 | void setShowWeekNums( bool enabled ); |
62 | void setCalendar( Calendar * ); | 62 | void setCalendar( Calendar * ); |
63 | void setBaseDate( const QDate & ); | 63 | void setBaseDate( const QDate & , bool doRepaint = true ); |
64 | KCal::DateList selectedDates() const { return mSelectedDates; } | 64 | KCal::DateList selectedDates() const { return mSelectedDates; } |
65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } | 65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } |
66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} | 66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} |
67 | QSize yourSizeHint() { return mySizeHint; } | ||
68 | KODayMatrix *dayMatrix() { return daymatrix ;} | ||
67 | public slots: | 69 | public slots: |
68 | void selectDates( const KCal::DateList & ); | 70 | void selectDates( const KCal::DateList & ); |
69 | void updateView(); | 71 | void updateView(); |
70 | void updateConfig(); | 72 | void updateConfig(); |
71 | void updateDayMatrix(); | 73 | void updateDayMatrix(); |
72 | 74 | ||
73 | signals: | 75 | signals: |
74 | void datesSelected( const KCal::DateList & ); | 76 | void datesSelected( const KCal::DateList & ); |
75 | void eventDropped( Event * ); | 77 | void eventDropped( Event * ); |
76 | void weekClicked( const QDate &); | 78 | void weekClicked( const QDate &); |
77 | 79 | ||
78 | void goPrevious(); | 80 | void goPrevious(); |
79 | void goNext(); | 81 | void goNext(); |
80 | 82 | ||
81 | void goNextMonth(); | 83 | void goNextMonth(); |
82 | void goPrevMonth(); | 84 | void goPrevMonth(); |
83 | void goNextYear(); | 85 | void goNextYear(); |
84 | void goPrevYear(); | 86 | void goPrevYear(); |
85 | void monthSelected( int ); | 87 | void monthSelected( int ); |
86 | 88 | ||
87 | // Signals emitted at midnight carrying the new date. | 89 | // Signals emitted at midnight carrying the new date. |
88 | void dayPassed( QDate ); | 90 | void dayPassed( QDate ); |
89 | void monthPassed( QDate ); | 91 | void monthPassed( QDate ); |
90 | 92 | ||
91 | protected slots: | 93 | protected slots: |
92 | 94 | ||
93 | /** | 95 | /** |
94 | * Called regularly to see if we need to update the view | 96 | * Called regularly to see if we need to update the view |
95 | * wrt. the today box and the month box. Only important | 97 | * wrt. the today box and the month box. Only important |
96 | * if you leave KOrganizer idle for long periods of time. | 98 | * if you leave KOrganizer idle for long periods of time. |
97 | * | 99 | * |
98 | * Until we have a reliable way of setting QTimers to go | 100 | * Until we have a reliable way of setting QTimers to go |
99 | * off at a particular wall-clock time, we need this, | 101 | * off at a particular wall-clock time, we need this, |
100 | * which calls passedMidnight() at the right moments. | 102 | * which calls passedMidnight() at the right moments. |
101 | */ | 103 | */ |
102 | void possiblyPastMidnight(); | 104 | void possiblyPastMidnight(); |
103 | 105 | ||
104 | /** handles updating the view when midnight has come by due to idle time. | 106 | /** handles updating the view when midnight has come by due to idle time. |
105 | * | 107 | * |
106 | */ | 108 | */ |
107 | void passedMidnight(); | 109 | void passedMidnight(); |
108 | void slotMonthSelected( int m ); | 110 | void slotMonthSelected( int m ); |
109 | protected: | 111 | protected: |
110 | void updateDates(); | 112 | void updateDates(); |
111 | 113 | ||
112 | void wheelEvent (QWheelEvent *); | 114 | void wheelEvent (QWheelEvent *); |
113 | 115 | ||
114 | bool eventFilter (QObject *,QEvent *); | 116 | bool eventFilter (QObject *,QEvent *); |
115 | 117 | ||
116 | private: | 118 | private: |
119 | QSize mySizeHint; | ||
117 | int mMonthSignalOffset; | 120 | int mMonthSignalOffset; |
118 | NavigatorBar *mNavigatorBar; | 121 | NavigatorBar *mNavigatorBar; |
119 | 122 | ||
120 | QFrame *headingSep; | 123 | QFrame *headingSep; |
121 | QFrame *weeknumSep; | 124 | QFrame *weeknumSep; |
122 | QLabel *headings[7]; | 125 | QLabel *headings[7]; |
123 | QLabel *weeknos[7]; | 126 | QLabel *weeknos[7]; |
124 | KODayMatrix *daymatrix; | 127 | KODayMatrix *daymatrix; |
125 | 128 | ||
126 | KCal::DateList mSelectedDates; | 129 | KCal::DateList mSelectedDates; |
127 | QDate m_MthYr; | 130 | QDate m_MthYr; |
128 | int m_fstDayOfWk; | 131 | int m_fstDayOfWk; |
129 | bool m_bShowWeekNums; | 132 | bool m_bShowWeekNums; |
130 | 133 | ||
131 | int dayNum(int row, int col); | 134 | int dayNum(int row, int col); |
132 | int dayToIndex(int dayNum); | 135 | int dayToIndex(int dayNum); |
133 | 136 | ||
134 | Calendar *mCalendar; | 137 | Calendar *mCalendar; |
135 | KCalendarSystem *mCalendarSystem; | 138 | KCalendarSystem *mCalendarSystem; |
136 | 139 | ||
137 | const QString *curHeaders; | 140 | const QString *curHeaders; |
138 | 141 | ||
139 | /** used to update the day view periodically, in particular every | 142 | /** used to update the day view periodically, in particular every |
140 | * midnight to move the "today" rectangle. | 143 | * midnight to move the "today" rectangle. |
141 | */ | 144 | */ |
142 | QTimer *updateTimer; | 145 | QTimer *updateTimer; |
143 | QDate lastDayChecked; | 146 | QDate lastDayChecked; |
144 | RolloverType updateRollover; | 147 | RolloverType updateRollover; |
145 | 148 | ||
146 | // Disabling copy constructor and assignment operator | 149 | // Disabling copy constructor and assignment operator |
147 | KDateNavigator(const KDateNavigator & ); | 150 | KDateNavigator(const KDateNavigator & ); |
148 | KDateNavigator &operator=(const KDateNavigator &); | 151 | KDateNavigator &operator=(const KDateNavigator &); |
149 | }; | 152 | }; |
150 | 153 | ||
151 | #endif | 154 | #endif |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a886f4a..17a8546 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,588 +1,588 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | #include <libkcal/vcaldrag.h> | 34 | #include <libkcal/vcaldrag.h> |
35 | #include <libkcal/icaldrag.h> | 35 | #include <libkcal/icaldrag.h> |
36 | #include <libkcal/dndfactory.h> | 36 | #include <libkcal/dndfactory.h> |
37 | #include <libkcal/calendarresources.h> | 37 | #include <libkcal/calendarresources.h> |
38 | #include <libkcal/resourcecalendar.h> | 38 | #include <libkcal/resourcecalendar.h> |
39 | #include <kresources/resourceselectdialog.h> | 39 | #include <kresources/resourceselectdialog.h> |
40 | 40 | ||
41 | #include <kcalendarsystem.h> | 41 | #include <kcalendarsystem.h> |
42 | 42 | ||
43 | #ifndef KORG_NOPLUGINS | 43 | #ifndef KORG_NOPLUGINS |
44 | #include "kocore.h" | 44 | #include "kocore.h" |
45 | #endif | 45 | #endif |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "koglobals.h" | 47 | #include "koglobals.h" |
48 | 48 | ||
49 | #include "kodaymatrix.h" | 49 | #include "kodaymatrix.h" |
50 | 50 | ||
51 | // ============================================================================ | 51 | // ============================================================================ |
52 | // D Y N A M I C T I P | 52 | // D Y N A M I C T I P |
53 | // ============================================================================ | 53 | // ============================================================================ |
54 | 54 | ||
55 | DynamicTip::DynamicTip( QWidget * parent ) | 55 | DynamicTip::DynamicTip( QWidget * parent ) |
56 | : QToolTip( parent ) | 56 | : QToolTip( parent ) |
57 | { | 57 | { |
58 | matrix = (KODayMatrix*)parent; | 58 | matrix = (KODayMatrix*)parent; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void DynamicTip::maybeTip( const QPoint &pos ) | 62 | void DynamicTip::maybeTip( const QPoint &pos ) |
63 | { | 63 | { |
64 | //calculate which cell of the matrix the mouse is in | 64 | //calculate which cell of the matrix the mouse is in |
65 | QRect sz = matrix->frameRect(); | 65 | QRect sz = matrix->frameRect(); |
66 | int dheight = sz.height()*7 / 42; | 66 | int dheight = sz.height()*7 / 42; |
67 | int dwidth = sz.width() / 7; | 67 | int dwidth = sz.width() / 7; |
68 | int row = pos.y()/dheight; | 68 | int row = pos.y()/dheight; |
69 | int col = pos.x()/dwidth; | 69 | int col = pos.x()/dwidth; |
70 | 70 | ||
71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
72 | 72 | ||
73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
74 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 74 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
75 | 75 | ||
76 | //show holiday names only | 76 | //show holiday names only |
77 | QString str = matrix->getHolidayLabel(col+row*7); | 77 | QString str = matrix->getHolidayLabel(col+row*7); |
78 | if (str.isEmpty()) return; | 78 | if (str.isEmpty()) return; |
79 | tip(rct, str); | 79 | tip(rct, str); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | // ============================================================================ | 83 | // ============================================================================ |
84 | // K O D A Y M A T R I X | 84 | // K O D A Y M A T R I X |
85 | // ============================================================================ | 85 | // ============================================================================ |
86 | 86 | ||
87 | const int KODayMatrix::NOSELECTION = -1000; | 87 | const int KODayMatrix::NOSELECTION = -1000; |
88 | const int KODayMatrix::NUMDAYS = 42; | 88 | const int KODayMatrix::NUMDAYS = 42; |
89 | 89 | ||
90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
91 | : QFrame( parent, name ), mCalendar( 0 ) | 91 | : QFrame( parent, name ), mCalendar( 0 ) |
92 | 92 | ||
93 | #if 0 | 93 | #if 0 |
94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
95 | QFrame(parent, name) | 95 | QFrame(parent, name) |
96 | #endif | 96 | #endif |
97 | { | 97 | { |
98 | 98 | ||
99 | mPendingUpdateBeforeRepaint = false; | 99 | mPendingUpdateBeforeRepaint = false; |
100 | 100 | ||
101 | // initialize dynamic arrays | 101 | // initialize dynamic arrays |
102 | days = new QDate[NUMDAYS]; | 102 | days = new QDate[NUMDAYS]; |
103 | daylbls = new QString[NUMDAYS]; | 103 | daylbls = new QString[NUMDAYS]; |
104 | events = new int[NUMDAYS]; | 104 | events = new int[NUMDAYS]; |
105 | mToolTip = new DynamicTip(this); | 105 | mToolTip = new DynamicTip(this); |
106 | 106 | ||
107 | // set default values used for drawing the matrix | 107 | // set default values used for drawing the matrix |
108 | mDefaultBackColor = palette().active().base(); | 108 | mDefaultBackColor = palette().active().base(); |
109 | mDefaultTextColor = palette().active().foreground(); | 109 | mDefaultTextColor = palette().active().foreground(); |
110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
112 | mSelectedDaysColor = QColor("white"); | 112 | mSelectedDaysColor = QColor("white"); |
113 | mTodayMarginWidth = 2; | 113 | mTodayMarginWidth = 2; |
114 | mSelEnd = mSelStart = NOSELECTION; | 114 | mSelEnd = mSelStart = NOSELECTION; |
115 | 115 | ||
116 | setAcceptDrops(true); | 116 | setAcceptDrops(true); |
117 | //setFont( QFont("Arial", 10) ); | 117 | //setFont( QFont("Arial", 10) ); |
118 | 118 | ||
119 | mUpdateTimer = new QTimer( this ); | 119 | mUpdateTimer = new QTimer( this ); |
120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
121 | mRepaintTimer = new QTimer( this ); | 121 | mRepaintTimer = new QTimer( this ); |
122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
123 | mDayChanged = false; | 123 | mDayChanged = false; |
124 | updateView(); | 124 | updateView(); |
125 | } | 125 | } |
126 | void KODayMatrix::setCalendar( Calendar *cal ) | 126 | void KODayMatrix::setCalendar( Calendar *cal ) |
127 | { | 127 | { |
128 | mCalendar = cal; | 128 | mCalendar = cal; |
129 | 129 | ||
130 | setAcceptDrops( mCalendar ); | 130 | setAcceptDrops( mCalendar ); |
131 | 131 | ||
132 | updateEvents(); | 132 | updateEvents(); |
133 | } | 133 | } |
134 | 134 | ||
135 | QColor KODayMatrix::getShadedColor(QColor color) | 135 | QColor KODayMatrix::getShadedColor(QColor color) |
136 | { | 136 | { |
137 | QColor shaded; | 137 | QColor shaded; |
138 | int h=0; | 138 | int h=0; |
139 | int s=0; | 139 | int s=0; |
140 | int v=0; | 140 | int v=0; |
141 | color.hsv(&h,&s,&v); | 141 | color.hsv(&h,&s,&v); |
142 | s = s/4; | 142 | s = s/4; |
143 | v = 192+v/4; | 143 | v = 192+v/4; |
144 | shaded.setHsv(h,s,v); | 144 | shaded.setHsv(h,s,v); |
145 | 145 | ||
146 | return shaded; | 146 | return shaded; |
147 | } | 147 | } |
148 | 148 | ||
149 | KODayMatrix::~KODayMatrix() | 149 | KODayMatrix::~KODayMatrix() |
150 | { | 150 | { |
151 | delete [] days; | 151 | delete [] days; |
152 | delete [] daylbls; | 152 | delete [] daylbls; |
153 | delete [] events; | 153 | delete [] events; |
154 | delete mToolTip; | 154 | delete mToolTip; |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | void KODayMatrix::setStartDate(QDate start) | 158 | void KODayMatrix::setStartDate(QDate start) |
159 | { | 159 | { |
160 | updateView(start); | 160 | updateView(start); |
161 | } | 161 | } |
162 | */ | 162 | */ |
163 | 163 | ||
164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
165 | { | 165 | { |
166 | 166 | ||
167 | if (mSelStart == NOSELECTION) { | 167 | if (mSelStart == NOSELECTION) { |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | //cope with selection being out of matrix limits at top (< 0) | 171 | //cope with selection being out of matrix limits at top (< 0) |
172 | int i0 = mSelStart; | 172 | int i0 = mSelStart; |
173 | if (i0 < 0) { | 173 | if (i0 < 0) { |
174 | for (int i = i0; i < 0; i++) { | 174 | for (int i = i0; i < 0; i++) { |
175 | selDays.append(days[0].addDays(i)); | 175 | selDays.append(days[0].addDays(i)); |
176 | } | 176 | } |
177 | i0 = 0; | 177 | i0 = 0; |
178 | } | 178 | } |
179 | 179 | ||
180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
181 | if (mSelEnd > NUMDAYS-1) { | 181 | if (mSelEnd > NUMDAYS-1) { |
182 | for (int i = i0; i <= NUMDAYS-1; i++) { | 182 | for (int i = i0; i <= NUMDAYS-1; i++) { |
183 | selDays.append(days[i]); | 183 | selDays.append(days[i]); |
184 | } | 184 | } |
185 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 185 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
186 | selDays.append(days[0].addDays(i)); | 186 | selDays.append(days[0].addDays(i)); |
187 | } | 187 | } |
188 | 188 | ||
189 | // apply normal routine to selection being entirely within matrix limits | 189 | // apply normal routine to selection being entirely within matrix limits |
190 | } else { | 190 | } else { |
191 | for (int i = i0; i <= mSelEnd; i++) { | 191 | for (int i = i0; i <= mSelEnd; i++) { |
192 | selDays.append(days[i]); | 192 | selDays.append(days[i]); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
198 | { | 198 | { |
199 | mSelStart = startdate.daysTo(start); | 199 | mSelStart = startdate.daysTo(start); |
200 | mSelEnd = startdate.daysTo(end); | 200 | mSelEnd = startdate.daysTo(end); |
201 | } | 201 | } |
202 | void KODayMatrix::clearSelection() | 202 | void KODayMatrix::clearSelection() |
203 | { | 203 | { |
204 | mSelEnd = mSelStart = NOSELECTION; | 204 | mSelEnd = mSelStart = NOSELECTION; |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | void KODayMatrix::recalculateToday() | 208 | void KODayMatrix::recalculateToday() |
209 | { | 209 | { |
210 | today = -1; | 210 | today = -1; |
211 | for (int i=0; i<NUMDAYS; i++) { | 211 | for (int i=0; i<NUMDAYS; i++) { |
212 | events[i] = 0; | 212 | events[i] = 0; |
213 | days[i] = startdate.addDays(i); | 213 | days[i] = startdate.addDays(i); |
214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
215 | 215 | ||
216 | // if today is in the currently displayed month, hilight today | 216 | // if today is in the currently displayed month, hilight today |
217 | if (days[i].year() == QDate::currentDate().year() && | 217 | if (days[i].year() == QDate::currentDate().year() && |
218 | days[i].month() == QDate::currentDate().month() && | 218 | days[i].month() == QDate::currentDate().month() && |
219 | days[i].day() == QDate::currentDate().day()) { | 219 | days[i].day() == QDate::currentDate().day()) { |
220 | today = i; | 220 | today = i; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | // qDebug(QString("Today is visible at %1.").arg(today)); | 223 | // qDebug(QString("Today is visible at %1.").arg(today)); |
224 | } | 224 | } |
225 | 225 | ||
226 | void KODayMatrix::updateView() | 226 | void KODayMatrix::updateView() |
227 | { | 227 | { |
228 | updateView(startdate); | 228 | updateView(startdate); |
229 | } | 229 | } |
230 | void KODayMatrix::repaintViewTimed() | 230 | void KODayMatrix::repaintViewTimed() |
231 | { | 231 | { |
232 | mRepaintTimer->stop(); | 232 | mRepaintTimer->stop(); |
233 | repaint(false); | 233 | repaint(false); |
234 | } | 234 | } |
235 | void KODayMatrix::updateViewTimed() | 235 | void KODayMatrix::updateViewTimed() |
236 | { | 236 | { |
237 | mUpdateTimer->stop(); | 237 | mUpdateTimer->stop(); |
238 | if ( !mCalendar ) { | 238 | if ( !mCalendar ) { |
239 | qDebug("NOT CAL "); | 239 | qDebug("NOT CAL "); |
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | //qDebug("KODayMatrix::updateViewTimed "); | 242 | //qDebug("KODayMatrix::updateViewTimed "); |
243 | for(int i = 0; i < NUMDAYS; i++) { | 243 | for(int i = 0; i < NUMDAYS; i++) { |
244 | // if events are set for the day then remember to draw it bold | 244 | // if events are set for the day then remember to draw it bold |
245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
246 | Event *event; | 246 | Event *event; |
247 | int numEvents = eventlist.count(); | 247 | int numEvents = eventlist.count(); |
248 | QString holiStr = ""; | 248 | QString holiStr = ""; |
249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
250 | ushort recurType = event->recurrence()->doesRecur(); | 250 | ushort recurType = event->recurrence()->doesRecur(); |
251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
253 | numEvents--; | 253 | numEvents--; |
254 | } | 254 | } |
255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
256 | if ( !holiStr.isEmpty() ) | 256 | if ( !holiStr.isEmpty() ) |
257 | holiStr += "\n"; | 257 | holiStr += "\n"; |
258 | holiStr += event->summary(); | 258 | holiStr += event->summary(); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | events[i] = numEvents; | 261 | events[i] = numEvents; |
262 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 262 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
264 | !holiStr.isEmpty()) { | 264 | !holiStr.isEmpty()) { |
265 | mHolidays[i] = holiStr; | 265 | mHolidays[i] = holiStr; |
266 | } else { | 266 | } else { |
267 | mHolidays[i] = QString::null; | 267 | mHolidays[i] = QString::null; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | if ( ! mPendingUpdateBeforeRepaint ) | 270 | if ( ! mPendingUpdateBeforeRepaint ) |
271 | repaint(false); | 271 | repaint(false); |
272 | } | 272 | } |
273 | void KODayMatrix::updateView(QDate actdate) | 273 | void KODayMatrix::updateView(QDate actdate) |
274 | { | 274 | { |
275 | 275 | ||
276 | if ( ! actdate.isValid() ) { | 276 | if ( ! actdate.isValid() ) { |
277 | //qDebug("date not valid "); | 277 | //qDebug("date not valid "); |
278 | return; | 278 | return; |
279 | } | 279 | } |
280 | mDayChanged = false; | 280 | mDayChanged = false; |
281 | //flag to indicate if the starting day of the matrix has changed by this call | 281 | //flag to indicate if the starting day of the matrix has changed by this call |
282 | //mDayChanged = false; | 282 | //mDayChanged = false; |
283 | // if a new startdate is to be set then apply Cornelius's calculation | 283 | // if a new startdate is to be set then apply Cornelius's calculation |
284 | // of the first day to be shown | 284 | // of the first day to be shown |
285 | if (actdate != startdate) { | 285 | if (actdate != startdate) { |
286 | // reset index of selection according to shift of starting date from startdate to actdate | 286 | // reset index of selection according to shift of starting date from startdate to actdate |
287 | if (mSelStart != NOSELECTION) { | 287 | if (mSelStart != NOSELECTION) { |
288 | int tmp = actdate.daysTo(startdate); | 288 | int tmp = actdate.daysTo(startdate); |
289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
290 | // shift selection if new one would be visible at least partly ! | 290 | // shift selection if new one would be visible at least partly ! |
291 | 291 | ||
292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
293 | // nested if is required for next X display pushed from a different month - correction required | 293 | // nested if is required for next X display pushed from a different month - correction required |
294 | // otherwise, for month forward and backward, it must be avoided | 294 | // otherwise, for month forward and backward, it must be avoided |
295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
296 | mSelStart = mSelStart + tmp; | 296 | mSelStart = mSelStart + tmp; |
297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
298 | mSelEnd = mSelEnd + tmp; | 298 | mSelEnd = mSelEnd + tmp; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | startdate = actdate; | 301 | startdate = actdate; |
302 | mDayChanged = true; | 302 | mDayChanged = true; |
303 | recalculateToday(); | 303 | recalculateToday(); |
304 | } | 304 | } |
305 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 305 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
306 | if ( !isVisible() ) { | 306 | if ( !isVisible() ) { |
307 | mPendingUpdateBeforeRepaint = true; | 307 | mPendingUpdateBeforeRepaint = true; |
308 | } else { | 308 | } else { |
309 | #ifdef DESKTOP_VERSION | 309 | #ifdef DESKTOP_VERSION |
310 | //mRepaintTimer->start( 250 ); | 310 | //mRepaintTimer->start( 250 ); |
311 | mUpdateTimer->start( 250 ); | 311 | mUpdateTimer->start( 250 ); |
312 | #else | 312 | #else |
313 | mRepaintTimer->start( 350 ); | 313 | mRepaintTimer->start( 350 ); |
314 | mUpdateTimer->start( 2000 ); | 314 | mUpdateTimer->start( 2000 ); |
315 | #endif | 315 | #endif |
316 | } | 316 | } |
317 | } | 317 | } |
318 | void KODayMatrix::updateEvents() | 318 | void KODayMatrix::updateEvents() |
319 | { | 319 | { |
320 | if ( !mCalendar ) return; | 320 | if ( !mCalendar ) return; |
321 | 321 | ||
322 | for( int i = 0; i < NUMDAYS; i++ ) { | 322 | for( int i = 0; i < NUMDAYS; i++ ) { |
323 | // if events are set for the day then remember to draw it bold | 323 | // if events are set for the day then remember to draw it bold |
324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
325 | int numEvents = eventlist.count(); | 325 | int numEvents = eventlist.count(); |
326 | Event *event; | 326 | Event *event; |
327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
328 | ushort recurType = event->doesRecur(); | 328 | ushort recurType = event->doesRecur(); |
329 | 329 | ||
330 | if ( ( recurType == Recurrence::rDaily && | 330 | if ( ( recurType == Recurrence::rDaily && |
331 | !KOPrefs::instance()->mDailyRecur ) || | 331 | !KOPrefs::instance()->mDailyRecur ) || |
332 | ( recurType == Recurrence::rWeekly && | 332 | ( recurType == Recurrence::rWeekly && |
333 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 333 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
334 | numEvents--; | 334 | numEvents--; |
335 | } | 335 | } |
336 | } | 336 | } |
337 | events[ i ] = numEvents; | 337 | events[ i ] = numEvents; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | const QDate& KODayMatrix::getDate(int offset) | 341 | const QDate& KODayMatrix::getDate(int offset) |
342 | { | 342 | { |
343 | if (offset < 0 || offset > NUMDAYS-1) { | 343 | if (offset < 0 || offset > NUMDAYS-1) { |
344 | qDebug("Wrong offset2 "); | 344 | qDebug("Wrong offset2 "); |
345 | return days[0]; | 345 | return days[0]; |
346 | } | 346 | } |
347 | return days[offset]; | 347 | return days[offset]; |
348 | } | 348 | } |
349 | 349 | ||
350 | QString KODayMatrix::getHolidayLabel(int offset) | 350 | QString KODayMatrix::getHolidayLabel(int offset) |
351 | { | 351 | { |
352 | if (offset < 0 || offset > NUMDAYS-1) { | 352 | if (offset < 0 || offset > NUMDAYS-1) { |
353 | qDebug("Wrong offset1 "); | 353 | qDebug("Wrong offset1 "); |
354 | return 0; | 354 | return 0; |
355 | } | 355 | } |
356 | return mHolidays[offset]; | 356 | return mHolidays[offset]; |
357 | } | 357 | } |
358 | 358 | ||
359 | int KODayMatrix::getDayIndexFrom(int x, int y) | 359 | int KODayMatrix::getDayIndexFrom(int x, int y) |
360 | { | 360 | { |
361 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 361 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
362 | 6 - x/daysize.width() : x/daysize.width()); | 362 | 6 - x/daysize.width() : x/daysize.width()); |
363 | } | 363 | } |
364 | 364 | ||
365 | // ---------------------------------------------------------------------------- | 365 | // ---------------------------------------------------------------------------- |
366 | // M O U S E E V E N T H A N D L I N G | 366 | // M O U S E E V E N T H A N D L I N G |
367 | // ---------------------------------------------------------------------------- | 367 | // ---------------------------------------------------------------------------- |
368 | 368 | ||
369 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 369 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
370 | { | 370 | { |
371 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 371 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
372 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 372 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
373 | mSelInit = mSelStart; | 373 | mSelInit = mSelStart; |
374 | } | 374 | } |
375 | 375 | ||
376 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 376 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
377 | { | 377 | { |
378 | 378 | ||
379 | int tmp = getDayIndexFrom(e->x(), e->y()); | 379 | int tmp = getDayIndexFrom(e->x(), e->y()); |
380 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 380 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
381 | 381 | ||
382 | if (mSelInit > tmp) { | 382 | if (mSelInit > tmp) { |
383 | mSelEnd = mSelInit; | 383 | mSelEnd = mSelInit; |
384 | if (tmp != mSelStart) { | 384 | if (tmp != mSelStart) { |
385 | mSelStart = tmp; | 385 | mSelStart = tmp; |
386 | repaint(false); | 386 | repaint(false); |
387 | } | 387 | } |
388 | } else { | 388 | } else { |
389 | mSelStart = mSelInit; | 389 | mSelStart = mSelInit; |
390 | 390 | ||
391 | //repaint only if selection has changed | 391 | //repaint only if selection has changed |
392 | if (tmp != mSelEnd) { | 392 | if (tmp != mSelEnd) { |
393 | mSelEnd = tmp; | 393 | mSelEnd = tmp; |
394 | repaint(false); | 394 | repaint(false); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | DateList daylist; | 398 | DateList daylist; |
399 | if ( mSelStart < 0 ) | 399 | if ( mSelStart < 0 ) |
400 | mSelStart = 0; | 400 | mSelStart = 0; |
401 | for (int i = mSelStart; i <= mSelEnd; i++) { | 401 | for (int i = mSelStart; i <= mSelEnd; i++) { |
402 | daylist.append(days[i]); | 402 | daylist.append(days[i]); |
403 | } | 403 | } |
404 | emit selected((const DateList)daylist); | 404 | emit selected((const DateList)daylist); |
405 | 405 | ||
406 | } | 406 | } |
407 | 407 | ||
408 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 408 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
409 | { | 409 | { |
410 | int tmp = getDayIndexFrom(e->x(), e->y()); | 410 | int tmp = getDayIndexFrom(e->x(), e->y()); |
411 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 411 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
412 | 412 | ||
413 | if (mSelInit > tmp) { | 413 | if (mSelInit > tmp) { |
414 | mSelEnd = mSelInit; | 414 | mSelEnd = mSelInit; |
415 | if (tmp != mSelStart) { | 415 | if (tmp != mSelStart) { |
416 | mSelStart = tmp; | 416 | mSelStart = tmp; |
417 | repaint(false); | 417 | repaint(false); |
418 | } | 418 | } |
419 | } else { | 419 | } else { |
420 | mSelStart = mSelInit; | 420 | mSelStart = mSelInit; |
421 | 421 | ||
422 | //repaint only if selection has changed | 422 | //repaint only if selection has changed |
423 | if (tmp != mSelEnd) { | 423 | if (tmp != mSelEnd) { |
424 | mSelEnd = tmp; | 424 | mSelEnd = tmp; |
425 | repaint(false); | 425 | repaint(false); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | } | 428 | } |
429 | 429 | ||
430 | // ---------------------------------------------------------------------------- | 430 | // ---------------------------------------------------------------------------- |
431 | // D R A G ' N D R O P H A N D L I N G | 431 | // D R A G ' N D R O P H A N D L I N G |
432 | // ---------------------------------------------------------------------------- | 432 | // ---------------------------------------------------------------------------- |
433 | 433 | ||
434 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 434 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
435 | { | 435 | { |
436 | #ifndef KORG_NODND | 436 | #ifndef KORG_NODND |
437 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 437 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
438 | e->ignore(); | 438 | e->ignore(); |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | 441 | ||
442 | // some visual feedback | 442 | // some visual feedback |
443 | // oldPalette = palette(); | 443 | // oldPalette = palette(); |
444 | // setPalette(my_HilitePalette); | 444 | // setPalette(my_HilitePalette); |
445 | // update(); | 445 | // update(); |
446 | #endif | 446 | #endif |
447 | } | 447 | } |
448 | 448 | ||
449 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 449 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
450 | { | 450 | { |
451 | #ifndef KORG_NODND | 451 | #ifndef KORG_NODND |
452 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 452 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
453 | e->ignore(); | 453 | e->ignore(); |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | 456 | ||
457 | e->accept(); | 457 | e->accept(); |
458 | #endif | 458 | #endif |
459 | } | 459 | } |
460 | 460 | ||
461 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 461 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
462 | { | 462 | { |
463 | #ifndef KORG_NODND | 463 | #ifndef KORG_NODND |
464 | // setPalette(oldPalette); | 464 | // setPalette(oldPalette); |
465 | // update(); | 465 | // update(); |
466 | #endif | 466 | #endif |
467 | } | 467 | } |
468 | 468 | ||
469 | void KODayMatrix::dropEvent(QDropEvent *e) | 469 | void KODayMatrix::dropEvent(QDropEvent *e) |
470 | { | 470 | { |
471 | #ifndef KORG_NODND | 471 | #ifndef KORG_NODND |
472 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 472 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
473 | 473 | ||
474 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 474 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
475 | e->ignore(); | 475 | e->ignore(); |
476 | return; | 476 | return; |
477 | } | 477 | } |
478 | 478 | ||
479 | DndFactory factory( mCalendar ); | 479 | DndFactory factory( mCalendar ); |
480 | Event *event = factory.createDrop(e); | 480 | Event *event = factory.createDrop(e); |
481 | 481 | ||
482 | if (event) { | 482 | if (event) { |
483 | e->acceptAction(); | 483 | e->acceptAction(); |
484 | 484 | ||
485 | Event *existingEvent = mCalendar->event(event->uid()); | 485 | Event *existingEvent = mCalendar->event(event->uid()); |
486 | 486 | ||
487 | if(existingEvent) { | 487 | if(existingEvent) { |
488 | // uniquify event | 488 | // uniquify event |
489 | event->recreate(); | 489 | event->recreate(); |
490 | /* | 490 | /* |
491 | KMessageBox::sorry(this, | 491 | KMessageBox::sorry(this, |
492 | i18n("Event already exists in this calendar."), | 492 | i18n("Event already exists in this calendar."), |
493 | i18n("Drop Event")); | 493 | i18n("Drop Event")); |
494 | delete event; | 494 | delete event; |
495 | return; | 495 | return; |
496 | */ | 496 | */ |
497 | } | 497 | } |
498 | // kdDebug() << "Drop new Event" << endl; | 498 | // kdDebug() << "Drop new Event" << endl; |
499 | // Adjust date | 499 | // Adjust date |
500 | QDateTime start = event->dtStart(); | 500 | QDateTime start = event->dtStart(); |
501 | QDateTime end = event->dtEnd(); | 501 | QDateTime end = event->dtEnd(); |
502 | int duration = start.daysTo(end); | 502 | int duration = start.daysTo(end); |
503 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 503 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
504 | 504 | ||
505 | start.setDate(days[idx]); | 505 | start.setDate(days[idx]); |
506 | end.setDate(days[idx].addDays(duration)); | 506 | end.setDate(days[idx].addDays(duration)); |
507 | 507 | ||
508 | event->setDtStart(start); | 508 | event->setDtStart(start); |
509 | event->setDtEnd(end); | 509 | event->setDtEnd(end); |
510 | mCalendar->addEvent(event); | 510 | mCalendar->addEvent(event); |
511 | 511 | ||
512 | emit eventDropped(event); | 512 | emit eventDropped(event); |
513 | } else { | 513 | } else { |
514 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 514 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
515 | e->ignore(); | 515 | e->ignore(); |
516 | } | 516 | } |
517 | #endif | 517 | #endif |
518 | } | 518 | } |
519 | 519 | ||
520 | // ---------------------------------------------------------------------------- | 520 | // ---------------------------------------------------------------------------- |
521 | // P A I N T E V E N T H A N D L I N G | 521 | // P A I N T E V E N T H A N D L I N G |
522 | // ---------------------------------------------------------------------------- | 522 | // ---------------------------------------------------------------------------- |
523 | 523 | ||
524 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 524 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
525 | { | 525 | { |
526 | if ( width() <= 0 || height() <= 0 ) | 526 | if ( width() <= 0 || height() <= 0 ) |
527 | return; | 527 | return; |
528 | if ( mPendingUpdateBeforeRepaint ) { | 528 | if ( mPendingUpdateBeforeRepaint ) { |
529 | updateViewTimed(); | 529 | updateViewTimed(); |
530 | mPendingUpdateBeforeRepaint = false; | 530 | mPendingUpdateBeforeRepaint = false; |
531 | } | 531 | } |
532 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 532 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
533 | myPix.resize(size() ); | 533 | myPix.resize(size() ); |
534 | } | 534 | } |
535 | QPainter p(&myPix); | 535 | QPainter p(&myPix); |
536 | p.setFont(font()); | 536 | p.setFont(font()); |
537 | 537 | ||
538 | QRect sz = frameRect(); | 538 | QRect sz = frameRect(); |
539 | int dheight = daysize.height(); | 539 | int dheight = daysize.height(); |
540 | int dwidth = daysize.width(); | 540 | int dwidth = daysize.width(); |
541 | int row,col; | 541 | int row,col; |
542 | int selw, selh; | 542 | int selw, selh; |
543 | bool isRTL = KOGlobals::self()->reverseLayout(); | 543 | bool isRTL = KOGlobals::self()->reverseLayout(); |
544 | 544 | ||
545 | // draw background and topleft frame | 545 | // draw background and topleft frame |
546 | p.fillRect(pevent->rect(), mDefaultBackColor); | 546 | p.fillRect(pevent->rect(), mDefaultBackColor); |
547 | p.setPen(mDefaultTextColor); | 547 | p.setPen(mDefaultTextColor); |
548 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 548 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
549 | 549 | ||
550 | // draw selected days with highlighted background color | 550 | // draw selected days with highlighted background color |
551 | if (mSelStart != NOSELECTION) { | 551 | if (mSelStart != NOSELECTION) { |
552 | 552 | ||
553 | row = mSelStart/7; | 553 | row = mSelStart/7; |
554 | col = mSelStart -row*7; | 554 | col = mSelStart -row*7; |
555 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 555 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
556 | 556 | ||
557 | if (row == mSelEnd/7) { | 557 | if (row == mSelEnd/7) { |
558 | // Single row selection | 558 | // Single row selection |
559 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 559 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
560 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 560 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
561 | } else { | 561 | } else { |
562 | // draw first row to the right | 562 | // draw first row to the right |
563 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 563 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
564 | dheight, selcol); | 564 | dheight, selcol); |
565 | // draw full block till last line | 565 | // draw full block till last line |
566 | selh = mSelEnd/7-row; | 566 | selh = mSelEnd/7-row; |
567 | if (selh > 1) { | 567 | if (selh > 1) { |
568 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 568 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
569 | } | 569 | } |
570 | // draw last block from left to mSelEnd | 570 | // draw last block from left to mSelEnd |
571 | selw = mSelEnd-7*(mSelEnd/7)+1; | 571 | selw = mSelEnd-7*(mSelEnd/7)+1; |
572 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 572 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
573 | selw*dwidth, dheight, selcol); | 573 | selw*dwidth, dheight, selcol); |
574 | } | 574 | } |
575 | } | 575 | } |
576 | 576 | ||
577 | // iterate over all days in the matrix and draw the day label in appropriate colors | 577 | // iterate over all days in the matrix and draw the day label in appropriate colors |
578 | QColor actcol = mDefaultTextColorShaded; | 578 | QColor actcol = mDefaultTextColorShaded; |
579 | p.setPen(actcol); | 579 | p.setPen(actcol); |
580 | QPen tmppen; | 580 | QPen tmppen; |
581 | for(int i = 0; i < NUMDAYS; i++) { | 581 | for(int i = 0; i < NUMDAYS; i++) { |
582 | row = i/7; | 582 | row = i/7; |
583 | col = isRTL ? 6-(i-row*7) : i-row*7; | 583 | col = isRTL ? 6-(i-row*7) : i-row*7; |
584 | 584 | ||
585 | // if it is the first day of a month switch color from normal to shaded and vice versa | 585 | // if it is the first day of a month switch color from normal to shaded and vice versa |
586 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 586 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
587 | if (actcol == mDefaultTextColorShaded) { | 587 | if (actcol == mDefaultTextColorShaded) { |
588 | actcol = mDefaultTextColor; | 588 | actcol = mDefaultTextColor; |