author | zautrix <zautrix> | 2005-06-13 20:42:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-13 20:42:10 (UTC) |
commit | fe1114cea0321405b362d642912f1f72257c7cbd (patch) (unidiff) | |
tree | 89f5cc1050a86c497fc406ebbea88669b6bea1a6 /korganizer | |
parent | 0000f74badd326f62620d818a5e5d9944e55bda0 (diff) | |
download | kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.zip kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.gz kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.bz2 |
fixxxx
-rw-r--r-- | korganizer/calendarview.cpp | 45 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 18 | ||||
-rw-r--r-- | korganizer/koprefs.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 12 |
5 files changed, 68 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 6e60c56..b0be340 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1690,534 +1690,563 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd | |||
1690 | QDate anniversary; | 1690 | QDate anniversary; |
1691 | QString realName; | 1691 | QString realName; |
1692 | QString email; | 1692 | QString email; |
1693 | QString assembledName; | 1693 | QString assembledName; |
1694 | QString uid; | 1694 | QString uid; |
1695 | bool ok = true; | 1695 | bool ok = true; |
1696 | for ( int i = 0; i < count; i++) | 1696 | for ( int i = 0; i < count; i++) |
1697 | { | 1697 | { |
1698 | if ( ! bar.isVisible() ) | 1698 | if ( ! bar.isVisible() ) |
1699 | return; | 1699 | return; |
1700 | bar.setProgress( i ); | 1700 | bar.setProgress( i ); |
1701 | qApp->processEvents(); | 1701 | qApp->processEvents(); |
1702 | 1702 | ||
1703 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1703 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1704 | if (!ok) { | 1704 | if (!ok) { |
1705 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1705 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1708 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1709 | if (!ok) { | 1709 | if (!ok) { |
1710 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1710 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1711 | } | 1711 | } |
1712 | realName = realNameList[i]; | 1712 | realName = realNameList[i]; |
1713 | email = emailList[i]; | 1713 | email = emailList[i]; |
1714 | assembledName = assembledNameList[i]; | 1714 | assembledName = assembledNameList[i]; |
1715 | uid = uidList[i]; | 1715 | uid = uidList[i]; |
1716 | //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() ); | 1716 | //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() ); |
1717 | 1717 | ||
1718 | if ( birthday.isValid() ){ | 1718 | if ( birthday.isValid() ){ |
1719 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1719 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1720 | KCal::Attendee::ReqParticipant,uid) ; | 1720 | KCal::Attendee::ReqParticipant,uid) ; |
1721 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1721 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1722 | ++addCount; | 1722 | ++addCount; |
1723 | } | 1723 | } |
1724 | 1724 | ||
1725 | if ( anniversary.isValid() ){ | 1725 | if ( anniversary.isValid() ){ |
1726 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1726 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1727 | KCal::Attendee::ReqParticipant,uid) ; | 1727 | KCal::Attendee::ReqParticipant,uid) ; |
1728 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1728 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1729 | ++addCount; | 1729 | ++addCount; |
1730 | } | 1730 | } |
1731 | } | 1731 | } |
1732 | 1732 | ||
1733 | updateView(); | 1733 | updateView(); |
1734 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1734 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1735 | 1735 | ||
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | 1740 | ||
1741 | 1741 | ||
1742 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1742 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1743 | { | 1743 | { |
1744 | //qDebug("addAnni "); | 1744 | //qDebug("addAnni "); |
1745 | Event * ev = new Event(); | 1745 | Event * ev = new Event(); |
1746 | ev->setOrganizer(KOPrefs::instance()->email()); | 1746 | ev->setOrganizer(KOPrefs::instance()->email()); |
1747 | if ( a ) { | 1747 | if ( a ) { |
1748 | ev->addAttendee( a ); | 1748 | ev->addAttendee( a ); |
1749 | } | 1749 | } |
1750 | QString kind; | 1750 | QString kind; |
1751 | if ( birthday ) { | 1751 | if ( birthday ) { |
1752 | kind = i18n( "Birthday" ); | 1752 | kind = i18n( "Birthday" ); |
1753 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1753 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1754 | } | 1754 | } |
1755 | else { | 1755 | else { |
1756 | kind = i18n( "Anniversary" ); | 1756 | kind = i18n( "Anniversary" ); |
1757 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1757 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1758 | } | 1758 | } |
1759 | ev->setCategories( kind ); | 1759 | ev->setCategories( kind ); |
1760 | ev->setDtStart( QDateTime(date) ); | 1760 | ev->setDtStart( QDateTime(date) ); |
1761 | ev->setDtEnd( QDateTime(date) ); | 1761 | ev->setDtEnd( QDateTime(date) ); |
1762 | ev->setFloats( true ); | 1762 | ev->setFloats( true ); |
1763 | Recurrence * rec = ev->recurrence(); | 1763 | Recurrence * rec = ev->recurrence(); |
1764 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1764 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1765 | rec->addYearlyNum( date.month() ); | 1765 | rec->addYearlyNum( date.month() ); |
1766 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1766 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1767 | delete ev; | 1767 | delete ev; |
1768 | return false; | 1768 | return false; |
1769 | } | 1769 | } |
1770 | return true; | 1770 | return true; |
1771 | 1771 | ||
1772 | } | 1772 | } |
1773 | bool CalendarView::importQtopia( const QString &categories, | 1773 | bool CalendarView::importQtopia( const QString &categories, |
1774 | const QString &datebook, | 1774 | const QString &datebook, |
1775 | const QString &todolist ) | 1775 | const QString &todolist ) |
1776 | { | 1776 | { |
1777 | 1777 | ||
1778 | QtopiaFormat qtopiaFormat; | 1778 | QtopiaFormat qtopiaFormat; |
1779 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1779 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1780 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1780 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1781 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1781 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1782 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1782 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1783 | 1783 | ||
1784 | updateView(); | 1784 | updateView(); |
1785 | return true; | 1785 | return true; |
1786 | 1786 | ||
1787 | #if 0 | 1787 | #if 0 |
1788 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1788 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1789 | mCurrentSyncDevice = "qtopia-XML"; | 1789 | mCurrentSyncDevice = "qtopia-XML"; |
1790 | if ( mSyncManager->mAskForPreferences ) | 1790 | if ( mSyncManager->mAskForPreferences ) |
1791 | edit_sync_options(); | 1791 | edit_sync_options(); |
1792 | qApp->processEvents(); | 1792 | qApp->processEvents(); |
1793 | CalendarLocal* calendar = new CalendarLocal(); | 1793 | CalendarLocal* calendar = new CalendarLocal(); |
1794 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1794 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1795 | bool syncOK = false; | 1795 | bool syncOK = false; |
1796 | QtopiaFormat qtopiaFormat; | 1796 | QtopiaFormat qtopiaFormat; |
1797 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1797 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1798 | bool loadOk = true; | 1798 | bool loadOk = true; |
1799 | if ( !categories.isEmpty() ) | 1799 | if ( !categories.isEmpty() ) |
1800 | loadOk = qtopiaFormat.load( calendar, categories ); | 1800 | loadOk = qtopiaFormat.load( calendar, categories ); |
1801 | if ( loadOk && !datebook.isEmpty() ) | 1801 | if ( loadOk && !datebook.isEmpty() ) |
1802 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1802 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1803 | if ( loadOk && !todolist.isEmpty() ) | 1803 | if ( loadOk && !todolist.isEmpty() ) |
1804 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1804 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1805 | 1805 | ||
1806 | if ( loadOk ) { | 1806 | if ( loadOk ) { |
1807 | getEventViewerDialog()->setSyncMode( true ); | 1807 | getEventViewerDialog()->setSyncMode( true ); |
1808 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1808 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1809 | getEventViewerDialog()->setSyncMode( false ); | 1809 | getEventViewerDialog()->setSyncMode( false ); |
1810 | qApp->processEvents(); | 1810 | qApp->processEvents(); |
1811 | if ( syncOK ) { | 1811 | if ( syncOK ) { |
1812 | if ( mSyncManager->mWriteBackFile ) | 1812 | if ( mSyncManager->mWriteBackFile ) |
1813 | { | 1813 | { |
1814 | // write back XML file | 1814 | // write back XML file |
1815 | 1815 | ||
1816 | } | 1816 | } |
1817 | setModified( true ); | 1817 | setModified( true ); |
1818 | } | 1818 | } |
1819 | } else { | 1819 | } else { |
1820 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1820 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1821 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1821 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1822 | question, i18n("Ok")) ; | 1822 | question, i18n("Ok")) ; |
1823 | } | 1823 | } |
1824 | delete calendar; | 1824 | delete calendar; |
1825 | updateView(); | 1825 | updateView(); |
1826 | return syncOK; | 1826 | return syncOK; |
1827 | 1827 | ||
1828 | 1828 | ||
1829 | #endif | 1829 | #endif |
1830 | 1830 | ||
1831 | } | 1831 | } |
1832 | 1832 | ||
1833 | void CalendarView::setSyncEventsReadOnly() | 1833 | void CalendarView::setSyncEventsReadOnly() |
1834 | { | 1834 | { |
1835 | Event * ev; | 1835 | Event * ev; |
1836 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1836 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1837 | ev = eL.first(); | 1837 | ev = eL.first(); |
1838 | while ( ev ) { | 1838 | while ( ev ) { |
1839 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1839 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1840 | ev->setReadOnly( true ); | 1840 | ev->setReadOnly( true ); |
1841 | ev = eL.next(); | 1841 | ev = eL.next(); |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | 1844 | ||
1845 | bool CalendarView::loadCalendars() | 1845 | bool CalendarView::loadCalendars() |
1846 | { | 1846 | { |
1847 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1847 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1848 | KopiCalendarFile * cal = calendars.first(); | 1848 | KopiCalendarFile * cal = calendars.first(); |
1849 | mCalendar->setDefaultCalendar( 1 ); | 1849 | mCalendar->setDefaultCalendar( 1 ); |
1850 | openCalendar( MainWindow::defaultFileName(), false ); | 1850 | openCalendar( MainWindow::defaultFileName(), false ); |
1851 | cal = calendars.next(); | 1851 | cal = calendars.next(); |
1852 | while ( cal ) { | 1852 | while ( cal ) { |
1853 | addCalendar( cal ); | 1853 | addCalendar( cal ); |
1854 | cal = calendars.next(); | 1854 | cal = calendars.next(); |
1855 | } | 1855 | } |
1856 | restoreCalendarSettings(); | 1856 | restoreCalendarSettings(); |
1857 | mCalendar->reInitAlarmSettings(); | 1857 | mCalendar->reInitAlarmSettings(); |
1858 | setSyncEventsReadOnly(); | 1858 | setSyncEventsReadOnly(); |
1859 | updateUnmanagedViews(); | 1859 | updateUnmanagedViews(); |
1860 | updateView(); | 1860 | updateView(); |
1861 | } | 1861 | } |
1862 | bool CalendarView::restoreCalendarSettings() | 1862 | bool CalendarView::restoreCalendarSettings() |
1863 | { | 1863 | { |
1864 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1864 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1865 | KopiCalendarFile * cal = calendars.first(); | 1865 | KopiCalendarFile * cal = calendars.first(); |
1866 | while ( cal ) { | 1866 | while ( cal ) { |
1867 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 1867 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
1868 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1868 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1869 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1869 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1870 | if ( cal->isStandard ) | 1870 | if ( cal->isStandard ) |
1871 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1871 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1872 | cal = calendars.next(); | 1872 | cal = calendars.next(); |
1873 | } | 1873 | } |
1874 | } | 1874 | } |
1875 | void CalendarView::addCalendarId( int id ) | 1875 | void CalendarView::addCalendarId( int id ) |
1876 | { | 1876 | { |
1877 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1877 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1878 | addCalendar( cal ); | 1878 | addCalendar( cal ); |
1879 | } | 1879 | } |
1880 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1880 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1881 | { | 1881 | { |
1882 | 1882 | cal->mErrorOnLoad = false; | |
1883 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) | 1883 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1884 | cal->mLoadDt = QDateTime::currentDateTime(); | ||
1884 | return true; | 1885 | return true; |
1886 | } | ||
1885 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | 1887 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); |
1886 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | 1888 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); |
1889 | cal->mErrorOnLoad = true; | ||
1887 | return false; | 1890 | return false; |
1888 | } | 1891 | } |
1889 | bool CalendarView::openCalendar(QString filename, bool merge) | 1892 | bool CalendarView::openCalendar(QString filename, bool merge) |
1890 | { | 1893 | { |
1891 | 1894 | ||
1892 | if (filename.isEmpty()) { | 1895 | if (filename.isEmpty()) { |
1893 | return false; | 1896 | return false; |
1894 | } | 1897 | } |
1895 | 1898 | ||
1896 | if (!QFile::exists(filename)) { | 1899 | if (!QFile::exists(filename)) { |
1897 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1900 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1898 | return false; | 1901 | return false; |
1899 | } | 1902 | } |
1900 | 1903 | ||
1901 | globalFlagBlockAgenda = 1; | 1904 | globalFlagBlockAgenda = 1; |
1902 | clearAllViews(); | 1905 | clearAllViews(); |
1903 | if (!merge) { | 1906 | if (!merge) { |
1904 | mViewManager->setDocumentId( filename ); | 1907 | mViewManager->setDocumentId( filename ); |
1905 | mCalendar->close(); | 1908 | mCalendar->close(); |
1906 | } | 1909 | } |
1907 | mStorage->setFileName( filename ); | 1910 | mStorage->setFileName( filename ); |
1908 | 1911 | ||
1909 | if ( mStorage->load() ) { | 1912 | if ( mStorage->load() ) { |
1910 | if ( merge ) ;//setModified( true ); | 1913 | if ( merge ) ;//setModified( true ); |
1911 | else { | 1914 | else { |
1912 | //setModified( true ); | 1915 | //setModified( true ); |
1913 | mViewManager->setDocumentId( filename ); | 1916 | mViewManager->setDocumentId( filename ); |
1914 | mDialogManager->setDocumentId( filename ); | 1917 | mDialogManager->setDocumentId( filename ); |
1915 | mTodoList->setDocumentId( filename ); | 1918 | mTodoList->setDocumentId( filename ); |
1916 | } | 1919 | } |
1917 | globalFlagBlockAgenda = 2; | 1920 | globalFlagBlockAgenda = 2; |
1918 | // if ( getLastSyncEvent() ) | 1921 | // if ( getLastSyncEvent() ) |
1919 | // getLastSyncEvent()->setReadOnly( true ); | 1922 | // getLastSyncEvent()->setReadOnly( true ); |
1920 | mCalendar->reInitAlarmSettings(); | 1923 | mCalendar->reInitAlarmSettings(); |
1921 | setSyncEventsReadOnly(); | 1924 | setSyncEventsReadOnly(); |
1922 | updateUnmanagedViews(); | 1925 | updateUnmanagedViews(); |
1923 | updateView(); | 1926 | updateView(); |
1924 | if ( filename != MainWindow::defaultFileName() ) { | 1927 | if ( filename != MainWindow::defaultFileName() ) { |
1925 | saveCalendar( MainWindow::defaultFileName() ); | 1928 | saveCalendar( MainWindow::defaultFileName() ); |
1926 | } else { | 1929 | } else { |
1927 | QFileInfo finf ( MainWindow::defaultFileName()); | 1930 | QFileInfo finf ( MainWindow::defaultFileName()); |
1928 | if ( finf.exists() ) { | 1931 | if ( finf.exists() ) { |
1929 | setLoadedFileVersion( finf.lastModified () ); | 1932 | setLoadedFileVersion( finf.lastModified () ); |
1930 | } | 1933 | } |
1931 | } | 1934 | } |
1932 | return true; | 1935 | return true; |
1933 | } else { | 1936 | } else { |
1934 | // while failing to load, the calendar object could | 1937 | // while failing to load, the calendar object could |
1935 | // have become partially populated. Clear it out. | 1938 | // have become partially populated. Clear it out. |
1936 | if ( !merge ) { | 1939 | if ( !merge ) { |
1937 | mCalendar->close(); | 1940 | mCalendar->close(); |
1938 | mViewManager->setDocumentId( filename ); | 1941 | mViewManager->setDocumentId( filename ); |
1939 | mDialogManager->setDocumentId( filename ); | 1942 | mDialogManager->setDocumentId( filename ); |
1940 | mTodoList->setDocumentId( filename ); | 1943 | mTodoList->setDocumentId( filename ); |
1941 | } | 1944 | } |
1942 | 1945 | ||
1943 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1946 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1944 | 1947 | ||
1945 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1948 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1946 | globalFlagBlockAgenda = 2; | 1949 | globalFlagBlockAgenda = 2; |
1947 | mCalendar->reInitAlarmSettings(); | 1950 | mCalendar->reInitAlarmSettings(); |
1948 | setSyncEventsReadOnly(); | 1951 | setSyncEventsReadOnly(); |
1949 | updateUnmanagedViews(); | 1952 | updateUnmanagedViews(); |
1950 | updateView(); | 1953 | updateView(); |
1951 | } | 1954 | } |
1952 | return false; | 1955 | return false; |
1953 | } | 1956 | } |
1954 | void CalendarView::showOpenError() | 1957 | void CalendarView::showOpenError() |
1955 | { | 1958 | { |
1956 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1959 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1957 | } | 1960 | } |
1958 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1961 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1959 | { | 1962 | { |
1960 | loadedFileVersion = dt; | 1963 | loadedFileVersion = dt; |
1961 | } | 1964 | } |
1962 | bool CalendarView::checkFileChanged(QString fn) | 1965 | bool CalendarView::checkFileChanged(QString fn) |
1963 | { | 1966 | { |
1964 | QFileInfo finf ( fn ); | 1967 | QFileInfo finf ( fn ); |
1965 | if ( !finf.exists() ) | 1968 | if ( !finf.exists() ) |
1966 | return true; | 1969 | return true; |
1967 | QDateTime dt = finf.lastModified (); | 1970 | QDateTime dt = finf.lastModified (); |
1968 | if ( dt <= loadedFileVersion ) | 1971 | if ( dt <= loadedFileVersion ) |
1969 | return false; | 1972 | return false; |
1970 | return true; | 1973 | return true; |
1971 | 1974 | ||
1972 | } | 1975 | } |
1973 | void CalendarView::watchSavedFile() | 1976 | void CalendarView::watchSavedFile() |
1974 | { | 1977 | { |
1975 | QFileInfo finf ( MainWindow::defaultFileName()); | 1978 | QFileInfo finf ( MainWindow::defaultFileName()); |
1976 | if ( !finf.exists() ) | 1979 | if ( !finf.exists() ) |
1977 | return; | 1980 | return; |
1978 | QDateTime dt = finf.lastModified (); | 1981 | QDateTime dt = finf.lastModified (); |
1979 | if ( dt < loadedFileVersion ) { | 1982 | if ( dt < loadedFileVersion ) { |
1980 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1983 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1981 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1984 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1982 | return; | 1985 | return; |
1983 | } | 1986 | } |
1984 | loadedFileVersion = dt; | 1987 | loadedFileVersion = dt; |
1985 | } | 1988 | } |
1986 | 1989 | bool CalendarView::checkAllFileVersions() | |
1990 | { | ||
1991 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
1992 | KopiCalendarFile * cal = calendars.first(); | ||
1993 | mCalendar->setDefaultCalendar( 1 ); | ||
1994 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
1995 | if ( !checkFileVersion(MainWindow::defaultFileName())) | ||
1996 | return false; | ||
1997 | cal = calendars.next(); | ||
1998 | QDateTime storeTemp = loadedFileVersion; | ||
1999 | while ( cal ) { | ||
2000 | if ( !cal->mErrorOnLoad ) { | ||
2001 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | ||
2002 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2003 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | ||
2004 | if ( !checkFileVersion(cal->mFileName )) { | ||
2005 | loadedFileVersion = storeTemp; | ||
2006 | updateView(); | ||
2007 | return false; | ||
2008 | } | ||
2009 | } | ||
2010 | cal = calendars.next(); | ||
2011 | } | ||
2012 | loadedFileVersion = storeTemp; | ||
2013 | updateView(); | ||
2014 | return true; | ||
2015 | } | ||
1987 | bool CalendarView::checkFileVersion(QString fn) | 2016 | bool CalendarView::checkFileVersion(QString fn) |
1988 | { | 2017 | { |
1989 | QFileInfo finf ( fn ); | 2018 | QFileInfo finf ( fn ); |
1990 | if ( !finf.exists() ) | 2019 | if ( !finf.exists() ) |
1991 | return true; | 2020 | return true; |
1992 | QDateTime dt = finf.lastModified (); | 2021 | QDateTime dt = finf.lastModified (); |
1993 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 2022 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1994 | //qDebug("file on disk version %s",dt.toString().latin1()); | 2023 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1995 | if ( dt <= loadedFileVersion ) | 2024 | if ( dt <= loadedFileVersion ) |
1996 | return true; | 2025 | return true; |
1997 | 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)) , | 2026 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1998 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2027 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1999 | i18n("Sync+save")); | 2028 | i18n("Sync+save")); |
2000 | 2029 | ||
2001 | if ( km == KMessageBox::Cancel ) | 2030 | if ( km == KMessageBox::Cancel ) |
2002 | return false; | 2031 | return false; |
2003 | if ( km == KMessageBox::Yes ) | 2032 | if ( km == KMessageBox::Yes ) |
2004 | return true; | 2033 | return true; |
2005 | 2034 | ||
2006 | setSyncDevice("deleteaftersync" ); | 2035 | setSyncDevice("deleteaftersync" ); |
2007 | mSyncManager->mAskForPreferences = true; | 2036 | mSyncManager->mAskForPreferences = true; |
2008 | mSyncManager->mSyncAlgoPrefs = 3; | 2037 | mSyncManager->mSyncAlgoPrefs = 3; |
2009 | mSyncManager->mWriteBackFile = false; | 2038 | mSyncManager->mWriteBackFile = false; |
2010 | mSyncManager->mWriteBackExistingOnly = false; | 2039 | mSyncManager->mWriteBackExistingOnly = false; |
2011 | mSyncManager->mShowSyncSummary = false; | 2040 | mSyncManager->mShowSyncSummary = false; |
2012 | syncCalendar( fn, 3 ); | 2041 | syncCalendar( fn, 3 ); |
2013 | Event * e = getLastSyncEvent(); | 2042 | Event * e = getLastSyncEvent(); |
2014 | if ( e ) | 2043 | if ( e ) |
2015 | deleteEvent ( e ); | 2044 | mCalendar->deleteEvent( e ); |
2016 | updateView(); | ||
2017 | return true; | 2045 | return true; |
2018 | } | 2046 | } |
2019 | bool CalendarView::saveCalendars() | 2047 | bool CalendarView::saveCalendars() |
2020 | { | 2048 | { |
2021 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2049 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2022 | KopiCalendarFile * cal = calendars.first(); | 2050 | KopiCalendarFile * cal = calendars.first(); |
2023 | mCalendar->setDefaultCalendar( 1 ); | 2051 | mCalendar->setDefaultCalendar( 1 ); |
2024 | mCalendar->setDefaultCalendarEnabledOnly(); | 2052 | mCalendar->setDefaultCalendarEnabledOnly(); |
2025 | saveCalendar( MainWindow::defaultFileName() ); | 2053 | saveCalendar( MainWindow::defaultFileName() ); |
2026 | cal = calendars.next(); | 2054 | cal = calendars.next(); |
2027 | while ( cal ) { | 2055 | while ( cal ) { |
2028 | if ( !cal->isReadOnly ) { | 2056 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2029 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2057 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2030 | mCalendar->setDefaultCalendarEnabledOnly(); | 2058 | mCalendar->setDefaultCalendarEnabledOnly(); |
2031 | saveCalendar( cal->mFileName ); | 2059 | if ( saveCalendar( cal->mFileName ) ) |
2060 | cal->mLoadDt = QDateTime::currentDateTime(); | ||
2032 | } | 2061 | } |
2033 | cal = calendars.next(); | 2062 | cal = calendars.next(); |
2034 | } | 2063 | } |
2035 | restoreCalendarSettings(); | 2064 | restoreCalendarSettings(); |
2036 | } | 2065 | } |
2037 | bool CalendarView::saveCalendar( QString filename ) | 2066 | bool CalendarView::saveCalendar( QString filename ) |
2038 | { | 2067 | { |
2039 | 2068 | ||
2040 | // Store back all unsaved data into calendar object | 2069 | // Store back all unsaved data into calendar object |
2041 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2070 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2042 | if ( mViewManager->currentView() ) | 2071 | if ( mViewManager->currentView() ) |
2043 | mViewManager->currentView()->flushView(); | 2072 | mViewManager->currentView()->flushView(); |
2044 | 2073 | ||
2045 | 2074 | ||
2046 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2075 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2047 | mStorage->setSaveFormat( new ICalFormat() ); | 2076 | mStorage->setSaveFormat( new ICalFormat() ); |
2048 | mStorage->setFileName( filename ); | 2077 | mStorage->setFileName( filename ); |
2049 | bool success; | 2078 | bool success; |
2050 | success = mStorage->save(); | 2079 | success = mStorage->save(); |
2051 | if ( !success ) { | 2080 | if ( !success ) { |
2052 | return false; | 2081 | return false; |
2053 | } | 2082 | } |
2054 | if ( filename == MainWindow::defaultFileName() ) { | 2083 | if ( filename == MainWindow::defaultFileName() ) { |
2055 | setLoadedFileVersion( lfv ); | 2084 | setLoadedFileVersion( lfv ); |
2056 | watchSavedFile(); | 2085 | watchSavedFile(); |
2057 | } | 2086 | } |
2058 | return true; | 2087 | return true; |
2059 | } | 2088 | } |
2060 | 2089 | ||
2061 | void CalendarView::closeCalendar() | 2090 | void CalendarView::closeCalendar() |
2062 | { | 2091 | { |
2063 | 2092 | ||
2064 | // child windows no longer valid | 2093 | // child windows no longer valid |
2065 | clearAllViews(); | 2094 | clearAllViews(); |
2066 | emit closingDown(); | 2095 | emit closingDown(); |
2067 | 2096 | ||
2068 | mCalendar->close(); | 2097 | mCalendar->close(); |
2069 | setModified(false); | 2098 | setModified(false); |
2070 | updateView(); | 2099 | updateView(); |
2071 | } | 2100 | } |
2072 | 2101 | ||
2073 | void CalendarView::archiveCalendar() | 2102 | void CalendarView::archiveCalendar() |
2074 | { | 2103 | { |
2075 | mDialogManager->showArchiveDialog(); | 2104 | mDialogManager->showArchiveDialog(); |
2076 | } | 2105 | } |
2077 | 2106 | ||
2078 | 2107 | ||
2079 | void CalendarView::readSettings() | 2108 | void CalendarView::readSettings() |
2080 | { | 2109 | { |
2081 | 2110 | ||
2082 | 2111 | ||
2083 | // mViewManager->showAgendaView(); | 2112 | // mViewManager->showAgendaView(); |
2084 | QString str; | 2113 | QString str; |
2085 | //qDebug("CalendarView::readSettings() "); | 2114 | //qDebug("CalendarView::readSettings() "); |
2086 | // read settings from the KConfig, supplying reasonable | 2115 | // read settings from the KConfig, supplying reasonable |
2087 | // defaults where none are to be found | 2116 | // defaults where none are to be found |
2088 | KConfig *config = KOGlobals::config(); | 2117 | KConfig *config = KOGlobals::config(); |
2089 | #ifndef KORG_NOSPLITTER | 2118 | #ifndef KORG_NOSPLITTER |
2090 | config->setGroup("KOrganizer Geometry"); | 2119 | config->setGroup("KOrganizer Geometry"); |
2091 | 2120 | ||
2092 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2121 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2093 | if (sizes.count() != 2) { | 2122 | if (sizes.count() != 2) { |
2094 | sizes << mDateNavigator->minimumSizeHint().width(); | 2123 | sizes << mDateNavigator->minimumSizeHint().width(); |
2095 | sizes << 300; | 2124 | sizes << 300; |
2096 | } | 2125 | } |
2097 | mPanner->setSizes(sizes); | 2126 | mPanner->setSizes(sizes); |
2098 | 2127 | ||
2099 | sizes = config->readIntListEntry("Separator2"); | 2128 | sizes = config->readIntListEntry("Separator2"); |
2100 | if ( ( mResourceView && sizes.count() == 4 ) || | 2129 | if ( ( mResourceView && sizes.count() == 4 ) || |
2101 | ( !mResourceView && sizes.count() == 3 ) ) { | 2130 | ( !mResourceView && sizes.count() == 3 ) ) { |
2102 | mLeftSplitter->setSizes(sizes); | 2131 | mLeftSplitter->setSizes(sizes); |
2103 | } | 2132 | } |
2104 | #endif | 2133 | #endif |
2105 | globalFlagBlockAgenda = 1; | 2134 | globalFlagBlockAgenda = 1; |
2106 | mViewManager->showAgendaView(); | 2135 | mViewManager->showAgendaView(); |
2107 | //mViewManager->readSettings( config ); | 2136 | //mViewManager->readSettings( config ); |
2108 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2137 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2109 | readFilterSettings(config); | 2138 | readFilterSettings(config); |
2110 | 2139 | ||
2111 | #ifdef DESKTOP_VERSION | 2140 | #ifdef DESKTOP_VERSION |
2112 | config->setGroup("WidgetLayout"); | 2141 | config->setGroup("WidgetLayout"); |
2113 | QStringList list; | 2142 | QStringList list; |
2114 | list = config->readListEntry("MainLayout"); | 2143 | list = config->readListEntry("MainLayout"); |
2115 | int x,y,w,h; | 2144 | int x,y,w,h; |
2116 | if ( ! list.isEmpty() ) { | 2145 | if ( ! list.isEmpty() ) { |
2117 | x = list[0].toInt(); | 2146 | x = list[0].toInt(); |
2118 | y = list[1].toInt(); | 2147 | y = list[1].toInt(); |
2119 | w = list[2].toInt(); | 2148 | w = list[2].toInt(); |
2120 | h = list[3].toInt(); | 2149 | h = list[3].toInt(); |
2121 | KApplication::testCoords( &x,&y,&w,&h ); | 2150 | KApplication::testCoords( &x,&y,&w,&h ); |
2122 | topLevelWidget()->setGeometry(x,y,w,h); | 2151 | topLevelWidget()->setGeometry(x,y,w,h); |
2123 | 2152 | ||
2124 | } else { | 2153 | } else { |
2125 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2154 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2126 | } | 2155 | } |
2127 | list = config->readListEntry("EditEventLayout"); | 2156 | list = config->readListEntry("EditEventLayout"); |
2128 | if ( ! list.isEmpty() ) { | 2157 | if ( ! list.isEmpty() ) { |
2129 | x = list[0].toInt(); | 2158 | x = list[0].toInt(); |
2130 | y = list[1].toInt(); | 2159 | y = list[1].toInt(); |
2131 | w = list[2].toInt(); | 2160 | w = list[2].toInt(); |
2132 | h = list[3].toInt(); | 2161 | h = list[3].toInt(); |
2133 | KApplication::testCoords( &x,&y,&w,&h ); | 2162 | KApplication::testCoords( &x,&y,&w,&h ); |
2134 | mEventEditor->setGeometry(x,y,w,h); | 2163 | mEventEditor->setGeometry(x,y,w,h); |
2135 | 2164 | ||
2136 | } | 2165 | } |
2137 | list = config->readListEntry("EditTodoLayout"); | 2166 | list = config->readListEntry("EditTodoLayout"); |
2138 | if ( ! list.isEmpty() ) { | 2167 | if ( ! list.isEmpty() ) { |
2139 | x = list[0].toInt(); | 2168 | x = list[0].toInt(); |
2140 | y = list[1].toInt(); | 2169 | y = list[1].toInt(); |
2141 | w = list[2].toInt(); | 2170 | w = list[2].toInt(); |
2142 | h = list[3].toInt(); | 2171 | h = list[3].toInt(); |
2143 | KApplication::testCoords( &x,&y,&w,&h ); | 2172 | KApplication::testCoords( &x,&y,&w,&h ); |
2144 | mTodoEditor->setGeometry(x,y,w,h); | 2173 | mTodoEditor->setGeometry(x,y,w,h); |
2145 | 2174 | ||
2146 | } | 2175 | } |
2147 | list = config->readListEntry("ViewerLayout"); | 2176 | list = config->readListEntry("ViewerLayout"); |
2148 | if ( ! list.isEmpty() ) { | 2177 | if ( ! list.isEmpty() ) { |
2149 | x = list[0].toInt(); | 2178 | x = list[0].toInt(); |
2150 | y = list[1].toInt(); | 2179 | y = list[1].toInt(); |
2151 | w = list[2].toInt(); | 2180 | w = list[2].toInt(); |
2152 | h = list[3].toInt(); | 2181 | h = list[3].toInt(); |
2153 | KApplication::testCoords( &x,&y,&w,&h ); | 2182 | KApplication::testCoords( &x,&y,&w,&h ); |
2154 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2183 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2155 | } | 2184 | } |
2156 | #endif | 2185 | #endif |
2157 | config->setGroup( "Views" ); | 2186 | config->setGroup( "Views" ); |
2158 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2187 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2159 | 2188 | ||
2160 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2189 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2161 | 2190 | ||
2162 | int resetval = 0; | 2191 | int resetval = 0; |
2163 | int maxVal = 0; | 2192 | int maxVal = 0; |
2164 | if (sizes.count() != 3) { | 2193 | if (sizes.count() != 3) { |
2165 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2194 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2166 | resetval = mDateNavigator->sizeHint().width()+2; | 2195 | resetval = mDateNavigator->sizeHint().width()+2; |
2167 | } else { | 2196 | } else { |
2168 | resetval = mDateNavigator->sizeHint().height()+2; | 2197 | resetval = mDateNavigator->sizeHint().height()+2; |
2169 | } | 2198 | } |
2170 | } | 2199 | } |
2171 | if ( resetval ) { | 2200 | if ( resetval ) { |
2172 | sizes.clear(); | 2201 | sizes.clear(); |
2173 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2202 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2174 | maxVal = QApplication::desktop()->width() -10; | 2203 | maxVal = QApplication::desktop()->width() -10; |
2175 | } else { | 2204 | } else { |
2176 | maxVal = QApplication::desktop()->height()-10; | 2205 | maxVal = QApplication::desktop()->height()-10; |
2177 | } | 2206 | } |
2178 | sizes << resetval; | 2207 | sizes << resetval; |
2179 | if ( maxVal < resetval + resetval) | 2208 | if ( maxVal < resetval + resetval) |
2180 | resetval = maxVal - resetval; | 2209 | resetval = maxVal - resetval; |
2181 | sizes << resetval; | 2210 | sizes << resetval; |
2182 | sizes << 100; | 2211 | sizes << 100; |
2183 | } | 2212 | } |
2184 | mLeftFrame->setSizes(sizes); | 2213 | mLeftFrame->setSizes(sizes); |
2185 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2214 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2186 | resetval = 0; | 2215 | resetval = 0; |
2187 | maxVal = 0; | 2216 | maxVal = 0; |
2188 | if (sizes.count() != 2) { | 2217 | if (sizes.count() != 2) { |
2189 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2218 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2190 | resetval = mDateNavigator->sizeHint().width()+2; | 2219 | resetval = mDateNavigator->sizeHint().width()+2; |
2191 | } else { | 2220 | } else { |
2192 | resetval = mDateNavigator->sizeHint().height()+2; | 2221 | resetval = mDateNavigator->sizeHint().height()+2; |
2193 | } | 2222 | } |
2194 | } | 2223 | } |
2195 | if ( resetval ) { | 2224 | if ( resetval ) { |
2196 | sizes.clear(); | 2225 | sizes.clear(); |
2197 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2226 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2198 | maxVal = QApplication::desktop()->width() -10; | 2227 | maxVal = QApplication::desktop()->width() -10; |
2199 | } else { | 2228 | } else { |
2200 | maxVal = QApplication::desktop()->height()-10; | 2229 | maxVal = QApplication::desktop()->height()-10; |
2201 | } | 2230 | } |
2202 | sizes << resetval; | 2231 | sizes << resetval; |
2203 | if ( maxVal < resetval + resetval) | 2232 | if ( maxVal < resetval + resetval) |
2204 | resetval = maxVal - resetval; | 2233 | resetval = maxVal - resetval; |
2205 | sizes << resetval; | 2234 | sizes << resetval; |
2206 | } | 2235 | } |
2207 | mMainFrame->setSizes(sizes); | 2236 | mMainFrame->setSizes(sizes); |
2208 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2237 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2209 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2238 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2210 | else mNavigator->selectDates( dateCount ); | 2239 | else mNavigator->selectDates( dateCount ); |
2211 | // mViewManager->readSettings( config ); | 2240 | // mViewManager->readSettings( config ); |
2212 | updateConfig(); | 2241 | updateConfig(); |
2213 | globalFlagBlockAgenda = 2; | 2242 | globalFlagBlockAgenda = 2; |
2214 | mViewManager->readSettings( config ); | 2243 | mViewManager->readSettings( config ); |
2215 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2244 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2216 | } | 2245 | } |
2217 | 2246 | ||
2218 | 2247 | ||
2219 | void CalendarView::writeSettings() | 2248 | void CalendarView::writeSettings() |
2220 | { | 2249 | { |
2221 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2250 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2222 | 2251 | ||
2223 | KConfig *config = KOGlobals::config(); | 2252 | KConfig *config = KOGlobals::config(); |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index ec5b7ab..d836fee 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -321,331 +321,332 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
321 | void writeFilterSettings(KConfig *config); | 321 | void writeFilterSettings(KConfig *config); |
322 | 322 | ||
323 | /** passes on the message that an event has changed to the currently | 323 | /** passes on the message that an event has changed to the currently |
324 | * activated view so that it can make appropriate display changes. */ | 324 | * activated view so that it can make appropriate display changes. */ |
325 | void changeEventDisplay(Event *, int); | 325 | void changeEventDisplay(Event *, int); |
326 | void changeIncidenceDisplay(Incidence *, int); | 326 | void changeIncidenceDisplay(Incidence *, int); |
327 | void changeTodoDisplay(Todo *, int); | 327 | void changeTodoDisplay(Todo *, int); |
328 | 328 | ||
329 | void eventAdded(Event *); | 329 | void eventAdded(Event *); |
330 | void eventChanged(Event *); | 330 | void eventChanged(Event *); |
331 | void eventToBeDeleted(Event *); | 331 | void eventToBeDeleted(Event *); |
332 | void eventDeleted(); | 332 | void eventDeleted(); |
333 | 333 | ||
334 | void todoAdded(Todo *); | 334 | void todoAdded(Todo *); |
335 | void todoChanged(Todo *); | 335 | void todoChanged(Todo *); |
336 | void todoToBeDeleted(Todo *); | 336 | void todoToBeDeleted(Todo *); |
337 | void todoDeleted(); | 337 | void todoDeleted(); |
338 | 338 | ||
339 | void updateView(const QDate &start, const QDate &end); | 339 | void updateView(const QDate &start, const QDate &end); |
340 | void updateView(); | 340 | void updateView(); |
341 | void clearAllViews(); | 341 | void clearAllViews(); |
342 | 342 | ||
343 | /** Full update of visible todo views */ | 343 | /** Full update of visible todo views */ |
344 | void updateTodoViews(); | 344 | void updateTodoViews(); |
345 | 345 | ||
346 | void updateUnmanagedViews(); | 346 | void updateUnmanagedViews(); |
347 | 347 | ||
348 | /** cut the current appointment to the clipboard */ | 348 | /** cut the current appointment to the clipboard */ |
349 | void edit_cut(); | 349 | void edit_cut(); |
350 | 350 | ||
351 | /** copy the current appointment(s) to the clipboard */ | 351 | /** copy the current appointment(s) to the clipboard */ |
352 | void edit_copy(); | 352 | void edit_copy(); |
353 | 353 | ||
354 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 354 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
355 | void edit_paste(); | 355 | void edit_paste(); |
356 | 356 | ||
357 | /** edit viewing and configuration options. */ | 357 | /** edit viewing and configuration options. */ |
358 | void edit_options(); | 358 | void edit_options(); |
359 | void edit_global_options(); | 359 | void edit_global_options(); |
360 | /** | 360 | /** |
361 | Functions for printing, previewing a print, and setting up printing | 361 | Functions for printing, previewing a print, and setting up printing |
362 | parameters. | 362 | parameters. |
363 | */ | 363 | */ |
364 | void print(); | 364 | void print(); |
365 | void printSetup(); | 365 | void printSetup(); |
366 | void printPreview(); | 366 | void printPreview(); |
367 | 367 | ||
368 | /** Export as iCalendar file */ | 368 | /** Export as iCalendar file */ |
369 | void exportICalendar(); | 369 | void exportICalendar(); |
370 | 370 | ||
371 | /** Export as vCalendar file */ | 371 | /** Export as vCalendar file */ |
372 | bool exportVCalendar( QString fn); | 372 | bool exportVCalendar( QString fn); |
373 | 373 | ||
374 | /** pop up a dialog to show an existing appointment. */ | 374 | /** pop up a dialog to show an existing appointment. */ |
375 | void appointment_show(); | 375 | void appointment_show(); |
376 | /** | 376 | /** |
377 | * pop up an Appointment Dialog to edit an existing appointment.Get | 377 | * pop up an Appointment Dialog to edit an existing appointment.Get |
378 | * information on the appointment from the list of unique IDs that is | 378 | * information on the appointment from the list of unique IDs that is |
379 | * currently in the View, called currIds. | 379 | * currently in the View, called currIds. |
380 | */ | 380 | */ |
381 | void appointment_edit(); | 381 | void appointment_edit(); |
382 | /** | 382 | /** |
383 | * pop up dialog confirming deletion of currently selected event in the | 383 | * pop up dialog confirming deletion of currently selected event in the |
384 | * View. | 384 | * View. |
385 | */ | 385 | */ |
386 | void appointment_delete(); | 386 | void appointment_delete(); |
387 | 387 | ||
388 | /** mails the currently selected event to a particular user as a vCalendar | 388 | /** mails the currently selected event to a particular user as a vCalendar |
389 | attachment. */ | 389 | attachment. */ |
390 | void action_mail(); | 390 | void action_mail(); |
391 | 391 | ||
392 | /* frees a subtodo from it's relation */ | 392 | /* frees a subtodo from it's relation */ |
393 | void todo_unsub( Todo * ); | 393 | void todo_unsub( Todo * ); |
394 | void todo_resub( Todo * parent, Todo * sub ); | 394 | void todo_resub( Todo * parent, Todo * sub ); |
395 | 395 | ||
396 | /** Take ownership of selected event. */ | 396 | /** Take ownership of selected event. */ |
397 | void takeOverEvent(); | 397 | void takeOverEvent(); |
398 | 398 | ||
399 | /** Take ownership of all events in calendar. */ | 399 | /** Take ownership of all events in calendar. */ |
400 | void takeOverCalendar(); | 400 | void takeOverCalendar(); |
401 | 401 | ||
402 | /** query whether or not the calendar is "dirty". */ | 402 | /** query whether or not the calendar is "dirty". */ |
403 | bool isModified(); | 403 | bool isModified(); |
404 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 404 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
405 | void setModified(bool modified=true); | 405 | void setModified(bool modified=true); |
406 | 406 | ||
407 | /** query if the calendar is read-only. */ | 407 | /** query if the calendar is read-only. */ |
408 | bool isReadOnly(); | 408 | bool isReadOnly(); |
409 | /** set state of calendar to read-only */ | 409 | /** set state of calendar to read-only */ |
410 | void setReadOnly(bool readOnly=true); | 410 | void setReadOnly(bool readOnly=true); |
411 | 411 | ||
412 | void eventUpdated(Incidence *); | 412 | void eventUpdated(Incidence *); |
413 | 413 | ||
414 | /* iTIP scheduling actions */ | 414 | /* iTIP scheduling actions */ |
415 | void schedule_publish(Incidence *incidence = 0); | 415 | void schedule_publish(Incidence *incidence = 0); |
416 | void schedule_request(Incidence *incidence = 0); | 416 | void schedule_request(Incidence *incidence = 0); |
417 | void schedule_refresh(Incidence *incidence = 0); | 417 | void schedule_refresh(Incidence *incidence = 0); |
418 | void schedule_cancel(Incidence *incidence = 0); | 418 | void schedule_cancel(Incidence *incidence = 0); |
419 | void schedule_add(Incidence *incidence = 0); | 419 | void schedule_add(Incidence *incidence = 0); |
420 | void schedule_reply(Incidence *incidence = 0); | 420 | void schedule_reply(Incidence *incidence = 0); |
421 | void schedule_counter(Incidence *incidence = 0); | 421 | void schedule_counter(Incidence *incidence = 0); |
422 | void schedule_declinecounter(Incidence *incidence = 0); | 422 | void schedule_declinecounter(Incidence *incidence = 0); |
423 | void schedule_publish_freebusy(int daysToPublish = 30); | 423 | void schedule_publish_freebusy(int daysToPublish = 30); |
424 | 424 | ||
425 | void openAddressbook(); | 425 | void openAddressbook(); |
426 | 426 | ||
427 | void editFilters(); | 427 | void editFilters(); |
428 | void toggleFilerEnabled(); | 428 | void toggleFilerEnabled(); |
429 | QPtrList<CalFilter> filters(); | 429 | QPtrList<CalFilter> filters(); |
430 | void toggleFilter(); | 430 | void toggleFilter(); |
431 | void showFilter(bool visible); | 431 | void showFilter(bool visible); |
432 | void updateFilter(); | 432 | void updateFilter(); |
433 | void filterEdited(); | 433 | void filterEdited(); |
434 | void selectFilter( int ); | 434 | void selectFilter( int ); |
435 | KOFilterView *filterView(); | 435 | KOFilterView *filterView(); |
436 | 436 | ||
437 | void showIntro(); | 437 | void showIntro(); |
438 | 438 | ||
439 | /** Move the curdatepient view date to today */ | 439 | /** Move the curdatepient view date to today */ |
440 | void goToday(); | 440 | void goToday(); |
441 | 441 | ||
442 | /** Move to the next date(s) in the current view */ | 442 | /** Move to the next date(s) in the current view */ |
443 | void goNext(); | 443 | void goNext(); |
444 | 444 | ||
445 | /** Move to the previous date(s) in the current view */ | 445 | /** Move to the previous date(s) in the current view */ |
446 | void goPrevious(); | 446 | void goPrevious(); |
447 | /** Move to the next date(s) in the current view */ | 447 | /** Move to the next date(s) in the current view */ |
448 | void goNextMonth(); | 448 | void goNextMonth(); |
449 | 449 | ||
450 | /** Move to the previous date(s) in the current view */ | 450 | /** Move to the previous date(s) in the current view */ |
451 | void goPreviousMonth(); | 451 | void goPreviousMonth(); |
452 | 452 | ||
453 | void toggleExpand(); | 453 | void toggleExpand(); |
454 | void toggleDateNavigatorWidget(); | 454 | void toggleDateNavigatorWidget(); |
455 | void toggleAllDaySize(); | 455 | void toggleAllDaySize(); |
456 | void dialogClosing(Incidence *); | 456 | void dialogClosing(Incidence *); |
457 | 457 | ||
458 | /** Look for new messages in the inbox */ | 458 | /** Look for new messages in the inbox */ |
459 | void lookForIncomingMessages(); | 459 | void lookForIncomingMessages(); |
460 | /** Look for new messages in the outbox */ | 460 | /** Look for new messages in the outbox */ |
461 | void lookForOutgoingMessages(); | 461 | void lookForOutgoingMessages(); |
462 | 462 | ||
463 | void processMainViewSelection( Incidence * ); | 463 | void processMainViewSelection( Incidence * ); |
464 | void processTodoListSelection( Incidence * ); | 464 | void processTodoListSelection( Incidence * ); |
465 | 465 | ||
466 | void processIncidenceSelection( Incidence * ); | 466 | void processIncidenceSelection( Incidence * ); |
467 | 467 | ||
468 | void purgeCompleted(); | 468 | void purgeCompleted(); |
469 | bool removeCompletedSubTodos( Todo* ); | 469 | bool removeCompletedSubTodos( Todo* ); |
470 | void slotCalendarChanged(); | 470 | void slotCalendarChanged(); |
471 | bool importBday(); | 471 | bool importBday(); |
472 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 472 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
473 | bool importQtopia( const QString &categoriesFile, | 473 | bool importQtopia( const QString &categoriesFile, |
474 | const QString &datebookFile, | 474 | const QString &datebookFile, |
475 | const QString &tasklistFile ); | 475 | const QString &tasklistFile ); |
476 | void syncExternal( int mode ); | 476 | void syncExternal( int mode ); |
477 | void slotSelectPickerDate( QDate ) ; | 477 | void slotSelectPickerDate( QDate ) ; |
478 | void showDatePicker() ; | 478 | void showDatePicker() ; |
479 | void showDatePickerPopup() ; | 479 | void showDatePickerPopup() ; |
480 | void moveIncidence(Incidence *) ; | 480 | void moveIncidence(Incidence *) ; |
481 | void beamIncidence(Incidence *) ; | 481 | void beamIncidence(Incidence *) ; |
482 | void beamCalendar() ; | 482 | void beamCalendar() ; |
483 | void beamFilteredCalendar() ; | 483 | void beamFilteredCalendar() ; |
484 | void beamIncidenceList(QPtrList<Incidence>) ; | 484 | void beamIncidenceList(QPtrList<Incidence>) ; |
485 | void manageCategories(); | 485 | void manageCategories(); |
486 | int addCategories(); | 486 | int addCategories(); |
487 | void removeCategories(); | 487 | void removeCategories(); |
488 | void setSyncDevice( QString ); | 488 | void setSyncDevice( QString ); |
489 | void setSyncName( QString ); | 489 | void setSyncName( QString ); |
490 | void showDay( QDate ); | 490 | void showDay( QDate ); |
491 | void undo_delete(); | 491 | void undo_delete(); |
492 | protected slots: | 492 | protected slots: |
493 | void resetFocus(); | 493 | void resetFocus(); |
494 | void slotViewerClosed(); | 494 | void slotViewerClosed(); |
495 | void timerAlarm(); | 495 | void timerAlarm(); |
496 | void suspendAlarm(); | 496 | void suspendAlarm(); |
497 | void beamDone( Ir *ir ); | 497 | void beamDone( Ir *ir ); |
498 | /** Select a view or adapt the current view to display the specified dates. */ | 498 | /** Select a view or adapt the current view to display the specified dates. */ |
499 | void showDates( const KCal::DateList & ); | 499 | void showDates( const KCal::DateList & ); |
500 | void selectWeekNum ( int ); | 500 | void selectWeekNum ( int ); |
501 | 501 | ||
502 | public: | 502 | public: |
503 | // show a standard warning | 503 | // show a standard warning |
504 | // returns KMsgBox::yesNoCancel() | 504 | // returns KMsgBox::yesNoCancel() |
505 | int msgCalModified(); | 505 | int msgCalModified(); |
506 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 506 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
507 | 507 | ||
508 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 508 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
509 | virtual void removeSyncInfo( QString syncProfile); | 509 | virtual void removeSyncInfo( QString syncProfile); |
510 | void setSyncManager(KSyncManager* manager); | 510 | void setSyncManager(KSyncManager* manager); |
511 | void setLoadedFileVersion(QDateTime); | 511 | void setLoadedFileVersion(QDateTime); |
512 | bool checkFileVersion(QString fn); | 512 | bool checkFileVersion(QString fn); |
513 | bool checkAllFileVersions(); | ||
513 | bool checkFileChanged(QString fn); | 514 | bool checkFileChanged(QString fn); |
514 | Event* getLastSyncEvent(); | 515 | Event* getLastSyncEvent(); |
515 | /** Adapt navigation units correpsonding to step size of navigation of the | 516 | /** Adapt navigation units correpsonding to step size of navigation of the |
516 | * current view. | 517 | * current view. |
517 | */ | 518 | */ |
518 | void adaptNavigationUnits(); | 519 | void adaptNavigationUnits(); |
519 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 520 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
520 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 521 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
521 | //Attendee* getYourAttendee(Event *event); | 522 | //Attendee* getYourAttendee(Event *event); |
522 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 523 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
523 | protected: | 524 | protected: |
524 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 525 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
525 | 526 | ||
526 | // returns KMsgBox::OKCandel() | 527 | // returns KMsgBox::OKCandel() |
527 | int msgItemDelete(const QString name); | 528 | int msgItemDelete(const QString name); |
528 | void showEventEditor(); | 529 | void showEventEditor(); |
529 | void showTodoEditor(); | 530 | void showTodoEditor(); |
530 | void writeLocale(); | 531 | void writeLocale(); |
531 | Todo *selectedTodo(); | 532 | Todo *selectedTodo(); |
532 | 533 | ||
533 | private: | 534 | private: |
534 | QDateTime mNextAlarmDateTime; | 535 | QDateTime mNextAlarmDateTime; |
535 | bool mViewerCallerIsSearchDialog; | 536 | bool mViewerCallerIsSearchDialog; |
536 | bool mBlockShowDates; | 537 | bool mBlockShowDates; |
537 | KSyncManager* mSyncManager; | 538 | KSyncManager* mSyncManager; |
538 | AlarmDialog * mAlarmDialog; | 539 | AlarmDialog * mAlarmDialog; |
539 | QString mAlarmNotification; | 540 | QString mAlarmNotification; |
540 | QString mSuspendAlarmNotification; | 541 | QString mSuspendAlarmNotification; |
541 | QTimer* mSuspendTimer; | 542 | QTimer* mSuspendTimer; |
542 | QTimer* mAlarmTimer; | 543 | QTimer* mAlarmTimer; |
543 | QTimer* mRecheckAlarmTimer; | 544 | QTimer* mRecheckAlarmTimer; |
544 | void computeAlarm( QString ); | 545 | void computeAlarm( QString ); |
545 | void startAlarm( QString, QString ); | 546 | void startAlarm( QString, QString ); |
546 | void setSyncEventsReadOnly(); | 547 | void setSyncEventsReadOnly(); |
547 | 548 | ||
548 | QDateTime loadedFileVersion; | 549 | QDateTime loadedFileVersion; |
549 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 550 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
550 | void checkExternalId( Incidence * inc ); | 551 | void checkExternalId( Incidence * inc ); |
551 | int mGlobalSyncMode; | 552 | int mGlobalSyncMode; |
552 | QString mCurrentSyncDevice; | 553 | QString mCurrentSyncDevice; |
553 | QString mCurrentSyncName; | 554 | QString mCurrentSyncName; |
554 | KOBeamPrefs* beamDialog; | 555 | KOBeamPrefs* beamDialog; |
555 | void init(); | 556 | void init(); |
556 | int mDatePickerMode; | 557 | int mDatePickerMode; |
557 | bool mFlagEditDescription; | 558 | bool mFlagEditDescription; |
558 | QDateTime mLastCalendarSync; | 559 | QDateTime mLastCalendarSync; |
559 | void createPrinter(); | 560 | void createPrinter(); |
560 | 561 | ||
561 | void calendarModified( bool, Calendar * ); | 562 | void calendarModified( bool, Calendar * ); |
562 | 563 | ||
563 | CalPrinter *mCalPrinter; | 564 | CalPrinter *mCalPrinter; |
564 | 565 | ||
565 | QSplitter *mPanner; | 566 | QSplitter *mPanner; |
566 | QSplitter *mLeftSplitter; | 567 | QSplitter *mLeftSplitter; |
567 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 568 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
568 | QWidgetStack *mRightFrame; | 569 | QWidgetStack *mRightFrame; |
569 | 570 | ||
570 | KDatePicker* mDatePicker; | 571 | KDatePicker* mDatePicker; |
571 | QVBox* mDateFrame; | 572 | QVBox* mDateFrame; |
572 | 573 | ||
573 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 574 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
574 | 575 | ||
575 | KOFilterView *mFilterView; | 576 | KOFilterView *mFilterView; |
576 | KOCalEditView *mCalEditView; | 577 | KOCalEditView *mCalEditView; |
577 | 578 | ||
578 | ResourceView *mResourceView; | 579 | ResourceView *mResourceView; |
579 | 580 | ||
580 | // calendar object for this viewing instance | 581 | // calendar object for this viewing instance |
581 | Calendar *mCalendar; | 582 | Calendar *mCalendar; |
582 | 583 | ||
583 | CalendarResourceManager *mResourceManager; | 584 | CalendarResourceManager *mResourceManager; |
584 | 585 | ||
585 | FileStorage *mStorage; | 586 | FileStorage *mStorage; |
586 | 587 | ||
587 | DateNavigator *mNavigator; | 588 | DateNavigator *mNavigator; |
588 | 589 | ||
589 | KOViewManager *mViewManager; | 590 | KOViewManager *mViewManager; |
590 | KODialogManager *mDialogManager; | 591 | KODialogManager *mDialogManager; |
591 | 592 | ||
592 | // Calendar filters | 593 | // Calendar filters |
593 | QPtrList<CalFilter> mFilters; | 594 | QPtrList<CalFilter> mFilters; |
594 | 595 | ||
595 | // various housekeeping variables. | 596 | // various housekeeping variables. |
596 | bool mModified; // flag indicating if calendar is modified | 597 | bool mModified; // flag indicating if calendar is modified |
597 | bool mReadOnly; // flag indicating if calendar is read-only | 598 | bool mReadOnly; // flag indicating if calendar is read-only |
598 | QDate mSaveSingleDate; | 599 | QDate mSaveSingleDate; |
599 | 600 | ||
600 | Incidence *mSelectedIncidence; | 601 | Incidence *mSelectedIncidence; |
601 | Incidence *mMoveIncidence; | 602 | Incidence *mMoveIncidence; |
602 | QDate mMoveIncidenceOldDate; | 603 | QDate mMoveIncidenceOldDate; |
603 | KOTodoView *mTodoList; | 604 | KOTodoView *mTodoList; |
604 | KOEventEditor * mEventEditor; | 605 | KOEventEditor * mEventEditor; |
605 | KOTodoEditor * mTodoEditor; | 606 | KOTodoEditor * mTodoEditor; |
606 | KOEventViewerDialog * mEventViewerDialog; | 607 | KOEventViewerDialog * mEventViewerDialog; |
607 | void keyPressEvent ( QKeyEvent *e) ; | 608 | void keyPressEvent ( QKeyEvent *e) ; |
608 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 609 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
609 | }; | 610 | }; |
610 | 611 | ||
611 | 612 | ||
612 | class CalendarViewVisitor : public Incidence::Visitor | 613 | class CalendarViewVisitor : public Incidence::Visitor |
613 | { | 614 | { |
614 | public: | 615 | public: |
615 | CalendarViewVisitor() : mView( 0 ) {} | 616 | CalendarViewVisitor() : mView( 0 ) {} |
616 | 617 | ||
617 | bool act( Incidence *incidence, CalendarView *view ) | 618 | bool act( Incidence *incidence, CalendarView *view ) |
618 | { | 619 | { |
619 | mView = view; | 620 | mView = view; |
620 | return incidence->accept( *this ); | 621 | return incidence->accept( *this ); |
621 | } | 622 | } |
622 | 623 | ||
623 | protected: | 624 | protected: |
624 | CalendarView *mView; | 625 | CalendarView *mView; |
625 | }; | 626 | }; |
626 | 627 | ||
627 | class ShowIncidenceVisitor : public CalendarViewVisitor | 628 | class ShowIncidenceVisitor : public CalendarViewVisitor |
628 | { | 629 | { |
629 | protected: | 630 | protected: |
630 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 631 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
631 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 632 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
632 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 633 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
633 | }; | 634 | }; |
634 | 635 | ||
635 | class EditIncidenceVisitor : public CalendarViewVisitor | 636 | class EditIncidenceVisitor : public CalendarViewVisitor |
636 | { | 637 | { |
637 | protected: | 638 | protected: |
638 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 639 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
639 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 640 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
640 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 641 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
641 | }; | 642 | }; |
642 | 643 | ||
643 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 644 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
644 | { | 645 | { |
645 | protected: | 646 | protected: |
646 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 647 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
647 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 648 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
648 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 649 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
649 | }; | 650 | }; |
650 | 651 | ||
651 | #endif | 652 | #endif |
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 361eec8..19d731f 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -42,350 +42,366 @@ | |||
42 | #include <kurlrequester.h> | 42 | #include <kurlrequester.h> |
43 | #include <klineedit.h> | 43 | #include <klineedit.h> |
44 | 44 | ||
45 | class KONewCalPrefs : public QDialog | 45 | class KONewCalPrefs : public QDialog |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : | 48 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : |
49 | QDialog( parent, name, true ) | 49 | QDialog( parent, name, true ) |
50 | { | 50 | { |
51 | setCaption( i18n("Add new Calendar") ); | 51 | setCaption( i18n("Add new Calendar") ); |
52 | QVBoxLayout* lay = new QVBoxLayout( this ); | 52 | QVBoxLayout* lay = new QVBoxLayout( this ); |
53 | lay->setSpacing( 3 ); | 53 | lay->setSpacing( 3 ); |
54 | lay->setMargin( 3 ); | 54 | lay->setMargin( 3 ); |
55 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); | 55 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); |
56 | lay->addWidget( lab ); | 56 | lay->addWidget( lab ); |
57 | nameE = new KLineEdit( this ); | 57 | nameE = new KLineEdit( this ); |
58 | lay->addWidget( nameE ); | 58 | lay->addWidget( nameE ); |
59 | lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); | 59 | lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); |
60 | lay->addWidget( lab ); | 60 | lay->addWidget( lab ); |
61 | url = new KURLRequester ( this ); | 61 | url = new KURLRequester ( this ); |
62 | lay->addWidget( url ); | 62 | lay->addWidget( url ); |
63 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 63 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
64 | lay->addWidget( ok ); | 64 | lay->addWidget( ok ); |
65 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 65 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
66 | lay->addWidget( cancel ); | 66 | lay->addWidget( cancel ); |
67 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 67 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
68 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 68 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
69 | //resize( 200, 200 ); | 69 | //resize( 200, 200 ); |
70 | } | 70 | } |
71 | 71 | ||
72 | QString calName() { return nameE->text(); } | 72 | QString calName() { return nameE->text(); } |
73 | QString calFileName() { return url->url(); } | 73 | QString calFileName() { return url->url(); } |
74 | private: | 74 | private: |
75 | KLineEdit* nameE; | 75 | KLineEdit* nameE; |
76 | KURLRequester *url; | 76 | KURLRequester *url; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 80 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
81 | const char* name,WFlags fl ) | 81 | const char* name,WFlags fl ) |
82 | : KOFilterView_base(parent,name,fl) | 82 | : KOFilterView_base(parent,name,fl) |
83 | { | 83 | { |
84 | mFilters = filterList; | 84 | mFilters = filterList; |
85 | 85 | ||
86 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 86 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
87 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 87 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
88 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 88 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
89 | } | 89 | } |
90 | 90 | ||
91 | KOFilterView::~KOFilterView() | 91 | KOFilterView::~KOFilterView() |
92 | { | 92 | { |
93 | // no need to delete child widgets, Qt does it all for us | 93 | // no need to delete child widgets, Qt does it all for us |
94 | } | 94 | } |
95 | 95 | ||
96 | bool KOFilterView::filtersEnabled() | 96 | bool KOFilterView::filtersEnabled() |
97 | { | 97 | { |
98 | return mEnabledCheck->isChecked(); | 98 | return mEnabledCheck->isChecked(); |
99 | } | 99 | } |
100 | 100 | ||
101 | void KOFilterView::setFiltersEnabled(bool set) | 101 | void KOFilterView::setFiltersEnabled(bool set) |
102 | { | 102 | { |
103 | mEnabledCheck->setChecked(set); | 103 | mEnabledCheck->setChecked(set); |
104 | emit filterChanged(); | 104 | emit filterChanged(); |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | void KOFilterView::updateFilters() | 108 | void KOFilterView::updateFilters() |
109 | { | 109 | { |
110 | mSelectionCombo->clear(); | 110 | mSelectionCombo->clear(); |
111 | 111 | ||
112 | CalFilter *filter = mFilters->first(); | 112 | CalFilter *filter = mFilters->first(); |
113 | while(filter) { | 113 | while(filter) { |
114 | mSelectionCombo->insertItem(filter->name()); | 114 | mSelectionCombo->insertItem(filter->name()); |
115 | filter = mFilters->next(); | 115 | filter = mFilters->next(); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | CalFilter *KOFilterView::selectedFilter() | 119 | CalFilter *KOFilterView::selectedFilter() |
120 | { | 120 | { |
121 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 121 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
122 | return f; | 122 | return f; |
123 | } | 123 | } |
124 | 124 | ||
125 | void KOFilterView::setSelectedFilter(QString filterName) | 125 | void KOFilterView::setSelectedFilter(QString filterName) |
126 | { | 126 | { |
127 | int filter_num = mSelectionCombo->count(); | 127 | int filter_num = mSelectionCombo->count(); |
128 | int i; | 128 | int i; |
129 | for (i=0;i<filter_num;i++) { | 129 | for (i=0;i<filter_num;i++) { |
130 | if (mSelectionCombo->text(i)==filterName) | 130 | if (mSelectionCombo->text(i)==filterName) |
131 | mSelectionCombo->setCurrentItem(i); | 131 | mSelectionCombo->setCurrentItem(i); |
132 | } | 132 | } |
133 | emit filterChanged(); | 133 | emit filterChanged(); |
134 | } | 134 | } |
135 | void KOFilterView::setSelectedFilter( int fil ) | 135 | void KOFilterView::setSelectedFilter( int fil ) |
136 | { | 136 | { |
137 | if ( fil >= mSelectionCombo->count() ) | 137 | if ( fil >= mSelectionCombo->count() ) |
138 | return; | 138 | return; |
139 | mSelectionCombo->setCurrentItem( fil ); | 139 | mSelectionCombo->setCurrentItem( fil ); |
140 | emit filterChanged(); | 140 | emit filterChanged(); |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | 144 | ||
145 | KOCalEditView::KOCalEditView(QWidget* parent, | 145 | KOCalEditView::KOCalEditView(QWidget* parent, |
146 | const char* name ) | 146 | const char* name ) |
147 | : QWidget(parent,name) | 147 | : QWidget(parent,name) |
148 | { | 148 | { |
149 | mw = 0; | 149 | mw = 0; |
150 | ml = new QVBoxLayout ( this ); | 150 | ml = new QVBoxLayout ( this ); |
151 | } | 151 | } |
152 | 152 | ||
153 | KOCalEditView::~KOCalEditView() | 153 | KOCalEditView::~KOCalEditView() |
154 | { | 154 | { |
155 | // no need to delete child widgets, Qt does it all for us | 155 | // no need to delete child widgets, Qt does it all for us |
156 | } | 156 | } |
157 | void KOCalEditView::selectCal(int id ,bool b) | 157 | void KOCalEditView::selectCal(int id ,bool b) |
158 | { | 158 | { |
159 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; | 159 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; |
160 | emit calendarEnabled ( id, b ); | 160 | emit calendarEnabled ( id, b ); |
161 | emit needsUpdate(); | 161 | emit needsUpdate(); |
162 | 162 | ||
163 | } | 163 | } |
164 | void KOCalEditView::selectStdCal( int id, bool b ) | 164 | void KOCalEditView::selectStdCal( int id, bool b ) |
165 | { | 165 | { |
166 | 166 | ||
167 | if ( !b ) { | 167 | if ( !b ) { |
168 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); | 168 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); |
169 | if ( it ) { | 169 | if ( it ) { |
170 | it->blockSignals( true ); | 170 | it->blockSignals( true ); |
171 | it->setChecked( true ); | 171 | it->setChecked( true ); |
172 | it->blockSignals( false ); | 172 | it->blockSignals( false ); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | return; | 175 | return; |
176 | } | 176 | } |
177 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); | 177 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); |
178 | KOCalCheckButton* it = mStdandardB.first(); | 178 | KOCalCheckButton* it = mStdandardB.first(); |
179 | while ( it ) { | 179 | while ( it ) { |
180 | if ( it->isChecked() ) { | 180 | if ( it->isChecked() ) { |
181 | if ( it != sen ) { | 181 | if ( it != sen ) { |
182 | it->blockSignals( true ); | 182 | it->blockSignals( true ); |
183 | it->setChecked( false ); | 183 | it->setChecked( false ); |
184 | it->blockSignals( false ); | 184 | it->blockSignals( false ); |
185 | break; | 185 | break; |
186 | } | 186 | } |
187 | } | 187 | } |
188 | it = mStdandardB.next(); | 188 | it = mStdandardB.next(); |
189 | } | 189 | } |
190 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 190 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
191 | while ( kkf ) { | 191 | while ( kkf ) { |
192 | kkf->isStandard = false; | 192 | kkf->isStandard = false; |
193 | kkf = KOPrefs::instance()->mCalendars.next(); | 193 | kkf = KOPrefs::instance()->mCalendars.next(); |
194 | } | 194 | } |
195 | KOPrefs::instance()->getCalendar( id )->isStandard = true; | 195 | KOPrefs::instance()->getCalendar( id )->isStandard = true; |
196 | emit setCalendarDefault ( id ); | 196 | emit setCalendarDefault ( id ); |
197 | } | 197 | } |
198 | 198 | ||
199 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 199 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
200 | { | 200 | { |
201 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 201 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
202 | emit alarmEnabled ( id , b ); | 202 | emit alarmEnabled ( id , b ); |
203 | emit needsUpdate(); | 203 | emit needsUpdate(); |
204 | } | 204 | } |
205 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 205 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
206 | { | 206 | { |
207 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 207 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
208 | emit calendarReadonly ( id , b ); | 208 | emit calendarReadonly ( id , b ); |
209 | emit needsUpdate(); | 209 | emit needsUpdate(); |
210 | 210 | ||
211 | } | 211 | } |
212 | void KOCalEditView::setColor( const QColor& c, int id ) | 212 | void KOCalEditView::setColor( const QColor& c, int id ) |
213 | { | 213 | { |
214 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 214 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
215 | emit needsUpdate(); | 215 | emit needsUpdate(); |
216 | } | 216 | } |
217 | void KOCalEditView::deleteCal( int id ) | 217 | void KOCalEditView::deleteCal( int id ) |
218 | { | 218 | { |
219 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 219 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
220 | QString name = kkf->mName; | 220 | QString name = kkf->mName; |
221 | QString file = kkf->mFileName; | 221 | QString file = kkf->mFileName; |
222 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; | 222 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; |
223 | if ( kkf->isStandard ) | 223 | if ( kkf->isStandard ) |
224 | selectStdCal( 1, true ); | 224 | selectStdCal( 1, true ); |
225 | emit removeCalendar ( id ); | 225 | emit removeCalendar ( id ); |
226 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 226 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
227 | emit needsUpdate(); | 227 | emit needsUpdate(); |
228 | readConfig(); | 228 | readConfig(); |
229 | } | 229 | } |
230 | void KOCalEditView::infoCal( int id ) | 230 | void KOCalEditView::infoCal( int id ) |
231 | { | 231 | { |
232 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 232 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
233 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; | 233 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; |
234 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | 234 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { |
235 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { | ||
236 | emit calendarAdded( id ); | ||
237 | readConfig(); | ||
238 | emit needsUpdate(); | ||
239 | } | ||
240 | } | ||
241 | else | ||
242 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | ||
235 | } | 243 | } |
236 | void KOCalEditView::readConfig() | 244 | void KOCalEditView::readConfig() |
237 | { | 245 | { |
238 | 246 | ||
239 | mStdandardB.clear(); | 247 | mStdandardB.clear(); |
240 | mEnabledB.clear(); | 248 | mEnabledB.clear(); |
241 | mAlarmB.clear(); | 249 | mAlarmB.clear(); |
242 | mROB.clear(); | 250 | mROB.clear(); |
243 | 251 | ||
244 | if ( mw ) delete mw; | 252 | if ( mw ) delete mw; |
245 | mw = new QWidget ( this ); | 253 | mw = new QWidget ( this ); |
246 | ml->addWidget ( mw ); | 254 | ml->addWidget ( mw ); |
247 | 255 | ||
248 | mainLayout = new QGridLayout ( mw , 2, 8 ); | 256 | mainLayout = new QGridLayout ( mw , 2, 8 ); |
249 | //mainLayout->setSpacing( 3 ); | 257 | //mainLayout->setSpacing( 3 ); |
250 | QPushButton * addBut = new QPushButton ( mw ); | 258 | QPushButton * addBut = new QPushButton ( mw ); |
251 | mainLayout->addWidget( addBut,0,0 ); | 259 | mainLayout->addWidget( addBut,0,0 ); |
252 | addBut->setPixmap ( SmallIcon("plus")); | 260 | addBut->setPixmap ( SmallIcon("plus")); |
253 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 261 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
254 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 262 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
255 | 263 | ||
256 | addBut = new QPushButton ( mw ); | 264 | addBut = new QPushButton ( mw ); |
257 | mainLayout->addWidget( addBut,0,1 ); | 265 | mainLayout->addWidget( addBut,0,1 ); |
258 | addBut->setPixmap ( SmallIcon("eye")); | 266 | addBut->setPixmap ( SmallIcon("eye")); |
259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 267 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
260 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 268 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
261 | 269 | ||
262 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); | 270 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); |
263 | mainLayout->addWidget( lab,0,2 ); | 271 | mainLayout->addWidget( lab,0,2 ); |
264 | 272 | ||
265 | addBut = new QPushButton ( mw ); | 273 | addBut = new QPushButton ( mw ); |
266 | mainLayout->addWidget( addBut,0,3 ); | 274 | mainLayout->addWidget( addBut,0,3 ); |
267 | addBut->setPixmap ( SmallIcon("bell")); | 275 | addBut->setPixmap ( SmallIcon("bell")); |
268 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 276 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
269 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 277 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
270 | 278 | ||
271 | addBut = new QPushButton ( mw ); | 279 | addBut = new QPushButton ( mw ); |
272 | mainLayout->addWidget( addBut,0,4 ); | 280 | mainLayout->addWidget( addBut,0,4 ); |
273 | addBut->setPixmap ( SmallIcon("pencil")); | 281 | addBut->setPixmap ( SmallIcon("pencil")); |
274 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 282 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
275 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 283 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
276 | 284 | ||
277 | lab = new QLabel ( i18n(" Color "), mw ); | 285 | lab = new QLabel ( i18n(" Color "), mw ); |
278 | mainLayout->addWidget( lab,0,5 ); | 286 | mainLayout->addWidget( lab,0,5 ); |
279 | #if 0 | 287 | #if 0 |
280 | addBut = new QPushButton ( mw ); | 288 | addBut = new QPushButton ( mw ); |
281 | mainLayout->addWidget( addBut,0,6 ); | 289 | mainLayout->addWidget( addBut,0,6 ); |
282 | addBut->setPixmap ( SmallIcon("minus")); | 290 | addBut->setPixmap ( SmallIcon("minus")); |
283 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); | 291 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); |
284 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 292 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
285 | #endif | 293 | #endif |
286 | 294 | ||
287 | 295 | ||
288 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 296 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
289 | int row = 1; | 297 | int row = 1; |
290 | while ( kkf ) { | 298 | while ( kkf ) { |
291 | 299 | ||
292 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); | 300 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); |
293 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); | 301 | mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); |
294 | cb->setChecked( kkf->isStandard ); | 302 | cb->setChecked( kkf->isStandard ); |
295 | cb->setNum( kkf->mCalNumber ); | 303 | cb->setNum( kkf->mCalNumber ); |
296 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); | 304 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); |
305 | if ( kkf->mErrorOnLoad ) | ||
306 | cb->setEnabled( false ); | ||
297 | cb = new KOCalCheckButton( mw ); | 307 | cb = new KOCalCheckButton( mw ); |
298 | mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); | 308 | mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); |
299 | cb->setChecked( kkf->isEnabled ); | 309 | cb->setChecked( kkf->isEnabled ); |
300 | cb->setNum( kkf->mCalNumber ); | 310 | cb->setNum( kkf->mCalNumber ); |
311 | if ( kkf->mErrorOnLoad ) | ||
312 | cb->setEnabled( false ); | ||
301 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); | 313 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); |
302 | KOCalButton* name = new KOCalButton( mw ); | 314 | KOCalButton* name = new KOCalButton( mw ); |
303 | name->setNum( kkf->mCalNumber ); | 315 | name->setNum( kkf->mCalNumber ); |
304 | name->setText( kkf->mName ); | 316 | name->setText( kkf->mName ); |
305 | mainLayout->addWidget( name,row,2 ); | 317 | mainLayout->addWidget( name,row,2 ); |
306 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); | 318 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); |
307 | cb = new KOCalCheckButton( mw ); | 319 | cb = new KOCalCheckButton( mw ); |
308 | mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); | 320 | mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); |
309 | cb->setChecked( kkf->isAlarmEnabled ); | 321 | cb->setChecked( kkf->isAlarmEnabled ); |
310 | cb->setNum( kkf->mCalNumber ); | 322 | cb->setNum( kkf->mCalNumber ); |
311 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 323 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
324 | if ( kkf->mErrorOnLoad ) | ||
325 | cb->setEnabled( false ); | ||
312 | cb = new KOCalCheckButton( mw ); | 326 | cb = new KOCalCheckButton( mw ); |
313 | mainLayout->addWidget( cb,row,4 );mROB.append( cb ); | 327 | mainLayout->addWidget( cb,row,4 );mROB.append( cb ); |
314 | cb->setChecked( kkf->isReadOnly ); | 328 | cb->setChecked( kkf->isReadOnly ); |
315 | cb->setNum( kkf->mCalNumber ); | 329 | cb->setNum( kkf->mCalNumber ); |
316 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 330 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
331 | if ( kkf->mErrorOnLoad ) | ||
332 | cb->setEnabled( false ); | ||
317 | KColorButton *colb = new KColorButton( mw ); | 333 | KColorButton *colb = new KColorButton( mw ); |
318 | mainLayout->addWidget( colb,row,5 ); | 334 | mainLayout->addWidget( colb,row,5 ); |
319 | colb->setID( kkf->mCalNumber ); | 335 | colb->setID( kkf->mCalNumber ); |
320 | colb->setColor( kkf->mDefaultColor ); | 336 | colb->setColor( kkf->mDefaultColor ); |
321 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 337 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
322 | if ( row > 1) { | 338 | if ( row > 1) { |
323 | KOCalButton* calb = new KOCalButton( mw ); | 339 | KOCalButton* calb = new KOCalButton( mw ); |
324 | mainLayout->addWidget( calb,row,6 ); | 340 | mainLayout->addWidget( calb,row,6 ); |
325 | calb->setNum( kkf->mCalNumber ); | 341 | calb->setNum( kkf->mCalNumber ); |
326 | calb->setPixmap ( SmallIcon("minus")); | 342 | calb->setPixmap ( SmallIcon("minus")); |
327 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 343 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
328 | int hei = calb->sizeHint().height(); | 344 | int hei = calb->sizeHint().height(); |
329 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 345 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
330 | } | 346 | } |
331 | ++row; | 347 | ++row; |
332 | kkf = KOPrefs::instance()->mCalendars.next(); | 348 | kkf = KOPrefs::instance()->mCalendars.next(); |
333 | } | 349 | } |
334 | lab = new QLabel ( "", mw ); | 350 | lab = new QLabel ( "", mw ); |
335 | mainLayout->addWidget( lab,row,0 ); | 351 | mainLayout->addWidget( lab,row,0 ); |
336 | mw->show(); | 352 | mw->show(); |
337 | 353 | ||
338 | } | 354 | } |
339 | void KOCalEditView::addCal() | 355 | void KOCalEditView::addCal() |
340 | { | 356 | { |
341 | qDebug("addcal "); | 357 | qDebug("addcal "); |
342 | KONewCalPrefs prefs ( this ); | 358 | KONewCalPrefs prefs ( this ); |
343 | if ( ! prefs.exec() ) | 359 | if ( ! prefs.exec() ) |
344 | return; | 360 | return; |
345 | QString name = prefs.calName(); | 361 | QString name = prefs.calName(); |
346 | QString file = prefs.calFileName(); | 362 | QString file = prefs.calFileName(); |
347 | QFileInfo fi ( file ); | 363 | QFileInfo fi ( file ); |
348 | if (!fi.exists() ) { | 364 | if (!fi.exists() ) { |
349 | KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); | 365 | KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); |
350 | return; | 366 | return; |
351 | } | 367 | } |
352 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 368 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
353 | kkf->mName = name; | 369 | kkf->mName = name; |
354 | kkf->mFileName = file; | 370 | kkf->mFileName = file; |
355 | emit calendarAdded( kkf->mCalNumber ); | 371 | emit calendarAdded( kkf->mCalNumber ); |
356 | readConfig(); | 372 | readConfig(); |
357 | emit needsUpdate(); | 373 | emit needsUpdate(); |
358 | } | 374 | } |
359 | void KOCalEditView::enableAll() | 375 | void KOCalEditView::enableAll() |
360 | { | 376 | { |
361 | toggleList( mEnabledB ); | 377 | toggleList( mEnabledB ); |
362 | } | 378 | } |
363 | void KOCalEditView::enableAlarm() | 379 | void KOCalEditView::enableAlarm() |
364 | { | 380 | { |
365 | toggleList( mAlarmB ); | 381 | toggleList( mAlarmB ); |
366 | } | 382 | } |
367 | void KOCalEditView::disableRO() | 383 | void KOCalEditView::disableRO() |
368 | { | 384 | { |
369 | toggleList( mROB ); | 385 | toggleList( mROB ); |
370 | } | 386 | } |
371 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) | 387 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) |
372 | { | 388 | { |
373 | bool dis = false; | 389 | bool dis = false; |
374 | KOCalCheckButton* it = list.first(); | 390 | KOCalCheckButton* it = list.first(); |
375 | while ( it ) { | 391 | while ( it ) { |
376 | if ( !it->isChecked() ) { | 392 | if ( !it->isChecked() ) { |
377 | dis = true; | 393 | dis = true; |
378 | break; | 394 | break; |
379 | } | 395 | } |
380 | it = list.next(); | 396 | it = list.next(); |
381 | } | 397 | } |
382 | it = list.first(); | 398 | it = list.first(); |
383 | while ( it ) { | 399 | while ( it ) { |
384 | it->setChecked(dis); | 400 | it->setChecked(dis); |
385 | it = list.next(); | 401 | it = list.next(); |
386 | } | 402 | } |
387 | } | 403 | } |
388 | void KOCalEditView::deleteAll() | 404 | void KOCalEditView::deleteAll() |
389 | { | 405 | { |
390 | qDebug("delteAll"); | 406 | qDebug("delteAll"); |
391 | } | 407 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index f114d88..463fc33 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,259 +1,262 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | 31 | ||
32 | class KConfig; | 32 | class KConfig; |
33 | class QFont; | 33 | class QFont; |
34 | class QColor; | 34 | class QColor; |
35 | class QStringList; | 35 | class QStringList; |
36 | 36 | ||
37 | #define VIEW_WN_VIEW 1 | 37 | #define VIEW_WN_VIEW 1 |
38 | #define VIEW_NX_VIEW 2 | 38 | #define VIEW_NX_VIEW 2 |
39 | #define VIEW_J_VIEW 3 | 39 | #define VIEW_J_VIEW 3 |
40 | #define VIEW_A_VIEW 4 | 40 | #define VIEW_A_VIEW 4 |
41 | #define VIEW_ML_VIEW 5 | 41 | #define VIEW_ML_VIEW 5 |
42 | #define VIEW_M_VIEW 6 | 42 | #define VIEW_M_VIEW 6 |
43 | #define VIEW_L_VIEW 7 | 43 | #define VIEW_L_VIEW 7 |
44 | #define VIEW_T_VIEW 8 | 44 | #define VIEW_T_VIEW 8 |
45 | 45 | ||
46 | class KopiCalendarFile : public QObject | 46 | class KopiCalendarFile : public QObject |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KopiCalendarFile( ) : QObject( ) | 49 | KopiCalendarFile( ) : QObject( ) |
50 | { | 50 | { |
51 | isStandard = false; | 51 | isStandard = false; |
52 | isEnabled = true; | 52 | isEnabled = true; |
53 | isAlarmEnabled = true; | 53 | isAlarmEnabled = true; |
54 | isReadOnly = false; | 54 | isReadOnly = false; |
55 | mName = "Calendar"; | 55 | mName = "Calendar"; |
56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; | 56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; |
57 | mCalNumber = 0; | 57 | mCalNumber = 0; |
58 | mDefaultColor = Qt::red; | 58 | mDefaultColor = Qt::red; |
59 | mErrorOnLoad = false; | ||
59 | } | 60 | } |
60 | bool isStandard; | 61 | bool isStandard; |
61 | bool isEnabled; | 62 | bool isEnabled; |
62 | bool isAlarmEnabled; | 63 | bool isAlarmEnabled; |
63 | bool isReadOnly; | 64 | bool isReadOnly; |
65 | bool mErrorOnLoad; | ||
64 | QString mName; | 66 | QString mName; |
65 | QString mFileName; | 67 | QString mFileName; |
66 | int mCalNumber; | 68 | int mCalNumber; |
67 | QColor mDefaultColor; | 69 | QColor mDefaultColor; |
70 | QDateTime mLoadDt; | ||
68 | }; | 71 | }; |
69 | class KOPrefs : public KPimPrefs | 72 | class KOPrefs : public KPimPrefs |
70 | { | 73 | { |
71 | public: | 74 | public: |
72 | enum { FormatVCalendar, FormatICalendar }; | 75 | enum { FormatVCalendar, FormatICalendar }; |
73 | enum { MailClientKMail, MailClientSendmail }; | 76 | enum { MailClientKMail, MailClientSendmail }; |
74 | enum { IMIPDummy, IMIPKMail }; | 77 | enum { IMIPDummy, IMIPKMail }; |
75 | enum { IMIPOutbox, IMIPdirectsend }; | 78 | enum { IMIPOutbox, IMIPdirectsend }; |
76 | enum { neverAuto, addressbookAuto, selectedAuto }; | 79 | enum { neverAuto, addressbookAuto, selectedAuto }; |
77 | enum { standardDestination, askDestination }; | 80 | enum { standardDestination, askDestination }; |
78 | 81 | ||
79 | virtual ~KOPrefs(); | 82 | virtual ~KOPrefs(); |
80 | 83 | ||
81 | /** Get instance of KOPrefs. It is made sure that there is only one | 84 | /** Get instance of KOPrefs. It is made sure that there is only one |
82 | instance. */ | 85 | instance. */ |
83 | static KOPrefs *instance(); | 86 | static KOPrefs *instance(); |
84 | 87 | ||
85 | /** Set preferences to default values */ | 88 | /** Set preferences to default values */ |
86 | void usrSetDefaults(); | 89 | void usrSetDefaults(); |
87 | 90 | ||
88 | /** Read preferences from config file */ | 91 | /** Read preferences from config file */ |
89 | void usrReadConfig(); | 92 | void usrReadConfig(); |
90 | 93 | ||
91 | /** Write preferences to config file */ | 94 | /** Write preferences to config file */ |
92 | void usrWriteConfig(); | 95 | void usrWriteConfig(); |
93 | void setCategoryDefaults(); | 96 | void setCategoryDefaults(); |
94 | void setAllDefaults(); | 97 | void setAllDefaults(); |
95 | KopiCalendarFile * getNewCalendar(); | 98 | KopiCalendarFile * getNewCalendar(); |
96 | KopiCalendarFile * getCalendar( int ); | 99 | KopiCalendarFile * getCalendar( int ); |
97 | void deleteCalendar( int ); | 100 | void deleteCalendar( int ); |
98 | QColor defaultColor( int ) const; | 101 | QColor defaultColor( int ) const; |
99 | protected: | 102 | protected: |
100 | void setTimeZoneIdDefault(); | 103 | void setTimeZoneIdDefault(); |
101 | 104 | ||
102 | /** Fill empty mail fields with default values. */ | 105 | /** Fill empty mail fields with default values. */ |
103 | void fillMailDefaults(); | 106 | void fillMailDefaults(); |
104 | 107 | ||
105 | private: | 108 | private: |
106 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 109 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
107 | object. */ | 110 | object. */ |
108 | KOPrefs(); | 111 | KOPrefs(); |
109 | 112 | ||
110 | static KOPrefs *mInstance; | 113 | static KOPrefs *mInstance; |
111 | QStringList getDefaultList(); | 114 | QStringList getDefaultList(); |
112 | QStringList getLocationDefaultList(); | 115 | QStringList getLocationDefaultList(); |
113 | public: | 116 | public: |
114 | // preferences data | 117 | // preferences data |
115 | KConfig* getConfig(); | 118 | KConfig* getConfig(); |
116 | void setFullName(const QString &); | 119 | void setFullName(const QString &); |
117 | QString fullName(); | 120 | QString fullName(); |
118 | void setEmail(const QString &); | 121 | void setEmail(const QString &); |
119 | QString email(); | 122 | QString email(); |
120 | 123 | ||
121 | QString mAdditional; | 124 | QString mAdditional; |
122 | 125 | ||
123 | bool mEmailControlCenter; | 126 | bool mEmailControlCenter; |
124 | 127 | ||
125 | bool mBcc; | 128 | bool mBcc; |
126 | bool mAutoSave; | 129 | bool mAutoSave; |
127 | int mAutoSaveInterval; | 130 | int mAutoSaveInterval; |
128 | bool mConfirm; | 131 | bool mConfirm; |
129 | 132 | ||
130 | bool mEnableGroupScheduling; | 133 | bool mEnableGroupScheduling; |
131 | bool mEnableProjectView; | 134 | bool mEnableProjectView; |
132 | 135 | ||
133 | int mDefaultFormat; | 136 | int mDefaultFormat; |
134 | int mMailClient; | 137 | int mMailClient; |
135 | 138 | ||
136 | int mStartTime; | 139 | int mStartTime; |
137 | int mDefaultDuration; | 140 | int mDefaultDuration; |
138 | int mAlarmTime; | 141 | int mAlarmTime; |
139 | 142 | ||
140 | int mWorkingHoursStart; | 143 | int mWorkingHoursStart; |
141 | int mWorkingHoursEnd; | 144 | int mWorkingHoursEnd; |
142 | bool mExcludeHolidays; | 145 | bool mExcludeHolidays; |
143 | bool mExcludeSaturdays; | 146 | bool mExcludeSaturdays; |
144 | bool mMarcusBainsShowSeconds; | 147 | bool mMarcusBainsShowSeconds; |
145 | 148 | ||
146 | QFont mTimeBarFont; | 149 | QFont mTimeBarFont; |
147 | QFont mMonthViewFont; | 150 | QFont mMonthViewFont; |
148 | QFont mAgendaViewFont; | 151 | QFont mAgendaViewFont; |
149 | QFont mMarcusBainsFont; | 152 | QFont mMarcusBainsFont; |
150 | QFont mTimeLabelsFont; | 153 | QFont mTimeLabelsFont; |
151 | QFont mTodoViewFont; | 154 | QFont mTodoViewFont; |
152 | QFont mListViewFont; | 155 | QFont mListViewFont; |
153 | QFont mDateNavigatorFont; | 156 | QFont mDateNavigatorFont; |
154 | QFont mEditBoxFont; | 157 | QFont mEditBoxFont; |
155 | QFont mJornalViewFont; | 158 | QFont mJornalViewFont; |
156 | QFont mWhatsNextFont; | 159 | QFont mWhatsNextFont; |
157 | QFont mEventViewFont; | 160 | QFont mEventViewFont; |
158 | 161 | ||
159 | 162 | ||
160 | 163 | ||
161 | 164 | ||
162 | QColor mHolidayColor; | 165 | QColor mHolidayColor; |
163 | QColor mHighlightColor; | 166 | QColor mHighlightColor; |
164 | QColor mEventColor; | 167 | QColor mEventColor; |
165 | QColor mTodoDoneColor; | 168 | QColor mTodoDoneColor; |
166 | QColor mAgendaBgColor; | 169 | QColor mAgendaBgColor; |
167 | QColor mWorkingHoursColor; | 170 | QColor mWorkingHoursColor; |
168 | QColor mTodoDueTodayColor; | 171 | QColor mTodoDueTodayColor; |
169 | QColor mTodoOverdueColor; | 172 | QColor mTodoOverdueColor; |
170 | QColor mTodoRunColor; | 173 | QColor mTodoRunColor; |
171 | QColor mMonthViewEvenColor; | 174 | QColor mMonthViewEvenColor; |
172 | QColor mMonthViewOddColor; | 175 | QColor mMonthViewOddColor; |
173 | QColor mMonthViewHolidayColor; | 176 | QColor mMonthViewHolidayColor; |
174 | bool mMonthViewUsesDayColors; | 177 | bool mMonthViewUsesDayColors; |
175 | bool mMonthViewSatSunTog; | 178 | bool mMonthViewSatSunTog; |
176 | bool mMonthViewWeek; | 179 | bool mMonthViewWeek; |
177 | QColor mAppColor1; | 180 | QColor mAppColor1; |
178 | QColor mAppColor2; | 181 | QColor mAppColor2; |
179 | bool mUseAppColors; | 182 | bool mUseAppColors; |
180 | 183 | ||
181 | int mDayBegins; | 184 | int mDayBegins; |
182 | int mHourSize; | 185 | int mHourSize; |
183 | int mAllDaySize; | 186 | int mAllDaySize; |
184 | bool mShowFullMenu; | 187 | bool mShowFullMenu; |
185 | bool mDailyRecur; | 188 | bool mDailyRecur; |
186 | bool mWeeklyRecur; | 189 | bool mWeeklyRecur; |
187 | bool mMonthDailyRecur; | 190 | bool mMonthDailyRecur; |
188 | bool mMonthWeeklyRecur; | 191 | bool mMonthWeeklyRecur; |
189 | bool mMonthShowIcons; | 192 | bool mMonthShowIcons; |
190 | bool mMonthShowTimes; | 193 | bool mMonthShowTimes; |
191 | bool mMonthShowShort; | 194 | bool mMonthShowShort; |
192 | bool mEnableToolTips; | 195 | bool mEnableToolTips; |
193 | bool mEnableMonthScroll; | 196 | bool mEnableMonthScroll; |
194 | bool mFullViewMonth; | 197 | bool mFullViewMonth; |
195 | bool mMonthViewUsesCategoryColor; | 198 | bool mMonthViewUsesCategoryColor; |
196 | bool mFullViewTodo; | 199 | bool mFullViewTodo; |
197 | bool mShowCompletedTodo; | 200 | bool mShowCompletedTodo; |
198 | bool mMarcusBainsEnabled; | 201 | bool mMarcusBainsEnabled; |
199 | int mNextXDays; | 202 | int mNextXDays; |
200 | int mWhatsNextDays; | 203 | int mWhatsNextDays; |
201 | int mWhatsNextPrios; | 204 | int mWhatsNextPrios; |
202 | bool mEnableQuickTodo; | 205 | bool mEnableQuickTodo; |
203 | 206 | ||
204 | bool mCompactDialogs; | 207 | bool mCompactDialogs; |
205 | bool mVerticalScreen; | 208 | bool mVerticalScreen; |
206 | 209 | ||
207 | bool mShowIconNewTodo; | 210 | bool mShowIconNewTodo; |
208 | bool mShowIconNewEvent; | 211 | bool mShowIconNewEvent; |
209 | bool mShowIconSearch; | 212 | bool mShowIconSearch; |
210 | bool mShowIconList; | 213 | bool mShowIconList; |
211 | bool mShowIconDay1; | 214 | bool mShowIconDay1; |
212 | bool mShowIconDay5; | 215 | bool mShowIconDay5; |
213 | bool mShowIconDay6; | 216 | bool mShowIconDay6; |
214 | bool mShowIconDay7; | 217 | bool mShowIconDay7; |
215 | bool mShowIconMonth; | 218 | bool mShowIconMonth; |
216 | bool mShowIconTodoview; | 219 | bool mShowIconTodoview; |
217 | bool mShowIconBackFast; | 220 | bool mShowIconBackFast; |
218 | bool mShowIconBack; | 221 | bool mShowIconBack; |
219 | bool mShowIconToday; | 222 | bool mShowIconToday; |
220 | bool mShowIconForward; | 223 | bool mShowIconForward; |
221 | bool mShowIconForwardFast; | 224 | bool mShowIconForwardFast; |
222 | bool mShowIconWhatsThis; | 225 | bool mShowIconWhatsThis; |
223 | bool mShowIconWeekNum; | 226 | bool mShowIconWeekNum; |
224 | bool mShowIconNextDays; | 227 | bool mShowIconNextDays; |
225 | bool mShowIconNext; | 228 | bool mShowIconNext; |
226 | bool mShowIconJournal; | 229 | bool mShowIconJournal; |
227 | bool mShowIconFilter; | 230 | bool mShowIconFilter; |
228 | bool mShowIconOnetoolbar; | 231 | bool mShowIconOnetoolbar; |
229 | bool mShowIconNavigator; | 232 | bool mShowIconNavigator; |
230 | bool mShowIconAllday; | 233 | bool mShowIconAllday; |
231 | bool mShowIconFilterview; | 234 | bool mShowIconFilterview; |
232 | bool mShowIconToggleFull; | 235 | bool mShowIconToggleFull; |
233 | 236 | ||
234 | bool mShowIconStretch; | 237 | bool mShowIconStretch; |
235 | 238 | ||
236 | bool mToolBarHor; | 239 | bool mToolBarHor; |
237 | bool mToolBarUp; | 240 | bool mToolBarUp; |
238 | bool mToolBarHorV; | 241 | bool mToolBarHorV; |
239 | bool mToolBarUpV; | 242 | bool mToolBarUpV; |
240 | bool mToolBarHorN; | 243 | bool mToolBarHorN; |
241 | bool mToolBarUpN; | 244 | bool mToolBarUpN; |
242 | bool mToolBarHorF; | 245 | bool mToolBarHorF; |
243 | bool mToolBarUpF; | 246 | bool mToolBarUpF; |
244 | bool mToolBarMiniIcons; | 247 | bool mToolBarMiniIcons; |
245 | 248 | ||
246 | bool mAskForQuit; | 249 | bool mAskForQuit; |
247 | bool mUsePassWd; | 250 | bool mUsePassWd; |
248 | bool mShowSyncEvents; | 251 | bool mShowSyncEvents; |
249 | bool mShowTodoInAgenda; | 252 | bool mShowTodoInAgenda; |
250 | bool mShowCompletedTodoInAgenda; | 253 | bool mShowCompletedTodoInAgenda; |
251 | bool mShowTimeInAgenda; | 254 | bool mShowTimeInAgenda; |
252 | bool mHideNonStartedTodos; | 255 | bool mHideNonStartedTodos; |
253 | 256 | ||
254 | bool mBlockPopupMenu; | 257 | bool mBlockPopupMenu; |
255 | 258 | ||
256 | int mLastSyncTime; | 259 | int mLastSyncTime; |
257 | void setCategoryColor(QString cat,const QColor & color); | 260 | void setCategoryColor(QString cat,const QColor & color); |
258 | QColor *categoryColor(QString cat); | 261 | QColor *categoryColor(QString cat); |
259 | 262 | ||
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index f05ada5..472a978 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1635,405 +1635,413 @@ void MainWindow::processIncidenceSelection( Incidence *incidence ) | |||
1635 | } | 1635 | } |
1636 | else | 1636 | else |
1637 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1637 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | } | 1640 | } |
1641 | else | 1641 | else |
1642 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1642 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1643 | if ( !incidence->location().isEmpty() ) | 1643 | if ( !incidence->location().isEmpty() ) |
1644 | startString += " (" +incidence->location()+")"; | 1644 | startString += " (" +incidence->location()+")"; |
1645 | setCaption( incidence->summary()+startString); | 1645 | setCaption( incidence->summary()+startString); |
1646 | 1646 | ||
1647 | enableIncidenceActions( true ); | 1647 | enableIncidenceActions( true ); |
1648 | 1648 | ||
1649 | if ( incidence->typeID() == eventID ) { | 1649 | if ( incidence->typeID() == eventID ) { |
1650 | mShowAction->setText( i18n("Show Event...") ); | 1650 | mShowAction->setText( i18n("Show Event...") ); |
1651 | mEditAction->setText( i18n("Edit Event...") ); | 1651 | mEditAction->setText( i18n("Edit Event...") ); |
1652 | mDeleteAction->setText( i18n("Delete Event...") ); | 1652 | mDeleteAction->setText( i18n("Delete Event...") ); |
1653 | 1653 | ||
1654 | mNewSubTodoAction->setEnabled( false ); | 1654 | mNewSubTodoAction->setEnabled( false ); |
1655 | } else if ( incidence->typeID() == todoID ) { | 1655 | } else if ( incidence->typeID() == todoID ) { |
1656 | mShowAction->setText( i18n("Show Todo...") ); | 1656 | mShowAction->setText( i18n("Show Todo...") ); |
1657 | mEditAction->setText( i18n("Edit Todo...") ); | 1657 | mEditAction->setText( i18n("Edit Todo...") ); |
1658 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1658 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1659 | 1659 | ||
1660 | mNewSubTodoAction->setEnabled( true ); | 1660 | mNewSubTodoAction->setEnabled( true ); |
1661 | } else { | 1661 | } else { |
1662 | mShowAction->setText( i18n("Show...") ); | 1662 | mShowAction->setText( i18n("Show...") ); |
1663 | mShowAction->setText( i18n("Edit...") ); | 1663 | mShowAction->setText( i18n("Edit...") ); |
1664 | mShowAction->setText( i18n("Delete...") ); | 1664 | mShowAction->setText( i18n("Delete...") ); |
1665 | 1665 | ||
1666 | mNewSubTodoAction->setEnabled( false ); | 1666 | mNewSubTodoAction->setEnabled( false ); |
1667 | } | 1667 | } |
1668 | } | 1668 | } |
1669 | 1669 | ||
1670 | void MainWindow::enableIncidenceActions( bool enabled ) | 1670 | void MainWindow::enableIncidenceActions( bool enabled ) |
1671 | { | 1671 | { |
1672 | mShowAction->setEnabled( enabled ); | 1672 | mShowAction->setEnabled( enabled ); |
1673 | mEditAction->setEnabled( enabled ); | 1673 | mEditAction->setEnabled( enabled ); |
1674 | mDeleteAction->setEnabled( enabled ); | 1674 | mDeleteAction->setEnabled( enabled ); |
1675 | 1675 | ||
1676 | mCloneAction->setEnabled( enabled ); | 1676 | mCloneAction->setEnabled( enabled ); |
1677 | mMoveAction->setEnabled( enabled ); | 1677 | mMoveAction->setEnabled( enabled ); |
1678 | mBeamAction->setEnabled( enabled ); | 1678 | mBeamAction->setEnabled( enabled ); |
1679 | mCancelAction->setEnabled( enabled ); | 1679 | mCancelAction->setEnabled( enabled ); |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | void MainWindow::importOL() | 1682 | void MainWindow::importOL() |
1683 | { | 1683 | { |
1684 | #ifdef _OL_IMPORT_ | 1684 | #ifdef _OL_IMPORT_ |
1685 | mView->clearAllViews(); | 1685 | mView->clearAllViews(); |
1686 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1686 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1687 | id->exec(); | 1687 | id->exec(); |
1688 | delete id; | 1688 | delete id; |
1689 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1689 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1690 | mView->updateView(); | 1690 | mView->updateView(); |
1691 | #endif | 1691 | #endif |
1692 | } | 1692 | } |
1693 | void MainWindow::importBday() | 1693 | void MainWindow::importBday() |
1694 | { | 1694 | { |
1695 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1695 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1696 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1696 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1697 | i18n("Import!"), i18n("Cancel"), 0, | 1697 | i18n("Import!"), i18n("Cancel"), 0, |
1698 | 0, 1 ); | 1698 | 0, 1 ); |
1699 | if ( result == 0 ) { | 1699 | if ( result == 0 ) { |
1700 | mView->importBday(); | 1700 | mView->importBday(); |
1701 | 1701 | ||
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | 1704 | ||
1705 | } | 1705 | } |
1706 | void MainWindow::importQtopia() | 1706 | void MainWindow::importQtopia() |
1707 | { | 1707 | { |
1708 | //#ifndef DESKTOP_VERSION | 1708 | //#ifndef DESKTOP_VERSION |
1709 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); | 1709 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); |
1710 | #ifdef DESKTOP_VERSION | 1710 | #ifdef DESKTOP_VERSION |
1711 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); | 1711 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); |
1712 | #endif | 1712 | #endif |
1713 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1713 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1714 | i18n("Import!"), i18n("Cancel"), 0, | 1714 | i18n("Import!"), i18n("Cancel"), 0, |
1715 | 0, 1 ); | 1715 | 0, 1 ); |
1716 | if ( result == 0 ) { | 1716 | if ( result == 0 ) { |
1717 | #ifndef DESKTOP_VERSION | 1717 | #ifndef DESKTOP_VERSION |
1718 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1718 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1719 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1719 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1720 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1720 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1721 | #else | 1721 | #else |
1722 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1722 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1723 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1723 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1724 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1724 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1725 | #endif | 1725 | #endif |
1726 | mView->importQtopia( categories, datebook, todolist ); | 1726 | mView->importQtopia( categories, datebook, todolist ); |
1727 | } | 1727 | } |
1728 | mView->calendar()->reInitAlarmSettings(); | 1728 | mView->calendar()->reInitAlarmSettings(); |
1729 | #if 0 | 1729 | #if 0 |
1730 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1730 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1731 | i18n("Not supported \non desktop!\n"), | 1731 | i18n("Not supported \non desktop!\n"), |
1732 | i18n("Ok"), i18n("Cancel"), 0, | 1732 | i18n("Ok"), i18n("Cancel"), 0, |
1733 | 0, 1 ); | 1733 | 0, 1 ); |
1734 | 1734 | ||
1735 | #endif | 1735 | #endif |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | void MainWindow::saveOnClose() | 1738 | void MainWindow::saveOnClose() |
1739 | { | 1739 | { |
1740 | KOPrefs *p = KOPrefs::instance(); | 1740 | KOPrefs *p = KOPrefs::instance(); |
1741 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1741 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1742 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1742 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1743 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1743 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1744 | if ( filterToolBar ) { | 1744 | if ( filterToolBar ) { |
1745 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1745 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1746 | } | 1746 | } |
1747 | #ifdef DESKTOP_VERSION | 1747 | #ifdef DESKTOP_VERSION |
1748 | 1748 | ||
1749 | QPoint myP; | 1749 | QPoint myP; |
1750 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1750 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1751 | if ( p->mToolBarHor ) | 1751 | if ( p->mToolBarHor ) |
1752 | p->mToolBarUp = myP.y() > height()/2; | 1752 | p->mToolBarUp = myP.y() > height()/2; |
1753 | else | 1753 | else |
1754 | p->mToolBarUp = myP.x() > width()/2; | 1754 | p->mToolBarUp = myP.x() > width()/2; |
1755 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1755 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1756 | if ( p->mToolBarHorV ) | 1756 | if ( p->mToolBarHorV ) |
1757 | p->mToolBarUpV = myP.y() > height()/2; | 1757 | p->mToolBarUpV = myP.y() > height()/2; |
1758 | else | 1758 | else |
1759 | p->mToolBarUpV = myP.x() > width()/2 ; | 1759 | p->mToolBarUpV = myP.x() > width()/2 ; |
1760 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1760 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1761 | if ( p->mToolBarHorN ) | 1761 | if ( p->mToolBarHorN ) |
1762 | p->mToolBarUpN = myP.y() > height()/2; | 1762 | p->mToolBarUpN = myP.y() > height()/2; |
1763 | else | 1763 | else |
1764 | p->mToolBarUpN = myP.x() > width()/2 ; | 1764 | p->mToolBarUpN = myP.x() > width()/2 ; |
1765 | if ( filterToolBar ) { | 1765 | if ( filterToolBar ) { |
1766 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1766 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1767 | if ( p->mToolBarHorF ) | 1767 | if ( p->mToolBarHorF ) |
1768 | p->mToolBarUpF = myP.y() > height()/2; | 1768 | p->mToolBarUpF = myP.y() > height()/2; |
1769 | else | 1769 | else |
1770 | p->mToolBarUpF = myP.x() > width()/2 ; | 1770 | p->mToolBarUpF = myP.x() > width()/2 ; |
1771 | } | 1771 | } |
1772 | #else | 1772 | #else |
1773 | if ( p->mToolBarHor ) | 1773 | if ( p->mToolBarHor ) |
1774 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1774 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1775 | else | 1775 | else |
1776 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1776 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1777 | if ( p->mToolBarHorV ) | 1777 | if ( p->mToolBarHorV ) |
1778 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1778 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1779 | else | 1779 | else |
1780 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1780 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1781 | 1781 | ||
1782 | if ( p->mToolBarHorN ) | 1782 | if ( p->mToolBarHorN ) |
1783 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1783 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1784 | else | 1784 | else |
1785 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1785 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1786 | if ( filterToolBar ) { | 1786 | if ( filterToolBar ) { |
1787 | if ( p->mToolBarHorF ) | 1787 | if ( p->mToolBarHorF ) |
1788 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1788 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1789 | else | 1789 | else |
1790 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1790 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1791 | } | 1791 | } |
1792 | #endif | 1792 | #endif |
1793 | 1793 | ||
1794 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1794 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1795 | save(); | 1795 | save(); |
1796 | mView->writeSettings(); | 1796 | mView->writeSettings(); |
1797 | } | 1797 | } |
1798 | void MainWindow::slotModifiedChanged( bool changed ) | 1798 | void MainWindow::slotModifiedChanged( bool changed ) |
1799 | { | 1799 | { |
1800 | if ( mBlockAtStartup ) | 1800 | if ( mBlockAtStartup ) |
1801 | return; | 1801 | return; |
1802 | 1802 | ||
1803 | int msec; | 1803 | int msec; |
1804 | // we store the changes after 1 minute, | 1804 | // we store the changes after 1 minute, |
1805 | // and for safety reasons after 10 minutes again | 1805 | // and for safety reasons after 10 minutes again |
1806 | if ( !mSyncManager->blockSave() ) | 1806 | if ( !mSyncManager->blockSave() ) |
1807 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1807 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1808 | else | 1808 | else |
1809 | msec = 1000 * 600; | 1809 | msec = 1000 * 600; |
1810 | mSaveTimer.start( msec, true ); // 1 minute | 1810 | mSaveTimer.start( msec, true ); // 1 minute |
1811 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1811 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1812 | mCalendarModifiedFlag = true; | 1812 | mCalendarModifiedFlag = true; |
1813 | } | 1813 | } |
1814 | void MainWindow::saveStopTimer() | 1814 | void MainWindow::saveStopTimer() |
1815 | { | 1815 | { |
1816 | mSaveTimer.stop(); | 1816 | mSaveTimer.stop(); |
1817 | } | 1817 | } |
1818 | void MainWindow::save() | 1818 | void MainWindow::save() |
1819 | { | 1819 | { |
1820 | if ( !mCalendarModifiedFlag ) { | 1820 | if ( !mCalendarModifiedFlag ) { |
1821 | qDebug("KO: Calendar not modified. Nothing saved."); | 1821 | qDebug("KO: Calendar not modified. Nothing saved."); |
1822 | return; | 1822 | return; |
1823 | } | 1823 | } |
1824 | if ( mSyncManager->blockSave() ) | 1824 | if ( mSyncManager->blockSave() ) |
1825 | return; | 1825 | return; |
1826 | mSyncManager->setBlockSave(true); | 1826 | mSyncManager->setBlockSave(true); |
1827 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1827 | if ( mView->checkAllFileVersions() ) { |
1828 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 1828 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
1829 | QDate reference ( 2000,1,1); | 1829 | QDate reference ( 2000,1,1); |
1830 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1830 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1831 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 1831 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
1832 | setCaption(i18n("Creating backup ... please wait ..." )); | 1832 | setCaption(i18n("Creating backup ... please wait ..." )); |
1833 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 1833 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
1834 | // we need the file path, the backup dir and the number of bups as param | 1834 | // we need the file path, the backup dir and the number of bups as param |
1835 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 1835 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
1836 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 1836 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
1837 | bupDir = KGlobalSettings::backupDataDir(); | 1837 | bupDir = KGlobalSettings::backupDataDir(); |
1838 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1838 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1839 | if ( retval == 0 ) { | 1839 | if ( retval == 0 ) { |
1840 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 1840 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
1841 | // retval == 0 : backup skipped for today, try again tomorrow | 1841 | // retval == 0 : backup skipped for today, try again tomorrow |
1842 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 1842 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
1843 | } else if ( retval == 1 ){ | 1843 | } else if ( retval == 1 ){ |
1844 | qDebug("KO: Backup created."); | 1844 | qDebug("KO: Backup created."); |
1845 | // backup ok | 1845 | // backup ok |
1846 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
1847 | KopiCalendarFile * cal = calendars.first(); | ||
1848 | cal = calendars.next(); | ||
1849 | while ( cal ) { | ||
1850 | if ( !cal->mErrorOnLoad ) { | ||
1851 | int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | ||
1852 | } | ||
1853 | cal = calendars.next(); | ||
1854 | } | ||
1846 | KOPrefs::instance()->mLastBackupDate = daysTo; | 1855 | KOPrefs::instance()->mLastBackupDate = daysTo; |
1847 | |||
1848 | } else if ( retval == 2 ){ | 1856 | } else if ( retval == 2 ){ |
1849 | qDebug("KO: Backup globally cancelled."); | 1857 | qDebug("KO: Backup globally cancelled."); |
1850 | // backup globally cancelled | 1858 | // backup globally cancelled |
1851 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 1859 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
1852 | } | 1860 | } |
1853 | // retval == 3: do nothing, try again later | 1861 | // retval == 3: do nothing, try again later |
1854 | } | 1862 | } |
1855 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 1863 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
1856 | } | 1864 | } |
1857 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1865 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1858 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1866 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1859 | qDebug("KO: Start saving data to file!"); | 1867 | qDebug("KO: Start saving data to file!"); |
1860 | mView->saveCalendars(); | 1868 | mView->saveCalendars(); |
1861 | mCalendarModifiedFlag = false; | 1869 | mCalendarModifiedFlag = false; |
1862 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1870 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1863 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1871 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1864 | QString savemes; | 1872 | QString savemes; |
1865 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1873 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1866 | setCaption(savemes); | 1874 | setCaption(savemes); |
1867 | } else | 1875 | } else |
1868 | setCaption(i18n("Saving cancelled!")); | 1876 | setCaption(i18n("Saving cancelled!")); |
1869 | mSyncManager->setBlockSave( false ); | 1877 | mSyncManager->setBlockSave( false ); |
1870 | } | 1878 | } |
1871 | 1879 | ||
1872 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1880 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1873 | { | 1881 | { |
1874 | if ( !e->isAutoRepeat() ) { | 1882 | if ( !e->isAutoRepeat() ) { |
1875 | mFlagKeyPressed = false; | 1883 | mFlagKeyPressed = false; |
1876 | } | 1884 | } |
1877 | } | 1885 | } |
1878 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1886 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1879 | { | 1887 | { |
1880 | qApp->processEvents(); | 1888 | qApp->processEvents(); |
1881 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1889 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1882 | e->ignore(); | 1890 | e->ignore(); |
1883 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1891 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1884 | return; | 1892 | return; |
1885 | } | 1893 | } |
1886 | if (! e->isAutoRepeat() ) | 1894 | if (! e->isAutoRepeat() ) |
1887 | mFlagKeyPressed = true; | 1895 | mFlagKeyPressed = true; |
1888 | KOPrefs *p = KOPrefs::instance(); | 1896 | KOPrefs *p = KOPrefs::instance(); |
1889 | bool showSelectedDates = false; | 1897 | bool showSelectedDates = false; |
1890 | int size; | 1898 | int size; |
1891 | int pro = 0; | 1899 | int pro = 0; |
1892 | //qDebug("MainWindow::keyPressEvent "); | 1900 | //qDebug("MainWindow::keyPressEvent "); |
1893 | switch ( e->key() ) { | 1901 | switch ( e->key() ) { |
1894 | case Qt::Key_Right: | 1902 | case Qt::Key_Right: |
1895 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1903 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1896 | mView->goNextMonth(); | 1904 | mView->goNextMonth(); |
1897 | else | 1905 | else |
1898 | mView->goNext(); | 1906 | mView->goNext(); |
1899 | showSelectedDates = true; | 1907 | showSelectedDates = true; |
1900 | break; | 1908 | break; |
1901 | case Qt::Key_Left: | 1909 | case Qt::Key_Left: |
1902 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1910 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1903 | mView->goPreviousMonth(); | 1911 | mView->goPreviousMonth(); |
1904 | else | 1912 | else |
1905 | mView->goPrevious(); | 1913 | mView->goPrevious(); |
1906 | showSelectedDates = true; | 1914 | showSelectedDates = true; |
1907 | break; | 1915 | break; |
1908 | case Qt::Key_Down: | 1916 | case Qt::Key_Down: |
1909 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1917 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1910 | break; | 1918 | break; |
1911 | case Qt::Key_Up: | 1919 | case Qt::Key_Up: |
1912 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1920 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1913 | break; | 1921 | break; |
1914 | case Qt::Key_K: | 1922 | case Qt::Key_K: |
1915 | mView->viewManager()->showMonthViewWeek(); | 1923 | mView->viewManager()->showMonthViewWeek(); |
1916 | break; | 1924 | break; |
1917 | case Qt::Key_I: | 1925 | case Qt::Key_I: |
1918 | mView->showIncidence(); | 1926 | mView->showIncidence(); |
1919 | break; | 1927 | break; |
1920 | case Qt::Key_Delete: | 1928 | case Qt::Key_Delete: |
1921 | case Qt::Key_Backspace: | 1929 | case Qt::Key_Backspace: |
1922 | mView->deleteIncidence(); | 1930 | mView->deleteIncidence(); |
1923 | break; | 1931 | break; |
1924 | case Qt::Key_D: | 1932 | case Qt::Key_D: |
1925 | mView->viewManager()->showDayView(); | 1933 | mView->viewManager()->showDayView(); |
1926 | showSelectedDates = true; | 1934 | showSelectedDates = true; |
1927 | break; | 1935 | break; |
1928 | case Qt::Key_O: | 1936 | case Qt::Key_O: |
1929 | mView->toggleFilerEnabled( ); | 1937 | mView->toggleFilerEnabled( ); |
1930 | break; | 1938 | break; |
1931 | case Qt::Key_0: | 1939 | case Qt::Key_0: |
1932 | case Qt::Key_1: | 1940 | case Qt::Key_1: |
1933 | case Qt::Key_2: | 1941 | case Qt::Key_2: |
1934 | case Qt::Key_3: | 1942 | case Qt::Key_3: |
1935 | case Qt::Key_4: | 1943 | case Qt::Key_4: |
1936 | case Qt::Key_5: | 1944 | case Qt::Key_5: |
1937 | case Qt::Key_6: | 1945 | case Qt::Key_6: |
1938 | case Qt::Key_7: | 1946 | case Qt::Key_7: |
1939 | case Qt::Key_8: | 1947 | case Qt::Key_8: |
1940 | case Qt::Key_9: | 1948 | case Qt::Key_9: |
1941 | pro = e->key()-48; | 1949 | pro = e->key()-48; |
1942 | if ( pro == 0 ) | 1950 | if ( pro == 0 ) |
1943 | pro = 10; | 1951 | pro = 10; |
1944 | if ( e->state() == Qt::ControlButton) | 1952 | if ( e->state() == Qt::ControlButton) |
1945 | pro += 10; | 1953 | pro += 10; |
1946 | break; | 1954 | break; |
1947 | case Qt::Key_M: | 1955 | case Qt::Key_M: |
1948 | mView->viewManager()->showMonthView(); | 1956 | mView->viewManager()->showMonthView(); |
1949 | showSelectedDates = true; | 1957 | showSelectedDates = true; |
1950 | break; | 1958 | break; |
1951 | case Qt::Key_Insert: | 1959 | case Qt::Key_Insert: |
1952 | mView->newEvent(); | 1960 | mView->newEvent(); |
1953 | break; | 1961 | break; |
1954 | case Qt::Key_S : | 1962 | case Qt::Key_S : |
1955 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1963 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1956 | mView->newSubTodo(); | 1964 | mView->newSubTodo(); |
1957 | else | 1965 | else |
1958 | mView->dialogManager()->showSearchDialog(); | 1966 | mView->dialogManager()->showSearchDialog(); |
1959 | break; | 1967 | break; |
1960 | case Qt::Key_Y : | 1968 | case Qt::Key_Y : |
1961 | case Qt::Key_Z : | 1969 | case Qt::Key_Z : |
1962 | mView->viewManager()->showWorkWeekView(); | 1970 | mView->viewManager()->showWorkWeekView(); |
1963 | showSelectedDates = true; | 1971 | showSelectedDates = true; |
1964 | break; | 1972 | break; |
1965 | case Qt::Key_U : | 1973 | case Qt::Key_U : |
1966 | mView->viewManager()->showWeekView(); | 1974 | mView->viewManager()->showWeekView(); |
1967 | showSelectedDates = true; | 1975 | showSelectedDates = true; |
1968 | break; | 1976 | break; |
1969 | case Qt::Key_H : | 1977 | case Qt::Key_H : |
1970 | keyBindings(); | 1978 | keyBindings(); |
1971 | break; | 1979 | break; |
1972 | case Qt::Key_W: | 1980 | case Qt::Key_W: |
1973 | mView->viewManager()->showWhatsNextView(); | 1981 | mView->viewManager()->showWhatsNextView(); |
1974 | break; | 1982 | break; |
1975 | case Qt::Key_L: | 1983 | case Qt::Key_L: |
1976 | mView->viewManager()->showListView(); | 1984 | mView->viewManager()->showListView(); |
1977 | break; | 1985 | break; |
1978 | case Qt::Key_N: | 1986 | case Qt::Key_N: |
1979 | mView->viewManager()->showNextView(); | 1987 | mView->viewManager()->showNextView(); |
1980 | break; | 1988 | break; |
1981 | case Qt::Key_V: | 1989 | case Qt::Key_V: |
1982 | mView->viewManager()->showTodoView(); | 1990 | mView->viewManager()->showTodoView(); |
1983 | break; | 1991 | break; |
1984 | case Qt::Key_C: | 1992 | case Qt::Key_C: |
1985 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1993 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1986 | break; | 1994 | break; |
1987 | case Qt::Key_P: | 1995 | case Qt::Key_P: |
1988 | mView->showDatePicker( ); | 1996 | mView->showDatePicker( ); |
1989 | break; | 1997 | break; |
1990 | case Qt::Key_F: | 1998 | case Qt::Key_F: |
1991 | mView->editFilters(); | 1999 | mView->editFilters(); |
1992 | break; | 2000 | break; |
1993 | case Qt::Key_R: | 2001 | case Qt::Key_R: |
1994 | mView->toggleFilter(); | 2002 | mView->toggleFilter(); |
1995 | break; | 2003 | break; |
1996 | case Qt::Key_X: | 2004 | case Qt::Key_X: |
1997 | if ( e->state() == Qt::ControlButton ) | 2005 | if ( e->state() == Qt::ControlButton ) |
1998 | mView->toggleDateNavigatorWidget(); | 2006 | mView->toggleDateNavigatorWidget(); |
1999 | else { | 2007 | else { |
2000 | mView->viewManager()->showNextXView(); | 2008 | mView->viewManager()->showNextXView(); |
2001 | showSelectedDates = true; | 2009 | showSelectedDates = true; |
2002 | } | 2010 | } |
2003 | break; | 2011 | break; |
2004 | case Qt::Key_Space: | 2012 | case Qt::Key_Space: |
2005 | mView->toggleExpand(); | 2013 | mView->toggleExpand(); |
2006 | break; | 2014 | break; |
2007 | case Qt::Key_A: | 2015 | case Qt::Key_A: |
2008 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2016 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2009 | mView->showNextAlarms(); | 2017 | mView->showNextAlarms(); |
2010 | else | 2018 | else |
2011 | mView->toggleAllDaySize(); | 2019 | mView->toggleAllDaySize(); |
2012 | break; | 2020 | break; |
2013 | case Qt::Key_T: | 2021 | case Qt::Key_T: |
2014 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2022 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2015 | mView->newTodo(); | 2023 | mView->newTodo(); |
2016 | else { | 2024 | else { |
2017 | mView->goToday(); | 2025 | mView->goToday(); |
2018 | showSelectedDates = true; | 2026 | showSelectedDates = true; |
2019 | } | 2027 | } |
2020 | break; | 2028 | break; |
2021 | case Qt::Key_J: | 2029 | case Qt::Key_J: |
2022 | mView->viewManager()->showJournalView(); | 2030 | mView->viewManager()->showJournalView(); |
2023 | break; | 2031 | break; |
2024 | case Qt::Key_B: | 2032 | case Qt::Key_B: |
2025 | mView->editIncidenceDescription();; | 2033 | mView->editIncidenceDescription();; |
2026 | break; | 2034 | break; |
2027 | // case Qt::Key_Return: | 2035 | // case Qt::Key_Return: |
2028 | case Qt::Key_E: | 2036 | case Qt::Key_E: |
2029 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2037 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2030 | mView->newEvent(); | 2038 | mView->newEvent(); |
2031 | else | 2039 | else |
2032 | mView->editIncidence(); | 2040 | mView->editIncidence(); |
2033 | break; | 2041 | break; |
2034 | case Qt::Key_Plus: | 2042 | case Qt::Key_Plus: |
2035 | size = p->mHourSize +2; | 2043 | size = p->mHourSize +2; |
2036 | if ( size <= 22 ) | 2044 | if ( size <= 22 ) |
2037 | configureAgenda( size ); | 2045 | configureAgenda( size ); |
2038 | break; | 2046 | break; |
2039 | case Qt::Key_Minus: | 2047 | case Qt::Key_Minus: |