summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-05-25 09:43:34 (UTC)
committer zautrix <zautrix>2005-05-25 09:43:34 (UTC)
commitce9b826d7c0d9249751f8fb7b791c3757aff3c39 (patch) (unidiff)
tree719bc7dea987d15c1ee38de58c5b2902c8e0a5ab
parent75c935404e0a803b7d39dd0cf4d83d4d6cd07da2 (diff)
downloadkdepimpi-ce9b826d7c0d9249751f8fb7b791c3757aff3c39.zip
kdepimpi-ce9b826d7c0d9249751f8fb7b791c3757aff3c39.tar.gz
kdepimpi-ce9b826d7c0d9249751f8fb7b791c3757aff3c39.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index a8ad467..503ef12 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,104 +1,104 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
@@ -1566,194 +1566,195 @@ bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a
1566 ev->setFloats( true ); 1566 ev->setFloats( true );
1567 Recurrence * rec = ev->recurrence(); 1567 Recurrence * rec = ev->recurrence();
1568 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1568 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1569 rec->addYearlyNum( date.month() ); 1569 rec->addYearlyNum( date.month() );
1570 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1570 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1571 delete ev; 1571 delete ev;
1572 return false; 1572 return false;
1573 } 1573 }
1574 return true; 1574 return true;
1575 1575
1576} 1576}
1577bool CalendarView::importQtopia( const QString &categories, 1577bool CalendarView::importQtopia( const QString &categories,
1578 const QString &datebook, 1578 const QString &datebook,
1579 const QString &todolist ) 1579 const QString &todolist )
1580{ 1580{
1581 1581
1582 QtopiaFormat qtopiaFormat; 1582 QtopiaFormat qtopiaFormat;
1583 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1583 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1584 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1584 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1585 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1585 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1586 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1586 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1587 1587
1588 updateView(); 1588 updateView();
1589 return true; 1589 return true;
1590 1590
1591#if 0 1591#if 0
1592 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1592 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1593 mCurrentSyncDevice = "qtopia-XML"; 1593 mCurrentSyncDevice = "qtopia-XML";
1594 if ( mSyncManager->mAskForPreferences ) 1594 if ( mSyncManager->mAskForPreferences )
1595 edit_sync_options(); 1595 edit_sync_options();
1596 qApp->processEvents(); 1596 qApp->processEvents();
1597 CalendarLocal* calendar = new CalendarLocal(); 1597 CalendarLocal* calendar = new CalendarLocal();
1598 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1598 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1599 bool syncOK = false; 1599 bool syncOK = false;
1600 QtopiaFormat qtopiaFormat; 1600 QtopiaFormat qtopiaFormat;
1601 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1601 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1602 bool loadOk = true; 1602 bool loadOk = true;
1603 if ( !categories.isEmpty() ) 1603 if ( !categories.isEmpty() )
1604 loadOk = qtopiaFormat.load( calendar, categories ); 1604 loadOk = qtopiaFormat.load( calendar, categories );
1605 if ( loadOk && !datebook.isEmpty() ) 1605 if ( loadOk && !datebook.isEmpty() )
1606 loadOk = qtopiaFormat.load( calendar, datebook ); 1606 loadOk = qtopiaFormat.load( calendar, datebook );
1607 if ( loadOk && !todolist.isEmpty() ) 1607 if ( loadOk && !todolist.isEmpty() )
1608 loadOk = qtopiaFormat.load( calendar, todolist ); 1608 loadOk = qtopiaFormat.load( calendar, todolist );
1609 1609
1610 if ( loadOk ) { 1610 if ( loadOk ) {
1611 getEventViewerDialog()->setSyncMode( true ); 1611 getEventViewerDialog()->setSyncMode( true );
1612 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1612 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1613 getEventViewerDialog()->setSyncMode( false ); 1613 getEventViewerDialog()->setSyncMode( false );
1614 qApp->processEvents(); 1614 qApp->processEvents();
1615 if ( syncOK ) { 1615 if ( syncOK ) {
1616 if ( mSyncManager->mWriteBackFile ) 1616 if ( mSyncManager->mWriteBackFile )
1617 { 1617 {
1618 // write back XML file 1618 // write back XML file
1619 1619
1620 } 1620 }
1621 setModified( true ); 1621 setModified( true );
1622 } 1622 }
1623 } else { 1623 } else {
1624 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1624 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1625 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1625 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1626 question, i18n("Ok")) ; 1626 question, i18n("Ok")) ;
1627 } 1627 }
1628 delete calendar; 1628 delete calendar;
1629 updateView(); 1629 updateView();
1630 return syncOK; 1630 return syncOK;
1631 1631
1632 1632
1633#endif 1633#endif
1634 1634
1635} 1635}
1636 1636
1637void CalendarView::setSyncEventsReadOnly() 1637void CalendarView::setSyncEventsReadOnly()
1638{ 1638{
1639 Event * ev; 1639 Event * ev;
1640 QPtrList<Event> eL = mCalendar->rawEvents(); 1640 QPtrList<Event> eL = mCalendar->rawEvents();
1641 ev = eL.first(); 1641 ev = eL.first();
1642 while ( ev ) { 1642 while ( ev ) {
1643 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1643 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1644 ev->setReadOnly( true ); 1644 ev->setReadOnly( true );
1645 ev = eL.next(); 1645 ev = eL.next();
1646 } 1646 }
1647} 1647}
1648bool CalendarView::openCalendar(QString filename, bool merge) 1648bool CalendarView::openCalendar(QString filename, bool merge)
1649{ 1649{
1650 1650
1651 if (filename.isEmpty()) { 1651 if (filename.isEmpty()) {
1652 return false; 1652 return false;
1653 } 1653 }
1654 1654
1655 if (!QFile::exists(filename)) { 1655 if (!QFile::exists(filename)) {
1656 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1656 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1657 return false; 1657 return false;
1658 } 1658 }
1659 1659
1660 globalFlagBlockAgenda = 1; 1660 globalFlagBlockAgenda = 1;
1661 if (!merge) { 1661 if (!merge) {
1662 mCalendar->close();
1663 mTodoList->clearList(); 1662 mTodoList->clearList();
1663 mViewManager->setDocumentId( filename );
1664 mCalendar->close();
1664 } 1665 }
1665 mStorage->setFileName( filename ); 1666 mStorage->setFileName( filename );
1666 1667
1667 if ( mStorage->load() ) { 1668 if ( mStorage->load() ) {
1668 if ( merge ) ;//setModified( true ); 1669 if ( merge ) ;//setModified( true );
1669 else { 1670 else {
1670 //setModified( true ); 1671 //setModified( true );
1671 mViewManager->setDocumentId( filename ); 1672 mViewManager->setDocumentId( filename );
1672 mDialogManager->setDocumentId( filename ); 1673 mDialogManager->setDocumentId( filename );
1673 mTodoList->setDocumentId( filename ); 1674 mTodoList->setDocumentId( filename );
1674 } 1675 }
1675 globalFlagBlockAgenda = 2; 1676 globalFlagBlockAgenda = 2;
1676 // if ( getLastSyncEvent() ) 1677 // if ( getLastSyncEvent() )
1677 // getLastSyncEvent()->setReadOnly( true ); 1678 // getLastSyncEvent()->setReadOnly( true );
1678 mCalendar->reInitAlarmSettings(); 1679 mCalendar->reInitAlarmSettings();
1679 setSyncEventsReadOnly(); 1680 setSyncEventsReadOnly();
1680 updateUnmanagedViews(); 1681 updateUnmanagedViews();
1681 updateView(); 1682 updateView();
1682 if ( filename != MainWindow::defaultFileName() ) { 1683 if ( filename != MainWindow::defaultFileName() ) {
1683 saveCalendar( MainWindow::defaultFileName() ); 1684 saveCalendar( MainWindow::defaultFileName() );
1684 } else { 1685 } else {
1685 QFileInfo finf ( MainWindow::defaultFileName()); 1686 QFileInfo finf ( MainWindow::defaultFileName());
1686 if ( finf.exists() ) { 1687 if ( finf.exists() ) {
1687 setLoadedFileVersion( finf.lastModified () ); 1688 setLoadedFileVersion( finf.lastModified () );
1688 } 1689 }
1689 } 1690 }
1690 return true; 1691 return true;
1691 } else { 1692 } else {
1692 // while failing to load, the calendar object could 1693 // while failing to load, the calendar object could
1693 // have become partially populated. Clear it out. 1694 // have become partially populated. Clear it out.
1694 if ( !merge ) { 1695 if ( !merge ) {
1695 mCalendar->close(); 1696 mCalendar->close();
1696 mViewManager->setDocumentId( filename ); 1697 mViewManager->setDocumentId( filename );
1697 mDialogManager->setDocumentId( filename ); 1698 mDialogManager->setDocumentId( filename );
1698 mTodoList->setDocumentId( filename ); 1699 mTodoList->setDocumentId( filename );
1699 } 1700 }
1700 1701
1701 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1702 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1702 1703
1703 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1704 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1704 globalFlagBlockAgenda = 2; 1705 globalFlagBlockAgenda = 2;
1705 mCalendar->reInitAlarmSettings(); 1706 mCalendar->reInitAlarmSettings();
1706 setSyncEventsReadOnly(); 1707 setSyncEventsReadOnly();
1707 updateUnmanagedViews(); 1708 updateUnmanagedViews();
1708 updateView(); 1709 updateView();
1709 } 1710 }
1710 return false; 1711 return false;
1711} 1712}
1712void CalendarView::showOpenError() 1713void CalendarView::showOpenError()
1713{ 1714{
1714 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1715 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1715} 1716}
1716void CalendarView::setLoadedFileVersion(QDateTime dt) 1717void CalendarView::setLoadedFileVersion(QDateTime dt)
1717{ 1718{
1718 loadedFileVersion = dt; 1719 loadedFileVersion = dt;
1719} 1720}
1720bool CalendarView::checkFileChanged(QString fn) 1721bool CalendarView::checkFileChanged(QString fn)
1721{ 1722{
1722 QFileInfo finf ( fn ); 1723 QFileInfo finf ( fn );
1723 if ( !finf.exists() ) 1724 if ( !finf.exists() )
1724 return true; 1725 return true;
1725 QDateTime dt = finf.lastModified (); 1726 QDateTime dt = finf.lastModified ();
1726 if ( dt <= loadedFileVersion ) 1727 if ( dt <= loadedFileVersion )
1727 return false; 1728 return false;
1728 return true; 1729 return true;
1729 1730
1730} 1731}
1731void CalendarView::watchSavedFile() 1732void CalendarView::watchSavedFile()
1732{ 1733{
1733 QFileInfo finf ( MainWindow::defaultFileName()); 1734 QFileInfo finf ( MainWindow::defaultFileName());
1734 if ( !finf.exists() ) 1735 if ( !finf.exists() )
1735 return; 1736 return;
1736 QDateTime dt = finf.lastModified (); 1737 QDateTime dt = finf.lastModified ();
1737 if ( dt < loadedFileVersion ) { 1738 if ( dt < loadedFileVersion ) {
1738 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1739 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1739 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1740 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1740 return; 1741 return;
1741 } 1742 }
1742 loadedFileVersion = dt; 1743 loadedFileVersion = dt;
1743} 1744}
1744 1745
1745bool CalendarView::checkFileVersion(QString fn) 1746bool CalendarView::checkFileVersion(QString fn)
1746{ 1747{
1747 QFileInfo finf ( fn ); 1748 QFileInfo finf ( fn );
1748 if ( !finf.exists() ) 1749 if ( !finf.exists() )
1749 return true; 1750 return true;
1750 QDateTime dt = finf.lastModified (); 1751 QDateTime dt = finf.lastModified ();
1751 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1752 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1752 //qDebug("file on disk version %s",dt.toString().latin1()); 1753 //qDebug("file on disk version %s",dt.toString().latin1());
1753 if ( dt <= loadedFileVersion ) 1754 if ( dt <= loadedFileVersion )
1754 return true; 1755 return true;
1755 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)) , 1756 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)) ,
1756 i18n("KO/Pi Warning"),i18n("Overwrite"), 1757 i18n("KO/Pi Warning"),i18n("Overwrite"),
1757 i18n("Sync+save")); 1758 i18n("Sync+save"));
1758 1759
1759 if ( km == KMessageBox::Cancel ) 1760 if ( km == KMessageBox::Cancel )