author | zautrix <zautrix> | 2005-06-07 05:09:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-07 05:09:23 (UTC) |
commit | 0bbef196163a267722978e34db2ba3daaee76f88 (patch) (unidiff) | |
tree | fac0b701aea6348490c5e9585820070b32b35e29 /korganizer/calendarview.cpp | |
parent | 790b8c38e1305b2f5ee4485e59a3ecd01e5b6f75 (diff) | |
download | kdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.zip kdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.tar.gz kdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.tar.bz2 |
clear view fixes
-rw-r--r-- | korganizer/calendarview.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 608b73b..e13d0be 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1099,96 +1099,97 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t | |||
1099 | return; | 1099 | return; |
1100 | } | 1100 | } |
1101 | if ( toDelete->type() == "Journal" ) | 1101 | if ( toDelete->type() == "Journal" ) |
1102 | return; | 1102 | return; |
1103 | 1103 | ||
1104 | Event* eve = lastSync.first(); | 1104 | Event* eve = lastSync.first(); |
1105 | 1105 | ||
1106 | while ( eve ) { | 1106 | while ( eve ) { |
1107 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1107 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1108 | if ( !id.isEmpty() ) { | 1108 | if ( !id.isEmpty() ) { |
1109 | QString des = eve->description(); | 1109 | QString des = eve->description(); |
1110 | QString pref = "e"; | 1110 | QString pref = "e"; |
1111 | if ( toDelete->type() == "Todo" ) | 1111 | if ( toDelete->type() == "Todo" ) |
1112 | pref = "t"; | 1112 | pref = "t"; |
1113 | des += pref+ id + ","; | 1113 | des += pref+ id + ","; |
1114 | eve->setReadOnly( false ); | 1114 | eve->setReadOnly( false ); |
1115 | eve->setDescription( des ); | 1115 | eve->setDescription( des ); |
1116 | //qDebug("setdes %s ", des.latin1()); | 1116 | //qDebug("setdes %s ", des.latin1()); |
1117 | eve->setReadOnly( true ); | 1117 | eve->setReadOnly( true ); |
1118 | } | 1118 | } |
1119 | eve = lastSync.next(); | 1119 | eve = lastSync.next(); |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | } | 1122 | } |
1123 | void CalendarView::checkExternalId( Incidence * inc ) | 1123 | void CalendarView::checkExternalId( Incidence * inc ) |
1124 | { | 1124 | { |
1125 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1125 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1126 | checkExternSyncEvent( lastSync, inc ); | 1126 | checkExternSyncEvent( lastSync, inc ); |
1127 | 1127 | ||
1128 | } | 1128 | } |
1129 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1129 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1130 | { | 1130 | { |
1131 | bool syncOK = true; | 1131 | bool syncOK = true; |
1132 | int addedEvent = 0; | 1132 | int addedEvent = 0; |
1133 | int addedEventR = 0; | 1133 | int addedEventR = 0; |
1134 | int deletedEventR = 0; | 1134 | int deletedEventR = 0; |
1135 | int deletedEventL = 0; | 1135 | int deletedEventL = 0; |
1136 | int changedLocal = 0; | 1136 | int changedLocal = 0; |
1137 | int changedRemote = 0; | 1137 | int changedRemote = 0; |
1138 | int filteredIN = 0; | 1138 | int filteredIN = 0; |
1139 | int filteredOUT = 0; | 1139 | int filteredOUT = 0; |
1140 | //QPtrList<Event> el = local->rawEvents(); | 1140 | //QPtrList<Event> el = local->rawEvents(); |
1141 | Event* eventR; | 1141 | Event* eventR; |
1142 | QString uid; | 1142 | QString uid; |
1143 | int take; | 1143 | int take; |
1144 | Event* eventL; | 1144 | Event* eventL; |
1145 | Event* eventRSync; | 1145 | Event* eventRSync; |
1146 | Event* eventLSync; | 1146 | Event* eventLSync; |
1147 | clearAllViews(); | ||
1147 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1148 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1148 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1149 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1149 | bool fullDateRange = false; | 1150 | bool fullDateRange = false; |
1150 | local->resetTempSyncStat(); | 1151 | local->resetTempSyncStat(); |
1151 | mLastCalendarSync = QDateTime::currentDateTime(); | 1152 | mLastCalendarSync = QDateTime::currentDateTime(); |
1152 | if ( mSyncManager->syncWithDesktop() ) { | 1153 | if ( mSyncManager->syncWithDesktop() ) { |
1153 | remote->resetPilotStat(1); | 1154 | remote->resetPilotStat(1); |
1154 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1155 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1155 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1156 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1156 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1157 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1157 | } else { | 1158 | } else { |
1158 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1159 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1159 | } | 1160 | } |
1160 | } | 1161 | } |
1161 | QDateTime modifiedCalendar = mLastCalendarSync; | 1162 | QDateTime modifiedCalendar = mLastCalendarSync; |
1162 | eventLSync = getLastSyncEvent(); | 1163 | eventLSync = getLastSyncEvent(); |
1163 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1164 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1164 | if ( eventR ) { | 1165 | if ( eventR ) { |
1165 | eventRSync = (Event*) eventR->clone(); | 1166 | eventRSync = (Event*) eventR->clone(); |
1166 | remote->deleteEvent(eventR ); | 1167 | remote->deleteEvent(eventR ); |
1167 | 1168 | ||
1168 | } else { | 1169 | } else { |
1169 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1170 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1170 | eventRSync = (Event*)eventLSync->clone(); | 1171 | eventRSync = (Event*)eventLSync->clone(); |
1171 | } else { | 1172 | } else { |
1172 | fullDateRange = true; | 1173 | fullDateRange = true; |
1173 | eventRSync = new Event(); | 1174 | eventRSync = new Event(); |
1174 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1175 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1175 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1176 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1176 | eventRSync->setDtStart( mLastCalendarSync ); | 1177 | eventRSync->setDtStart( mLastCalendarSync ); |
1177 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1178 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1178 | eventRSync->setCategories( i18n("SyncEvent") ); | 1179 | eventRSync->setCategories( i18n("SyncEvent") ); |
1179 | } | 1180 | } |
1180 | } | 1181 | } |
1181 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1182 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1182 | fullDateRange = true; | 1183 | fullDateRange = true; |
1183 | 1184 | ||
1184 | if ( ! fullDateRange ) { | 1185 | if ( ! fullDateRange ) { |
1185 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1186 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1186 | 1187 | ||
1187 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1188 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1188 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1189 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1189 | fullDateRange = true; | 1190 | fullDateRange = true; |
1190 | } | 1191 | } |
1191 | } | 1192 | } |
1192 | if ( mSyncManager->syncWithDesktop() ) { | 1193 | if ( mSyncManager->syncWithDesktop() ) { |
1193 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1194 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1194 | } | 1195 | } |
@@ -1791,98 +1792,98 @@ bool CalendarView::importQtopia( const QString &categories, | |||
1791 | getEventViewerDialog()->setSyncMode( false ); | 1792 | getEventViewerDialog()->setSyncMode( false ); |
1792 | qApp->processEvents(); | 1793 | qApp->processEvents(); |
1793 | if ( syncOK ) { | 1794 | if ( syncOK ) { |
1794 | if ( mSyncManager->mWriteBackFile ) | 1795 | if ( mSyncManager->mWriteBackFile ) |
1795 | { | 1796 | { |
1796 | // write back XML file | 1797 | // write back XML file |
1797 | 1798 | ||
1798 | } | 1799 | } |
1799 | setModified( true ); | 1800 | setModified( true ); |
1800 | } | 1801 | } |
1801 | } else { | 1802 | } else { |
1802 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1803 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1803 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1804 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1804 | question, i18n("Ok")) ; | 1805 | question, i18n("Ok")) ; |
1805 | } | 1806 | } |
1806 | delete calendar; | 1807 | delete calendar; |
1807 | updateView(); | 1808 | updateView(); |
1808 | return syncOK; | 1809 | return syncOK; |
1809 | 1810 | ||
1810 | 1811 | ||
1811 | #endif | 1812 | #endif |
1812 | 1813 | ||
1813 | } | 1814 | } |
1814 | 1815 | ||
1815 | void CalendarView::setSyncEventsReadOnly() | 1816 | void CalendarView::setSyncEventsReadOnly() |
1816 | { | 1817 | { |
1817 | Event * ev; | 1818 | Event * ev; |
1818 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1819 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1819 | ev = eL.first(); | 1820 | ev = eL.first(); |
1820 | while ( ev ) { | 1821 | while ( ev ) { |
1821 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1822 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1822 | ev->setReadOnly( true ); | 1823 | ev->setReadOnly( true ); |
1823 | ev = eL.next(); | 1824 | ev = eL.next(); |
1824 | } | 1825 | } |
1825 | } | 1826 | } |
1826 | bool CalendarView::openCalendar(QString filename, bool merge) | 1827 | bool CalendarView::openCalendar(QString filename, bool merge) |
1827 | { | 1828 | { |
1828 | 1829 | ||
1829 | if (filename.isEmpty()) { | 1830 | if (filename.isEmpty()) { |
1830 | return false; | 1831 | return false; |
1831 | } | 1832 | } |
1832 | 1833 | ||
1833 | if (!QFile::exists(filename)) { | 1834 | if (!QFile::exists(filename)) { |
1834 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1835 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1835 | return false; | 1836 | return false; |
1836 | } | 1837 | } |
1837 | 1838 | ||
1838 | globalFlagBlockAgenda = 1; | 1839 | globalFlagBlockAgenda = 1; |
1840 | clearAllViews(); | ||
1839 | if (!merge) { | 1841 | if (!merge) { |
1840 | mTodoList->clearList(); | ||
1841 | mViewManager->setDocumentId( filename ); | 1842 | mViewManager->setDocumentId( filename ); |
1842 | mCalendar->close(); | 1843 | mCalendar->close(); |
1843 | } | 1844 | } |
1844 | mStorage->setFileName( filename ); | 1845 | mStorage->setFileName( filename ); |
1845 | 1846 | ||
1846 | if ( mStorage->load() ) { | 1847 | if ( mStorage->load() ) { |
1847 | if ( merge ) ;//setModified( true ); | 1848 | if ( merge ) ;//setModified( true ); |
1848 | else { | 1849 | else { |
1849 | //setModified( true ); | 1850 | //setModified( true ); |
1850 | mViewManager->setDocumentId( filename ); | 1851 | mViewManager->setDocumentId( filename ); |
1851 | mDialogManager->setDocumentId( filename ); | 1852 | mDialogManager->setDocumentId( filename ); |
1852 | mTodoList->setDocumentId( filename ); | 1853 | mTodoList->setDocumentId( filename ); |
1853 | } | 1854 | } |
1854 | globalFlagBlockAgenda = 2; | 1855 | globalFlagBlockAgenda = 2; |
1855 | // if ( getLastSyncEvent() ) | 1856 | // if ( getLastSyncEvent() ) |
1856 | // getLastSyncEvent()->setReadOnly( true ); | 1857 | // getLastSyncEvent()->setReadOnly( true ); |
1857 | mCalendar->reInitAlarmSettings(); | 1858 | mCalendar->reInitAlarmSettings(); |
1858 | setSyncEventsReadOnly(); | 1859 | setSyncEventsReadOnly(); |
1859 | updateUnmanagedViews(); | 1860 | updateUnmanagedViews(); |
1860 | updateView(); | 1861 | updateView(); |
1861 | if ( filename != MainWindow::defaultFileName() ) { | 1862 | if ( filename != MainWindow::defaultFileName() ) { |
1862 | saveCalendar( MainWindow::defaultFileName() ); | 1863 | saveCalendar( MainWindow::defaultFileName() ); |
1863 | } else { | 1864 | } else { |
1864 | QFileInfo finf ( MainWindow::defaultFileName()); | 1865 | QFileInfo finf ( MainWindow::defaultFileName()); |
1865 | if ( finf.exists() ) { | 1866 | if ( finf.exists() ) { |
1866 | setLoadedFileVersion( finf.lastModified () ); | 1867 | setLoadedFileVersion( finf.lastModified () ); |
1867 | } | 1868 | } |
1868 | } | 1869 | } |
1869 | return true; | 1870 | return true; |
1870 | } else { | 1871 | } else { |
1871 | // while failing to load, the calendar object could | 1872 | // while failing to load, the calendar object could |
1872 | // have become partially populated. Clear it out. | 1873 | // have become partially populated. Clear it out. |
1873 | if ( !merge ) { | 1874 | if ( !merge ) { |
1874 | mCalendar->close(); | 1875 | mCalendar->close(); |
1875 | mViewManager->setDocumentId( filename ); | 1876 | mViewManager->setDocumentId( filename ); |
1876 | mDialogManager->setDocumentId( filename ); | 1877 | mDialogManager->setDocumentId( filename ); |
1877 | mTodoList->setDocumentId( filename ); | 1878 | mTodoList->setDocumentId( filename ); |
1878 | } | 1879 | } |
1879 | 1880 | ||
1880 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1881 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1881 | 1882 | ||
1882 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1883 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1883 | globalFlagBlockAgenda = 2; | 1884 | globalFlagBlockAgenda = 2; |
1884 | mCalendar->reInitAlarmSettings(); | 1885 | mCalendar->reInitAlarmSettings(); |
1885 | setSyncEventsReadOnly(); | 1886 | setSyncEventsReadOnly(); |
1886 | updateUnmanagedViews(); | 1887 | updateUnmanagedViews(); |
1887 | updateView(); | 1888 | updateView(); |
1888 | } | 1889 | } |
@@ -1903,129 +1904,131 @@ bool CalendarView::checkFileChanged(QString fn) | |||
1903 | return true; | 1904 | return true; |
1904 | QDateTime dt = finf.lastModified (); | 1905 | QDateTime dt = finf.lastModified (); |
1905 | if ( dt <= loadedFileVersion ) | 1906 | if ( dt <= loadedFileVersion ) |
1906 | return false; | 1907 | return false; |
1907 | return true; | 1908 | return true; |
1908 | 1909 | ||
1909 | } | 1910 | } |
1910 | void CalendarView::watchSavedFile() | 1911 | void CalendarView::watchSavedFile() |
1911 | { | 1912 | { |
1912 | QFileInfo finf ( MainWindow::defaultFileName()); | 1913 | QFileInfo finf ( MainWindow::defaultFileName()); |
1913 | if ( !finf.exists() ) | 1914 | if ( !finf.exists() ) |
1914 | return; | 1915 | return; |
1915 | QDateTime dt = finf.lastModified (); | 1916 | QDateTime dt = finf.lastModified (); |
1916 | if ( dt < loadedFileVersion ) { | 1917 | if ( dt < loadedFileVersion ) { |
1917 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1918 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1918 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1919 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1919 | return; | 1920 | return; |
1920 | } | 1921 | } |
1921 | loadedFileVersion = dt; | 1922 | loadedFileVersion = dt; |
1922 | } | 1923 | } |
1923 | 1924 | ||
1924 | bool CalendarView::checkFileVersion(QString fn) | 1925 | bool CalendarView::checkFileVersion(QString fn) |
1925 | { | 1926 | { |
1926 | QFileInfo finf ( fn ); | 1927 | QFileInfo finf ( fn ); |
1927 | if ( !finf.exists() ) | 1928 | if ( !finf.exists() ) |
1928 | return true; | 1929 | return true; |
1929 | QDateTime dt = finf.lastModified (); | 1930 | QDateTime dt = finf.lastModified (); |
1930 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1931 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1931 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1932 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1932 | if ( dt <= loadedFileVersion ) | 1933 | if ( dt <= loadedFileVersion ) |
1933 | return true; | 1934 | return true; |
1934 | 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)) , | 1935 | 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)) , |
1935 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1936 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1936 | i18n("Sync+save")); | 1937 | i18n("Sync+save")); |
1937 | 1938 | ||
1938 | if ( km == KMessageBox::Cancel ) | 1939 | if ( km == KMessageBox::Cancel ) |
1939 | return false; | 1940 | return false; |
1940 | if ( km == KMessageBox::Yes ) | 1941 | if ( km == KMessageBox::Yes ) |
1941 | return true; | 1942 | return true; |
1942 | 1943 | ||
1943 | setSyncDevice("deleteaftersync" ); | 1944 | setSyncDevice("deleteaftersync" ); |
1944 | mSyncManager->mAskForPreferences = true; | 1945 | mSyncManager->mAskForPreferences = true; |
1945 | mSyncManager->mSyncAlgoPrefs = 3; | 1946 | mSyncManager->mSyncAlgoPrefs = 3; |
1946 | mSyncManager->mWriteBackFile = false; | 1947 | mSyncManager->mWriteBackFile = false; |
1947 | mSyncManager->mWriteBackExistingOnly = false; | 1948 | mSyncManager->mWriteBackExistingOnly = false; |
1948 | mSyncManager->mShowSyncSummary = false; | 1949 | mSyncManager->mShowSyncSummary = false; |
1949 | syncCalendar( fn, 3 ); | 1950 | syncCalendar( fn, 3 ); |
1950 | Event * e = getLastSyncEvent(); | 1951 | Event * e = getLastSyncEvent(); |
1951 | mCalendar->deleteEvent ( e ); | 1952 | if ( e ) |
1953 | deleteEvent ( e ); | ||
1952 | updateView(); | 1954 | updateView(); |
1953 | return true; | 1955 | return true; |
1954 | } | 1956 | } |
1955 | 1957 | ||
1956 | bool CalendarView::saveCalendar( QString filename ) | 1958 | bool CalendarView::saveCalendar( QString filename ) |
1957 | { | 1959 | { |
1958 | 1960 | ||
1959 | // Store back all unsaved data into calendar object | 1961 | // Store back all unsaved data into calendar object |
1960 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1962 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1961 | if ( mViewManager->currentView() ) | 1963 | if ( mViewManager->currentView() ) |
1962 | mViewManager->currentView()->flushView(); | 1964 | mViewManager->currentView()->flushView(); |
1963 | 1965 | ||
1964 | 1966 | ||
1965 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1967 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1966 | mStorage->setSaveFormat( new ICalFormat() ); | 1968 | mStorage->setSaveFormat( new ICalFormat() ); |
1967 | mStorage->setFileName( filename ); | 1969 | mStorage->setFileName( filename ); |
1968 | bool success; | 1970 | bool success; |
1969 | success = mStorage->save(); | 1971 | success = mStorage->save(); |
1970 | if ( !success ) { | 1972 | if ( !success ) { |
1971 | return false; | 1973 | return false; |
1972 | } | 1974 | } |
1973 | if ( filename == MainWindow::defaultFileName() ) { | 1975 | if ( filename == MainWindow::defaultFileName() ) { |
1974 | setLoadedFileVersion( lfv ); | 1976 | setLoadedFileVersion( lfv ); |
1975 | watchSavedFile(); | 1977 | watchSavedFile(); |
1976 | } | 1978 | } |
1977 | return true; | 1979 | return true; |
1978 | } | 1980 | } |
1979 | 1981 | ||
1980 | void CalendarView::closeCalendar() | 1982 | void CalendarView::closeCalendar() |
1981 | { | 1983 | { |
1982 | 1984 | ||
1983 | // child windows no longer valid | 1985 | // child windows no longer valid |
1986 | clearAllViews(); | ||
1984 | emit closingDown(); | 1987 | emit closingDown(); |
1985 | 1988 | ||
1986 | mCalendar->close(); | 1989 | mCalendar->close(); |
1987 | setModified(false); | 1990 | setModified(false); |
1988 | updateView(); | 1991 | updateView(); |
1989 | } | 1992 | } |
1990 | 1993 | ||
1991 | void CalendarView::archiveCalendar() | 1994 | void CalendarView::archiveCalendar() |
1992 | { | 1995 | { |
1993 | mDialogManager->showArchiveDialog(); | 1996 | mDialogManager->showArchiveDialog(); |
1994 | } | 1997 | } |
1995 | 1998 | ||
1996 | 1999 | ||
1997 | void CalendarView::readSettings() | 2000 | void CalendarView::readSettings() |
1998 | { | 2001 | { |
1999 | 2002 | ||
2000 | 2003 | ||
2001 | // mViewManager->showAgendaView(); | 2004 | // mViewManager->showAgendaView(); |
2002 | QString str; | 2005 | QString str; |
2003 | //qDebug("CalendarView::readSettings() "); | 2006 | //qDebug("CalendarView::readSettings() "); |
2004 | // read settings from the KConfig, supplying reasonable | 2007 | // read settings from the KConfig, supplying reasonable |
2005 | // defaults where none are to be found | 2008 | // defaults where none are to be found |
2006 | KConfig *config = KOGlobals::config(); | 2009 | KConfig *config = KOGlobals::config(); |
2007 | #ifndef KORG_NOSPLITTER | 2010 | #ifndef KORG_NOSPLITTER |
2008 | config->setGroup("KOrganizer Geometry"); | 2011 | config->setGroup("KOrganizer Geometry"); |
2009 | 2012 | ||
2010 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2013 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2011 | if (sizes.count() != 2) { | 2014 | if (sizes.count() != 2) { |
2012 | sizes << mDateNavigator->minimumSizeHint().width(); | 2015 | sizes << mDateNavigator->minimumSizeHint().width(); |
2013 | sizes << 300; | 2016 | sizes << 300; |
2014 | } | 2017 | } |
2015 | mPanner->setSizes(sizes); | 2018 | mPanner->setSizes(sizes); |
2016 | 2019 | ||
2017 | sizes = config->readIntListEntry("Separator2"); | 2020 | sizes = config->readIntListEntry("Separator2"); |
2018 | if ( ( mResourceView && sizes.count() == 4 ) || | 2021 | if ( ( mResourceView && sizes.count() == 4 ) || |
2019 | ( !mResourceView && sizes.count() == 3 ) ) { | 2022 | ( !mResourceView && sizes.count() == 3 ) ) { |
2020 | mLeftSplitter->setSizes(sizes); | 2023 | mLeftSplitter->setSizes(sizes); |
2021 | } | 2024 | } |
2022 | #endif | 2025 | #endif |
2023 | globalFlagBlockAgenda = 1; | 2026 | globalFlagBlockAgenda = 1; |
2024 | mViewManager->showAgendaView(); | 2027 | mViewManager->showAgendaView(); |
2025 | //mViewManager->readSettings( config ); | 2028 | //mViewManager->readSettings( config ); |
2026 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2029 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2027 | readFilterSettings(config); | 2030 | readFilterSettings(config); |
2028 | 2031 | ||
2029 | #ifdef DESKTOP_VERSION | 2032 | #ifdef DESKTOP_VERSION |
2030 | config->setGroup("WidgetLayout"); | 2033 | config->setGroup("WidgetLayout"); |
2031 | QStringList list; | 2034 | QStringList list; |
@@ -2387,96 +2390,107 @@ void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | |||
2387 | updateUnmanagedViews(); | 2390 | updateUnmanagedViews(); |
2388 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2391 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2389 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2392 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2390 | mCalendar->checkAlarmForIncidence( 0, true ); | 2393 | mCalendar->checkAlarmForIncidence( 0, true ); |
2391 | if ( mEventViewerDialog ) | 2394 | if ( mEventViewerDialog ) |
2392 | mEventViewerDialog->hide(); | 2395 | mEventViewerDialog->hide(); |
2393 | } | 2396 | } |
2394 | else | 2397 | else |
2395 | mCalendar->checkAlarmForIncidence( which , false ); | 2398 | mCalendar->checkAlarmForIncidence( which , false ); |
2396 | } | 2399 | } |
2397 | 2400 | ||
2398 | // most of the changeEventDisplays() right now just call the view's | 2401 | // most of the changeEventDisplays() right now just call the view's |
2399 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2402 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2400 | void CalendarView::changeEventDisplay(Event *which, int action) | 2403 | void CalendarView::changeEventDisplay(Event *which, int action) |
2401 | { | 2404 | { |
2402 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2405 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2403 | changeIncidenceDisplay((Incidence *)which, action); | 2406 | changeIncidenceDisplay((Incidence *)which, action); |
2404 | mDateNavigator->updateView(); | 2407 | mDateNavigator->updateView(); |
2405 | //mDialogManager->updateSearchDialog(); | 2408 | //mDialogManager->updateSearchDialog(); |
2406 | 2409 | ||
2407 | if (which) { | 2410 | if (which) { |
2408 | // If there is an event view visible update the display | 2411 | // If there is an event view visible update the display |
2409 | mViewManager->currentView()->changeEventDisplay(which,action); | 2412 | mViewManager->currentView()->changeEventDisplay(which,action); |
2410 | // TODO: check, if update needed | 2413 | // TODO: check, if update needed |
2411 | // if (which->getTodoStatus()) { | 2414 | // if (which->getTodoStatus()) { |
2412 | mTodoList->updateView(); | 2415 | mTodoList->updateView(); |
2413 | // } | 2416 | // } |
2414 | } else { | 2417 | } else { |
2415 | mViewManager->currentView()->updateView(); | 2418 | mViewManager->currentView()->updateView(); |
2416 | } | 2419 | } |
2417 | } | 2420 | } |
2418 | 2421 | ||
2419 | 2422 | ||
2420 | void CalendarView::updateTodoViews() | 2423 | void CalendarView::updateTodoViews() |
2421 | { | 2424 | { |
2422 | mTodoList->updateView(); | 2425 | mTodoList->updateView(); |
2423 | mViewManager->currentView()->updateView(); | 2426 | mViewManager->currentView()->updateView(); |
2424 | 2427 | ||
2425 | } | 2428 | } |
2426 | 2429 | ||
2427 | 2430 | ||
2428 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2431 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2429 | { | 2432 | { |
2430 | mTodoList->updateView(); | 2433 | mTodoList->updateView(); |
2431 | mViewManager->updateView(start, end); | 2434 | mViewManager->updateView(start, end); |
2432 | //mDateNavigator->updateView(); | 2435 | //mDateNavigator->updateView(); |
2433 | } | 2436 | } |
2434 | 2437 | ||
2438 | void CalendarView::clearAllViews() | ||
2439 | { | ||
2440 | mTodoList->clearList(); | ||
2441 | mViewManager->clearAllViews(); | ||
2442 | SearchDialog * sd = mDialogManager->getSearchDialog(); | ||
2443 | if ( sd ) { | ||
2444 | KOListView* kol = sd->listview(); | ||
2445 | if ( kol ) | ||
2446 | kol->clearList(); | ||
2447 | } | ||
2448 | } | ||
2435 | void CalendarView::updateView() | 2449 | void CalendarView::updateView() |
2436 | { | 2450 | { |
2437 | DateList tmpList = mNavigator->selectedDates(); | 2451 | DateList tmpList = mNavigator->selectedDates(); |
2438 | 2452 | ||
2439 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2453 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2440 | mTodoList->updateView(); | 2454 | mTodoList->updateView(); |
2441 | // We assume that the navigator only selects consecutive days. | 2455 | // We assume that the navigator only selects consecutive days. |
2442 | updateView( tmpList.first(), tmpList.last() ); | 2456 | updateView( tmpList.first(), tmpList.last() ); |
2443 | } | 2457 | } |
2444 | 2458 | ||
2445 | void CalendarView::updateUnmanagedViews() | 2459 | void CalendarView::updateUnmanagedViews() |
2446 | { | 2460 | { |
2447 | mDateNavigator->updateDayMatrix(); | 2461 | mDateNavigator->updateDayMatrix(); |
2448 | } | 2462 | } |
2449 | 2463 | ||
2450 | int CalendarView::msgItemDelete(const QString name) | 2464 | int CalendarView::msgItemDelete(const QString name) |
2451 | { | 2465 | { |
2452 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2466 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2453 | i18n("This item will be\npermanently deleted."), | 2467 | i18n("This item will be\npermanently deleted."), |
2454 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2468 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2455 | } | 2469 | } |
2456 | 2470 | ||
2457 | 2471 | ||
2458 | void CalendarView::edit_cut() | 2472 | void CalendarView::edit_cut() |
2459 | { | 2473 | { |
2460 | Event *anEvent=0; | 2474 | Event *anEvent=0; |
2461 | 2475 | ||
2462 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2476 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2463 | 2477 | ||
2464 | if (mViewManager->currentView()->isEventView()) { | 2478 | if (mViewManager->currentView()->isEventView()) { |
2465 | if ( incidence && incidence->type() == "Event" ) { | 2479 | if ( incidence && incidence->type() == "Event" ) { |
2466 | anEvent = static_cast<Event *>(incidence); | 2480 | anEvent = static_cast<Event *>(incidence); |
2467 | } | 2481 | } |
2468 | } | 2482 | } |
2469 | 2483 | ||
2470 | if (!anEvent) { | 2484 | if (!anEvent) { |
2471 | KNotifyClient::beep(); | 2485 | KNotifyClient::beep(); |
2472 | return; | 2486 | return; |
2473 | } | 2487 | } |
2474 | DndFactory factory( mCalendar ); | 2488 | DndFactory factory( mCalendar ); |
2475 | factory.cutIncidence(anEvent); | 2489 | factory.cutIncidence(anEvent); |
2476 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2490 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2477 | } | 2491 | } |
2478 | 2492 | ||
2479 | void CalendarView::edit_copy() | 2493 | void CalendarView::edit_copy() |
2480 | { | 2494 | { |
2481 | Event *anEvent=0; | 2495 | Event *anEvent=0; |
2482 | 2496 | ||
@@ -3898,96 +3912,97 @@ void CalendarView::toggleFilerEnabled( ) | |||
3898 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3912 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3899 | if ( !mFilterView->filtersEnabled() ) | 3913 | if ( !mFilterView->filtersEnabled() ) |
3900 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3914 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3901 | 3915 | ||
3902 | } | 3916 | } |
3903 | void CalendarView::updateFilter() | 3917 | void CalendarView::updateFilter() |
3904 | { | 3918 | { |
3905 | CalFilter *filter = mFilterView->selectedFilter(); | 3919 | CalFilter *filter = mFilterView->selectedFilter(); |
3906 | if (filter) { | 3920 | if (filter) { |
3907 | QString mess; | 3921 | QString mess; |
3908 | if (mFilterView->filtersEnabled()) { | 3922 | if (mFilterView->filtersEnabled()) { |
3909 | mess = i18n("Filter selected: ")+filter->name(); | 3923 | mess = i18n("Filter selected: ")+filter->name(); |
3910 | filter->setEnabled(true); | 3924 | filter->setEnabled(true); |
3911 | } | 3925 | } |
3912 | else filter->setEnabled(false); | 3926 | else filter->setEnabled(false); |
3913 | mCalendar->setFilter(filter); | 3927 | mCalendar->setFilter(filter); |
3914 | updateView(); | 3928 | updateView(); |
3915 | if ( !mess.isEmpty() ) | 3929 | if ( !mess.isEmpty() ) |
3916 | topLevelWidget()->setCaption( mess ); | 3930 | topLevelWidget()->setCaption( mess ); |
3917 | 3931 | ||
3918 | } | 3932 | } |
3919 | } | 3933 | } |
3920 | 3934 | ||
3921 | void CalendarView::filterEdited() | 3935 | void CalendarView::filterEdited() |
3922 | { | 3936 | { |
3923 | mFilterView->updateFilters(); | 3937 | mFilterView->updateFilters(); |
3924 | updateFilter(); | 3938 | updateFilter(); |
3925 | writeSettings(); | 3939 | writeSettings(); |
3926 | } | 3940 | } |
3927 | 3941 | ||
3928 | 3942 | ||
3929 | void CalendarView::takeOverEvent() | 3943 | void CalendarView::takeOverEvent() |
3930 | { | 3944 | { |
3931 | Incidence *incidence = currentSelection(); | 3945 | Incidence *incidence = currentSelection(); |
3932 | 3946 | ||
3933 | if (!incidence) return; | 3947 | if (!incidence) return; |
3934 | 3948 | ||
3935 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3949 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3936 | incidence->recreate(); | 3950 | incidence->recreate(); |
3937 | incidence->setReadOnly(false); | 3951 | incidence->setReadOnly(false); |
3938 | 3952 | ||
3939 | updateView(); | 3953 | updateView(); |
3940 | } | 3954 | } |
3941 | 3955 | ||
3942 | void CalendarView::takeOverCalendar() | 3956 | void CalendarView::takeOverCalendar() |
3943 | { | 3957 | { |
3944 | // TODO: Create Calendar::allIncidences() function and use it here | 3958 | // TODO: Create Calendar::allIncidences() function and use it here |
3945 | 3959 | ||
3960 | clearAllViews(); | ||
3946 | QPtrList<Event> events = mCalendar->events(); | 3961 | QPtrList<Event> events = mCalendar->events(); |
3947 | for(uint i=0; i<events.count(); ++i) { | 3962 | for(uint i=0; i<events.count(); ++i) { |
3948 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3963 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3949 | events.at(i)->recreate(); | 3964 | events.at(i)->recreate(); |
3950 | events.at(i)->setReadOnly(false); | 3965 | events.at(i)->setReadOnly(false); |
3951 | } | 3966 | } |
3952 | 3967 | ||
3953 | QPtrList<Todo> todos = mCalendar->todos(); | 3968 | QPtrList<Todo> todos = mCalendar->todos(); |
3954 | for(uint i=0; i<todos.count(); ++i) { | 3969 | for(uint i=0; i<todos.count(); ++i) { |
3955 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3970 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3956 | todos.at(i)->recreate(); | 3971 | todos.at(i)->recreate(); |
3957 | todos.at(i)->setReadOnly(false); | 3972 | todos.at(i)->setReadOnly(false); |
3958 | } | 3973 | } |
3959 | 3974 | ||
3960 | QPtrList<Journal> journals = mCalendar->journals(); | 3975 | QPtrList<Journal> journals = mCalendar->journals(); |
3961 | for(uint i=0; i<journals.count(); ++i) { | 3976 | for(uint i=0; i<journals.count(); ++i) { |
3962 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3977 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3963 | journals.at(i)->recreate(); | 3978 | journals.at(i)->recreate(); |
3964 | journals.at(i)->setReadOnly(false); | 3979 | journals.at(i)->setReadOnly(false); |
3965 | } | 3980 | } |
3966 | 3981 | ||
3967 | updateView(); | 3982 | updateView(); |
3968 | } | 3983 | } |
3969 | 3984 | ||
3970 | void CalendarView::showIntro() | 3985 | void CalendarView::showIntro() |
3971 | { | 3986 | { |
3972 | kdDebug() << "To be implemented." << endl; | 3987 | kdDebug() << "To be implemented." << endl; |
3973 | } | 3988 | } |
3974 | 3989 | ||
3975 | QWidgetStack *CalendarView::viewStack() | 3990 | QWidgetStack *CalendarView::viewStack() |
3976 | { | 3991 | { |
3977 | return mRightFrame; | 3992 | return mRightFrame; |
3978 | } | 3993 | } |
3979 | 3994 | ||
3980 | QWidget *CalendarView::leftFrame() | 3995 | QWidget *CalendarView::leftFrame() |
3981 | { | 3996 | { |
3982 | return ( QWidget *)mLeftFrame; | 3997 | return ( QWidget *)mLeftFrame; |
3983 | } | 3998 | } |
3984 | 3999 | ||
3985 | DateNavigator *CalendarView::dateNavigator() | 4000 | DateNavigator *CalendarView::dateNavigator() |
3986 | { | 4001 | { |
3987 | return mNavigator; | 4002 | return mNavigator; |
3988 | } | 4003 | } |
3989 | 4004 | ||
3990 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4005 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3991 | { | 4006 | { |
3992 | return mDateNavigator->navigatorView(); | 4007 | return mDateNavigator->navigatorView(); |
3993 | } | 4008 | } |