summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp3
3 files changed, 18 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3635cfa..eaea040 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1421,234 +1421,247 @@ bool CalendarView::importQtopia( const QString &categories,
1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1424 1424
1425 updateView(); 1425 updateView();
1426 return true; 1426 return true;
1427 1427
1428#if 0 1428#if 0
1429 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1429 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1430 mCurrentSyncDevice = "qtopia-XML"; 1430 mCurrentSyncDevice = "qtopia-XML";
1431 if ( KOPrefs::instance()->mAskForPreferences ) 1431 if ( KOPrefs::instance()->mAskForPreferences )
1432 edit_sync_options(); 1432 edit_sync_options();
1433 qApp->processEvents(); 1433 qApp->processEvents();
1434 CalendarLocal* calendar = new CalendarLocal(); 1434 CalendarLocal* calendar = new CalendarLocal();
1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1436 bool syncOK = false; 1436 bool syncOK = false;
1437 QtopiaFormat qtopiaFormat; 1437 QtopiaFormat qtopiaFormat;
1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1439 bool loadOk = true; 1439 bool loadOk = true;
1440 if ( !categories.isEmpty() ) 1440 if ( !categories.isEmpty() )
1441 loadOk = qtopiaFormat.load( calendar, categories ); 1441 loadOk = qtopiaFormat.load( calendar, categories );
1442 if ( loadOk && !datebook.isEmpty() ) 1442 if ( loadOk && !datebook.isEmpty() )
1443 loadOk = qtopiaFormat.load( calendar, datebook ); 1443 loadOk = qtopiaFormat.load( calendar, datebook );
1444 if ( loadOk && !todolist.isEmpty() ) 1444 if ( loadOk && !todolist.isEmpty() )
1445 loadOk = qtopiaFormat.load( calendar, todolist ); 1445 loadOk = qtopiaFormat.load( calendar, todolist );
1446 1446
1447 if ( loadOk ) { 1447 if ( loadOk ) {
1448 getEventViewerDialog()->setSyncMode( true ); 1448 getEventViewerDialog()->setSyncMode( true );
1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1450 getEventViewerDialog()->setSyncMode( false ); 1450 getEventViewerDialog()->setSyncMode( false );
1451 qApp->processEvents(); 1451 qApp->processEvents();
1452 if ( syncOK ) { 1452 if ( syncOK ) {
1453 if ( KOPrefs::instance()->mWriteBackFile ) 1453 if ( KOPrefs::instance()->mWriteBackFile )
1454 { 1454 {
1455 // write back XML file 1455 // write back XML file
1456 1456
1457 } 1457 }
1458 setModified( true ); 1458 setModified( true );
1459 } 1459 }
1460 } else { 1460 } else {
1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1463 question, i18n("Ok")) ; 1463 question, i18n("Ok")) ;
1464 } 1464 }
1465 delete calendar; 1465 delete calendar;
1466 updateView(); 1466 updateView();
1467 return syncOK; 1467 return syncOK;
1468 1468
1469 1469
1470#endif 1470#endif
1471 1471
1472} 1472}
1473 1473
1474void CalendarView::setSyncEventsReadOnly() 1474void CalendarView::setSyncEventsReadOnly()
1475{ 1475{
1476 Event * ev; 1476 Event * ev;
1477 QPtrList<Event> eL = mCalendar->rawEvents(); 1477 QPtrList<Event> eL = mCalendar->rawEvents();
1478 ev = eL.first(); 1478 ev = eL.first();
1479 while ( ev ) { 1479 while ( ev ) {
1480 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1480 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1481 ev->setReadOnly( true ); 1481 ev->setReadOnly( true );
1482 ev = eL.next(); 1482 ev = eL.next();
1483 } 1483 }
1484} 1484}
1485bool CalendarView::openCalendar(QString filename, bool merge) 1485bool CalendarView::openCalendar(QString filename, bool merge)
1486{ 1486{
1487 1487
1488 if (filename.isEmpty()) { 1488 if (filename.isEmpty()) {
1489 return false; 1489 return false;
1490 } 1490 }
1491 1491
1492 if (!QFile::exists(filename)) { 1492 if (!QFile::exists(filename)) {
1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1494 return false; 1494 return false;
1495 } 1495 }
1496 1496
1497 globalFlagBlockAgenda = 1; 1497 globalFlagBlockAgenda = 1;
1498 if (!merge) mCalendar->close(); 1498 if (!merge) mCalendar->close();
1499 1499
1500 mStorage->setFileName( filename ); 1500 mStorage->setFileName( filename );
1501 1501
1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1503 if ( merge ) ;//setModified( true ); 1503 if ( merge ) ;//setModified( true );
1504 else { 1504 else {
1505 //setModified( true ); 1505 //setModified( true );
1506 mViewManager->setDocumentId( filename ); 1506 mViewManager->setDocumentId( filename );
1507 mDialogManager->setDocumentId( filename ); 1507 mDialogManager->setDocumentId( filename );
1508 mTodoList->setDocumentId( filename ); 1508 mTodoList->setDocumentId( filename );
1509 } 1509 }
1510 globalFlagBlockAgenda = 2; 1510 globalFlagBlockAgenda = 2;
1511 // if ( getLastSyncEvent() ) 1511 // if ( getLastSyncEvent() )
1512 // getLastSyncEvent()->setReadOnly( true ); 1512 // getLastSyncEvent()->setReadOnly( true );
1513 mCalendar->reInitAlarmSettings(); 1513 mCalendar->reInitAlarmSettings();
1514 setSyncEventsReadOnly(); 1514 setSyncEventsReadOnly();
1515 updateUnmanagedViews(); 1515 updateUnmanagedViews();
1516 updateView(); 1516 updateView();
1517 if ( filename != MainWindow::defaultFileName() ) 1517 if ( filename != MainWindow::defaultFileName() )
1518 saveCalendar( MainWindow::defaultFileName() ); 1518 saveCalendar( MainWindow::defaultFileName() );
1519 loadedFileVersion = QDateTime::currentDateTime(); 1519 loadedFileVersion = QDateTime::currentDateTime();
1520 return true; 1520 return true;
1521 } else { 1521 } else {
1522 // while failing to load, the calendar object could 1522 // while failing to load, the calendar object could
1523 // have become partially populated. Clear it out. 1523 // have become partially populated. Clear it out.
1524 if ( !merge ) mCalendar->close(); 1524 if ( !merge ) mCalendar->close();
1525 1525
1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1527 1527
1528 globalFlagBlockAgenda = 2; 1528 globalFlagBlockAgenda = 2;
1529 updateView(); 1529 updateView();
1530 } 1530 }
1531 return false; 1531 return false;
1532} 1532}
1533void CalendarView::setLoadedFileVersion(QDateTime dt) 1533void CalendarView::setLoadedFileVersion(QDateTime dt)
1534{ 1534{
1535 loadedFileVersion = dt; 1535 loadedFileVersion = dt;
1536} 1536}
1537bool CalendarView::checkFileChanged(QString fn) 1537bool CalendarView::checkFileChanged(QString fn)
1538{ 1538{
1539 QFileInfo finf ( fn ); 1539 QFileInfo finf ( fn );
1540 if ( !finf.exists() ) 1540 if ( !finf.exists() )
1541 return true; 1541 return true;
1542 QDateTime dt = finf.lastModified (); 1542 QDateTime dt = finf.lastModified ();
1543 if ( dt <= loadedFileVersion ) 1543 if ( dt <= loadedFileVersion )
1544 return false; 1544 return false;
1545 return true; 1545 return true;
1546 1546
1547} 1547}
1548void CalendarView::watchSavedFile()
1549{
1550 QFileInfo finf ( MainWindow::defaultFileName());
1551 if ( !finf.exists() )
1552 return;
1553 QDateTime dt = finf.lastModified ();
1554 if ( dt < loadedFileVersion ) {
1555 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1556 return;
1557 }
1558 loadedFileVersion = dt;
1559}
1560
1548bool CalendarView::checkFileVersion(QString fn) 1561bool CalendarView::checkFileVersion(QString fn)
1549{ 1562{
1550 QFileInfo finf ( fn ); 1563 QFileInfo finf ( fn );
1551 if ( !finf.exists() ) 1564 if ( !finf.exists() )
1552 return true; 1565 return true;
1553 QDateTime dt = finf.lastModified (); 1566 QDateTime dt = finf.lastModified ();
1554 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1567 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1555 //qDebug("file on disk version %s",dt.toString().latin1()); 1568 //qDebug("file on disk version %s",dt.toString().latin1());
1556 if ( dt <= loadedFileVersion ) 1569 if ( dt <= loadedFileVersion )
1557 return true; 1570 return true;
1558 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, false)) , 1571 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)) ,
1559 i18n("KO/Pi Warning"),i18n("Overwrite"), 1572 i18n("KO/Pi Warning"),i18n("Overwrite"),
1560 i18n("Sync+save")); 1573 i18n("Sync+save"));
1561 1574
1562 if ( km == KMessageBox::Cancel ) 1575 if ( km == KMessageBox::Cancel )
1563 return false; 1576 return false;
1564 if ( km == KMessageBox::Yes ) 1577 if ( km == KMessageBox::Yes )
1565 return true; 1578 return true;
1566 1579
1567 setSyncDevice("deleteaftersync" ); 1580 setSyncDevice("deleteaftersync" );
1568 KOPrefs::instance()->mAskForPreferences = true; 1581 KOPrefs::instance()->mAskForPreferences = true;
1569 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1582 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1570 KOPrefs::instance()->mWriteBackFile = false; 1583 KOPrefs::instance()->mWriteBackFile = false;
1571 KOPrefs::instance()->mWriteBackExistingOnly = false; 1584 KOPrefs::instance()->mWriteBackExistingOnly = false;
1572 KOPrefs::instance()->mShowSyncSummary = false; 1585 KOPrefs::instance()->mShowSyncSummary = false;
1573 syncCalendar( fn, 3 ); 1586 syncCalendar( fn, 3 );
1574 Event * e = getLastSyncEvent(); 1587 Event * e = getLastSyncEvent();
1575 mCalendar->deleteEvent ( e ); 1588 mCalendar->deleteEvent ( e );
1576 updateView(); 1589 updateView();
1577 return true; 1590 return true;
1578} 1591}
1579 1592
1580bool CalendarView::saveCalendar( QString filename ) 1593bool CalendarView::saveCalendar( QString filename )
1581{ 1594{
1582 1595
1583 // Store back all unsaved data into calendar object 1596 // Store back all unsaved data into calendar object
1584 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1597 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1585 if ( mViewManager->currentView() ) 1598 if ( mViewManager->currentView() )
1586 mViewManager->currentView()->flushView(); 1599 mViewManager->currentView()->flushView();
1587 1600
1588 //mStorage->setFileName( filename ); 1601 //mStorage->setFileName( filename );
1589 1602
1590 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1603 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1591 mStorage->setFileName( filename ); 1604 mStorage->setFileName( filename );
1592 bool success; 1605 bool success;
1593 success = mStorage->save(); 1606 success = mStorage->save();
1594 if ( !success ) { 1607 if ( !success ) {
1595 return false; 1608 return false;
1596 } 1609 }
1597 1610
1598 return true; 1611 return true;
1599} 1612}
1600 1613
1601void CalendarView::closeCalendar() 1614void CalendarView::closeCalendar()
1602{ 1615{
1603 1616
1604 // child windows no longer valid 1617 // child windows no longer valid
1605 emit closingDown(); 1618 emit closingDown();
1606 1619
1607 mCalendar->close(); 1620 mCalendar->close();
1608 setModified(false); 1621 setModified(false);
1609 updateView(); 1622 updateView();
1610} 1623}
1611 1624
1612void CalendarView::archiveCalendar() 1625void CalendarView::archiveCalendar()
1613{ 1626{
1614 mDialogManager->showArchiveDialog(); 1627 mDialogManager->showArchiveDialog();
1615} 1628}
1616 1629
1617 1630
1618void CalendarView::readSettings() 1631void CalendarView::readSettings()
1619{ 1632{
1620 1633
1621 1634
1622 // mViewManager->showAgendaView(); 1635 // mViewManager->showAgendaView();
1623 QString str; 1636 QString str;
1624 //qDebug("CalendarView::readSettings() "); 1637 //qDebug("CalendarView::readSettings() ");
1625 // read settings from the KConfig, supplying reasonable 1638 // read settings from the KConfig, supplying reasonable
1626 // defaults where none are to be found 1639 // defaults where none are to be found
1627 KConfig *config = KOGlobals::config(); 1640 KConfig *config = KOGlobals::config();
1628#ifndef KORG_NOSPLITTER 1641#ifndef KORG_NOSPLITTER
1629 config->setGroup("KOrganizer Geometry"); 1642 config->setGroup("KOrganizer Geometry");
1630 1643
1631 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1644 QValueList<int> sizes = config->readIntListEntry("Separator1");
1632 if (sizes.count() != 2) { 1645 if (sizes.count() != 2) {
1633 sizes << mDateNavigator->minimumSizeHint().width(); 1646 sizes << mDateNavigator->minimumSizeHint().width();
1634 sizes << 300; 1647 sizes << 300;
1635 } 1648 }
1636 mPanner->setSizes(sizes); 1649 mPanner->setSizes(sizes);
1637 1650
1638 sizes = config->readIntListEntry("Separator2"); 1651 sizes = config->readIntListEntry("Separator2");
1639 if ( ( mResourceView && sizes.count() == 4 ) || 1652 if ( ( mResourceView && sizes.count() == 4 ) ||
1640 ( !mResourceView && sizes.count() == 3 ) ) { 1653 ( !mResourceView && sizes.count() == 3 ) ) {
1641 mLeftSplitter->setSizes(sizes); 1654 mLeftSplitter->setSizes(sizes);
1642 } 1655 }
1643#endif 1656#endif
1644 globalFlagBlockAgenda = 1; 1657 globalFlagBlockAgenda = 1;
1645 mViewManager->showAgendaView(); 1658 mViewManager->showAgendaView();
1646 //mViewManager->readSettings( config ); 1659 //mViewManager->readSettings( config );
1647 mTodoList->restoreLayout(config,QString("Todo Layout")); 1660 mTodoList->restoreLayout(config,QString("Todo Layout"));
1648 readFilterSettings(config); 1661 readFilterSettings(config);
1649 config->setGroup( "Views" ); 1662 config->setGroup( "Views" );
1650 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1663 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1651 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1664 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1652 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1665 else if ( dateCount == 7 ) mNavigator->selectWeek();
1653 else mNavigator->selectDates( dateCount ); 1666 else mNavigator->selectDates( dateCount );
1654 // mViewManager->readSettings( config ); 1667 // mViewManager->readSettings( config );
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index a3315ad..355bb84 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -79,192 +79,193 @@ using namespace KCal;
79*/ 79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer 80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83 public: 83 public:
84 /** 84 /**
85 Constructs a new calendar view widget. 85 Constructs a new calendar view widget.
86 86
87 @param calendar calendar document 87 @param calendar calendar document
88 @param parent parent window 88 @param parent parent window
89 @param name Qt internal widget object name 89 @param name Qt internal widget object name
90 */ 90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 ); 92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0, 93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 virtual ~CalendarView(); 95 virtual ~CalendarView();
96 96
97 Calendar *calendar() { return mCalendar; } 97 Calendar *calendar() { return mCalendar; }
98 98
99 KOViewManager *viewManager(); 99 KOViewManager *viewManager();
100 KODialogManager *dialogManager(); 100 KODialogManager *dialogManager();
101 101
102 QDate startDate(); 102 QDate startDate();
103 QDate endDate(); 103 QDate endDate();
104 104
105 QWidgetStack *viewStack(); 105 QWidgetStack *viewStack();
106 QWidget *leftFrame(); 106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar(); 107 NavigatorBar *navigatorBar();
108 108
109 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
111 111
112 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 115 Incidence *currentSelection();
116 void setupExternSyncProfiles(); 116 void setupExternSyncProfiles();
117 117
118 signals: 118 signals:
119 /** This todo has been modified */ 119 /** This todo has been modified */
120 void todoModified(Todo *, int); 120 void todoModified(Todo *, int);
121 121
122 /** when change is made to options dialog, the topwidget will catch this 122 /** when change is made to options dialog, the topwidget will catch this
123 * and emit this signal which notifies all widgets which have registered 123 * and emit this signal which notifies all widgets which have registered
124 * for notification to update their settings. */ 124 * for notification to update their settings. */
125 void configChanged(); 125 void configChanged();
126 /** emitted when the topwidget is closing down, so that any attached 126 /** emitted when the topwidget is closing down, so that any attached
127 child windows can also close. */ 127 child windows can also close. */
128 void closingDown(); 128 void closingDown();
129 /** emitted right before we die */ 129 /** emitted right before we die */
130 void closed(QWidget *); 130 void closed(QWidget *);
131 131
132 /** Emitted when state of modified flag changes */ 132 /** Emitted when state of modified flag changes */
133 void modifiedChanged(bool); 133 void modifiedChanged(bool);
134 void signalmodified(); 134 void signalmodified();
135 135
136 /** Emitted when state of read-only flag changes */ 136 /** Emitted when state of read-only flag changes */
137 void readOnlyChanged(bool); 137 void readOnlyChanged(bool);
138 138
139 /** Emitted when the unit of navigation changes */ 139 /** Emitted when the unit of navigation changes */
140 void changeNavStringPrev(const QString &); 140 void changeNavStringPrev(const QString &);
141 void changeNavStringNext(const QString &); 141 void changeNavStringNext(const QString &);
142 142
143 /** Emitted when state of events selection has changed and user is organizer*/ 143 /** Emitted when state of events selection has changed and user is organizer*/
144 void organizerEventsSelected(bool); 144 void organizerEventsSelected(bool);
145 /** Emitted when state of events selection has changed and user is attendee*/ 145 /** Emitted when state of events selection has changed and user is attendee*/
146 void groupEventsSelected(bool); 146 void groupEventsSelected(bool);
147 /** 147 /**
148 Emitted when an incidence gets selected. If the selection is cleared the 148 Emitted when an incidence gets selected. If the selection is cleared the
149 signal is emitted with 0 as argument. 149 signal is emitted with 0 as argument.
150 */ 150 */
151 void incidenceSelected( Incidence * ); 151 void incidenceSelected( Incidence * );
152 /** Emitted, when a todoitem is selected or deselected. */ 152 /** Emitted, when a todoitem is selected or deselected. */
153 void todoSelected( bool ); 153 void todoSelected( bool );
154 154
155 /** 155 /**
156 Emitted, when clipboard content changes. Parameter indicates if paste 156 Emitted, when clipboard content changes. Parameter indicates if paste
157 is possible or not. 157 is possible or not.
158 */ 158 */
159 void pasteEnabled(bool); 159 void pasteEnabled(bool);
160 160
161 /** Emitted, when the number of incoming messages has changed. */ 161 /** Emitted, when the number of incoming messages has changed. */
162 void numIncomingChanged(int); 162 void numIncomingChanged(int);
163 163
164 /** Emitted, when the number of outgoing messages has changed. */ 164 /** Emitted, when the number of outgoing messages has changed. */
165 void numOutgoingChanged(int); 165 void numOutgoingChanged(int);
166 166
167 /** Send status message, which can e.g. be displayed in the status bar. */ 167 /** Send status message, which can e.g. be displayed in the status bar. */
168 void statusMessage(const QString &); 168 void statusMessage(const QString &);
169 169
170 void calendarViewExpanded( bool ); 170 void calendarViewExpanded( bool );
171 void updateSearchDialog(); 171 void updateSearchDialog();
172 172
173 173
174 public slots: 174 public slots:
175 void watchSavedFile();
175 void recheckTimerAlarm(); 176 void recheckTimerAlarm();
176 void checkNextTimerAlarm(); 177 void checkNextTimerAlarm();
177 void addAlarm(const QDateTime &qdt, const QString &noti ); 178 void addAlarm(const QDateTime &qdt, const QString &noti );
178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 179 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
179 void removeAlarm(const QDateTime &qdt, const QString &noti ); 180 void removeAlarm(const QDateTime &qdt, const QString &noti );
180 181
181 /** options dialog made a changed to the configuration. we catch this 182 /** options dialog made a changed to the configuration. we catch this
182 * and notify all widgets which need to update their configuration. */ 183 * and notify all widgets which need to update their configuration. */
183 void updateConfig(); 184 void updateConfig();
184 185
185 /** 186 /**
186 Load calendar from file \a filename. If \a merge is true, load 187 Load calendar from file \a filename. If \a merge is true, load
187 calendar into existing one, if it is false, clear calendar, before 188 calendar into existing one, if it is false, clear calendar, before
188 loading. Return true, if calendar could be successfully loaded. 189 loading. Return true, if calendar could be successfully loaded.
189 */ 190 */
190 bool openCalendar(QString filename, bool merge=false); 191 bool openCalendar(QString filename, bool merge=false);
191 bool syncCalendar(QString filename,int mode = 0 ); 192 bool syncCalendar(QString filename,int mode = 0 );
192 193
193 /** 194 /**
194 Save calendar data to file. Return true if calendar could be 195 Save calendar data to file. Return true if calendar could be
195 successfully saved. 196 successfully saved.
196 */ 197 */
197 bool saveCalendar(QString filename); 198 bool saveCalendar(QString filename);
198 199
199 /** 200 /**
200 Close calendar. Clear calendar data and reset views to display an empty 201 Close calendar. Clear calendar data and reset views to display an empty
201 calendar. 202 calendar.
202 */ 203 */
203 void closeCalendar(); 204 void closeCalendar();
204 205
205 /** Archive old events of calendar */ 206 /** Archive old events of calendar */
206 void archiveCalendar(); 207 void archiveCalendar();
207 208
208 void showIncidence(); 209 void showIncidence();
209 void editIncidence(); 210 void editIncidence();
210 void editIncidenceDescription(); 211 void editIncidenceDescription();
211 void deleteIncidence(); 212 void deleteIncidence();
212 213
213 /** create an editeventwin with supplied date/time, and if bool is true, 214 /** create an editeventwin with supplied date/time, and if bool is true,
214 * make the event take all day. */ 215 * make the event take all day. */
215 void newEvent(QDateTime, QDateTime, bool allDay = false); 216 void newEvent(QDateTime, QDateTime, bool allDay = false);
216 void newEvent(QDateTime fh); 217 void newEvent(QDateTime fh);
217 void newEvent(QDate dt); 218 void newEvent(QDate dt);
218 /** create new event without having a date hint. Takes current date as 219 /** create new event without having a date hint. Takes current date as
219 default hint. */ 220 default hint. */
220 void newEvent(); 221 void newEvent();
221 void newFloatingEvent(); 222 void newFloatingEvent();
222 223
223 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 224 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
224 void showIncidence(Incidence *); 225 void showIncidence(Incidence *);
225 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 226 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
226 void editIncidence(Incidence *); 227 void editIncidence(Incidence *);
227 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 228 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
228 void deleteIncidence(Incidence *); 229 void deleteIncidence(Incidence *);
229 void cloneIncidence(Incidence *); 230 void cloneIncidence(Incidence *);
230 void cancelIncidence(Incidence *); 231 void cancelIncidence(Incidence *);
231 /** Create an editor for the supplied event. */ 232 /** Create an editor for the supplied event. */
232 void editEvent(Event *); 233 void editEvent(Event *);
233 /** Delete the supplied event. */ 234 /** Delete the supplied event. */
234 void deleteEvent(Event *); 235 void deleteEvent(Event *);
235 /** Delete the event with the given unique ID. Returns false, if event wasn't 236 /** Delete the event with the given unique ID. Returns false, if event wasn't
236 found. */ 237 found. */
237 bool deleteEvent(const QString &uid); 238 bool deleteEvent(const QString &uid);
238 /** Create a read-only viewer dialog for the supplied event. */ 239 /** Create a read-only viewer dialog for the supplied event. */
239 void showEvent(Event *); 240 void showEvent(Event *);
240 241
241 void editJournal(Journal *); 242 void editJournal(Journal *);
242 void showJournal(Journal *); 243 void showJournal(Journal *);
243 void deleteJournal(Journal *); 244 void deleteJournal(Journal *);
244 /** Create an editor dialog for a todo */ 245 /** Create an editor dialog for a todo */
245 void editTodo(Todo *); 246 void editTodo(Todo *);
246 /** Create a read-only viewer dialog for the supplied todo */ 247 /** Create a read-only viewer dialog for the supplied todo */
247 void showTodo(Todo *); 248 void showTodo(Todo *);
248 /** create new todo */ 249 /** create new todo */
249 void newTodo(); 250 void newTodo();
250 /** create new todo with a parent todo */ 251 /** create new todo with a parent todo */
251 void newSubTodo(); 252 void newSubTodo();
252 /** create new todo with a parent todo */ 253 /** create new todo with a parent todo */
253 void newSubTodo(Todo *); 254 void newSubTodo(Todo *);
254 /** Delete todo */ 255 /** Delete todo */
255 void deleteTodo(Todo *); 256 void deleteTodo(Todo *);
256 257
257 258
258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 259 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
259 * emitted as result. */ 260 * emitted as result. */
260 void checkClipboard(); 261 void checkClipboard();
261 262
262 /** using the KConfig associated with the kapp variable, read in the 263 /** using the KConfig associated with the kapp variable, read in the
263 * settings from the config file. 264 * settings from the config file.
264 */ 265 */
265 void readSettings(); 266 void readSettings();
266 267
267 /** write current state to config file. */ 268 /** write current state to config file. */
268 void writeSettings(); 269 void writeSettings();
269 270
270 /** read settings for calendar filters */ 271 /** read settings for calendar filters */
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 1c4a186..6315c64 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1315,196 +1315,197 @@ void MainWindow::processIncidenceSelection( Incidence *incidence )
1315 mShowAction->setText( i18n("Show...") ); 1315 mShowAction->setText( i18n("Show...") );
1316 mShowAction->setText( i18n("Edit...") ); 1316 mShowAction->setText( i18n("Edit...") );
1317 mShowAction->setText( i18n("Delete...") ); 1317 mShowAction->setText( i18n("Delete...") );
1318 1318
1319 mNewSubTodoAction->setEnabled( false ); 1319 mNewSubTodoAction->setEnabled( false );
1320 } 1320 }
1321} 1321}
1322 1322
1323void MainWindow::enableIncidenceActions( bool enabled ) 1323void MainWindow::enableIncidenceActions( bool enabled )
1324{ 1324{
1325 mShowAction->setEnabled( enabled ); 1325 mShowAction->setEnabled( enabled );
1326 mEditAction->setEnabled( enabled ); 1326 mEditAction->setEnabled( enabled );
1327 mDeleteAction->setEnabled( enabled ); 1327 mDeleteAction->setEnabled( enabled );
1328} 1328}
1329 1329
1330void MainWindow::importOL() 1330void MainWindow::importOL()
1331{ 1331{
1332#ifdef _WIN32_ 1332#ifdef _WIN32_
1333 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1333 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1334 id->exec(); 1334 id->exec();
1335 delete id; 1335 delete id;
1336 mView->updateView(); 1336 mView->updateView();
1337#endif 1337#endif
1338} 1338}
1339void MainWindow::importBday() 1339void MainWindow::importBday()
1340{ 1340{
1341 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1341 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1342 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1342 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1343 i18n("Import!"), i18n("Cancel"), 0, 1343 i18n("Import!"), i18n("Cancel"), 0,
1344 0, 1 ); 1344 0, 1 );
1345 if ( result == 0 ) { 1345 if ( result == 0 ) {
1346 mView->importBday(); 1346 mView->importBday();
1347 1347
1348 } 1348 }
1349 1349
1350 1350
1351} 1351}
1352void MainWindow::importQtopia() 1352void MainWindow::importQtopia()
1353{ 1353{
1354#ifndef DESKTOP_VERSION 1354#ifndef DESKTOP_VERSION
1355 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1355 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1356 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"), 1356 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"),
1357 i18n("Import!"), i18n("Cancel"), 0, 1357 i18n("Import!"), i18n("Cancel"), 0,
1358 0, 1 ); 1358 0, 1 );
1359 if ( result == 0 ) { 1359 if ( result == 0 ) {
1360 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1360 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1361 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1361 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1362 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1362 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1363 mView->importQtopia( categories, datebook, todolist ); 1363 mView->importQtopia( categories, datebook, todolist );
1364 } 1364 }
1365#else 1365#else
1366 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1366 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1367 i18n("Not supported \non desktop!\n"), 1367 i18n("Not supported \non desktop!\n"),
1368 i18n("Ok"), i18n("Cancel"), 0, 1368 i18n("Ok"), i18n("Cancel"), 0,
1369 0, 1 ); 1369 0, 1 );
1370 1370
1371#endif 1371#endif
1372} 1372}
1373 1373
1374void MainWindow::saveOnClose() 1374void MainWindow::saveOnClose()
1375{ 1375{
1376 KOPrefs *p = KOPrefs::instance(); 1376 KOPrefs *p = KOPrefs::instance();
1377 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1377 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1378 p->mToolBarUp = iconToolBar->x() > width()/2 || 1378 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1379 iconToolBar->y() > height()/2; 1379 iconToolBar->y() > height()/2;
1380 mView->writeSettings(); 1380 mView->writeSettings();
1381 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1381 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1382 save(); 1382 save();
1383} 1383}
1384void MainWindow::slotModifiedChanged( bool changed ) 1384void MainWindow::slotModifiedChanged( bool changed )
1385{ 1385{
1386 if ( mBlockAtStartup ) 1386 if ( mBlockAtStartup )
1387 return; 1387 return;
1388 int msec; 1388 int msec;
1389 // we store the changes after 1 minute, 1389 // we store the changes after 1 minute,
1390 // and for safety reasons after 10 minutes again 1390 // and for safety reasons after 10 minutes again
1391 if ( !mBlockSaveFlag ) 1391 if ( !mBlockSaveFlag )
1392 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1392 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1393 else 1393 else
1394 msec = 1000 * 600; 1394 msec = 1000 * 600;
1395 mSaveTimer.start( msec, true ); // 1 minute 1395 mSaveTimer.start( msec, true ); // 1 minute
1396 qDebug("KO: Saving File in %d secs!", msec/1000); 1396 qDebug("KO: Saving File in %d secs!", msec/1000);
1397 mCalendarModifiedFlag = true; 1397 mCalendarModifiedFlag = true;
1398} 1398}
1399#include <qfileinfo.h> 1399#include <qfileinfo.h>
1400void MainWindow::save() 1400void MainWindow::save()
1401{ 1401{
1402 if ( mBlockSaveFlag ) 1402 if ( mBlockSaveFlag )
1403 return; 1403 return;
1404 bool store = mBlockSaveFlag; 1404 bool store = mBlockSaveFlag;
1405 mBlockSaveFlag = true; 1405 mBlockSaveFlag = true;
1406 if ( mView->checkFileVersion( defaultFileName()) ) { 1406 if ( mView->checkFileVersion( defaultFileName()) ) {
1407 1407
1408 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1408 QTime neededSaveTime = QDateTime::currentDateTime().time();
1409 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1409 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1410 qDebug("KO: Start saving data to file!"); 1410 qDebug("KO: Start saving data to file!");
1411 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1411 mView->saveCalendar( defaultFileName() ); 1412 mView->saveCalendar( defaultFileName() );
1412 1413
1413 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1414 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1414 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1415 mView->watchSavedFile();
1415 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1416 qDebug("KO: Needed %d ms for saving.",msNeeded );
1416 QString savemes; 1417 QString savemes;
1417 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1418 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1418 setCaption(savemes); 1419 setCaption(savemes);
1419 } else 1420 } else
1420 setCaption(i18n("Saving cancelled!")); 1421 setCaption(i18n("Saving cancelled!"));
1421 mCalendarModifiedFlag = false; 1422 mCalendarModifiedFlag = false;
1422 mBlockSaveFlag = store; 1423 mBlockSaveFlag = store;
1423} 1424}
1424 1425
1425void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1426void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1426{ 1427{
1427 if ( !e->isAutoRepeat() ) { 1428 if ( !e->isAutoRepeat() ) {
1428 mFlagKeyPressed = false; 1429 mFlagKeyPressed = false;
1429 } 1430 }
1430} 1431}
1431void MainWindow::keyPressEvent ( QKeyEvent * e ) 1432void MainWindow::keyPressEvent ( QKeyEvent * e )
1432{ 1433{
1433 qApp->processEvents(); 1434 qApp->processEvents();
1434 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1435 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1435 e->ignore(); 1436 e->ignore();
1436 // qDebug(" ignore %d",e->isAutoRepeat() ); 1437 // qDebug(" ignore %d",e->isAutoRepeat() );
1437 return; 1438 return;
1438 } 1439 }
1439 if (! e->isAutoRepeat() ) 1440 if (! e->isAutoRepeat() )
1440 mFlagKeyPressed = true; 1441 mFlagKeyPressed = true;
1441 KOPrefs *p = KOPrefs::instance(); 1442 KOPrefs *p = KOPrefs::instance();
1442 bool showSelectedDates = false; 1443 bool showSelectedDates = false;
1443 int size; 1444 int size;
1444 int pro = 0; 1445 int pro = 0;
1445 //qDebug("MainWindow::keyPressEvent "); 1446 //qDebug("MainWindow::keyPressEvent ");
1446 switch ( e->key() ) { 1447 switch ( e->key() ) {
1447 case Qt::Key_Right: 1448 case Qt::Key_Right:
1448 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1449 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1449 mView->goNextMonth(); 1450 mView->goNextMonth();
1450 else 1451 else
1451 mView->goNext(); 1452 mView->goNext();
1452 showSelectedDates = true; 1453 showSelectedDates = true;
1453 break; 1454 break;
1454 case Qt::Key_Left: 1455 case Qt::Key_Left:
1455 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1456 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1456 mView->goPreviousMonth(); 1457 mView->goPreviousMonth();
1457 else 1458 else
1458 mView->goPrevious(); 1459 mView->goPrevious();
1459 showSelectedDates = true; 1460 showSelectedDates = true;
1460 break; 1461 break;
1461 case Qt::Key_Down: 1462 case Qt::Key_Down:
1462 mView->viewManager()->agendaView()->scrollOneHourDown(); 1463 mView->viewManager()->agendaView()->scrollOneHourDown();
1463 break; 1464 break;
1464 case Qt::Key_Up: 1465 case Qt::Key_Up:
1465 mView->viewManager()->agendaView()->scrollOneHourUp(); 1466 mView->viewManager()->agendaView()->scrollOneHourUp();
1466 break; 1467 break;
1467 case Qt::Key_I: 1468 case Qt::Key_I:
1468 mView->showIncidence(); 1469 mView->showIncidence();
1469 break; 1470 break;
1470 case Qt::Key_Delete: 1471 case Qt::Key_Delete:
1471 case Qt::Key_Backspace: 1472 case Qt::Key_Backspace:
1472 mView->deleteIncidence(); 1473 mView->deleteIncidence();
1473 break; 1474 break;
1474 case Qt::Key_D: 1475 case Qt::Key_D:
1475 mView->viewManager()->showDayView(); 1476 mView->viewManager()->showDayView();
1476 showSelectedDates = true; 1477 showSelectedDates = true;
1477 break; 1478 break;
1478 case Qt::Key_O: 1479 case Qt::Key_O:
1479 mView->toggleFilerEnabled( ); 1480 mView->toggleFilerEnabled( );
1480 break; 1481 break;
1481 case Qt::Key_0: 1482 case Qt::Key_0:
1482 case Qt::Key_1: 1483 case Qt::Key_1:
1483 case Qt::Key_2: 1484 case Qt::Key_2:
1484 case Qt::Key_3: 1485 case Qt::Key_3:
1485 case Qt::Key_4: 1486 case Qt::Key_4:
1486 case Qt::Key_5: 1487 case Qt::Key_5:
1487 case Qt::Key_6: 1488 case Qt::Key_6:
1488 case Qt::Key_7: 1489 case Qt::Key_7:
1489 case Qt::Key_8: 1490 case Qt::Key_8:
1490 case Qt::Key_9: 1491 case Qt::Key_9:
1491 pro = e->key()-48; 1492 pro = e->key()-48;
1492 if ( pro == 0 ) 1493 if ( pro == 0 )
1493 pro = 10; 1494 pro = 10;
1494 if ( e->state() == Qt::ControlButton) 1495 if ( e->state() == Qt::ControlButton)
1495 pro += 10; 1496 pro += 10;
1496 break; 1497 break;
1497 case Qt::Key_M: 1498 case Qt::Key_M:
1498 mView->viewManager()->showMonthView(); 1499 mView->viewManager()->showMonthView();
1499 showSelectedDates = true; 1500 showSelectedDates = true;
1500 break; 1501 break;
1501 case Qt::Key_Insert: 1502 case Qt::Key_Insert:
1502 mView->newEvent(); 1503 mView->newEvent();
1503 break; 1504 break;
1504 case Qt::Key_S : 1505 case Qt::Key_S :
1505 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1506 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1506 mView->newSubTodo(); 1507 mView->newSubTodo();
1507 else 1508 else
1508 mView->dialogManager()->showSearchDialog(); 1509 mView->dialogManager()->showSearchDialog();
1509 break; 1510 break;
1510 case Qt::Key_Y : 1511 case Qt::Key_Y :