summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 08:32:25 (UTC)
committer zautrix <zautrix>2004-10-05 08:32:25 (UTC)
commit701cd3c2b2b713c12797f5bda24c35d3a7889539 (patch) (unidiff)
tree56d07b2f4a050fbc839ab6435b2266e8a52a08ba
parentad859d26b813101adab963f50e694961702561d9 (diff)
downloadkdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.zip
kdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.tar.gz
kdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.tar.bz2
warning dialog fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp4
3 files changed, 17 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index fecc7e2..687943e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1430,201 +1430,214 @@ bool CalendarView::importQtopia( const QString &categories,
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() ) { 1502 if ( mStorage->load() ) {
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 loadedFileVersion = QDateTime::currentDateTime(); 1517 loadedFileVersion = QDateTime::currentDateTime();
1518 if ( filename != MainWindow::defaultFileName() ) { 1518 if ( filename != MainWindow::defaultFileName() ) {
1519 saveCalendar( MainWindow::defaultFileName() ); 1519 saveCalendar( MainWindow::defaultFileName() );
1520 watchSavedFile(); 1520 watchSavedFile();
1521 } 1521 }
1522 return true; 1522 return true;
1523 } else { 1523 } else {
1524 // while failing to load, the calendar object could 1524 // while failing to load, the calendar object could
1525 // have become partially populated. Clear it out. 1525 // have become partially populated. Clear it out.
1526 if ( !merge ) mCalendar->close(); 1526 if ( !merge ) {
1527 mCalendar->close();
1528 mViewManager->setDocumentId( filename );
1529 mDialogManager->setDocumentId( filename );
1530 mTodoList->setDocumentId( filename );
1531 }
1527 1532
1528 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1533 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1529 1534
1535 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1530 globalFlagBlockAgenda = 2; 1536 globalFlagBlockAgenda = 2;
1537 mCalendar->reInitAlarmSettings();
1538 setSyncEventsReadOnly();
1539 updateUnmanagedViews();
1531 updateView(); 1540 updateView();
1532 } 1541 }
1533 return false; 1542 return false;
1534} 1543}
1544void CalendarView::showOpenError()
1545{
1546 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1547}
1535void CalendarView::setLoadedFileVersion(QDateTime dt) 1548void CalendarView::setLoadedFileVersion(QDateTime dt)
1536{ 1549{
1537 loadedFileVersion = dt; 1550 loadedFileVersion = dt;
1538} 1551}
1539bool CalendarView::checkFileChanged(QString fn) 1552bool CalendarView::checkFileChanged(QString fn)
1540{ 1553{
1541 QFileInfo finf ( fn ); 1554 QFileInfo finf ( fn );
1542 if ( !finf.exists() ) 1555 if ( !finf.exists() )
1543 return true; 1556 return true;
1544 QDateTime dt = finf.lastModified (); 1557 QDateTime dt = finf.lastModified ();
1545 if ( dt <= loadedFileVersion ) 1558 if ( dt <= loadedFileVersion )
1546 return false; 1559 return false;
1547 return true; 1560 return true;
1548 1561
1549} 1562}
1550void CalendarView::watchSavedFile() 1563void CalendarView::watchSavedFile()
1551{ 1564{
1552 QFileInfo finf ( MainWindow::defaultFileName()); 1565 QFileInfo finf ( MainWindow::defaultFileName());
1553 if ( !finf.exists() ) 1566 if ( !finf.exists() )
1554 return; 1567 return;
1555 QDateTime dt = finf.lastModified (); 1568 QDateTime dt = finf.lastModified ();
1556 if ( dt < loadedFileVersion ) { 1569 if ( dt < loadedFileVersion ) {
1557 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1570 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1558 return; 1571 return;
1559 } 1572 }
1560 loadedFileVersion = dt; 1573 loadedFileVersion = dt;
1561} 1574}
1562 1575
1563bool CalendarView::checkFileVersion(QString fn) 1576bool CalendarView::checkFileVersion(QString fn)
1564{ 1577{
1565 QFileInfo finf ( fn ); 1578 QFileInfo finf ( fn );
1566 if ( !finf.exists() ) 1579 if ( !finf.exists() )
1567 return true; 1580 return true;
1568 QDateTime dt = finf.lastModified (); 1581 QDateTime dt = finf.lastModified ();
1569 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1582 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1570 //qDebug("file on disk version %s",dt.toString().latin1()); 1583 //qDebug("file on disk version %s",dt.toString().latin1());
1571 if ( dt <= loadedFileVersion ) 1584 if ( dt <= loadedFileVersion )
1572 return true; 1585 return true;
1573 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)) , 1586 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)) ,
1574 i18n("KO/Pi Warning"),i18n("Overwrite"), 1587 i18n("KO/Pi Warning"),i18n("Overwrite"),
1575 i18n("Sync+save")); 1588 i18n("Sync+save"));
1576 1589
1577 if ( km == KMessageBox::Cancel ) 1590 if ( km == KMessageBox::Cancel )
1578 return false; 1591 return false;
1579 if ( km == KMessageBox::Yes ) 1592 if ( km == KMessageBox::Yes )
1580 return true; 1593 return true;
1581 1594
1582 setSyncDevice("deleteaftersync" ); 1595 setSyncDevice("deleteaftersync" );
1583 KOPrefs::instance()->mAskForPreferences = true; 1596 KOPrefs::instance()->mAskForPreferences = true;
1584 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1597 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1585 KOPrefs::instance()->mWriteBackFile = false; 1598 KOPrefs::instance()->mWriteBackFile = false;
1586 KOPrefs::instance()->mWriteBackExistingOnly = false; 1599 KOPrefs::instance()->mWriteBackExistingOnly = false;
1587 KOPrefs::instance()->mShowSyncSummary = false; 1600 KOPrefs::instance()->mShowSyncSummary = false;
1588 syncCalendar( fn, 3 ); 1601 syncCalendar( fn, 3 );
1589 Event * e = getLastSyncEvent(); 1602 Event * e = getLastSyncEvent();
1590 mCalendar->deleteEvent ( e ); 1603 mCalendar->deleteEvent ( e );
1591 updateView(); 1604 updateView();
1592 return true; 1605 return true;
1593} 1606}
1594 1607
1595bool CalendarView::saveCalendar( QString filename ) 1608bool CalendarView::saveCalendar( QString filename )
1596{ 1609{
1597 1610
1598 // Store back all unsaved data into calendar object 1611 // Store back all unsaved data into calendar object
1599 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1612 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1600 if ( mViewManager->currentView() ) 1613 if ( mViewManager->currentView() )
1601 mViewManager->currentView()->flushView(); 1614 mViewManager->currentView()->flushView();
1602 1615
1603 //mStorage->setFileName( filename ); 1616 //mStorage->setFileName( filename );
1604 1617
1605 mStorage->setSaveFormat( new ICalFormat() ); 1618 mStorage->setSaveFormat( new ICalFormat() );
1606 mStorage->setFileName( filename ); 1619 mStorage->setFileName( filename );
1607 bool success; 1620 bool success;
1608 success = mStorage->save(); 1621 success = mStorage->save();
1609 if ( !success ) { 1622 if ( !success ) {
1610 return false; 1623 return false;
1611 } 1624 }
1612 1625
1613 return true; 1626 return true;
1614} 1627}
1615 1628
1616void CalendarView::closeCalendar() 1629void CalendarView::closeCalendar()
1617{ 1630{
1618 1631
1619 // child windows no longer valid 1632 // child windows no longer valid
1620 emit closingDown(); 1633 emit closingDown();
1621 1634
1622 mCalendar->close(); 1635 mCalendar->close();
1623 setModified(false); 1636 setModified(false);
1624 updateView(); 1637 updateView();
1625} 1638}
1626 1639
1627void CalendarView::archiveCalendar() 1640void CalendarView::archiveCalendar()
1628{ 1641{
1629 mDialogManager->showArchiveDialog(); 1642 mDialogManager->showArchiveDialog();
1630} 1643}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 355bb84..cd54685 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 showOpenError();
175 void watchSavedFile(); 176 void watchSavedFile();
176 void recheckTimerAlarm(); 177 void recheckTimerAlarm();
177 void checkNextTimerAlarm(); 178 void checkNextTimerAlarm();
178 void addAlarm(const QDateTime &qdt, const QString &noti ); 179 void addAlarm(const QDateTime &qdt, const QString &noti );
179 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 180 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
180 void removeAlarm(const QDateTime &qdt, const QString &noti ); 181 void removeAlarm(const QDateTime &qdt, const QString &noti );
181 182
182 /** options dialog made a changed to the configuration. we catch this 183 /** options dialog made a changed to the configuration. we catch this
183 * and notify all widgets which need to update their configuration. */ 184 * and notify all widgets which need to update their configuration. */
184 void updateConfig(); 185 void updateConfig();
185 186
186 /** 187 /**
187 Load calendar from file \a filename. If \a merge is true, load 188 Load calendar from file \a filename. If \a merge is true, load
188 calendar into existing one, if it is false, clear calendar, before 189 calendar into existing one, if it is false, clear calendar, before
189 loading. Return true, if calendar could be successfully loaded. 190 loading. Return true, if calendar could be successfully loaded.
190 */ 191 */
191 bool openCalendar(QString filename, bool merge=false); 192 bool openCalendar(QString filename, bool merge=false);
192 bool syncCalendar(QString filename,int mode = 0 ); 193 bool syncCalendar(QString filename,int mode = 0 );
193 194
194 /** 195 /**
195 Save calendar data to file. Return true if calendar could be 196 Save calendar data to file. Return true if calendar could be
196 successfully saved. 197 successfully saved.
197 */ 198 */
198 bool saveCalendar(QString filename); 199 bool saveCalendar(QString filename);
199 200
200 /** 201 /**
201 Close calendar. Clear calendar data and reset views to display an empty 202 Close calendar. Clear calendar data and reset views to display an empty
202 calendar. 203 calendar.
203 */ 204 */
204 void closeCalendar(); 205 void closeCalendar();
205 206
206 /** Archive old events of calendar */ 207 /** Archive old events of calendar */
207 void archiveCalendar(); 208 void archiveCalendar();
208 209
209 void showIncidence(); 210 void showIncidence();
210 void editIncidence(); 211 void editIncidence();
211 void editIncidenceDescription(); 212 void editIncidenceDescription();
212 void deleteIncidence(); 213 void deleteIncidence();
213 214
214 /** create an editeventwin with supplied date/time, and if bool is true, 215 /** create an editeventwin with supplied date/time, and if bool is true,
215 * make the event take all day. */ 216 * make the event take all day. */
216 void newEvent(QDateTime, QDateTime, bool allDay = false); 217 void newEvent(QDateTime, QDateTime, bool allDay = false);
217 void newEvent(QDateTime fh); 218 void newEvent(QDateTime fh);
218 void newEvent(QDate dt); 219 void newEvent(QDate dt);
219 /** create new event without having a date hint. Takes current date as 220 /** create new event without having a date hint. Takes current date as
220 default hint. */ 221 default hint. */
221 void newEvent(); 222 void newEvent();
222 void newFloatingEvent(); 223 void newFloatingEvent();
223 224
224 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 225 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
225 void showIncidence(Incidence *); 226 void showIncidence(Incidence *);
226 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 227 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
227 void editIncidence(Incidence *); 228 void editIncidence(Incidence *);
228 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 229 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
229 void deleteIncidence(Incidence *); 230 void deleteIncidence(Incidence *);
230 void cloneIncidence(Incidence *); 231 void cloneIncidence(Incidence *);
231 void cancelIncidence(Incidence *); 232 void cancelIncidence(Incidence *);
232 /** Create an editor for the supplied event. */ 233 /** Create an editor for the supplied event. */
233 void editEvent(Event *); 234 void editEvent(Event *);
234 /** Delete the supplied event. */ 235 /** Delete the supplied event. */
235 void deleteEvent(Event *); 236 void deleteEvent(Event *);
236 /** Delete the event with the given unique ID. Returns false, if event wasn't 237 /** Delete the event with the given unique ID. Returns false, if event wasn't
237 found. */ 238 found. */
238 bool deleteEvent(const QString &uid); 239 bool deleteEvent(const QString &uid);
239 /** Create a read-only viewer dialog for the supplied event. */ 240 /** Create a read-only viewer dialog for the supplied event. */
240 void showEvent(Event *); 241 void showEvent(Event *);
241 242
242 void editJournal(Journal *); 243 void editJournal(Journal *);
243 void showJournal(Journal *); 244 void showJournal(Journal *);
244 void deleteJournal(Journal *); 245 void deleteJournal(Journal *);
245 /** Create an editor dialog for a todo */ 246 /** Create an editor dialog for a todo */
246 void editTodo(Todo *); 247 void editTodo(Todo *);
247 /** Create a read-only viewer dialog for the supplied todo */ 248 /** Create a read-only viewer dialog for the supplied todo */
248 void showTodo(Todo *); 249 void showTodo(Todo *);
249 /** create new todo */ 250 /** create new todo */
250 void newTodo(); 251 void newTodo();
251 /** create new todo with a parent todo */ 252 /** create new todo with a parent todo */
252 void newSubTodo(); 253 void newSubTodo();
253 /** create new todo with a parent todo */ 254 /** create new todo with a parent todo */
254 void newSubTodo(Todo *); 255 void newSubTodo(Todo *);
255 /** Delete todo */ 256 /** Delete todo */
256 void deleteTodo(Todo *); 257 void deleteTodo(Todo *);
257 258
258 259
259 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 260 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
260 * emitted as result. */ 261 * emitted as result. */
261 void checkClipboard(); 262 void checkClipboard();
262 263
263 /** using the KConfig associated with the kapp variable, read in the 264 /** using the KConfig associated with the kapp variable, read in the
264 * settings from the config file. 265 * settings from the config file.
265 */ 266 */
266 void readSettings(); 267 void readSettings();
267 268
268 /** write current state to config file. */ 269 /** write current state to config file. */
269 void writeSettings(); 270 void writeSettings();
270 271
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 43ee2d7..7b666d1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -51,220 +51,218 @@
51#include "kstandarddirs.h" 51#include "kstandarddirs.h"
52#include "koprefs.h" 52#include "koprefs.h"
53#include "kfiledialog.h" 53#include "kfiledialog.h"
54#include "koglobals.h" 54#include "koglobals.h"
55#include "kglobal.h" 55#include "kglobal.h"
56#include "klocale.h" 56#include "klocale.h"
57#include "kconfig.h" 57#include "kconfig.h"
58#include "simplealarmclient.h" 58#include "simplealarmclient.h"
59#include "externalapphandler.h" 59#include "externalapphandler.h"
60 60
61using namespace KCal; 61using namespace KCal;
62#ifndef _WIN32_ 62#ifndef _WIN32_
63#include <unistd.h> 63#include <unistd.h>
64#else 64#else
65#include "koimportoldialog.h" 65#include "koimportoldialog.h"
66#endif 66#endif
67#include "mainwindow.h" 67#include "mainwindow.h"
68 68
69int globalFlagBlockStartup; 69int globalFlagBlockStartup;
70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
71 QMainWindow( parent, name ) 71 QMainWindow( parent, name )
72{ 72{
73 mPassWordPiSync = "abc"; 73 mPassWordPiSync = "abc";
74#ifdef DESKTOP_VERSION 74#ifdef DESKTOP_VERSION
75 setFont( QFont("Arial"), 14 ); 75 setFont( QFont("Arial"), 14 );
76#endif 76#endif
77 mSyncActionDialog = 0; 77 mSyncActionDialog = 0;
78 mServerSocket = 0; 78 mServerSocket = 0;
79 mClosed = false; 79 mClosed = false;
80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
81 QString confFile = locateLocal("config","korganizerrc"); 81 QString confFile = locateLocal("config","korganizerrc");
82 QFileInfo finf ( confFile ); 82 QFileInfo finf ( confFile );
83 bool showWarning = !finf.exists(); 83 bool showWarning = !finf.exists();
84 setIcon(SmallIcon( "ko24" ) ); 84 setIcon(SmallIcon( "ko24" ) );
85 mBlockAtStartup = true; 85 mBlockAtStartup = true;
86 mFlagKeyPressed = false; 86 mFlagKeyPressed = false;
87 setCaption("KOrganizer/Pi"); 87 setCaption("KOrganizer/Pi");
88 KOPrefs *p = KOPrefs::instance(); 88 KOPrefs *p = KOPrefs::instance();
89 KPimGlobalPrefs::instance()->setGlobalConfig(); 89 KPimGlobalPrefs::instance()->setGlobalConfig();
90 // if ( QApplication::desktop()->height() > 480 ) { 90 // if ( QApplication::desktop()->height() > 480 ) {
91// if ( p->mHourSize == 4 ) 91// if ( p->mHourSize == 4 )
92// p->mHourSize = 6; 92// p->mHourSize = 6;
93// } 93// }
94 if ( p->mHourSize > 18 ) 94 if ( p->mHourSize > 18 )
95 p->mHourSize = 18; 95 p->mHourSize = 18;
96 QMainWindow::ToolBarDock tbd; 96 QMainWindow::ToolBarDock tbd;
97 if ( p->mToolBarHor ) { 97 if ( p->mToolBarHor ) {
98 if ( p->mToolBarUp ) 98 if ( p->mToolBarUp )
99 tbd = Bottom; 99 tbd = Bottom;
100 else 100 else
101 tbd = Top; 101 tbd = Top;
102 } 102 }
103 else { 103 else {
104 if ( p->mToolBarUp ) 104 if ( p->mToolBarUp )
105 tbd = Right; 105 tbd = Right;
106 else 106 else
107 tbd = Left; 107 tbd = Left;
108 } 108 }
109 if ( KOPrefs::instance()->mUseAppColors ) 109 if ( KOPrefs::instance()->mUseAppColors )
110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
111 globalFlagBlockStartup = 1; 111 globalFlagBlockStartup = 1;
112 iconToolBar = new QPEToolBar( this ); 112 iconToolBar = new QPEToolBar( this );
113 addToolBar (iconToolBar , tbd ); 113 addToolBar (iconToolBar , tbd );
114 mBlockSaveFlag = false; 114 mBlockSaveFlag = false;
115 mCalendarModifiedFlag = false; 115 mCalendarModifiedFlag = false;
116 116
117 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 117 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
118 splash->setAlignment ( AlignCenter ); 118 splash->setAlignment ( AlignCenter );
119 setCentralWidget( splash ); 119 setCentralWidget( splash );
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121 showMaximized(); 121 showMaximized();
122#endif 122#endif
123 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 123 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
124 setDefaultPreferences(); 124 setDefaultPreferences();
125 mCalendar = new CalendarLocal(); 125 mCalendar = new CalendarLocal();
126 mView = new CalendarView( mCalendar, this,"mCalendar " ); 126 mView = new CalendarView( mCalendar, this,"mCalendar " );
127 mView->hide(); 127 mView->hide();
128 //mView->resize(splash->size() ); 128 //mView->resize(splash->size() );
129 initActions(); 129 initActions();
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 iconToolBar->show(); 131 iconToolBar->show();
132 qApp->processEvents(); 132 qApp->processEvents();
133#endif 133#endif
134 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 134 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
135 int vh = height() ; 135 int vh = height() ;
136 int vw = width(); 136 int vw = width();
137 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 137 //qDebug("Toolbar hei %d ",iconToolBar->height() );
138 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 138 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
139 vh -= iconToolBar->height(); 139 vh -= iconToolBar->height();
140 } else { 140 } else {
141 vw -= iconToolBar->height(); 141 vw -= iconToolBar->height();
142 } 142 }
143 //mView->setMaximumSize( splash->size() ); 143 //mView->setMaximumSize( splash->size() );
144 //mView->resize( splash->size() ); 144 //mView->resize( splash->size() );
145 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 145 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
146 mView->readSettings(); 146 mView->readSettings();
147 bool oldOpened = false;
148 bool newFile = false; 147 bool newFile = false;
149 if( !QFile::exists( defaultFileName() ) ) { 148 if( !QFile::exists( defaultFileName() ) ) {
150 QFileInfo finfo ( defaultFileName() ); 149 QFileInfo finfo ( defaultFileName() );
151 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 150 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
152 qDebug("oldfile %s ", oldFile.latin1()); 151 qDebug("oldfile %s ", oldFile.latin1());
153 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 152 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
154 finfo.setFile( oldFile ); 153 finfo.setFile( oldFile );
155 if (finfo.exists() ) { 154 if (finfo.exists() ) {
156 KMessageBox::information( this, message); 155 KMessageBox::information( this, message);
157 mView->openCalendar( oldFile ); 156 mView->openCalendar( oldFile );
158 qApp->processEvents(); 157 qApp->processEvents();
159 } else { 158 } else {
160 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 159 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
161 finfo.setFile( oldFile ); 160 finfo.setFile( oldFile );
162 if (finfo.exists() ) { 161 if (finfo.exists() ) {
163 KMessageBox::information( this, message); 162 KMessageBox::information( this, message);
164 mView->openCalendar( oldFile ); 163 mView->openCalendar( oldFile );
165 qApp->processEvents(); 164 qApp->processEvents();
166 } 165 }
167 } 166 }
168 mView->saveCalendar( defaultFileName() ); 167 mView->saveCalendar( defaultFileName() );
169 newFile = true; 168 newFile = true;
170 } 169 }
171 170
172 QTime neededSaveTime = QDateTime::currentDateTime().time(); 171 QTime neededSaveTime = QDateTime::currentDateTime().time();
173 if ( ! oldOpened ) 172 mView->openCalendar( defaultFileName() );
174 mView->openCalendar( defaultFileName() );
175 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 173 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
176 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 174 qDebug("KO: Calendar loading time: %d ms",msNeeded );
177 175
178 if ( KOPrefs::instance()->mLanguageChanged ) { 176 if ( KOPrefs::instance()->mLanguageChanged ) {
179 KOPrefs::instance()->setCategoryDefaults(); 177 KOPrefs::instance()->setCategoryDefaults();
180 int count = mView->addCategories(); 178 int count = mView->addCategories();
181 KOPrefs::instance()->mLanguageChanged = false; 179 KOPrefs::instance()->mLanguageChanged = false;
182 } 180 }
183 processIncidenceSelection( 0 ); 181 processIncidenceSelection( 0 );
184 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 182 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
185 SLOT( processIncidenceSelection( Incidence * ) ) ); 183 SLOT( processIncidenceSelection( Incidence * ) ) );
186 connect( mView, SIGNAL( modifiedChanged( bool ) ), 184 connect( mView, SIGNAL( modifiedChanged( bool ) ),
187 SLOT( slotModifiedChanged( bool ) ) ); 185 SLOT( slotModifiedChanged( bool ) ) );
188 186
189 187
190 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 188 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
191 mView->setModified( false ); 189 mView->setModified( false );
192 mBlockAtStartup = false; 190 mBlockAtStartup = false;
193 mView->setModified( false ); 191 mView->setModified( false );
194 setCentralWidget( mView ); 192 setCentralWidget( mView );
195 globalFlagBlockStartup = 0; 193 globalFlagBlockStartup = 0;
196 mView->show(); 194 mView->show();
197 delete splash; 195 delete splash;
198 if ( newFile ) 196 if ( newFile )
199 mView->updateConfig(); 197 mView->updateConfig();
200 // qApp->processEvents(); 198 // qApp->processEvents();
201 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 199 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
202 fillSyncMenu(); 200 fillSyncMenu();
203 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 201 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
204 if ( showWarning ) { 202 if ( showWarning ) {
205 KMessageBox::information( this, 203 KMessageBox::information( this,
206 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 204 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
207 qApp->processEvents(); 205 qApp->processEvents();
208 mView->dialogManager()->showSyncOptions(); 206 mView->dialogManager()->showSyncOptions();
209 } 207 }
210 208
211 //US listen for result adressed from Ka/Pi 209 //US listen for result adressed from Ka/Pi
212#ifndef DESKTOP_VERSION 210#ifndef DESKTOP_VERSION
213 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 211 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
214#endif 212#endif
215} 213}
216MainWindow::~MainWindow() 214MainWindow::~MainWindow()
217{ 215{
218 //qDebug("MainWindow::~MainWindow() "); 216 //qDebug("MainWindow::~MainWindow() ");
219 //save toolbar location 217 //save toolbar location
220 delete mServerSocket; 218 delete mServerSocket;
221 delete mCalendar; 219 delete mCalendar;
222 delete KOPrefs::instance(); 220 delete KOPrefs::instance();
223 delete KIncidenceFormatter::instance(); 221 delete KIncidenceFormatter::instance();
224 222
225 223
226} 224}
227void MainWindow::showMaximized () 225void MainWindow::showMaximized ()
228{ 226{
229#ifndef DESKTOP_VERSION 227#ifndef DESKTOP_VERSION
230 if ( ! globalFlagBlockStartup ) 228 if ( ! globalFlagBlockStartup )
231 if ( mClosed ) 229 if ( mClosed )
232 mView->goToday(); 230 mView->goToday();
233#endif 231#endif
234 QWidget::showMaximized () ; 232 QWidget::showMaximized () ;
235 mClosed = false; 233 mClosed = false;
236} 234}
237void MainWindow::closeEvent( QCloseEvent* ce ) 235void MainWindow::closeEvent( QCloseEvent* ce )
238{ 236{
239 237
240 238
241 239
242 if ( ! KOPrefs::instance()->mAskForQuit ) { 240 if ( ! KOPrefs::instance()->mAskForQuit ) {
243 saveOnClose(); 241 saveOnClose();
244 mClosed = true; 242 mClosed = true;
245 ce->accept(); 243 ce->accept();
246 return; 244 return;
247 245
248 } 246 }
249 247
250 switch( QMessageBox::information( this, "KO/Pi", 248 switch( QMessageBox::information( this, "KO/Pi",
251 i18n("Do you really want\nto close KO/Pi?"), 249 i18n("Do you really want\nto close KO/Pi?"),
252 i18n("Close"), i18n("No"), 250 i18n("Close"), i18n("No"),
253 0, 0 ) ) { 251 0, 0 ) ) {
254 case 0: 252 case 0:
255 saveOnClose(); 253 saveOnClose();
256 mClosed = true; 254 mClosed = true;
257 ce->accept(); 255 ce->accept();
258 break; 256 break;
259 case 1: 257 case 1:
260 ce->ignore(); 258 ce->ignore();
261 break; 259 break;
262 case 2: 260 case 2:
263 261
264 default: 262 default:
265 break; 263 break;
266 } 264 }
267 265
268 266
269} 267}
270 268