-rw-r--r-- | korganizer/calendarview.cpp | 11 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 29 | ||||
-rw-r--r-- | korganizer/koeventviewer.h | 1 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 14 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 7 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 16 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 15 |
10 files changed, 86 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a330414..0015bd6 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4104 +1,4113 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | class KOBeamPrefs : public QDialog | 142 | class KOBeamPrefs : public QDialog |
143 | { | 143 | { |
144 | public: | 144 | public: |
145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
146 | QDialog( parent, name, true ) | 146 | QDialog( parent, name, true ) |
147 | { | 147 | { |
148 | setCaption( i18n("Beam Options") ); | 148 | setCaption( i18n("Beam Options") ); |
149 | QVBoxLayout* lay = new QVBoxLayout( this ); | 149 | QVBoxLayout* lay = new QVBoxLayout( this ); |
150 | lay->setSpacing( 3 ); | 150 | lay->setSpacing( 3 ); |
151 | lay->setMargin( 3 ); | 151 | lay->setMargin( 3 ); |
152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
153 | lay->addWidget( format ); | 153 | lay->addWidget( format ); |
154 | format->setExclusive ( true ) ; | 154 | format->setExclusive ( true ) ; |
155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
156 | lay->addWidget( time ); time->setExclusive ( true ) ; | 156 | lay->addWidget( time ); time->setExclusive ( true ) ; |
157 | vcal = new QRadioButton(" vCalendar ", format ); | 157 | vcal = new QRadioButton(" vCalendar ", format ); |
158 | ical = new QRadioButton(" iCalendar ", format ); | 158 | ical = new QRadioButton(" iCalendar ", format ); |
159 | vcal->setChecked( true ); | 159 | vcal->setChecked( true ); |
160 | tz = new QRadioButton(i18n(" With timezone "), time ); | 160 | tz = new QRadioButton(i18n(" With timezone "), time ); |
161 | local = new QRadioButton(i18n(" Local time "), time ); | 161 | local = new QRadioButton(i18n(" Local time "), time ); |
162 | tz->setChecked( true ); | 162 | tz->setChecked( true ); |
163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
164 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
166 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
169 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
173 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
174 | private: | 174 | private: |
175 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
176 | }; | 176 | }; |
177 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
178 | { | 178 | { |
179 | public: | 179 | public: |
180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
181 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
182 | { | 182 | { |
183 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
184 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
185 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
186 | lay->setMargin( 3 ); | 186 | lay->setMargin( 3 ); |
187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
188 | lay->addWidget( lab ); | 188 | lay->addWidget( lab ); |
189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
190 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
191 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
194 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
196 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
198 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
201 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
205 | private: | 205 | private: |
206 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
212 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
213 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
214 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
215 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
216 | { | 216 | { |
217 | 217 | ||
218 | mEventEditor = 0; | 218 | mEventEditor = 0; |
219 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
220 | 220 | ||
221 | init(); | 221 | init(); |
222 | } | 222 | } |
223 | 223 | ||
224 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
225 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
226 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
227 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
228 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
229 | { | 229 | { |
230 | 230 | ||
231 | mEventEditor = 0; | 231 | mEventEditor = 0; |
232 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
233 | init(); | 233 | init(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void CalendarView::init() | 236 | void CalendarView::init() |
237 | { | 237 | { |
238 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 238 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
239 | setFocusPolicy ( WheelFocus ); | 239 | setFocusPolicy ( WheelFocus ); |
240 | mViewerCallerIsSearchDialog = false; | 240 | mViewerCallerIsSearchDialog = false; |
241 | mBlockShowDates = false; | 241 | mBlockShowDates = false; |
242 | beamDialog = new KOBeamPrefs(); | 242 | beamDialog = new KOBeamPrefs(); |
243 | mDatePickerMode = 0; | 243 | mDatePickerMode = 0; |
244 | mCurrentSyncDevice = ""; | 244 | mCurrentSyncDevice = ""; |
245 | writeLocale(); | 245 | writeLocale(); |
246 | mViewManager = new KOViewManager( this ); | 246 | mViewManager = new KOViewManager( this ); |
247 | mDialogManager = new KODialogManager( this ); | 247 | mDialogManager = new KODialogManager( this ); |
248 | mEventViewerDialog = 0; | 248 | mEventViewerDialog = 0; |
249 | mModified = false; | 249 | mModified = false; |
250 | mReadOnly = false; | 250 | mReadOnly = false; |
251 | mSelectedIncidence = 0; | 251 | mSelectedIncidence = 0; |
252 | mCalPrinter = 0; | 252 | mCalPrinter = 0; |
253 | mFilters.setAutoDelete(true); | 253 | mFilters.setAutoDelete(true); |
254 | 254 | ||
255 | mCalendar->registerObserver( this ); | 255 | mCalendar->registerObserver( this ); |
256 | // TODO: Make sure that view is updated, when calendar is changed. | 256 | // TODO: Make sure that view is updated, when calendar is changed. |
257 | 257 | ||
258 | mStorage = new FileStorage( mCalendar ); | 258 | mStorage = new FileStorage( mCalendar ); |
259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
260 | 260 | ||
261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
262 | #ifndef KORG_NOSPLITTER | 262 | #ifndef KORG_NOSPLITTER |
263 | // create the main layout frames. | 263 | // create the main layout frames. |
264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
265 | topLayout->addWidget(mPanner); | 265 | topLayout->addWidget(mPanner); |
266 | 266 | ||
267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
268 | "CalendarView::LeftFrame"); | 268 | "CalendarView::LeftFrame"); |
269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
270 | 270 | ||
271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
272 | "CalendarView::DateNavigator" ); | 272 | "CalendarView::DateNavigator" ); |
273 | 273 | ||
274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
276 | mTodoList->setNavigator( mNavigator ); | 276 | mTodoList->setNavigator( mNavigator ); |
277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
278 | 278 | ||
279 | #ifdef KORG_NORESOURCEVIEW | 279 | #ifdef KORG_NORESOURCEVIEW |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | #else | 281 | #else |
282 | if ( mResourceManager ) { | 282 | if ( mResourceManager ) { |
283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
284 | mResourceView->updateView(); | 284 | mResourceView->updateView(); |
285 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 285 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
286 | SLOT( updateView() ) ); | 286 | SLOT( updateView() ) ); |
287 | } else { | 287 | } else { |
288 | mResourceView = 0; | 288 | mResourceView = 0; |
289 | } | 289 | } |
290 | #endif | 290 | #endif |
291 | QWidget *rightBox = new QWidget( mPanner ); | 291 | QWidget *rightBox = new QWidget( mPanner ); |
292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
293 | 293 | ||
294 | mRightFrame = new QWidgetStack( rightBox ); | 294 | mRightFrame = new QWidgetStack( rightBox ); |
295 | rightLayout->addWidget( mRightFrame, 1 ); | 295 | rightLayout->addWidget( mRightFrame, 1 ); |
296 | 296 | ||
297 | mLeftFrame = mLeftSplitter; | 297 | mLeftFrame = mLeftSplitter; |
298 | #else | 298 | #else |
299 | //QWidget *mainBox = new QWidget( this ); | 299 | //QWidget *mainBox = new QWidget( this ); |
300 | //QWidget *leftFrame = new QWidget( mainBox ); | 300 | //QWidget *leftFrame = new QWidget( mainBox ); |
301 | //QBoxLayout * mainBoxLayout; | 301 | //QBoxLayout * mainBoxLayout; |
302 | if ( KOPrefs::instance()->mVerticalScreen ) { | 302 | if ( KOPrefs::instance()->mVerticalScreen ) { |
303 | //mainBoxLayout = new QVBoxLayout(mainBox); | 303 | //mainBoxLayout = new QVBoxLayout(mainBox); |
304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
305 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 305 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
306 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 306 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
307 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 307 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
308 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 308 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
309 | } else { | 309 | } else { |
310 | //mainBoxLayout = new QHBoxLayout(mainBox); | 310 | //mainBoxLayout = new QHBoxLayout(mainBox); |
311 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 311 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
312 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 312 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
313 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 313 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
314 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 314 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
315 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 315 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
316 | } | 316 | } |
317 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 317 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
318 | //QBoxLayout * leftFrameLayout; | 318 | //QBoxLayout * leftFrameLayout; |
319 | topLayout->addWidget( mMainFrame ); | 319 | topLayout->addWidget( mMainFrame ); |
320 | //mainBoxLayout->addWidget (mLeftFrame); | 320 | //mainBoxLayout->addWidget (mLeftFrame); |
321 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 321 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
322 | "CalendarView::DateNavigator" ); | 322 | "CalendarView::DateNavigator" ); |
323 | #if 0 | 323 | #if 0 |
324 | // FIXME | 324 | // FIXME |
325 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 325 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
326 | "CalendarView::DateNavigator", QDate::currentDate()); | 326 | "CalendarView::DateNavigator", QDate::currentDate()); |
327 | #endif | 327 | #endif |
328 | // mDateNavigator->blockSignals( true ); | 328 | // mDateNavigator->blockSignals( true ); |
329 | //leftFrameLayout->addWidget( mDateNavigator ); | 329 | //leftFrameLayout->addWidget( mDateNavigator ); |
330 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 330 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
331 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 331 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
332 | mTodoList->setNavigator( mNavigator ); | 332 | mTodoList->setNavigator( mNavigator ); |
333 | #if 0 | 333 | #if 0 |
334 | if ( QApplication::desktop()->width() < 480 ) { | 334 | if ( QApplication::desktop()->width() < 480 ) { |
335 | leftFrameLayout->addWidget(mFilterView); | 335 | leftFrameLayout->addWidget(mFilterView); |
336 | leftFrameLayout->addWidget(mTodoList, 2 ); | 336 | leftFrameLayout->addWidget(mTodoList, 2 ); |
337 | 337 | ||
338 | } else { | 338 | } else { |
339 | leftFrameLayout->addWidget(mTodoList,2 ); | 339 | leftFrameLayout->addWidget(mTodoList,2 ); |
340 | leftFrameLayout->addWidget(mFilterView ); | 340 | leftFrameLayout->addWidget(mFilterView ); |
341 | } | 341 | } |
342 | #endif | 342 | #endif |
343 | mFilterView->hide(); | 343 | mFilterView->hide(); |
344 | QWidget *rightBox = new QWidget( mMainFrame ); | 344 | QWidget *rightBox = new QWidget( mMainFrame ); |
345 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 345 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
346 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 346 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
347 | mRightFrame = new QWidgetStack( rightBox ); | 347 | mRightFrame = new QWidgetStack( rightBox ); |
348 | rightLayout->addWidget( mRightFrame, 10 ); | 348 | rightLayout->addWidget( mRightFrame, 10 ); |
349 | 349 | ||
350 | //mLeftFrame = (QWidget *)leftFrame; | 350 | //mLeftFrame = (QWidget *)leftFrame; |
351 | if ( KOPrefs::instance()->mVerticalScreen ) { | 351 | if ( KOPrefs::instance()->mVerticalScreen ) { |
352 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 352 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
353 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 353 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
354 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 354 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
355 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 355 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
356 | } else { | 356 | } else { |
357 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 357 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
358 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 358 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
359 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 359 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
360 | } | 360 | } |
361 | if ( !KOPrefs::instance()->mShowDateNavigator) | 361 | if ( !KOPrefs::instance()->mShowDateNavigator) |
362 | mDateNavigator->hide(); | 362 | mDateNavigator->hide(); |
363 | //qDebug("Calendarview Size %d %d ", width(), height()); | 363 | //qDebug("Calendarview Size %d %d ", width(), height()); |
364 | #endif | 364 | #endif |
365 | 365 | ||
366 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 366 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
367 | SLOT( showDates( const KCal::DateList & ) ) ); | 367 | SLOT( showDates( const KCal::DateList & ) ) ); |
368 | 368 | ||
369 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 369 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
370 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 370 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
371 | 371 | ||
372 | 372 | ||
373 | 373 | ||
374 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 374 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
375 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 375 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
376 | 376 | ||
377 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 377 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
378 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 378 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
379 | 379 | ||
380 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 380 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
381 | mNavigator, SLOT( selectPreviousYear() ) ); | 381 | mNavigator, SLOT( selectPreviousYear() ) ); |
382 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 382 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
383 | mNavigator, SLOT( selectNextYear() ) ); | 383 | mNavigator, SLOT( selectNextYear() ) ); |
384 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 384 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
385 | mNavigator, SLOT( selectPreviousMonth() ) ); | 385 | mNavigator, SLOT( selectPreviousMonth() ) ); |
386 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 386 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
387 | mNavigator, SLOT( selectNextMonth() ) ); | 387 | mNavigator, SLOT( selectNextMonth() ) ); |
388 | 388 | ||
389 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 389 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
390 | mNavigator, SLOT( selectPrevious() ) ); | 390 | mNavigator, SLOT( selectPrevious() ) ); |
391 | connect( mDateNavigator, SIGNAL( goNext() ), | 391 | connect( mDateNavigator, SIGNAL( goNext() ), |
392 | mNavigator, SLOT( selectNext() ) ); | 392 | mNavigator, SLOT( selectNext() ) ); |
393 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 393 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
394 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 394 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
395 | 395 | ||
396 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 396 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
397 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 397 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
398 | #if 0 | 398 | #if 0 |
399 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 399 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
400 | SLOT( incidenceAdded( Incidence *) ) ); | 400 | SLOT( incidenceAdded( Incidence *) ) ); |
401 | #endif | 401 | #endif |
402 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 402 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
403 | 403 | ||
404 | connect( this, SIGNAL( configChanged() ), | 404 | connect( this, SIGNAL( configChanged() ), |
405 | mDateNavigator, SLOT( updateConfig() ) ); | 405 | mDateNavigator, SLOT( updateConfig() ) ); |
406 | 406 | ||
407 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 407 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
408 | SLOT( newTodo() ) ); | 408 | SLOT( newTodo() ) ); |
409 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 409 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
410 | SLOT( newSubTodo( Todo * ) ) ); | 410 | SLOT( newSubTodo( Todo * ) ) ); |
411 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 411 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
412 | SLOT( editTodo( Todo * ) ) ); | 412 | SLOT( editTodo( Todo * ) ) ); |
413 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 413 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
414 | SLOT( showTodo( Todo *) ) ); | 414 | SLOT( showTodo( Todo *) ) ); |
415 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 415 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
416 | SLOT( deleteTodo( Todo *) ) ); | 416 | SLOT( deleteTodo( Todo *) ) ); |
417 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 417 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
418 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 418 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
419 | SLOT( purgeCompleted() ) ); | 419 | SLOT( purgeCompleted() ) ); |
420 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 420 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
421 | SIGNAL( todoModified( Todo *, int ) ) ); | 421 | SIGNAL( todoModified( Todo *, int ) ) ); |
422 | 422 | ||
423 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 423 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
424 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 424 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
425 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 425 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
426 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 426 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
427 | 427 | ||
428 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 428 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
429 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 429 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
430 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 430 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
431 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 431 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
432 | 432 | ||
433 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 433 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
434 | this, SLOT ( todo_unsub( Todo * ) ) ); | 434 | this, SLOT ( todo_unsub( Todo * ) ) ); |
435 | 435 | ||
436 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 436 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
437 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 437 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
438 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 438 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
439 | SLOT( updateTodo( Todo *, int ) ) ); | 439 | SLOT( updateTodo( Todo *, int ) ) ); |
440 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 440 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
441 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 441 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
442 | 442 | ||
443 | 443 | ||
444 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 444 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
445 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 445 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
446 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 446 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
447 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 447 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
448 | 448 | ||
449 | 449 | ||
450 | 450 | ||
451 | 451 | ||
452 | 452 | ||
453 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 453 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
454 | SLOT(checkClipboard())); | 454 | SLOT(checkClipboard())); |
455 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 455 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
456 | SLOT( processTodoListSelection( Incidence * ) ) ); | 456 | SLOT( processTodoListSelection( Incidence * ) ) ); |
457 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 457 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
458 | 458 | ||
459 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 459 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
460 | 460 | ||
461 | mDateFrame = new QVBox(0,0,WType_Popup); | 461 | mDateFrame = new QVBox(0,0,WType_Popup); |
462 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 462 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
463 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 463 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
464 | mDateFrame->setLineWidth(3); | 464 | mDateFrame->setLineWidth(3); |
465 | mDateFrame->hide(); | 465 | mDateFrame->hide(); |
466 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 466 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
467 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 467 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
468 | 468 | ||
469 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 469 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
470 | 470 | ||
471 | mEventEditor = mDialogManager->getEventEditor(); | 471 | mEventEditor = mDialogManager->getEventEditor(); |
472 | mTodoEditor = mDialogManager->getTodoEditor(); | 472 | mTodoEditor = mDialogManager->getTodoEditor(); |
473 | 473 | ||
474 | mFlagEditDescription = false; | 474 | mFlagEditDescription = false; |
475 | 475 | ||
476 | mSuspendTimer = new QTimer( this ); | 476 | mSuspendTimer = new QTimer( this ); |
477 | mAlarmTimer = new QTimer( this ); | 477 | mAlarmTimer = new QTimer( this ); |
478 | mRecheckAlarmTimer = new QTimer( this ); | 478 | mRecheckAlarmTimer = new QTimer( this ); |
479 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 479 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
480 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 480 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
481 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 481 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
482 | mAlarmDialog = new AlarmDialog( this ); | 482 | mAlarmDialog = new AlarmDialog( this ); |
483 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 483 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
484 | mAlarmDialog->setServerNotification( false ); | 484 | mAlarmDialog->setServerNotification( false ); |
485 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 485 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
486 | 486 | ||
487 | 487 | ||
488 | #ifndef DESKTOP_VERSION | 488 | #ifndef DESKTOP_VERSION |
489 | //US listen for arriving address resultsets | 489 | //US listen for arriving address resultsets |
490 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 490 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
491 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 491 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
492 | #endif | 492 | #endif |
493 | mDateNavigator->setCalendar( mCalendar ); | 493 | mDateNavigator->setCalendar( mCalendar ); |
494 | } | 494 | } |
495 | 495 | ||
496 | 496 | ||
497 | CalendarView::~CalendarView() | 497 | CalendarView::~CalendarView() |
498 | { | 498 | { |
499 | // kdDebug() << "~CalendarView()" << endl; | 499 | // kdDebug() << "~CalendarView()" << endl; |
500 | //qDebug("CalendarView::~CalendarView() "); | 500 | //qDebug("CalendarView::~CalendarView() "); |
501 | delete mDialogManager; | 501 | delete mDialogManager; |
502 | delete mViewManager; | 502 | delete mViewManager; |
503 | delete mStorage; | 503 | delete mStorage; |
504 | delete mDateFrame ; | 504 | delete mDateFrame ; |
505 | delete beamDialog; | 505 | delete beamDialog; |
506 | delete mEventViewerDialog; | 506 | delete mEventViewerDialog; |
507 | //kdDebug() << "~CalendarView() done" << endl; | 507 | //kdDebug() << "~CalendarView() done" << endl; |
508 | } | 508 | } |
509 | 509 | ||
510 | void CalendarView::showDay( QDate d ) | 510 | void CalendarView::showDay( QDate d ) |
511 | { | 511 | { |
512 | dateNavigator()->blockSignals( true ); | 512 | dateNavigator()->blockSignals( true ); |
513 | dateNavigator()->selectDate( d ); | 513 | dateNavigator()->selectDate( d ); |
514 | dateNavigator()->blockSignals( false ); | 514 | dateNavigator()->blockSignals( false ); |
515 | mViewManager->showDayView(); | 515 | mViewManager->showDayView(); |
516 | //dateNavigator()->selectDate( d ); | 516 | //dateNavigator()->selectDate( d ); |
517 | } | 517 | } |
518 | void CalendarView::timerAlarm() | 518 | void CalendarView::timerAlarm() |
519 | { | 519 | { |
520 | //qDebug("CalendarView::timerAlarm() "); | 520 | //qDebug("CalendarView::timerAlarm() "); |
521 | computeAlarm(mAlarmNotification ); | 521 | computeAlarm(mAlarmNotification ); |
522 | } | 522 | } |
523 | 523 | ||
524 | void CalendarView::suspendAlarm() | 524 | void CalendarView::suspendAlarm() |
525 | { | 525 | { |
526 | //qDebug(" CalendarView::suspendAlarm() "); | 526 | //qDebug(" CalendarView::suspendAlarm() "); |
527 | computeAlarm(mSuspendAlarmNotification ); | 527 | computeAlarm(mSuspendAlarmNotification ); |
528 | 528 | ||
529 | } | 529 | } |
530 | 530 | ||
531 | void CalendarView::startAlarm( QString mess , QString filename) | 531 | void CalendarView::startAlarm( QString mess , QString filename) |
532 | { | 532 | { |
533 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 533 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
534 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 534 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
535 | 535 | ||
536 | } | 536 | } |
537 | 537 | ||
538 | void CalendarView::checkNextTimerAlarm() | 538 | void CalendarView::checkNextTimerAlarm() |
539 | { | 539 | { |
540 | mCalendar->checkAlarmForIncidence( 0, true ); | 540 | mCalendar->checkAlarmForIncidence( 0, true ); |
541 | } | 541 | } |
542 | 542 | ||
543 | void CalendarView::computeAlarm( QString msg ) | 543 | void CalendarView::computeAlarm( QString msg ) |
544 | { | 544 | { |
545 | 545 | ||
546 | QString mess = msg; | 546 | QString mess = msg; |
547 | QString mAlarmMessage = mess.mid( 9 ); | 547 | QString mAlarmMessage = mess.mid( 9 ); |
548 | QString filename = MainWindow::resourcePath(); | 548 | QString filename = MainWindow::resourcePath(); |
549 | filename += "koalarm.wav"; | 549 | filename += "koalarm.wav"; |
550 | QString tempfilename; | 550 | QString tempfilename; |
551 | if ( mess.left( 13 ) == "suspend_alarm") { | 551 | if ( mess.left( 13 ) == "suspend_alarm") { |
552 | bool error = false; | 552 | bool error = false; |
553 | int len = mess.mid( 13 ).find("+++"); | 553 | int len = mess.mid( 13 ).find("+++"); |
554 | if ( len < 2 ) | 554 | if ( len < 2 ) |
555 | error = true; | 555 | error = true; |
556 | else { | 556 | else { |
557 | tempfilename = mess.mid( 13, len ); | 557 | tempfilename = mess.mid( 13, len ); |
558 | if ( !QFile::exists( tempfilename ) ) | 558 | if ( !QFile::exists( tempfilename ) ) |
559 | error = true; | 559 | error = true; |
560 | } | 560 | } |
561 | if ( ! error ) { | 561 | if ( ! error ) { |
562 | filename = tempfilename; | 562 | filename = tempfilename; |
563 | } | 563 | } |
564 | mAlarmMessage = mess.mid( 13+len+3 ); | 564 | mAlarmMessage = mess.mid( 13+len+3 ); |
565 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 565 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
566 | startAlarm( mAlarmMessage, filename); | 566 | startAlarm( mAlarmMessage, filename); |
567 | return; | 567 | return; |
568 | } | 568 | } |
569 | if ( mess.left( 11 ) == "timer_alarm") { | 569 | if ( mess.left( 11 ) == "timer_alarm") { |
570 | //mTimerTime = 0; | 570 | //mTimerTime = 0; |
571 | startAlarm( mess.mid( 11 ), filename ); | 571 | startAlarm( mess.mid( 11 ), filename ); |
572 | return; | 572 | return; |
573 | } | 573 | } |
574 | if ( mess.left( 10 ) == "proc_alarm") { | 574 | if ( mess.left( 10 ) == "proc_alarm") { |
575 | bool error = false; | 575 | bool error = false; |
576 | int len = mess.mid( 10 ).find("+++"); | 576 | int len = mess.mid( 10 ).find("+++"); |
577 | if ( len < 2 ) | 577 | if ( len < 2 ) |
578 | error = true; | 578 | error = true; |
579 | else { | 579 | else { |
580 | tempfilename = mess.mid( 10, len ); | 580 | tempfilename = mess.mid( 10, len ); |
581 | if ( !QFile::exists( tempfilename ) ) | 581 | if ( !QFile::exists( tempfilename ) ) |
582 | error = true; | 582 | error = true; |
583 | } | 583 | } |
584 | if ( error ) { | 584 | if ( error ) { |
585 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 585 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
586 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 586 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
587 | } else { | 587 | } else { |
588 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 588 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
589 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 589 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
590 | #ifndef _WIN32_ | 590 | #ifndef _WIN32_ |
591 | if ( vfork () == 0 ) { | 591 | if ( vfork () == 0 ) { |
592 | execl ( tempfilename.latin1(), 0 ); | 592 | execl ( tempfilename.latin1(), 0 ); |
593 | return; | 593 | return; |
594 | } | 594 | } |
595 | #else | 595 | #else |
596 | QProcess* p = new QProcess(); | 596 | QProcess* p = new QProcess(); |
597 | p->addArgument( tempfilename.latin1() ); | 597 | p->addArgument( tempfilename.latin1() ); |
598 | p->start(); | 598 | p->start(); |
599 | return; | 599 | return; |
600 | #endif | 600 | #endif |
601 | 601 | ||
602 | return; | 602 | return; |
603 | } | 603 | } |
604 | 604 | ||
605 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 605 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
606 | } | 606 | } |
607 | if ( mess.left( 11 ) == "audio_alarm") { | 607 | if ( mess.left( 11 ) == "audio_alarm") { |
608 | bool error = false; | 608 | bool error = false; |
609 | int len = mess.mid( 11 ).find("+++"); | 609 | int len = mess.mid( 11 ).find("+++"); |
610 | if ( len < 2 ) | 610 | if ( len < 2 ) |
611 | error = true; | 611 | error = true; |
612 | else { | 612 | else { |
613 | tempfilename = mess.mid( 11, len ); | 613 | tempfilename = mess.mid( 11, len ); |
614 | if ( !QFile::exists( tempfilename ) ) | 614 | if ( !QFile::exists( tempfilename ) ) |
615 | error = true; | 615 | error = true; |
616 | } | 616 | } |
617 | if ( ! error ) { | 617 | if ( ! error ) { |
618 | filename = tempfilename; | 618 | filename = tempfilename; |
619 | } | 619 | } |
620 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 620 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
621 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 621 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
622 | } | 622 | } |
623 | if ( mess.left( 9 ) == "cal_alarm") { | 623 | if ( mess.left( 9 ) == "cal_alarm") { |
624 | mAlarmMessage = mess.mid( 9 ) ; | 624 | mAlarmMessage = mess.mid( 9 ) ; |
625 | } | 625 | } |
626 | 626 | ||
627 | startAlarm( mAlarmMessage, filename ); | 627 | startAlarm( mAlarmMessage, filename ); |
628 | 628 | ||
629 | 629 | ||
630 | } | 630 | } |
631 | 631 | ||
632 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 632 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
633 | { | 633 | { |
634 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 634 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
635 | 635 | ||
636 | mSuspendAlarmNotification = noti; | 636 | mSuspendAlarmNotification = noti; |
637 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 637 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
638 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 638 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
639 | mSuspendTimer->start( ms , true ); | 639 | mSuspendTimer->start( ms , true ); |
640 | 640 | ||
641 | } | 641 | } |
642 | 642 | ||
643 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 643 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
644 | { | 644 | { |
645 | mNextAlarmDateTime = qdt; | 645 | mNextAlarmDateTime = qdt; |
646 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 646 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
647 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 647 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
648 | #ifndef DESKTOP_VERSION | 648 | #ifndef DESKTOP_VERSION |
649 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 649 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
650 | #endif | 650 | #endif |
651 | return; | 651 | return; |
652 | } | 652 | } |
653 | int maxSec; | 653 | int maxSec; |
654 | //maxSec = 5; //testing only | 654 | //maxSec = 5; //testing only |
655 | maxSec = 86400+3600; // one day+1hour | 655 | maxSec = 86400+3600; // one day+1hour |
656 | mAlarmNotification = noti; | 656 | mAlarmNotification = noti; |
657 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 657 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
658 | if ( sec > maxSec ) { | 658 | if ( sec > maxSec ) { |
659 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 659 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
660 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 660 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
661 | return; | 661 | return; |
662 | } else { | 662 | } else { |
663 | mRecheckAlarmTimer->stop(); | 663 | mRecheckAlarmTimer->stop(); |
664 | } | 664 | } |
665 | //qDebug("Alarm timer started with secs: %d ", sec); | 665 | //qDebug("Alarm timer started with secs: %d ", sec); |
666 | mAlarmTimer->start( sec *1000 , true ); | 666 | mAlarmTimer->start( sec *1000 , true ); |
667 | 667 | ||
668 | } | 668 | } |
669 | // called by mRecheckAlarmTimer to get next alarm | 669 | // called by mRecheckAlarmTimer to get next alarm |
670 | // we need this, because a QTimer has only a max range of 25 days | 670 | // we need this, because a QTimer has only a max range of 25 days |
671 | void CalendarView::recheckTimerAlarm() | 671 | void CalendarView::recheckTimerAlarm() |
672 | { | 672 | { |
673 | mAlarmTimer->stop(); | 673 | mAlarmTimer->stop(); |
674 | mRecheckAlarmTimer->stop(); | 674 | mRecheckAlarmTimer->stop(); |
675 | mCalendar->checkAlarmForIncidence( 0, true ); | 675 | mCalendar->checkAlarmForIncidence( 0, true ); |
676 | } | 676 | } |
677 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 677 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
678 | { | 678 | { |
679 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 679 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
680 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 680 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
681 | #ifndef DESKTOP_VERSION | 681 | #ifndef DESKTOP_VERSION |
682 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 682 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
683 | #endif | 683 | #endif |
684 | return; | 684 | return; |
685 | } | 685 | } |
686 | mAlarmTimer->stop(); | 686 | mAlarmTimer->stop(); |
687 | } | 687 | } |
688 | void CalendarView::selectWeekNum ( int num ) | 688 | void CalendarView::selectWeekNum ( int num ) |
689 | { | 689 | { |
690 | dateNavigator()->blockSignals( true ); | 690 | dateNavigator()->blockSignals( true ); |
691 | dateNavigator()->selectWeek( num ); | 691 | dateNavigator()->selectWeek( num ); |
692 | dateNavigator()->blockSignals( false ); | 692 | dateNavigator()->blockSignals( false ); |
693 | mViewManager->showWeekView(); | 693 | mViewManager->showWeekView(); |
694 | } | 694 | } |
695 | KOViewManager *CalendarView::viewManager() | 695 | KOViewManager *CalendarView::viewManager() |
696 | { | 696 | { |
697 | return mViewManager; | 697 | return mViewManager; |
698 | } | 698 | } |
699 | 699 | ||
700 | KODialogManager *CalendarView::dialogManager() | 700 | KODialogManager *CalendarView::dialogManager() |
701 | { | 701 | { |
702 | return mDialogManager; | 702 | return mDialogManager; |
703 | } | 703 | } |
704 | 704 | ||
705 | QDate CalendarView::startDate() | 705 | QDate CalendarView::startDate() |
706 | { | 706 | { |
707 | DateList dates = mNavigator->selectedDates(); | 707 | DateList dates = mNavigator->selectedDates(); |
708 | 708 | ||
709 | return dates.first(); | 709 | return dates.first(); |
710 | } | 710 | } |
711 | 711 | ||
712 | QDate CalendarView::endDate() | 712 | QDate CalendarView::endDate() |
713 | { | 713 | { |
714 | DateList dates = mNavigator->selectedDates(); | 714 | DateList dates = mNavigator->selectedDates(); |
715 | 715 | ||
716 | return dates.last(); | 716 | return dates.last(); |
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | void CalendarView::createPrinter() | 720 | void CalendarView::createPrinter() |
721 | { | 721 | { |
722 | #ifndef KORG_NOPRINTER | 722 | #ifndef KORG_NOPRINTER |
723 | if (!mCalPrinter) { | 723 | if (!mCalPrinter) { |
724 | mCalPrinter = new CalPrinter(this, mCalendar); | 724 | mCalPrinter = new CalPrinter(this, mCalendar); |
725 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 725 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
726 | } | 726 | } |
727 | #endif | 727 | #endif |
728 | } | 728 | } |
729 | 729 | ||
730 | 730 | ||
731 | //KOPrefs::instance()->mWriteBackFile | 731 | //KOPrefs::instance()->mWriteBackFile |
732 | //KOPrefs::instance()->mWriteBackExistingOnly | 732 | //KOPrefs::instance()->mWriteBackExistingOnly |
733 | 733 | ||
734 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 734 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
735 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 735 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
736 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 736 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
737 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 737 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
738 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 738 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
739 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 739 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
740 | 740 | ||
741 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 741 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
742 | { | 742 | { |
743 | 743 | ||
744 | // 0 equal | 744 | // 0 equal |
745 | // 1 take local | 745 | // 1 take local |
746 | // 2 take remote | 746 | // 2 take remote |
747 | // 3 cancel | 747 | // 3 cancel |
748 | QDateTime lastSync = mLastCalendarSync; | 748 | QDateTime lastSync = mLastCalendarSync; |
749 | QDateTime localMod = local->lastModified(); | 749 | QDateTime localMod = local->lastModified(); |
750 | QDateTime remoteMod = remote->lastModified(); | 750 | QDateTime remoteMod = remote->lastModified(); |
751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
752 | bool remCh, locCh; | 752 | bool remCh, locCh; |
753 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 753 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
754 | //if ( remCh ) | 754 | //if ( remCh ) |
755 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 755 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
756 | locCh = ( localMod > mLastCalendarSync ); | 756 | locCh = ( localMod > mLastCalendarSync ); |
757 | if ( !remCh && ! locCh ) { | 757 | if ( !remCh && ! locCh ) { |
758 | //qDebug("both not changed "); | 758 | //qDebug("both not changed "); |
759 | lastSync = localMod.addDays(1); | 759 | lastSync = localMod.addDays(1); |
760 | if ( mode <= SYNC_PREF_ASK ) | 760 | if ( mode <= SYNC_PREF_ASK ) |
761 | return 0; | 761 | return 0; |
762 | } else { | 762 | } else { |
763 | if ( locCh ) { | 763 | if ( locCh ) { |
764 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 764 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
765 | lastSync = localMod.addDays( -1 ); | 765 | lastSync = localMod.addDays( -1 ); |
766 | if ( !remCh ) | 766 | if ( !remCh ) |
767 | remoteMod = ( lastSync.addDays( -1 ) ); | 767 | remoteMod = ( lastSync.addDays( -1 ) ); |
768 | } else { | 768 | } else { |
769 | //qDebug(" not loc changed "); | 769 | //qDebug(" not loc changed "); |
770 | lastSync = localMod.addDays( 1 ); | 770 | lastSync = localMod.addDays( 1 ); |
771 | if ( remCh ) | 771 | if ( remCh ) |
772 | remoteMod =( lastSync.addDays( 1 ) ); | 772 | remoteMod =( lastSync.addDays( 1 ) ); |
773 | 773 | ||
774 | } | 774 | } |
775 | } | 775 | } |
776 | full = true; | 776 | full = true; |
777 | if ( mode < SYNC_PREF_ASK ) | 777 | if ( mode < SYNC_PREF_ASK ) |
778 | mode = SYNC_PREF_ASK; | 778 | mode = SYNC_PREF_ASK; |
779 | } else { | 779 | } else { |
780 | if ( localMod == remoteMod ) | 780 | if ( localMod == remoteMod ) |
781 | // if ( local->revision() == remote->revision() ) | 781 | // if ( local->revision() == remote->revision() ) |
782 | return 0; | 782 | return 0; |
783 | 783 | ||
784 | } | 784 | } |
785 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 785 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
786 | 786 | ||
787 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 787 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
788 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 788 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
789 | //full = true; //debug only | 789 | //full = true; //debug only |
790 | if ( full ) { | 790 | if ( full ) { |
791 | bool equ = false; | 791 | bool equ = false; |
792 | if ( local->type() == "Event" ) { | 792 | if ( local->type() == "Event" ) { |
793 | equ = (*((Event*) local) == *((Event*) remote)); | 793 | equ = (*((Event*) local) == *((Event*) remote)); |
794 | } | 794 | } |
795 | else if ( local->type() =="Todo" ) | 795 | else if ( local->type() =="Todo" ) |
796 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 796 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
797 | else if ( local->type() =="Journal" ) | 797 | else if ( local->type() =="Journal" ) |
798 | equ = (*((Journal*) local) == *((Journal*) remote)); | 798 | equ = (*((Journal*) local) == *((Journal*) remote)); |
799 | if ( equ ) { | 799 | if ( equ ) { |
800 | //qDebug("equal "); | 800 | //qDebug("equal "); |
801 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 801 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
802 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 802 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
803 | } | 803 | } |
804 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 804 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
805 | return 0; | 805 | return 0; |
806 | 806 | ||
807 | }//else //debug only | 807 | }//else //debug only |
808 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 808 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
809 | } | 809 | } |
810 | int result; | 810 | int result; |
811 | bool localIsNew; | 811 | bool localIsNew; |
812 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 812 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
813 | 813 | ||
814 | if ( full && mode < SYNC_PREF_NEWEST ) | 814 | if ( full && mode < SYNC_PREF_NEWEST ) |
815 | mode = SYNC_PREF_ASK; | 815 | mode = SYNC_PREF_ASK; |
816 | 816 | ||
817 | switch( mode ) { | 817 | switch( mode ) { |
818 | case SYNC_PREF_LOCAL: | 818 | case SYNC_PREF_LOCAL: |
819 | if ( lastSync > remoteMod ) | 819 | if ( lastSync > remoteMod ) |
820 | return 1; | 820 | return 1; |
821 | if ( lastSync > localMod ) | 821 | if ( lastSync > localMod ) |
822 | return 2; | 822 | return 2; |
823 | return 1; | 823 | return 1; |
824 | break; | 824 | break; |
825 | case SYNC_PREF_REMOTE: | 825 | case SYNC_PREF_REMOTE: |
826 | if ( lastSync > remoteMod ) | 826 | if ( lastSync > remoteMod ) |
827 | return 1; | 827 | return 1; |
828 | if ( lastSync > localMod ) | 828 | if ( lastSync > localMod ) |
829 | return 2; | 829 | return 2; |
830 | return 2; | 830 | return 2; |
831 | break; | 831 | break; |
832 | case SYNC_PREF_NEWEST: | 832 | case SYNC_PREF_NEWEST: |
833 | if ( localMod > remoteMod ) | 833 | if ( localMod > remoteMod ) |
834 | return 1; | 834 | return 1; |
835 | else | 835 | else |
836 | return 2; | 836 | return 2; |
837 | break; | 837 | break; |
838 | case SYNC_PREF_ASK: | 838 | case SYNC_PREF_ASK: |
839 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 839 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
840 | if ( lastSync > remoteMod ) | 840 | if ( lastSync > remoteMod ) |
841 | return 1; | 841 | return 1; |
842 | if ( lastSync > localMod ) | 842 | if ( lastSync > localMod ) |
843 | return 2; | 843 | return 2; |
844 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 844 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
845 | localIsNew = localMod >= remoteMod; | 845 | localIsNew = localMod >= remoteMod; |
846 | if ( localIsNew ) | 846 | if ( localIsNew ) |
847 | getEventViewerDialog()->setColorMode( 1 ); | 847 | getEventViewerDialog()->setColorMode( 1 ); |
848 | else | 848 | else |
849 | getEventViewerDialog()->setColorMode( 2 ); | 849 | getEventViewerDialog()->setColorMode( 2 ); |
850 | getEventViewerDialog()->setIncidence(local); | 850 | getEventViewerDialog()->setIncidence(local); |
851 | if ( localIsNew ) | 851 | if ( localIsNew ) |
852 | getEventViewerDialog()->setColorMode( 2 ); | 852 | getEventViewerDialog()->setColorMode( 2 ); |
853 | else | 853 | else |
854 | getEventViewerDialog()->setColorMode( 1 ); | 854 | getEventViewerDialog()->setColorMode( 1 ); |
855 | getEventViewerDialog()->addIncidence(remote); | 855 | getEventViewerDialog()->addIncidence(remote); |
856 | getEventViewerDialog()->setColorMode( 0 ); | 856 | getEventViewerDialog()->setColorMode( 0 ); |
857 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 857 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
858 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 858 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
859 | getEventViewerDialog()->showMe(); | 859 | getEventViewerDialog()->showMe(); |
860 | result = getEventViewerDialog()->executeS( localIsNew ); | 860 | result = getEventViewerDialog()->executeS( localIsNew ); |
861 | return result; | 861 | return result; |
862 | 862 | ||
863 | break; | 863 | break; |
864 | case SYNC_PREF_FORCE_LOCAL: | 864 | case SYNC_PREF_FORCE_LOCAL: |
865 | return 1; | 865 | return 1; |
866 | break; | 866 | break; |
867 | case SYNC_PREF_FORCE_REMOTE: | 867 | case SYNC_PREF_FORCE_REMOTE: |
868 | return 2; | 868 | return 2; |
869 | break; | 869 | break; |
870 | 870 | ||
871 | default: | 871 | default: |
872 | // SYNC_PREF_TAKE_BOTH not implemented | 872 | // SYNC_PREF_TAKE_BOTH not implemented |
873 | break; | 873 | break; |
874 | } | 874 | } |
875 | return 0; | 875 | return 0; |
876 | } | 876 | } |
877 | Event* CalendarView::getLastSyncEvent() | 877 | Event* CalendarView::getLastSyncEvent() |
878 | { | 878 | { |
879 | Event* lse; | 879 | Event* lse; |
880 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 880 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
881 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 881 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
882 | if (!lse) { | 882 | if (!lse) { |
883 | lse = new Event(); | 883 | lse = new Event(); |
884 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 884 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
885 | QString sum = ""; | 885 | QString sum = ""; |
886 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 886 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
887 | sum = "E: "; | 887 | sum = "E: "; |
888 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 888 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
889 | lse->setDtStart( mLastCalendarSync ); | 889 | lse->setDtStart( mLastCalendarSync ); |
890 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 890 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
891 | lse->setCategories( i18n("SyncEvent") ); | 891 | lse->setCategories( i18n("SyncEvent") ); |
892 | lse->setReadOnly( true ); | 892 | lse->setReadOnly( true ); |
893 | mCalendar->addEvent( lse ); | 893 | mCalendar->addEvent( lse ); |
894 | } | 894 | } |
895 | 895 | ||
896 | return lse; | 896 | return lse; |
897 | 897 | ||
898 | } | 898 | } |
899 | 899 | ||
900 | // we check, if the to delete event has a id for a profile | 900 | // we check, if the to delete event has a id for a profile |
901 | // if yes, we set this id in the profile to delete | 901 | // if yes, we set this id in the profile to delete |
902 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 902 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
903 | { | 903 | { |
904 | if ( lastSync.count() == 0 ) { | 904 | if ( lastSync.count() == 0 ) { |
905 | //qDebug(" lastSync.count() == 0"); | 905 | //qDebug(" lastSync.count() == 0"); |
906 | return; | 906 | return; |
907 | } | 907 | } |
908 | if ( toDelete->type() == "Journal" ) | 908 | if ( toDelete->type() == "Journal" ) |
909 | return; | 909 | return; |
910 | 910 | ||
911 | Event* eve = lastSync.first(); | 911 | Event* eve = lastSync.first(); |
912 | 912 | ||
913 | while ( eve ) { | 913 | while ( eve ) { |
914 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 914 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
915 | if ( !id.isEmpty() ) { | 915 | if ( !id.isEmpty() ) { |
916 | QString des = eve->description(); | 916 | QString des = eve->description(); |
917 | QString pref = "e"; | 917 | QString pref = "e"; |
918 | if ( toDelete->type() == "Todo" ) | 918 | if ( toDelete->type() == "Todo" ) |
919 | pref = "t"; | 919 | pref = "t"; |
920 | des += pref+ id + ","; | 920 | des += pref+ id + ","; |
921 | eve->setReadOnly( false ); | 921 | eve->setReadOnly( false ); |
922 | eve->setDescription( des ); | 922 | eve->setDescription( des ); |
923 | //qDebug("setdes %s ", des.latin1()); | 923 | //qDebug("setdes %s ", des.latin1()); |
924 | eve->setReadOnly( true ); | 924 | eve->setReadOnly( true ); |
925 | } | 925 | } |
926 | eve = lastSync.next(); | 926 | eve = lastSync.next(); |
927 | } | 927 | } |
928 | 928 | ||
929 | } | 929 | } |
930 | void CalendarView::checkExternalId( Incidence * inc ) | 930 | void CalendarView::checkExternalId( Incidence * inc ) |
931 | { | 931 | { |
932 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 932 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
933 | checkExternSyncEvent( lastSync, inc ); | 933 | checkExternSyncEvent( lastSync, inc ); |
934 | 934 | ||
935 | } | 935 | } |
936 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 936 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
937 | { | 937 | { |
938 | bool syncOK = true; | 938 | bool syncOK = true; |
939 | int addedEvent = 0; | 939 | int addedEvent = 0; |
940 | int addedEventR = 0; | 940 | int addedEventR = 0; |
941 | int deletedEventR = 0; | 941 | int deletedEventR = 0; |
942 | int deletedEventL = 0; | 942 | int deletedEventL = 0; |
943 | int changedLocal = 0; | 943 | int changedLocal = 0; |
944 | int changedRemote = 0; | 944 | int changedRemote = 0; |
945 | int filteredIN = 0; | 945 | int filteredIN = 0; |
946 | int filteredOUT = 0; | 946 | int filteredOUT = 0; |
947 | //QPtrList<Event> el = local->rawEvents(); | 947 | //QPtrList<Event> el = local->rawEvents(); |
948 | Event* eventR; | 948 | Event* eventR; |
949 | QString uid; | 949 | QString uid; |
950 | int take; | 950 | int take; |
951 | Event* eventL; | 951 | Event* eventL; |
952 | Event* eventRSync; | 952 | Event* eventRSync; |
953 | Event* eventLSync; | 953 | Event* eventLSync; |
954 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 954 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
955 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 955 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
956 | bool fullDateRange = false; | 956 | bool fullDateRange = false; |
957 | local->resetTempSyncStat(); | 957 | local->resetTempSyncStat(); |
958 | mLastCalendarSync = QDateTime::currentDateTime(); | 958 | mLastCalendarSync = QDateTime::currentDateTime(); |
959 | if ( mSyncManager->syncWithDesktop() ) { | 959 | if ( mSyncManager->syncWithDesktop() ) { |
960 | remote->resetPilotStat(1); | 960 | remote->resetPilotStat(1); |
961 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 961 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
962 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 962 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
963 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 963 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
964 | } else { | 964 | } else { |
965 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 965 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | QDateTime modifiedCalendar = mLastCalendarSync; | 968 | QDateTime modifiedCalendar = mLastCalendarSync; |
969 | eventLSync = getLastSyncEvent(); | 969 | eventLSync = getLastSyncEvent(); |
970 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 970 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
971 | if ( eventR ) { | 971 | if ( eventR ) { |
972 | eventRSync = (Event*) eventR->clone(); | 972 | eventRSync = (Event*) eventR->clone(); |
973 | remote->deleteEvent(eventR ); | 973 | remote->deleteEvent(eventR ); |
974 | 974 | ||
975 | } else { | 975 | } else { |
976 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 976 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
977 | eventRSync = (Event*)eventLSync->clone(); | 977 | eventRSync = (Event*)eventLSync->clone(); |
978 | } else { | 978 | } else { |
979 | fullDateRange = true; | 979 | fullDateRange = true; |
980 | eventRSync = new Event(); | 980 | eventRSync = new Event(); |
981 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 981 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
982 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 982 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
983 | eventRSync->setDtStart( mLastCalendarSync ); | 983 | eventRSync->setDtStart( mLastCalendarSync ); |
984 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 984 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
985 | eventRSync->setCategories( i18n("SyncEvent") ); | 985 | eventRSync->setCategories( i18n("SyncEvent") ); |
986 | } | 986 | } |
987 | } | 987 | } |
988 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 988 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
989 | fullDateRange = true; | 989 | fullDateRange = true; |
990 | 990 | ||
991 | if ( ! fullDateRange ) { | 991 | if ( ! fullDateRange ) { |
992 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 992 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
993 | 993 | ||
994 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 994 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
995 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 995 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
996 | fullDateRange = true; | 996 | fullDateRange = true; |
997 | } | 997 | } |
998 | } | 998 | } |
999 | if ( mSyncManager->syncWithDesktop() ) { | 999 | if ( mSyncManager->syncWithDesktop() ) { |
1000 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1000 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1001 | } | 1001 | } |
1002 | if ( fullDateRange ) | 1002 | if ( fullDateRange ) |
1003 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1003 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1004 | else | 1004 | else |
1005 | mLastCalendarSync = eventLSync->dtStart(); | 1005 | mLastCalendarSync = eventLSync->dtStart(); |
1006 | // for resyncing if own file has changed | 1006 | // for resyncing if own file has changed |
1007 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1007 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1008 | mLastCalendarSync = loadedFileVersion; | 1008 | mLastCalendarSync = loadedFileVersion; |
1009 | //qDebug("setting mLastCalendarSync "); | 1009 | //qDebug("setting mLastCalendarSync "); |
1010 | } | 1010 | } |
1011 | //qDebug("*************************** "); | 1011 | //qDebug("*************************** "); |
1012 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1012 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1013 | QPtrList<Incidence> er = remote->rawIncidences(); | 1013 | QPtrList<Incidence> er = remote->rawIncidences(); |
1014 | Incidence* inR = er.first(); | 1014 | Incidence* inR = er.first(); |
1015 | Incidence* inL; | 1015 | Incidence* inL; |
1016 | QProgressBar bar( er.count(),0 ); | 1016 | QProgressBar bar( er.count(),0 ); |
1017 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1017 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1018 | 1018 | ||
1019 | // ************** setting up filter ************* | 1019 | // ************** setting up filter ************* |
1020 | CalFilter *filterIN = 0; | 1020 | CalFilter *filterIN = 0; |
1021 | CalFilter *filterOUT = 0; | 1021 | CalFilter *filterOUT = 0; |
1022 | CalFilter *filter = mFilters.first(); | 1022 | CalFilter *filter = mFilters.first(); |
1023 | while(filter) { | 1023 | while(filter) { |
1024 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1024 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1025 | filterIN = filter; | 1025 | filterIN = filter; |
1026 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1026 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1027 | filterOUT = filter; | 1027 | filterOUT = filter; |
1028 | filter = mFilters.next(); | 1028 | filter = mFilters.next(); |
1029 | } | 1029 | } |
1030 | int w = 300; | 1030 | int w = 300; |
1031 | if ( QApplication::desktop()->width() < 320 ) | 1031 | if ( QApplication::desktop()->width() < 320 ) |
1032 | w = 220; | 1032 | w = 220; |
1033 | int h = bar.sizeHint().height() ; | 1033 | int h = bar.sizeHint().height() ; |
1034 | int dw = QApplication::desktop()->width(); | 1034 | int dw = QApplication::desktop()->width(); |
1035 | int dh = QApplication::desktop()->height(); | 1035 | int dh = QApplication::desktop()->height(); |
1036 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1036 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1037 | bar.show(); | 1037 | bar.show(); |
1038 | int modulo = (er.count()/10)+1; | 1038 | int modulo = (er.count()/10)+1; |
1039 | int incCounter = 0; | 1039 | int incCounter = 0; |
1040 | while ( inR ) { | 1040 | while ( inR ) { |
1041 | if ( ! bar.isVisible() ) | 1041 | if ( ! bar.isVisible() ) |
1042 | return false; | 1042 | return false; |
1043 | if ( incCounter % modulo == 0 ) | 1043 | if ( incCounter % modulo == 0 ) |
1044 | bar.setProgress( incCounter ); | 1044 | bar.setProgress( incCounter ); |
1045 | ++incCounter; | 1045 | ++incCounter; |
1046 | uid = inR->uid(); | 1046 | uid = inR->uid(); |
1047 | bool skipIncidence = false; | 1047 | bool skipIncidence = false; |
1048 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1048 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1049 | skipIncidence = true; | 1049 | skipIncidence = true; |
1050 | QString idS; | 1050 | QString idS; |
1051 | qApp->processEvents(); | 1051 | qApp->processEvents(); |
1052 | if ( !skipIncidence ) { | 1052 | if ( !skipIncidence ) { |
1053 | inL = local->incidence( uid ); | 1053 | inL = local->incidence( uid ); |
1054 | if ( inL ) { // maybe conflict - same uid in both calendars | 1054 | if ( inL ) { // maybe conflict - same uid in both calendars |
1055 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1055 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1056 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1056 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1057 | if ( take == 3 ) | 1057 | if ( take == 3 ) |
1058 | return false; | 1058 | return false; |
1059 | if ( take == 1 ) {// take local ********************** | 1059 | if ( take == 1 ) {// take local ********************** |
1060 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1060 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1061 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1061 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1062 | else | 1062 | else |
1063 | idS = inR->IDStr(); | 1063 | idS = inR->IDStr(); |
1064 | remote->deleteIncidence( inR ); | 1064 | remote->deleteIncidence( inR ); |
1065 | inR = inL->clone(); | 1065 | inR = inL->clone(); |
1066 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1066 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1067 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1067 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1068 | inR->setIDStr( idS ); | 1068 | inR->setIDStr( idS ); |
1069 | remote->addIncidence( inR ); | 1069 | remote->addIncidence( inR ); |
1070 | if ( mSyncManager->syncWithDesktop() ) | 1070 | if ( mSyncManager->syncWithDesktop() ) |
1071 | inR->setPilotId( 2 ); | 1071 | inR->setPilotId( 2 ); |
1072 | ++changedRemote; | 1072 | ++changedRemote; |
1073 | } else {// take remote ********************** | 1073 | } else {// take remote ********************** |
1074 | idS = inL->IDStr(); | 1074 | idS = inL->IDStr(); |
1075 | int pid = inL->pilotId(); | 1075 | int pid = inL->pilotId(); |
1076 | local->deleteIncidence( inL ); | 1076 | local->deleteIncidence( inL ); |
1077 | inL = inR->clone(); | 1077 | inL = inR->clone(); |
1078 | if ( mSyncManager->syncWithDesktop() ) | 1078 | if ( mSyncManager->syncWithDesktop() ) |
1079 | inL->setPilotId( pid ); | 1079 | inL->setPilotId( pid ); |
1080 | inL->setIDStr( idS ); | 1080 | inL->setIDStr( idS ); |
1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1082 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1082 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1083 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1083 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1084 | } | 1084 | } |
1085 | local->addIncidence( inL ); | 1085 | local->addIncidence( inL ); |
1086 | ++changedLocal; | 1086 | ++changedLocal; |
1087 | } | 1087 | } |
1088 | } | 1088 | } |
1089 | } else { // no conflict ********** add or delete remote | 1089 | } else { // no conflict ********** add or delete remote |
1090 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1090 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1091 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1091 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1092 | QString des = eventLSync->description(); | 1092 | QString des = eventLSync->description(); |
1093 | QString pref = "e"; | 1093 | QString pref = "e"; |
1094 | if ( inR->type() == "Todo" ) | 1094 | if ( inR->type() == "Todo" ) |
1095 | pref = "t"; | 1095 | pref = "t"; |
1096 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1096 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1097 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1097 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1098 | //remote->deleteIncidence( inR ); | 1098 | //remote->deleteIncidence( inR ); |
1099 | ++deletedEventR; | 1099 | ++deletedEventR; |
1100 | } else { | 1100 | } else { |
1101 | inR->setLastModified( modifiedCalendar ); | 1101 | inR->setLastModified( modifiedCalendar ); |
1102 | inL = inR->clone(); | 1102 | inL = inR->clone(); |
1103 | inL->setIDStr( ":" ); | 1103 | inL->setIDStr( ":" ); |
1104 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1104 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1105 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1105 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1106 | local->addIncidence( inL ); | 1106 | local->addIncidence( inL ); |
1107 | ++addedEvent; | 1107 | ++addedEvent; |
1108 | 1108 | ||
1109 | } | 1109 | } |
1110 | } else { | 1110 | } else { |
1111 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1111 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1112 | inR->setLastModified( modifiedCalendar ); | 1112 | inR->setLastModified( modifiedCalendar ); |
1113 | inL = inR->clone(); | 1113 | inL = inR->clone(); |
1114 | inL->setIDStr( ":" ); | 1114 | inL->setIDStr( ":" ); |
1115 | local->addIncidence( inL ); | 1115 | local->addIncidence( inL ); |
1116 | ++addedEvent; | 1116 | ++addedEvent; |
1117 | 1117 | ||
1118 | } else { | 1118 | } else { |
1119 | checkExternSyncEvent(eventRSyncSharp, inR); | 1119 | checkExternSyncEvent(eventRSyncSharp, inR); |
1120 | remote->deleteIncidence( inR ); | 1120 | remote->deleteIncidence( inR ); |
1121 | ++deletedEventR; | 1121 | ++deletedEventR; |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | } else { | 1124 | } else { |
1125 | ++filteredIN; | 1125 | ++filteredIN; |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | inR = er.next(); | 1129 | inR = er.next(); |
1130 | } | 1130 | } |
1131 | QPtrList<Incidence> el = local->rawIncidences(); | 1131 | QPtrList<Incidence> el = local->rawIncidences(); |
1132 | inL = el.first(); | 1132 | inL = el.first(); |
1133 | modulo = (el.count()/10)+1; | 1133 | modulo = (el.count()/10)+1; |
1134 | bar.setCaption (i18n("Add / remove events") ); | 1134 | bar.setCaption (i18n("Add / remove events") ); |
1135 | bar.setTotalSteps ( el.count() ) ; | 1135 | bar.setTotalSteps ( el.count() ) ; |
1136 | bar.show(); | 1136 | bar.show(); |
1137 | incCounter = 0; | 1137 | incCounter = 0; |
1138 | 1138 | ||
1139 | while ( inL ) { | 1139 | while ( inL ) { |
1140 | 1140 | ||
1141 | qApp->processEvents(); | 1141 | qApp->processEvents(); |
1142 | if ( ! bar.isVisible() ) | 1142 | if ( ! bar.isVisible() ) |
1143 | return false; | 1143 | return false; |
1144 | if ( incCounter % modulo == 0 ) | 1144 | if ( incCounter % modulo == 0 ) |
1145 | bar.setProgress( incCounter ); | 1145 | bar.setProgress( incCounter ); |
1146 | ++incCounter; | 1146 | ++incCounter; |
1147 | uid = inL->uid(); | 1147 | uid = inL->uid(); |
1148 | bool skipIncidence = false; | 1148 | bool skipIncidence = false; |
1149 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1149 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1150 | skipIncidence = true; | 1150 | skipIncidence = true; |
1151 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1151 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1152 | skipIncidence = true; | 1152 | skipIncidence = true; |
1153 | if ( !skipIncidence ) { | 1153 | if ( !skipIncidence ) { |
1154 | inR = remote->incidence( uid ); | 1154 | inR = remote->incidence( uid ); |
1155 | if ( ! inR ) { | 1155 | if ( ! inR ) { |
1156 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1156 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1157 | // no conflict ********** add or delete local | 1157 | // no conflict ********** add or delete local |
1158 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1158 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1159 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1159 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1160 | checkExternSyncEvent(eventLSyncSharp, inL); | 1160 | checkExternSyncEvent(eventLSyncSharp, inL); |
1161 | local->deleteIncidence( inL ); | 1161 | local->deleteIncidence( inL ); |
1162 | ++deletedEventL; | 1162 | ++deletedEventL; |
1163 | } else { | 1163 | } else { |
1164 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1164 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1165 | inL->removeID(mCurrentSyncDevice ); | 1165 | inL->removeID(mCurrentSyncDevice ); |
1166 | ++addedEventR; | 1166 | ++addedEventR; |
1167 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1167 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1168 | inL->setLastModified( modifiedCalendar ); | 1168 | inL->setLastModified( modifiedCalendar ); |
1169 | inR = inL->clone(); | 1169 | inR = inL->clone(); |
1170 | inR->setIDStr( ":" ); | 1170 | inR->setIDStr( ":" ); |
1171 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1171 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1172 | remote->addIncidence( inR ); | 1172 | remote->addIncidence( inR ); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | } else { | 1175 | } else { |
1176 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1176 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1177 | checkExternSyncEvent(eventLSyncSharp, inL); | 1177 | checkExternSyncEvent(eventLSyncSharp, inL); |
1178 | local->deleteIncidence( inL ); | 1178 | local->deleteIncidence( inL ); |
1179 | ++deletedEventL; | 1179 | ++deletedEventL; |
1180 | } else { | 1180 | } else { |
1181 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1181 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1182 | ++addedEventR; | 1182 | ++addedEventR; |
1183 | inL->setLastModified( modifiedCalendar ); | 1183 | inL->setLastModified( modifiedCalendar ); |
1184 | inR = inL->clone(); | 1184 | inR = inL->clone(); |
1185 | inR->setIDStr( ":" ); | 1185 | inR->setIDStr( ":" ); |
1186 | remote->addIncidence( inR ); | 1186 | remote->addIncidence( inR ); |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | } else { | 1190 | } else { |
1191 | ++filteredOUT; | 1191 | ++filteredOUT; |
1192 | } | 1192 | } |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | inL = el.next(); | 1195 | inL = el.next(); |
1196 | } | 1196 | } |
1197 | int delFut = 0; | 1197 | int delFut = 0; |
1198 | int remRem = 0; | 1198 | int remRem = 0; |
1199 | if ( mSyncManager->mWriteBackInFuture ) { | 1199 | if ( mSyncManager->mWriteBackInFuture ) { |
1200 | er = remote->rawIncidences(); | 1200 | er = remote->rawIncidences(); |
1201 | remRem = er.count(); | 1201 | remRem = er.count(); |
1202 | inR = er.first(); | 1202 | inR = er.first(); |
1203 | QDateTime dt; | 1203 | QDateTime dt; |
1204 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1204 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1205 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1205 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1206 | while ( inR ) { | 1206 | while ( inR ) { |
1207 | if ( inR->type() == "Todo" ) { | 1207 | if ( inR->type() == "Todo" ) { |
1208 | Todo * t = (Todo*)inR; | 1208 | Todo * t = (Todo*)inR; |
1209 | if ( t->hasDueDate() ) | 1209 | if ( t->hasDueDate() ) |
1210 | dt = t->dtDue(); | 1210 | dt = t->dtDue(); |
1211 | else | 1211 | else |
1212 | dt = cur.addSecs( 62 ); | 1212 | dt = cur.addSecs( 62 ); |
1213 | } | 1213 | } |
1214 | else if (inR->type() == "Event" ) { | 1214 | else if (inR->type() == "Event" ) { |
1215 | bool ok; | 1215 | bool ok; |
1216 | dt = inR->getNextOccurence( cur, &ok ); | 1216 | dt = inR->getNextOccurence( cur, &ok ); |
1217 | if ( !ok ) | 1217 | if ( !ok ) |
1218 | dt = cur.addSecs( -62 ); | 1218 | dt = cur.addSecs( -62 ); |
1219 | } | 1219 | } |
1220 | else | 1220 | else |
1221 | dt = inR->dtStart(); | 1221 | dt = inR->dtStart(); |
1222 | if ( dt < cur || dt > end ) { | 1222 | if ( dt < cur || dt > end ) { |
1223 | remote->deleteIncidence( inR ); | 1223 | remote->deleteIncidence( inR ); |
1224 | ++delFut; | 1224 | ++delFut; |
1225 | } | 1225 | } |
1226 | inR = er.next(); | 1226 | inR = er.next(); |
1227 | } | 1227 | } |
1228 | } | 1228 | } |
1229 | bar.hide(); | 1229 | bar.hide(); |
1230 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1230 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1231 | eventLSync->setReadOnly( false ); | 1231 | eventLSync->setReadOnly( false ); |
1232 | eventLSync->setDtStart( mLastCalendarSync ); | 1232 | eventLSync->setDtStart( mLastCalendarSync ); |
1233 | eventRSync->setDtStart( mLastCalendarSync ); | 1233 | eventRSync->setDtStart( mLastCalendarSync ); |
1234 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1234 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1235 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1235 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1236 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1236 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1237 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1237 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1238 | eventLSync->setReadOnly( true ); | 1238 | eventLSync->setReadOnly( true ); |
1239 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1239 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1240 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1240 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1241 | remote->addEvent( eventRSync ); | 1241 | remote->addEvent( eventRSync ); |
1242 | else | 1242 | else |
1243 | delete eventRSync; | 1243 | delete eventRSync; |
1244 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1244 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1245 | QString mes; | 1245 | QString mes; |
1246 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1246 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1247 | QString delmess; | 1247 | QString delmess; |
1248 | if ( delFut ) { | 1248 | if ( delFut ) { |
1249 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1249 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1250 | mes += delmess; | 1250 | mes += delmess; |
1251 | } | 1251 | } |
1252 | mes = i18n("Local calendar changed!\n") +mes; | 1252 | mes = i18n("Local calendar changed!\n") +mes; |
1253 | mCalendar->checkAlarmForIncidence( 0, true ); | 1253 | mCalendar->checkAlarmForIncidence( 0, true ); |
1254 | qDebug( mes ); | 1254 | qDebug( mes ); |
1255 | if ( mSyncManager->mShowSyncSummary ) { | 1255 | if ( mSyncManager->mShowSyncSummary ) { |
1256 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1256 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1257 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1257 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1258 | qDebug("KO: WB cancelled "); | 1258 | qDebug("KO: WB cancelled "); |
1259 | mSyncManager->mWriteBackFile = false; | 1259 | mSyncManager->mWriteBackFile = false; |
1260 | return syncOK; | 1260 | return syncOK; |
1261 | } | 1261 | } |
1262 | } | 1262 | } |
1263 | return syncOK; | 1263 | return syncOK; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | void CalendarView::setSyncDevice( QString s ) | 1266 | void CalendarView::setSyncDevice( QString s ) |
1267 | { | 1267 | { |
1268 | mCurrentSyncDevice= s; | 1268 | mCurrentSyncDevice= s; |
1269 | } | 1269 | } |
1270 | void CalendarView::setSyncName( QString s ) | 1270 | void CalendarView::setSyncName( QString s ) |
1271 | { | 1271 | { |
1272 | mCurrentSyncName= s; | 1272 | mCurrentSyncName= s; |
1273 | } | 1273 | } |
1274 | bool CalendarView::syncCalendar(QString filename, int mode) | 1274 | bool CalendarView::syncCalendar(QString filename, int mode) |
1275 | { | 1275 | { |
1276 | //qDebug("syncCalendar %s ", filename.latin1()); | 1276 | //qDebug("syncCalendar %s ", filename.latin1()); |
1277 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1277 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1278 | CalendarLocal* calendar = new CalendarLocal(); | 1278 | CalendarLocal* calendar = new CalendarLocal(); |
1279 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1279 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1280 | FileStorage* storage = new FileStorage( calendar ); | 1280 | FileStorage* storage = new FileStorage( calendar ); |
1281 | bool syncOK = false; | 1281 | bool syncOK = false; |
1282 | storage->setFileName( filename ); | 1282 | storage->setFileName( filename ); |
1283 | // qDebug("loading ... "); | 1283 | // qDebug("loading ... "); |
1284 | if ( storage->load() ) { | 1284 | if ( storage->load() ) { |
1285 | getEventViewerDialog()->setSyncMode( true ); | 1285 | getEventViewerDialog()->setSyncMode( true ); |
1286 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1286 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1287 | getEventViewerDialog()->setSyncMode( false ); | 1287 | getEventViewerDialog()->setSyncMode( false ); |
1288 | if ( syncOK ) { | 1288 | if ( syncOK ) { |
1289 | if ( mSyncManager->mWriteBackFile ) | 1289 | if ( mSyncManager->mWriteBackFile ) |
1290 | { | 1290 | { |
1291 | storage->setSaveFormat( new ICalFormat() ); | 1291 | storage->setSaveFormat( new ICalFormat() ); |
1292 | storage->save(); | 1292 | storage->save(); |
1293 | } | 1293 | } |
1294 | } | 1294 | } |
1295 | setModified( true ); | 1295 | setModified( true ); |
1296 | } | 1296 | } |
1297 | delete storage; | 1297 | delete storage; |
1298 | delete calendar; | 1298 | delete calendar; |
1299 | if ( syncOK ) | 1299 | if ( syncOK ) |
1300 | updateView(); | 1300 | updateView(); |
1301 | return syncOK; | 1301 | return syncOK; |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | void CalendarView::syncExternal( int mode ) | 1304 | void CalendarView::syncExternal( int mode ) |
1305 | { | 1305 | { |
1306 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1306 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1307 | 1307 | ||
1308 | qApp->processEvents(); | 1308 | qApp->processEvents(); |
1309 | CalendarLocal* calendar = new CalendarLocal(); | 1309 | CalendarLocal* calendar = new CalendarLocal(); |
1310 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1310 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1311 | bool syncOK = false; | 1311 | bool syncOK = false; |
1312 | bool loadSuccess = false; | 1312 | bool loadSuccess = false; |
1313 | PhoneFormat* phoneFormat = 0; | 1313 | PhoneFormat* phoneFormat = 0; |
1314 | emit tempDisableBR(true); | 1314 | emit tempDisableBR(true); |
1315 | #ifndef DESKTOP_VERSION | 1315 | #ifndef DESKTOP_VERSION |
1316 | SharpFormat* sharpFormat = 0; | 1316 | SharpFormat* sharpFormat = 0; |
1317 | if ( mode == 0 ) { // sharp | 1317 | if ( mode == 0 ) { // sharp |
1318 | sharpFormat = new SharpFormat () ; | 1318 | sharpFormat = new SharpFormat () ; |
1319 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1319 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1320 | 1320 | ||
1321 | } else | 1321 | } else |
1322 | #endif | 1322 | #endif |
1323 | if ( mode == 1 ) { // phone | 1323 | if ( mode == 1 ) { // phone |
1324 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1324 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1325 | mSyncManager->mPhoneDevice, | 1325 | mSyncManager->mPhoneDevice, |
1326 | mSyncManager->mPhoneConnection, | 1326 | mSyncManager->mPhoneConnection, |
1327 | mSyncManager->mPhoneModel); | 1327 | mSyncManager->mPhoneModel); |
1328 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1328 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1329 | 1329 | ||
1330 | } else { | 1330 | } else { |
1331 | emit tempDisableBR(false); | 1331 | emit tempDisableBR(false); |
1332 | return; | 1332 | return; |
1333 | } | 1333 | } |
1334 | if ( loadSuccess ) { | 1334 | if ( loadSuccess ) { |
1335 | getEventViewerDialog()->setSyncMode( true ); | 1335 | getEventViewerDialog()->setSyncMode( true ); |
1336 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1336 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1337 | getEventViewerDialog()->setSyncMode( false ); | 1337 | getEventViewerDialog()->setSyncMode( false ); |
1338 | qApp->processEvents(); | 1338 | qApp->processEvents(); |
1339 | if ( syncOK ) { | 1339 | if ( syncOK ) { |
1340 | if ( mSyncManager->mWriteBackFile ) | 1340 | if ( mSyncManager->mWriteBackFile ) |
1341 | { | 1341 | { |
1342 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1342 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1343 | Incidence* inc = iL.first(); | 1343 | Incidence* inc = iL.first(); |
1344 | if ( phoneFormat ) { | 1344 | if ( phoneFormat ) { |
1345 | while ( inc ) { | 1345 | while ( inc ) { |
1346 | inc->removeID(mCurrentSyncDevice); | 1346 | inc->removeID(mCurrentSyncDevice); |
1347 | inc = iL.next(); | 1347 | inc = iL.next(); |
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | #ifndef DESKTOP_VERSION | 1350 | #ifndef DESKTOP_VERSION |
1351 | if ( sharpFormat ) | 1351 | if ( sharpFormat ) |
1352 | sharpFormat->save(calendar); | 1352 | sharpFormat->save(calendar); |
1353 | #endif | 1353 | #endif |
1354 | if ( phoneFormat ) | 1354 | if ( phoneFormat ) |
1355 | phoneFormat->save(calendar); | 1355 | phoneFormat->save(calendar); |
1356 | iL = calendar->rawIncidences(); | 1356 | iL = calendar->rawIncidences(); |
1357 | inc = iL.first(); | 1357 | inc = iL.first(); |
1358 | Incidence* loc; | 1358 | Incidence* loc; |
1359 | while ( inc ) { | 1359 | while ( inc ) { |
1360 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1360 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1361 | loc = mCalendar->incidence(inc->uid() ); | 1361 | loc = mCalendar->incidence(inc->uid() ); |
1362 | if ( loc ) { | 1362 | if ( loc ) { |
1363 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1363 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1364 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1364 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1365 | } | 1365 | } |
1366 | } | 1366 | } |
1367 | inc = iL.next(); | 1367 | inc = iL.next(); |
1368 | } | 1368 | } |
1369 | Incidence* lse = getLastSyncEvent(); | 1369 | Incidence* lse = getLastSyncEvent(); |
1370 | if ( lse ) { | 1370 | if ( lse ) { |
1371 | lse->setReadOnly( false ); | 1371 | lse->setReadOnly( false ); |
1372 | lse->setDescription( "" ); | 1372 | lse->setDescription( "" ); |
1373 | lse->setReadOnly( true ); | 1373 | lse->setReadOnly( true ); |
1374 | } | 1374 | } |
1375 | } | 1375 | } |
1376 | } else { | 1376 | } else { |
1377 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1377 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1378 | } | 1378 | } |
1379 | setModified( true ); | 1379 | setModified( true ); |
1380 | } else { | 1380 | } else { |
1381 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1381 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1382 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1382 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1383 | question, i18n("Ok")) ; | 1383 | question, i18n("Ok")) ; |
1384 | 1384 | ||
1385 | } | 1385 | } |
1386 | delete calendar; | 1386 | delete calendar; |
1387 | updateView(); | 1387 | updateView(); |
1388 | emit tempDisableBR(false); | 1388 | emit tempDisableBR(false); |
1389 | return ;//syncOK; | 1389 | return ;//syncOK; |
1390 | 1390 | ||
1391 | } | 1391 | } |
1392 | 1392 | ||
1393 | bool CalendarView::importBday() | 1393 | bool CalendarView::importBday() |
1394 | { | 1394 | { |
1395 | #ifndef KORG_NOKABC | 1395 | #ifndef KORG_NOKABC |
1396 | 1396 | ||
1397 | #ifdef DESKTOP_VERSION | 1397 | #ifdef DESKTOP_VERSION |
1398 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1398 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1399 | KABC::AddressBook::Iterator it; | 1399 | KABC::AddressBook::Iterator it; |
1400 | int count = 0; | 1400 | int count = 0; |
1401 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1401 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1402 | ++count; | 1402 | ++count; |
1403 | } | 1403 | } |
1404 | QProgressBar bar(count,0 ); | 1404 | QProgressBar bar(count,0 ); |
1405 | int w = 300; | 1405 | int w = 300; |
1406 | if ( QApplication::desktop()->width() < 320 ) | 1406 | if ( QApplication::desktop()->width() < 320 ) |
1407 | w = 220; | 1407 | w = 220; |
1408 | int h = bar.sizeHint().height() ; | 1408 | int h = bar.sizeHint().height() ; |
1409 | int dw = QApplication::desktop()->width(); | 1409 | int dw = QApplication::desktop()->width(); |
1410 | int dh = QApplication::desktop()->height(); | 1410 | int dh = QApplication::desktop()->height(); |
1411 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1411 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1412 | bar.show(); | 1412 | bar.show(); |
1413 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1413 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1414 | qApp->processEvents(); | 1414 | qApp->processEvents(); |
1415 | count = 0; | 1415 | count = 0; |
1416 | int addCount = 0; | 1416 | int addCount = 0; |
1417 | KCal::Attendee* a = 0; | 1417 | KCal::Attendee* a = 0; |
1418 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1418 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1419 | if ( ! bar.isVisible() ) | 1419 | if ( ! bar.isVisible() ) |
1420 | return false; | 1420 | return false; |
1421 | bar.setProgress( count++ ); | 1421 | bar.setProgress( count++ ); |
1422 | qApp->processEvents(); | 1422 | qApp->processEvents(); |
1423 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1423 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1424 | if ( (*it).birthday().date().isValid() ){ | 1424 | if ( (*it).birthday().date().isValid() ){ |
1425 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1425 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1426 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1426 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1427 | ++addCount; | 1427 | ++addCount; |
1428 | } | 1428 | } |
1429 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1429 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1430 | if ( anni.isValid() ){ | 1430 | if ( anni.isValid() ){ |
1431 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1431 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1432 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1432 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1433 | ++addCount; | 1433 | ++addCount; |
1434 | } | 1434 | } |
1435 | } | 1435 | } |
1436 | updateView(); | 1436 | updateView(); |
1437 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1437 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1438 | #else //DESKTOP_VERSION | 1438 | #else //DESKTOP_VERSION |
1439 | 1439 | ||
1440 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1440 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1441 | // the result should now arrive through method insertBirthdays | 1441 | // the result should now arrive through method insertBirthdays |
1442 | 1442 | ||
1443 | #endif //DESKTOP_VERSION | 1443 | #endif //DESKTOP_VERSION |
1444 | 1444 | ||
1445 | #endif //KORG_NOKABC | 1445 | #endif //KORG_NOKABC |
1446 | 1446 | ||
1447 | 1447 | ||
1448 | return true; | 1448 | return true; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1451 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1452 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1452 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1453 | const QStringList& anniversaryList, const QStringList& realNameList, | 1453 | const QStringList& anniversaryList, const QStringList& realNameList, |
1454 | const QStringList& emailList, const QStringList& assembledNameList, | 1454 | const QStringList& emailList, const QStringList& assembledNameList, |
1455 | const QStringList& uidList) | 1455 | const QStringList& uidList) |
1456 | { | 1456 | { |
1457 | //qDebug("KO::CalendarView::insertBirthdays"); | 1457 | //qDebug("KO::CalendarView::insertBirthdays"); |
1458 | if (uid == this->name()) | 1458 | if (uid == this->name()) |
1459 | { | 1459 | { |
1460 | int count = birthdayList.count(); | 1460 | int count = birthdayList.count(); |
1461 | int addCount = 0; | 1461 | int addCount = 0; |
1462 | KCal::Attendee* a = 0; | 1462 | KCal::Attendee* a = 0; |
1463 | 1463 | ||
1464 | //qDebug("CalView 1 %i", count); | 1464 | //qDebug("CalView 1 %i", count); |
1465 | 1465 | ||
1466 | QProgressBar bar(count,0 ); | 1466 | QProgressBar bar(count,0 ); |
1467 | int w = 300; | 1467 | int w = 300; |
1468 | if ( QApplication::desktop()->width() < 320 ) | 1468 | if ( QApplication::desktop()->width() < 320 ) |
1469 | w = 220; | 1469 | w = 220; |
1470 | int h = bar.sizeHint().height() ; | 1470 | int h = bar.sizeHint().height() ; |
1471 | int dw = QApplication::desktop()->width(); | 1471 | int dw = QApplication::desktop()->width(); |
1472 | int dh = QApplication::desktop()->height(); | 1472 | int dh = QApplication::desktop()->height(); |
1473 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1473 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1474 | bar.show(); | 1474 | bar.show(); |
1475 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1475 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1476 | qApp->processEvents(); | 1476 | qApp->processEvents(); |
1477 | 1477 | ||
1478 | QDate birthday; | 1478 | QDate birthday; |
1479 | QDate anniversary; | 1479 | QDate anniversary; |
1480 | QString realName; | 1480 | QString realName; |
1481 | QString email; | 1481 | QString email; |
1482 | QString assembledName; | 1482 | QString assembledName; |
1483 | QString uid; | 1483 | QString uid; |
1484 | bool ok = true; | 1484 | bool ok = true; |
1485 | for ( int i = 0; i < count; i++) | 1485 | for ( int i = 0; i < count; i++) |
1486 | { | 1486 | { |
1487 | if ( ! bar.isVisible() ) | 1487 | if ( ! bar.isVisible() ) |
1488 | return; | 1488 | return; |
1489 | bar.setProgress( i ); | 1489 | bar.setProgress( i ); |
1490 | qApp->processEvents(); | 1490 | qApp->processEvents(); |
1491 | 1491 | ||
1492 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1492 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1493 | if (!ok) { | 1493 | if (!ok) { |
1494 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1494 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1497 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1498 | if (!ok) { | 1498 | if (!ok) { |
1499 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1499 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1500 | } | 1500 | } |
1501 | realName = realNameList[i]; | 1501 | realName = realNameList[i]; |
1502 | email = emailList[i]; | 1502 | email = emailList[i]; |
1503 | assembledName = assembledNameList[i]; | 1503 | assembledName = assembledNameList[i]; |
1504 | uid = uidList[i]; | 1504 | uid = uidList[i]; |
1505 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1505 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1506 | 1506 | ||
1507 | if ( birthday.isValid() ){ | 1507 | if ( birthday.isValid() ){ |
1508 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1508 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1509 | KCal::Attendee::ReqParticipant,uid) ; | 1509 | KCal::Attendee::ReqParticipant,uid) ; |
1510 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1510 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1511 | ++addCount; | 1511 | ++addCount; |
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | if ( anniversary.isValid() ){ | 1514 | if ( anniversary.isValid() ){ |
1515 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1515 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1516 | KCal::Attendee::ReqParticipant,uid) ; | 1516 | KCal::Attendee::ReqParticipant,uid) ; |
1517 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1517 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1518 | ++addCount; | 1518 | ++addCount; |
1519 | } | 1519 | } |
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | updateView(); | 1522 | updateView(); |
1523 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1523 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1524 | 1524 | ||
1525 | } | 1525 | } |
1526 | 1526 | ||
1527 | } | 1527 | } |
1528 | 1528 | ||
1529 | 1529 | ||
1530 | 1530 | ||
1531 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1531 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1532 | { | 1532 | { |
1533 | //qDebug("addAnni "); | 1533 | //qDebug("addAnni "); |
1534 | Event * ev = new Event(); | 1534 | Event * ev = new Event(); |
1535 | ev->setOrganizer(KOPrefs::instance()->email()); | 1535 | ev->setOrganizer(KOPrefs::instance()->email()); |
1536 | if ( a ) { | 1536 | if ( a ) { |
1537 | ev->addAttendee( a ); | 1537 | ev->addAttendee( a ); |
1538 | } | 1538 | } |
1539 | QString kind; | 1539 | QString kind; |
1540 | if ( birthday ) { | 1540 | if ( birthday ) { |
1541 | kind = i18n( "Birthday" ); | 1541 | kind = i18n( "Birthday" ); |
1542 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1542 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1543 | } | 1543 | } |
1544 | else { | 1544 | else { |
1545 | kind = i18n( "Anniversary" ); | 1545 | kind = i18n( "Anniversary" ); |
1546 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1546 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1547 | } | 1547 | } |
1548 | ev->setCategories( kind ); | 1548 | ev->setCategories( kind ); |
1549 | ev->setDtStart( QDateTime(date) ); | 1549 | ev->setDtStart( QDateTime(date) ); |
1550 | ev->setDtEnd( QDateTime(date) ); | 1550 | ev->setDtEnd( QDateTime(date) ); |
1551 | ev->setFloats( true ); | 1551 | ev->setFloats( true ); |
1552 | Recurrence * rec = ev->recurrence(); | 1552 | Recurrence * rec = ev->recurrence(); |
1553 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1553 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1554 | rec->addYearlyNum( date.month() ); | 1554 | rec->addYearlyNum( date.month() ); |
1555 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1555 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1556 | delete ev; | 1556 | delete ev; |
1557 | return false; | 1557 | return false; |
1558 | } | 1558 | } |
1559 | return true; | 1559 | return true; |
1560 | 1560 | ||
1561 | } | 1561 | } |
1562 | bool CalendarView::importQtopia( const QString &categories, | 1562 | bool CalendarView::importQtopia( const QString &categories, |
1563 | const QString &datebook, | 1563 | const QString &datebook, |
1564 | const QString &todolist ) | 1564 | const QString &todolist ) |
1565 | { | 1565 | { |
1566 | 1566 | ||
1567 | QtopiaFormat qtopiaFormat; | 1567 | QtopiaFormat qtopiaFormat; |
1568 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1568 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1569 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1569 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1570 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1570 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1571 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1571 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1572 | 1572 | ||
1573 | updateView(); | 1573 | updateView(); |
1574 | return true; | 1574 | return true; |
1575 | 1575 | ||
1576 | #if 0 | 1576 | #if 0 |
1577 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1577 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1578 | mCurrentSyncDevice = "qtopia-XML"; | 1578 | mCurrentSyncDevice = "qtopia-XML"; |
1579 | if ( mSyncManager->mAskForPreferences ) | 1579 | if ( mSyncManager->mAskForPreferences ) |
1580 | edit_sync_options(); | 1580 | edit_sync_options(); |
1581 | qApp->processEvents(); | 1581 | qApp->processEvents(); |
1582 | CalendarLocal* calendar = new CalendarLocal(); | 1582 | CalendarLocal* calendar = new CalendarLocal(); |
1583 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1583 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1584 | bool syncOK = false; | 1584 | bool syncOK = false; |
1585 | QtopiaFormat qtopiaFormat; | 1585 | QtopiaFormat qtopiaFormat; |
1586 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1586 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1587 | bool loadOk = true; | 1587 | bool loadOk = true; |
1588 | if ( !categories.isEmpty() ) | 1588 | if ( !categories.isEmpty() ) |
1589 | loadOk = qtopiaFormat.load( calendar, categories ); | 1589 | loadOk = qtopiaFormat.load( calendar, categories ); |
1590 | if ( loadOk && !datebook.isEmpty() ) | 1590 | if ( loadOk && !datebook.isEmpty() ) |
1591 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1591 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1592 | if ( loadOk && !todolist.isEmpty() ) | 1592 | if ( loadOk && !todolist.isEmpty() ) |
1593 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1593 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1594 | 1594 | ||
1595 | if ( loadOk ) { | 1595 | if ( loadOk ) { |
1596 | getEventViewerDialog()->setSyncMode( true ); | 1596 | getEventViewerDialog()->setSyncMode( true ); |
1597 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1597 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1598 | getEventViewerDialog()->setSyncMode( false ); | 1598 | getEventViewerDialog()->setSyncMode( false ); |
1599 | qApp->processEvents(); | 1599 | qApp->processEvents(); |
1600 | if ( syncOK ) { | 1600 | if ( syncOK ) { |
1601 | if ( mSyncManager->mWriteBackFile ) | 1601 | if ( mSyncManager->mWriteBackFile ) |
1602 | { | 1602 | { |
1603 | // write back XML file | 1603 | // write back XML file |
1604 | 1604 | ||
1605 | } | 1605 | } |
1606 | setModified( true ); | 1606 | setModified( true ); |
1607 | } | 1607 | } |
1608 | } else { | 1608 | } else { |
1609 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1609 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1610 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1610 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1611 | question, i18n("Ok")) ; | 1611 | question, i18n("Ok")) ; |
1612 | } | 1612 | } |
1613 | delete calendar; | 1613 | delete calendar; |
1614 | updateView(); | 1614 | updateView(); |
1615 | return syncOK; | 1615 | return syncOK; |
1616 | 1616 | ||
1617 | 1617 | ||
1618 | #endif | 1618 | #endif |
1619 | 1619 | ||
1620 | } | 1620 | } |
1621 | 1621 | ||
1622 | void CalendarView::setSyncEventsReadOnly() | 1622 | void CalendarView::setSyncEventsReadOnly() |
1623 | { | 1623 | { |
1624 | Event * ev; | 1624 | Event * ev; |
1625 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1625 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1626 | ev = eL.first(); | 1626 | ev = eL.first(); |
1627 | while ( ev ) { | 1627 | while ( ev ) { |
1628 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1628 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1629 | ev->setReadOnly( true ); | 1629 | ev->setReadOnly( true ); |
1630 | ev = eL.next(); | 1630 | ev = eL.next(); |
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | bool CalendarView::openCalendar(QString filename, bool merge) | 1633 | bool CalendarView::openCalendar(QString filename, bool merge) |
1634 | { | 1634 | { |
1635 | 1635 | ||
1636 | if (filename.isEmpty()) { | 1636 | if (filename.isEmpty()) { |
1637 | return false; | 1637 | return false; |
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | if (!QFile::exists(filename)) { | 1640 | if (!QFile::exists(filename)) { |
1641 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1641 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1642 | return false; | 1642 | return false; |
1643 | } | 1643 | } |
1644 | 1644 | ||
1645 | globalFlagBlockAgenda = 1; | 1645 | globalFlagBlockAgenda = 1; |
1646 | if (!merge) mCalendar->close(); | 1646 | if (!merge) mCalendar->close(); |
1647 | 1647 | ||
1648 | mStorage->setFileName( filename ); | 1648 | mStorage->setFileName( filename ); |
1649 | 1649 | ||
1650 | if ( mStorage->load() ) { | 1650 | if ( mStorage->load() ) { |
1651 | if ( merge ) ;//setModified( true ); | 1651 | if ( merge ) ;//setModified( true ); |
1652 | else { | 1652 | else { |
1653 | //setModified( true ); | 1653 | //setModified( true ); |
1654 | mViewManager->setDocumentId( filename ); | 1654 | mViewManager->setDocumentId( filename ); |
1655 | mDialogManager->setDocumentId( filename ); | 1655 | mDialogManager->setDocumentId( filename ); |
1656 | mTodoList->setDocumentId( filename ); | 1656 | mTodoList->setDocumentId( filename ); |
1657 | } | 1657 | } |
1658 | globalFlagBlockAgenda = 2; | 1658 | globalFlagBlockAgenda = 2; |
1659 | // if ( getLastSyncEvent() ) | 1659 | // if ( getLastSyncEvent() ) |
1660 | // getLastSyncEvent()->setReadOnly( true ); | 1660 | // getLastSyncEvent()->setReadOnly( true ); |
1661 | mCalendar->reInitAlarmSettings(); | 1661 | mCalendar->reInitAlarmSettings(); |
1662 | setSyncEventsReadOnly(); | 1662 | setSyncEventsReadOnly(); |
1663 | updateUnmanagedViews(); | 1663 | updateUnmanagedViews(); |
1664 | updateView(); | 1664 | updateView(); |
1665 | if ( filename != MainWindow::defaultFileName() ) { | 1665 | if ( filename != MainWindow::defaultFileName() ) { |
1666 | saveCalendar( MainWindow::defaultFileName() ); | 1666 | saveCalendar( MainWindow::defaultFileName() ); |
1667 | } else { | 1667 | } else { |
1668 | QFileInfo finf ( MainWindow::defaultFileName()); | 1668 | QFileInfo finf ( MainWindow::defaultFileName()); |
1669 | if ( finf.exists() ) { | 1669 | if ( finf.exists() ) { |
1670 | setLoadedFileVersion( finf.lastModified () ); | 1670 | setLoadedFileVersion( finf.lastModified () ); |
1671 | } | 1671 | } |
1672 | } | 1672 | } |
1673 | return true; | 1673 | return true; |
1674 | } else { | 1674 | } else { |
1675 | // while failing to load, the calendar object could | 1675 | // while failing to load, the calendar object could |
1676 | // have become partially populated. Clear it out. | 1676 | // have become partially populated. Clear it out. |
1677 | if ( !merge ) { | 1677 | if ( !merge ) { |
1678 | mCalendar->close(); | 1678 | mCalendar->close(); |
1679 | mViewManager->setDocumentId( filename ); | 1679 | mViewManager->setDocumentId( filename ); |
1680 | mDialogManager->setDocumentId( filename ); | 1680 | mDialogManager->setDocumentId( filename ); |
1681 | mTodoList->setDocumentId( filename ); | 1681 | mTodoList->setDocumentId( filename ); |
1682 | } | 1682 | } |
1683 | 1683 | ||
1684 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1684 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1685 | 1685 | ||
1686 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1686 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1687 | globalFlagBlockAgenda = 2; | 1687 | globalFlagBlockAgenda = 2; |
1688 | mCalendar->reInitAlarmSettings(); | 1688 | mCalendar->reInitAlarmSettings(); |
1689 | setSyncEventsReadOnly(); | 1689 | setSyncEventsReadOnly(); |
1690 | updateUnmanagedViews(); | 1690 | updateUnmanagedViews(); |
1691 | updateView(); | 1691 | updateView(); |
1692 | } | 1692 | } |
1693 | return false; | 1693 | return false; |
1694 | } | 1694 | } |
1695 | void CalendarView::showOpenError() | 1695 | void CalendarView::showOpenError() |
1696 | { | 1696 | { |
1697 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1697 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1698 | } | 1698 | } |
1699 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1699 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1700 | { | 1700 | { |
1701 | loadedFileVersion = dt; | 1701 | loadedFileVersion = dt; |
1702 | } | 1702 | } |
1703 | bool CalendarView::checkFileChanged(QString fn) | 1703 | bool CalendarView::checkFileChanged(QString fn) |
1704 | { | 1704 | { |
1705 | QFileInfo finf ( fn ); | 1705 | QFileInfo finf ( fn ); |
1706 | if ( !finf.exists() ) | 1706 | if ( !finf.exists() ) |
1707 | return true; | 1707 | return true; |
1708 | QDateTime dt = finf.lastModified (); | 1708 | QDateTime dt = finf.lastModified (); |
1709 | if ( dt <= loadedFileVersion ) | 1709 | if ( dt <= loadedFileVersion ) |
1710 | return false; | 1710 | return false; |
1711 | return true; | 1711 | return true; |
1712 | 1712 | ||
1713 | } | 1713 | } |
1714 | void CalendarView::watchSavedFile() | 1714 | void CalendarView::watchSavedFile() |
1715 | { | 1715 | { |
1716 | QFileInfo finf ( MainWindow::defaultFileName()); | 1716 | QFileInfo finf ( MainWindow::defaultFileName()); |
1717 | if ( !finf.exists() ) | 1717 | if ( !finf.exists() ) |
1718 | return; | 1718 | return; |
1719 | QDateTime dt = finf.lastModified (); | 1719 | QDateTime dt = finf.lastModified (); |
1720 | if ( dt < loadedFileVersion ) { | 1720 | if ( dt < loadedFileVersion ) { |
1721 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1721 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1722 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1722 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1723 | return; | 1723 | return; |
1724 | } | 1724 | } |
1725 | loadedFileVersion = dt; | 1725 | loadedFileVersion = dt; |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | bool CalendarView::checkFileVersion(QString fn) | 1728 | bool CalendarView::checkFileVersion(QString fn) |
1729 | { | 1729 | { |
1730 | QFileInfo finf ( fn ); | 1730 | QFileInfo finf ( fn ); |
1731 | if ( !finf.exists() ) | 1731 | if ( !finf.exists() ) |
1732 | return true; | 1732 | return true; |
1733 | QDateTime dt = finf.lastModified (); | 1733 | QDateTime dt = finf.lastModified (); |
1734 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1734 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1735 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1735 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1736 | if ( dt <= loadedFileVersion ) | 1736 | if ( dt <= loadedFileVersion ) |
1737 | return true; | 1737 | return true; |
1738 | 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)) , | 1738 | 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)) , |
1739 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1739 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1740 | i18n("Sync+save")); | 1740 | i18n("Sync+save")); |
1741 | 1741 | ||
1742 | if ( km == KMessageBox::Cancel ) | 1742 | if ( km == KMessageBox::Cancel ) |
1743 | return false; | 1743 | return false; |
1744 | if ( km == KMessageBox::Yes ) | 1744 | if ( km == KMessageBox::Yes ) |
1745 | return true; | 1745 | return true; |
1746 | 1746 | ||
1747 | setSyncDevice("deleteaftersync" ); | 1747 | setSyncDevice("deleteaftersync" ); |
1748 | mSyncManager->mAskForPreferences = true; | 1748 | mSyncManager->mAskForPreferences = true; |
1749 | mSyncManager->mSyncAlgoPrefs = 3; | 1749 | mSyncManager->mSyncAlgoPrefs = 3; |
1750 | mSyncManager->mWriteBackFile = false; | 1750 | mSyncManager->mWriteBackFile = false; |
1751 | mSyncManager->mWriteBackExistingOnly = false; | 1751 | mSyncManager->mWriteBackExistingOnly = false; |
1752 | mSyncManager->mShowSyncSummary = false; | 1752 | mSyncManager->mShowSyncSummary = false; |
1753 | syncCalendar( fn, 3 ); | 1753 | syncCalendar( fn, 3 ); |
1754 | Event * e = getLastSyncEvent(); | 1754 | Event * e = getLastSyncEvent(); |
1755 | mCalendar->deleteEvent ( e ); | 1755 | mCalendar->deleteEvent ( e ); |
1756 | updateView(); | 1756 | updateView(); |
1757 | return true; | 1757 | return true; |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | bool CalendarView::saveCalendar( QString filename ) | 1760 | bool CalendarView::saveCalendar( QString filename ) |
1761 | { | 1761 | { |
1762 | 1762 | ||
1763 | // Store back all unsaved data into calendar object | 1763 | // Store back all unsaved data into calendar object |
1764 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1764 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1765 | if ( mViewManager->currentView() ) | 1765 | if ( mViewManager->currentView() ) |
1766 | mViewManager->currentView()->flushView(); | 1766 | mViewManager->currentView()->flushView(); |
1767 | 1767 | ||
1768 | 1768 | ||
1769 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1769 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1770 | mStorage->setSaveFormat( new ICalFormat() ); | 1770 | mStorage->setSaveFormat( new ICalFormat() ); |
1771 | mStorage->setFileName( filename ); | 1771 | mStorage->setFileName( filename ); |
1772 | bool success; | 1772 | bool success; |
1773 | success = mStorage->save(); | 1773 | success = mStorage->save(); |
1774 | if ( !success ) { | 1774 | if ( !success ) { |
1775 | return false; | 1775 | return false; |
1776 | } | 1776 | } |
1777 | if ( filename == MainWindow::defaultFileName() ) { | 1777 | if ( filename == MainWindow::defaultFileName() ) { |
1778 | setLoadedFileVersion( lfv ); | 1778 | setLoadedFileVersion( lfv ); |
1779 | watchSavedFile(); | 1779 | watchSavedFile(); |
1780 | } | 1780 | } |
1781 | return true; | 1781 | return true; |
1782 | } | 1782 | } |
1783 | 1783 | ||
1784 | void CalendarView::closeCalendar() | 1784 | void CalendarView::closeCalendar() |
1785 | { | 1785 | { |
1786 | 1786 | ||
1787 | // child windows no longer valid | 1787 | // child windows no longer valid |
1788 | emit closingDown(); | 1788 | emit closingDown(); |
1789 | 1789 | ||
1790 | mCalendar->close(); | 1790 | mCalendar->close(); |
1791 | setModified(false); | 1791 | setModified(false); |
1792 | updateView(); | 1792 | updateView(); |
1793 | } | 1793 | } |
1794 | 1794 | ||
1795 | void CalendarView::archiveCalendar() | 1795 | void CalendarView::archiveCalendar() |
1796 | { | 1796 | { |
1797 | mDialogManager->showArchiveDialog(); | 1797 | mDialogManager->showArchiveDialog(); |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | 1800 | ||
1801 | void CalendarView::readSettings() | 1801 | void CalendarView::readSettings() |
1802 | { | 1802 | { |
1803 | 1803 | ||
1804 | 1804 | ||
1805 | // mViewManager->showAgendaView(); | 1805 | // mViewManager->showAgendaView(); |
1806 | QString str; | 1806 | QString str; |
1807 | //qDebug("CalendarView::readSettings() "); | 1807 | //qDebug("CalendarView::readSettings() "); |
1808 | // read settings from the KConfig, supplying reasonable | 1808 | // read settings from the KConfig, supplying reasonable |
1809 | // defaults where none are to be found | 1809 | // defaults where none are to be found |
1810 | KConfig *config = KOGlobals::config(); | 1810 | KConfig *config = KOGlobals::config(); |
1811 | #ifndef KORG_NOSPLITTER | 1811 | #ifndef KORG_NOSPLITTER |
1812 | config->setGroup("KOrganizer Geometry"); | 1812 | config->setGroup("KOrganizer Geometry"); |
1813 | 1813 | ||
1814 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1814 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1815 | if (sizes.count() != 2) { | 1815 | if (sizes.count() != 2) { |
1816 | sizes << mDateNavigator->minimumSizeHint().width(); | 1816 | sizes << mDateNavigator->minimumSizeHint().width(); |
1817 | sizes << 300; | 1817 | sizes << 300; |
1818 | } | 1818 | } |
1819 | mPanner->setSizes(sizes); | 1819 | mPanner->setSizes(sizes); |
1820 | 1820 | ||
1821 | sizes = config->readIntListEntry("Separator2"); | 1821 | sizes = config->readIntListEntry("Separator2"); |
1822 | if ( ( mResourceView && sizes.count() == 4 ) || | 1822 | if ( ( mResourceView && sizes.count() == 4 ) || |
1823 | ( !mResourceView && sizes.count() == 3 ) ) { | 1823 | ( !mResourceView && sizes.count() == 3 ) ) { |
1824 | mLeftSplitter->setSizes(sizes); | 1824 | mLeftSplitter->setSizes(sizes); |
1825 | } | 1825 | } |
1826 | #endif | 1826 | #endif |
1827 | globalFlagBlockAgenda = 1; | 1827 | globalFlagBlockAgenda = 1; |
1828 | mViewManager->showAgendaView(); | 1828 | mViewManager->showAgendaView(); |
1829 | //mViewManager->readSettings( config ); | 1829 | //mViewManager->readSettings( config ); |
1830 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1830 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1831 | readFilterSettings(config); | 1831 | readFilterSettings(config); |
1832 | 1832 | ||
1833 | #ifdef DESKTOP_VERSION | 1833 | #ifdef DESKTOP_VERSION |
1834 | config->setGroup("WidgetLayout"); | 1834 | config->setGroup("WidgetLayout"); |
1835 | QStringList list; | 1835 | QStringList list; |
1836 | list = config->readListEntry("MainLayout"); | 1836 | list = config->readListEntry("MainLayout"); |
1837 | int x,y,w,h; | 1837 | int x,y,w,h; |
1838 | if ( ! list.isEmpty() ) { | 1838 | if ( ! list.isEmpty() ) { |
1839 | x = list[0].toInt(); | 1839 | x = list[0].toInt(); |
1840 | y = list[1].toInt(); | 1840 | y = list[1].toInt(); |
1841 | w = list[2].toInt(); | 1841 | w = list[2].toInt(); |
1842 | h = list[3].toInt(); | 1842 | h = list[3].toInt(); |
1843 | topLevelWidget()->setGeometry(x,y,w,h); | 1843 | topLevelWidget()->setGeometry(x,y,w,h); |
1844 | 1844 | ||
1845 | } else { | 1845 | } else { |
1846 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1846 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1847 | } | 1847 | } |
1848 | list = config->readListEntry("EditEventLayout"); | 1848 | list = config->readListEntry("EditEventLayout"); |
1849 | if ( ! list.isEmpty() ) { | 1849 | if ( ! list.isEmpty() ) { |
1850 | x = list[0].toInt(); | 1850 | x = list[0].toInt(); |
1851 | y = list[1].toInt(); | 1851 | y = list[1].toInt(); |
1852 | w = list[2].toInt(); | 1852 | w = list[2].toInt(); |
1853 | h = list[3].toInt(); | 1853 | h = list[3].toInt(); |
1854 | mEventEditor->setGeometry(x,y,w,h); | 1854 | mEventEditor->setGeometry(x,y,w,h); |
1855 | 1855 | ||
1856 | } | 1856 | } |
1857 | list = config->readListEntry("EditTodoLayout"); | 1857 | list = config->readListEntry("EditTodoLayout"); |
1858 | if ( ! list.isEmpty() ) { | 1858 | if ( ! list.isEmpty() ) { |
1859 | x = list[0].toInt(); | 1859 | x = list[0].toInt(); |
1860 | y = list[1].toInt(); | 1860 | y = list[1].toInt(); |
1861 | w = list[2].toInt(); | 1861 | w = list[2].toInt(); |
1862 | h = list[3].toInt(); | 1862 | h = list[3].toInt(); |
1863 | mTodoEditor->setGeometry(x,y,w,h); | 1863 | mTodoEditor->setGeometry(x,y,w,h); |
1864 | 1864 | ||
1865 | } | 1865 | } |
1866 | list = config->readListEntry("ViewerLayout"); | 1866 | list = config->readListEntry("ViewerLayout"); |
1867 | if ( ! list.isEmpty() ) { | 1867 | if ( ! list.isEmpty() ) { |
1868 | x = list[0].toInt(); | 1868 | x = list[0].toInt(); |
1869 | y = list[1].toInt(); | 1869 | y = list[1].toInt(); |
1870 | w = list[2].toInt(); | 1870 | w = list[2].toInt(); |
1871 | h = list[3].toInt(); | 1871 | h = list[3].toInt(); |
1872 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1872 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1873 | } | 1873 | } |
1874 | #endif | 1874 | #endif |
1875 | config->setGroup( "Views" ); | 1875 | config->setGroup( "Views" ); |
1876 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1876 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1877 | 1877 | ||
1878 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1878 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1879 | 1879 | ||
1880 | int resetval = 0; | 1880 | int resetval = 0; |
1881 | int maxVal = 0; | 1881 | int maxVal = 0; |
1882 | if (sizes.count() != 3) { | 1882 | if (sizes.count() != 3) { |
1883 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1883 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1884 | resetval = mDateNavigator->sizeHint().width()+2; | 1884 | resetval = mDateNavigator->sizeHint().width()+2; |
1885 | } else { | 1885 | } else { |
1886 | resetval = mDateNavigator->sizeHint().height()+2; | 1886 | resetval = mDateNavigator->sizeHint().height()+2; |
1887 | } | 1887 | } |
1888 | } | 1888 | } |
1889 | if ( resetval ) { | 1889 | if ( resetval ) { |
1890 | sizes.clear(); | 1890 | sizes.clear(); |
1891 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1891 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1892 | maxVal = QApplication::desktop()->width() -10; | 1892 | maxVal = QApplication::desktop()->width() -10; |
1893 | } else { | 1893 | } else { |
1894 | maxVal = QApplication::desktop()->height()-10; | 1894 | maxVal = QApplication::desktop()->height()-10; |
1895 | } | 1895 | } |
1896 | sizes << resetval; | 1896 | sizes << resetval; |
1897 | if ( maxVal < resetval + resetval) | 1897 | if ( maxVal < resetval + resetval) |
1898 | resetval = maxVal - resetval; | 1898 | resetval = maxVal - resetval; |
1899 | sizes << resetval; | 1899 | sizes << resetval; |
1900 | sizes << 100; | 1900 | sizes << 100; |
1901 | } | 1901 | } |
1902 | mLeftFrame->setSizes(sizes); | 1902 | mLeftFrame->setSizes(sizes); |
1903 | sizes = config->readIntListEntry("Main Splitter Frame"); | 1903 | sizes = config->readIntListEntry("Main Splitter Frame"); |
1904 | resetval = 0; | 1904 | resetval = 0; |
1905 | maxVal = 0; | 1905 | maxVal = 0; |
1906 | if (sizes.count() != 2) { | 1906 | if (sizes.count() != 2) { |
1907 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 1907 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
1908 | resetval = mDateNavigator->sizeHint().width()+2; | 1908 | resetval = mDateNavigator->sizeHint().width()+2; |
1909 | } else { | 1909 | } else { |
1910 | resetval = mDateNavigator->sizeHint().height()+2; | 1910 | resetval = mDateNavigator->sizeHint().height()+2; |
1911 | } | 1911 | } |
1912 | } | 1912 | } |
1913 | if ( resetval ) { | 1913 | if ( resetval ) { |
1914 | sizes.clear(); | 1914 | sizes.clear(); |
1915 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 1915 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
1916 | maxVal = QApplication::desktop()->width() -10; | 1916 | maxVal = QApplication::desktop()->width() -10; |
1917 | } else { | 1917 | } else { |
1918 | maxVal = QApplication::desktop()->height()-10; | 1918 | maxVal = QApplication::desktop()->height()-10; |
1919 | } | 1919 | } |
1920 | sizes << resetval; | 1920 | sizes << resetval; |
1921 | if ( maxVal < resetval + resetval) | 1921 | if ( maxVal < resetval + resetval) |
1922 | resetval = maxVal - resetval; | 1922 | resetval = maxVal - resetval; |
1923 | sizes << resetval; | 1923 | sizes << resetval; |
1924 | } | 1924 | } |
1925 | mMainFrame->setSizes(sizes); | 1925 | mMainFrame->setSizes(sizes); |
1926 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1926 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1927 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1927 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1928 | else mNavigator->selectDates( dateCount ); | 1928 | else mNavigator->selectDates( dateCount ); |
1929 | // mViewManager->readSettings( config ); | 1929 | // mViewManager->readSettings( config ); |
1930 | updateConfig(); | 1930 | updateConfig(); |
1931 | globalFlagBlockAgenda = 2; | 1931 | globalFlagBlockAgenda = 2; |
1932 | mViewManager->readSettings( config ); | 1932 | mViewManager->readSettings( config ); |
1933 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 1933 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | 1936 | ||
1937 | void CalendarView::writeSettings() | 1937 | void CalendarView::writeSettings() |
1938 | { | 1938 | { |
1939 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1939 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1940 | 1940 | ||
1941 | KConfig *config = KOGlobals::config(); | 1941 | KConfig *config = KOGlobals::config(); |
1942 | 1942 | ||
1943 | mViewManager->writeSettings( config ); | 1943 | mViewManager->writeSettings( config ); |
1944 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1944 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1945 | mDialogManager->writeSettings( config ); | 1945 | mDialogManager->writeSettings( config ); |
1946 | //KOPrefs::instance()->usrWriteConfig(); | 1946 | //KOPrefs::instance()->usrWriteConfig(); |
1947 | KOPrefs::instance()->writeConfig(); | 1947 | KOPrefs::instance()->writeConfig(); |
1948 | 1948 | ||
1949 | writeFilterSettings(config); | 1949 | writeFilterSettings(config); |
1950 | 1950 | ||
1951 | config->setGroup( "Views" ); | 1951 | config->setGroup( "Views" ); |
1952 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1952 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1953 | 1953 | ||
1954 | QValueList<int> listINT = mLeftFrame->sizes(); | 1954 | QValueList<int> listINT = mLeftFrame->sizes(); |
1955 | config->writeEntry("Left Splitter Frame",listINT); | 1955 | config->writeEntry("Left Splitter Frame",listINT); |
1956 | QValueList<int> listINT2 = mMainFrame->sizes(); | 1956 | QValueList<int> listINT2 = mMainFrame->sizes(); |
1957 | config->writeEntry("Main Splitter Frame",listINT2); | 1957 | config->writeEntry("Main Splitter Frame",listINT2); |
1958 | #ifdef DESKTOP_VERSION | 1958 | #ifdef DESKTOP_VERSION |
1959 | config->setGroup("WidgetLayout"); | 1959 | config->setGroup("WidgetLayout"); |
1960 | QStringList list ;//= config->readListEntry("MainLayout"); | 1960 | QStringList list ;//= config->readListEntry("MainLayout"); |
1961 | int x,y,w,h; | 1961 | int x,y,w,h; |
1962 | QWidget* wid; | 1962 | QWidget* wid; |
1963 | wid = topLevelWidget(); | 1963 | wid = topLevelWidget(); |
1964 | x = wid->geometry().x(); | 1964 | x = wid->geometry().x(); |
1965 | y = wid->geometry().y(); | 1965 | y = wid->geometry().y(); |
1966 | w = wid->width(); | 1966 | w = wid->width(); |
1967 | h = wid->height(); | 1967 | h = wid->height(); |
1968 | list.clear(); | 1968 | list.clear(); |
1969 | list << QString::number( x ); | 1969 | list << QString::number( x ); |
1970 | list << QString::number( y ); | 1970 | list << QString::number( y ); |
1971 | list << QString::number( w ); | 1971 | list << QString::number( w ); |
1972 | list << QString::number( h ); | 1972 | list << QString::number( h ); |
1973 | config->writeEntry("MainLayout",list ); | 1973 | config->writeEntry("MainLayout",list ); |
1974 | 1974 | ||
1975 | wid = mEventEditor; | 1975 | wid = mEventEditor; |
1976 | x = wid->geometry().x(); | 1976 | x = wid->geometry().x(); |
1977 | y = wid->geometry().y(); | 1977 | y = wid->geometry().y(); |
1978 | w = wid->width(); | 1978 | w = wid->width(); |
1979 | h = wid->height(); | 1979 | h = wid->height(); |
1980 | list.clear(); | 1980 | list.clear(); |
1981 | list << QString::number( x ); | 1981 | list << QString::number( x ); |
1982 | list << QString::number( y ); | 1982 | list << QString::number( y ); |
1983 | list << QString::number( w ); | 1983 | list << QString::number( w ); |
1984 | list << QString::number( h ); | 1984 | list << QString::number( h ); |
1985 | config->writeEntry("EditEventLayout",list ); | 1985 | config->writeEntry("EditEventLayout",list ); |
1986 | 1986 | ||
1987 | wid = mTodoEditor; | 1987 | wid = mTodoEditor; |
1988 | x = wid->geometry().x(); | 1988 | x = wid->geometry().x(); |
1989 | y = wid->geometry().y(); | 1989 | y = wid->geometry().y(); |
1990 | w = wid->width(); | 1990 | w = wid->width(); |
1991 | h = wid->height(); | 1991 | h = wid->height(); |
1992 | list.clear(); | 1992 | list.clear(); |
1993 | list << QString::number( x ); | 1993 | list << QString::number( x ); |
1994 | list << QString::number( y ); | 1994 | list << QString::number( y ); |
1995 | list << QString::number( w ); | 1995 | list << QString::number( w ); |
1996 | list << QString::number( h ); | 1996 | list << QString::number( h ); |
1997 | config->writeEntry("EditTodoLayout",list ); | 1997 | config->writeEntry("EditTodoLayout",list ); |
1998 | wid = getEventViewerDialog(); | 1998 | wid = getEventViewerDialog(); |
1999 | x = wid->geometry().x(); | 1999 | x = wid->geometry().x(); |
2000 | y = wid->geometry().y(); | 2000 | y = wid->geometry().y(); |
2001 | w = wid->width(); | 2001 | w = wid->width(); |
2002 | h = wid->height(); | 2002 | h = wid->height(); |
2003 | list.clear(); | 2003 | list.clear(); |
2004 | list << QString::number( x ); | 2004 | list << QString::number( x ); |
2005 | list << QString::number( y ); | 2005 | list << QString::number( y ); |
2006 | list << QString::number( w ); | 2006 | list << QString::number( w ); |
2007 | list << QString::number( h ); | 2007 | list << QString::number( h ); |
2008 | config->writeEntry("ViewerLayout",list ); | 2008 | config->writeEntry("ViewerLayout",list ); |
2009 | wid = mDialogManager->getSearchDialog(); | 2009 | wid = mDialogManager->getSearchDialog(); |
2010 | if ( wid ) { | 2010 | if ( wid ) { |
2011 | x = wid->geometry().x(); | 2011 | x = wid->geometry().x(); |
2012 | y = wid->geometry().y(); | 2012 | y = wid->geometry().y(); |
2013 | w = wid->width(); | 2013 | w = wid->width(); |
2014 | h = wid->height(); | 2014 | h = wid->height(); |
2015 | list.clear(); | 2015 | list.clear(); |
2016 | list << QString::number( x ); | 2016 | list << QString::number( x ); |
2017 | list << QString::number( y ); | 2017 | list << QString::number( y ); |
2018 | list << QString::number( w ); | 2018 | list << QString::number( w ); |
2019 | list << QString::number( h ); | 2019 | list << QString::number( h ); |
2020 | config->writeEntry("SearchLayout",list ); | 2020 | config->writeEntry("SearchLayout",list ); |
2021 | } | 2021 | } |
2022 | #endif | 2022 | #endif |
2023 | 2023 | ||
2024 | 2024 | ||
2025 | config->sync(); | 2025 | config->sync(); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | void CalendarView::readFilterSettings(KConfig *config) | 2028 | void CalendarView::readFilterSettings(KConfig *config) |
2029 | { | 2029 | { |
2030 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2030 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2031 | 2031 | ||
2032 | mFilters.clear(); | 2032 | mFilters.clear(); |
2033 | 2033 | ||
2034 | config->setGroup("General"); | 2034 | config->setGroup("General"); |
2035 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2035 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2036 | 2036 | ||
2037 | QStringList::ConstIterator it = filterList.begin(); | 2037 | QStringList::ConstIterator it = filterList.begin(); |
2038 | QStringList::ConstIterator end = filterList.end(); | 2038 | QStringList::ConstIterator end = filterList.end(); |
2039 | while(it != end) { | 2039 | while(it != end) { |
2040 | // kdDebug() << " filter: " << (*it) << endl; | 2040 | // kdDebug() << " filter: " << (*it) << endl; |
2041 | 2041 | ||
2042 | CalFilter *filter; | 2042 | CalFilter *filter; |
2043 | filter = new CalFilter(*it); | 2043 | filter = new CalFilter(*it); |
2044 | config->setGroup("Filter_" + (*it)); | 2044 | config->setGroup("Filter_" + (*it)); |
2045 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2045 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2046 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2046 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2047 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2047 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2048 | mFilters.append(filter); | 2048 | mFilters.append(filter); |
2049 | 2049 | ||
2050 | ++it; | 2050 | ++it; |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | if (mFilters.count() == 0) { | 2053 | if (mFilters.count() == 0) { |
2054 | CalFilter *filter = new CalFilter(i18n("Default")); | 2054 | CalFilter *filter = new CalFilter(i18n("Default")); |
2055 | mFilters.append(filter); | 2055 | mFilters.append(filter); |
2056 | } | 2056 | } |
2057 | mFilterView->updateFilters(); | 2057 | mFilterView->updateFilters(); |
2058 | config->setGroup("FilterView"); | 2058 | config->setGroup("FilterView"); |
2059 | 2059 | ||
2060 | mFilterView->blockSignals(true); | 2060 | mFilterView->blockSignals(true); |
2061 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2061 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2062 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2062 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2063 | mFilterView->blockSignals(false); | 2063 | mFilterView->blockSignals(false); |
2064 | // We do it manually to avoid it being done twice by the above calls | 2064 | // We do it manually to avoid it being done twice by the above calls |
2065 | updateFilter(); | 2065 | updateFilter(); |
2066 | } | 2066 | } |
2067 | 2067 | ||
2068 | void CalendarView::writeFilterSettings(KConfig *config) | 2068 | void CalendarView::writeFilterSettings(KConfig *config) |
2069 | { | 2069 | { |
2070 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2070 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2071 | 2071 | ||
2072 | QStringList filterList; | 2072 | QStringList filterList; |
2073 | 2073 | ||
2074 | CalFilter *filter = mFilters.first(); | 2074 | CalFilter *filter = mFilters.first(); |
2075 | while(filter) { | 2075 | while(filter) { |
2076 | // kdDebug() << " fn: " << filter->name() << endl; | 2076 | // kdDebug() << " fn: " << filter->name() << endl; |
2077 | filterList << filter->name(); | 2077 | filterList << filter->name(); |
2078 | config->setGroup("Filter_" + filter->name()); | 2078 | config->setGroup("Filter_" + filter->name()); |
2079 | config->writeEntry("Criteria",filter->criteria()); | 2079 | config->writeEntry("Criteria",filter->criteria()); |
2080 | config->writeEntry("CategoryList",filter->categoryList()); | 2080 | config->writeEntry("CategoryList",filter->categoryList()); |
2081 | filter = mFilters.next(); | 2081 | filter = mFilters.next(); |
2082 | } | 2082 | } |
2083 | config->setGroup("General"); | 2083 | config->setGroup("General"); |
2084 | config->writeEntry("CalendarFilters",filterList); | 2084 | config->writeEntry("CalendarFilters",filterList); |
2085 | 2085 | ||
2086 | config->setGroup("FilterView"); | 2086 | config->setGroup("FilterView"); |
2087 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2087 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2088 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2088 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2089 | } | 2089 | } |
2090 | 2090 | ||
2091 | 2091 | ||
2092 | void CalendarView::goToday() | 2092 | void CalendarView::goToday() |
2093 | { | 2093 | { |
2094 | if ( mViewManager->currentView()->isMonthView() ) | 2094 | if ( mViewManager->currentView()->isMonthView() ) |
2095 | mNavigator->selectTodayMonth(); | 2095 | mNavigator->selectTodayMonth(); |
2096 | else | 2096 | else |
2097 | mNavigator->selectToday(); | 2097 | mNavigator->selectToday(); |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void CalendarView::goNext() | 2100 | void CalendarView::goNext() |
2101 | { | 2101 | { |
2102 | mNavigator->selectNext(); | 2102 | mNavigator->selectNext(); |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | void CalendarView::goPrevious() | 2105 | void CalendarView::goPrevious() |
2106 | { | 2106 | { |
2107 | mNavigator->selectPrevious(); | 2107 | mNavigator->selectPrevious(); |
2108 | } | 2108 | } |
2109 | void CalendarView::goNextMonth() | 2109 | void CalendarView::goNextMonth() |
2110 | { | 2110 | { |
2111 | mNavigator->selectNextMonth(); | 2111 | mNavigator->selectNextMonth(); |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | void CalendarView::goPreviousMonth() | 2114 | void CalendarView::goPreviousMonth() |
2115 | { | 2115 | { |
2116 | mNavigator->selectPreviousMonth(); | 2116 | mNavigator->selectPreviousMonth(); |
2117 | } | 2117 | } |
2118 | void CalendarView::writeLocale() | 2118 | void CalendarView::writeLocale() |
2119 | { | 2119 | { |
2120 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2120 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2121 | #if 0 | 2121 | #if 0 |
2122 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2122 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2123 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2123 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2124 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2124 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2125 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2125 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2126 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2126 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2127 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2127 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2128 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2128 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2129 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2129 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2130 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2130 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2131 | KOPrefs::instance()->mDaylightsavingStart, | 2131 | KOPrefs::instance()->mDaylightsavingStart, |
2132 | KOPrefs::instance()->mDaylightsavingEnd ); | 2132 | KOPrefs::instance()->mDaylightsavingEnd ); |
2133 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2133 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2134 | #endif | 2134 | #endif |
2135 | } | 2135 | } |
2136 | void CalendarView::updateConfig() | 2136 | void CalendarView::updateConfig() |
2137 | { | 2137 | { |
2138 | writeLocale(); | 2138 | writeLocale(); |
2139 | if ( KOPrefs::instance()->mUseAppColors ) | 2139 | if ( KOPrefs::instance()->mUseAppColors ) |
2140 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2140 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2141 | emit configChanged(); | 2141 | emit configChanged(); |
2142 | mTodoList->updateConfig(); | 2142 | mTodoList->updateConfig(); |
2143 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2143 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2144 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2144 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2145 | // To make the "fill window" configurations work | 2145 | // To make the "fill window" configurations work |
2146 | //mViewManager->raiseCurrentView(); | 2146 | //mViewManager->raiseCurrentView(); |
2147 | } | 2147 | } |
2148 | 2148 | ||
2149 | 2149 | ||
2150 | void CalendarView::eventChanged(Event *event) | 2150 | void CalendarView::eventChanged(Event *event) |
2151 | { | 2151 | { |
2152 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2152 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2153 | //updateUnmanagedViews(); | 2153 | //updateUnmanagedViews(); |
2154 | } | 2154 | } |
2155 | 2155 | ||
2156 | void CalendarView::eventAdded(Event *event) | 2156 | void CalendarView::eventAdded(Event *event) |
2157 | { | 2157 | { |
2158 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2158 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2159 | } | 2159 | } |
2160 | 2160 | ||
2161 | void CalendarView::eventToBeDeleted(Event *) | 2161 | void CalendarView::eventToBeDeleted(Event *) |
2162 | { | 2162 | { |
2163 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2163 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2164 | } | 2164 | } |
2165 | 2165 | ||
2166 | void CalendarView::eventDeleted() | 2166 | void CalendarView::eventDeleted() |
2167 | { | 2167 | { |
2168 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2168 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2169 | } | 2169 | } |
2170 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2170 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2171 | { | 2171 | { |
2172 | changeIncidenceDisplay((Incidence *)which, action); | 2172 | changeIncidenceDisplay((Incidence *)which, action); |
2173 | mDateNavigator->updateView(); //LR | 2173 | mDateNavigator->updateView(); //LR |
2174 | //mDialogManager->updateSearchDialog(); | 2174 | //mDialogManager->updateSearchDialog(); |
2175 | 2175 | ||
2176 | if (which) { | 2176 | if (which) { |
2177 | mViewManager->updateWNview(); | 2177 | mViewManager->updateWNview(); |
2178 | //mTodoList->updateView(); | 2178 | //mTodoList->updateView(); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | } | 2181 | } |
2182 | 2182 | ||
2183 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2183 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2184 | { | 2184 | { |
2185 | updateUnmanagedViews(); | 2185 | updateUnmanagedViews(); |
2186 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2186 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2187 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2187 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2188 | mCalendar->checkAlarmForIncidence( 0, true ); | 2188 | mCalendar->checkAlarmForIncidence( 0, true ); |
2189 | if ( mEventViewerDialog ) | 2189 | if ( mEventViewerDialog ) |
2190 | mEventViewerDialog->hide(); | 2190 | mEventViewerDialog->hide(); |
2191 | } | 2191 | } |
2192 | else | 2192 | else |
2193 | mCalendar->checkAlarmForIncidence( which , false ); | 2193 | mCalendar->checkAlarmForIncidence( which , false ); |
2194 | } | 2194 | } |
2195 | 2195 | ||
2196 | // most of the changeEventDisplays() right now just call the view's | 2196 | // most of the changeEventDisplays() right now just call the view's |
2197 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2197 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2198 | void CalendarView::changeEventDisplay(Event *which, int action) | 2198 | void CalendarView::changeEventDisplay(Event *which, int action) |
2199 | { | 2199 | { |
2200 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2200 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2201 | changeIncidenceDisplay((Incidence *)which, action); | 2201 | changeIncidenceDisplay((Incidence *)which, action); |
2202 | mDateNavigator->updateView(); | 2202 | mDateNavigator->updateView(); |
2203 | //mDialogManager->updateSearchDialog(); | 2203 | //mDialogManager->updateSearchDialog(); |
2204 | 2204 | ||
2205 | if (which) { | 2205 | if (which) { |
2206 | // If there is an event view visible update the display | 2206 | // If there is an event view visible update the display |
2207 | mViewManager->currentView()->changeEventDisplay(which,action); | 2207 | mViewManager->currentView()->changeEventDisplay(which,action); |
2208 | // TODO: check, if update needed | 2208 | // TODO: check, if update needed |
2209 | // if (which->getTodoStatus()) { | 2209 | // if (which->getTodoStatus()) { |
2210 | mTodoList->updateView(); | 2210 | mTodoList->updateView(); |
2211 | // } | 2211 | // } |
2212 | } else { | 2212 | } else { |
2213 | mViewManager->currentView()->updateView(); | 2213 | mViewManager->currentView()->updateView(); |
2214 | } | 2214 | } |
2215 | } | 2215 | } |
2216 | 2216 | ||
2217 | 2217 | ||
2218 | void CalendarView::updateTodoViews() | 2218 | void CalendarView::updateTodoViews() |
2219 | { | 2219 | { |
2220 | mTodoList->updateView(); | 2220 | mTodoList->updateView(); |
2221 | mViewManager->currentView()->updateView(); | 2221 | mViewManager->currentView()->updateView(); |
2222 | 2222 | ||
2223 | } | 2223 | } |
2224 | 2224 | ||
2225 | 2225 | ||
2226 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2226 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2227 | { | 2227 | { |
2228 | mTodoList->updateView(); | 2228 | mTodoList->updateView(); |
2229 | mViewManager->updateView(start, end); | 2229 | mViewManager->updateView(start, end); |
2230 | //mDateNavigator->updateView(); | 2230 | //mDateNavigator->updateView(); |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | void CalendarView::updateView() | 2233 | void CalendarView::updateView() |
2234 | { | 2234 | { |
2235 | DateList tmpList = mNavigator->selectedDates(); | 2235 | DateList tmpList = mNavigator->selectedDates(); |
2236 | 2236 | ||
2237 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2237 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2238 | mTodoList->updateView(); | 2238 | mTodoList->updateView(); |
2239 | // We assume that the navigator only selects consecutive days. | 2239 | // We assume that the navigator only selects consecutive days. |
2240 | updateView( tmpList.first(), tmpList.last() ); | 2240 | updateView( tmpList.first(), tmpList.last() ); |
2241 | } | 2241 | } |
2242 | 2242 | ||
2243 | void CalendarView::updateUnmanagedViews() | 2243 | void CalendarView::updateUnmanagedViews() |
2244 | { | 2244 | { |
2245 | mDateNavigator->updateDayMatrix(); | 2245 | mDateNavigator->updateDayMatrix(); |
2246 | } | 2246 | } |
2247 | 2247 | ||
2248 | int CalendarView::msgItemDelete(const QString name) | 2248 | int CalendarView::msgItemDelete(const QString name) |
2249 | { | 2249 | { |
2250 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2250 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2251 | i18n("This item will be\npermanently deleted."), | 2251 | i18n("This item will be\npermanently deleted."), |
2252 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2252 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | 2255 | ||
2256 | void CalendarView::edit_cut() | 2256 | void CalendarView::edit_cut() |
2257 | { | 2257 | { |
2258 | Event *anEvent=0; | 2258 | Event *anEvent=0; |
2259 | 2259 | ||
2260 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2260 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2261 | 2261 | ||
2262 | if (mViewManager->currentView()->isEventView()) { | 2262 | if (mViewManager->currentView()->isEventView()) { |
2263 | if ( incidence && incidence->type() == "Event" ) { | 2263 | if ( incidence && incidence->type() == "Event" ) { |
2264 | anEvent = static_cast<Event *>(incidence); | 2264 | anEvent = static_cast<Event *>(incidence); |
2265 | } | 2265 | } |
2266 | } | 2266 | } |
2267 | 2267 | ||
2268 | if (!anEvent) { | 2268 | if (!anEvent) { |
2269 | KNotifyClient::beep(); | 2269 | KNotifyClient::beep(); |
2270 | return; | 2270 | return; |
2271 | } | 2271 | } |
2272 | DndFactory factory( mCalendar ); | 2272 | DndFactory factory( mCalendar ); |
2273 | factory.cutIncidence(anEvent); | 2273 | factory.cutIncidence(anEvent); |
2274 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2274 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2275 | } | 2275 | } |
2276 | 2276 | ||
2277 | void CalendarView::edit_copy() | 2277 | void CalendarView::edit_copy() |
2278 | { | 2278 | { |
2279 | Event *anEvent=0; | 2279 | Event *anEvent=0; |
2280 | 2280 | ||
2281 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2281 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2282 | 2282 | ||
2283 | if (mViewManager->currentView()->isEventView()) { | 2283 | if (mViewManager->currentView()->isEventView()) { |
2284 | if ( incidence && incidence->type() == "Event" ) { | 2284 | if ( incidence && incidence->type() == "Event" ) { |
2285 | anEvent = static_cast<Event *>(incidence); | 2285 | anEvent = static_cast<Event *>(incidence); |
2286 | } | 2286 | } |
2287 | } | 2287 | } |
2288 | 2288 | ||
2289 | if (!anEvent) { | 2289 | if (!anEvent) { |
2290 | KNotifyClient::beep(); | 2290 | KNotifyClient::beep(); |
2291 | return; | 2291 | return; |
2292 | } | 2292 | } |
2293 | DndFactory factory( mCalendar ); | 2293 | DndFactory factory( mCalendar ); |
2294 | factory.copyIncidence(anEvent); | 2294 | factory.copyIncidence(anEvent); |
2295 | } | 2295 | } |
2296 | 2296 | ||
2297 | void CalendarView::edit_paste() | 2297 | void CalendarView::edit_paste() |
2298 | { | 2298 | { |
2299 | QDate date = mNavigator->selectedDates().first(); | 2299 | QDate date = mNavigator->selectedDates().first(); |
2300 | 2300 | ||
2301 | DndFactory factory( mCalendar ); | 2301 | DndFactory factory( mCalendar ); |
2302 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2302 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2303 | 2303 | ||
2304 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2304 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2305 | } | 2305 | } |
2306 | 2306 | ||
2307 | void CalendarView::edit_options() | 2307 | void CalendarView::edit_options() |
2308 | { | 2308 | { |
2309 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2309 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2310 | emit save(); | 2310 | emit save(); |
2311 | emit saveStopTimer(); | 2311 | emit saveStopTimer(); |
2312 | mDialogManager->showOptionsDialog(); | 2312 | mDialogManager->showOptionsDialog(); |
2313 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2313 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2314 | emit saveStopTimer(); | 2314 | emit saveStopTimer(); |
2315 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2315 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2316 | i18n("Timezone settings"),i18n("Reload"))) { | 2316 | i18n("Timezone settings"),i18n("Reload"))) { |
2317 | qDebug("KO: TZ reload cancelled "); | 2317 | qDebug("KO: TZ reload cancelled "); |
2318 | return; | 2318 | return; |
2319 | } | 2319 | } |
2320 | qDebug("KO: Timezone change "); | 2320 | qDebug("KO: Timezone change "); |
2321 | openCalendar( MainWindow::defaultFileName() ); | 2321 | openCalendar( MainWindow::defaultFileName() ); |
2322 | setModified(true); | 2322 | setModified(true); |
2323 | } | 2323 | } |
2324 | else | 2324 | else |
2325 | qDebug("KO: No tz change "); | 2325 | qDebug("KO: No tz change "); |
2326 | 2326 | ||
2327 | } | 2327 | } |
2328 | 2328 | ||
2329 | 2329 | ||
2330 | void CalendarView::slotSelectPickerDate( QDate d) | 2330 | void CalendarView::slotSelectPickerDate( QDate d) |
2331 | { | 2331 | { |
2332 | mDateFrame->hide(); | 2332 | mDateFrame->hide(); |
2333 | if ( mDatePickerMode == 1 ) { | 2333 | if ( mDatePickerMode == 1 ) { |
2334 | mNavigator->slotDaySelect( d ); | 2334 | mNavigator->slotDaySelect( d ); |
2335 | } else if ( mDatePickerMode == 2 ) { | 2335 | } else if ( mDatePickerMode == 2 ) { |
2336 | if ( mMoveIncidence->type() == "Todo" ) { | 2336 | if ( mMoveIncidence->type() == "Todo" ) { |
2337 | Todo * to = (Todo *) mMoveIncidence; | 2337 | Todo * to = (Todo *) mMoveIncidence; |
2338 | QTime tim; | 2338 | QTime tim; |
2339 | int len = 0; | 2339 | int len = 0; |
2340 | if ( to->hasStartDate() && to->hasDueDate() ) | 2340 | if ( to->hasStartDate() && to->hasDueDate() ) |
2341 | len = to->dtStart().secsTo( to->dtDue()); | 2341 | len = to->dtStart().secsTo( to->dtDue()); |
2342 | if ( to->hasDueDate() ) | 2342 | if ( to->hasDueDate() ) |
2343 | tim = to->dtDue().time(); | 2343 | tim = to->dtDue().time(); |
2344 | else { | 2344 | else { |
2345 | tim = QTime ( 0,0,0 ); | 2345 | tim = QTime ( 0,0,0 ); |
2346 | to->setFloats( true ); | 2346 | to->setFloats( true ); |
2347 | to->setHasDueDate( true ); | 2347 | to->setHasDueDate( true ); |
2348 | } | 2348 | } |
2349 | QDateTime dt ( d,tim ); | 2349 | QDateTime dt ( d,tim ); |
2350 | to->setDtDue( dt ); | 2350 | to->setDtDue( dt ); |
2351 | 2351 | ||
2352 | if ( to->hasStartDate() ) { | 2352 | if ( to->hasStartDate() ) { |
2353 | if ( len>0 ) | 2353 | if ( len>0 ) |
2354 | to->setDtStart(to->dtDue().addSecs( -len )); | 2354 | to->setDtStart(to->dtDue().addSecs( -len )); |
2355 | else | 2355 | else |
2356 | if (to->dtStart() > to->dtDue() ) | 2356 | if (to->dtStart() > to->dtDue() ) |
2357 | to->setDtStart(to->dtDue().addDays( -3 )); | 2357 | to->setDtStart(to->dtDue().addDays( -3 )); |
2358 | } | 2358 | } |
2359 | 2359 | ||
2360 | todoChanged( to ); | 2360 | todoChanged( to ); |
2361 | } else { | 2361 | } else { |
2362 | if ( mMoveIncidence->doesRecur() ) { | 2362 | if ( mMoveIncidence->doesRecur() ) { |
2363 | #if 0 | 2363 | #if 0 |
2364 | // PENDING implement this | 2364 | // PENDING implement this |
2365 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2365 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2366 | mCalendar()->addIncidence( newInc ); | 2366 | mCalendar()->addIncidence( newInc ); |
2367 | if ( mMoveIncidence->type() == "Todo" ) | 2367 | if ( mMoveIncidence->type() == "Todo" ) |
2368 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2368 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2369 | else | 2369 | else |
2370 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2370 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2371 | mMoveIncidence = newInc; | 2371 | mMoveIncidence = newInc; |
2372 | 2372 | ||
2373 | #endif | 2373 | #endif |
2374 | } | 2374 | } |
2375 | QTime tim = mMoveIncidence->dtStart().time(); | 2375 | QTime tim = mMoveIncidence->dtStart().time(); |
2376 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2376 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2377 | QDateTime dt ( d,tim ); | 2377 | QDateTime dt ( d,tim ); |
2378 | mMoveIncidence->setDtStart( dt ); | 2378 | mMoveIncidence->setDtStart( dt ); |
2379 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2379 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2380 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2380 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2381 | } | 2381 | } |
2382 | 2382 | ||
2383 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2383 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2384 | } | 2384 | } |
2385 | } | 2385 | } |
2386 | 2386 | ||
2387 | void CalendarView::removeCategories() | 2387 | void CalendarView::removeCategories() |
2388 | { | 2388 | { |
2389 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2389 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2390 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2390 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2391 | QStringList catIncList; | 2391 | QStringList catIncList; |
2392 | QStringList newCatList; | 2392 | QStringList newCatList; |
2393 | Incidence* inc = incList.first(); | 2393 | Incidence* inc = incList.first(); |
2394 | int i; | 2394 | int i; |
2395 | int count = 0; | 2395 | int count = 0; |
2396 | while ( inc ) { | 2396 | while ( inc ) { |
2397 | newCatList.clear(); | 2397 | newCatList.clear(); |
2398 | catIncList = inc->categories() ; | 2398 | catIncList = inc->categories() ; |
2399 | for( i = 0; i< catIncList.count(); ++i ) { | 2399 | for( i = 0; i< catIncList.count(); ++i ) { |
2400 | if ( catList.contains (catIncList[i])) | 2400 | if ( catList.contains (catIncList[i])) |
2401 | newCatList.append( catIncList[i] ); | 2401 | newCatList.append( catIncList[i] ); |
2402 | } | 2402 | } |
2403 | newCatList.sort(); | 2403 | newCatList.sort(); |
2404 | inc->setCategories( newCatList.join(",") ); | 2404 | inc->setCategories( newCatList.join(",") ); |
2405 | inc = incList.next(); | 2405 | inc = incList.next(); |
2406 | } | 2406 | } |
2407 | } | 2407 | } |
2408 | 2408 | ||
2409 | int CalendarView::addCategories() | 2409 | int CalendarView::addCategories() |
2410 | { | 2410 | { |
2411 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2411 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2412 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2412 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2413 | QStringList catIncList; | 2413 | QStringList catIncList; |
2414 | Incidence* inc = incList.first(); | 2414 | Incidence* inc = incList.first(); |
2415 | int i; | 2415 | int i; |
2416 | int count = 0; | 2416 | int count = 0; |
2417 | while ( inc ) { | 2417 | while ( inc ) { |
2418 | catIncList = inc->categories() ; | 2418 | catIncList = inc->categories() ; |
2419 | for( i = 0; i< catIncList.count(); ++i ) { | 2419 | for( i = 0; i< catIncList.count(); ++i ) { |
2420 | if ( !catList.contains (catIncList[i])) { | 2420 | if ( !catList.contains (catIncList[i])) { |
2421 | catList.append( catIncList[i] ); | 2421 | catList.append( catIncList[i] ); |
2422 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2422 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2423 | ++count; | 2423 | ++count; |
2424 | } | 2424 | } |
2425 | } | 2425 | } |
2426 | inc = incList.next(); | 2426 | inc = incList.next(); |
2427 | } | 2427 | } |
2428 | catList.sort(); | 2428 | catList.sort(); |
2429 | KOPrefs::instance()->mCustomCategories = catList; | 2429 | KOPrefs::instance()->mCustomCategories = catList; |
2430 | return count; | 2430 | return count; |
2431 | } | 2431 | } |
2432 | 2432 | ||
2433 | void CalendarView::manageCategories() | 2433 | void CalendarView::manageCategories() |
2434 | { | 2434 | { |
2435 | KOCatPrefs* cp = new KOCatPrefs(); | 2435 | KOCatPrefs* cp = new KOCatPrefs(); |
2436 | cp->show(); | 2436 | cp->show(); |
2437 | int w =cp->sizeHint().width() ; | 2437 | int w =cp->sizeHint().width() ; |
2438 | int h = cp->sizeHint().height() ; | 2438 | int h = cp->sizeHint().height() ; |
2439 | int dw = QApplication::desktop()->width(); | 2439 | int dw = QApplication::desktop()->width(); |
2440 | int dh = QApplication::desktop()->height(); | 2440 | int dh = QApplication::desktop()->height(); |
2441 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2441 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2442 | if ( !cp->exec() ) { | 2442 | if ( !cp->exec() ) { |
2443 | delete cp; | 2443 | delete cp; |
2444 | return; | 2444 | return; |
2445 | } | 2445 | } |
2446 | int count = 0; | 2446 | int count = 0; |
2447 | if ( cp->addCat() ) { | 2447 | if ( cp->addCat() ) { |
2448 | count = addCategories(); | 2448 | count = addCategories(); |
2449 | if ( count ) { | 2449 | if ( count ) { |
2450 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2450 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2451 | writeSettings(); | 2451 | writeSettings(); |
2452 | } else | 2452 | } else |
2453 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2453 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2454 | } else { | 2454 | } else { |
2455 | removeCategories(); | 2455 | removeCategories(); |
2456 | updateView(); | 2456 | updateView(); |
2457 | } | 2457 | } |
2458 | delete cp; | 2458 | delete cp; |
2459 | } | 2459 | } |
2460 | 2460 | ||
2461 | void CalendarView::beamIncidence(Incidence * Inc) | 2461 | void CalendarView::beamIncidence(Incidence * Inc) |
2462 | { | 2462 | { |
2463 | QPtrList<Incidence> delSel ; | 2463 | QPtrList<Incidence> delSel ; |
2464 | delSel.append(Inc); | 2464 | delSel.append(Inc); |
2465 | beamIncidenceList( delSel ); | 2465 | beamIncidenceList( delSel ); |
2466 | } | 2466 | } |
2467 | void CalendarView::beamCalendar() | 2467 | void CalendarView::beamCalendar() |
2468 | { | 2468 | { |
2469 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2469 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2470 | //qDebug("beamCalendar() "); | 2470 | //qDebug("beamCalendar() "); |
2471 | beamIncidenceList( delSel ); | 2471 | beamIncidenceList( delSel ); |
2472 | } | 2472 | } |
2473 | void CalendarView::beamFilteredCalendar() | 2473 | void CalendarView::beamFilteredCalendar() |
2474 | { | 2474 | { |
2475 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2475 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2476 | //qDebug("beamFilteredCalendar() "); | 2476 | //qDebug("beamFilteredCalendar() "); |
2477 | beamIncidenceList( delSel ); | 2477 | beamIncidenceList( delSel ); |
2478 | } | 2478 | } |
2479 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2479 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2480 | { | 2480 | { |
2481 | if ( beamDialog->exec () == QDialog::Rejected ) | 2481 | if ( beamDialog->exec () == QDialog::Rejected ) |
2482 | return; | 2482 | return; |
2483 | #ifdef DESKTOP_VERSION | 2483 | #ifdef DESKTOP_VERSION |
2484 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2484 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2485 | #else | 2485 | #else |
2486 | QString fn = "/tmp/kopibeamfile"; | 2486 | QString fn = "/tmp/kopibeamfile"; |
2487 | #endif | 2487 | #endif |
2488 | QString mes; | 2488 | QString mes; |
2489 | bool createbup = true; | 2489 | bool createbup = true; |
2490 | if ( createbup ) { | 2490 | if ( createbup ) { |
2491 | QString description = "\n"; | 2491 | QString description = "\n"; |
2492 | CalendarLocal* cal = new CalendarLocal(); | 2492 | CalendarLocal* cal = new CalendarLocal(); |
2493 | if ( beamDialog->beamLocal() ) | 2493 | if ( beamDialog->beamLocal() ) |
2494 | cal->setLocalTime(); | 2494 | cal->setLocalTime(); |
2495 | else | 2495 | else |
2496 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2496 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2497 | Incidence *incidence = delSel.first(); | 2497 | Incidence *incidence = delSel.first(); |
2498 | bool addText = false; | 2498 | bool addText = false; |
2499 | if ( delSel.count() < 10 ) | 2499 | if ( delSel.count() < 10 ) |
2500 | addText = true; | 2500 | addText = true; |
2501 | else { | 2501 | else { |
2502 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2502 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2503 | } | 2503 | } |
2504 | while ( incidence ) { | 2504 | while ( incidence ) { |
2505 | Incidence *in = incidence->clone(); | 2505 | Incidence *in = incidence->clone(); |
2506 | if ( ! in->summary().isEmpty() ) { | 2506 | if ( ! in->summary().isEmpty() ) { |
2507 | in->setDescription(""); | 2507 | in->setDescription(""); |
2508 | } else { | 2508 | } else { |
2509 | in->setSummary( in->description().left(20)); | 2509 | in->setSummary( in->description().left(20)); |
2510 | in->setDescription(""); | 2510 | in->setDescription(""); |
2511 | } | 2511 | } |
2512 | if ( addText ) | 2512 | if ( addText ) |
2513 | description += in->summary() + "\n"; | 2513 | description += in->summary() + "\n"; |
2514 | cal->addIncidence( in ); | 2514 | cal->addIncidence( in ); |
2515 | incidence = delSel.next(); | 2515 | incidence = delSel.next(); |
2516 | } | 2516 | } |
2517 | if ( beamDialog->beamVcal() ) { | 2517 | if ( beamDialog->beamVcal() ) { |
2518 | fn += ".vcs"; | 2518 | fn += ".vcs"; |
2519 | FileStorage storage( cal, fn, new VCalFormat ); | 2519 | FileStorage storage( cal, fn, new VCalFormat ); |
2520 | storage.save(); | 2520 | storage.save(); |
2521 | } else { | 2521 | } else { |
2522 | fn += ".ics"; | 2522 | fn += ".ics"; |
2523 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2523 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2524 | storage.save(); | 2524 | storage.save(); |
2525 | } | 2525 | } |
2526 | delete cal; | 2526 | delete cal; |
2527 | mes = i18n("KO/Pi: Ready for beaming"); | 2527 | mes = i18n("KO/Pi: Ready for beaming"); |
2528 | topLevelWidget()->setCaption(mes); | 2528 | topLevelWidget()->setCaption(mes); |
2529 | KApplication::convert2latin1( fn ); | 2529 | KApplication::convert2latin1( fn ); |
2530 | #ifndef DESKTOP_VERSION | 2530 | #ifndef DESKTOP_VERSION |
2531 | Ir *ir = new Ir( this ); | 2531 | Ir *ir = new Ir( this ); |
2532 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2532 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2533 | ir->send( fn, description, "text/x-vCalendar" ); | 2533 | ir->send( fn, description, "text/x-vCalendar" ); |
2534 | #endif | 2534 | #endif |
2535 | } | 2535 | } |
2536 | } | 2536 | } |
2537 | void CalendarView::beamDone( Ir *ir ) | 2537 | void CalendarView::beamDone( Ir *ir ) |
2538 | { | 2538 | { |
2539 | #ifndef DESKTOP_VERSION | 2539 | #ifndef DESKTOP_VERSION |
2540 | delete ir; | 2540 | delete ir; |
2541 | #endif | 2541 | #endif |
2542 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2542 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2543 | topLevelWidget()->raise(); | 2543 | topLevelWidget()->raise(); |
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | void CalendarView::moveIncidence(Incidence * inc ) | 2546 | void CalendarView::moveIncidence(Incidence * inc ) |
2547 | { | 2547 | { |
2548 | if ( !inc ) return; | 2548 | if ( !inc ) return; |
2549 | showDatePickerPopup(); | 2549 | showDatePickerPopup(); |
2550 | mDatePickerMode = 2; | 2550 | mDatePickerMode = 2; |
2551 | mMoveIncidence = inc ; | 2551 | mMoveIncidence = inc ; |
2552 | QDate da; | 2552 | QDate da; |
2553 | if ( mMoveIncidence->type() == "Todo" ) { | 2553 | if ( mMoveIncidence->type() == "Todo" ) { |
2554 | Todo * to = (Todo *) mMoveIncidence; | 2554 | Todo * to = (Todo *) mMoveIncidence; |
2555 | if ( to->hasDueDate() ) | 2555 | if ( to->hasDueDate() ) |
2556 | da = to->dtDue().date(); | 2556 | da = to->dtDue().date(); |
2557 | else | 2557 | else |
2558 | da = QDate::currentDate(); | 2558 | da = QDate::currentDate(); |
2559 | } else { | 2559 | } else { |
2560 | da = mMoveIncidence->dtStart().date(); | 2560 | da = mMoveIncidence->dtStart().date(); |
2561 | } | 2561 | } |
2562 | //PENDING set date for recurring incidence to date of recurrence | 2562 | //PENDING set date for recurring incidence to date of recurrence |
2563 | //mMoveIncidenceOldDate; | 2563 | //mMoveIncidenceOldDate; |
2564 | mDatePicker->setDate( da ); | 2564 | mDatePicker->setDate( da ); |
2565 | } | 2565 | } |
2566 | void CalendarView::showDatePickerPopup() | 2566 | void CalendarView::showDatePickerPopup() |
2567 | { | 2567 | { |
2568 | if ( mDateFrame->isVisible() ) | 2568 | if ( mDateFrame->isVisible() ) |
2569 | mDateFrame->hide(); | 2569 | mDateFrame->hide(); |
2570 | else { | 2570 | else { |
2571 | int offX = 0, offY = 0; | 2571 | int offX = 0, offY = 0; |
2572 | #ifdef DESKTOP_VERSION | 2572 | #ifdef DESKTOP_VERSION |
2573 | int w =mDatePicker->sizeHint().width() ; | 2573 | int w =mDatePicker->sizeHint().width() ; |
2574 | int h = mDatePicker->sizeHint().height() ; | 2574 | int h = mDatePicker->sizeHint().height() ; |
2575 | int dw = topLevelWidget()->width(); | 2575 | int dw = topLevelWidget()->width(); |
2576 | int dh = topLevelWidget()->height(); | 2576 | int dh = topLevelWidget()->height(); |
2577 | offX = topLevelWidget()->x(); | 2577 | offX = topLevelWidget()->x(); |
2578 | offY = topLevelWidget()->y(); | 2578 | offY = topLevelWidget()->y(); |
2579 | #else | 2579 | #else |
2580 | int w =mDatePicker->sizeHint().width() ; | 2580 | int w =mDatePicker->sizeHint().width() ; |
2581 | int h = mDatePicker->sizeHint().height() ; | 2581 | int h = mDatePicker->sizeHint().height() ; |
2582 | int dw = QApplication::desktop()->width(); | 2582 | int dw = QApplication::desktop()->width(); |
2583 | int dh = QApplication::desktop()->height(); | 2583 | int dh = QApplication::desktop()->height(); |
2584 | #endif | 2584 | #endif |
2585 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2585 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2586 | mDateFrame->show(); | 2586 | mDateFrame->show(); |
2587 | } | 2587 | } |
2588 | } | 2588 | } |
2589 | void CalendarView::showDatePicker( ) | 2589 | void CalendarView::showDatePicker( ) |
2590 | { | 2590 | { |
2591 | showDatePickerPopup(); | 2591 | showDatePickerPopup(); |
2592 | mDatePickerMode = 1; | 2592 | mDatePickerMode = 1; |
2593 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2593 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | void CalendarView::showEventEditor() | 2596 | void CalendarView::showEventEditor() |
2597 | { | 2597 | { |
2598 | #ifdef DESKTOP_VERSION | 2598 | #ifdef DESKTOP_VERSION |
2599 | int x,y,w,h; | 2599 | int x,y,w,h; |
2600 | x = mEventEditor->geometry().x(); | 2600 | x = mEventEditor->geometry().x(); |
2601 | y = mEventEditor->geometry().y(); | 2601 | y = mEventEditor->geometry().y(); |
2602 | w = mEventEditor->width(); | 2602 | w = mEventEditor->width(); |
2603 | h = mEventEditor->height(); | 2603 | h = mEventEditor->height(); |
2604 | mEventEditor->show(); | 2604 | mEventEditor->show(); |
2605 | mEventEditor->setGeometry(x,y,w,h); | 2605 | mEventEditor->setGeometry(x,y,w,h); |
2606 | #else | 2606 | #else |
2607 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2607 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2608 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2608 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2609 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2609 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2610 | qApp->processEvents(); | 2610 | qApp->processEvents(); |
2611 | delete mEventEditor; | 2611 | delete mEventEditor; |
2612 | mEventEditor = mDialogManager->getEventEditor(); | 2612 | mEventEditor = mDialogManager->getEventEditor(); |
2613 | topLevelWidget()->setCaption( i18n("") ); | 2613 | topLevelWidget()->setCaption( i18n("") ); |
2614 | } | 2614 | } |
2615 | mEventEditor->showMaximized(); | 2615 | mEventEditor->showMaximized(); |
2616 | #endif | 2616 | #endif |
2617 | } | 2617 | } |
2618 | void CalendarView::showTodoEditor() | 2618 | void CalendarView::showTodoEditor() |
2619 | { | 2619 | { |
2620 | #ifdef DESKTOP_VERSION | 2620 | #ifdef DESKTOP_VERSION |
2621 | int x,y,w,h; | 2621 | int x,y,w,h; |
2622 | x = mTodoEditor->geometry().x(); | 2622 | x = mTodoEditor->geometry().x(); |
2623 | y = mTodoEditor->geometry().y(); | 2623 | y = mTodoEditor->geometry().y(); |
2624 | w = mTodoEditor->width(); | 2624 | w = mTodoEditor->width(); |
2625 | h = mTodoEditor->height(); | 2625 | h = mTodoEditor->height(); |
2626 | mTodoEditor->show(); | 2626 | mTodoEditor->show(); |
2627 | mTodoEditor->setGeometry(x,y,w,h); | 2627 | mTodoEditor->setGeometry(x,y,w,h); |
2628 | #else | 2628 | #else |
2629 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2629 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2630 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2630 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2631 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2631 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2632 | qApp->processEvents(); | 2632 | qApp->processEvents(); |
2633 | delete mTodoEditor; | 2633 | delete mTodoEditor; |
2634 | mTodoEditor = mDialogManager->getTodoEditor(); | 2634 | mTodoEditor = mDialogManager->getTodoEditor(); |
2635 | topLevelWidget()->setCaption( i18n("") ); | 2635 | topLevelWidget()->setCaption( i18n("") ); |
2636 | } | 2636 | } |
2637 | mTodoEditor->showMaximized(); | 2637 | mTodoEditor->showMaximized(); |
2638 | #endif | 2638 | #endif |
2639 | } | 2639 | } |
2640 | 2640 | ||
2641 | void CalendarView::cloneIncidence() | 2641 | void CalendarView::cloneIncidence() |
2642 | { | 2642 | { |
2643 | Incidence *incidence = currentSelection(); | 2643 | Incidence *incidence = currentSelection(); |
2644 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2644 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2645 | if ( incidence ) { | 2645 | if ( incidence ) { |
2646 | cloneIncidence(incidence); | 2646 | cloneIncidence(incidence); |
2647 | } | 2647 | } |
2648 | } | 2648 | } |
2649 | void CalendarView::moveIncidence() | 2649 | void CalendarView::moveIncidence() |
2650 | { | 2650 | { |
2651 | Incidence *incidence = currentSelection(); | 2651 | Incidence *incidence = currentSelection(); |
2652 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2652 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2653 | if ( incidence ) { | 2653 | if ( incidence ) { |
2654 | moveIncidence(incidence); | 2654 | moveIncidence(incidence); |
2655 | } | 2655 | } |
2656 | } | 2656 | } |
2657 | void CalendarView::beamIncidence() | 2657 | void CalendarView::beamIncidence() |
2658 | { | 2658 | { |
2659 | Incidence *incidence = currentSelection(); | 2659 | Incidence *incidence = currentSelection(); |
2660 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2660 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2661 | if ( incidence ) { | 2661 | if ( incidence ) { |
2662 | beamIncidence(incidence); | 2662 | beamIncidence(incidence); |
2663 | } | 2663 | } |
2664 | } | 2664 | } |
2665 | void CalendarView::toggleCancelIncidence() | 2665 | void CalendarView::toggleCancelIncidence() |
2666 | { | 2666 | { |
2667 | Incidence *incidence = currentSelection(); | 2667 | Incidence *incidence = currentSelection(); |
2668 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2668 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2669 | if ( incidence ) { | 2669 | if ( incidence ) { |
2670 | cancelIncidence(incidence); | 2670 | cancelIncidence(incidence); |
2671 | } | 2671 | } |
2672 | } | 2672 | } |
2673 | 2673 | ||
2674 | 2674 | ||
2675 | void CalendarView::cancelIncidence(Incidence * inc ) | 2675 | void CalendarView::cancelIncidence(Incidence * inc ) |
2676 | { | 2676 | { |
2677 | inc->setCancelled( ! inc->cancelled() ); | 2677 | inc->setCancelled( ! inc->cancelled() ); |
2678 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2678 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2679 | updateView(); | 2679 | updateView(); |
2680 | } | 2680 | } |
2681 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2681 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2682 | { | 2682 | { |
2683 | Incidence * newInc = orgInc->clone(); | 2683 | Incidence * newInc = orgInc->clone(); |
2684 | newInc->recreate(); | 2684 | newInc->recreate(); |
2685 | 2685 | ||
2686 | if ( newInc->type() == "Todo" ) { | 2686 | if ( newInc->type() == "Todo" ) { |
2687 | Todo* t = (Todo*) newInc; | 2687 | Todo* t = (Todo*) newInc; |
2688 | showTodoEditor(); | 2688 | showTodoEditor(); |
2689 | mTodoEditor->editTodo( t ); | 2689 | mTodoEditor->editTodo( t ); |
2690 | if ( mTodoEditor->exec() ) { | 2690 | if ( mTodoEditor->exec() ) { |
2691 | mCalendar->addTodo( t ); | 2691 | mCalendar->addTodo( t ); |
2692 | updateView(); | 2692 | updateView(); |
2693 | } else { | 2693 | } else { |
2694 | delete t; | 2694 | delete t; |
2695 | } | 2695 | } |
2696 | } | 2696 | } |
2697 | else { | 2697 | else { |
2698 | Event* e = (Event*) newInc; | 2698 | Event* e = (Event*) newInc; |
2699 | showEventEditor(); | 2699 | showEventEditor(); |
2700 | mEventEditor->editEvent( e ); | 2700 | mEventEditor->editEvent( e ); |
2701 | if ( mEventEditor->exec() ) { | 2701 | if ( mEventEditor->exec() ) { |
2702 | mCalendar->addEvent( e ); | 2702 | mCalendar->addEvent( e ); |
2703 | updateView(); | 2703 | updateView(); |
2704 | } else { | 2704 | } else { |
2705 | delete e; | 2705 | delete e; |
2706 | } | 2706 | } |
2707 | } | 2707 | } |
2708 | setActiveWindow(); | 2708 | setActiveWindow(); |
2709 | } | 2709 | } |
2710 | 2710 | ||
2711 | void CalendarView::newEvent() | 2711 | void CalendarView::newEvent() |
2712 | { | 2712 | { |
2713 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2713 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2714 | KOAgendaView *aView = mViewManager->agendaView(); | 2714 | KOAgendaView *aView = mViewManager->agendaView(); |
2715 | if (aView) { | 2715 | if (aView) { |
2716 | if (aView->selectionStart().isValid()) { | 2716 | if (aView->selectionStart().isValid()) { |
2717 | if (aView->selectedIsAllDay()) { | 2717 | if (aView->selectedIsAllDay()) { |
2718 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2718 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2719 | } else { | 2719 | } else { |
2720 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2720 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2721 | } | 2721 | } |
2722 | return; | 2722 | return; |
2723 | } | 2723 | } |
2724 | } | 2724 | } |
2725 | 2725 | ||
2726 | QDate date = mNavigator->selectedDates().first(); | 2726 | QDate date = mNavigator->selectedDates().first(); |
2727 | QDateTime current = QDateTime::currentDateTime(); | 2727 | QDateTime current = QDateTime::currentDateTime(); |
2728 | if ( date <= current.date() ) { | 2728 | if ( date <= current.date() ) { |
2729 | int hour = current.time().hour() +1; | 2729 | int hour = current.time().hour() +1; |
2730 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2730 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2731 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2731 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2732 | } else | 2732 | } else |
2733 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2733 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2734 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2734 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2735 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2735 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2736 | } | 2736 | } |
2737 | 2737 | ||
2738 | void CalendarView::newEvent(QDateTime fh) | 2738 | void CalendarView::newEvent(QDateTime fh) |
2739 | { | 2739 | { |
2740 | newEvent(fh, | 2740 | newEvent(fh, |
2741 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2741 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2742 | } | 2742 | } |
2743 | 2743 | ||
2744 | void CalendarView::newEvent(QDate dt) | 2744 | void CalendarView::newEvent(QDate dt) |
2745 | { | 2745 | { |
2746 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2746 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2747 | QDateTime(dt, QTime(0,0,0)), true); | 2747 | QDateTime(dt, QTime(0,0,0)), true); |
2748 | } | 2748 | } |
2749 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2749 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2750 | { | 2750 | { |
2751 | newEvent(fromHint, toHint, false); | 2751 | newEvent(fromHint, toHint, false); |
2752 | } | 2752 | } |
2753 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2753 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2754 | { | 2754 | { |
2755 | 2755 | ||
2756 | showEventEditor(); | 2756 | showEventEditor(); |
2757 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2757 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2758 | if ( mFilterView->filtersEnabled() ) { | 2758 | if ( mFilterView->filtersEnabled() ) { |
2759 | CalFilter *filter = mFilterView->selectedFilter(); | 2759 | CalFilter *filter = mFilterView->selectedFilter(); |
2760 | if (filter && filter->showCategories()) { | 2760 | if (filter && filter->showCategories()) { |
2761 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2761 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2762 | } | 2762 | } |
2763 | if ( filter ) | 2763 | if ( filter ) |
2764 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2764 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2765 | } | 2765 | } |
2766 | mEventEditor->exec(); | 2766 | mEventEditor->exec(); |
2767 | setActiveWindow(); | 2767 | setActiveWindow(); |
2768 | } | 2768 | } |
2769 | void CalendarView::todoAdded(Todo * t) | 2769 | void CalendarView::todoAdded(Todo * t) |
2770 | { | 2770 | { |
2771 | 2771 | ||
2772 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2772 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2773 | updateTodoViews(); | 2773 | updateTodoViews(); |
2774 | } | 2774 | } |
2775 | void CalendarView::todoChanged(Todo * t) | 2775 | void CalendarView::todoChanged(Todo * t) |
2776 | { | 2776 | { |
2777 | emit todoModified( t, 4 ); | 2777 | emit todoModified( t, 4 ); |
2778 | // updateTodoViews(); | 2778 | // updateTodoViews(); |
2779 | } | 2779 | } |
2780 | void CalendarView::todoToBeDeleted(Todo *) | 2780 | void CalendarView::todoToBeDeleted(Todo *) |
2781 | { | 2781 | { |
2782 | //qDebug("todoToBeDeleted(Todo *) "); | 2782 | //qDebug("todoToBeDeleted(Todo *) "); |
2783 | updateTodoViews(); | 2783 | updateTodoViews(); |
2784 | } | 2784 | } |
2785 | void CalendarView::todoDeleted() | 2785 | void CalendarView::todoDeleted() |
2786 | { | 2786 | { |
2787 | //qDebug(" todoDeleted()"); | 2787 | //qDebug(" todoDeleted()"); |
2788 | updateTodoViews(); | 2788 | updateTodoViews(); |
2789 | } | 2789 | } |
2790 | 2790 | ||
2791 | 2791 | ||
2792 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2792 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2793 | { | 2793 | { |
2794 | showTodoEditor(); | 2794 | showTodoEditor(); |
2795 | mTodoEditor->newTodo(dt,0,allday); | 2795 | mTodoEditor->newTodo(dt,0,allday); |
2796 | if ( mFilterView->filtersEnabled() ) { | 2796 | if ( mFilterView->filtersEnabled() ) { |
2797 | CalFilter *filter = mFilterView->selectedFilter(); | 2797 | CalFilter *filter = mFilterView->selectedFilter(); |
2798 | if (filter && filter->showCategories()) { | 2798 | if (filter && filter->showCategories()) { |
2799 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2799 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2800 | } | 2800 | } |
2801 | if ( filter ) | 2801 | if ( filter ) |
2802 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2802 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2803 | } | 2803 | } |
2804 | mTodoEditor->exec(); | 2804 | mTodoEditor->exec(); |
2805 | setActiveWindow(); | 2805 | setActiveWindow(); |
2806 | } | 2806 | } |
2807 | 2807 | ||
2808 | void CalendarView::newTodo() | 2808 | void CalendarView::newTodo() |
2809 | { | 2809 | { |
2810 | newTodoDateTime( QDateTime(),true ); | 2810 | newTodoDateTime( QDateTime(),true ); |
2811 | } | 2811 | } |
2812 | 2812 | ||
2813 | void CalendarView::newSubTodo() | 2813 | void CalendarView::newSubTodo() |
2814 | { | 2814 | { |
2815 | Todo *todo = selectedTodo(); | 2815 | Todo *todo = selectedTodo(); |
2816 | if ( todo ) newSubTodo( todo ); | 2816 | if ( todo ) newSubTodo( todo ); |
2817 | } | 2817 | } |
2818 | 2818 | ||
2819 | void CalendarView::newSubTodo(Todo *parentEvent) | 2819 | void CalendarView::newSubTodo(Todo *parentEvent) |
2820 | { | 2820 | { |
2821 | 2821 | ||
2822 | showTodoEditor(); | 2822 | showTodoEditor(); |
2823 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2823 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2824 | mTodoEditor->exec(); | 2824 | mTodoEditor->exec(); |
2825 | setActiveWindow(); | 2825 | setActiveWindow(); |
2826 | } | 2826 | } |
2827 | 2827 | ||
2828 | void CalendarView::newFloatingEvent() | 2828 | void CalendarView::newFloatingEvent() |
2829 | { | 2829 | { |
2830 | DateList tmpList = mNavigator->selectedDates(); | 2830 | DateList tmpList = mNavigator->selectedDates(); |
2831 | QDate date = tmpList.first(); | 2831 | QDate date = tmpList.first(); |
2832 | 2832 | ||
2833 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2833 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2834 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2834 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2835 | } | 2835 | } |
2836 | 2836 | ||
2837 | 2837 | ||
2838 | void CalendarView::editEvent( Event *event ) | 2838 | void CalendarView::editEvent( Event *event ) |
2839 | { | 2839 | { |
2840 | 2840 | ||
2841 | if ( !event ) return; | 2841 | if ( !event ) return; |
2842 | if ( event->isReadOnly() ) { | 2842 | if ( event->isReadOnly() ) { |
2843 | showEvent( event ); | 2843 | showEvent( event ); |
2844 | return; | 2844 | return; |
2845 | } | 2845 | } |
2846 | showEventEditor(); | 2846 | showEventEditor(); |
2847 | mEventEditor->editEvent( event , mFlagEditDescription); | 2847 | mEventEditor->editEvent( event , mFlagEditDescription); |
2848 | mEventEditor->exec(); | 2848 | mEventEditor->exec(); |
2849 | setActiveWindow(); | 2849 | setActiveWindow(); |
2850 | 2850 | ||
2851 | } | 2851 | } |
2852 | void CalendarView::editJournal( Journal *jour ) | 2852 | void CalendarView::editJournal( Journal *jour ) |
2853 | { | 2853 | { |
2854 | if ( !jour ) return; | 2854 | if ( !jour ) return; |
2855 | mDialogManager->hideSearchDialog(); | 2855 | mDialogManager->hideSearchDialog(); |
2856 | mViewManager->showJournalView(); | 2856 | mViewManager->showJournalView(); |
2857 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2857 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2858 | } | 2858 | } |
2859 | void CalendarView::editTodo( Todo *todo ) | 2859 | void CalendarView::editTodo( Todo *todo ) |
2860 | { | 2860 | { |
2861 | if ( !todo ) return; | 2861 | if ( !todo ) return; |
2862 | 2862 | ||
2863 | if ( todo->isReadOnly() ) { | 2863 | if ( todo->isReadOnly() ) { |
2864 | showTodo( todo ); | 2864 | showTodo( todo ); |
2865 | return; | 2865 | return; |
2866 | } | 2866 | } |
2867 | showTodoEditor(); | 2867 | showTodoEditor(); |
2868 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2868 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2869 | mTodoEditor->exec(); | 2869 | mTodoEditor->exec(); |
2870 | setActiveWindow(); | 2870 | setActiveWindow(); |
2871 | 2871 | ||
2872 | } | 2872 | } |
2873 | 2873 | ||
2874 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2874 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2875 | { | 2875 | { |
2876 | if ( !mEventViewerDialog ) { | 2876 | if ( !mEventViewerDialog ) { |
2877 | mEventViewerDialog = new KOEventViewerDialog(0); | 2877 | mEventViewerDialog = new KOEventViewerDialog(0); |
2878 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2878 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2879 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2879 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2880 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2880 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2881 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2881 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2882 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2882 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2883 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2883 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2884 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 2884 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
2885 | this, SLOT( slotViewerClosed() ) ); | 2885 | this, SLOT( slotViewerClosed() ) ); |
2886 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2886 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2887 | this, SLOT( todoChanged(Todo *) ) ); | 2887 | this, SLOT( todoChanged(Todo *) ) ); |
2888 | mEventViewerDialog->resize( 640, 480 ); | 2888 | mEventViewerDialog->resize( 640, 480 ); |
2889 | 2889 | ||
2890 | } | 2890 | } |
2891 | return mEventViewerDialog; | 2891 | return mEventViewerDialog; |
2892 | } | 2892 | } |
2893 | void CalendarView::showEvent(Event *event) | 2893 | void CalendarView::showEvent(Event *event) |
2894 | { | 2894 | { |
2895 | getEventViewerDialog()->setEvent(event); | 2895 | getEventViewerDialog()->setEvent(event); |
2896 | getEventViewerDialog()->showMe(); | 2896 | getEventViewerDialog()->showMe(); |
2897 | } | 2897 | } |
2898 | 2898 | ||
2899 | void CalendarView::showTodo(Todo *event) | 2899 | void CalendarView::showTodo(Todo *event) |
2900 | { | 2900 | { |
2901 | getEventViewerDialog()->setTodo(event); | 2901 | getEventViewerDialog()->setTodo(event); |
2902 | getEventViewerDialog()->showMe(); | 2902 | getEventViewerDialog()->showMe(); |
2903 | } | 2903 | } |
2904 | void CalendarView::showJournal( Journal *jour ) | 2904 | void CalendarView::showJournal( Journal *jour ) |
2905 | { | 2905 | { |
2906 | getEventViewerDialog()->setJournal(jour); | 2906 | getEventViewerDialog()->setJournal(jour); |
2907 | getEventViewerDialog()->showMe(); | 2907 | getEventViewerDialog()->showMe(); |
2908 | 2908 | ||
2909 | } | 2909 | } |
2910 | // void CalendarView::todoModified (Todo *event, int changed) | 2910 | // void CalendarView::todoModified (Todo *event, int changed) |
2911 | // { | 2911 | // { |
2912 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2912 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2913 | // // kdDebug() << "Todo modified and open" << endl; | 2913 | // // kdDebug() << "Todo modified and open" << endl; |
2914 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2914 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2915 | // // temp->modified (changed); | 2915 | // // temp->modified (changed); |
2916 | 2916 | ||
2917 | // // } | 2917 | // // } |
2918 | 2918 | ||
2919 | // mViewManager->updateView(); | 2919 | // mViewManager->updateView(); |
2920 | // } | 2920 | // } |
2921 | 2921 | ||
2922 | void CalendarView::appointment_show() | 2922 | void CalendarView::appointment_show() |
2923 | { | 2923 | { |
2924 | Event *anEvent = 0; | 2924 | Event *anEvent = 0; |
2925 | 2925 | ||
2926 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2926 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2927 | 2927 | ||
2928 | if (mViewManager->currentView()->isEventView()) { | 2928 | if (mViewManager->currentView()->isEventView()) { |
2929 | if ( incidence && incidence->type() == "Event" ) { | 2929 | if ( incidence && incidence->type() == "Event" ) { |
2930 | anEvent = static_cast<Event *>(incidence); | 2930 | anEvent = static_cast<Event *>(incidence); |
2931 | } | 2931 | } |
2932 | } | 2932 | } |
2933 | 2933 | ||
2934 | if (!anEvent) { | 2934 | if (!anEvent) { |
2935 | KNotifyClient::beep(); | 2935 | KNotifyClient::beep(); |
2936 | return; | 2936 | return; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | showEvent(anEvent); | 2939 | showEvent(anEvent); |
2940 | } | 2940 | } |
2941 | 2941 | ||
2942 | void CalendarView::appointment_edit() | 2942 | void CalendarView::appointment_edit() |
2943 | { | 2943 | { |
2944 | Event *anEvent = 0; | 2944 | Event *anEvent = 0; |
2945 | 2945 | ||
2946 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2946 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2947 | 2947 | ||
2948 | if (mViewManager->currentView()->isEventView()) { | 2948 | if (mViewManager->currentView()->isEventView()) { |
2949 | if ( incidence && incidence->type() == "Event" ) { | 2949 | if ( incidence && incidence->type() == "Event" ) { |
2950 | anEvent = static_cast<Event *>(incidence); | 2950 | anEvent = static_cast<Event *>(incidence); |
2951 | } | 2951 | } |
2952 | } | 2952 | } |
2953 | 2953 | ||
2954 | if (!anEvent) { | 2954 | if (!anEvent) { |
2955 | KNotifyClient::beep(); | 2955 | KNotifyClient::beep(); |
2956 | return; | 2956 | return; |
2957 | } | 2957 | } |
2958 | 2958 | ||
2959 | editEvent(anEvent); | 2959 | editEvent(anEvent); |
2960 | } | 2960 | } |
2961 | 2961 | ||
2962 | void CalendarView::appointment_delete() | 2962 | void CalendarView::appointment_delete() |
2963 | { | 2963 | { |
2964 | Event *anEvent = 0; | 2964 | Event *anEvent = 0; |
2965 | 2965 | ||
2966 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2966 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2967 | 2967 | ||
2968 | if (mViewManager->currentView()->isEventView()) { | 2968 | if (mViewManager->currentView()->isEventView()) { |
2969 | if ( incidence && incidence->type() == "Event" ) { | 2969 | if ( incidence && incidence->type() == "Event" ) { |
2970 | anEvent = static_cast<Event *>(incidence); | 2970 | anEvent = static_cast<Event *>(incidence); |
2971 | } | 2971 | } |
2972 | } | 2972 | } |
2973 | 2973 | ||
2974 | if (!anEvent) { | 2974 | if (!anEvent) { |
2975 | KNotifyClient::beep(); | 2975 | KNotifyClient::beep(); |
2976 | return; | 2976 | return; |
2977 | } | 2977 | } |
2978 | 2978 | ||
2979 | deleteEvent(anEvent); | 2979 | deleteEvent(anEvent); |
2980 | } | 2980 | } |
2981 | 2981 | ||
2982 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2982 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2983 | { | 2983 | { |
2984 | if (!sub) return; | 2984 | if (!sub) return; |
2985 | if (!parent) return; | 2985 | if (!parent) return; |
2986 | if ( sub->relatedTo() ) | 2986 | if ( sub->relatedTo() ) |
2987 | sub->relatedTo()->removeRelation(sub); | 2987 | sub->relatedTo()->removeRelation(sub); |
2988 | sub->setRelatedTo(parent); | 2988 | sub->setRelatedTo(parent); |
2989 | sub->setRelatedToUid(parent->uid()); | 2989 | sub->setRelatedToUid(parent->uid()); |
2990 | parent->addRelation(sub); | 2990 | parent->addRelation(sub); |
2991 | sub->updated(); | 2991 | sub->updated(); |
2992 | parent->updated(); | 2992 | parent->updated(); |
2993 | setModified(true); | 2993 | setModified(true); |
2994 | updateView(); | 2994 | updateView(); |
2995 | } | 2995 | } |
2996 | void CalendarView::todo_unsub(Todo *anTodo ) | 2996 | void CalendarView::todo_unsub(Todo *anTodo ) |
2997 | { | 2997 | { |
2998 | // Todo *anTodo = selectedTodo(); | 2998 | // Todo *anTodo = selectedTodo(); |
2999 | if (!anTodo) return; | 2999 | if (!anTodo) return; |
3000 | if (!anTodo->relatedTo()) return; | 3000 | if (!anTodo->relatedTo()) return; |
3001 | anTodo->relatedTo()->removeRelation(anTodo); | 3001 | anTodo->relatedTo()->removeRelation(anTodo); |
3002 | anTodo->setRelatedTo(0); | 3002 | anTodo->setRelatedTo(0); |
3003 | anTodo->updated(); | 3003 | anTodo->updated(); |
3004 | anTodo->setRelatedToUid(""); | 3004 | anTodo->setRelatedToUid(""); |
3005 | setModified(true); | 3005 | setModified(true); |
3006 | updateView(); | 3006 | updateView(); |
3007 | } | 3007 | } |
3008 | 3008 | ||
3009 | void CalendarView::deleteTodo(Todo *todo) | 3009 | void CalendarView::deleteTodo(Todo *todo) |
3010 | { | 3010 | { |
3011 | if (!todo) { | 3011 | if (!todo) { |
3012 | KNotifyClient::beep(); | 3012 | KNotifyClient::beep(); |
3013 | return; | 3013 | return; |
3014 | } | 3014 | } |
3015 | if (KOPrefs::instance()->mConfirm) { | 3015 | if (KOPrefs::instance()->mConfirm) { |
3016 | QString text = todo->summary().left(20); | 3016 | QString text = todo->summary().left(20); |
3017 | if (!todo->relations().isEmpty()) { | 3017 | if (!todo->relations().isEmpty()) { |
3018 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3018 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3019 | 3019 | ||
3020 | } | 3020 | } |
3021 | switch (msgItemDelete(text)) { | 3021 | switch (msgItemDelete(text)) { |
3022 | case KMessageBox::Continue: // OK | 3022 | case KMessageBox::Continue: // OK |
3023 | bool deleteT = false; | 3023 | bool deleteT = false; |
3024 | if (!todo->relations().isEmpty()) { | 3024 | if (!todo->relations().isEmpty()) { |
3025 | deleteT = removeCompletedSubTodos( todo ); | 3025 | deleteT = removeCompletedSubTodos( todo ); |
3026 | } | 3026 | } |
3027 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3027 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3028 | if ( !deleteT ) { | 3028 | if ( !deleteT ) { |
3029 | checkExternalId( todo ); | 3029 | checkExternalId( todo ); |
3030 | calendar()->deleteTodo(todo); | 3030 | calendar()->deleteTodo(todo); |
3031 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3031 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3032 | updateView(); | 3032 | updateView(); |
3033 | } | 3033 | } |
3034 | break; | 3034 | break; |
3035 | } // switch | 3035 | } // switch |
3036 | } else { | 3036 | } else { |
3037 | checkExternalId( todo ); | 3037 | checkExternalId( todo ); |
3038 | mCalendar->deleteTodo(todo); | 3038 | mCalendar->deleteTodo(todo); |
3039 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3039 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3040 | updateView(); | 3040 | updateView(); |
3041 | } | 3041 | } |
3042 | 3042 | ||
3043 | emit updateSearchDialog(); | 3043 | emit updateSearchDialog(); |
3044 | } | 3044 | } |
3045 | void CalendarView::deleteJournal(Journal *jour) | 3045 | void CalendarView::deleteJournal(Journal *jour) |
3046 | { | 3046 | { |
3047 | if (!jour) { | 3047 | if (!jour) { |
3048 | KNotifyClient::beep(); | 3048 | KNotifyClient::beep(); |
3049 | return; | 3049 | return; |
3050 | } | 3050 | } |
3051 | if (KOPrefs::instance()->mConfirm) { | 3051 | if (KOPrefs::instance()->mConfirm) { |
3052 | switch (msgItemDelete( jour->description().left(20))) { | 3052 | switch (msgItemDelete( jour->description().left(20))) { |
3053 | case KMessageBox::Continue: // OK | 3053 | case KMessageBox::Continue: // OK |
3054 | calendar()->deleteJournal(jour); | 3054 | calendar()->deleteJournal(jour); |
3055 | updateView(); | 3055 | updateView(); |
3056 | break; | 3056 | break; |
3057 | } // switch | 3057 | } // switch |
3058 | } else { | 3058 | } else { |
3059 | calendar()->deleteJournal(jour);; | 3059 | calendar()->deleteJournal(jour);; |
3060 | updateView(); | 3060 | updateView(); |
3061 | } | 3061 | } |
3062 | emit updateSearchDialog(); | 3062 | emit updateSearchDialog(); |
3063 | } | 3063 | } |
3064 | 3064 | ||
3065 | void CalendarView::deleteEvent(Event *anEvent) | 3065 | void CalendarView::deleteEvent(Event *anEvent) |
3066 | { | 3066 | { |
3067 | if (!anEvent) { | 3067 | if (!anEvent) { |
3068 | KNotifyClient::beep(); | 3068 | KNotifyClient::beep(); |
3069 | return; | 3069 | return; |
3070 | } | 3070 | } |
3071 | 3071 | ||
3072 | if (anEvent->recurrence()->doesRecur()) { | 3072 | if (anEvent->recurrence()->doesRecur()) { |
3073 | QDate itemDate = mViewManager->currentSelectionDate(); | 3073 | QDate itemDate = mViewManager->currentSelectionDate(); |
3074 | int km; | 3074 | int km; |
3075 | if (!itemDate.isValid()) { | 3075 | if (!itemDate.isValid()) { |
3076 | //kdDebug() << "Date Not Valid" << endl; | 3076 | //kdDebug() << "Date Not Valid" << endl; |
3077 | if (KOPrefs::instance()->mConfirm) { | 3077 | if (KOPrefs::instance()->mConfirm) { |
3078 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3078 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3079 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3079 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3080 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3080 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3081 | if ( km == KMessageBox::Continue ) | 3081 | if ( km == KMessageBox::Continue ) |
3082 | km = KMessageBox::No; // No = all below | 3082 | km = KMessageBox::No; // No = all below |
3083 | } else | 3083 | } else |
3084 | km = KMessageBox::No; | 3084 | km = KMessageBox::No; |
3085 | } else { | 3085 | } else { |
3086 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3086 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3087 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3087 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3088 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3088 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3089 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3089 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3090 | i18n("All")); | 3090 | i18n("All")); |
3091 | } | 3091 | } |
3092 | switch(km) { | 3092 | switch(km) { |
3093 | 3093 | ||
3094 | case KMessageBox::No: // Continue // all | 3094 | case KMessageBox::No: // Continue // all |
3095 | //qDebug("KMessageBox::No "); | 3095 | //qDebug("KMessageBox::No "); |
3096 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3096 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3097 | schedule(Scheduler::Cancel,anEvent); | 3097 | schedule(Scheduler::Cancel,anEvent); |
3098 | 3098 | ||
3099 | checkExternalId( anEvent); | 3099 | checkExternalId( anEvent); |
3100 | mCalendar->deleteEvent(anEvent); | 3100 | mCalendar->deleteEvent(anEvent); |
3101 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3101 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3102 | break; | 3102 | break; |
3103 | 3103 | ||
3104 | // Disabled because it does not work | 3104 | // Disabled because it does not work |
3105 | //#if 0 | 3105 | //#if 0 |
3106 | case KMessageBox::Yes: // just this one | 3106 | case KMessageBox::Yes: // just this one |
3107 | //QDate qd = mNavigator->selectedDates().first(); | 3107 | //QDate qd = mNavigator->selectedDates().first(); |
3108 | //if (!qd.isValid()) { | 3108 | //if (!qd.isValid()) { |
3109 | // kdDebug() << "no date selected, or invalid date" << endl; | 3109 | // kdDebug() << "no date selected, or invalid date" << endl; |
3110 | // KNotifyClient::beep(); | 3110 | // KNotifyClient::beep(); |
3111 | // return; | 3111 | // return; |
3112 | //} | 3112 | //} |
3113 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3113 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3114 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3114 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3115 | anEvent->addExDate(itemDate); | 3115 | anEvent->addExDate(itemDate); |
3116 | int duration = anEvent->recurrence()->duration(); | 3116 | int duration = anEvent->recurrence()->duration(); |
3117 | if ( duration > 0 ) { | 3117 | if ( duration > 0 ) { |
3118 | anEvent->recurrence()->setDuration( duration - 1 ); | 3118 | anEvent->recurrence()->setDuration( duration - 1 ); |
3119 | } | 3119 | } |
3120 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3120 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3121 | } | 3121 | } |
3122 | break; | 3122 | break; |
3123 | //#endif | 3123 | //#endif |
3124 | } // switch | 3124 | } // switch |
3125 | } else { | 3125 | } else { |
3126 | if (KOPrefs::instance()->mConfirm) { | 3126 | if (KOPrefs::instance()->mConfirm) { |
3127 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3127 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3128 | i18n("\nAre you sure you want\nto delete this event?"), | 3128 | i18n("\nAre you sure you want\nto delete this event?"), |
3129 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3129 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3130 | case KMessageBox::Continue: // OK | 3130 | case KMessageBox::Continue: // OK |
3131 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3131 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3132 | schedule(Scheduler::Cancel,anEvent); | 3132 | schedule(Scheduler::Cancel,anEvent); |
3133 | checkExternalId( anEvent); | 3133 | checkExternalId( anEvent); |
3134 | mCalendar->deleteEvent(anEvent); | 3134 | mCalendar->deleteEvent(anEvent); |
3135 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3135 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3136 | break; | 3136 | break; |
3137 | } // switch | 3137 | } // switch |
3138 | } else { | 3138 | } else { |
3139 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3139 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3140 | schedule(Scheduler::Cancel,anEvent); | 3140 | schedule(Scheduler::Cancel,anEvent); |
3141 | checkExternalId( anEvent); | 3141 | checkExternalId( anEvent); |
3142 | mCalendar->deleteEvent(anEvent); | 3142 | mCalendar->deleteEvent(anEvent); |
3143 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3143 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3144 | } | 3144 | } |
3145 | } // if-else | 3145 | } // if-else |
3146 | emit updateSearchDialog(); | 3146 | emit updateSearchDialog(); |
3147 | } | 3147 | } |
3148 | 3148 | ||
3149 | bool CalendarView::deleteEvent(const QString &uid) | 3149 | bool CalendarView::deleteEvent(const QString &uid) |
3150 | { | 3150 | { |
3151 | Event *ev = mCalendar->event(uid); | 3151 | Event *ev = mCalendar->event(uid); |
3152 | if (ev) { | 3152 | if (ev) { |
3153 | deleteEvent(ev); | 3153 | deleteEvent(ev); |
3154 | return true; | 3154 | return true; |
3155 | } else { | 3155 | } else { |
3156 | return false; | 3156 | return false; |
3157 | } | 3157 | } |
3158 | } | 3158 | } |
3159 | 3159 | ||
3160 | /*****************************************************************************/ | 3160 | /*****************************************************************************/ |
3161 | 3161 | ||
3162 | void CalendarView::action_mail() | 3162 | void CalendarView::action_mail() |
3163 | { | 3163 | { |
3164 | #ifndef KORG_NOMAIL | 3164 | #ifndef KORG_NOMAIL |
3165 | KOMailClient mailClient; | 3165 | KOMailClient mailClient; |
3166 | 3166 | ||
3167 | Incidence *incidence = currentSelection(); | 3167 | Incidence *incidence = currentSelection(); |
3168 | 3168 | ||
3169 | if (!incidence) { | 3169 | if (!incidence) { |
3170 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3170 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3171 | return; | 3171 | return; |
3172 | } | 3172 | } |
3173 | if(incidence->attendeeCount() == 0 ) { | 3173 | if(incidence->attendeeCount() == 0 ) { |
3174 | KMessageBox::sorry(this, | 3174 | KMessageBox::sorry(this, |
3175 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3175 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3176 | return; | 3176 | return; |
3177 | } | 3177 | } |
3178 | 3178 | ||
3179 | CalendarLocal cal_tmp; | 3179 | CalendarLocal cal_tmp; |
3180 | Event *event = 0; | 3180 | Event *event = 0; |
3181 | Event *ev = 0; | 3181 | Event *ev = 0; |
3182 | if ( incidence && incidence->type() == "Event" ) { | 3182 | if ( incidence && incidence->type() == "Event" ) { |
3183 | event = static_cast<Event *>(incidence); | 3183 | event = static_cast<Event *>(incidence); |
3184 | ev = new Event(*event); | 3184 | ev = new Event(*event); |
3185 | cal_tmp.addEvent(ev); | 3185 | cal_tmp.addEvent(ev); |
3186 | } | 3186 | } |
3187 | ICalFormat mForm(); | 3187 | ICalFormat mForm(); |
3188 | QString attachment = mForm.toString( &cal_tmp ); | 3188 | QString attachment = mForm.toString( &cal_tmp ); |
3189 | if (ev) delete(ev); | 3189 | if (ev) delete(ev); |
3190 | 3190 | ||
3191 | mailClient.mailAttendees(currentSelection(), attachment); | 3191 | mailClient.mailAttendees(currentSelection(), attachment); |
3192 | 3192 | ||
3193 | #endif | 3193 | #endif |
3194 | 3194 | ||
3195 | #if 0 | 3195 | #if 0 |
3196 | Event *anEvent = 0; | 3196 | Event *anEvent = 0; |
3197 | if (mViewManager->currentView()->isEventView()) { | 3197 | if (mViewManager->currentView()->isEventView()) { |
3198 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3198 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3199 | } | 3199 | } |
3200 | 3200 | ||
3201 | if (!anEvent) { | 3201 | if (!anEvent) { |
3202 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3202 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3203 | return; | 3203 | return; |
3204 | } | 3204 | } |
3205 | if(anEvent->attendeeCount() == 0 ) { | 3205 | if(anEvent->attendeeCount() == 0 ) { |
3206 | KMessageBox::sorry(this, | 3206 | KMessageBox::sorry(this, |
3207 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3207 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3208 | return; | 3208 | return; |
3209 | } | 3209 | } |
3210 | 3210 | ||
3211 | mailobject.emailEvent(anEvent); | 3211 | mailobject.emailEvent(anEvent); |
3212 | #endif | 3212 | #endif |
3213 | } | 3213 | } |
3214 | 3214 | ||
3215 | 3215 | ||
3216 | void CalendarView::schedule_publish(Incidence *incidence) | 3216 | void CalendarView::schedule_publish(Incidence *incidence) |
3217 | { | 3217 | { |
3218 | Event *event = 0; | 3218 | Event *event = 0; |
3219 | Todo *todo = 0; | 3219 | Todo *todo = 0; |
3220 | 3220 | ||
3221 | if (incidence == 0) { | 3221 | if (incidence == 0) { |
3222 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3222 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3223 | if (incidence == 0) { | 3223 | if (incidence == 0) { |
3224 | incidence = mTodoList->selectedIncidences().first(); | 3224 | incidence = mTodoList->selectedIncidences().first(); |
3225 | } | 3225 | } |
3226 | } | 3226 | } |
3227 | if ( incidence && incidence->type() == "Event" ) { | 3227 | if ( incidence && incidence->type() == "Event" ) { |
3228 | event = static_cast<Event *>(incidence); | 3228 | event = static_cast<Event *>(incidence); |
3229 | } else { | 3229 | } else { |
3230 | if ( incidence && incidence->type() == "Todo" ) { | 3230 | if ( incidence && incidence->type() == "Todo" ) { |
3231 | todo = static_cast<Todo *>(incidence); | 3231 | todo = static_cast<Todo *>(incidence); |
3232 | } | 3232 | } |
3233 | } | 3233 | } |
3234 | 3234 | ||
3235 | if (!event && !todo) { | 3235 | if (!event && !todo) { |
3236 | KMessageBox::sorry(this,i18n("No event selected.")); | 3236 | KMessageBox::sorry(this,i18n("No event selected.")); |
3237 | return; | 3237 | return; |
3238 | } | 3238 | } |
3239 | 3239 | ||
3240 | PublishDialog *publishdlg = new PublishDialog(); | 3240 | PublishDialog *publishdlg = new PublishDialog(); |
3241 | if (incidence->attendeeCount()>0) { | 3241 | if (incidence->attendeeCount()>0) { |
3242 | QPtrList<Attendee> attendees = incidence->attendees(); | 3242 | QPtrList<Attendee> attendees = incidence->attendees(); |
3243 | attendees.first(); | 3243 | attendees.first(); |
3244 | while ( attendees.current()!=0 ) { | 3244 | while ( attendees.current()!=0 ) { |
3245 | publishdlg->addAttendee(attendees.current()); | 3245 | publishdlg->addAttendee(attendees.current()); |
3246 | attendees.next(); | 3246 | attendees.next(); |
3247 | } | 3247 | } |
3248 | } | 3248 | } |
3249 | bool send = true; | 3249 | bool send = true; |
3250 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3250 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3251 | if ( publishdlg->exec() != QDialog::Accepted ) | 3251 | if ( publishdlg->exec() != QDialog::Accepted ) |
3252 | send = false; | 3252 | send = false; |
3253 | } | 3253 | } |
3254 | if ( send ) { | 3254 | if ( send ) { |
3255 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3255 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3256 | if ( event ) { | 3256 | if ( event ) { |
3257 | Event *ev = new Event(*event); | 3257 | Event *ev = new Event(*event); |
3258 | ev->registerObserver(0); | 3258 | ev->registerObserver(0); |
3259 | ev->clearAttendees(); | 3259 | ev->clearAttendees(); |
3260 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3260 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3261 | delete(ev); | 3261 | delete(ev); |
3262 | } | 3262 | } |
3263 | } else { | 3263 | } else { |
3264 | if ( todo ) { | 3264 | if ( todo ) { |
3265 | Todo *ev = new Todo(*todo); | 3265 | Todo *ev = new Todo(*todo); |
3266 | ev->registerObserver(0); | 3266 | ev->registerObserver(0); |
3267 | ev->clearAttendees(); | 3267 | ev->clearAttendees(); |
3268 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3268 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3269 | delete(ev); | 3269 | delete(ev); |
3270 | } | 3270 | } |
3271 | } | 3271 | } |
3272 | } | 3272 | } |
3273 | } | 3273 | } |
3274 | delete publishdlg; | 3274 | delete publishdlg; |
3275 | } | 3275 | } |
3276 | 3276 | ||
3277 | void CalendarView::schedule_request(Incidence *incidence) | 3277 | void CalendarView::schedule_request(Incidence *incidence) |
3278 | { | 3278 | { |
3279 | schedule(Scheduler::Request,incidence); | 3279 | schedule(Scheduler::Request,incidence); |
3280 | } | 3280 | } |
3281 | 3281 | ||
3282 | void CalendarView::schedule_refresh(Incidence *incidence) | 3282 | void CalendarView::schedule_refresh(Incidence *incidence) |
3283 | { | 3283 | { |
3284 | schedule(Scheduler::Refresh,incidence); | 3284 | schedule(Scheduler::Refresh,incidence); |
3285 | } | 3285 | } |
3286 | 3286 | ||
3287 | void CalendarView::schedule_cancel(Incidence *incidence) | 3287 | void CalendarView::schedule_cancel(Incidence *incidence) |
3288 | { | 3288 | { |
3289 | schedule(Scheduler::Cancel,incidence); | 3289 | schedule(Scheduler::Cancel,incidence); |
3290 | } | 3290 | } |
3291 | 3291 | ||
3292 | void CalendarView::schedule_add(Incidence *incidence) | 3292 | void CalendarView::schedule_add(Incidence *incidence) |
3293 | { | 3293 | { |
3294 | schedule(Scheduler::Add,incidence); | 3294 | schedule(Scheduler::Add,incidence); |
3295 | } | 3295 | } |
3296 | 3296 | ||
3297 | void CalendarView::schedule_reply(Incidence *incidence) | 3297 | void CalendarView::schedule_reply(Incidence *incidence) |
3298 | { | 3298 | { |
3299 | schedule(Scheduler::Reply,incidence); | 3299 | schedule(Scheduler::Reply,incidence); |
3300 | } | 3300 | } |
3301 | 3301 | ||
3302 | void CalendarView::schedule_counter(Incidence *incidence) | 3302 | void CalendarView::schedule_counter(Incidence *incidence) |
3303 | { | 3303 | { |
3304 | schedule(Scheduler::Counter,incidence); | 3304 | schedule(Scheduler::Counter,incidence); |
3305 | } | 3305 | } |
3306 | 3306 | ||
3307 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3307 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3308 | { | 3308 | { |
3309 | schedule(Scheduler::Declinecounter,incidence); | 3309 | schedule(Scheduler::Declinecounter,incidence); |
3310 | } | 3310 | } |
3311 | 3311 | ||
3312 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3312 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3313 | { | 3313 | { |
3314 | QDateTime start = QDateTime::currentDateTime(); | 3314 | QDateTime start = QDateTime::currentDateTime(); |
3315 | QDateTime end = start.addDays(daysToPublish); | 3315 | QDateTime end = start.addDays(daysToPublish); |
3316 | 3316 | ||
3317 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3317 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3318 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3318 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3319 | 3319 | ||
3320 | 3320 | ||
3321 | PublishDialog *publishdlg = new PublishDialog(); | 3321 | PublishDialog *publishdlg = new PublishDialog(); |
3322 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3322 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3323 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3323 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3324 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3324 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3325 | delete(freebusy); | 3325 | delete(freebusy); |
3326 | } | 3326 | } |
3327 | } | 3327 | } |
3328 | delete publishdlg; | 3328 | delete publishdlg; |
3329 | } | 3329 | } |
3330 | 3330 | ||
3331 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3331 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3332 | { | 3332 | { |
3333 | Event *event = 0; | 3333 | Event *event = 0; |
3334 | Todo *todo = 0; | 3334 | Todo *todo = 0; |
3335 | 3335 | ||
3336 | if (incidence == 0) { | 3336 | if (incidence == 0) { |
3337 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3337 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3338 | if (incidence == 0) { | 3338 | if (incidence == 0) { |
3339 | incidence = mTodoList->selectedIncidences().first(); | 3339 | incidence = mTodoList->selectedIncidences().first(); |
3340 | } | 3340 | } |
3341 | } | 3341 | } |
3342 | if ( incidence && incidence->type() == "Event" ) { | 3342 | if ( incidence && incidence->type() == "Event" ) { |
3343 | event = static_cast<Event *>(incidence); | 3343 | event = static_cast<Event *>(incidence); |
3344 | } | 3344 | } |
3345 | if ( incidence && incidence->type() == "Todo" ) { | 3345 | if ( incidence && incidence->type() == "Todo" ) { |
3346 | todo = static_cast<Todo *>(incidence); | 3346 | todo = static_cast<Todo *>(incidence); |
3347 | } | 3347 | } |
3348 | 3348 | ||
3349 | if (!event && !todo) { | 3349 | if (!event && !todo) { |
3350 | KMessageBox::sorry(this,i18n("No event selected.")); | 3350 | KMessageBox::sorry(this,i18n("No event selected.")); |
3351 | return; | 3351 | return; |
3352 | } | 3352 | } |
3353 | 3353 | ||
3354 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3354 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3355 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3355 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3356 | return; | 3356 | return; |
3357 | } | 3357 | } |
3358 | 3358 | ||
3359 | Event *ev = 0; | 3359 | Event *ev = 0; |
3360 | if (event) ev = new Event(*event); | 3360 | if (event) ev = new Event(*event); |
3361 | Todo *to = 0; | 3361 | Todo *to = 0; |
3362 | if (todo) to = new Todo(*todo); | 3362 | if (todo) to = new Todo(*todo); |
3363 | 3363 | ||
3364 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3364 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3365 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3365 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3366 | if (!me) { | 3366 | if (!me) { |
3367 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3367 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3368 | return; | 3368 | return; |
3369 | } | 3369 | } |
3370 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3370 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3371 | StatusDialog *statdlg = new StatusDialog(this); | 3371 | StatusDialog *statdlg = new StatusDialog(this); |
3372 | if (!statdlg->exec()==QDialog::Accepted) return; | 3372 | if (!statdlg->exec()==QDialog::Accepted) return; |
3373 | me->setStatus( statdlg->status() ); | 3373 | me->setStatus( statdlg->status() ); |
3374 | delete(statdlg); | 3374 | delete(statdlg); |
3375 | } | 3375 | } |
3376 | Attendee *menew = new Attendee(*me); | 3376 | Attendee *menew = new Attendee(*me); |
3377 | if (ev) { | 3377 | if (ev) { |
3378 | ev->clearAttendees(); | 3378 | ev->clearAttendees(); |
3379 | ev->addAttendee(menew,false); | 3379 | ev->addAttendee(menew,false); |
3380 | } else { | 3380 | } else { |
3381 | if (to) { | 3381 | if (to) { |
3382 | todo->clearAttendees(); | 3382 | todo->clearAttendees(); |
3383 | todo->addAttendee(menew,false); | 3383 | todo->addAttendee(menew,false); |
3384 | } | 3384 | } |
3385 | } | 3385 | } |
3386 | } | 3386 | } |
3387 | 3387 | ||
3388 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3388 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3389 | if (ev) { | 3389 | if (ev) { |
3390 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3390 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3391 | } else { | 3391 | } else { |
3392 | if (to) { | 3392 | if (to) { |
3393 | if ( !dlg->addMessage(to,method) ) delete(to); | 3393 | if ( !dlg->addMessage(to,method) ) delete(to); |
3394 | } | 3394 | } |
3395 | } | 3395 | } |
3396 | } | 3396 | } |
3397 | 3397 | ||
3398 | void CalendarView::openAddressbook() | 3398 | void CalendarView::openAddressbook() |
3399 | { | 3399 | { |
3400 | KRun::runCommand("kaddressbook"); | 3400 | KRun::runCommand("kaddressbook"); |
3401 | } | 3401 | } |
3402 | 3402 | ||
3403 | void CalendarView::setModified(bool modified) | 3403 | void CalendarView::setModified(bool modified) |
3404 | { | 3404 | { |
3405 | if ( modified ) | 3405 | if ( modified ) |
3406 | emit signalmodified(); | 3406 | emit signalmodified(); |
3407 | if (mModified != modified) { | 3407 | if (mModified != modified) { |
3408 | mModified = modified; | 3408 | mModified = modified; |
3409 | emit modifiedChanged(mModified); | 3409 | emit modifiedChanged(mModified); |
3410 | } | 3410 | } |
3411 | } | 3411 | } |
3412 | 3412 | ||
3413 | bool CalendarView::isReadOnly() | 3413 | bool CalendarView::isReadOnly() |
3414 | { | 3414 | { |
3415 | return mReadOnly; | 3415 | return mReadOnly; |
3416 | } | 3416 | } |
3417 | 3417 | ||
3418 | void CalendarView::setReadOnly(bool readOnly) | 3418 | void CalendarView::setReadOnly(bool readOnly) |
3419 | { | 3419 | { |
3420 | if (mReadOnly != readOnly) { | 3420 | if (mReadOnly != readOnly) { |
3421 | mReadOnly = readOnly; | 3421 | mReadOnly = readOnly; |
3422 | emit readOnlyChanged(mReadOnly); | 3422 | emit readOnlyChanged(mReadOnly); |
3423 | } | 3423 | } |
3424 | } | 3424 | } |
3425 | 3425 | ||
3426 | bool CalendarView::isModified() | 3426 | bool CalendarView::isModified() |
3427 | { | 3427 | { |
3428 | return mModified; | 3428 | return mModified; |
3429 | } | 3429 | } |
3430 | 3430 | void CalendarView::slotprintSelInc() | |
3431 | { | ||
3432 | if ( currentSelection() == 0 ) { | ||
3433 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | ||
3434 | return; | ||
3435 | } | ||
3436 | showIncidence(); | ||
3437 | getEventViewerDialog()->print(); | ||
3438 | |||
3439 | } | ||
3431 | void CalendarView::printSetup() | 3440 | void CalendarView::printSetup() |
3432 | { | 3441 | { |
3433 | #ifndef KORG_NOPRINTER | 3442 | #ifndef KORG_NOPRINTER |
3434 | createPrinter(); | 3443 | createPrinter(); |
3435 | 3444 | ||
3436 | mCalPrinter->setupPrinter(); | 3445 | mCalPrinter->setupPrinter(); |
3437 | #endif | 3446 | #endif |
3438 | } | 3447 | } |
3439 | 3448 | ||
3440 | void CalendarView::print() | 3449 | void CalendarView::print() |
3441 | { | 3450 | { |
3442 | #ifndef KORG_NOPRINTER | 3451 | #ifndef KORG_NOPRINTER |
3443 | createPrinter(); | 3452 | createPrinter(); |
3444 | 3453 | ||
3445 | DateList tmpDateList = mNavigator->selectedDates(); | 3454 | DateList tmpDateList = mNavigator->selectedDates(); |
3446 | mCalPrinter->print(CalPrinter::Month, | 3455 | mCalPrinter->print(CalPrinter::Month, |
3447 | tmpDateList.first(), tmpDateList.last()); | 3456 | tmpDateList.first(), tmpDateList.last()); |
3448 | #endif | 3457 | #endif |
3449 | } | 3458 | } |
3450 | 3459 | ||
3451 | void CalendarView::printPreview() | 3460 | void CalendarView::printPreview() |
3452 | { | 3461 | { |
3453 | #ifndef KORG_NOPRINTER | 3462 | #ifndef KORG_NOPRINTER |
3454 | kdDebug() << "CalendarView::printPreview()" << endl; | 3463 | kdDebug() << "CalendarView::printPreview()" << endl; |
3455 | 3464 | ||
3456 | createPrinter(); | 3465 | createPrinter(); |
3457 | 3466 | ||
3458 | DateList tmpDateList = mNavigator->selectedDates(); | 3467 | DateList tmpDateList = mNavigator->selectedDates(); |
3459 | 3468 | ||
3460 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3469 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3461 | tmpDateList.last()); | 3470 | tmpDateList.last()); |
3462 | #endif | 3471 | #endif |
3463 | } | 3472 | } |
3464 | 3473 | ||
3465 | void CalendarView::exportICalendar() | 3474 | void CalendarView::exportICalendar() |
3466 | { | 3475 | { |
3467 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3476 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3468 | 3477 | ||
3469 | // Force correct extension | 3478 | // Force correct extension |
3470 | if (filename.right(4) != ".ics") filename += ".ics"; | 3479 | if (filename.right(4) != ".ics") filename += ".ics"; |
3471 | 3480 | ||
3472 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3481 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3473 | storage.save(); | 3482 | storage.save(); |
3474 | } | 3483 | } |
3475 | 3484 | ||
3476 | bool CalendarView::exportVCalendar( QString filename ) | 3485 | bool CalendarView::exportVCalendar( QString filename ) |
3477 | { | 3486 | { |
3478 | if (mCalendar->journals().count() > 0) { | 3487 | if (mCalendar->journals().count() > 0) { |
3479 | int result = KMessageBox::warningContinueCancel(this, | 3488 | int result = KMessageBox::warningContinueCancel(this, |
3480 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3489 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3481 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3490 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3482 | true); | 3491 | true); |
3483 | if (result != KMessageBox::Continue) return false; | 3492 | if (result != KMessageBox::Continue) return false; |
3484 | } | 3493 | } |
3485 | 3494 | ||
3486 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3495 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3487 | 3496 | ||
3488 | // Force correct extension | 3497 | // Force correct extension |
3489 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3498 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3490 | 3499 | ||
3491 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3500 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3492 | return storage.save(); | 3501 | return storage.save(); |
3493 | 3502 | ||
3494 | } | 3503 | } |
3495 | 3504 | ||
3496 | void CalendarView::eventUpdated(Incidence *) | 3505 | void CalendarView::eventUpdated(Incidence *) |
3497 | { | 3506 | { |
3498 | setModified(); | 3507 | setModified(); |
3499 | // Don't call updateView here. The code, which has caused the update of the | 3508 | // Don't call updateView here. The code, which has caused the update of the |
3500 | // event is responsible for updating the view. | 3509 | // event is responsible for updating the view. |
3501 | // updateView(); | 3510 | // updateView(); |
3502 | } | 3511 | } |
3503 | 3512 | ||
3504 | void CalendarView::adaptNavigationUnits() | 3513 | void CalendarView::adaptNavigationUnits() |
3505 | { | 3514 | { |
3506 | if (mViewManager->currentView()->isEventView()) { | 3515 | if (mViewManager->currentView()->isEventView()) { |
3507 | int days = mViewManager->currentView()->currentDateCount(); | 3516 | int days = mViewManager->currentView()->currentDateCount(); |
3508 | if (days == 1) { | 3517 | if (days == 1) { |
3509 | emit changeNavStringPrev(i18n("&Previous Day")); | 3518 | emit changeNavStringPrev(i18n("&Previous Day")); |
3510 | emit changeNavStringNext(i18n("&Next Day")); | 3519 | emit changeNavStringNext(i18n("&Next Day")); |
3511 | } else { | 3520 | } else { |
3512 | emit changeNavStringPrev(i18n("&Previous Week")); | 3521 | emit changeNavStringPrev(i18n("&Previous Week")); |
3513 | emit changeNavStringNext(i18n("&Next Week")); | 3522 | emit changeNavStringNext(i18n("&Next Week")); |
3514 | } | 3523 | } |
3515 | } | 3524 | } |
3516 | } | 3525 | } |
3517 | 3526 | ||
3518 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3527 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3519 | { | 3528 | { |
3520 | if ( incidence ) mTodoList->clearSelection(); | 3529 | if ( incidence ) mTodoList->clearSelection(); |
3521 | processIncidenceSelection( incidence ); | 3530 | processIncidenceSelection( incidence ); |
3522 | } | 3531 | } |
3523 | 3532 | ||
3524 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3533 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3525 | { | 3534 | { |
3526 | if ( incidence && mViewManager->currentView() ) { | 3535 | if ( incidence && mViewManager->currentView() ) { |
3527 | mViewManager->currentView()->clearSelection(); | 3536 | mViewManager->currentView()->clearSelection(); |
3528 | } | 3537 | } |
3529 | processIncidenceSelection( incidence ); | 3538 | processIncidenceSelection( incidence ); |
3530 | } | 3539 | } |
3531 | 3540 | ||
3532 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3541 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3533 | { | 3542 | { |
3534 | if ( incidence == mSelectedIncidence ) return; | 3543 | if ( incidence == mSelectedIncidence ) return; |
3535 | 3544 | ||
3536 | mSelectedIncidence = incidence; | 3545 | mSelectedIncidence = incidence; |
3537 | 3546 | ||
3538 | emit incidenceSelected( mSelectedIncidence ); | 3547 | emit incidenceSelected( mSelectedIncidence ); |
3539 | 3548 | ||
3540 | if ( incidence && incidence->type() == "Event" ) { | 3549 | if ( incidence && incidence->type() == "Event" ) { |
3541 | Event *event = static_cast<Event *>( incidence ); | 3550 | Event *event = static_cast<Event *>( incidence ); |
3542 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3551 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3543 | emit organizerEventsSelected( true ); | 3552 | emit organizerEventsSelected( true ); |
3544 | } else { | 3553 | } else { |
3545 | emit organizerEventsSelected(false); | 3554 | emit organizerEventsSelected(false); |
3546 | } | 3555 | } |
3547 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3556 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3548 | KOPrefs::instance()->email() ) ) { | 3557 | KOPrefs::instance()->email() ) ) { |
3549 | emit groupEventsSelected( true ); | 3558 | emit groupEventsSelected( true ); |
3550 | } else { | 3559 | } else { |
3551 | emit groupEventsSelected(false); | 3560 | emit groupEventsSelected(false); |
3552 | } | 3561 | } |
3553 | return; | 3562 | return; |
3554 | } else { | 3563 | } else { |
3555 | if ( incidence && incidence->type() == "Todo" ) { | 3564 | if ( incidence && incidence->type() == "Todo" ) { |
3556 | emit todoSelected( true ); | 3565 | emit todoSelected( true ); |
3557 | Todo *event = static_cast<Todo *>( incidence ); | 3566 | Todo *event = static_cast<Todo *>( incidence ); |
3558 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3567 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3559 | emit organizerEventsSelected( true ); | 3568 | emit organizerEventsSelected( true ); |
3560 | } else { | 3569 | } else { |
3561 | emit organizerEventsSelected(false); | 3570 | emit organizerEventsSelected(false); |
3562 | } | 3571 | } |
3563 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3572 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3564 | KOPrefs::instance()->email() ) ) { | 3573 | KOPrefs::instance()->email() ) ) { |
3565 | emit groupEventsSelected( true ); | 3574 | emit groupEventsSelected( true ); |
3566 | } else { | 3575 | } else { |
3567 | emit groupEventsSelected(false); | 3576 | emit groupEventsSelected(false); |
3568 | } | 3577 | } |
3569 | return; | 3578 | return; |
3570 | } else { | 3579 | } else { |
3571 | emit todoSelected( false ); | 3580 | emit todoSelected( false ); |
3572 | emit organizerEventsSelected(false); | 3581 | emit organizerEventsSelected(false); |
3573 | emit groupEventsSelected(false); | 3582 | emit groupEventsSelected(false); |
3574 | } | 3583 | } |
3575 | return; | 3584 | return; |
3576 | } | 3585 | } |
3577 | 3586 | ||
3578 | /* if ( incidence && incidence->type() == "Todo" ) { | 3587 | /* if ( incidence && incidence->type() == "Todo" ) { |
3579 | emit todoSelected( true ); | 3588 | emit todoSelected( true ); |
3580 | } else { | 3589 | } else { |
3581 | emit todoSelected( false ); | 3590 | emit todoSelected( false ); |
3582 | }*/ | 3591 | }*/ |
3583 | } | 3592 | } |
3584 | 3593 | ||
3585 | 3594 | ||
3586 | void CalendarView::checkClipboard() | 3595 | void CalendarView::checkClipboard() |
3587 | { | 3596 | { |
3588 | #ifndef KORG_NODND | 3597 | #ifndef KORG_NODND |
3589 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3598 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3590 | emit pasteEnabled(true); | 3599 | emit pasteEnabled(true); |
3591 | } else { | 3600 | } else { |
3592 | emit pasteEnabled(false); | 3601 | emit pasteEnabled(false); |
3593 | } | 3602 | } |
3594 | #endif | 3603 | #endif |
3595 | } | 3604 | } |
3596 | 3605 | ||
3597 | void CalendarView::showDates(const DateList &selectedDates) | 3606 | void CalendarView::showDates(const DateList &selectedDates) |
3598 | { | 3607 | { |
3599 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3608 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3600 | 3609 | ||
3601 | 3610 | ||
3602 | if ( !mBlockShowDates ) { | 3611 | if ( !mBlockShowDates ) { |
3603 | if ( mViewManager->currentView() ) { | 3612 | if ( mViewManager->currentView() ) { |
3604 | updateView( selectedDates.first(), selectedDates.last() ); | 3613 | updateView( selectedDates.first(), selectedDates.last() ); |
3605 | } else { | 3614 | } else { |
3606 | mViewManager->showAgendaView(); | 3615 | mViewManager->showAgendaView(); |
3607 | } | 3616 | } |
3608 | } | 3617 | } |
3609 | 3618 | ||
3610 | QDate date = selectedDates.first(); | 3619 | QDate date = selectedDates.first(); |
3611 | if ( ! date.isValid() ) { | 3620 | if ( ! date.isValid() ) { |
3612 | topLevelWidget()->setCaption(""); | 3621 | topLevelWidget()->setCaption(""); |
3613 | return; | 3622 | return; |
3614 | } | 3623 | } |
3615 | 3624 | ||
3616 | QString selDates; | 3625 | QString selDates; |
3617 | selDates = KGlobal::locale()->formatDate( date, true); | 3626 | selDates = KGlobal::locale()->formatDate( date, true); |
3618 | if (selectedDates.first() < selectedDates.last() ) | 3627 | if (selectedDates.first() < selectedDates.last() ) |
3619 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3628 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3620 | else { | 3629 | else { |
3621 | QString addString; | 3630 | QString addString; |
3622 | if ( date == QDateTime::currentDateTime().date() ) | 3631 | if ( date == QDateTime::currentDateTime().date() ) |
3623 | addString = i18n("Today"); | 3632 | addString = i18n("Today"); |
3624 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 3633 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
3625 | addString = i18n("Tomorrow"); | 3634 | addString = i18n("Tomorrow"); |
3626 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 3635 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
3627 | addString = i18n("Yesterday"); | 3636 | addString = i18n("Yesterday"); |
3628 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 3637 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
3629 | addString = i18n("Day before yesterday"); | 3638 | addString = i18n("Day before yesterday"); |
3630 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 3639 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
3631 | addString = i18n("Day after tomorrow"); | 3640 | addString = i18n("Day after tomorrow"); |
3632 | if ( !addString.isEmpty() ) { | 3641 | if ( !addString.isEmpty() ) { |
3633 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3642 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3634 | return; | 3643 | return; |
3635 | } | 3644 | } |
3636 | } | 3645 | } |
3637 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3646 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3638 | 3647 | ||
3639 | } | 3648 | } |
3640 | 3649 | ||
3641 | QPtrList<CalFilter> CalendarView::filters() | 3650 | QPtrList<CalFilter> CalendarView::filters() |
3642 | { | 3651 | { |
3643 | return mFilters; | 3652 | return mFilters; |
3644 | 3653 | ||
3645 | } | 3654 | } |
3646 | void CalendarView::editFilters() | 3655 | void CalendarView::editFilters() |
3647 | { | 3656 | { |
3648 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3657 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3649 | 3658 | ||
3650 | CalFilter *filter = mFilters.first(); | 3659 | CalFilter *filter = mFilters.first(); |
3651 | while(filter) { | 3660 | while(filter) { |
3652 | kdDebug() << " Filter: " << filter->name() << endl; | 3661 | kdDebug() << " Filter: " << filter->name() << endl; |
3653 | filter = mFilters.next(); | 3662 | filter = mFilters.next(); |
3654 | } | 3663 | } |
3655 | 3664 | ||
3656 | mDialogManager->showFilterEditDialog(&mFilters); | 3665 | mDialogManager->showFilterEditDialog(&mFilters); |
3657 | } | 3666 | } |
3658 | void CalendarView::toggleFilter() | 3667 | void CalendarView::toggleFilter() |
3659 | { | 3668 | { |
3660 | showFilter(! mFilterView->isVisible()); | 3669 | showFilter(! mFilterView->isVisible()); |
3661 | } | 3670 | } |
3662 | 3671 | ||
3663 | KOFilterView *CalendarView::filterView() | 3672 | KOFilterView *CalendarView::filterView() |
3664 | { | 3673 | { |
3665 | return mFilterView; | 3674 | return mFilterView; |
3666 | } | 3675 | } |
3667 | void CalendarView::selectFilter( int fil ) | 3676 | void CalendarView::selectFilter( int fil ) |
3668 | { | 3677 | { |
3669 | mFilterView->setSelectedFilter( fil ); | 3678 | mFilterView->setSelectedFilter( fil ); |
3670 | } | 3679 | } |
3671 | void CalendarView::showFilter(bool visible) | 3680 | void CalendarView::showFilter(bool visible) |
3672 | { | 3681 | { |
3673 | if (visible) mFilterView->show(); | 3682 | if (visible) mFilterView->show(); |
3674 | else mFilterView->hide(); | 3683 | else mFilterView->hide(); |
3675 | } | 3684 | } |
3676 | void CalendarView::toggleFilerEnabled( ) | 3685 | void CalendarView::toggleFilerEnabled( ) |
3677 | { | 3686 | { |
3678 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3687 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3679 | if ( !mFilterView->filtersEnabled() ) | 3688 | if ( !mFilterView->filtersEnabled() ) |
3680 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3689 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3681 | 3690 | ||
3682 | } | 3691 | } |
3683 | void CalendarView::updateFilter() | 3692 | void CalendarView::updateFilter() |
3684 | { | 3693 | { |
3685 | CalFilter *filter = mFilterView->selectedFilter(); | 3694 | CalFilter *filter = mFilterView->selectedFilter(); |
3686 | if (filter) { | 3695 | if (filter) { |
3687 | QString mess; | 3696 | QString mess; |
3688 | if (mFilterView->filtersEnabled()) { | 3697 | if (mFilterView->filtersEnabled()) { |
3689 | mess = i18n("Filter selected: ")+filter->name(); | 3698 | mess = i18n("Filter selected: ")+filter->name(); |
3690 | filter->setEnabled(true); | 3699 | filter->setEnabled(true); |
3691 | } | 3700 | } |
3692 | else filter->setEnabled(false); | 3701 | else filter->setEnabled(false); |
3693 | mCalendar->setFilter(filter); | 3702 | mCalendar->setFilter(filter); |
3694 | updateView(); | 3703 | updateView(); |
3695 | if ( !mess.isEmpty() ) | 3704 | if ( !mess.isEmpty() ) |
3696 | topLevelWidget()->setCaption( mess ); | 3705 | topLevelWidget()->setCaption( mess ); |
3697 | 3706 | ||
3698 | } | 3707 | } |
3699 | } | 3708 | } |
3700 | 3709 | ||
3701 | void CalendarView::filterEdited() | 3710 | void CalendarView::filterEdited() |
3702 | { | 3711 | { |
3703 | mFilterView->updateFilters(); | 3712 | mFilterView->updateFilters(); |
3704 | updateFilter(); | 3713 | updateFilter(); |
3705 | writeSettings(); | 3714 | writeSettings(); |
3706 | } | 3715 | } |
3707 | 3716 | ||
3708 | 3717 | ||
3709 | void CalendarView::takeOverEvent() | 3718 | void CalendarView::takeOverEvent() |
3710 | { | 3719 | { |
3711 | Incidence *incidence = currentSelection(); | 3720 | Incidence *incidence = currentSelection(); |
3712 | 3721 | ||
3713 | if (!incidence) return; | 3722 | if (!incidence) return; |
3714 | 3723 | ||
3715 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3724 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3716 | incidence->recreate(); | 3725 | incidence->recreate(); |
3717 | incidence->setReadOnly(false); | 3726 | incidence->setReadOnly(false); |
3718 | 3727 | ||
3719 | updateView(); | 3728 | updateView(); |
3720 | } | 3729 | } |
3721 | 3730 | ||
3722 | void CalendarView::takeOverCalendar() | 3731 | void CalendarView::takeOverCalendar() |
3723 | { | 3732 | { |
3724 | // TODO: Create Calendar::allIncidences() function and use it here | 3733 | // TODO: Create Calendar::allIncidences() function and use it here |
3725 | 3734 | ||
3726 | QPtrList<Event> events = mCalendar->events(); | 3735 | QPtrList<Event> events = mCalendar->events(); |
3727 | for(uint i=0; i<events.count(); ++i) { | 3736 | for(uint i=0; i<events.count(); ++i) { |
3728 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3737 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3729 | events.at(i)->recreate(); | 3738 | events.at(i)->recreate(); |
3730 | events.at(i)->setReadOnly(false); | 3739 | events.at(i)->setReadOnly(false); |
3731 | } | 3740 | } |
3732 | 3741 | ||
3733 | QPtrList<Todo> todos = mCalendar->todos(); | 3742 | QPtrList<Todo> todos = mCalendar->todos(); |
3734 | for(uint i=0; i<todos.count(); ++i) { | 3743 | for(uint i=0; i<todos.count(); ++i) { |
3735 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3744 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3736 | todos.at(i)->recreate(); | 3745 | todos.at(i)->recreate(); |
3737 | todos.at(i)->setReadOnly(false); | 3746 | todos.at(i)->setReadOnly(false); |
3738 | } | 3747 | } |
3739 | 3748 | ||
3740 | QPtrList<Journal> journals = mCalendar->journals(); | 3749 | QPtrList<Journal> journals = mCalendar->journals(); |
3741 | for(uint i=0; i<journals.count(); ++i) { | 3750 | for(uint i=0; i<journals.count(); ++i) { |
3742 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3751 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3743 | journals.at(i)->recreate(); | 3752 | journals.at(i)->recreate(); |
3744 | journals.at(i)->setReadOnly(false); | 3753 | journals.at(i)->setReadOnly(false); |
3745 | } | 3754 | } |
3746 | 3755 | ||
3747 | updateView(); | 3756 | updateView(); |
3748 | } | 3757 | } |
3749 | 3758 | ||
3750 | void CalendarView::showIntro() | 3759 | void CalendarView::showIntro() |
3751 | { | 3760 | { |
3752 | kdDebug() << "To be implemented." << endl; | 3761 | kdDebug() << "To be implemented." << endl; |
3753 | } | 3762 | } |
3754 | 3763 | ||
3755 | QWidgetStack *CalendarView::viewStack() | 3764 | QWidgetStack *CalendarView::viewStack() |
3756 | { | 3765 | { |
3757 | return mRightFrame; | 3766 | return mRightFrame; |
3758 | } | 3767 | } |
3759 | 3768 | ||
3760 | QWidget *CalendarView::leftFrame() | 3769 | QWidget *CalendarView::leftFrame() |
3761 | { | 3770 | { |
3762 | return ( QWidget *)mLeftFrame; | 3771 | return ( QWidget *)mLeftFrame; |
3763 | } | 3772 | } |
3764 | 3773 | ||
3765 | DateNavigator *CalendarView::dateNavigator() | 3774 | DateNavigator *CalendarView::dateNavigator() |
3766 | { | 3775 | { |
3767 | return mNavigator; | 3776 | return mNavigator; |
3768 | } | 3777 | } |
3769 | 3778 | ||
3770 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3779 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3771 | { | 3780 | { |
3772 | return mDateNavigator->navigatorView(); | 3781 | return mDateNavigator->navigatorView(); |
3773 | } | 3782 | } |
3774 | void CalendarView::toggleDateNavigatorWidget() | 3783 | void CalendarView::toggleDateNavigatorWidget() |
3775 | { | 3784 | { |
3776 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3785 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3777 | 3786 | ||
3778 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3787 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3779 | mDateNavigator->hide(); | 3788 | mDateNavigator->hide(); |
3780 | else | 3789 | else |
3781 | mDateNavigator->show(); | 3790 | mDateNavigator->show(); |
3782 | } | 3791 | } |
3783 | void CalendarView::addView(KOrg::BaseView *view) | 3792 | void CalendarView::addView(KOrg::BaseView *view) |
3784 | { | 3793 | { |
3785 | mViewManager->addView(view); | 3794 | mViewManager->addView(view); |
3786 | } | 3795 | } |
3787 | 3796 | ||
3788 | void CalendarView::showView(KOrg::BaseView *view) | 3797 | void CalendarView::showView(KOrg::BaseView *view) |
3789 | { | 3798 | { |
3790 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3799 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3791 | } | 3800 | } |
3792 | 3801 | ||
3793 | Incidence *CalendarView::currentSelection() | 3802 | Incidence *CalendarView::currentSelection() |
3794 | { | 3803 | { |
3795 | return mViewManager->currentSelection(); | 3804 | return mViewManager->currentSelection(); |
3796 | } | 3805 | } |
3797 | void CalendarView::toggleAllDaySize() | 3806 | void CalendarView::toggleAllDaySize() |
3798 | { | 3807 | { |
3799 | /* | 3808 | /* |
3800 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3809 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3801 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3810 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3802 | else | 3811 | else |
3803 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3812 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3804 | */ | 3813 | */ |
3805 | viewManager()->agendaView()->toggleAllDay(); | 3814 | viewManager()->agendaView()->toggleAllDay(); |
3806 | } | 3815 | } |
3807 | void CalendarView::toggleExpand() | 3816 | void CalendarView::toggleExpand() |
3808 | { | 3817 | { |
3809 | // if ( mLeftFrame->isHidden() ) { | 3818 | // if ( mLeftFrame->isHidden() ) { |
3810 | // mLeftFrame->show(); | 3819 | // mLeftFrame->show(); |
3811 | // emit calendarViewExpanded( false ); | 3820 | // emit calendarViewExpanded( false ); |
3812 | // } else { | 3821 | // } else { |
3813 | // mLeftFrame->hide(); | 3822 | // mLeftFrame->hide(); |
3814 | // emit calendarViewExpanded( true ); | 3823 | // emit calendarViewExpanded( true ); |
3815 | // } | 3824 | // } |
3816 | //qDebug(" CalendarView::toggleExpand()"); | 3825 | //qDebug(" CalendarView::toggleExpand()"); |
3817 | globalFlagBlockAgenda = 1; | 3826 | globalFlagBlockAgenda = 1; |
3818 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3827 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3819 | globalFlagBlockAgenda = 5; | 3828 | globalFlagBlockAgenda = 5; |
3820 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3829 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3821 | //mViewManager->showView( 0, true ); | 3830 | //mViewManager->showView( 0, true ); |
3822 | } | 3831 | } |
3823 | 3832 | ||
3824 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3833 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3825 | { | 3834 | { |
3826 | setModified( modified ); | 3835 | setModified( modified ); |
3827 | } | 3836 | } |
3828 | 3837 | ||
3829 | Todo *CalendarView::selectedTodo() | 3838 | Todo *CalendarView::selectedTodo() |
3830 | { | 3839 | { |
3831 | Incidence *incidence = currentSelection(); | 3840 | Incidence *incidence = currentSelection(); |
3832 | if ( incidence && incidence->type() == "Todo" ) { | 3841 | if ( incidence && incidence->type() == "Todo" ) { |
3833 | return static_cast<Todo *>( incidence ); | 3842 | return static_cast<Todo *>( incidence ); |
3834 | } | 3843 | } |
3835 | 3844 | ||
3836 | incidence = mTodoList->selectedIncidences().first(); | 3845 | incidence = mTodoList->selectedIncidences().first(); |
3837 | if ( incidence && incidence->type() == "Todo" ) { | 3846 | if ( incidence && incidence->type() == "Todo" ) { |
3838 | return static_cast<Todo *>( incidence ); | 3847 | return static_cast<Todo *>( incidence ); |
3839 | } | 3848 | } |
3840 | 3849 | ||
3841 | return 0; | 3850 | return 0; |
3842 | } | 3851 | } |
3843 | 3852 | ||
3844 | void CalendarView::dialogClosing(Incidence *in) | 3853 | void CalendarView::dialogClosing(Incidence *in) |
3845 | { | 3854 | { |
3846 | // mDialogList.remove(in); | 3855 | // mDialogList.remove(in); |
3847 | } | 3856 | } |
3848 | 3857 | ||
3849 | void CalendarView::showIncidence() | 3858 | void CalendarView::showIncidence() |
3850 | { | 3859 | { |
3851 | mViewerCallerIsSearchDialog = false; | 3860 | mViewerCallerIsSearchDialog = false; |
3852 | Incidence *incidence = currentSelection(); | 3861 | Incidence *incidence = currentSelection(); |
3853 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3862 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3854 | if ( incidence ) { | 3863 | if ( incidence ) { |
3855 | ShowIncidenceVisitor v; | 3864 | ShowIncidenceVisitor v; |
3856 | v.act( incidence, this ); | 3865 | v.act( incidence, this ); |
3857 | } | 3866 | } |
3858 | } | 3867 | } |
3859 | void CalendarView::editIncidenceDescription() | 3868 | void CalendarView::editIncidenceDescription() |
3860 | { | 3869 | { |
3861 | mFlagEditDescription = true; | 3870 | mFlagEditDescription = true; |
3862 | editIncidence(); | 3871 | editIncidence(); |
3863 | mFlagEditDescription = false; | 3872 | mFlagEditDescription = false; |
3864 | } | 3873 | } |
3865 | void CalendarView::editIncidence() | 3874 | void CalendarView::editIncidence() |
3866 | { | 3875 | { |
3867 | // qDebug("editIncidence() "); | 3876 | // qDebug("editIncidence() "); |
3868 | Incidence *incidence = currentSelection(); | 3877 | Incidence *incidence = currentSelection(); |
3869 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3878 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3870 | if ( incidence ) { | 3879 | if ( incidence ) { |
3871 | EditIncidenceVisitor v; | 3880 | EditIncidenceVisitor v; |
3872 | v.act( incidence, this ); | 3881 | v.act( incidence, this ); |
3873 | } | 3882 | } |
3874 | } | 3883 | } |
3875 | 3884 | ||
3876 | void CalendarView::deleteIncidence() | 3885 | void CalendarView::deleteIncidence() |
3877 | { | 3886 | { |
3878 | Incidence *incidence = currentSelection(); | 3887 | Incidence *incidence = currentSelection(); |
3879 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3888 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3880 | if ( incidence ) { | 3889 | if ( incidence ) { |
3881 | deleteIncidence(incidence); | 3890 | deleteIncidence(incidence); |
3882 | } | 3891 | } |
3883 | } | 3892 | } |
3884 | 3893 | ||
3885 | void CalendarView::showIncidence(Incidence *incidence) | 3894 | void CalendarView::showIncidence(Incidence *incidence) |
3886 | { | 3895 | { |
3887 | mViewerCallerIsSearchDialog = false; | 3896 | mViewerCallerIsSearchDialog = false; |
3888 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3897 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3889 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3898 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3890 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3899 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3891 | mViewerCallerIsSearchDialog = true; | 3900 | mViewerCallerIsSearchDialog = true; |
3892 | } | 3901 | } |
3893 | } | 3902 | } |
3894 | if ( incidence ) { | 3903 | if ( incidence ) { |
3895 | ShowIncidenceVisitor v; | 3904 | ShowIncidenceVisitor v; |
3896 | v.act( incidence, this ); | 3905 | v.act( incidence, this ); |
3897 | } | 3906 | } |
3898 | } | 3907 | } |
3899 | 3908 | ||
3900 | void CalendarView::editIncidence(Incidence *incidence) | 3909 | void CalendarView::editIncidence(Incidence *incidence) |
3901 | { | 3910 | { |
3902 | if ( incidence ) { | 3911 | if ( incidence ) { |
3903 | 3912 | ||
3904 | EditIncidenceVisitor v; | 3913 | EditIncidenceVisitor v; |
3905 | v.act( incidence, this ); | 3914 | v.act( incidence, this ); |
3906 | 3915 | ||
3907 | } | 3916 | } |
3908 | } | 3917 | } |
3909 | 3918 | ||
3910 | void CalendarView::deleteIncidence(Incidence *incidence) | 3919 | void CalendarView::deleteIncidence(Incidence *incidence) |
3911 | { | 3920 | { |
3912 | //qDebug(" CalendarView::deleteIncidence "); | 3921 | //qDebug(" CalendarView::deleteIncidence "); |
3913 | if ( incidence ) { | 3922 | if ( incidence ) { |
3914 | DeleteIncidenceVisitor v; | 3923 | DeleteIncidenceVisitor v; |
3915 | v.act( incidence, this ); | 3924 | v.act( incidence, this ); |
3916 | } | 3925 | } |
3917 | } | 3926 | } |
3918 | 3927 | ||
3919 | 3928 | ||
3920 | void CalendarView::lookForOutgoingMessages() | 3929 | void CalendarView::lookForOutgoingMessages() |
3921 | { | 3930 | { |
3922 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3931 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3923 | ogd->loadMessages(); | 3932 | ogd->loadMessages(); |
3924 | } | 3933 | } |
3925 | 3934 | ||
3926 | void CalendarView::lookForIncomingMessages() | 3935 | void CalendarView::lookForIncomingMessages() |
3927 | { | 3936 | { |
3928 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3937 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3929 | icd->retrieve(); | 3938 | icd->retrieve(); |
3930 | } | 3939 | } |
3931 | 3940 | ||
3932 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3941 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3933 | { | 3942 | { |
3934 | bool deleteTodo = true; | 3943 | bool deleteTodo = true; |
3935 | QPtrList<Incidence> subTodos; | 3944 | QPtrList<Incidence> subTodos; |
3936 | Incidence *aTodo; | 3945 | Incidence *aTodo; |
3937 | subTodos = t->relations(); | 3946 | subTodos = t->relations(); |
3938 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3947 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3939 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3948 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3940 | deleteTodo = false; | 3949 | deleteTodo = false; |
3941 | } | 3950 | } |
3942 | if ( deleteTodo ) { | 3951 | if ( deleteTodo ) { |
3943 | if ( t->isCompleted() && !t->doesRecur()) { | 3952 | if ( t->isCompleted() && !t->doesRecur()) { |
3944 | checkExternalId( t ); | 3953 | checkExternalId( t ); |
3945 | mCalendar->deleteTodo( t ); | 3954 | mCalendar->deleteTodo( t ); |
3946 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3955 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3947 | } | 3956 | } |
3948 | else | 3957 | else |
3949 | deleteTodo = false; | 3958 | deleteTodo = false; |
3950 | } | 3959 | } |
3951 | return deleteTodo; | 3960 | return deleteTodo; |
3952 | 3961 | ||
3953 | } | 3962 | } |
3954 | void CalendarView::purgeCompleted() | 3963 | void CalendarView::purgeCompleted() |
3955 | { | 3964 | { |
3956 | int result = KMessageBox::warningContinueCancel(this, | 3965 | int result = KMessageBox::warningContinueCancel(this, |
3957 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3966 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3958 | 3967 | ||
3959 | if (result == KMessageBox::Continue) { | 3968 | if (result == KMessageBox::Continue) { |
3960 | 3969 | ||
3961 | QPtrList<Todo> todoCal; | 3970 | QPtrList<Todo> todoCal; |
3962 | QPtrList<Todo> rootTodos; | 3971 | QPtrList<Todo> rootTodos; |
3963 | //QPtrList<Incidence> rel; | 3972 | //QPtrList<Incidence> rel; |
3964 | Todo *aTodo;//, *rTodo; | 3973 | Todo *aTodo;//, *rTodo; |
3965 | Incidence *rIncidence; | 3974 | Incidence *rIncidence; |
3966 | bool childDelete = false; | 3975 | bool childDelete = false; |
3967 | bool deletedOne = true; | 3976 | bool deletedOne = true; |
3968 | todoCal = calendar()->todos(); | 3977 | todoCal = calendar()->todos(); |
3969 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3978 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3970 | if ( !aTodo->relatedTo() ) | 3979 | if ( !aTodo->relatedTo() ) |
3971 | rootTodos.append( aTodo ); | 3980 | rootTodos.append( aTodo ); |
3972 | } | 3981 | } |
3973 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3982 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3974 | removeCompletedSubTodos( aTodo ); | 3983 | removeCompletedSubTodos( aTodo ); |
3975 | } | 3984 | } |
3976 | 3985 | ||
3977 | updateView(); | 3986 | updateView(); |
3978 | } | 3987 | } |
3979 | } | 3988 | } |
3980 | 3989 | ||
3981 | void CalendarView::slotCalendarChanged() | 3990 | void CalendarView::slotCalendarChanged() |
3982 | { | 3991 | { |
3983 | ; | 3992 | ; |
3984 | } | 3993 | } |
3985 | 3994 | ||
3986 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3995 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3987 | { | 3996 | { |
3988 | //qDebug(" alendarView::keyPressEvent "); | 3997 | //qDebug(" alendarView::keyPressEvent "); |
3989 | e->ignore(); | 3998 | e->ignore(); |
3990 | } | 3999 | } |
3991 | 4000 | ||
3992 | 4001 | ||
3993 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4002 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3994 | { | 4003 | { |
3995 | // mSyncManager = manager; | 4004 | // mSyncManager = manager; |
3996 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4005 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3997 | qDebug("KO: SyncKDE request detected!"); | 4006 | qDebug("KO: SyncKDE request detected!"); |
3998 | } | 4007 | } |
3999 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4008 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4000 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4009 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4001 | return syncCalendar( filename, mode ); | 4010 | return syncCalendar( filename, mode ); |
4002 | } | 4011 | } |
4003 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4012 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4004 | { | 4013 | { |
4005 | //mSyncManager = manager; | 4014 | //mSyncManager = manager; |
4006 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4015 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4007 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4016 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4008 | if ( resource == "sharp" ) | 4017 | if ( resource == "sharp" ) |
4009 | syncExternal( 0 ); | 4018 | syncExternal( 0 ); |
4010 | if ( resource == "phone" ) | 4019 | if ( resource == "phone" ) |
4011 | syncExternal( 1 ); | 4020 | syncExternal( 1 ); |
4012 | // pending setmodified | 4021 | // pending setmodified |
4013 | return true; | 4022 | return true; |
4014 | } | 4023 | } |
4015 | void CalendarView::setSyncManager(KSyncManager* manager) | 4024 | void CalendarView::setSyncManager(KSyncManager* manager) |
4016 | { | 4025 | { |
4017 | mSyncManager = manager; | 4026 | mSyncManager = manager; |
4018 | } | 4027 | } |
4019 | 4028 | ||
4020 | void CalendarView::removeSyncInfo( QString syncProfile) | 4029 | void CalendarView::removeSyncInfo( QString syncProfile) |
4021 | { | 4030 | { |
4022 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4031 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4023 | mCalendar->removeSyncInfo( syncProfile ); | 4032 | mCalendar->removeSyncInfo( syncProfile ); |
4024 | 4033 | ||
4025 | } | 4034 | } |
4026 | 4035 | ||
4027 | void CalendarView::undo_delete() | 4036 | void CalendarView::undo_delete() |
4028 | { | 4037 | { |
4029 | //qDebug("undo_delete() "); | 4038 | //qDebug("undo_delete() "); |
4030 | Incidence* undo = mCalendar->undoIncidence(); | 4039 | Incidence* undo = mCalendar->undoIncidence(); |
4031 | if ( !undo ) { | 4040 | if ( !undo ) { |
4032 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4041 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4033 | i18n("KO/Pi")); | 4042 | i18n("KO/Pi")); |
4034 | return; | 4043 | return; |
4035 | } | 4044 | } |
4036 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4045 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4037 | i18n("\nAre you sure you want\nto restore this?"), | 4046 | i18n("\nAre you sure you want\nto restore this?"), |
4038 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4047 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4039 | mCalendar->undoDeleteIncidence(); | 4048 | mCalendar->undoDeleteIncidence(); |
4040 | updateView(); | 4049 | updateView(); |
4041 | } | 4050 | } |
4042 | } | 4051 | } |
4043 | 4052 | ||
4044 | void CalendarView::slotViewerClosed() | 4053 | void CalendarView::slotViewerClosed() |
4045 | { | 4054 | { |
4046 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4055 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4047 | } | 4056 | } |
4048 | 4057 | ||
4049 | void CalendarView::resetFocus() | 4058 | void CalendarView::resetFocus() |
4050 | { | 4059 | { |
4051 | if ( mViewerCallerIsSearchDialog ) { | 4060 | if ( mViewerCallerIsSearchDialog ) { |
4052 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4061 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4053 | mDialogManager->getSearchDialog()->raise(); | 4062 | mDialogManager->getSearchDialog()->raise(); |
4054 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4063 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4055 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4064 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4056 | } else | 4065 | } else |
4057 | mViewerCallerIsSearchDialog = false; | 4066 | mViewerCallerIsSearchDialog = false; |
4058 | } | 4067 | } |
4059 | if ( !mViewerCallerIsSearchDialog ) { | 4068 | if ( !mViewerCallerIsSearchDialog ) { |
4060 | //mViewManager->currentView()->setFocus(); | 4069 | //mViewManager->currentView()->setFocus(); |
4061 | //qDebug("sssssssssssssssset focus "); | 4070 | //qDebug("sssssssssssssssset focus "); |
4062 | topLevelWidget()->raise(); | 4071 | topLevelWidget()->raise(); |
4063 | setActiveWindow(); | 4072 | setActiveWindow(); |
4064 | //setFocus(); | 4073 | //setFocus(); |
4065 | } | 4074 | } |
4066 | mViewerCallerIsSearchDialog = false; | 4075 | mViewerCallerIsSearchDialog = false; |
4067 | } | 4076 | } |
4068 | 4077 | ||
4069 | void CalendarView::showNextAlarms() | 4078 | void CalendarView::showNextAlarms() |
4070 | { | 4079 | { |
4071 | QString message; | 4080 | QString message; |
4072 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4081 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4073 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4082 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4074 | QString sum = mCalendar->nextSummary(); | 4083 | QString sum = mCalendar->nextSummary(); |
4075 | QDateTime nextA = mNextAlarmDateTime; | 4084 | QDateTime nextA = mNextAlarmDateTime; |
4076 | QDateTime cur = QDateTime::currentDateTime(); | 4085 | QDateTime cur = QDateTime::currentDateTime(); |
4077 | int secs = cur.secsTo( nextA ); | 4086 | int secs = cur.secsTo( nextA ); |
4078 | int min = secs /60; | 4087 | int min = secs /60; |
4079 | int hours = min /60; | 4088 | int hours = min /60; |
4080 | min = min % 60; | 4089 | min = min % 60; |
4081 | int days = hours /24; | 4090 | int days = hours /24; |
4082 | hours = hours % 24; | 4091 | hours = hours % 24; |
4083 | 4092 | ||
4084 | message = i18n("The next alarm is in:\n"); | 4093 | message = i18n("The next alarm is in:\n"); |
4085 | if ( days > 1 ) | 4094 | if ( days > 1 ) |
4086 | message += i18n("%1 days\n").arg( days ); | 4095 | message += i18n("%1 days\n").arg( days ); |
4087 | else if ( days == 1 ) | 4096 | else if ( days == 1 ) |
4088 | message += i18n("1 day\n"); | 4097 | message += i18n("1 day\n"); |
4089 | if ( hours > 1 ) | 4098 | if ( hours > 1 ) |
4090 | message += i18n("%1 hours\n").arg( hours ); | 4099 | message += i18n("%1 hours\n").arg( hours ); |
4091 | else if ( hours == 1 ) | 4100 | else if ( hours == 1 ) |
4092 | message += i18n("1 hour\n"); | 4101 | message += i18n("1 hour\n"); |
4093 | if ( min > 1 ) | 4102 | if ( min > 1 ) |
4094 | message += i18n("%1 minutes\n").arg( min ); | 4103 | message += i18n("%1 minutes\n").arg( min ); |
4095 | else if ( min == 1 ) | 4104 | else if ( min == 1 ) |
4096 | message += i18n("1 minute\n"); | 4105 | message += i18n("1 minute\n"); |
4097 | 4106 | ||
4098 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4107 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4099 | } else { | 4108 | } else { |
4100 | message = i18n("There is no next alarm."); | 4109 | message = i18n("There is no next alarm."); |
4101 | 4110 | ||
4102 | } | 4111 | } |
4103 | KMessageBox::information( this, message); | 4112 | KMessageBox::information( this, message); |
4104 | } | 4113 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 9782ffe..05a34b4 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,619 +1,620 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <KDGanttMinimizeSplitter.h> | 42 | #include <KDGanttMinimizeSplitter.h> |
43 | 43 | ||
44 | #include <korganizer/calendarviewbase.h> | 44 | #include <korganizer/calendarviewbase.h> |
45 | 45 | ||
46 | #include <ksyncmanager.h> | 46 | #include <ksyncmanager.h> |
47 | 47 | ||
48 | class QWidgetStack; | 48 | class QWidgetStack; |
49 | class QSplitter; | 49 | class QSplitter; |
50 | 50 | ||
51 | class CalPrinter; | 51 | class CalPrinter; |
52 | class KOFilterView; | 52 | class KOFilterView; |
53 | class KOViewManager; | 53 | class KOViewManager; |
54 | class KODialogManager; | 54 | class KODialogManager; |
55 | class KOTodoView; | 55 | class KOTodoView; |
56 | class KDateNavigator; | 56 | class KDateNavigator; |
57 | class DateNavigatorContainer; | 57 | class DateNavigatorContainer; |
58 | class DateNavigator; | 58 | class DateNavigator; |
59 | class KOIncidenceEditor; | 59 | class KOIncidenceEditor; |
60 | class KDatePicker; | 60 | class KDatePicker; |
61 | class ResourceView; | 61 | class ResourceView; |
62 | class KOEventEditor; | 62 | class KOEventEditor; |
63 | class KOTodoEditor ; | 63 | class KOTodoEditor ; |
64 | class KOEventViewerDialog; | 64 | class KOEventViewerDialog; |
65 | class KOBeamPrefs; | 65 | class KOBeamPrefs; |
66 | class KSyncProfile; | 66 | class KSyncProfile; |
67 | class AlarmDialog; | 67 | class AlarmDialog; |
68 | class KCal::Attendee; | 68 | class KCal::Attendee; |
69 | 69 | ||
70 | namespace KCal { class FileStorage; } | 70 | namespace KCal { class FileStorage; } |
71 | 71 | ||
72 | using namespace KCal; | 72 | using namespace KCal; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | This is the main calendar widget. It provides the different vies on t he | 75 | This is the main calendar widget. It provides the different vies on t he |
76 | calendar data as well as the date navigator. It also handles synchronisation | 76 | calendar data as well as the date navigator. It also handles synchronisation |
77 | of the different views and controls the different dialogs like preferences, | 77 | of the different views and controls the different dialogs like preferences, |
78 | event editor, search dialog etc. | 78 | event editor, search dialog etc. |
79 | 79 | ||
80 | @short main calendar view widget | 80 | @short main calendar view widget |
81 | @author Cornelius Schumacher | 81 | @author Cornelius Schumacher |
82 | */ | 82 | */ |
83 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 83 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
84 | { | 84 | { |
85 | Q_OBJECT | 85 | Q_OBJECT |
86 | public: | 86 | public: |
87 | /** | 87 | /** |
88 | Constructs a new calendar view widget. | 88 | Constructs a new calendar view widget. |
89 | 89 | ||
90 | @param calendar calendar document | 90 | @param calendar calendar document |
91 | @param parent parent window | 91 | @param parent parent window |
92 | @param name Qt internal widget object name | 92 | @param name Qt internal widget object name |
93 | */ | 93 | */ |
94 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 94 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
95 | const char *name = 0 ); | 95 | const char *name = 0 ); |
96 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 96 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
97 | const char *name = 0 ); | 97 | const char *name = 0 ); |
98 | virtual ~CalendarView(); | 98 | virtual ~CalendarView(); |
99 | 99 | ||
100 | Calendar *calendar() { return mCalendar; } | 100 | Calendar *calendar() { return mCalendar; } |
101 | 101 | ||
102 | KOViewManager *viewManager(); | 102 | KOViewManager *viewManager(); |
103 | KODialogManager *dialogManager(); | 103 | KODialogManager *dialogManager(); |
104 | 104 | ||
105 | QDate startDate(); | 105 | QDate startDate(); |
106 | QDate endDate(); | 106 | QDate endDate(); |
107 | 107 | ||
108 | QWidgetStack *viewStack(); | 108 | QWidgetStack *viewStack(); |
109 | QWidget *leftFrame(); | 109 | QWidget *leftFrame(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | void save (); | 120 | void save (); |
121 | void saveStopTimer (); | 121 | void saveStopTimer (); |
122 | void tempDisableBR(bool); | 122 | void tempDisableBR(bool); |
123 | /** This todo has been modified */ | 123 | /** This todo has been modified */ |
124 | void todoModified(Todo *, int); | 124 | void todoModified(Todo *, int); |
125 | 125 | ||
126 | /** when change is made to options dialog, the topwidget will catch this | 126 | /** when change is made to options dialog, the topwidget will catch this |
127 | * and emit this signal which notifies all widgets which have registered | 127 | * and emit this signal which notifies all widgets which have registered |
128 | * for notification to update their settings. */ | 128 | * for notification to update their settings. */ |
129 | void configChanged(); | 129 | void configChanged(); |
130 | /** emitted when the topwidget is closing down, so that any attached | 130 | /** emitted when the topwidget is closing down, so that any attached |
131 | child windows can also close. */ | 131 | child windows can also close. */ |
132 | void closingDown(); | 132 | void closingDown(); |
133 | /** emitted right before we die */ | 133 | /** emitted right before we die */ |
134 | void closed(QWidget *); | 134 | void closed(QWidget *); |
135 | 135 | ||
136 | /** Emitted when state of modified flag changes */ | 136 | /** Emitted when state of modified flag changes */ |
137 | void modifiedChanged(bool); | 137 | void modifiedChanged(bool); |
138 | void signalmodified(); | 138 | void signalmodified(); |
139 | 139 | ||
140 | /** Emitted when state of read-only flag changes */ | 140 | /** Emitted when state of read-only flag changes */ |
141 | void readOnlyChanged(bool); | 141 | void readOnlyChanged(bool); |
142 | 142 | ||
143 | /** Emitted when the unit of navigation changes */ | 143 | /** Emitted when the unit of navigation changes */ |
144 | void changeNavStringPrev(const QString &); | 144 | void changeNavStringPrev(const QString &); |
145 | void changeNavStringNext(const QString &); | 145 | void changeNavStringNext(const QString &); |
146 | 146 | ||
147 | /** Emitted when state of events selection has changed and user is organizer*/ | 147 | /** Emitted when state of events selection has changed and user is organizer*/ |
148 | void organizerEventsSelected(bool); | 148 | void organizerEventsSelected(bool); |
149 | /** Emitted when state of events selection has changed and user is attendee*/ | 149 | /** Emitted when state of events selection has changed and user is attendee*/ |
150 | void groupEventsSelected(bool); | 150 | void groupEventsSelected(bool); |
151 | /** | 151 | /** |
152 | Emitted when an incidence gets selected. If the selection is cleared the | 152 | Emitted when an incidence gets selected. If the selection is cleared the |
153 | signal is emitted with 0 as argument. | 153 | signal is emitted with 0 as argument. |
154 | */ | 154 | */ |
155 | void incidenceSelected( Incidence * ); | 155 | void incidenceSelected( Incidence * ); |
156 | /** Emitted, when a todoitem is selected or deselected. */ | 156 | /** Emitted, when a todoitem is selected or deselected. */ |
157 | void todoSelected( bool ); | 157 | void todoSelected( bool ); |
158 | 158 | ||
159 | /** | 159 | /** |
160 | Emitted, when clipboard content changes. Parameter indicates if paste | 160 | Emitted, when clipboard content changes. Parameter indicates if paste |
161 | is possible or not. | 161 | is possible or not. |
162 | */ | 162 | */ |
163 | void pasteEnabled(bool); | 163 | void pasteEnabled(bool); |
164 | 164 | ||
165 | /** Emitted, when the number of incoming messages has changed. */ | 165 | /** Emitted, when the number of incoming messages has changed. */ |
166 | void numIncomingChanged(int); | 166 | void numIncomingChanged(int); |
167 | 167 | ||
168 | /** Emitted, when the number of outgoing messages has changed. */ | 168 | /** Emitted, when the number of outgoing messages has changed. */ |
169 | void numOutgoingChanged(int); | 169 | void numOutgoingChanged(int); |
170 | 170 | ||
171 | /** Send status message, which can e.g. be displayed in the status bar. */ | 171 | /** Send status message, which can e.g. be displayed in the status bar. */ |
172 | void statusMessage(const QString &); | 172 | void statusMessage(const QString &); |
173 | 173 | ||
174 | void calendarViewExpanded( bool ); | 174 | void calendarViewExpanded( bool ); |
175 | void updateSearchDialog(); | 175 | void updateSearchDialog(); |
176 | 176 | ||
177 | 177 | ||
178 | public slots: | 178 | public slots: |
179 | void slotprintSelInc(); | ||
179 | void showNextAlarms(); | 180 | void showNextAlarms(); |
180 | void showOpenError(); | 181 | void showOpenError(); |
181 | void watchSavedFile(); | 182 | void watchSavedFile(); |
182 | void recheckTimerAlarm(); | 183 | void recheckTimerAlarm(); |
183 | void checkNextTimerAlarm(); | 184 | void checkNextTimerAlarm(); |
184 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 185 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
185 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 186 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
186 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 187 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
187 | 188 | ||
188 | /** options dialog made a changed to the configuration. we catch this | 189 | /** options dialog made a changed to the configuration. we catch this |
189 | * and notify all widgets which need to update their configuration. */ | 190 | * and notify all widgets which need to update their configuration. */ |
190 | void updateConfig(); | 191 | void updateConfig(); |
191 | 192 | ||
192 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 193 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
193 | const QStringList& anniversaryList, const QStringList& realNameList, | 194 | const QStringList& anniversaryList, const QStringList& realNameList, |
194 | const QStringList& emailList, const QStringList& assembledNameList, | 195 | const QStringList& emailList, const QStringList& assembledNameList, |
195 | const QStringList& uidList); | 196 | const QStringList& uidList); |
196 | 197 | ||
197 | /** | 198 | /** |
198 | Load calendar from file \a filename. If \a merge is true, load | 199 | Load calendar from file \a filename. If \a merge is true, load |
199 | calendar into existing one, if it is false, clear calendar, before | 200 | calendar into existing one, if it is false, clear calendar, before |
200 | loading. Return true, if calendar could be successfully loaded. | 201 | loading. Return true, if calendar could be successfully loaded. |
201 | */ | 202 | */ |
202 | bool openCalendar(QString filename, bool merge=false); | 203 | bool openCalendar(QString filename, bool merge=false); |
203 | bool syncCalendar(QString filename,int mode = 0 ); | 204 | bool syncCalendar(QString filename,int mode = 0 ); |
204 | 205 | ||
205 | /** | 206 | /** |
206 | Save calendar data to file. Return true if calendar could be | 207 | Save calendar data to file. Return true if calendar could be |
207 | successfully saved. | 208 | successfully saved. |
208 | */ | 209 | */ |
209 | bool saveCalendar(QString filename); | 210 | bool saveCalendar(QString filename); |
210 | 211 | ||
211 | /** | 212 | /** |
212 | Close calendar. Clear calendar data and reset views to display an empty | 213 | Close calendar. Clear calendar data and reset views to display an empty |
213 | calendar. | 214 | calendar. |
214 | */ | 215 | */ |
215 | void closeCalendar(); | 216 | void closeCalendar(); |
216 | 217 | ||
217 | /** Archive old events of calendar */ | 218 | /** Archive old events of calendar */ |
218 | void archiveCalendar(); | 219 | void archiveCalendar(); |
219 | 220 | ||
220 | void showIncidence(); | 221 | void showIncidence(); |
221 | void editIncidence(); | 222 | void editIncidence(); |
222 | void editIncidenceDescription(); | 223 | void editIncidenceDescription(); |
223 | void deleteIncidence(); | 224 | void deleteIncidence(); |
224 | void cloneIncidence(); | 225 | void cloneIncidence(); |
225 | void moveIncidence(); | 226 | void moveIncidence(); |
226 | void beamIncidence(); | 227 | void beamIncidence(); |
227 | void toggleCancelIncidence(); | 228 | void toggleCancelIncidence(); |
228 | 229 | ||
229 | /** create an editeventwin with supplied date/time, and if bool is true, | 230 | /** create an editeventwin with supplied date/time, and if bool is true, |
230 | * make the event take all day. */ | 231 | * make the event take all day. */ |
231 | void newEvent(QDateTime, QDateTime, bool allDay ); | 232 | void newEvent(QDateTime, QDateTime, bool allDay ); |
232 | void newEvent(QDateTime, QDateTime); | 233 | void newEvent(QDateTime, QDateTime); |
233 | void newEvent(QDateTime fh); | 234 | void newEvent(QDateTime fh); |
234 | void newEvent(QDate dt); | 235 | void newEvent(QDate dt); |
235 | /** create new event without having a date hint. Takes current date as | 236 | /** create new event without having a date hint. Takes current date as |
236 | default hint. */ | 237 | default hint. */ |
237 | void newEvent(); | 238 | void newEvent(); |
238 | void newFloatingEvent(); | 239 | void newFloatingEvent(); |
239 | 240 | ||
240 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 241 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
241 | void showIncidence(Incidence *); | 242 | void showIncidence(Incidence *); |
242 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 243 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
243 | void editIncidence(Incidence *); | 244 | void editIncidence(Incidence *); |
244 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 245 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
245 | void deleteIncidence(Incidence *); | 246 | void deleteIncidence(Incidence *); |
246 | void cloneIncidence(Incidence *); | 247 | void cloneIncidence(Incidence *); |
247 | void cancelIncidence(Incidence *); | 248 | void cancelIncidence(Incidence *); |
248 | /** Create an editor for the supplied event. */ | 249 | /** Create an editor for the supplied event. */ |
249 | void editEvent(Event *); | 250 | void editEvent(Event *); |
250 | /** Delete the supplied event. */ | 251 | /** Delete the supplied event. */ |
251 | void deleteEvent(Event *); | 252 | void deleteEvent(Event *); |
252 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 253 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
253 | found. */ | 254 | found. */ |
254 | bool deleteEvent(const QString &uid); | 255 | bool deleteEvent(const QString &uid); |
255 | /** Create a read-only viewer dialog for the supplied event. */ | 256 | /** Create a read-only viewer dialog for the supplied event. */ |
256 | void showEvent(Event *); | 257 | void showEvent(Event *); |
257 | 258 | ||
258 | void editJournal(Journal *); | 259 | void editJournal(Journal *); |
259 | void showJournal(Journal *); | 260 | void showJournal(Journal *); |
260 | void deleteJournal(Journal *); | 261 | void deleteJournal(Journal *); |
261 | /** Create an editor dialog for a todo */ | 262 | /** Create an editor dialog for a todo */ |
262 | void editTodo(Todo *); | 263 | void editTodo(Todo *); |
263 | /** Create a read-only viewer dialog for the supplied todo */ | 264 | /** Create a read-only viewer dialog for the supplied todo */ |
264 | void showTodo(Todo *); | 265 | void showTodo(Todo *); |
265 | /** create new todo */ | 266 | /** create new todo */ |
266 | void newTodo(); | 267 | void newTodo(); |
267 | void newTodoDateTime(QDateTime, bool allday); | 268 | void newTodoDateTime(QDateTime, bool allday); |
268 | /** create new todo with a parent todo */ | 269 | /** create new todo with a parent todo */ |
269 | void newSubTodo(); | 270 | void newSubTodo(); |
270 | /** create new todo with a parent todo */ | 271 | /** create new todo with a parent todo */ |
271 | void newSubTodo(Todo *); | 272 | void newSubTodo(Todo *); |
272 | /** Delete todo */ | 273 | /** Delete todo */ |
273 | void deleteTodo(Todo *); | 274 | void deleteTodo(Todo *); |
274 | 275 | ||
275 | 276 | ||
276 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 277 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
277 | * emitted as result. */ | 278 | * emitted as result. */ |
278 | void checkClipboard(); | 279 | void checkClipboard(); |
279 | 280 | ||
280 | /** using the KConfig associated with the kapp variable, read in the | 281 | /** using the KConfig associated with the kapp variable, read in the |
281 | * settings from the config file. | 282 | * settings from the config file. |
282 | */ | 283 | */ |
283 | void readSettings(); | 284 | void readSettings(); |
284 | 285 | ||
285 | /** write current state to config file. */ | 286 | /** write current state to config file. */ |
286 | void writeSettings(); | 287 | void writeSettings(); |
287 | 288 | ||
288 | /** read settings for calendar filters */ | 289 | /** read settings for calendar filters */ |
289 | void readFilterSettings(KConfig *config); | 290 | void readFilterSettings(KConfig *config); |
290 | 291 | ||
291 | /** write settings for calendar filters */ | 292 | /** write settings for calendar filters */ |
292 | void writeFilterSettings(KConfig *config); | 293 | void writeFilterSettings(KConfig *config); |
293 | 294 | ||
294 | /** passes on the message that an event has changed to the currently | 295 | /** passes on the message that an event has changed to the currently |
295 | * activated view so that it can make appropriate display changes. */ | 296 | * activated view so that it can make appropriate display changes. */ |
296 | void changeEventDisplay(Event *, int); | 297 | void changeEventDisplay(Event *, int); |
297 | void changeIncidenceDisplay(Incidence *, int); | 298 | void changeIncidenceDisplay(Incidence *, int); |
298 | void changeTodoDisplay(Todo *, int); | 299 | void changeTodoDisplay(Todo *, int); |
299 | 300 | ||
300 | void eventAdded(Event *); | 301 | void eventAdded(Event *); |
301 | void eventChanged(Event *); | 302 | void eventChanged(Event *); |
302 | void eventToBeDeleted(Event *); | 303 | void eventToBeDeleted(Event *); |
303 | void eventDeleted(); | 304 | void eventDeleted(); |
304 | 305 | ||
305 | void todoAdded(Todo *); | 306 | void todoAdded(Todo *); |
306 | void todoChanged(Todo *); | 307 | void todoChanged(Todo *); |
307 | void todoToBeDeleted(Todo *); | 308 | void todoToBeDeleted(Todo *); |
308 | void todoDeleted(); | 309 | void todoDeleted(); |
309 | 310 | ||
310 | void updateView(const QDate &start, const QDate &end); | 311 | void updateView(const QDate &start, const QDate &end); |
311 | void updateView(); | 312 | void updateView(); |
312 | 313 | ||
313 | /** Full update of visible todo views */ | 314 | /** Full update of visible todo views */ |
314 | void updateTodoViews(); | 315 | void updateTodoViews(); |
315 | 316 | ||
316 | void updateUnmanagedViews(); | 317 | void updateUnmanagedViews(); |
317 | 318 | ||
318 | /** cut the current appointment to the clipboard */ | 319 | /** cut the current appointment to the clipboard */ |
319 | void edit_cut(); | 320 | void edit_cut(); |
320 | 321 | ||
321 | /** copy the current appointment(s) to the clipboard */ | 322 | /** copy the current appointment(s) to the clipboard */ |
322 | void edit_copy(); | 323 | void edit_copy(); |
323 | 324 | ||
324 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 325 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
325 | void edit_paste(); | 326 | void edit_paste(); |
326 | 327 | ||
327 | /** edit viewing and configuration options. */ | 328 | /** edit viewing and configuration options. */ |
328 | void edit_options(); | 329 | void edit_options(); |
329 | /** | 330 | /** |
330 | Functions for printing, previewing a print, and setting up printing | 331 | Functions for printing, previewing a print, and setting up printing |
331 | parameters. | 332 | parameters. |
332 | */ | 333 | */ |
333 | void print(); | 334 | void print(); |
334 | void printSetup(); | 335 | void printSetup(); |
335 | void printPreview(); | 336 | void printPreview(); |
336 | 337 | ||
337 | /** Export as iCalendar file */ | 338 | /** Export as iCalendar file */ |
338 | void exportICalendar(); | 339 | void exportICalendar(); |
339 | 340 | ||
340 | /** Export as vCalendar file */ | 341 | /** Export as vCalendar file */ |
341 | bool exportVCalendar( QString fn); | 342 | bool exportVCalendar( QString fn); |
342 | 343 | ||
343 | /** pop up a dialog to show an existing appointment. */ | 344 | /** pop up a dialog to show an existing appointment. */ |
344 | void appointment_show(); | 345 | void appointment_show(); |
345 | /** | 346 | /** |
346 | * pop up an Appointment Dialog to edit an existing appointment.Get | 347 | * pop up an Appointment Dialog to edit an existing appointment.Get |
347 | * information on the appointment from the list of unique IDs that is | 348 | * information on the appointment from the list of unique IDs that is |
348 | * currently in the View, called currIds. | 349 | * currently in the View, called currIds. |
349 | */ | 350 | */ |
350 | void appointment_edit(); | 351 | void appointment_edit(); |
351 | /** | 352 | /** |
352 | * pop up dialog confirming deletion of currently selected event in the | 353 | * pop up dialog confirming deletion of currently selected event in the |
353 | * View. | 354 | * View. |
354 | */ | 355 | */ |
355 | void appointment_delete(); | 356 | void appointment_delete(); |
356 | 357 | ||
357 | /** mails the currently selected event to a particular user as a vCalendar | 358 | /** mails the currently selected event to a particular user as a vCalendar |
358 | attachment. */ | 359 | attachment. */ |
359 | void action_mail(); | 360 | void action_mail(); |
360 | 361 | ||
361 | /* frees a subtodo from it's relation */ | 362 | /* frees a subtodo from it's relation */ |
362 | void todo_unsub( Todo * ); | 363 | void todo_unsub( Todo * ); |
363 | void todo_resub( Todo * parent, Todo * sub ); | 364 | void todo_resub( Todo * parent, Todo * sub ); |
364 | 365 | ||
365 | /** Take ownership of selected event. */ | 366 | /** Take ownership of selected event. */ |
366 | void takeOverEvent(); | 367 | void takeOverEvent(); |
367 | 368 | ||
368 | /** Take ownership of all events in calendar. */ | 369 | /** Take ownership of all events in calendar. */ |
369 | void takeOverCalendar(); | 370 | void takeOverCalendar(); |
370 | 371 | ||
371 | /** query whether or not the calendar is "dirty". */ | 372 | /** query whether or not the calendar is "dirty". */ |
372 | bool isModified(); | 373 | bool isModified(); |
373 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 374 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
374 | void setModified(bool modified=true); | 375 | void setModified(bool modified=true); |
375 | 376 | ||
376 | /** query if the calendar is read-only. */ | 377 | /** query if the calendar is read-only. */ |
377 | bool isReadOnly(); | 378 | bool isReadOnly(); |
378 | /** set state of calendar to read-only */ | 379 | /** set state of calendar to read-only */ |
379 | void setReadOnly(bool readOnly=true); | 380 | void setReadOnly(bool readOnly=true); |
380 | 381 | ||
381 | void eventUpdated(Incidence *); | 382 | void eventUpdated(Incidence *); |
382 | 383 | ||
383 | /* iTIP scheduling actions */ | 384 | /* iTIP scheduling actions */ |
384 | void schedule_publish(Incidence *incidence = 0); | 385 | void schedule_publish(Incidence *incidence = 0); |
385 | void schedule_request(Incidence *incidence = 0); | 386 | void schedule_request(Incidence *incidence = 0); |
386 | void schedule_refresh(Incidence *incidence = 0); | 387 | void schedule_refresh(Incidence *incidence = 0); |
387 | void schedule_cancel(Incidence *incidence = 0); | 388 | void schedule_cancel(Incidence *incidence = 0); |
388 | void schedule_add(Incidence *incidence = 0); | 389 | void schedule_add(Incidence *incidence = 0); |
389 | void schedule_reply(Incidence *incidence = 0); | 390 | void schedule_reply(Incidence *incidence = 0); |
390 | void schedule_counter(Incidence *incidence = 0); | 391 | void schedule_counter(Incidence *incidence = 0); |
391 | void schedule_declinecounter(Incidence *incidence = 0); | 392 | void schedule_declinecounter(Incidence *incidence = 0); |
392 | void schedule_publish_freebusy(int daysToPublish = 30); | 393 | void schedule_publish_freebusy(int daysToPublish = 30); |
393 | 394 | ||
394 | void openAddressbook(); | 395 | void openAddressbook(); |
395 | 396 | ||
396 | void editFilters(); | 397 | void editFilters(); |
397 | void toggleFilerEnabled(); | 398 | void toggleFilerEnabled(); |
398 | QPtrList<CalFilter> filters(); | 399 | QPtrList<CalFilter> filters(); |
399 | void toggleFilter(); | 400 | void toggleFilter(); |
400 | void showFilter(bool visible); | 401 | void showFilter(bool visible); |
401 | void updateFilter(); | 402 | void updateFilter(); |
402 | void filterEdited(); | 403 | void filterEdited(); |
403 | void selectFilter( int ); | 404 | void selectFilter( int ); |
404 | KOFilterView *filterView(); | 405 | KOFilterView *filterView(); |
405 | 406 | ||
406 | void showIntro(); | 407 | void showIntro(); |
407 | 408 | ||
408 | /** Move the curdatepient view date to today */ | 409 | /** Move the curdatepient view date to today */ |
409 | void goToday(); | 410 | void goToday(); |
410 | 411 | ||
411 | /** Move to the next date(s) in the current view */ | 412 | /** Move to the next date(s) in the current view */ |
412 | void goNext(); | 413 | void goNext(); |
413 | 414 | ||
414 | /** Move to the previous date(s) in the current view */ | 415 | /** Move to the previous date(s) in the current view */ |
415 | void goPrevious(); | 416 | void goPrevious(); |
416 | /** Move to the next date(s) in the current view */ | 417 | /** Move to the next date(s) in the current view */ |
417 | void goNextMonth(); | 418 | void goNextMonth(); |
418 | 419 | ||
419 | /** Move to the previous date(s) in the current view */ | 420 | /** Move to the previous date(s) in the current view */ |
420 | void goPreviousMonth(); | 421 | void goPreviousMonth(); |
421 | 422 | ||
422 | void toggleExpand(); | 423 | void toggleExpand(); |
423 | void toggleDateNavigatorWidget(); | 424 | void toggleDateNavigatorWidget(); |
424 | void toggleAllDaySize(); | 425 | void toggleAllDaySize(); |
425 | void dialogClosing(Incidence *); | 426 | void dialogClosing(Incidence *); |
426 | 427 | ||
427 | /** Look for new messages in the inbox */ | 428 | /** Look for new messages in the inbox */ |
428 | void lookForIncomingMessages(); | 429 | void lookForIncomingMessages(); |
429 | /** Look for new messages in the outbox */ | 430 | /** Look for new messages in the outbox */ |
430 | void lookForOutgoingMessages(); | 431 | void lookForOutgoingMessages(); |
431 | 432 | ||
432 | void processMainViewSelection( Incidence * ); | 433 | void processMainViewSelection( Incidence * ); |
433 | void processTodoListSelection( Incidence * ); | 434 | void processTodoListSelection( Incidence * ); |
434 | 435 | ||
435 | void processIncidenceSelection( Incidence * ); | 436 | void processIncidenceSelection( Incidence * ); |
436 | 437 | ||
437 | void purgeCompleted(); | 438 | void purgeCompleted(); |
438 | bool removeCompletedSubTodos( Todo* ); | 439 | bool removeCompletedSubTodos( Todo* ); |
439 | void slotCalendarChanged(); | 440 | void slotCalendarChanged(); |
440 | bool importBday(); | 441 | bool importBday(); |
441 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 442 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
442 | bool importQtopia( const QString &categoriesFile, | 443 | bool importQtopia( const QString &categoriesFile, |
443 | const QString &datebookFile, | 444 | const QString &datebookFile, |
444 | const QString &tasklistFile ); | 445 | const QString &tasklistFile ); |
445 | void syncExternal( int mode ); | 446 | void syncExternal( int mode ); |
446 | void slotSelectPickerDate( QDate ) ; | 447 | void slotSelectPickerDate( QDate ) ; |
447 | void showDatePicker() ; | 448 | void showDatePicker() ; |
448 | void showDatePickerPopup() ; | 449 | void showDatePickerPopup() ; |
449 | void moveIncidence(Incidence *) ; | 450 | void moveIncidence(Incidence *) ; |
450 | void beamIncidence(Incidence *) ; | 451 | void beamIncidence(Incidence *) ; |
451 | void beamCalendar() ; | 452 | void beamCalendar() ; |
452 | void beamFilteredCalendar() ; | 453 | void beamFilteredCalendar() ; |
453 | void beamIncidenceList(QPtrList<Incidence>) ; | 454 | void beamIncidenceList(QPtrList<Incidence>) ; |
454 | void manageCategories(); | 455 | void manageCategories(); |
455 | int addCategories(); | 456 | int addCategories(); |
456 | void removeCategories(); | 457 | void removeCategories(); |
457 | void setSyncDevice( QString ); | 458 | void setSyncDevice( QString ); |
458 | void setSyncName( QString ); | 459 | void setSyncName( QString ); |
459 | void showDay( QDate ); | 460 | void showDay( QDate ); |
460 | void undo_delete(); | 461 | void undo_delete(); |
461 | protected slots: | 462 | protected slots: |
462 | void resetFocus(); | 463 | void resetFocus(); |
463 | void slotViewerClosed(); | 464 | void slotViewerClosed(); |
464 | void timerAlarm(); | 465 | void timerAlarm(); |
465 | void suspendAlarm(); | 466 | void suspendAlarm(); |
466 | void beamDone( Ir *ir ); | 467 | void beamDone( Ir *ir ); |
467 | /** Select a view or adapt the current view to display the specified dates. */ | 468 | /** Select a view or adapt the current view to display the specified dates. */ |
468 | void showDates( const KCal::DateList & ); | 469 | void showDates( const KCal::DateList & ); |
469 | void selectWeekNum ( int ); | 470 | void selectWeekNum ( int ); |
470 | 471 | ||
471 | public: | 472 | public: |
472 | // show a standard warning | 473 | // show a standard warning |
473 | // returns KMsgBox::yesNoCancel() | 474 | // returns KMsgBox::yesNoCancel() |
474 | int msgCalModified(); | 475 | int msgCalModified(); |
475 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 476 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
476 | 477 | ||
477 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 478 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
478 | virtual void removeSyncInfo( QString syncProfile); | 479 | virtual void removeSyncInfo( QString syncProfile); |
479 | void setSyncManager(KSyncManager* manager); | 480 | void setSyncManager(KSyncManager* manager); |
480 | void setLoadedFileVersion(QDateTime); | 481 | void setLoadedFileVersion(QDateTime); |
481 | bool checkFileVersion(QString fn); | 482 | bool checkFileVersion(QString fn); |
482 | bool checkFileChanged(QString fn); | 483 | bool checkFileChanged(QString fn); |
483 | Event* getLastSyncEvent(); | 484 | Event* getLastSyncEvent(); |
484 | /** Adapt navigation units correpsonding to step size of navigation of the | 485 | /** Adapt navigation units correpsonding to step size of navigation of the |
485 | * current view. | 486 | * current view. |
486 | */ | 487 | */ |
487 | void adaptNavigationUnits(); | 488 | void adaptNavigationUnits(); |
488 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 489 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
489 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 490 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
490 | //Attendee* getYourAttendee(Event *event); | 491 | //Attendee* getYourAttendee(Event *event); |
491 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 492 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
492 | protected: | 493 | protected: |
493 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 494 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
494 | 495 | ||
495 | // returns KMsgBox::OKCandel() | 496 | // returns KMsgBox::OKCandel() |
496 | int msgItemDelete(const QString name); | 497 | int msgItemDelete(const QString name); |
497 | void showEventEditor(); | 498 | void showEventEditor(); |
498 | void showTodoEditor(); | 499 | void showTodoEditor(); |
499 | void writeLocale(); | 500 | void writeLocale(); |
500 | Todo *selectedTodo(); | 501 | Todo *selectedTodo(); |
501 | 502 | ||
502 | private: | 503 | private: |
503 | QDateTime mNextAlarmDateTime; | 504 | QDateTime mNextAlarmDateTime; |
504 | bool mViewerCallerIsSearchDialog; | 505 | bool mViewerCallerIsSearchDialog; |
505 | bool mBlockShowDates; | 506 | bool mBlockShowDates; |
506 | KSyncManager* mSyncManager; | 507 | KSyncManager* mSyncManager; |
507 | AlarmDialog * mAlarmDialog; | 508 | AlarmDialog * mAlarmDialog; |
508 | QString mAlarmNotification; | 509 | QString mAlarmNotification; |
509 | QString mSuspendAlarmNotification; | 510 | QString mSuspendAlarmNotification; |
510 | QTimer* mSuspendTimer; | 511 | QTimer* mSuspendTimer; |
511 | QTimer* mAlarmTimer; | 512 | QTimer* mAlarmTimer; |
512 | QTimer* mRecheckAlarmTimer; | 513 | QTimer* mRecheckAlarmTimer; |
513 | void computeAlarm( QString ); | 514 | void computeAlarm( QString ); |
514 | void startAlarm( QString, QString ); | 515 | void startAlarm( QString, QString ); |
515 | void setSyncEventsReadOnly(); | 516 | void setSyncEventsReadOnly(); |
516 | 517 | ||
517 | QDateTime loadedFileVersion; | 518 | QDateTime loadedFileVersion; |
518 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 519 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
519 | void checkExternalId( Incidence * inc ); | 520 | void checkExternalId( Incidence * inc ); |
520 | int mGlobalSyncMode; | 521 | int mGlobalSyncMode; |
521 | QString mCurrentSyncDevice; | 522 | QString mCurrentSyncDevice; |
522 | QString mCurrentSyncName; | 523 | QString mCurrentSyncName; |
523 | KOBeamPrefs* beamDialog; | 524 | KOBeamPrefs* beamDialog; |
524 | void init(); | 525 | void init(); |
525 | int mDatePickerMode; | 526 | int mDatePickerMode; |
526 | bool mFlagEditDescription; | 527 | bool mFlagEditDescription; |
527 | QDateTime mLastCalendarSync; | 528 | QDateTime mLastCalendarSync; |
528 | void createPrinter(); | 529 | void createPrinter(); |
529 | 530 | ||
530 | void calendarModified( bool, Calendar * ); | 531 | void calendarModified( bool, Calendar * ); |
531 | 532 | ||
532 | CalPrinter *mCalPrinter; | 533 | CalPrinter *mCalPrinter; |
533 | 534 | ||
534 | QSplitter *mPanner; | 535 | QSplitter *mPanner; |
535 | QSplitter *mLeftSplitter; | 536 | QSplitter *mLeftSplitter; |
536 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 537 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
537 | QWidgetStack *mRightFrame; | 538 | QWidgetStack *mRightFrame; |
538 | 539 | ||
539 | KDatePicker* mDatePicker; | 540 | KDatePicker* mDatePicker; |
540 | QVBox* mDateFrame; | 541 | QVBox* mDateFrame; |
541 | 542 | ||
542 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 543 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
543 | 544 | ||
544 | KOFilterView *mFilterView; | 545 | KOFilterView *mFilterView; |
545 | 546 | ||
546 | ResourceView *mResourceView; | 547 | ResourceView *mResourceView; |
547 | 548 | ||
548 | // calendar object for this viewing instance | 549 | // calendar object for this viewing instance |
549 | Calendar *mCalendar; | 550 | Calendar *mCalendar; |
550 | 551 | ||
551 | CalendarResourceManager *mResourceManager; | 552 | CalendarResourceManager *mResourceManager; |
552 | 553 | ||
553 | FileStorage *mStorage; | 554 | FileStorage *mStorage; |
554 | 555 | ||
555 | DateNavigator *mNavigator; | 556 | DateNavigator *mNavigator; |
556 | 557 | ||
557 | KOViewManager *mViewManager; | 558 | KOViewManager *mViewManager; |
558 | KODialogManager *mDialogManager; | 559 | KODialogManager *mDialogManager; |
559 | 560 | ||
560 | // Calendar filters | 561 | // Calendar filters |
561 | QPtrList<CalFilter> mFilters; | 562 | QPtrList<CalFilter> mFilters; |
562 | 563 | ||
563 | // various housekeeping variables. | 564 | // various housekeeping variables. |
564 | bool mModified; // flag indicating if calendar is modified | 565 | bool mModified; // flag indicating if calendar is modified |
565 | bool mReadOnly; // flag indicating if calendar is read-only | 566 | bool mReadOnly; // flag indicating if calendar is read-only |
566 | QDate mSaveSingleDate; | 567 | QDate mSaveSingleDate; |
567 | 568 | ||
568 | Incidence *mSelectedIncidence; | 569 | Incidence *mSelectedIncidence; |
569 | Incidence *mMoveIncidence; | 570 | Incidence *mMoveIncidence; |
570 | QDate mMoveIncidenceOldDate; | 571 | QDate mMoveIncidenceOldDate; |
571 | KOTodoView *mTodoList; | 572 | KOTodoView *mTodoList; |
572 | KOEventEditor * mEventEditor; | 573 | KOEventEditor * mEventEditor; |
573 | KOTodoEditor * mTodoEditor; | 574 | KOTodoEditor * mTodoEditor; |
574 | KOEventViewerDialog * mEventViewerDialog; | 575 | KOEventViewerDialog * mEventViewerDialog; |
575 | void keyPressEvent ( QKeyEvent *e) ; | 576 | void keyPressEvent ( QKeyEvent *e) ; |
576 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 577 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
577 | }; | 578 | }; |
578 | 579 | ||
579 | 580 | ||
580 | class CalendarViewVisitor : public Incidence::Visitor | 581 | class CalendarViewVisitor : public Incidence::Visitor |
581 | { | 582 | { |
582 | public: | 583 | public: |
583 | CalendarViewVisitor() : mView( 0 ) {} | 584 | CalendarViewVisitor() : mView( 0 ) {} |
584 | 585 | ||
585 | bool act( Incidence *incidence, CalendarView *view ) | 586 | bool act( Incidence *incidence, CalendarView *view ) |
586 | { | 587 | { |
587 | mView = view; | 588 | mView = view; |
588 | return incidence->accept( *this ); | 589 | return incidence->accept( *this ); |
589 | } | 590 | } |
590 | 591 | ||
591 | protected: | 592 | protected: |
592 | CalendarView *mView; | 593 | CalendarView *mView; |
593 | }; | 594 | }; |
594 | 595 | ||
595 | class ShowIncidenceVisitor : public CalendarViewVisitor | 596 | class ShowIncidenceVisitor : public CalendarViewVisitor |
596 | { | 597 | { |
597 | protected: | 598 | protected: |
598 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 599 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
599 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 600 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
600 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 601 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
601 | }; | 602 | }; |
602 | 603 | ||
603 | class EditIncidenceVisitor : public CalendarViewVisitor | 604 | class EditIncidenceVisitor : public CalendarViewVisitor |
604 | { | 605 | { |
605 | protected: | 606 | protected: |
606 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 607 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
607 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 608 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
608 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 609 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
609 | }; | 610 | }; |
610 | 611 | ||
611 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 612 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
612 | { | 613 | { |
613 | protected: | 614 | protected: |
614 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 615 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
615 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 616 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
616 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 617 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
617 | }; | 618 | }; |
618 | 619 | ||
619 | #endif | 620 | #endif |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 1508638..445fc86 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,721 +1,750 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #include <qprinter.h> | ||
57 | #include <qpainter.h> | ||
58 | #include <qpaintdevicemetrics.h> | ||
56 | #else //DESKTOP_VERSION | 59 | #else //DESKTOP_VERSION |
57 | #include <externalapphandler.h> | 60 | #include <externalapphandler.h> |
58 | #include <qtopia/qcopenvelope_qws.h> | 61 | #include <qtopia/qcopenvelope_qws.h> |
59 | #endif //DESKTOP_VERSION | 62 | #endif //DESKTOP_VERSION |
60 | 63 | ||
61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
62 | : QTextBrowser(parent,name) | 65 | : QTextBrowser(parent,name) |
63 | { | 66 | { |
64 | mSyncMode = false; | 67 | mSyncMode = false; |
65 | mColorMode = 0; | 68 | mColorMode = 0; |
66 | } | 69 | } |
67 | 70 | ||
68 | KOEventViewer::~KOEventViewer() | 71 | KOEventViewer::~KOEventViewer() |
69 | { | 72 | { |
70 | } | 73 | } |
71 | 74 | ||
75 | void KOEventViewer::printMe() | ||
76 | { | ||
77 | #ifdef DESKTOP_VERSION | ||
78 | QPrinter printer; | ||
79 | if (!printer.setup() ) | ||
80 | return; | ||
81 | QPainter p; | ||
82 | p.begin ( &printer ); | ||
83 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
84 | float dx, dy; | ||
85 | int wid = (m.width() * 9)/10; | ||
86 | dx = (float) wid/(float)contentsWidth (); | ||
87 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
88 | float scale; | ||
89 | // scale to fit the width or height of the paper | ||
90 | if ( dx < dy ) | ||
91 | scale = dx; | ||
92 | else | ||
93 | scale = dy; | ||
94 | p.translate( m.width()/10,0 ); | ||
95 | p.scale( scale, scale ); | ||
96 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
97 | p.end(); | ||
98 | #endif | ||
99 | |||
100 | } | ||
72 | void KOEventViewer::setSource(const QString& n) | 101 | void KOEventViewer::setSource(const QString& n) |
73 | { | 102 | { |
74 | 103 | ||
75 | if ( n.left(3) == "uid" ) | 104 | if ( n.left(3) == "uid" ) |
76 | #ifdef DESKTOP_VERSION | 105 | #ifdef DESKTOP_VERSION |
77 | { | 106 | { |
78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 107 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
79 | KABC::AddressBook::Iterator it; | 108 | KABC::AddressBook::Iterator it; |
80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 109 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
81 | // LR I do not understand, why the uid string is different on zaurus and desktop | 110 | // LR I do not understand, why the uid string is different on zaurus and desktop |
82 | QString uid = "uid://"+(*it).uid(); | 111 | QString uid = "uid://"+(*it).uid(); |
83 | 112 | ||
84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 113 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
85 | if (n == uid ) { | 114 | if (n == uid ) { |
86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 115 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
87 | QDialog dia( this,"dia123", true ); | 116 | QDialog dia( this,"dia123", true ); |
88 | dia.setCaption( i18n("Details of attendee") ); | 117 | dia.setCaption( i18n("Details of attendee") ); |
89 | QVBoxLayout lay ( &dia ); | 118 | QVBoxLayout lay ( &dia ); |
90 | KABC::AddresseeView av ( &dia ); | 119 | KABC::AddresseeView av ( &dia ); |
91 | av.setAddressee( (*it) ); | 120 | av.setAddressee( (*it) ); |
92 | lay.addWidget( &av ); | 121 | lay.addWidget( &av ); |
93 | if ( QApplication::desktop()->width() < 480 ) | 122 | if ( QApplication::desktop()->width() < 480 ) |
94 | dia.resize( 220, 240); | 123 | dia.resize( 220, 240); |
95 | else { | 124 | else { |
96 | dia.resize( 400,400); | 125 | dia.resize( 400,400); |
97 | } | 126 | } |
98 | dia.exec(); | 127 | dia.exec(); |
99 | break; | 128 | break; |
100 | } | 129 | } |
101 | } | 130 | } |
102 | return; | 131 | return; |
103 | } | 132 | } |
104 | #else | 133 | #else |
105 | { | 134 | { |
106 | if ( "uid:organizer" == n ) { | 135 | if ( "uid:organizer" == n ) { |
107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 136 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
108 | return; | 137 | return; |
109 | } | 138 | } |
110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 139 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
111 | if (attendees.count()) { | 140 | if (attendees.count()) { |
112 | Attendee *a; | 141 | Attendee *a; |
113 | for(a=attendees.first();a;a=attendees.next()) { | 142 | for(a=attendees.first();a;a=attendees.next()) { |
114 | if ( "uid:"+a->uid() == n ) { | 143 | if ( "uid:"+a->uid() == n ) { |
115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 144 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
116 | return; | 145 | return; |
117 | } | 146 | } |
118 | } | 147 | } |
119 | } | 148 | } |
120 | return; | 149 | return; |
121 | } | 150 | } |
122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 151 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
123 | // the result should now arrive through method insertAttendees | 152 | // the result should now arrive through method insertAttendees |
124 | //QString uid = "uid:"+(*it).uid(); | 153 | //QString uid = "uid:"+(*it).uid(); |
125 | #endif | 154 | #endif |
126 | if ( n.left(6) == "mailto" ) { | 155 | if ( n.left(6) == "mailto" ) { |
127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 156 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
128 | #ifndef DESKTOP_VERSION | 157 | #ifndef DESKTOP_VERSION |
129 | if ( n.mid(7,3) == "ALL" ) { | 158 | if ( n.mid(7,3) == "ALL" ) { |
130 | qDebug("all "); | 159 | qDebug("all "); |
131 | mailToAttendees( true ); | 160 | mailToAttendees( true ); |
132 | } else if ( n.mid(7,4) == "RSVP" ) { | 161 | } else if ( n.mid(7,4) == "RSVP" ) { |
133 | mailToAttendees( false ); | 162 | mailToAttendees( false ); |
134 | qDebug("rsvp "); | 163 | qDebug("rsvp "); |
135 | } else { | 164 | } else { |
136 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 165 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
137 | e << n.mid(7); | 166 | e << n.mid(7); |
138 | } | 167 | } |
139 | #endif | 168 | #endif |
140 | 169 | ||
141 | } | 170 | } |
142 | 171 | ||
143 | 172 | ||
144 | #ifndef KORG_NODCOP | 173 | #ifndef KORG_NODCOP |
145 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 174 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
146 | QString tmpStr; | 175 | QString tmpStr; |
147 | if (n.startsWith("mailto:")) { | 176 | if (n.startsWith("mailto:")) { |
148 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 177 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
149 | //emit showIncidence(n); | 178 | //emit showIncidence(n); |
150 | return; | 179 | return; |
151 | } else if (n.startsWith("uid:")) { | 180 | } else if (n.startsWith("uid:")) { |
152 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 181 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
153 | const QByteArray noParamData; | 182 | const QByteArray noParamData; |
154 | const QByteArray paramData; | 183 | const QByteArray paramData; |
155 | QByteArray replyData; | 184 | QByteArray replyData; |
156 | QCString replyTypeStr; | 185 | QCString replyTypeStr; |
157 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 186 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
158 | bool foundAbbrowser = PING_ABBROWSER; | 187 | bool foundAbbrowser = PING_ABBROWSER; |
159 | 188 | ||
160 | if (foundAbbrowser) { | 189 | if (foundAbbrowser) { |
161 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 190 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
162 | //client->send("kaddressbook","KAddressBookIface", | 191 | //client->send("kaddressbook","KAddressBookIface", |
163 | QDataStream arg(paramData, IO_WriteOnly); | 192 | QDataStream arg(paramData, IO_WriteOnly); |
164 | arg << n.mid(6); | 193 | arg << n.mid(6); |
165 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 194 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
166 | return; | 195 | return; |
167 | } else { | 196 | } else { |
168 | /* | 197 | /* |
169 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 198 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
170 | We start it without its main interface | 199 | We start it without its main interface |
171 | */ | 200 | */ |
172 | KIconLoader* iconLoader = new KIconLoader(); | 201 | KIconLoader* iconLoader = new KIconLoader(); |
173 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 202 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
174 | ActionManager::setStartedKAddressBook(true); | 203 | ActionManager::setStartedKAddressBook(true); |
175 | tmpStr = "kaddressbook --editor-only --uid "; | 204 | tmpStr = "kaddressbook --editor-only --uid "; |
176 | tmpStr += KProcess::quote(n.mid(6)); | 205 | tmpStr += KProcess::quote(n.mid(6)); |
177 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 206 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
178 | return; | 207 | return; |
179 | } | 208 | } |
180 | } else { | 209 | } else { |
181 | //QTextBrowser::setSource(n); | 210 | //QTextBrowser::setSource(n); |
182 | } | 211 | } |
183 | #endif | 212 | #endif |
184 | } | 213 | } |
185 | void KOEventViewer::mailToAttendees( bool all ) | 214 | void KOEventViewer::mailToAttendees( bool all ) |
186 | { | 215 | { |
187 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 216 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
188 | if (attendees.count() == 0) return; | 217 | if (attendees.count() == 0) return; |
189 | QStringList nameList; | 218 | QStringList nameList; |
190 | QStringList emailList; | 219 | QStringList emailList; |
191 | QStringList uidList; | 220 | QStringList uidList; |
192 | Attendee* a; | 221 | Attendee* a; |
193 | for(a=attendees.first();a;a=attendees.next()) { | 222 | for(a=attendees.first();a;a=attendees.next()) { |
194 | if ( !all && !a->RSVP() ) continue; | 223 | if ( !all && !a->RSVP() ) continue; |
195 | if (!a->email().isEmpty()) { | 224 | if (!a->email().isEmpty()) { |
196 | nameList.append (a->name() ); | 225 | nameList.append (a->name() ); |
197 | emailList.append (a->email() ); | 226 | emailList.append (a->email() ); |
198 | uidList.append (a->uid() ); | 227 | uidList.append (a->uid() ); |
199 | } | 228 | } |
200 | } | 229 | } |
201 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 230 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
202 | #ifndef DESKTOP_VERSION | 231 | #ifndef DESKTOP_VERSION |
203 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 232 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
204 | #endif | 233 | #endif |
205 | 234 | ||
206 | } | 235 | } |
207 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 236 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
208 | { | 237 | { |
209 | int number=text.contains("\n"); | 238 | int number=text.contains("\n"); |
210 | QString str = "<" + tag + ">"; | 239 | QString str = "<" + tag + ">"; |
211 | QString tmpText=text; | 240 | QString tmpText=text; |
212 | QString tmpStr=str; | 241 | QString tmpStr=str; |
213 | if(number !=-1) | 242 | if(number !=-1) |
214 | { | 243 | { |
215 | if (number > 0) { | 244 | if (number > 0) { |
216 | int pos=0; | 245 | int pos=0; |
217 | QString tmp; | 246 | QString tmp; |
218 | for(int i=0;i<=number;i++) { | 247 | for(int i=0;i<=number;i++) { |
219 | pos=tmpText.find("\n"); | 248 | pos=tmpText.find("\n"); |
220 | tmp=tmpText.left(pos); | 249 | tmp=tmpText.left(pos); |
221 | tmpText=tmpText.right(tmpText.length()-pos-1); | 250 | tmpText=tmpText.right(tmpText.length()-pos-1); |
222 | tmpStr+=tmp+"<br>"; | 251 | tmpStr+=tmp+"<br>"; |
223 | } | 252 | } |
224 | } | 253 | } |
225 | else tmpStr += tmpText; | 254 | else tmpStr += tmpText; |
226 | tmpStr+="</" + tag + ">"; | 255 | tmpStr+="</" + tag + ">"; |
227 | mText.append(tmpStr); | 256 | mText.append(tmpStr); |
228 | } | 257 | } |
229 | else | 258 | else |
230 | { | 259 | { |
231 | str += text + "</" + tag + ">"; | 260 | str += text + "</" + tag + ">"; |
232 | mText.append(str); | 261 | mText.append(str); |
233 | } | 262 | } |
234 | } | 263 | } |
235 | 264 | ||
236 | void KOEventViewer::setColorMode( int m ) | 265 | void KOEventViewer::setColorMode( int m ) |
237 | { | 266 | { |
238 | mColorMode = m; | 267 | mColorMode = m; |
239 | } | 268 | } |
240 | void KOEventViewer::appendEvent(Event *event, int mode ) | 269 | void KOEventViewer::appendEvent(Event *event, int mode ) |
241 | { | 270 | { |
242 | mMailSubject = ""; | 271 | mMailSubject = ""; |
243 | mCurrentIncidence = event; | 272 | mCurrentIncidence = event; |
244 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 273 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
245 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 274 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
246 | if ( mode == 0 ) { | 275 | if ( mode == 0 ) { |
247 | addTag("h2",deTag(event->summary())); | 276 | addTag("h2",deTag(event->summary())); |
248 | } | 277 | } |
249 | else { | 278 | else { |
250 | if ( mColorMode == 1 ) { | 279 | if ( mColorMode == 1 ) { |
251 | mText +="<font color=\"#00A000\">"; | 280 | mText +="<font color=\"#00A000\">"; |
252 | } | 281 | } |
253 | if ( mColorMode == 2 ) { | 282 | if ( mColorMode == 2 ) { |
254 | mText +="<font color=\"#C00000\">"; | 283 | mText +="<font color=\"#C00000\">"; |
255 | } | 284 | } |
256 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 285 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
257 | if ( mode == 1 ) { | 286 | if ( mode == 1 ) { |
258 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 287 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
259 | } else { | 288 | } else { |
260 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 289 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
261 | } | 290 | } |
262 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 291 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
263 | if ( mColorMode ) | 292 | if ( mColorMode ) |
264 | mText += "</font>"; | 293 | mText += "</font>"; |
265 | } | 294 | } |
266 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 295 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
267 | if (event->cancelled ()) { | 296 | if (event->cancelled ()) { |
268 | mText +="<font color=\"#B00000\">"; | 297 | mText +="<font color=\"#B00000\">"; |
269 | addTag("i",i18n("This event has been cancelled!")); | 298 | addTag("i",i18n("This event has been cancelled!")); |
270 | mText.append("<br>"); | 299 | mText.append("<br>"); |
271 | mText += "</font>"; | 300 | mText += "</font>"; |
272 | mMailSubject += i18n("(cancelled)"); | 301 | mMailSubject += i18n("(cancelled)"); |
273 | } | 302 | } |
274 | if (!event->location().isEmpty()) { | 303 | if (!event->location().isEmpty()) { |
275 | addTag("b",i18n("Location: ")); | 304 | addTag("b",i18n("Location: ")); |
276 | mText.append(deTag(event->location())+"<br>"); | 305 | mText.append(deTag(event->location())+"<br>"); |
277 | mMailSubject += i18n(" at ") + event->location(); | 306 | mMailSubject += i18n(" at ") + event->location(); |
278 | } | 307 | } |
279 | if (event->doesFloat()) { | 308 | if (event->doesFloat()) { |
280 | if (event->isMultiDay()) { | 309 | if (event->isMultiDay()) { |
281 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 310 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
282 | .arg(event->dtStartDateStr(shortDate)) | 311 | .arg(event->dtStartDateStr(shortDate)) |
283 | .arg(event->dtEndDateStr(shortDate))); | 312 | .arg(event->dtEndDateStr(shortDate))); |
284 | } else { | 313 | } else { |
285 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 314 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
286 | } | 315 | } |
287 | } else { | 316 | } else { |
288 | if (event->isMultiDay()) { | 317 | if (event->isMultiDay()) { |
289 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 318 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
290 | .arg(event->dtStartStr( shortDate))); | 319 | .arg(event->dtStartStr( shortDate))); |
291 | mText.append(i18n("<p><b>To:</b> %1</p>") | 320 | mText.append(i18n("<p><b>To:</b> %1</p>") |
292 | .arg(event->dtEndStr(shortDate))); | 321 | .arg(event->dtEndStr(shortDate))); |
293 | } else { | 322 | } else { |
294 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 323 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
295 | .arg(event->dtStartDateStr( shortDate ))); | 324 | .arg(event->dtStartDateStr( shortDate ))); |
296 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 325 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
297 | .arg(event->dtStartTimeStr()) | 326 | .arg(event->dtStartTimeStr()) |
298 | .arg(event->dtEndTimeStr())); | 327 | .arg(event->dtEndTimeStr())); |
299 | } | 328 | } |
300 | } | 329 | } |
301 | 330 | ||
302 | if (event->recurrence()->doesRecur()) { | 331 | if (event->recurrence()->doesRecur()) { |
303 | 332 | ||
304 | QString recurText = event->recurrence()->recurrenceText(); | 333 | QString recurText = event->recurrence()->recurrenceText(); |
305 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 334 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
306 | bool ok; | 335 | bool ok; |
307 | QDate start = QDate::currentDate(); | 336 | QDate start = QDate::currentDate(); |
308 | QDateTime next; | 337 | QDateTime next; |
309 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 338 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
310 | if ( ok ) { | 339 | if ( ok ) { |
311 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 340 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
312 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 341 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
313 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); | 342 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); |
314 | 343 | ||
315 | } else { | 344 | } else { |
316 | bool last; | 345 | bool last; |
317 | QDate nextd; | 346 | QDate nextd; |
318 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 347 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
319 | if ( last ) { | 348 | if ( last ) { |
320 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 349 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
321 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 350 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
322 | } | 351 | } |
323 | } | 352 | } |
324 | } else { | 353 | } else { |
325 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 354 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
326 | 355 | ||
327 | } | 356 | } |
328 | 357 | ||
329 | 358 | ||
330 | if (event->isAlarmEnabled()) { | 359 | if (event->isAlarmEnabled()) { |
331 | Alarm *alarm =event->alarms().first() ; | 360 | Alarm *alarm =event->alarms().first() ; |
332 | QDateTime t = alarm->time(); | 361 | QDateTime t = alarm->time(); |
333 | int min = t.secsTo( event->dtStart() )/60; | 362 | int min = t.secsTo( event->dtStart() )/60; |
334 | QString s =i18n("( %1 min before )").arg( min ); | 363 | QString s =i18n("( %1 min before )").arg( min ); |
335 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 364 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
336 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 365 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
337 | //addTag("p",s); | 366 | //addTag("p",s); |
338 | } | 367 | } |
339 | 368 | ||
340 | addTag("b",i18n("Access: ")); | 369 | addTag("b",i18n("Access: ")); |
341 | mText.append(event->secrecyStr()+"<br>"); | 370 | mText.append(event->secrecyStr()+"<br>"); |
342 | 371 | ||
343 | 372 | ||
344 | if ( KOPrefs::instance()->mEVshowDetails ) { | 373 | if ( KOPrefs::instance()->mEVshowDetails ) { |
345 | if (!event->description().isEmpty()) { | 374 | if (!event->description().isEmpty()) { |
346 | addTag("p",i18n("<b>Details: </b>")); | 375 | addTag("p",i18n("<b>Details: </b>")); |
347 | addTag("p",deTag(event->description())); | 376 | addTag("p",deTag(event->description())); |
348 | } | 377 | } |
349 | } | 378 | } |
350 | formatCategories(event); | 379 | formatCategories(event); |
351 | 380 | ||
352 | formatReadOnly(event); | 381 | formatReadOnly(event); |
353 | formatAttendees(event); | 382 | formatAttendees(event); |
354 | 383 | ||
355 | if ( KOPrefs::instance()->mEVshowCreated ) { | 384 | if ( KOPrefs::instance()->mEVshowCreated ) { |
356 | addTag("p",i18n("<b>Created: ") +" </b>"); | 385 | addTag("p",i18n("<b>Created: ") +" </b>"); |
357 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 386 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
358 | 387 | ||
359 | } | 388 | } |
360 | if ( KOPrefs::instance()->mEVshowChanged ) { | 389 | if ( KOPrefs::instance()->mEVshowChanged ) { |
361 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 390 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
362 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 391 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
363 | 392 | ||
364 | } | 393 | } |
365 | setText(mText); | 394 | setText(mText); |
366 | //QWhatsThis::add(this,mText); | 395 | //QWhatsThis::add(this,mText); |
367 | 396 | ||
368 | } | 397 | } |
369 | 398 | ||
370 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 399 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
371 | { | 400 | { |
372 | mMailSubject = ""; | 401 | mMailSubject = ""; |
373 | mCurrentIncidence = event; | 402 | mCurrentIncidence = event; |
374 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 403 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
375 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 404 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
376 | if (mode == 0 ) | 405 | if (mode == 0 ) |
377 | addTag("h2",deTag(event->summary())); | 406 | addTag("h2",deTag(event->summary())); |
378 | else { | 407 | else { |
379 | if ( mColorMode == 1 ) { | 408 | if ( mColorMode == 1 ) { |
380 | mText +="<font color=\"#00A000\">"; | 409 | mText +="<font color=\"#00A000\">"; |
381 | } | 410 | } |
382 | if ( mColorMode == 2 ) { | 411 | if ( mColorMode == 2 ) { |
383 | mText +="<font color=\"#B00000\">"; | 412 | mText +="<font color=\"#B00000\">"; |
384 | } | 413 | } |
385 | if ( mode == 1 ) { | 414 | if ( mode == 1 ) { |
386 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 415 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
387 | } else { | 416 | } else { |
388 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 417 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
389 | } | 418 | } |
390 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 419 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
391 | if ( mColorMode ) | 420 | if ( mColorMode ) |
392 | mText += "</font>"; | 421 | mText += "</font>"; |
393 | } | 422 | } |
394 | mMailSubject += i18n( "Todo " )+ event->summary(); | 423 | mMailSubject += i18n( "Todo " )+ event->summary(); |
395 | 424 | ||
396 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 425 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
397 | mText +="<font color=\"#B00000\">"; | 426 | mText +="<font color=\"#B00000\">"; |
398 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); | 427 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); |
399 | mText += "</font>"; | 428 | mText += "</font>"; |
400 | } else { | 429 | } else { |
401 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 430 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
402 | .arg(event->percentComplete())); | 431 | .arg(event->percentComplete())); |
403 | } | 432 | } |
404 | 433 | ||
405 | if (event->cancelled ()) { | 434 | if (event->cancelled ()) { |
406 | mText +="<font color=\"#B00000\">"; | 435 | mText +="<font color=\"#B00000\">"; |
407 | addTag("i",i18n("This todo has been cancelled!")); | 436 | addTag("i",i18n("This todo has been cancelled!")); |
408 | mText.append("<br>"); | 437 | mText.append("<br>"); |
409 | mText += "</font>"; | 438 | mText += "</font>"; |
410 | mMailSubject += i18n("(cancelled)"); | 439 | mMailSubject += i18n("(cancelled)"); |
411 | } | 440 | } |
412 | 441 | ||
413 | if (!event->location().isEmpty()) { | 442 | if (!event->location().isEmpty()) { |
414 | addTag("b",i18n("Location: ")); | 443 | addTag("b",i18n("Location: ")); |
415 | mText.append(deTag(event->location())+"<br>"); | 444 | mText.append(deTag(event->location())+"<br>"); |
416 | mMailSubject += i18n(" at ") + event->location(); | 445 | mMailSubject += i18n(" at ") + event->location(); |
417 | } | 446 | } |
418 | 447 | ||
419 | if (event->recurrence()->doesRecur()) { | 448 | if (event->recurrence()->doesRecur()) { |
420 | 449 | ||
421 | QString recurText = event->recurrence()->recurrenceText(); | 450 | QString recurText = event->recurrence()->recurrenceText(); |
422 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 451 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
423 | 452 | ||
424 | } | 453 | } |
425 | if (event->hasStartDate()) { | 454 | if (event->hasStartDate()) { |
426 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 455 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
427 | } | 456 | } |
428 | if (event->hasDueDate()) { | 457 | if (event->hasDueDate()) { |
429 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 458 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
430 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 459 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
431 | } | 460 | } |
432 | addTag("b",i18n("Access: ")); | 461 | addTag("b",i18n("Access: ")); |
433 | mText.append(event->secrecyStr()+"<br>"); | 462 | mText.append(event->secrecyStr()+"<br>"); |
434 | if ( KOPrefs::instance()->mEVshowDetails ) { | 463 | if ( KOPrefs::instance()->mEVshowDetails ) { |
435 | if (!event->description().isEmpty()) { | 464 | if (!event->description().isEmpty()) { |
436 | addTag("p",i18n("<b>Details: </b>")); | 465 | addTag("p",i18n("<b>Details: </b>")); |
437 | addTag("p",deTag(event->description())); | 466 | addTag("p",deTag(event->description())); |
438 | } | 467 | } |
439 | } | 468 | } |
440 | 469 | ||
441 | formatCategories(event); | 470 | formatCategories(event); |
442 | 471 | ||
443 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 472 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
444 | .arg(QString::number(event->priority()))); | 473 | .arg(QString::number(event->priority()))); |
445 | 474 | ||
446 | formatReadOnly(event); | 475 | formatReadOnly(event); |
447 | formatAttendees(event); | 476 | formatAttendees(event); |
448 | if ( event->relatedTo() ) { | 477 | if ( event->relatedTo() ) { |
449 | addTag("b",i18n("Parent todo:<br>")); | 478 | addTag("b",i18n("Parent todo:<br>")); |
450 | mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 479 | mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); |
451 | } | 480 | } |
452 | QPtrList<Incidence> Relations = event->relations(); | 481 | QPtrList<Incidence> Relations = event->relations(); |
453 | Incidence *to; | 482 | Incidence *to; |
454 | if ( Relations.first() ) | 483 | if ( Relations.first() ) |
455 | addTag("b",i18n("Sub todos:<br>")); | 484 | addTag("b",i18n("Sub todos:<br>")); |
456 | for (to=Relations.first();to;to=Relations.next()) { | 485 | for (to=Relations.first();to;to=Relations.next()) { |
457 | mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 486 | mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); |
458 | 487 | ||
459 | } | 488 | } |
460 | if ( KOPrefs::instance()->mEVshowCreated ) { | 489 | if ( KOPrefs::instance()->mEVshowCreated ) { |
461 | addTag("p",i18n("<b>Created: ") +" </b>"); | 490 | addTag("p",i18n("<b>Created: ") +" </b>"); |
462 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 491 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
463 | 492 | ||
464 | } | 493 | } |
465 | if ( KOPrefs::instance()->mEVshowChanged ) { | 494 | if ( KOPrefs::instance()->mEVshowChanged ) { |
466 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 495 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
467 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 496 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
468 | 497 | ||
469 | } | 498 | } |
470 | setText(mText); | 499 | setText(mText); |
471 | } | 500 | } |
472 | 501 | ||
473 | void KOEventViewer::formatCategories(Incidence *event) | 502 | void KOEventViewer::formatCategories(Incidence *event) |
474 | { | 503 | { |
475 | if (!event->categoriesStr().isEmpty()) { | 504 | if (!event->categoriesStr().isEmpty()) { |
476 | if (event->categories().count() == 1) { | 505 | if (event->categories().count() == 1) { |
477 | addTag("h3",i18n("Category")); | 506 | addTag("h3",i18n("Category")); |
478 | } else { | 507 | } else { |
479 | addTag("h3",i18n("Categories")); | 508 | addTag("h3",i18n("Categories")); |
480 | } | 509 | } |
481 | addTag("p",event->categoriesStr()); | 510 | addTag("p",event->categoriesStr()); |
482 | } | 511 | } |
483 | } | 512 | } |
484 | void KOEventViewer::formatAttendees(Incidence *event) | 513 | void KOEventViewer::formatAttendees(Incidence *event) |
485 | { | 514 | { |
486 | QPtrList<Attendee> attendees = event->attendees(); | 515 | QPtrList<Attendee> attendees = event->attendees(); |
487 | if (attendees.count()) { | 516 | if (attendees.count()) { |
488 | 517 | ||
489 | 518 | ||
490 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 519 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
491 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 520 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
492 | addTag("h3",i18n("Organizer")); | 521 | addTag("h3",i18n("Organizer")); |
493 | mText.append("<ul><li>"); | 522 | mText.append("<ul><li>"); |
494 | #ifndef KORG_NOKABC | 523 | #ifndef KORG_NOKABC |
495 | 524 | ||
496 | #ifdef DESKTOP_VERSION | 525 | #ifdef DESKTOP_VERSION |
497 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 526 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
498 | KABC::Addressee::List addressList; | 527 | KABC::Addressee::List addressList; |
499 | addressList = add_book->findByEmail(event->organizer()); | 528 | addressList = add_book->findByEmail(event->organizer()); |
500 | KABC::Addressee o = addressList.first(); | 529 | KABC::Addressee o = addressList.first(); |
501 | if (!o.isEmpty() && addressList.size()<2) { | 530 | if (!o.isEmpty() && addressList.size()<2) { |
502 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 531 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
503 | mText += o.formattedName(); | 532 | mText += o.formattedName(); |
504 | mText += "</a>\n"; | 533 | mText += "</a>\n"; |
505 | } else { | 534 | } else { |
506 | mText.append(event->organizer()); | 535 | mText.append(event->organizer()); |
507 | } | 536 | } |
508 | #else //DESKTOP_VERSION | 537 | #else //DESKTOP_VERSION |
509 | mText += "<a href=\"uid:organizer\">"; | 538 | mText += "<a href=\"uid:organizer\">"; |
510 | mText += event->organizer(); | 539 | mText += event->organizer(); |
511 | mText += "</a>\n"; | 540 | mText += "</a>\n"; |
512 | #endif //DESKTOP_VERSION | 541 | #endif //DESKTOP_VERSION |
513 | 542 | ||
514 | 543 | ||
515 | #else | 544 | #else |
516 | mText.append(event->organizer()); | 545 | mText.append(event->organizer()); |
517 | #endif | 546 | #endif |
518 | 547 | ||
519 | if (iconPath) { | 548 | if (iconPath) { |
520 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 549 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
521 | mText += "<IMG src=\"" + iconPath + "\">"; | 550 | mText += "<IMG src=\"" + iconPath + "\">"; |
522 | mText += "</a>\n"; | 551 | mText += "</a>\n"; |
523 | } | 552 | } |
524 | mText.append("</li></ul>"); | 553 | mText.append("</li></ul>"); |
525 | 554 | ||
526 | addTag("h3",i18n("Attendees")); | 555 | addTag("h3",i18n("Attendees")); |
527 | Attendee *a; | 556 | Attendee *a; |
528 | mText.append("<ul>"); | 557 | mText.append("<ul>"); |
529 | int a_count = 0; | 558 | int a_count = 0; |
530 | int a_count_nr = 0; | 559 | int a_count_nr = 0; |
531 | 560 | ||
532 | for(a=attendees.first();a;a=attendees.next()) { | 561 | for(a=attendees.first();a;a=attendees.next()) { |
533 | #ifndef KORG_NOKABC | 562 | #ifndef KORG_NOKABC |
534 | #ifdef DESKTOP_VERSION | 563 | #ifdef DESKTOP_VERSION |
535 | if (a->name().isEmpty()) { | 564 | if (a->name().isEmpty()) { |
536 | addressList = add_book->findByEmail(a->email()); | 565 | addressList = add_book->findByEmail(a->email()); |
537 | KABC::Addressee o = addressList.first(); | 566 | KABC::Addressee o = addressList.first(); |
538 | if (!o.isEmpty() && addressList.size()<2) { | 567 | if (!o.isEmpty() && addressList.size()<2) { |
539 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 568 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
540 | mText += o.formattedName(); | 569 | mText += o.formattedName(); |
541 | mText += "</a>\n"; | 570 | mText += "</a>\n"; |
542 | } else { | 571 | } else { |
543 | mText += "<li>"; | 572 | mText += "<li>"; |
544 | mText.append(a->email()); | 573 | mText.append(a->email()); |
545 | mText += "\n"; | 574 | mText += "\n"; |
546 | } | 575 | } |
547 | } else { | 576 | } else { |
548 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 577 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
549 | if (!a->name().isEmpty()) mText += a->name(); | 578 | if (!a->name().isEmpty()) mText += a->name(); |
550 | else mText += a->email(); | 579 | else mText += a->email(); |
551 | mText += "</a>\n"; | 580 | mText += "</a>\n"; |
552 | } | 581 | } |
553 | #else //DESKTOP_VERSION | 582 | #else //DESKTOP_VERSION |
554 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 583 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
555 | if (!a->name().isEmpty()) mText += a->name(); | 584 | if (!a->name().isEmpty()) mText += a->name(); |
556 | else mText += a->email(); | 585 | else mText += a->email(); |
557 | mText += "</a>\n"; | 586 | mText += "</a>\n"; |
558 | #endif //DESKTOP_VERSION | 587 | #endif //DESKTOP_VERSION |
559 | #else | 588 | #else |
560 | //qDebug("nokabc "); | 589 | //qDebug("nokabc "); |
561 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 590 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
562 | if (!a->name().isEmpty()) mText += a->name(); | 591 | if (!a->name().isEmpty()) mText += a->name(); |
563 | else mText += a->email(); | 592 | else mText += a->email(); |
564 | mText += "</a>\n"; | 593 | mText += "</a>\n"; |
565 | #endif | 594 | #endif |
566 | 595 | ||
567 | 596 | ||
568 | if (!a->email().isEmpty()) { | 597 | if (!a->email().isEmpty()) { |
569 | if (iconPath) { | 598 | if (iconPath) { |
570 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 599 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
571 | if ( a->RSVP() ) { | 600 | if ( a->RSVP() ) { |
572 | ++a_count_nr; | 601 | ++a_count_nr; |
573 | mText += "<IMG src=\"" + iconPath + "\">"; | 602 | mText += "<IMG src=\"" + iconPath + "\">"; |
574 | } | 603 | } |
575 | else { | 604 | else { |
576 | ++a_count; | 605 | ++a_count; |
577 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 606 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
578 | } | 607 | } |
579 | mText += "</a>\n"; | 608 | mText += "</a>\n"; |
580 | } | 609 | } |
581 | } | 610 | } |
582 | if (a->status() != Attendee::NeedsAction ) | 611 | if (a->status() != Attendee::NeedsAction ) |
583 | mText +="[" + a->statusStr() + "] "; | 612 | mText +="[" + a->statusStr() + "] "; |
584 | if (a->role() == Attendee::Chair ) | 613 | if (a->role() == Attendee::Chair ) |
585 | mText +="(" + a->roleStr().left(1) + ".)"; | 614 | mText +="(" + a->roleStr().left(1) + ".)"; |
586 | } | 615 | } |
587 | mText.append("</li></ul>"); | 616 | mText.append("</li></ul>"); |
588 | if ( (a_count+a_count_nr) > 1 ) { | 617 | if ( (a_count+a_count_nr) > 1 ) { |
589 | mText += "<a href=\"mailto:ALL\">"; | 618 | mText += "<a href=\"mailto:ALL\">"; |
590 | mText += i18n( "Mail to all" ); | 619 | mText += i18n( "Mail to all" ); |
591 | mText += "</a> ( "; | 620 | mText += "</a> ( "; |
592 | mText += "<IMG src=\"" + iconPath + "\">"; | 621 | mText += "<IMG src=\"" + iconPath + "\">"; |
593 | mText += i18n( " and " ); | 622 | mText += i18n( " and " ); |
594 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; | 623 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; |
595 | mText += "<br>\n"; | 624 | mText += "<br>\n"; |
596 | 625 | ||
597 | 626 | ||
598 | } | 627 | } |
599 | if ( a_count_nr > 1 ) { | 628 | if ( a_count_nr > 1 ) { |
600 | mText += "<a href=\"mailto:RSVP\">"; | 629 | mText += "<a href=\"mailto:RSVP\">"; |
601 | mText += i18n( "Mail to selected" ); | 630 | mText += i18n( "Mail to selected" ); |
602 | mText += "</a> ( "; | 631 | mText += "</a> ( "; |
603 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); | 632 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); |
604 | mText += "<br>\n"; | 633 | mText += "<br>\n"; |
605 | } | 634 | } |
606 | } | 635 | } |
607 | 636 | ||
608 | } | 637 | } |
609 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 638 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
610 | { | 639 | { |
611 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 640 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
612 | if (mode == 0 ) { | 641 | if (mode == 0 ) { |
613 | addTag("h2",i18n("Journal from: ")); | 642 | addTag("h2",i18n("Journal from: ")); |
614 | } | 643 | } |
615 | else { | 644 | else { |
616 | if ( mode == 1 ) { | 645 | if ( mode == 1 ) { |
617 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); | 646 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); |
618 | } else { | 647 | } else { |
619 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); | 648 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); |
620 | } | 649 | } |
621 | } | 650 | } |
622 | topLevelWidget()->setCaption("Journal Viewer"); | 651 | topLevelWidget()->setCaption("Journal Viewer"); |
623 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 652 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
624 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 653 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
625 | if (!jour->description().isEmpty()) { | 654 | if (!jour->description().isEmpty()) { |
626 | addTag("p",deTag(jour->description())); | 655 | addTag("p",deTag(jour->description())); |
627 | } | 656 | } |
628 | setText(mText); | 657 | setText(mText); |
629 | } | 658 | } |
630 | 659 | ||
631 | void KOEventViewer::formatReadOnly(Incidence *event) | 660 | void KOEventViewer::formatReadOnly(Incidence *event) |
632 | { | 661 | { |
633 | if (event->isReadOnly()) { | 662 | if (event->isReadOnly()) { |
634 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 663 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
635 | } | 664 | } |
636 | } | 665 | } |
637 | void KOEventViewer::setSyncMode( bool b ) | 666 | void KOEventViewer::setSyncMode( bool b ) |
638 | { | 667 | { |
639 | mSyncMode = b; | 668 | mSyncMode = b; |
640 | } | 669 | } |
641 | 670 | ||
642 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 671 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
643 | { | 672 | { |
644 | if ( clearV ) | 673 | if ( clearV ) |
645 | clearEvents(); | 674 | clearEvents(); |
646 | if ( mSyncMode ) { | 675 | if ( mSyncMode ) { |
647 | if ( clearV ) | 676 | if ( clearV ) |
648 | appendTodo(event,1 ); | 677 | appendTodo(event,1 ); |
649 | else | 678 | else |
650 | appendTodo(event,2); | 679 | appendTodo(event,2); |
651 | } else | 680 | } else |
652 | appendTodo(event); | 681 | appendTodo(event); |
653 | } | 682 | } |
654 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 683 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
655 | { | 684 | { |
656 | if ( clearV ) | 685 | if ( clearV ) |
657 | clearEvents(); | 686 | clearEvents(); |
658 | if ( mSyncMode ) { | 687 | if ( mSyncMode ) { |
659 | if ( clearV ) | 688 | if ( clearV ) |
660 | appendJournal(event, 1); | 689 | appendJournal(event, 1); |
661 | else | 690 | else |
662 | appendJournal(event, 2); | 691 | appendJournal(event, 2); |
663 | } else | 692 | } else |
664 | appendJournal(event); | 693 | appendJournal(event); |
665 | } | 694 | } |
666 | 695 | ||
667 | void KOEventViewer::setEvent(Event *event) | 696 | void KOEventViewer::setEvent(Event *event) |
668 | { | 697 | { |
669 | clearEvents(); | 698 | clearEvents(); |
670 | if ( mSyncMode ) | 699 | if ( mSyncMode ) |
671 | appendEvent(event, 1); | 700 | appendEvent(event, 1); |
672 | else | 701 | else |
673 | appendEvent(event); | 702 | appendEvent(event); |
674 | } | 703 | } |
675 | 704 | ||
676 | void KOEventViewer::addEvent(Event *event) | 705 | void KOEventViewer::addEvent(Event *event) |
677 | { | 706 | { |
678 | if ( mSyncMode ) | 707 | if ( mSyncMode ) |
679 | appendEvent(event, 2); | 708 | appendEvent(event, 2); |
680 | else | 709 | else |
681 | appendEvent(event); | 710 | appendEvent(event); |
682 | } | 711 | } |
683 | 712 | ||
684 | void KOEventViewer::clearEvents(bool now) | 713 | void KOEventViewer::clearEvents(bool now) |
685 | { | 714 | { |
686 | mText = ""; | 715 | mText = ""; |
687 | if (now) setText(mText); | 716 | if (now) setText(mText); |
688 | } | 717 | } |
689 | 718 | ||
690 | void KOEventViewer::addText(QString text) | 719 | void KOEventViewer::addText(QString text) |
691 | { | 720 | { |
692 | mText.append(text); | 721 | mText.append(text); |
693 | setText(mText); | 722 | setText(mText); |
694 | } | 723 | } |
695 | QString KOEventViewer::deTag(QString text) | 724 | QString KOEventViewer::deTag(QString text) |
696 | { | 725 | { |
697 | #if QT_VERSION >= 0x030000 | 726 | #if QT_VERSION >= 0x030000 |
698 | text.replace( '<' , "<" ); | 727 | text.replace( '<' , "<" ); |
699 | text.replace( '>' , ">" ); | 728 | text.replace( '>' , ">" ); |
700 | #else | 729 | #else |
701 | if ( text.find ('<') >= 0 ) { | 730 | if ( text.find ('<') >= 0 ) { |
702 | text.replace( QRegExp("<") , "<" ); | 731 | text.replace( QRegExp("<") , "<" ); |
703 | } | 732 | } |
704 | if ( text.find ('>') >= 0 ) { | 733 | if ( text.find ('>') >= 0 ) { |
705 | text.replace( QRegExp(">") , ">" ); | 734 | text.replace( QRegExp(">") , ">" ); |
706 | } | 735 | } |
707 | #endif | 736 | #endif |
708 | return text; | 737 | return text; |
709 | } | 738 | } |
710 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) | 739 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) |
711 | { | 740 | { |
712 | switch ( e->key() ) { | 741 | switch ( e->key() ) { |
713 | case Qt::Key_Return: | 742 | case Qt::Key_Return: |
714 | case Qt::Key_Enter : | 743 | case Qt::Key_Enter : |
715 | e->ignore(); | 744 | e->ignore(); |
716 | break; | 745 | break; |
717 | default: | 746 | default: |
718 | QTextBrowser::keyPressEvent ( e ); | 747 | QTextBrowser::keyPressEvent ( e ); |
719 | break; | 748 | break; |
720 | } | 749 | } |
721 | } | 750 | } |
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h index 47cc5e9..ca5bc15 100644 --- a/korganizer/koeventviewer.h +++ b/korganizer/koeventviewer.h | |||
@@ -1,77 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOEVENTVIEWER_H | 19 | #ifndef KOEVENTVIEWER_H |
20 | #define KOEVENTVIEWER_H | 20 | #define KOEVENTVIEWER_H |
21 | // | 21 | // |
22 | // Viewer widget for events. | 22 | // Viewer widget for events. |
23 | // | 23 | // |
24 | 24 | ||
25 | #include <qtextbrowser.h> | 25 | #include <qtextbrowser.h> |
26 | 26 | ||
27 | #include <libkcal/event.h> | 27 | #include <libkcal/event.h> |
28 | #include <libkcal/journal.h> | 28 | #include <libkcal/journal.h> |
29 | 29 | ||
30 | 30 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | class KOEventViewer : public QTextBrowser { | 33 | class KOEventViewer : public QTextBrowser { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | KOEventViewer(QWidget *parent=0,const char *name=0); | 36 | KOEventViewer(QWidget *parent=0,const char *name=0); |
37 | virtual ~KOEventViewer(); | 37 | virtual ~KOEventViewer(); |
38 | 38 | ||
39 | void setSource(const QString &); | 39 | void setSource(const QString &); |
40 | void setEvent(Event *event); | 40 | void setEvent(Event *event); |
41 | void addEvent(Event *event); | 41 | void addEvent(Event *event); |
42 | void setTodo(Todo *event, bool clearV = true ); | 42 | void setTodo(Todo *event, bool clearV = true ); |
43 | void setJournal(Journal *jour, bool clearV = true ); | 43 | void setJournal(Journal *jour, bool clearV = true ); |
44 | 44 | ||
45 | void appendEvent(Event *event, int mode = 0 ); | 45 | void appendEvent(Event *event, int mode = 0 ); |
46 | void appendTodo(Todo *event, int mode = 0 ); | 46 | void appendTodo(Todo *event, int mode = 0 ); |
47 | void appendJournal(Journal *jour, int mode = 0 ); | 47 | void appendJournal(Journal *jour, int mode = 0 ); |
48 | 48 | ||
49 | void clearEvents(bool now=false); | 49 | void clearEvents(bool now=false); |
50 | 50 | ||
51 | void addText(QString text); | 51 | void addText(QString text); |
52 | void setSyncMode( bool ); | 52 | void setSyncMode( bool ); |
53 | void setColorMode( int ); | 53 | void setColorMode( int ); |
54 | void mailToAttendees( bool all ); | 54 | void mailToAttendees( bool all ); |
55 | void printMe(); | ||
55 | 56 | ||
56 | protected: | 57 | protected: |
57 | int mColorMode; | 58 | int mColorMode; |
58 | void addTag(const QString & tag,const QString & text); | 59 | void addTag(const QString & tag,const QString & text); |
59 | 60 | ||
60 | void formatCategories(Incidence *event); | 61 | void formatCategories(Incidence *event); |
61 | void formatAttendees(Incidence *event); | 62 | void formatAttendees(Incidence *event); |
62 | void formatReadOnly(Incidence *event); | 63 | void formatReadOnly(Incidence *event); |
63 | void keyPressEvent ( QKeyEvent * e ); | 64 | void keyPressEvent ( QKeyEvent * e ); |
64 | 65 | ||
65 | private: | 66 | private: |
66 | QTextBrowser *mEventTextView; | 67 | QTextBrowser *mEventTextView; |
67 | bool mSyncMode; | 68 | bool mSyncMode; |
68 | QString deTag(QString text); | 69 | QString deTag(QString text); |
69 | 70 | ||
70 | QString mText; | 71 | QString mText; |
71 | QString mMailSubject; | 72 | QString mMailSubject; |
72 | Incidence* mCurrentIncidence; | 73 | Incidence* mCurrentIncidence; |
73 | signals: | 74 | signals: |
74 | void launchaddressbook(QString uid); | 75 | void launchaddressbook(QString uid); |
75 | }; | 76 | }; |
76 | 77 | ||
77 | #endif | 78 | #endif |
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index f734696..ec55cca 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,302 +1,316 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | 21 | ||
22 | #include <libkcal/event.h> | 22 | #include <libkcal/event.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | 25 | ||
26 | #include "koeventviewer.h" | 26 | #include "koeventviewer.h" |
27 | #include <kmessagebox.h> | ||
27 | #include "koprefs.h" | 28 | #include "koprefs.h" |
28 | #include <libkcal/todo.h> | 29 | #include <libkcal/todo.h> |
29 | #include "qapp.h" | 30 | #include "qapp.h" |
30 | 31 | ||
31 | #include "koeventviewerdialog.h" | 32 | #include "koeventviewerdialog.h" |
32 | extern int globalFlagBlockAgenda; | 33 | extern int globalFlagBlockAgenda; |
33 | 34 | ||
34 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 35 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
35 | : KDialogBase(parent,name, | 36 | : KDialogBase(parent,name, |
36 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
37 | true , | 38 | true , |
38 | #else | 39 | #else |
39 | false, | 40 | false, |
40 | #endif | 41 | #endif |
41 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 42 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
42 | { | 43 | { |
43 | sendSignalViewerClosed = true; | 44 | sendSignalViewerClosed = true; |
44 | mEventViewer = new KOEventViewer(this); | 45 | mEventViewer = new KOEventViewer(this); |
45 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 46 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
46 | setMainWidget(mEventViewer); | 47 | setMainWidget(mEventViewer); |
47 | setButtonText(Ok, i18n("Edit") ); | 48 | setButtonText(Ok, i18n("Edit") ); |
48 | 49 | ||
49 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 50 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
50 | SLOT(editIncidence())); | 51 | SLOT(editIncidence())); |
51 | QObject::connect(this,SIGNAL(user1Clicked()), | 52 | QObject::connect(this,SIGNAL(user1Clicked()), |
52 | SLOT(showIncidence())); | 53 | SLOT(showIncidence())); |
53 | mIncidence = 0; | 54 | mIncidence = 0; |
54 | // TODO: Set a sensible size (based on the content?). | 55 | // TODO: Set a sensible size (based on the content?). |
55 | //showMaximized(); | 56 | //showMaximized(); |
56 | //qDebug("++++++++++++KOEventViewerDialog() "); | 57 | //qDebug("++++++++++++KOEventViewerDialog() "); |
57 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 58 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
58 | // setFixedSize( 240,284 ); | 59 | // setFixedSize( 240,284 ); |
59 | // move( 0, 15 ); | 60 | // move( 0, 15 ); |
60 | // } else { | 61 | // } else { |
61 | // setMinimumSize(300,200); | 62 | // setMinimumSize(300,200); |
62 | // resize(320,300); | 63 | // resize(320,300); |
63 | // } | 64 | // } |
64 | mSyncMode = false; | 65 | mSyncMode = false; |
65 | mSyncResult = 0; | 66 | mSyncResult = 0; |
66 | 67 | ||
67 | } | 68 | } |
68 | 69 | ||
69 | KOEventViewerDialog::~KOEventViewerDialog() | 70 | KOEventViewerDialog::~KOEventViewerDialog() |
70 | { | 71 | { |
71 | //qDebug("-------~KOEventViewerDialog() "); | 72 | //qDebug("-------~KOEventViewerDialog() "); |
72 | } | 73 | } |
73 | void KOEventViewerDialog::showMe() | 74 | void KOEventViewerDialog::showMe() |
74 | { | 75 | { |
75 | 76 | ||
76 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
77 | int x,y,w,h; | 78 | int x,y,w,h; |
78 | x = geometry().x(); | 79 | x = geometry().x(); |
79 | y = geometry().y(); | 80 | y = geometry().y(); |
80 | w = width(); | 81 | w = width(); |
81 | h = height(); | 82 | h = height(); |
82 | show(); | 83 | show(); |
83 | setGeometry(x,y,w,h); | 84 | setGeometry(x,y,w,h); |
84 | #else | 85 | #else |
85 | showMaximized(); | 86 | showMaximized(); |
86 | #endif | 87 | #endif |
87 | raise(); | 88 | raise(); |
88 | setActiveWindow(); | 89 | setActiveWindow(); |
89 | mEventViewer->setFocus(); | 90 | mEventViewer->setFocus(); |
90 | //raise(); | 91 | //raise(); |
91 | 92 | ||
92 | } | 93 | } |
94 | void KOEventViewerDialog::print() | ||
95 | { | ||
96 | qDebug("PRINT "); | ||
97 | int km = KMessageBox::warningContinueCancel(this,mIncidence->summary().left(35) + | ||
98 | i18n("\n\nDo you really want to print this item?"), | ||
99 | i18n("KO/Pi Print Confirmation"),i18n("Print")); | ||
100 | if ( km != KMessageBox::Continue ) { | ||
101 | qDebug("cancel "); | ||
102 | return; | ||
103 | } | ||
104 | mEventViewer->printMe(); | ||
105 | |||
106 | } | ||
93 | void KOEventViewerDialog::setSyncMode( bool b ) | 107 | void KOEventViewerDialog::setSyncMode( bool b ) |
94 | { | 108 | { |
95 | mSyncMode = b; | 109 | mSyncMode = b; |
96 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 110 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
97 | if ( mSyncMode ) { | 111 | if ( mSyncMode ) { |
98 | findButton( Close )->setText( i18n("Cancel Sync")); | 112 | findButton( Close )->setText( i18n("Cancel Sync")); |
99 | findButton( Ok )->setText( i18n("Remote")); | 113 | findButton( Ok )->setText( i18n("Remote")); |
100 | findButton( User1 )->setText( i18n("Local")); | 114 | findButton( User1 )->setText( i18n("Local")); |
101 | } else { | 115 | } else { |
102 | findButton( Close )->setText( i18n("Close")); | 116 | findButton( Close )->setText( i18n("Close")); |
103 | findButton( Ok )->setText( i18n("Edit")); | 117 | findButton( Ok )->setText( i18n("Edit")); |
104 | findButton( User1 )->setText( i18n("Agenda")); | 118 | findButton( User1 )->setText( i18n("Agenda")); |
105 | } | 119 | } |
106 | mEventViewer->setSyncMode( b ); | 120 | mEventViewer->setSyncMode( b ); |
107 | } | 121 | } |
108 | void KOEventViewerDialog::setColorMode( int m ) | 122 | void KOEventViewerDialog::setColorMode( int m ) |
109 | { | 123 | { |
110 | mEventViewer->setColorMode( m ); | 124 | mEventViewer->setColorMode( m ); |
111 | } | 125 | } |
112 | int KOEventViewerDialog::executeS( bool local ) | 126 | int KOEventViewerDialog::executeS( bool local ) |
113 | { | 127 | { |
114 | mSyncResult = 3; | 128 | mSyncResult = 3; |
115 | if ( local ) | 129 | if ( local ) |
116 | findButton( User1 )->setFocus(); | 130 | findButton( User1 )->setFocus(); |
117 | else | 131 | else |
118 | findButton( Ok )->setFocus(); | 132 | findButton( Ok )->setFocus(); |
119 | exec(); | 133 | exec(); |
120 | return mSyncResult; | 134 | return mSyncResult; |
121 | } | 135 | } |
122 | 136 | ||
123 | void KOEventViewerDialog::updateConfig() | 137 | void KOEventViewerDialog::updateConfig() |
124 | { | 138 | { |
125 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 139 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
126 | 140 | ||
127 | } | 141 | } |
128 | void KOEventViewerDialog::setEvent(Event *event) | 142 | void KOEventViewerDialog::setEvent(Event *event) |
129 | { | 143 | { |
130 | mEventViewer->setEvent(event); | 144 | mEventViewer->setEvent(event); |
131 | mIncidence = event; | 145 | mIncidence = event; |
132 | mEventViewer->setFocus(); | 146 | mEventViewer->setFocus(); |
133 | //findButton( Close )->setFocus(); | 147 | //findButton( Close )->setFocus(); |
134 | if ( !mSyncMode ) { | 148 | if ( !mSyncMode ) { |
135 | findButton( User1 )->setText( i18n("Agenda")); | 149 | findButton( User1 )->setText( i18n("Agenda")); |
136 | } | 150 | } |
137 | } | 151 | } |
138 | void KOEventViewerDialog::setIncidence(Incidence *in ) | 152 | void KOEventViewerDialog::setIncidence(Incidence *in ) |
139 | { | 153 | { |
140 | if ( in->type() == "Event" ) | 154 | if ( in->type() == "Event" ) |
141 | setEvent( (Event*) in ); | 155 | setEvent( (Event*) in ); |
142 | else if ( in->type() =="Todo" ) | 156 | else if ( in->type() =="Todo" ) |
143 | setTodo( (Todo*) in ); | 157 | setTodo( (Todo*) in ); |
144 | else if ( in->type() =="Journal" ) | 158 | else if ( in->type() =="Journal" ) |
145 | setJournal( (Journal*) in ); | 159 | setJournal( (Journal*) in ); |
146 | } | 160 | } |
147 | void KOEventViewerDialog::addIncidence(Incidence *in) | 161 | void KOEventViewerDialog::addIncidence(Incidence *in) |
148 | { | 162 | { |
149 | if ( in->type() == "Event" ) | 163 | if ( in->type() == "Event" ) |
150 | addEvent( (Event*) in ); | 164 | addEvent( (Event*) in ); |
151 | else if ( in->type() =="Todo" ) | 165 | else if ( in->type() =="Todo" ) |
152 | mEventViewer->setTodo( (Todo*) in, false ); | 166 | mEventViewer->setTodo( (Todo*) in, false ); |
153 | else if ( in->type() =="Journal" ) | 167 | else if ( in->type() =="Journal" ) |
154 | mEventViewer->setJournal( (Journal*) in, false ); | 168 | mEventViewer->setJournal( (Journal*) in, false ); |
155 | if ( mSyncMode ) { | 169 | if ( mSyncMode ) { |
156 | findButton( User1 )->setFocus(); | 170 | findButton( User1 )->setFocus(); |
157 | setCaption(i18n("Conflict! Please choose entry")); | 171 | setCaption(i18n("Conflict! Please choose entry")); |
158 | } | 172 | } |
159 | } | 173 | } |
160 | 174 | ||
161 | void KOEventViewerDialog::addEvent(Event *event) | 175 | void KOEventViewerDialog::addEvent(Event *event) |
162 | { | 176 | { |
163 | mEventViewer->addEvent(event); | 177 | mEventViewer->addEvent(event); |
164 | mIncidence = event; | 178 | mIncidence = event; |
165 | mEventViewer->setFocus(); | 179 | mEventViewer->setFocus(); |
166 | //findButton( Close )->setFocus(); | 180 | //findButton( Close )->setFocus(); |
167 | if ( !mSyncMode ) { | 181 | if ( !mSyncMode ) { |
168 | findButton( User1 )->setText( i18n("Agenda")); | 182 | findButton( User1 )->setText( i18n("Agenda")); |
169 | } | 183 | } |
170 | } | 184 | } |
171 | 185 | ||
172 | void KOEventViewerDialog::setTodo(Todo *event) | 186 | void KOEventViewerDialog::setTodo(Todo *event) |
173 | { | 187 | { |
174 | mEventViewer->setTodo(event); | 188 | mEventViewer->setTodo(event); |
175 | mIncidence = (Incidence*)event; | 189 | mIncidence = (Incidence*)event; |
176 | mEventViewer->setFocus(); | 190 | mEventViewer->setFocus(); |
177 | //findButton( Close )->setFocus(); | 191 | //findButton( Close )->setFocus(); |
178 | if ( !mSyncMode ) { | 192 | if ( !mSyncMode ) { |
179 | findButton( User1 )->setText( i18n("Set complete")); | 193 | findButton( User1 )->setText( i18n("Set complete")); |
180 | } | 194 | } |
181 | } | 195 | } |
182 | void KOEventViewerDialog::setJournal(Journal *j) | 196 | void KOEventViewerDialog::setJournal(Journal *j) |
183 | { | 197 | { |
184 | mEventViewer->setJournal(j); | 198 | mEventViewer->setJournal(j); |
185 | mIncidence = (Incidence*)j; | 199 | mIncidence = (Incidence*)j; |
186 | mEventViewer->setFocus(); | 200 | mEventViewer->setFocus(); |
187 | //findButton( Close )->setFocus(); | 201 | //findButton( Close )->setFocus(); |
188 | if ( !mSyncMode ) { | 202 | if ( !mSyncMode ) { |
189 | findButton( User1 )->setText( i18n("Agenda")); | 203 | findButton( User1 )->setText( i18n("Agenda")); |
190 | } | 204 | } |
191 | } | 205 | } |
192 | 206 | ||
193 | void KOEventViewerDialog::addText(QString text) | 207 | void KOEventViewerDialog::addText(QString text) |
194 | { | 208 | { |
195 | mEventViewer->addText(text); | 209 | mEventViewer->addText(text); |
196 | mEventViewer->setFocus(); | 210 | mEventViewer->setFocus(); |
197 | //findButton( Close )->setFocus(); | 211 | //findButton( Close )->setFocus(); |
198 | } | 212 | } |
199 | void KOEventViewerDialog::editIncidence() | 213 | void KOEventViewerDialog::editIncidence() |
200 | { | 214 | { |
201 | sendSignalViewerClosed = false; | 215 | sendSignalViewerClosed = false; |
202 | if ( mSyncMode ) { | 216 | if ( mSyncMode ) { |
203 | mSyncResult = 2; | 217 | mSyncResult = 2; |
204 | accept(); | 218 | accept(); |
205 | return; | 219 | return; |
206 | } | 220 | } |
207 | if ( mIncidence ){ | 221 | if ( mIncidence ){ |
208 | #ifndef DESKTOP_VERSION | 222 | #ifndef DESKTOP_VERSION |
209 | hide(); | 223 | hide(); |
210 | #endif | 224 | #endif |
211 | emit editIncidence( mIncidence ); | 225 | emit editIncidence( mIncidence ); |
212 | } | 226 | } |
213 | } | 227 | } |
214 | void KOEventViewerDialog::showIncidence() | 228 | void KOEventViewerDialog::showIncidence() |
215 | { | 229 | { |
216 | sendSignalViewerClosed = false; | 230 | sendSignalViewerClosed = false; |
217 | if ( mSyncMode ) { | 231 | if ( mSyncMode ) { |
218 | mSyncResult = 1; | 232 | mSyncResult = 1; |
219 | accept(); | 233 | accept(); |
220 | return; | 234 | return; |
221 | } | 235 | } |
222 | 236 | ||
223 | if ( mIncidence ){ | 237 | if ( mIncidence ){ |
224 | #ifndef DESKTOP_VERSION | 238 | #ifndef DESKTOP_VERSION |
225 | hide(); | 239 | hide(); |
226 | #endif | 240 | #endif |
227 | QDate date; | 241 | QDate date; |
228 | if ( mIncidence->type() == "Todo" ) { | 242 | if ( mIncidence->type() == "Todo" ) { |
229 | /* | 243 | /* |
230 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 244 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
231 | date = ((Todo*)mIncidence)->dtDue().date(); | 245 | date = ((Todo*)mIncidence)->dtDue().date(); |
232 | else { | 246 | else { |
233 | globalFlagBlockAgenda = 2; | 247 | globalFlagBlockAgenda = 2; |
234 | emit showAgendaView( false ); | 248 | emit showAgendaView( false ); |
235 | return; | 249 | return; |
236 | } | 250 | } |
237 | */ | 251 | */ |
238 | ((Todo*)mIncidence)->setCompleted( true ); | 252 | ((Todo*)mIncidence)->setCompleted( true ); |
239 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 253 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
240 | hide(); | 254 | hide(); |
241 | emit todoCompleted(((Todo*)mIncidence)); | 255 | emit todoCompleted(((Todo*)mIncidence)); |
242 | return; | 256 | return; |
243 | 257 | ||
244 | } else | 258 | } else |
245 | date = mIncidence->dtStart().date(); | 259 | date = mIncidence->dtStart().date(); |
246 | globalFlagBlockAgenda = 1; | 260 | globalFlagBlockAgenda = 1; |
247 | emit showAgendaView( false ); | 261 | emit showAgendaView( false ); |
248 | globalFlagBlockAgenda = 2; | 262 | globalFlagBlockAgenda = 2; |
249 | emit jumpToTime( date ); | 263 | emit jumpToTime( date ); |
250 | } | 264 | } |
251 | } | 265 | } |
252 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 266 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
253 | { | 267 | { |
254 | switch ( e->key() ) { | 268 | switch ( e->key() ) { |
255 | 269 | ||
256 | case Qt::Key_A : | 270 | case Qt::Key_A : |
257 | case Qt::Key_L : | 271 | case Qt::Key_L : |
258 | showIncidence(); | 272 | showIncidence(); |
259 | break; | 273 | break; |
260 | case Qt::Key_E : | 274 | case Qt::Key_E : |
261 | case Qt::Key_R : | 275 | case Qt::Key_R : |
262 | editIncidence(); | 276 | editIncidence(); |
263 | break; | 277 | break; |
264 | case Qt::Key_C: | 278 | case Qt::Key_C: |
265 | case Qt::Key_Escape: | 279 | case Qt::Key_Escape: |
266 | sendSignalViewerClosed = true; | 280 | sendSignalViewerClosed = true; |
267 | close(); | 281 | close(); |
268 | break; | 282 | break; |
269 | case Qt::Key_I: | 283 | case Qt::Key_I: |
270 | #ifndef DESKTOP_VERSION | 284 | #ifndef DESKTOP_VERSION |
271 | sendSignalViewerClosed = true; | 285 | sendSignalViewerClosed = true; |
272 | close(); | 286 | close(); |
273 | #else | 287 | #else |
274 | sendSignalViewerClosed = true; | 288 | sendSignalViewerClosed = true; |
275 | slotViewerClosed(); | 289 | slotViewerClosed(); |
276 | //accept(); | 290 | //accept(); |
277 | #endif | 291 | #endif |
278 | break; | 292 | break; |
279 | default: | 293 | default: |
280 | KDialogBase::keyPressEvent ( e ); | 294 | KDialogBase::keyPressEvent ( e ); |
281 | break; | 295 | break; |
282 | } | 296 | } |
283 | 297 | ||
284 | } | 298 | } |
285 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) | 299 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) |
286 | { | 300 | { |
287 | KDialogBase::hideEvent ( e ); | 301 | KDialogBase::hideEvent ( e ); |
288 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); | 302 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); |
289 | } | 303 | } |
290 | 304 | ||
291 | void KOEventViewerDialog::slotViewerClosed() | 305 | void KOEventViewerDialog::slotViewerClosed() |
292 | { | 306 | { |
293 | if ( mSyncMode ) | 307 | if ( mSyncMode ) |
294 | return; | 308 | return; |
295 | 309 | ||
296 | if ( sendSignalViewerClosed ) { | 310 | if ( sendSignalViewerClosed ) { |
297 | //qDebug("KOEventViewerDialog::hideEvent "); | 311 | //qDebug("KOEventViewerDialog::hideEvent "); |
298 | emit signalViewerClosed(); | 312 | emit signalViewerClosed(); |
299 | } | 313 | } |
300 | sendSignalViewerClosed = true; | 314 | sendSignalViewerClosed = true; |
301 | } | 315 | } |
302 | 316 | ||
diff --git a/korganizer/koeventviewerdialog.h b/korganizer/koeventviewerdialog.h index 36431ad..8e1cd44 100644 --- a/korganizer/koeventviewerdialog.h +++ b/korganizer/koeventviewerdialog.h | |||
@@ -1,75 +1,76 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOEVENTVIEWERDIALOG_H | 19 | #ifndef KOEVENTVIEWERDIALOG_H |
20 | #define KOEVENTVIEWERDIALOG_H | 20 | #define KOEVENTVIEWERDIALOG_H |
21 | // | 21 | // |
22 | // Viewer dialog for events. | 22 | // Viewer dialog for events. |
23 | // | 23 | // |
24 | 24 | ||
25 | #include <qtextview.h> | 25 | #include <qtextview.h> |
26 | 26 | ||
27 | #include <kdialogbase.h> | 27 | #include <kdialogbase.h> |
28 | 28 | ||
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | 30 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | class KOEventViewer; | 33 | class KOEventViewer; |
34 | 34 | ||
35 | class KOEventViewerDialog : public KDialogBase { | 35 | class KOEventViewerDialog : public KDialogBase { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | KOEventViewerDialog(QWidget *parent=0,const char *name=0); | 38 | KOEventViewerDialog(QWidget *parent=0,const char *name=0); |
39 | virtual ~KOEventViewerDialog(); | 39 | virtual ~KOEventViewerDialog(); |
40 | 40 | ||
41 | void setEvent(Event *event); | 41 | void setEvent(Event *event); |
42 | void addEvent(Event *event); | 42 | void addEvent(Event *event); |
43 | void setTodo(Todo *event); | 43 | void setTodo(Todo *event); |
44 | void setJournal(Journal *journal); | 44 | void setJournal(Journal *journal); |
45 | void setIncidence(Incidence *inc); | 45 | void setIncidence(Incidence *inc); |
46 | void addIncidence(Incidence *inc); | 46 | void addIncidence(Incidence *inc); |
47 | void addText(QString text); | 47 | void addText(QString text); |
48 | void showMe(); | 48 | void showMe(); |
49 | void setSyncMode( bool ); | 49 | void setSyncMode( bool ); |
50 | void setColorMode( int m ); | 50 | void setColorMode( int m ); |
51 | int executeS( bool ); | 51 | int executeS( bool ); |
52 | public slots: | 52 | public slots: |
53 | void updateConfig(); | 53 | void updateConfig(); |
54 | void print(); | ||
54 | signals: | 55 | signals: |
55 | void editIncidence( Incidence* ); | 56 | void editIncidence( Incidence* ); |
56 | void jumpToTime( const QDate &); | 57 | void jumpToTime( const QDate &); |
57 | void showAgendaView( bool ); | 58 | void showAgendaView( bool ); |
58 | void todoCompleted(Todo*); | 59 | void todoCompleted(Todo*); |
59 | void signalViewerClosed(); | 60 | void signalViewerClosed(); |
60 | private slots: | 61 | private slots: |
61 | void slotViewerClosed(); | 62 | void slotViewerClosed(); |
62 | void editIncidence(); | 63 | void editIncidence(); |
63 | void showIncidence(); | 64 | void showIncidence(); |
64 | protected: | 65 | protected: |
65 | void hideEvent ( QHideEvent * e ); | 66 | void hideEvent ( QHideEvent * e ); |
66 | private: | 67 | private: |
67 | bool sendSignalViewerClosed; | 68 | bool sendSignalViewerClosed; |
68 | bool mSyncMode; | 69 | bool mSyncMode; |
69 | int mSyncResult; | 70 | int mSyncResult; |
70 | KOEventViewer *mEventViewer; | 71 | KOEventViewer *mEventViewer; |
71 | Incidence* mIncidence; | 72 | Incidence* mIncidence; |
72 | void keyPressEvent ( QKeyEvent * e ); | 73 | void keyPressEvent ( QKeyEvent * e ); |
73 | }; | 74 | }; |
74 | 75 | ||
75 | #endif | 76 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index e80b3fc..8752636 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,792 +1,799 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") { | 91 | else if (view == "Month") { |
92 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 92 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
93 | showMonthView(); | 93 | showMonthView(); |
94 | else | 94 | else |
95 | showMonthViewWeek(); | 95 | showMonthViewWeek(); |
96 | } | 96 | } |
97 | else if (view == "List") showListView(); | 97 | else if (view == "List") showListView(); |
98 | else if (view == "Journal") showJournalView(); | 98 | else if (view == "Journal") showJournalView(); |
99 | else if (view == "TimeSpan") showTimeSpanView(); | 99 | else if (view == "TimeSpan") showTimeSpanView(); |
100 | else if (view == "Todo") showTodoView(); | 100 | else if (view == "Todo") showTodoView(); |
101 | else { | 101 | else { |
102 | config->setGroup( "Views" ); | 102 | config->setGroup( "Views" ); |
103 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 103 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
104 | mCurrentAgendaView = dateCount; | 104 | mCurrentAgendaView = dateCount; |
105 | showAgendaView(); | 105 | showAgendaView(); |
106 | mCurrentAgendaView = dateCount; | 106 | mCurrentAgendaView = dateCount; |
107 | #ifdef DESKTOP_VERSION | 107 | #ifdef DESKTOP_VERSION |
108 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); | 108 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); |
109 | #endif | 109 | #endif |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | void KOViewManager::showDateView( int view, QDate date) | 113 | void KOViewManager::showDateView( int view, QDate date) |
114 | { | 114 | { |
115 | static int lastMode = 0; | 115 | static int lastMode = 0; |
116 | static int lastCount = 0; | 116 | static int lastCount = 0; |
117 | static bool lastNDMode = false; | 117 | static bool lastNDMode = false; |
118 | static QDate lastDate; | 118 | static QDate lastDate; |
119 | //qDebug("date %d %s", view, date.toString().latin1()); | 119 | //qDebug("date %d %s", view, date.toString().latin1()); |
120 | 120 | ||
121 | if (view != 9) | 121 | if (view != 9) |
122 | lastMode = 0; | 122 | lastMode = 0; |
123 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); | 123 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); |
124 | bool savemFlagShowNextxDays = mFlagShowNextxDays; | 124 | bool savemFlagShowNextxDays = mFlagShowNextxDays; |
125 | mFlagShowNextxDays = false; | 125 | mFlagShowNextxDays = false; |
126 | if ( view == 3 ) { | 126 | if ( view == 3 ) { |
127 | //mCurrentAgendaView = 1 ; | 127 | //mCurrentAgendaView = 1 ; |
128 | lastDate = mMainView->dateNavigator()->selectedDates().first(); | 128 | lastDate = mMainView->dateNavigator()->selectedDates().first(); |
129 | lastCount = mMainView->dateNavigator()->selectedDates().count(); | 129 | lastCount = mMainView->dateNavigator()->selectedDates().count(); |
130 | lastNDMode = savemFlagShowNextxDays; | 130 | lastNDMode = savemFlagShowNextxDays; |
131 | mMainView->dateNavigator()->selectDate( date ); | 131 | mMainView->dateNavigator()->selectDate( date ); |
132 | lastMode = 1; | 132 | lastMode = 1; |
133 | mCurrentAgendaView = 1 ; | 133 | mCurrentAgendaView = 1 ; |
134 | } else if (view == 4 ) { | 134 | } else if (view == 4 ) { |
135 | mCurrentAgendaView = 7 ; | 135 | mCurrentAgendaView = 7 ; |
136 | mMainView->dateNavigator()->selectDates( date, 7 ); | 136 | mMainView->dateNavigator()->selectDates( date, 7 ); |
137 | } else if (view == 5 ) { | 137 | } else if (view == 5 ) { |
138 | mCurrentAgendaView = 14 ; | 138 | mCurrentAgendaView = 14 ; |
139 | mMainView->dateNavigator()->selectDates( date, 14); | 139 | mMainView->dateNavigator()->selectDates( date, 14); |
140 | } else if (view == 6 ) { | 140 | } else if (view == 6 ) { |
141 | //mMainView->dateNavigator()->selectDates( date, 7 ); | 141 | //mMainView->dateNavigator()->selectDates( date, 7 ); |
142 | showMonthView(); | 142 | showMonthView(); |
143 | } else if (view == 7 ) { | 143 | } else if (view == 7 ) { |
144 | mMainView->dateNavigator()->selectDate( date ); | 144 | mMainView->dateNavigator()->selectDate( date ); |
145 | showJournalView(); | 145 | showJournalView(); |
146 | } else if (view == 8 ) { | 146 | } else if (view == 8 ) { |
147 | globalFlagBlockAgenda = 1; | 147 | globalFlagBlockAgenda = 1; |
148 | if ( mCurrentAgendaView != 3 ) | 148 | if ( mCurrentAgendaView != 3 ) |
149 | mCurrentAgendaView = -1; | 149 | mCurrentAgendaView = -1; |
150 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 150 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
151 | globalFlagBlockAgenda = 2; | 151 | globalFlagBlockAgenda = 2; |
152 | mMainView->dateNavigator()->selectDates( date , | 152 | mMainView->dateNavigator()->selectDates( date , |
153 | KOPrefs::instance()->mNextXDays ); | 153 | KOPrefs::instance()->mNextXDays ); |
154 | mFlagShowNextxDays = true; | 154 | mFlagShowNextxDays = true; |
155 | mCurrentAgendaView = 3 ; | 155 | mCurrentAgendaView = 3 ; |
156 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) | 156 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) |
157 | if ( lastMode ) { | 157 | if ( lastMode ) { |
158 | mCurrentAgendaView = lastCount ; | 158 | mCurrentAgendaView = lastCount ; |
159 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); | 159 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); |
160 | mFlagShowNextxDays = lastNDMode; | 160 | mFlagShowNextxDays = lastNDMode; |
161 | if ( mFlagShowNextxDays ) { | 161 | if ( mFlagShowNextxDays ) { |
162 | mCurrentAgendaView = 3 ; | 162 | mCurrentAgendaView = 3 ; |
163 | } | 163 | } |
164 | } else | 164 | } else |
165 | showWeekView(); | 165 | showWeekView(); |
166 | } else if (view == 10) { | 166 | } else if (view == 10) { |
167 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); | 167 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | 172 | ||
173 | void KOViewManager::writeSettings(KConfig *config) | 173 | void KOViewManager::writeSettings(KConfig *config) |
174 | { | 174 | { |
175 | config->setGroup("General"); | 175 | config->setGroup("General"); |
176 | 176 | ||
177 | QString view; | 177 | QString view; |
178 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 178 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
179 | else if (mCurrentView == mMonthView) view = "Month"; | 179 | else if (mCurrentView == mMonthView) view = "Month"; |
180 | else if (mCurrentView == mListView) view = "List"; | 180 | else if (mCurrentView == mListView) view = "List"; |
181 | else if (mCurrentView == mJournalView) view = "Journal"; | 181 | else if (mCurrentView == mJournalView) view = "Journal"; |
182 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 182 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
183 | else if (mCurrentView == mTodoView) view = "Todo"; | 183 | else if (mCurrentView == mTodoView) view = "Todo"; |
184 | else view = "Agenda"; | 184 | else view = "Agenda"; |
185 | 185 | ||
186 | config->writeEntry("Current View",view); | 186 | config->writeEntry("Current View",view); |
187 | 187 | ||
188 | if (mAgendaView) { | 188 | if (mAgendaView) { |
189 | mAgendaView->writeSettings(config); | 189 | mAgendaView->writeSettings(config); |
190 | } | 190 | } |
191 | if (mTimeSpanView) { | 191 | if (mTimeSpanView) { |
192 | mTimeSpanView->writeSettings(config); | 192 | mTimeSpanView->writeSettings(config); |
193 | } | 193 | } |
194 | if (mListView) { | 194 | if (mListView) { |
195 | mListView->writeSettings(config); | 195 | mListView->writeSettings(config); |
196 | } | 196 | } |
197 | if (mTodoView) { | 197 | if (mTodoView) { |
198 | mTodoView->saveLayout(config,"Todo View"); | 198 | mTodoView->saveLayout(config,"Todo View"); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | void KOViewManager::showNextView() | 201 | void KOViewManager::showNextView() |
202 | { | 202 | { |
203 | if (mCurrentView == mWhatsNextView) goto NEXT_X; | 203 | if (mCurrentView == mWhatsNextView) goto NEXT_X; |
204 | 204 | ||
205 | if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; | 205 | if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; |
206 | 206 | ||
207 | if (mCurrentView == mJournalView ) goto DAY_1; | 207 | if (mCurrentView == mJournalView ) goto DAY_1; |
208 | 208 | ||
209 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; | 209 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; |
210 | 210 | ||
211 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; | 211 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; |
212 | 212 | ||
213 | if (mCurrentView == mAgendaView ) goto DAY_6; | 213 | if (mCurrentView == mAgendaView ) goto DAY_6; |
214 | 214 | ||
215 | if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; | 215 | if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; |
216 | 216 | ||
217 | if (mCurrentView == mMonthView ) goto LIST; | 217 | if (mCurrentView == mMonthView ) goto LIST; |
218 | 218 | ||
219 | if (mCurrentView == mListView ) goto TODO; | 219 | if (mCurrentView == mListView ) goto TODO; |
220 | 220 | ||
221 | // if (mCurrentView == mTodoView ) goto LIST; | 221 | // if (mCurrentView == mTodoView ) goto LIST; |
222 | 222 | ||
223 | 223 | ||
224 | NEXT: | 224 | NEXT: |
225 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();return ;} | 225 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();return ;} |
226 | NEXT_X: | 226 | NEXT_X: |
227 | if ( KOPrefs::instance()->mShowIconNextDays ) { showNextXView() ;return ;} | 227 | if ( KOPrefs::instance()->mShowIconNextDays ) { showNextXView() ;return ;} |
228 | JOURNAL: | 228 | JOURNAL: |
229 | if ( KOPrefs::instance()->mShowIconJournal ) { showJournalView() ;return ;} | 229 | if ( KOPrefs::instance()->mShowIconJournal ) { showJournalView() ;return ;} |
230 | DAY_1: | 230 | DAY_1: |
231 | if ( KOPrefs::instance()->mShowIconDay1 ) { showDayView() ;return ;} | 231 | if ( KOPrefs::instance()->mShowIconDay1 ) { showDayView() ;return ;} |
232 | DAY_5: | 232 | DAY_5: |
233 | if ( KOPrefs::instance()->mShowIconDay5 ) { showWorkWeekView() ;return ;} | 233 | if ( KOPrefs::instance()->mShowIconDay5 ) { showWorkWeekView() ;return ;} |
234 | DAY_7: | 234 | DAY_7: |
235 | if ( KOPrefs::instance()->mShowIconDay7 ) { showWeekView();return ;} | 235 | if ( KOPrefs::instance()->mShowIconDay7 ) { showWeekView();return ;} |
236 | DAY_6: | 236 | DAY_6: |
237 | if ( KOPrefs::instance()->mShowIconDay6 ) { showMonthViewWeek();return ;} | 237 | if ( KOPrefs::instance()->mShowIconDay6 ) { showMonthViewWeek();return ;} |
238 | MONTH: | 238 | MONTH: |
239 | if ( KOPrefs::instance()->mShowIconMonth ) { showMonthView();return ;} | 239 | if ( KOPrefs::instance()->mShowIconMonth ) { showMonthView();return ;} |
240 | LIST: | 240 | LIST: |
241 | if ( KOPrefs::instance()->mShowIconList ) { showListView() ;return ;} | 241 | if ( KOPrefs::instance()->mShowIconList ) { showListView() ;return ;} |
242 | TODO: | 242 | TODO: |
243 | if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;return ;} | 243 | if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;return ;} |
244 | 244 | ||
245 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();return ;} | 245 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();return ;} |
246 | 246 | ||
247 | if ( KOPrefs::instance()->mShowIconNextDays ) { showNextXView() ;return ;} | 247 | if ( KOPrefs::instance()->mShowIconNextDays ) { showNextXView() ;return ;} |
248 | 248 | ||
249 | if ( KOPrefs::instance()->mShowIconJournal ) { showJournalView() ;return ;} | 249 | if ( KOPrefs::instance()->mShowIconJournal ) { showJournalView() ;return ;} |
250 | 250 | ||
251 | if ( KOPrefs::instance()->mShowIconDay1 ) { showDayView() ;return ;} | 251 | if ( KOPrefs::instance()->mShowIconDay1 ) { showDayView() ;return ;} |
252 | 252 | ||
253 | if ( KOPrefs::instance()->mShowIconDay5 ) { showWorkWeekView() ;return ;} | 253 | if ( KOPrefs::instance()->mShowIconDay5 ) { showWorkWeekView() ;return ;} |
254 | 254 | ||
255 | if ( KOPrefs::instance()->mShowIconDay7 ) { showWeekView();return ;} | 255 | if ( KOPrefs::instance()->mShowIconDay7 ) { showWeekView();return ;} |
256 | 256 | ||
257 | if ( KOPrefs::instance()->mShowIconDay6 ) { showMonthViewWeek();return ;} | 257 | if ( KOPrefs::instance()->mShowIconDay6 ) { showMonthViewWeek();return ;} |
258 | 258 | ||
259 | if ( KOPrefs::instance()->mShowIconMonth ) { showMonthView();return ;} | 259 | if ( KOPrefs::instance()->mShowIconMonth ) { showMonthView();return ;} |
260 | 260 | ||
261 | if ( KOPrefs::instance()->mShowIconList ) { showListView() ;return ;} | 261 | if ( KOPrefs::instance()->mShowIconList ) { showListView() ;return ;} |
262 | 262 | ||
263 | if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;return ;} | 263 | if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;return ;} |
264 | 264 | ||
265 | 265 | ||
266 | 266 | ||
267 | } | 267 | } |
268 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 268 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
269 | { | 269 | { |
270 | 270 | ||
271 | //mFlagShowNextxDays = false; | 271 | //mFlagShowNextxDays = false; |
272 | //if(view == mCurrentView) return; | 272 | //if(view == mCurrentView) return; |
273 | if ( view == 0 ) { | 273 | if ( view == 0 ) { |
274 | view = mCurrentView; | 274 | view = mCurrentView; |
275 | if ( view == 0 ) | 275 | if ( view == 0 ) |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | bool callupdate = !(view == mCurrentView); | 278 | bool callupdate = !(view == mCurrentView); |
279 | bool full = fullScreen; | 279 | bool full = fullScreen; |
280 | if(view == mCurrentView && view != mWhatsNextView ) { | 280 | if(view == mCurrentView && view != mWhatsNextView ) { |
281 | if ( mCurrentAgendaView < 0 ) | 281 | if ( mCurrentAgendaView < 0 ) |
282 | return; | 282 | return; |
283 | if ( view != mMonthView ) | 283 | if ( view != mMonthView ) |
284 | full = mMainView->leftFrame()->isVisible(); | 284 | full = mMainView->leftFrame()->isVisible(); |
285 | } else { | 285 | } else { |
286 | if ( view == mMonthView && mMonthView) | 286 | if ( view == mMonthView && mMonthView) |
287 | ;//mMonthView->skipResize = true ; | 287 | ;//mMonthView->skipResize = true ; |
288 | mCurrentView = view; | 288 | mCurrentView = view; |
289 | // bool full = fullScreen; | 289 | // bool full = fullScreen; |
290 | bool isFull = !mMainView->leftFrame()->isVisible(); | 290 | bool isFull = !mMainView->leftFrame()->isVisible(); |
291 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 291 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
292 | full = true; | 292 | full = true; |
293 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 293 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
294 | full = false; | 294 | full = false; |
295 | } | 295 | } |
296 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 296 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
297 | //raiseCurrentView( full ); | 297 | //raiseCurrentView( full ); |
298 | mMainView->processIncidenceSelection( 0 ); | 298 | mMainView->processIncidenceSelection( 0 ); |
299 | //mMainView->updateView(); | 299 | //mMainView->updateView(); |
300 | raiseCurrentView( full, callupdate ); | 300 | raiseCurrentView( full, callupdate ); |
301 | mMainView->adaptNavigationUnits(); | 301 | mMainView->adaptNavigationUnits(); |
302 | } | 302 | } |
303 | 303 | ||
304 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | 304 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
305 | { | 305 | { |
306 | mCurrentAgendaView = 0; | 306 | mCurrentAgendaView = 0; |
307 | if ( fullScreen ) { | 307 | if ( fullScreen ) { |
308 | mMainView->leftFrame()->hide(); | 308 | mMainView->leftFrame()->hide(); |
309 | } else { | 309 | } else { |
310 | mMainView->leftFrame()->show(); | 310 | mMainView->leftFrame()->show(); |
311 | } | 311 | } |
312 | //if ( mCurrentView == mMonthView ) qApp->processEvents(); | 312 | //if ( mCurrentView == mMonthView ) qApp->processEvents(); |
313 | emit signalFullScreen( !fullScreen ); | 313 | emit signalFullScreen( !fullScreen ); |
314 | if ( callUpdateView ) | 314 | if ( callUpdateView ) |
315 | mMainView->updateView(); | 315 | mMainView->updateView(); |
316 | 316 | ||
317 | if ( globalFlagBlockAgenda == 5 ) { | 317 | if ( globalFlagBlockAgenda == 5 ) { |
318 | globalFlagBlockAgenda = 4; | 318 | globalFlagBlockAgenda = 4; |
319 | globalFlagBlockAgendaItemPaint = 1; | 319 | globalFlagBlockAgendaItemPaint = 1; |
320 | } | 320 | } |
321 | mMainView->viewStack()->raiseWidget(mCurrentView); | 321 | mMainView->viewStack()->raiseWidget(mCurrentView); |
322 | if ( globalFlagBlockAgenda == 4 ) { | 322 | if ( globalFlagBlockAgenda == 4 ) { |
323 | if ( mCurrentView == mAgendaView ) { | 323 | if ( mCurrentView == mAgendaView ) { |
324 | //globalFlagBlockAgenda =1 ; | 324 | //globalFlagBlockAgenda =1 ; |
325 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 325 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
326 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 326 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
327 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 327 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
328 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 328 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
329 | qApp->processEvents(); | 329 | qApp->processEvents(); |
330 | //qDebug("qApp->processEvents() "); | 330 | //qDebug("qApp->processEvents() "); |
331 | globalFlagBlockAgenda = 0; | 331 | globalFlagBlockAgenda = 0; |
332 | mAgendaView->repaintAgenda(); | 332 | mAgendaView->repaintAgenda(); |
333 | 333 | ||
334 | } | 334 | } |
335 | globalFlagBlockAgenda = 0; | 335 | globalFlagBlockAgenda = 0; |
336 | } | 336 | } |
337 | emit signalAgendaView( mCurrentView == mAgendaView ); | 337 | emit signalAgendaView( mCurrentView == mAgendaView ); |
338 | //qDebug("raiseCurrentView ende "); | 338 | //qDebug("raiseCurrentView ende "); |
339 | 339 | ||
340 | } | 340 | } |
341 | 341 | ||
342 | void KOViewManager::updateView() | 342 | void KOViewManager::updateView() |
343 | { | 343 | { |
344 | // qDebug("KOViewManager::updateView() "); | 344 | // qDebug("KOViewManager::updateView() "); |
345 | // if we are updating mTodoView, we get endless recursion | 345 | // if we are updating mTodoView, we get endless recursion |
346 | if ( mTodoView == mCurrentView ) | 346 | if ( mTodoView == mCurrentView ) |
347 | return; | 347 | return; |
348 | if ( mCurrentView ) mCurrentView->updateView(); | 348 | if ( mCurrentView ) mCurrentView->updateView(); |
349 | 349 | ||
350 | } | 350 | } |
351 | 351 | ||
352 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 352 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
353 | { | 353 | { |
354 | // kdDebug() << "KOViewManager::updateView()" << endl; | 354 | // kdDebug() << "KOViewManager::updateView()" << endl; |
355 | 355 | ||
356 | if (mCurrentView) mCurrentView->showDates(start, end); | 356 | if (mCurrentView) mCurrentView->showDates(start, end); |
357 | 357 | ||
358 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); | 358 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | void KOViewManager::updateWNview() | 362 | void KOViewManager::updateWNview() |
363 | { | 363 | { |
364 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 364 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
365 | mWhatsNextView->updateView(); | 365 | mWhatsNextView->updateView(); |
366 | 366 | ||
367 | } | 367 | } |
368 | void KOViewManager::showWhatsNextView() | 368 | void KOViewManager::showWhatsNextView() |
369 | { | 369 | { |
370 | if (!mWhatsNextView) { | 370 | if (!mWhatsNextView) { |
371 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 371 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
372 | "KOViewManager::WhatsNextView"); | 372 | "KOViewManager::WhatsNextView"); |
373 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 373 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
374 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 374 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
375 | addView(mWhatsNextView); | 375 | addView(mWhatsNextView); |
376 | connect(this, SIGNAL( printWNV() ), | 376 | connect(this, SIGNAL( printWNV() ), |
377 | mWhatsNextView, SLOT( printMe() ) ); | 377 | mWhatsNextView, SLOT( printMe() ) ); |
378 | } | 378 | } |
379 | globalFlagBlockAgenda = 1; | 379 | globalFlagBlockAgenda = 1; |
380 | showView(mWhatsNextView, true ); | 380 | showView(mWhatsNextView, true ); |
381 | //mWhatsNextView->updateView(); | 381 | //mWhatsNextView->updateView(); |
382 | 382 | ||
383 | } | 383 | } |
384 | 384 | ||
385 | void KOViewManager::slotprintWNV() | ||
386 | { | ||
387 | if (!mWhatsNextView) | ||
388 | showWhatsNextView(); | ||
389 | emit printWNV(); | ||
390 | |||
391 | } | ||
385 | void KOViewManager::showListView() | 392 | void KOViewManager::showListView() |
386 | { | 393 | { |
387 | if (!mListView) { | 394 | if (!mListView) { |
388 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 395 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
389 | addView(mListView); | 396 | addView(mListView); |
390 | 397 | ||
391 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 398 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
392 | mMainView, SLOT(showIncidence(Incidence *))); | 399 | mMainView, SLOT(showIncidence(Incidence *))); |
393 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 400 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
394 | mMainView, SLOT(editIncidence(Incidence *))); | 401 | mMainView, SLOT(editIncidence(Incidence *))); |
395 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 402 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
396 | mMainView, SLOT(deleteIncidence(Incidence *))); | 403 | mMainView, SLOT(deleteIncidence(Incidence *))); |
397 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 404 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
398 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 405 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
399 | connect( mListView, SIGNAL( signalNewEvent() ), | 406 | connect( mListView, SIGNAL( signalNewEvent() ), |
400 | mMainView, SLOT( newEvent() ) ); | 407 | mMainView, SLOT( newEvent() ) ); |
401 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 408 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
402 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 409 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
403 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
404 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 411 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
405 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 412 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
406 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 413 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
407 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 414 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
408 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 415 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
409 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 416 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
410 | } | 417 | } |
411 | // bool temp = mFlagShowNextxDays; | 418 | // bool temp = mFlagShowNextxDays; |
412 | //globalFlagBlockPainting = true; | 419 | //globalFlagBlockPainting = true; |
413 | globalFlagBlockAgenda = 1; | 420 | globalFlagBlockAgenda = 1; |
414 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 421 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
415 | mMainView->setBlockShowDates( true ); | 422 | mMainView->setBlockShowDates( true ); |
416 | mMainView->dateNavigator()->selectMonth(); | 423 | mMainView->dateNavigator()->selectMonth(); |
417 | mMainView->setBlockShowDates( false ); | 424 | mMainView->setBlockShowDates( false ); |
418 | } | 425 | } |
419 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 426 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
420 | //mFlagShowNextxDays = temp; | 427 | //mFlagShowNextxDays = temp; |
421 | } | 428 | } |
422 | 429 | ||
423 | void KOViewManager::showAgendaView( bool fullScreen ) | 430 | void KOViewManager::showAgendaView( bool fullScreen ) |
424 | { | 431 | { |
425 | 432 | ||
426 | mMainView->dialogManager()->hideSearchDialog(); | 433 | mMainView->dialogManager()->hideSearchDialog(); |
427 | // qDebug("KOViewManager::showAgendaView "); | 434 | // qDebug("KOViewManager::showAgendaView "); |
428 | bool full; | 435 | bool full; |
429 | full = fullScreen; | 436 | full = fullScreen; |
430 | if (!mAgendaView) { | 437 | if (!mAgendaView) { |
431 | full = false; | 438 | full = false; |
432 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 439 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
433 | addView(mAgendaView); | 440 | addView(mAgendaView); |
434 | #ifndef DESKTOP_VERSION | 441 | #ifndef DESKTOP_VERSION |
435 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 442 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
436 | #endif | 443 | #endif |
437 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 444 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
438 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 445 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
439 | 446 | ||
440 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 447 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
441 | 448 | ||
442 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 449 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
443 | 450 | ||
444 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 451 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
445 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 452 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
446 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 453 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
447 | mMainView, SLOT(newEvent(QDateTime))); | 454 | mMainView, SLOT(newEvent(QDateTime))); |
448 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 455 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
449 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 456 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
450 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 457 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
451 | mMainView, SLOT(newEvent(QDate))); | 458 | mMainView, SLOT(newEvent(QDate))); |
452 | 459 | ||
453 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 460 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
454 | mMainView, SLOT(editIncidence(Incidence *))); | 461 | mMainView, SLOT(editIncidence(Incidence *))); |
455 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 462 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
456 | mMainView, SLOT(showIncidence(Incidence *))); | 463 | mMainView, SLOT(showIncidence(Incidence *))); |
457 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 464 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
458 | mMainView, SLOT(deleteIncidence(Incidence *))); | 465 | mMainView, SLOT(deleteIncidence(Incidence *))); |
459 | 466 | ||
460 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 467 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
461 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 468 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
462 | 469 | ||
463 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 470 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
464 | mMainView, SLOT( toggleExpand() ) ); | 471 | mMainView, SLOT( toggleExpand() ) ); |
465 | 472 | ||
466 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 473 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
467 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 474 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
468 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 475 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
469 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 476 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
470 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 477 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
471 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 478 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
472 | SLOT( updateTodo( Todo *, int ) ) ); | 479 | SLOT( updateTodo( Todo *, int ) ) ); |
473 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 480 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
474 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 481 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
475 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 482 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
476 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 483 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
477 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 484 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
478 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 485 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
479 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), | 486 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), |
480 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); | 487 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); |
481 | mAgendaView->readSettings(); | 488 | mAgendaView->readSettings(); |
482 | mAgendaView->updateConfig(); | 489 | mAgendaView->updateConfig(); |
483 | } | 490 | } |
484 | 491 | ||
485 | showView( mAgendaView, full); | 492 | showView( mAgendaView, full); |
486 | 493 | ||
487 | } | 494 | } |
488 | 495 | ||
489 | void KOViewManager::showDayView() | 496 | void KOViewManager::showDayView() |
490 | { | 497 | { |
491 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 498 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
492 | mFlagShowNextxDays = false; | 499 | mFlagShowNextxDays = false; |
493 | globalFlagBlockLabel = 1; | 500 | globalFlagBlockLabel = 1; |
494 | globalFlagBlockAgenda = 1; | 501 | globalFlagBlockAgenda = 1; |
495 | if ( mCurrentAgendaView != 1 ) | 502 | if ( mCurrentAgendaView != 1 ) |
496 | mCurrentAgendaView = -1; | 503 | mCurrentAgendaView = -1; |
497 | showAgendaView(); | 504 | showAgendaView(); |
498 | qApp->processEvents(); | 505 | qApp->processEvents(); |
499 | globalFlagBlockAgenda = 2; | 506 | globalFlagBlockAgenda = 2; |
500 | globalFlagBlockLabel = 0; | 507 | globalFlagBlockLabel = 0; |
501 | mMainView->dateNavigator()->selectDates( 1 ); | 508 | mMainView->dateNavigator()->selectDates( 1 ); |
502 | mCurrentAgendaView = 1 ; | 509 | mCurrentAgendaView = 1 ; |
503 | 510 | ||
504 | } | 511 | } |
505 | 512 | ||
506 | void KOViewManager::showWorkWeekView() | 513 | void KOViewManager::showWorkWeekView() |
507 | { | 514 | { |
508 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 515 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
509 | mFlagShowNextxDays = false; | 516 | mFlagShowNextxDays = false; |
510 | globalFlagBlockAgenda = 1; | 517 | globalFlagBlockAgenda = 1; |
511 | globalFlagBlockLabel = 1; | 518 | globalFlagBlockLabel = 1; |
512 | if ( mCurrentAgendaView != 5 ) | 519 | if ( mCurrentAgendaView != 5 ) |
513 | mCurrentAgendaView = -1; | 520 | mCurrentAgendaView = -1; |
514 | showAgendaView(); | 521 | showAgendaView(); |
515 | qApp->processEvents(); | 522 | qApp->processEvents(); |
516 | globalFlagBlockAgenda = 2; | 523 | globalFlagBlockAgenda = 2; |
517 | globalFlagBlockLabel = 0; | 524 | globalFlagBlockLabel = 0; |
518 | mMainView->dateNavigator()->selectWorkWeek(); | 525 | mMainView->dateNavigator()->selectWorkWeek(); |
519 | mCurrentAgendaView = 5 ; | 526 | mCurrentAgendaView = 5 ; |
520 | 527 | ||
521 | } | 528 | } |
522 | 529 | ||
523 | void KOViewManager::showWeekView() | 530 | void KOViewManager::showWeekView() |
524 | { | 531 | { |
525 | /* | 532 | /* |
526 | globalFlagBlockAgenda = 2; | 533 | globalFlagBlockAgenda = 2; |
527 | qDebug("4globalFlagBlockAgenda = 2; "); | 534 | qDebug("4globalFlagBlockAgenda = 2; "); |
528 | //globalFlagBlockPainting = true; | 535 | //globalFlagBlockPainting = true; |
529 | mMainView->dateNavigator()->selectWeek(); | 536 | mMainView->dateNavigator()->selectWeek(); |
530 | showAgendaView(); | 537 | showAgendaView(); |
531 | */ | 538 | */ |
532 | 539 | ||
533 | 540 | ||
534 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 541 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
535 | mFlagShowNextxDays = false; | 542 | mFlagShowNextxDays = false; |
536 | globalFlagBlockAgenda = 1; | 543 | globalFlagBlockAgenda = 1; |
537 | globalFlagBlockLabel = 1; | 544 | globalFlagBlockLabel = 1; |
538 | if ( mCurrentAgendaView != 7 ) | 545 | if ( mCurrentAgendaView != 7 ) |
539 | mCurrentAgendaView = -1; | 546 | mCurrentAgendaView = -1; |
540 | showAgendaView(); | 547 | showAgendaView(); |
541 | qApp->processEvents(); | 548 | qApp->processEvents(); |
542 | globalFlagBlockAgenda = 2; | 549 | globalFlagBlockAgenda = 2; |
543 | globalFlagBlockLabel = 0; | 550 | globalFlagBlockLabel = 0; |
544 | mMainView->dateNavigator()->selectWeek(); | 551 | mMainView->dateNavigator()->selectWeek(); |
545 | mCurrentAgendaView = 7 ; | 552 | mCurrentAgendaView = 7 ; |
546 | } | 553 | } |
547 | 554 | ||
548 | void KOViewManager::showNextXView() | 555 | void KOViewManager::showNextXView() |
549 | { | 556 | { |
550 | 557 | ||
551 | globalFlagBlockAgenda = 1; | 558 | globalFlagBlockAgenda = 1; |
552 | if ( mCurrentAgendaView != 3 ) | 559 | if ( mCurrentAgendaView != 3 ) |
553 | mCurrentAgendaView = -1; | 560 | mCurrentAgendaView = -1; |
554 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 561 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
555 | globalFlagBlockAgenda = 2; | 562 | globalFlagBlockAgenda = 2; |
556 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 563 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
557 | KOPrefs::instance()->mNextXDays ); | 564 | KOPrefs::instance()->mNextXDays ); |
558 | mFlagShowNextxDays = true; | 565 | mFlagShowNextxDays = true; |
559 | mCurrentAgendaView = 3 ; | 566 | mCurrentAgendaView = 3 ; |
560 | } | 567 | } |
561 | bool KOViewManager::showsNextDays() | 568 | bool KOViewManager::showsNextDays() |
562 | { | 569 | { |
563 | return mFlagShowNextxDays; | 570 | return mFlagShowNextxDays; |
564 | } | 571 | } |
565 | void KOViewManager::createMonthView() | 572 | void KOViewManager::createMonthView() |
566 | { | 573 | { |
567 | if (!mMonthView) { | 574 | if (!mMonthView) { |
568 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 575 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
569 | 576 | ||
570 | addView(mMonthView); | 577 | addView(mMonthView); |
571 | // mMonthView->show(); | 578 | // mMonthView->show(); |
572 | // SIGNALS/SLOTS FOR MONTH VIEW | 579 | // SIGNALS/SLOTS FOR MONTH VIEW |
573 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 580 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
574 | mMainView, SLOT(newEvent(QDateTime))); | 581 | mMainView, SLOT(newEvent(QDateTime))); |
575 | 582 | ||
576 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 583 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
577 | mMainView, SLOT(showIncidence(Incidence *))); | 584 | mMainView, SLOT(showIncidence(Incidence *))); |
578 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 585 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
579 | mMainView, SLOT(editIncidence(Incidence *))); | 586 | mMainView, SLOT(editIncidence(Incidence *))); |
580 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 587 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
581 | mMainView, SLOT(deleteIncidence(Incidence *))); | 588 | mMainView, SLOT(deleteIncidence(Incidence *))); |
582 | 589 | ||
583 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 590 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
584 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 591 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
585 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 592 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
586 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 593 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
587 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 594 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
588 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 595 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
589 | 596 | ||
590 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 597 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
591 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 598 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
592 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 599 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
593 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 600 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
594 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 601 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
595 | mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); | 602 | mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); |
596 | connect( mMonthView, SIGNAL( selectMonth() ), | 603 | connect( mMonthView, SIGNAL( selectMonth() ), |
597 | mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); | 604 | mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); |
598 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 605 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
599 | mMainView, SLOT ( showDay( QDate ) ) ); | 606 | mMainView, SLOT ( showDay( QDate ) ) ); |
600 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 607 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
601 | connect( mMonthView, SIGNAL(nextMonth() ), | 608 | connect( mMonthView, SIGNAL(nextMonth() ), |
602 | mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 609 | mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
603 | connect( mMonthView, SIGNAL(prevMonth() ), | 610 | connect( mMonthView, SIGNAL(prevMonth() ), |
604 | mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 611 | mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
605 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), | 612 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), |
606 | mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); | 613 | mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); |
607 | connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), | 614 | connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), |
608 | mMainView->dateNavigator(), SLOT( selectNextYear() ) ); | 615 | mMainView->dateNavigator(), SLOT( selectNextYear() ) ); |
609 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), | 616 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), |
610 | mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); | 617 | mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); |
611 | connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), | 618 | connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), |
612 | mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); | 619 | mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); |
613 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), | 620 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), |
614 | mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); | 621 | mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); |
615 | connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), | 622 | connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), |
616 | mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); | 623 | mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); |
617 | 624 | ||
618 | connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 625 | connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
619 | mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); | 626 | mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); |
620 | 627 | ||
621 | 628 | ||
622 | connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), | 629 | connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), |
623 | mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); | 630 | mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); |
624 | 631 | ||
625 | } | 632 | } |
626 | } | 633 | } |
627 | void KOViewManager::showMonthViewWeek() | 634 | void KOViewManager::showMonthViewWeek() |
628 | { | 635 | { |
629 | createMonthView(); | 636 | createMonthView(); |
630 | globalFlagBlockAgenda = 1; | 637 | globalFlagBlockAgenda = 1; |
631 | bool full = true; | 638 | bool full = true; |
632 | if ( mCurrentView == mMonthView) | 639 | if ( mCurrentView == mMonthView) |
633 | full = mMainView->leftFrame()->isVisible(); | 640 | full = mMainView->leftFrame()->isVisible(); |
634 | if ( !KOPrefs::instance()->mMonthViewWeek ) { | 641 | if ( !KOPrefs::instance()->mMonthViewWeek ) { |
635 | mMonthView->switchView(); | 642 | mMonthView->switchView(); |
636 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) | 643 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) |
637 | full = false; | 644 | full = false; |
638 | else | 645 | else |
639 | full = true; | 646 | full = true; |
640 | } | 647 | } |
641 | mMainView->dateNavigator()->selectWeek(); | 648 | mMainView->dateNavigator()->selectWeek(); |
642 | showView(mMonthView, full ); | 649 | showView(mMonthView, full ); |
643 | } | 650 | } |
644 | 651 | ||
645 | void KOViewManager::showMonth( const QDate & date ) | 652 | void KOViewManager::showMonth( const QDate & date ) |
646 | { | 653 | { |
647 | mMainView->dateNavigator()->blockSignals( true ); | 654 | mMainView->dateNavigator()->blockSignals( true ); |
648 | mMainView->dateNavigator()->selectDate( date ); | 655 | mMainView->dateNavigator()->selectDate( date ); |
649 | mMainView->dateNavigator()->blockSignals( false ); | 656 | mMainView->dateNavigator()->blockSignals( false ); |
650 | showMonthView(); | 657 | showMonthView(); |
651 | } | 658 | } |
652 | void KOViewManager::showMonthView() | 659 | void KOViewManager::showMonthView() |
653 | { | 660 | { |
654 | 661 | ||
655 | createMonthView(); | 662 | createMonthView(); |
656 | globalFlagBlockAgenda = 1; | 663 | globalFlagBlockAgenda = 1; |
657 | //mFlagShowNextxDays = false; | 664 | //mFlagShowNextxDays = false; |
658 | bool full = true; | 665 | bool full = true; |
659 | if ( mCurrentView == mMonthView) | 666 | if ( mCurrentView == mMonthView) |
660 | full = mMainView->leftFrame()->isVisible(); | 667 | full = mMainView->leftFrame()->isVisible(); |
661 | // if(mMonthView == mCurrentView) return; | 668 | // if(mMonthView == mCurrentView) return; |
662 | if ( KOPrefs::instance()->mMonthViewWeek ) { | 669 | if ( KOPrefs::instance()->mMonthViewWeek ) { |
663 | mMonthView->switchView(); | 670 | mMonthView->switchView(); |
664 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) | 671 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) |
665 | full = false; | 672 | full = false; |
666 | else | 673 | else |
667 | full = true; | 674 | full = true; |
668 | } | 675 | } |
669 | mMainView->dateNavigator()->selectMonth(); | 676 | mMainView->dateNavigator()->selectMonth(); |
670 | 677 | ||
671 | showView(mMonthView, full ); | 678 | showView(mMonthView, full ); |
672 | 679 | ||
673 | } | 680 | } |
674 | 681 | ||
675 | void KOViewManager::showTodoView() | 682 | void KOViewManager::showTodoView() |
676 | { | 683 | { |
677 | //mFlagShowNextxDays = false; | 684 | //mFlagShowNextxDays = false; |
678 | if ( !mTodoView ) { | 685 | if ( !mTodoView ) { |
679 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 686 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
680 | "KOViewManager::TodoView" ); | 687 | "KOViewManager::TodoView" ); |
681 | 688 | ||
682 | addView( mTodoView ); | 689 | addView( mTodoView ); |
683 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 690 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
684 | 691 | ||
685 | // SIGNALS/SLOTS FOR TODO VIEW | 692 | // SIGNALS/SLOTS FOR TODO VIEW |
686 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 693 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
687 | mMainView, SLOT( newTodo() ) ); | 694 | mMainView, SLOT( newTodo() ) ); |
688 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 695 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
689 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 696 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
690 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 697 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
691 | mMainView, SLOT( showTodo( Todo * ) ) ); | 698 | mMainView, SLOT( showTodo( Todo * ) ) ); |
692 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 699 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
693 | mMainView, SLOT( editTodo( Todo * ) ) ); | 700 | mMainView, SLOT( editTodo( Todo * ) ) ); |
694 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 701 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
695 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 702 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
696 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 703 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
697 | mMainView, SLOT( purgeCompleted() ) ); | 704 | mMainView, SLOT( purgeCompleted() ) ); |
698 | 705 | ||
699 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 706 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
700 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 707 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
701 | 708 | ||
702 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 709 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
703 | SLOT( updateConfig() ) ); | 710 | SLOT( updateConfig() ) ); |
704 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 711 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
705 | SLOT( updateTodo( Todo *, int ) ) ); | 712 | SLOT( updateTodo( Todo *, int ) ) ); |
706 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 713 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
707 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 714 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
708 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 715 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
709 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 716 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
710 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 717 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
711 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 718 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
712 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 719 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
713 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 720 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
714 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 721 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
715 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 722 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
716 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 723 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
717 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 724 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
718 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 725 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
719 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 726 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
720 | KConfig *config = KOGlobals::config(); | 727 | KConfig *config = KOGlobals::config(); |
721 | mTodoView->restoreLayout(config,"Todo View"); | 728 | mTodoView->restoreLayout(config,"Todo View"); |
722 | mTodoView->setNavigator( mMainView->dateNavigator() ); | 729 | mTodoView->setNavigator( mMainView->dateNavigator() ); |
723 | } | 730 | } |
724 | 731 | ||
725 | globalFlagBlockAgenda = 1; | 732 | globalFlagBlockAgenda = 1; |
726 | showView( mTodoView, true ); | 733 | showView( mTodoView, true ); |
727 | 734 | ||
728 | } | 735 | } |
729 | 736 | ||
730 | void KOViewManager::showJournalView() | 737 | void KOViewManager::showJournalView() |
731 | { | 738 | { |
732 | //mFlagShowNextxDays = false; | 739 | //mFlagShowNextxDays = false; |
733 | if (!mJournalView) { | 740 | if (!mJournalView) { |
734 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 741 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
735 | "KOViewManager::JournalView"); | 742 | "KOViewManager::JournalView"); |
736 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 743 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
737 | SLOT( updateConfig() ) ); | 744 | SLOT( updateConfig() ) ); |
738 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 745 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
739 | addView(mJournalView); | 746 | addView(mJournalView); |
740 | } | 747 | } |
741 | 748 | ||
742 | showView(mJournalView); | 749 | showView(mJournalView); |
743 | mMainView->dateNavigator()->selectDates( 1 ); | 750 | mMainView->dateNavigator()->selectDates( 1 ); |
744 | } | 751 | } |
745 | 752 | ||
746 | void KOViewManager::showTimeSpanView() | 753 | void KOViewManager::showTimeSpanView() |
747 | { | 754 | { |
748 | //mFlagShowNextxDays = false; | 755 | //mFlagShowNextxDays = false; |
749 | if (!mTimeSpanView) { | 756 | if (!mTimeSpanView) { |
750 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 757 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
751 | "KOViewManager::TimeSpanView"); | 758 | "KOViewManager::TimeSpanView"); |
752 | addView(mTimeSpanView); | 759 | addView(mTimeSpanView); |
753 | 760 | ||
754 | mTimeSpanView->readSettings(); | 761 | mTimeSpanView->readSettings(); |
755 | } | 762 | } |
756 | 763 | ||
757 | showView(mTimeSpanView); | 764 | showView(mTimeSpanView); |
758 | } | 765 | } |
759 | 766 | ||
760 | Incidence *KOViewManager::currentSelection() | 767 | Incidence *KOViewManager::currentSelection() |
761 | { | 768 | { |
762 | if (!mCurrentView) return 0; | 769 | if (!mCurrentView) return 0; |
763 | if ( mCurrentView == mListView ) { | 770 | if ( mCurrentView == mListView ) { |
764 | if ( mListView->currentItem() ) | 771 | if ( mListView->currentItem() ) |
765 | return mListView->currentItem(); | 772 | return mListView->currentItem(); |
766 | } | 773 | } |
767 | return mCurrentView->selectedIncidences().first(); | 774 | return mCurrentView->selectedIncidences().first(); |
768 | } | 775 | } |
769 | 776 | ||
770 | QDate KOViewManager::currentSelectionDate() | 777 | QDate KOViewManager::currentSelectionDate() |
771 | { | 778 | { |
772 | QDate qd; | 779 | QDate qd; |
773 | if (mCurrentView) { | 780 | if (mCurrentView) { |
774 | DateList qvl = mCurrentView->selectedDates(); | 781 | DateList qvl = mCurrentView->selectedDates(); |
775 | if (!qvl.isEmpty()) qd = qvl.first(); | 782 | if (!qvl.isEmpty()) qd = qvl.first(); |
776 | } | 783 | } |
777 | return qd; | 784 | return qd; |
778 | } | 785 | } |
779 | 786 | ||
780 | void KOViewManager::addView(KOrg::BaseView *view) | 787 | void KOViewManager::addView(KOrg::BaseView *view) |
781 | { | 788 | { |
782 | #if QT_VERSION >= 0x030000 | 789 | #if QT_VERSION >= 0x030000 |
783 | mMainView->viewStack()->addWidget( view ); | 790 | mMainView->viewStack()->addWidget( view ); |
784 | #else | 791 | #else |
785 | mMainView->viewStack()->addWidget( view, 1 ); | 792 | mMainView->viewStack()->addWidget( view, 1 ); |
786 | #endif | 793 | #endif |
787 | } | 794 | } |
788 | 795 | ||
789 | void KOViewManager::setDocumentId( const QString &id ) | 796 | void KOViewManager::setDocumentId( const QString &id ) |
790 | { | 797 | { |
791 | if (mTodoView) mTodoView->setDocumentId( id ); | 798 | if (mTodoView) mTodoView->setDocumentId( id ); |
792 | } | 799 | } |
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index d829f14..1d565a6 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h | |||
@@ -1,122 +1,123 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 | 3 | Copyright (c) 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef KOVIEWMANAGER_H | 24 | #ifndef KOVIEWMANAGER_H |
25 | #define KOVIEWMANAGER_H | 25 | #define KOVIEWMANAGER_H |
26 | 26 | ||
27 | #include <qobject.h> | 27 | #include <qobject.h> |
28 | 28 | ||
29 | #include <korganizer/baseview.h> | 29 | #include <korganizer/baseview.h> |
30 | 30 | ||
31 | class CalendarView; | 31 | class CalendarView; |
32 | 32 | ||
33 | class KOListView; | 33 | class KOListView; |
34 | class KOAgendaView; | 34 | class KOAgendaView; |
35 | class KOMonthView; | 35 | class KOMonthView; |
36 | class KOTimeSpanView; | 36 | class KOTimeSpanView; |
37 | class KOTodoView; | 37 | class KOTodoView; |
38 | class KOWhatsNextView; | 38 | class KOWhatsNextView; |
39 | class KOJournalView; | 39 | class KOJournalView; |
40 | 40 | ||
41 | using namespace KCal; | 41 | using namespace KCal; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | This class manages the views of the calendar. It owns the objects and handles | 44 | This class manages the views of the calendar. It owns the objects and handles |
45 | creation and selection. | 45 | creation and selection. |
46 | */ | 46 | */ |
47 | class KOViewManager : public QObject | 47 | class KOViewManager : public QObject |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | KOViewManager( CalendarView * ); | 51 | KOViewManager( CalendarView * ); |
52 | virtual ~KOViewManager(); | 52 | virtual ~KOViewManager(); |
53 | 53 | ||
54 | /** changes the view to be the currently selected view */ | 54 | /** changes the view to be the currently selected view */ |
55 | void showView(KOrg::BaseView *, bool fullScreen = false ); | 55 | void showView(KOrg::BaseView *, bool fullScreen = false ); |
56 | void updateWNview(); | 56 | void updateWNview(); |
57 | void readSettings(KConfig *config); | 57 | void readSettings(KConfig *config); |
58 | void writeSettings(KConfig *config); | 58 | void writeSettings(KConfig *config); |
59 | bool showsNextDays(); | 59 | bool showsNextDays(); |
60 | /** Read which view was shown last from config file */ | 60 | /** Read which view was shown last from config file */ |
61 | void readCurrentView(KConfig *); | 61 | void readCurrentView(KConfig *); |
62 | /** Write which view is currently shown to config file */ | 62 | /** Write which view is currently shown to config file */ |
63 | void writeCurrentView(KConfig *); | 63 | void writeCurrentView(KConfig *); |
64 | 64 | ||
65 | KOrg::BaseView *currentView(); | 65 | KOrg::BaseView *currentView(); |
66 | 66 | ||
67 | void setDocumentId( const QString & ); | 67 | void setDocumentId( const QString & ); |
68 | 68 | ||
69 | void updateView( const QDate &start, const QDate &end ); | 69 | void updateView( const QDate &start, const QDate &end ); |
70 | 70 | ||
71 | void raiseCurrentView( bool fullScreen = false , bool updateView = false); | 71 | void raiseCurrentView( bool fullScreen = false , bool updateView = false); |
72 | 72 | ||
73 | void addView(KOrg::BaseView *); | 73 | void addView(KOrg::BaseView *); |
74 | 74 | ||
75 | Incidence *currentSelection(); | 75 | Incidence *currentSelection(); |
76 | QDate currentSelectionDate(); | 76 | QDate currentSelectionDate(); |
77 | 77 | ||
78 | KOAgendaView *agendaView() const { return mAgendaView; } | 78 | KOAgendaView *agendaView() const { return mAgendaView; } |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void printWNV(); | 81 | void printWNV(); |
82 | void signalFullScreen( bool ); | 82 | void signalFullScreen( bool ); |
83 | void signalAgendaView( bool ); | 83 | void signalAgendaView( bool ); |
84 | public slots: | 84 | public slots: |
85 | void slotprintWNV(); | ||
85 | void showNextView(); | 86 | void showNextView(); |
86 | void showMonth( const QDate & ); | 87 | void showMonth( const QDate & ); |
87 | void showDateView( int, QDate ); | 88 | void showDateView( int, QDate ); |
88 | void updateView(); | 89 | void updateView(); |
89 | void showWhatsNextView(); | 90 | void showWhatsNextView(); |
90 | void showListView(); | 91 | void showListView(); |
91 | void showAgendaView( bool fullScreen = false ); | 92 | void showAgendaView( bool fullScreen = false ); |
92 | void showDayView(); | 93 | void showDayView(); |
93 | void showWorkWeekView(); | 94 | void showWorkWeekView(); |
94 | void showWeekView(); | 95 | void showWeekView(); |
95 | void showNextXView(); | 96 | void showNextXView(); |
96 | void showMonthView(); | 97 | void showMonthView(); |
97 | void showMonthViewWeek(); | 98 | void showMonthViewWeek(); |
98 | void showTodoView(); | 99 | void showTodoView(); |
99 | void showJournalView(); | 100 | void showJournalView(); |
100 | void showTimeSpanView(); | 101 | void showTimeSpanView(); |
101 | 102 | ||
102 | private: | 103 | private: |
103 | void createMonthView(); | 104 | void createMonthView(); |
104 | CalendarView *mMainView; | 105 | CalendarView *mMainView; |
105 | 106 | ||
106 | int mCurrentAgendaView; | 107 | int mCurrentAgendaView; |
107 | KOAgendaView *mAgendaView; | 108 | KOAgendaView *mAgendaView; |
108 | KOListView *mListView; | 109 | KOListView *mListView; |
109 | KOMonthView *mMonthView; | 110 | KOMonthView *mMonthView; |
110 | KOTodoView *mTodoView; | 111 | KOTodoView *mTodoView; |
111 | KOWhatsNextView *mWhatsNextView; | 112 | KOWhatsNextView *mWhatsNextView; |
112 | KOJournalView *mJournalView; | 113 | KOJournalView *mJournalView; |
113 | KOTimeSpanView *mTimeSpanView; | 114 | KOTimeSpanView *mTimeSpanView; |
114 | 115 | ||
115 | KOrg::BaseView *mCurrentView; // currently active event view | 116 | KOrg::BaseView *mCurrentView; // currently active event view |
116 | 117 | ||
117 | int mAgendaViewMode; | 118 | int mAgendaViewMode; |
118 | bool mFlagShowNextxDays; | 119 | bool mFlagShowNextxDays; |
119 | 120 | ||
120 | }; | 121 | }; |
121 | 122 | ||
122 | #endif | 123 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index a4e0834..ad1c0cd 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2302 +1,2314 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "ktoolbar.h" | 60 | #include "ktoolbar.h" |
61 | #include "klocale.h" | 61 | #include "klocale.h" |
62 | #include "kconfig.h" | 62 | #include "kconfig.h" |
63 | #include "simplealarmclient.h" | 63 | #include "simplealarmclient.h" |
64 | #include "externalapphandler.h" | 64 | #include "externalapphandler.h" |
65 | 65 | ||
66 | using namespace KCal; | 66 | using namespace KCal; |
67 | #ifndef _WIN32_ | 67 | #ifndef _WIN32_ |
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | #else | 69 | #else |
70 | #ifdef _OL_IMPORT_ | 70 | #ifdef _OL_IMPORT_ |
71 | #include "koimportoldialog.h" | 71 | #include "koimportoldialog.h" |
72 | #endif | 72 | #endif |
73 | #endif | 73 | #endif |
74 | #include "mainwindow.h" | 74 | #include "mainwindow.h" |
75 | 75 | ||
76 | 76 | ||
77 | class KOex2phonePrefs : public QDialog | 77 | class KOex2phonePrefs : public QDialog |
78 | { | 78 | { |
79 | public: | 79 | public: |
80 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 80 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
81 | QDialog( parent, name, true ) | 81 | QDialog( parent, name, true ) |
82 | { | 82 | { |
83 | setCaption( i18n("Export to phone options") ); | 83 | setCaption( i18n("Export to phone options") ); |
84 | QVBoxLayout* lay = new QVBoxLayout( this ); | 84 | QVBoxLayout* lay = new QVBoxLayout( this ); |
85 | lay->setSpacing( 3 ); | 85 | lay->setSpacing( 3 ); |
86 | lay->setMargin( 3 ); | 86 | lay->setMargin( 3 ); |
87 | QLabel *lab; | 87 | QLabel *lab; |
88 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 88 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
89 | lab->setAlignment (AlignHCenter ); | 89 | lab->setAlignment (AlignHCenter ); |
90 | QHBox* temphb; | 90 | QHBox* temphb; |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("I/O device: "), temphb ); | 92 | new QLabel( i18n("I/O device: "), temphb ); |
93 | mPhoneDevice = new QLineEdit( temphb); | 93 | mPhoneDevice = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Connection: "), temphb ); | 96 | new QLabel( i18n("Connection: "), temphb ); |
97 | mPhoneConnection = new QLineEdit( temphb); | 97 | mPhoneConnection = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | temphb = new QHBox( this ); | 99 | temphb = new QHBox( this ); |
100 | new QLabel( i18n("Model(opt.): "), temphb ); | 100 | new QLabel( i18n("Model(opt.): "), temphb ); |
101 | mPhoneModel = new QLineEdit( temphb); | 101 | mPhoneModel = new QLineEdit( temphb); |
102 | lay->addWidget( temphb ); | 102 | lay->addWidget( temphb ); |
103 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 103 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
104 | mWriteBackFuture->setChecked( true ); | 104 | mWriteBackFuture->setChecked( true ); |
105 | lay->addWidget( mWriteBackFuture ); | 105 | lay->addWidget( mWriteBackFuture ); |
106 | temphb = new QHBox( this ); | 106 | temphb = new QHBox( this ); |
107 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 107 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
108 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 108 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
109 | mWriteBackFutureWeeks->setValue( 8 ); | 109 | mWriteBackFutureWeeks->setValue( 8 ); |
110 | lay->addWidget( temphb ); | 110 | lay->addWidget( temphb ); |
111 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 111 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
112 | lab->setAlignment (AlignHCenter ); | 112 | lab->setAlignment (AlignHCenter ); |
113 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 113 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
114 | lay->addWidget( ok ); | 114 | lay->addWidget( ok ); |
115 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 115 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
116 | lay->addWidget( cancel ); | 116 | lay->addWidget( cancel ); |
117 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 117 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
118 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 118 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
119 | resize( 220, 240 ); | 119 | resize( 220, 240 ); |
120 | qApp->processEvents(); | 120 | qApp->processEvents(); |
121 | int dw = QApplication::desktop()->width(); | 121 | int dw = QApplication::desktop()->width(); |
122 | int dh = QApplication::desktop()->height(); | 122 | int dh = QApplication::desktop()->height(); |
123 | move( (dw-width())/2, (dh - height() )/2 ); | 123 | move( (dw-width())/2, (dh - height() )/2 ); |
124 | } | 124 | } |
125 | 125 | ||
126 | public: | 126 | public: |
127 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 127 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
128 | QCheckBox* mWriteBackFuture; | 128 | QCheckBox* mWriteBackFuture; |
129 | QSpinBox* mWriteBackFutureWeeks; | 129 | QSpinBox* mWriteBackFutureWeeks; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | int globalFlagBlockStartup; | 132 | int globalFlagBlockStartup; |
133 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 133 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
134 | QMainWindow( parent, name ) | 134 | QMainWindow( parent, name ) |
135 | { | 135 | { |
136 | 136 | ||
137 | mClosed = false; | 137 | mClosed = false; |
138 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 138 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
139 | QString confFile = locateLocal("config","korganizerrc"); | 139 | QString confFile = locateLocal("config","korganizerrc"); |
140 | QFileInfo finf ( confFile ); | 140 | QFileInfo finf ( confFile ); |
141 | bool showWarning = !finf.exists(); | 141 | bool showWarning = !finf.exists(); |
142 | setIcon(SmallIcon( "ko24" ) ); | 142 | setIcon(SmallIcon( "ko24" ) ); |
143 | mBlockAtStartup = true; | 143 | mBlockAtStartup = true; |
144 | mFlagKeyPressed = false; | 144 | mFlagKeyPressed = false; |
145 | setCaption("KO/Pi"); | 145 | setCaption("KO/Pi"); |
146 | KOPrefs *p = KOPrefs::instance(); | 146 | KOPrefs *p = KOPrefs::instance(); |
147 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 147 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
148 | if ( p->mHourSize > 22 ) | 148 | if ( p->mHourSize > 22 ) |
149 | p->mHourSize = 22; | 149 | p->mHourSize = 22; |
150 | QMainWindow::ToolBarDock tbd; | 150 | QMainWindow::ToolBarDock tbd; |
151 | if ( p->mToolBarHor ) { | 151 | if ( p->mToolBarHor ) { |
152 | if ( p->mToolBarUp ) | 152 | if ( p->mToolBarUp ) |
153 | tbd = Bottom; | 153 | tbd = Bottom; |
154 | else | 154 | else |
155 | tbd = Top; | 155 | tbd = Top; |
156 | } | 156 | } |
157 | else { | 157 | else { |
158 | if ( p->mToolBarUp ) | 158 | if ( p->mToolBarUp ) |
159 | tbd = Right; | 159 | tbd = Right; |
160 | else | 160 | else |
161 | tbd = Left; | 161 | tbd = Left; |
162 | } | 162 | } |
163 | if ( KOPrefs::instance()->mUseAppColors ) | 163 | if ( KOPrefs::instance()->mUseAppColors ) |
164 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 164 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
165 | globalFlagBlockStartup = 1; | 165 | globalFlagBlockStartup = 1; |
166 | iconToolBar = new QPEToolBar( this ); | 166 | iconToolBar = new QPEToolBar( this ); |
167 | addToolBar (iconToolBar , tbd ); | 167 | addToolBar (iconToolBar , tbd ); |
168 | 168 | ||
169 | if ( KOPrefs::instance()->mShowIconFilter ) { | 169 | if ( KOPrefs::instance()->mShowIconFilter ) { |
170 | if ( p->mToolBarHorF ) { | 170 | if ( p->mToolBarHorF ) { |
171 | if ( p->mToolBarUpF ) | 171 | if ( p->mToolBarUpF ) |
172 | tbd = Bottom; | 172 | tbd = Bottom; |
173 | else | 173 | else |
174 | tbd = Top; | 174 | tbd = Top; |
175 | } | 175 | } |
176 | else { | 176 | else { |
177 | if ( p->mToolBarUpF ) | 177 | if ( p->mToolBarUpF ) |
178 | tbd = Right; | 178 | tbd = Right; |
179 | else | 179 | else |
180 | tbd = Left; | 180 | tbd = Left; |
181 | } | 181 | } |
182 | filterToolBar = new QPEToolBar ( this ); | 182 | filterToolBar = new QPEToolBar ( this ); |
183 | filterMenubar = new QPEMenuBar( filterToolBar ); | 183 | filterMenubar = new QPEMenuBar( filterToolBar ); |
184 | QFontMetrics fm ( filterMenubar->font() ); | 184 | QFontMetrics fm ( filterMenubar->font() ); |
185 | 185 | ||
186 | filterPopupMenu = new QPopupMenu( this ); | 186 | filterPopupMenu = new QPopupMenu( this ); |
187 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 187 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
188 | filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+"Ax" ) ); | 188 | QString addTest = "Ax"; |
189 | #ifdef DESKTOP_VERSION | ||
190 | addTest = "AAAx"; | ||
191 | #endif | ||
192 | filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); | ||
189 | addToolBar (filterToolBar , tbd ); | 193 | addToolBar (filterToolBar , tbd ); |
190 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 194 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
191 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 195 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
192 | } else { | 196 | } else { |
193 | filterToolBar = 0; | 197 | filterToolBar = 0; |
194 | filterMenubar = 0; | 198 | filterMenubar = 0; |
195 | filterPopupMenu = 0; | 199 | filterPopupMenu = 0; |
196 | } | 200 | } |
197 | if ( p->mShowIconOnetoolbar ) { | 201 | if ( p->mShowIconOnetoolbar ) { |
198 | viewToolBar = iconToolBar ; | 202 | viewToolBar = iconToolBar ; |
199 | navigatorToolBar = iconToolBar ; | 203 | navigatorToolBar = iconToolBar ; |
200 | } else { | 204 | } else { |
201 | if ( p->mToolBarHorV ) { | 205 | if ( p->mToolBarHorV ) { |
202 | if ( p->mToolBarUpV ) | 206 | if ( p->mToolBarUpV ) |
203 | tbd = Bottom; | 207 | tbd = Bottom; |
204 | else | 208 | else |
205 | tbd = Top; | 209 | tbd = Top; |
206 | } | 210 | } |
207 | else { | 211 | else { |
208 | if ( p->mToolBarUpV ) | 212 | if ( p->mToolBarUpV ) |
209 | tbd = Right; | 213 | tbd = Right; |
210 | else | 214 | else |
211 | tbd = Left; | 215 | tbd = Left; |
212 | } | 216 | } |
213 | viewToolBar = new QPEToolBar( this ); | 217 | viewToolBar = new QPEToolBar( this ); |
214 | addToolBar (viewToolBar , tbd ); | 218 | addToolBar (viewToolBar , tbd ); |
215 | if ( p->mToolBarHorN ) { | 219 | if ( p->mToolBarHorN ) { |
216 | if ( p->mToolBarUpN ) | 220 | if ( p->mToolBarUpN ) |
217 | tbd = Bottom; | 221 | tbd = Bottom; |
218 | else | 222 | else |
219 | tbd = Top; | 223 | tbd = Top; |
220 | } | 224 | } |
221 | else { | 225 | else { |
222 | if ( p->mToolBarUpN ) | 226 | if ( p->mToolBarUpN ) |
223 | tbd = Right; | 227 | tbd = Right; |
224 | else | 228 | else |
225 | tbd = Left; | 229 | tbd = Left; |
226 | } | 230 | } |
227 | navigatorToolBar = new QPEToolBar( this ); | 231 | navigatorToolBar = new QPEToolBar( this ); |
228 | addToolBar (navigatorToolBar , tbd ); | 232 | addToolBar (navigatorToolBar , tbd ); |
229 | } | 233 | } |
230 | 234 | ||
231 | 235 | ||
232 | 236 | ||
233 | mCalendarModifiedFlag = false; | 237 | mCalendarModifiedFlag = false; |
234 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 238 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
235 | splash->setAlignment ( AlignCenter ); | 239 | splash->setAlignment ( AlignCenter ); |
236 | setCentralWidget( splash ); | 240 | setCentralWidget( splash ); |
237 | #ifndef DESKTOP_VERSION | 241 | #ifndef DESKTOP_VERSION |
238 | showMaximized(); | 242 | showMaximized(); |
239 | #endif | 243 | #endif |
240 | 244 | ||
241 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 245 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
242 | setDefaultPreferences(); | 246 | setDefaultPreferences(); |
243 | mCalendar = new CalendarLocal(); | 247 | mCalendar = new CalendarLocal(); |
244 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 248 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
245 | mView->hide(); | 249 | mView->hide(); |
246 | //mView->resize(splash->size() ); | 250 | //mView->resize(splash->size() ); |
247 | initActions(); | 251 | initActions(); |
248 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 252 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
249 | mSyncManager->setBlockSave(false); | 253 | mSyncManager->setBlockSave(false); |
250 | mView->setSyncManager(mSyncManager); | 254 | mView->setSyncManager(mSyncManager); |
251 | #ifndef DESKTOP_VERSION | 255 | #ifndef DESKTOP_VERSION |
252 | iconToolBar->show(); | 256 | iconToolBar->show(); |
253 | qApp->processEvents(); | 257 | qApp->processEvents(); |
254 | #endif | 258 | #endif |
255 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 259 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
256 | int vh = height() ; | 260 | int vh = height() ; |
257 | int vw = width(); | 261 | int vw = width(); |
258 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 262 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
259 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 263 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
260 | vh -= iconToolBar->height(); | 264 | vh -= iconToolBar->height(); |
261 | } else { | 265 | } else { |
262 | vw -= iconToolBar->height(); | 266 | vw -= iconToolBar->height(); |
263 | } | 267 | } |
264 | //mView->setMaximumSize( splash->size() ); | 268 | //mView->setMaximumSize( splash->size() ); |
265 | //mView->resize( splash->size() ); | 269 | //mView->resize( splash->size() ); |
266 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 270 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
267 | mView->readSettings(); | 271 | mView->readSettings(); |
268 | bool newFile = false; | 272 | bool newFile = false; |
269 | if( !QFile::exists( defaultFileName() ) ) { | 273 | if( !QFile::exists( defaultFileName() ) ) { |
270 | QFileInfo finfo ( defaultFileName() ); | 274 | QFileInfo finfo ( defaultFileName() ); |
271 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 275 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
272 | qDebug("oldfile %s ", oldFile.latin1()); | 276 | qDebug("oldfile %s ", oldFile.latin1()); |
273 | 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"; | 277 | 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"; |
274 | finfo.setFile( oldFile ); | 278 | finfo.setFile( oldFile ); |
275 | if (finfo.exists() ) { | 279 | if (finfo.exists() ) { |
276 | KMessageBox::information( this, message); | 280 | KMessageBox::information( this, message); |
277 | mView->openCalendar( oldFile ); | 281 | mView->openCalendar( oldFile ); |
278 | qApp->processEvents(); | 282 | qApp->processEvents(); |
279 | } else { | 283 | } else { |
280 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 284 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
281 | finfo.setFile( oldFile ); | 285 | finfo.setFile( oldFile ); |
282 | if (finfo.exists() ) { | 286 | if (finfo.exists() ) { |
283 | KMessageBox::information( this, message); | 287 | KMessageBox::information( this, message); |
284 | mView->openCalendar( oldFile ); | 288 | mView->openCalendar( oldFile ); |
285 | qApp->processEvents(); | 289 | qApp->processEvents(); |
286 | } | 290 | } |
287 | } | 291 | } |
288 | mView->saveCalendar( defaultFileName() ); | 292 | mView->saveCalendar( defaultFileName() ); |
289 | newFile = true; | 293 | newFile = true; |
290 | } | 294 | } |
291 | 295 | ||
292 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 296 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
293 | mView->openCalendar( defaultFileName() ); | 297 | mView->openCalendar( defaultFileName() ); |
294 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 298 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
295 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 299 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
296 | 300 | ||
297 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 301 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
298 | KOPrefs::instance()->setAllDefaults(); | 302 | KOPrefs::instance()->setAllDefaults(); |
299 | int count = mView->addCategories(); | 303 | int count = mView->addCategories(); |
300 | } | 304 | } |
301 | processIncidenceSelection( 0 ); | 305 | processIncidenceSelection( 0 ); |
302 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 306 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
303 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 307 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
304 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 308 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
305 | SLOT( slotModifiedChanged( bool ) ) ); | 309 | SLOT( slotModifiedChanged( bool ) ) ); |
306 | 310 | ||
307 | 311 | ||
308 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 312 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
309 | SLOT( disableBR(bool) ) ); | 313 | SLOT( disableBR(bool) ) ); |
310 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 314 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
311 | mView->setModified( false ); | 315 | mView->setModified( false ); |
312 | mBlockAtStartup = false; | 316 | mBlockAtStartup = false; |
313 | mView->setModified( false ); | 317 | mView->setModified( false ); |
314 | setCentralWidget( mView ); | 318 | setCentralWidget( mView ); |
315 | globalFlagBlockStartup = 0; | 319 | globalFlagBlockStartup = 0; |
316 | mView->show(); | 320 | mView->show(); |
317 | delete splash; | 321 | delete splash; |
318 | if ( newFile ) | 322 | if ( newFile ) |
319 | mView->updateConfig(); | 323 | mView->updateConfig(); |
320 | // qApp->processEvents(); | 324 | // qApp->processEvents(); |
321 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 325 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
322 | //fillSyncMenu(); | 326 | //fillSyncMenu(); |
323 | 327 | ||
324 | 328 | ||
325 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 329 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
326 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 330 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
327 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 331 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
328 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 332 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
329 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 333 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
330 | mSyncManager->setDefaultFileName( sentSyncFile()); | 334 | mSyncManager->setDefaultFileName( sentSyncFile()); |
331 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 335 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
332 | mSyncManager->fillSyncMenu(); | 336 | mSyncManager->fillSyncMenu(); |
333 | 337 | ||
334 | 338 | ||
335 | 339 | ||
336 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 340 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
337 | if ( showWarning ) { | 341 | if ( showWarning ) { |
338 | KMessageBox::information( this, | 342 | KMessageBox::information( this, |
339 | "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"); | 343 | "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"); |
340 | qApp->processEvents(); | 344 | qApp->processEvents(); |
341 | mView->dialogManager()->showSyncOptions(); | 345 | mView->dialogManager()->showSyncOptions(); |
342 | } | 346 | } |
343 | 347 | ||
344 | //US listen for result adressed from Ka/Pi | 348 | //US listen for result adressed from Ka/Pi |
345 | #ifndef DESKTOP_VERSION | 349 | #ifndef DESKTOP_VERSION |
346 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 350 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
347 | #endif | 351 | #endif |
348 | #ifndef DESKTOP_VERSION | 352 | #ifndef DESKTOP_VERSION |
349 | infrared = 0; | 353 | infrared = 0; |
350 | #endif | 354 | #endif |
355 | updateFilterToolbar(); | ||
351 | updateWeek( mView->startDate() ); | 356 | updateWeek( mView->startDate() ); |
352 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 357 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
353 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 358 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
354 | mBRdisabled = false; | 359 | mBRdisabled = false; |
355 | //toggleBeamReceive(); | 360 | //toggleBeamReceive(); |
356 | } | 361 | } |
357 | MainWindow::~MainWindow() | 362 | MainWindow::~MainWindow() |
358 | { | 363 | { |
359 | //qDebug("MainWindow::~MainWindow() "); | 364 | //qDebug("MainWindow::~MainWindow() "); |
360 | //save toolbar location | 365 | //save toolbar location |
361 | delete mCalendar; | 366 | delete mCalendar; |
362 | delete mSyncManager; | 367 | delete mSyncManager; |
363 | #ifndef DESKTOP_VERSION | 368 | #ifndef DESKTOP_VERSION |
364 | if ( infrared ) | 369 | if ( infrared ) |
365 | delete infrared; | 370 | delete infrared; |
366 | #endif | 371 | #endif |
367 | 372 | ||
368 | 373 | ||
369 | } | 374 | } |
370 | 375 | ||
371 | void MainWindow::disableBR(bool b) | 376 | void MainWindow::disableBR(bool b) |
372 | { | 377 | { |
373 | #ifndef DESKTOP_VERSION | 378 | #ifndef DESKTOP_VERSION |
374 | if ( b ) { | 379 | if ( b ) { |
375 | if ( infrared ) { | 380 | if ( infrared ) { |
376 | toggleBeamReceive(); | 381 | toggleBeamReceive(); |
377 | mBRdisabled = true; | 382 | mBRdisabled = true; |
378 | } | 383 | } |
379 | mBRdisabled = true; | 384 | mBRdisabled = true; |
380 | } else { | 385 | } else { |
381 | if ( mBRdisabled ) { | 386 | if ( mBRdisabled ) { |
382 | mBRdisabled = false; | 387 | mBRdisabled = false; |
383 | //makes no sense,because other cal ap is probably running | 388 | //makes no sense,because other cal ap is probably running |
384 | // toggleBeamReceive(); | 389 | // toggleBeamReceive(); |
385 | } | 390 | } |
386 | } | 391 | } |
387 | #endif | 392 | #endif |
388 | 393 | ||
389 | } | 394 | } |
390 | bool MainWindow::beamReceiveEnabled() | 395 | bool MainWindow::beamReceiveEnabled() |
391 | { | 396 | { |
392 | #ifndef DESKTOP_VERSION | 397 | #ifndef DESKTOP_VERSION |
393 | return ( infrared != 0 ); | 398 | return ( infrared != 0 ); |
394 | #endif | 399 | #endif |
395 | return false; | 400 | return false; |
396 | } | 401 | } |
397 | 402 | ||
398 | void MainWindow::toggleBeamReceive() | 403 | void MainWindow::toggleBeamReceive() |
399 | { | 404 | { |
400 | if ( mBRdisabled ) | 405 | if ( mBRdisabled ) |
401 | return; | 406 | return; |
402 | #ifndef DESKTOP_VERSION | 407 | #ifndef DESKTOP_VERSION |
403 | if ( infrared ) { | 408 | if ( infrared ) { |
404 | qDebug("disable BeamReceive "); | 409 | qDebug("disable BeamReceive "); |
405 | delete infrared; | 410 | delete infrared; |
406 | infrared = 0; | 411 | infrared = 0; |
407 | brAction->setOn(false); | 412 | brAction->setOn(false); |
408 | return; | 413 | return; |
409 | } | 414 | } |
410 | qDebug("enable BeamReceive "); | 415 | qDebug("enable BeamReceive "); |
411 | brAction->setOn(true); | 416 | brAction->setOn(true); |
412 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 417 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
413 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 418 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
414 | #endif | 419 | #endif |
415 | } | 420 | } |
416 | void MainWindow::showMaximized () | 421 | void MainWindow::showMaximized () |
417 | { | 422 | { |
418 | #ifndef DESKTOP_VERSION | 423 | #ifndef DESKTOP_VERSION |
419 | if ( ! globalFlagBlockStartup ) | 424 | if ( ! globalFlagBlockStartup ) |
420 | if ( mClosed ) | 425 | if ( mClosed ) |
421 | mView->goToday(); | 426 | mView->goToday(); |
422 | #endif | 427 | #endif |
423 | QWidget::showMaximized () ; | 428 | QWidget::showMaximized () ; |
424 | mClosed = false; | 429 | mClosed = false; |
425 | } | 430 | } |
426 | void MainWindow::closeEvent( QCloseEvent* ce ) | 431 | void MainWindow::closeEvent( QCloseEvent* ce ) |
427 | { | 432 | { |
428 | 433 | ||
429 | 434 | ||
430 | 435 | ||
431 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 436 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
432 | saveOnClose(); | 437 | saveOnClose(); |
433 | mClosed = true; | 438 | mClosed = true; |
434 | ce->accept(); | 439 | ce->accept(); |
435 | return; | 440 | return; |
436 | 441 | ||
437 | } | 442 | } |
438 | 443 | ||
439 | switch( QMessageBox::information( this, "KO/Pi", | 444 | switch( QMessageBox::information( this, "KO/Pi", |
440 | i18n("Do you really want\nto close KO/Pi?"), | 445 | i18n("Do you really want\nto close KO/Pi?"), |
441 | i18n("Close"), i18n("No"), | 446 | i18n("Close"), i18n("No"), |
442 | 0, 0 ) ) { | 447 | 0, 0 ) ) { |
443 | case 0: | 448 | case 0: |
444 | saveOnClose(); | 449 | saveOnClose(); |
445 | mClosed = true; | 450 | mClosed = true; |
446 | ce->accept(); | 451 | ce->accept(); |
447 | break; | 452 | break; |
448 | case 1: | 453 | case 1: |
449 | ce->ignore(); | 454 | ce->ignore(); |
450 | break; | 455 | break; |
451 | case 2: | 456 | case 2: |
452 | 457 | ||
453 | default: | 458 | default: |
454 | break; | 459 | break; |
455 | } | 460 | } |
456 | 461 | ||
457 | 462 | ||
458 | } | 463 | } |
459 | 464 | ||
460 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 465 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
461 | { | 466 | { |
462 | QDataStream stream( data, IO_ReadOnly ); | 467 | QDataStream stream( data, IO_ReadOnly ); |
463 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 468 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
464 | //QString datamess; | 469 | //QString datamess; |
465 | //qDebug("message "); | 470 | //qDebug("message "); |
466 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 471 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
467 | 472 | ||
468 | if ( cmsg == "setDocument(QString)" ) { | 473 | if ( cmsg == "setDocument(QString)" ) { |
469 | QDataStream stream( data, IO_ReadOnly ); | 474 | QDataStream stream( data, IO_ReadOnly ); |
470 | QString fileName; | 475 | QString fileName; |
471 | stream >> fileName; | 476 | stream >> fileName; |
472 | //qDebug("filename %s ", fileName.latin1()); | 477 | //qDebug("filename %s ", fileName.latin1()); |
473 | showMaximized(); | 478 | showMaximized(); |
474 | raise(); | 479 | raise(); |
475 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 480 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
476 | mSyncManager->slotSyncMenu( 1002 ); | 481 | mSyncManager->slotSyncMenu( 1002 ); |
477 | return; | 482 | return; |
478 | } | 483 | } |
479 | 484 | ||
480 | if ( cmsg == "-writeFile" ) { | 485 | if ( cmsg == "-writeFile" ) { |
481 | // I made from the "-writeFile" an "-writeAlarm" | 486 | // I made from the "-writeFile" an "-writeAlarm" |
482 | mView->viewManager()->showWhatsNextView(); | 487 | mView->viewManager()->showWhatsNextView(); |
483 | mCalendar->checkAlarmForIncidence( 0, true); | 488 | mCalendar->checkAlarmForIncidence( 0, true); |
484 | showMaximized(); | 489 | showMaximized(); |
485 | raise(); | 490 | raise(); |
486 | return; | 491 | return; |
487 | 492 | ||
488 | } | 493 | } |
489 | if ( cmsg == "-writeFileSilent" ) { | 494 | if ( cmsg == "-writeFileSilent" ) { |
490 | // I made from the "-writeFile" an "-writeAlarm" | 495 | // I made from the "-writeFile" an "-writeAlarm" |
491 | // mView->viewManager()->showWhatsNextView(); | 496 | // mView->viewManager()->showWhatsNextView(); |
492 | mCalendar->checkAlarmForIncidence( 0, true); | 497 | mCalendar->checkAlarmForIncidence( 0, true); |
493 | //showMaximized(); | 498 | //showMaximized(); |
494 | //raise(); | 499 | //raise(); |
495 | hide(); | 500 | hide(); |
496 | return; | 501 | return; |
497 | } | 502 | } |
498 | if ( cmsg == "-newCountdown" ) { | 503 | if ( cmsg == "-newCountdown" ) { |
499 | qDebug("newCountdown "); | 504 | qDebug("newCountdown "); |
500 | 505 | ||
501 | } | 506 | } |
502 | QString msg ; | 507 | QString msg ; |
503 | QString allmsg = cmsg; | 508 | QString allmsg = cmsg; |
504 | while ( allmsg.length() > 0 ) { | 509 | while ( allmsg.length() > 0 ) { |
505 | int nextC = allmsg.find( "-", 1 ); | 510 | int nextC = allmsg.find( "-", 1 ); |
506 | if ( nextC == -1 ) { | 511 | if ( nextC == -1 ) { |
507 | msg = allmsg; | 512 | msg = allmsg; |
508 | allmsg = ""; | 513 | allmsg = ""; |
509 | } else{ | 514 | } else{ |
510 | msg = allmsg.left( nextC ); | 515 | msg = allmsg.left( nextC ); |
511 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 516 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
512 | } | 517 | } |
513 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 518 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
514 | if ( msg == "-newEvent" ) { | 519 | if ( msg == "-newEvent" ) { |
515 | mView->newEvent(); | 520 | mView->newEvent(); |
516 | } | 521 | } |
517 | if ( msg == "-newTodo" ) { | 522 | if ( msg == "-newTodo" ) { |
518 | mView->newTodo(); | 523 | mView->newTodo(); |
519 | 524 | ||
520 | } | 525 | } |
521 | if ( msg == "-showWN" ) { | 526 | if ( msg == "-showWN" ) { |
522 | mView->viewManager()->showWhatsNextView(); | 527 | mView->viewManager()->showWhatsNextView(); |
523 | } | 528 | } |
524 | if ( msg == "-showTodo" ) { | 529 | if ( msg == "-showTodo" ) { |
525 | mView->viewManager()->showTodoView(); | 530 | mView->viewManager()->showTodoView(); |
526 | } | 531 | } |
527 | if ( msg == "-showList" ) { | 532 | if ( msg == "-showList" ) { |
528 | mView->viewManager()->showListView(); | 533 | mView->viewManager()->showListView(); |
529 | } | 534 | } |
530 | else if ( msg == "-showDay" ) { | 535 | else if ( msg == "-showDay" ) { |
531 | mView->viewManager()->showDayView(); | 536 | mView->viewManager()->showDayView(); |
532 | } | 537 | } |
533 | else if ( msg == "-showWWeek" ) { | 538 | else if ( msg == "-showWWeek" ) { |
534 | mView->viewManager()->showWorkWeekView(); | 539 | mView->viewManager()->showWorkWeekView(); |
535 | } | 540 | } |
536 | else if ( msg == "-ringSync" ) { | 541 | else if ( msg == "-ringSync" ) { |
537 | mSyncManager->multiSync( false ); | 542 | mSyncManager->multiSync( false ); |
538 | } | 543 | } |
539 | else if ( msg == "-showWeek" ) { | 544 | else if ( msg == "-showWeek" ) { |
540 | mView->viewManager()->showWeekView(); | 545 | mView->viewManager()->showWeekView(); |
541 | } | 546 | } |
542 | else if ( msg == "-showTodo" ) { | 547 | else if ( msg == "-showTodo" ) { |
543 | mView->viewManager()->showTodoView(); | 548 | mView->viewManager()->showTodoView(); |
544 | } | 549 | } |
545 | else if ( msg == "-showJournal" ) { | 550 | else if ( msg == "-showJournal" ) { |
546 | mView->dateNavigator()->selectDates( 1 ); | 551 | mView->dateNavigator()->selectDates( 1 ); |
547 | mView->dateNavigator()->selectToday(); | 552 | mView->dateNavigator()->selectToday(); |
548 | mView->viewManager()->showJournalView(); | 553 | mView->viewManager()->showJournalView(); |
549 | } | 554 | } |
550 | else if ( msg == "-showKO" ) { | 555 | else if ( msg == "-showKO" ) { |
551 | mView->viewManager()->showNextXView(); | 556 | mView->viewManager()->showNextXView(); |
552 | } | 557 | } |
553 | else if ( msg == "-showWNext" ) { | 558 | else if ( msg == "-showWNext" ) { |
554 | mView->viewManager()->showWhatsNextView(); | 559 | mView->viewManager()->showWhatsNextView(); |
555 | } | 560 | } |
556 | else if ( msg == "nextView()" ) { | 561 | else if ( msg == "nextView()" ) { |
557 | mView->viewManager()->showNextView(); | 562 | mView->viewManager()->showNextView(); |
558 | } | 563 | } |
559 | else if ( msg == "-showNextXView" ) { | 564 | else if ( msg == "-showNextXView" ) { |
560 | mView->viewManager()->showNextXView(); | 565 | mView->viewManager()->showNextXView(); |
561 | } | 566 | } |
562 | 567 | ||
563 | 568 | ||
564 | } | 569 | } |
565 | 570 | ||
566 | showMaximized(); | 571 | showMaximized(); |
567 | raise(); | 572 | raise(); |
568 | } | 573 | } |
569 | 574 | ||
570 | QPixmap MainWindow::loadPixmap( QString name ) | 575 | QPixmap MainWindow::loadPixmap( QString name ) |
571 | { | 576 | { |
572 | return SmallIcon( name ); | 577 | return SmallIcon( name ); |
573 | 578 | ||
574 | } | 579 | } |
575 | void MainWindow::initActions() | 580 | void MainWindow::initActions() |
576 | { | 581 | { |
577 | //KOPrefs::instance()->mShowFullMenu | 582 | //KOPrefs::instance()->mShowFullMenu |
578 | iconToolBar->clear(); | 583 | iconToolBar->clear(); |
579 | KOPrefs *p = KOPrefs::instance(); | 584 | KOPrefs *p = KOPrefs::instance(); |
580 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 585 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
581 | 586 | ||
582 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 587 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
583 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 588 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
584 | QPopupMenu *importMenu = new QPopupMenu( this ); | 589 | QPopupMenu *importMenu = new QPopupMenu( this ); |
585 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 590 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
586 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 591 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
587 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 592 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
588 | selectFilterMenu = new QPopupMenu( this ); | 593 | selectFilterMenu = new QPopupMenu( this ); |
589 | selectFilterMenu->setCheckable( true ); | 594 | selectFilterMenu->setCheckable( true ); |
590 | syncMenu = new QPopupMenu( this ); | 595 | syncMenu = new QPopupMenu( this ); |
591 | configureAgendaMenu = new QPopupMenu( this ); | 596 | configureAgendaMenu = new QPopupMenu( this ); |
592 | configureToolBarMenu = new QPopupMenu( this ); | 597 | configureToolBarMenu = new QPopupMenu( this ); |
593 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 598 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
594 | QIconSet icon; | 599 | QIconSet icon; |
595 | int pixWid = 22, pixHei = 22; | 600 | int pixWid = 22, pixHei = 22; |
596 | QString pathString = ""; | 601 | QString pathString = ""; |
597 | if ( !p->mToolBarMiniIcons ) { | 602 | if ( !p->mToolBarMiniIcons ) { |
598 | if ( QApplication::desktop()->width() < 480 ) { | 603 | if ( QApplication::desktop()->width() < 480 ) { |
599 | pathString += "icons16/"; | 604 | pathString += "icons16/"; |
600 | pixWid = 18; pixHei = 16; | 605 | pixWid = 18; pixHei = 16; |
601 | } | 606 | } |
602 | } else { | 607 | } else { |
603 | pathString += "iconsmini/"; | 608 | pathString += "iconsmini/"; |
604 | pixWid = 18; pixHei = 16; | 609 | pixWid = 18; pixHei = 16; |
605 | } | 610 | } |
606 | if ( KOPrefs::instance()->mShowFullMenu ) { | 611 | if ( KOPrefs::instance()->mShowFullMenu ) { |
607 | QMenuBar *menuBar1; | 612 | QMenuBar *menuBar1; |
608 | menuBar1 = menuBar(); | 613 | menuBar1 = menuBar(); |
609 | menuBar1->insertItem( i18n("File"), importMenu ); | 614 | menuBar1->insertItem( i18n("File"), importMenu ); |
610 | menuBar1->insertItem( i18n("View"), viewMenu ); | 615 | menuBar1->insertItem( i18n("View"), viewMenu ); |
611 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 616 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
612 | #ifdef DESKTOP_VERSION | 617 | #ifdef DESKTOP_VERSION |
613 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 618 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
614 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 619 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
615 | #else | 620 | #else |
616 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 621 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
617 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 622 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
618 | #endif | 623 | #endif |
619 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 624 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
620 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 625 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
621 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 626 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
622 | } else { | 627 | } else { |
623 | QPEMenuBar *menuBar1; | 628 | QPEMenuBar *menuBar1; |
624 | menuBar1 = new QPEMenuBar( iconToolBar ); | 629 | menuBar1 = new QPEMenuBar( iconToolBar ); |
625 | QPopupMenu *menuBar = new QPopupMenu( this ); | 630 | QPopupMenu *menuBar = new QPopupMenu( this ); |
626 | icon = loadPixmap( pathString + "z_menu" ); | 631 | icon = loadPixmap( pathString + "z_menu" ); |
627 | menuBar1->insertItem( icon.pixmap(), menuBar); | 632 | menuBar1->insertItem( icon.pixmap(), menuBar); |
628 | //menuBar1->insertItem( i18n("ME"), menuBar); | 633 | //menuBar1->insertItem( i18n("ME"), menuBar); |
629 | menuBar->insertItem( i18n("File"), importMenu ); | 634 | menuBar->insertItem( i18n("File"), importMenu ); |
630 | menuBar->insertItem( i18n("View"), viewMenu ); | 635 | menuBar->insertItem( i18n("View"), viewMenu ); |
631 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 636 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
632 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 637 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
633 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 638 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
634 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 639 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
635 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 640 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
636 | menuBar->insertItem( i18n("Help"), helpMenu ); | 641 | menuBar->insertItem( i18n("Help"), helpMenu ); |
637 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 642 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
638 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 643 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
639 | } | 644 | } |
640 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 645 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
641 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 646 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
642 | mWeekBgColor = iconToolBar->backgroundColor(); | 647 | mWeekBgColor = iconToolBar->backgroundColor(); |
643 | mWeekPixmap.resize( pixWid , pixHei ); | 648 | mWeekPixmap.resize( pixWid , pixHei ); |
644 | mWeekPixmap.fill( mWeekBgColor ); | 649 | mWeekPixmap.fill( mWeekBgColor ); |
645 | icon = mWeekPixmap; | 650 | icon = mWeekPixmap; |
646 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 651 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
647 | if ( p-> mShowIconWeekNum ) | 652 | if ( p-> mShowIconWeekNum ) |
648 | mWeekAction->addTo( iconToolBar ); | 653 | mWeekAction->addTo( iconToolBar ); |
649 | mWeekFont = font(); | 654 | mWeekFont = font(); |
650 | 655 | ||
651 | int fontPoint = mWeekFont.pointSize(); | 656 | int fontPoint = mWeekFont.pointSize(); |
652 | QFontMetrics f( mWeekFont ); | 657 | QFontMetrics f( mWeekFont ); |
653 | int fontWid = f.width( "30" ); | 658 | int fontWid = f.width( "30" ); |
654 | while ( fontWid > pixWid ) { | 659 | while ( fontWid > pixWid ) { |
655 | --fontPoint; | 660 | --fontPoint; |
656 | mWeekFont.setPointSize( fontPoint ); | 661 | mWeekFont.setPointSize( fontPoint ); |
657 | QFontMetrics f( mWeekFont ); | 662 | QFontMetrics f( mWeekFont ); |
658 | fontWid = f.width( "30" ); | 663 | fontWid = f.width( "30" ); |
659 | //qDebug("dec-- "); | 664 | //qDebug("dec-- "); |
660 | } | 665 | } |
661 | 666 | ||
662 | connect( mWeekAction, SIGNAL( activated() ), | 667 | connect( mWeekAction, SIGNAL( activated() ), |
663 | this, SLOT( weekAction() ) ); | 668 | this, SLOT( weekAction() ) ); |
664 | 669 | ||
665 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 670 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
666 | 671 | ||
667 | //#endif | 672 | //#endif |
668 | // ****************** | 673 | // ****************** |
669 | QAction *action; | 674 | QAction *action; |
670 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 675 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
671 | configureToolBarMenu->setCheckable( true ); | 676 | configureToolBarMenu->setCheckable( true ); |
672 | 677 | ||
673 | 678 | ||
674 | configureAgendaMenu->setCheckable( true ); | 679 | configureAgendaMenu->setCheckable( true ); |
675 | int iii ; | 680 | int iii ; |
676 | for ( iii = 1;iii<= 10 ;++iii ){ | 681 | for ( iii = 1;iii<= 10 ;++iii ){ |
677 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 682 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
678 | } | 683 | } |
679 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 684 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
680 | 685 | ||
681 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 686 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
682 | this, SLOT( showConfigureAgenda( ) ) ); | 687 | this, SLOT( showConfigureAgenda( ) ) ); |
683 | 688 | ||
684 | icon = loadPixmap( pathString + "configure" ); | 689 | icon = loadPixmap( pathString + "configure" ); |
685 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 690 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
686 | action->addTo( actionMenu ); | 691 | action->addTo( actionMenu ); |
687 | connect( action, SIGNAL( activated() ), | 692 | connect( action, SIGNAL( activated() ), |
688 | mView, SLOT( edit_options() ) ); | 693 | mView, SLOT( edit_options() ) ); |
689 | actionMenu->insertSeparator(); | 694 | actionMenu->insertSeparator(); |
690 | 695 | ||
691 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 696 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
692 | action->addTo( actionMenu ); | 697 | action->addTo( actionMenu ); |
693 | connect( action, SIGNAL( activated() ), | 698 | connect( action, SIGNAL( activated() ), |
694 | mView, SLOT( undo_delete() ) ); | 699 | mView, SLOT( undo_delete() ) ); |
695 | actionMenu->insertSeparator(); | 700 | actionMenu->insertSeparator(); |
696 | 701 | ||
697 | icon = loadPixmap( pathString + "newevent" ); | 702 | icon = loadPixmap( pathString + "newevent" ); |
698 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 703 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
699 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 704 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
700 | configureToolBarMenu->insertSeparator(); | 705 | configureToolBarMenu->insertSeparator(); |
701 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 706 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
702 | configureToolBarMenu->insertSeparator(); | 707 | configureToolBarMenu->insertSeparator(); |
703 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 708 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
704 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 709 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
705 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 710 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
706 | ne_action->addTo( actionMenu ); | 711 | ne_action->addTo( actionMenu ); |
707 | connect( ne_action, SIGNAL( activated() ), | 712 | connect( ne_action, SIGNAL( activated() ), |
708 | mView, SLOT( newEvent() ) ); | 713 | mView, SLOT( newEvent() ) ); |
709 | icon = loadPixmap( pathString + "newtodo" ); | 714 | icon = loadPixmap( pathString + "newtodo" ); |
710 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 715 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
711 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 716 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
712 | nt_action->addTo( actionMenu ); | 717 | nt_action->addTo( actionMenu ); |
713 | connect( nt_action, SIGNAL( activated() ), | 718 | connect( nt_action, SIGNAL( activated() ), |
714 | mView, SLOT( newTodo() ) ); | 719 | mView, SLOT( newTodo() ) ); |
715 | 720 | ||
716 | icon = loadPixmap( pathString + "today" ); | 721 | icon = loadPixmap( pathString + "today" ); |
717 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 722 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
718 | today_action->addTo( viewMenu ); | 723 | today_action->addTo( viewMenu ); |
719 | connect( today_action, SIGNAL( activated() ), | 724 | connect( today_action, SIGNAL( activated() ), |
720 | mView, SLOT( goToday() ) ); | 725 | mView, SLOT( goToday() ) ); |
721 | viewMenu->insertSeparator(); | 726 | viewMenu->insertSeparator(); |
722 | 727 | ||
723 | icon = loadPixmap( pathString + "navi" ); | 728 | icon = loadPixmap( pathString + "navi" ); |
724 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 729 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
725 | action->addTo( viewMenu ); | 730 | action->addTo( viewMenu ); |
726 | connect( action, SIGNAL( activated() ), | 731 | connect( action, SIGNAL( activated() ), |
727 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 732 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
728 | mToggleNav = action ; | 733 | mToggleNav = action ; |
729 | icon = loadPixmap( pathString + "filter" ); | 734 | icon = loadPixmap( pathString + "filter" ); |
730 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 735 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
731 | action->addTo( viewMenu ); | 736 | action->addTo( viewMenu ); |
732 | connect( action, SIGNAL( activated() ), | 737 | connect( action, SIGNAL( activated() ), |
733 | mView, SLOT( toggleFilter() ) ); | 738 | mView, SLOT( toggleFilter() ) ); |
734 | mToggleFilter = action; | 739 | mToggleFilter = action; |
735 | icon = loadPixmap( pathString + "allday" ); | 740 | icon = loadPixmap( pathString + "allday" ); |
736 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 741 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
737 | action->addTo( viewMenu ); | 742 | action->addTo( viewMenu ); |
738 | connect( action, SIGNAL( activated() ), | 743 | connect( action, SIGNAL( activated() ), |
739 | mView, SLOT( toggleAllDaySize() ) ); | 744 | mView, SLOT( toggleAllDaySize() ) ); |
740 | mToggleAllday = action; | 745 | mToggleAllday = action; |
741 | 746 | ||
742 | 747 | ||
743 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 748 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
744 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 749 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
745 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 750 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
746 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 751 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
747 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 752 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
748 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 753 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
749 | 754 | ||
750 | viewMenu->insertSeparator(); | 755 | viewMenu->insertSeparator(); |
751 | icon = loadPixmap( pathString + "picker" ); | 756 | icon = loadPixmap( pathString + "picker" ); |
752 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 757 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
753 | action->addTo( viewMenu ); | 758 | action->addTo( viewMenu ); |
754 | connect( action, SIGNAL( activated() ), | 759 | connect( action, SIGNAL( activated() ), |
755 | mView, SLOT( showDatePicker() ) ); | 760 | mView, SLOT( showDatePicker() ) ); |
756 | action->addTo( iconToolBar ); | 761 | action->addTo( iconToolBar ); |
757 | viewMenu->insertSeparator(); | 762 | viewMenu->insertSeparator(); |
758 | 763 | ||
759 | 764 | ||
760 | icon = loadPixmap( pathString + "whatsnext" ); | 765 | icon = loadPixmap( pathString + "whatsnext" ); |
761 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 766 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
762 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 767 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
763 | whatsnext_action->addTo( viewMenu ); | 768 | whatsnext_action->addTo( viewMenu ); |
764 | connect( whatsnext_action, SIGNAL( activated() ), | 769 | connect( whatsnext_action, SIGNAL( activated() ), |
765 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 770 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
766 | 771 | ||
767 | icon = loadPixmap( pathString + "xdays" ); | 772 | icon = loadPixmap( pathString + "xdays" ); |
768 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 773 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
769 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 774 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
770 | xdays_action->addTo( viewMenu ); | 775 | xdays_action->addTo( viewMenu ); |
771 | connect( xdays_action, SIGNAL( activated() ), | 776 | connect( xdays_action, SIGNAL( activated() ), |
772 | mView->viewManager(), SLOT( showNextXView() ) ); | 777 | mView->viewManager(), SLOT( showNextXView() ) ); |
773 | 778 | ||
774 | 779 | ||
775 | icon = loadPixmap( pathString + "journal" ); | 780 | icon = loadPixmap( pathString + "journal" ); |
776 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 781 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
777 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 782 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
778 | viewjournal_action->addTo( viewMenu ); | 783 | viewjournal_action->addTo( viewMenu ); |
779 | connect( viewjournal_action, SIGNAL( activated() ), | 784 | connect( viewjournal_action, SIGNAL( activated() ), |
780 | mView->viewManager(), SLOT( showJournalView() ) ); | 785 | mView->viewManager(), SLOT( showJournalView() ) ); |
781 | 786 | ||
782 | 787 | ||
783 | icon = loadPixmap( pathString + "day" ); | 788 | icon = loadPixmap( pathString + "day" ); |
784 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 789 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
785 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 790 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
786 | day1_action->addTo( viewMenu ); | 791 | day1_action->addTo( viewMenu ); |
787 | // action->addTo( toolBar ); | 792 | // action->addTo( toolBar ); |
788 | connect( day1_action, SIGNAL( activated() ), | 793 | connect( day1_action, SIGNAL( activated() ), |
789 | mView->viewManager(), SLOT( showDayView() ) ); | 794 | mView->viewManager(), SLOT( showDayView() ) ); |
790 | 795 | ||
791 | icon = loadPixmap( pathString + "workweek" ); | 796 | icon = loadPixmap( pathString + "workweek" ); |
792 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 797 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
793 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 798 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
794 | day5_action->addTo( viewMenu ); | 799 | day5_action->addTo( viewMenu ); |
795 | connect( day5_action, SIGNAL( activated() ), | 800 | connect( day5_action, SIGNAL( activated() ), |
796 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 801 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
797 | 802 | ||
798 | icon = loadPixmap( pathString + "week" ); | 803 | icon = loadPixmap( pathString + "week" ); |
799 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 804 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
800 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 805 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
801 | day7_action->addTo( viewMenu ); | 806 | day7_action->addTo( viewMenu ); |
802 | connect( day7_action, SIGNAL( activated() ), | 807 | connect( day7_action, SIGNAL( activated() ), |
803 | mView->viewManager(), SLOT( showWeekView() ) ); | 808 | mView->viewManager(), SLOT( showWeekView() ) ); |
804 | 809 | ||
805 | icon = loadPixmap( pathString + "workweek2" ); | 810 | icon = loadPixmap( pathString + "workweek2" ); |
806 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 811 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
807 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 812 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
808 | day6_action->addTo( viewMenu ); | 813 | day6_action->addTo( viewMenu ); |
809 | connect( day6_action, SIGNAL( activated() ), | 814 | connect( day6_action, SIGNAL( activated() ), |
810 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 815 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
811 | 816 | ||
812 | icon = loadPixmap( pathString + "month" ); | 817 | icon = loadPixmap( pathString + "month" ); |
813 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 818 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
814 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 819 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
815 | month_action->addTo( viewMenu ); | 820 | month_action->addTo( viewMenu ); |
816 | connect( month_action, SIGNAL( activated() ), | 821 | connect( month_action, SIGNAL( activated() ), |
817 | mView->viewManager(), SLOT( showMonthView() ) ); | 822 | mView->viewManager(), SLOT( showMonthView() ) ); |
818 | 823 | ||
819 | icon = loadPixmap( pathString + "list" ); | 824 | icon = loadPixmap( pathString + "list" ); |
820 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 825 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
821 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 826 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
822 | showlist_action->addTo( viewMenu ); | 827 | showlist_action->addTo( viewMenu ); |
823 | connect( showlist_action, SIGNAL( activated() ), | 828 | connect( showlist_action, SIGNAL( activated() ), |
824 | mView->viewManager(), SLOT( showListView() ) ); | 829 | mView->viewManager(), SLOT( showListView() ) ); |
825 | 830 | ||
826 | icon = loadPixmap( pathString + "todo" ); | 831 | icon = loadPixmap( pathString + "todo" ); |
827 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 832 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
828 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 833 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
829 | todoview_action->addTo( viewMenu ); | 834 | todoview_action->addTo( viewMenu ); |
830 | connect( todoview_action, SIGNAL( activated() ), | 835 | connect( todoview_action, SIGNAL( activated() ), |
831 | mView->viewManager(), SLOT( showTodoView() ) ); | 836 | mView->viewManager(), SLOT( showTodoView() ) ); |
832 | 837 | ||
833 | 838 | ||
834 | 839 | ||
835 | #if 0 | 840 | #if 0 |
836 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 841 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
837 | action->addTo( viewMenu ); | 842 | action->addTo( viewMenu ); |
838 | connect( action, SIGNAL( activated() ), | 843 | connect( action, SIGNAL( activated() ), |
839 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 844 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
840 | #endif | 845 | #endif |
841 | 846 | ||
842 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 847 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
843 | this ); | 848 | this ); |
844 | mNewSubTodoAction->addTo( actionMenu ); | 849 | mNewSubTodoAction->addTo( actionMenu ); |
845 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 850 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
846 | mView, SLOT( newSubTodo() ) ); | 851 | mView, SLOT( newSubTodo() ) ); |
847 | 852 | ||
848 | actionMenu->insertSeparator(); | 853 | actionMenu->insertSeparator(); |
849 | 854 | ||
850 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 855 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
851 | mShowAction->addTo( actionMenu ); | 856 | mShowAction->addTo( actionMenu ); |
852 | connect( mShowAction, SIGNAL( activated() ), | 857 | connect( mShowAction, SIGNAL( activated() ), |
853 | mView, SLOT( showIncidence() ) ); | 858 | mView, SLOT( showIncidence() ) ); |
854 | 859 | ||
855 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 860 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
856 | mEditAction->addTo( actionMenu ); | 861 | mEditAction->addTo( actionMenu ); |
857 | connect( mEditAction, SIGNAL( activated() ), | 862 | connect( mEditAction, SIGNAL( activated() ), |
858 | mView, SLOT( editIncidence() ) ); | 863 | mView, SLOT( editIncidence() ) ); |
859 | 864 | ||
860 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 865 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
861 | mDeleteAction->addTo( actionMenu ); | 866 | mDeleteAction->addTo( actionMenu ); |
862 | connect( mDeleteAction, SIGNAL( activated() ), | 867 | connect( mDeleteAction, SIGNAL( activated() ), |
863 | mView, SLOT( deleteIncidence() ) ); | 868 | mView, SLOT( deleteIncidence() ) ); |
864 | 869 | ||
865 | 870 | ||
866 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 871 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
867 | mCloneAction->addTo( actionMenu ); | 872 | mCloneAction->addTo( actionMenu ); |
868 | connect( mCloneAction, SIGNAL( activated() ), | 873 | connect( mCloneAction, SIGNAL( activated() ), |
869 | mView, SLOT( cloneIncidence() ) ); | 874 | mView, SLOT( cloneIncidence() ) ); |
870 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 875 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
871 | mMoveAction->addTo( actionMenu ); | 876 | mMoveAction->addTo( actionMenu ); |
872 | connect( mMoveAction, SIGNAL( activated() ), | 877 | connect( mMoveAction, SIGNAL( activated() ), |
873 | mView, SLOT( moveIncidence() ) ); | 878 | mView, SLOT( moveIncidence() ) ); |
874 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 879 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
875 | mBeamAction->addTo( actionMenu ); | 880 | mBeamAction->addTo( actionMenu ); |
876 | connect( mBeamAction, SIGNAL( activated() ), | 881 | connect( mBeamAction, SIGNAL( activated() ), |
877 | mView, SLOT( beamIncidence() ) ); | 882 | mView, SLOT( beamIncidence() ) ); |
878 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 883 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
879 | mCancelAction->addTo( actionMenu ); | 884 | mCancelAction->addTo( actionMenu ); |
880 | connect( mCancelAction, SIGNAL( activated() ), | 885 | connect( mCancelAction, SIGNAL( activated() ), |
881 | mView, SLOT( toggleCancelIncidence() ) ); | 886 | mView, SLOT( toggleCancelIncidence() ) ); |
882 | 887 | ||
883 | actionMenu->insertSeparator(); | 888 | actionMenu->insertSeparator(); |
884 | 889 | ||
885 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 890 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
886 | this ); | 891 | this ); |
887 | action->addTo( actionMenu ); | 892 | action->addTo( actionMenu ); |
888 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 893 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
889 | 894 | ||
890 | icon = loadPixmap( pathString + "search" ); | 895 | icon = loadPixmap( pathString + "search" ); |
891 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 896 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
892 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); | 897 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); |
893 | search_action->addTo( actionMenu ); | 898 | search_action->addTo( actionMenu ); |
894 | connect( search_action, SIGNAL( activated() ), | 899 | connect( search_action, SIGNAL( activated() ), |
895 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 900 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
896 | 901 | ||
897 | 902 | ||
898 | 903 | ||
899 | if ( KOPrefs::instance()->mShowFullMenu ) { | 904 | if ( KOPrefs::instance()->mShowFullMenu ) { |
900 | actionMenu->insertSeparator(); | 905 | actionMenu->insertSeparator(); |
901 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 906 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
902 | 907 | ||
903 | } | 908 | } |
904 | // actionMenu->insertSeparator(); | 909 | // actionMenu->insertSeparator(); |
905 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 910 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
906 | this ); | 911 | this ); |
907 | action->addTo( importMenu_X ); | 912 | action->addTo( importMenu_X ); |
908 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 913 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
909 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 914 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
910 | this ); | 915 | this ); |
911 | action->addTo( importMenu_X ); | 916 | action->addTo( importMenu_X ); |
912 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 917 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
913 | importMenu_X->insertSeparator(); | 918 | importMenu_X->insertSeparator(); |
914 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 919 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
915 | this ); | 920 | this ); |
916 | action->addTo( importMenu_X ); | 921 | action->addTo( importMenu_X ); |
917 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 922 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
918 | //#ifndef DESKTOP_VERSION | 923 | //#ifndef DESKTOP_VERSION |
919 | importMenu_X->insertSeparator(); | 924 | importMenu_X->insertSeparator(); |
920 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 925 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
921 | this ); | 926 | this ); |
922 | action->addTo( importMenu_X ); | 927 | action->addTo( importMenu_X ); |
923 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 928 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
924 | //#else | 929 | //#else |
925 | #ifdef _OL_IMPORT_ | 930 | #ifdef _OL_IMPORT_ |
926 | importMenu_X->insertSeparator(); | 931 | importMenu_X->insertSeparator(); |
927 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 932 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
928 | this ); | 933 | this ); |
929 | action->addTo( importMenu_X ); | 934 | action->addTo( importMenu_X ); |
930 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 935 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
931 | #endif | 936 | #endif |
932 | //#endif | 937 | //#endif |
933 | 938 | ||
934 | //importMenu->insertSeparator(); | 939 | //importMenu->insertSeparator(); |
935 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 940 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
936 | this ); | 941 | this ); |
937 | action->addTo( importMenu ); | 942 | action->addTo( importMenu ); |
938 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 943 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
939 | 944 | ||
940 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 945 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
941 | this ); | 946 | this ); |
942 | action->addTo( importMenu ); | 947 | action->addTo( importMenu ); |
943 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 948 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
944 | importMenu->insertSeparator(); | 949 | importMenu->insertSeparator(); |
945 | importMenu->insertItem( i18n("Import"), importMenu_X ); | 950 | importMenu->insertItem( i18n("Import"), importMenu_X ); |
946 | //importMenu->insertSeparator(); | 951 | //importMenu->insertSeparator(); |
947 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 952 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
948 | this ); | 953 | this ); |
949 | action->addTo( exportMenu_X ); | 954 | action->addTo( exportMenu_X ); |
950 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 955 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
951 | 956 | ||
952 | 957 | ||
953 | //LR | 958 | //LR |
954 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 959 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
955 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 960 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
956 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 961 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
957 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 962 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
958 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); | 963 | exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); |
959 | 964 | ||
960 | importMenu->insertItem( i18n("Export"), exportMenu_X ); | 965 | importMenu->insertItem( i18n("Export"), exportMenu_X ); |
961 | #ifndef DESKTOP_VERSION | 966 | #ifndef DESKTOP_VERSION |
962 | //importMenu->insertSeparator(); | 967 | //importMenu->insertSeparator(); |
963 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 968 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
964 | this ); | 969 | this ); |
965 | brAction->addTo( beamMenu_X ); | 970 | brAction->addTo( beamMenu_X ); |
966 | brAction->setToggleAction (true ) ; | 971 | brAction->setToggleAction (true ) ; |
967 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 972 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
968 | 973 | ||
969 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 974 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
970 | this ); | 975 | this ); |
971 | action->addTo( beamMenu_X ); | 976 | action->addTo( beamMenu_X ); |
972 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 977 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
973 | 978 | ||
974 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 979 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
975 | this ); | 980 | this ); |
976 | action->addTo( beamMenu_X ); | 981 | action->addTo( beamMenu_X ); |
977 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 982 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
978 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); | 983 | importMenu->insertItem( i18n("Beam"), beamMenu_X ); |
979 | #else | 984 | #else |
980 | //importMenu->insertSeparator(); | 985 | //importMenu->insertSeparator(); |
981 | icon = loadPixmap( pathString + "print" ); | 986 | icon = loadPixmap( pathString + "print" ); |
982 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 987 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
983 | action->addTo( beamMenu_X ); | 988 | action->addTo( beamMenu_X ); |
984 | connect( action, SIGNAL( activated() ), | 989 | connect( action, SIGNAL( activated() ), |
985 | this, SLOT( printCal() ) ); | 990 | this, SLOT( printCal() ) ); |
986 | 991 | ||
987 | icon = loadPixmap( pathString + "print" ); | 992 | icon = loadPixmap( pathString + "print" ); |
988 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 993 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
989 | action->addTo( beamMenu_X ); | 994 | action->addTo( beamMenu_X ); |
990 | connect( action, SIGNAL( activated() ), | 995 | connect( action, SIGNAL( activated() ), |
991 | this, SLOT( printSel() ) ); | 996 | this, SLOT( printSel() ) ); |
992 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 997 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
993 | action->addTo( beamMenu_X ); | 998 | action->addTo( beamMenu_X ); |
994 | connect( action, SIGNAL( activated() ), | 999 | connect( action, SIGNAL( activated() ), |
995 | mView->viewManager(), SIGNAL( printWNV() ) ); | 1000 | mView->viewManager(), SLOT( slotprintWNV() ) ); |
1001 | |||
1002 | action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); | ||
1003 | action->addTo( beamMenu_X ); | ||
1004 | connect( action, SIGNAL( activated() ), | ||
1005 | mView, SLOT( slotprintSelInc() ) ); | ||
1006 | |||
1007 | |||
996 | importMenu->insertItem( i18n("Print"), beamMenu_X ); | 1008 | importMenu->insertItem( i18n("Print"), beamMenu_X ); |
997 | #endif | 1009 | #endif |
998 | importMenu->insertSeparator(); | 1010 | importMenu->insertSeparator(); |
999 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 1011 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
1000 | this ); | 1012 | this ); |
1001 | action->addTo( importMenu ); | 1013 | action->addTo( importMenu ); |
1002 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 1014 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
1003 | importMenu->insertSeparator(); | 1015 | importMenu->insertSeparator(); |
1004 | action = new QAction( "beam all", i18n("Save"), 0, | 1016 | action = new QAction( "beam all", i18n("Save"), 0, |
1005 | this ); | 1017 | this ); |
1006 | action->addTo( importMenu ); | 1018 | action->addTo( importMenu ); |
1007 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 1019 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
1008 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 1020 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
1009 | this ); | 1021 | this ); |
1010 | action->addTo( importMenu ); | 1022 | action->addTo( importMenu ); |
1011 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 1023 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
1012 | 1024 | ||
1013 | //menuBar->insertItem( "Configure",configureMenu ); | 1025 | //menuBar->insertItem( "Configure",configureMenu ); |
1014 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 1026 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
1015 | icon = loadPixmap( "korganizer/korganizer" ); | 1027 | icon = loadPixmap( "korganizer/korganizer" ); |
1016 | 1028 | ||
1017 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 1029 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
1018 | action->addTo( helpMenu ); | 1030 | action->addTo( helpMenu ); |
1019 | connect( action, SIGNAL( activated() ), | 1031 | connect( action, SIGNAL( activated() ), |
1020 | SLOT( whatsNew() ) ); | 1032 | SLOT( whatsNew() ) ); |
1021 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 1033 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
1022 | action->addTo( helpMenu ); | 1034 | action->addTo( helpMenu ); |
1023 | connect( action, SIGNAL( activated() ), | 1035 | connect( action, SIGNAL( activated() ), |
1024 | SLOT( features() ) ); | 1036 | SLOT( features() ) ); |
1025 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 1037 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
1026 | action->addTo( helpMenu ); | 1038 | action->addTo( helpMenu ); |
1027 | connect( action, SIGNAL( activated() ), | 1039 | connect( action, SIGNAL( activated() ), |
1028 | SLOT( keyBindings() ) ); | 1040 | SLOT( keyBindings() ) ); |
1029 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 1041 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
1030 | action->addTo( helpMenu ); | 1042 | action->addTo( helpMenu ); |
1031 | connect( action, SIGNAL( activated() ), | 1043 | connect( action, SIGNAL( activated() ), |
1032 | SLOT( synchowto() ) ); | 1044 | SLOT( synchowto() ) ); |
1033 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 1045 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
1034 | action->addTo( helpMenu ); | 1046 | action->addTo( helpMenu ); |
1035 | connect( action, SIGNAL( activated() ), | 1047 | connect( action, SIGNAL( activated() ), |
1036 | SLOT( kdesynchowto() ) ); | 1048 | SLOT( kdesynchowto() ) ); |
1037 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 1049 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
1038 | action->addTo( helpMenu ); | 1050 | action->addTo( helpMenu ); |
1039 | connect( action, SIGNAL( activated() ), | 1051 | connect( action, SIGNAL( activated() ), |
1040 | SLOT( multisynchowto() ) ); | 1052 | SLOT( multisynchowto() ) ); |
1041 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 1053 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
1042 | action->addTo( helpMenu ); | 1054 | action->addTo( helpMenu ); |
1043 | connect( action, SIGNAL( activated() ), | 1055 | connect( action, SIGNAL( activated() ), |
1044 | SLOT( aboutAutoSaving() ) ); | 1056 | SLOT( aboutAutoSaving() ) ); |
1045 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 1057 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
1046 | action->addTo( helpMenu ); | 1058 | action->addTo( helpMenu ); |
1047 | connect( action, SIGNAL( activated() ), | 1059 | connect( action, SIGNAL( activated() ), |
1048 | SLOT( aboutKnownBugs() ) ); | 1060 | SLOT( aboutKnownBugs() ) ); |
1049 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 1061 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
1050 | action->addTo( helpMenu ); | 1062 | action->addTo( helpMenu ); |
1051 | connect( action, SIGNAL( activated() ), | 1063 | connect( action, SIGNAL( activated() ), |
1052 | SLOT( usertrans() ) ); | 1064 | SLOT( usertrans() ) ); |
1053 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 1065 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
1054 | action->addTo( helpMenu ); | 1066 | action->addTo( helpMenu ); |
1055 | connect( action, SIGNAL( activated() ), | 1067 | connect( action, SIGNAL( activated() ), |
1056 | SLOT( faq() ) ); | 1068 | SLOT( faq() ) ); |
1057 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 1069 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
1058 | action->addTo( helpMenu ); | 1070 | action->addTo( helpMenu ); |
1059 | connect( action, SIGNAL( activated() ), | 1071 | connect( action, SIGNAL( activated() ), |
1060 | SLOT( licence() ) ); | 1072 | SLOT( licence() ) ); |
1061 | action = new QAction( "about", i18n("About..."), 0, this ); | 1073 | action = new QAction( "about", i18n("About..."), 0, this ); |
1062 | action->addTo( helpMenu ); | 1074 | action->addTo( helpMenu ); |
1063 | connect( action, SIGNAL( activated() ), | 1075 | connect( action, SIGNAL( activated() ), |
1064 | SLOT( about() ) ); | 1076 | SLOT( about() ) ); |
1065 | //menuBar->insertSeparator(); | 1077 | //menuBar->insertSeparator(); |
1066 | 1078 | ||
1067 | // ****************************************************** | 1079 | // ****************************************************** |
1068 | // menubar icons | 1080 | // menubar icons |
1069 | 1081 | ||
1070 | 1082 | ||
1071 | 1083 | ||
1072 | //menuBar->insertItem( iconToolBar ); | 1084 | //menuBar->insertItem( iconToolBar ); |
1073 | //xdays_action | 1085 | //xdays_action |
1074 | if (p-> mShowIconNewEvent) | 1086 | if (p-> mShowIconNewEvent) |
1075 | ne_action->addTo( iconToolBar ); | 1087 | ne_action->addTo( iconToolBar ); |
1076 | if (p->mShowIconNewTodo ) | 1088 | if (p->mShowIconNewTodo ) |
1077 | nt_action->addTo( iconToolBar ); | 1089 | nt_action->addTo( iconToolBar ); |
1078 | if (p-> mShowIconSearch) | 1090 | if (p-> mShowIconSearch) |
1079 | search_action->addTo( iconToolBar ); | 1091 | search_action->addTo( iconToolBar ); |
1080 | if (p-> mShowIconWhatsThis) | 1092 | if (p-> mShowIconWhatsThis) |
1081 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1093 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1082 | if (p-> mShowIconNext) | 1094 | if (p-> mShowIconNext) |
1083 | whatsnext_action->addTo( viewToolBar ); | 1095 | whatsnext_action->addTo( viewToolBar ); |
1084 | if (p-> mShowIconNextDays) | 1096 | if (p-> mShowIconNextDays) |
1085 | xdays_action->addTo( viewToolBar ); | 1097 | xdays_action->addTo( viewToolBar ); |
1086 | if (p-> mShowIconJournal) | 1098 | if (p-> mShowIconJournal) |
1087 | viewjournal_action->addTo( viewToolBar ); | 1099 | viewjournal_action->addTo( viewToolBar ); |
1088 | if (p-> mShowIconDay1) | 1100 | if (p-> mShowIconDay1) |
1089 | day1_action->addTo( viewToolBar ); | 1101 | day1_action->addTo( viewToolBar ); |
1090 | if (p-> mShowIconDay5) | 1102 | if (p-> mShowIconDay5) |
1091 | day5_action->addTo( viewToolBar ); | 1103 | day5_action->addTo( viewToolBar ); |
1092 | if (p-> mShowIconDay7) | 1104 | if (p-> mShowIconDay7) |
1093 | day7_action->addTo( viewToolBar ); | 1105 | day7_action->addTo( viewToolBar ); |
1094 | if (p-> mShowIconDay6) | 1106 | if (p-> mShowIconDay6) |
1095 | day6_action->addTo( viewToolBar ); | 1107 | day6_action->addTo( viewToolBar ); |
1096 | if (p-> mShowIconMonth) | 1108 | if (p-> mShowIconMonth) |
1097 | month_action->addTo( viewToolBar ); | 1109 | month_action->addTo( viewToolBar ); |
1098 | if (p-> mShowIconList) | 1110 | if (p-> mShowIconList) |
1099 | showlist_action->addTo( viewToolBar ); | 1111 | showlist_action->addTo( viewToolBar ); |
1100 | if (p-> mShowIconTodoview) | 1112 | if (p-> mShowIconTodoview) |
1101 | todoview_action->addTo( viewToolBar ); | 1113 | todoview_action->addTo( viewToolBar ); |
1102 | 1114 | ||
1103 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1115 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1104 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); | 1116 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); |
1105 | if (p-> mShowIconBackFast) { | 1117 | if (p-> mShowIconBackFast) { |
1106 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1118 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1107 | connect( action, SIGNAL( activated() ), | 1119 | connect( action, SIGNAL( activated() ), |
1108 | mView, SLOT( goPreviousMonth() ) ); | 1120 | mView, SLOT( goPreviousMonth() ) ); |
1109 | action->addTo( navigatorToolBar ); | 1121 | action->addTo( navigatorToolBar ); |
1110 | } | 1122 | } |
1111 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1123 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1112 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); | 1124 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); |
1113 | if (p-> mShowIconBack) { | 1125 | if (p-> mShowIconBack) { |
1114 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1126 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1115 | connect( action, SIGNAL( activated() ), | 1127 | connect( action, SIGNAL( activated() ), |
1116 | mView, SLOT( goPrevious() ) ); | 1128 | mView, SLOT( goPrevious() ) ); |
1117 | action->addTo( navigatorToolBar ); | 1129 | action->addTo( navigatorToolBar ); |
1118 | } | 1130 | } |
1119 | icon = loadPixmap( pathString + "today" ); | 1131 | icon = loadPixmap( pathString + "today" ); |
1120 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1132 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1121 | if (p-> mShowIconToday) | 1133 | if (p-> mShowIconToday) |
1122 | today_action->addTo( navigatorToolBar ); | 1134 | today_action->addTo( navigatorToolBar ); |
1123 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1135 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1124 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1136 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1125 | if (p-> mShowIconForward) { | 1137 | if (p-> mShowIconForward) { |
1126 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1138 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1127 | connect( action, SIGNAL( activated() ), | 1139 | connect( action, SIGNAL( activated() ), |
1128 | mView, SLOT( goNext() ) ); | 1140 | mView, SLOT( goNext() ) ); |
1129 | action->addTo( navigatorToolBar ); | 1141 | action->addTo( navigatorToolBar ); |
1130 | } | 1142 | } |
1131 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1143 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1132 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1144 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1133 | if (p-> mShowIconForwardFast) { | 1145 | if (p-> mShowIconForwardFast) { |
1134 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1146 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1135 | connect( action, SIGNAL( activated() ), | 1147 | connect( action, SIGNAL( activated() ), |
1136 | mView, SLOT( goNextMonth() ) ); | 1148 | mView, SLOT( goNextMonth() ) ); |
1137 | action->addTo( navigatorToolBar ); | 1149 | action->addTo( navigatorToolBar ); |
1138 | } | 1150 | } |
1139 | 1151 | ||
1140 | 1152 | ||
1141 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); | 1153 | configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); |
1142 | 1154 | ||
1143 | if (p-> mShowIconNewEvent) | 1155 | if (p-> mShowIconNewEvent) |
1144 | configureToolBarMenu->setItemChecked( 10, true ); | 1156 | configureToolBarMenu->setItemChecked( 10, true ); |
1145 | if (p->mShowIconNewTodo ) | 1157 | if (p->mShowIconNewTodo ) |
1146 | configureToolBarMenu->setItemChecked( 20, true ); | 1158 | configureToolBarMenu->setItemChecked( 20, true ); |
1147 | if (p-> mShowIconSearch) | 1159 | if (p-> mShowIconSearch) |
1148 | configureToolBarMenu->setItemChecked( 120, true ); | 1160 | configureToolBarMenu->setItemChecked( 120, true ); |
1149 | if (p-> mShowIconList) | 1161 | if (p-> mShowIconList) |
1150 | configureToolBarMenu->setItemChecked( 30, true ); | 1162 | configureToolBarMenu->setItemChecked( 30, true ); |
1151 | if (p-> mShowIconDay1) | 1163 | if (p-> mShowIconDay1) |
1152 | configureToolBarMenu->setItemChecked( 40, true ); | 1164 | configureToolBarMenu->setItemChecked( 40, true ); |
1153 | if (p-> mShowIconDay5) | 1165 | if (p-> mShowIconDay5) |
1154 | configureToolBarMenu->setItemChecked( 50, true ); | 1166 | configureToolBarMenu->setItemChecked( 50, true ); |
1155 | if (p-> mShowIconDay6) | 1167 | if (p-> mShowIconDay6) |
1156 | configureToolBarMenu->setItemChecked( 75, true ); | 1168 | configureToolBarMenu->setItemChecked( 75, true ); |
1157 | if (p-> mShowIconDay7) | 1169 | if (p-> mShowIconDay7) |
1158 | configureToolBarMenu->setItemChecked( 60, true ); | 1170 | configureToolBarMenu->setItemChecked( 60, true ); |
1159 | if (p-> mShowIconMonth) | 1171 | if (p-> mShowIconMonth) |
1160 | configureToolBarMenu->setItemChecked( 70, true ); | 1172 | configureToolBarMenu->setItemChecked( 70, true ); |
1161 | if (p-> mShowIconTodoview) | 1173 | if (p-> mShowIconTodoview) |
1162 | configureToolBarMenu->setItemChecked( 80, true ); | 1174 | configureToolBarMenu->setItemChecked( 80, true ); |
1163 | if (p-> mShowIconBackFast) | 1175 | if (p-> mShowIconBackFast) |
1164 | configureToolBarMenu->setItemChecked( 200, true ); | 1176 | configureToolBarMenu->setItemChecked( 200, true ); |
1165 | if (p-> mShowIconBack) | 1177 | if (p-> mShowIconBack) |
1166 | configureToolBarMenu->setItemChecked( 210, true ); | 1178 | configureToolBarMenu->setItemChecked( 210, true ); |
1167 | if (p-> mShowIconToday) | 1179 | if (p-> mShowIconToday) |
1168 | configureToolBarMenu->setItemChecked( 130, true ); | 1180 | configureToolBarMenu->setItemChecked( 130, true ); |
1169 | if (p-> mShowIconForward) | 1181 | if (p-> mShowIconForward) |
1170 | configureToolBarMenu->setItemChecked( 220, true ); | 1182 | configureToolBarMenu->setItemChecked( 220, true ); |
1171 | if (p-> mShowIconForwardFast) | 1183 | if (p-> mShowIconForwardFast) |
1172 | configureToolBarMenu->setItemChecked( 230, true ); | 1184 | configureToolBarMenu->setItemChecked( 230, true ); |
1173 | if (p-> mShowIconNextDays) | 1185 | if (p-> mShowIconNextDays) |
1174 | configureToolBarMenu->setItemChecked( 100, true ); | 1186 | configureToolBarMenu->setItemChecked( 100, true ); |
1175 | if (p-> mShowIconNext) | 1187 | if (p-> mShowIconNext) |
1176 | configureToolBarMenu->setItemChecked( 110, true ); | 1188 | configureToolBarMenu->setItemChecked( 110, true ); |
1177 | if (p-> mShowIconJournal) | 1189 | if (p-> mShowIconJournal) |
1178 | configureToolBarMenu->setItemChecked( 90, true ); | 1190 | configureToolBarMenu->setItemChecked( 90, true ); |
1179 | if (p-> mShowIconWhatsThis) | 1191 | if (p-> mShowIconWhatsThis) |
1180 | configureToolBarMenu->setItemChecked( 300, true ); | 1192 | configureToolBarMenu->setItemChecked( 300, true ); |
1181 | if (p-> mShowIconWeekNum) | 1193 | if (p-> mShowIconWeekNum) |
1182 | configureToolBarMenu->setItemChecked( 400, true ); | 1194 | configureToolBarMenu->setItemChecked( 400, true ); |
1183 | if (!p-> mShowIconStretch) { | 1195 | if (!p-> mShowIconStretch) { |
1184 | QLabel* dummy = new QLabel( iconToolBar ); | 1196 | QLabel* dummy = new QLabel( iconToolBar ); |
1185 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1197 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1186 | dummy->setMinimumWidth( 0 ); | 1198 | dummy->setMinimumWidth( 0 ); |
1187 | iconToolBar->setStretchableWidget ( dummy ) ; | 1199 | iconToolBar->setStretchableWidget ( dummy ) ; |
1188 | } | 1200 | } |
1189 | else { | 1201 | else { |
1190 | iconToolBar->setHorizontalStretchable (true ); | 1202 | iconToolBar->setHorizontalStretchable (true ); |
1191 | viewToolBar->setHorizontalStretchable (true ); | 1203 | viewToolBar->setHorizontalStretchable (true ); |
1192 | navigatorToolBar->setHorizontalStretchable (true ); | 1204 | navigatorToolBar->setHorizontalStretchable (true ); |
1193 | iconToolBar->setVerticalStretchable (true ); | 1205 | iconToolBar->setVerticalStretchable (true ); |
1194 | viewToolBar->setVerticalStretchable (true ); | 1206 | viewToolBar->setVerticalStretchable (true ); |
1195 | navigatorToolBar->setVerticalStretchable (true ); | 1207 | navigatorToolBar->setVerticalStretchable (true ); |
1196 | configureToolBarMenu->setItemChecked( 5, true ); | 1208 | configureToolBarMenu->setItemChecked( 5, true ); |
1197 | } | 1209 | } |
1198 | if (p-> mShowIconFilter) | 1210 | if (p-> mShowIconFilter) |
1199 | configureToolBarMenu->setItemChecked( 7, true ); | 1211 | configureToolBarMenu->setItemChecked( 7, true ); |
1200 | if (p-> mShowIconOnetoolbar) | 1212 | if (p-> mShowIconOnetoolbar) |
1201 | configureToolBarMenu->setItemChecked( 6, true ); | 1213 | configureToolBarMenu->setItemChecked( 6, true ); |
1202 | 1214 | ||
1203 | 1215 | ||
1204 | if ( filterMenubar ) | 1216 | if ( filterMenubar ) |
1205 | connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); | 1217 | connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); |
1206 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1218 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1207 | configureAgenda( p->mHourSize ); | 1219 | configureAgenda( p->mHourSize ); |
1208 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1220 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1209 | } | 1221 | } |
1210 | 1222 | ||
1211 | void MainWindow::exportToPhone( int mode ) | 1223 | void MainWindow::exportToPhone( int mode ) |
1212 | { | 1224 | { |
1213 | 1225 | ||
1214 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1226 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1215 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1227 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1216 | KOex2phonePrefs ex2phone; | 1228 | KOex2phonePrefs ex2phone; |
1217 | 1229 | ||
1218 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1230 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1219 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1231 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1220 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1232 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1221 | if ( mode == 1 ) | 1233 | if ( mode == 1 ) |
1222 | ex2phone.setCaption(i18n("Export complete calendar")); | 1234 | ex2phone.setCaption(i18n("Export complete calendar")); |
1223 | if ( mode == 2 ) | 1235 | if ( mode == 2 ) |
1224 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1236 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1225 | 1237 | ||
1226 | if ( !ex2phone.exec() ) { | 1238 | if ( !ex2phone.exec() ) { |
1227 | return; | 1239 | return; |
1228 | } | 1240 | } |
1229 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1241 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1230 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1242 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1231 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1243 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1232 | 1244 | ||
1233 | int inFuture = 0; | 1245 | int inFuture = 0; |
1234 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1246 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1235 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1247 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1236 | QPtrList<Incidence> delSel; | 1248 | QPtrList<Incidence> delSel; |
1237 | if ( mode == 1 ) | 1249 | if ( mode == 1 ) |
1238 | delSel = mCalendar->rawIncidences(); | 1250 | delSel = mCalendar->rawIncidences(); |
1239 | if ( mode == 2 ) | 1251 | if ( mode == 2 ) |
1240 | delSel = mCalendar->incidences(); | 1252 | delSel = mCalendar->incidences(); |
1241 | CalendarLocal* cal = new CalendarLocal(); | 1253 | CalendarLocal* cal = new CalendarLocal(); |
1242 | cal->setLocalTime(); | 1254 | cal->setLocalTime(); |
1243 | Incidence *incidence = delSel.first(); | 1255 | Incidence *incidence = delSel.first(); |
1244 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1256 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1245 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1257 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1246 | while ( incidence ) { | 1258 | while ( incidence ) { |
1247 | if ( incidence->type() != "Journal" ) { | 1259 | if ( incidence->type() != "Journal" ) { |
1248 | bool add = true; | 1260 | bool add = true; |
1249 | if ( inFuture ) { | 1261 | if ( inFuture ) { |
1250 | QDateTime dt; | 1262 | QDateTime dt; |
1251 | if ( incidence->type() == "Todo" ) { | 1263 | if ( incidence->type() == "Todo" ) { |
1252 | Todo * t = (Todo*)incidence; | 1264 | Todo * t = (Todo*)incidence; |
1253 | if ( t->hasDueDate() ) | 1265 | if ( t->hasDueDate() ) |
1254 | dt = t->dtDue(); | 1266 | dt = t->dtDue(); |
1255 | else | 1267 | else |
1256 | dt = cur.addSecs( 62 ); | 1268 | dt = cur.addSecs( 62 ); |
1257 | } | 1269 | } |
1258 | else { | 1270 | else { |
1259 | bool ok; | 1271 | bool ok; |
1260 | dt = incidence->getNextOccurence( cur, &ok ); | 1272 | dt = incidence->getNextOccurence( cur, &ok ); |
1261 | if ( !ok ) | 1273 | if ( !ok ) |
1262 | dt = cur.addSecs( -62 ); | 1274 | dt = cur.addSecs( -62 ); |
1263 | } | 1275 | } |
1264 | if ( dt < cur || dt > end ) { | 1276 | if ( dt < cur || dt > end ) { |
1265 | add = false; | 1277 | add = false; |
1266 | } | 1278 | } |
1267 | } | 1279 | } |
1268 | if ( add ) { | 1280 | if ( add ) { |
1269 | Incidence *in = incidence->clone(); | 1281 | Incidence *in = incidence->clone(); |
1270 | cal->addIncidence( in ); | 1282 | cal->addIncidence( in ); |
1271 | } | 1283 | } |
1272 | } | 1284 | } |
1273 | incidence = delSel.next(); | 1285 | incidence = delSel.next(); |
1274 | } | 1286 | } |
1275 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1287 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1276 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1288 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1277 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1289 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1278 | 1290 | ||
1279 | setCaption( i18n("Writing to phone...")); | 1291 | setCaption( i18n("Writing to phone...")); |
1280 | if ( PhoneFormat::writeToPhone( cal ) ) | 1292 | if ( PhoneFormat::writeToPhone( cal ) ) |
1281 | setCaption( i18n("Export to phone successful!")); | 1293 | setCaption( i18n("Export to phone successful!")); |
1282 | else | 1294 | else |
1283 | setCaption( i18n("Error exporting to phone!")); | 1295 | setCaption( i18n("Error exporting to phone!")); |
1284 | delete cal; | 1296 | delete cal; |
1285 | } | 1297 | } |
1286 | 1298 | ||
1287 | 1299 | ||
1288 | void MainWindow::setDefaultPreferences() | 1300 | void MainWindow::setDefaultPreferences() |
1289 | { | 1301 | { |
1290 | KOPrefs *p = KOPrefs::instance(); | 1302 | KOPrefs *p = KOPrefs::instance(); |
1291 | 1303 | ||
1292 | p->mCompactDialogs = true; | 1304 | p->mCompactDialogs = true; |
1293 | p->mConfirm = true; | 1305 | p->mConfirm = true; |
1294 | // p->mEnableQuickTodo = false; | 1306 | // p->mEnableQuickTodo = false; |
1295 | 1307 | ||
1296 | } | 1308 | } |
1297 | 1309 | ||
1298 | QString MainWindow::resourcePath() | 1310 | QString MainWindow::resourcePath() |
1299 | { | 1311 | { |
1300 | return KGlobal::iconLoader()->iconPath(); | 1312 | return KGlobal::iconLoader()->iconPath(); |
1301 | } | 1313 | } |
1302 | 1314 | ||
1303 | void MainWindow::displayText( QString text ,QString cap ) | 1315 | void MainWindow::displayText( QString text ,QString cap ) |
1304 | { | 1316 | { |
1305 | QDialog dia( this, "name", true ); ; | 1317 | QDialog dia( this, "name", true ); ; |
1306 | dia.setCaption( cap ); | 1318 | dia.setCaption( cap ); |
1307 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1319 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1308 | lay->setSpacing( 3 ); | 1320 | lay->setSpacing( 3 ); |
1309 | lay->setMargin( 3 ); | 1321 | lay->setMargin( 3 ); |
1310 | QTextBrowser tb ( &dia ); | 1322 | QTextBrowser tb ( &dia ); |
1311 | lay->addWidget( &tb ); | 1323 | lay->addWidget( &tb ); |
1312 | tb.setText( text ); | 1324 | tb.setText( text ); |
1313 | #ifdef DESKTOP_VERSION | 1325 | #ifdef DESKTOP_VERSION |
1314 | dia.resize( 640, 480); | 1326 | dia.resize( 640, 480); |
1315 | #else | 1327 | #else |
1316 | dia.showMaximized(); | 1328 | dia.showMaximized(); |
1317 | #endif | 1329 | #endif |
1318 | dia.exec(); | 1330 | dia.exec(); |
1319 | } | 1331 | } |
1320 | 1332 | ||
1321 | void MainWindow::features() | 1333 | void MainWindow::features() |
1322 | { | 1334 | { |
1323 | 1335 | ||
1324 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1336 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1325 | } | 1337 | } |
1326 | 1338 | ||
1327 | void MainWindow::usertrans() | 1339 | void MainWindow::usertrans() |
1328 | { | 1340 | { |
1329 | 1341 | ||
1330 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1342 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1331 | } | 1343 | } |
1332 | 1344 | ||
1333 | void MainWindow::kdesynchowto() | 1345 | void MainWindow::kdesynchowto() |
1334 | { | 1346 | { |
1335 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1347 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1336 | } | 1348 | } |
1337 | void MainWindow::multisynchowto() | 1349 | void MainWindow::multisynchowto() |
1338 | { | 1350 | { |
1339 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1351 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1340 | } | 1352 | } |
1341 | void MainWindow::synchowto() | 1353 | void MainWindow::synchowto() |
1342 | { | 1354 | { |
1343 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1355 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1344 | } | 1356 | } |
1345 | void MainWindow::faq() | 1357 | void MainWindow::faq() |
1346 | { | 1358 | { |
1347 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1359 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1348 | 1360 | ||
1349 | } | 1361 | } |
1350 | void MainWindow::whatsNew() | 1362 | void MainWindow::whatsNew() |
1351 | { | 1363 | { |
1352 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1364 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1353 | 1365 | ||
1354 | } | 1366 | } |
1355 | void MainWindow::licence() | 1367 | void MainWindow::licence() |
1356 | { | 1368 | { |
1357 | KApplication::showLicence(); | 1369 | KApplication::showLicence(); |
1358 | 1370 | ||
1359 | } | 1371 | } |
1360 | void MainWindow::about() | 1372 | void MainWindow::about() |
1361 | { | 1373 | { |
1362 | QString version; | 1374 | QString version; |
1363 | #include <../version> | 1375 | #include <../version> |
1364 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1376 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1365 | i18n("KOrganizer/Platform-independent\n") + | 1377 | i18n("KOrganizer/Platform-independent\n") + |
1366 | "(KO/Pi) " + version + " - " + | 1378 | "(KO/Pi) " + version + " - " + |
1367 | 1379 | ||
1368 | #ifdef DESKTOP_VERSION | 1380 | #ifdef DESKTOP_VERSION |
1369 | i18n("Desktop Edition\n") + | 1381 | i18n("Desktop Edition\n") + |
1370 | #else | 1382 | #else |
1371 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1383 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1372 | #endif | 1384 | #endif |
1373 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); | 1385 | i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); |
1374 | } | 1386 | } |
1375 | void MainWindow::keyBindings() | 1387 | void MainWindow::keyBindings() |
1376 | { | 1388 | { |
1377 | QString cap = i18n("KO/Pi Keys + Colors"); | 1389 | QString cap = i18n("KO/Pi Keys + Colors"); |
1378 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1390 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1379 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1391 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1380 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1392 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1381 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1393 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1382 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1394 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1383 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1395 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1384 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1396 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1385 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1397 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1386 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1398 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1387 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1399 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1388 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1400 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1389 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1401 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1390 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1402 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1391 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1403 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1392 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1404 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1393 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1405 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1394 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1406 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1395 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1407 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1396 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1408 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1397 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1409 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1398 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1410 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1399 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1411 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1400 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1412 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1401 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1413 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1402 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1414 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1403 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1415 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1404 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1416 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1405 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1417 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1406 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1418 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1407 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1419 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1408 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1420 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1409 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1421 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1410 | i18n("<p><h3>In list view:</h3></p>\n") + | 1422 | i18n("<p><h3>In list view:</h3></p>\n") + |
1411 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1423 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1412 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1424 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1413 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1425 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1414 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1426 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1415 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1427 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1416 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1428 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1417 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1429 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1418 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1430 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1419 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1431 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1420 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1432 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1421 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1433 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1422 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1434 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1423 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1435 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1424 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1436 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1425 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1437 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1426 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1438 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1427 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1439 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1428 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1440 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1429 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1441 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1430 | displayText( text, cap); | 1442 | displayText( text, cap); |
1431 | } | 1443 | } |
1432 | void MainWindow::aboutAutoSaving() | 1444 | void MainWindow::aboutAutoSaving() |
1433 | { | 1445 | { |
1434 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); | 1446 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); |
1435 | 1447 | ||
1436 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1448 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1437 | 1449 | ||
1438 | } | 1450 | } |
1439 | void MainWindow::aboutKnownBugs() | 1451 | void MainWindow::aboutKnownBugs() |
1440 | { | 1452 | { |
1441 | QMessageBox* msg; | 1453 | QMessageBox* msg; |
1442 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1454 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1443 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1455 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1444 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1456 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1445 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1457 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1446 | i18n("\nor report them in the bugtracker on\n") + | 1458 | i18n("\nor report them in the bugtracker on\n") + |
1447 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1459 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1448 | QMessageBox::NoIcon, | 1460 | QMessageBox::NoIcon, |
1449 | QMessageBox::Ok, | 1461 | QMessageBox::Ok, |
1450 | QMessageBox::NoButton, | 1462 | QMessageBox::NoButton, |
1451 | QMessageBox::NoButton); | 1463 | QMessageBox::NoButton); |
1452 | msg->exec(); | 1464 | msg->exec(); |
1453 | delete msg; | 1465 | delete msg; |
1454 | 1466 | ||
1455 | } | 1467 | } |
1456 | 1468 | ||
1457 | QString MainWindow::defaultFileName() | 1469 | QString MainWindow::defaultFileName() |
1458 | { | 1470 | { |
1459 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1471 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1460 | } | 1472 | } |
1461 | QString MainWindow::syncFileName() | 1473 | QString MainWindow::syncFileName() |
1462 | { | 1474 | { |
1463 | #ifdef DESKTOP_VERSION | 1475 | #ifdef DESKTOP_VERSION |
1464 | return locateLocal( "tmp", "synccalendar.ics" ); | 1476 | return locateLocal( "tmp", "synccalendar.ics" ); |
1465 | #else | 1477 | #else |
1466 | return QString( "/tmp/synccalendar.ics" ); | 1478 | return QString( "/tmp/synccalendar.ics" ); |
1467 | #endif | 1479 | #endif |
1468 | } | 1480 | } |
1469 | void MainWindow::updateWeek(QDate seda) | 1481 | void MainWindow::updateWeek(QDate seda) |
1470 | { | 1482 | { |
1471 | int weekNum = 0; | 1483 | int weekNum = 0; |
1472 | QDate d = QDate ( seda.year(), 1,1); | 1484 | QDate d = QDate ( seda.year(), 1,1); |
1473 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday | 1485 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday |
1474 | if ( seda.addDays(6).year() != seda.year() ) { | 1486 | if ( seda.addDays(6).year() != seda.year() ) { |
1475 | if ( seda.year() != d.year() ) { | 1487 | if ( seda.year() != d.year() ) { |
1476 | if ( d.dayOfWeek() > 4 ) | 1488 | if ( d.dayOfWeek() > 4 ) |
1477 | d = QDate ( seda.year(), 1,1); | 1489 | d = QDate ( seda.year(), 1,1); |
1478 | else | 1490 | else |
1479 | weekNum = 1; | 1491 | weekNum = 1; |
1480 | } else { | 1492 | } else { |
1481 | QDate dd( seda.year()+1, 1,1); | 1493 | QDate dd( seda.year()+1, 1,1); |
1482 | if ( dd.dayOfWeek() <= 4 ) | 1494 | if ( dd.dayOfWeek() <= 4 ) |
1483 | weekNum = 1; | 1495 | weekNum = 1; |
1484 | } | 1496 | } |
1485 | } | 1497 | } |
1486 | if ( weekNum == 0 ){ | 1498 | if ( weekNum == 0 ){ |
1487 | int dow = d.dayOfWeek(); | 1499 | int dow = d.dayOfWeek(); |
1488 | if ( dow <= 4 ) | 1500 | if ( dow <= 4 ) |
1489 | d = d.addDays( 1-dow ); | 1501 | d = d.addDays( 1-dow ); |
1490 | else // 5,6,7 | 1502 | else // 5,6,7 |
1491 | d = d.addDays( 8-dow ); | 1503 | d = d.addDays( 8-dow ); |
1492 | // we have the first week of the year.we are on monday | 1504 | // we have the first week of the year.we are on monday |
1493 | weekNum = d.daysTo( seda ) / 7 +1; | 1505 | weekNum = d.daysTo( seda ) / 7 +1; |
1494 | } | 1506 | } |
1495 | 1507 | ||
1496 | mWeekPixmap.fill( mWeekBgColor ); | 1508 | mWeekPixmap.fill( mWeekBgColor ); |
1497 | QPainter p ( &mWeekPixmap ); | 1509 | QPainter p ( &mWeekPixmap ); |
1498 | p.setFont( mWeekFont ); | 1510 | p.setFont( mWeekFont ); |
1499 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1511 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1500 | p.end(); | 1512 | p.end(); |
1501 | QIconSet icon3 ( mWeekPixmap ); | 1513 | QIconSet icon3 ( mWeekPixmap ); |
1502 | mWeekAction->setIconSet ( icon3 ); | 1514 | mWeekAction->setIconSet ( icon3 ); |
1503 | 1515 | ||
1504 | } | 1516 | } |
1505 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1517 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1506 | { | 1518 | { |
1507 | updateWeek( selectedDates.first() ); | 1519 | updateWeek( selectedDates.first() ); |
1508 | } | 1520 | } |
1509 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1521 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1510 | { | 1522 | { |
1511 | 1523 | ||
1512 | if ( !incidence ) { | 1524 | if ( !incidence ) { |
1513 | enableIncidenceActions( false ); | 1525 | enableIncidenceActions( false ); |
1514 | 1526 | ||
1515 | mNewSubTodoAction->setEnabled( false ); | 1527 | mNewSubTodoAction->setEnabled( false ); |
1516 | setCaptionToDates(); | 1528 | setCaptionToDates(); |
1517 | return; | 1529 | return; |
1518 | 1530 | ||
1519 | } | 1531 | } |
1520 | 1532 | ||
1521 | //KGlobal::locale()->formatDateTime(nextA, true); | 1533 | //KGlobal::locale()->formatDateTime(nextA, true); |
1522 | QString startString = ""; | 1534 | QString startString = ""; |
1523 | if ( incidence->type() != "Todo" ) { | 1535 | if ( incidence->type() != "Todo" ) { |
1524 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1536 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1525 | if ( incidence->doesFloat() ) { | 1537 | if ( incidence->doesFloat() ) { |
1526 | startString += ": "+incidence->dtStartDateStr( true ); | 1538 | startString += ": "+incidence->dtStartDateStr( true ); |
1527 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1539 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1528 | 1540 | ||
1529 | } else { | 1541 | } else { |
1530 | startString = ": "+incidence->dtStartStr(true); | 1542 | startString = ": "+incidence->dtStartStr(true); |
1531 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1543 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1532 | 1544 | ||
1533 | } | 1545 | } |
1534 | 1546 | ||
1535 | } else { | 1547 | } else { |
1536 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1548 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1537 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1549 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1538 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1550 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1539 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { | 1551 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { |
1540 | bool ok; | 1552 | bool ok; |
1541 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1553 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1542 | if ( ok ) { | 1554 | if ( ok ) { |
1543 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1555 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1544 | startString += i18n(" (%1 y.)"). arg( years ); | 1556 | startString += i18n(" (%1 y.)"). arg( years ); |
1545 | } | 1557 | } |
1546 | } | 1558 | } |
1547 | else | 1559 | else |
1548 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1560 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1549 | } | 1561 | } |
1550 | 1562 | ||
1551 | } | 1563 | } |
1552 | else | 1564 | else |
1553 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1565 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1554 | if ( !incidence->location().isEmpty() ) | 1566 | if ( !incidence->location().isEmpty() ) |
1555 | startString += " (" +incidence->location()+")"; | 1567 | startString += " (" +incidence->location()+")"; |
1556 | setCaption( incidence->summary()+startString); | 1568 | setCaption( incidence->summary()+startString); |
1557 | 1569 | ||
1558 | enableIncidenceActions( true ); | 1570 | enableIncidenceActions( true ); |
1559 | 1571 | ||
1560 | if ( incidence->type() == "Event" ) { | 1572 | if ( incidence->type() == "Event" ) { |
1561 | mShowAction->setText( i18n("Show Event...") ); | 1573 | mShowAction->setText( i18n("Show Event...") ); |
1562 | mEditAction->setText( i18n("Edit Event...") ); | 1574 | mEditAction->setText( i18n("Edit Event...") ); |
1563 | mDeleteAction->setText( i18n("Delete Event...") ); | 1575 | mDeleteAction->setText( i18n("Delete Event...") ); |
1564 | 1576 | ||
1565 | mNewSubTodoAction->setEnabled( false ); | 1577 | mNewSubTodoAction->setEnabled( false ); |
1566 | } else if ( incidence->type() == "Todo" ) { | 1578 | } else if ( incidence->type() == "Todo" ) { |
1567 | mShowAction->setText( i18n("Show Todo...") ); | 1579 | mShowAction->setText( i18n("Show Todo...") ); |
1568 | mEditAction->setText( i18n("Edit Todo...") ); | 1580 | mEditAction->setText( i18n("Edit Todo...") ); |
1569 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1581 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1570 | 1582 | ||
1571 | mNewSubTodoAction->setEnabled( true ); | 1583 | mNewSubTodoAction->setEnabled( true ); |
1572 | } else { | 1584 | } else { |
1573 | mShowAction->setText( i18n("Show...") ); | 1585 | mShowAction->setText( i18n("Show...") ); |
1574 | mShowAction->setText( i18n("Edit...") ); | 1586 | mShowAction->setText( i18n("Edit...") ); |
1575 | mShowAction->setText( i18n("Delete...") ); | 1587 | mShowAction->setText( i18n("Delete...") ); |
1576 | 1588 | ||
1577 | mNewSubTodoAction->setEnabled( false ); | 1589 | mNewSubTodoAction->setEnabled( false ); |
1578 | } | 1590 | } |
1579 | } | 1591 | } |
1580 | 1592 | ||
1581 | void MainWindow::enableIncidenceActions( bool enabled ) | 1593 | void MainWindow::enableIncidenceActions( bool enabled ) |
1582 | { | 1594 | { |
1583 | mShowAction->setEnabled( enabled ); | 1595 | mShowAction->setEnabled( enabled ); |
1584 | mEditAction->setEnabled( enabled ); | 1596 | mEditAction->setEnabled( enabled ); |
1585 | mDeleteAction->setEnabled( enabled ); | 1597 | mDeleteAction->setEnabled( enabled ); |
1586 | 1598 | ||
1587 | mCloneAction->setEnabled( enabled ); | 1599 | mCloneAction->setEnabled( enabled ); |
1588 | mMoveAction->setEnabled( enabled ); | 1600 | mMoveAction->setEnabled( enabled ); |
1589 | mBeamAction->setEnabled( enabled ); | 1601 | mBeamAction->setEnabled( enabled ); |
1590 | mCancelAction->setEnabled( enabled ); | 1602 | mCancelAction->setEnabled( enabled ); |
1591 | } | 1603 | } |
1592 | 1604 | ||
1593 | void MainWindow::importOL() | 1605 | void MainWindow::importOL() |
1594 | { | 1606 | { |
1595 | #ifdef _OL_IMPORT_ | 1607 | #ifdef _OL_IMPORT_ |
1596 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1608 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1597 | id->exec(); | 1609 | id->exec(); |
1598 | delete id; | 1610 | delete id; |
1599 | mView->updateView(); | 1611 | mView->updateView(); |
1600 | #endif | 1612 | #endif |
1601 | } | 1613 | } |
1602 | void MainWindow::importBday() | 1614 | void MainWindow::importBday() |
1603 | { | 1615 | { |
1604 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1616 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1605 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1617 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1606 | i18n("Import!"), i18n("Cancel"), 0, | 1618 | i18n("Import!"), i18n("Cancel"), 0, |
1607 | 0, 1 ); | 1619 | 0, 1 ); |
1608 | if ( result == 0 ) { | 1620 | if ( result == 0 ) { |
1609 | mView->importBday(); | 1621 | mView->importBday(); |
1610 | 1622 | ||
1611 | } | 1623 | } |
1612 | 1624 | ||
1613 | 1625 | ||
1614 | } | 1626 | } |
1615 | void MainWindow::importQtopia() | 1627 | void MainWindow::importQtopia() |
1616 | { | 1628 | { |
1617 | //#ifndef DESKTOP_VERSION | 1629 | //#ifndef DESKTOP_VERSION |
1618 | QString mess = 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"); | 1630 | QString mess = 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"); |
1619 | #ifdef DESKTOP_VERSION | 1631 | #ifdef DESKTOP_VERSION |
1620 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); | 1632 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); |
1621 | #endif | 1633 | #endif |
1622 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1634 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1623 | i18n("Import!"), i18n("Cancel"), 0, | 1635 | i18n("Import!"), i18n("Cancel"), 0, |
1624 | 0, 1 ); | 1636 | 0, 1 ); |
1625 | if ( result == 0 ) { | 1637 | if ( result == 0 ) { |
1626 | #ifndef DESKTOP_VERSION | 1638 | #ifndef DESKTOP_VERSION |
1627 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1639 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1628 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1640 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1629 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1641 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1630 | #else | 1642 | #else |
1631 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1643 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1632 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1644 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1633 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1645 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1634 | #endif | 1646 | #endif |
1635 | mView->importQtopia( categories, datebook, todolist ); | 1647 | mView->importQtopia( categories, datebook, todolist ); |
1636 | } | 1648 | } |
1637 | #if 0 | 1649 | #if 0 |
1638 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1650 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1639 | i18n("Not supported \non desktop!\n"), | 1651 | i18n("Not supported \non desktop!\n"), |
1640 | i18n("Ok"), i18n("Cancel"), 0, | 1652 | i18n("Ok"), i18n("Cancel"), 0, |
1641 | 0, 1 ); | 1653 | 0, 1 ); |
1642 | 1654 | ||
1643 | #endif | 1655 | #endif |
1644 | } | 1656 | } |
1645 | 1657 | ||
1646 | void MainWindow::saveOnClose() | 1658 | void MainWindow::saveOnClose() |
1647 | { | 1659 | { |
1648 | KOPrefs *p = KOPrefs::instance(); | 1660 | KOPrefs *p = KOPrefs::instance(); |
1649 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1661 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1650 | if ( p->mToolBarHor ) | 1662 | if ( p->mToolBarHor ) |
1651 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1663 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1652 | else | 1664 | else |
1653 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1665 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1654 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1666 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1655 | if ( p->mToolBarHorV ) | 1667 | if ( p->mToolBarHorV ) |
1656 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1668 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1657 | else | 1669 | else |
1658 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1670 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1659 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1671 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1660 | if ( p->mToolBarHorN ) | 1672 | if ( p->mToolBarHorN ) |
1661 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1673 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1662 | else | 1674 | else |
1663 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1675 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1664 | if ( filterToolBar ) { | 1676 | if ( filterToolBar ) { |
1665 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1677 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1666 | if ( p->mToolBarHorF ) | 1678 | if ( p->mToolBarHorF ) |
1667 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1679 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1668 | else | 1680 | else |
1669 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1681 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1670 | } | 1682 | } |
1671 | mView->writeSettings(); | 1683 | mView->writeSettings(); |
1672 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1684 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1673 | save(); | 1685 | save(); |
1674 | } | 1686 | } |
1675 | void MainWindow::slotModifiedChanged( bool changed ) | 1687 | void MainWindow::slotModifiedChanged( bool changed ) |
1676 | { | 1688 | { |
1677 | if ( mBlockAtStartup ) | 1689 | if ( mBlockAtStartup ) |
1678 | return; | 1690 | return; |
1679 | 1691 | ||
1680 | int msec; | 1692 | int msec; |
1681 | // we store the changes after 1 minute, | 1693 | // we store the changes after 1 minute, |
1682 | // and for safety reasons after 10 minutes again | 1694 | // and for safety reasons after 10 minutes again |
1683 | if ( !mSyncManager->blockSave() ) | 1695 | if ( !mSyncManager->blockSave() ) |
1684 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1696 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1685 | else | 1697 | else |
1686 | msec = 1000 * 600; | 1698 | msec = 1000 * 600; |
1687 | mSaveTimer.start( msec, true ); // 1 minute | 1699 | mSaveTimer.start( msec, true ); // 1 minute |
1688 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1700 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1689 | mCalendarModifiedFlag = true; | 1701 | mCalendarModifiedFlag = true; |
1690 | } | 1702 | } |
1691 | void MainWindow::saveStopTimer() | 1703 | void MainWindow::saveStopTimer() |
1692 | { | 1704 | { |
1693 | mSaveTimer.stop(); | 1705 | mSaveTimer.stop(); |
1694 | if (mSaveTimer.isActive() ) | 1706 | if (mSaveTimer.isActive() ) |
1695 | qDebug("ti active "); | 1707 | qDebug("ti active "); |
1696 | else | 1708 | else |
1697 | qDebug("KO: Save timer stopped"); | 1709 | qDebug("KO: Save timer stopped"); |
1698 | } | 1710 | } |
1699 | void MainWindow::save() | 1711 | void MainWindow::save() |
1700 | { | 1712 | { |
1701 | if ( !mCalendarModifiedFlag ) { | 1713 | if ( !mCalendarModifiedFlag ) { |
1702 | qDebug("KO: Calendar not modified. Nothing saved."); | 1714 | qDebug("KO: Calendar not modified. Nothing saved."); |
1703 | return; | 1715 | return; |
1704 | } | 1716 | } |
1705 | if ( mSyncManager->blockSave() ) | 1717 | if ( mSyncManager->blockSave() ) |
1706 | return; | 1718 | return; |
1707 | mSyncManager->setBlockSave(true); | 1719 | mSyncManager->setBlockSave(true); |
1708 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1720 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1709 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1721 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1710 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1722 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1711 | qDebug("KO: Start saving data to file!"); | 1723 | qDebug("KO: Start saving data to file!"); |
1712 | mView->saveCalendar( defaultFileName() ); | 1724 | mView->saveCalendar( defaultFileName() ); |
1713 | mCalendarModifiedFlag = false; | 1725 | mCalendarModifiedFlag = false; |
1714 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1726 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1715 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1727 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1716 | QString savemes; | 1728 | QString savemes; |
1717 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1729 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1718 | setCaption(savemes); | 1730 | setCaption(savemes); |
1719 | } else | 1731 | } else |
1720 | setCaption(i18n("Saving cancelled!")); | 1732 | setCaption(i18n("Saving cancelled!")); |
1721 | mSyncManager->setBlockSave( false ); | 1733 | mSyncManager->setBlockSave( false ); |
1722 | } | 1734 | } |
1723 | 1735 | ||
1724 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1736 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1725 | { | 1737 | { |
1726 | if ( !e->isAutoRepeat() ) { | 1738 | if ( !e->isAutoRepeat() ) { |
1727 | mFlagKeyPressed = false; | 1739 | mFlagKeyPressed = false; |
1728 | } | 1740 | } |
1729 | } | 1741 | } |
1730 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1742 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1731 | { | 1743 | { |
1732 | qApp->processEvents(); | 1744 | qApp->processEvents(); |
1733 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1745 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1734 | e->ignore(); | 1746 | e->ignore(); |
1735 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1747 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1736 | return; | 1748 | return; |
1737 | } | 1749 | } |
1738 | if (! e->isAutoRepeat() ) | 1750 | if (! e->isAutoRepeat() ) |
1739 | mFlagKeyPressed = true; | 1751 | mFlagKeyPressed = true; |
1740 | KOPrefs *p = KOPrefs::instance(); | 1752 | KOPrefs *p = KOPrefs::instance(); |
1741 | bool showSelectedDates = false; | 1753 | bool showSelectedDates = false; |
1742 | int size; | 1754 | int size; |
1743 | int pro = 0; | 1755 | int pro = 0; |
1744 | //qDebug("MainWindow::keyPressEvent "); | 1756 | //qDebug("MainWindow::keyPressEvent "); |
1745 | switch ( e->key() ) { | 1757 | switch ( e->key() ) { |
1746 | case Qt::Key_Right: | 1758 | case Qt::Key_Right: |
1747 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1759 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1748 | mView->goNextMonth(); | 1760 | mView->goNextMonth(); |
1749 | else | 1761 | else |
1750 | mView->goNext(); | 1762 | mView->goNext(); |
1751 | showSelectedDates = true; | 1763 | showSelectedDates = true; |
1752 | break; | 1764 | break; |
1753 | case Qt::Key_Left: | 1765 | case Qt::Key_Left: |
1754 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1766 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1755 | mView->goPreviousMonth(); | 1767 | mView->goPreviousMonth(); |
1756 | else | 1768 | else |
1757 | mView->goPrevious(); | 1769 | mView->goPrevious(); |
1758 | showSelectedDates = true; | 1770 | showSelectedDates = true; |
1759 | break; | 1771 | break; |
1760 | case Qt::Key_Down: | 1772 | case Qt::Key_Down: |
1761 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1773 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1762 | break; | 1774 | break; |
1763 | case Qt::Key_Up: | 1775 | case Qt::Key_Up: |
1764 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1776 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1765 | break; | 1777 | break; |
1766 | case Qt::Key_K: | 1778 | case Qt::Key_K: |
1767 | mView->viewManager()->showMonthViewWeek(); | 1779 | mView->viewManager()->showMonthViewWeek(); |
1768 | break; | 1780 | break; |
1769 | case Qt::Key_I: | 1781 | case Qt::Key_I: |
1770 | mView->showIncidence(); | 1782 | mView->showIncidence(); |
1771 | break; | 1783 | break; |
1772 | case Qt::Key_Delete: | 1784 | case Qt::Key_Delete: |
1773 | case Qt::Key_Backspace: | 1785 | case Qt::Key_Backspace: |
1774 | mView->deleteIncidence(); | 1786 | mView->deleteIncidence(); |
1775 | break; | 1787 | break; |
1776 | case Qt::Key_D: | 1788 | case Qt::Key_D: |
1777 | mView->viewManager()->showDayView(); | 1789 | mView->viewManager()->showDayView(); |
1778 | showSelectedDates = true; | 1790 | showSelectedDates = true; |
1779 | break; | 1791 | break; |
1780 | case Qt::Key_O: | 1792 | case Qt::Key_O: |
1781 | mView->toggleFilerEnabled( ); | 1793 | mView->toggleFilerEnabled( ); |
1782 | break; | 1794 | break; |
1783 | case Qt::Key_0: | 1795 | case Qt::Key_0: |
1784 | case Qt::Key_1: | 1796 | case Qt::Key_1: |
1785 | case Qt::Key_2: | 1797 | case Qt::Key_2: |
1786 | case Qt::Key_3: | 1798 | case Qt::Key_3: |
1787 | case Qt::Key_4: | 1799 | case Qt::Key_4: |
1788 | case Qt::Key_5: | 1800 | case Qt::Key_5: |
1789 | case Qt::Key_6: | 1801 | case Qt::Key_6: |
1790 | case Qt::Key_7: | 1802 | case Qt::Key_7: |
1791 | case Qt::Key_8: | 1803 | case Qt::Key_8: |
1792 | case Qt::Key_9: | 1804 | case Qt::Key_9: |
1793 | pro = e->key()-48; | 1805 | pro = e->key()-48; |
1794 | if ( pro == 0 ) | 1806 | if ( pro == 0 ) |
1795 | pro = 10; | 1807 | pro = 10; |
1796 | if ( e->state() == Qt::ControlButton) | 1808 | if ( e->state() == Qt::ControlButton) |
1797 | pro += 10; | 1809 | pro += 10; |
1798 | break; | 1810 | break; |
1799 | case Qt::Key_M: | 1811 | case Qt::Key_M: |
1800 | mView->viewManager()->showMonthView(); | 1812 | mView->viewManager()->showMonthView(); |
1801 | showSelectedDates = true; | 1813 | showSelectedDates = true; |
1802 | break; | 1814 | break; |
1803 | case Qt::Key_Insert: | 1815 | case Qt::Key_Insert: |
1804 | mView->newEvent(); | 1816 | mView->newEvent(); |
1805 | break; | 1817 | break; |
1806 | case Qt::Key_S : | 1818 | case Qt::Key_S : |
1807 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1819 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1808 | mView->newSubTodo(); | 1820 | mView->newSubTodo(); |
1809 | else | 1821 | else |
1810 | mView->dialogManager()->showSearchDialog(); | 1822 | mView->dialogManager()->showSearchDialog(); |
1811 | break; | 1823 | break; |
1812 | case Qt::Key_Y : | 1824 | case Qt::Key_Y : |
1813 | case Qt::Key_Z : | 1825 | case Qt::Key_Z : |
1814 | mView->viewManager()->showWorkWeekView(); | 1826 | mView->viewManager()->showWorkWeekView(); |
1815 | showSelectedDates = true; | 1827 | showSelectedDates = true; |
1816 | break; | 1828 | break; |
1817 | case Qt::Key_U : | 1829 | case Qt::Key_U : |
1818 | mView->viewManager()->showWeekView(); | 1830 | mView->viewManager()->showWeekView(); |
1819 | showSelectedDates = true; | 1831 | showSelectedDates = true; |
1820 | break; | 1832 | break; |
1821 | case Qt::Key_H : | 1833 | case Qt::Key_H : |
1822 | keyBindings(); | 1834 | keyBindings(); |
1823 | break; | 1835 | break; |
1824 | case Qt::Key_W: | 1836 | case Qt::Key_W: |
1825 | mView->viewManager()->showWhatsNextView(); | 1837 | mView->viewManager()->showWhatsNextView(); |
1826 | break; | 1838 | break; |
1827 | case Qt::Key_L: | 1839 | case Qt::Key_L: |
1828 | mView->viewManager()->showListView(); | 1840 | mView->viewManager()->showListView(); |
1829 | break; | 1841 | break; |
1830 | case Qt::Key_N: | 1842 | case Qt::Key_N: |
1831 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1843 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1832 | mView->viewManager()->showNextView(); | 1844 | mView->viewManager()->showNextView(); |
1833 | else { | 1845 | else { |
1834 | mView->viewManager()->showNextXView(); | 1846 | mView->viewManager()->showNextXView(); |
1835 | showSelectedDates = true; | 1847 | showSelectedDates = true; |
1836 | } | 1848 | } |
1837 | break; | 1849 | break; |
1838 | case Qt::Key_V: | 1850 | case Qt::Key_V: |
1839 | mView->viewManager()->showTodoView(); | 1851 | mView->viewManager()->showTodoView(); |
1840 | break; | 1852 | break; |
1841 | case Qt::Key_C: | 1853 | case Qt::Key_C: |
1842 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1854 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1843 | break; | 1855 | break; |
1844 | case Qt::Key_P: | 1856 | case Qt::Key_P: |
1845 | mView->showDatePicker( ); | 1857 | mView->showDatePicker( ); |
1846 | break; | 1858 | break; |
1847 | case Qt::Key_F: | 1859 | case Qt::Key_F: |
1848 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1860 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1849 | mView->editFilters(); | 1861 | mView->editFilters(); |
1850 | else | 1862 | else |
1851 | mView->toggleFilter(); | 1863 | mView->toggleFilter(); |
1852 | break; | 1864 | break; |
1853 | case Qt::Key_X: | 1865 | case Qt::Key_X: |
1854 | mView->toggleDateNavigatorWidget(); | 1866 | mView->toggleDateNavigatorWidget(); |
1855 | break; | 1867 | break; |
1856 | case Qt::Key_Space: | 1868 | case Qt::Key_Space: |
1857 | mView->toggleExpand(); | 1869 | mView->toggleExpand(); |
1858 | break; | 1870 | break; |
1859 | case Qt::Key_A: | 1871 | case Qt::Key_A: |
1860 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 1872 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
1861 | mView->showNextAlarms(); | 1873 | mView->showNextAlarms(); |
1862 | else | 1874 | else |
1863 | mView->toggleAllDaySize(); | 1875 | mView->toggleAllDaySize(); |
1864 | break; | 1876 | break; |
1865 | case Qt::Key_T: | 1877 | case Qt::Key_T: |
1866 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1878 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1867 | mView->newTodo(); | 1879 | mView->newTodo(); |
1868 | else { | 1880 | else { |
1869 | mView->goToday(); | 1881 | mView->goToday(); |
1870 | showSelectedDates = true; | 1882 | showSelectedDates = true; |
1871 | } | 1883 | } |
1872 | break; | 1884 | break; |
1873 | case Qt::Key_J: | 1885 | case Qt::Key_J: |
1874 | mView->viewManager()->showJournalView(); | 1886 | mView->viewManager()->showJournalView(); |
1875 | break; | 1887 | break; |
1876 | case Qt::Key_B: | 1888 | case Qt::Key_B: |
1877 | mView->editIncidenceDescription();; | 1889 | mView->editIncidenceDescription();; |
1878 | break; | 1890 | break; |
1879 | // case Qt::Key_Return: | 1891 | // case Qt::Key_Return: |
1880 | case Qt::Key_E: | 1892 | case Qt::Key_E: |
1881 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1893 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1882 | mView->newEvent(); | 1894 | mView->newEvent(); |
1883 | else | 1895 | else |
1884 | mView->editIncidence(); | 1896 | mView->editIncidence(); |
1885 | break; | 1897 | break; |
1886 | case Qt::Key_Plus: | 1898 | case Qt::Key_Plus: |
1887 | size = p->mHourSize +2; | 1899 | size = p->mHourSize +2; |
1888 | if ( size <= 22 ) | 1900 | if ( size <= 22 ) |
1889 | configureAgenda( size ); | 1901 | configureAgenda( size ); |
1890 | break; | 1902 | break; |
1891 | case Qt::Key_Minus: | 1903 | case Qt::Key_Minus: |
1892 | size = p->mHourSize - 2; | 1904 | size = p->mHourSize - 2; |
1893 | if ( size >= 4 ) | 1905 | if ( size >= 4 ) |
1894 | configureAgenda( size ); | 1906 | configureAgenda( size ); |
1895 | break; | 1907 | break; |
1896 | 1908 | ||
1897 | 1909 | ||
1898 | default: | 1910 | default: |
1899 | e->ignore(); | 1911 | e->ignore(); |
1900 | } | 1912 | } |
1901 | if ( pro > 0 ) { | 1913 | if ( pro > 0 ) { |
1902 | mView->selectFilter( pro-1 ); | 1914 | mView->selectFilter( pro-1 ); |
1903 | } | 1915 | } |
1904 | if ( showSelectedDates ) { | 1916 | if ( showSelectedDates ) { |
1905 | ;// setCaptionToDates(); | 1917 | ;// setCaptionToDates(); |
1906 | } | 1918 | } |
1907 | 1919 | ||
1908 | } | 1920 | } |
1909 | 1921 | ||
1910 | void MainWindow::fillFilterMenu() | 1922 | void MainWindow::fillFilterMenu() |
1911 | { | 1923 | { |
1912 | selectFilterMenu->clear(); | 1924 | selectFilterMenu->clear(); |
1913 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 1925 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
1914 | selectFilterMenu->insertSeparator(); | 1926 | selectFilterMenu->insertSeparator(); |
1915 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 1927 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
1916 | 1928 | ||
1917 | selectFilterMenu->insertSeparator(); | 1929 | selectFilterMenu->insertSeparator(); |
1918 | QPtrList<CalFilter> fili = mView->filters(); | 1930 | QPtrList<CalFilter> fili = mView->filters(); |
1919 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1931 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1920 | CalFilter *filter = fili.first(); | 1932 | CalFilter *filter = fili.first(); |
1921 | int iii = 2; | 1933 | int iii = 2; |
1922 | bool checkitem = mView->filterView()->filtersEnabled(); | 1934 | bool checkitem = mView->filterView()->filtersEnabled(); |
1923 | while(filter) { | 1935 | while(filter) { |
1924 | selectFilterMenu->insertItem( filter->name(), iii ); | 1936 | selectFilterMenu->insertItem( filter->name(), iii ); |
1925 | if ( filter == curfilter) | 1937 | if ( filter == curfilter) |
1926 | selectFilterMenu->setItemChecked( iii, checkitem ); | 1938 | selectFilterMenu->setItemChecked( iii, checkitem ); |
1927 | filter = fili.next(); | 1939 | filter = fili.next(); |
1928 | ++iii; | 1940 | ++iii; |
1929 | } | 1941 | } |
1930 | if ( !checkitem ) | 1942 | if ( !checkitem ) |
1931 | selectFilterMenu->setItemChecked( 1, true ); | 1943 | selectFilterMenu->setItemChecked( 1, true ); |
1932 | } | 1944 | } |
1933 | void MainWindow::fillFilterMenuPopup() | 1945 | void MainWindow::fillFilterMenuPopup() |
1934 | { | 1946 | { |
1935 | filterPopupMenu->clear(); | 1947 | filterPopupMenu->clear(); |
1936 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 1948 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
1937 | 1949 | ||
1938 | filterPopupMenu->insertSeparator(); | 1950 | filterPopupMenu->insertSeparator(); |
1939 | QPtrList<CalFilter> fili = mView->filters(); | 1951 | QPtrList<CalFilter> fili = mView->filters(); |
1940 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1952 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1941 | CalFilter *filter = fili.first(); | 1953 | CalFilter *filter = fili.first(); |
1942 | int iii = 1; | 1954 | int iii = 1; |
1943 | bool checkitem = mView->filterView()->filtersEnabled(); | 1955 | bool checkitem = mView->filterView()->filtersEnabled(); |
1944 | while(filter) { | 1956 | while(filter) { |
1945 | filterPopupMenu->insertItem( filter->name(), iii ); | 1957 | filterPopupMenu->insertItem( filter->name(), iii ); |
1946 | if ( filter == curfilter) | 1958 | if ( filter == curfilter) |
1947 | filterPopupMenu->setItemChecked( iii, checkitem ); | 1959 | filterPopupMenu->setItemChecked( iii, checkitem ); |
1948 | filter = fili.next(); | 1960 | filter = fili.next(); |
1949 | ++iii; | 1961 | ++iii; |
1950 | } | 1962 | } |
1951 | if ( !checkitem ) | 1963 | if ( !checkitem ) |
1952 | filterPopupMenu->setItemChecked( 0, true ); | 1964 | filterPopupMenu->setItemChecked( 0, true ); |
1953 | } | 1965 | } |
1954 | void MainWindow::selectFilter( int fil ) | 1966 | void MainWindow::selectFilter( int fil ) |
1955 | { | 1967 | { |
1956 | 1968 | ||
1957 | if ( fil == 0 ) { | 1969 | if ( fil == 0 ) { |
1958 | mView->editFilters( ); | 1970 | mView->editFilters( ); |
1959 | } else if ( fil == 1 ){ | 1971 | } else if ( fil == 1 ){ |
1960 | if ( mView->filterView()->filtersEnabled() ) | 1972 | if ( mView->filterView()->filtersEnabled() ) |
1961 | mView->toggleFilerEnabled( ); | 1973 | mView->toggleFilerEnabled( ); |
1962 | } else { | 1974 | } else { |
1963 | if ( !mView->filterView()->filtersEnabled() ) { | 1975 | if ( !mView->filterView()->filtersEnabled() ) { |
1964 | mView->filterView()->blockSignals( true ); | 1976 | mView->filterView()->blockSignals( true ); |
1965 | mView->toggleFilerEnabled( ); | 1977 | mView->toggleFilerEnabled( ); |
1966 | mView->filterView()->blockSignals( false ); | 1978 | mView->filterView()->blockSignals( false ); |
1967 | } | 1979 | } |
1968 | mView->selectFilter( fil-2 ); | 1980 | mView->selectFilter( fil-2 ); |
1969 | } | 1981 | } |
1970 | } | 1982 | } |
1971 | void MainWindow::updateFilterToolbar() | 1983 | void MainWindow::updateFilterToolbar() |
1972 | { | 1984 | { |
1973 | if ( filterMenubar ) { | 1985 | if ( filterMenubar ) { |
1974 | if ( !mView->filterView()->filtersEnabled() ) { | 1986 | if ( !mView->filterView()->filtersEnabled() ) { |
1975 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 1987 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
1976 | } else { | 1988 | } else { |
1977 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1989 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1978 | if ( curfilter ) { | 1990 | if ( curfilter ) { |
1979 | filterMenubar->changeItem( 0, curfilter->name() ); | 1991 | filterMenubar->changeItem( 0, curfilter->name() ); |
1980 | } | 1992 | } |
1981 | } | 1993 | } |
1982 | } | 1994 | } |
1983 | } | 1995 | } |
1984 | void MainWindow::selectFilterPopup( int fil ) | 1996 | void MainWindow::selectFilterPopup( int fil ) |
1985 | { | 1997 | { |
1986 | selectFilter( fil + 1 ); | 1998 | selectFilter( fil + 1 ); |
1987 | 1999 | ||
1988 | } | 2000 | } |
1989 | void MainWindow::configureToolBar( int item ) | 2001 | void MainWindow::configureToolBar( int item ) |
1990 | { | 2002 | { |
1991 | 2003 | ||
1992 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2004 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1993 | KOPrefs *p = KOPrefs::instance(); | 2005 | KOPrefs *p = KOPrefs::instance(); |
1994 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2006 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1995 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2007 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
1996 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2008 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
1997 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2009 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1998 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2010 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1999 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2011 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2000 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2012 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2001 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2013 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2002 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2014 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2003 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2015 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2004 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2016 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2005 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2017 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2006 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2018 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2007 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2019 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2008 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2020 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2009 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2021 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2010 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2022 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2011 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2023 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2012 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2024 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2013 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2025 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2014 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2026 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2015 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2027 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2016 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2028 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2017 | // initActions(); | 2029 | // initActions(); |
2018 | } | 2030 | } |
2019 | void MainWindow::setCaption ( const QString & c ) | 2031 | void MainWindow::setCaption ( const QString & c ) |
2020 | { | 2032 | { |
2021 | QString cap = c; | 2033 | QString cap = c; |
2022 | cap.replace( QRegExp("\n"), " " ); | 2034 | cap.replace( QRegExp("\n"), " " ); |
2023 | cap = cap.stripWhiteSpace(); | 2035 | cap = cap.stripWhiteSpace(); |
2024 | if ( cap.isEmpty() ) | 2036 | if ( cap.isEmpty() ) |
2025 | cap = "KO/Pi"; | 2037 | cap = "KO/Pi"; |
2026 | QWidget::setCaption( cap ); | 2038 | QWidget::setCaption( cap ); |
2027 | } | 2039 | } |
2028 | void MainWindow::setCaptionToDates() | 2040 | void MainWindow::setCaptionToDates() |
2029 | { | 2041 | { |
2030 | QString selDates; | 2042 | QString selDates; |
2031 | QDate date = mView->startDate(); | 2043 | QDate date = mView->startDate(); |
2032 | if ( ! date.isValid() ) { | 2044 | if ( ! date.isValid() ) { |
2033 | setCaption(""); | 2045 | setCaption(""); |
2034 | return; | 2046 | return; |
2035 | } | 2047 | } |
2036 | selDates = KGlobal::locale()->formatDate( date, true); | 2048 | selDates = KGlobal::locale()->formatDate( date, true); |
2037 | if (mView->startDate() < mView->endDate() ) | 2049 | if (mView->startDate() < mView->endDate() ) |
2038 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2050 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2039 | else { | 2051 | else { |
2040 | QString addString; | 2052 | QString addString; |
2041 | if ( date == QDateTime::currentDateTime().date() ) | 2053 | if ( date == QDateTime::currentDateTime().date() ) |
2042 | addString = i18n("Today"); | 2054 | addString = i18n("Today"); |
2043 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2055 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2044 | addString = i18n("Tomorrow"); | 2056 | addString = i18n("Tomorrow"); |
2045 | if ( !addString.isEmpty() ) | 2057 | if ( !addString.isEmpty() ) |
2046 | selDates = addString+", "+selDates ; | 2058 | selDates = addString+", "+selDates ; |
2047 | } | 2059 | } |
2048 | setCaption( i18n("Dates: ") + selDates ); | 2060 | setCaption( i18n("Dates: ") + selDates ); |
2049 | 2061 | ||
2050 | } | 2062 | } |
2051 | void MainWindow::showConfigureAgenda( ) | 2063 | void MainWindow::showConfigureAgenda( ) |
2052 | { | 2064 | { |
2053 | int iii; | 2065 | int iii; |
2054 | for ( iii = 1;iii<= 10 ;++iii ){ | 2066 | for ( iii = 1;iii<= 10 ;++iii ){ |
2055 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2067 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2056 | } | 2068 | } |
2057 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2069 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2058 | } | 2070 | } |
2059 | void MainWindow::configureAgenda( int item ) | 2071 | void MainWindow::configureAgenda( int item ) |
2060 | { | 2072 | { |
2061 | if ( KOPrefs::instance()->mHourSize == item ) | 2073 | if ( KOPrefs::instance()->mHourSize == item ) |
2062 | return; | 2074 | return; |
2063 | KOPrefs::instance()->mHourSize=item; | 2075 | KOPrefs::instance()->mHourSize=item; |
2064 | mView->viewManager()->agendaView()->updateConfig(); | 2076 | mView->viewManager()->agendaView()->updateConfig(); |
2065 | } | 2077 | } |
2066 | 2078 | ||
2067 | void MainWindow::saveCalendar() | 2079 | void MainWindow::saveCalendar() |
2068 | { | 2080 | { |
2069 | QString fn = KOPrefs::instance()->mLastSaveFile; | 2081 | QString fn = KOPrefs::instance()->mLastSaveFile; |
2070 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 2082 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
2071 | 2083 | ||
2072 | if ( fn == "" ) | 2084 | if ( fn == "" ) |
2073 | return; | 2085 | return; |
2074 | QFileInfo info; | 2086 | QFileInfo info; |
2075 | info.setFile( fn ); | 2087 | info.setFile( fn ); |
2076 | QString mes; | 2088 | QString mes; |
2077 | bool createbup = true; | 2089 | bool createbup = true; |
2078 | if ( info. exists() ) { | 2090 | if ( info. exists() ) { |
2079 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 2091 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
2080 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2092 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2081 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2093 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2082 | 0, 1 ); | 2094 | 0, 1 ); |
2083 | if ( result != 0 ) { | 2095 | if ( result != 0 ) { |
2084 | createbup = false; | 2096 | createbup = false; |
2085 | } | 2097 | } |
2086 | } | 2098 | } |
2087 | if ( createbup ) { | 2099 | if ( createbup ) { |
2088 | mView->saveCalendar( fn ); | 2100 | mView->saveCalendar( fn ); |
2089 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 2101 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
2090 | KOPrefs::instance()->mLastSaveFile = fn; | 2102 | KOPrefs::instance()->mLastSaveFile = fn; |
2091 | setCaption(mes); | 2103 | setCaption(mes); |
2092 | } | 2104 | } |
2093 | } | 2105 | } |
2094 | void MainWindow::loadCalendar() | 2106 | void MainWindow::loadCalendar() |
2095 | { | 2107 | { |
2096 | 2108 | ||
2097 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2109 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2098 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2110 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2099 | 2111 | ||
2100 | if ( fn == "" ) | 2112 | if ( fn == "" ) |
2101 | return; | 2113 | return; |
2102 | QFileInfo info; | 2114 | QFileInfo info; |
2103 | info.setFile( fn ); | 2115 | info.setFile( fn ); |
2104 | QString mess; | 2116 | QString mess; |
2105 | bool loadbup = true; | 2117 | bool loadbup = true; |
2106 | if ( info. exists() ) { | 2118 | if ( info. exists() ) { |
2107 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2119 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2108 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2120 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2109 | mess, | 2121 | mess, |
2110 | i18n("Load!"), i18n("Cancel"), 0, | 2122 | i18n("Load!"), i18n("Cancel"), 0, |
2111 | 0, 1 ); | 2123 | 0, 1 ); |
2112 | if ( result != 0 ) { | 2124 | if ( result != 0 ) { |
2113 | loadbup = false; | 2125 | loadbup = false; |
2114 | } | 2126 | } |
2115 | } else { | 2127 | } else { |
2116 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2128 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2117 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2129 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2118 | 0, 1 ); | 2130 | 0, 1 ); |
2119 | 2131 | ||
2120 | return; | 2132 | return; |
2121 | } | 2133 | } |
2122 | if ( loadbup ) { | 2134 | if ( loadbup ) { |
2123 | mView->openCalendar( fn ); | 2135 | mView->openCalendar( fn ); |
2124 | KOPrefs::instance()->mLastLoadFile = fn; | 2136 | KOPrefs::instance()->mLastLoadFile = fn; |
2125 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2137 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2126 | setCaption(mess); | 2138 | setCaption(mess); |
2127 | } | 2139 | } |
2128 | 2140 | ||
2129 | } | 2141 | } |
2130 | void MainWindow::quickImportIcal() | 2142 | void MainWindow::quickImportIcal() |
2131 | { | 2143 | { |
2132 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2144 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2133 | } | 2145 | } |
2134 | void MainWindow::importFile( QString fn, bool quick ) | 2146 | void MainWindow::importFile( QString fn, bool quick ) |
2135 | { | 2147 | { |
2136 | QFileInfo info; | 2148 | QFileInfo info; |
2137 | info.setFile( fn ); | 2149 | info.setFile( fn ); |
2138 | QString mess; | 2150 | QString mess; |
2139 | bool loadbup = true; | 2151 | bool loadbup = true; |
2140 | if ( !info. exists() ) { | 2152 | if ( !info. exists() ) { |
2141 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2153 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2142 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2154 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2143 | mess ); | 2155 | mess ); |
2144 | return; | 2156 | return; |
2145 | } | 2157 | } |
2146 | int result = 0; | 2158 | int result = 0; |
2147 | if ( !quick ) { | 2159 | if ( !quick ) { |
2148 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2160 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2149 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2161 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2150 | mess, | 2162 | mess, |
2151 | "Import", "Cancel", 0, | 2163 | "Import", "Cancel", 0, |
2152 | 0, 1 ); | 2164 | 0, 1 ); |
2153 | } | 2165 | } |
2154 | if ( result == 0 ) { | 2166 | if ( result == 0 ) { |
2155 | if ( mView->openCalendar( fn, true )) { | 2167 | if ( mView->openCalendar( fn, true )) { |
2156 | KOPrefs::instance()->mLastImportFile = fn; | 2168 | KOPrefs::instance()->mLastImportFile = fn; |
2157 | setCaption(i18n("Imported file successfully")); | 2169 | setCaption(i18n("Imported file successfully")); |
2158 | } else { | 2170 | } else { |
2159 | setCaption(i18n("Error importing file")); | 2171 | setCaption(i18n("Error importing file")); |
2160 | } | 2172 | } |
2161 | } | 2173 | } |
2162 | } | 2174 | } |
2163 | 2175 | ||
2164 | void MainWindow::importIcal() | 2176 | void MainWindow::importIcal() |
2165 | { | 2177 | { |
2166 | 2178 | ||
2167 | QString fn =KOPrefs::instance()->mLastImportFile; | 2179 | QString fn =KOPrefs::instance()->mLastImportFile; |
2168 | 2180 | ||
2169 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2181 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2170 | if ( fn == "" ) | 2182 | if ( fn == "" ) |
2171 | return; | 2183 | return; |
2172 | importFile( fn, true ); | 2184 | importFile( fn, true ); |
2173 | 2185 | ||
2174 | } | 2186 | } |
2175 | 2187 | ||
2176 | void MainWindow::exportVCalendar() | 2188 | void MainWindow::exportVCalendar() |
2177 | { | 2189 | { |
2178 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2190 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2179 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2191 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2180 | if ( fn == "" ) | 2192 | if ( fn == "" ) |
2181 | return; | 2193 | return; |
2182 | QFileInfo info; | 2194 | QFileInfo info; |
2183 | info.setFile( fn ); | 2195 | info.setFile( fn ); |
2184 | QString mes; | 2196 | QString mes; |
2185 | bool createbup = true; | 2197 | bool createbup = true; |
2186 | if ( info. exists() ) { | 2198 | if ( info. exists() ) { |
2187 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2199 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2188 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2200 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2189 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2201 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2190 | 0, 1 ); | 2202 | 0, 1 ); |
2191 | if ( result != 0 ) { | 2203 | if ( result != 0 ) { |
2192 | createbup = false; | 2204 | createbup = false; |
2193 | } | 2205 | } |
2194 | } | 2206 | } |
2195 | if ( createbup ) { | 2207 | if ( createbup ) { |
2196 | if ( mView->exportVCalendar( fn ) ) { | 2208 | if ( mView->exportVCalendar( fn ) ) { |
2197 | KOPrefs::instance()->mLastVcalFile = fn; | 2209 | KOPrefs::instance()->mLastVcalFile = fn; |
2198 | if ( fn.length() > 20 ) | 2210 | if ( fn.length() > 20 ) |
2199 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2211 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2200 | else | 2212 | else |
2201 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2213 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2202 | setCaption(mes); | 2214 | setCaption(mes); |
2203 | } | 2215 | } |
2204 | } | 2216 | } |
2205 | 2217 | ||
2206 | } | 2218 | } |
2207 | QString MainWindow::sentSyncFile() | 2219 | QString MainWindow::sentSyncFile() |
2208 | { | 2220 | { |
2209 | #ifdef DESKTOP_VERSION | 2221 | #ifdef DESKTOP_VERSION |
2210 | return locateLocal( "tmp", "copysynccal.ics" ); | 2222 | return locateLocal( "tmp", "copysynccal.ics" ); |
2211 | #else | 2223 | #else |
2212 | return QString( "/tmp/copysynccal.ics" ); | 2224 | return QString( "/tmp/copysynccal.ics" ); |
2213 | #endif | 2225 | #endif |
2214 | } | 2226 | } |
2215 | 2227 | ||
2216 | void MainWindow::syncFileRequest() | 2228 | void MainWindow::syncFileRequest() |
2217 | { | 2229 | { |
2218 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2230 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2219 | mSyncManager->slotSyncMenu( 999 ); | 2231 | mSyncManager->slotSyncMenu( 999 ); |
2220 | } | 2232 | } |
2221 | 2233 | ||
2222 | setCaption(i18n("Saving Data to temp file ..." )); | 2234 | setCaption(i18n("Saving Data to temp file ..." )); |
2223 | mView->saveCalendar( sentSyncFile() ); | 2235 | mView->saveCalendar( sentSyncFile() ); |
2224 | setCaption(i18n("Data saved to temp file!" )); | 2236 | setCaption(i18n("Data saved to temp file!" )); |
2225 | 2237 | ||
2226 | } | 2238 | } |
2227 | void MainWindow::getFile( bool success ) | 2239 | void MainWindow::getFile( bool success ) |
2228 | { | 2240 | { |
2229 | if ( ! success ) { | 2241 | if ( ! success ) { |
2230 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2242 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2231 | return; | 2243 | return; |
2232 | } | 2244 | } |
2233 | mView->openCalendar( sentSyncFile() ); | 2245 | mView->openCalendar( sentSyncFile() ); |
2234 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2246 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2235 | mSyncManager->slotSyncMenu( 999 ); | 2247 | mSyncManager->slotSyncMenu( 999 ); |
2236 | } | 2248 | } |
2237 | setCaption( i18n("Pi-Sync successful!") ); | 2249 | setCaption( i18n("Pi-Sync successful!") ); |
2238 | } | 2250 | } |
2239 | 2251 | ||
2240 | void MainWindow::printSel( ) | 2252 | void MainWindow::printSel( ) |
2241 | { | 2253 | { |
2242 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2254 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2243 | } | 2255 | } |
2244 | 2256 | ||
2245 | void MainWindow::printCal() | 2257 | void MainWindow::printCal() |
2246 | { | 2258 | { |
2247 | mView->print();//mCp->showDialog(); | 2259 | mView->print();//mCp->showDialog(); |
2248 | } | 2260 | } |
2249 | 2261 | ||
2250 | 2262 | ||
2251 | #include "libkdepim/kdatepicker.h" | 2263 | #include "libkdepim/kdatepicker.h" |
2252 | #include <kdatetbl.h> | 2264 | #include <kdatetbl.h> |
2253 | void MainWindow::weekAction() | 2265 | void MainWindow::weekAction() |
2254 | { | 2266 | { |
2255 | int month; | 2267 | int month; |
2256 | KPopupFrame* popup = new KPopupFrame(this); | 2268 | KPopupFrame* popup = new KPopupFrame(this); |
2257 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2269 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2258 | // ----- | 2270 | // ----- |
2259 | picker->resize(picker->sizeHint()); | 2271 | picker->resize(picker->sizeHint()); |
2260 | popup->setMainWidget(picker); | 2272 | popup->setMainWidget(picker); |
2261 | picker->setFocus(); | 2273 | picker->setFocus(); |
2262 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2274 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2263 | int x = 0; | 2275 | int x = 0; |
2264 | int y = iconToolBar->height(); | 2276 | int y = iconToolBar->height(); |
2265 | int dX = 0; | 2277 | int dX = 0; |
2266 | int dY = 0; | 2278 | int dY = 0; |
2267 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2279 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2268 | if ( iconToolBar->y() > height()/2 ) { | 2280 | if ( iconToolBar->y() > height()/2 ) { |
2269 | dY = picker->sizeHint().height()+8; | 2281 | dY = picker->sizeHint().height()+8; |
2270 | y = 0; | 2282 | y = 0; |
2271 | } | 2283 | } |
2272 | } else { | 2284 | } else { |
2273 | if ( iconToolBar->x() > width()/2 ) { // right side | 2285 | if ( iconToolBar->x() > width()/2 ) { // right side |
2274 | x=0; | 2286 | x=0; |
2275 | dX= picker->sizeHint().width()+8; | 2287 | dX= picker->sizeHint().width()+8; |
2276 | y = 0; | 2288 | y = 0; |
2277 | } else { | 2289 | } else { |
2278 | x= iconToolBar->width(); | 2290 | x= iconToolBar->width(); |
2279 | y = 0; | 2291 | y = 0; |
2280 | } | 2292 | } |
2281 | } | 2293 | } |
2282 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2294 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2283 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2295 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2284 | { | 2296 | { |
2285 | month = picker->getResult(); | 2297 | month = picker->getResult(); |
2286 | emit selectWeek ( month ); | 2298 | emit selectWeek ( month ); |
2287 | //qDebug("weekSelected %d ", month); | 2299 | //qDebug("weekSelected %d ", month); |
2288 | } | 2300 | } |
2289 | delete popup; | 2301 | delete popup; |
2290 | } | 2302 | } |
2291 | 2303 | ||
2292 | void MainWindow::hideEvent ( QHideEvent * ) | 2304 | void MainWindow::hideEvent ( QHideEvent * ) |
2293 | { | 2305 | { |
2294 | QString message; | 2306 | QString message; |
2295 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2307 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2296 | if ( nextA.isValid() ) { | 2308 | if ( nextA.isValid() ) { |
2297 | QString sum = mCalendar->nextSummary(); | 2309 | QString sum = mCalendar->nextSummary(); |
2298 | 2310 | ||
2299 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); | 2311 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); |
2300 | setCaption( message ); | 2312 | setCaption( message ); |
2301 | } | 2313 | } |
2302 | } | 2314 | } |
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 49149f2..0610d55 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,278 +1,279 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include "libkdepim/kdatepicker.h" | 38 | #include "libkdepim/kdatepicker.h" |
39 | #include <knotifyclient.h> | 39 | #include <knotifyclient.h> |
40 | #include "kdatetbl.h" | 40 | #include "kdatetbl.h" |
41 | 41 | ||
42 | #include "koglobals.h" | 42 | #include "koglobals.h" |
43 | #include <kglobalsettings.h> | 43 | #include <kglobalsettings.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #ifndef KORG_NOPLUGINS | 45 | #ifndef KORG_NOPLUGINS |
46 | #include "kocore.h" | 46 | #include "kocore.h" |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <kcalendarsystem.h> | 49 | #include <kcalendarsystem.h> |
50 | 50 | ||
51 | #include "navigatorbar.h" | 51 | #include "navigatorbar.h" |
52 | 52 | ||
53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) | 53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) |
54 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ) |
55 | { | 55 | { |
56 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 56 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
57 | 57 | ||
58 | // Set up the control buttons and date label | 58 | // Set up the control buttons and date label |
59 | mCtrlFrame = new QFrame( this ); | 59 | mCtrlFrame = new QFrame( this ); |
60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
61 | mCtrlFrame->setLineWidth(1); | 61 | mCtrlFrame->setLineWidth(1); |
62 | 62 | ||
63 | topLayout->addWidget( mCtrlFrame ); | 63 | topLayout->addWidget( mCtrlFrame ); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | bool isRTL = KOGlobals::self()->reverseLayout(); | 67 | bool isRTL = KOGlobals::self()->reverseLayout(); |
68 | #ifndef DESKTOP_VERSION | 68 | #ifndef DESKTOP_VERSION |
69 | bool isDesktop = false; | 69 | bool isDesktop = false; |
70 | #else | 70 | #else |
71 | bool isDesktop = true; | 71 | bool isDesktop = true; |
72 | #endif | 72 | #endif |
73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
74 | isDesktop = true; | 74 | isDesktop = true; |
75 | // Create backward navigation buttons | 75 | // Create backward navigation buttons |
76 | mPrevYear = new QPushButton( mCtrlFrame ); | 76 | mPrevYear = new QPushButton( mCtrlFrame ); |
77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); | 77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); |
78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
79 | 79 | ||
80 | mPrevMonth = new QPushButton( mCtrlFrame ); | 80 | mPrevMonth = new QPushButton( mCtrlFrame ); |
81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); | 81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); |
82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
83 | 83 | ||
84 | // Create forward navigation buttons | 84 | // Create forward navigation buttons |
85 | mNextMonth = new QPushButton( mCtrlFrame ); | 85 | mNextMonth = new QPushButton( mCtrlFrame ); |
86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); | 86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); |
87 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 87 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
88 | 88 | ||
89 | mPrevWeek = new QPushButton( mCtrlFrame ); | 89 | mPrevWeek = new QPushButton( mCtrlFrame ); |
90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); | 91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); |
92 | 92 | ||
93 | // Create forward navigation buttons | 93 | // Create forward navigation buttons |
94 | mNextWeek = new QPushButton( mCtrlFrame ); | 94 | mNextWeek = new QPushButton( mCtrlFrame ); |
95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
96 | QToolTip::add( mNextWeek, i18n("Next Week") ); | 96 | QToolTip::add( mNextWeek, i18n("Next Week") ); |
97 | 97 | ||
98 | mNextYear = new QPushButton( mCtrlFrame ); | 98 | mNextYear = new QPushButton( mCtrlFrame ); |
99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); | 99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); |
100 | QToolTip::add( mNextYear, i18n("Next Year") ); | 100 | QToolTip::add( mNextYear, i18n("Next Year") ); |
101 | mSelectMonth = new QPushButton( mCtrlFrame ); | 101 | mSelectMonth = new QPushButton( mCtrlFrame ); |
102 | // Create month name label | 102 | // Create month name label |
103 | //selectMonth->setFont( tfont ); | 103 | //selectMonth->setFont( tfont ); |
104 | // selectMonth->setAlignment( AlignCenter ); | 104 | // selectMonth->setAlignment( AlignCenter ); |
105 | //mDateLabel = new QLabel( selectMonth ); | 105 | //mDateLabel = new QLabel( selectMonth ); |
106 | //mDateLabel->setFont( tfont ); | 106 | //mDateLabel->setFont( tfont ); |
107 | //mDateLabel->setAlignment( AlignCenter ); | 107 | //mDateLabel->setAlignment( AlignCenter ); |
108 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 108 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
109 | mNextMonth->setFlat( true); | 109 | mNextMonth->setFlat( true); |
110 | mNextWeek->setFlat( true); | 110 | mNextWeek->setFlat( true); |
111 | mNextYear->setFlat( true); | 111 | mNextYear->setFlat( true); |
112 | mSelectMonth->setFlat( true); | 112 | mSelectMonth->setFlat( true); |
113 | mPrevYear->setFlat( true); | 113 | mPrevYear->setFlat( true); |
114 | mPrevMonth->setFlat( true); | 114 | mPrevMonth->setFlat( true); |
115 | mPrevWeek->setFlat( true); | 115 | mPrevWeek->setFlat( true); |
116 | |||
117 | mPrevYear->setAutoRepeat( true ); | ||
118 | mPrevMonth->setAutoRepeat( true ); | ||
119 | mNextMonth->setAutoRepeat( true ); | ||
120 | mPrevWeek->setAutoRepeat( true ); | ||
121 | mNextWeek->setAutoRepeat( true ); | ||
122 | mNextYear->setAutoRepeat( true ); | ||
116 | } else { | 123 | } else { |
117 | mPrevWeek->hide(); | 124 | mPrevWeek->hide(); |
118 | mNextWeek->hide(); | 125 | mNextWeek->hide(); |
119 | } | 126 | } |
120 | 127 | ||
121 | resetFont( font() ); | 128 | resetFont( font() ); |
122 | 129 | ||
123 | 130 | ||
124 | // set up control frame layout | 131 | // set up control frame layout |
125 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 132 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
126 | ctrlLayout->addWidget( mPrevYear, 3 ); | 133 | ctrlLayout->addWidget( mPrevYear, 3 ); |
127 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 134 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
128 | ctrlLayout->addWidget( mPrevWeek, 3 ); | 135 | ctrlLayout->addWidget( mPrevWeek, 3 ); |
129 | //ctrlLayout->addStretch( 1 ); | 136 | //ctrlLayout->addStretch( 1 ); |
130 | // ctrlLayout->addSpacing( 1 ); | 137 | // ctrlLayout->addSpacing( 1 ); |
131 | // ctrlLayout->addWidget( mDateLabel ); | 138 | // ctrlLayout->addWidget( mDateLabel ); |
132 | ctrlLayout->addWidget( mSelectMonth ); | 139 | ctrlLayout->addWidget( mSelectMonth ); |
133 | // ctrlLayout->addSpacing( 1 ); | 140 | // ctrlLayout->addSpacing( 1 ); |
134 | // ctrlLayout->addStretch( 1 ); | 141 | // ctrlLayout->addStretch( 1 ); |
135 | ctrlLayout->addWidget( mNextWeek, 3 ); | 142 | ctrlLayout->addWidget( mNextWeek, 3 ); |
136 | ctrlLayout->addWidget( mNextMonth, 3 ); | 143 | ctrlLayout->addWidget( mNextMonth, 3 ); |
137 | ctrlLayout->addWidget( mNextYear, 3 ); | 144 | ctrlLayout->addWidget( mNextYear, 3 ); |
138 | 145 | ||
139 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 146 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
140 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 147 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
141 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 148 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
142 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); | 149 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); |
143 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); | 150 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); |
144 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 151 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
145 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 152 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
146 | mPrevYear->setFocusPolicy(NoFocus); | 153 | mPrevYear->setFocusPolicy(NoFocus); |
147 | mPrevMonth->setFocusPolicy(NoFocus); | 154 | mPrevMonth->setFocusPolicy(NoFocus); |
148 | mNextMonth->setFocusPolicy(NoFocus); | 155 | mNextMonth->setFocusPolicy(NoFocus); |
149 | mPrevWeek->setFocusPolicy(NoFocus); | 156 | mPrevWeek->setFocusPolicy(NoFocus); |
150 | mNextWeek->setFocusPolicy(NoFocus); | 157 | mNextWeek->setFocusPolicy(NoFocus); |
151 | mNextYear->setFocusPolicy(NoFocus); | 158 | mNextYear->setFocusPolicy(NoFocus); |
152 | mSelectMonth->setFocusPolicy(NoFocus); | 159 | mSelectMonth->setFocusPolicy(NoFocus); |
153 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 160 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
154 | mPrevYear->setAutoRepeat( true ); | 161 | |
155 | mPrevMonth->setAutoRepeat( true ); | ||
156 | mNextMonth->setAutoRepeat( true ); | ||
157 | mPrevWeek->setAutoRepeat( true ); | ||
158 | mNextWeek->setAutoRepeat( true ); | ||
159 | mNextYear->setAutoRepeat( true ); | ||
160 | |||
161 | } | 162 | } |
162 | 163 | ||
163 | NavigatorBar::~NavigatorBar() | 164 | NavigatorBar::~NavigatorBar() |
164 | { | 165 | { |
165 | } | 166 | } |
166 | QSize NavigatorBar::sizeHint() const | 167 | QSize NavigatorBar::sizeHint() const |
167 | { | 168 | { |
168 | int wid = mCurrentMinWid ; | 169 | int wid = mCurrentMinWid ; |
169 | if ( mPrevYear->isVisible() ) | 170 | if ( mPrevYear->isVisible() ) |
170 | wid += mCurrentButtonMinWid; | 171 | wid += mCurrentButtonMinWid; |
171 | if ( mPrevMonth->isVisible() ) | 172 | if ( mPrevMonth->isVisible() ) |
172 | wid += mCurrentButtonMinWid; | 173 | wid += mCurrentButtonMinWid; |
173 | if ( mPrevWeek->isVisible() ) | 174 | if ( mPrevWeek->isVisible() ) |
174 | wid += mCurrentButtonMinWid; | 175 | wid += mCurrentButtonMinWid; |
175 | if ( mNextMonth->isVisible() ) | 176 | if ( mNextMonth->isVisible() ) |
176 | wid += mCurrentButtonMinWid; | 177 | wid += mCurrentButtonMinWid; |
177 | if ( mNextWeek->isVisible() ) | 178 | if ( mNextWeek->isVisible() ) |
178 | wid += mCurrentButtonMinWid; | 179 | wid += mCurrentButtonMinWid; |
179 | if ( mNextYear->isVisible() ) | 180 | if ( mNextYear->isVisible() ) |
180 | wid += mCurrentButtonMinWid; | 181 | wid += mCurrentButtonMinWid; |
181 | //qDebug("ret %d %d ", wid, mCurrentHei); | 182 | //qDebug("ret %d %d ", wid, mCurrentHei); |
182 | return QSize ( wid, mCurrentHei ); | 183 | return QSize ( wid, mCurrentHei ); |
183 | } | 184 | } |
184 | QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const | 185 | QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const |
185 | { | 186 | { |
186 | return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); | 187 | return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); |
187 | } | 188 | } |
188 | void NavigatorBar::resetFont ( QFont fo ) | 189 | void NavigatorBar::resetFont ( QFont fo ) |
189 | { | 190 | { |
190 | 191 | ||
191 | QFont tfont = fo; | 192 | QFont tfont = fo; |
192 | if ( QApplication::desktop()->width() >= 480 ) | 193 | if ( QApplication::desktop()->width() >= 480 ) |
193 | tfont.setPointSize(tfont.pointSize()+2); | 194 | tfont.setPointSize(tfont.pointSize()+2); |
194 | tfont.setBold(true); | 195 | tfont.setBold(true); |
195 | 196 | ||
196 | mSelectMonth->setFont( tfont ); | 197 | mSelectMonth->setFont( tfont ); |
197 | // Set minimum width to width of widest month name label | 198 | // Set minimum width to width of widest month name label |
198 | int i; | 199 | int i; |
199 | int maxwidth = 0; | 200 | int maxwidth = 0; |
200 | QFontMetrics fm ( mSelectMonth->font() ); | 201 | QFontMetrics fm ( mSelectMonth->font() ); |
201 | int width = fm.width("September '00" ); | 202 | int width = fm.width("September '00" ); |
202 | maxwidth = width+2; | 203 | maxwidth = width+2; |
203 | int size = fm.height()+2; | 204 | int size = fm.height()+2; |
204 | if ( QApplication::desktop()->width() >= 480 ) { | 205 | if ( QApplication::desktop()->width() >= 480 ) { |
205 | size += 6; | 206 | size += 6; |
206 | maxwidth+= 6; | 207 | maxwidth+= 6; |
207 | } | 208 | } |
208 | mSelectMonth->setMinimumWidth( maxwidth ); | 209 | mSelectMonth->setMinimumWidth( maxwidth ); |
209 | mSelectMonth->setFixedHeight( size ); | 210 | mSelectMonth->setFixedHeight( size ); |
210 | mPrevYear->setFixedHeight( size ); | 211 | mPrevYear->setFixedHeight( size ); |
211 | mPrevMonth->setFixedHeight( size ); | 212 | mPrevMonth->setFixedHeight( size ); |
212 | mPrevWeek->setFixedHeight( size ); | 213 | mPrevWeek->setFixedHeight( size ); |
213 | mNextMonth->setFixedHeight( size ); | 214 | mNextMonth->setFixedHeight( size ); |
214 | mNextWeek->setFixedHeight( size ); | 215 | mNextWeek->setFixedHeight( size ); |
215 | mNextYear->setFixedHeight ( size ); | 216 | mNextYear->setFixedHeight ( size ); |
216 | mCurrentHei = size +2; | 217 | mCurrentHei = size +2; |
217 | mCurrentMinWid = maxwidth+2; | 218 | mCurrentMinWid = maxwidth+2; |
218 | mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; | 219 | mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; |
219 | } | 220 | } |
220 | 221 | ||
221 | void NavigatorBar::showButtons( bool left, bool right ) | 222 | void NavigatorBar::showButtons( bool left, bool right ) |
222 | { | 223 | { |
223 | if ( left ) { | 224 | if ( left ) { |
224 | mPrevYear->show(); | 225 | mPrevYear->show(); |
225 | mPrevMonth->show(); | 226 | mPrevMonth->show(); |
226 | } else { | 227 | } else { |
227 | mPrevYear->hide(); | 228 | mPrevYear->hide(); |
228 | mPrevMonth->hide(); | 229 | mPrevMonth->hide(); |
229 | } | 230 | } |
230 | 231 | ||
231 | if ( right ) { | 232 | if ( right ) { |
232 | mNextYear->show(); | 233 | mNextYear->show(); |
233 | mNextMonth->show(); | 234 | mNextMonth->show(); |
234 | } else { | 235 | } else { |
235 | mNextYear->hide(); | 236 | mNextYear->hide(); |
236 | mNextMonth->hide(); | 237 | mNextMonth->hide(); |
237 | } | 238 | } |
238 | if ( !left && !right ) { | 239 | if ( !left && !right ) { |
239 | //mSelectMonth->setMaximumWidth( 1024 ); | 240 | //mSelectMonth->setMaximumWidth( 1024 ); |
240 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 241 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
241 | } | 242 | } |
242 | } | 243 | } |
243 | 244 | ||
244 | void NavigatorBar::selectMonth() | 245 | void NavigatorBar::selectMonth() |
245 | { | 246 | { |
246 | 247 | ||
247 | int month; | 248 | int month; |
248 | KPopupFrame* popup = new KPopupFrame(this); | 249 | KPopupFrame* popup = new KPopupFrame(this); |
249 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 250 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
250 | // ----- | 251 | // ----- |
251 | picker->resize(picker->sizeHint()); | 252 | picker->resize(picker->sizeHint()); |
252 | popup->setMainWidget(picker); | 253 | popup->setMainWidget(picker); |
253 | picker->setFocus(); | 254 | picker->setFocus(); |
254 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 255 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
255 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 256 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
256 | { | 257 | { |
257 | month = picker->getResult(); | 258 | month = picker->getResult(); |
258 | emit monthSelected ( month ); | 259 | emit monthSelected ( month ); |
259 | } else { | 260 | } else { |
260 | KNotifyClient::beep(); | 261 | KNotifyClient::beep(); |
261 | } | 262 | } |
262 | delete popup; | 263 | delete popup; |
263 | } | 264 | } |
264 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 265 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
265 | { | 266 | { |
266 | if (dateList.count() > 0) { | 267 | if (dateList.count() > 0) { |
267 | QDate date = dateList.first(); | 268 | QDate date = dateList.first(); |
268 | 269 | ||
269 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 270 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
270 | 271 | ||
271 | // compute the label at the top of the navigator | 272 | // compute the label at the top of the navigator |
272 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 273 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
273 | QString::number( calSys->year( date ) ).right(2); | 274 | QString::number( calSys->year( date ) ).right(2); |
274 | 275 | ||
275 | mSelectMonth->setText( dtstr ); | 276 | mSelectMonth->setText( dtstr ); |
276 | } | 277 | } |
277 | } | 278 | } |
278 | 279 | ||