summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-14 15:00:29 (UTC)
committer zautrix <zautrix>2005-06-14 15:00:29 (UTC)
commit9b2265ffbe8c21fff0b00b376dd3925e4b44168b (patch) (unidiff)
tree27147c040dc5bbd44f2210955e4df2fb1930fb93
parentd38f601cfdb510fc39dd798af44a50c7958d7be8 (diff)
downloadkdepimpi-9b2265ffbe8c21fff0b00b376dd3925e4b44168b.zip
kdepimpi-9b2265ffbe8c21fff0b00b376dd3925e4b44168b.tar.gz
kdepimpi-9b2265ffbe8c21fff0b00b376dd3925e4b44168b.tar.bz2
compile fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b0be340..dd4ea41 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1765,396 +1765,399 @@ bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a
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}
1773bool CalendarView::importQtopia( const QString &categories, 1773bool 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
1833void CalendarView::setSyncEventsReadOnly() 1833void 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
1845bool CalendarView::loadCalendars() 1845bool 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 return true;
1861} 1862}
1862bool CalendarView::restoreCalendarSettings() 1863bool CalendarView::restoreCalendarSettings()
1863{ 1864{
1864 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1865 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1865 KopiCalendarFile * cal = calendars.first(); 1866 KopiCalendarFile * cal = calendars.first();
1866 while ( cal ) { 1867 while ( cal ) {
1867 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1868 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1868 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1869 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1869 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1870 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1870 if ( cal->isStandard ) 1871 if ( cal->isStandard )
1871 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1872 mCalendar->setDefaultCalendar( cal->mCalNumber );
1872 cal = calendars.next(); 1873 cal = calendars.next();
1873 } 1874 }
1875 return true;
1874} 1876}
1875void CalendarView::addCalendarId( int id ) 1877void CalendarView::addCalendarId( int id )
1876{ 1878{
1877 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1879 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1878 addCalendar( cal ); 1880 addCalendar( cal );
1879} 1881}
1880bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1882bool CalendarView::addCalendar( KopiCalendarFile * cal )
1881{ 1883{
1882 cal->mErrorOnLoad = false; 1884 cal->mErrorOnLoad = false;
1883 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1885 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1884 cal->mLoadDt = QDateTime::currentDateTime(); 1886 cal->mLoadDt = QDateTime::currentDateTime();
1885 return true; 1887 return true;
1886 } 1888 }
1887 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1889 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1888 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1890 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1889 cal->mErrorOnLoad = true; 1891 cal->mErrorOnLoad = true;
1890 return false; 1892 return false;
1891} 1893}
1892bool CalendarView::openCalendar(QString filename, bool merge) 1894bool CalendarView::openCalendar(QString filename, bool merge)
1893{ 1895{
1894 1896
1895 if (filename.isEmpty()) { 1897 if (filename.isEmpty()) {
1896 return false; 1898 return false;
1897 } 1899 }
1898 1900
1899 if (!QFile::exists(filename)) { 1901 if (!QFile::exists(filename)) {
1900 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1902 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1901 return false; 1903 return false;
1902 } 1904 }
1903 1905
1904 globalFlagBlockAgenda = 1; 1906 globalFlagBlockAgenda = 1;
1905 clearAllViews(); 1907 clearAllViews();
1906 if (!merge) { 1908 if (!merge) {
1907 mViewManager->setDocumentId( filename ); 1909 mViewManager->setDocumentId( filename );
1908 mCalendar->close(); 1910 mCalendar->close();
1909 } 1911 }
1910 mStorage->setFileName( filename ); 1912 mStorage->setFileName( filename );
1911 1913
1912 if ( mStorage->load() ) { 1914 if ( mStorage->load() ) {
1913 if ( merge ) ;//setModified( true ); 1915 if ( merge ) ;//setModified( true );
1914 else { 1916 else {
1915 //setModified( true ); 1917 //setModified( true );
1916 mViewManager->setDocumentId( filename ); 1918 mViewManager->setDocumentId( filename );
1917 mDialogManager->setDocumentId( filename ); 1919 mDialogManager->setDocumentId( filename );
1918 mTodoList->setDocumentId( filename ); 1920 mTodoList->setDocumentId( filename );
1919 } 1921 }
1920 globalFlagBlockAgenda = 2; 1922 globalFlagBlockAgenda = 2;
1921 // if ( getLastSyncEvent() ) 1923 // if ( getLastSyncEvent() )
1922 // getLastSyncEvent()->setReadOnly( true ); 1924 // getLastSyncEvent()->setReadOnly( true );
1923 mCalendar->reInitAlarmSettings(); 1925 mCalendar->reInitAlarmSettings();
1924 setSyncEventsReadOnly(); 1926 setSyncEventsReadOnly();
1925 updateUnmanagedViews(); 1927 updateUnmanagedViews();
1926 updateView(); 1928 updateView();
1927 if ( filename != MainWindow::defaultFileName() ) { 1929 if ( filename != MainWindow::defaultFileName() ) {
1928 saveCalendar( MainWindow::defaultFileName() ); 1930 saveCalendar( MainWindow::defaultFileName() );
1929 } else { 1931 } else {
1930 QFileInfo finf ( MainWindow::defaultFileName()); 1932 QFileInfo finf ( MainWindow::defaultFileName());
1931 if ( finf.exists() ) { 1933 if ( finf.exists() ) {
1932 setLoadedFileVersion( finf.lastModified () ); 1934 setLoadedFileVersion( finf.lastModified () );
1933 } 1935 }
1934 } 1936 }
1935 return true; 1937 return true;
1936 } else { 1938 } else {
1937 // while failing to load, the calendar object could 1939 // while failing to load, the calendar object could
1938 // have become partially populated. Clear it out. 1940 // have become partially populated. Clear it out.
1939 if ( !merge ) { 1941 if ( !merge ) {
1940 mCalendar->close(); 1942 mCalendar->close();
1941 mViewManager->setDocumentId( filename ); 1943 mViewManager->setDocumentId( filename );
1942 mDialogManager->setDocumentId( filename ); 1944 mDialogManager->setDocumentId( filename );
1943 mTodoList->setDocumentId( filename ); 1945 mTodoList->setDocumentId( filename );
1944 } 1946 }
1945 1947
1946 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1948 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1947 1949
1948 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1950 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1949 globalFlagBlockAgenda = 2; 1951 globalFlagBlockAgenda = 2;
1950 mCalendar->reInitAlarmSettings(); 1952 mCalendar->reInitAlarmSettings();
1951 setSyncEventsReadOnly(); 1953 setSyncEventsReadOnly();
1952 updateUnmanagedViews(); 1954 updateUnmanagedViews();
1953 updateView(); 1955 updateView();
1954 } 1956 }
1955 return false; 1957 return false;
1956} 1958}
1957void CalendarView::showOpenError() 1959void CalendarView::showOpenError()
1958{ 1960{
1959 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1961 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1960} 1962}
1961void CalendarView::setLoadedFileVersion(QDateTime dt) 1963void CalendarView::setLoadedFileVersion(QDateTime dt)
1962{ 1964{
1963 loadedFileVersion = dt; 1965 loadedFileVersion = dt;
1964} 1966}
1965bool CalendarView::checkFileChanged(QString fn) 1967bool CalendarView::checkFileChanged(QString fn)
1966{ 1968{
1967 QFileInfo finf ( fn ); 1969 QFileInfo finf ( fn );
1968 if ( !finf.exists() ) 1970 if ( !finf.exists() )
1969 return true; 1971 return true;
1970 QDateTime dt = finf.lastModified (); 1972 QDateTime dt = finf.lastModified ();
1971 if ( dt <= loadedFileVersion ) 1973 if ( dt <= loadedFileVersion )
1972 return false; 1974 return false;
1973 return true; 1975 return true;
1974 1976
1975} 1977}
1976void CalendarView::watchSavedFile() 1978void CalendarView::watchSavedFile()
1977{ 1979{
1978 QFileInfo finf ( MainWindow::defaultFileName()); 1980 QFileInfo finf ( MainWindow::defaultFileName());
1979 if ( !finf.exists() ) 1981 if ( !finf.exists() )
1980 return; 1982 return;
1981 QDateTime dt = finf.lastModified (); 1983 QDateTime dt = finf.lastModified ();
1982 if ( dt < loadedFileVersion ) { 1984 if ( dt < loadedFileVersion ) {
1983 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1985 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1984 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1986 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1985 return; 1987 return;
1986 } 1988 }
1987 loadedFileVersion = dt; 1989 loadedFileVersion = dt;
1988} 1990}
1989bool CalendarView::checkAllFileVersions() 1991bool CalendarView::checkAllFileVersions()
1990{ 1992{
1991 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1993 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1992 KopiCalendarFile * cal = calendars.first(); 1994 KopiCalendarFile * cal = calendars.first();
1993 mCalendar->setDefaultCalendar( 1 ); 1995 mCalendar->setDefaultCalendar( 1 );
1994 mCalendar->setDefaultCalendarEnabledOnly(); 1996 mCalendar->setDefaultCalendarEnabledOnly();
1995 if ( !checkFileVersion(MainWindow::defaultFileName())) 1997 if ( !checkFileVersion(MainWindow::defaultFileName()))
1996 return false; 1998 return false;
1997 cal = calendars.next(); 1999 cal = calendars.next();
1998 QDateTime storeTemp = loadedFileVersion; 2000 QDateTime storeTemp = loadedFileVersion;
1999 while ( cal ) { 2001 while ( cal ) {
2000 if ( !cal->mErrorOnLoad ) { 2002 if ( !cal->mErrorOnLoad ) {
2001 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2003 mCalendar->setDefaultCalendar( cal->mCalNumber );
2002 mCalendar->setDefaultCalendarEnabledOnly(); 2004 mCalendar->setDefaultCalendarEnabledOnly();
2003 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2005 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2004 if ( !checkFileVersion(cal->mFileName )) { 2006 if ( !checkFileVersion(cal->mFileName )) {
2005 loadedFileVersion = storeTemp; 2007 loadedFileVersion = storeTemp;
2006 updateView(); 2008 updateView();
2007 return false; 2009 return false;
2008 } 2010 }
2009 } 2011 }
2010 cal = calendars.next(); 2012 cal = calendars.next();
2011 } 2013 }
2012 loadedFileVersion = storeTemp; 2014 loadedFileVersion = storeTemp;
2013 updateView(); 2015 updateView();
2014 return true; 2016 return true;
2015} 2017}
2016bool CalendarView::checkFileVersion(QString fn) 2018bool CalendarView::checkFileVersion(QString fn)
2017{ 2019{
2018 QFileInfo finf ( fn ); 2020 QFileInfo finf ( fn );
2019 if ( !finf.exists() ) 2021 if ( !finf.exists() )
2020 return true; 2022 return true;
2021 QDateTime dt = finf.lastModified (); 2023 QDateTime dt = finf.lastModified ();
2022 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 2024 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
2023 //qDebug("file on disk version %s",dt.toString().latin1()); 2025 //qDebug("file on disk version %s",dt.toString().latin1());
2024 if ( dt <= loadedFileVersion ) 2026 if ( dt <= loadedFileVersion )
2025 return true; 2027 return 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)) , 2028 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)) ,
2027 i18n("KO/Pi Warning"),i18n("Overwrite"), 2029 i18n("KO/Pi Warning"),i18n("Overwrite"),
2028 i18n("Sync+save")); 2030 i18n("Sync+save"));
2029 2031
2030 if ( km == KMessageBox::Cancel ) 2032 if ( km == KMessageBox::Cancel )
2031 return false; 2033 return false;
2032 if ( km == KMessageBox::Yes ) 2034 if ( km == KMessageBox::Yes )
2033 return true; 2035 return true;
2034 2036
2035 setSyncDevice("deleteaftersync" ); 2037 setSyncDevice("deleteaftersync" );
2036 mSyncManager->mAskForPreferences = true; 2038 mSyncManager->mAskForPreferences = true;
2037 mSyncManager->mSyncAlgoPrefs = 3; 2039 mSyncManager->mSyncAlgoPrefs = 3;
2038 mSyncManager->mWriteBackFile = false; 2040 mSyncManager->mWriteBackFile = false;
2039 mSyncManager->mWriteBackExistingOnly = false; 2041 mSyncManager->mWriteBackExistingOnly = false;
2040 mSyncManager->mShowSyncSummary = false; 2042 mSyncManager->mShowSyncSummary = false;
2041 syncCalendar( fn, 3 ); 2043 syncCalendar( fn, 3 );
2042 Event * e = getLastSyncEvent(); 2044 Event * e = getLastSyncEvent();
2043 if ( e ) 2045 if ( e )
2044 mCalendar->deleteEvent( e ); 2046 mCalendar->deleteEvent( e );
2045 return true; 2047 return true;
2046} 2048}
2047bool CalendarView::saveCalendars() 2049bool CalendarView::saveCalendars()
2048{ 2050{
2049 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2051 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2050 KopiCalendarFile * cal = calendars.first(); 2052 KopiCalendarFile * cal = calendars.first();
2051 mCalendar->setDefaultCalendar( 1 ); 2053 mCalendar->setDefaultCalendar( 1 );
2052 mCalendar->setDefaultCalendarEnabledOnly(); 2054 mCalendar->setDefaultCalendarEnabledOnly();
2053 saveCalendar( MainWindow::defaultFileName() ); 2055 saveCalendar( MainWindow::defaultFileName() );
2054 cal = calendars.next(); 2056 cal = calendars.next();
2055 while ( cal ) { 2057 while ( cal ) {
2056 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2058 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2057 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2059 mCalendar->setDefaultCalendar( cal->mCalNumber );
2058 mCalendar->setDefaultCalendarEnabledOnly(); 2060 mCalendar->setDefaultCalendarEnabledOnly();
2059 if ( saveCalendar( cal->mFileName ) ) 2061 if ( saveCalendar( cal->mFileName ) )
2060 cal->mLoadDt = QDateTime::currentDateTime(); 2062 cal->mLoadDt = QDateTime::currentDateTime();
2061 } 2063 }
2062 cal = calendars.next(); 2064 cal = calendars.next();
2063 } 2065 }
2064 restoreCalendarSettings(); 2066 restoreCalendarSettings();
2067 return true;
2065} 2068}
2066bool CalendarView::saveCalendar( QString filename ) 2069bool CalendarView::saveCalendar( QString filename )
2067{ 2070{
2068 2071
2069 // Store back all unsaved data into calendar object 2072 // Store back all unsaved data into calendar object
2070 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2073 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2071 if ( mViewManager->currentView() ) 2074 if ( mViewManager->currentView() )
2072 mViewManager->currentView()->flushView(); 2075 mViewManager->currentView()->flushView();
2073 2076
2074 2077
2075 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2078 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2076 mStorage->setSaveFormat( new ICalFormat() ); 2079 mStorage->setSaveFormat( new ICalFormat() );
2077 mStorage->setFileName( filename ); 2080 mStorage->setFileName( filename );
2078 bool success; 2081 bool success;
2079 success = mStorage->save(); 2082 success = mStorage->save();
2080 if ( !success ) { 2083 if ( !success ) {
2081 return false; 2084 return false;
2082 } 2085 }
2083 if ( filename == MainWindow::defaultFileName() ) { 2086 if ( filename == MainWindow::defaultFileName() ) {
2084 setLoadedFileVersion( lfv ); 2087 setLoadedFileVersion( lfv );
2085 watchSavedFile(); 2088 watchSavedFile();
2086 } 2089 }
2087 return true; 2090 return true;
2088} 2091}
2089 2092
2090void CalendarView::closeCalendar() 2093void CalendarView::closeCalendar()
2091{ 2094{
2092 2095
2093 // child windows no longer valid 2096 // child windows no longer valid
2094 clearAllViews(); 2097 clearAllViews();
2095 emit closingDown(); 2098 emit closingDown();
2096 2099
2097 mCalendar->close(); 2100 mCalendar->close();
2098 setModified(false); 2101 setModified(false);
2099 updateView(); 2102 updateView();
2100} 2103}
2101 2104
2102void CalendarView::archiveCalendar() 2105void CalendarView::archiveCalendar()
2103{ 2106{
2104 mDialogManager->showArchiveDialog(); 2107 mDialogManager->showArchiveDialog();
2105} 2108}
2106 2109
2107 2110
2108void CalendarView::readSettings() 2111void CalendarView::readSettings()
2109{ 2112{
2110 2113
2111 2114
2112 // mViewManager->showAgendaView(); 2115 // mViewManager->showAgendaView();
2113 QString str; 2116 QString str;
2114 //qDebug("CalendarView::readSettings() "); 2117 //qDebug("CalendarView::readSettings() ");
2115 // read settings from the KConfig, supplying reasonable 2118 // read settings from the KConfig, supplying reasonable
2116 // defaults where none are to be found 2119 // defaults where none are to be found
2117 KConfig *config = KOGlobals::config(); 2120 KConfig *config = KOGlobals::config();
2118#ifndef KORG_NOSPLITTER 2121#ifndef KORG_NOSPLITTER
2119 config->setGroup("KOrganizer Geometry"); 2122 config->setGroup("KOrganizer Geometry");
2120 2123
2121 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2124 QValueList<int> sizes = config->readIntListEntry("Separator1");
2122 if (sizes.count() != 2) { 2125 if (sizes.count() != 2) {
2123 sizes << mDateNavigator->minimumSizeHint().width(); 2126 sizes << mDateNavigator->minimumSizeHint().width();
2124 sizes << 300; 2127 sizes << 300;
2125 } 2128 }
2126 mPanner->setSizes(sizes); 2129 mPanner->setSizes(sizes);
2127 2130
2128 sizes = config->readIntListEntry("Separator2"); 2131 sizes = config->readIntListEntry("Separator2");
2129 if ( ( mResourceView && sizes.count() == 4 ) || 2132 if ( ( mResourceView && sizes.count() == 4 ) ||
2130 ( !mResourceView && sizes.count() == 3 ) ) { 2133 ( !mResourceView && sizes.count() == 3 ) ) {
2131 mLeftSplitter->setSizes(sizes); 2134 mLeftSplitter->setSizes(sizes);
2132 } 2135 }
2133#endif 2136#endif
2134 globalFlagBlockAgenda = 1; 2137 globalFlagBlockAgenda = 1;
2135 mViewManager->showAgendaView(); 2138 mViewManager->showAgendaView();
2136 //mViewManager->readSettings( config ); 2139 //mViewManager->readSettings( config );
2137 mTodoList->restoreLayout(config,QString("Todo Layout")); 2140 mTodoList->restoreLayout(config,QString("Todo Layout"));
2138 readFilterSettings(config); 2141 readFilterSettings(config);
2139 2142
2140#ifdef DESKTOP_VERSION 2143#ifdef DESKTOP_VERSION
2141 config->setGroup("WidgetLayout"); 2144 config->setGroup("WidgetLayout");
2142 QStringList list; 2145 QStringList list;
2143 list = config->readListEntry("MainLayout"); 2146 list = config->readListEntry("MainLayout");
2144 int x,y,w,h; 2147 int x,y,w,h;
2145 if ( ! list.isEmpty() ) { 2148 if ( ! list.isEmpty() ) {
2146 x = list[0].toInt(); 2149 x = list[0].toInt();
2147 y = list[1].toInt(); 2150 y = list[1].toInt();
2148 w = list[2].toInt(); 2151 w = list[2].toInt();
2149 h = list[3].toInt(); 2152 h = list[3].toInt();
2150 KApplication::testCoords( &x,&y,&w,&h ); 2153 KApplication::testCoords( &x,&y,&w,&h );
2151 topLevelWidget()->setGeometry(x,y,w,h); 2154 topLevelWidget()->setGeometry(x,y,w,h);
2152 2155
2153 } else { 2156 } else {
2154 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2157 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2155 } 2158 }
2156 list = config->readListEntry("EditEventLayout"); 2159 list = config->readListEntry("EditEventLayout");
2157 if ( ! list.isEmpty() ) { 2160 if ( ! list.isEmpty() ) {
2158 x = list[0].toInt(); 2161 x = list[0].toInt();
2159 y = list[1].toInt(); 2162 y = list[1].toInt();
2160 w = list[2].toInt(); 2163 w = list[2].toInt();