summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
-rw-r--r--korganizer/datenavigatorcontainer.cpp2
2 files changed, 3 insertions, 19 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8100e25..9a4e719 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1500,808 +1500,792 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
1500 //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() ); 1500 //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() );
1501 1501
1502 if ( birthday.isValid() ){ 1502 if ( birthday.isValid() ){
1503 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1503 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1504 KCal::Attendee::ReqParticipant,uid) ; 1504 KCal::Attendee::ReqParticipant,uid) ;
1505 if ( addAnniversary( birthday, assembledName, a, true ) ) 1505 if ( addAnniversary( birthday, assembledName, a, true ) )
1506 ++addCount; 1506 ++addCount;
1507 } 1507 }
1508 1508
1509 if ( anniversary.isValid() ){ 1509 if ( anniversary.isValid() ){
1510 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1510 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1511 KCal::Attendee::ReqParticipant,uid) ; 1511 KCal::Attendee::ReqParticipant,uid) ;
1512 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1512 if ( addAnniversary( anniversary, assembledName, a, false ) )
1513 ++addCount; 1513 ++addCount;
1514 } 1514 }
1515 } 1515 }
1516 1516
1517 updateView(); 1517 updateView();
1518 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1518 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1519 1519
1520 } 1520 }
1521 1521
1522} 1522}
1523 1523
1524 1524
1525 1525
1526bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1526bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1527{ 1527{
1528 //qDebug("addAnni "); 1528 //qDebug("addAnni ");
1529 Event * ev = new Event(); 1529 Event * ev = new Event();
1530 ev->setOrganizer(KOPrefs::instance()->email()); 1530 ev->setOrganizer(KOPrefs::instance()->email());
1531 if ( a ) { 1531 if ( a ) {
1532 ev->addAttendee( a ); 1532 ev->addAttendee( a );
1533 } 1533 }
1534 QString kind; 1534 QString kind;
1535 if ( birthday ) { 1535 if ( birthday ) {
1536 kind = i18n( "Birthday" ); 1536 kind = i18n( "Birthday" );
1537 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1537 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1538 } 1538 }
1539 else { 1539 else {
1540 kind = i18n( "Anniversary" ); 1540 kind = i18n( "Anniversary" );
1541 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1541 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1542 } 1542 }
1543 ev->setCategories( kind ); 1543 ev->setCategories( kind );
1544 ev->setDtStart( QDateTime(date) ); 1544 ev->setDtStart( QDateTime(date) );
1545 ev->setDtEnd( QDateTime(date) ); 1545 ev->setDtEnd( QDateTime(date) );
1546 ev->setFloats( true ); 1546 ev->setFloats( true );
1547 Recurrence * rec = ev->recurrence(); 1547 Recurrence * rec = ev->recurrence();
1548 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1548 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1549 rec->addYearlyNum( date.month() ); 1549 rec->addYearlyNum( date.month() );
1550 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1550 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1551 delete ev; 1551 delete ev;
1552 return false; 1552 return false;
1553 } 1553 }
1554 return true; 1554 return true;
1555 1555
1556} 1556}
1557bool CalendarView::importQtopia( const QString &categories, 1557bool CalendarView::importQtopia( const QString &categories,
1558 const QString &datebook, 1558 const QString &datebook,
1559 const QString &todolist ) 1559 const QString &todolist )
1560{ 1560{
1561 1561
1562 QtopiaFormat qtopiaFormat; 1562 QtopiaFormat qtopiaFormat;
1563 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1563 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1564 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1564 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1565 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1565 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1566 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1566 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1567 1567
1568 updateView(); 1568 updateView();
1569 return true; 1569 return true;
1570 1570
1571#if 0 1571#if 0
1572 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1572 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1573 mCurrentSyncDevice = "qtopia-XML"; 1573 mCurrentSyncDevice = "qtopia-XML";
1574 if ( mSyncManager->mAskForPreferences ) 1574 if ( mSyncManager->mAskForPreferences )
1575 edit_sync_options(); 1575 edit_sync_options();
1576 qApp->processEvents(); 1576 qApp->processEvents();
1577 CalendarLocal* calendar = new CalendarLocal(); 1577 CalendarLocal* calendar = new CalendarLocal();
1578 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1578 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1579 bool syncOK = false; 1579 bool syncOK = false;
1580 QtopiaFormat qtopiaFormat; 1580 QtopiaFormat qtopiaFormat;
1581 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1581 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1582 bool loadOk = true; 1582 bool loadOk = true;
1583 if ( !categories.isEmpty() ) 1583 if ( !categories.isEmpty() )
1584 loadOk = qtopiaFormat.load( calendar, categories ); 1584 loadOk = qtopiaFormat.load( calendar, categories );
1585 if ( loadOk && !datebook.isEmpty() ) 1585 if ( loadOk && !datebook.isEmpty() )
1586 loadOk = qtopiaFormat.load( calendar, datebook ); 1586 loadOk = qtopiaFormat.load( calendar, datebook );
1587 if ( loadOk && !todolist.isEmpty() ) 1587 if ( loadOk && !todolist.isEmpty() )
1588 loadOk = qtopiaFormat.load( calendar, todolist ); 1588 loadOk = qtopiaFormat.load( calendar, todolist );
1589 1589
1590 if ( loadOk ) { 1590 if ( loadOk ) {
1591 getEventViewerDialog()->setSyncMode( true ); 1591 getEventViewerDialog()->setSyncMode( true );
1592 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1592 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1593 getEventViewerDialog()->setSyncMode( false ); 1593 getEventViewerDialog()->setSyncMode( false );
1594 qApp->processEvents(); 1594 qApp->processEvents();
1595 if ( syncOK ) { 1595 if ( syncOK ) {
1596 if ( mSyncManager->mWriteBackFile ) 1596 if ( mSyncManager->mWriteBackFile )
1597 { 1597 {
1598 // write back XML file 1598 // write back XML file
1599 1599
1600 } 1600 }
1601 setModified( true ); 1601 setModified( true );
1602 } 1602 }
1603 } else { 1603 } else {
1604 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1604 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1605 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1605 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1606 question, i18n("Ok")) ; 1606 question, i18n("Ok")) ;
1607 } 1607 }
1608 delete calendar; 1608 delete calendar;
1609 updateView(); 1609 updateView();
1610 return syncOK; 1610 return syncOK;
1611 1611
1612 1612
1613#endif 1613#endif
1614 1614
1615} 1615}
1616 1616
1617void CalendarView::setSyncEventsReadOnly() 1617void CalendarView::setSyncEventsReadOnly()
1618{ 1618{
1619 Event * ev; 1619 Event * ev;
1620 QPtrList<Event> eL = mCalendar->rawEvents(); 1620 QPtrList<Event> eL = mCalendar->rawEvents();
1621 ev = eL.first(); 1621 ev = eL.first();
1622 while ( ev ) { 1622 while ( ev ) {
1623 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1623 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1624 ev->setReadOnly( true ); 1624 ev->setReadOnly( true );
1625 ev = eL.next(); 1625 ev = eL.next();
1626 } 1626 }
1627} 1627}
1628bool CalendarView::openCalendar(QString filename, bool merge) 1628bool CalendarView::openCalendar(QString filename, bool merge)
1629{ 1629{
1630 1630
1631 if (filename.isEmpty()) { 1631 if (filename.isEmpty()) {
1632 return false; 1632 return false;
1633 } 1633 }
1634 1634
1635 if (!QFile::exists(filename)) { 1635 if (!QFile::exists(filename)) {
1636 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1636 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1637 return false; 1637 return false;
1638 } 1638 }
1639 1639
1640 globalFlagBlockAgenda = 1; 1640 globalFlagBlockAgenda = 1;
1641 if (!merge) mCalendar->close(); 1641 if (!merge) mCalendar->close();
1642 1642
1643 mStorage->setFileName( filename ); 1643 mStorage->setFileName( filename );
1644 1644
1645 if ( mStorage->load() ) { 1645 if ( mStorage->load() ) {
1646 if ( merge ) ;//setModified( true ); 1646 if ( merge ) ;//setModified( true );
1647 else { 1647 else {
1648 //setModified( true ); 1648 //setModified( true );
1649 mViewManager->setDocumentId( filename ); 1649 mViewManager->setDocumentId( filename );
1650 mDialogManager->setDocumentId( filename ); 1650 mDialogManager->setDocumentId( filename );
1651 mTodoList->setDocumentId( filename ); 1651 mTodoList->setDocumentId( filename );
1652 } 1652 }
1653 globalFlagBlockAgenda = 2; 1653 globalFlagBlockAgenda = 2;
1654 // if ( getLastSyncEvent() ) 1654 // if ( getLastSyncEvent() )
1655 // getLastSyncEvent()->setReadOnly( true ); 1655 // getLastSyncEvent()->setReadOnly( true );
1656 mCalendar->reInitAlarmSettings(); 1656 mCalendar->reInitAlarmSettings();
1657 setSyncEventsReadOnly(); 1657 setSyncEventsReadOnly();
1658 updateUnmanagedViews(); 1658 updateUnmanagedViews();
1659 updateView(); 1659 updateView();
1660 if ( filename != MainWindow::defaultFileName() ) { 1660 if ( filename != MainWindow::defaultFileName() ) {
1661 saveCalendar( MainWindow::defaultFileName() ); 1661 saveCalendar( MainWindow::defaultFileName() );
1662 } else { 1662 } else {
1663 QFileInfo finf ( MainWindow::defaultFileName()); 1663 QFileInfo finf ( MainWindow::defaultFileName());
1664 if ( finf.exists() ) { 1664 if ( finf.exists() ) {
1665 setLoadedFileVersion( finf.lastModified () ); 1665 setLoadedFileVersion( finf.lastModified () );
1666 } 1666 }
1667 } 1667 }
1668 return true; 1668 return true;
1669 } else { 1669 } else {
1670 // while failing to load, the calendar object could 1670 // while failing to load, the calendar object could
1671 // have become partially populated. Clear it out. 1671 // have become partially populated. Clear it out.
1672 if ( !merge ) { 1672 if ( !merge ) {
1673 mCalendar->close(); 1673 mCalendar->close();
1674 mViewManager->setDocumentId( filename ); 1674 mViewManager->setDocumentId( filename );
1675 mDialogManager->setDocumentId( filename ); 1675 mDialogManager->setDocumentId( filename );
1676 mTodoList->setDocumentId( filename ); 1676 mTodoList->setDocumentId( filename );
1677 } 1677 }
1678 1678
1679 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1679 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1680 1680
1681 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1681 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1682 globalFlagBlockAgenda = 2; 1682 globalFlagBlockAgenda = 2;
1683 mCalendar->reInitAlarmSettings(); 1683 mCalendar->reInitAlarmSettings();
1684 setSyncEventsReadOnly(); 1684 setSyncEventsReadOnly();
1685 updateUnmanagedViews(); 1685 updateUnmanagedViews();
1686 updateView(); 1686 updateView();
1687 } 1687 }
1688 return false; 1688 return false;
1689} 1689}
1690void CalendarView::showOpenError() 1690void CalendarView::showOpenError()
1691{ 1691{
1692 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1692 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1693} 1693}
1694void CalendarView::setLoadedFileVersion(QDateTime dt) 1694void CalendarView::setLoadedFileVersion(QDateTime dt)
1695{ 1695{
1696 loadedFileVersion = dt; 1696 loadedFileVersion = dt;
1697} 1697}
1698bool CalendarView::checkFileChanged(QString fn) 1698bool CalendarView::checkFileChanged(QString fn)
1699{ 1699{
1700 QFileInfo finf ( fn ); 1700 QFileInfo finf ( fn );
1701 if ( !finf.exists() ) 1701 if ( !finf.exists() )
1702 return true; 1702 return true;
1703 QDateTime dt = finf.lastModified (); 1703 QDateTime dt = finf.lastModified ();
1704 if ( dt <= loadedFileVersion ) 1704 if ( dt <= loadedFileVersion )
1705 return false; 1705 return false;
1706 return true; 1706 return true;
1707 1707
1708} 1708}
1709void CalendarView::watchSavedFile() 1709void CalendarView::watchSavedFile()
1710{ 1710{
1711 QFileInfo finf ( MainWindow::defaultFileName()); 1711 QFileInfo finf ( MainWindow::defaultFileName());
1712 if ( !finf.exists() ) 1712 if ( !finf.exists() )
1713 return; 1713 return;
1714 QDateTime dt = finf.lastModified (); 1714 QDateTime dt = finf.lastModified ();
1715 if ( dt < loadedFileVersion ) { 1715 if ( dt < loadedFileVersion ) {
1716 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1716 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1717 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1717 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1718 return; 1718 return;
1719 } 1719 }
1720 loadedFileVersion = dt; 1720 loadedFileVersion = dt;
1721} 1721}
1722 1722
1723bool CalendarView::checkFileVersion(QString fn) 1723bool CalendarView::checkFileVersion(QString fn)
1724{ 1724{
1725 QFileInfo finf ( fn ); 1725 QFileInfo finf ( fn );
1726 if ( !finf.exists() ) 1726 if ( !finf.exists() )
1727 return true; 1727 return true;
1728 QDateTime dt = finf.lastModified (); 1728 QDateTime dt = finf.lastModified ();
1729 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1729 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1730 //qDebug("file on disk version %s",dt.toString().latin1()); 1730 //qDebug("file on disk version %s",dt.toString().latin1());
1731 if ( dt <= loadedFileVersion ) 1731 if ( dt <= loadedFileVersion )
1732 return true; 1732 return true;
1733 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)) , 1733 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)) ,
1734 i18n("KO/Pi Warning"),i18n("Overwrite"), 1734 i18n("KO/Pi Warning"),i18n("Overwrite"),
1735 i18n("Sync+save")); 1735 i18n("Sync+save"));
1736 1736
1737 if ( km == KMessageBox::Cancel ) 1737 if ( km == KMessageBox::Cancel )
1738 return false; 1738 return false;
1739 if ( km == KMessageBox::Yes ) 1739 if ( km == KMessageBox::Yes )
1740 return true; 1740 return true;
1741 1741
1742 setSyncDevice("deleteaftersync" ); 1742 setSyncDevice("deleteaftersync" );
1743 mSyncManager->mAskForPreferences = true; 1743 mSyncManager->mAskForPreferences = true;
1744 mSyncManager->mSyncAlgoPrefs = 3; 1744 mSyncManager->mSyncAlgoPrefs = 3;
1745 mSyncManager->mWriteBackFile = false; 1745 mSyncManager->mWriteBackFile = false;
1746 mSyncManager->mWriteBackExistingOnly = false; 1746 mSyncManager->mWriteBackExistingOnly = false;
1747 mSyncManager->mShowSyncSummary = false; 1747 mSyncManager->mShowSyncSummary = false;
1748 syncCalendar( fn, 3 ); 1748 syncCalendar( fn, 3 );
1749 Event * e = getLastSyncEvent(); 1749 Event * e = getLastSyncEvent();
1750 mCalendar->deleteEvent ( e ); 1750 mCalendar->deleteEvent ( e );
1751 updateView(); 1751 updateView();
1752 return true; 1752 return true;
1753} 1753}
1754 1754
1755bool CalendarView::saveCalendar( QString filename ) 1755bool CalendarView::saveCalendar( QString filename )
1756{ 1756{
1757 1757
1758 // Store back all unsaved data into calendar object 1758 // Store back all unsaved data into calendar object
1759 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1759 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1760 if ( mViewManager->currentView() ) 1760 if ( mViewManager->currentView() )
1761 mViewManager->currentView()->flushView(); 1761 mViewManager->currentView()->flushView();
1762 1762
1763 1763
1764 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1764 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1765 mStorage->setSaveFormat( new ICalFormat() ); 1765 mStorage->setSaveFormat( new ICalFormat() );
1766 mStorage->setFileName( filename ); 1766 mStorage->setFileName( filename );
1767 bool success; 1767 bool success;
1768 success = mStorage->save(); 1768 success = mStorage->save();
1769 if ( !success ) { 1769 if ( !success ) {
1770 return false; 1770 return false;
1771 } 1771 }
1772 if ( filename == MainWindow::defaultFileName() ) { 1772 if ( filename == MainWindow::defaultFileName() ) {
1773 setLoadedFileVersion( lfv ); 1773 setLoadedFileVersion( lfv );
1774 watchSavedFile(); 1774 watchSavedFile();
1775 } 1775 }
1776 return true; 1776 return true;
1777} 1777}
1778 1778
1779void CalendarView::closeCalendar() 1779void CalendarView::closeCalendar()
1780{ 1780{
1781 1781
1782 // child windows no longer valid 1782 // child windows no longer valid
1783 emit closingDown(); 1783 emit closingDown();
1784 1784
1785 mCalendar->close(); 1785 mCalendar->close();
1786 setModified(false); 1786 setModified(false);
1787 updateView(); 1787 updateView();
1788} 1788}
1789 1789
1790void CalendarView::archiveCalendar() 1790void CalendarView::archiveCalendar()
1791{ 1791{
1792 mDialogManager->showArchiveDialog(); 1792 mDialogManager->showArchiveDialog();
1793} 1793}
1794 1794
1795 1795
1796void CalendarView::readSettings() 1796void CalendarView::readSettings()
1797{ 1797{
1798 1798
1799 1799
1800 // mViewManager->showAgendaView(); 1800 // mViewManager->showAgendaView();
1801 QString str; 1801 QString str;
1802 //qDebug("CalendarView::readSettings() "); 1802 //qDebug("CalendarView::readSettings() ");
1803 // read settings from the KConfig, supplying reasonable 1803 // read settings from the KConfig, supplying reasonable
1804 // defaults where none are to be found 1804 // defaults where none are to be found
1805 KConfig *config = KOGlobals::config(); 1805 KConfig *config = KOGlobals::config();
1806#ifndef KORG_NOSPLITTER 1806#ifndef KORG_NOSPLITTER
1807 config->setGroup("KOrganizer Geometry"); 1807 config->setGroup("KOrganizer Geometry");
1808 1808
1809 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1809 QValueList<int> sizes = config->readIntListEntry("Separator1");
1810 if (sizes.count() != 2) { 1810 if (sizes.count() != 2) {
1811 sizes << mDateNavigator->minimumSizeHint().width(); 1811 sizes << mDateNavigator->minimumSizeHint().width();
1812 sizes << 300; 1812 sizes << 300;
1813 } 1813 }
1814 mPanner->setSizes(sizes); 1814 mPanner->setSizes(sizes);
1815 1815
1816 sizes = config->readIntListEntry("Separator2"); 1816 sizes = config->readIntListEntry("Separator2");
1817 if ( ( mResourceView && sizes.count() == 4 ) || 1817 if ( ( mResourceView && sizes.count() == 4 ) ||
1818 ( !mResourceView && sizes.count() == 3 ) ) { 1818 ( !mResourceView && sizes.count() == 3 ) ) {
1819 mLeftSplitter->setSizes(sizes); 1819 mLeftSplitter->setSizes(sizes);
1820 } 1820 }
1821#endif 1821#endif
1822 globalFlagBlockAgenda = 1; 1822 globalFlagBlockAgenda = 1;
1823 mViewManager->showAgendaView(); 1823 mViewManager->showAgendaView();
1824 //mViewManager->readSettings( config ); 1824 //mViewManager->readSettings( config );
1825 mTodoList->restoreLayout(config,QString("Todo Layout")); 1825 mTodoList->restoreLayout(config,QString("Todo Layout"));
1826 readFilterSettings(config); 1826 readFilterSettings(config);
1827 1827
1828#ifdef DESKTOP_VERSION 1828#ifdef DESKTOP_VERSION
1829 config->setGroup("WidgetLayout"); 1829 config->setGroup("WidgetLayout");
1830 QStringList list; 1830 QStringList list;
1831 list = config->readListEntry("MainLayout"); 1831 list = config->readListEntry("MainLayout");
1832 int x,y,w,h; 1832 int x,y,w,h;
1833 if ( ! list.isEmpty() ) { 1833 if ( ! list.isEmpty() ) {
1834 x = list[0].toInt(); 1834 x = list[0].toInt();
1835 y = list[1].toInt(); 1835 y = list[1].toInt();
1836 w = list[2].toInt(); 1836 w = list[2].toInt();
1837 h = list[3].toInt(); 1837 h = list[3].toInt();
1838 topLevelWidget()->setGeometry(x,y,w,h); 1838 topLevelWidget()->setGeometry(x,y,w,h);
1839 1839
1840 } else { 1840 } else {
1841 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1841 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1842 } 1842 }
1843 list = config->readListEntry("EditEventLayout"); 1843 list = config->readListEntry("EditEventLayout");
1844 if ( ! list.isEmpty() ) { 1844 if ( ! list.isEmpty() ) {
1845 x = list[0].toInt(); 1845 x = list[0].toInt();
1846 y = list[1].toInt(); 1846 y = list[1].toInt();
1847 w = list[2].toInt(); 1847 w = list[2].toInt();
1848 h = list[3].toInt(); 1848 h = list[3].toInt();
1849 mEventEditor->setGeometry(x,y,w,h); 1849 mEventEditor->setGeometry(x,y,w,h);
1850 1850
1851 } 1851 }
1852 list = config->readListEntry("EditTodoLayout"); 1852 list = config->readListEntry("EditTodoLayout");
1853 if ( ! list.isEmpty() ) { 1853 if ( ! list.isEmpty() ) {
1854 x = list[0].toInt(); 1854 x = list[0].toInt();
1855 y = list[1].toInt(); 1855 y = list[1].toInt();
1856 w = list[2].toInt(); 1856 w = list[2].toInt();
1857 h = list[3].toInt(); 1857 h = list[3].toInt();
1858 mTodoEditor->setGeometry(x,y,w,h); 1858 mTodoEditor->setGeometry(x,y,w,h);
1859 1859
1860 } 1860 }
1861 list = config->readListEntry("ViewerLayout"); 1861 list = config->readListEntry("ViewerLayout");
1862 if ( ! list.isEmpty() ) { 1862 if ( ! list.isEmpty() ) {
1863 x = list[0].toInt(); 1863 x = list[0].toInt();
1864 y = list[1].toInt(); 1864 y = list[1].toInt();
1865 w = list[2].toInt(); 1865 w = list[2].toInt();
1866 h = list[3].toInt(); 1866 h = list[3].toInt();
1867 getEventViewerDialog()->setGeometry(x,y,w,h); 1867 getEventViewerDialog()->setGeometry(x,y,w,h);
1868 } 1868 }
1869#endif 1869#endif
1870 config->setGroup( "Views" ); 1870 config->setGroup( "Views" );
1871 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1871 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1872 1872
1873 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1873 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1874 1874
1875 int resetval = 0; 1875 int resetval = 0;
1876 int maxVal = 0; 1876 int maxVal = 0;
1877 if (sizes.count() != 3) { 1877 if (sizes.count() != 3) {
1878 if ( KOPrefs::instance()->mVerticalScreen ) { 1878 if ( KOPrefs::instance()->mVerticalScreen ) {
1879 resetval = mDateNavigator->sizeHint().width()+2; 1879 resetval = mDateNavigator->sizeHint().width()+2;
1880 } else { 1880 } else {
1881 resetval = mDateNavigator->sizeHint().height()+2; 1881 resetval = mDateNavigator->sizeHint().height()+2;
1882 } 1882 }
1883 } 1883 }
1884 if ( !resetval ){// i.e. sizes.count() == 3
1885 if ( KOPrefs::instance()->mVerticalScreen ) {
1886 if ( sizes[0] < mDateNavigator->sizeHint().width()+1 )
1887 resetval = mDateNavigator->sizeHint().width()+2;
1888 } else {
1889 if ( sizes[0] < mDateNavigator->sizeHint().height()+1 )
1890 resetval = mDateNavigator->sizeHint().height()+2;
1891 }
1892 }
1893 if ( resetval ) { 1884 if ( resetval ) {
1894 sizes.clear(); 1885 sizes.clear();
1895 if ( KOPrefs::instance()->mVerticalScreen ) { 1886 if ( KOPrefs::instance()->mVerticalScreen ) {
1896 maxVal = QApplication::desktop()->width() -10; 1887 maxVal = QApplication::desktop()->width() -10;
1897 } else { 1888 } else {
1898 maxVal = QApplication::desktop()->height()-10; 1889 maxVal = QApplication::desktop()->height()-10;
1899 } 1890 }
1900 sizes << resetval; 1891 sizes << resetval;
1901 if ( maxVal < resetval + resetval) 1892 if ( maxVal < resetval + resetval)
1902 resetval = maxVal - resetval; 1893 resetval = maxVal - resetval;
1903 sizes << resetval; 1894 sizes << resetval;
1904 sizes << 100; 1895 sizes << 100;
1905 } 1896 }
1906 mLeftFrame->setSizes(sizes); 1897 mLeftFrame->setSizes(sizes);
1907 sizes = config->readIntListEntry("Main Splitter Frame"); 1898 sizes = config->readIntListEntry("Main Splitter Frame");
1899 resetval = 0;
1900 maxVal = 0;
1908 if (sizes.count() != 2) { 1901 if (sizes.count() != 2) {
1909 if ( !KOPrefs::instance()->mVerticalScreen ) { 1902 if ( !KOPrefs::instance()->mVerticalScreen ) {
1910 resetval = mDateNavigator->sizeHint().width()+2; 1903 resetval = mDateNavigator->sizeHint().width()+2;
1911 } else { 1904 } else {
1912 resetval = mDateNavigator->sizeHint().height()+2; 1905 resetval = mDateNavigator->sizeHint().height()+2;
1913 } 1906 }
1914 } 1907 }
1915 if ( !resetval ){// i.e. sizes.count() == 3
1916 if ( !KOPrefs::instance()->mVerticalScreen ) {
1917 if ( sizes[0] < mDateNavigator->sizeHint().width()+1 )
1918 resetval = mDateNavigator->sizeHint().width()+2;
1919 } else {
1920 if ( sizes[0] < mDateNavigator->sizeHint().height()+1 )
1921 resetval = mDateNavigator->sizeHint().height()+2;
1922 }
1923 }
1924 if ( resetval ) { 1908 if ( resetval ) {
1925 sizes.clear(); 1909 sizes.clear();
1926 if ( !KOPrefs::instance()->mVerticalScreen ) { 1910 if ( !KOPrefs::instance()->mVerticalScreen ) {
1927 maxVal = QApplication::desktop()->width() -10; 1911 maxVal = QApplication::desktop()->width() -10;
1928 } else { 1912 } else {
1929 maxVal = QApplication::desktop()->height()-10; 1913 maxVal = QApplication::desktop()->height()-10;
1930 } 1914 }
1931 sizes << resetval; 1915 sizes << resetval;
1932 if ( maxVal < resetval + resetval) 1916 if ( maxVal < resetval + resetval)
1933 resetval = maxVal - resetval; 1917 resetval = maxVal - resetval;
1934 sizes << resetval; 1918 sizes << resetval;
1935 } 1919 }
1936 mMainFrame->setSizes(sizes); 1920 mMainFrame->setSizes(sizes);
1937 1921
1938 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1922 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1939 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1923 else if ( dateCount == 7 ) mNavigator->selectWeek();
1940 else mNavigator->selectDates( dateCount ); 1924 else mNavigator->selectDates( dateCount );
1941 // mViewManager->readSettings( config ); 1925 // mViewManager->readSettings( config );
1942 updateConfig(); 1926 updateConfig();
1943 globalFlagBlockAgenda = 2; 1927 globalFlagBlockAgenda = 2;
1944 mViewManager->readSettings( config ); 1928 mViewManager->readSettings( config );
1945} 1929}
1946 1930
1947 1931
1948void CalendarView::writeSettings() 1932void CalendarView::writeSettings()
1949{ 1933{
1950 // kdDebug() << "CalendarView::writeSettings" << endl; 1934 // kdDebug() << "CalendarView::writeSettings" << endl;
1951 1935
1952 KConfig *config = KOGlobals::config(); 1936 KConfig *config = KOGlobals::config();
1953 1937
1954 mViewManager->writeSettings( config ); 1938 mViewManager->writeSettings( config );
1955 mTodoList->saveLayout(config,QString("Todo Layout")); 1939 mTodoList->saveLayout(config,QString("Todo Layout"));
1956 mDialogManager->writeSettings( config ); 1940 mDialogManager->writeSettings( config );
1957 //KOPrefs::instance()->usrWriteConfig(); 1941 //KOPrefs::instance()->usrWriteConfig();
1958 KOPrefs::instance()->writeConfig(); 1942 KOPrefs::instance()->writeConfig();
1959 1943
1960 writeFilterSettings(config); 1944 writeFilterSettings(config);
1961 1945
1962 config->setGroup( "Views" ); 1946 config->setGroup( "Views" );
1963 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1947 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1964 1948
1965 QValueList<int> listINT = mLeftFrame->sizes(); 1949 QValueList<int> listINT = mLeftFrame->sizes();
1966 config->writeEntry("Left Splitter Frame",listINT); 1950 config->writeEntry("Left Splitter Frame",listINT);
1967 QValueList<int> listINT2 = mMainFrame->sizes(); 1951 QValueList<int> listINT2 = mMainFrame->sizes();
1968 config->writeEntry("Main Splitter Frame",listINT2); 1952 config->writeEntry("Main Splitter Frame",listINT2);
1969#ifdef DESKTOP_VERSION 1953#ifdef DESKTOP_VERSION
1970 config->setGroup("WidgetLayout"); 1954 config->setGroup("WidgetLayout");
1971 QStringList list ;//= config->readListEntry("MainLayout"); 1955 QStringList list ;//= config->readListEntry("MainLayout");
1972 int x,y,w,h; 1956 int x,y,w,h;
1973 QWidget* wid; 1957 QWidget* wid;
1974 wid = topLevelWidget(); 1958 wid = topLevelWidget();
1975 x = wid->geometry().x(); 1959 x = wid->geometry().x();
1976 y = wid->geometry().y(); 1960 y = wid->geometry().y();
1977 w = wid->width(); 1961 w = wid->width();
1978 h = wid->height(); 1962 h = wid->height();
1979 list.clear(); 1963 list.clear();
1980 list << QString::number( x ); 1964 list << QString::number( x );
1981 list << QString::number( y ); 1965 list << QString::number( y );
1982 list << QString::number( w ); 1966 list << QString::number( w );
1983 list << QString::number( h ); 1967 list << QString::number( h );
1984 config->writeEntry("MainLayout",list ); 1968 config->writeEntry("MainLayout",list );
1985 1969
1986 wid = mEventEditor; 1970 wid = mEventEditor;
1987 x = wid->geometry().x(); 1971 x = wid->geometry().x();
1988 y = wid->geometry().y(); 1972 y = wid->geometry().y();
1989 w = wid->width(); 1973 w = wid->width();
1990 h = wid->height(); 1974 h = wid->height();
1991 list.clear(); 1975 list.clear();
1992 list << QString::number( x ); 1976 list << QString::number( x );
1993 list << QString::number( y ); 1977 list << QString::number( y );
1994 list << QString::number( w ); 1978 list << QString::number( w );
1995 list << QString::number( h ); 1979 list << QString::number( h );
1996 config->writeEntry("EditEventLayout",list ); 1980 config->writeEntry("EditEventLayout",list );
1997 1981
1998 wid = mTodoEditor; 1982 wid = mTodoEditor;
1999 x = wid->geometry().x(); 1983 x = wid->geometry().x();
2000 y = wid->geometry().y(); 1984 y = wid->geometry().y();
2001 w = wid->width(); 1985 w = wid->width();
2002 h = wid->height(); 1986 h = wid->height();
2003 list.clear(); 1987 list.clear();
2004 list << QString::number( x ); 1988 list << QString::number( x );
2005 list << QString::number( y ); 1989 list << QString::number( y );
2006 list << QString::number( w ); 1990 list << QString::number( w );
2007 list << QString::number( h ); 1991 list << QString::number( h );
2008 config->writeEntry("EditTodoLayout",list ); 1992 config->writeEntry("EditTodoLayout",list );
2009 wid = getEventViewerDialog(); 1993 wid = getEventViewerDialog();
2010 x = wid->geometry().x(); 1994 x = wid->geometry().x();
2011 y = wid->geometry().y(); 1995 y = wid->geometry().y();
2012 w = wid->width(); 1996 w = wid->width();
2013 h = wid->height(); 1997 h = wid->height();
2014 list.clear(); 1998 list.clear();
2015 list << QString::number( x ); 1999 list << QString::number( x );
2016 list << QString::number( y ); 2000 list << QString::number( y );
2017 list << QString::number( w ); 2001 list << QString::number( w );
2018 list << QString::number( h ); 2002 list << QString::number( h );
2019 config->writeEntry("ViewerLayout",list ); 2003 config->writeEntry("ViewerLayout",list );
2020 wid = mDialogManager->getSearchDialog(); 2004 wid = mDialogManager->getSearchDialog();
2021 if ( wid ) { 2005 if ( wid ) {
2022 x = wid->geometry().x(); 2006 x = wid->geometry().x();
2023 y = wid->geometry().y(); 2007 y = wid->geometry().y();
2024 w = wid->width(); 2008 w = wid->width();
2025 h = wid->height(); 2009 h = wid->height();
2026 list.clear(); 2010 list.clear();
2027 list << QString::number( x ); 2011 list << QString::number( x );
2028 list << QString::number( y ); 2012 list << QString::number( y );
2029 list << QString::number( w ); 2013 list << QString::number( w );
2030 list << QString::number( h ); 2014 list << QString::number( h );
2031 config->writeEntry("SearchLayout",list ); 2015 config->writeEntry("SearchLayout",list );
2032 } 2016 }
2033#endif 2017#endif
2034 2018
2035 2019
2036 config->sync(); 2020 config->sync();
2037} 2021}
2038 2022
2039void CalendarView::readFilterSettings(KConfig *config) 2023void CalendarView::readFilterSettings(KConfig *config)
2040{ 2024{
2041 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2025 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2042 2026
2043 mFilters.clear(); 2027 mFilters.clear();
2044 2028
2045 config->setGroup("General"); 2029 config->setGroup("General");
2046 QStringList filterList = config->readListEntry("CalendarFilters"); 2030 QStringList filterList = config->readListEntry("CalendarFilters");
2047 2031
2048 QStringList::ConstIterator it = filterList.begin(); 2032 QStringList::ConstIterator it = filterList.begin();
2049 QStringList::ConstIterator end = filterList.end(); 2033 QStringList::ConstIterator end = filterList.end();
2050 while(it != end) { 2034 while(it != end) {
2051 // kdDebug() << " filter: " << (*it) << endl; 2035 // kdDebug() << " filter: " << (*it) << endl;
2052 2036
2053 CalFilter *filter; 2037 CalFilter *filter;
2054 filter = new CalFilter(*it); 2038 filter = new CalFilter(*it);
2055 config->setGroup("Filter_" + (*it)); 2039 config->setGroup("Filter_" + (*it));
2056 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2040 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2057 filter->setCriteria(config->readNumEntry("Criteria",0)); 2041 filter->setCriteria(config->readNumEntry("Criteria",0));
2058 filter->setCategoryList(config->readListEntry("CategoryList")); 2042 filter->setCategoryList(config->readListEntry("CategoryList"));
2059 mFilters.append(filter); 2043 mFilters.append(filter);
2060 2044
2061 ++it; 2045 ++it;
2062 } 2046 }
2063 2047
2064 if (mFilters.count() == 0) { 2048 if (mFilters.count() == 0) {
2065 CalFilter *filter = new CalFilter(i18n("Default")); 2049 CalFilter *filter = new CalFilter(i18n("Default"));
2066 mFilters.append(filter); 2050 mFilters.append(filter);
2067 } 2051 }
2068 mFilterView->updateFilters(); 2052 mFilterView->updateFilters();
2069 config->setGroup("FilterView"); 2053 config->setGroup("FilterView");
2070 2054
2071 mFilterView->blockSignals(true); 2055 mFilterView->blockSignals(true);
2072 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2056 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2073 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2057 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2074 mFilterView->blockSignals(false); 2058 mFilterView->blockSignals(false);
2075 // We do it manually to avoid it being done twice by the above calls 2059 // We do it manually to avoid it being done twice by the above calls
2076 updateFilter(); 2060 updateFilter();
2077} 2061}
2078 2062
2079void CalendarView::writeFilterSettings(KConfig *config) 2063void CalendarView::writeFilterSettings(KConfig *config)
2080{ 2064{
2081 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2065 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2082 2066
2083 QStringList filterList; 2067 QStringList filterList;
2084 2068
2085 CalFilter *filter = mFilters.first(); 2069 CalFilter *filter = mFilters.first();
2086 while(filter) { 2070 while(filter) {
2087 // kdDebug() << " fn: " << filter->name() << endl; 2071 // kdDebug() << " fn: " << filter->name() << endl;
2088 filterList << filter->name(); 2072 filterList << filter->name();
2089 config->setGroup("Filter_" + filter->name()); 2073 config->setGroup("Filter_" + filter->name());
2090 config->writeEntry("Criteria",filter->criteria()); 2074 config->writeEntry("Criteria",filter->criteria());
2091 config->writeEntry("CategoryList",filter->categoryList()); 2075 config->writeEntry("CategoryList",filter->categoryList());
2092 filter = mFilters.next(); 2076 filter = mFilters.next();
2093 } 2077 }
2094 config->setGroup("General"); 2078 config->setGroup("General");
2095 config->writeEntry("CalendarFilters",filterList); 2079 config->writeEntry("CalendarFilters",filterList);
2096 2080
2097 config->setGroup("FilterView"); 2081 config->setGroup("FilterView");
2098 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2082 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2099 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2083 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2100} 2084}
2101 2085
2102 2086
2103void CalendarView::goToday() 2087void CalendarView::goToday()
2104{ 2088{
2105 if ( mViewManager->currentView()->isMonthView() ) 2089 if ( mViewManager->currentView()->isMonthView() )
2106 mNavigator->selectTodayMonth(); 2090 mNavigator->selectTodayMonth();
2107 else 2091 else
2108 mNavigator->selectToday(); 2092 mNavigator->selectToday();
2109} 2093}
2110 2094
2111void CalendarView::goNext() 2095void CalendarView::goNext()
2112{ 2096{
2113 mNavigator->selectNext(); 2097 mNavigator->selectNext();
2114} 2098}
2115 2099
2116void CalendarView::goPrevious() 2100void CalendarView::goPrevious()
2117{ 2101{
2118 mNavigator->selectPrevious(); 2102 mNavigator->selectPrevious();
2119} 2103}
2120void CalendarView::goNextMonth() 2104void CalendarView::goNextMonth()
2121{ 2105{
2122 mNavigator->selectNextMonth(); 2106 mNavigator->selectNextMonth();
2123} 2107}
2124 2108
2125void CalendarView::goPreviousMonth() 2109void CalendarView::goPreviousMonth()
2126{ 2110{
2127 mNavigator->selectPreviousMonth(); 2111 mNavigator->selectPreviousMonth();
2128} 2112}
2129void CalendarView::writeLocale() 2113void CalendarView::writeLocale()
2130{ 2114{
2131 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2115 //KPimGlobalPrefs::instance()->setGlobalConfig();
2132#if 0 2116#if 0
2133 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2117 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2134 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2118 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2135 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2119 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2136 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2120 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2137 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2121 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2138 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2122 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2139 dummy = KOPrefs::instance()->mUserDateFormatShort; 2123 dummy = KOPrefs::instance()->mUserDateFormatShort;
2140 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2124 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2141 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2125 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2142 KOPrefs::instance()->mDaylightsavingStart, 2126 KOPrefs::instance()->mDaylightsavingStart,
2143 KOPrefs::instance()->mDaylightsavingEnd ); 2127 KOPrefs::instance()->mDaylightsavingEnd );
2144 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2128 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2145#endif 2129#endif
2146} 2130}
2147void CalendarView::updateConfig() 2131void CalendarView::updateConfig()
2148{ 2132{
2149 writeLocale(); 2133 writeLocale();
2150 if ( KOPrefs::instance()->mUseAppColors ) 2134 if ( KOPrefs::instance()->mUseAppColors )
2151 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2135 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2152 emit configChanged(); 2136 emit configChanged();
2153 mTodoList->updateConfig(); 2137 mTodoList->updateConfig();
2154 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2138 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2155 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2139 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2156 // To make the "fill window" configurations work 2140 // To make the "fill window" configurations work
2157 //mViewManager->raiseCurrentView(); 2141 //mViewManager->raiseCurrentView();
2158} 2142}
2159 2143
2160 2144
2161void CalendarView::eventChanged(Event *event) 2145void CalendarView::eventChanged(Event *event)
2162{ 2146{
2163 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2147 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2164 //updateUnmanagedViews(); 2148 //updateUnmanagedViews();
2165} 2149}
2166 2150
2167void CalendarView::eventAdded(Event *event) 2151void CalendarView::eventAdded(Event *event)
2168{ 2152{
2169 changeEventDisplay(event,KOGlobals::EVENTADDED); 2153 changeEventDisplay(event,KOGlobals::EVENTADDED);
2170} 2154}
2171 2155
2172void CalendarView::eventToBeDeleted(Event *) 2156void CalendarView::eventToBeDeleted(Event *)
2173{ 2157{
2174 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2158 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2175} 2159}
2176 2160
2177void CalendarView::eventDeleted() 2161void CalendarView::eventDeleted()
2178{ 2162{
2179 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2163 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2180} 2164}
2181void CalendarView::changeTodoDisplay(Todo *which, int action) 2165void CalendarView::changeTodoDisplay(Todo *which, int action)
2182{ 2166{
2183 changeIncidenceDisplay((Incidence *)which, action); 2167 changeIncidenceDisplay((Incidence *)which, action);
2184 mDateNavigator->updateView(); //LR 2168 mDateNavigator->updateView(); //LR
2185 //mDialogManager->updateSearchDialog(); 2169 //mDialogManager->updateSearchDialog();
2186 2170
2187 if (which) { 2171 if (which) {
2188 mViewManager->updateWNview(); 2172 mViewManager->updateWNview();
2189 //mTodoList->updateView(); 2173 //mTodoList->updateView();
2190 } 2174 }
2191 2175
2192} 2176}
2193 2177
2194void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2178void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2195{ 2179{
2196 updateUnmanagedViews(); 2180 updateUnmanagedViews();
2197 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2181 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2198 if ( action == KOGlobals::EVENTDELETED ) { //delete 2182 if ( action == KOGlobals::EVENTDELETED ) { //delete
2199 mCalendar->checkAlarmForIncidence( 0, true ); 2183 mCalendar->checkAlarmForIncidence( 0, true );
2200 if ( mEventViewerDialog ) 2184 if ( mEventViewerDialog )
2201 mEventViewerDialog->hide(); 2185 mEventViewerDialog->hide();
2202 } 2186 }
2203 else 2187 else
2204 mCalendar->checkAlarmForIncidence( which , false ); 2188 mCalendar->checkAlarmForIncidence( which , false );
2205} 2189}
2206 2190
2207// most of the changeEventDisplays() right now just call the view's 2191// most of the changeEventDisplays() right now just call the view's
2208// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2192// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2209void CalendarView::changeEventDisplay(Event *which, int action) 2193void CalendarView::changeEventDisplay(Event *which, int action)
2210{ 2194{
2211 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2195 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2212 changeIncidenceDisplay((Incidence *)which, action); 2196 changeIncidenceDisplay((Incidence *)which, action);
2213 mDateNavigator->updateView(); 2197 mDateNavigator->updateView();
2214 //mDialogManager->updateSearchDialog(); 2198 //mDialogManager->updateSearchDialog();
2215 2199
2216 if (which) { 2200 if (which) {
2217 // If there is an event view visible update the display 2201 // If there is an event view visible update the display
2218 mViewManager->currentView()->changeEventDisplay(which,action); 2202 mViewManager->currentView()->changeEventDisplay(which,action);
2219 // TODO: check, if update needed 2203 // TODO: check, if update needed
2220 // if (which->getTodoStatus()) { 2204 // if (which->getTodoStatus()) {
2221 mTodoList->updateView(); 2205 mTodoList->updateView();
2222 // } 2206 // }
2223 } else { 2207 } else {
2224 mViewManager->currentView()->updateView(); 2208 mViewManager->currentView()->updateView();
2225 } 2209 }
2226} 2210}
2227 2211
2228 2212
2229void CalendarView::updateTodoViews() 2213void CalendarView::updateTodoViews()
2230{ 2214{
2231 mTodoList->updateView(); 2215 mTodoList->updateView();
2232 mViewManager->currentView()->updateView(); 2216 mViewManager->currentView()->updateView();
2233 2217
2234} 2218}
2235 2219
2236 2220
2237void CalendarView::updateView(const QDate &start, const QDate &end) 2221void CalendarView::updateView(const QDate &start, const QDate &end)
2238{ 2222{
2239 mTodoList->updateView(); 2223 mTodoList->updateView();
2240 mViewManager->updateView(start, end); 2224 mViewManager->updateView(start, end);
2241 //mDateNavigator->updateView(); 2225 //mDateNavigator->updateView();
2242} 2226}
2243 2227
2244void CalendarView::updateView() 2228void CalendarView::updateView()
2245{ 2229{
2246 DateList tmpList = mNavigator->selectedDates(); 2230 DateList tmpList = mNavigator->selectedDates();
2247 2231
2248 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2232 if ( KOPrefs::instance()->mHideNonStartedTodos )
2249 mTodoList->updateView(); 2233 mTodoList->updateView();
2250 // We assume that the navigator only selects consecutive days. 2234 // We assume that the navigator only selects consecutive days.
2251 updateView( tmpList.first(), tmpList.last() ); 2235 updateView( tmpList.first(), tmpList.last() );
2252} 2236}
2253 2237
2254void CalendarView::updateUnmanagedViews() 2238void CalendarView::updateUnmanagedViews()
2255{ 2239{
2256 mDateNavigator->updateDayMatrix(); 2240 mDateNavigator->updateDayMatrix();
2257} 2241}
2258 2242
2259int CalendarView::msgItemDelete(const QString name) 2243int CalendarView::msgItemDelete(const QString name)
2260{ 2244{
2261 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2245 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2262 i18n("This item will be\npermanently deleted."), 2246 i18n("This item will be\npermanently deleted."),
2263 i18n("KO/Pi Confirmation"),i18n("Delete")); 2247 i18n("KO/Pi Confirmation"),i18n("Delete"));
2264} 2248}
2265 2249
2266 2250
2267void CalendarView::edit_cut() 2251void CalendarView::edit_cut()
2268{ 2252{
2269 Event *anEvent=0; 2253 Event *anEvent=0;
2270 2254
2271 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2255 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2272 2256
2273 if (mViewManager->currentView()->isEventView()) { 2257 if (mViewManager->currentView()->isEventView()) {
2274 if ( incidence && incidence->type() == "Event" ) { 2258 if ( incidence && incidence->type() == "Event" ) {
2275 anEvent = static_cast<Event *>(incidence); 2259 anEvent = static_cast<Event *>(incidence);
2276 } 2260 }
2277 } 2261 }
2278 2262
2279 if (!anEvent) { 2263 if (!anEvent) {
2280 KNotifyClient::beep(); 2264 KNotifyClient::beep();
2281 return; 2265 return;
2282 } 2266 }
2283 DndFactory factory( mCalendar ); 2267 DndFactory factory( mCalendar );
2284 factory.cutIncidence(anEvent); 2268 factory.cutIncidence(anEvent);
2285 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2269 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2286} 2270}
2287 2271
2288void CalendarView::edit_copy() 2272void CalendarView::edit_copy()
2289{ 2273{
2290 Event *anEvent=0; 2274 Event *anEvent=0;
2291 2275
2292 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2276 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2293 2277
2294 if (mViewManager->currentView()->isEventView()) { 2278 if (mViewManager->currentView()->isEventView()) {
2295 if ( incidence && incidence->type() == "Event" ) { 2279 if ( incidence && incidence->type() == "Event" ) {
2296 anEvent = static_cast<Event *>(incidence); 2280 anEvent = static_cast<Event *>(incidence);
2297 } 2281 }
2298 } 2282 }
2299 2283
2300 if (!anEvent) { 2284 if (!anEvent) {
2301 KNotifyClient::beep(); 2285 KNotifyClient::beep();
2302 return; 2286 return;
2303 } 2287 }
2304 DndFactory factory( mCalendar ); 2288 DndFactory factory( mCalendar );
2305 factory.copyIncidence(anEvent); 2289 factory.copyIncidence(anEvent);
2306} 2290}
2307 2291
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index ab0dd50..18756f0 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,276 +1,276 @@
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#include "koprefs.h" 36#include "koprefs.h"
37 37
38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, 38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
39 const char *name ) 39 const char *name )
40 : QWidget( parent, name ), mCalendar( 0 ), 40 : QWidget( parent, name ), mCalendar( 0 ),
41 mHorizontalCount( 1 ), mVerticalCount( 1 ) 41 mHorizontalCount( 1 ), mVerticalCount( 1 )
42{ 42{
43 mExtraViews.setAutoDelete( true ); 43 mExtraViews.setAutoDelete( true );
44 44
45 mNavigatorView = new KDateNavigator( this, name ); 45 mNavigatorView = new KDateNavigator( this, name );
46 46
47 connectNavigatorView( mNavigatorView ); 47 connectNavigatorView( mNavigatorView );
48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
49} 49}
50 50
51DateNavigatorContainer::~DateNavigatorContainer() 51DateNavigatorContainer::~DateNavigatorContainer()
52{ 52{
53} 53}
54 54
55void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 55void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
56{ 56{
57 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 57 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
58 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 58 SIGNAL( datesSelected( const KCal::DateList & ) ) );
59#if 0 59#if 0
60 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 60 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
61 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 61 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
62 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 62 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
63 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 63 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
64#endif 64#endif
65 connect( v, SIGNAL( weekClicked( const QDate & ) ), 65 connect( v, SIGNAL( weekClicked( const QDate & ) ),
66 SIGNAL( weekClicked( const QDate & ) ) ); 66 SIGNAL( weekClicked( const QDate & ) ) );
67 67
68 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 68 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
69 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 69 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
70 70
71 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 71 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
72 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 72 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
73 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 73 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
74 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 74 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
75 75
76 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 76 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
77} 77}
78 78
79void DateNavigatorContainer::setCalendar( Calendar *cal ) 79void DateNavigatorContainer::setCalendar( Calendar *cal )
80{ 80{
81 mCalendar = cal; 81 mCalendar = cal;
82 mNavigatorView->setCalendar( cal ); 82 mNavigatorView->setCalendar( cal );
83 KDateNavigator *n; 83 KDateNavigator *n;
84 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 84 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
85 n->setCalendar( cal ); 85 n->setCalendar( cal );
86 } 86 }
87} 87}
88 88
89void DateNavigatorContainer::updateDayMatrix() 89void DateNavigatorContainer::updateDayMatrix()
90{ 90{
91 mNavigatorView->updateDayMatrix(); 91 mNavigatorView->updateDayMatrix();
92 KDateNavigator *n; 92 KDateNavigator *n;
93 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 93 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
94 n->updateDayMatrix(); 94 n->updateDayMatrix();
95 } 95 }
96} 96}
97 97
98void DateNavigatorContainer::updateToday() 98void DateNavigatorContainer::updateToday()
99{ 99{
100 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 100 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
101#if 0 101#if 0
102 mNavigatorView->updateToday(); 102 mNavigatorView->updateToday();
103 KDateNavigator *n; 103 KDateNavigator *n;
104 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 104 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
105 n->updateToday(); 105 n->updateToday();
106 } 106 }
107#endif 107#endif
108} 108}
109 109
110void DateNavigatorContainer::updateView() 110void DateNavigatorContainer::updateView()
111{ 111{
112 mNavigatorView->updateView(); 112 mNavigatorView->updateView();
113 KDateNavigator *n; 113 KDateNavigator *n;
114 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 114 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
115 n->updateView(); 115 n->updateView();
116 } 116 }
117} 117}
118 118
119void DateNavigatorContainer::updateConfig() 119void DateNavigatorContainer::updateConfig()
120{ 120{
121 mNavigatorView->updateConfig(); 121 mNavigatorView->updateConfig();
122 KDateNavigator *n; 122 KDateNavigator *n;
123 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 123 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
124 n->updateConfig(); 124 n->updateConfig();
125 } 125 }
126} 126}
127 127
128void DateNavigatorContainer::selectDates( const DateList &dateList ) 128void DateNavigatorContainer::selectDates( const DateList &dateList )
129{ 129{
130 mNavigatorView->selectDates( dateList ); 130 mNavigatorView->selectDates( dateList );
131 setBaseDates(); 131 setBaseDates();
132 if ( mExtraViews.count() ) { 132 if ( mExtraViews.count() ) {
133 KDateNavigator *view = mExtraViews.at( 0 ); 133 KDateNavigator *view = mExtraViews.at( 0 );
134 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 134 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
135 view->dayMatrix()->repaint( false ); 135 view->dayMatrix()->repaint( false );
136 if ( mExtraViews.count() > 1 ) { 136 if ( mExtraViews.count() > 1 ) {
137 KDateNavigator *view = mExtraViews.at( 1 ); 137 KDateNavigator *view = mExtraViews.at( 1 );
138 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 138 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
139 view->dayMatrix()->repaint( false ); 139 view->dayMatrix()->repaint( false );
140 } 140 }
141 } 141 }
142} 142}
143 143
144void DateNavigatorContainer::setBaseDates() 144void DateNavigatorContainer::setBaseDates()
145{ 145{
146 KCal::DateList dateList = mNavigatorView->selectedDates(); 146 KCal::DateList dateList = mNavigatorView->selectedDates();
147 if ( dateList.isEmpty() ) { 147 if ( dateList.isEmpty() ) {
148 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; 148 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
149 } 149 }
150 QDate baseDate = dateList.first(); 150 QDate baseDate = dateList.first();
151 KDateNavigator *n; 151 KDateNavigator *n;
152 bool doRepaint = false; // skip first repaint 152 bool doRepaint = false; // skip first repaint
153 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 153 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
154 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 154 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
155 n->setBaseDate( baseDate, doRepaint ); 155 n->setBaseDate( baseDate, doRepaint );
156 doRepaint = true; 156 doRepaint = true;
157 } 157 }
158} 158}
159 159
160void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 160void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
161{ 161{
162#if 0 162#if 0
163 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; 163 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
164 kdDebug(5850) << " CURRENT SIZE: " << size() << endl; 164 kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
165 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; 165 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
166 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; 166 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
167 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; 167 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
168#endif 168#endif
169 //QSize minSize = mNavigatorView->sizeHintTwoButtons(); 169 //QSize minSize = mNavigatorView->sizeHintTwoButtons();
170 QSize minSize = mNavigatorView->yourSizeHint(); 170 QSize minSize = mNavigatorView->yourSizeHint();
171 171
172// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; 172// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
173 173
174 int verticalCount = size().height() / minSize.height(); 174 int verticalCount = size().height() / minSize.height();
175 int horizontalCount = size().width() / minSize.width(); 175 int horizontalCount = size().width() / minSize.width();
176 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 176 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
177 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 177 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
178 bool fontchange = false; 178 bool fontchange = false;
179 if ( horizontalCount == 1) 179 if ( horizontalCount == 1)
180 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 180 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
181 QFont fo; 181 QFont fo;
182 if ( horizontalCount != mHorizontalCount || 182 if ( horizontalCount != mHorizontalCount ||
183 verticalCount != mVerticalCount ) { 183 verticalCount != mVerticalCount ) {
184 uint count = horizontalCount * verticalCount; 184 uint count = horizontalCount * verticalCount;
185 if ( count == 0 ) { 185 if ( count == 0 ) {
186 bool ok; 186 bool ok;
187 fo = mNavigatorView->yourFontHint( size() , &ok ); 187 fo = mNavigatorView->yourFontHint( size() , &ok );
188 //mNavigatorView->resize( size() ); 188 //mNavigatorView->resize( size() );
189 //if ( ! ok ) 189 //if ( ! ok )
190 // return; 190 // return;
191 int butt = 2; 191 int butt = 2;
192 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 192 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
193 if ( horizontalCount <= 1 ) 193 if ( horizontalCount <= 1 )
194 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 194 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
195 else 195 else
196 minSize = mNavigatorView->sizeHintTwoButtons(); 196 minSize = mNavigatorView->sizeHintTwoButtons();
197 verticalCount = size().height() / minSize.height(); 197 verticalCount = size().height() / minSize.height();
198 horizontalCount = size().width() / minSize.width(); 198 horizontalCount = size().width() / minSize.width();
199 if ( horizontalCount == 0 ) 199 if ( horizontalCount == 0 )
200 horizontalCount = 1; 200 horizontalCount = 1;
201 if ( verticalCount == 0 ) 201 if ( verticalCount == 0 )
202 verticalCount = 1; 202 verticalCount = 1;
203 fontchange = true; 203 fontchange = true;
204 count = horizontalCount * verticalCount; 204 count = horizontalCount * verticalCount;
205 } else { 205 } else {
206 if ( mNavigatorView->fontChanged() ) { 206 if ( mNavigatorView->fontChanged() ) {
207 fontchange = true; 207 fontchange = true;
208 fo = KOPrefs::instance()->mDateNavigatorFont; 208 fo = KOPrefs::instance()->mDateNavigatorFont;
209 mNavigatorView->changeFont( fo ); 209 mNavigatorView->changeFont( fo );
210 mNavigatorView->unsetFontChanged(); 210 mNavigatorView->unsetFontChanged();
211 } 211 }
212 } 212 }
213 213
214 while ( count > ( mExtraViews.count() + 1 ) ) { 214 while ( count > ( mExtraViews.count() + 1 ) ) {
215 KDateNavigator *n = new KDateNavigator( this ); 215 KDateNavigator *n = new KDateNavigator( this );
216 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 216 n->setMonthSignalOffset ( mExtraViews.count()+1 );
217 mExtraViews.append( n ); 217 mExtraViews.append( n );
218 n->setCalendar( mCalendar ); 218 n->setCalendar( mCalendar );
219 setBaseDates(); 219 setBaseDates();
220 connectNavigatorView( n ); 220 connectNavigatorView( n );
221 n->show(); 221 n->show();
222 } 222 }
223 int iii = 0; 223 int iii = 0;
224 while ( iii < ( mExtraViews.count() ) ) { 224 while ( iii < ( mExtraViews.count() ) ) {
225 if ( iii < count-1 ) 225 if ( iii < count-1 )
226 mExtraViews.at( iii )->show(); 226 mExtraViews.at( iii )->show();
227 else 227 else
228 mExtraViews.at( iii )->hide(); 228 mExtraViews.at( iii )->hide();
229 ++iii; 229 ++iii;
230 } 230 }
231 if ( fontchange ) { 231 if ( fontchange ) {
232 //mNavigatorView->changeFont( fo ); 232 //mNavigatorView->changeFont( fo );
233 uint i; 233 uint i;
234 for( i = 0; i < mExtraViews.count(); ++i ) { 234 for( i = 0; i < mExtraViews.count(); ++i ) {
235 KDateNavigator *view = mExtraViews.at( i ); 235 KDateNavigator *view = mExtraViews.at( i );
236 view->changeFont( fo ); 236 view->changeFont( fo );
237 } 237 }
238 } 238 }
239 mHorizontalCount = horizontalCount; 239 mHorizontalCount = horizontalCount;
240 mVerticalCount = verticalCount; 240 mVerticalCount = verticalCount;
241 } 241 }
242 //qDebug("COUNT %d ", mExtraViews.count()); 242 //qDebug("COUNT %d ", mExtraViews.count());
243 int height = size().height() / verticalCount; 243 int height = size().height() / verticalCount;
244 int width = size().width() / horizontalCount; 244 int width = size().width() / horizontalCount;
245 245
246 NavigatorBar *bar = mNavigatorView->navigatorBar(); 246 NavigatorBar *bar = mNavigatorView->navigatorBar();
247 if ( horizontalCount > 1 ) bar->showButtons( true, false ); 247 if ( horizontalCount > 1 ) bar->showButtons( true, false );
248 else bar->showButtons( true, true ); 248 else bar->showButtons( true, true );
249 249
250 mNavigatorView->setGeometry(0, 250 mNavigatorView->setGeometry(0,
251 0, width, height ); 251 0, width, height );
252 for( uint i = 0; i < mExtraViews.count(); ++i ) { 252 for( uint i = 0; i < mExtraViews.count(); ++i ) {
253 int x = ( i + 1 ) % horizontalCount; 253 int x = ( i + 1 ) % horizontalCount;
254 int y = ( i + 1 ) / horizontalCount; 254 int y = ( i + 1 ) / horizontalCount;
255 255
256 KDateNavigator *view = mExtraViews.at( i ); 256 KDateNavigator *view = mExtraViews.at( i );
257 bar = view->navigatorBar(); 257 bar = view->navigatorBar();
258 if ( y > 0 ) bar->showButtons( false, false ); 258 if ( y > 0 ) bar->showButtons( false, false );
259 else { 259 else {
260 if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); 260 if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
261 else bar->showButtons( false, false ); 261 else bar->showButtons( false, false );
262 } 262 }
263 view->setGeometry( x * width, 263 view->setGeometry( x * width,
264 y * height, width, height ); 264 y * height, width, height );
265 } 265 }
266} 266}
267 267
268QSize DateNavigatorContainer::minimumSizeHint() const 268QSize DateNavigatorContainer::minimumSizeHint() const
269{ 269{
270 return mNavigatorView->minimumSizeHint(); 270 return mNavigatorView->minimumSizeHint();
271} 271}
272 272
273QSize DateNavigatorContainer::sizeHint() const 273QSize DateNavigatorContainer::sizeHint() const
274{ 274{
275 return mNavigatorView->sizeHint(); 275 return mNavigatorView->yourSizeHint();
276} 276}