summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -1453,170 +1453,183 @@ bool CalendarView::importQtopia( const QString &categories,
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();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index a3315ad..355bb84 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -111,128 +111,129 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
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. */
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 1c4a186..6315c64 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1347,132 +1347,133 @@ void MainWindow::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: