author | zautrix <zautrix> | 2005-09-18 23:40:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-18 23:40:38 (UTC) |
commit | 2d346e4052fd726e657daee4ac3f2bcc7103f5fb (patch) (unidiff) | |
tree | 9952b888e0790bc032ba4e0c3c4165ec283a4139 | |
parent | 06ebec95579816144ee65981835e6e3482e20a28 (diff) | |
download | kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.zip kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.gz kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.bz2 |
wn
-rw-r--r-- | kalarmd/alarmdialog.cpp | 12 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 11 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 13 |
3 files changed, 22 insertions, 14 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index ddb125a..18ce9da 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -1,340 +1,344 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KDE alarm daemon. | 2 | This file is part of the KDE alarm daemon. |
3 | Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000 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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // $Id$ | 24 | // $Id$ |
25 | 25 | ||
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qapp.h> | 28 | #include <qapp.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qsound.h> | 33 | #include <qsound.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #define protected public | 37 | #define protected public |
38 | #include <qspinbox.h> | 38 | #include <qspinbox.h> |
39 | #undef protected | 39 | #undef protected |
40 | #else | 40 | #else |
41 | #include <qspinbox.h> | 41 | #include <qspinbox.h> |
42 | #endif | 42 | #endif |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #ifndef _WIN32_ | 44 | #ifndef _WIN32_ |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
47 | #endif | 47 | #endif |
48 | #include <stdio.h> | 48 | #include <stdio.h> |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> |
50 | 50 | ||
51 | #ifndef DESKTOP_VERSION | 51 | #ifndef DESKTOP_VERSION |
52 | #include <qtopia/alarmserver.h> | 52 | #include <qtopia/alarmserver.h> |
53 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
54 | #include <qtopia/sound.h> | 54 | #include <qtopia/sound.h> |
55 | 55 | ||
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #include "alarmdialog.h" | 58 | #include "alarmdialog.h" |
59 | 59 | ||
60 | 60 | ||
61 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | 61 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) |
62 | : QDialog (parent, name ,false, Qt::WStyle_StaysOnTop ) | 62 | : QDialog (parent, name ,false, Qt::WStyle_StaysOnTop ) |
63 | { | 63 | { |
64 | setCaption( "KO/Pi Alarm!" ); | 64 | setCaption( "KO/Pi Alarm!" ); |
65 | QVBoxLayout* layout = new QVBoxLayout( this); | 65 | QVBoxLayout* layout = new QVBoxLayout( this); |
66 | QLabel* l = new QLabel("The following event triggered alarm:",this); | 66 | QLabel* l = new QLabel("The following event triggered alarm:",this); |
67 | layout->addWidget ( l ); | 67 | layout->addWidget ( l ); |
68 | l->setAlignment( AlignCenter); | 68 | l->setAlignment( AlignCenter); |
69 | mMessage = new QLabel ( " ", this ); | 69 | mMessage = new QLabel ( " ", this ); |
70 | int fs = 18; | 70 | int fs = 18; |
71 | int fs2 = 12; | 71 | int fs2 = 12; |
72 | int baseSize = 6; | 72 | int baseSize = 6; |
73 | if ( QApplication::desktop()->width() < 480 ) { | 73 | if ( QApplication::desktop()->width() < 480 ) { |
74 | fs2 = 10; | 74 | fs2 = 10; |
75 | fs = 12; | 75 | fs = 12; |
76 | baseSize = 4; | 76 | baseSize = 4; |
77 | } | 77 | } |
78 | layout->setSpacing( 3 ); | 78 | layout->setSpacing( 3 ); |
79 | layout->setMargin( 3 ); | 79 | layout->setMargin( 3 ); |
80 | QFont fo = QApplication::font(); | 80 | QFont fo = QApplication::font(); |
81 | fo.setBold( true ); | 81 | fo.setBold( true ); |
82 | fo.setPointSize( fs2 ); | 82 | fo.setPointSize( fs2 ); |
83 | l->setFont( fo ); | 83 | l->setFont( fo ); |
84 | fo.setPointSize( fs ); | 84 | fo.setPointSize( fs ); |
85 | mMessage->setFont(fo ); | 85 | mMessage->setFont(fo ); |
86 | mMessage->setAlignment( AlignCenter); | 86 | mMessage->setAlignment( AlignCenter); |
87 | layout->addWidget ( mMessage ); | 87 | layout->addWidget ( mMessage ); |
88 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); | 88 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); |
89 | mMissedAlarms->setAlignment( AlignCenter); | 89 | mMissedAlarms->setAlignment( AlignCenter); |
90 | 90 | ||
91 | playSoundTimer = new QTimer( this ); | 91 | playSoundTimer = new QTimer( this ); |
92 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); | 92 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); |
93 | 93 | ||
94 | playSoundTimer->stop(); | 94 | playSoundTimer->stop(); |
95 | 95 | ||
96 | layout->addWidget ( mMissedAlarms ); | 96 | layout->addWidget ( mMissedAlarms ); |
97 | mMissedAlarmsCombo = new QComboBox ( this ); | 97 | mMissedAlarmsCombo = new QComboBox ( this ); |
98 | layout->addWidget ( mMissedAlarmsCombo ); | 98 | layout->addWidget ( mMissedAlarmsCombo ); |
99 | 99 | ||
100 | QLabel* labb = new QLabel("Suspend\nduration\n(minutes):",this); | 100 | QLabel* labb = new QLabel("Suspend\nduration\n(minutes):",this); |
101 | #ifdef DESKTOP_VERSION | 101 | #ifdef DESKTOP_VERSION |
102 | fo = font(); | 102 | fo = font(); |
103 | fo.setPointSize( 12 ); | 103 | fo.setPointSize( 12 ); |
104 | labb->setFont ( fo ); | 104 | labb->setFont ( fo ); |
105 | #endif | 105 | #endif |
106 | labb->setAlignment(AlignCenter); | 106 | labb->setAlignment(AlignCenter); |
107 | //layout->addWidget ( labb ); | 107 | //layout->addWidget ( labb ); |
108 | fo = font(); | 108 | fo = font(); |
109 | int pointSize = 36; | 109 | int pointSize = 36; |
110 | if ( QApplication::desktop()->width() <= 320 ) | 110 | if ( QApplication::desktop()->width() <= 320 ) |
111 | pointSize = 18; | 111 | pointSize = 18; |
112 | fo.setPointSize( pointSize ); | 112 | fo.setPointSize( pointSize ); |
113 | mSuspendSpin = new QSpinBox(1,1440,1,this); | 113 | mSuspendSpin = new QSpinBox(1,1440,1,this); |
114 | mSuspendSpin->setFont( fo ); | 114 | mSuspendSpin->setFont( fo ); |
115 | mSuspendSpin->setValue(7); // default suspend duration | 115 | mSuspendSpin->setValue(7); // default suspend duration |
116 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 116 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
117 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 117 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
118 | 118 | ||
119 | #if QT_VERSION < 0x030000 | 119 | #if QT_VERSION < 0x030000 |
120 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 120 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
121 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 121 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
122 | #endif | 122 | #endif |
123 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); | 123 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); |
124 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 124 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
125 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); | 125 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); |
126 | layoutSpin->addStretch (); | 126 | layoutSpin->addStretch (); |
127 | layoutSpin->addWidget ( labb ); | 127 | layoutSpin->addWidget ( labb ); |
128 | layoutSpin->addWidget ( mSuspendSpin ); | 128 | layoutSpin->addWidget ( mSuspendSpin ); |
129 | layoutSpin->addStretch (); | 129 | layoutSpin->addStretch (); |
130 | 130 | ||
131 | QVBox * bbox = new QVBox ( this ); | 131 | QVBox * bbox = new QVBox ( this ); |
132 | layout->addWidget ( bbox ); | 132 | layout->addWidget ( bbox ); |
133 | bbox->layout()->setSpacing( 2 ); | 133 | bbox->layout()->setSpacing( 2 ); |
134 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); | 134 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); |
135 | labb->setAlignment(AlignCenter); | 135 | labb->setAlignment(AlignCenter); |
136 | mSuspendButton = new QPushButton( "Suspend", bbox); | 136 | mSuspendButton = new QPushButton( "Suspend", bbox); |
137 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); | 137 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); |
138 | okbut = new QPushButton( "Ok", bbox); | 138 | okbut = new QPushButton( "Ok", bbox); |
139 | mSuspendButton->setFont( fo ); | 139 | mSuspendButton->setFont( fo ); |
140 | silen->setFont( fo ); | 140 | silen->setFont( fo ); |
141 | okbut->setFont( fo ); | 141 | okbut->setFont( fo ); |
142 | okbut->setDefault( true ); | 142 | okbut->setDefault( true ); |
143 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); | 143 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); |
144 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); | 144 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); |
145 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); | 145 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); |
146 | connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); | 146 | connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); |
147 | #ifndef _WIN32_ | 147 | #ifndef _WIN32_ |
148 | if ( QFile::exists ( "/dev/sharp_led" ) ) | 148 | if ( QFile::exists ( "/dev/sharp_led" ) ) |
149 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 149 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
150 | else | 150 | else |
151 | #endif | 151 | #endif |
152 | fd_led = 0; | 152 | fd_led = 0; |
153 | statusLED.which = SHARP_LED_SALARM; | 153 | statusLED.which = SHARP_LED_SALARM; |
154 | mSilent = false; | 154 | mSilent = false; |
155 | mSuspendCounter = 0; | 155 | mSuspendCounter = 0; |
156 | setServerNotification( true ); | 156 | setServerNotification( true ); |
157 | } | 157 | } |
158 | void AlarmDialog::reject () | 158 | void AlarmDialog::reject () |
159 | { | 159 | { |
160 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); | 160 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); |
161 | slotSuspend(); | 161 | slotSuspend(); |
162 | } | 162 | } |
163 | AlarmDialog::~AlarmDialog() | 163 | AlarmDialog::~AlarmDialog() |
164 | { | 164 | { |
165 | } | 165 | } |
166 | void AlarmDialog::silent () | 166 | void AlarmDialog::silent () |
167 | { | 167 | { |
168 | mSilent = true; | 168 | mSilent = true; |
169 | } | 169 | } |
170 | void AlarmDialog::accept() | 170 | void AlarmDialog::accept() |
171 | { | 171 | { |
172 | slotOk(); | 172 | slotOk(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void AlarmDialog::suspend() | 175 | void AlarmDialog::suspend() |
176 | { | 176 | { |
177 | #ifdef DESKTOP_VERSION | 177 | #ifdef DESKTOP_VERSION |
178 | 178 | ||
179 | #else | 179 | #else |
180 | Sound::soundAlarm (); | 180 | Sound::soundAlarm (); |
181 | #endif | 181 | #endif |
182 | } | 182 | } |
183 | void AlarmDialog::slotOk() | 183 | void AlarmDialog::slotOk() |
184 | { | 184 | { |
185 | mStopAlarm = true; | 185 | mStopAlarm = true; |
186 | mMissedAlarms->setText("(No missed Alarms)"); | 186 | mMissedAlarms->setText("(No missed Alarms)"); |
187 | mMessage->setText(""); | 187 | mMessage->setText(""); |
188 | mMissedAlarmsCombo->clear(); | 188 | mMissedAlarmsCombo->clear(); |
189 | #ifndef _WIN32_ | 189 | #ifndef _WIN32_ |
190 | if ( fd_led > 0 ) { | 190 | if ( fd_led > 0 ) { |
191 | statusLED.status = LED_SALARM_OFF ; | 191 | statusLED.status = LED_SALARM_OFF ; |
192 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 192 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
193 | } | 193 | } |
194 | #endif | 194 | #endif |
195 | QDialog::accept(); | 195 | QDialog::accept(); |
196 | } | 196 | } |
197 | 197 | ||
198 | void AlarmDialog::slotSuspend() | 198 | void AlarmDialog::slotSuspend() |
199 | { | 199 | { |
200 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); | 200 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); |
201 | mStopAlarm = true; | 201 | mStopAlarm = true; |
202 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); | 202 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); |
203 | QString mess = "suspend_alarm" +mFileName+"+++" ; | 203 | QString mess = "suspend_alarm" +mFileName+"+++" ; |
204 | if ( mMessage->text().left( 10 ) !="Suspended:" ) | 204 | if ( mMessage->text().left( 10 ) !="Suspended:" ) |
205 | mess += "Suspended:\n"; | 205 | mess += "Suspended:\n"; |
206 | mess +=mMessage->text(); | 206 | mess +=mMessage->text(); |
207 | #ifndef DESKTOP_VERSION | 207 | #ifndef DESKTOP_VERSION |
208 | if ( mServerNotification ) | 208 | if ( mServerNotification ) |
209 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); | 209 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); |
210 | #endif | 210 | #endif |
211 | emit addAlarm( nextA , mess ); | 211 | emit addAlarm( nextA , mess ); |
212 | slotOk(); | 212 | slotOk(); |
213 | } | 213 | } |
214 | 214 | ||
215 | void AlarmDialog::setServerNotification( bool b ) | 215 | void AlarmDialog::setServerNotification( bool b ) |
216 | { | 216 | { |
217 | mServerNotification = b; | 217 | mServerNotification = b; |
218 | } | 218 | } |
219 | int AlarmDialog::getSuspendTime( ) | 219 | int AlarmDialog::getSuspendTime( ) |
220 | { | 220 | { |
221 | return mSuspendSpin->value(); | 221 | return mSuspendSpin->value(); |
222 | 222 | ||
223 | } | 223 | } |
224 | void AlarmDialog::setSuspendTime( int val ) | 224 | void AlarmDialog::setSuspendTime( int val ) |
225 | { | 225 | { |
226 | mSuspendSpin->setValue( val ); | 226 | mSuspendSpin->setValue( val ); |
227 | } | 227 | } |
228 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) | 228 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) |
229 | { | 229 | { |
230 | if ( mess.left( 9) != "Suspended" ) | 230 | if ( mess.left( 9) != "Suspended" ) |
231 | mSuspendCounter = suspendtimes; | 231 | mSuspendCounter = suspendtimes; |
232 | mPauseCount = pause; | 232 | mPauseCount = pause; |
233 | mFileName = fn; | 233 | mFileName = fn; |
234 | mPlayWav = playwav; | 234 | mPlayWav = playwav; |
235 | if ( !QFile::exists( fn ) ) | 235 | if ( !QFile::exists( fn ) ) |
236 | mFileName = ""; | 236 | mFileName = ""; |
237 | alarmCounter = 0 ; | 237 | alarmCounter = 0 ; |
238 | maxAlarmReplay = replay ; | 238 | maxAlarmReplay = replay ; |
239 | mStopAlarm = false; | 239 | mStopAlarm = false; |
240 | mSilent = false; | 240 | mSilent = false; |
241 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { | 241 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { |
242 | mMissedAlarmsCombo->show(); | 242 | mMissedAlarmsCombo->show(); |
243 | QString newItem = mMessage->text().stripWhiteSpace(); | 243 | QString newItem = mMessage->text().stripWhiteSpace(); |
244 | newItem.replace( QRegExp("\n"), QString(" ") ); | 244 | newItem.replace( QRegExp("\n"), QString(" ") ); |
245 | mMissedAlarmsCombo->insertItem( newItem ); | 245 | mMissedAlarmsCombo->insertItem( newItem ); |
246 | mMissedAlarms->setText( "Missed alarms:"); | 246 | mMissedAlarms->setText( "Missed alarms:"); |
247 | } else | 247 | } else |
248 | mMissedAlarmsCombo->hide(); | 248 | mMissedAlarmsCombo->hide(); |
249 | mMessage->setText(mess); | 249 | mMessage->setText(mess); |
250 | int w = minimumSizeHint().width() ; | 250 | int w = minimumSizeHint().width() ; |
251 | int h = minimumSizeHint().height() ; | 251 | int h = minimumSizeHint().height() ; |
252 | int dw = QApplication::desktop()->width(); | 252 | int dw = QApplication::desktop()->width(); |
253 | int dh = QApplication::desktop()->height(); | 253 | int dh = QApplication::desktop()->height(); |
254 | if ( w < 220 ) w = 220; | ||
255 | if ( h < 220 ) h = 220; | ||
254 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 256 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
255 | hide(); | 257 | showNormal(); |
258 | setActiveWindow(); | ||
259 | raise(); | ||
260 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
261 | //hide(); | ||
256 | 262 | ||
257 | #ifndef _WIN32_ | 263 | #ifndef _WIN32_ |
258 | if ( fd_led > 0 ) { | 264 | if ( fd_led > 0 ) { |
259 | statusLED.status = LED_SALARM_ON ; | 265 | statusLED.status = LED_SALARM_ON ; |
260 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 266 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
261 | } | 267 | } |
262 | #endif | 268 | #endif |
263 | okbut->setDefault( true ); | 269 | okbut->setDefault( true ); |
264 | QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); | 270 | QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); |
265 | // playSoundTimer->start( 1000, true ); | 271 | // playSoundTimer->start( 1000, true ); |
266 | return true; | 272 | return true; |
267 | 273 | ||
268 | } | 274 | } |
269 | 275 | ||
270 | void AlarmDialog::forceRepaint() | 276 | void AlarmDialog::forceRepaint() |
271 | { | 277 | { |
272 | |||
273 | showNormal(); | ||
274 | setActiveWindow(); | 278 | setActiveWindow(); |
275 | raise(); | 279 | repaint(); |
276 | mSuspendSpin->setFocus(); | 280 | mSuspendSpin->setFocus(); |
277 | playSoundTimer->start( 1000, true ); | 281 | playSoundTimer->start( 1000, true ); |
278 | 282 | ||
279 | } | 283 | } |
280 | void AlarmDialog::spinBoxChanged( int v ) | 284 | void AlarmDialog::spinBoxChanged( int v ) |
281 | { | 285 | { |
282 | okbut->setDefault( false ); | 286 | okbut->setDefault( false ); |
283 | mSilent = true; | 287 | mSilent = true; |
284 | } | 288 | } |
285 | 289 | ||
286 | void AlarmDialog::playSound () | 290 | void AlarmDialog::playSound () |
287 | { | 291 | { |
288 | 292 | ||
289 | if (mStopAlarm ) | 293 | if (mStopAlarm ) |
290 | return; | 294 | return; |
291 | if ( mSilent ) | 295 | if ( mSilent ) |
292 | return; | 296 | return; |
293 | //showNormal(); | 297 | //showNormal(); |
294 | setActiveWindow(); | 298 | setActiveWindow(); |
295 | //raise(); | 299 | //raise(); |
296 | mSuspendSpin->setFocus(); | 300 | mSuspendSpin->setFocus(); |
297 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { | 301 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { |
298 | ++alarmCounter; | 302 | ++alarmCounter; |
299 | #ifdef DESKTOP_VERSION | 303 | #ifdef DESKTOP_VERSION |
300 | mPlayWav = true; | 304 | mPlayWav = true; |
301 | #endif | 305 | #endif |
302 | if ( !mPlayWav || mFileName.length() < 2 ) { | 306 | if ( !mPlayWav || mFileName.length() < 2 ) { |
303 | 307 | ||
304 | #ifdef DESKTOP_VERSION | 308 | #ifdef DESKTOP_VERSION |
305 | qDebug("Sound play not possible - file not found"); | 309 | qDebug("Sound play not possible - file not found"); |
306 | #else | 310 | #else |
307 | Sound::soundAlarm (); | 311 | Sound::soundAlarm (); |
308 | #endif | 312 | #endif |
309 | } else | 313 | } else |
310 | 314 | ||
311 | { | 315 | { |
312 | #ifdef DESKTOP_VERSION | 316 | #ifdef DESKTOP_VERSION |
313 | #ifdef _WIN32_ | 317 | #ifdef _WIN32_ |
314 | QSound::play ( mFileName ); | 318 | QSound::play ( mFileName ); |
315 | #else | 319 | #else |
316 | 320 | ||
317 | QString command = "playwave -r 22050 " + mFileName; | 321 | QString command = "playwave -r 22050 " + mFileName; |
318 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); | 322 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); |
319 | int ret = system ( command.latin1() ); | 323 | int ret = system ( command.latin1() ); |
320 | if ( ret != 0 ) { | 324 | if ( ret != 0 ) { |
321 | qDebug("Sound play command failed: %s ",command.latin1() ); | 325 | qDebug("Sound play command failed: %s ",command.latin1() ); |
322 | } | 326 | } |
323 | 327 | ||
324 | #endif | 328 | #endif |
325 | 329 | ||
326 | #else | 330 | #else |
327 | QSound::play ( mFileName ); | 331 | QSound::play ( mFileName ); |
328 | #endif | 332 | #endif |
329 | qDebug("BEEP!"); | 333 | qDebug("BEEP!"); |
330 | } | 334 | } |
331 | } else { | 335 | } else { |
332 | if ( ! mSilent && mSuspendCounter > 0 ) { | 336 | if ( ! mSilent && mSuspendCounter > 0 ) { |
333 | --mSuspendCounter; | 337 | --mSuspendCounter; |
334 | reject (); | 338 | reject (); |
335 | hide(); | 339 | hide(); |
336 | return; | 340 | return; |
337 | } | 341 | } |
338 | } | 342 | } |
339 | playSoundTimer->start( mPauseCount * 1000, true ); | 343 | playSoundTimer->start( mPauseCount * 1000, true ); |
340 | } | 344 | } |
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index a0ac232..8ea8a73 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -1,674 +1,679 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KOrganizer alarm daemon. | 2 | This file is part of the KOrganizer alarm daemon. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "simplealarmdaemonimpl.h" | 24 | #include "simplealarmdaemonimpl.h" |
25 | 25 | ||
26 | #include "alarmdialog.h" | 26 | #include "alarmdialog.h" |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qapp.h> | 28 | #include <qapp.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qhbox.h> | 31 | #include <qhbox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #define protected public | 39 | #define protected public |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #undef protected | 41 | #undef protected |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qtopia/qcopenvelope_qws.h> | 43 | #include <qtopia/qcopenvelope_qws.h> |
44 | #include <qtopia/alarmserver.h> | 44 | #include <qtopia/alarmserver.h> |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | 50 | ||
51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | 51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) |
52 | : QLabel( parent ) | 52 | : QLabel( parent ) |
53 | { | 53 | { |
54 | mAlarmDialog = new AlarmDialog( 0 ); | 54 | mAlarmDialog = new AlarmDialog( 0 ); |
55 | mPopUp = new QPopupMenu( this ); | 55 | mPopUp = new QPopupMenu( this ); |
56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); | 56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); |
57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); | 57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); |
58 | mPopUp->insertSeparator(); | 58 | mPopUp->insertSeparator(); |
59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); | 59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); |
60 | mPopUp->insertSeparator(); | 60 | mPopUp->insertSeparator(); |
61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); | 61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); |
62 | mPopUp->insertSeparator(); | 62 | mPopUp->insertSeparator(); |
63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); | 63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); |
64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); | 64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); |
65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); | 65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); |
66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); | 66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); |
67 | mPopUp->insertSeparator(); | 67 | mPopUp->insertSeparator(); |
68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); | 68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); |
69 | mTimerPopUp = new QPopupMenu( this ); | 69 | mTimerPopUp = new QPopupMenu( this ); |
70 | QFont fon = mTimerPopUp->font(); | ||
71 | int points = (fon.pointSize()*4)/3; | ||
72 | fon.setPointSize( points ); | ||
73 | mTimerPopUp->setFont( fon ); | ||
74 | mPopUp->setFont( fon ); | ||
70 | mBeepPopUp = new QPopupMenu( this ); | 75 | mBeepPopUp = new QPopupMenu( this ); |
71 | mSoundPopUp = new QPopupMenu( this ); | 76 | mSoundPopUp = new QPopupMenu( this ); |
72 | mPausePopUp = new QPopupMenu( this ); | 77 | mPausePopUp = new QPopupMenu( this ); |
73 | QPopupMenu* savePopUp = new QPopupMenu( this ); | 78 | QPopupMenu* savePopUp = new QPopupMenu( this ); |
74 | savePopUp->insertItem( "Save", 0 ); | 79 | savePopUp->insertItem( "Save", 0 ); |
75 | savePopUp->insertItem( "Load", 1 ); | 80 | savePopUp->insertItem( "Load", 1 ); |
76 | mSoundPopUp->insertItem( "Buzzer", 0 ); | 81 | mSoundPopUp->insertItem( "Buzzer", 0 ); |
77 | mSoundPopUp->insertItem( "Wav file", 1 ); | 82 | mSoundPopUp->insertItem( "Wav file", 1 ); |
78 | mPausePopUp->insertItem( " 1 sec", 1 ); | 83 | mPausePopUp->insertItem( " 1 sec", 1 ); |
79 | mPausePopUp->insertItem( " 2 sec", 2 ); | 84 | mPausePopUp->insertItem( " 2 sec", 2 ); |
80 | mPausePopUp->insertItem( " 3 sec", 3 ); | 85 | mPausePopUp->insertItem( " 3 sec", 3 ); |
81 | mPausePopUp->insertItem( " 5 sec", 5 ); | 86 | mPausePopUp->insertItem( " 5 sec", 5 ); |
82 | mPausePopUp->insertItem( "10 sec", 10 ); | 87 | mPausePopUp->insertItem( "10 sec", 10 ); |
83 | mPausePopUp->insertItem( "30 sec", 30 ); | 88 | mPausePopUp->insertItem( "30 sec", 30 ); |
84 | mPausePopUp->insertItem( " 1 min", 60 ); | 89 | mPausePopUp->insertItem( " 1 min", 60 ); |
85 | mPausePopUp->insertItem( " 5 min", 300 ); | 90 | mPausePopUp->insertItem( " 5 min", 300 ); |
86 | mPausePopUp->insertItem( "10 min", 600 ); | 91 | mPausePopUp->insertItem( "10 min", 600 ); |
87 | mSuspendPopUp = new QPopupMenu( this ); | 92 | mSuspendPopUp = new QPopupMenu( this ); |
88 | mSuspendPopUp->insertItem( "Off", 0 ); | 93 | mSuspendPopUp->insertItem( "Off", 0 ); |
89 | mSuspendPopUp->insertItem( " 1x", 1 ); | 94 | mSuspendPopUp->insertItem( " 1x", 1 ); |
90 | mSuspendPopUp->insertItem( " 2x", 2 ); | 95 | mSuspendPopUp->insertItem( " 2x", 2 ); |
91 | mSuspendPopUp->insertItem( " 3x", 3 ); | 96 | mSuspendPopUp->insertItem( " 3x", 3 ); |
92 | mSuspendPopUp->insertItem( " 5x", 5 ); | 97 | mSuspendPopUp->insertItem( " 5x", 5 ); |
93 | mSuspendPopUp->insertItem( "10x", 10 ); | 98 | mSuspendPopUp->insertItem( "10x", 10 ); |
94 | mSuspendPopUp->insertItem( "20x", 20 ); | 99 | mSuspendPopUp->insertItem( "20x", 20 ); |
95 | mSuspendPopUp->insertItem( "30x", 30 ); | 100 | mSuspendPopUp->insertItem( "30x", 30 ); |
96 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); | 101 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); |
97 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); | 102 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); |
98 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); | 103 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); |
99 | mBeepPopUp->insertItem( "Config",savePopUp ); | 104 | mBeepPopUp->insertItem( "Config",savePopUp ); |
100 | mBeepPopUp->insertItem( "300", 300 ); | 105 | mBeepPopUp->insertItem( "300", 300 ); |
101 | mBeepPopUp->insertItem( "180", 180 ); | 106 | mBeepPopUp->insertItem( "180", 180 ); |
102 | mBeepPopUp->insertItem( "60", 60 ); | 107 | mBeepPopUp->insertItem( "60", 60 ); |
103 | mBeepPopUp->insertItem( "30", 30 ); | 108 | mBeepPopUp->insertItem( "30", 30 ); |
104 | mBeepPopUp->insertItem( "10", 10 ); | 109 | mBeepPopUp->insertItem( "10", 10 ); |
105 | mBeepPopUp->insertItem( "3", 3 ); | 110 | mBeepPopUp->insertItem( "3", 3 ); |
106 | mBeepPopUp->insertItem( "1", 1 ); | 111 | mBeepPopUp->insertItem( "1", 1 ); |
107 | mBeepPopUp->insertItem( "Off", 0 ); | 112 | mBeepPopUp->insertItem( "Off", 0 ); |
108 | mBeepPopUp->insertSeparator(); | 113 | mBeepPopUp->insertSeparator(); |
109 | mBeepPopUp->insertItem( "Simulate", 1000 ); | 114 | mBeepPopUp->insertItem( "Simulate", 1000 ); |
110 | mBeepPopUp->setCheckable( true ); | 115 | mBeepPopUp->setCheckable( true ); |
111 | mPopUp->insertSeparator(); | 116 | mPopUp->insertSeparator(); |
112 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); | 117 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); |
113 | mPopUp->insertSeparator(); | 118 | mPopUp->insertSeparator(); |
114 | mPopUp->insertItem( "Timer", mTimerPopUp ); | 119 | mPopUp->insertItem( "Timer", mTimerPopUp ); |
115 | //mPopUp->insertSeparator(); | 120 | //mPopUp->insertSeparator(); |
116 | //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); | 121 | //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); |
117 | 122 | ||
118 | mPopUp->resize( mPopUp->sizeHint() ); | 123 | mPopUp->resize( mPopUp->sizeHint() ); |
119 | mPlayBeeps = 60; | 124 | mPlayBeeps = 60; |
120 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 125 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
121 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); | 126 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); |
122 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); | 127 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); |
123 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); | 128 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); |
124 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); | 129 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); |
125 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); | 130 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); |
126 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); | 131 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); |
127 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); | 132 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); |
128 | mTimerTime = 0; | 133 | mTimerTime = 0; |
129 | mCustomText = "Custom Text"; | 134 | mCustomText = "Custom Text"; |
130 | mCustomMinutes = 7; | 135 | mCustomMinutes = 7; |
131 | mTimerPopupConf = 1; | 136 | mTimerPopupConf = 1; |
132 | fillTimerPopUp(); | 137 | fillTimerPopUp(); |
133 | mPausePlay = 0; | 138 | mPausePlay = 0; |
134 | confPause( 1 ); | 139 | confPause( 1 ); |
135 | mSuspend = 0; | 140 | mSuspend = 0; |
136 | confSuspend( 0 ); | 141 | confSuspend( 0 ); |
137 | if ( QApplication::desktop()->width() < 480 ) { | 142 | if ( QApplication::desktop()->width() < 480 ) { |
138 | wavAlarm = false; | 143 | wavAlarm = false; |
139 | mSoundPopUp->setItemChecked ( 0, true ); | 144 | mSoundPopUp->setItemChecked ( 0, true ); |
140 | } | 145 | } |
141 | else { | 146 | else { |
142 | wavAlarm = true; | 147 | wavAlarm = true; |
143 | mSoundPopUp->setItemChecked ( 1, true ); | 148 | mSoundPopUp->setItemChecked ( 1, true ); |
144 | } | 149 | } |
145 | saveSlot( 1 ); | 150 | saveSlot( 1 ); |
146 | } | 151 | } |
147 | 152 | ||
148 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | 153 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() |
149 | { | 154 | { |
150 | //delete mPopUp; | 155 | //delete mPopUp; |
151 | delete mAlarmDialog; | 156 | delete mAlarmDialog; |
152 | } | 157 | } |
153 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | 158 | void SimpleAlarmDaemonImpl::saveSlot( int load ) |
154 | { | 159 | { |
155 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; | 160 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; |
156 | //qDebug("save %d ", load ); | 161 | //qDebug("save %d ", load ); |
157 | QFile file( fileName ); | 162 | QFile file( fileName ); |
158 | if ( load ) { | 163 | if ( load ) { |
159 | if( !QFile::exists( fileName) ) | 164 | if( !QFile::exists( fileName) ) |
160 | return; | 165 | return; |
161 | if (!file.open( IO_ReadOnly ) ) { | 166 | if (!file.open( IO_ReadOnly ) ) { |
162 | return ; | 167 | return ; |
163 | } | 168 | } |
164 | QString line; | 169 | QString line; |
165 | bool ok; | 170 | bool ok; |
166 | int val; | 171 | int val; |
167 | int len; | 172 | int len; |
168 | while ( file.readLine( line, 1024 ) > 0 ) { | 173 | while ( file.readLine( line, 1024 ) > 0 ) { |
169 | //qDebug("read %s ", line.latin1()); | 174 | //qDebug("read %s ", line.latin1()); |
170 | len = line.length(); | 175 | len = line.length(); |
171 | if ( line.left(4 ) == "PPAU" ) { | 176 | if ( line.left(4 ) == "PPAU" ) { |
172 | val = line.mid( 4,len-5).toInt( &ok ); | 177 | val = line.mid( 4,len-5).toInt( &ok ); |
173 | if ( ok ) { | 178 | if ( ok ) { |
174 | confPause( val ); | 179 | confPause( val ); |
175 | } | 180 | } |
176 | } | 181 | } |
177 | if ( line.left(4 ) == "SUCO" ) { | 182 | if ( line.left(4 ) == "SUCO" ) { |
178 | val = line.mid( 4,len-5).toInt( &ok ); | 183 | val = line.mid( 4,len-5).toInt( &ok ); |
179 | if ( ok ) | 184 | if ( ok ) |
180 | confSuspend ( val ); | 185 | confSuspend ( val ); |
181 | } | 186 | } |
182 | if ( line.left(4 ) == "WAAL" ) { | 187 | if ( line.left(4 ) == "WAAL" ) { |
183 | val = line.mid( 4,len-5).toInt( &ok ); | 188 | val = line.mid( 4,len-5).toInt( &ok ); |
184 | if ( ok ) | 189 | if ( ok ) |
185 | confSound( val ); | 190 | confSound( val ); |
186 | 191 | ||
187 | } | 192 | } |
188 | if ( line.left(4 ) == "PLBE" ) { | 193 | if ( line.left(4 ) == "PLBE" ) { |
189 | val = line.mid( 4,len-5).toInt( &ok ); | 194 | val = line.mid( 4,len-5).toInt( &ok ); |
190 | if ( ok ) | 195 | if ( ok ) |
191 | slotPlayBeep( val ); | 196 | slotPlayBeep( val ); |
192 | 197 | ||
193 | } | 198 | } |
194 | if ( line.left(4 ) == "CUTE" ) { | 199 | if ( line.left(4 ) == "CUTE" ) { |
195 | mCustomText = line.mid( 5,len-6); | 200 | mCustomText = line.mid( 5,len-6); |
196 | // qDebug("text ***%s*** ",mCustomText.latin1() ); | 201 | // qDebug("text ***%s*** ",mCustomText.latin1() ); |
197 | 202 | ||
198 | } | 203 | } |
199 | if ( line.left(4 ) == "CUMI" ) { | 204 | if ( line.left(4 ) == "CUMI" ) { |
200 | val = line.mid( 4,len-5).toInt( &ok ); | 205 | val = line.mid( 4,len-5).toInt( &ok ); |
201 | if ( ok ) | 206 | if ( ok ) |
202 | mCustomMinutes = val; | 207 | mCustomMinutes = val; |
203 | 208 | ||
204 | } | 209 | } |
205 | if ( line.left(4 ) == "SUTI" ) { | 210 | if ( line.left(4 ) == "SUTI" ) { |
206 | val = line.mid( 4,len-5).toInt( &ok ); | 211 | val = line.mid( 4,len-5).toInt( &ok ); |
207 | if ( ok ) | 212 | if ( ok ) |
208 | mAlarmDialog->setSuspendTime( val );; | 213 | mAlarmDialog->setSuspendTime( val );; |
209 | 214 | ||
210 | } | 215 | } |
211 | } | 216 | } |
212 | file.close(); | 217 | file.close(); |
213 | } else { | 218 | } else { |
214 | if (!file.open( IO_WriteOnly ) ) { | 219 | if (!file.open( IO_WriteOnly ) ) { |
215 | return; | 220 | return; |
216 | } | 221 | } |
217 | QString configString ; | 222 | QString configString ; |
218 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; | 223 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; |
219 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; | 224 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; |
220 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | 225 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; |
221 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | 226 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; |
222 | configString += "CUTE " + mCustomText + "\n"; | 227 | configString += "CUTE " + mCustomText + "\n"; |
223 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | 228 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; |
224 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | 229 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; |
225 | QTextStream ts( &file ); | 230 | QTextStream ts( &file ); |
226 | ts << configString ; | 231 | ts << configString ; |
227 | file.close(); | 232 | file.close(); |
228 | } | 233 | } |
229 | 234 | ||
230 | } | 235 | } |
231 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 236 | void SimpleAlarmDaemonImpl::confSuspend( int num ) |
232 | { | 237 | { |
233 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | 238 | mSuspendPopUp->setItemChecked ( mSuspend,false ); |
234 | mSuspend = num; | 239 | mSuspend = num; |
235 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | 240 | mSuspendPopUp->setItemChecked ( mSuspend,true ); |
236 | } | 241 | } |
237 | void SimpleAlarmDaemonImpl::confPause( int num ) | 242 | void SimpleAlarmDaemonImpl::confPause( int num ) |
238 | { | 243 | { |
239 | mPausePopUp->setItemChecked ( mPausePlay,false ); | 244 | mPausePopUp->setItemChecked ( mPausePlay,false ); |
240 | mPausePlay = num; | 245 | mPausePlay = num; |
241 | mPausePopUp->setItemChecked ( mPausePlay,true ); | 246 | mPausePopUp->setItemChecked ( mPausePlay,true ); |
242 | } | 247 | } |
243 | void SimpleAlarmDaemonImpl::confSound( int num ) | 248 | void SimpleAlarmDaemonImpl::confSound( int num ) |
244 | { | 249 | { |
245 | if ( num == 0 ) { | 250 | if ( num == 0 ) { |
246 | wavAlarm = false; | 251 | wavAlarm = false; |
247 | mSoundPopUp->setItemChecked ( 0, true ); | 252 | mSoundPopUp->setItemChecked ( 0, true ); |
248 | mSoundPopUp->setItemChecked ( 1, false ); | 253 | mSoundPopUp->setItemChecked ( 1, false ); |
249 | } else { | 254 | } else { |
250 | wavAlarm = true; | 255 | wavAlarm = true; |
251 | mSoundPopUp->setItemChecked ( 0, false ); | 256 | mSoundPopUp->setItemChecked ( 0, false ); |
252 | mSoundPopUp->setItemChecked ( 1, true ); | 257 | mSoundPopUp->setItemChecked ( 1, true ); |
253 | } | 258 | } |
254 | } | 259 | } |
255 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 260 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) |
256 | { | 261 | { |
257 | if ( num == 1000 ) { | 262 | if ( num == 1000 ) { |
258 | simulate(); | 263 | simulate(); |
259 | return; | 264 | return; |
260 | } | 265 | } |
261 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | 266 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); |
262 | mPlayBeeps = num; | 267 | mPlayBeeps = num; |
263 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 268 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
264 | } | 269 | } |
265 | 270 | ||
266 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 271 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) |
267 | { | 272 | { |
268 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | 273 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); |
269 | QString mess = QString::fromUtf8(msg.data()); | 274 | QString mess = QString::fromUtf8(msg.data()); |
270 | mAlarmMessage = mess.mid( 9 ); | 275 | mAlarmMessage = mess.mid( 9 ); |
271 | QString filename = getenv("QPEDIR") ; | 276 | QString filename = getenv("QPEDIR") ; |
272 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 277 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
273 | QString tempfilename; | 278 | QString tempfilename; |
274 | if ( mess.left( 13 ) == "suspend_alarm") { | 279 | if ( mess.left( 13 ) == "suspend_alarm") { |
275 | bool error = false; | 280 | bool error = false; |
276 | int len = mess.mid( 13 ).find("+++"); | 281 | int len = mess.mid( 13 ).find("+++"); |
277 | if ( len < 2 ) | 282 | if ( len < 2 ) |
278 | error = true; | 283 | error = true; |
279 | else { | 284 | else { |
280 | tempfilename = mess.mid( 13, len ); | 285 | tempfilename = mess.mid( 13, len ); |
281 | if ( !QFile::exists( tempfilename ) ) | 286 | if ( !QFile::exists( tempfilename ) ) |
282 | error = true; | 287 | error = true; |
283 | } | 288 | } |
284 | if ( ! error ) { | 289 | if ( ! error ) { |
285 | filename = tempfilename; | 290 | filename = tempfilename; |
286 | } | 291 | } |
287 | mAlarmMessage = mess.mid( 13+len+3 ); | 292 | mAlarmMessage = mess.mid( 13+len+3 ); |
288 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 293 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
289 | startAlarm( mAlarmMessage, filename); | 294 | startAlarm( mAlarmMessage, filename); |
290 | return; | 295 | return; |
291 | } | 296 | } |
292 | if ( mess.left( 11 ) == "timer_alarm") { | 297 | if ( mess.left( 11 ) == "timer_alarm") { |
293 | mTimerTime = 0; | 298 | mTimerTime = 0; |
294 | startAlarm( mess.mid( 11 ), filename ); | 299 | startAlarm( mess.mid( 11 ), filename ); |
295 | return; | 300 | return; |
296 | } | 301 | } |
297 | if ( mess.left( 10 ) == "proc_alarm") { | 302 | if ( mess.left( 10 ) == "proc_alarm") { |
298 | bool error = false; | 303 | bool error = false; |
299 | int len = mess.mid( 10 ).find("+++"); | 304 | int len = mess.mid( 10 ).find("+++"); |
300 | if ( len < 2 ) | 305 | if ( len < 2 ) |
301 | error = true; | 306 | error = true; |
302 | else { | 307 | else { |
303 | tempfilename = mess.mid( 10, len ); | 308 | tempfilename = mess.mid( 10, len ); |
304 | if ( !QFile::exists( tempfilename ) ) | 309 | if ( !QFile::exists( tempfilename ) ) |
305 | error = true; | 310 | error = true; |
306 | } | 311 | } |
307 | if ( error ) { | 312 | if ( error ) { |
308 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 313 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
309 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 314 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
310 | } else { | 315 | } else { |
311 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 316 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
312 | if ( vfork () == 0 ) { | 317 | if ( vfork () == 0 ) { |
313 | execl ( tempfilename.latin1(), 0 ); | 318 | execl ( tempfilename.latin1(), 0 ); |
314 | return; | 319 | return; |
315 | } | 320 | } |
316 | QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); | 321 | QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); |
317 | return; | 322 | return; |
318 | } | 323 | } |
319 | 324 | ||
320 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 325 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
321 | } | 326 | } |
322 | if ( mess.left( 11 ) == "audio_alarm") { | 327 | if ( mess.left( 11 ) == "audio_alarm") { |
323 | bool error = false; | 328 | bool error = false; |
324 | int len = mess.mid( 11 ).find("+++"); | 329 | int len = mess.mid( 11 ).find("+++"); |
325 | if ( len < 2 ) | 330 | if ( len < 2 ) |
326 | error = true; | 331 | error = true; |
327 | else { | 332 | else { |
328 | tempfilename = mess.mid( 11, len ); | 333 | tempfilename = mess.mid( 11, len ); |
329 | if ( !QFile::exists( tempfilename ) ) | 334 | if ( !QFile::exists( tempfilename ) ) |
330 | error = true; | 335 | error = true; |
331 | } | 336 | } |
332 | if ( ! error ) { | 337 | if ( ! error ) { |
333 | filename = tempfilename; | 338 | filename = tempfilename; |
334 | } | 339 | } |
335 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 340 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
336 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 341 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
337 | } | 342 | } |
338 | if ( mess.left( 9 ) == "cal_alarm") { | 343 | if ( mess.left( 9 ) == "cal_alarm") { |
339 | mAlarmMessage = mess.mid( 9 ) ; | 344 | mAlarmMessage = mess.mid( 9 ) ; |
340 | } | 345 | } |
341 | 346 | ||
342 | QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); | 347 | QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); |
343 | startAlarm( mAlarmMessage, filename ); | 348 | startAlarm( mAlarmMessage, filename ); |
344 | 349 | ||
345 | } | 350 | } |
346 | 351 | ||
347 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 352 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
348 | { | 353 | { |
349 | return 0; | 354 | return 0; |
350 | } | 355 | } |
351 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 356 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
352 | { | 357 | { |
353 | //mAlarmDialog->show(); | 358 | //mAlarmDialog->show(); |
354 | //mAlarmDialog->raise(); | 359 | //mAlarmDialog->raise(); |
355 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 360 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
356 | } | 361 | } |
357 | 362 | ||
358 | 363 | ||
359 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 364 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
360 | { | 365 | { |
361 | 366 | ||
362 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 367 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
363 | if ( mTimerPopupConf == mTimerTime ) { | 368 | if ( mTimerPopupConf == mTimerTime ) { |
364 | if ( mTimerTime ) { | 369 | if ( mTimerTime ) { |
365 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 370 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
366 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 371 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
367 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); | 372 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); |
368 | } | 373 | } |
369 | else { | 374 | else { |
370 | QString text = mCustomText.stripWhiteSpace (); | 375 | QString text = mCustomText.stripWhiteSpace (); |
371 | int in = text.find( " " ); | 376 | int in = text.find( " " ); |
372 | text = text.left ( in ); | 377 | text = text.left ( in ); |
373 | mTimerPopUp->changeItem ( 3, text ); | 378 | mTimerPopUp->changeItem ( 3, text ); |
374 | } | 379 | } |
375 | return; | 380 | return; |
376 | } | 381 | } |
377 | mTimerPopupConf = mTimerTime; | 382 | mTimerPopupConf = mTimerTime; |
378 | mTimerPopUp->clear(); | 383 | mTimerPopUp->clear(); |
379 | if ( mTimerTime ) { | 384 | if ( mTimerTime ) { |
380 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 385 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
381 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 386 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
382 | 387 | ||
383 | 388 | ||
384 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); | 389 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); |
385 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); | 390 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); |
386 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); | 391 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); |
387 | } else { | 392 | } else { |
388 | 393 | ||
389 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | 394 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; |
390 | QFile file( fileName ); | 395 | QFile file( fileName ); |
391 | if( !QFile::exists( fileName) ) { | 396 | if( !QFile::exists( fileName) ) { |
392 | // write defaults | 397 | // write defaults |
393 | if (!file.open( IO_WriteOnly ) ) { | 398 | if (!file.open( IO_WriteOnly ) ) { |
394 | return; | 399 | return; |
395 | } | 400 | } |
396 | QString configString ; | 401 | QString configString ; |
397 | configString += "#config file for kopi alarm timer\n"; | 402 | configString += "#config file for kopi alarm timer\n"; |
398 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | 403 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; |
399 | configString += "24 hours; 1440\n"; | 404 | configString += "24 hours; 1440\n"; |
400 | configString += "8 hours; 480\n"; | 405 | configString += "8 hours; 480\n"; |
401 | configString += "5 hours; 300\n"; | 406 | configString += "5 hours; 300\n"; |
402 | configString += "1 hour; 60\n"; | 407 | configString += "1 hour; 60\n"; |
403 | configString += "30 min; 30\n"; | 408 | configString += "30 min; 30\n"; |
404 | configString += "15 min; 15\n"; | 409 | configString += "15 min; 15\n"; |
405 | configString += "SEPARATOR\n"; | 410 | configString += "SEPARATOR\n"; |
406 | configString += "Pizza; 22\n"; | 411 | configString += "Pizza; 22\n"; |
407 | configString += "Nap; 45\n"; | 412 | configString += "Nap; 45\n"; |
408 | configString += "Tea; 5\n"; | 413 | configString += "Tea; 5\n"; |
409 | QTextStream ts( &file ); | 414 | QTextStream ts( &file ); |
410 | ts << configString ; | 415 | ts << configString ; |
411 | file.close(); | 416 | file.close(); |
412 | } | 417 | } |
413 | 418 | ||
414 | if (!file.open( IO_ReadOnly ) ) { | 419 | if (!file.open( IO_ReadOnly ) ) { |
415 | return ; | 420 | return ; |
416 | } | 421 | } |
417 | QString line; | 422 | QString line; |
418 | bool ok; | 423 | bool ok; |
419 | while ( file.readLine( line, 1024 ) > 0 ) { | 424 | while ( file.readLine( line, 1024 ) > 0 ) { |
420 | //qDebug("read %s ", line.latin1()); | 425 | //qDebug("read %s ", line.latin1()); |
421 | if ( line.left(1 ) != "#" ) { | 426 | if ( line.left(1 ) != "#" ) { |
422 | // no comment | 427 | // no comment |
423 | if ( line.left(9 ) == "SEPARATOR" ) { | 428 | if ( line.left(9 ) == "SEPARATOR" ) { |
424 | mTimerPopUp->insertSeparator(); | 429 | mTimerPopUp->insertSeparator(); |
425 | } else { | 430 | } else { |
426 | QStringList li = QStringList::split(";",line); | 431 | QStringList li = QStringList::split(";",line); |
427 | ok = false; | 432 | ok = false; |
428 | if ( li.count() == 2 ) { | 433 | if ( li.count() == 2 ) { |
429 | int val = li[1].toInt( &ok ); | 434 | int val = li[1].toInt( &ok ); |
430 | if ( ok && val > 0 ) { | 435 | if ( ok && val > 0 ) { |
431 | mTimerPopUp->insertItem( li[0], val+10); | 436 | mTimerPopUp->insertItem( li[0], val+10); |
432 | } | 437 | } |
433 | } | 438 | } |
434 | } | 439 | } |
435 | } | 440 | } |
436 | } | 441 | } |
437 | file.close(); | 442 | file.close(); |
438 | #if 0 | 443 | #if 0 |
439 | mTimerPopUp->insertItem( "24 hours", 1440 ); | 444 | mTimerPopUp->insertItem( "24 hours", 1440 ); |
440 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | 445 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); |
441 | mTimerPopUp->insertItem( " 8 hours", 480 ); | 446 | mTimerPopUp->insertItem( " 8 hours", 480 ); |
442 | mTimerPopUp->insertItem( " 5 hours", 300 ); | 447 | mTimerPopUp->insertItem( " 5 hours", 300 ); |
443 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | 448 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); |
444 | mTimerPopUp->insertItem( " 1 hour", 60 ); | 449 | mTimerPopUp->insertItem( " 1 hour", 60 ); |
445 | mTimerPopUp->insertItem( "30 min", 30 ); | 450 | mTimerPopUp->insertItem( "30 min", 30 ); |
446 | mTimerPopUp->insertItem( "15 min", 15 ); | 451 | mTimerPopUp->insertItem( "15 min", 15 ); |
447 | mTimerPopUp->insertItem( "10 min", 10 ); | 452 | mTimerPopUp->insertItem( "10 min", 10 ); |
448 | //mTimerPopUp->insertItem( " 5 min", 5 ); | 453 | //mTimerPopUp->insertItem( " 5 min", 5 ); |
449 | mTimerPopUp->insertSeparator(); | 454 | mTimerPopUp->insertSeparator(); |
450 | mTimerPopUp->insertItem( "Pizza", 22 ); | 455 | mTimerPopUp->insertItem( "Pizza", 22 ); |
451 | mTimerPopUp->insertItem( "Nap", 45 ); | 456 | mTimerPopUp->insertItem( "Nap", 45 ); |
452 | mTimerPopUp->insertItem( "Tea", 5 ); | 457 | mTimerPopUp->insertItem( "Tea", 5 ); |
453 | #endif | 458 | #endif |
454 | QString text = mCustomText.stripWhiteSpace (); | 459 | QString text = mCustomText.stripWhiteSpace (); |
455 | int in = text.find( " " ); | 460 | int in = text.find( " " ); |
456 | text = text.left ( in ); | 461 | text = text.left ( in ); |
457 | mTimerPopUp->insertItem( text, 3 ); | 462 | mTimerPopUp->insertItem( text, 3 ); |
458 | mTimerPopUp->insertSeparator(); | 463 | mTimerPopUp->insertSeparator(); |
459 | mTimerPopUp->insertItem( "Customize", 2 ); | 464 | mTimerPopUp->insertItem( "Customize", 2 ); |
460 | } | 465 | } |
461 | 466 | ||
462 | } | 467 | } |
463 | 468 | ||
464 | void SimpleAlarmDaemonImpl::showTimer() | 469 | void SimpleAlarmDaemonImpl::showTimer() |
465 | { | 470 | { |
466 | fillTimerPopUp(); | 471 | fillTimerPopUp(); |
467 | } | 472 | } |
468 | 473 | ||
469 | void SimpleAlarmDaemonImpl::confTimer( int time ) | 474 | void SimpleAlarmDaemonImpl::confTimer( int time ) |
470 | { | 475 | { |
471 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | 476 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); |
472 | int minutes = time; | 477 | int minutes = time; |
473 | if ( minutes == 0 ) { | 478 | if ( minutes == 0 ) { |
474 | if ( ! mTimerTime ) | 479 | if ( ! mTimerTime ) |
475 | return; | 480 | return; |
476 | 481 | ||
477 | QDialog dia ( 0, ("Stop Timer" ), true ); | 482 | QDialog dia ( 0, ("Stop Timer" ), true ); |
478 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); | 483 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); |
479 | lab.setAlignment( AlignCenter ); | 484 | lab.setAlignment( AlignCenter ); |
480 | dia.setCaption(("KO/Pi Timer Stop" )); | 485 | dia.setCaption(("KO/Pi Timer Stop" )); |
481 | QVBoxLayout lay( &dia ); | 486 | QVBoxLayout lay( &dia ); |
482 | lay.addWidget( &lab); | 487 | lay.addWidget( &lab); |
483 | QPushButton ok ( "Stop timer!", &dia); | 488 | QPushButton ok ( "Stop timer!", &dia); |
484 | QFont fo = dia.font(); | 489 | QFont fo = dia.font(); |
485 | fo.setPointSize( 36 ); | 490 | fo.setPointSize( 36 ); |
486 | ok.setFont( fo ); | 491 | ok.setFont( fo ); |
487 | lay.addWidget( &ok); | 492 | lay.addWidget( &ok); |
488 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 493 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
489 | QPushButton con ( "Continue timer!", &dia); | 494 | QPushButton con ( "Continue timer!", &dia); |
490 | fo.setPointSize( 36 ); | 495 | fo.setPointSize( 36 ); |
491 | con.setFont( fo ); | 496 | con.setFont( fo ); |
492 | lay.addWidget( &con); | 497 | lay.addWidget( &con); |
493 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); | 498 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); |
494 | lay.setMargin(5); | 499 | lay.setMargin(5); |
495 | lay.setSpacing(5); | 500 | lay.setSpacing(5); |
496 | dia.resize(dia.sizeHint() ); | 501 | dia.resize(dia.sizeHint() ); |
497 | 502 | ||
498 | if ( !dia.exec() ) | 503 | if ( !dia.exec() ) |
499 | return; | 504 | return; |
500 | 505 | ||
501 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); | 506 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); |
502 | mTimerTime = 0; | 507 | mTimerTime = 0; |
503 | return; | 508 | return; |
504 | } | 509 | } |
505 | if ( mTimerTime ) | 510 | if ( mTimerTime ) |
506 | return; | 511 | return; |
507 | if ( minutes == 1 ) { | 512 | if ( minutes == 1 ) { |
508 | return; | 513 | return; |
509 | } | 514 | } |
510 | QString mess = "timer_alarm"; | 515 | QString mess = "timer_alarm"; |
511 | mess += ("Timer Alarm!\n"); | 516 | mess += ("Timer Alarm!\n"); |
512 | if ( minutes == 3 ) { | 517 | if ( minutes == 3 ) { |
513 | mess += mCustomText; | 518 | mess += mCustomText; |
514 | minutes = mCustomMinutes ; | 519 | minutes = mCustomMinutes ; |
515 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 520 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
516 | int in = mRunningTimerText.find( " " ); | 521 | int in = mRunningTimerText.find( " " ); |
517 | mRunningTimerText = mRunningTimerText.left ( in ); | 522 | mRunningTimerText = mRunningTimerText.left ( in ); |
518 | } | 523 | } |
519 | else { | 524 | else { |
520 | if ( minutes == 2 ) { | 525 | if ( minutes == 2 ) { |
521 | // ask time | 526 | // ask time |
522 | QDialog dia ( 0, ("Customize Timer" ), true ); | 527 | QDialog dia ( 0, ("Customize Timer" ), true ); |
523 | QLabel lab (("Message Text:"), &dia ); | 528 | QLabel lab (("Message Text:"), &dia ); |
524 | dia.setCaption(("KO/Pi Timer" )); | 529 | dia.setCaption(("KO/Pi Timer" )); |
525 | QVBoxLayout lay( &dia ); | 530 | QVBoxLayout lay( &dia ); |
526 | lay.setMargin(5); | 531 | lay.setMargin(5); |
527 | lay.setSpacing(5); | 532 | lay.setSpacing(5); |
528 | lay.addWidget( &lab); | 533 | lay.addWidget( &lab); |
529 | QLineEdit lEdit( mCustomText, &dia ); | 534 | QLineEdit lEdit( mCustomText, &dia ); |
530 | lay.addWidget( &lEdit); | 535 | lay.addWidget( &lEdit); |
531 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 536 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
532 | lay.addWidget( &lab2); | 537 | lay.addWidget( &lab2); |
533 | QHBox hbox1 ( &dia ); | 538 | QHBox hbox1 ( &dia ); |
534 | lay.addWidget( &hbox1); | 539 | lay.addWidget( &hbox1); |
535 | QLabel lab3 (("Hours"), &hbox1 ); | 540 | QLabel lab3 (("Hours"), &hbox1 ); |
536 | QLabel lab4 (("Minutes"), &hbox1 ); | 541 | QLabel lab4 (("Minutes"), &hbox1 ); |
537 | QHBox hbox ( &dia ); | 542 | QHBox hbox ( &dia ); |
538 | QSpinBox spinh( 0, 24, 1,& hbox ); | 543 | QSpinBox spinh( 0, 24, 1,& hbox ); |
539 | QFont fo = dia.font(); | 544 | QFont fo = dia.font(); |
540 | fo.setPointSize( 36 ); | 545 | fo.setPointSize( 36 ); |
541 | QSpinBox spinm( 0, 59, 1,&hbox ); | 546 | QSpinBox spinm( 0, 59, 1,&hbox ); |
542 | spinm.setFont( fo ); | 547 | spinm.setFont( fo ); |
543 | spinh.setFont( fo ); | 548 | spinh.setFont( fo ); |
544 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); | 549 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); |
545 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); | 550 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); |
546 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); | 551 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); |
547 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); | 552 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); |
548 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); | 553 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); |
549 | spinh.setFixedSize( 100,62 ); | 554 | spinh.setFixedSize( 100,62 ); |
550 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); | 555 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); |
551 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); | 556 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); |
552 | spinm.downButton ()->setGeometry( 50,50,50,50); | 557 | spinm.downButton ()->setGeometry( 50,50,50,50); |
553 | // spinm.setSuffix( " m" ); | 558 | // spinm.setSuffix( " m" ); |
554 | //spinh.setSuffix( " h" ); | 559 | //spinh.setSuffix( " h" ); |
555 | spinm.setWrapping ( true ); | 560 | spinm.setWrapping ( true ); |
556 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); | 561 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); |
557 | spinm.setLineStep( 1 ); | 562 | spinm.setLineStep( 1 ); |
558 | spinm.setFixedSize( 110,62 ); | 563 | spinm.setFixedSize( 110,62 ); |
559 | lay.addWidget( &hbox); | 564 | lay.addWidget( &hbox); |
560 | QLabel lab5 ("Timer fires at:", &dia ); | 565 | QLabel lab5 ("Timer fires at:", &dia ); |
561 | lab5.setAlignment( AlignCenter ); | 566 | lab5.setAlignment( AlignCenter ); |
562 | lay.addWidget( &lab5); | 567 | lay.addWidget( &lab5); |
563 | KODateLabel dl ( &dia ); | 568 | KODateLabel dl ( &dia ); |
564 | dl.setAlignment( AlignCenter ); | 569 | dl.setAlignment( AlignCenter ); |
565 | dl.setFont( fo ); | 570 | dl.setFont( fo ); |
566 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); | 571 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); |
567 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); | 572 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); |
568 | lay.addWidget( &dl); | 573 | lay.addWidget( &dl); |
569 | spinh.setValue( mCustomMinutes/60 ); | 574 | spinh.setValue( mCustomMinutes/60 ); |
570 | spinm.setValue( mCustomMinutes%60 ); | 575 | spinm.setValue( mCustomMinutes%60 ); |
571 | QPushButton ok ( "Start timer", &dia); | 576 | QPushButton ok ( "Start timer", &dia); |
572 | ok.setDefault( true ); | 577 | ok.setDefault( true ); |
573 | ok.setFont( fo ); | 578 | ok.setFont( fo ); |
574 | spinh.setFocus(); | 579 | spinh.setFocus(); |
575 | lay.addWidget( &ok); | 580 | lay.addWidget( &ok); |
576 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 581 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
577 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | 582 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); |
578 | 583 | ||
579 | if ( !dia.exec() ) | 584 | if ( !dia.exec() ) |
580 | return; | 585 | return; |
581 | mCustomText = lEdit.text(); | 586 | mCustomText = lEdit.text(); |
582 | mCustomMinutes = spinh.value()*60+spinm.value(); | 587 | mCustomMinutes = spinh.value()*60+spinm.value(); |
583 | if ( mCustomMinutes == 0 ) | 588 | if ( mCustomMinutes == 0 ) |
584 | mCustomMinutes = 1; | 589 | mCustomMinutes = 1; |
585 | if ( mCustomMinutes > 1440 ) | 590 | if ( mCustomMinutes > 1440 ) |
586 | mCustomMinutes = 1440; | 591 | mCustomMinutes = 1440; |
587 | mess += mCustomText; | 592 | mess += mCustomText; |
588 | minutes = mCustomMinutes; | 593 | minutes = mCustomMinutes; |
589 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 594 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
590 | int in = mRunningTimerText.find( " " ); | 595 | int in = mRunningTimerText.find( " " ); |
591 | mRunningTimerText = mRunningTimerText.left ( in ); | 596 | mRunningTimerText = mRunningTimerText.left ( in ); |
592 | } | 597 | } |
593 | else { | 598 | else { |
594 | mess += mTimerPopUp->text( minutes ); | 599 | mess += mTimerPopUp->text( minutes ); |
595 | mRunningTimerText = mTimerPopUp->text( minutes ); | 600 | mRunningTimerText = mTimerPopUp->text( minutes ); |
596 | minutes -= 10; | 601 | minutes -= 10; |
597 | } | 602 | } |
598 | } | 603 | } |
599 | //minutes = 1; | 604 | //minutes = 1; |
600 | 605 | ||
601 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 606 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
602 | timerMesssage = mess; | 607 | timerMesssage = mess; |
603 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); | 608 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); |
604 | mTimerTime = 1; | 609 | mTimerTime = 1; |
605 | } | 610 | } |
606 | 611 | ||
607 | void SimpleAlarmDaemonImpl::writeFile() | 612 | void SimpleAlarmDaemonImpl::writeFile() |
608 | { | 613 | { |
609 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 614 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
610 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | 615 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); |
611 | } | 616 | } |
612 | void SimpleAlarmDaemonImpl::showWN() | 617 | void SimpleAlarmDaemonImpl::showWN() |
613 | { | 618 | { |
614 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 619 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
615 | } | 620 | } |
616 | void SimpleAlarmDaemonImpl::newTodo() | 621 | void SimpleAlarmDaemonImpl::newTodo() |
617 | { | 622 | { |
618 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 623 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
619 | } | 624 | } |
620 | 625 | ||
621 | void SimpleAlarmDaemonImpl::newEvent() | 626 | void SimpleAlarmDaemonImpl::newEvent() |
622 | { | 627 | { |
623 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 628 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
624 | 629 | ||
625 | } | 630 | } |
626 | void SimpleAlarmDaemonImpl::newMail() | 631 | void SimpleAlarmDaemonImpl::newMail() |
627 | { | 632 | { |
628 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); | 633 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); |
629 | } | 634 | } |
630 | void SimpleAlarmDaemonImpl::showAdd() | 635 | void SimpleAlarmDaemonImpl::showAdd() |
631 | { | 636 | { |
632 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 637 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
633 | } | 638 | } |
634 | void SimpleAlarmDaemonImpl::ringSync() | 639 | void SimpleAlarmDaemonImpl::ringSync() |
635 | { | 640 | { |
636 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 641 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
637 | 642 | ||
638 | } | 643 | } |
639 | void SimpleAlarmDaemonImpl::newCountdown() | 644 | void SimpleAlarmDaemonImpl::newCountdown() |
640 | { | 645 | { |
641 | //recieve("cal_alarm", 10 ); | 646 | //recieve("cal_alarm", 10 ); |
642 | } | 647 | } |
643 | void SimpleAlarmDaemonImpl::simulate() | 648 | void SimpleAlarmDaemonImpl::simulate() |
644 | { | 649 | { |
645 | QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); | 650 | QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); |
646 | QString filename = getenv("QPEDIR") ; | 651 | QString filename = getenv("QPEDIR") ; |
647 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 652 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
648 | startAlarm("Alarm simulation", filename ); | 653 | startAlarm("Alarm simulation", filename ); |
649 | } | 654 | } |
650 | void SimpleAlarmDaemonImpl::showKO() | 655 | void SimpleAlarmDaemonImpl::showKO() |
651 | { | 656 | { |
652 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 657 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
653 | // testing only | 658 | // testing only |
654 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); | 659 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); |
655 | 660 | ||
656 | } | 661 | } |
657 | void SimpleAlarmDaemonImpl::showTodo() | 662 | void SimpleAlarmDaemonImpl::showTodo() |
658 | { | 663 | { |
659 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 664 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
660 | 665 | ||
661 | } | 666 | } |
662 | void SimpleAlarmDaemonImpl::writeJournal() | 667 | void SimpleAlarmDaemonImpl::writeJournal() |
663 | { | 668 | { |
664 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 669 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
665 | 670 | ||
666 | } | 671 | } |
667 | 672 | ||
668 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 673 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
669 | { | 674 | { |
670 | 675 | ||
671 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 676 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
672 | 677 | ||
673 | } | 678 | } |
674 | 679 | ||
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 98d3e35..fb0b4ad 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,961 +1,960 @@ | |||
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/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qtopia/alarmserver.h> | 27 | #include <qtopia/alarmserver.h> |
28 | #include <qtopia/qcopenvelope_qws.h> | 28 | #include <qtopia/qcopenvelope_qws.h> |
29 | #include <unistd.h> // for sleep | 29 | #include <unistd.h> // for sleep |
30 | #else | 30 | #else |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <resource.h> | 33 | //#include <resource.h> |
34 | 34 | ||
35 | #endif | 35 | #endif |
36 | #include <libkcal/calendarlocal.h> | 36 | #include <libkcal/calendarlocal.h> |
37 | #include <libkcal/todo.h> | 37 | #include <libkcal/todo.h> |
38 | #include <libkcal/phoneformat.h> | 38 | #include <libkcal/phoneformat.h> |
39 | #include <libkdepim/ksyncprofile.h> | 39 | #include <libkdepim/ksyncprofile.h> |
40 | #include <libkdepim/phoneaccess.h> | 40 | #include <libkdepim/phoneaccess.h> |
41 | #include <libkcal/kincidenceformatter.h> | 41 | #include <libkcal/kincidenceformatter.h> |
42 | #include <libkdepim/kpimglobalprefs.h> | 42 | #include <libkdepim/kpimglobalprefs.h> |
43 | 43 | ||
44 | #include "calendarview.h" | 44 | #include "calendarview.h" |
45 | #include "koviewmanager.h" | 45 | #include "koviewmanager.h" |
46 | #include "datenavigator.h" | 46 | #include "datenavigator.h" |
47 | #include "koagendaview.h" | 47 | #include "koagendaview.h" |
48 | #include "kojournalview.h" | 48 | #include "kojournalview.h" |
49 | #include "koagenda.h" | 49 | #include "koagenda.h" |
50 | #include "kodialogmanager.h" | 50 | #include "kodialogmanager.h" |
51 | #include "kdialogbase.h" | 51 | #include "kdialogbase.h" |
52 | #include "kapplication.h" | 52 | #include "kapplication.h" |
53 | #include "kofilterview.h" | 53 | #include "kofilterview.h" |
54 | #include "kstandarddirs.h" | 54 | #include "kstandarddirs.h" |
55 | #include "koprefs.h" | 55 | #include "koprefs.h" |
56 | #include "kfiledialog.h" | 56 | #include "kfiledialog.h" |
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #include "kglobal.h" | 58 | #include "kglobal.h" |
59 | #include "ktoolbar.h" | 59 | #include "ktoolbar.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "externalapphandler.h" | 62 | #include "externalapphandler.h" |
63 | #include <kglobalsettings.h> | 63 | #include <kglobalsettings.h> |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #ifdef _OL_IMPORT_ | 69 | #ifdef _OL_IMPORT_ |
70 | #include "koimportoldialog.h" | 70 | #include "koimportoldialog.h" |
71 | #endif | 71 | #endif |
72 | #endif | 72 | #endif |
73 | #include "mainwindow.h" | 73 | #include "mainwindow.h" |
74 | 74 | ||
75 | 75 | ||
76 | class KOex2phonePrefs : public QDialog | 76 | class KOex2phonePrefs : public QDialog |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
80 | QDialog( parent, name, true ) | 80 | QDialog( parent, name, true ) |
81 | { | 81 | { |
82 | setCaption( i18n("Export to phone options") ); | 82 | setCaption( i18n("Export to phone options") ); |
83 | QVBoxLayout* lay = new QVBoxLayout( this ); | 83 | QVBoxLayout* lay = new QVBoxLayout( this ); |
84 | lay->setSpacing( 3 ); | 84 | lay->setSpacing( 3 ); |
85 | lay->setMargin( 3 ); | 85 | lay->setMargin( 3 ); |
86 | QLabel *lab; | 86 | QLabel *lab; |
87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
88 | lab->setAlignment (AlignHCenter ); | 88 | lab->setAlignment (AlignHCenter ); |
89 | QHBox* temphb; | 89 | QHBox* temphb; |
90 | temphb = new QHBox( this ); | 90 | temphb = new QHBox( this ); |
91 | new QLabel( i18n("I/O device: "), temphb ); | 91 | new QLabel( i18n("I/O device: "), temphb ); |
92 | mPhoneDevice = new QLineEdit( temphb); | 92 | mPhoneDevice = new QLineEdit( temphb); |
93 | lay->addWidget( temphb ); | 93 | lay->addWidget( temphb ); |
94 | temphb = new QHBox( this ); | 94 | temphb = new QHBox( this ); |
95 | new QLabel( i18n("Connection: "), temphb ); | 95 | new QLabel( i18n("Connection: "), temphb ); |
96 | mPhoneConnection = new QLineEdit( temphb); | 96 | mPhoneConnection = new QLineEdit( temphb); |
97 | lay->addWidget( temphb ); | 97 | lay->addWidget( temphb ); |
98 | temphb = new QHBox( this ); | 98 | temphb = new QHBox( this ); |
99 | new QLabel( i18n("Model(opt.): "), temphb ); | 99 | new QLabel( i18n("Model(opt.): "), temphb ); |
100 | mPhoneModel = new QLineEdit( temphb); | 100 | mPhoneModel = new QLineEdit( temphb); |
101 | lay->addWidget( temphb ); | 101 | lay->addWidget( temphb ); |
102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
103 | mWriteBackFuture->setChecked( true ); | 103 | mWriteBackFuture->setChecked( true ); |
104 | lay->addWidget( mWriteBackFuture ); | 104 | lay->addWidget( mWriteBackFuture ); |
105 | temphb = new QHBox( this ); | 105 | temphb = new QHBox( this ); |
106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
108 | mWriteBackFutureWeeks->setValue( 8 ); | 108 | mWriteBackFutureWeeks->setValue( 8 ); |
109 | lay->addWidget( temphb ); | 109 | lay->addWidget( temphb ); |
110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
111 | lab->setAlignment (AlignHCenter ); | 111 | lab->setAlignment (AlignHCenter ); |
112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
113 | lay->addWidget( ok ); | 113 | lay->addWidget( ok ); |
114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
115 | lay->addWidget( cancel ); | 115 | lay->addWidget( cancel ); |
116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
118 | resize( 220, 240 ); | 118 | resize( 220, 240 ); |
119 | qApp->processEvents(); | 119 | qApp->processEvents(); |
120 | int dw = QApplication::desktop()->width(); | 120 | int dw = QApplication::desktop()->width(); |
121 | int dh = QApplication::desktop()->height(); | 121 | int dh = QApplication::desktop()->height(); |
122 | move( (dw-width())/2, (dh - height() )/2 ); | 122 | move( (dw-width())/2, (dh - height() )/2 ); |
123 | } | 123 | } |
124 | 124 | ||
125 | public: | 125 | public: |
126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
127 | QCheckBox* mWriteBackFuture; | 127 | QCheckBox* mWriteBackFuture; |
128 | QSpinBox* mWriteBackFutureWeeks; | 128 | QSpinBox* mWriteBackFutureWeeks; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | QPixmap* sgListViewCompletedPix[6]; | 131 | QPixmap* sgListViewCompletedPix[6]; |
132 | QPixmap* sgListViewJournalPix; | 132 | QPixmap* sgListViewJournalPix; |
133 | 133 | ||
134 | 134 | ||
135 | int globalFlagBlockStartup; | 135 | int globalFlagBlockStartup; |
136 | MainWindow::MainWindow( QWidget *parent, const char *name ) : | 136 | MainWindow::MainWindow( QWidget *parent, const char *name ) : |
137 | QMainWindow( parent, name ) | 137 | QMainWindow( parent, name ) |
138 | { | 138 | { |
139 | sgListViewCompletedPix[5] = &listviewPix; | 139 | sgListViewCompletedPix[5] = &listviewPix; |
140 | sgListViewCompletedPix[0] = &listviewPix0; | 140 | sgListViewCompletedPix[0] = &listviewPix0; |
141 | sgListViewCompletedPix[1] = &listviewPix20; | 141 | sgListViewCompletedPix[1] = &listviewPix20; |
142 | sgListViewCompletedPix[2] = &listviewPix40; | 142 | sgListViewCompletedPix[2] = &listviewPix40; |
143 | sgListViewCompletedPix[3] = &listviewPix60; | 143 | sgListViewCompletedPix[3] = &listviewPix60; |
144 | sgListViewCompletedPix[4] = &listviewPix80; | 144 | sgListViewCompletedPix[4] = &listviewPix80; |
145 | //int size = 12; | 145 | //int size = 12; |
146 | { | 146 | { |
147 | sgListViewCompletedPix[5]->resize( 11, 11 ); | 147 | sgListViewCompletedPix[5]->resize( 11, 11 ); |
148 | sgListViewCompletedPix[5]->fill( Qt::white ); | 148 | sgListViewCompletedPix[5]->fill( Qt::white ); |
149 | QPainter p ( sgListViewCompletedPix[5] ); | 149 | QPainter p ( sgListViewCompletedPix[5] ); |
150 | p.drawRect( 0,0,11,11); | 150 | p.drawRect( 0,0,11,11); |
151 | p.drawLine ( 2, 5, 4 , 7 ) ; | 151 | p.drawLine ( 2, 5, 4 , 7 ) ; |
152 | p.drawLine ( 4 , 7 , 8, 3) ; | 152 | p.drawLine ( 4 , 7 , 8, 3) ; |
153 | int iii = 0; | 153 | int iii = 0; |
154 | for ( iii = 0; iii < 5; ++iii ) { | 154 | for ( iii = 0; iii < 5; ++iii ) { |
155 | sgListViewCompletedPix[iii]->resize( 11, 11 ); | 155 | sgListViewCompletedPix[iii]->resize( 11, 11 ); |
156 | sgListViewCompletedPix[iii]->fill( Qt::white ); | 156 | sgListViewCompletedPix[iii]->fill( Qt::white ); |
157 | QPainter p ( sgListViewCompletedPix[iii] ); | 157 | QPainter p ( sgListViewCompletedPix[iii] ); |
158 | p.drawRect( 0,0,11,11); | 158 | p.drawRect( 0,0,11,11); |
159 | if ( iii ) | 159 | if ( iii ) |
160 | p.fillRect( 1,1,iii*2,9,Qt::gray ); | 160 | p.fillRect( 1,1,iii*2,9,Qt::gray ); |
161 | } | 161 | } |
162 | sgListViewJournalPix = &journalPix; | 162 | sgListViewJournalPix = &journalPix; |
163 | sgListViewJournalPix->resize( 11, 11 ); | 163 | sgListViewJournalPix->resize( 11, 11 ); |
164 | sgListViewJournalPix->fill( Qt::white ); | 164 | sgListViewJournalPix->fill( Qt::white ); |
165 | { | 165 | { |
166 | QPainter p ( sgListViewJournalPix ); | 166 | QPainter p ( sgListViewJournalPix ); |
167 | p.drawRect( 0,0,11,11); | 167 | p.drawRect( 0,0,11,11); |
168 | p.drawLine( 2,3,5,3); | 168 | p.drawLine( 2,3,5,3); |
169 | p.drawLine( 2,5,8,5); | 169 | p.drawLine( 2,5,8,5); |
170 | p.drawLine( 2,7,6,7); | 170 | p.drawLine( 2,7,6,7); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | mClosed = false; | 173 | mClosed = false; |
174 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 174 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
175 | QString confFile = locateLocal("config","korganizerrc"); | 175 | QString confFile = locateLocal("config","korganizerrc"); |
176 | QFileInfo finf ( confFile ); | 176 | QFileInfo finf ( confFile ); |
177 | bool showWarning = !finf.exists(); | 177 | bool showWarning = !finf.exists(); |
178 | setIcon(SmallIcon( "ko24" ) ); | 178 | setIcon(SmallIcon( "ko24" ) ); |
179 | mBlockAtStartup = true; | 179 | mBlockAtStartup = true; |
180 | mFlagKeyPressed = false; | 180 | mFlagKeyPressed = false; |
181 | setCaption("KO/Pi"); | 181 | setCaption("KO/Pi"); |
182 | KOPrefs *p = KOPrefs::instance(); | 182 | KOPrefs *p = KOPrefs::instance(); |
183 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 183 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
184 | p->mCurrentDisplayedView = 0; | 184 | p->mCurrentDisplayedView = 0; |
185 | if ( p->mHourSize > 22 ) | 185 | if ( p->mHourSize > 22 ) |
186 | p->mHourSize = 22; | 186 | p->mHourSize = 22; |
187 | QMainWindow::ToolBarDock tbd; | 187 | QMainWindow::ToolBarDock tbd; |
188 | if ( p->mToolBarHor ) { | 188 | if ( p->mToolBarHor ) { |
189 | if ( p->mToolBarUp ) | 189 | if ( p->mToolBarUp ) |
190 | tbd = Bottom; | 190 | tbd = Bottom; |
191 | else | 191 | else |
192 | tbd = Top; | 192 | tbd = Top; |
193 | } | 193 | } |
194 | else { | 194 | else { |
195 | if ( p->mToolBarUp ) | 195 | if ( p->mToolBarUp ) |
196 | tbd = Right; | 196 | tbd = Right; |
197 | else | 197 | else |
198 | tbd = Left; | 198 | tbd = Left; |
199 | } | 199 | } |
200 | if ( KOPrefs::instance()->mUseAppColors ) | 200 | if ( KOPrefs::instance()->mUseAppColors ) |
201 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 201 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
202 | globalFlagBlockStartup = 1; | 202 | globalFlagBlockStartup = 1; |
203 | iconToolBar = new QPEToolBar( this ); | 203 | iconToolBar = new QPEToolBar( this ); |
204 | addToolBar (iconToolBar , tbd ); | 204 | addToolBar (iconToolBar , tbd ); |
205 | 205 | ||
206 | #ifdef DESKTOP_VERSION | 206 | #ifdef DESKTOP_VERSION |
207 | if ( KOPrefs::instance()->mShowIconFilter ) | 207 | if ( KOPrefs::instance()->mShowIconFilter ) |
208 | #else | 208 | #else |
209 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) | 209 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | { | 212 | { |
213 | if ( p->mToolBarHorF ) { | 213 | if ( p->mToolBarHorF ) { |
214 | if ( p->mToolBarUpF ) | 214 | if ( p->mToolBarUpF ) |
215 | tbd = Bottom; | 215 | tbd = Bottom; |
216 | else | 216 | else |
217 | tbd = Top; | 217 | tbd = Top; |
218 | } | 218 | } |
219 | else { | 219 | else { |
220 | if ( p->mToolBarUpF ) | 220 | if ( p->mToolBarUpF ) |
221 | tbd = Right; | 221 | tbd = Right; |
222 | else | 222 | else |
223 | tbd = Left; | 223 | tbd = Left; |
224 | } | 224 | } |
225 | filterToolBar = new QPEToolBar ( this ); | 225 | filterToolBar = new QPEToolBar ( this ); |
226 | filterMenubar = new KMenuBar( 0 ); | 226 | filterMenubar = new KMenuBar( 0 ); |
227 | QFontMetrics fm ( filterMenubar->font() ); | 227 | QFontMetrics fm ( filterMenubar->font() ); |
228 | #ifndef DESKTOP_VERSION | 228 | #ifndef DESKTOP_VERSION |
229 | filterToolBar->setFocusPolicy( NoFocus ); | 229 | filterToolBar->setFocusPolicy( NoFocus ); |
230 | filterMenubar->setFocusPolicy( NoFocus ); | 230 | filterMenubar->setFocusPolicy( NoFocus ); |
231 | #endif | 231 | #endif |
232 | filterPopupMenu = new QPopupMenu( this ); | 232 | filterPopupMenu = new QPopupMenu( this ); |
233 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 233 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
234 | QString addTest = "A"; | 234 | QString addTest = "A"; |
235 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); | 235 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); |
236 | #ifdef DESKTOP_VERSION | 236 | #ifdef DESKTOP_VERSION |
237 | addTest = "AAAAAABBBCCCx"; | 237 | addTest = "AAAAAABBBCCCx"; |
238 | #else | 238 | #else |
239 | addTest = "AAAAAx"; | 239 | addTest = "AAAAAx"; |
240 | #endif | 240 | #endif |
241 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); | 241 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); |
242 | addToolBar (filterToolBar , tbd ); | 242 | addToolBar (filterToolBar , tbd ); |
243 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 243 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
244 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 244 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
245 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 245 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
246 | filterToolBar->hide(); | 246 | filterToolBar->hide(); |
247 | } else { | 247 | } else { |
248 | filterToolBar = 0; | 248 | filterToolBar = 0; |
249 | filterMenubar = 0; | 249 | filterMenubar = 0; |
250 | filterPopupMenu = 0; | 250 | filterPopupMenu = 0; |
251 | } | 251 | } |
252 | if ( p->mShowIconOnetoolbar ) { | 252 | if ( p->mShowIconOnetoolbar ) { |
253 | viewToolBar = iconToolBar ; | 253 | viewToolBar = iconToolBar ; |
254 | navigatorToolBar = iconToolBar ; | 254 | navigatorToolBar = iconToolBar ; |
255 | } else { | 255 | } else { |
256 | #ifndef DESKTOP_VERSION | 256 | #ifndef DESKTOP_VERSION |
257 | setToolBarsMovable( false ); | 257 | setToolBarsMovable( false ); |
258 | #endif | 258 | #endif |
259 | if ( p->mToolBarHorV ) { | 259 | if ( p->mToolBarHorV ) { |
260 | if ( p->mToolBarUpV ) | 260 | if ( p->mToolBarUpV ) |
261 | tbd = Bottom; | 261 | tbd = Bottom; |
262 | else | 262 | else |
263 | tbd = Top; | 263 | tbd = Top; |
264 | } | 264 | } |
265 | else { | 265 | else { |
266 | if ( p->mToolBarUpV ) | 266 | if ( p->mToolBarUpV ) |
267 | tbd = Right; | 267 | tbd = Right; |
268 | else | 268 | else |
269 | tbd = Left; | 269 | tbd = Left; |
270 | } | 270 | } |
271 | viewToolBar = new QPEToolBar( this ); | 271 | viewToolBar = new QPEToolBar( this ); |
272 | addToolBar (viewToolBar , tbd ); | 272 | addToolBar (viewToolBar , tbd ); |
273 | if ( p->mToolBarHorN ) { | 273 | if ( p->mToolBarHorN ) { |
274 | if ( p->mToolBarUpN ) | 274 | if ( p->mToolBarUpN ) |
275 | tbd = Bottom; | 275 | tbd = Bottom; |
276 | else | 276 | else |
277 | tbd = Top; | 277 | tbd = Top; |
278 | } | 278 | } |
279 | else { | 279 | else { |
280 | if ( p->mToolBarUpN ) | 280 | if ( p->mToolBarUpN ) |
281 | tbd = Right; | 281 | tbd = Right; |
282 | else | 282 | else |
283 | tbd = Left; | 283 | tbd = Left; |
284 | } | 284 | } |
285 | navigatorToolBar = new QPEToolBar( this ); | 285 | navigatorToolBar = new QPEToolBar( this ); |
286 | addToolBar (navigatorToolBar , tbd ); | 286 | addToolBar (navigatorToolBar , tbd ); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | 290 | ||
291 | mCalendarModifiedFlag = false; | 291 | mCalendarModifiedFlag = false; |
292 | // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 292 | // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
293 | //splash->setAlignment ( AlignCenter ); | 293 | //splash->setAlignment ( AlignCenter ); |
294 | //setCentralWidget( splash ); | 294 | //setCentralWidget( splash ); |
295 | #ifndef DESKTOP_VERSION | 295 | #ifndef DESKTOP_VERSION |
296 | //showMaximized(); | 296 | //showMaximized(); |
297 | #endif | 297 | #endif |
298 | 298 | ||
299 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 299 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
300 | setDefaultPreferences(); | 300 | setDefaultPreferences(); |
301 | mCalendar = new CalendarLocal(); | 301 | mCalendar = new CalendarLocal(); |
302 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 302 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
303 | setCentralWidget( mView ); | 303 | setCentralWidget( mView ); |
304 | //mView->hide(); | 304 | //mView->hide(); |
305 | //mView->resize(splash->size() ); | 305 | //mView->resize(splash->size() ); |
306 | initActions(); | 306 | initActions(); |
307 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 307 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
308 | mSyncManager->setBlockSave(false); | 308 | mSyncManager->setBlockSave(false); |
309 | mView->setSyncManager(mSyncManager); | 309 | mView->setSyncManager(mSyncManager); |
310 | #ifndef DESKTOP_VERSION | 310 | #ifndef DESKTOP_VERSION |
311 | iconToolBar->show(); | 311 | //iconToolBar->show(); |
312 | qApp->processEvents(); | 312 | //qApp->processEvents(); |
313 | #endif | 313 | #endif |
314 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 314 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
315 | int vh = height() ; | 315 | int vh = height() ; |
316 | int vw = width(); | 316 | int vw = width(); |
317 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 317 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
318 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 318 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
319 | vh -= iconToolBar->height(); | 319 | vh -= iconToolBar->height(); |
320 | } else { | 320 | } else { |
321 | vw -= iconToolBar->height(); | 321 | vw -= iconToolBar->height(); |
322 | } | 322 | } |
323 | //mView->setMaximumSize( splash->size() ); | 323 | //mView->setMaximumSize( splash->size() ); |
324 | //mView->resize( splash->size() ); | 324 | //mView->resize( splash->size() ); |
325 | //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 ()); |
326 | mView->readSettings(); | 326 | mView->readSettings(); |
327 | bool newFile = false; | 327 | bool newFile = false; |
328 | if( !QFile::exists( defaultFileName() ) ) { | 328 | if( !QFile::exists( defaultFileName() ) ) { |
329 | QFileInfo finfo ( defaultFileName() ); | 329 | QFileInfo finfo ( defaultFileName() ); |
330 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 330 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
331 | 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"; | 331 | 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"; |
332 | finfo.setFile( oldFile ); | 332 | finfo.setFile( oldFile ); |
333 | if (finfo.exists() ) { | 333 | if (finfo.exists() ) { |
334 | KMessageBox::information( this, message); | 334 | KMessageBox::information( this, message); |
335 | mView->openCalendar( oldFile ); | 335 | mView->openCalendar( oldFile ); |
336 | qApp->processEvents(); | 336 | qApp->processEvents(); |
337 | } else { | 337 | } else { |
338 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 338 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
339 | finfo.setFile( oldFile ); | 339 | finfo.setFile( oldFile ); |
340 | if (finfo.exists() ) { | 340 | if (finfo.exists() ) { |
341 | KMessageBox::information( this, message); | 341 | KMessageBox::information( this, message); |
342 | mView->openCalendar( oldFile ); | 342 | mView->openCalendar( oldFile ); |
343 | qApp->processEvents(); | 343 | qApp->processEvents(); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | mView->saveCalendar( defaultFileName() ); | 346 | mView->saveCalendar( defaultFileName() ); |
347 | newFile = true; | 347 | newFile = true; |
348 | } | 348 | } |
349 | 349 | ||
350 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); | 350 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); |
351 | //mView->loadCalendars(); | 351 | //mView->loadCalendars(); |
352 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 352 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
353 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 353 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
354 | 354 | ||
355 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 355 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
356 | KOPrefs::instance()->setAllDefaults(); | 356 | KOPrefs::instance()->setAllDefaults(); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 360 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
361 | SLOT( disableBR(bool) ) ); | 361 | SLOT( disableBR(bool) ) ); |
362 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 362 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
363 | setCentralWidget( mView ); | 363 | setCentralWidget( mView ); |
364 | globalFlagBlockStartup = 0; | 364 | globalFlagBlockStartup = 0; |
365 | //mView->show(); | 365 | //mView->show(); |
366 | //delete splash; | 366 | //delete splash; |
367 | if ( newFile ) | 367 | if ( newFile ) |
368 | mView->updateConfig(); | 368 | mView->updateConfig(); |
369 | // qApp->processEvents(); | 369 | // qApp->processEvents(); |
370 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 370 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
371 | //fillSyncMenu(); | 371 | //fillSyncMenu(); |
372 | 372 | ||
373 | 373 | ||
374 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 374 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
375 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 375 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
376 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 376 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
377 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 377 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
378 | mSyncManager->setDefaultFileName( sentSyncFile()); | 378 | mSyncManager->setDefaultFileName( sentSyncFile()); |
379 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 379 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
380 | mSyncManager->fillSyncMenu(); | 380 | mSyncManager->fillSyncMenu(); |
381 | 381 | ||
382 | 382 | ||
383 | 383 | ||
384 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 384 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
385 | if ( showWarning ) { | 385 | if ( showWarning ) { |
386 | KMessageBox::information( this, | 386 | KMessageBox::information( this, |
387 | "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"); | 387 | "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"); |
388 | qApp->processEvents(); | 388 | //qApp->processEvents(); |
389 | mView->dialogManager()->showSyncOptions(); | 389 | mView->dialogManager()->showSyncOptions(); |
390 | } | 390 | } |
391 | 391 | ||
392 | //US listen for result adressed from Ka/Pi | 392 | //US listen for result adressed from Ka/Pi |
393 | 393 | ||
394 | #ifndef DESKTOP_VERSION | 394 | #ifndef DESKTOP_VERSION |
395 | infrared = 0; | 395 | infrared = 0; |
396 | #endif | 396 | #endif |
397 | updateFilterToolbar(); | 397 | updateFilterToolbar(); |
398 | updateWeek( mView->startDate() ); | 398 | updateWeek( mView->startDate() ); |
399 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 399 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
400 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 400 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
401 | mBRdisabled = false; | 401 | mBRdisabled = false; |
402 | //toggleBeamReceive(); | 402 | //toggleBeamReceive(); |
403 | 403 | ||
404 | setCaption(i18n("Loading calendar files ... please wait" )); | 404 | setCaption(i18n("Loading calendar files ... please wait" )); |
405 | mSaveDelay = 0; | 405 | mSaveDelay = 0; |
406 | QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() )); | 406 | QTimer::singleShot( 1, this, SLOT ( loadDataAfterStart() )); |
407 | } | 407 | } |
408 | MainWindow::~MainWindow() | 408 | MainWindow::~MainWindow() |
409 | { | 409 | { |
410 | //qDebug("MainWindow::~MainWindow() "); | 410 | //qDebug("MainWindow::~MainWindow() "); |
411 | //save toolbar location | 411 | //save toolbar location |
412 | delete mCalendar; | 412 | delete mCalendar; |
413 | delete mSyncManager; | 413 | delete mSyncManager; |
414 | #ifndef DESKTOP_VERSION | 414 | #ifndef DESKTOP_VERSION |
415 | if ( infrared ) | 415 | if ( infrared ) |
416 | delete infrared; | 416 | delete infrared; |
417 | #endif | 417 | #endif |
418 | 418 | ||
419 | 419 | ||
420 | } | 420 | } |
421 | 421 | ||
422 | void MainWindow::loadDataAfterStart() | 422 | void MainWindow::loadDataAfterStart() |
423 | { | 423 | { |
424 | 424 | ||
425 | qDebug("KO: Start loading files..." ); | 425 | qDebug("KO: Start loading files..." ); |
426 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 426 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
427 | mView->loadCalendars(); | 427 | mView->loadCalendars(); |
428 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 428 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
429 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 429 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
430 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 430 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); |
431 | mView->setModified( false ); | 431 | mView->setModified( false ); |
432 | mBlockAtStartup = false; | 432 | mBlockAtStartup = false; |
433 | mView->setModified( false ); | 433 | mView->setModified( false ); |
434 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 434 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
435 | processIncidenceSelection( 0 ); | 435 | processIncidenceSelection( 0 ); |
436 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 436 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
437 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 437 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
438 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 438 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
439 | SLOT( slotModifiedChanged( bool ) ) ); | 439 | SLOT( slotModifiedChanged( bool ) ) ); |
440 | 440 | ||
441 | #ifndef DESKTOP_VERSION | 441 | #ifndef DESKTOP_VERSION |
442 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 442 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
443 | connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); | 443 | connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); |
444 | disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); | 444 | disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); |
445 | ((QPEApplication*) qApp)->showMainWidget( this ); | ||
445 | if ( !mCStringMess.isEmpty() ) | 446 | if ( !mCStringMess.isEmpty() ) |
446 | recieve( mCStringMess, mByteData ); | 447 | recieve( mCStringMess, mByteData ); |
447 | #endif | 448 | #endif |
448 | |||
449 | |||
450 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 449 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); |
451 | } | 450 | } |
452 | 451 | ||
453 | void MainWindow::slotResetFocus() | 452 | void MainWindow::slotResetFocus() |
454 | { | 453 | { |
455 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); | 454 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); |
456 | mFocusLoop = 3; | 455 | mFocusLoop = 3; |
457 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 456 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
458 | } | 457 | } |
459 | void MainWindow::slotResetFocusLoop() | 458 | void MainWindow::slotResetFocusLoop() |
460 | { | 459 | { |
461 | --mFocusLoop; | 460 | --mFocusLoop; |
462 | QWidget* fw = mView->viewManager()->currentView(); | 461 | QWidget* fw = mView->viewManager()->currentView(); |
463 | if ( fw ) { | 462 | if ( fw ) { |
464 | //qDebug("loop "); | 463 | //qDebug("loop "); |
465 | fw->setFocus(); | 464 | fw->setFocus(); |
466 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) | 465 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) |
467 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 466 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
468 | } | 467 | } |
469 | 468 | ||
470 | } | 469 | } |
471 | void MainWindow::disableBR(bool b) | 470 | void MainWindow::disableBR(bool b) |
472 | { | 471 | { |
473 | #ifndef DESKTOP_VERSION | 472 | #ifndef DESKTOP_VERSION |
474 | if ( b ) { | 473 | if ( b ) { |
475 | if ( infrared ) { | 474 | if ( infrared ) { |
476 | toggleBeamReceive(); | 475 | toggleBeamReceive(); |
477 | mBRdisabled = true; | 476 | mBRdisabled = true; |
478 | } | 477 | } |
479 | mBRdisabled = true; | 478 | mBRdisabled = true; |
480 | } else { | 479 | } else { |
481 | if ( mBRdisabled ) { | 480 | if ( mBRdisabled ) { |
482 | mBRdisabled = false; | 481 | mBRdisabled = false; |
483 | //makes no sense,because other cal ap is probably running | 482 | //makes no sense,because other cal ap is probably running |
484 | // toggleBeamReceive(); | 483 | // toggleBeamReceive(); |
485 | } | 484 | } |
486 | } | 485 | } |
487 | #endif | 486 | #endif |
488 | 487 | ||
489 | } | 488 | } |
490 | bool MainWindow::beamReceiveEnabled() | 489 | bool MainWindow::beamReceiveEnabled() |
491 | { | 490 | { |
492 | #ifndef DESKTOP_VERSION | 491 | #ifndef DESKTOP_VERSION |
493 | return ( infrared != 0 ); | 492 | return ( infrared != 0 ); |
494 | #endif | 493 | #endif |
495 | return false; | 494 | return false; |
496 | } | 495 | } |
497 | 496 | ||
498 | void MainWindow::toggleBeamReceive() | 497 | void MainWindow::toggleBeamReceive() |
499 | { | 498 | { |
500 | if ( mBRdisabled ) | 499 | if ( mBRdisabled ) |
501 | return; | 500 | return; |
502 | #ifndef DESKTOP_VERSION | 501 | #ifndef DESKTOP_VERSION |
503 | if ( infrared ) { | 502 | if ( infrared ) { |
504 | qDebug("KO: Disable BeamReceive "); | 503 | qDebug("KO: Disable BeamReceive "); |
505 | delete infrared; | 504 | delete infrared; |
506 | infrared = 0; | 505 | infrared = 0; |
507 | brAction->setOn(false); | 506 | brAction->setOn(false); |
508 | return; | 507 | return; |
509 | } | 508 | } |
510 | qDebug("KO: Enable BeamReceive "); | 509 | qDebug("KO: Enable BeamReceive "); |
511 | brAction->setOn(true); | 510 | brAction->setOn(true); |
512 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 511 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
513 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 512 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
514 | #endif | 513 | #endif |
515 | } | 514 | } |
516 | void MainWindow::showMaximized () | 515 | void MainWindow::showMaximized () |
517 | { | 516 | { |
518 | #ifndef DESKTOP_VERSION | 517 | #ifndef DESKTOP_VERSION |
519 | if ( ! globalFlagBlockStartup ) | 518 | if ( ! globalFlagBlockStartup ) |
520 | if ( mClosed ) | 519 | if ( mClosed ) |
521 | mView->goToday(); | 520 | mView->goToday(); |
522 | #endif | 521 | #endif |
523 | QWidget::showMaximized () ; | 522 | QWidget::showMaximized () ; |
524 | mClosed = false; | 523 | mClosed = false; |
525 | } | 524 | } |
526 | 525 | ||
527 | bool MainWindow::askForQuitOnSaveError() | 526 | bool MainWindow::askForQuitOnSaveError() |
528 | { | 527 | { |
529 | bool retval = false; | 528 | bool retval = false; |
530 | switch( QMessageBox::information( this, "KO/Pi", | 529 | switch( QMessageBox::information( this, "KO/Pi", |
531 | i18n("Error saving data") + "!\n" + | 530 | i18n("Error saving data") + "!\n" + |
532 | i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" + | 531 | i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" + |
533 | i18n("Do you really want\nto close KO/Pi?"), | 532 | i18n("Do you really want\nto close KO/Pi?"), |
534 | i18n(" Yes, close "), i18n("No"), | 533 | i18n(" Yes, close "), i18n("No"), |
535 | 0, 1 ) ) { | 534 | 0, 1 ) ) { |
536 | case 0: | 535 | case 0: |
537 | retval = true; | 536 | retval = true; |
538 | break; | 537 | break; |
539 | default: | 538 | default: |
540 | break; | 539 | break; |
541 | } | 540 | } |
542 | return retval; | 541 | return retval; |
543 | } | 542 | } |
544 | 543 | ||
545 | void MainWindow::closeEvent( QCloseEvent* ce ) | 544 | void MainWindow::closeEvent( QCloseEvent* ce ) |
546 | { | 545 | { |
547 | 546 | ||
548 | 547 | ||
549 | 548 | ||
550 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 549 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
551 | saveOnClose(); | 550 | saveOnClose(); |
552 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { | 551 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { |
553 | ce->ignore(); | 552 | ce->ignore(); |
554 | return; | 553 | return; |
555 | } | 554 | } |
556 | mClosed = true; | 555 | mClosed = true; |
557 | ce->accept(); | 556 | ce->accept(); |
558 | return; | 557 | return; |
559 | 558 | ||
560 | } | 559 | } |
561 | 560 | ||
562 | switch( QMessageBox::information( this, "KO/Pi", | 561 | switch( QMessageBox::information( this, "KO/Pi", |
563 | i18n("Do you really want\nto close KO/Pi?"), | 562 | i18n("Do you really want\nto close KO/Pi?"), |
564 | i18n("Close"), i18n("No"), | 563 | i18n("Close"), i18n("No"), |
565 | 0, 0 ) ) { | 564 | 0, 0 ) ) { |
566 | case 0: | 565 | case 0: |
567 | saveOnClose(); | 566 | saveOnClose(); |
568 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { | 567 | if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { |
569 | ce->ignore(); | 568 | ce->ignore(); |
570 | return; | 569 | return; |
571 | } | 570 | } |
572 | mClosed = true; | 571 | mClosed = true; |
573 | ce->accept(); | 572 | ce->accept(); |
574 | break; | 573 | break; |
575 | case 1: | 574 | case 1: |
576 | ce->ignore(); | 575 | ce->ignore(); |
577 | break; | 576 | break; |
578 | case 2: | 577 | case 2: |
579 | 578 | ||
580 | default: | 579 | default: |
581 | break; | 580 | break; |
582 | } | 581 | } |
583 | 582 | ||
584 | 583 | ||
585 | } | 584 | } |
586 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) | 585 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) |
587 | { | 586 | { |
588 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | 587 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); |
589 | mCStringMess = cmsg; | 588 | mCStringMess = cmsg; |
590 | mByteData = data; | 589 | mByteData = data; |
591 | } | 590 | } |
592 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 591 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
593 | { | 592 | { |
594 | QDataStream stream( data, IO_ReadOnly ); | 593 | QDataStream stream( data, IO_ReadOnly ); |
595 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 594 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
596 | //QString datamess; | 595 | //QString datamess; |
597 | //qDebug("message "); | 596 | //qDebug("message "); |
598 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 597 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
599 | 598 | ||
600 | if ( cmsg == "setDocument(QString)" ) { | 599 | if ( cmsg == "setDocument(QString)" ) { |
601 | QDataStream stream( data, IO_ReadOnly ); | 600 | QDataStream stream( data, IO_ReadOnly ); |
602 | QString fileName; | 601 | QString fileName; |
603 | stream >> fileName; | 602 | stream >> fileName; |
604 | //qDebug("filename %s ", fileName.latin1()); | 603 | //qDebug("filename %s ", fileName.latin1()); |
605 | showMaximized(); | 604 | showMaximized(); |
606 | raise(); | 605 | raise(); |
607 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 606 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
608 | mSyncManager->slotSyncMenu( 1002 ); | 607 | mSyncManager->slotSyncMenu( 1002 ); |
609 | return; | 608 | return; |
610 | } | 609 | } |
611 | 610 | ||
612 | if ( cmsg == "-writeFile" ) { | 611 | if ( cmsg == "-writeFile" ) { |
613 | // I made from the "-writeFile" an "-writeAlarm" | 612 | // I made from the "-writeFile" an "-writeAlarm" |
614 | mView->viewManager()->showWhatsNextView(); | 613 | mView->viewManager()->showWhatsNextView(); |
615 | mCalendar->checkAlarmForIncidence( 0, true); | 614 | mCalendar->checkAlarmForIncidence( 0, true); |
616 | showMaximized(); | 615 | showMaximized(); |
617 | raise(); | 616 | raise(); |
618 | return; | 617 | return; |
619 | 618 | ||
620 | } | 619 | } |
621 | if ( cmsg == "-writeFileSilent" ) { | 620 | if ( cmsg == "-writeFileSilent" ) { |
622 | // I made from the "-writeFile" an "-writeAlarm" | 621 | // I made from the "-writeFile" an "-writeAlarm" |
623 | // mView->viewManager()->showWhatsNextView(); | 622 | // mView->viewManager()->showWhatsNextView(); |
624 | mCalendar->checkAlarmForIncidence( 0, true); | 623 | mCalendar->checkAlarmForIncidence( 0, true); |
625 | //showMaximized(); | 624 | //showMaximized(); |
626 | //raise(); | 625 | //raise(); |
627 | hide(); | 626 | hide(); |
628 | return; | 627 | return; |
629 | } | 628 | } |
630 | if ( cmsg == "-newCountdown" ) { | 629 | if ( cmsg == "-newCountdown" ) { |
631 | qDebug("newCountdown "); | 630 | qDebug("newCountdown "); |
632 | 631 | ||
633 | } | 632 | } |
634 | QString msg ; | 633 | QString msg ; |
635 | QString allmsg = cmsg; | 634 | QString allmsg = cmsg; |
636 | while ( allmsg.length() > 0 ) { | 635 | while ( allmsg.length() > 0 ) { |
637 | int nextC = allmsg.find( "-", 1 ); | 636 | int nextC = allmsg.find( "-", 1 ); |
638 | if ( nextC == -1 ) { | 637 | if ( nextC == -1 ) { |
639 | msg = allmsg; | 638 | msg = allmsg; |
640 | allmsg = ""; | 639 | allmsg = ""; |
641 | } else{ | 640 | } else{ |
642 | msg = allmsg.left( nextC ); | 641 | msg = allmsg.left( nextC ); |
643 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 642 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
644 | } | 643 | } |
645 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 644 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
646 | if ( msg == "-newEvent" ) { | 645 | if ( msg == "-newEvent" ) { |
647 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); | 646 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); |
648 | } | 647 | } |
649 | if ( msg == "-newTodo" ) { | 648 | if ( msg == "-newTodo" ) { |
650 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); | 649 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); |
651 | } | 650 | } |
652 | if ( msg == "-showWN" ) { | 651 | if ( msg == "-showWN" ) { |
653 | mView->viewManager()->showWhatsNextView(); | 652 | mView->viewManager()->showWhatsNextView(); |
654 | } | 653 | } |
655 | if ( msg == "-showTodo" ) { | 654 | if ( msg == "-showTodo" ) { |
656 | mView->viewManager()->showTodoView(); | 655 | mView->viewManager()->showTodoView(); |
657 | } | 656 | } |
658 | if ( msg == "-showList" ) { | 657 | if ( msg == "-showList" ) { |
659 | mView->viewManager()->showListView(); | 658 | mView->viewManager()->showListView(); |
660 | } | 659 | } |
661 | else if ( msg == "-showDay" ) { | 660 | else if ( msg == "-showDay" ) { |
662 | mView->viewManager()->showDayView(); | 661 | mView->viewManager()->showDayView(); |
663 | } | 662 | } |
664 | else if ( msg == "-showWWeek" ) { | 663 | else if ( msg == "-showWWeek" ) { |
665 | mView->viewManager()->showWorkWeekView(); | 664 | mView->viewManager()->showWorkWeekView(); |
666 | } | 665 | } |
667 | else if ( msg == "-ringSync" ) { | 666 | else if ( msg == "-ringSync" ) { |
668 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); | 667 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); |
669 | } | 668 | } |
670 | else if ( msg == "-showWeek" ) { | 669 | else if ( msg == "-showWeek" ) { |
671 | mView->viewManager()->showWeekView(); | 670 | mView->viewManager()->showWeekView(); |
672 | } | 671 | } |
673 | else if ( msg == "-showTodo" ) { | 672 | else if ( msg == "-showTodo" ) { |
674 | mView->viewManager()->showTodoView(); | 673 | mView->viewManager()->showTodoView(); |
675 | } | 674 | } |
676 | else if ( msg == "-showJournal" ) { | 675 | else if ( msg == "-showJournal" ) { |
677 | mView->dateNavigator()->selectDates( 1 ); | 676 | mView->dateNavigator()->selectDates( 1 ); |
678 | mView->dateNavigator()->selectToday(); | 677 | mView->dateNavigator()->selectToday(); |
679 | mView->viewManager()->showJournalView(); | 678 | mView->viewManager()->showJournalView(); |
680 | } | 679 | } |
681 | else if ( msg == "-showKO" ) { | 680 | else if ( msg == "-showKO" ) { |
682 | mView->viewManager()->showNextXView(); | 681 | mView->viewManager()->showNextXView(); |
683 | } | 682 | } |
684 | else if ( msg == "-showWNext" ) { | 683 | else if ( msg == "-showWNext" ) { |
685 | mView->viewManager()->showWhatsNextView(); | 684 | mView->viewManager()->showWhatsNextView(); |
686 | } | 685 | } |
687 | else if ( msg == "nextView()" ) { | 686 | else if ( msg == "nextView()" ) { |
688 | mView->viewManager()->showNextView(); | 687 | mView->viewManager()->showNextView(); |
689 | } | 688 | } |
690 | else if ( msg == "-showNextXView" ) { | 689 | else if ( msg == "-showNextXView" ) { |
691 | mView->viewManager()->showNextXView(); | 690 | mView->viewManager()->showNextXView(); |
692 | } | 691 | } |
693 | 692 | ||
694 | 693 | ||
695 | } | 694 | } |
696 | 695 | ||
697 | showMaximized(); | 696 | showMaximized(); |
698 | raise(); | 697 | raise(); |
699 | } | 698 | } |
700 | void MainWindow::startMultiSync() | 699 | void MainWindow::startMultiSync() |
701 | { | 700 | { |
702 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 701 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
703 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), | 702 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), |
704 | question, | 703 | question, |
705 | i18n("Yes"), i18n("No"), | 704 | i18n("Yes"), i18n("No"), |
706 | 0, 0 ) != 0 ) { | 705 | 0, 0 ) != 0 ) { |
707 | setCaption(i18n("Aborted! Nothing synced!")); | 706 | setCaption(i18n("Aborted! Nothing synced!")); |
708 | return; | 707 | return; |
709 | } | 708 | } |
710 | mSyncManager->multiSync( false ); | 709 | mSyncManager->multiSync( false ); |
711 | #ifndef DESKTOP_VERSION | 710 | #ifndef DESKTOP_VERSION |
712 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); | 711 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); |
713 | #endif | 712 | #endif |
714 | } | 713 | } |
715 | QPixmap MainWindow::loadPixmap( QString name ) | 714 | QPixmap MainWindow::loadPixmap( QString name ) |
716 | { | 715 | { |
717 | return SmallIcon( name ); | 716 | return SmallIcon( name ); |
718 | 717 | ||
719 | } | 718 | } |
720 | void MainWindow::setUsesBigPixmaps ( bool b ) | 719 | void MainWindow::setUsesBigPixmaps ( bool b ) |
721 | { | 720 | { |
722 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); | 721 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); |
723 | if ( b ) | 722 | if ( b ) |
724 | qDebug("KO: BigPixmaps are not supported "); | 723 | qDebug("KO: BigPixmaps are not supported "); |
725 | } | 724 | } |
726 | void MainWindow::initActions() | 725 | void MainWindow::initActions() |
727 | { | 726 | { |
728 | //KOPrefs::instance()->mShowFullMenu | 727 | //KOPrefs::instance()->mShowFullMenu |
729 | iconToolBar->clear(); | 728 | iconToolBar->clear(); |
730 | KOPrefs *p = KOPrefs::instance(); | 729 | KOPrefs *p = KOPrefs::instance(); |
731 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 730 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
732 | 731 | ||
733 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 732 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
734 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 733 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
735 | mCurrentItemMenu = new QPopupMenu ( this ); | 734 | mCurrentItemMenu = new QPopupMenu ( this ); |
736 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); | 735 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); |
737 | QPopupMenu *importMenu = new QPopupMenu( this ); | 736 | QPopupMenu *importMenu = new QPopupMenu( this ); |
738 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 737 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
739 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 738 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
740 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 739 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
741 | selectFilterMenu = new QPopupMenu( this ); | 740 | selectFilterMenu = new QPopupMenu( this ); |
742 | selectFilterMenu->setCheckable( true ); | 741 | selectFilterMenu->setCheckable( true ); |
743 | syncMenu = new QPopupMenu( this ); | 742 | syncMenu = new QPopupMenu( this ); |
744 | configureAgendaMenu = new QPopupMenu( this ); | 743 | configureAgendaMenu = new QPopupMenu( this ); |
745 | configureToolBarMenu = new QPopupMenu( this ); | 744 | configureToolBarMenu = new QPopupMenu( this ); |
746 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 745 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
747 | QIconSet icon; | 746 | QIconSet icon; |
748 | int pixWid = 22, pixHei = 22; | 747 | int pixWid = 22, pixHei = 22; |
749 | QString pathString = ""; | 748 | QString pathString = ""; |
750 | if ( !p->mToolBarMiniIcons ) { | 749 | if ( !p->mToolBarMiniIcons ) { |
751 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { | 750 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { |
752 | pathString += "icons16/"; | 751 | pathString += "icons16/"; |
753 | pixWid = 18; pixHei = 16; | 752 | pixWid = 18; pixHei = 16; |
754 | } | 753 | } |
755 | } else { | 754 | } else { |
756 | pathString += "iconsmini/"; | 755 | pathString += "iconsmini/"; |
757 | pixWid = 18; pixHei = 16; | 756 | pixWid = 18; pixHei = 16; |
758 | } | 757 | } |
759 | 758 | ||
760 | if ( KOPrefs::instance()->mShowFullMenu ) { | 759 | if ( KOPrefs::instance()->mShowFullMenu ) { |
761 | menuBar1 = new KMenuBar( this );//menuBar(); | 760 | menuBar1 = new KMenuBar( this );//menuBar(); |
762 | //setMenuBar( menuBar1 ); | 761 | //setMenuBar( menuBar1 ); |
763 | menuBar1->show(); | 762 | menuBar1->show(); |
764 | menuBar1->insertItem( i18n("File"), importMenu ); | 763 | menuBar1->insertItem( i18n("File"), importMenu ); |
765 | menuBar1->insertItem( i18n("View"), viewMenu ); | 764 | menuBar1->insertItem( i18n("View"), viewMenu ); |
766 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); | 765 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); |
767 | menuBar1->insertItem( i18n("Action"), actionMenu ); | 766 | menuBar1->insertItem( i18n("Action"), actionMenu ); |
768 | #ifdef DESKTOP_VERSION | 767 | #ifdef DESKTOP_VERSION |
769 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 768 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
770 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 769 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
771 | #else | 770 | #else |
772 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 771 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
773 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 772 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
774 | #endif | 773 | #endif |
775 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 774 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
776 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 775 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
777 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 776 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
778 | } else { | 777 | } else { |
779 | menuBar1 = new KMenuBar( iconToolBar ); | 778 | menuBar1 = new KMenuBar( iconToolBar ); |
780 | QPopupMenu *menuBar = new QPopupMenu( this ); | 779 | QPopupMenu *menuBar = new QPopupMenu( this ); |
781 | icon = loadPixmap( pathString + "z_menu" ); | 780 | icon = loadPixmap( pathString + "z_menu" ); |
782 | menuBar1->insertItem( icon.pixmap(), menuBar); | 781 | menuBar1->insertItem( icon.pixmap(), menuBar); |
783 | //menuBar1->insertItem( i18n("ME"), menuBar); | 782 | //menuBar1->insertItem( i18n("ME"), menuBar); |
784 | menuBar->insertItem( i18n("File"), importMenu ); | 783 | menuBar->insertItem( i18n("File"), importMenu ); |
785 | menuBar->insertItem( i18n("View"), viewMenu ); | 784 | menuBar->insertItem( i18n("View"), viewMenu ); |
786 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); | 785 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); |
787 | menuBar->insertItem( i18n("Action"), actionMenu ); | 786 | menuBar->insertItem( i18n("Action"), actionMenu ); |
788 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 787 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
789 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 788 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
790 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 789 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
791 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 790 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
792 | menuBar->insertItem( i18n("Help"), helpMenu ); | 791 | menuBar->insertItem( i18n("Help"), helpMenu ); |
793 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 792 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
794 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 793 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
795 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); | 794 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); |
796 | } | 795 | } |
797 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 796 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
798 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 797 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
799 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 798 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
800 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 799 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
801 | 800 | ||
802 | 801 | ||
803 | mWeekBgColor = iconToolBar->backgroundColor(); | 802 | mWeekBgColor = iconToolBar->backgroundColor(); |
804 | mWeekPixmap.resize( pixWid , pixHei ); | 803 | mWeekPixmap.resize( pixWid , pixHei ); |
805 | mWeekPixmap.fill( mWeekBgColor ); | 804 | mWeekPixmap.fill( mWeekBgColor ); |
806 | icon = mWeekPixmap; | 805 | icon = mWeekPixmap; |
807 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 806 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
808 | if ( p-> mShowIconWeekNum ) | 807 | if ( p-> mShowIconWeekNum ) |
809 | mWeekAction->addTo( iconToolBar ); | 808 | mWeekAction->addTo( iconToolBar ); |
810 | mWeekFont = font(); | 809 | mWeekFont = font(); |
811 | 810 | ||
812 | int fontPoint = mWeekFont.pointSize(); | 811 | int fontPoint = mWeekFont.pointSize(); |
813 | QFontMetrics f( mWeekFont ); | 812 | QFontMetrics f( mWeekFont ); |
814 | int fontWid = f.width( "30" ); | 813 | int fontWid = f.width( "30" ); |
815 | while ( fontWid > pixWid ) { | 814 | while ( fontWid > pixWid ) { |
816 | --fontPoint; | 815 | --fontPoint; |
817 | mWeekFont.setPointSize( fontPoint ); | 816 | mWeekFont.setPointSize( fontPoint ); |
818 | QFontMetrics f( mWeekFont ); | 817 | QFontMetrics f( mWeekFont ); |
819 | fontWid = f.width( "30" ); | 818 | fontWid = f.width( "30" ); |
820 | //qDebug("dec-- "); | 819 | //qDebug("dec-- "); |
821 | } | 820 | } |
822 | 821 | ||
823 | connect( mWeekAction, SIGNAL( activated() ), | 822 | connect( mWeekAction, SIGNAL( activated() ), |
824 | this, SLOT( weekAction() ) ); | 823 | this, SLOT( weekAction() ) ); |
825 | 824 | ||
826 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 825 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
827 | if ( p->mShowIconFilterview ) { | 826 | if ( p->mShowIconFilterview ) { |
828 | icon = loadPixmap( pathString + "filter" ); | 827 | icon = loadPixmap( pathString + "filter" ); |
829 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); | 828 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); |
830 | connect( actionFilterMenuTB, SIGNAL( activated() ), | 829 | connect( actionFilterMenuTB, SIGNAL( activated() ), |
831 | this, SLOT( fillFilterMenuTB() ) ); | 830 | this, SLOT( fillFilterMenuTB() ) ); |
832 | actionFilterMenuTB->addTo( iconToolBar ); | 831 | actionFilterMenuTB->addTo( iconToolBar ); |
833 | selectFilterMenuTB = new QPopupMenu( this ); | 832 | selectFilterMenuTB = new QPopupMenu( this ); |
834 | selectFilterMenuTB->setCheckable( true ); | 833 | selectFilterMenuTB->setCheckable( true ); |
835 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 834 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
836 | } | 835 | } |
837 | 836 | ||
838 | //#endif | 837 | //#endif |
839 | // ****************** | 838 | // ****************** |
840 | QAction *action; | 839 | QAction *action; |
841 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 840 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
842 | configureToolBarMenu->setCheckable( true ); | 841 | configureToolBarMenu->setCheckable( true ); |
843 | 842 | ||
844 | 843 | ||
845 | configureAgendaMenu->setCheckable( true ); | 844 | configureAgendaMenu->setCheckable( true ); |
846 | int iii ; | 845 | int iii ; |
847 | for ( iii = 1;iii<= 10 ;++iii ){ | 846 | for ( iii = 1;iii<= 10 ;++iii ){ |
848 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 847 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
849 | } | 848 | } |
850 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 849 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
851 | 850 | ||
852 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 851 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
853 | this, SLOT( showConfigureAgenda( ) ) ); | 852 | this, SLOT( showConfigureAgenda( ) ) ); |
854 | icon = loadPixmap( pathString + "today" ); | 853 | icon = loadPixmap( pathString + "today" ); |
855 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 854 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
856 | today_action->addTo( actionMenu ); | 855 | today_action->addTo( actionMenu ); |
857 | connect( today_action, SIGNAL( activated() ), | 856 | connect( today_action, SIGNAL( activated() ), |
858 | mView, SLOT( goToday() ) ); | 857 | mView, SLOT( goToday() ) ); |
859 | 858 | ||
860 | icon = loadPixmap( pathString + "picker" ); | 859 | icon = loadPixmap( pathString + "picker" ); |
861 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); | 860 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); |
862 | dPickerAction->addTo( actionMenu ); | 861 | dPickerAction->addTo( actionMenu ); |
863 | connect( dPickerAction, SIGNAL( activated() ), | 862 | connect( dPickerAction, SIGNAL( activated() ), |
864 | mView, SLOT( showDatePicker() ) ); | 863 | mView, SLOT( showDatePicker() ) ); |
865 | 864 | ||
866 | icon = loadPixmap( pathString + "search" ); | 865 | icon = loadPixmap( pathString + "search" ); |
867 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 866 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
868 | search_action->addTo( actionMenu ); | 867 | search_action->addTo( actionMenu ); |
869 | connect( search_action, SIGNAL( activated() ), | 868 | connect( search_action, SIGNAL( activated() ), |
870 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 869 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
871 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); | 870 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); |
872 | 871 | ||
873 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); | 872 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); |
874 | action->addTo( nextConflictMenu ); | 873 | action->addTo( nextConflictMenu ); |
875 | connect( action, SIGNAL( activated() ), | 874 | connect( action, SIGNAL( activated() ), |
876 | mView, SLOT( conflictAll() ) ); | 875 | mView, SLOT( conflictAll() ) ); |
877 | 876 | ||
878 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); | 877 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); |
879 | action->addTo( nextConflictMenu ); | 878 | action->addTo( nextConflictMenu ); |
880 | connect( action, SIGNAL( activated() ), | 879 | connect( action, SIGNAL( activated() ), |
881 | mView, SLOT( conflictAllday() ) ); | 880 | mView, SLOT( conflictAllday() ) ); |
882 | 881 | ||
883 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); | 882 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); |
884 | action->addTo( nextConflictMenu ); | 883 | action->addTo( nextConflictMenu ); |
885 | connect( action, SIGNAL( activated() ), | 884 | connect( action, SIGNAL( activated() ), |
886 | mView, SLOT( conflictNotAll() ) ); | 885 | mView, SLOT( conflictNotAll() ) ); |
887 | 886 | ||
888 | actionMenu->insertSeparator(); | 887 | actionMenu->insertSeparator(); |
889 | 888 | ||
890 | icon = loadPixmap( pathString + "newevent" ); | 889 | icon = loadPixmap( pathString + "newevent" ); |
891 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 890 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
892 | ne_action->addTo( mCurrentItemMenu ); | 891 | ne_action->addTo( mCurrentItemMenu ); |
893 | connect( ne_action, SIGNAL( activated() ), | 892 | connect( ne_action, SIGNAL( activated() ), |
894 | mView, SLOT( newEvent() ) ); | 893 | mView, SLOT( newEvent() ) ); |
895 | icon = loadPixmap( pathString + "newtodo" ); | 894 | icon = loadPixmap( pathString + "newtodo" ); |
896 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 895 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
897 | nt_action->addTo( mCurrentItemMenu ); | 896 | nt_action->addTo( mCurrentItemMenu ); |
898 | connect( nt_action, SIGNAL( activated() ), | 897 | connect( nt_action, SIGNAL( activated() ), |
899 | mView, SLOT( newTodo() ) ); | 898 | mView, SLOT( newTodo() ) ); |
900 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 899 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
901 | this ); | 900 | this ); |
902 | mNewSubTodoAction->addTo( mCurrentItemMenu ); | 901 | mNewSubTodoAction->addTo( mCurrentItemMenu ); |
903 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 902 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
904 | mView, SLOT( newSubTodo() ) ); | 903 | mView, SLOT( newSubTodo() ) ); |
905 | 904 | ||
906 | mCurrentItemMenu->insertSeparator(); | 905 | mCurrentItemMenu->insertSeparator(); |
907 | icon = loadPixmap( pathString + "newevent" ); | 906 | icon = loadPixmap( pathString + "newevent" ); |
908 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 907 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
909 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 908 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
910 | configureToolBarMenu->insertSeparator(); | 909 | configureToolBarMenu->insertSeparator(); |
911 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 910 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
912 | configureToolBarMenu->insertSeparator(); | 911 | configureToolBarMenu->insertSeparator(); |
913 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 912 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
914 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 913 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
915 | icon = loadPixmap( pathString + "newtodo" ); | 914 | icon = loadPixmap( pathString + "newtodo" ); |
916 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 915 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
917 | 916 | ||
918 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); | 917 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); |
919 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); | 918 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); |
920 | mShowAction->addTo( mCurrentItemMenu ); | 919 | mShowAction->addTo( mCurrentItemMenu ); |
921 | connect( mShowAction, SIGNAL( activated() ), | 920 | connect( mShowAction, SIGNAL( activated() ), |
922 | mView, SLOT( showIncidence() ) ); | 921 | mView, SLOT( showIncidence() ) ); |
923 | 922 | ||
924 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 923 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
925 | mEditAction->addTo( mCurrentItemMenu ); | 924 | mEditAction->addTo( mCurrentItemMenu ); |
926 | connect( mEditAction, SIGNAL( activated() ), | 925 | connect( mEditAction, SIGNAL( activated() ), |
927 | mView, SLOT( editIncidence() ) ); | 926 | mView, SLOT( editIncidence() ) ); |
928 | 927 | ||
929 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 928 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
930 | mDeleteAction->addTo( mCurrentItemMenu ); | 929 | mDeleteAction->addTo( mCurrentItemMenu ); |
931 | connect( mDeleteAction, SIGNAL( activated() ), | 930 | connect( mDeleteAction, SIGNAL( activated() ), |
932 | mView, SLOT( deleteIncidence() ) ); | 931 | mView, SLOT( deleteIncidence() ) ); |
933 | 932 | ||
934 | 933 | ||
935 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 934 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
936 | mCloneAction->addTo( mCurrentItemMenu ); | 935 | mCloneAction->addTo( mCurrentItemMenu ); |
937 | connect( mCloneAction, SIGNAL( activated() ), | 936 | connect( mCloneAction, SIGNAL( activated() ), |
938 | mView, SLOT( cloneIncidence() ) ); | 937 | mView, SLOT( cloneIncidence() ) ); |
939 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 938 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
940 | mMoveAction->addTo( mCurrentItemMenu ); | 939 | mMoveAction->addTo( mCurrentItemMenu ); |
941 | connect( mMoveAction, SIGNAL( activated() ), | 940 | connect( mMoveAction, SIGNAL( activated() ), |
942 | mView, SLOT( moveIncidence() ) ); | 941 | mView, SLOT( moveIncidence() ) ); |
943 | #ifndef DESKTOP_VERSION | 942 | #ifndef DESKTOP_VERSION |
944 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 943 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
945 | mBeamAction->addTo(mCurrentItemMenu ); | 944 | mBeamAction->addTo(mCurrentItemMenu ); |
946 | connect( mBeamAction, SIGNAL( activated() ), | 945 | connect( mBeamAction, SIGNAL( activated() ), |
947 | mView, SLOT( beamIncidence() ) ); | 946 | mView, SLOT( beamIncidence() ) ); |
948 | #endif | 947 | #endif |
949 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 948 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
950 | mCancelAction->addTo( mCurrentItemMenu ); | 949 | mCancelAction->addTo( mCurrentItemMenu ); |
951 | connect( mCancelAction, SIGNAL( activated() ), | 950 | connect( mCancelAction, SIGNAL( activated() ), |
952 | mView, SLOT( toggleCancelIncidence() ) ); | 951 | mView, SLOT( toggleCancelIncidence() ) ); |
953 | 952 | ||
954 | 953 | ||
955 | mCurrentItemMenu->insertSeparator(); | 954 | mCurrentItemMenu->insertSeparator(); |
956 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 955 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
957 | action->addTo( mCurrentItemMenu ); | 956 | action->addTo( mCurrentItemMenu ); |
958 | connect( action, SIGNAL( activated() ), | 957 | connect( action, SIGNAL( activated() ), |
959 | mView, SLOT( undo_delete() ) ); | 958 | mView, SLOT( undo_delete() ) ); |
960 | 959 | ||
961 | // *********************** | 960 | // *********************** |
@@ -1535,1026 +1534,1026 @@ void MainWindow::exportToPhone( int mode ) | |||
1535 | else { | 1534 | else { |
1536 | bool ok; | 1535 | bool ok; |
1537 | dt = incidence->getNextOccurence( cur, &ok ); | 1536 | dt = incidence->getNextOccurence( cur, &ok ); |
1538 | if ( !ok ) | 1537 | if ( !ok ) |
1539 | dt = cur.addSecs( -62 ); | 1538 | dt = cur.addSecs( -62 ); |
1540 | } | 1539 | } |
1541 | if ( dt < cur || dt > end ) { | 1540 | if ( dt < cur || dt > end ) { |
1542 | add = false; | 1541 | add = false; |
1543 | } | 1542 | } |
1544 | } | 1543 | } |
1545 | if ( add ) { | 1544 | if ( add ) { |
1546 | Incidence *in = incidence->clone(); | 1545 | Incidence *in = incidence->clone(); |
1547 | cal->addIncidence( in ); | 1546 | cal->addIncidence( in ); |
1548 | } | 1547 | } |
1549 | } | 1548 | } |
1550 | incidence = delSel.next(); | 1549 | incidence = delSel.next(); |
1551 | } | 1550 | } |
1552 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1551 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1553 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1552 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1554 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1553 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1555 | 1554 | ||
1556 | setCaption( i18n("Writing to phone...")); | 1555 | setCaption( i18n("Writing to phone...")); |
1557 | if ( PhoneFormat::writeToPhone( cal ) ) | 1556 | if ( PhoneFormat::writeToPhone( cal ) ) |
1558 | setCaption( i18n("Export to phone successful!")); | 1557 | setCaption( i18n("Export to phone successful!")); |
1559 | else | 1558 | else |
1560 | setCaption( i18n("Error exporting to phone!")); | 1559 | setCaption( i18n("Error exporting to phone!")); |
1561 | delete cal; | 1560 | delete cal; |
1562 | } | 1561 | } |
1563 | 1562 | ||
1564 | 1563 | ||
1565 | void MainWindow::setDefaultPreferences() | 1564 | void MainWindow::setDefaultPreferences() |
1566 | { | 1565 | { |
1567 | KOPrefs *p = KOPrefs::instance(); | 1566 | KOPrefs *p = KOPrefs::instance(); |
1568 | 1567 | ||
1569 | p->mCompactDialogs = true; | 1568 | p->mCompactDialogs = true; |
1570 | p->mConfirm = true; | 1569 | p->mConfirm = true; |
1571 | // p->mEnableQuickTodo = false; | 1570 | // p->mEnableQuickTodo = false; |
1572 | 1571 | ||
1573 | } | 1572 | } |
1574 | 1573 | ||
1575 | QString MainWindow::resourcePath() | 1574 | QString MainWindow::resourcePath() |
1576 | { | 1575 | { |
1577 | return KGlobal::iconLoader()->iconPath(); | 1576 | return KGlobal::iconLoader()->iconPath(); |
1578 | } | 1577 | } |
1579 | 1578 | ||
1580 | void MainWindow::displayText( QString text ,QString cap ) | 1579 | void MainWindow::displayText( QString text ,QString cap ) |
1581 | { | 1580 | { |
1582 | QDialog dia( this, "name", true ); ; | 1581 | QDialog dia( this, "name", true ); ; |
1583 | dia.setCaption( cap ); | 1582 | dia.setCaption( cap ); |
1584 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1583 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1585 | lay->setSpacing( 3 ); | 1584 | lay->setSpacing( 3 ); |
1586 | lay->setMargin( 3 ); | 1585 | lay->setMargin( 3 ); |
1587 | QTextBrowser tb ( &dia ); | 1586 | QTextBrowser tb ( &dia ); |
1588 | lay->addWidget( &tb ); | 1587 | lay->addWidget( &tb ); |
1589 | tb.setText( text ); | 1588 | tb.setText( text ); |
1590 | #ifdef DESKTOP_VERSION | 1589 | #ifdef DESKTOP_VERSION |
1591 | dia.resize( 640, 480); | 1590 | dia.resize( 640, 480); |
1592 | #else | 1591 | #else |
1593 | dia.showMaximized(); | 1592 | dia.showMaximized(); |
1594 | #endif | 1593 | #endif |
1595 | dia.exec(); | 1594 | dia.exec(); |
1596 | } | 1595 | } |
1597 | 1596 | ||
1598 | void MainWindow::features() | 1597 | void MainWindow::features() |
1599 | { | 1598 | { |
1600 | 1599 | ||
1601 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1600 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1602 | } | 1601 | } |
1603 | 1602 | ||
1604 | void MainWindow::usertrans() | 1603 | void MainWindow::usertrans() |
1605 | { | 1604 | { |
1606 | 1605 | ||
1607 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1606 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1608 | } | 1607 | } |
1609 | 1608 | ||
1610 | void MainWindow::storagehowto() | 1609 | void MainWindow::storagehowto() |
1611 | { | 1610 | { |
1612 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 1611 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
1613 | } | 1612 | } |
1614 | void MainWindow::timetrackinghowto() | 1613 | void MainWindow::timetrackinghowto() |
1615 | { | 1614 | { |
1616 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); | 1615 | KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); |
1617 | } | 1616 | } |
1618 | void MainWindow::kdesynchowto() | 1617 | void MainWindow::kdesynchowto() |
1619 | { | 1618 | { |
1620 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1619 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1621 | } | 1620 | } |
1622 | void MainWindow::multisynchowto() | 1621 | void MainWindow::multisynchowto() |
1623 | { | 1622 | { |
1624 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1623 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1625 | } | 1624 | } |
1626 | void MainWindow::synchowto() | 1625 | void MainWindow::synchowto() |
1627 | { | 1626 | { |
1628 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1627 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1629 | } | 1628 | } |
1630 | void MainWindow::faq() | 1629 | void MainWindow::faq() |
1631 | { | 1630 | { |
1632 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1631 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1633 | 1632 | ||
1634 | } | 1633 | } |
1635 | void MainWindow::whatsNew() | 1634 | void MainWindow::whatsNew() |
1636 | { | 1635 | { |
1637 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1636 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1638 | 1637 | ||
1639 | } | 1638 | } |
1640 | void MainWindow::licence() | 1639 | void MainWindow::licence() |
1641 | { | 1640 | { |
1642 | KApplication::showLicence(); | 1641 | KApplication::showLicence(); |
1643 | 1642 | ||
1644 | } | 1643 | } |
1645 | void MainWindow::about() | 1644 | void MainWindow::about() |
1646 | { | 1645 | { |
1647 | QString version; | 1646 | QString version; |
1648 | #include <../version> | 1647 | #include <../version> |
1649 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1648 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1650 | i18n("KOrganizer/Platform-independent\n") + | 1649 | i18n("KOrganizer/Platform-independent\n") + |
1651 | "(KO/Pi) " + version + " - " + | 1650 | "(KO/Pi) " + version + " - " + |
1652 | 1651 | ||
1653 | #ifdef DESKTOP_VERSION | 1652 | #ifdef DESKTOP_VERSION |
1654 | i18n("Desktop Edition\n") + | 1653 | i18n("Desktop Edition\n") + |
1655 | #else | 1654 | #else |
1656 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + | 1655 | i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + |
1657 | #endif | 1656 | #endif |
1658 | 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!") ); | 1657 | 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!") ); |
1659 | } | 1658 | } |
1660 | void MainWindow::keyBindings() | 1659 | void MainWindow::keyBindings() |
1661 | { | 1660 | { |
1662 | QString cap = i18n("KO/Pi Keys + Colors"); | 1661 | QString cap = i18n("KO/Pi Keys + Colors"); |
1663 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1662 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1664 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1663 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1665 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + | 1664 | i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + |
1666 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + | 1665 | i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + |
1667 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1666 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1668 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1667 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1669 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ | 1668 | i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ |
1670 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1669 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1671 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1670 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1672 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ | 1671 | i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ |
1673 | i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ | 1672 | i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ |
1674 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1673 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1675 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1674 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1676 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1675 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1677 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ | 1676 | i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ |
1678 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1677 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1679 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1678 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1680 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ | 1679 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ |
1681 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1680 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1682 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1681 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1683 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1682 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1684 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1683 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1685 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1684 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1686 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1685 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1687 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1686 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1688 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1687 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1689 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1688 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1690 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1689 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1691 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1690 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1692 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1691 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1693 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1692 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1694 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1693 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1695 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1694 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1696 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1695 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1697 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1696 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1698 | i18n("<p><h3>In list view:</h3></p>\n") + | 1697 | i18n("<p><h3>In list view:</h3></p>\n") + |
1699 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1698 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1700 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1699 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1701 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1700 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1702 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1701 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1703 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1702 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1704 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1703 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1705 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1704 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1706 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1705 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1707 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1706 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1708 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1707 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1709 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1708 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1710 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1709 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1711 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1710 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1712 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1711 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1713 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1712 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1714 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1713 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1715 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1714 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1716 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1715 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1717 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1716 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1718 | displayText( text, cap); | 1717 | displayText( text, cap); |
1719 | } | 1718 | } |
1720 | void MainWindow::aboutAutoSaving() | 1719 | void MainWindow::aboutAutoSaving() |
1721 | { | 1720 | { |
1722 | 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"); | 1721 | 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"); |
1723 | 1722 | ||
1724 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1723 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1725 | 1724 | ||
1726 | } | 1725 | } |
1727 | void MainWindow::aboutKnownBugs() | 1726 | void MainWindow::aboutKnownBugs() |
1728 | { | 1727 | { |
1729 | QMessageBox* msg; | 1728 | QMessageBox* msg; |
1730 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1729 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1731 | 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")+ | 1730 | 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")+ |
1732 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1731 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1733 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1732 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1734 | i18n("\nor report them in the bugtracker on\n") + | 1733 | i18n("\nor report them in the bugtracker on\n") + |
1735 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1734 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1736 | QMessageBox::NoIcon, | 1735 | QMessageBox::NoIcon, |
1737 | QMessageBox::Ok, | 1736 | QMessageBox::Ok, |
1738 | QMessageBox::NoButton, | 1737 | QMessageBox::NoButton, |
1739 | QMessageBox::NoButton); | 1738 | QMessageBox::NoButton); |
1740 | msg->exec(); | 1739 | msg->exec(); |
1741 | delete msg; | 1740 | delete msg; |
1742 | 1741 | ||
1743 | } | 1742 | } |
1744 | 1743 | ||
1745 | QString MainWindow::defaultFileName() | 1744 | QString MainWindow::defaultFileName() |
1746 | { | 1745 | { |
1747 | return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); | 1746 | return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); |
1748 | } | 1747 | } |
1749 | QString MainWindow::syncFileName() | 1748 | QString MainWindow::syncFileName() |
1750 | { | 1749 | { |
1751 | #ifdef DESKTOP_VERSION | 1750 | #ifdef DESKTOP_VERSION |
1752 | return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); | 1751 | return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); |
1753 | #else | 1752 | #else |
1754 | return QString( "/tmp/synccalendar.ics" ); | 1753 | return QString( "/tmp/synccalendar.ics" ); |
1755 | #endif | 1754 | #endif |
1756 | } | 1755 | } |
1757 | #include "koglobals.h" | 1756 | #include "koglobals.h" |
1758 | #include <kcalendarsystem.h> | 1757 | #include <kcalendarsystem.h> |
1759 | void MainWindow::updateWeek(QDate seda) | 1758 | void MainWindow::updateWeek(QDate seda) |
1760 | { | 1759 | { |
1761 | int weekNum = KGlobal::locale()->weekNum ( seda ); | 1760 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1762 | mWeekPixmap.fill( mWeekBgColor ); | 1761 | mWeekPixmap.fill( mWeekBgColor ); |
1763 | QPainter p ( &mWeekPixmap ); | 1762 | QPainter p ( &mWeekPixmap ); |
1764 | p.setFont( mWeekFont ); | 1763 | p.setFont( mWeekFont ); |
1765 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1764 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1766 | p.end(); | 1765 | p.end(); |
1767 | QIconSet icon3 ( mWeekPixmap ); | 1766 | QIconSet icon3 ( mWeekPixmap ); |
1768 | mWeekAction->setIconSet ( icon3 ); | 1767 | mWeekAction->setIconSet ( icon3 ); |
1769 | 1768 | ||
1770 | } | 1769 | } |
1771 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1770 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1772 | { | 1771 | { |
1773 | updateWeek( selectedDates.first() ); | 1772 | updateWeek( selectedDates.first() ); |
1774 | } | 1773 | } |
1775 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1774 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1776 | { | 1775 | { |
1777 | if ( !incidence ) { | 1776 | if ( !incidence ) { |
1778 | mShowAction->setMenuText( i18n("Show") ); | 1777 | mShowAction->setMenuText( i18n("Show") ); |
1779 | enableIncidenceActions( false ); | 1778 | enableIncidenceActions( false ); |
1780 | mNewSubTodoAction->setEnabled( false ); | 1779 | mNewSubTodoAction->setEnabled( false ); |
1781 | setCaptionToDates(); | 1780 | setCaptionToDates(); |
1782 | return; | 1781 | return; |
1783 | } | 1782 | } |
1784 | QString startString = ""; | 1783 | QString startString = ""; |
1785 | if ( incidence->typeID() != todoID ) { | 1784 | if ( incidence->typeID() != todoID ) { |
1786 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1785 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1787 | if ( incidence->doesFloat() ) { | 1786 | if ( incidence->doesFloat() ) { |
1788 | startString += ": "+incidence->dtStartDateStr( true ); | 1787 | startString += ": "+incidence->dtStartDateStr( true ); |
1789 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1788 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1790 | } else { | 1789 | } else { |
1791 | startString = ": "+incidence->dtStartStr(true); | 1790 | startString = ": "+incidence->dtStartStr(true); |
1792 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1791 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1793 | } | 1792 | } |
1794 | } else { | 1793 | } else { |
1795 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1794 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1796 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1795 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1797 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1796 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1798 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { | 1797 | if ( incidence->isBirthday() || incidence->isAnniversary() ) { |
1799 | bool ok; | 1798 | bool ok; |
1800 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1799 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1801 | if ( ok ) { | 1800 | if ( ok ) { |
1802 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1801 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1803 | startString += i18n(" (%1 y.)"). arg( years ); | 1802 | startString += i18n(" (%1 y.)"). arg( years ); |
1804 | } | 1803 | } |
1805 | } | 1804 | } |
1806 | else | 1805 | else |
1807 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1806 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1808 | } | 1807 | } |
1809 | } | 1808 | } |
1810 | else { | 1809 | else { |
1811 | if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) | 1810 | if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) |
1812 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); | 1811 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); |
1813 | else | 1812 | else |
1814 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1813 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1815 | } | 1814 | } |
1816 | if ( !incidence->location().isEmpty() ) | 1815 | if ( !incidence->location().isEmpty() ) |
1817 | startString += " (" +incidence->location()+")"; | 1816 | startString += " (" +incidence->location()+")"; |
1818 | setCaption( incidence->summary()+startString); | 1817 | setCaption( incidence->summary()+startString); |
1819 | enableIncidenceActions( true ); | 1818 | enableIncidenceActions( true ); |
1820 | if ( incidence->typeID() == eventID ) { | 1819 | if ( incidence->typeID() == eventID ) { |
1821 | mShowAction->setMenuText( i18n("Show Event") ); | 1820 | mShowAction->setMenuText( i18n("Show Event") ); |
1822 | mNewSubTodoAction->setEnabled( false ); | 1821 | mNewSubTodoAction->setEnabled( false ); |
1823 | } else if ( incidence->typeID() == todoID ) { | 1822 | } else if ( incidence->typeID() == todoID ) { |
1824 | mShowAction->setMenuText( i18n("Show Todo") ); | 1823 | mShowAction->setMenuText( i18n("Show Todo") ); |
1825 | mNewSubTodoAction->setEnabled( true ); | 1824 | mNewSubTodoAction->setEnabled( true ); |
1826 | } else { | 1825 | } else { |
1827 | mShowAction->setMenuText( i18n("Show") ); | 1826 | mShowAction->setMenuText( i18n("Show") ); |
1828 | mNewSubTodoAction->setEnabled( false ); | 1827 | mNewSubTodoAction->setEnabled( false ); |
1829 | } | 1828 | } |
1830 | #ifdef DESKTOP_VERSION | 1829 | #ifdef DESKTOP_VERSION |
1831 | static QPixmap jP = SmallIcon( "journal" ); | 1830 | static QPixmap jP = SmallIcon( "journal" ); |
1832 | static QPixmap eP = SmallIcon( "newevent" ); | 1831 | static QPixmap eP = SmallIcon( "newevent" ); |
1833 | static QPixmap tP = SmallIcon( "newtodo" ); | 1832 | static QPixmap tP = SmallIcon( "newtodo" ); |
1834 | QIconSet icon; | 1833 | QIconSet icon; |
1835 | if ( incidence->typeID() == todoID ) | 1834 | if ( incidence->typeID() == todoID ) |
1836 | icon = QIconSet ( tP ); | 1835 | icon = QIconSet ( tP ); |
1837 | else if ( incidence->typeID() == eventID ) | 1836 | else if ( incidence->typeID() == eventID ) |
1838 | icon = QIconSet ( eP ); | 1837 | icon = QIconSet ( eP ); |
1839 | else if ( incidence->typeID() == journalID ) | 1838 | else if ( incidence->typeID() == journalID ) |
1840 | icon = QIconSet ( jP ); | 1839 | icon = QIconSet ( jP ); |
1841 | mPrintSelAction->setIconSet ( icon ); | 1840 | mPrintSelAction->setIconSet ( icon ); |
1842 | #endif | 1841 | #endif |
1843 | } | 1842 | } |
1844 | 1843 | ||
1845 | void MainWindow::enableIncidenceActions( bool enabled ) | 1844 | void MainWindow::enableIncidenceActions( bool enabled ) |
1846 | { | 1845 | { |
1847 | mShowAction->setEnabled( enabled ); | 1846 | mShowAction->setEnabled( enabled ); |
1848 | mEditAction->setEnabled( enabled ); | 1847 | mEditAction->setEnabled( enabled ); |
1849 | mDeleteAction->setEnabled( enabled ); | 1848 | mDeleteAction->setEnabled( enabled ); |
1850 | 1849 | ||
1851 | mCloneAction->setEnabled( enabled ); | 1850 | mCloneAction->setEnabled( enabled ); |
1852 | mMoveAction->setEnabled( enabled ); | 1851 | mMoveAction->setEnabled( enabled ); |
1853 | #ifndef DESKTOP_VERSION | 1852 | #ifndef DESKTOP_VERSION |
1854 | mBeamAction->setEnabled( enabled ); | 1853 | mBeamAction->setEnabled( enabled ); |
1855 | #else | 1854 | #else |
1856 | mPrintSelAction->setEnabled( enabled ); | 1855 | mPrintSelAction->setEnabled( enabled ); |
1857 | #endif | 1856 | #endif |
1858 | mCancelAction->setEnabled( enabled ); | 1857 | mCancelAction->setEnabled( enabled ); |
1859 | } | 1858 | } |
1860 | 1859 | ||
1861 | void MainWindow::importOL() | 1860 | void MainWindow::importOL() |
1862 | { | 1861 | { |
1863 | #ifdef _OL_IMPORT_ | 1862 | #ifdef _OL_IMPORT_ |
1864 | mView->clearAllViews(); | 1863 | mView->clearAllViews(); |
1865 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1864 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1866 | id->exec(); | 1865 | id->exec(); |
1867 | delete id; | 1866 | delete id; |
1868 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1867 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1869 | mView->updateView(); | 1868 | mView->updateView(); |
1870 | #endif | 1869 | #endif |
1871 | } | 1870 | } |
1872 | void MainWindow::importBday() | 1871 | void MainWindow::importBday() |
1873 | { | 1872 | { |
1874 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), | 1873 | int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), |
1875 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1874 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1876 | i18n("Import!"), i18n("Cancel"), 0, | 1875 | i18n("Import!"), i18n("Cancel"), 0, |
1877 | 0, 1 ); | 1876 | 0, 1 ); |
1878 | if ( result == 0 ) { | 1877 | if ( result == 0 ) { |
1879 | mView->importBday(); | 1878 | mView->importBday(); |
1880 | 1879 | ||
1881 | } | 1880 | } |
1882 | 1881 | ||
1883 | 1882 | ||
1884 | } | 1883 | } |
1885 | void MainWindow::importQtopia() | 1884 | void MainWindow::importQtopia() |
1886 | { | 1885 | { |
1887 | //#ifndef DESKTOP_VERSION | 1886 | //#ifndef DESKTOP_VERSION |
1888 | 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"); | 1887 | 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"); |
1889 | #ifdef DESKTOP_VERSION | 1888 | #ifdef DESKTOP_VERSION |
1890 | 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"); | 1889 | 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"); |
1891 | #endif | 1890 | #endif |
1892 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1891 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1893 | i18n("Import!"), i18n("Cancel"), 0, | 1892 | i18n("Import!"), i18n("Cancel"), 0, |
1894 | 0, 1 ); | 1893 | 0, 1 ); |
1895 | if ( result == 0 ) { | 1894 | if ( result == 0 ) { |
1896 | #ifndef DESKTOP_VERSION | 1895 | #ifndef DESKTOP_VERSION |
1897 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1896 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1898 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1897 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1899 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1898 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1900 | #else | 1899 | #else |
1901 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1900 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1902 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1901 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1903 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1902 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1904 | #endif | 1903 | #endif |
1905 | mView->importQtopia( categories, datebook, todolist ); | 1904 | mView->importQtopia( categories, datebook, todolist ); |
1906 | } | 1905 | } |
1907 | mView->calendar()->reInitAlarmSettings(); | 1906 | mView->calendar()->reInitAlarmSettings(); |
1908 | #if 0 | 1907 | #if 0 |
1909 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1908 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1910 | i18n("Not supported \non desktop!\n"), | 1909 | i18n("Not supported \non desktop!\n"), |
1911 | i18n("Ok"), i18n("Cancel"), 0, | 1910 | i18n("Ok"), i18n("Cancel"), 0, |
1912 | 0, 1 ); | 1911 | 0, 1 ); |
1913 | 1912 | ||
1914 | #endif | 1913 | #endif |
1915 | } | 1914 | } |
1916 | 1915 | ||
1917 | void MainWindow::saveOnClose() | 1916 | void MainWindow::saveOnClose() |
1918 | { | 1917 | { |
1919 | KOPrefs *p = KOPrefs::instance(); | 1918 | KOPrefs *p = KOPrefs::instance(); |
1920 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1919 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1921 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1920 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1922 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1921 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1923 | if ( filterToolBar ) { | 1922 | if ( filterToolBar ) { |
1924 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1923 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1925 | } | 1924 | } |
1926 | #ifdef DESKTOP_VERSION | 1925 | #ifdef DESKTOP_VERSION |
1927 | 1926 | ||
1928 | QPoint myP; | 1927 | QPoint myP; |
1929 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1928 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1930 | if ( p->mToolBarHor ) | 1929 | if ( p->mToolBarHor ) |
1931 | p->mToolBarUp = myP.y() > height()/2; | 1930 | p->mToolBarUp = myP.y() > height()/2; |
1932 | else | 1931 | else |
1933 | p->mToolBarUp = myP.x() > width()/2; | 1932 | p->mToolBarUp = myP.x() > width()/2; |
1934 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1933 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1935 | if ( p->mToolBarHorV ) | 1934 | if ( p->mToolBarHorV ) |
1936 | p->mToolBarUpV = myP.y() > height()/2; | 1935 | p->mToolBarUpV = myP.y() > height()/2; |
1937 | else | 1936 | else |
1938 | p->mToolBarUpV = myP.x() > width()/2 ; | 1937 | p->mToolBarUpV = myP.x() > width()/2 ; |
1939 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1938 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1940 | if ( p->mToolBarHorN ) | 1939 | if ( p->mToolBarHorN ) |
1941 | p->mToolBarUpN = myP.y() > height()/2; | 1940 | p->mToolBarUpN = myP.y() > height()/2; |
1942 | else | 1941 | else |
1943 | p->mToolBarUpN = myP.x() > width()/2 ; | 1942 | p->mToolBarUpN = myP.x() > width()/2 ; |
1944 | if ( filterToolBar ) { | 1943 | if ( filterToolBar ) { |
1945 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1944 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1946 | if ( p->mToolBarHorF ) | 1945 | if ( p->mToolBarHorF ) |
1947 | p->mToolBarUpF = myP.y() > height()/2; | 1946 | p->mToolBarUpF = myP.y() > height()/2; |
1948 | else | 1947 | else |
1949 | p->mToolBarUpF = myP.x() > width()/2 ; | 1948 | p->mToolBarUpF = myP.x() > width()/2 ; |
1950 | } | 1949 | } |
1951 | #else | 1950 | #else |
1952 | if ( p->mToolBarHor ) | 1951 | if ( p->mToolBarHor ) |
1953 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1952 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1954 | else | 1953 | else |
1955 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1954 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1956 | if ( p->mToolBarHorV ) | 1955 | if ( p->mToolBarHorV ) |
1957 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1956 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1958 | else | 1957 | else |
1959 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1958 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1960 | 1959 | ||
1961 | if ( p->mToolBarHorN ) | 1960 | if ( p->mToolBarHorN ) |
1962 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1961 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1963 | else | 1962 | else |
1964 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1963 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1965 | if ( filterToolBar ) { | 1964 | if ( filterToolBar ) { |
1966 | if ( p->mToolBarHorF ) | 1965 | if ( p->mToolBarHorF ) |
1967 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1966 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1968 | else | 1967 | else |
1969 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1968 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1970 | } | 1969 | } |
1971 | #endif | 1970 | #endif |
1972 | save(); | 1971 | save(); |
1973 | mView->writeSettings(); | 1972 | mView->writeSettings(); |
1974 | mView->checkSuspendAlarm(); | 1973 | mView->checkSuspendAlarm(); |
1975 | } | 1974 | } |
1976 | void MainWindow::slotModifiedChanged( bool ) | 1975 | void MainWindow::slotModifiedChanged( bool ) |
1977 | { | 1976 | { |
1978 | if ( mBlockAtStartup ) | 1977 | if ( mBlockAtStartup ) |
1979 | return; | 1978 | return; |
1980 | 1979 | ||
1981 | int msec; | 1980 | int msec; |
1982 | if ( mCalendarModifiedFlag ) { | 1981 | if ( mCalendarModifiedFlag ) { |
1983 | //qDebug(" MainWindow timer is running "); | 1982 | //qDebug(" MainWindow timer is running "); |
1984 | return; | 1983 | return; |
1985 | } | 1984 | } |
1986 | // we store the changes after 1 minute, | 1985 | // we store the changes after 1 minute, |
1987 | // and for safety reasons after 10 minutes again | 1986 | // and for safety reasons after 10 minutes again |
1988 | if ( !mSyncManager->blockSave() ) | 1987 | if ( !mSyncManager->blockSave() ) |
1989 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1988 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1990 | else | 1989 | else |
1991 | msec = 1000 * 600; | 1990 | msec = 1000 * 600; |
1992 | mSaveTimer.start( msec, true ); // 1 minute | 1991 | mSaveTimer.start( msec, true ); // 1 minute |
1993 | mSaveTimerStart = QDateTime::currentDateTime(); | 1992 | mSaveTimerStart = QDateTime::currentDateTime(); |
1994 | mSaveDelay = msec/1000; | 1993 | mSaveDelay = msec/1000; |
1995 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1994 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1996 | mCalendarModifiedFlag = true; | 1995 | mCalendarModifiedFlag = true; |
1997 | } | 1996 | } |
1998 | void MainWindow::saveStopTimer() | 1997 | void MainWindow::saveStopTimer() |
1999 | { | 1998 | { |
2000 | mSaveTimer.stop(); | 1999 | mSaveTimer.stop(); |
2001 | } | 2000 | } |
2002 | void MainWindow::backupAllFiles() | 2001 | void MainWindow::backupAllFiles() |
2003 | { | 2002 | { |
2004 | QDate reference ( 2000,1,1); | 2003 | QDate reference ( 2000,1,1); |
2005 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2004 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2006 | setCaption(i18n("Creating backup ... please wait ..." )); | 2005 | setCaption(i18n("Creating backup ... please wait ..." )); |
2007 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 2006 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
2008 | // we need the file path, the backup dir and the number of bups as param | 2007 | // we need the file path, the backup dir and the number of bups as param |
2009 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2008 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2010 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2009 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2011 | bupDir = KGlobalSettings::backupDataDir(); | 2010 | bupDir = KGlobalSettings::backupDataDir(); |
2012 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 2011 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
2013 | if ( retval == 0 ) { | 2012 | if ( retval == 0 ) { |
2014 | setCaption(i18n("Backup cancelled" )); | 2013 | setCaption(i18n("Backup cancelled" )); |
2015 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 2014 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
2016 | // retval == 0 : backup skipped for today, try again tomorrow | 2015 | // retval == 0 : backup skipped for today, try again tomorrow |
2017 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 2016 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
2018 | } else if ( retval == 1 ){ | 2017 | } else if ( retval == 1 ){ |
2019 | qDebug("KO: Backup created."); | 2018 | qDebug("KO: Backup created."); |
2020 | // backup ok | 2019 | // backup ok |
2021 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2020 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2022 | KopiCalendarFile * cal = calendars.first(); | 2021 | KopiCalendarFile * cal = calendars.first(); |
2023 | cal = calendars.next(); | 2022 | cal = calendars.next(); |
2024 | while ( cal ) { | 2023 | while ( cal ) { |
2025 | if ( !cal->mErrorOnLoad ) { | 2024 | if ( !cal->mErrorOnLoad ) { |
2026 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 2025 | KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
2027 | } | 2026 | } |
2028 | cal = calendars.next(); | 2027 | cal = calendars.next(); |
2029 | } | 2028 | } |
2030 | KOPrefs::instance()->mLastBackupDate = daysTo; | 2029 | KOPrefs::instance()->mLastBackupDate = daysTo; |
2031 | setCaption(i18n("Backup succesfully finished" )); | 2030 | setCaption(i18n("Backup succesfully finished" )); |
2032 | } else if ( retval == 2 ){ | 2031 | } else if ( retval == 2 ){ |
2033 | setCaption(i18n("Backup globally disabled" )); | 2032 | setCaption(i18n("Backup globally disabled" )); |
2034 | qDebug("KO: Backup globally cancelled."); | 2033 | qDebug("KO: Backup globally cancelled."); |
2035 | // backup globally cancelled | 2034 | // backup globally cancelled |
2036 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2035 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2037 | } | 2036 | } |
2038 | // retval == 3: do nothing, try again later | 2037 | // retval == 3: do nothing, try again later |
2039 | } | 2038 | } |
2040 | void MainWindow::save() | 2039 | void MainWindow::save() |
2041 | { | 2040 | { |
2042 | if ( mSaveDelay ) { | 2041 | if ( mSaveDelay ) { |
2043 | int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); | 2042 | int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); |
2044 | if ( mSaveDelay < elapsed ) { | 2043 | if ( mSaveDelay < elapsed ) { |
2045 | qDebug("KO: Pending save after wakeup from suspend detected."); | 2044 | qDebug("KO: Pending save after wakeup from suspend detected."); |
2046 | qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); | 2045 | qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); |
2047 | qDebug("KO: Restarting save timer to save in 15 sec."); | 2046 | qDebug("KO: Restarting save timer to save in 10 sec."); |
2048 | int msec = 15000; | 2047 | int msec = 10000; |
2049 | mSaveTimer.start( msec, true ); | 2048 | mSaveTimer.start( msec, true ); |
2050 | mSaveTimerStart = QDateTime::currentDateTime(); | 2049 | mSaveTimerStart = QDateTime::currentDateTime(); |
2051 | mSaveDelay = msec/1000; | 2050 | mSaveDelay = msec/1000; |
2052 | return; | 2051 | return; |
2053 | } | 2052 | } |
2054 | } | 2053 | } |
2055 | 2054 | ||
2056 | if ( mView->viewManager()->journalView() ) | 2055 | if ( mView->viewManager()->journalView() ) |
2057 | mView->viewManager()->journalView()->checkModified(); | 2056 | mView->viewManager()->journalView()->checkModified(); |
2058 | if ( !mCalendarModifiedFlag ) { | 2057 | if ( !mCalendarModifiedFlag ) { |
2059 | qDebug("KO: Calendar not modified. Nothing saved."); | 2058 | qDebug("KO: Calendar not modified. Nothing saved."); |
2060 | return; | 2059 | return; |
2061 | } | 2060 | } |
2062 | if ( mSyncManager->blockSave() ) { | 2061 | if ( mSyncManager->blockSave() ) { |
2063 | slotModifiedChanged( true ); | 2062 | slotModifiedChanged( true ); |
2064 | return; | 2063 | return; |
2065 | } | 2064 | } |
2066 | mSaveDelay = 0; | 2065 | mSaveDelay = 0; |
2067 | mSyncManager->setBlockSave(true); | 2066 | mSyncManager->setBlockSave(true); |
2068 | if ( mView->checkAllFileVersions() ) { | 2067 | if ( mView->checkAllFileVersions() ) { |
2069 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 2068 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
2070 | QDate reference ( 2000,1,1); | 2069 | QDate reference ( 2000,1,1); |
2071 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 2070 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
2072 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 2071 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
2073 | backupAllFiles(); | 2072 | backupAllFiles(); |
2074 | } | 2073 | } |
2075 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2074 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2076 | } | 2075 | } |
2077 | QTime neededSaveTime; | 2076 | QTime neededSaveTime; |
2078 | neededSaveTime.start(); | 2077 | neededSaveTime.start(); |
2079 | if ( !isMinimized () ) | 2078 | if ( !isMinimized () ) |
2080 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2079 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2081 | qDebug("KO: Start saving data to file!"); | 2080 | qDebug("KO: Start saving data to file!"); |
2082 | if ( mView->saveCalendars() ) | 2081 | if ( mView->saveCalendars() ) |
2083 | mCalendarModifiedFlag = false; | 2082 | mCalendarModifiedFlag = false; |
2084 | int msNeeded = neededSaveTime.elapsed(); | 2083 | int msNeeded = neededSaveTime.elapsed(); |
2085 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2084 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2086 | QString savemes; | 2085 | QString savemes; |
2087 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 2086 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
2088 | if ( !isMinimized () ) | 2087 | if ( !isMinimized () ) |
2089 | setCaption(savemes); | 2088 | setCaption(savemes); |
2090 | else | 2089 | else |
2091 | qDebug(savemes); | 2090 | qDebug(savemes); |
2092 | } else { | 2091 | } else { |
2093 | setCaption(i18n("Saving cancelled!")); | 2092 | setCaption(i18n("Saving cancelled!")); |
2094 | mCalendarModifiedFlag = false; | 2093 | mCalendarModifiedFlag = false; |
2095 | slotModifiedChanged( true ); | 2094 | slotModifiedChanged( true ); |
2096 | } | 2095 | } |
2097 | mSyncManager->setBlockSave( false ); | 2096 | mSyncManager->setBlockSave( false ); |
2098 | } | 2097 | } |
2099 | 2098 | ||
2100 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 2099 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
2101 | { | 2100 | { |
2102 | if ( !e->isAutoRepeat() ) { | 2101 | if ( !e->isAutoRepeat() ) { |
2103 | mFlagKeyPressed = false; | 2102 | mFlagKeyPressed = false; |
2104 | } | 2103 | } |
2105 | } | 2104 | } |
2106 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 2105 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
2107 | { | 2106 | { |
2108 | qApp->processEvents(); | 2107 | qApp->processEvents(); |
2109 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2108 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2110 | e->ignore(); | 2109 | e->ignore(); |
2111 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 2110 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
2112 | return; | 2111 | return; |
2113 | } | 2112 | } |
2114 | if (! e->isAutoRepeat() ) | 2113 | if (! e->isAutoRepeat() ) |
2115 | mFlagKeyPressed = true; | 2114 | mFlagKeyPressed = true; |
2116 | KOPrefs *p = KOPrefs::instance(); | 2115 | KOPrefs *p = KOPrefs::instance(); |
2117 | bool showSelectedDates = false; | 2116 | bool showSelectedDates = false; |
2118 | int size; | 2117 | int size; |
2119 | int pro = 0; | 2118 | int pro = 0; |
2120 | //qDebug("MainWindow::keyPressEvent "); | 2119 | //qDebug("MainWindow::keyPressEvent "); |
2121 | switch ( e->key() ) { | 2120 | switch ( e->key() ) { |
2122 | case Qt::Key_Right: | 2121 | case Qt::Key_Right: |
2123 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2122 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2124 | mView->goNextMonth(); | 2123 | mView->goNextMonth(); |
2125 | else | 2124 | else |
2126 | mView->goNext(); | 2125 | mView->goNext(); |
2127 | showSelectedDates = true; | 2126 | showSelectedDates = true; |
2128 | break; | 2127 | break; |
2129 | case Qt::Key_Left: | 2128 | case Qt::Key_Left: |
2130 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2129 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2131 | mView->goPreviousMonth(); | 2130 | mView->goPreviousMonth(); |
2132 | else | 2131 | else |
2133 | mView->goPrevious(); | 2132 | mView->goPrevious(); |
2134 | showSelectedDates = true; | 2133 | showSelectedDates = true; |
2135 | break; | 2134 | break; |
2136 | case Qt::Key_Down: | 2135 | case Qt::Key_Down: |
2137 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 2136 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
2138 | break; | 2137 | break; |
2139 | case Qt::Key_Up: | 2138 | case Qt::Key_Up: |
2140 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 2139 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
2141 | break; | 2140 | break; |
2142 | case Qt::Key_K: | 2141 | case Qt::Key_K: |
2143 | mView->viewManager()->showMonthViewWeek(); | 2142 | mView->viewManager()->showMonthViewWeek(); |
2144 | break; | 2143 | break; |
2145 | case Qt::Key_I: | 2144 | case Qt::Key_I: |
2146 | mView->showIncidence(); | 2145 | mView->showIncidence(); |
2147 | break; | 2146 | break; |
2148 | case Qt::Key_Delete: | 2147 | case Qt::Key_Delete: |
2149 | case Qt::Key_Backspace: | 2148 | case Qt::Key_Backspace: |
2150 | mView->deleteIncidence(); | 2149 | mView->deleteIncidence(); |
2151 | break; | 2150 | break; |
2152 | case Qt::Key_D: | 2151 | case Qt::Key_D: |
2153 | mView->viewManager()->showDayView(); | 2152 | mView->viewManager()->showDayView(); |
2154 | showSelectedDates = true; | 2153 | showSelectedDates = true; |
2155 | break; | 2154 | break; |
2156 | case Qt::Key_O: | 2155 | case Qt::Key_O: |
2157 | mView->toggleFilerEnabled( ); | 2156 | mView->toggleFilerEnabled( ); |
2158 | break; | 2157 | break; |
2159 | case Qt::Key_0: | 2158 | case Qt::Key_0: |
2160 | case Qt::Key_1: | 2159 | case Qt::Key_1: |
2161 | case Qt::Key_2: | 2160 | case Qt::Key_2: |
2162 | case Qt::Key_3: | 2161 | case Qt::Key_3: |
2163 | case Qt::Key_4: | 2162 | case Qt::Key_4: |
2164 | case Qt::Key_5: | 2163 | case Qt::Key_5: |
2165 | case Qt::Key_6: | 2164 | case Qt::Key_6: |
2166 | case Qt::Key_7: | 2165 | case Qt::Key_7: |
2167 | case Qt::Key_8: | 2166 | case Qt::Key_8: |
2168 | case Qt::Key_9: | 2167 | case Qt::Key_9: |
2169 | pro = e->key()-48; | 2168 | pro = e->key()-48; |
2170 | if ( pro == 0 ) | 2169 | if ( pro == 0 ) |
2171 | pro = 10; | 2170 | pro = 10; |
2172 | if ( e->state() == Qt::ControlButton) | 2171 | if ( e->state() == Qt::ControlButton) |
2173 | pro += 10; | 2172 | pro += 10; |
2174 | break; | 2173 | break; |
2175 | case Qt::Key_M: | 2174 | case Qt::Key_M: |
2176 | mView->viewManager()->showMonthView(); | 2175 | mView->viewManager()->showMonthView(); |
2177 | showSelectedDates = true; | 2176 | showSelectedDates = true; |
2178 | break; | 2177 | break; |
2179 | case Qt::Key_Insert: | 2178 | case Qt::Key_Insert: |
2180 | mView->newEvent(); | 2179 | mView->newEvent(); |
2181 | break; | 2180 | break; |
2182 | case Qt::Key_S : | 2181 | case Qt::Key_S : |
2183 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2182 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2184 | mView->newSubTodo(); | 2183 | mView->newSubTodo(); |
2185 | else | 2184 | else |
2186 | mView->dialogManager()->showSearchDialog(); | 2185 | mView->dialogManager()->showSearchDialog(); |
2187 | break; | 2186 | break; |
2188 | case Qt::Key_Y : | 2187 | case Qt::Key_Y : |
2189 | case Qt::Key_Z : | 2188 | case Qt::Key_Z : |
2190 | mView->viewManager()->showWorkWeekView(); | 2189 | mView->viewManager()->showWorkWeekView(); |
2191 | showSelectedDates = true; | 2190 | showSelectedDates = true; |
2192 | break; | 2191 | break; |
2193 | case Qt::Key_U : | 2192 | case Qt::Key_U : |
2194 | mView->viewManager()->showWeekView(); | 2193 | mView->viewManager()->showWeekView(); |
2195 | showSelectedDates = true; | 2194 | showSelectedDates = true; |
2196 | break; | 2195 | break; |
2197 | case Qt::Key_H : | 2196 | case Qt::Key_H : |
2198 | keyBindings(); | 2197 | keyBindings(); |
2199 | break; | 2198 | break; |
2200 | case Qt::Key_W: | 2199 | case Qt::Key_W: |
2201 | mView->viewManager()->showWhatsNextView(); | 2200 | mView->viewManager()->showWhatsNextView(); |
2202 | break; | 2201 | break; |
2203 | case Qt::Key_L: | 2202 | case Qt::Key_L: |
2204 | mView->viewManager()->showListView(); | 2203 | mView->viewManager()->showListView(); |
2205 | break; | 2204 | break; |
2206 | case Qt::Key_N: | 2205 | case Qt::Key_N: |
2207 | mView->viewManager()->showNextView(); | 2206 | mView->viewManager()->showNextView(); |
2208 | break; | 2207 | break; |
2209 | case Qt::Key_V: | 2208 | case Qt::Key_V: |
2210 | mView->viewManager()->showTodoView(); | 2209 | mView->viewManager()->showTodoView(); |
2211 | break; | 2210 | break; |
2212 | case Qt::Key_C: | 2211 | case Qt::Key_C: |
2213 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 2212 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
2214 | break; | 2213 | break; |
2215 | case Qt::Key_P: | 2214 | case Qt::Key_P: |
2216 | mView->showDatePicker( ); | 2215 | mView->showDatePicker( ); |
2217 | break; | 2216 | break; |
2218 | case Qt::Key_F: | 2217 | case Qt::Key_F: |
2219 | mView->editFilters(); | 2218 | mView->editFilters(); |
2220 | break; | 2219 | break; |
2221 | case Qt::Key_R: | 2220 | case Qt::Key_R: |
2222 | mView->toggleFilter(); | 2221 | mView->toggleFilter(); |
2223 | break; | 2222 | break; |
2224 | case Qt::Key_X: | 2223 | case Qt::Key_X: |
2225 | if ( e->state() == Qt::ControlButton ) | 2224 | if ( e->state() == Qt::ControlButton ) |
2226 | mView->toggleDateNavigatorWidget(); | 2225 | mView->toggleDateNavigatorWidget(); |
2227 | else { | 2226 | else { |
2228 | mView->viewManager()->showNextXView(); | 2227 | mView->viewManager()->showNextXView(); |
2229 | showSelectedDates = true; | 2228 | showSelectedDates = true; |
2230 | } | 2229 | } |
2231 | break; | 2230 | break; |
2232 | case Qt::Key_Space: | 2231 | case Qt::Key_Space: |
2233 | mView->toggleExpand(); | 2232 | mView->toggleExpand(); |
2234 | break; | 2233 | break; |
2235 | case Qt::Key_A: | 2234 | case Qt::Key_A: |
2236 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2235 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2237 | mView->showNextAlarms(); | 2236 | mView->showNextAlarms(); |
2238 | else | 2237 | else |
2239 | mView->toggleAllDaySize(); | 2238 | mView->toggleAllDaySize(); |
2240 | break; | 2239 | break; |
2241 | case Qt::Key_T: | 2240 | case Qt::Key_T: |
2242 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2241 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2243 | mView->newTodo(); | 2242 | mView->newTodo(); |
2244 | else { | 2243 | else { |
2245 | mView->goToday(); | 2244 | mView->goToday(); |
2246 | showSelectedDates = true; | 2245 | showSelectedDates = true; |
2247 | } | 2246 | } |
2248 | break; | 2247 | break; |
2249 | case Qt::Key_Q: | 2248 | case Qt::Key_Q: |
2250 | if ( e->state() == Qt::ControlButton ) | 2249 | if ( e->state() == Qt::ControlButton ) |
2251 | mView->conflictNotAll(); | 2250 | mView->conflictNotAll(); |
2252 | else if ( e->state() == Qt::ShiftButton ) | 2251 | else if ( e->state() == Qt::ShiftButton ) |
2253 | mView->conflictAllday(); | 2252 | mView->conflictAllday(); |
2254 | else | 2253 | else |
2255 | mView->conflictAll(); | 2254 | mView->conflictAll(); |
2256 | break; | 2255 | break; |
2257 | case Qt::Key_J: | 2256 | case Qt::Key_J: |
2258 | mView->viewManager()->showJournalView(); | 2257 | mView->viewManager()->showJournalView(); |
2259 | break; | 2258 | break; |
2260 | case Qt::Key_B: | 2259 | case Qt::Key_B: |
2261 | mView->editIncidenceDescription();; | 2260 | mView->editIncidenceDescription();; |
2262 | break; | 2261 | break; |
2263 | // case Qt::Key_Return: | 2262 | // case Qt::Key_Return: |
2264 | case Qt::Key_E: | 2263 | case Qt::Key_E: |
2265 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2264 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2266 | mView->newEvent(); | 2265 | mView->newEvent(); |
2267 | else | 2266 | else |
2268 | mView->editIncidence(); | 2267 | mView->editIncidence(); |
2269 | break; | 2268 | break; |
2270 | case Qt::Key_Plus: | 2269 | case Qt::Key_Plus: |
2271 | size = p->mHourSize +2; | 2270 | size = p->mHourSize +2; |
2272 | if ( size <= 22 ) | 2271 | if ( size <= 22 ) |
2273 | configureAgenda( size ); | 2272 | configureAgenda( size ); |
2274 | break; | 2273 | break; |
2275 | case Qt::Key_Minus: | 2274 | case Qt::Key_Minus: |
2276 | size = p->mHourSize - 2; | 2275 | size = p->mHourSize - 2; |
2277 | if ( size >= 4 ) | 2276 | if ( size >= 4 ) |
2278 | configureAgenda( size ); | 2277 | configureAgenda( size ); |
2279 | break; | 2278 | break; |
2280 | 2279 | ||
2281 | 2280 | ||
2282 | default: | 2281 | default: |
2283 | e->ignore(); | 2282 | e->ignore(); |
2284 | } | 2283 | } |
2285 | if ( pro > 0 ) { | 2284 | if ( pro > 0 ) { |
2286 | selectFilter( pro+1 ); | 2285 | selectFilter( pro+1 ); |
2287 | } | 2286 | } |
2288 | if ( showSelectedDates ) { | 2287 | if ( showSelectedDates ) { |
2289 | ;// setCaptionToDates(); | 2288 | ;// setCaptionToDates(); |
2290 | } | 2289 | } |
2291 | 2290 | ||
2292 | } | 2291 | } |
2293 | void MainWindow::fillFilterMenuTB() | 2292 | void MainWindow::fillFilterMenuTB() |
2294 | { | 2293 | { |
2295 | selectFilterMenuTB->clear(); | 2294 | selectFilterMenuTB->clear(); |
2296 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); | 2295 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); |
2297 | selectFilterMenuTB->insertSeparator(); | 2296 | selectFilterMenuTB->insertSeparator(); |
2298 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); | 2297 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); |
2299 | 2298 | ||
2300 | selectFilterMenuTB->insertSeparator(); | 2299 | selectFilterMenuTB->insertSeparator(); |
2301 | QPtrList<CalFilter> fili = mView->filters(); | 2300 | QPtrList<CalFilter> fili = mView->filters(); |
2302 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2301 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2303 | CalFilter *filter = fili.first(); | 2302 | CalFilter *filter = fili.first(); |
2304 | int iii = 2; | 2303 | int iii = 2; |
2305 | bool checkitem = mView->filterView()->filtersEnabled(); | 2304 | bool checkitem = mView->filterView()->filtersEnabled(); |
2306 | while(filter) { | 2305 | while(filter) { |
2307 | selectFilterMenuTB->insertItem( filter->name(), iii ); | 2306 | selectFilterMenuTB->insertItem( filter->name(), iii ); |
2308 | if ( filter == curfilter) | 2307 | if ( filter == curfilter) |
2309 | selectFilterMenuTB->setItemChecked( iii, checkitem ); | 2308 | selectFilterMenuTB->setItemChecked( iii, checkitem ); |
2310 | filter = fili.next(); | 2309 | filter = fili.next(); |
2311 | ++iii; | 2310 | ++iii; |
2312 | } | 2311 | } |
2313 | if ( !checkitem ) | 2312 | if ( !checkitem ) |
2314 | selectFilterMenuTB->setItemChecked( 1, true ); | 2313 | selectFilterMenuTB->setItemChecked( 1, true ); |
2315 | 2314 | ||
2316 | int x = 0; | 2315 | int x = 0; |
2317 | int y = iconToolBar->height(); | 2316 | int y = iconToolBar->height(); |
2318 | int dX = 0; | 2317 | int dX = 0; |
2319 | int dY = 0; | 2318 | int dY = 0; |
2320 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2319 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2321 | if ( iconToolBar->y() > height()/2 ) { | 2320 | if ( iconToolBar->y() > height()/2 ) { |
2322 | dY = selectFilterMenuTB->sizeHint().height()+8; | 2321 | dY = selectFilterMenuTB->sizeHint().height()+8; |
2323 | y = 0; | 2322 | y = 0; |
2324 | } | 2323 | } |
2325 | } else { | 2324 | } else { |
2326 | if ( iconToolBar->x() > width()/2 ) { // right side | 2325 | if ( iconToolBar->x() > width()/2 ) { // right side |
2327 | x=0; | 2326 | x=0; |
2328 | dX= selectFilterMenuTB->sizeHint().width()+8; | 2327 | dX= selectFilterMenuTB->sizeHint().width()+8; |
2329 | y = 0; | 2328 | y = 0; |
2330 | } else { | 2329 | } else { |
2331 | x= iconToolBar->width(); | 2330 | x= iconToolBar->width(); |
2332 | y = 0; | 2331 | y = 0; |
2333 | } | 2332 | } |
2334 | } | 2333 | } |
2335 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2334 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2336 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); | 2335 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); |
2337 | } | 2336 | } |
2338 | void MainWindow::fillFilterMenu() | 2337 | void MainWindow::fillFilterMenu() |
2339 | { | 2338 | { |
2340 | selectFilterMenu->clear(); | 2339 | selectFilterMenu->clear(); |
2341 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 2340 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
2342 | selectFilterMenu->insertSeparator(); | 2341 | selectFilterMenu->insertSeparator(); |
2343 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 2342 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
2344 | 2343 | ||
2345 | selectFilterMenu->insertSeparator(); | 2344 | selectFilterMenu->insertSeparator(); |
2346 | QPtrList<CalFilter> fili = mView->filters(); | 2345 | QPtrList<CalFilter> fili = mView->filters(); |
2347 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2346 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2348 | CalFilter *filter = fili.first(); | 2347 | CalFilter *filter = fili.first(); |
2349 | int iii = 2; | 2348 | int iii = 2; |
2350 | bool checkitem = mView->filterView()->filtersEnabled(); | 2349 | bool checkitem = mView->filterView()->filtersEnabled(); |
2351 | while(filter) { | 2350 | while(filter) { |
2352 | selectFilterMenu->insertItem( filter->name(), iii ); | 2351 | selectFilterMenu->insertItem( filter->name(), iii ); |
2353 | if ( filter == curfilter) | 2352 | if ( filter == curfilter) |
2354 | selectFilterMenu->setItemChecked( iii, checkitem ); | 2353 | selectFilterMenu->setItemChecked( iii, checkitem ); |
2355 | filter = fili.next(); | 2354 | filter = fili.next(); |
2356 | ++iii; | 2355 | ++iii; |
2357 | } | 2356 | } |
2358 | if ( !checkitem ) | 2357 | if ( !checkitem ) |
2359 | selectFilterMenu->setItemChecked( 1, true ); | 2358 | selectFilterMenu->setItemChecked( 1, true ); |
2360 | } | 2359 | } |
2361 | void MainWindow::fillFilterMenuPopup() | 2360 | void MainWindow::fillFilterMenuPopup() |
2362 | { | 2361 | { |
2363 | filterPopupMenu->clear(); | 2362 | filterPopupMenu->clear(); |
2364 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 2363 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
2365 | 2364 | ||
2366 | filterPopupMenu->insertSeparator(); | 2365 | filterPopupMenu->insertSeparator(); |
2367 | QPtrList<CalFilter> fili = mView->filters(); | 2366 | QPtrList<CalFilter> fili = mView->filters(); |
2368 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2367 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2369 | CalFilter *filter = fili.first(); | 2368 | CalFilter *filter = fili.first(); |
2370 | int iii = 1; | 2369 | int iii = 1; |
2371 | bool checkitem = mView->filterView()->filtersEnabled(); | 2370 | bool checkitem = mView->filterView()->filtersEnabled(); |
2372 | while(filter) { | 2371 | while(filter) { |
2373 | filterPopupMenu->insertItem( filter->name(), iii ); | 2372 | filterPopupMenu->insertItem( filter->name(), iii ); |
2374 | if ( filter == curfilter) | 2373 | if ( filter == curfilter) |
2375 | filterPopupMenu->setItemChecked( iii, checkitem ); | 2374 | filterPopupMenu->setItemChecked( iii, checkitem ); |
2376 | filter = fili.next(); | 2375 | filter = fili.next(); |
2377 | ++iii; | 2376 | ++iii; |
2378 | } | 2377 | } |
2379 | if ( !checkitem ) | 2378 | if ( !checkitem ) |
2380 | filterPopupMenu->setItemChecked( 0, true ); | 2379 | filterPopupMenu->setItemChecked( 0, true ); |
2381 | } | 2380 | } |
2382 | void MainWindow::selectFilter( int fil ) | 2381 | void MainWindow::selectFilter( int fil ) |
2383 | { | 2382 | { |
2384 | 2383 | ||
2385 | if ( fil == 0 ) { | 2384 | if ( fil == 0 ) { |
2386 | mView->editFilters( ); | 2385 | mView->editFilters( ); |
2387 | } else if ( fil == 1 ){ | 2386 | } else if ( fil == 1 ){ |
2388 | if ( mView->filterView()->filtersEnabled() ) | 2387 | if ( mView->filterView()->filtersEnabled() ) |
2389 | mView->toggleFilerEnabled( ); | 2388 | mView->toggleFilerEnabled( ); |
2390 | } else { | 2389 | } else { |
2391 | if ( !mView->filterView()->filtersEnabled() ) { | 2390 | if ( !mView->filterView()->filtersEnabled() ) { |
2392 | mView->filterView()->blockSignals( true ); | 2391 | mView->filterView()->blockSignals( true ); |
2393 | mView->toggleFilerEnabled( ); | 2392 | mView->toggleFilerEnabled( ); |
2394 | mView->filterView()->blockSignals( false ); | 2393 | mView->filterView()->blockSignals( false ); |
2395 | } | 2394 | } |
2396 | mView->selectFilter( fil-2 ); | 2395 | mView->selectFilter( fil-2 ); |
2397 | } | 2396 | } |
2398 | } | 2397 | } |
2399 | void MainWindow::updateFilterToolbar() | 2398 | void MainWindow::updateFilterToolbar() |
2400 | { | 2399 | { |
2401 | if ( filterMenubar ) { | 2400 | if ( filterMenubar ) { |
2402 | if ( !mView->filterView()->filtersEnabled() ) { | 2401 | if ( !mView->filterView()->filtersEnabled() ) { |
2403 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 2402 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2404 | } else { | 2403 | } else { |
2405 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2404 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2406 | if ( curfilter ) { | 2405 | if ( curfilter ) { |
2407 | QString name = curfilter->name(); | 2406 | QString name = curfilter->name(); |
2408 | if ( name.length() > 12 ) | 2407 | if ( name.length() > 12 ) |
2409 | name = name.left(10)+"..."; | 2408 | name = name.left(10)+"..."; |
2410 | filterMenubar->changeItem( 0, name ); | 2409 | filterMenubar->changeItem( 0, name ); |
2411 | } | 2410 | } |
2412 | } | 2411 | } |
2413 | } | 2412 | } |
2414 | } | 2413 | } |
2415 | void MainWindow::selectFilterPopup( int fil ) | 2414 | void MainWindow::selectFilterPopup( int fil ) |
2416 | { | 2415 | { |
2417 | selectFilter( fil + 1 ); | 2416 | selectFilter( fil + 1 ); |
2418 | 2417 | ||
2419 | } | 2418 | } |
2420 | void MainWindow::configureToolBar( int item ) | 2419 | void MainWindow::configureToolBar( int item ) |
2421 | { | 2420 | { |
2422 | 2421 | ||
2423 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2422 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2424 | KOPrefs *p = KOPrefs::instance(); | 2423 | KOPrefs *p = KOPrefs::instance(); |
2425 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2424 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2426 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2425 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2427 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2426 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2428 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2427 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2429 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2428 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2430 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2429 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2431 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2430 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2432 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2431 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2433 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2432 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2434 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2433 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2435 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2434 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2436 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2435 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2437 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2436 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2438 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2437 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2439 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2438 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2440 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2439 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2441 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2440 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2442 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2441 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2443 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2442 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2444 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2443 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2445 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2444 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2446 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2445 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2447 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2446 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2448 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2447 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2449 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2448 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2450 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2449 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2451 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2450 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2452 | // initActions(); | 2451 | // initActions(); |
2453 | setCaption ( i18n("Toolbar changes needs a restart!") ); | 2452 | setCaption ( i18n("Toolbar changes needs a restart!") ); |
2454 | } | 2453 | } |
2455 | void MainWindow::setCaption ( const QString & c ) | 2454 | void MainWindow::setCaption ( const QString & c ) |
2456 | { | 2455 | { |
2457 | QString cap = c; | 2456 | QString cap = c; |
2458 | cap.replace( QRegExp("\n"), " " ); | 2457 | cap.replace( QRegExp("\n"), " " ); |
2459 | cap = cap.stripWhiteSpace(); | 2458 | cap = cap.stripWhiteSpace(); |
2460 | if ( cap.isEmpty() ) | 2459 | if ( cap.isEmpty() ) |
2461 | cap = "KO/Pi"; | 2460 | cap = "KO/Pi"; |
2462 | QWidget::setCaption( cap ); | 2461 | QWidget::setCaption( cap ); |
2463 | } | 2462 | } |
2464 | void MainWindow::setCaptionToDates() | 2463 | void MainWindow::setCaptionToDates() |
2465 | { | 2464 | { |
2466 | QString selDates; | 2465 | QString selDates; |
2467 | QDate date = mView->startDate(); | 2466 | QDate date = mView->startDate(); |
2468 | if ( ! date.isValid() ) { | 2467 | if ( ! date.isValid() ) { |
2469 | setCaption(""); | 2468 | setCaption(""); |
2470 | return; | 2469 | return; |
2471 | } | 2470 | } |
2472 | selDates = KGlobal::locale()->formatDate( date, true); | 2471 | selDates = KGlobal::locale()->formatDate( date, true); |
2473 | if (mView->startDate() < mView->endDate() ) | 2472 | if (mView->startDate() < mView->endDate() ) |
2474 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2473 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2475 | else { | 2474 | else { |
2476 | QString addString; | 2475 | QString addString; |
2477 | if ( date == QDateTime::currentDateTime().date() ) | 2476 | if ( date == QDateTime::currentDateTime().date() ) |
2478 | addString = i18n("Today"); | 2477 | addString = i18n("Today"); |
2479 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2478 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2480 | addString = i18n("Tomorrow"); | 2479 | addString = i18n("Tomorrow"); |
2481 | if ( !addString.isEmpty() ) | 2480 | if ( !addString.isEmpty() ) |
2482 | selDates = addString+", "+selDates ; | 2481 | selDates = addString+", "+selDates ; |
2483 | } | 2482 | } |
2484 | setCaption( i18n("Dates: ") + selDates ); | 2483 | setCaption( i18n("Dates: ") + selDates ); |
2485 | 2484 | ||
2486 | } | 2485 | } |
2487 | void MainWindow::showConfigureAgenda( ) | 2486 | void MainWindow::showConfigureAgenda( ) |
2488 | { | 2487 | { |
2489 | int iii; | 2488 | int iii; |
2490 | for ( iii = 1;iii<= 10 ;++iii ){ | 2489 | for ( iii = 1;iii<= 10 ;++iii ){ |
2491 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2490 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2492 | } | 2491 | } |
2493 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2492 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2494 | } | 2493 | } |
2495 | void MainWindow::configureAgenda( int item ) | 2494 | void MainWindow::configureAgenda( int item ) |
2496 | { | 2495 | { |
2497 | if ( KOPrefs::instance()->mHourSize == item ) | 2496 | if ( KOPrefs::instance()->mHourSize == item ) |
2498 | return; | 2497 | return; |
2499 | KOPrefs::instance()->mHourSize=item; | 2498 | KOPrefs::instance()->mHourSize=item; |
2500 | mView->viewManager()->agendaView()->updateConfig(); | 2499 | mView->viewManager()->agendaView()->updateConfig(); |
2501 | } | 2500 | } |
2502 | 2501 | ||
2503 | void MainWindow::saveCalendar() | 2502 | void MainWindow::saveCalendar() |
2504 | { | 2503 | { |
2505 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2504 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2506 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2505 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2507 | bupDir = KGlobalSettings::backupDataDir(); | 2506 | bupDir = KGlobalSettings::backupDataDir(); |
2508 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); | 2507 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); |
2509 | QString bupHint; | 2508 | QString bupHint; |
2510 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) | 2509 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) |
2511 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); | 2510 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); |
2512 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; | 2511 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; |
2513 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; | 2512 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; |
2514 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2513 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2515 | save(); | 2514 | save(); |
2516 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; | 2515 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; |
2517 | backupAllFiles(); | 2516 | backupAllFiles(); |
2518 | } | 2517 | } |
2519 | void MainWindow::loadCalendar() | 2518 | void MainWindow::loadCalendar() |
2520 | { | 2519 | { |
2521 | 2520 | ||
2522 | 2521 | ||
2523 | #if 0 | 2522 | #if 0 |
2524 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2523 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2525 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2524 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2526 | 2525 | ||
2527 | if ( fn == "" ) | 2526 | if ( fn == "" ) |
2528 | return; | 2527 | return; |
2529 | QFileInfo info; | 2528 | QFileInfo info; |
2530 | info.setFile( fn ); | 2529 | info.setFile( fn ); |
2531 | QString mess; | 2530 | QString mess; |
2532 | bool loadbup = true; | 2531 | bool loadbup = true; |
2533 | if ( info. exists() ) { | 2532 | if ( info. exists() ) { |
2534 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2533 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2535 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2534 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2536 | mess, | 2535 | mess, |
2537 | i18n("Load!"), i18n("Cancel"), 0, | 2536 | i18n("Load!"), i18n("Cancel"), 0, |
2538 | 0, 1 ); | 2537 | 0, 1 ); |
2539 | if ( result != 0 ) { | 2538 | if ( result != 0 ) { |
2540 | loadbup = false; | 2539 | loadbup = false; |
2541 | } | 2540 | } |
2542 | } else { | 2541 | } else { |
2543 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2542 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2544 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2543 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2545 | 0, 1 ); | 2544 | 0, 1 ); |
2546 | 2545 | ||
2547 | return; | 2546 | return; |
2548 | } | 2547 | } |
2549 | if ( loadbup ) { | 2548 | if ( loadbup ) { |
2550 | mView->openCalendar( fn ); | 2549 | mView->openCalendar( fn ); |
2551 | KOPrefs::instance()->mLastLoadFile = fn; | 2550 | KOPrefs::instance()->mLastLoadFile = fn; |
2552 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2551 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2553 | setCaption(mess); | 2552 | setCaption(mess); |
2554 | } | 2553 | } |
2555 | #endif | 2554 | #endif |
2556 | 2555 | ||
2557 | } | 2556 | } |
2558 | void MainWindow::quickImportIcal() | 2557 | void MainWindow::quickImportIcal() |
2559 | { | 2558 | { |
2560 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2559 | importFile( KOPrefs::instance()->mLastImportFile, false ); |