summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-26 21:33:09 (UTC)
committer zautrix <zautrix>2005-03-26 21:33:09 (UTC)
commit7177e62052b732f901eca6627825d0b38d8438be (patch) (unidiff)
tree9c6531a24e57221db445841610eaed7350ddc21f
parenta24f954912ee2dbb76dcbde1abc9f20b06abbf93 (diff)
downloadkdepimpi-7177e62052b732f901eca6627825d0b38d8438be.zip
kdepimpi-7177e62052b732f901eca6627825d0b38d8438be.tar.gz
kdepimpi-7177e62052b732f901eca6627825d0b38d8438be.tar.bz2
next view
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp4
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/koviewmanager.cpp65
-rw-r--r--korganizer/koviewmanager.h1
-rw-r--r--korganizer/mainwindow.cpp5
5 files changed, 75 insertions, 2 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index ec7f730..e8ec033 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -1,681 +1,683 @@
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
51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) 51SimpleAlarmDaemonImpl::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( "What's Todo?", this, SLOT ( showTodo() ) ); 59 mPopUp->insertItem( "What's Todo?", 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(); 70 QFont fon = mTimerPopUp->font();
71 fon.setPointSize( fon.pointSize() *3/2 ); 71 fon.setPointSize( fon.pointSize() *3/2 );
72 mTimerPopUp->setFont( fon ); 72 mTimerPopUp->setFont( fon );
73 mBeepPopUp = new QPopupMenu( this ); 73 mBeepPopUp = new QPopupMenu( this );
74 mSoundPopUp = new QPopupMenu( this ); 74 mSoundPopUp = new QPopupMenu( this );
75 mPausePopUp = new QPopupMenu( this ); 75 mPausePopUp = new QPopupMenu( this );
76 QPopupMenu* savePopUp = new QPopupMenu( this ); 76 QPopupMenu* savePopUp = new QPopupMenu( this );
77 savePopUp->insertItem( "Save", 0 ); 77 savePopUp->insertItem( "Save", 0 );
78 savePopUp->insertItem( "Load", 1 ); 78 savePopUp->insertItem( "Load", 1 );
79 mSoundPopUp->insertItem( "Buzzer", 0 ); 79 mSoundPopUp->insertItem( "Buzzer", 0 );
80 mSoundPopUp->insertItem( "Wav file", 1 ); 80 mSoundPopUp->insertItem( "Wav file", 1 );
81 mPausePopUp->insertItem( " 1 sec", 1 ); 81 mPausePopUp->insertItem( " 1 sec", 1 );
82 mPausePopUp->insertItem( " 2 sec", 2 ); 82 mPausePopUp->insertItem( " 2 sec", 2 );
83 mPausePopUp->insertItem( " 3 sec", 3 ); 83 mPausePopUp->insertItem( " 3 sec", 3 );
84 mPausePopUp->insertItem( " 5 sec", 5 ); 84 mPausePopUp->insertItem( " 5 sec", 5 );
85 mPausePopUp->insertItem( "10 sec", 10 ); 85 mPausePopUp->insertItem( "10 sec", 10 );
86 mPausePopUp->insertItem( "30 sec", 30 ); 86 mPausePopUp->insertItem( "30 sec", 30 );
87 mPausePopUp->insertItem( " 1 min", 60 ); 87 mPausePopUp->insertItem( " 1 min", 60 );
88 mPausePopUp->insertItem( " 5 min", 300 ); 88 mPausePopUp->insertItem( " 5 min", 300 );
89 mPausePopUp->insertItem( "10 min", 600 ); 89 mPausePopUp->insertItem( "10 min", 600 );
90 mSuspendPopUp = new QPopupMenu( this ); 90 mSuspendPopUp = new QPopupMenu( this );
91 mSuspendPopUp->insertItem( "Off", 0 ); 91 mSuspendPopUp->insertItem( "Off", 0 );
92 mSuspendPopUp->insertItem( " 1x", 1 ); 92 mSuspendPopUp->insertItem( " 1x", 1 );
93 mSuspendPopUp->insertItem( " 2x", 2 ); 93 mSuspendPopUp->insertItem( " 2x", 2 );
94 mSuspendPopUp->insertItem( " 3x", 3 ); 94 mSuspendPopUp->insertItem( " 3x", 3 );
95 mSuspendPopUp->insertItem( " 5x", 5 ); 95 mSuspendPopUp->insertItem( " 5x", 5 );
96 mSuspendPopUp->insertItem( "10x", 10 ); 96 mSuspendPopUp->insertItem( "10x", 10 );
97 mSuspendPopUp->insertItem( "20x", 20 ); 97 mSuspendPopUp->insertItem( "20x", 20 );
98 mSuspendPopUp->insertItem( "30x", 30 ); 98 mSuspendPopUp->insertItem( "30x", 30 );
99 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 99 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
100 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 100 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
101 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 101 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
102 mBeepPopUp->insertItem( "Config",savePopUp ); 102 mBeepPopUp->insertItem( "Config",savePopUp );
103 mBeepPopUp->insertItem( "300", 300 ); 103 mBeepPopUp->insertItem( "300", 300 );
104 mBeepPopUp->insertItem( "180", 180 ); 104 mBeepPopUp->insertItem( "180", 180 );
105 mBeepPopUp->insertItem( "60", 60 ); 105 mBeepPopUp->insertItem( "60", 60 );
106 mBeepPopUp->insertItem( "30", 30 ); 106 mBeepPopUp->insertItem( "30", 30 );
107 mBeepPopUp->insertItem( "10", 10 ); 107 mBeepPopUp->insertItem( "10", 10 );
108 mBeepPopUp->insertItem( "3", 3 ); 108 mBeepPopUp->insertItem( "3", 3 );
109 mBeepPopUp->insertItem( "1", 1 ); 109 mBeepPopUp->insertItem( "1", 1 );
110 mBeepPopUp->insertItem( "Off", 0 ); 110 mBeepPopUp->insertItem( "Off", 0 );
111 mBeepPopUp->setCheckable( true ); 111 mBeepPopUp->setCheckable( true );
112 mPopUp->insertSeparator(); 112 mPopUp->insertSeparator();
113 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 113 mPopUp->insertItem( "Play beeps", mBeepPopUp );
114 mPopUp->insertSeparator(); 114 mPopUp->insertSeparator();
115 mPopUp->insertItem( "Timer", mTimerPopUp ); 115 mPopUp->insertItem( "Timer", mTimerPopUp );
116 mPopUp->insertSeparator(); 116 mPopUp->insertSeparator();
117 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 117 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
118 118
119 mPopUp->resize( mPopUp->sizeHint() ); 119 mPopUp->resize( mPopUp->sizeHint() );
120 mPlayBeeps = 60; 120 mPlayBeeps = 60;
121 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 121 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
122 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 122 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
123 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 123 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
124 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 124 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
125 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 125 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
126 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 126 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
127 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 127 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
128 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 128 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
129 mTimerTime = 0; 129 mTimerTime = 0;
130 mCustomText = "Custom Text"; 130 mCustomText = "Custom Text";
131 mCustomMinutes = 7; 131 mCustomMinutes = 7;
132 mTimerPopupConf = 1; 132 mTimerPopupConf = 1;
133 fillTimerPopUp(); 133 fillTimerPopUp();
134 mPausePlay = 0; 134 mPausePlay = 0;
135 confPause( 1 ); 135 confPause( 1 );
136 mSuspend = 0; 136 mSuspend = 0;
137 confSuspend( 0 ); 137 confSuspend( 0 );
138 if ( QApplication::desktop()->width() < 480 ) { 138 if ( QApplication::desktop()->width() < 480 ) {
139 wavAlarm = false; 139 wavAlarm = false;
140 mSoundPopUp->setItemChecked ( 0, true ); 140 mSoundPopUp->setItemChecked ( 0, true );
141 } 141 }
142 else { 142 else {
143 wavAlarm = true; 143 wavAlarm = true;
144 mSoundPopUp->setItemChecked ( 1, true ); 144 mSoundPopUp->setItemChecked ( 1, true );
145 } 145 }
146 saveSlot( 1 ); 146 saveSlot( 1 );
147} 147}
148 148
149SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 149SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
150{ 150{
151 //delete mPopUp; 151 //delete mPopUp;
152 delete mAlarmDialog; 152 delete mAlarmDialog;
153} 153}
154void SimpleAlarmDaemonImpl::saveSlot( int load ) 154void SimpleAlarmDaemonImpl::saveSlot( int load )
155{ 155{
156 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 156 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
157 //qDebug("save %d ", load ); 157 //qDebug("save %d ", load );
158 QFile file( fileName ); 158 QFile file( fileName );
159 if ( load ) { 159 if ( load ) {
160 if( !QFile::exists( fileName) ) 160 if( !QFile::exists( fileName) )
161 return; 161 return;
162 if (!file.open( IO_ReadOnly ) ) { 162 if (!file.open( IO_ReadOnly ) ) {
163 return ; 163 return ;
164 } 164 }
165 QString line; 165 QString line;
166 bool ok; 166 bool ok;
167 int val; 167 int val;
168 int len; 168 int len;
169 while ( file.readLine( line, 1024 ) > 0 ) { 169 while ( file.readLine( line, 1024 ) > 0 ) {
170 //qDebug("read %s ", line.latin1()); 170 //qDebug("read %s ", line.latin1());
171 len = line.length(); 171 len = line.length();
172 if ( line.left(4 ) == "PPAU" ) { 172 if ( line.left(4 ) == "PPAU" ) {
173 val = line.mid( 4,len-5).toInt( &ok ); 173 val = line.mid( 4,len-5).toInt( &ok );
174 if ( ok ) { 174 if ( ok ) {
175 confPause( val ); 175 confPause( val );
176 } 176 }
177 } 177 }
178 if ( line.left(4 ) == "SUCO" ) { 178 if ( line.left(4 ) == "SUCO" ) {
179 val = line.mid( 4,len-5).toInt( &ok ); 179 val = line.mid( 4,len-5).toInt( &ok );
180 if ( ok ) 180 if ( ok )
181 confSuspend ( val ); 181 confSuspend ( val );
182 } 182 }
183 if ( line.left(4 ) == "WAAL" ) { 183 if ( line.left(4 ) == "WAAL" ) {
184 val = line.mid( 4,len-5).toInt( &ok ); 184 val = line.mid( 4,len-5).toInt( &ok );
185 if ( ok ) 185 if ( ok )
186 confSound( val ); 186 confSound( val );
187 187
188 } 188 }
189 if ( line.left(4 ) == "PLBE" ) { 189 if ( line.left(4 ) == "PLBE" ) {
190 val = line.mid( 4,len-5).toInt( &ok ); 190 val = line.mid( 4,len-5).toInt( &ok );
191 if ( ok ) 191 if ( ok )
192 slotPlayBeep( val ); 192 slotPlayBeep( val );
193 193
194 } 194 }
195 if ( line.left(4 ) == "CUTE" ) { 195 if ( line.left(4 ) == "CUTE" ) {
196 mCustomText = line.mid( 5,len-6); 196 mCustomText = line.mid( 5,len-6);
197 // qDebug("text ***%s*** ",mCustomText.latin1() ); 197 // qDebug("text ***%s*** ",mCustomText.latin1() );
198 198
199 } 199 }
200 if ( line.left(4 ) == "CUMI" ) { 200 if ( line.left(4 ) == "CUMI" ) {
201 val = line.mid( 4,len-5).toInt( &ok ); 201 val = line.mid( 4,len-5).toInt( &ok );
202 if ( ok ) 202 if ( ok )
203 mCustomMinutes = val; 203 mCustomMinutes = val;
204 204
205 } 205 }
206 if ( line.left(4 ) == "SUTI" ) { 206 if ( line.left(4 ) == "SUTI" ) {
207 val = line.mid( 4,len-5).toInt( &ok ); 207 val = line.mid( 4,len-5).toInt( &ok );
208 if ( ok ) 208 if ( ok )
209 mAlarmDialog->setSuspendTime( val );; 209 mAlarmDialog->setSuspendTime( val );;
210 210
211 } 211 }
212 } 212 }
213 file.close(); 213 file.close();
214 } else { 214 } else {
215 if (!file.open( IO_WriteOnly ) ) { 215 if (!file.open( IO_WriteOnly ) ) {
216 return; 216 return;
217 } 217 }
218 QString configString ; 218 QString configString ;
219 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 219 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
220 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 220 configString += "SUCO " + QString::number( mSuspend ) + "\n";
221 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 221 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
222 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 222 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
223 configString += "CUTE " + mCustomText + "\n"; 223 configString += "CUTE " + mCustomText + "\n";
224 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 224 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
225 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 225 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
226 QTextStream ts( &file ); 226 QTextStream ts( &file );
227 ts << configString ; 227 ts << configString ;
228 file.close(); 228 file.close();
229 } 229 }
230 230
231} 231}
232void SimpleAlarmDaemonImpl::confSuspend( int num ) 232void SimpleAlarmDaemonImpl::confSuspend( int num )
233{ 233{
234 mSuspendPopUp->setItemChecked ( mSuspend,false ); 234 mSuspendPopUp->setItemChecked ( mSuspend,false );
235 mSuspend = num; 235 mSuspend = num;
236 mSuspendPopUp->setItemChecked ( mSuspend,true ); 236 mSuspendPopUp->setItemChecked ( mSuspend,true );
237} 237}
238void SimpleAlarmDaemonImpl::confPause( int num ) 238void SimpleAlarmDaemonImpl::confPause( int num )
239{ 239{
240 mPausePopUp->setItemChecked ( mPausePlay,false ); 240 mPausePopUp->setItemChecked ( mPausePlay,false );
241 mPausePlay = num; 241 mPausePlay = num;
242 mPausePopUp->setItemChecked ( mPausePlay,true ); 242 mPausePopUp->setItemChecked ( mPausePlay,true );
243} 243}
244void SimpleAlarmDaemonImpl::confSound( int num ) 244void SimpleAlarmDaemonImpl::confSound( int num )
245{ 245{
246 if ( num == 0 ) { 246 if ( num == 0 ) {
247 wavAlarm = false; 247 wavAlarm = false;
248 mSoundPopUp->setItemChecked ( 0, true ); 248 mSoundPopUp->setItemChecked ( 0, true );
249 mSoundPopUp->setItemChecked ( 1, false ); 249 mSoundPopUp->setItemChecked ( 1, false );
250 } else { 250 } else {
251 wavAlarm = true; 251 wavAlarm = true;
252 mSoundPopUp->setItemChecked ( 0, false ); 252 mSoundPopUp->setItemChecked ( 0, false );
253 mSoundPopUp->setItemChecked ( 1, true ); 253 mSoundPopUp->setItemChecked ( 1, true );
254 } 254 }
255} 255}
256void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 256void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
257{ 257{
258 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 258 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
259 mPlayBeeps = num; 259 mPlayBeeps = num;
260 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 260 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
261} 261}
262 262
263void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 263void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
264{ 264{
265 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 265 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
266 QString mess = msg; 266 QString mess = msg;
267 mAlarmMessage = mess.mid( 9 ); 267 mAlarmMessage = mess.mid( 9 );
268 QString filename = getenv("QPEDIR") ; 268 QString filename = getenv("QPEDIR") ;
269 filename += "/pics/kdepim/korganizer/koalarm.wav"; 269 filename += "/pics/kdepim/korganizer/koalarm.wav";
270 QString tempfilename; 270 QString tempfilename;
271 if ( mess.left( 13 ) == "suspend_alarm") { 271 if ( mess.left( 13 ) == "suspend_alarm") {
272 bool error = false; 272 bool error = false;
273 int len = mess.mid( 13 ).find("+++"); 273 int len = mess.mid( 13 ).find("+++");
274 if ( len < 2 ) 274 if ( len < 2 )
275 error = true; 275 error = true;
276 else { 276 else {
277 tempfilename = mess.mid( 13, len ); 277 tempfilename = mess.mid( 13, len );
278 if ( !QFile::exists( tempfilename ) ) 278 if ( !QFile::exists( tempfilename ) )
279 error = true; 279 error = true;
280 } 280 }
281 if ( ! error ) { 281 if ( ! error ) {
282 filename = tempfilename; 282 filename = tempfilename;
283 } 283 }
284 mAlarmMessage = mess.mid( 13+len+3 ); 284 mAlarmMessage = mess.mid( 13+len+3 );
285 //qDebug("suspend file %s ",tempfilename.latin1() ); 285 //qDebug("suspend file %s ",tempfilename.latin1() );
286 startAlarm( mAlarmMessage, filename); 286 startAlarm( mAlarmMessage, filename);
287 return; 287 return;
288 } 288 }
289 if ( mess.left( 11 ) == "timer_alarm") { 289 if ( mess.left( 11 ) == "timer_alarm") {
290 mTimerTime = 0; 290 mTimerTime = 0;
291 startAlarm( mess.mid( 11 ), filename ); 291 startAlarm( mess.mid( 11 ), filename );
292 return; 292 return;
293 } 293 }
294 if ( mess.left( 10 ) == "proc_alarm") { 294 if ( mess.left( 10 ) == "proc_alarm") {
295 bool error = false; 295 bool error = false;
296 int len = mess.mid( 10 ).find("+++"); 296 int len = mess.mid( 10 ).find("+++");
297 if ( len < 2 ) 297 if ( len < 2 )
298 error = true; 298 error = true;
299 else { 299 else {
300 tempfilename = mess.mid( 10, len ); 300 tempfilename = mess.mid( 10, len );
301 if ( !QFile::exists( tempfilename ) ) 301 if ( !QFile::exists( tempfilename ) )
302 error = true; 302 error = true;
303 } 303 }
304 if ( error ) { 304 if ( error ) {
305 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 305 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
306 mAlarmMessage += mess.mid( 10+len+3+9 ); 306 mAlarmMessage += mess.mid( 10+len+3+9 );
307 } else { 307 } else {
308 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 308 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
309 //qDebug("-----system command %s ",tempfilename.latin1() ); 309 //qDebug("-----system command %s ",tempfilename.latin1() );
310 if ( vfork () == 0 ) { 310 if ( vfork () == 0 ) {
311 execl ( tempfilename.latin1(), 0 ); 311 execl ( tempfilename.latin1(), 0 );
312 return; 312 return;
313 } 313 }
314 return; 314 return;
315 } 315 }
316 316
317 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 317 //qDebug("+++++++system command %s ",tempfilename.latin1() );
318 } 318 }
319 if ( mess.left( 11 ) == "audio_alarm") { 319 if ( mess.left( 11 ) == "audio_alarm") {
320 bool error = false; 320 bool error = false;
321 int len = mess.mid( 11 ).find("+++"); 321 int len = mess.mid( 11 ).find("+++");
322 if ( len < 2 ) 322 if ( len < 2 )
323 error = true; 323 error = true;
324 else { 324 else {
325 tempfilename = mess.mid( 11, len ); 325 tempfilename = mess.mid( 11, len );
326 if ( !QFile::exists( tempfilename ) ) 326 if ( !QFile::exists( tempfilename ) )
327 error = true; 327 error = true;
328 } 328 }
329 if ( ! error ) { 329 if ( ! error ) {
330 filename = tempfilename; 330 filename = tempfilename;
331 } 331 }
332 mAlarmMessage = mess.mid( 11+len+3+9 ); 332 mAlarmMessage = mess.mid( 11+len+3+9 );
333 //qDebug("audio file command %s ",tempfilename.latin1() ); 333 //qDebug("audio file command %s ",tempfilename.latin1() );
334 } 334 }
335 if ( mess.left( 9 ) == "cal_alarm") { 335 if ( mess.left( 9 ) == "cal_alarm") {
336 mAlarmMessage = mess.mid( 9 ) ; 336 mAlarmMessage = mess.mid( 9 ) ;
337 } 337 }
338 338
339 writeFile(); 339 writeFile();
340 startAlarm( mAlarmMessage, filename ); 340 startAlarm( mAlarmMessage, filename );
341 341
342} 342}
343 343
344int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 344int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
345{ 345{
346 return 0; 346 return 0;
347} 347}
348void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 348void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
349{ 349{
350 //mAlarmDialog->show(); 350 //mAlarmDialog->show();
351 //mAlarmDialog->raise(); 351 //mAlarmDialog->raise();
352 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 352 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
353} 353}
354 354
355 355
356void SimpleAlarmDaemonImpl::fillTimerPopUp() 356void SimpleAlarmDaemonImpl::fillTimerPopUp()
357{ 357{
358 358
359 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 359 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
360 if ( mTimerPopupConf == mTimerTime ) { 360 if ( mTimerPopupConf == mTimerTime ) {
361 if ( mTimerTime ) { 361 if ( mTimerTime ) {
362 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 362 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
363 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 363 QTime t ( secs/3600, (secs/60)%60, secs%60 );
364 mTimerPopUp->changeItem ( 1 , t.toString() + " (remaining time)"); 364 mTimerPopUp->changeItem ( 1 , t.toString() + " (remaining time)");
365 } 365 }
366 else { 366 else {
367 QString text = mCustomText.stripWhiteSpace (); 367 QString text = mCustomText.stripWhiteSpace ();
368 int in = text.find( " " ); 368 int in = text.find( " " );
369 text = text.left ( in ); 369 text = text.left ( in );
370 mTimerPopUp->changeItem ( 3, text ); 370 mTimerPopUp->changeItem ( 3, text );
371 } 371 }
372 return; 372 return;
373 } 373 }
374 mTimerPopupConf = mTimerTime; 374 mTimerPopupConf = mTimerTime;
375 mTimerPopUp->clear(); 375 mTimerPopUp->clear();
376 if ( mTimerTime ) { 376 if ( mTimerTime ) {
377 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 377 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
378 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 378 QTime t ( secs/3600, (secs/60)%60, secs%60 );
379 379
380 380
381 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 381 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
382 mTimerPopUp->insertItem( t.toString() + " (remaining time)",1); 382 mTimerPopUp->insertItem( t.toString() + " (remaining time)",1);
383 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm time)",2); 383 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm time)",2);
384 } else { 384 } else {
385 385
386 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 386 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
387 QFile file( fileName ); 387 QFile file( fileName );
388 if( !QFile::exists( fileName) ) { 388 if( !QFile::exists( fileName) ) {
389 // write defaults 389 // write defaults
390 if (!file.open( IO_WriteOnly ) ) { 390 if (!file.open( IO_WriteOnly ) ) {
391 return; 391 return;
392 } 392 }
393 QString configString ; 393 QString configString ;
394 configString += "#config file for kopi alarm timer\n"; 394 configString += "#config file for kopi alarm timer\n";
395 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 395 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
396 configString += "#NOTE: minimum value for timer are 3 minutes!\n"; 396 configString += "#NOTE: minimum value for timer are 3 minutes!\n";
397 configString += "24 h; 1440\n"; 397 configString += "24 h; 1440\n";
398 configString += " 8 h; 480\n"; 398 configString += " 8 h; 480\n";
399 configString += " 5 h; 300\n"; 399 configString += " 5 h; 300\n";
400 configString += " 1 h; 60\n"; 400 configString += " 1 h; 60\n";
401 configString += "30 min; 30\n"; 401 configString += "30 min; 30\n";
402 configString += "15 min; 15\n"; 402 configString += "15 min; 15\n";
403 configString += "SEPARATOR\n"; 403 configString += "SEPARATOR\n";
404 configString += "Pizza; 22\n"; 404 configString += "Pizza; 22\n";
405 configString += "Nap; 45\n"; 405 configString += "Nap; 45\n";
406 configString += "Tea; 5\n"; 406 configString += "Tea; 5\n";
407 QTextStream ts( &file ); 407 QTextStream ts( &file );
408 ts << configString ; 408 ts << configString ;
409 file.close(); 409 file.close();
410 } 410 }
411 411
412 if (!file.open( IO_ReadOnly ) ) { 412 if (!file.open( IO_ReadOnly ) ) {
413 return ; 413 return ;
414 } 414 }
415 QString line; 415 QString line;
416 bool ok; 416 bool ok;
417 while ( file.readLine( line, 1024 ) > 0 ) { 417 while ( file.readLine( line, 1024 ) > 0 ) {
418 //qDebug("read %s ", line.latin1()); 418 //qDebug("read %s ", line.latin1());
419 if ( line.left(1 ) != "#" ) { 419 if ( line.left(1 ) != "#" ) {
420 // no comment 420 // no comment
421 if ( line.left(9 ) == "SEPARATOR" ) { 421 if ( line.left(9 ) == "SEPARATOR" ) {
422 mTimerPopUp->insertSeparator(); 422 mTimerPopUp->insertSeparator();
423 } else { 423 } else {
424 QStringList li = QStringList::split(";",line); 424 QStringList li = QStringList::split(";",line);
425 ok = false; 425 ok = false;
426 if ( li.count() == 2 ) { 426 if ( li.count() == 2 ) {
427 int val = li[1].toInt( &ok ); 427 int val = li[1].toInt( &ok );
428 if ( ok && val > 2 ) { 428 if ( ok && val > 2 ) {
429 mTimerPopUp->insertItem( li[0], val); 429 mTimerPopUp->insertItem( li[0], val);
430 } 430 }
431 } 431 }
432 } 432 }
433 } 433 }
434 } 434 }
435 file.close(); 435 file.close();
436#if 0 436#if 0
437 mTimerPopUp->insertItem( "24 h", 1440 ); 437 mTimerPopUp->insertItem( "24 h", 1440 );
438 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 438 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
439 mTimerPopUp->insertItem( " 8 h", 480 ); 439 mTimerPopUp->insertItem( " 8 h", 480 );
440 mTimerPopUp->insertItem( " 5 h", 300 ); 440 mTimerPopUp->insertItem( " 5 h", 300 );
441 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 441 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
442 mTimerPopUp->insertItem( " 1 h", 60 ); 442 mTimerPopUp->insertItem( " 1 h", 60 );
443 mTimerPopUp->insertItem( "30 min", 30 ); 443 mTimerPopUp->insertItem( "30 min", 30 );
444 mTimerPopUp->insertItem( "15 min", 15 ); 444 mTimerPopUp->insertItem( "15 min", 15 );
445 mTimerPopUp->insertItem( "10 min", 10 ); 445 mTimerPopUp->insertItem( "10 min", 10 );
446 //mTimerPopUp->insertItem( " 5 min", 5 ); 446 //mTimerPopUp->insertItem( " 5 min", 5 );
447 mTimerPopUp->insertSeparator(); 447 mTimerPopUp->insertSeparator();
448 mTimerPopUp->insertItem( "Pizza", 22 ); 448 mTimerPopUp->insertItem( "Pizza", 22 );
449 mTimerPopUp->insertItem( "Nap", 45 ); 449 mTimerPopUp->insertItem( "Nap", 45 );
450 mTimerPopUp->insertItem( "Tea", 5 ); 450 mTimerPopUp->insertItem( "Tea", 5 );
451#endif 451#endif
452 QString text = mCustomText.stripWhiteSpace (); 452 QString text = mCustomText.stripWhiteSpace ();
453 int in = text.find( " " ); 453 int in = text.find( " " );
454 text = text.left ( in ); 454 text = text.left ( in );
455 mTimerPopUp->insertItem( text, 3 ); 455 mTimerPopUp->insertItem( text, 3 );
456 mTimerPopUp->insertSeparator(); 456 mTimerPopUp->insertSeparator();
457 mTimerPopUp->insertItem( "Customize", 2 ); 457 mTimerPopUp->insertItem( "Customize", 2 );
458 } 458 }
459 459
460} 460}
461 461
462void SimpleAlarmDaemonImpl::showTimer() 462void SimpleAlarmDaemonImpl::showTimer()
463{ 463{
464 fillTimerPopUp(); 464 fillTimerPopUp();
465} 465}
466 466
467void SimpleAlarmDaemonImpl::confTimer( int time ) 467void SimpleAlarmDaemonImpl::confTimer( int time )
468{ 468{
469 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 469 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
470 int minutes = time; 470 int minutes = time;
471 if ( minutes == 0 ) { 471 if ( minutes == 0 ) {
472 if ( ! mTimerTime ) 472 if ( ! mTimerTime )
473 return; 473 return;
474 474
475 QDialog dia ( 0, ("Stop Timer" ), true ); 475 QDialog dia ( 0, ("Stop Timer" ), true );
476 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 476 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
477 lab.setAlignment( AlignCenter ); 477 lab.setAlignment( AlignCenter );
478 dia.setCaption(("KO/Pi Timer Stop" )); 478 dia.setCaption(("KO/Pi Timer Stop" ));
479 QVBoxLayout lay( &dia ); 479 QVBoxLayout lay( &dia );
480 lay.addWidget( &lab); 480 lay.addWidget( &lab);
481 QPushButton ok ( "Stop timer!", &dia); 481 QPushButton ok ( "Stop timer!", &dia);
482 QFont fo = dia.font(); 482 QFont fo = dia.font();
483 fo.setPointSize( 36 ); 483 fo.setPointSize( 36 );
484 ok.setFont( fo ); 484 ok.setFont( fo );
485 lay.addWidget( &ok); 485 lay.addWidget( &ok);
486 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 486 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
487 QPushButton con ( "Continue timer!", &dia); 487 QPushButton con ( "Continue timer!", &dia);
488 fo.setPointSize( 36 ); 488 fo.setPointSize( 36 );
489 con.setFont( fo ); 489 con.setFont( fo );
490 lay.addWidget( &con); 490 lay.addWidget( &con);
491 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 491 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
492 lay.setMargin(5); 492 lay.setMargin(5);
493 lay.setSpacing(5); 493 lay.setSpacing(5);
494 dia.resize(dia.sizeHint() ); 494 dia.resize(dia.sizeHint() );
495 495
496 if ( !dia.exec() ) 496 if ( !dia.exec() )
497 return; 497 return;
498 498
499 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); 499 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() );
500 mTimerTime = 0; 500 mTimerTime = 0;
501 return; 501 return;
502 } 502 }
503 if ( mTimerTime ) 503 if ( mTimerTime )
504 return; 504 return;
505 if ( minutes == 1 ) { 505 if ( minutes == 1 ) {
506 return; 506 return;
507 } 507 }
508 QString mess = "timer_alarm"; 508 QString mess = "timer_alarm";
509 mess += ("Timer Alarm!\n"); 509 mess += ("Timer Alarm!\n");
510 if ( minutes == 22 ) { 510 if ( minutes == 22 ) {
511 mess += ( "Pizza is ready"); 511 mess += ( "Pizza is ready");
512 mRunningTimerText = "Pizza"; 512 mRunningTimerText = "Pizza";
513 } 513 }
514 else if ( minutes == 45 ) { 514 else if ( minutes == 45 ) {
515 mess += ( "Please wake up!"); 515 mess += ( "Please wake up!");
516 mRunningTimerText = "Nap"; 516 mRunningTimerText = "Nap";
517 } 517 }
518 else if ( minutes == 5 ) { 518 else if ( minutes == 5 ) {
519 mess += ( "Tea is ready"); 519 mess += ( "Tea is ready");
520 mRunningTimerText = "Tea"; 520 mRunningTimerText = "Tea";
521 } 521 }
522 else if ( minutes == 3 ) { 522 else if ( minutes == 3 ) {
523 mess += mCustomText; 523 mess += mCustomText;
524 minutes = mCustomMinutes ; 524 minutes = mCustomMinutes ;
525 mRunningTimerText = mCustomText.stripWhiteSpace (); 525 mRunningTimerText = mCustomText.stripWhiteSpace ();
526 int in = mRunningTimerText.find( " " ); 526 int in = mRunningTimerText.find( " " );
527 mRunningTimerText = mRunningTimerText.left ( in ); 527 mRunningTimerText = mRunningTimerText.left ( in );
528 } 528 }
529 else { 529 else {
530 if ( minutes == 2 ) { 530 if ( minutes == 2 ) {
531 // ask time 531 // ask time
532 QDialog dia ( 0, ("Customize Timer" ), true ); 532 QDialog dia ( 0, ("Customize Timer" ), true );
533 QLabel lab (("Message Text:"), &dia ); 533 QLabel lab (("Message Text:"), &dia );
534 dia.setCaption(("KO/Pi Timer" )); 534 dia.setCaption(("KO/Pi Timer" ));
535 QVBoxLayout lay( &dia ); 535 QVBoxLayout lay( &dia );
536 lay.setMargin(5); 536 lay.setMargin(5);
537 lay.setSpacing(5); 537 lay.setSpacing(5);
538 lay.addWidget( &lab); 538 lay.addWidget( &lab);
539 QLineEdit lEdit( mCustomText, &dia ); 539 QLineEdit lEdit( mCustomText, &dia );
540 lay.addWidget( &lEdit); 540 lay.addWidget( &lEdit);
541 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 541 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
542 lay.addWidget( &lab2); 542 lay.addWidget( &lab2);
543 QHBox hbox1 ( &dia ); 543 QHBox hbox1 ( &dia );
544 lay.addWidget( &hbox1); 544 lay.addWidget( &hbox1);
545 QLabel lab3 (("Hours"), &hbox1 ); 545 QLabel lab3 (("Hours"), &hbox1 );
546 QLabel lab4 (("Minutes"), &hbox1 ); 546 QLabel lab4 (("Minutes"), &hbox1 );
547 QHBox hbox ( &dia ); 547 QHBox hbox ( &dia );
548 QSpinBox spinh( 0, 24, 1,& hbox ); 548 QSpinBox spinh( 0, 24, 1,& hbox );
549 QFont fo = dia.font(); 549 QFont fo = dia.font();
550 fo.setPointSize( 36 ); 550 fo.setPointSize( 36 );
551 QSpinBox spinm( 0, 59, 1,&hbox ); 551 QSpinBox spinm( 0, 59, 1,&hbox );
552 spinm.setFont( fo ); 552 spinm.setFont( fo );
553 spinh.setFont( fo ); 553 spinh.setFont( fo );
554 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 554 spinh.setButtonSymbols( QSpinBox::PlusMinus );
555 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 555 spinm.setButtonSymbols( QSpinBox::PlusMinus );
556 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 556 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
557 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 557 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
558 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 558 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
559 spinh.setFixedSize( 100,62 ); 559 spinh.setFixedSize( 100,62 );
560 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 560 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
561 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 561 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
562 spinm.downButton ()->setGeometry( 50,50,50,50); 562 spinm.downButton ()->setGeometry( 50,50,50,50);
563 spinm.setSuffix( " m" ); 563 spinm.setSuffix( " m" );
564 spinh.setSuffix( " h" ); 564 spinh.setSuffix( " h" );
565 spinm.setWrapping ( true ); 565 spinm.setWrapping ( true );
566 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 566 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
567 spinm.setLineStep( 1 ); 567 spinm.setLineStep( 1 );
568 spinm.setFixedSize( 110,62 ); 568 spinm.setFixedSize( 110,62 );
569 lay.addWidget( &hbox); 569 lay.addWidget( &hbox);
570 QLabel lab5 ("Timer fires at:", &dia ); 570 QLabel lab5 ("Timer fires at:", &dia );
571 lab5.setAlignment( AlignCenter ); 571 lab5.setAlignment( AlignCenter );
572 lay.addWidget( &lab5); 572 lay.addWidget( &lab5);
573 KODateLabel dl ( &dia ); 573 KODateLabel dl ( &dia );
574 dl.setAlignment( AlignCenter ); 574 dl.setAlignment( AlignCenter );
575 dl.setFont( fo ); 575 dl.setFont( fo );
576 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 576 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
577 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 577 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
578 lay.addWidget( &dl); 578 lay.addWidget( &dl);
579 spinh.setValue( mCustomMinutes/60 ); 579 spinh.setValue( mCustomMinutes/60 );
580 spinm.setValue( mCustomMinutes%60 ); 580 spinm.setValue( mCustomMinutes%60 );
581 QPushButton ok ( "Start timer", &dia); 581 QPushButton ok ( "Start timer", &dia);
582 ok.setFont( fo ); 582 ok.setFont( fo );
583 lay.addWidget( &ok); 583 lay.addWidget( &ok);
584 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 584 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
585 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 585 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
586 586
587 if ( !dia.exec() ) 587 if ( !dia.exec() )
588 return; 588 return;
589 mCustomText = lEdit.text(); 589 mCustomText = lEdit.text();
590 mCustomMinutes = spinh.value()*60+spinm.value(); 590 mCustomMinutes = spinh.value()*60+spinm.value();
591 if ( mCustomMinutes == 0 ) 591 if ( mCustomMinutes == 0 )
592 mCustomMinutes = 1; 592 mCustomMinutes = 1;
593 if ( mCustomMinutes > 1440 ) 593 if ( mCustomMinutes > 1440 )
594 mCustomMinutes = 1440; 594 mCustomMinutes = 1440;
595 mess += mCustomText; 595 mess += mCustomText;
596 minutes = mCustomMinutes; 596 minutes = mCustomMinutes;
597 mRunningTimerText = mCustomText.stripWhiteSpace (); 597 mRunningTimerText = mCustomText.stripWhiteSpace ();
598 int in = mRunningTimerText.find( " " ); 598 int in = mRunningTimerText.find( " " );
599 mRunningTimerText = mRunningTimerText.left ( in ); 599 mRunningTimerText = mRunningTimerText.left ( in );
600 } 600 }
601 else { 601 else {
602 mess+= QString::number ( minutes ) + ( " minutes are past!"); 602 mess+= QString::number ( minutes ) + ( " minutes are past!");
603 int min = minutes; 603 int min = minutes;
604 if ( min % 60 == 0 ) 604 if ( min % 60 == 0 )
605 mRunningTimerText = QString::number ( min/60 ) + ( " hours"); 605 mRunningTimerText = QString::number ( min/60 ) + ( " hours");
606 else 606 else
607 mRunningTimerText = QString::number ( minutes ) + ( " minutes"); 607 mRunningTimerText = QString::number ( minutes ) + ( " minutes");
608 } 608 }
609 } 609 }
610 //minutes = 1; 610 //minutes = 1;
611 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 611 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
612 timerMesssage = mess; 612 timerMesssage = mess;
613 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 613 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
614 mTimerTime = 1; 614 mTimerTime = 1;
615} 615}
616 616
617void SimpleAlarmDaemonImpl::writeFile() 617void SimpleAlarmDaemonImpl::writeFile()
618{ 618{
619 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 619 QCopEnvelope e("QPE/Application/kopi", "-writeFile");
620} 620}
621void SimpleAlarmDaemonImpl::showWN() 621void SimpleAlarmDaemonImpl::showWN()
622{ 622{
623 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 623 QCopEnvelope e("QPE/Application/kopi", "-showWN");
624} 624}
625void SimpleAlarmDaemonImpl::newTodo() 625void SimpleAlarmDaemonImpl::newTodo()
626{ 626{
627 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 627 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
628} 628}
629 629
630void SimpleAlarmDaemonImpl::newEvent() 630void SimpleAlarmDaemonImpl::newEvent()
631{ 631{
632 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 632 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
633 633
634} 634}
635void SimpleAlarmDaemonImpl::newMail() 635void SimpleAlarmDaemonImpl::newMail()
636{ 636{
637 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 637 QCopEnvelope e("QPE/Application/ompi", "newMail()");
638} 638}
639void SimpleAlarmDaemonImpl::showAdd() 639void SimpleAlarmDaemonImpl::showAdd()
640{ 640{
641 QCopEnvelope e("QPE/Application/kapi", "raise()"); 641 QCopEnvelope e("QPE/Application/kapi", "raise()");
642} 642}
643void SimpleAlarmDaemonImpl::ringSync() 643void SimpleAlarmDaemonImpl::ringSync()
644{ 644{
645 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 645 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
646 646
647} 647}
648void SimpleAlarmDaemonImpl::newCountdown() 648void SimpleAlarmDaemonImpl::newCountdown()
649{ 649{
650 //recieve("cal_alarm", 10 ); 650 //recieve("cal_alarm", 10 );
651} 651}
652void SimpleAlarmDaemonImpl::simulate() 652void SimpleAlarmDaemonImpl::simulate()
653{ 653{
654 writeFile(); 654 writeFile();
655 QString filename = getenv("QPEDIR") ; 655 QString filename = getenv("QPEDIR") ;
656 filename += "/pics/kdepim/korganizer/koalarm.wav"; 656 filename += "/pics/kdepim/korganizer/koalarm.wav";
657 startAlarm("Alarm simulation", filename ); 657 startAlarm("Alarm simulation", filename );
658} 658}
659void SimpleAlarmDaemonImpl::showKO() 659void SimpleAlarmDaemonImpl::showKO()
660{ 660{
661 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 661 QCopEnvelope e("QPE/Application/kopi", "-showKO");
662 // testing only
663 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
662 664
663} 665}
664void SimpleAlarmDaemonImpl::showTodo() 666void SimpleAlarmDaemonImpl::showTodo()
665{ 667{
666 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 668 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
667 669
668} 670}
669void SimpleAlarmDaemonImpl::writeJournal() 671void SimpleAlarmDaemonImpl::writeJournal()
670{ 672{
671 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 673 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
672 674
673} 675}
674 676
675void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 677void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
676{ 678{
677 679
678 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 680 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
679 681
680} 682}
681 683
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index a32333c..fa6b951 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1573 +1,1575 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 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 <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 mRows = rows; 84 mRows = rows;
85 85
86 setMinimumHeight( 20 ); 86 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 87 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 88
89 enableClipper(true); 89 enableClipper(true);
90 90
91 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
93 93
94 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
95 95
96 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
97} 97}
98 98
99void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
100{ 100{
101 mCellHeight = height; 101 mCellHeight = height;
102} 102}
103 103
104/* 104/*
105 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 109{
110 110
111 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
112 // return; 112 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 115 // code assumes the latter...
116 116
117 // now, for a workaround... 117 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 119 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
121 // end of workaround 121 // end of workaround
122 122
123 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
126 QString hour; 126 QString hour;
127 QString suffix; 127 QString suffix;
128 QString fullTime; 128 QString fullTime;
129 int tW = fm.width("24:00i"); 129 int tW = fm.width("24:00i");
130 int timeHeight = fm.height(); 130 int timeHeight = fm.height();
131 timeHeight -= (timeHeight/4-2); 131 timeHeight -= (timeHeight/4-2);
132 int borderWidth = 0; 132 int borderWidth = 0;
133 QFont nFont = p->font(); 133 QFont nFont = p->font();
134 QFont sFont = nFont; 134 QFont sFont = nFont;
135 sFont.setPointSize( sFont.pointSize()/2+2 ); 135 sFont.setPointSize( sFont.pointSize()/2+2 );
136 if (!KGlobal::locale()->use12Clock()) 136 if (!KGlobal::locale()->use12Clock())
137 suffix = "00"; 137 suffix = "00";
138 else 138 else
139 borderWidth = 0; 139 borderWidth = 0;
140 QFontMetrics fmS( sFont ); 140 QFontMetrics fmS( sFont );
141 int sHei = fmS.height(); 141 int sHei = fmS.height();
142 if ( timeHeight > mCellHeight ) { 142 if ( timeHeight > mCellHeight ) {
143 timeHeight = mCellHeight-1; 143 timeHeight = mCellHeight-1;
144 sHei -= 2; 144 sHei -= 2;
145 } 145 }
146 146
147 while (y < cy + ch) { 147 while (y < cy + ch) {
148 p->drawLine(cx,y,cx+tW,y); 148 p->drawLine(cx,y,cx+tW,y);
149 hour.setNum(cell); 149 hour.setNum(cell);
150 150
151 // handle 24h and am/pm time formats 151 // handle 24h and am/pm time formats
152 if (KGlobal::locale()->use12Clock()) { 152 if (KGlobal::locale()->use12Clock()) {
153 if (cell > 11) suffix = "pm"; 153 if (cell > 11) suffix = "pm";
154 else 154 else
155 suffix = "am"; 155 suffix = "am";
156 if (cell == 0) hour.setNum(12); 156 if (cell == 0) hour.setNum(12);
157 if (cell > 12) hour.setNum(cell - 12); 157 if (cell > 12) hour.setNum(cell - 12);
158 } 158 }
159 159
160 // create string in format of "XX:XX" or "XXpm/am" 160 // create string in format of "XX:XX" or "XXpm/am"
161 fullTime = hour;// + suffix; 161 fullTime = hour;// + suffix;
162 162
163 // center and draw the time label 163 // center and draw the time label
164 int timeWidth = fm.width(fullTime+"i"); 164 int timeWidth = fm.width(fullTime+"i");
165 int tw2 = fm.width(suffix); 165 int tw2 = fm.width(suffix);
166 int offset = this->width() - timeWidth - tw2; 166 int offset = this->width() - timeWidth - tw2;
167 p->setFont( nFont ); 167 p->setFont( nFont );
168 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); 168 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime);
169 p->setFont( sFont ); 169 p->setFont( sFont );
170 offset += timeWidth; 170 offset += timeWidth;
171 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 171 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
172 172
173 // increment indices 173 // increment indices
174 y += mCellHeight; 174 y += mCellHeight;
175 cell++; 175 cell++;
176 } 176 }
177} 177}
178 178
179/** 179/**
180 Calculates the minimum width. 180 Calculates the minimum width.
181*/ 181*/
182int TimeLabels::minimumWidth() const 182int TimeLabels::minimumWidth() const
183{ 183{
184 return mMiniWidth; 184 return mMiniWidth;
185} 185}
186 186
187/** updates widget's internal state */ 187/** updates widget's internal state */
188void TimeLabels::updateConfig() 188void TimeLabels::updateConfig()
189{ 189{
190 // set the font 190 // set the font
191 // config->setGroup("Fonts"); 191 // config->setGroup("Fonts");
192 // QFont font = config->readFontEntry("TimeBar Font"); 192 // QFont font = config->readFontEntry("TimeBar Font");
193 setFont(KOPrefs::instance()->mTimeBarFont); 193 setFont(KOPrefs::instance()->mTimeBarFont);
194 mMiniWidth = fontMetrics().width("88:88") + 2 ; 194 mMiniWidth = fontMetrics().width("88:88") + 2 ;
195 // update geometry restrictions based on new settings 195 // update geometry restrictions based on new settings
196 setFixedWidth(minimumWidth()); 196 setFixedWidth(minimumWidth());
197 197
198 // update HourSize 198 // update HourSize
199 mCellHeight = KOPrefs::instance()->mHourSize*4; 199 mCellHeight = KOPrefs::instance()->mHourSize*4;
200 resizeContents(50,mRows * mCellHeight); 200 resizeContents(50,mRows * mCellHeight);
201} 201}
202 202
203/** update time label positions */ 203/** update time label positions */
204void TimeLabels::positionChanged() 204void TimeLabels::positionChanged()
205{ 205{
206 int adjustment = mAgenda->contentsY(); 206 int adjustment = mAgenda->contentsY();
207 setContentsPos(0, adjustment); 207 setContentsPos(0, adjustment);
208} 208}
209 209
210/** */ 210/** */
211void TimeLabels::setAgenda(KOAgenda* agenda) 211void TimeLabels::setAgenda(KOAgenda* agenda)
212{ 212{
213 mAgenda = agenda; 213 mAgenda = agenda;
214} 214}
215 215
216void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 216void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
217{ 217{
218 mMouseDownY = e->pos().y(); 218 mMouseDownY = e->pos().y();
219 mOrgCap = topLevelWidget()->caption(); 219 mOrgCap = topLevelWidget()->caption();
220} 220}
221 221
222void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 222void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
223{ 223{
224 int diff = mMouseDownY - e->pos().y(); 224 int diff = mMouseDownY - e->pos().y();
225 if ( diff < 10 && diff > -10 ) 225 if ( diff < 10 && diff > -10 )
226 return; 226 return;
227 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 227 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
228 if ( tSize < 4 ) 228 if ( tSize < 4 )
229 tSize = 4; 229 tSize = 4;
230 if ( tSize > 22 ) 230 if ( tSize > 22 )
231 tSize = 22; 231 tSize = 22;
232 tSize = (tSize-2)/2; 232 tSize = (tSize-2)/2;
233 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 233 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
234 234
235} 235}
236void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 236void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
237{ 237{
238 topLevelWidget()->setCaption( mOrgCap ); 238 topLevelWidget()->setCaption( mOrgCap );
239 int diff = mMouseDownY - e->pos().y(); 239 int diff = mMouseDownY - e->pos().y();
240 if ( diff < 10 && diff > -10 ) 240 if ( diff < 10 && diff > -10 )
241 return; 241 return;
242 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 242 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
243 if ( tSize < 4 ) 243 if ( tSize < 4 )
244 tSize = 4; 244 tSize = 4;
245 if ( tSize > 22 ) 245 if ( tSize > 22 )
246 tSize = 22; 246 tSize = 22;
247 tSize = (tSize/2)*2; 247 tSize = (tSize/2)*2;
248 if ( tSize == KOPrefs::instance()->mHourSize ) 248 if ( tSize == KOPrefs::instance()->mHourSize )
249 return; 249 return;
250 KOPrefs::instance()->mHourSize = tSize; 250 KOPrefs::instance()->mHourSize = tSize;
251 emit scaleChanged(); 251 emit scaleChanged();
252} 252}
253 253
254/** This is called in response to repaint() */ 254/** This is called in response to repaint() */
255void TimeLabels::paintEvent(QPaintEvent*) 255void TimeLabels::paintEvent(QPaintEvent*)
256{ 256{
257 257
258 // kdDebug() << "paintevent..." << endl; 258 // kdDebug() << "paintevent..." << endl;
259 // this is another hack! 259 // this is another hack!
260 // QPainter painter(this); 260 // QPainter painter(this);
261 //QString c 261 //QString c
262 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 262 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
263} 263}
264 264
265//////////////////////////////////////////////////////////////////////////// 265////////////////////////////////////////////////////////////////////////////
266 266
267EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 267EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
268 : QFrame(parent,name) 268 : QFrame(parent,name)
269{ 269{
270 mColumns = 1; 270 mColumns = 1;
271 mTopBox = 0; 271 mTopBox = 0;
272 mLocation = loc; 272 mLocation = loc;
273 mTopLayout = 0; 273 mTopLayout = 0;
274 mPaintWidget = 0; 274 mPaintWidget = 0;
275 mXOffset = 0; 275 mXOffset = 0;
276 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 276 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
277 else mPixmap = SmallIcon("1downarrow"); 277 else mPixmap = SmallIcon("1downarrow");
278 mEnabled.resize(mColumns); 278 mEnabled.resize(mColumns);
279 mEnabled.fill( false ); 279 mEnabled.fill( false );
280 setMinimumHeight(mPixmap.height()); 280 setMinimumHeight(mPixmap.height());
281} 281}
282 282
283EventIndicator::~EventIndicator() 283EventIndicator::~EventIndicator()
284{ 284{
285} 285}
286 286
287void EventIndicator::drawContents(QPainter *p) 287void EventIndicator::drawContents(QPainter *p)
288{ 288{
289 289
290 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 290 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
291 KDGanttSplitterHandle* han = 0; 291 KDGanttSplitterHandle* han = 0;
292 if ( mPaintWidget ) 292 if ( mPaintWidget )
293 han = mPaintWidget->firstHandle(); 293 han = mPaintWidget->firstHandle();
294 if ( ! han ) { 294 if ( ! han ) {
295 int i; 295 int i;
296 for(i=0;i<mColumns;++i) { 296 for(i=0;i<mColumns;++i) {
297 if (mEnabled[i]) { 297 if (mEnabled[i]) {
298 int cellWidth = contentsRect().right()/mColumns; 298 int cellWidth = contentsRect().right()/mColumns;
299 int xOffset = KOGlobals::self()->reverseLayout() ? 299 int xOffset = KOGlobals::self()->reverseLayout() ?
300 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 300 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
301 i*cellWidth + (cellWidth -mPixmap.width()) /2; 301 i*cellWidth + (cellWidth -mPixmap.width()) /2;
302 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 302 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
303 } 303 }
304 } 304 }
305 } else { 305 } else {
306 han->repaint(); 306 han->repaint();
307 //mPaintWidget->setBackgroundColor( red ); 307 //mPaintWidget->setBackgroundColor( red );
308 308
309 QPainter pa( han ); 309 QPainter pa( han );
310 int i; 310 int i;
311 bool setColor = false; 311 bool setColor = false;
312 for(i=0;i<mColumns;++i) { 312 for(i=0;i<mColumns;++i) {
313 if (mEnabled[i]) { 313 if (mEnabled[i]) {
314 setColor = true; 314 setColor = true;
315 315
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 318 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
319 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 319 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
320 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 320 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
321 //qDebug("222draw pix %d ",xOffset ); 321 //qDebug("222draw pix %d ",xOffset );
322 322
323 } 323 }
324 324
325 } 325 }
326 pa.end(); 326 pa.end();
327 327
328 } 328 }
329} 329}
330 330
331void EventIndicator::setXOffset( int x ) 331void EventIndicator::setXOffset( int x )
332{ 332{
333 mXOffset = x; 333 mXOffset = x;
334} 334}
335void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 335void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
336{ 336{
337 mPaintWidget = w; 337 mPaintWidget = w;
338 setMaximumHeight(0); 338 setMaximumHeight(0);
339 setMinimumHeight(0); 339 setMinimumHeight(0);
340} 340}
341void EventIndicator::changeColumns(int columns) 341void EventIndicator::changeColumns(int columns)
342{ 342{
343 mColumns = columns; 343 mColumns = columns;
344 mEnabled.resize(mColumns); 344 mEnabled.resize(mColumns);
345 345
346 update(); 346 update();
347} 347}
348 348
349void EventIndicator::enableColumn(int column, bool enable) 349void EventIndicator::enableColumn(int column, bool enable)
350{ 350{
351 mEnabled[column] = enable; 351 mEnabled[column] = enable;
352} 352}
353 353
354 354
355//////////////////////////////////////////////////////////////////////////// 355////////////////////////////////////////////////////////////////////////////
356//////////////////////////////////////////////////////////////////////////// 356////////////////////////////////////////////////////////////////////////////
357//////////////////////////////////////////////////////////////////////////// 357////////////////////////////////////////////////////////////////////////////
358 358
359KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 359KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
360 KOEventView (cal,parent,name) 360 KOEventView (cal,parent,name)
361{ 361{
362 mBlockUpdating = true; 362 mBlockUpdating = true;
363 mStartHour = 8; 363 mStartHour = 8;
364 mSelectedDates.append(QDate::currentDate()); 364 mSelectedDates.append(QDate::currentDate());
365 365
366 mLayoutDayLabels = 0; 366 mLayoutDayLabels = 0;
367 mDayLabelsFrame = 0; 367 mDayLabelsFrame = 0;
368 mDayLabels = 0; 368 mDayLabels = 0;
369 bool isRTL = KOGlobals::self()->reverseLayout(); 369 bool isRTL = KOGlobals::self()->reverseLayout();
370 QPixmap expandPix; 370 QPixmap expandPix;
371 if ( KOPrefs::instance()->mVerticalScreen ) { 371 if ( KOPrefs::instance()->mVerticalScreen ) {
372 expandPix = SmallIcon( "1updownarrow" ); 372 expandPix = SmallIcon( "1updownarrow" );
373 } else { 373 } else {
374 expandPix = SmallIcon("1leftrightarrow" ); 374 expandPix = SmallIcon("1leftrightarrow" );
375 } 375 }
376 376
377 QBoxLayout *topLayout = new QVBoxLayout(this); 377 QBoxLayout *topLayout = new QVBoxLayout(this);
378 378
379 // Create day name labels for agenda columns 379 // Create day name labels for agenda columns
380 // Create agenda splitter 380 // Create agenda splitter
381 381
382 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 382 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
383 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 383 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
384 topLayout->addWidget( mSplitterAgenda ); 384 topLayout->addWidget( mSplitterAgenda );
385 mAllDayFrame = new QHBox(mSplitterAgenda); 385 mAllDayFrame = new QHBox(mSplitterAgenda);
386 mAllDayFrame->setFocusPolicy(NoFocus); 386 mAllDayFrame->setFocusPolicy(NoFocus);
387 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 387 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
388 agendaFrame->setFocusPolicy(NoFocus); 388 agendaFrame->setFocusPolicy(NoFocus);
389 389
390 // Create all-day agenda widget 390 // Create all-day agenda widget
391 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 391 mDummyAllDayLeft = new QVBox( mAllDayFrame );
392 392
393 mExpandButton = new QPushButton(mDummyAllDayLeft); 393 mExpandButton = new QPushButton(mDummyAllDayLeft);
394 mExpandButton->setPixmap( expandPix ); 394 mExpandButton->setPixmap( expandPix );
395 int widebut = mExpandButton->sizeHint().width()+4; 395 int widebut = mExpandButton->sizeHint().width()+4;
396 int heibut = mExpandButton->sizeHint().height()+4; 396 int heibut = mExpandButton->sizeHint().height()+4;
397 if ( heibut > widebut ) 397 if ( heibut > widebut )
398 widebut = heibut ; 398 widebut = heibut ;
399 if ( QApplication::desktop()->width() < 480 ) 399 if ( QApplication::desktop()->width() < 480 )
400 widebut = widebut*3/2; 400 widebut = widebut*3/2;
401 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 401 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
402 // QSizePolicy::Fixed ) ); 402 // QSizePolicy::Fixed ) );
403 mExpandButton->setFixedSize( widebut, widebut); 403 mExpandButton->setFixedSize( widebut, widebut);
404 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 404 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
405 mExpandButton->setFocusPolicy(NoFocus); 405 mExpandButton->setFocusPolicy(NoFocus);
406 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 406 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
407 mAllDayAgenda->setFocusPolicy(NoFocus); 407 mAllDayAgenda->setFocusPolicy(NoFocus);
408 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 408 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
409 409
410 // Create event context menu for all day agenda 410 // Create event context menu for all day agenda
411 mAllDayAgendaPopup = eventPopup(); 411 mAllDayAgendaPopup = eventPopup();
412 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 412 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
413 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 413 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
414 414
415 // Create agenda frame 415 // Create agenda frame
416 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 416 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
417 // QHBox *agendaFrame = new QHBox(splitterAgenda); 417 // QHBox *agendaFrame = new QHBox(splitterAgenda);
418 418
419 // create event indicator bars 419 // create event indicator bars
420 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 420 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
421#ifndef DESKTOP_VERSION 421#ifndef DESKTOP_VERSION
422 // FIX 422 // FIX
423 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 423 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
424#endif 424#endif
425 mDayLabelsFrame = new QHBox(agendaFrame); 425 mDayLabelsFrame = new QHBox(agendaFrame);
426 //topLayout->addWidget(mDayLabelsFrame); 426 //topLayout->addWidget(mDayLabelsFrame);
427 mDayLabels = new QFrame (mDayLabelsFrame); 427 mDayLabels = new QFrame (mDayLabelsFrame);
428 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 428 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
429 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 429 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
430 agendaLayout->addWidget(mEventIndicatorTop,1,1); 430 agendaLayout->addWidget(mEventIndicatorTop,1,1);
431 431
432 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 432 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
433 agendaFrame); 433 agendaFrame);
434 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 434 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
435 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 435 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
436 agendaLayout->addWidget(dummyAgendaRight,1,2); 436 agendaLayout->addWidget(dummyAgendaRight,1,2);
437 437
438 // Create time labels 438 // Create time labels
439 mTimeLabels = new TimeLabels(24,agendaFrame); 439 mTimeLabels = new TimeLabels(24,agendaFrame);
440 agendaLayout->addWidget(mTimeLabels,2,0); 440 agendaLayout->addWidget(mTimeLabels,2,0);
441 connect(mTimeLabels,SIGNAL( scaleChanged()), 441 connect(mTimeLabels,SIGNAL( scaleChanged()),
442 this,SLOT(updateConfig())); 442 this,SLOT(updateConfig()));
443 443
444 // Create agenda 444 // Create agenda
445 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 445 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
446 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 446 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
447 agendaLayout->setColStretch(1,1); 447 agendaLayout->setColStretch(1,1);
448 mAgenda->setFocusPolicy(NoFocus); 448 mAgenda->setFocusPolicy(NoFocus);
449 // Create event context menu for agenda 449 // Create event context menu for agenda
450 mAgendaPopup = eventPopup(); 450 mAgendaPopup = eventPopup();
451 451
452 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 452 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
453 i18n("Toggle Alarm"),mAgenda, 453 i18n("Toggle Alarm"),mAgenda,
454 SLOT(popupAlarm()),true); 454 SLOT(popupAlarm()),true);
455 455
456 456
457 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 457 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
458 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 458 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
459 459
460 // make connections between dependent widgets 460 // make connections between dependent widgets
461 mTimeLabels->setAgenda(mAgenda); 461 mTimeLabels->setAgenda(mAgenda);
462 462
463 // Update widgets to reflect user preferences 463 // Update widgets to reflect user preferences
464 // updateConfig(); 464 // updateConfig();
465 465
466 // createDayLabels(); 466 // createDayLabels();
467 467
468 // these blank widgets make the All Day Event box line up with the agenda 468 // these blank widgets make the All Day Event box line up with the agenda
469 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 469 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
470 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 470 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
471 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 471 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
472 472
473 // Scrolling 473 // Scrolling
474 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 474 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
475 mTimeLabels, SLOT(positionChanged())); 475 mTimeLabels, SLOT(positionChanged()));
476 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 476 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
477 SLOT(setContentsPos(int))); 477 SLOT(setContentsPos(int)));
478 478
479 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 479 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
480 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 480 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
481 481
482 // Create/Show/Edit/Delete Event 482 // Create/Show/Edit/Delete Event
483 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 483 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
484 SLOT(newEvent(int,int))); 484 SLOT(newEvent(int,int)));
485 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 485 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
486 SLOT(newTodo(int,int))); 486 SLOT(newTodo(int,int)));
487 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 487 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
488 SLOT(newEvent(int,int,int,int))); 488 SLOT(newEvent(int,int,int,int)));
489 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 489 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
490 SLOT(newEventAllDay(int,int))); 490 SLOT(newEventAllDay(int,int)));
491 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 491 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
492 SLOT(newTodoAllDay(int,int))); 492 SLOT(newTodoAllDay(int,int)));
493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
494 SLOT(newEventAllDay(int,int))); 494 SLOT(newEventAllDay(int,int)));
495 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 495 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
496 SLOT(newTimeSpanSelected(int,int,int,int))); 496 SLOT(newTimeSpanSelected(int,int,int,int)));
497 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 497 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
498 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 498 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
499 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 499 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
500 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 500 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
501 501
502 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 502 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
503 SIGNAL(editIncidenceSignal(Incidence *))); 503 SIGNAL(editIncidenceSignal(Incidence *)));
504 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 504 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
505 SIGNAL(editIncidenceSignal(Incidence *))); 505 SIGNAL(editIncidenceSignal(Incidence *)));
506 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 506 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
507 SIGNAL(showIncidenceSignal(Incidence *))); 507 SIGNAL(showIncidenceSignal(Incidence *)));
508 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 508 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
509 SIGNAL(showIncidenceSignal(Incidence *))); 509 SIGNAL(showIncidenceSignal(Incidence *)));
510 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 510 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
511 SIGNAL(deleteIncidenceSignal(Incidence *))); 511 SIGNAL(deleteIncidenceSignal(Incidence *)));
512 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 512 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
513 SIGNAL(deleteIncidenceSignal(Incidence *))); 513 SIGNAL(deleteIncidenceSignal(Incidence *)));
514 514
515 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 515 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
516 SLOT(updateEventDates(KOAgendaItem *, int ))); 516 SLOT(updateEventDates(KOAgendaItem *, int )));
517 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 517 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
518 SLOT(updateEventDates(KOAgendaItem *, int))); 518 SLOT(updateEventDates(KOAgendaItem *, int)));
519 519
520 // event indicator update 520 // event indicator update
521 connect(mAgenda,SIGNAL(lowerYChanged(int)), 521 connect(mAgenda,SIGNAL(lowerYChanged(int)),
522 SLOT(updateEventIndicatorTop(int))); 522 SLOT(updateEventIndicatorTop(int)));
523 connect(mAgenda,SIGNAL(upperYChanged(int)), 523 connect(mAgenda,SIGNAL(upperYChanged(int)),
524 SLOT(updateEventIndicatorBottom(int))); 524 SLOT(updateEventIndicatorBottom(int)));
525 // drag signals 525 // drag signals
526 /* 526 /*
527 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 527 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
528 SLOT(startDrag(Event *))); 528 SLOT(startDrag(Event *)));
529 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 529 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
530 SLOT(startDrag(Event *))); 530 SLOT(startDrag(Event *)));
531 */ 531 */
532 // synchronize selections 532 // synchronize selections
533 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 533 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
534 mAllDayAgenda, SLOT( deselectItem() ) ); 534 mAllDayAgenda, SLOT( deselectItem() ) );
535 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 535 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
536 mAgenda, SLOT( deselectItem() ) ); 536 mAgenda, SLOT( deselectItem() ) );
537 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 537 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
538 SIGNAL( incidenceSelected( Incidence * ) ) ); 538 SIGNAL( incidenceSelected( Incidence * ) ) );
539 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 539 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
540 SIGNAL( incidenceSelected( Incidence * ) ) ); 540 SIGNAL( incidenceSelected( Incidence * ) ) );
541 connect( mAgenda, SIGNAL( resizedSignal() ), 541 connect( mAgenda, SIGNAL( resizedSignal() ),
542 SLOT( updateConfig( ) ) ); 542 SLOT( updateConfig( ) ) );
543 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 543 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
544 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 544 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
545 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 545 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
546 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 546 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
547 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 547 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
548 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 548 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
549 549
550 550
551} 551}
552 552
553void KOAgendaView::toggleAllDay() 553void KOAgendaView::toggleAllDay()
554{ 554{
555 if ( mSplitterAgenda->firstHandle() ) 555 if ( mSplitterAgenda->firstHandle() )
556 mSplitterAgenda->firstHandle()->toggle(); 556 mSplitterAgenda->firstHandle()->toggle();
557} 557}
558void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 558void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
559{ 559{
560 calendar()->addIncidence( inc ); 560 calendar()->addIncidence( inc );
561 561
562 if ( incOld ) { 562 if ( incOld ) {
563 if ( incOld->type() == "Todo" ) 563 if ( incOld->type() == "Todo" )
564 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 564 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
565 else 565 else
566 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 566 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
567 } 567 }
568 568
569} 569}
570 570
571KOAgendaView::~KOAgendaView() 571KOAgendaView::~KOAgendaView()
572{ 572{
573 delete mAgendaPopup; 573 delete mAgendaPopup;
574 delete mAllDayAgendaPopup; 574 delete mAllDayAgendaPopup;
575 delete KOAgendaItem::paintPix(); 575 delete KOAgendaItem::paintPix();
576 delete KOAgendaItem::paintPixSel(); 576 delete KOAgendaItem::paintPixSel();
577} 577}
578void KOAgendaView::resizeEvent( QResizeEvent* e ) 578void KOAgendaView::resizeEvent( QResizeEvent* e )
579{ 579{
580 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 580 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
581 bool uc = false; 581 bool uc = false;
582 int ow = e->oldSize().width(); 582 int ow = e->oldSize().width();
583 int oh = e->oldSize().height(); 583 int oh = e->oldSize().height();
584 int w = e->size().width(); 584 int w = e->size().width();
585 int h = e->size().height(); 585 int h = e->size().height();
586 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 586 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
587 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 587 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
588 uc = true; 588 uc = true;
589 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 589 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
590 } 590 }
591 mUpcomingWidth = e->size().width() ; 591 mUpcomingWidth = e->size().width() ;
592 if ( mBlockUpdating || uc ) { 592 if ( mBlockUpdating || uc ) {
593 mBlockUpdating = false; 593 mBlockUpdating = false;
594 //mAgenda->setMinimumSize(800 , 600 ); 594 //mAgenda->setMinimumSize(800 , 600 );
595 //qDebug("mAgenda->resize+++++++++++++++ "); 595 //qDebug("mAgenda->resize+++++++++++++++ ");
596 updateConfig(); 596 updateConfig();
597 //qDebug("KOAgendaView::Updating now possible "); 597 //qDebug("KOAgendaView::Updating now possible ");
598 } else 598 } else
599 createDayLabels(); 599 createDayLabels();
600 //qDebug("resizeEvent end "); 600 //qDebug("resizeEvent end ");
601 601
602} 602}
603void KOAgendaView::slotDaylabelClicked( int num ) 603void KOAgendaView::slotDaylabelClicked( int num )
604{ 604{
605 605
606 QDate firstDate = mSelectedDates.first(); 606 QDate firstDate = mSelectedDates.first();
607 if ( num == -1 ) 607 if ( num == -1 )
608 emit showDateView( 6, firstDate ); 608 emit showDateView( 6, firstDate );
609 else if (num >= 0 ) { 609 else if (num >= 0 ) {
610 if ( mSelectedDates.count() == 1) 610 if ( mSelectedDates.count() == 1)
611 emit showDateView( 9, firstDate.addDays( num ) ); 611 emit showDateView( 9, firstDate.addDays( num ) );
612 else 612 else
613 emit showDateView( 3, firstDate.addDays( num ) ); 613 emit showDateView( 3, firstDate.addDays( num ) );
614 } 614 }
615 else 615 else
616 showDateView( 10, firstDate.addDays(1) ); 616 showDateView( 10, firstDate.addDays(1) );
617} 617}
618 618
619KOAgendaButton* KOAgendaView::getNewDaylabel() 619KOAgendaButton* KOAgendaView::getNewDaylabel()
620{ 620{
621 621
622 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 622 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
623 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 623 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
624 mDayLabelsList.append( dayLabel ); 624 mDayLabelsList.append( dayLabel );
625 mLayoutDayLabels->addWidget(dayLabel); 625 mLayoutDayLabels->addWidget(dayLabel);
626 return dayLabel ; 626 return dayLabel ;
627} 627}
628 628
629void KOAgendaView::createDayLabels() 629void KOAgendaView::createDayLabels()
630{ 630{
631 631
632 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 632 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
633 // qDebug(" KOAgendaView::createDayLabels() blocked "); 633 // qDebug(" KOAgendaView::createDayLabels() blocked ");
634 return; 634 return;
635 635
636 } 636 }
637 int newHight; 637 int newHight;
638 638
639 // ### Before deleting and recreating we could check if mSelectedDates changed... 639 // ### Before deleting and recreating we could check if mSelectedDates changed...
640 // It would remove some flickering and gain speed (since this is called by 640 // It would remove some flickering and gain speed (since this is called by
641 // each updateView() call) 641 // each updateView() call)
642 642
643 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 643 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
644 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 644 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
645 if ( maxWid < 0 ) 645 if ( maxWid < 0 )
646 maxWid = 20; 646 maxWid = 20;
647 647
648 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 648 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
649 QFontMetrics fm ( dlf ); 649 QFontMetrics fm ( dlf );
650 int selCount = mSelectedDates.count(); 650 int selCount = mSelectedDates.count();
651 QString dayTest = "Mon 20"; 651 QString dayTest = "Mon 20";
652 //QString dayTest = "Mon 20"; 652 //QString dayTest = "Mon 20";
653 int wid = fm.width( dayTest ); 653 int wid = fm.width( dayTest );
654 //maxWid -= ( selCount * 3 ); //working for QLabels 654 //maxWid -= ( selCount * 3 ); //working for QLabels
655 maxWid -= ( selCount * 3 ); //working for QPushButton 655 maxWid -= ( selCount * 3 ); //working for QPushButton
656 if ( maxWid < 0 ) 656 if ( maxWid < 0 )
657 maxWid = 20; 657 maxWid = 20;
658 int needWid = wid * selCount; 658 int needWid = wid * selCount;
659 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 659 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
660 //if ( needWid > maxWid ) 660 //if ( needWid > maxWid )
661 // qDebug("DAYLABELS TOOOOOOO BIG "); 661 // qDebug("DAYLABELS TOOOOOOO BIG ");
662 while ( needWid > maxWid ) { 662 while ( needWid > maxWid ) {
663 dayTest = dayTest.left( dayTest.length() - 1 ); 663 dayTest = dayTest.left( dayTest.length() - 1 );
664 wid = fm.width( dayTest ); 664 wid = fm.width( dayTest );
665 needWid = wid * selCount; 665 needWid = wid * selCount;
666 } 666 }
667 int maxLen = dayTest.length(); 667 int maxLen = dayTest.length();
668 int fontPoint = dlf.pointSize(); 668 int fontPoint = dlf.pointSize();
669 if ( maxLen < 2 ) { 669 if ( maxLen < 2 ) {
670 int fontPoint = dlf.pointSize(); 670 int fontPoint = dlf.pointSize();
671 while ( fontPoint > 4 ) { 671 while ( fontPoint > 4 ) {
672 --fontPoint; 672 --fontPoint;
673 dlf.setPointSize( fontPoint ); 673 dlf.setPointSize( fontPoint );
674 QFontMetrics f( dlf ); 674 QFontMetrics f( dlf );
675 wid = f.width( "30" ); 675 wid = f.width( "30" );
676 needWid = wid * selCount; 676 needWid = wid * selCount;
677 if ( needWid < maxWid ) 677 if ( needWid < maxWid )
678 break; 678 break;
679 } 679 }
680 maxLen = 2; 680 maxLen = 2;
681 } 681 }
682 //qDebug("Max len %d ", dayTest.length() ); 682 //qDebug("Max len %d ", dayTest.length() );
683 683
684 QFontMetrics tempF( dlf ); 684 QFontMetrics tempF( dlf );
685 newHight = tempF.height(); 685 newHight = tempF.height();
686 mDayLabels->setFont( dlf ); 686 mDayLabels->setFont( dlf );
687 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 687 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
688 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 688 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
689 //mLayoutDayLabels->addSpacing( 2 ); 689 //mLayoutDayLabels->addSpacing( 2 );
690 // QFont lFont = dlf; 690 // QFont lFont = dlf;
691 bool appendLabels = false; 691 bool appendLabels = false;
692 KOAgendaButton *dayLabel; 692 KOAgendaButton *dayLabel;
693 dayLabel = mDayLabelsList.first(); 693 dayLabel = mDayLabelsList.first();
694 if ( !dayLabel ) { 694 if ( !dayLabel ) {
695 appendLabels = true; 695 appendLabels = true;
696 dayLabel = getNewDaylabel(); 696 dayLabel = getNewDaylabel();
697 } 697 }
698 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 698 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
699 dayLabel->setFont( dlf ); 699 dayLabel->setFont( dlf );
700 dayLabel->setNum( -1 ); 700 dayLabel->setNum( -1 );
701 //dayLabel->setAlignment(QLabel::AlignHCenter); 701 //dayLabel->setAlignment(QLabel::AlignHCenter);
702 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 702 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
703 dayLabel->show(); 703 dayLabel->show();
704 DateList::ConstIterator dit; 704 DateList::ConstIterator dit;
705 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 705 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
706 int counter = -1; 706 int counter = -1;
707 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 707 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
708 ++counter; 708 ++counter;
709 QDate date = *dit; 709 QDate date = *dit;
710 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 710 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
711 if ( ! appendLabels ) { 711 if ( ! appendLabels ) {
712 dayLabel = mDayLabelsList.next(); 712 dayLabel = mDayLabelsList.next();
713 if ( !dayLabel ) 713 if ( !dayLabel )
714 appendLabels = true; 714 appendLabels = true;
715 } 715 }
716 if ( appendLabels ) { 716 if ( appendLabels ) {
717 dayLabel = getNewDaylabel(); 717 dayLabel = getNewDaylabel();
718 } 718 }
719 dayLabel->setMinimumWidth( 1 ); 719 dayLabel->setMinimumWidth( 1 );
720 dayLabel->setMaximumWidth( 10240 ); 720 dayLabel->setMaximumWidth( 10240 );
721 dayLabel->setFont( dlf ); 721 dayLabel->setFont( dlf );
722 dayLabel->show(); 722 dayLabel->show();
723 dayLabel->setNum( counter ); 723 dayLabel->setNum( counter );
724 QString str; 724 QString str;
725 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 725 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
726 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 726 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
727 switch ( maxLen ) { 727 switch ( maxLen ) {
728 case 2: 728 case 2:
729 str = QString::number( date.day() ); 729 str = QString::number( date.day() );
730 break; 730 break;
731 731
732 case 3: 732 case 3:
733 str = dayName.left( 1 ) +QString::number( date.day()); 733 str = dayName.left( 1 ) +QString::number( date.day());
734 734
735 break; 735 break;
736 case 4: 736 case 4:
737 str = dayName.left( 1 ) + " " +QString::number( date.day()); 737 str = dayName.left( 1 ) + " " +QString::number( date.day());
738 738
739 break; 739 break;
740 case 5: 740 case 5:
741 str = dayName.left( 2 ) + " " +QString::number( date.day()); 741 str = dayName.left( 2 ) + " " +QString::number( date.day());
742 742
743 break; 743 break;
744 case 6: 744 case 6:
745 str = dayName.left( 3 ) + " " +QString::number( date.day()); 745 str = dayName.left( 3 ) + " " +QString::number( date.day());
746 break; 746 break;
747 747
748 default: 748 default:
749 break; 749 break;
750 } 750 }
751 if ( oneday ) { 751 if ( oneday ) {
752 QString addString; 752 QString addString;
753 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 753 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
754 addString = i18n("Today"); 754 addString = i18n("Today");
755 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 755 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
756 addString = i18n("Tomorrow"); 756 addString = i18n("Tomorrow");
757 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 757 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
758 addString = i18n("Yesterday"); 758 addString = i18n("Yesterday");
759 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 759 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
760 addString = i18n("Day before yesterday"); 760 addString = i18n("Day before yesterday");
761 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 761 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
762 addString = i18n("Day after tomorrow"); 762 addString = i18n("Day after tomorrow");
763 if ( !addString.isEmpty() ) { 763 if ( !addString.isEmpty() ) {
764 str = addString+", " + str; 764 str = addString+", " + str;
765 } else {
766 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
765 } 767 }
766 } 768 }
767 dayLabel->setText(str); 769 dayLabel->setText(str);
768 //dayLabel->setAlignment(QLabel::AlignHCenter); 770 //dayLabel->setAlignment(QLabel::AlignHCenter);
769 if (date == QDate::currentDate()) { 771 if (date == QDate::currentDate()) {
770 QFont bFont = dlf; 772 QFont bFont = dlf;
771 bFont.setBold( true ); 773 bFont.setBold( true );
772 dayLabel->setFont(bFont); 774 dayLabel->setFont(bFont);
773 } 775 }
774 //dayLayout->addWidget(dayLabel); 776 //dayLayout->addWidget(dayLabel);
775 777
776#ifndef KORG_NOPLUGINS 778#ifndef KORG_NOPLUGINS
777 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 779 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
778 CalendarDecoration *it; 780 CalendarDecoration *it;
779 for(it = cds.first(); it; it = cds.next()) { 781 for(it = cds.first(); it; it = cds.next()) {
780 QString text = it->shortText( date ); 782 QString text = it->shortText( date );
781 if ( !text.isEmpty() ) { 783 if ( !text.isEmpty() ) {
782 QLabel *label = new QLabel(text,mDayLabels); 784 QLabel *label = new QLabel(text,mDayLabels);
783 label->setAlignment(AlignCenter); 785 label->setAlignment(AlignCenter);
784 dayLayout->addWidget(label); 786 dayLayout->addWidget(label);
785 } 787 }
786 } 788 }
787 789
788 for(it = cds.first(); it; it = cds.next()) { 790 for(it = cds.first(); it; it = cds.next()) {
789 QWidget *wid = it->smallWidget(mDayLabels,date); 791 QWidget *wid = it->smallWidget(mDayLabels,date);
790 if ( wid ) { 792 if ( wid ) {
791 // wid->setHeight(20); 793 // wid->setHeight(20);
792 dayLayout->addWidget(wid); 794 dayLayout->addWidget(wid);
793 } 795 }
794 } 796 }
795#endif 797#endif
796 } 798 }
797 if ( ! appendLabels ) { 799 if ( ! appendLabels ) {
798 dayLabel = mDayLabelsList.next(); 800 dayLabel = mDayLabelsList.next();
799 if ( !dayLabel ) 801 if ( !dayLabel )
800 appendLabels = true; 802 appendLabels = true;
801 } 803 }
802 if ( appendLabels ) { 804 if ( appendLabels ) {
803 dayLabel = getNewDaylabel(); 805 dayLabel = getNewDaylabel();
804 } 806 }
805 //dayLabel->hide();//test only 807 //dayLabel->hide();//test only
806 808
807 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 809 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
808 if ( offset < 0 ) offset = 0; 810 if ( offset < 0 ) offset = 0;
809 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 811 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
810 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 812 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
811 dayLabel->setFont( dlf ); 813 dayLabel->setFont( dlf );
812 dayLabel->show(); 814 dayLabel->show();
813 dayLabel->setNum( -2 ); 815 dayLabel->setNum( -2 );
814 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 816 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
815 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 817 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
816 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 818 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
817 if ( !appendLabels ) { 819 if ( !appendLabels ) {
818 dayLabel = mDayLabelsList.next(); 820 dayLabel = mDayLabelsList.next();
819 while ( dayLabel ) { 821 while ( dayLabel ) {
820 //qDebug("!dayLabel %d",dayLabel ); 822 //qDebug("!dayLabel %d",dayLabel );
821 dayLabel->hide(); 823 dayLabel->hide();
822 dayLabel = mDayLabelsList.next(); 824 dayLabel = mDayLabelsList.next();
823 } 825 }
824 } 826 }
825 //mDayLabelsFrame->show(); 827 //mDayLabelsFrame->show();
826 //mDayLabels->show(); 828 //mDayLabels->show();
827 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 829 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
828 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 830 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
829 mDayLabelsFrame->setFixedHeight( newHight ); 831 mDayLabelsFrame->setFixedHeight( newHight );
830} 832}
831 833
832int KOAgendaView::maxDatesHint() 834int KOAgendaView::maxDatesHint()
833{ 835{
834 // Not sure about the max number of events, so return 0 for now. 836 // Not sure about the max number of events, so return 0 for now.
835 return 0; 837 return 0;
836} 838}
837 839
838int KOAgendaView::currentDateCount() 840int KOAgendaView::currentDateCount()
839{ 841{
840 return mSelectedDates.count(); 842 return mSelectedDates.count();
841} 843}
842 844
843QPtrList<Incidence> KOAgendaView::selectedIncidences() 845QPtrList<Incidence> KOAgendaView::selectedIncidences()
844{ 846{
845 QPtrList<Incidence> selected; 847 QPtrList<Incidence> selected;
846 Incidence *incidence; 848 Incidence *incidence;
847 849
848 incidence = mAgenda->selectedIncidence(); 850 incidence = mAgenda->selectedIncidence();
849 if (incidence) selected.append(incidence); 851 if (incidence) selected.append(incidence);
850 852
851 incidence = mAllDayAgenda->selectedIncidence(); 853 incidence = mAllDayAgenda->selectedIncidence();
852 if (incidence) selected.append(incidence); 854 if (incidence) selected.append(incidence);
853 855
854 return selected; 856 return selected;
855} 857}
856 858
857DateList KOAgendaView::selectedDates() 859DateList KOAgendaView::selectedDates()
858{ 860{
859 DateList selected; 861 DateList selected;
860 QDate qd; 862 QDate qd;
861 863
862 qd = mAgenda->selectedIncidenceDate(); 864 qd = mAgenda->selectedIncidenceDate();
863 if (qd.isValid()) selected.append(qd); 865 if (qd.isValid()) selected.append(qd);
864 866
865 qd = mAllDayAgenda->selectedIncidenceDate(); 867 qd = mAllDayAgenda->selectedIncidenceDate();
866 if (qd.isValid()) selected.append(qd); 868 if (qd.isValid()) selected.append(qd);
867 869
868 return selected; 870 return selected;
869} 871}
870 872
871 873
872void KOAgendaView::updateView() 874void KOAgendaView::updateView()
873{ 875{
874 if ( mBlockUpdating ) 876 if ( mBlockUpdating )
875 return; 877 return;
876 // kdDebug() << "KOAgendaView::updateView()" << endl; 878 // kdDebug() << "KOAgendaView::updateView()" << endl;
877 fillAgenda(); 879 fillAgenda();
878 880
879} 881}
880 882
881 883
882/* 884/*
883 Update configuration settings for the agenda view. This method is not 885 Update configuration settings for the agenda view. This method is not
884 complete. 886 complete.
885*/ 887*/
886void KOAgendaView::updateConfig() 888void KOAgendaView::updateConfig()
887{ 889{
888 if ( mBlockUpdating ) 890 if ( mBlockUpdating )
889 return; 891 return;
890 892
891 // update config for children 893 // update config for children
892 mTimeLabels->updateConfig(); 894 mTimeLabels->updateConfig();
893 mAgenda->storePosition(); 895 mAgenda->storePosition();
894 mAgenda->updateConfig(); 896 mAgenda->updateConfig();
895 mAllDayAgenda->updateConfig(); 897 mAllDayAgenda->updateConfig();
896 // widget synchronization 898 // widget synchronization
897 //TODO: find a better way, maybe signal/slot 899 //TODO: find a better way, maybe signal/slot
898 mTimeLabels->positionChanged(); 900 mTimeLabels->positionChanged();
899 901
900 // for some reason, this needs to be called explicitly 902 // for some reason, this needs to be called explicitly
901 mTimeLabels->repaint(); 903 mTimeLabels->repaint();
902 904
903 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 905 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
904 906
905 // ToolTips displaying summary of events 907 // ToolTips displaying summary of events
906 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 908 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
907 ->mEnableToolTips); 909 ->mEnableToolTips);
908 910
909 //setHolidayMasks(); 911 //setHolidayMasks();
910 912
911 //createDayLabels(); called by via updateView(); 913 //createDayLabels(); called by via updateView();
912 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 914 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
913 updateView(); 915 updateView();
914 mAgenda->restorePosition(); 916 mAgenda->restorePosition();
915} 917}
916 918
917 919
918void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 920void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
919{ 921{
920 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 922 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
921 //qDebug("KOAgendaView::updateEventDates "); 923 //qDebug("KOAgendaView::updateEventDates ");
922 QDateTime startDt,endDt; 924 QDateTime startDt,endDt;
923 QDate startDate; 925 QDate startDate;
924 int lenInSecs; 926 int lenInSecs;
925 // if ( type == KOAgenda::RESIZETOP ) 927 // if ( type == KOAgenda::RESIZETOP )
926 // qDebug("RESIZETOP "); 928 // qDebug("RESIZETOP ");
927 // if ( type == KOAgenda::RESIZEBOTTOM ) 929 // if ( type == KOAgenda::RESIZEBOTTOM )
928 // qDebug("RESIZEBOTTOM "); 930 // qDebug("RESIZEBOTTOM ");
929 // if ( type == KOAgenda::MOVE ) 931 // if ( type == KOAgenda::MOVE )
930 // qDebug("MOVE "); 932 // qDebug("MOVE ");
931 if ( item->incidence()->type() == "Event" ) { 933 if ( item->incidence()->type() == "Event" ) {
932 startDt =item->incidence()->dtStart(); 934 startDt =item->incidence()->dtStart();
933 endDt = item->incidence()->dtEnd(); 935 endDt = item->incidence()->dtEnd();
934 lenInSecs = startDt.secsTo( endDt ); 936 lenInSecs = startDt.secsTo( endDt );
935 } 937 }
936 938
937 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 939 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
938 940
939 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 941 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
940 startDate = mSelectedDates[item->mLastMoveXPos]; 942 startDate = mSelectedDates[item->mLastMoveXPos];
941 } else { 943 } else {
942 if (item->cellX() < 0) { 944 if (item->cellX() < 0) {
943 startDate = (mSelectedDates.first()).addDays(item->cellX()); 945 startDate = (mSelectedDates.first()).addDays(item->cellX());
944 } else { 946 } else {
945 startDate = mSelectedDates[item->cellX()]; 947 startDate = mSelectedDates[item->cellX()];
946 } 948 }
947 } 949 }
948 startDt.setDate(startDate); 950 startDt.setDate(startDate);
949 951
950 if (item->incidence()->doesFloat()) { 952 if (item->incidence()->doesFloat()) {
951 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 953 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
952 } else { 954 } else {
953 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 955 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
954 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 956 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
955 if ( item->incidence()->type() == "Event" ) { 957 if ( item->incidence()->type() == "Event" ) {
956 if ( type == KOAgenda::MOVE ) { 958 if ( type == KOAgenda::MOVE ) {
957 endDt = startDt.addSecs(lenInSecs); 959 endDt = startDt.addSecs(lenInSecs);
958 960
959 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 961 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
960 if (item->lastMultiItem()) { 962 if (item->lastMultiItem()) {
961 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 963 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
962 endDt.setDate(startDate. 964 endDt.setDate(startDate.
963 addDays(item->lastMultiItem()->cellX() - item->cellX())); 965 addDays(item->lastMultiItem()->cellX() - item->cellX()));
964 } else { 966 } else {
965 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 967 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
966 endDt.setDate(startDate); 968 endDt.setDate(startDate);
967 } 969 }
968 } 970 }
969 } else { 971 } else {
970 // todo 972 // todo
971 if (item->lastMultiItem()) { 973 if (item->lastMultiItem()) {
972 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 974 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
973 endDt.setDate(startDate. 975 endDt.setDate(startDate.
974 addDays(item->lastMultiItem()->cellX() - item->cellX())); 976 addDays(item->lastMultiItem()->cellX() - item->cellX()));
975 } else { 977 } else {
976 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 978 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
977 if ( item->cellYBottom() > 0 ) 979 if ( item->cellYBottom() > 0 )
978 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 980 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
979 else 981 else
980 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 982 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
981 endDt.setDate(startDate); 983 endDt.setDate(startDate);
982 } 984 }
983 } 985 }
984 } 986 }
985 if ( item->incidence()->type() == "Event" ) { 987 if ( item->incidence()->type() == "Event" ) {
986 item->incidence()->setDtStart(startDt); 988 item->incidence()->setDtStart(startDt);
987 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 989 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
988 } else if ( item->incidence()->type() == "Todo" ) { 990 } else if ( item->incidence()->type() == "Todo" ) {
989 Todo* to = static_cast<Todo*>(item->incidence()); 991 Todo* to = static_cast<Todo*>(item->incidence());
990 992
991 to->setDtDue(endDt); 993 to->setDtDue(endDt);
992 if ( to->hasStartDate() ) { 994 if ( to->hasStartDate() ) {
993 if (to->dtStart() >= to->dtDue() ) 995 if (to->dtStart() >= to->dtDue() )
994 to->setDtStart(to->dtDue().addDays( -2 )); 996 to->setDtStart(to->dtDue().addDays( -2 ));
995 } 997 }
996 998
997 } 999 }
998 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1000 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
999 item->incidence()->setRevision(item->incidence()->revision()+1); 1001 item->incidence()->setRevision(item->incidence()->revision()+1);
1000 item->setItemDate(startDt.date()); 1002 item->setItemDate(startDt.date());
1001 //item->updateItem(); 1003 //item->updateItem();
1002 if ( item->incidence()->type() == "Todo" ) { 1004 if ( item->incidence()->type() == "Todo" ) {
1003 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1005 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1004 1006
1005 } 1007 }
1006 else 1008 else
1007 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1009 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1008 item->updateItem(); 1010 item->updateItem();
1009} 1011}
1010 1012
1011void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1013void KOAgendaView::showDates( const QDate &start, const QDate &end )
1012{ 1014{
1013 // kdDebug() << "KOAgendaView::selectDates" << endl; 1015 // kdDebug() << "KOAgendaView::selectDates" << endl;
1014 1016
1015 mSelectedDates.clear(); 1017 mSelectedDates.clear();
1016 // qDebug("KOAgendaView::showDates "); 1018 // qDebug("KOAgendaView::showDates ");
1017 QDate d = start; 1019 QDate d = start;
1018 while (d <= end) { 1020 while (d <= end) {
1019 mSelectedDates.append(d); 1021 mSelectedDates.append(d);
1020 d = d.addDays( 1 ); 1022 d = d.addDays( 1 );
1021 } 1023 }
1022 1024
1023 // and update the view 1025 // and update the view
1024 fillAgenda(); 1026 fillAgenda();
1025} 1027}
1026 1028
1027 1029
1028void KOAgendaView::showEvents(QPtrList<Event>) 1030void KOAgendaView::showEvents(QPtrList<Event>)
1029{ 1031{
1030 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1032 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1031} 1033}
1032 1034
1033void KOAgendaView::changeEventDisplay(Event *, int) 1035void KOAgendaView::changeEventDisplay(Event *, int)
1034{ 1036{
1035 // qDebug("KOAgendaView::changeEventDisplay "); 1037 // qDebug("KOAgendaView::changeEventDisplay ");
1036 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1038 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1037 // this should be re-written to be MUCH smarter. Right now we 1039 // this should be re-written to be MUCH smarter. Right now we
1038 // are just playing dumb. 1040 // are just playing dumb.
1039 fillAgenda(); 1041 fillAgenda();
1040} 1042}
1041 1043
1042void KOAgendaView::fillAgenda(const QDate &) 1044void KOAgendaView::fillAgenda(const QDate &)
1043{ 1045{
1044 // qDebug("KOAgendaView::fillAgenda "); 1046 // qDebug("KOAgendaView::fillAgenda ");
1045 fillAgenda(); 1047 fillAgenda();
1046} 1048}
1047 1049
1048void KOAgendaView::fillAgenda() 1050void KOAgendaView::fillAgenda()
1049{ 1051{
1050 if ( globalFlagBlockStartup ) 1052 if ( globalFlagBlockStartup )
1051 return; 1053 return;
1052 if ( globalFlagBlockAgenda == 1 ) 1054 if ( globalFlagBlockAgenda == 1 )
1053 return; 1055 return;
1054 //if ( globalFlagBlockAgenda == 2 ) 1056 //if ( globalFlagBlockAgenda == 2 )
1055 //globalFlagBlockAgenda = 0; 1057 //globalFlagBlockAgenda = 0;
1056 // globalFlagBlockPainting = false; 1058 // globalFlagBlockPainting = false;
1057 if ( globalFlagBlockAgenda == 0 ) 1059 if ( globalFlagBlockAgenda == 0 )
1058 globalFlagBlockAgenda = 1; 1060 globalFlagBlockAgenda = 1;
1059 // clearView(); 1061 // clearView();
1060 //qDebug("fillAgenda()++++ "); 1062 //qDebug("fillAgenda()++++ ");
1061 globalFlagBlockAgendaItemPaint = 1; 1063 globalFlagBlockAgendaItemPaint = 1;
1062 1064
1063 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1065 mAllDayAgenda->changeColumns(mSelectedDates.count());
1064 mAgenda->changeColumns(mSelectedDates.count()); 1066 mAgenda->changeColumns(mSelectedDates.count());
1065 qApp->processEvents(); 1067 qApp->processEvents();
1066 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1068 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1067 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1069 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1068 setHolidayMasks(); 1070 setHolidayMasks();
1069 1071
1070 //mAgenda->hideUnused(); 1072 //mAgenda->hideUnused();
1071 //mAllDayAgenda->hideUnused(); 1073 //mAllDayAgenda->hideUnused();
1072 1074
1073 // mAgenda->blockNextRepaint( false ); 1075 // mAgenda->blockNextRepaint( false );
1074 // mAgenda->viewport()->repaint(); 1076 // mAgenda->viewport()->repaint();
1075 // mAgenda->blockNextRepaint( true ); 1077 // mAgenda->blockNextRepaint( true );
1076 mMinY.resize(mSelectedDates.count()); 1078 mMinY.resize(mSelectedDates.count());
1077 mMaxY.resize(mSelectedDates.count()); 1079 mMaxY.resize(mSelectedDates.count());
1078 1080
1079 QPtrList<Event> dayEvents; 1081 QPtrList<Event> dayEvents;
1080 1082
1081 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1083 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1082 // Therefore, gtodoset all of them. 1084 // Therefore, gtodoset all of them.
1083 QPtrList<Todo> todos = calendar()->todos(); 1085 QPtrList<Todo> todos = calendar()->todos();
1084 1086
1085 mAgenda->setDateList(mSelectedDates); 1087 mAgenda->setDateList(mSelectedDates);
1086 1088
1087 QDate today = QDate::currentDate(); 1089 QDate today = QDate::currentDate();
1088 1090
1089 DateList::ConstIterator dit; 1091 DateList::ConstIterator dit;
1090 int curCol = 0; 1092 int curCol = 0;
1091 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1093 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1092 QDate currentDate = *dit; 1094 QDate currentDate = *dit;
1093 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1095 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1094 // << endl; 1096 // << endl;
1095 1097
1096 dayEvents = calendar()->events(currentDate,true); 1098 dayEvents = calendar()->events(currentDate,true);
1097 1099
1098 // Default values, which can never be reached 1100 // Default values, which can never be reached
1099 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1101 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1100 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1102 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1101 1103
1102 unsigned int numEvent; 1104 unsigned int numEvent;
1103 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1105 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1104 Event *event = dayEvents.at(numEvent); 1106 Event *event = dayEvents.at(numEvent);
1105 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1107 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1106 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1108 if ( event->uid().left(15) == QString("last-syncEvent-") )
1107 continue; 1109 continue;
1108 // kdDebug() << " Event: " << event->summary() << endl; 1110 // kdDebug() << " Event: " << event->summary() << endl;
1109 1111
1110 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1112 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1111 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1113 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1112 1114
1113 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1115 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1114 1116
1115 if (event->doesFloat()) { 1117 if (event->doesFloat()) {
1116 if (event->recurrence()->doesRecur()) { 1118 if (event->recurrence()->doesRecur()) {
1117 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1119 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1118 } else { 1120 } else {
1119 if (beginX <= 0 && curCol == 0) { 1121 if (beginX <= 0 && curCol == 0) {
1120 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1122 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1121 } else if (beginX == curCol) { 1123 } else if (beginX == curCol) {
1122 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1124 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1123 } 1125 }
1124 } 1126 }
1125 } else if (event->isMultiDay()) { 1127 } else if (event->isMultiDay()) {
1126 if ( event->doesRecur () ) { 1128 if ( event->doesRecur () ) {
1127 QDate dateit = currentDate; 1129 QDate dateit = currentDate;
1128 int count = 0; 1130 int count = 0;
1129 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1131 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1130 while (! event->recursOn( dateit ) && count <= max ) { 1132 while (! event->recursOn( dateit ) && count <= max ) {
1131 ++count; 1133 ++count;
1132 dateit = dateit.addDays( -1 ); 1134 dateit = dateit.addDays( -1 );
1133 } 1135 }
1134 bool ok; 1136 bool ok;
1135 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1137 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1136 if ( ok ) 1138 if ( ok )
1137 { 1139 {
1138 int secs = event->dtStart().secsTo( event->dtEnd() ); 1140 int secs = event->dtStart().secsTo( event->dtEnd() );
1139 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1141 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1140 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1142 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1141 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1143 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1142 1144
1143 } 1145 }
1144 } 1146 }
1145 int startY = mAgenda->timeToY(event->dtStart().time()); 1147 int startY = mAgenda->timeToY(event->dtStart().time());
1146 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1148 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1147 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1149 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1148 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1150 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1149 //qDebug("insert!!! "); 1151 //qDebug("insert!!! ");
1150 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1152 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1151 } 1153 }
1152 if (beginX == curCol) { 1154 if (beginX == curCol) {
1153 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1155 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1154 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1156 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1155 } else if (endX == curCol) { 1157 } else if (endX == curCol) {
1156 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1158 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1157 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1159 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1158 } else { 1160 } else {
1159 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1161 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1160 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1162 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1161 } 1163 }
1162 } else { 1164 } else {
1163 int startY = mAgenda->timeToY(event->dtStart().time()); 1165 int startY = mAgenda->timeToY(event->dtStart().time());
1164 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1166 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1165 if (endY < startY) endY = startY; 1167 if (endY < startY) endY = startY;
1166 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1168 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1167 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1169 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1168 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1170 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1169 } 1171 }
1170 } 1172 }
1171 // ---------- [display Todos -------------- 1173 // ---------- [display Todos --------------
1172 unsigned int numTodo; 1174 unsigned int numTodo;
1173 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1175 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1174 Todo *todo = todos.at(numTodo); 1176 Todo *todo = todos.at(numTodo);
1175 1177
1176 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1178 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1177 1179
1178 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1180 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1179 // Already completed items can be displayed on their original due date 1181 // Already completed items can be displayed on their original due date
1180 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1182 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1181 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1183 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1182 bool fillIn = false; 1184 bool fillIn = false;
1183 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1185 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1184 fillIn = true; 1186 fillIn = true;
1185 if ( ! fillIn && !todo->hasCompletedDate() ) 1187 if ( ! fillIn && !todo->hasCompletedDate() )
1186 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1188 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1187 if ( fillIn ) { 1189 if ( fillIn ) {
1188 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1190 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1189 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1191 if ( KOPrefs::instance()->mShowTodoInAgenda )
1190 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1192 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1191 } 1193 }
1192 else { 1194 else {
1193 QDateTime dt; 1195 QDateTime dt;
1194 if ( todo->hasCompletedDate() ) 1196 if ( todo->hasCompletedDate() )
1195 dt = todo->completed(); 1197 dt = todo->completed();
1196 else 1198 else
1197 dt = todo->dtDue();; 1199 dt = todo->dtDue();;
1198 1200
1199 1201
1200 int endY = mAgenda->timeToY(dt.time()) - 1; 1202 int endY = mAgenda->timeToY(dt.time()) - 1;
1201 int hi = (18/KOPrefs::instance()->mHourSize); 1203 int hi = (18/KOPrefs::instance()->mHourSize);
1202 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1204 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1203 int startY = endY -hi; 1205 int startY = endY -hi;
1204 1206
1205 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1207 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1206 1208
1207 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1209 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1208 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1210 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1209 } 1211 }
1210 } 1212 }
1211 } 1213 }
1212 // ---------- display Todos] -------------- 1214 // ---------- display Todos] --------------
1213 1215
1214 ++curCol; 1216 ++curCol;
1215 } 1217 }
1216 mAgenda->hideUnused(); 1218 mAgenda->hideUnused();
1217 mAllDayAgenda->hideUnused(); 1219 mAllDayAgenda->hideUnused();
1218 mAgenda->checkScrollBoundaries(); 1220 mAgenda->checkScrollBoundaries();
1219 1221
1220 deleteSelectedDateTime(); 1222 deleteSelectedDateTime();
1221 1223
1222 createDayLabels(); 1224 createDayLabels();
1223 emit incidenceSelected( 0 ); 1225 emit incidenceSelected( 0 );
1224 1226
1225 if ( globalFlagBlockAgenda == 2 ) { 1227 if ( globalFlagBlockAgenda == 2 ) {
1226 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1228 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1227 setStartHour( KOPrefs::instance()->mDayBegins ); 1229 setStartHour( KOPrefs::instance()->mDayBegins );
1228 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1230 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1229 setStartHour( QTime::currentTime ().hour() ); 1231 setStartHour( QTime::currentTime ().hour() );
1230 // qApp->processEvents(); 1232 // qApp->processEvents();
1231 } 1233 }
1232 qApp->processEvents(); 1234 qApp->processEvents();
1233 //qDebug("qApp->processEvents(); END "); 1235 //qDebug("qApp->processEvents(); END ");
1234 globalFlagBlockAgenda = 0; 1236 globalFlagBlockAgenda = 0;
1235 1237
1236 // mAgenda->hideUnused(); 1238 // mAgenda->hideUnused();
1237 //mAllDayAgenda->hideUnused(); 1239 //mAllDayAgenda->hideUnused();
1238 mAllDayAgenda->drawContentsToPainter(); 1240 mAllDayAgenda->drawContentsToPainter();
1239 mAgenda->drawContentsToPainter(); 1241 mAgenda->drawContentsToPainter();
1240 repaintAgenda(); 1242 repaintAgenda();
1241 // mAgenda->finishUpdate(); 1243 // mAgenda->finishUpdate();
1242 //mAllDayAgenda->finishUpdate(); 1244 //mAllDayAgenda->finishUpdate();
1243 1245
1244 // repaintAgenda(); 1246 // repaintAgenda();
1245 //qApp->processEvents(); 1247 //qApp->processEvents();
1246 // globalFlagBlockAgenda = 0; 1248 // globalFlagBlockAgenda = 0;
1247} 1249}
1248void KOAgendaView::repaintAgenda() 1250void KOAgendaView::repaintAgenda()
1249{ 1251{
1250 // mAllDayAgenda->drawContentsToPainter(); 1252 // mAllDayAgenda->drawContentsToPainter();
1251// mAllDayAgenda->viewport()->repaint( false ); 1253// mAllDayAgenda->viewport()->repaint( false );
1252// mAgenda->drawContentsToPainter(); 1254// mAgenda->drawContentsToPainter();
1253// mAgenda->viewport()->repaint( false ); 1255// mAgenda->viewport()->repaint( false );
1254// qApp->processEvents(); 1256// qApp->processEvents();
1255 1257
1256 //qDebug("KOAgendaView::repaintAgenda() "); 1258 //qDebug("KOAgendaView::repaintAgenda() ");
1257 //qApp->processEvents(); 1259 //qApp->processEvents();
1258 mAgenda->viewport()->repaint( false ); 1260 mAgenda->viewport()->repaint( false );
1259 mAllDayAgenda->viewport()->repaint( false ); 1261 mAllDayAgenda->viewport()->repaint( false );
1260 mAgenda->finishUpdate(); 1262 mAgenda->finishUpdate();
1261 mAllDayAgenda->finishUpdate(); 1263 mAllDayAgenda->finishUpdate();
1262} 1264}
1263 1265
1264 1266
1265void KOAgendaView::clearView() 1267void KOAgendaView::clearView()
1266{ 1268{
1267 // kdDebug() << "ClearView" << endl; 1269 // kdDebug() << "ClearView" << endl;
1268 mAllDayAgenda->clear(); 1270 mAllDayAgenda->clear();
1269 mAgenda->clear(); 1271 mAgenda->clear();
1270} 1272}
1271 1273
1272void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1274void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1273 const QDate &td) 1275 const QDate &td)
1274{ 1276{
1275#ifndef KORG_NOPRINTER 1277#ifndef KORG_NOPRINTER
1276 if (fd == td) 1278 if (fd == td)
1277 calPrinter->preview(CalPrinter::Day, fd, td); 1279 calPrinter->preview(CalPrinter::Day, fd, td);
1278 else 1280 else
1279 calPrinter->preview(CalPrinter::Week, fd, td); 1281 calPrinter->preview(CalPrinter::Week, fd, td);
1280#endif 1282#endif
1281} 1283}
1282 1284
1283// void KOAgendaView::updateMovedTodo() 1285// void KOAgendaView::updateMovedTodo()
1284// { 1286// {
1285// // updateConfig(); 1287// // updateConfig();
1286// // emit updateTodoViews(); 1288// // emit updateTodoViews();
1287// } 1289// }
1288 1290
1289void KOAgendaView::newEvent(int gx, int gy) 1291void KOAgendaView::newEvent(int gx, int gy)
1290{ 1292{
1291 if (!mSelectedDates.count()) return; 1293 if (!mSelectedDates.count()) return;
1292 1294
1293 QDate day = mSelectedDates[gx]; 1295 QDate day = mSelectedDates[gx];
1294 1296
1295 QTime time = mAgenda->gyToTime(gy); 1297 QTime time = mAgenda->gyToTime(gy);
1296 QDateTime dt(day,time); 1298 QDateTime dt(day,time);
1297 // if ( dt < QDateTime::currentDateTime () ) 1299 // if ( dt < QDateTime::currentDateTime () )
1298 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1300 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1299 emit newEventSignal(dt); 1301 emit newEventSignal(dt);
1300} 1302}
1301 1303
1302void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1304void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1303{ 1305{
1304 if (!mSelectedDates.count()) return; 1306 if (!mSelectedDates.count()) return;
1305 1307
1306 QDate dayStart = mSelectedDates[gxStart]; 1308 QDate dayStart = mSelectedDates[gxStart];
1307 QDate dayEnd = mSelectedDates[gxEnd]; 1309 QDate dayEnd = mSelectedDates[gxEnd];
1308 1310
1309 QTime timeStart = mAgenda->gyToTime(gyStart); 1311 QTime timeStart = mAgenda->gyToTime(gyStart);
1310 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1312 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1311 1313
1312 QDateTime dtStart(dayStart,timeStart); 1314 QDateTime dtStart(dayStart,timeStart);
1313 QDateTime dtEnd(dayEnd,timeEnd); 1315 QDateTime dtEnd(dayEnd,timeEnd);
1314 1316
1315 emit newEventSignal(dtStart,dtEnd); 1317 emit newEventSignal(dtStart,dtEnd);
1316} 1318}
1317 1319
1318void KOAgendaView::newEventAllDay(int gx, int ) 1320void KOAgendaView::newEventAllDay(int gx, int )
1319{ 1321{
1320 if (!mSelectedDates.count()) return; 1322 if (!mSelectedDates.count()) return;
1321 1323
1322 QDate day = mSelectedDates[gx]; 1324 QDate day = mSelectedDates[gx];
1323 1325
1324 emit newEventSignal(day); 1326 emit newEventSignal(day);
1325} 1327}
1326void KOAgendaView::newTodoAllDay(int gx, int ) 1328void KOAgendaView::newTodoAllDay(int gx, int )
1327{ 1329{
1328 if (!mSelectedDates.count()) return; 1330 if (!mSelectedDates.count()) return;
1329 1331
1330 QDateTime day (mSelectedDates[gx] ); 1332 QDateTime day (mSelectedDates[gx] );
1331 emit newTodoSignal(day, true); 1333 emit newTodoSignal(day, true);
1332} 1334}
1333void KOAgendaView::newTodo(int gx, int gy ) 1335void KOAgendaView::newTodo(int gx, int gy )
1334{ 1336{
1335 if (!mSelectedDates.count()) return; 1337 if (!mSelectedDates.count()) return;
1336 QDate dayStart = mSelectedDates[gx]; 1338 QDate dayStart = mSelectedDates[gx];
1337 QTime timeStart = mAgenda->gyToTime(gy); 1339 QTime timeStart = mAgenda->gyToTime(gy);
1338 QDateTime dt (dayStart,timeStart); 1340 QDateTime dt (dayStart,timeStart);
1339 emit newTodoSignal( dt, false ); 1341 emit newTodoSignal( dt, false );
1340} 1342}
1341 1343
1342void KOAgendaView::updateEventIndicatorTop(int newY) 1344void KOAgendaView::updateEventIndicatorTop(int newY)
1343{ 1345{
1344 uint i; 1346 uint i;
1345 for(i=0;i<mMinY.size();++i) { 1347 for(i=0;i<mMinY.size();++i) {
1346 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1348 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1347 else mEventIndicatorTop->enableColumn(i,false); 1349 else mEventIndicatorTop->enableColumn(i,false);
1348 } 1350 }
1349 1351
1350 mEventIndicatorTop->update(); 1352 mEventIndicatorTop->update();
1351} 1353}
1352 1354
1353void KOAgendaView::updateEventIndicatorBottom(int newY) 1355void KOAgendaView::updateEventIndicatorBottom(int newY)
1354{ 1356{
1355 uint i; 1357 uint i;
1356 for(i=0;i<mMaxY.size();++i) { 1358 for(i=0;i<mMaxY.size();++i) {
1357 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1359 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1358 else mEventIndicatorBottom->enableColumn(i,false); 1360 else mEventIndicatorBottom->enableColumn(i,false);
1359 } 1361 }
1360 1362
1361 mEventIndicatorBottom->update(); 1363 mEventIndicatorBottom->update();
1362} 1364}
1363 1365
1364void KOAgendaView::startDrag(Event *event) 1366void KOAgendaView::startDrag(Event *event)
1365{ 1367{
1366#ifndef KORG_NODND 1368#ifndef KORG_NODND
1367 DndFactory factory( calendar() ); 1369 DndFactory factory( calendar() );
1368 ICalDrag *vd = factory.createDrag(event,this); 1370 ICalDrag *vd = factory.createDrag(event,this);
1369 if (vd->drag()) { 1371 if (vd->drag()) {
1370 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1372 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1371 } 1373 }
1372#endif 1374#endif
1373} 1375}
1374 1376
1375void KOAgendaView::readSettings() 1377void KOAgendaView::readSettings()
1376{ 1378{
1377 readSettings(KOGlobals::config()); 1379 readSettings(KOGlobals::config());
1378} 1380}
1379 1381
1380void KOAgendaView::readSettings(KConfig *config) 1382void KOAgendaView::readSettings(KConfig *config)
1381{ 1383{
1382 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1384 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1383 1385
1384 config->setGroup("Views"); 1386 config->setGroup("Views");
1385 1387
1386 //#ifndef KORG_NOSPLITTER 1388 //#ifndef KORG_NOSPLITTER
1387 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1389 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1388 if (sizes.count() == 2) { 1390 if (sizes.count() == 2) {
1389 if ( sizes[0] < 20 ) { 1391 if ( sizes[0] < 20 ) {
1390 sizes[1] = sizes[1] +20 - sizes[0]; 1392 sizes[1] = sizes[1] +20 - sizes[0];
1391 sizes[0] = 20; 1393 sizes[0] = 20;
1392 } 1394 }
1393 mSplitterAgenda->setSizes(sizes); 1395 mSplitterAgenda->setSizes(sizes);
1394 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1396 // qDebug("read %d %d ",sizes[0],sizes[1] );
1395 } 1397 }
1396 //#endif 1398 //#endif
1397 1399
1398 // updateConfig(); 1400 // updateConfig();
1399} 1401}
1400 1402
1401void KOAgendaView::writeSettings(KConfig *config) 1403void KOAgendaView::writeSettings(KConfig *config)
1402{ 1404{
1403 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1405 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1404 1406
1405 config->setGroup("Views"); 1407 config->setGroup("Views");
1406 1408
1407 //#ifndef KORG_NOSPLITTER 1409 //#ifndef KORG_NOSPLITTER
1408 QValueList<int> list = mSplitterAgenda->sizes(); 1410 QValueList<int> list = mSplitterAgenda->sizes();
1409 config->writeEntry("Separator AgendaView",list); 1411 config->writeEntry("Separator AgendaView",list);
1410 //qDebug("write %d %d ", list[0],list[1] ); 1412 //qDebug("write %d %d ", list[0],list[1] );
1411 //#endif 1413 //#endif
1412} 1414}
1413 1415
1414void KOAgendaView::setHolidayMasks() 1416void KOAgendaView::setHolidayMasks()
1415{ 1417{
1416 mHolidayMask.resize(mSelectedDates.count()); 1418 mHolidayMask.resize(mSelectedDates.count());
1417 1419
1418 uint i; 1420 uint i;
1419 for(i=0;i<mSelectedDates.count();++i) { 1421 for(i=0;i<mSelectedDates.count();++i) {
1420 QDate date = mSelectedDates[i]; 1422 QDate date = mSelectedDates[i];
1421 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1423 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1422 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1424 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1423 bool showHoliday = false; 1425 bool showHoliday = false;
1424 if ( KOPrefs::instance()->mExcludeHolidays ) { 1426 if ( KOPrefs::instance()->mExcludeHolidays ) {
1425 QPtrList<Event> events = calendar()->events( date, true ); 1427 QPtrList<Event> events = calendar()->events( date, true );
1426 Event *event; 1428 Event *event;
1427 for( event = events.first(); event; event = events.next() ) { 1429 for( event = events.first(); event; event = events.next() ) {
1428 if ( event->isHoliday()) { 1430 if ( event->isHoliday()) {
1429 showHoliday = true; 1431 showHoliday = true;
1430 break; 1432 break;
1431 } 1433 }
1432 } 1434 }
1433 1435
1434 } 1436 }
1435 1437
1436#ifndef KORG_NOPLUGINS 1438#ifndef KORG_NOPLUGINS
1437 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1439 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1438 !KOCore::self()->holiday(date).isEmpty(); 1440 !KOCore::self()->holiday(date).isEmpty();
1439#endif 1441#endif
1440 bool showDay = showSaturday || showSunday || showHoliday; 1442 bool showDay = showSaturday || showSunday || showHoliday;
1441 1443
1442 if (showDay) { 1444 if (showDay) {
1443 mHolidayMask.at(i) = true; 1445 mHolidayMask.at(i) = true;
1444 } else { 1446 } else {
1445 mHolidayMask.at(i) = false; 1447 mHolidayMask.at(i) = false;
1446 } 1448 }
1447 } 1449 }
1448 1450
1449 mAgenda->setHolidayMask(&mHolidayMask); 1451 mAgenda->setHolidayMask(&mHolidayMask);
1450 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1452 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1451} 1453}
1452 1454
1453void KOAgendaView::setContentsPos(int y) 1455void KOAgendaView::setContentsPos(int y)
1454{ 1456{
1455 mAgenda->setContentsPos(0,y); 1457 mAgenda->setContentsPos(0,y);
1456} 1458}
1457 1459
1458void KOAgendaView::clearSelection() 1460void KOAgendaView::clearSelection()
1459{ 1461{
1460 mAgenda->deselectItem(); 1462 mAgenda->deselectItem();
1461 mAllDayAgenda->deselectItem(); 1463 mAllDayAgenda->deselectItem();
1462} 1464}
1463 1465
1464void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1466void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1465 int gxEnd, int gyEnd) 1467 int gxEnd, int gyEnd)
1466{ 1468{
1467 mTimeSpanInAllDay = true; 1469 mTimeSpanInAllDay = true;
1468 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1470 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1469} 1471}
1470 1472
1471 1473
1472 1474
1473 1475
1474void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1476void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1475 int gxEnd, int gyEnd) 1477 int gxEnd, int gyEnd)
1476{ 1478{
1477 if (!mSelectedDates.count()) return; 1479 if (!mSelectedDates.count()) return;
1478 1480
1479 QDate dayStart = mSelectedDates[gxStart]; 1481 QDate dayStart = mSelectedDates[gxStart];
1480 QDate dayEnd = mSelectedDates[gxEnd]; 1482 QDate dayEnd = mSelectedDates[gxEnd];
1481 1483
1482 QTime timeStart = mAgenda->gyToTime(gyStart); 1484 QTime timeStart = mAgenda->gyToTime(gyStart);
1483 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1485 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1484 1486
1485 QDateTime dtStart(dayStart,timeStart); 1487 QDateTime dtStart(dayStart,timeStart);
1486 QDateTime dtEnd(dayEnd,timeEnd); 1488 QDateTime dtEnd(dayEnd,timeEnd);
1487 1489
1488 mTimeSpanBegin = dtStart; 1490 mTimeSpanBegin = dtStart;
1489 mTimeSpanEnd = dtEnd; 1491 mTimeSpanEnd = dtEnd;
1490 1492
1491} 1493}
1492 1494
1493void KOAgendaView::deleteSelectedDateTime() 1495void KOAgendaView::deleteSelectedDateTime()
1494{ 1496{
1495 mTimeSpanBegin.setDate(QDate()); 1497 mTimeSpanBegin.setDate(QDate());
1496 mTimeSpanEnd.setDate(QDate()); 1498 mTimeSpanEnd.setDate(QDate());
1497 mTimeSpanInAllDay = false; 1499 mTimeSpanInAllDay = false;
1498} 1500}
1499 1501
1500void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1502void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1501{ 1503{
1502 e->ignore(); 1504 e->ignore();
1503} 1505}
1504 1506
1505void KOAgendaView::scrollOneHourUp() 1507void KOAgendaView::scrollOneHourUp()
1506{ 1508{
1507 1509
1508 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1510 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1509} 1511}
1510void KOAgendaView::scrollOneHourDown() 1512void KOAgendaView::scrollOneHourDown()
1511{ 1513{
1512 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1514 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1513} 1515}
1514 1516
1515void KOAgendaView::setStartHour( int h ) 1517void KOAgendaView::setStartHour( int h )
1516{ 1518{
1517 mAgenda->setStartHour( h ); 1519 mAgenda->setStartHour( h );
1518 1520
1519} 1521}
1520void KOAgendaView::setInitStartHour() 1522void KOAgendaView::setInitStartHour()
1521{ 1523{
1522 1524
1523 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1525 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1524 setStartHour( QTime::currentTime ().hour() ); 1526 setStartHour( QTime::currentTime ().hour() );
1525 else 1527 else
1526 setStartHour( KOPrefs::instance()->mDayBegins ); 1528 setStartHour( KOPrefs::instance()->mDayBegins );
1527 1529
1528} 1530}
1529 1531
1530 1532
1531void KOAgendaView::updateTodo( Todo * t, int ) 1533void KOAgendaView::updateTodo( Todo * t, int )
1532{ 1534{
1533 if ( !isVisible() ) 1535 if ( !isVisible() )
1534 return; 1536 return;
1535 bool remove = false; 1537 bool remove = false;
1536 bool removeAD = false; 1538 bool removeAD = false;
1537 QDate da; 1539 QDate da;
1538 if ( t->hasCompletedDate() ) 1540 if ( t->hasCompletedDate() )
1539 da = t->completed().date(); 1541 da = t->completed().date();
1540 else 1542 else
1541 da = t->dtDue().date(); 1543 da = t->dtDue().date();
1542 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1544 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1543 remove = true; 1545 remove = true;
1544 removeAD = true; 1546 removeAD = true;
1545 } 1547 }
1546 else { 1548 else {
1547 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1549 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1548 if ( overdue && 1550 if ( overdue &&
1549 QDate::currentDate() >= mSelectedDates.first() && 1551 QDate::currentDate() >= mSelectedDates.first() &&
1550 QDate::currentDate() <= mSelectedDates.last()) { 1552 QDate::currentDate() <= mSelectedDates.last()) {
1551 removeAD = false; 1553 removeAD = false;
1552 remove = true; 1554 remove = true;
1553 } 1555 }
1554 else { 1556 else {
1555 1557
1556 if ( da < mSelectedDates.first() || 1558 if ( da < mSelectedDates.first() ||
1557 da > mSelectedDates.last() ) { 1559 da > mSelectedDates.last() ) {
1558 remove = true; 1560 remove = true;
1559 removeAD = true; 1561 removeAD = true;
1560 } else { 1562 } else {
1561 remove = t->doesFloat() && !t->hasCompletedDate(); 1563 remove = t->doesFloat() && !t->hasCompletedDate();
1562 removeAD = !remove; 1564 removeAD = !remove;
1563 } 1565 }
1564 } 1566 }
1565 } 1567 }
1566 int days = mSelectedDates.first().daysTo( da ); 1568 int days = mSelectedDates.first().daysTo( da );
1567 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1569 //qDebug("daysto %d %d %d", days, remove,removeAD );
1568 mAgenda->updateTodo( t , days, remove); 1570 mAgenda->updateTodo( t , days, remove);
1569 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1571 if ( KOPrefs::instance()->mShowTodoInAgenda )
1570 mAllDayAgenda->updateTodo( t , days, removeAD); 1572 mAllDayAgenda->updateTodo( t , days, removeAD);
1571 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1573 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1572 1574
1573} 1575}
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 31ee5e2..b5de4a1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,726 +1,791 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->dateNavigator()->selectDate( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ; 133 mCurrentAgendaView = 1 ;
134 } else if (view == 4 ) { 134 } else if (view == 4 ) {
135 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
136 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
137 } else if (view == 5 ) { 137 } else if (view == 5 ) {
138 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
139 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
140 } else if (view == 6 ) { 140 } else if (view == 6 ) {
141 //mMainView->dateNavigator()->selectDates( date, 7 ); 141 //mMainView->dateNavigator()->selectDates( date, 7 );
142 showMonthView(); 142 showMonthView();
143 } else if (view == 7 ) { 143 } else if (view == 7 ) {
144 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
145 showJournalView(); 145 showJournalView();
146 } else if (view == 8 ) { 146 } else if (view == 8 ) {
147 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
148 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
149 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
150 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
151 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
152 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
153 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
154 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
155 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
157 if ( lastMode ) { 157 if ( lastMode ) {
158 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
159 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
160 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
161 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
162 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
163 } 163 }
164 } else 164 } else
165 showWeekView(); 165 showWeekView();
166 } else if (view == 10) { 166 } else if (view == 10) {
167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
168 } 168 }
169} 169}
170 170
171 171
172 172
173void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
174{ 174{
175 config->setGroup("General"); 175 config->setGroup("General");
176 176
177 QString view; 177 QString view;
178 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
179 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
180 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
181 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
183 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
184 else view = "Agenda"; 184 else view = "Agenda";
185 185
186 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
187 187
188 if (mAgendaView) { 188 if (mAgendaView) {
189 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
190 } 190 }
191 if (mTimeSpanView) { 191 if (mTimeSpanView) {
192 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
193 } 193 }
194 if (mListView) { 194 if (mListView) {
195 mListView->writeSettings(config); 195 mListView->writeSettings(config);
196 } 196 }
197 if (mTodoView) { 197 if (mTodoView) {
198 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
199 } 199 }
200} 200}
201void KOViewManager::showNextView()
202{
203 if (mCurrentView == mWhatsNextView) goto NEXT_X;
204
205 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto LIST;
206
207 if (mCurrentView == mListView ) goto DAY_1;
208
209 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
210
211 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
212
213 if (mCurrentView == mAgendaView ) goto DAY_6;
214
215 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
216
217 if (mCurrentView == mMonthView ) goto TODO;
218
219 if (mCurrentView == mTodoView ) goto JOURNAL;
220
221 NEXT:
222 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();return ;}
223 NEXT_X:
224 if ( KOPrefs::instance()->mShowIconNextDays ) { showNextXView() ;return ;}
225 LIST:
226 if ( KOPrefs::instance()->mShowIconList ) { showListView() ;return ;}
227 DAY_1:
228 if ( KOPrefs::instance()->mShowIconDay1 ) { showDayView() ;return ;}
229 DAY_5:
230 if ( KOPrefs::instance()->mShowIconDay5 ) { showWorkWeekView() ;return ;}
231 DAY_7:
232 if ( KOPrefs::instance()->mShowIconDay7 ) { showWeekView();return ;}
233 DAY_6:
234 if ( KOPrefs::instance()->mShowIconDay6 ) { showMonthViewWeek();return ;}
235 MONTH:
236 if ( KOPrefs::instance()->mShowIconMonth ) { showMonthView();return ;}
237 TODO:
238 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;return ;}
239 JOURNAL:
240 if ( KOPrefs::instance()->mShowIconJournal ) { showJournalView() ;return ;}
241
242
243
244 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();return ;}
245
246 if ( KOPrefs::instance()->mShowIconNextDays ) { showNextXView() ;return ;}
247
248 if ( KOPrefs::instance()->mShowIconList ) { showListView() ;return ;}
249
250 if ( KOPrefs::instance()->mShowIconDay1 ) { showDayView() ;return ;}
201 251
252 if ( KOPrefs::instance()->mShowIconDay5 ) { showWorkWeekView() ;return ;}
253
254 if ( KOPrefs::instance()->mShowIconDay7 ) { showWeekView();return ;}
255
256 if ( KOPrefs::instance()->mShowIconDay6 ) { showMonthViewWeek();return ;}
257
258 if ( KOPrefs::instance()->mShowIconMonth ) { showMonthView();return ;}
259
260 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;return ;}
261
262 if ( KOPrefs::instance()->mShowIconJournal ) { showJournalView() ;return ;}
263
264
265
266}
202void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 267void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
203{ 268{
204 269
205 //mFlagShowNextxDays = false; 270 //mFlagShowNextxDays = false;
206 //if(view == mCurrentView) return; 271 //if(view == mCurrentView) return;
207 if ( view == 0 ) { 272 if ( view == 0 ) {
208 view = mCurrentView; 273 view = mCurrentView;
209 if ( view == 0 ) 274 if ( view == 0 )
210 return; 275 return;
211 } 276 }
212 bool callupdate = !(view == mCurrentView); 277 bool callupdate = !(view == mCurrentView);
213 bool full = fullScreen; 278 bool full = fullScreen;
214 if(view == mCurrentView && view != mWhatsNextView ) { 279 if(view == mCurrentView && view != mWhatsNextView ) {
215 if ( mCurrentAgendaView < 0 ) 280 if ( mCurrentAgendaView < 0 )
216 return; 281 return;
217 if ( view != mMonthView ) 282 if ( view != mMonthView )
218 full = mMainView->leftFrame()->isVisible(); 283 full = mMainView->leftFrame()->isVisible();
219 } else { 284 } else {
220 if ( view == mMonthView && mMonthView) 285 if ( view == mMonthView && mMonthView)
221 ;//mMonthView->skipResize = true ; 286 ;//mMonthView->skipResize = true ;
222 mCurrentView = view; 287 mCurrentView = view;
223 // bool full = fullScreen; 288 // bool full = fullScreen;
224 bool isFull = !mMainView->leftFrame()->isVisible(); 289 bool isFull = !mMainView->leftFrame()->isVisible();
225 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 290 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
226 full = true; 291 full = true;
227 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 292 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
228 full = false; 293 full = false;
229 } 294 }
230 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 295 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
231 //raiseCurrentView( full ); 296 //raiseCurrentView( full );
232 mMainView->processIncidenceSelection( 0 ); 297 mMainView->processIncidenceSelection( 0 );
233 //mMainView->updateView(); 298 //mMainView->updateView();
234 raiseCurrentView( full, callupdate ); 299 raiseCurrentView( full, callupdate );
235 mMainView->adaptNavigationUnits(); 300 mMainView->adaptNavigationUnits();
236} 301}
237 302
238void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 303void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
239{ 304{
240 mCurrentAgendaView = 0; 305 mCurrentAgendaView = 0;
241 if ( fullScreen ) { 306 if ( fullScreen ) {
242 mMainView->leftFrame()->hide(); 307 mMainView->leftFrame()->hide();
243 } else { 308 } else {
244 mMainView->leftFrame()->show(); 309 mMainView->leftFrame()->show();
245 } 310 }
246 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 311 //if ( mCurrentView == mMonthView ) qApp->processEvents();
247 emit signalFullScreen( !fullScreen ); 312 emit signalFullScreen( !fullScreen );
248 if ( callUpdateView ) 313 if ( callUpdateView )
249 mMainView->updateView(); 314 mMainView->updateView();
250 315
251 if ( globalFlagBlockAgenda == 5 ) { 316 if ( globalFlagBlockAgenda == 5 ) {
252 globalFlagBlockAgenda = 4; 317 globalFlagBlockAgenda = 4;
253 globalFlagBlockAgendaItemPaint = 1; 318 globalFlagBlockAgendaItemPaint = 1;
254 } 319 }
255 mMainView->viewStack()->raiseWidget(mCurrentView); 320 mMainView->viewStack()->raiseWidget(mCurrentView);
256 if ( globalFlagBlockAgenda == 4 ) { 321 if ( globalFlagBlockAgenda == 4 ) {
257 if ( mCurrentView == mAgendaView ) { 322 if ( mCurrentView == mAgendaView ) {
258 //globalFlagBlockAgenda =1 ; 323 //globalFlagBlockAgenda =1 ;
259 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 324 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
260 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 325 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
261 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 326 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
262 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 327 mAgendaView->setStartHour( QTime::currentTime ().hour() );
263 qApp->processEvents(); 328 qApp->processEvents();
264 //qDebug("qApp->processEvents() "); 329 //qDebug("qApp->processEvents() ");
265 globalFlagBlockAgenda = 0; 330 globalFlagBlockAgenda = 0;
266 mAgendaView->repaintAgenda(); 331 mAgendaView->repaintAgenda();
267 332
268 } 333 }
269 globalFlagBlockAgenda = 0; 334 globalFlagBlockAgenda = 0;
270 } 335 }
271 emit signalAgendaView( mCurrentView == mAgendaView ); 336 emit signalAgendaView( mCurrentView == mAgendaView );
272 //qDebug("raiseCurrentView ende "); 337 //qDebug("raiseCurrentView ende ");
273 338
274} 339}
275 340
276void KOViewManager::updateView() 341void KOViewManager::updateView()
277{ 342{
278 // qDebug("KOViewManager::updateView() "); 343 // qDebug("KOViewManager::updateView() ");
279 // if we are updating mTodoView, we get endless recursion 344 // if we are updating mTodoView, we get endless recursion
280 if ( mTodoView == mCurrentView ) 345 if ( mTodoView == mCurrentView )
281 return; 346 return;
282 if ( mCurrentView ) mCurrentView->updateView(); 347 if ( mCurrentView ) mCurrentView->updateView();
283 348
284} 349}
285 350
286void KOViewManager::updateView(const QDate &start, const QDate &end) 351void KOViewManager::updateView(const QDate &start, const QDate &end)
287{ 352{
288 // kdDebug() << "KOViewManager::updateView()" << endl; 353 // kdDebug() << "KOViewManager::updateView()" << endl;
289 354
290 if (mCurrentView) mCurrentView->showDates(start, end); 355 if (mCurrentView) mCurrentView->showDates(start, end);
291 356
292 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 357 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
293} 358}
294 359
295 360
296void KOViewManager::updateWNview() 361void KOViewManager::updateWNview()
297{ 362{
298 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 363 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
299 mWhatsNextView->updateView(); 364 mWhatsNextView->updateView();
300 365
301} 366}
302void KOViewManager::showWhatsNextView() 367void KOViewManager::showWhatsNextView()
303{ 368{
304 if (!mWhatsNextView) { 369 if (!mWhatsNextView) {
305 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 370 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
306 "KOViewManager::WhatsNextView"); 371 "KOViewManager::WhatsNextView");
307 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 372 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
308 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 373 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
309 addView(mWhatsNextView); 374 addView(mWhatsNextView);
310 connect(this, SIGNAL( printWNV() ), 375 connect(this, SIGNAL( printWNV() ),
311 mWhatsNextView, SLOT( printMe() ) ); 376 mWhatsNextView, SLOT( printMe() ) );
312 } 377 }
313 globalFlagBlockAgenda = 1; 378 globalFlagBlockAgenda = 1;
314 showView(mWhatsNextView, true ); 379 showView(mWhatsNextView, true );
315 //mWhatsNextView->updateView(); 380 //mWhatsNextView->updateView();
316 381
317} 382}
318 383
319void KOViewManager::showListView() 384void KOViewManager::showListView()
320{ 385{
321 if (!mListView) { 386 if (!mListView) {
322 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 387 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
323 addView(mListView); 388 addView(mListView);
324 389
325 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 390 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
326 mMainView, SLOT(showIncidence(Incidence *))); 391 mMainView, SLOT(showIncidence(Incidence *)));
327 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 392 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
328 mMainView, SLOT(editIncidence(Incidence *))); 393 mMainView, SLOT(editIncidence(Incidence *)));
329 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 394 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
330 mMainView, SLOT(deleteIncidence(Incidence *))); 395 mMainView, SLOT(deleteIncidence(Incidence *)));
331 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 396 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
332 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 397 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
333 connect( mListView, SIGNAL( signalNewEvent() ), 398 connect( mListView, SIGNAL( signalNewEvent() ),
334 mMainView, SLOT( newEvent() ) ); 399 mMainView, SLOT( newEvent() ) );
335 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 400 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
336 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 401 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
337 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 402 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
338 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 403 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
339 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 404 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
340 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 405 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
341 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 406 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
342 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 407 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
343 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 408 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
344 } 409 }
345 // bool temp = mFlagShowNextxDays; 410 // bool temp = mFlagShowNextxDays;
346 //globalFlagBlockPainting = true; 411 //globalFlagBlockPainting = true;
347 globalFlagBlockAgenda = 1; 412 globalFlagBlockAgenda = 1;
348 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 413 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
349 mMainView->setBlockShowDates( true ); 414 mMainView->setBlockShowDates( true );
350 mMainView->dateNavigator()->selectMonth(); 415 mMainView->dateNavigator()->selectMonth();
351 mMainView->setBlockShowDates( false ); 416 mMainView->setBlockShowDates( false );
352 } 417 }
353 showView(mListView, KOPrefs::instance()->mFullViewTodo); 418 showView(mListView, KOPrefs::instance()->mFullViewTodo);
354 //mFlagShowNextxDays = temp; 419 //mFlagShowNextxDays = temp;
355} 420}
356 421
357void KOViewManager::showAgendaView( bool fullScreen ) 422void KOViewManager::showAgendaView( bool fullScreen )
358{ 423{
359 424
360 mMainView->dialogManager()->hideSearchDialog(); 425 mMainView->dialogManager()->hideSearchDialog();
361 // qDebug("KOViewManager::showAgendaView "); 426 // qDebug("KOViewManager::showAgendaView ");
362 bool full; 427 bool full;
363 full = fullScreen; 428 full = fullScreen;
364 if (!mAgendaView) { 429 if (!mAgendaView) {
365 full = false; 430 full = false;
366 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 431 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
367 addView(mAgendaView); 432 addView(mAgendaView);
368#ifndef DESKTOP_VERSION 433#ifndef DESKTOP_VERSION
369 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 434 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
370#endif 435#endif
371 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 436 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
372 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 437 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
373 438
374 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 439 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
375 440
376 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 441 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
377 442
378 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 443 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
379 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 444 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
380 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 445 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
381 mMainView, SLOT(newEvent(QDateTime))); 446 mMainView, SLOT(newEvent(QDateTime)));
382 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 447 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
383 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 448 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
384 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 449 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
385 mMainView, SLOT(newEvent(QDate))); 450 mMainView, SLOT(newEvent(QDate)));
386 451
387 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 452 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
388 mMainView, SLOT(editIncidence(Incidence *))); 453 mMainView, SLOT(editIncidence(Incidence *)));
389 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 454 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
390 mMainView, SLOT(showIncidence(Incidence *))); 455 mMainView, SLOT(showIncidence(Incidence *)));
391 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 456 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
392 mMainView, SLOT(deleteIncidence(Incidence *))); 457 mMainView, SLOT(deleteIncidence(Incidence *)));
393 458
394 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 459 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
395 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 460 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
396 461
397 connect(mAgendaView, SIGNAL( toggleExpand() ), 462 connect(mAgendaView, SIGNAL( toggleExpand() ),
398 mMainView, SLOT( toggleExpand() ) ); 463 mMainView, SLOT( toggleExpand() ) );
399 464
400 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 465 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
401 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 466 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
402 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 467 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
403 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 468 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
404 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 469 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
405 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 470 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
406 SLOT( updateTodo( Todo *, int ) ) ); 471 SLOT( updateTodo( Todo *, int ) ) );
407 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 472 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
408 mMainView, SIGNAL( todoModified( Todo *, int ))); 473 mMainView, SIGNAL( todoModified( Todo *, int )));
409 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 474 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
410 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 475 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
411 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 476 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
412 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 477 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
413 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 478 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
414 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 479 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
415 mAgendaView->readSettings(); 480 mAgendaView->readSettings();
416 mAgendaView->updateConfig(); 481 mAgendaView->updateConfig();
417 } 482 }
418 483
419 showView( mAgendaView, full); 484 showView( mAgendaView, full);
420 485
421} 486}
422 487
423void KOViewManager::showDayView() 488void KOViewManager::showDayView()
424{ 489{
425 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 490 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
426 mFlagShowNextxDays = false; 491 mFlagShowNextxDays = false;
427 globalFlagBlockLabel = 1; 492 globalFlagBlockLabel = 1;
428 globalFlagBlockAgenda = 1; 493 globalFlagBlockAgenda = 1;
429 if ( mCurrentAgendaView != 1 ) 494 if ( mCurrentAgendaView != 1 )
430 mCurrentAgendaView = -1; 495 mCurrentAgendaView = -1;
431 showAgendaView(); 496 showAgendaView();
432 qApp->processEvents(); 497 qApp->processEvents();
433 globalFlagBlockAgenda = 2; 498 globalFlagBlockAgenda = 2;
434 globalFlagBlockLabel = 0; 499 globalFlagBlockLabel = 0;
435 mMainView->dateNavigator()->selectDates( 1 ); 500 mMainView->dateNavigator()->selectDates( 1 );
436 mCurrentAgendaView = 1 ; 501 mCurrentAgendaView = 1 ;
437 502
438} 503}
439 504
440void KOViewManager::showWorkWeekView() 505void KOViewManager::showWorkWeekView()
441{ 506{
442 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 507 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
443 mFlagShowNextxDays = false; 508 mFlagShowNextxDays = false;
444 globalFlagBlockAgenda = 1; 509 globalFlagBlockAgenda = 1;
445 globalFlagBlockLabel = 1; 510 globalFlagBlockLabel = 1;
446 if ( mCurrentAgendaView != 5 ) 511 if ( mCurrentAgendaView != 5 )
447 mCurrentAgendaView = -1; 512 mCurrentAgendaView = -1;
448 showAgendaView(); 513 showAgendaView();
449 qApp->processEvents(); 514 qApp->processEvents();
450 globalFlagBlockAgenda = 2; 515 globalFlagBlockAgenda = 2;
451 globalFlagBlockLabel = 0; 516 globalFlagBlockLabel = 0;
452 mMainView->dateNavigator()->selectWorkWeek(); 517 mMainView->dateNavigator()->selectWorkWeek();
453 mCurrentAgendaView = 5 ; 518 mCurrentAgendaView = 5 ;
454 519
455} 520}
456 521
457void KOViewManager::showWeekView() 522void KOViewManager::showWeekView()
458{ 523{
459 /* 524 /*
460 globalFlagBlockAgenda = 2; 525 globalFlagBlockAgenda = 2;
461 qDebug("4globalFlagBlockAgenda = 2; "); 526 qDebug("4globalFlagBlockAgenda = 2; ");
462 //globalFlagBlockPainting = true; 527 //globalFlagBlockPainting = true;
463 mMainView->dateNavigator()->selectWeek(); 528 mMainView->dateNavigator()->selectWeek();
464 showAgendaView(); 529 showAgendaView();
465 */ 530 */
466 531
467 532
468 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 533 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
469 mFlagShowNextxDays = false; 534 mFlagShowNextxDays = false;
470 globalFlagBlockAgenda = 1; 535 globalFlagBlockAgenda = 1;
471 globalFlagBlockLabel = 1; 536 globalFlagBlockLabel = 1;
472 if ( mCurrentAgendaView != 7 ) 537 if ( mCurrentAgendaView != 7 )
473 mCurrentAgendaView = -1; 538 mCurrentAgendaView = -1;
474 showAgendaView(); 539 showAgendaView();
475 qApp->processEvents(); 540 qApp->processEvents();
476 globalFlagBlockAgenda = 2; 541 globalFlagBlockAgenda = 2;
477 globalFlagBlockLabel = 0; 542 globalFlagBlockLabel = 0;
478 mMainView->dateNavigator()->selectWeek(); 543 mMainView->dateNavigator()->selectWeek();
479 mCurrentAgendaView = 7 ; 544 mCurrentAgendaView = 7 ;
480} 545}
481 546
482void KOViewManager::showNextXView() 547void KOViewManager::showNextXView()
483{ 548{
484 549
485 globalFlagBlockAgenda = 1; 550 globalFlagBlockAgenda = 1;
486 if ( mCurrentAgendaView != 3 ) 551 if ( mCurrentAgendaView != 3 )
487 mCurrentAgendaView = -1; 552 mCurrentAgendaView = -1;
488 showAgendaView(KOPrefs::instance()->mFullViewMonth); 553 showAgendaView(KOPrefs::instance()->mFullViewMonth);
489 globalFlagBlockAgenda = 2; 554 globalFlagBlockAgenda = 2;
490 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 555 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
491 KOPrefs::instance()->mNextXDays ); 556 KOPrefs::instance()->mNextXDays );
492 mFlagShowNextxDays = true; 557 mFlagShowNextxDays = true;
493 mCurrentAgendaView = 3 ; 558 mCurrentAgendaView = 3 ;
494} 559}
495bool KOViewManager::showsNextDays() 560bool KOViewManager::showsNextDays()
496{ 561{
497 return mFlagShowNextxDays; 562 return mFlagShowNextxDays;
498} 563}
499void KOViewManager::createMonthView() 564void KOViewManager::createMonthView()
500{ 565{
501if (!mMonthView) { 566if (!mMonthView) {
502 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 567 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
503 568
504 addView(mMonthView); 569 addView(mMonthView);
505 // mMonthView->show(); 570 // mMonthView->show();
506 // SIGNALS/SLOTS FOR MONTH VIEW 571 // SIGNALS/SLOTS FOR MONTH VIEW
507 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 572 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
508 mMainView, SLOT(newEvent(QDateTime))); 573 mMainView, SLOT(newEvent(QDateTime)));
509 574
510 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 575 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
511 mMainView, SLOT(showIncidence(Incidence *))); 576 mMainView, SLOT(showIncidence(Incidence *)));
512 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 577 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
513 mMainView, SLOT(editIncidence(Incidence *))); 578 mMainView, SLOT(editIncidence(Incidence *)));
514 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 579 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
515 mMainView, SLOT(deleteIncidence(Incidence *))); 580 mMainView, SLOT(deleteIncidence(Incidence *)));
516 581
517 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 582 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
518 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 583 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
519 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 584 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
520 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 585 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
521 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 586 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
522 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 587 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
523 588
524 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 589 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
525 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 590 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
526 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 591 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
527 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 592 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
528 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 593 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
529 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 594 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
530 connect( mMonthView, SIGNAL( selectMonth() ), 595 connect( mMonthView, SIGNAL( selectMonth() ),
531 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 596 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
532 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 597 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
533 mMainView, SLOT ( showDay( QDate ) ) ); 598 mMainView, SLOT ( showDay( QDate ) ) );
534 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 599 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
535 connect( mMonthView, SIGNAL(nextMonth() ), 600 connect( mMonthView, SIGNAL(nextMonth() ),
536 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 601 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
537 connect( mMonthView, SIGNAL(prevMonth() ), 602 connect( mMonthView, SIGNAL(prevMonth() ),
538 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 603 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
539 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 604 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
540 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 605 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
541 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 606 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
542 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 607 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
543 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 608 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
544 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 609 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
545 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 610 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
546 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 611 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
547 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 612 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
548 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 613 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
549 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 614 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
550 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 615 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
551 616
552 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 617 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
553 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 618 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
554 619
555 620
556 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 621 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
557 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 622 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
558 623
559 } 624 }
560} 625}
561void KOViewManager::showMonthViewWeek() 626void KOViewManager::showMonthViewWeek()
562{ 627{
563 createMonthView(); 628 createMonthView();
564 globalFlagBlockAgenda = 1; 629 globalFlagBlockAgenda = 1;
565 bool full = true; 630 bool full = true;
566 if ( mCurrentView == mMonthView) 631 if ( mCurrentView == mMonthView)
567 full = mMainView->leftFrame()->isVisible(); 632 full = mMainView->leftFrame()->isVisible();
568 if ( !KOPrefs::instance()->mMonthViewWeek ) { 633 if ( !KOPrefs::instance()->mMonthViewWeek ) {
569 mMonthView->switchView(); 634 mMonthView->switchView();
570 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 635 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
571 full = false; 636 full = false;
572 else 637 else
573 full = true; 638 full = true;
574 } 639 }
575 mMainView->dateNavigator()->selectWeek(); 640 mMainView->dateNavigator()->selectWeek();
576 showView(mMonthView, full ); 641 showView(mMonthView, full );
577} 642}
578 643
579void KOViewManager::showMonth( const QDate & date ) 644void KOViewManager::showMonth( const QDate & date )
580{ 645{
581 mMainView->dateNavigator()->blockSignals( true ); 646 mMainView->dateNavigator()->blockSignals( true );
582 mMainView->dateNavigator()->selectDate( date ); 647 mMainView->dateNavigator()->selectDate( date );
583 mMainView->dateNavigator()->blockSignals( false ); 648 mMainView->dateNavigator()->blockSignals( false );
584 showMonthView(); 649 showMonthView();
585} 650}
586void KOViewManager::showMonthView() 651void KOViewManager::showMonthView()
587 { 652 {
588 653
589 createMonthView(); 654 createMonthView();
590 globalFlagBlockAgenda = 1; 655 globalFlagBlockAgenda = 1;
591 //mFlagShowNextxDays = false; 656 //mFlagShowNextxDays = false;
592 bool full = true; 657 bool full = true;
593 if ( mCurrentView == mMonthView) 658 if ( mCurrentView == mMonthView)
594 full = mMainView->leftFrame()->isVisible(); 659 full = mMainView->leftFrame()->isVisible();
595 // if(mMonthView == mCurrentView) return; 660 // if(mMonthView == mCurrentView) return;
596 if ( KOPrefs::instance()->mMonthViewWeek ) { 661 if ( KOPrefs::instance()->mMonthViewWeek ) {
597 mMonthView->switchView(); 662 mMonthView->switchView();
598 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 663 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
599 full = false; 664 full = false;
600 else 665 else
601 full = true; 666 full = true;
602 } 667 }
603 mMainView->dateNavigator()->selectMonth(); 668 mMainView->dateNavigator()->selectMonth();
604 669
605 showView(mMonthView, full ); 670 showView(mMonthView, full );
606 671
607} 672}
608 673
609void KOViewManager::showTodoView() 674void KOViewManager::showTodoView()
610{ 675{
611 //mFlagShowNextxDays = false; 676 //mFlagShowNextxDays = false;
612 if ( !mTodoView ) { 677 if ( !mTodoView ) {
613 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 678 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
614 "KOViewManager::TodoView" ); 679 "KOViewManager::TodoView" );
615 680
616 addView( mTodoView ); 681 addView( mTodoView );
617 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 682 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
618 683
619 // SIGNALS/SLOTS FOR TODO VIEW 684 // SIGNALS/SLOTS FOR TODO VIEW
620 connect( mTodoView, SIGNAL( newTodoSignal() ), 685 connect( mTodoView, SIGNAL( newTodoSignal() ),
621 mMainView, SLOT( newTodo() ) ); 686 mMainView, SLOT( newTodo() ) );
622 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 687 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
623 mMainView, SLOT( newSubTodo( Todo *) ) ); 688 mMainView, SLOT( newSubTodo( Todo *) ) );
624 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 689 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
625 mMainView, SLOT( showTodo( Todo * ) ) ); 690 mMainView, SLOT( showTodo( Todo * ) ) );
626 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 691 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
627 mMainView, SLOT( editTodo( Todo * ) ) ); 692 mMainView, SLOT( editTodo( Todo * ) ) );
628 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 693 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
629 mMainView, SLOT( deleteTodo( Todo * ) ) ); 694 mMainView, SLOT( deleteTodo( Todo * ) ) );
630 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 695 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
631 mMainView, SLOT( purgeCompleted() ) ); 696 mMainView, SLOT( purgeCompleted() ) );
632 697
633 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 698 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
634 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 699 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
635 700
636 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 701 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
637 SLOT( updateConfig() ) ); 702 SLOT( updateConfig() ) );
638 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 703 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
639 SLOT( updateTodo( Todo *, int ) ) ); 704 SLOT( updateTodo( Todo *, int ) ) );
640 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 705 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
641 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 706 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
642 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 707 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
643 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 708 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
644 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 709 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
645 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 710 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
646 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 711 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
647 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 712 mMainView, SLOT ( todo_unsub( Todo * ) ) );
648 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 713 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
649 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 714 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
650 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 715 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
651 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 716 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
652 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 717 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
653 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 718 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
654 KConfig *config = KOGlobals::config(); 719 KConfig *config = KOGlobals::config();
655 mTodoView->restoreLayout(config,"Todo View"); 720 mTodoView->restoreLayout(config,"Todo View");
656 mTodoView->setNavigator( mMainView->dateNavigator() ); 721 mTodoView->setNavigator( mMainView->dateNavigator() );
657 } 722 }
658 723
659 globalFlagBlockAgenda = 1; 724 globalFlagBlockAgenda = 1;
660 showView( mTodoView, true ); 725 showView( mTodoView, true );
661 726
662} 727}
663 728
664void KOViewManager::showJournalView() 729void KOViewManager::showJournalView()
665{ 730{
666 //mFlagShowNextxDays = false; 731 //mFlagShowNextxDays = false;
667 if (!mJournalView) { 732 if (!mJournalView) {
668 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 733 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
669 "KOViewManager::JournalView"); 734 "KOViewManager::JournalView");
670 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 735 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
671 SLOT( updateConfig() ) ); 736 SLOT( updateConfig() ) );
672 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 737 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
673 addView(mJournalView); 738 addView(mJournalView);
674 } 739 }
675 740
676 showView(mJournalView); 741 showView(mJournalView);
677 mMainView->dateNavigator()->selectDates( 1 ); 742 mMainView->dateNavigator()->selectDates( 1 );
678} 743}
679 744
680void KOViewManager::showTimeSpanView() 745void KOViewManager::showTimeSpanView()
681{ 746{
682 //mFlagShowNextxDays = false; 747 //mFlagShowNextxDays = false;
683 if (!mTimeSpanView) { 748 if (!mTimeSpanView) {
684 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 749 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
685 "KOViewManager::TimeSpanView"); 750 "KOViewManager::TimeSpanView");
686 addView(mTimeSpanView); 751 addView(mTimeSpanView);
687 752
688 mTimeSpanView->readSettings(); 753 mTimeSpanView->readSettings();
689 } 754 }
690 755
691 showView(mTimeSpanView); 756 showView(mTimeSpanView);
692} 757}
693 758
694Incidence *KOViewManager::currentSelection() 759Incidence *KOViewManager::currentSelection()
695{ 760{
696 if (!mCurrentView) return 0; 761 if (!mCurrentView) return 0;
697 if ( mCurrentView == mListView ) { 762 if ( mCurrentView == mListView ) {
698 if ( mListView->currentItem() ) 763 if ( mListView->currentItem() )
699 return mListView->currentItem(); 764 return mListView->currentItem();
700 } 765 }
701 return mCurrentView->selectedIncidences().first(); 766 return mCurrentView->selectedIncidences().first();
702} 767}
703 768
704QDate KOViewManager::currentSelectionDate() 769QDate KOViewManager::currentSelectionDate()
705{ 770{
706 QDate qd; 771 QDate qd;
707 if (mCurrentView) { 772 if (mCurrentView) {
708 DateList qvl = mCurrentView->selectedDates(); 773 DateList qvl = mCurrentView->selectedDates();
709 if (!qvl.isEmpty()) qd = qvl.first(); 774 if (!qvl.isEmpty()) qd = qvl.first();
710 } 775 }
711 return qd; 776 return qd;
712} 777}
713 778
714void KOViewManager::addView(KOrg::BaseView *view) 779void KOViewManager::addView(KOrg::BaseView *view)
715{ 780{
716#if QT_VERSION >= 0x030000 781#if QT_VERSION >= 0x030000
717 mMainView->viewStack()->addWidget( view ); 782 mMainView->viewStack()->addWidget( view );
718#else 783#else
719 mMainView->viewStack()->addWidget( view, 1 ); 784 mMainView->viewStack()->addWidget( view, 1 );
720#endif 785#endif
721} 786}
722 787
723void KOViewManager::setDocumentId( const QString &id ) 788void KOViewManager::setDocumentId( const QString &id )
724{ 789{
725 if (mTodoView) mTodoView->setDocumentId( id ); 790 if (mTodoView) mTodoView->setDocumentId( id );
726} 791}
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
index 6290227..d829f14 100644
--- a/korganizer/koviewmanager.h
+++ b/korganizer/koviewmanager.h
@@ -1,121 +1,122 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 3 Copyright (c) 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef KOVIEWMANAGER_H 24#ifndef KOVIEWMANAGER_H
25#define KOVIEWMANAGER_H 25#define KOVIEWMANAGER_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28 28
29#include <korganizer/baseview.h> 29#include <korganizer/baseview.h>
30 30
31class CalendarView; 31class CalendarView;
32 32
33class KOListView; 33class KOListView;
34class KOAgendaView; 34class KOAgendaView;
35class KOMonthView; 35class KOMonthView;
36class KOTimeSpanView; 36class KOTimeSpanView;
37class KOTodoView; 37class KOTodoView;
38class KOWhatsNextView; 38class KOWhatsNextView;
39class KOJournalView; 39class KOJournalView;
40 40
41using namespace KCal; 41using namespace KCal;
42 42
43/** 43/**
44 This class manages the views of the calendar. It owns the objects and handles 44 This class manages the views of the calendar. It owns the objects and handles
45 creation and selection. 45 creation and selection.
46*/ 46*/
47class KOViewManager : public QObject 47class KOViewManager : public QObject
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOViewManager( CalendarView * ); 51 KOViewManager( CalendarView * );
52 virtual ~KOViewManager(); 52 virtual ~KOViewManager();
53 53
54 /** changes the view to be the currently selected view */ 54 /** changes the view to be the currently selected view */
55 void showView(KOrg::BaseView *, bool fullScreen = false ); 55 void showView(KOrg::BaseView *, bool fullScreen = false );
56 void updateWNview(); 56 void updateWNview();
57 void readSettings(KConfig *config); 57 void readSettings(KConfig *config);
58 void writeSettings(KConfig *config); 58 void writeSettings(KConfig *config);
59 bool showsNextDays(); 59 bool showsNextDays();
60 /** Read which view was shown last from config file */ 60 /** Read which view was shown last from config file */
61 void readCurrentView(KConfig *); 61 void readCurrentView(KConfig *);
62 /** Write which view is currently shown to config file */ 62 /** Write which view is currently shown to config file */
63 void writeCurrentView(KConfig *); 63 void writeCurrentView(KConfig *);
64 64
65 KOrg::BaseView *currentView(); 65 KOrg::BaseView *currentView();
66 66
67 void setDocumentId( const QString & ); 67 void setDocumentId( const QString & );
68 68
69 void updateView( const QDate &start, const QDate &end ); 69 void updateView( const QDate &start, const QDate &end );
70 70
71 void raiseCurrentView( bool fullScreen = false , bool updateView = false); 71 void raiseCurrentView( bool fullScreen = false , bool updateView = false);
72 72
73 void addView(KOrg::BaseView *); 73 void addView(KOrg::BaseView *);
74 74
75 Incidence *currentSelection(); 75 Incidence *currentSelection();
76 QDate currentSelectionDate(); 76 QDate currentSelectionDate();
77 77
78 KOAgendaView *agendaView() const { return mAgendaView; } 78 KOAgendaView *agendaView() const { return mAgendaView; }
79 79
80 signals: 80 signals:
81 void printWNV(); 81 void printWNV();
82 void signalFullScreen( bool ); 82 void signalFullScreen( bool );
83 void signalAgendaView( bool ); 83 void signalAgendaView( bool );
84 public slots: 84 public slots:
85 void showNextView();
85 void showMonth( const QDate & ); 86 void showMonth( const QDate & );
86 void showDateView( int, QDate ); 87 void showDateView( int, QDate );
87 void updateView(); 88 void updateView();
88 void showWhatsNextView(); 89 void showWhatsNextView();
89 void showListView(); 90 void showListView();
90 void showAgendaView( bool fullScreen = false ); 91 void showAgendaView( bool fullScreen = false );
91 void showDayView(); 92 void showDayView();
92 void showWorkWeekView(); 93 void showWorkWeekView();
93 void showWeekView(); 94 void showWeekView();
94 void showNextXView(); 95 void showNextXView();
95 void showMonthView(); 96 void showMonthView();
96 void showMonthViewWeek(); 97 void showMonthViewWeek();
97 void showTodoView(); 98 void showTodoView();
98 void showJournalView(); 99 void showJournalView();
99 void showTimeSpanView(); 100 void showTimeSpanView();
100 101
101 private: 102 private:
102 void createMonthView(); 103 void createMonthView();
103 CalendarView *mMainView; 104 CalendarView *mMainView;
104 105
105 int mCurrentAgendaView; 106 int mCurrentAgendaView;
106 KOAgendaView *mAgendaView; 107 KOAgendaView *mAgendaView;
107 KOListView *mListView; 108 KOListView *mListView;
108 KOMonthView *mMonthView; 109 KOMonthView *mMonthView;
109 KOTodoView *mTodoView; 110 KOTodoView *mTodoView;
110 KOWhatsNextView *mWhatsNextView; 111 KOWhatsNextView *mWhatsNextView;
111 KOJournalView *mJournalView; 112 KOJournalView *mJournalView;
112 KOTimeSpanView *mTimeSpanView; 113 KOTimeSpanView *mTimeSpanView;
113 114
114 KOrg::BaseView *mCurrentView; // currently active event view 115 KOrg::BaseView *mCurrentView; // currently active event view
115 116
116 int mAgendaViewMode; 117 int mAgendaViewMode;
117 bool mFlagShowNextxDays; 118 bool mFlagShowNextxDays;
118 119
119}; 120};
120 121
121#endif 122#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 7d5cf72..b947cac 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2126 +1,2129 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using 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
76class KOex2phonePrefs : public QDialog 76class 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
125public: 125public:
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
131int globalFlagBlockStartup; 131int globalFlagBlockStartup;
132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
133 QMainWindow( parent, name ) 133 QMainWindow( parent, name )
134{ 134{
135 135
136 mClosed = false; 136 mClosed = false;
137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
138 QString confFile = locateLocal("config","korganizerrc"); 138 QString confFile = locateLocal("config","korganizerrc");
139 QFileInfo finf ( confFile ); 139 QFileInfo finf ( confFile );
140 bool showWarning = !finf.exists(); 140 bool showWarning = !finf.exists();
141 setIcon(SmallIcon( "ko24" ) ); 141 setIcon(SmallIcon( "ko24" ) );
142 mBlockAtStartup = true; 142 mBlockAtStartup = true;
143 mFlagKeyPressed = false; 143 mFlagKeyPressed = false;
144 setCaption("KO/Pi"); 144 setCaption("KO/Pi");
145 KOPrefs *p = KOPrefs::instance(); 145 KOPrefs *p = KOPrefs::instance();
146 KPimGlobalPrefs::instance()->setGlobalConfig(); 146 KPimGlobalPrefs::instance()->setGlobalConfig();
147 if ( p->mHourSize > 22 ) 147 if ( p->mHourSize > 22 )
148 p->mHourSize = 22; 148 p->mHourSize = 22;
149 QMainWindow::ToolBarDock tbd; 149 QMainWindow::ToolBarDock tbd;
150 if ( p->mToolBarHor ) { 150 if ( p->mToolBarHor ) {
151 if ( p->mToolBarUp ) 151 if ( p->mToolBarUp )
152 tbd = Bottom; 152 tbd = Bottom;
153 else 153 else
154 tbd = Top; 154 tbd = Top;
155 } 155 }
156 else { 156 else {
157 if ( p->mToolBarUp ) 157 if ( p->mToolBarUp )
158 tbd = Right; 158 tbd = Right;
159 else 159 else
160 tbd = Left; 160 tbd = Left;
161 } 161 }
162 if ( KOPrefs::instance()->mUseAppColors ) 162 if ( KOPrefs::instance()->mUseAppColors )
163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
164 globalFlagBlockStartup = 1; 164 globalFlagBlockStartup = 1;
165 iconToolBar = new QPEToolBar( this ); 165 iconToolBar = new QPEToolBar( this );
166 addToolBar (iconToolBar , tbd ); 166 addToolBar (iconToolBar , tbd );
167 mCalendarModifiedFlag = false; 167 mCalendarModifiedFlag = false;
168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
169 splash->setAlignment ( AlignCenter ); 169 splash->setAlignment ( AlignCenter );
170 setCentralWidget( splash ); 170 setCentralWidget( splash );
171#ifndef DESKTOP_VERSION 171#ifndef DESKTOP_VERSION
172 showMaximized(); 172 showMaximized();
173#endif 173#endif
174 174
175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
176 setDefaultPreferences(); 176 setDefaultPreferences();
177 mCalendar = new CalendarLocal(); 177 mCalendar = new CalendarLocal();
178 mView = new CalendarView( mCalendar, this,"mCalendar " ); 178 mView = new CalendarView( mCalendar, this,"mCalendar " );
179 mView->hide(); 179 mView->hide();
180 //mView->resize(splash->size() ); 180 //mView->resize(splash->size() );
181 initActions(); 181 initActions();
182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
183 mSyncManager->setBlockSave(false); 183 mSyncManager->setBlockSave(false);
184 mView->setSyncManager(mSyncManager); 184 mView->setSyncManager(mSyncManager);
185#ifndef DESKTOP_VERSION 185#ifndef DESKTOP_VERSION
186 iconToolBar->show(); 186 iconToolBar->show();
187 qApp->processEvents(); 187 qApp->processEvents();
188#endif 188#endif
189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
190 int vh = height() ; 190 int vh = height() ;
191 int vw = width(); 191 int vw = width();
192 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 192 //qDebug("Toolbar hei %d ",iconToolBar->height() );
193 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 193 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
194 vh -= iconToolBar->height(); 194 vh -= iconToolBar->height();
195 } else { 195 } else {
196 vw -= iconToolBar->height(); 196 vw -= iconToolBar->height();
197 } 197 }
198 //mView->setMaximumSize( splash->size() ); 198 //mView->setMaximumSize( splash->size() );
199 //mView->resize( splash->size() ); 199 //mView->resize( splash->size() );
200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
201 mView->readSettings(); 201 mView->readSettings();
202 bool newFile = false; 202 bool newFile = false;
203 if( !QFile::exists( defaultFileName() ) ) { 203 if( !QFile::exists( defaultFileName() ) ) {
204 QFileInfo finfo ( defaultFileName() ); 204 QFileInfo finfo ( defaultFileName() );
205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
206 qDebug("oldfile %s ", oldFile.latin1()); 206 qDebug("oldfile %s ", oldFile.latin1());
207 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"; 207 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";
208 finfo.setFile( oldFile ); 208 finfo.setFile( oldFile );
209 if (finfo.exists() ) { 209 if (finfo.exists() ) {
210 KMessageBox::information( this, message); 210 KMessageBox::information( this, message);
211 mView->openCalendar( oldFile ); 211 mView->openCalendar( oldFile );
212 qApp->processEvents(); 212 qApp->processEvents();
213 } else { 213 } else {
214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
215 finfo.setFile( oldFile ); 215 finfo.setFile( oldFile );
216 if (finfo.exists() ) { 216 if (finfo.exists() ) {
217 KMessageBox::information( this, message); 217 KMessageBox::information( this, message);
218 mView->openCalendar( oldFile ); 218 mView->openCalendar( oldFile );
219 qApp->processEvents(); 219 qApp->processEvents();
220 } 220 }
221 } 221 }
222 mView->saveCalendar( defaultFileName() ); 222 mView->saveCalendar( defaultFileName() );
223 newFile = true; 223 newFile = true;
224 } 224 }
225 225
226 QTime neededSaveTime = QDateTime::currentDateTime().time(); 226 QTime neededSaveTime = QDateTime::currentDateTime().time();
227 mView->openCalendar( defaultFileName() ); 227 mView->openCalendar( defaultFileName() );
228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
229 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 229 qDebug("KO: Calendar loading time: %d ms",msNeeded );
230 230
231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
232 KOPrefs::instance()->setAllDefaults(); 232 KOPrefs::instance()->setAllDefaults();
233 int count = mView->addCategories(); 233 int count = mView->addCategories();
234 } 234 }
235 processIncidenceSelection( 0 ); 235 processIncidenceSelection( 0 );
236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
237 SLOT( processIncidenceSelection( Incidence * ) ) ); 237 SLOT( processIncidenceSelection( Incidence * ) ) );
238 connect( mView, SIGNAL( modifiedChanged( bool ) ), 238 connect( mView, SIGNAL( modifiedChanged( bool ) ),
239 SLOT( slotModifiedChanged( bool ) ) ); 239 SLOT( slotModifiedChanged( bool ) ) );
240 240
241 241
242 connect( mView, SIGNAL( tempDisableBR(bool) ), 242 connect( mView, SIGNAL( tempDisableBR(bool) ),
243 SLOT( disableBR(bool) ) ); 243 SLOT( disableBR(bool) ) );
244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
245 mView->setModified( false ); 245 mView->setModified( false );
246 mBlockAtStartup = false; 246 mBlockAtStartup = false;
247 mView->setModified( false ); 247 mView->setModified( false );
248 setCentralWidget( mView ); 248 setCentralWidget( mView );
249 globalFlagBlockStartup = 0; 249 globalFlagBlockStartup = 0;
250 mView->show(); 250 mView->show();
251 delete splash; 251 delete splash;
252 if ( newFile ) 252 if ( newFile )
253 mView->updateConfig(); 253 mView->updateConfig();
254 // qApp->processEvents(); 254 // qApp->processEvents();
255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
256 //fillSyncMenu(); 256 //fillSyncMenu();
257 257
258 258
259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
264 mSyncManager->setDefaultFileName( sentSyncFile()); 264 mSyncManager->setDefaultFileName( sentSyncFile());
265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
266 mSyncManager->fillSyncMenu(); 266 mSyncManager->fillSyncMenu();
267 267
268 268
269 269
270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
271 if ( showWarning ) { 271 if ( showWarning ) {
272 KMessageBox::information( this, 272 KMessageBox::information( this,
273 "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"); 273 "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");
274 qApp->processEvents(); 274 qApp->processEvents();
275 mView->dialogManager()->showSyncOptions(); 275 mView->dialogManager()->showSyncOptions();
276 } 276 }
277 277
278 //US listen for result adressed from Ka/Pi 278 //US listen for result adressed from Ka/Pi
279#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
281#endif 281#endif
282#ifndef DESKTOP_VERSION 282#ifndef DESKTOP_VERSION
283 infrared = 0; 283 infrared = 0;
284#endif 284#endif
285 updateWeek( mView->startDate() ); 285 updateWeek( mView->startDate() );
286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
287 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 287 SLOT( updateWeekNum( const KCal::DateList & ) ) );
288 mBRdisabled = false; 288 mBRdisabled = false;
289 //toggleBeamReceive(); 289 //toggleBeamReceive();
290} 290}
291MainWindow::~MainWindow() 291MainWindow::~MainWindow()
292{ 292{
293 //qDebug("MainWindow::~MainWindow() "); 293 //qDebug("MainWindow::~MainWindow() ");
294 //save toolbar location 294 //save toolbar location
295 delete mCalendar; 295 delete mCalendar;
296 delete mSyncManager; 296 delete mSyncManager;
297#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
298 if ( infrared ) 298 if ( infrared )
299 delete infrared; 299 delete infrared;
300#endif 300#endif
301 301
302 302
303} 303}
304 304
305void MainWindow::disableBR(bool b) 305void MainWindow::disableBR(bool b)
306{ 306{
307#ifndef DESKTOP_VERSION 307#ifndef DESKTOP_VERSION
308 if ( b ) { 308 if ( b ) {
309 if ( infrared ) { 309 if ( infrared ) {
310 toggleBeamReceive(); 310 toggleBeamReceive();
311 mBRdisabled = true; 311 mBRdisabled = true;
312 } 312 }
313 mBRdisabled = true; 313 mBRdisabled = true;
314 } else { 314 } else {
315 if ( mBRdisabled ) { 315 if ( mBRdisabled ) {
316 mBRdisabled = false; 316 mBRdisabled = false;
317 //makes no sense,because other cal ap is probably running 317 //makes no sense,because other cal ap is probably running
318 // toggleBeamReceive(); 318 // toggleBeamReceive();
319 } 319 }
320 } 320 }
321#endif 321#endif
322 322
323} 323}
324bool MainWindow::beamReceiveEnabled() 324bool MainWindow::beamReceiveEnabled()
325{ 325{
326#ifndef DESKTOP_VERSION 326#ifndef DESKTOP_VERSION
327 return ( infrared != 0 ); 327 return ( infrared != 0 );
328#endif 328#endif
329 return false; 329 return false;
330} 330}
331 331
332void MainWindow::toggleBeamReceive() 332void MainWindow::toggleBeamReceive()
333{ 333{
334 if ( mBRdisabled ) 334 if ( mBRdisabled )
335 return; 335 return;
336#ifndef DESKTOP_VERSION 336#ifndef DESKTOP_VERSION
337 if ( infrared ) { 337 if ( infrared ) {
338 qDebug("disable BeamReceive "); 338 qDebug("disable BeamReceive ");
339 delete infrared; 339 delete infrared;
340 infrared = 0; 340 infrared = 0;
341 brAction->setOn(false); 341 brAction->setOn(false);
342 return; 342 return;
343 } 343 }
344 qDebug("enable BeamReceive "); 344 qDebug("enable BeamReceive ");
345 brAction->setOn(true); 345 brAction->setOn(true);
346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
348#endif 348#endif
349} 349}
350void MainWindow::showMaximized () 350void MainWindow::showMaximized ()
351{ 351{
352#ifndef DESKTOP_VERSION 352#ifndef DESKTOP_VERSION
353 if ( ! globalFlagBlockStartup ) 353 if ( ! globalFlagBlockStartup )
354 if ( mClosed ) 354 if ( mClosed )
355 mView->goToday(); 355 mView->goToday();
356#endif 356#endif
357 QWidget::showMaximized () ; 357 QWidget::showMaximized () ;
358 mClosed = false; 358 mClosed = false;
359} 359}
360void MainWindow::closeEvent( QCloseEvent* ce ) 360void MainWindow::closeEvent( QCloseEvent* ce )
361{ 361{
362 362
363 363
364 364
365 if ( ! KOPrefs::instance()->mAskForQuit ) { 365 if ( ! KOPrefs::instance()->mAskForQuit ) {
366 saveOnClose(); 366 saveOnClose();
367 mClosed = true; 367 mClosed = true;
368 ce->accept(); 368 ce->accept();
369 return; 369 return;
370 370
371 } 371 }
372 372
373 switch( QMessageBox::information( this, "KO/Pi", 373 switch( QMessageBox::information( this, "KO/Pi",
374 i18n("Do you really want\nto close KO/Pi?"), 374 i18n("Do you really want\nto close KO/Pi?"),
375 i18n("Close"), i18n("No"), 375 i18n("Close"), i18n("No"),
376 0, 0 ) ) { 376 0, 0 ) ) {
377 case 0: 377 case 0:
378 saveOnClose(); 378 saveOnClose();
379 mClosed = true; 379 mClosed = true;
380 ce->accept(); 380 ce->accept();
381 break; 381 break;
382 case 1: 382 case 1:
383 ce->ignore(); 383 ce->ignore();
384 break; 384 break;
385 case 2: 385 case 2:
386 386
387 default: 387 default:
388 break; 388 break;
389 } 389 }
390 390
391 391
392} 392}
393 393
394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
395{ 395{
396 QDataStream stream( data, IO_ReadOnly ); 396 QDataStream stream( data, IO_ReadOnly );
397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
398 //QString datamess; 398 //QString datamess;
399 //qDebug("message "); 399 //qDebug("message ");
400 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 400 qDebug("KO: QCOP message received: %s ", cmsg.data() );
401 401
402 if ( cmsg == "setDocument(QString)" ) { 402 if ( cmsg == "setDocument(QString)" ) {
403 QDataStream stream( data, IO_ReadOnly ); 403 QDataStream stream( data, IO_ReadOnly );
404 QString fileName; 404 QString fileName;
405 stream >> fileName; 405 stream >> fileName;
406 //qDebug("filename %s ", fileName.latin1()); 406 //qDebug("filename %s ", fileName.latin1());
407 showMaximized(); 407 showMaximized();
408 raise(); 408 raise();
409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
410 mSyncManager->slotSyncMenu( 1002 ); 410 mSyncManager->slotSyncMenu( 1002 );
411 return; 411 return;
412 } 412 }
413 413
414 if ( cmsg == "-writeFile" ) { 414 if ( cmsg == "-writeFile" ) {
415 // I made from the "-writeFile" an "-writeAlarm" 415 // I made from the "-writeFile" an "-writeAlarm"
416 mView->viewManager()->showWhatsNextView(); 416 mView->viewManager()->showWhatsNextView();
417 mCalendar->checkAlarmForIncidence( 0, true); 417 mCalendar->checkAlarmForIncidence( 0, true);
418 showMaximized(); 418 showMaximized();
419 raise(); 419 raise();
420 return; 420 return;
421 421
422 } 422 }
423 if ( cmsg == "-writeFileSilent" ) { 423 if ( cmsg == "-writeFileSilent" ) {
424 // I made from the "-writeFile" an "-writeAlarm" 424 // I made from the "-writeFile" an "-writeAlarm"
425 // mView->viewManager()->showWhatsNextView(); 425 // mView->viewManager()->showWhatsNextView();
426 mCalendar->checkAlarmForIncidence( 0, true); 426 mCalendar->checkAlarmForIncidence( 0, true);
427 //showMaximized(); 427 //showMaximized();
428 //raise(); 428 //raise();
429 hide(); 429 hide();
430 return; 430 return;
431 } 431 }
432 if ( cmsg == "-newCountdown" ) { 432 if ( cmsg == "-newCountdown" ) {
433 qDebug("newCountdown "); 433 qDebug("newCountdown ");
434 434
435 } 435 }
436 QString msg ; 436 QString msg ;
437 QString allmsg = cmsg; 437 QString allmsg = cmsg;
438 while ( allmsg.length() > 0 ) { 438 while ( allmsg.length() > 0 ) {
439 int nextC = allmsg.find( "-", 1 ); 439 int nextC = allmsg.find( "-", 1 );
440 if ( nextC == -1 ) { 440 if ( nextC == -1 ) {
441 msg = allmsg; 441 msg = allmsg;
442 allmsg = ""; 442 allmsg = "";
443 } else{ 443 } else{
444 msg = allmsg.left( nextC ); 444 msg = allmsg.left( nextC );
445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
446 } 446 }
447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
448 if ( msg == "-newEvent" ) { 448 if ( msg == "-newEvent" ) {
449 mView->newEvent(); 449 mView->newEvent();
450 } 450 }
451 if ( msg == "-newTodo" ) { 451 if ( msg == "-newTodo" ) {
452 mView->newTodo(); 452 mView->newTodo();
453 453
454 } 454 }
455 if ( msg == "-showWN" ) { 455 if ( msg == "-showWN" ) {
456 mView->viewManager()->showWhatsNextView(); 456 mView->viewManager()->showWhatsNextView();
457 } 457 }
458 if ( msg == "-showTodo" ) { 458 if ( msg == "-showTodo" ) {
459 mView->viewManager()->showTodoView(); 459 mView->viewManager()->showTodoView();
460 } 460 }
461 if ( msg == "-showList" ) { 461 if ( msg == "-showList" ) {
462 mView->viewManager()->showListView(); 462 mView->viewManager()->showListView();
463 } 463 }
464 else if ( msg == "-showDay" ) { 464 else if ( msg == "-showDay" ) {
465 mView->viewManager()->showDayView(); 465 mView->viewManager()->showDayView();
466 } 466 }
467 else if ( msg == "-showWWeek" ) { 467 else if ( msg == "-showWWeek" ) {
468 mView->viewManager()->showWorkWeekView(); 468 mView->viewManager()->showWorkWeekView();
469 } 469 }
470 else if ( msg == "-ringSync" ) { 470 else if ( msg == "-ringSync" ) {
471 mSyncManager->multiSync( false ); 471 mSyncManager->multiSync( false );
472 } 472 }
473 else if ( msg == "-showWeek" ) { 473 else if ( msg == "-showWeek" ) {
474 mView->viewManager()->showWeekView(); 474 mView->viewManager()->showWeekView();
475 } 475 }
476 else if ( msg == "-showTodo" ) { 476 else if ( msg == "-showTodo" ) {
477 mView->viewManager()->showTodoView(); 477 mView->viewManager()->showTodoView();
478 } 478 }
479 else if ( msg == "-showJournal" ) { 479 else if ( msg == "-showJournal" ) {
480 mView->dateNavigator()->selectDates( 1 ); 480 mView->dateNavigator()->selectDates( 1 );
481 mView->dateNavigator()->selectToday(); 481 mView->dateNavigator()->selectToday();
482 mView->viewManager()->showJournalView(); 482 mView->viewManager()->showJournalView();
483 } 483 }
484 else if ( msg == "-showKO" ) { 484 else if ( msg == "-showKO" ) {
485 mView->viewManager()->showNextXView(); 485 mView->viewManager()->showNextXView();
486 } 486 }
487 else if ( msg == "-showWNext" || msg == "nextView()" ) { 487 else if ( msg == "-showWNext" ) {
488 mView->viewManager()->showWhatsNextView(); 488 mView->viewManager()->showWhatsNextView();
489 } 489 }
490 else if ( msg == "nextView()" ) {
491 mView->viewManager()->showNextView();
492 }
490 else if ( msg == "-showNextXView" ) { 493 else if ( msg == "-showNextXView" ) {
491 mView->viewManager()->showNextXView(); 494 mView->viewManager()->showNextXView();
492 } 495 }
493 496
494 497
495 } 498 }
496 499
497 showMaximized(); 500 showMaximized();
498 raise(); 501 raise();
499} 502}
500 503
501QPixmap MainWindow::loadPixmap( QString name ) 504QPixmap MainWindow::loadPixmap( QString name )
502{ 505{
503 return SmallIcon( name ); 506 return SmallIcon( name );
504 507
505} 508}
506void MainWindow::initActions() 509void MainWindow::initActions()
507{ 510{
508 //KOPrefs::instance()->mShowFullMenu 511 //KOPrefs::instance()->mShowFullMenu
509 iconToolBar->clear(); 512 iconToolBar->clear();
510 KOPrefs *p = KOPrefs::instance(); 513 KOPrefs *p = KOPrefs::instance();
511 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 514 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
512 515
513 QPopupMenu *viewMenu = new QPopupMenu( this ); 516 QPopupMenu *viewMenu = new QPopupMenu( this );
514 QPopupMenu *actionMenu = new QPopupMenu( this ); 517 QPopupMenu *actionMenu = new QPopupMenu( this );
515 QPopupMenu *importMenu = new QPopupMenu( this ); 518 QPopupMenu *importMenu = new QPopupMenu( this );
516 QPopupMenu *importMenu_X = new QPopupMenu( this ); 519 QPopupMenu *importMenu_X = new QPopupMenu( this );
517 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 520 QPopupMenu *exportMenu_X = new QPopupMenu( this );
518 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 521 QPopupMenu *beamMenu_X = new QPopupMenu( this );
519 selectFilterMenu = new QPopupMenu( this ); 522 selectFilterMenu = new QPopupMenu( this );
520 selectFilterMenu->setCheckable( true ); 523 selectFilterMenu->setCheckable( true );
521 syncMenu = new QPopupMenu( this ); 524 syncMenu = new QPopupMenu( this );
522 configureAgendaMenu = new QPopupMenu( this ); 525 configureAgendaMenu = new QPopupMenu( this );
523 configureToolBarMenu = new QPopupMenu( this ); 526 configureToolBarMenu = new QPopupMenu( this );
524 QPopupMenu *helpMenu = new QPopupMenu( this ); 527 QPopupMenu *helpMenu = new QPopupMenu( this );
525 QIconSet icon; 528 QIconSet icon;
526 int pixWid = 22, pixHei = 22; 529 int pixWid = 22, pixHei = 22;
527 QString pathString = ""; 530 QString pathString = "";
528 if ( !p->mToolBarMiniIcons ) { 531 if ( !p->mToolBarMiniIcons ) {
529 if ( QApplication::desktop()->width() < 480 ) { 532 if ( QApplication::desktop()->width() < 480 ) {
530 pathString += "icons16/"; 533 pathString += "icons16/";
531 pixWid = 18; pixHei = 16; 534 pixWid = 18; pixHei = 16;
532 } 535 }
533 } else { 536 } else {
534 pathString += "iconsmini/"; 537 pathString += "iconsmini/";
535 pixWid = 18; pixHei = 16; 538 pixWid = 18; pixHei = 16;
536 } 539 }
537 if ( KOPrefs::instance()->mShowFullMenu ) { 540 if ( KOPrefs::instance()->mShowFullMenu ) {
538 QMenuBar *menuBar1; 541 QMenuBar *menuBar1;
539 menuBar1 = menuBar(); 542 menuBar1 = menuBar();
540 menuBar1->insertItem( i18n("File"), importMenu ); 543 menuBar1->insertItem( i18n("File"), importMenu );
541 menuBar1->insertItem( i18n("View"), viewMenu ); 544 menuBar1->insertItem( i18n("View"), viewMenu );
542 menuBar1->insertItem( i18n("Actions"), actionMenu ); 545 menuBar1->insertItem( i18n("Actions"), actionMenu );
543#ifdef DESKTOP_VERSION 546#ifdef DESKTOP_VERSION
544 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 547 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
545 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 548 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
546#else 549#else
547 menuBar1->insertItem( i18n("Sync"), syncMenu ); 550 menuBar1->insertItem( i18n("Sync"), syncMenu );
548 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 551 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
549#endif 552#endif
550 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 553 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
551 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 554 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
552 menuBar1->insertItem( i18n("Help"), helpMenu ); 555 menuBar1->insertItem( i18n("Help"), helpMenu );
553 } else { 556 } else {
554 QPEMenuBar *menuBar1; 557 QPEMenuBar *menuBar1;
555 menuBar1 = new QPEMenuBar( iconToolBar ); 558 menuBar1 = new QPEMenuBar( iconToolBar );
556 QPopupMenu *menuBar = new QPopupMenu( this ); 559 QPopupMenu *menuBar = new QPopupMenu( this );
557 icon = loadPixmap( pathString + "z_menu" ); 560 icon = loadPixmap( pathString + "z_menu" );
558 menuBar1->insertItem( icon.pixmap(), menuBar); 561 menuBar1->insertItem( icon.pixmap(), menuBar);
559 //menuBar1->insertItem( i18n("ME"), menuBar); 562 //menuBar1->insertItem( i18n("ME"), menuBar);
560 menuBar->insertItem( i18n("File"), importMenu ); 563 menuBar->insertItem( i18n("File"), importMenu );
561 menuBar->insertItem( i18n("View"), viewMenu ); 564 menuBar->insertItem( i18n("View"), viewMenu );
562 menuBar->insertItem( i18n("Actions"), actionMenu ); 565 menuBar->insertItem( i18n("Actions"), actionMenu );
563 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 566 menuBar->insertItem( i18n("Synchronize"), syncMenu );
564 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 567 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
565 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 568 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
566 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 569 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
567 menuBar->insertItem( i18n("Help"), helpMenu ); 570 menuBar->insertItem( i18n("Help"), helpMenu );
568 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 571 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
569 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 572 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
570 } 573 }
571 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 574 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
572 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 575 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
573 mWeekBgColor = iconToolBar->backgroundColor(); 576 mWeekBgColor = iconToolBar->backgroundColor();
574 mWeekPixmap.resize( pixWid , pixHei ); 577 mWeekPixmap.resize( pixWid , pixHei );
575 mWeekPixmap.fill( mWeekBgColor ); 578 mWeekPixmap.fill( mWeekBgColor );
576 icon = mWeekPixmap; 579 icon = mWeekPixmap;
577 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 580 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
578 if ( p-> mShowIconWeekNum ) 581 if ( p-> mShowIconWeekNum )
579 mWeekAction->addTo( iconToolBar ); 582 mWeekAction->addTo( iconToolBar );
580 mWeekFont = font(); 583 mWeekFont = font();
581 584
582 int fontPoint = mWeekFont.pointSize(); 585 int fontPoint = mWeekFont.pointSize();
583 QFontMetrics f( mWeekFont ); 586 QFontMetrics f( mWeekFont );
584 int fontWid = f.width( "30" ); 587 int fontWid = f.width( "30" );
585 while ( fontWid > pixWid ) { 588 while ( fontWid > pixWid ) {
586 --fontPoint; 589 --fontPoint;
587 mWeekFont.setPointSize( fontPoint ); 590 mWeekFont.setPointSize( fontPoint );
588 QFontMetrics f( mWeekFont ); 591 QFontMetrics f( mWeekFont );
589 fontWid = f.width( "30" ); 592 fontWid = f.width( "30" );
590 qDebug("dec-- "); 593 qDebug("dec-- ");
591 } 594 }
592 595
593 connect( mWeekAction, SIGNAL( activated() ), 596 connect( mWeekAction, SIGNAL( activated() ),
594 this, SLOT( weekAction() ) ); 597 this, SLOT( weekAction() ) );
595 598
596 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 599 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
597 600
598 //#endif 601 //#endif
599 // ****************** 602 // ******************
600 QAction *action; 603 QAction *action;
601 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 604 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
602 configureToolBarMenu->setCheckable( true ); 605 configureToolBarMenu->setCheckable( true );
603 606
604 607
605 configureAgendaMenu->setCheckable( true ); 608 configureAgendaMenu->setCheckable( true );
606 int iii ; 609 int iii ;
607 for ( iii = 1;iii<= 10 ;++iii ){ 610 for ( iii = 1;iii<= 10 ;++iii ){
608 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 611 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
609 } 612 }
610 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 613 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
611 614
612 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 615 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
613 this, SLOT( showConfigureAgenda( ) ) ); 616 this, SLOT( showConfigureAgenda( ) ) );
614 617
615 icon = loadPixmap( pathString + "configure" ); 618 icon = loadPixmap( pathString + "configure" );
616 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 619 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
617 action->addTo( actionMenu ); 620 action->addTo( actionMenu );
618 connect( action, SIGNAL( activated() ), 621 connect( action, SIGNAL( activated() ),
619 mView, SLOT( edit_options() ) ); 622 mView, SLOT( edit_options() ) );
620 actionMenu->insertSeparator(); 623 actionMenu->insertSeparator();
621 624
622 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 625 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
623 action->addTo( actionMenu ); 626 action->addTo( actionMenu );
624 connect( action, SIGNAL( activated() ), 627 connect( action, SIGNAL( activated() ),
625 mView, SLOT( undo_delete() ) ); 628 mView, SLOT( undo_delete() ) );
626 actionMenu->insertSeparator(); 629 actionMenu->insertSeparator();
627 630
628 icon = loadPixmap( pathString + "newevent" ); 631 icon = loadPixmap( pathString + "newevent" );
629 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 632 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
630 configureToolBarMenu->insertSeparator(); 633 configureToolBarMenu->insertSeparator();
631 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 634 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
632 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 635 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
633 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 636 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
634 ne_action->addTo( actionMenu ); 637 ne_action->addTo( actionMenu );
635 connect( ne_action, SIGNAL( activated() ), 638 connect( ne_action, SIGNAL( activated() ),
636 mView, SLOT( newEvent() ) ); 639 mView, SLOT( newEvent() ) );
637 icon = loadPixmap( pathString + "newtodo" ); 640 icon = loadPixmap( pathString + "newtodo" );
638 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 641 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
639 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 642 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
640 nt_action->addTo( actionMenu ); 643 nt_action->addTo( actionMenu );
641 connect( nt_action, SIGNAL( activated() ), 644 connect( nt_action, SIGNAL( activated() ),
642 mView, SLOT( newTodo() ) ); 645 mView, SLOT( newTodo() ) );
643 646
644 icon = loadPixmap( pathString + "today" ); 647 icon = loadPixmap( pathString + "today" );
645 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 648 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
646 today_action->addTo( viewMenu ); 649 today_action->addTo( viewMenu );
647 connect( today_action, SIGNAL( activated() ), 650 connect( today_action, SIGNAL( activated() ),
648 mView, SLOT( goToday() ) ); 651 mView, SLOT( goToday() ) );
649 viewMenu->insertSeparator(); 652 viewMenu->insertSeparator();
650 653
651 icon = loadPixmap( pathString + "navi" ); 654 icon = loadPixmap( pathString + "navi" );
652 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 655 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
653 action->addTo( viewMenu ); 656 action->addTo( viewMenu );
654 connect( action, SIGNAL( activated() ), 657 connect( action, SIGNAL( activated() ),
655 mView, SLOT( toggleDateNavigatorWidget() ) ); 658 mView, SLOT( toggleDateNavigatorWidget() ) );
656 mToggleNav = action ; 659 mToggleNav = action ;
657 icon = loadPixmap( pathString + "filter" ); 660 icon = loadPixmap( pathString + "filter" );
658 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 661 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
659 action->addTo( viewMenu ); 662 action->addTo( viewMenu );
660 connect( action, SIGNAL( activated() ), 663 connect( action, SIGNAL( activated() ),
661 mView, SLOT( toggleFilter() ) ); 664 mView, SLOT( toggleFilter() ) );
662 mToggleFilter = action; 665 mToggleFilter = action;
663 icon = loadPixmap( pathString + "allday" ); 666 icon = loadPixmap( pathString + "allday" );
664 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 667 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
665 action->addTo( viewMenu ); 668 action->addTo( viewMenu );
666 connect( action, SIGNAL( activated() ), 669 connect( action, SIGNAL( activated() ),
667 mView, SLOT( toggleAllDaySize() ) ); 670 mView, SLOT( toggleAllDaySize() ) );
668 mToggleAllday = action; 671 mToggleAllday = action;
669 672
670 673
671 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 674 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
672 mToggleNav, SLOT( setEnabled ( bool ) ) ); 675 mToggleNav, SLOT( setEnabled ( bool ) ) );
673 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 676 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
674 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 677 mToggleFilter, SLOT( setEnabled ( bool ) ) );
675 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 678 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
676 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 679 mToggleAllday, SLOT( setEnabled ( bool ) ) );
677 680
678 viewMenu->insertSeparator(); 681 viewMenu->insertSeparator();
679 icon = loadPixmap( pathString + "picker" ); 682 icon = loadPixmap( pathString + "picker" );
680 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 683 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
681 action->addTo( viewMenu ); 684 action->addTo( viewMenu );
682 connect( action, SIGNAL( activated() ), 685 connect( action, SIGNAL( activated() ),
683 mView, SLOT( showDatePicker() ) ); 686 mView, SLOT( showDatePicker() ) );
684 action->addTo( iconToolBar ); 687 action->addTo( iconToolBar );
685 viewMenu->insertSeparator(); 688 viewMenu->insertSeparator();
686 icon = loadPixmap( pathString + "list" ); 689 icon = loadPixmap( pathString + "list" );
687 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 690 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
688 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 691 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
689 showlist_action->addTo( viewMenu ); 692 showlist_action->addTo( viewMenu );
690 connect( showlist_action, SIGNAL( activated() ), 693 connect( showlist_action, SIGNAL( activated() ),
691 mView->viewManager(), SLOT( showListView() ) ); 694 mView->viewManager(), SLOT( showListView() ) );
692 695
693 696
694 icon = loadPixmap( pathString + "day" ); 697 icon = loadPixmap( pathString + "day" );
695 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 698 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
696 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 699 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
697 day1_action->addTo( viewMenu ); 700 day1_action->addTo( viewMenu );
698 // action->addTo( toolBar ); 701 // action->addTo( toolBar );
699 connect( day1_action, SIGNAL( activated() ), 702 connect( day1_action, SIGNAL( activated() ),
700 mView->viewManager(), SLOT( showDayView() ) ); 703 mView->viewManager(), SLOT( showDayView() ) );
701 704
702 icon = loadPixmap( pathString + "workweek" ); 705 icon = loadPixmap( pathString + "workweek" );
703 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 706 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
704 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 707 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
705 day5_action->addTo( viewMenu ); 708 day5_action->addTo( viewMenu );
706 connect( day5_action, SIGNAL( activated() ), 709 connect( day5_action, SIGNAL( activated() ),
707 mView->viewManager(), SLOT( showWorkWeekView() ) ); 710 mView->viewManager(), SLOT( showWorkWeekView() ) );
708 711
709 icon = loadPixmap( pathString + "week" ); 712 icon = loadPixmap( pathString + "week" );
710 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 713 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
711 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 714 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
712 day7_action->addTo( viewMenu ); 715 day7_action->addTo( viewMenu );
713 connect( day7_action, SIGNAL( activated() ), 716 connect( day7_action, SIGNAL( activated() ),
714 mView->viewManager(), SLOT( showWeekView() ) ); 717 mView->viewManager(), SLOT( showWeekView() ) );
715 718
716 icon = loadPixmap( pathString + "workweek2" ); 719 icon = loadPixmap( pathString + "workweek2" );
717 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 720 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
718 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 721 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
719 day6_action->addTo( viewMenu ); 722 day6_action->addTo( viewMenu );
720 connect( day6_action, SIGNAL( activated() ), 723 connect( day6_action, SIGNAL( activated() ),
721 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 724 mView->viewManager(), SLOT( showMonthViewWeek() ) );
722 725
723 icon = loadPixmap( pathString + "month" ); 726 icon = loadPixmap( pathString + "month" );
724 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 727 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
725 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 728 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
726 month_action->addTo( viewMenu ); 729 month_action->addTo( viewMenu );
727 connect( month_action, SIGNAL( activated() ), 730 connect( month_action, SIGNAL( activated() ),
728 mView->viewManager(), SLOT( showMonthView() ) ); 731 mView->viewManager(), SLOT( showMonthView() ) );
729 732
730 icon = loadPixmap( pathString + "todo" ); 733 icon = loadPixmap( pathString + "todo" );
731 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 734 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
732 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 735 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
733 todoview_action->addTo( viewMenu ); 736 todoview_action->addTo( viewMenu );
734 connect( todoview_action, SIGNAL( activated() ), 737 connect( todoview_action, SIGNAL( activated() ),
735 mView->viewManager(), SLOT( showTodoView() ) ); 738 mView->viewManager(), SLOT( showTodoView() ) );
736 739
737 icon = loadPixmap( pathString + "journal" ); 740 icon = loadPixmap( pathString + "journal" );
738 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 741 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
739 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 742 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
740 viewjournal_action->addTo( viewMenu ); 743 viewjournal_action->addTo( viewMenu );
741 connect( viewjournal_action, SIGNAL( activated() ), 744 connect( viewjournal_action, SIGNAL( activated() ),
742 mView->viewManager(), SLOT( showJournalView() ) ); 745 mView->viewManager(), SLOT( showJournalView() ) );
743 746
744 icon = loadPixmap( pathString + "xdays" ); 747 icon = loadPixmap( pathString + "xdays" );
745 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 748 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
746 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 749 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
747 xdays_action->addTo( viewMenu ); 750 xdays_action->addTo( viewMenu );
748 connect( xdays_action, SIGNAL( activated() ), 751 connect( xdays_action, SIGNAL( activated() ),
749 mView->viewManager(), SLOT( showNextXView() ) ); 752 mView->viewManager(), SLOT( showNextXView() ) );
750 753
751 icon = loadPixmap( pathString + "whatsnext" ); 754 icon = loadPixmap( pathString + "whatsnext" );
752 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 755 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
753 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 756 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
754 whatsnext_action->addTo( viewMenu ); 757 whatsnext_action->addTo( viewMenu );
755 connect( whatsnext_action, SIGNAL( activated() ), 758 connect( whatsnext_action, SIGNAL( activated() ),
756 mView->viewManager(), SLOT( showWhatsNextView() ) ); 759 mView->viewManager(), SLOT( showWhatsNextView() ) );
757 760
758#if 0 761#if 0
759 action = new QAction( "view_timespan", "Time Span", 0, this ); 762 action = new QAction( "view_timespan", "Time Span", 0, this );
760 action->addTo( viewMenu ); 763 action->addTo( viewMenu );
761 connect( action, SIGNAL( activated() ), 764 connect( action, SIGNAL( activated() ),
762 mView->viewManager(), SLOT( showTimeSpanView() ) ); 765 mView->viewManager(), SLOT( showTimeSpanView() ) );
763#endif 766#endif
764 767
765 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 768 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
766 this ); 769 this );
767 mNewSubTodoAction->addTo( actionMenu ); 770 mNewSubTodoAction->addTo( actionMenu );
768 connect( mNewSubTodoAction, SIGNAL( activated() ), 771 connect( mNewSubTodoAction, SIGNAL( activated() ),
769 mView, SLOT( newSubTodo() ) ); 772 mView, SLOT( newSubTodo() ) );
770 773
771 actionMenu->insertSeparator(); 774 actionMenu->insertSeparator();
772 775
773 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 776 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
774 mShowAction->addTo( actionMenu ); 777 mShowAction->addTo( actionMenu );
775 connect( mShowAction, SIGNAL( activated() ), 778 connect( mShowAction, SIGNAL( activated() ),
776 mView, SLOT( showIncidence() ) ); 779 mView, SLOT( showIncidence() ) );
777 780
778 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 781 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
779 mEditAction->addTo( actionMenu ); 782 mEditAction->addTo( actionMenu );
780 connect( mEditAction, SIGNAL( activated() ), 783 connect( mEditAction, SIGNAL( activated() ),
781 mView, SLOT( editIncidence() ) ); 784 mView, SLOT( editIncidence() ) );
782 785
783 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 786 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
784 mDeleteAction->addTo( actionMenu ); 787 mDeleteAction->addTo( actionMenu );
785 connect( mDeleteAction, SIGNAL( activated() ), 788 connect( mDeleteAction, SIGNAL( activated() ),
786 mView, SLOT( deleteIncidence() ) ); 789 mView, SLOT( deleteIncidence() ) );
787 790
788 791
789 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 792 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
790 mCloneAction->addTo( actionMenu ); 793 mCloneAction->addTo( actionMenu );
791 connect( mCloneAction, SIGNAL( activated() ), 794 connect( mCloneAction, SIGNAL( activated() ),
792 mView, SLOT( cloneIncidence() ) ); 795 mView, SLOT( cloneIncidence() ) );
793 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 796 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
794 mMoveAction->addTo( actionMenu ); 797 mMoveAction->addTo( actionMenu );
795 connect( mMoveAction, SIGNAL( activated() ), 798 connect( mMoveAction, SIGNAL( activated() ),
796 mView, SLOT( moveIncidence() ) ); 799 mView, SLOT( moveIncidence() ) );
797 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 800 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
798 mBeamAction->addTo( actionMenu ); 801 mBeamAction->addTo( actionMenu );
799 connect( mBeamAction, SIGNAL( activated() ), 802 connect( mBeamAction, SIGNAL( activated() ),
800 mView, SLOT( beamIncidence() ) ); 803 mView, SLOT( beamIncidence() ) );
801 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 804 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
802 mCancelAction->addTo( actionMenu ); 805 mCancelAction->addTo( actionMenu );
803 connect( mCancelAction, SIGNAL( activated() ), 806 connect( mCancelAction, SIGNAL( activated() ),
804 mView, SLOT( toggleCancelIncidence() ) ); 807 mView, SLOT( toggleCancelIncidence() ) );
805 808
806 actionMenu->insertSeparator(); 809 actionMenu->insertSeparator();
807 810
808 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 811 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
809 this ); 812 this );
810 action->addTo( actionMenu ); 813 action->addTo( actionMenu );
811 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 814 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
812 815
813 icon = loadPixmap( pathString + "search" ); 816 icon = loadPixmap( pathString + "search" );
814 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 817 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
815 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 818 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
816 search_action->addTo( actionMenu ); 819 search_action->addTo( actionMenu );
817 connect( search_action, SIGNAL( activated() ), 820 connect( search_action, SIGNAL( activated() ),
818 mView->dialogManager(), SLOT( showSearchDialog() ) ); 821 mView->dialogManager(), SLOT( showSearchDialog() ) );
819 822
820 823
821 824
822 if ( KOPrefs::instance()->mShowFullMenu ) { 825 if ( KOPrefs::instance()->mShowFullMenu ) {
823 actionMenu->insertSeparator(); 826 actionMenu->insertSeparator();
824 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 827 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
825 828
826 } 829 }
827 // actionMenu->insertSeparator(); 830 // actionMenu->insertSeparator();
828 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 831 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
829 this ); 832 this );
830 action->addTo( importMenu_X ); 833 action->addTo( importMenu_X );
831 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 834 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
832 action = new QAction( "import_quick", i18n("Import last file"), 0, 835 action = new QAction( "import_quick", i18n("Import last file"), 0,
833 this ); 836 this );
834 action->addTo( importMenu_X ); 837 action->addTo( importMenu_X );
835 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 838 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
836 importMenu_X->insertSeparator(); 839 importMenu_X->insertSeparator();
837 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 840 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
838 this ); 841 this );
839 action->addTo( importMenu_X ); 842 action->addTo( importMenu_X );
840 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 843 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
841 //#ifndef DESKTOP_VERSION 844 //#ifndef DESKTOP_VERSION
842 importMenu_X->insertSeparator(); 845 importMenu_X->insertSeparator();
843 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 846 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
844 this ); 847 this );
845 action->addTo( importMenu_X ); 848 action->addTo( importMenu_X );
846 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 849 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
847 //#else 850 //#else
848#ifdef _OL_IMPORT_ 851#ifdef _OL_IMPORT_
849 importMenu_X->insertSeparator(); 852 importMenu_X->insertSeparator();
850 action = new QAction( "import_ol", i18n("Import from OL"), 0, 853 action = new QAction( "import_ol", i18n("Import from OL"), 0,
851 this ); 854 this );
852 action->addTo( importMenu_X ); 855 action->addTo( importMenu_X );
853 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 856 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
854#endif 857#endif
855 //#endif 858 //#endif
856 859
857 //importMenu->insertSeparator(); 860 //importMenu->insertSeparator();
858 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 861 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
859 this ); 862 this );
860 action->addTo( importMenu ); 863 action->addTo( importMenu );
861 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 864 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
862 865
863 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 866 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
864 this ); 867 this );
865 action->addTo( importMenu ); 868 action->addTo( importMenu );
866 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 869 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
867 importMenu->insertSeparator(); 870 importMenu->insertSeparator();
868 importMenu->insertItem( i18n("Import"), importMenu_X ); 871 importMenu->insertItem( i18n("Import"), importMenu_X );
869 //importMenu->insertSeparator(); 872 //importMenu->insertSeparator();
870 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 873 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
871 this ); 874 this );
872 action->addTo( exportMenu_X ); 875 action->addTo( exportMenu_X );
873 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 876 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
874 877
875 878
876 //LR 879 //LR
877 QPopupMenu *ex2phone = new QPopupMenu( this ); 880 QPopupMenu *ex2phone = new QPopupMenu( this );
878 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 881 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
879 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 882 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
880 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 883 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
881 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 884 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
882 885
883 importMenu->insertItem( i18n("Export"), exportMenu_X ); 886 importMenu->insertItem( i18n("Export"), exportMenu_X );
884#ifndef DESKTOP_VERSION 887#ifndef DESKTOP_VERSION
885 //importMenu->insertSeparator(); 888 //importMenu->insertSeparator();
886 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 889 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
887 this ); 890 this );
888 brAction->addTo( beamMenu_X ); 891 brAction->addTo( beamMenu_X );
889 brAction->setToggleAction (true ) ; 892 brAction->setToggleAction (true ) ;
890 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 893 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
891 894
892 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 895 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
893 this ); 896 this );
894 action->addTo( beamMenu_X ); 897 action->addTo( beamMenu_X );
895 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 898 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
896 899
897 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 900 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
898 this ); 901 this );
899 action->addTo( beamMenu_X ); 902 action->addTo( beamMenu_X );
900 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 903 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
901 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 904 importMenu->insertItem( i18n("Beam"), beamMenu_X );
902#else 905#else
903 //importMenu->insertSeparator(); 906 //importMenu->insertSeparator();
904 icon = loadPixmap( pathString + "print" ); 907 icon = loadPixmap( pathString + "print" );
905 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 908 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
906 action->addTo( beamMenu_X ); 909 action->addTo( beamMenu_X );
907 connect( action, SIGNAL( activated() ), 910 connect( action, SIGNAL( activated() ),
908 this, SLOT( printCal() ) ); 911 this, SLOT( printCal() ) );
909 912
910 icon = loadPixmap( pathString + "print" ); 913 icon = loadPixmap( pathString + "print" );
911 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 914 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
912 action->addTo( beamMenu_X ); 915 action->addTo( beamMenu_X );
913 connect( action, SIGNAL( activated() ), 916 connect( action, SIGNAL( activated() ),
914 this, SLOT( printSel() ) ); 917 this, SLOT( printSel() ) );
915 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 918 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
916 action->addTo( beamMenu_X ); 919 action->addTo( beamMenu_X );
917 connect( action, SIGNAL( activated() ), 920 connect( action, SIGNAL( activated() ),
918 mView->viewManager(), SIGNAL( printWNV() ) ); 921 mView->viewManager(), SIGNAL( printWNV() ) );
919 importMenu->insertItem( i18n("Print"), beamMenu_X ); 922 importMenu->insertItem( i18n("Print"), beamMenu_X );
920#endif 923#endif
921 importMenu->insertSeparator(); 924 importMenu->insertSeparator();
922 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 925 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
923 this ); 926 this );
924 action->addTo( importMenu ); 927 action->addTo( importMenu );
925 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 928 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
926 importMenu->insertSeparator(); 929 importMenu->insertSeparator();
927 action = new QAction( "beam all", i18n("Save"), 0, 930 action = new QAction( "beam all", i18n("Save"), 0,
928 this ); 931 this );
929 action->addTo( importMenu ); 932 action->addTo( importMenu );
930 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 933 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
931 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 934 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
932 this ); 935 this );
933 action->addTo( importMenu ); 936 action->addTo( importMenu );
934 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 937 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
935 938
936 //menuBar->insertItem( "Configure",configureMenu ); 939 //menuBar->insertItem( "Configure",configureMenu );
937 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 940 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
938 icon = loadPixmap( "korganizer/korganizer" ); 941 icon = loadPixmap( "korganizer/korganizer" );
939 942
940 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 943 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
941 action->addTo( helpMenu ); 944 action->addTo( helpMenu );
942 connect( action, SIGNAL( activated() ), 945 connect( action, SIGNAL( activated() ),
943 SLOT( whatsNew() ) ); 946 SLOT( whatsNew() ) );
944 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 947 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
945 action->addTo( helpMenu ); 948 action->addTo( helpMenu );
946 connect( action, SIGNAL( activated() ), 949 connect( action, SIGNAL( activated() ),
947 SLOT( features() ) ); 950 SLOT( features() ) );
948 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 951 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
949 action->addTo( helpMenu ); 952 action->addTo( helpMenu );
950 connect( action, SIGNAL( activated() ), 953 connect( action, SIGNAL( activated() ),
951 SLOT( keyBindings() ) ); 954 SLOT( keyBindings() ) );
952 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 955 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
953 action->addTo( helpMenu ); 956 action->addTo( helpMenu );
954 connect( action, SIGNAL( activated() ), 957 connect( action, SIGNAL( activated() ),
955 SLOT( synchowto() ) ); 958 SLOT( synchowto() ) );
956 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 959 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
957 action->addTo( helpMenu ); 960 action->addTo( helpMenu );
958 connect( action, SIGNAL( activated() ), 961 connect( action, SIGNAL( activated() ),
959 SLOT( kdesynchowto() ) ); 962 SLOT( kdesynchowto() ) );
960 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 963 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
961 action->addTo( helpMenu ); 964 action->addTo( helpMenu );
962 connect( action, SIGNAL( activated() ), 965 connect( action, SIGNAL( activated() ),
963 SLOT( multisynchowto() ) ); 966 SLOT( multisynchowto() ) );
964 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 967 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
965 action->addTo( helpMenu ); 968 action->addTo( helpMenu );
966 connect( action, SIGNAL( activated() ), 969 connect( action, SIGNAL( activated() ),
967 SLOT( aboutAutoSaving() ) ); 970 SLOT( aboutAutoSaving() ) );
968 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 971 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
969 action->addTo( helpMenu ); 972 action->addTo( helpMenu );
970 connect( action, SIGNAL( activated() ), 973 connect( action, SIGNAL( activated() ),
971 SLOT( aboutKnownBugs() ) ); 974 SLOT( aboutKnownBugs() ) );
972 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 975 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
973 action->addTo( helpMenu ); 976 action->addTo( helpMenu );
974 connect( action, SIGNAL( activated() ), 977 connect( action, SIGNAL( activated() ),
975 SLOT( usertrans() ) ); 978 SLOT( usertrans() ) );
976 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 979 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
977 action->addTo( helpMenu ); 980 action->addTo( helpMenu );
978 connect( action, SIGNAL( activated() ), 981 connect( action, SIGNAL( activated() ),
979 SLOT( faq() ) ); 982 SLOT( faq() ) );
980 action = new QAction( "licence", i18n("Licence..."), 0, this ); 983 action = new QAction( "licence", i18n("Licence..."), 0, this );
981 action->addTo( helpMenu ); 984 action->addTo( helpMenu );
982 connect( action, SIGNAL( activated() ), 985 connect( action, SIGNAL( activated() ),
983 SLOT( licence() ) ); 986 SLOT( licence() ) );
984 action = new QAction( "about", i18n("About..."), 0, this ); 987 action = new QAction( "about", i18n("About..."), 0, this );
985 action->addTo( helpMenu ); 988 action->addTo( helpMenu );
986 connect( action, SIGNAL( activated() ), 989 connect( action, SIGNAL( activated() ),
987 SLOT( about() ) ); 990 SLOT( about() ) );
988 //menuBar->insertSeparator(); 991 //menuBar->insertSeparator();
989 992
990 // ****************************************************** 993 // ******************************************************
991 // menubar icons 994 // menubar icons
992 995
993 996
994 iconToolBar->setHorizontalStretchable (true ); 997 iconToolBar->setHorizontalStretchable (true );
995 //menuBar->insertItem( iconToolBar ); 998 //menuBar->insertItem( iconToolBar );
996 //xdays_action 999 //xdays_action
997 if (p-> mShowIconNewEvent) 1000 if (p-> mShowIconNewEvent)
998 ne_action->addTo( iconToolBar ); 1001 ne_action->addTo( iconToolBar );
999 if (p->mShowIconNewTodo ) 1002 if (p->mShowIconNewTodo )
1000 nt_action->addTo( iconToolBar ); 1003 nt_action->addTo( iconToolBar );
1001 if (p-> mShowIconSearch) 1004 if (p-> mShowIconSearch)
1002 search_action->addTo( iconToolBar ); 1005 search_action->addTo( iconToolBar );
1003 if (p-> mShowIconWhatsThis) 1006 if (p-> mShowIconWhatsThis)
1004 QWhatsThis::whatsThisButton ( iconToolBar ); 1007 QWhatsThis::whatsThisButton ( iconToolBar );
1005 if (p-> mShowIconNext) 1008 if (p-> mShowIconNext)
1006 whatsnext_action->addTo( iconToolBar ); 1009 whatsnext_action->addTo( iconToolBar );
1007 if (p-> mShowIconNextDays) 1010 if (p-> mShowIconNextDays)
1008 xdays_action->addTo( iconToolBar ); 1011 xdays_action->addTo( iconToolBar );
1009 if (p-> mShowIconList) 1012 if (p-> mShowIconList)
1010 showlist_action->addTo( iconToolBar ); 1013 showlist_action->addTo( iconToolBar );
1011 if (p-> mShowIconDay1) 1014 if (p-> mShowIconDay1)
1012 day1_action->addTo( iconToolBar ); 1015 day1_action->addTo( iconToolBar );
1013 if (p-> mShowIconDay5) 1016 if (p-> mShowIconDay5)
1014 day5_action->addTo( iconToolBar ); 1017 day5_action->addTo( iconToolBar );
1015 if (p-> mShowIconDay7) 1018 if (p-> mShowIconDay7)
1016 day7_action->addTo( iconToolBar ); 1019 day7_action->addTo( iconToolBar );
1017 if (p-> mShowIconDay6) 1020 if (p-> mShowIconDay6)
1018 day6_action->addTo( iconToolBar ); 1021 day6_action->addTo( iconToolBar );
1019 if (p-> mShowIconMonth) 1022 if (p-> mShowIconMonth)
1020 month_action->addTo( iconToolBar ); 1023 month_action->addTo( iconToolBar );
1021 if (p-> mShowIconTodoview) 1024 if (p-> mShowIconTodoview)
1022 todoview_action->addTo( iconToolBar ); 1025 todoview_action->addTo( iconToolBar );
1023 if (p-> mShowIconJournal) 1026 if (p-> mShowIconJournal)
1024 viewjournal_action->addTo( iconToolBar ); 1027 viewjournal_action->addTo( iconToolBar );
1025 icon = loadPixmap( pathString + "2leftarrowB" ); 1028 icon = loadPixmap( pathString + "2leftarrowB" );
1026 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 1029 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
1027 if (p-> mShowIconBackFast) { 1030 if (p-> mShowIconBackFast) {
1028 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1031 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1029 connect( action, SIGNAL( activated() ), 1032 connect( action, SIGNAL( activated() ),
1030 mView, SLOT( goPreviousMonth() ) ); 1033 mView, SLOT( goPreviousMonth() ) );
1031 action->addTo( iconToolBar ); 1034 action->addTo( iconToolBar );
1032 } 1035 }
1033 icon = loadPixmap( pathString + "1leftarrowB" ); 1036 icon = loadPixmap( pathString + "1leftarrowB" );
1034 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 1037 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
1035 if (p-> mShowIconBack) { 1038 if (p-> mShowIconBack) {
1036 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1039 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1037 connect( action, SIGNAL( activated() ), 1040 connect( action, SIGNAL( activated() ),
1038 mView, SLOT( goPrevious() ) ); 1041 mView, SLOT( goPrevious() ) );
1039 action->addTo( iconToolBar ); 1042 action->addTo( iconToolBar );
1040 } 1043 }
1041 icon = loadPixmap( pathString + "today" ); 1044 icon = loadPixmap( pathString + "today" );
1042 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1045 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1043 if (p-> mShowIconToday) 1046 if (p-> mShowIconToday)
1044 today_action->addTo( iconToolBar ); 1047 today_action->addTo( iconToolBar );
1045 icon = loadPixmap( pathString + "1rightarrowB" ); 1048 icon = loadPixmap( pathString + "1rightarrowB" );
1046 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1049 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1047 if (p-> mShowIconForward) { 1050 if (p-> mShowIconForward) {
1048 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1051 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1049 connect( action, SIGNAL( activated() ), 1052 connect( action, SIGNAL( activated() ),
1050 mView, SLOT( goNext() ) ); 1053 mView, SLOT( goNext() ) );
1051 action->addTo( iconToolBar ); 1054 action->addTo( iconToolBar );
1052 } 1055 }
1053 icon = loadPixmap( pathString + "2rightarrowB" ); 1056 icon = loadPixmap( pathString + "2rightarrowB" );
1054 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1057 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1055 if (p-> mShowIconForwardFast) { 1058 if (p-> mShowIconForwardFast) {
1056 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1059 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1057 connect( action, SIGNAL( activated() ), 1060 connect( action, SIGNAL( activated() ),
1058 mView, SLOT( goNextMonth() ) ); 1061 mView, SLOT( goNextMonth() ) );
1059 action->addTo( iconToolBar ); 1062 action->addTo( iconToolBar );
1060 } 1063 }
1061 1064
1062 1065
1063 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 1066 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
1064 1067
1065 if (p-> mShowIconNewEvent) 1068 if (p-> mShowIconNewEvent)
1066 configureToolBarMenu->setItemChecked( 10, true ); 1069 configureToolBarMenu->setItemChecked( 10, true );
1067 if (p->mShowIconNewTodo ) 1070 if (p->mShowIconNewTodo )
1068 configureToolBarMenu->setItemChecked( 20, true ); 1071 configureToolBarMenu->setItemChecked( 20, true );
1069 if (p-> mShowIconSearch) 1072 if (p-> mShowIconSearch)
1070 configureToolBarMenu->setItemChecked( 120, true ); 1073 configureToolBarMenu->setItemChecked( 120, true );
1071 if (p-> mShowIconList) 1074 if (p-> mShowIconList)
1072 configureToolBarMenu->setItemChecked( 30, true ); 1075 configureToolBarMenu->setItemChecked( 30, true );
1073 if (p-> mShowIconDay1) 1076 if (p-> mShowIconDay1)
1074 configureToolBarMenu->setItemChecked( 40, true ); 1077 configureToolBarMenu->setItemChecked( 40, true );
1075 if (p-> mShowIconDay5) 1078 if (p-> mShowIconDay5)
1076 configureToolBarMenu->setItemChecked( 50, true ); 1079 configureToolBarMenu->setItemChecked( 50, true );
1077 if (p-> mShowIconDay6) 1080 if (p-> mShowIconDay6)
1078 configureToolBarMenu->setItemChecked( 75, true ); 1081 configureToolBarMenu->setItemChecked( 75, true );
1079 if (p-> mShowIconDay7) 1082 if (p-> mShowIconDay7)
1080 configureToolBarMenu->setItemChecked( 60, true ); 1083 configureToolBarMenu->setItemChecked( 60, true );
1081 if (p-> mShowIconMonth) 1084 if (p-> mShowIconMonth)
1082 configureToolBarMenu->setItemChecked( 70, true ); 1085 configureToolBarMenu->setItemChecked( 70, true );
1083 if (p-> mShowIconTodoview) 1086 if (p-> mShowIconTodoview)
1084 configureToolBarMenu->setItemChecked( 80, true ); 1087 configureToolBarMenu->setItemChecked( 80, true );
1085 if (p-> mShowIconBackFast) 1088 if (p-> mShowIconBackFast)
1086 configureToolBarMenu->setItemChecked( 200, true ); 1089 configureToolBarMenu->setItemChecked( 200, true );
1087 if (p-> mShowIconBack) 1090 if (p-> mShowIconBack)
1088 configureToolBarMenu->setItemChecked( 210, true ); 1091 configureToolBarMenu->setItemChecked( 210, true );
1089 if (p-> mShowIconToday) 1092 if (p-> mShowIconToday)
1090 configureToolBarMenu->setItemChecked( 130, true ); 1093 configureToolBarMenu->setItemChecked( 130, true );
1091 if (p-> mShowIconForward) 1094 if (p-> mShowIconForward)
1092 configureToolBarMenu->setItemChecked( 220, true ); 1095 configureToolBarMenu->setItemChecked( 220, true );
1093 if (p-> mShowIconForwardFast) 1096 if (p-> mShowIconForwardFast)
1094 configureToolBarMenu->setItemChecked( 230, true ); 1097 configureToolBarMenu->setItemChecked( 230, true );
1095 if (p-> mShowIconNextDays) 1098 if (p-> mShowIconNextDays)
1096 configureToolBarMenu->setItemChecked( 100, true ); 1099 configureToolBarMenu->setItemChecked( 100, true );
1097 if (p-> mShowIconNext) 1100 if (p-> mShowIconNext)
1098 configureToolBarMenu->setItemChecked( 110, true ); 1101 configureToolBarMenu->setItemChecked( 110, true );
1099 if (p-> mShowIconJournal) 1102 if (p-> mShowIconJournal)
1100 configureToolBarMenu->setItemChecked( 90, true ); 1103 configureToolBarMenu->setItemChecked( 90, true );
1101 if (p-> mShowIconWhatsThis) 1104 if (p-> mShowIconWhatsThis)
1102 configureToolBarMenu->setItemChecked( 300, true ); 1105 configureToolBarMenu->setItemChecked( 300, true );
1103 if (p-> mShowIconWeekNum) 1106 if (p-> mShowIconWeekNum)
1104 configureToolBarMenu->setItemChecked( 400, true ); 1107 configureToolBarMenu->setItemChecked( 400, true );
1105 QLabel* dummy = new QLabel( iconToolBar ); 1108 QLabel* dummy = new QLabel( iconToolBar );
1106 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1109 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1107 if (!p-> mShowIconStretch) 1110 if (!p-> mShowIconStretch)
1108 iconToolBar->setStretchableWidget ( dummy ) ; 1111 iconToolBar->setStretchableWidget ( dummy ) ;
1109 else 1112 else
1110 configureToolBarMenu->setItemChecked( 5, true ); 1113 configureToolBarMenu->setItemChecked( 5, true );
1111 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1114 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1112 configureAgenda( p->mHourSize ); 1115 configureAgenda( p->mHourSize );
1113 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1116 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1114} 1117}
1115 1118
1116void MainWindow::exportToPhone( int mode ) 1119void MainWindow::exportToPhone( int mode )
1117{ 1120{
1118 1121
1119 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1122 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1120 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1123 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1121 KOex2phonePrefs ex2phone; 1124 KOex2phonePrefs ex2phone;
1122 1125
1123 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1126 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1124 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1127 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1125 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1128 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1126 if ( mode == 1 ) 1129 if ( mode == 1 )
1127 ex2phone.setCaption(i18n("Export complete calendar")); 1130 ex2phone.setCaption(i18n("Export complete calendar"));
1128 if ( mode == 2 ) 1131 if ( mode == 2 )
1129 ex2phone.setCaption(i18n("Export filtered calendar")); 1132 ex2phone.setCaption(i18n("Export filtered calendar"));
1130 1133
1131 if ( !ex2phone.exec() ) { 1134 if ( !ex2phone.exec() ) {
1132 return; 1135 return;
1133 } 1136 }
1134 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1137 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1135 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1138 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1136 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1139 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1137 1140
1138 int inFuture = 0; 1141 int inFuture = 0;
1139 if ( ex2phone.mWriteBackFuture->isChecked() ) 1142 if ( ex2phone.mWriteBackFuture->isChecked() )
1140 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1143 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1141 QPtrList<Incidence> delSel; 1144 QPtrList<Incidence> delSel;
1142 if ( mode == 1 ) 1145 if ( mode == 1 )
1143 delSel = mCalendar->rawIncidences(); 1146 delSel = mCalendar->rawIncidences();
1144 if ( mode == 2 ) 1147 if ( mode == 2 )
1145 delSel = mCalendar->incidences(); 1148 delSel = mCalendar->incidences();
1146 CalendarLocal* cal = new CalendarLocal(); 1149 CalendarLocal* cal = new CalendarLocal();
1147 cal->setLocalTime(); 1150 cal->setLocalTime();
1148 Incidence *incidence = delSel.first(); 1151 Incidence *incidence = delSel.first();
1149 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1152 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1150 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1153 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1151 while ( incidence ) { 1154 while ( incidence ) {
1152 if ( incidence->type() != "Journal" ) { 1155 if ( incidence->type() != "Journal" ) {
1153 bool add = true; 1156 bool add = true;
1154 if ( inFuture ) { 1157 if ( inFuture ) {
1155 QDateTime dt; 1158 QDateTime dt;
1156 if ( incidence->type() == "Todo" ) { 1159 if ( incidence->type() == "Todo" ) {
1157 Todo * t = (Todo*)incidence; 1160 Todo * t = (Todo*)incidence;
1158 if ( t->hasDueDate() ) 1161 if ( t->hasDueDate() )
1159 dt = t->dtDue(); 1162 dt = t->dtDue();
1160 else 1163 else
1161 dt = cur.addSecs( 62 ); 1164 dt = cur.addSecs( 62 );
1162 } 1165 }
1163 else { 1166 else {
1164 bool ok; 1167 bool ok;
1165 dt = incidence->getNextOccurence( cur, &ok ); 1168 dt = incidence->getNextOccurence( cur, &ok );
1166 if ( !ok ) 1169 if ( !ok )
1167 dt = cur.addSecs( -62 ); 1170 dt = cur.addSecs( -62 );
1168 } 1171 }
1169 if ( dt < cur || dt > end ) { 1172 if ( dt < cur || dt > end ) {
1170 add = false; 1173 add = false;
1171 } 1174 }
1172 } 1175 }
1173 if ( add ) { 1176 if ( add ) {
1174 Incidence *in = incidence->clone(); 1177 Incidence *in = incidence->clone();
1175 cal->addIncidence( in ); 1178 cal->addIncidence( in );
1176 } 1179 }
1177 } 1180 }
1178 incidence = delSel.next(); 1181 incidence = delSel.next();
1179 } 1182 }
1180 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1183 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1181 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1184 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1182 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1185 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1183 1186
1184 setCaption( i18n("Writing to phone...")); 1187 setCaption( i18n("Writing to phone..."));
1185 if ( PhoneFormat::writeToPhone( cal ) ) 1188 if ( PhoneFormat::writeToPhone( cal ) )
1186 setCaption( i18n("Export to phone successful!")); 1189 setCaption( i18n("Export to phone successful!"));
1187 else 1190 else
1188 setCaption( i18n("Error exporting to phone!")); 1191 setCaption( i18n("Error exporting to phone!"));
1189 delete cal; 1192 delete cal;
1190} 1193}
1191 1194
1192 1195
1193void MainWindow::setDefaultPreferences() 1196void MainWindow::setDefaultPreferences()
1194{ 1197{
1195 KOPrefs *p = KOPrefs::instance(); 1198 KOPrefs *p = KOPrefs::instance();
1196 1199
1197 p->mCompactDialogs = true; 1200 p->mCompactDialogs = true;
1198 p->mConfirm = true; 1201 p->mConfirm = true;
1199 // p->mEnableQuickTodo = false; 1202 // p->mEnableQuickTodo = false;
1200 1203
1201} 1204}
1202 1205
1203QString MainWindow::resourcePath() 1206QString MainWindow::resourcePath()
1204{ 1207{
1205 return KGlobal::iconLoader()->iconPath(); 1208 return KGlobal::iconLoader()->iconPath();
1206} 1209}
1207 1210
1208void MainWindow::displayText( QString text ,QString cap ) 1211void MainWindow::displayText( QString text ,QString cap )
1209{ 1212{
1210 QDialog dia( this, "name", true ); ; 1213 QDialog dia( this, "name", true ); ;
1211 dia.setCaption( cap ); 1214 dia.setCaption( cap );
1212 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1215 QVBoxLayout* lay = new QVBoxLayout( &dia );
1213 lay->setSpacing( 3 ); 1216 lay->setSpacing( 3 );
1214 lay->setMargin( 3 ); 1217 lay->setMargin( 3 );
1215 QTextBrowser tb ( &dia ); 1218 QTextBrowser tb ( &dia );
1216 lay->addWidget( &tb ); 1219 lay->addWidget( &tb );
1217 tb.setText( text ); 1220 tb.setText( text );
1218#ifdef DESKTOP_VERSION 1221#ifdef DESKTOP_VERSION
1219 dia.resize( 640, 480); 1222 dia.resize( 640, 480);
1220#else 1223#else
1221 dia.showMaximized(); 1224 dia.showMaximized();
1222#endif 1225#endif
1223 dia.exec(); 1226 dia.exec();
1224} 1227}
1225 1228
1226void MainWindow::features() 1229void MainWindow::features()
1227{ 1230{
1228 1231
1229 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1232 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1230} 1233}
1231 1234
1232void MainWindow::usertrans() 1235void MainWindow::usertrans()
1233{ 1236{
1234 1237
1235 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1238 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1236} 1239}
1237 1240
1238void MainWindow::kdesynchowto() 1241void MainWindow::kdesynchowto()
1239{ 1242{
1240 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1243 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1241} 1244}
1242void MainWindow::multisynchowto() 1245void MainWindow::multisynchowto()
1243{ 1246{
1244 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1247 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1245} 1248}
1246void MainWindow::synchowto() 1249void MainWindow::synchowto()
1247{ 1250{
1248 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1251 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1249} 1252}
1250void MainWindow::faq() 1253void MainWindow::faq()
1251{ 1254{
1252 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1255 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1253 1256
1254} 1257}
1255void MainWindow::whatsNew() 1258void MainWindow::whatsNew()
1256{ 1259{
1257 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1260 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1258 1261
1259} 1262}
1260void MainWindow::licence() 1263void MainWindow::licence()
1261{ 1264{
1262 KApplication::showLicence(); 1265 KApplication::showLicence();
1263 1266
1264} 1267}
1265void MainWindow::about() 1268void MainWindow::about()
1266{ 1269{
1267 QString version; 1270 QString version;
1268#include <../version> 1271#include <../version>
1269 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1272 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1270 i18n("KOrganizer/Platform-independent\n") + 1273 i18n("KOrganizer/Platform-independent\n") +
1271 "(KO/Pi) " + version + " - " + 1274 "(KO/Pi) " + version + " - " +
1272 1275
1273#ifdef DESKTOP_VERSION 1276#ifdef DESKTOP_VERSION
1274 i18n("Desktop Edition\n") + 1277 i18n("Desktop Edition\n") +
1275#else 1278#else
1276 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1279 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1277#endif 1280#endif
1278 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!") ); 1281 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!") );
1279} 1282}
1280void MainWindow::keyBindings() 1283void MainWindow::keyBindings()
1281{ 1284{
1282 QString cap = i18n("KO/Pi Keys + Colors"); 1285 QString cap = i18n("KO/Pi Keys + Colors");
1283 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1286 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1284 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1287 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1285 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1288 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1286 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1289 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1287 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1290 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1288 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1291 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1289 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1292 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1290 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1293 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1291 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1294 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1292 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1295 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1293 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1296 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1294 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1297 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1295 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1298 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1296 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1299 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1297 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1300 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1298 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1301 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1299 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1302 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1300 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1303 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1301 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1304 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1302 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1305 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1303 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1306 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1304 i18n("<p><h3>In agenda view:</h3></p>\n") + 1307 i18n("<p><h3>In agenda view:</h3></p>\n") +
1305 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1308 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1306 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1309 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1307 i18n("<p><h3>In todo view:</h3></p>\n") + 1310 i18n("<p><h3>In todo view:</h3></p>\n") +
1308 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1311 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1309 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1312 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1310 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1313 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1311 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1314 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1312 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1315 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1313 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1316 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1314 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1317 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1315 i18n("<p><h3>In list view:</h3></p>\n") + 1318 i18n("<p><h3>In list view:</h3></p>\n") +
1316 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1319 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1317 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1320 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1318 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1321 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1319 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1322 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1320 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1323 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1321 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1324 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1322 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1325 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1323 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1326 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1324 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1327 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1325 i18n("<p><b>E</b>: Edit item</p>\n") + 1328 i18n("<p><b>E</b>: Edit item</p>\n") +
1326 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1329 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1327 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1330 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1328 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1331 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1329 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1332 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1330 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1333 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1331 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1334 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1332 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1335 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1333 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1336 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1334 i18n("<p><b>White</b>: Item readonly</p>\n"); 1337 i18n("<p><b>White</b>: Item readonly</p>\n");
1335 displayText( text, cap); 1338 displayText( text, cap);
1336} 1339}
1337void MainWindow::aboutAutoSaving() 1340void MainWindow::aboutAutoSaving()
1338{ 1341{
1339 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"); 1342 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");
1340 1343
1341 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1344 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1342 1345
1343} 1346}
1344void MainWindow::aboutKnownBugs() 1347void MainWindow::aboutKnownBugs()
1345{ 1348{
1346 QMessageBox* msg; 1349 QMessageBox* msg;
1347 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1350 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1348 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")+ 1351 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")+
1349 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1352 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1350 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1353 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1351 i18n("\nor report them in the bugtracker on\n") + 1354 i18n("\nor report them in the bugtracker on\n") +
1352 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1355 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1353 QMessageBox::NoIcon, 1356 QMessageBox::NoIcon,
1354 QMessageBox::Ok, 1357 QMessageBox::Ok,
1355 QMessageBox::NoButton, 1358 QMessageBox::NoButton,
1356 QMessageBox::NoButton); 1359 QMessageBox::NoButton);
1357 msg->exec(); 1360 msg->exec();
1358 delete msg; 1361 delete msg;
1359 1362
1360} 1363}
1361 1364
1362QString MainWindow::defaultFileName() 1365QString MainWindow::defaultFileName()
1363{ 1366{
1364 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1367 return locateLocal( "data", "korganizer/mycalendar.ics" );
1365} 1368}
1366QString MainWindow::syncFileName() 1369QString MainWindow::syncFileName()
1367{ 1370{
1368#ifdef DESKTOP_VERSION 1371#ifdef DESKTOP_VERSION
1369 return locateLocal( "tmp", "synccalendar.ics" ); 1372 return locateLocal( "tmp", "synccalendar.ics" );
1370#else 1373#else
1371 return QString( "/tmp/synccalendar.ics" ); 1374 return QString( "/tmp/synccalendar.ics" );
1372#endif 1375#endif
1373} 1376}
1374void MainWindow::updateWeek(QDate seda) 1377void MainWindow::updateWeek(QDate seda)
1375{ 1378{
1376 int weekNum = 0; 1379 int weekNum = 0;
1377 QDate d = QDate ( seda.year(), 1,1); 1380 QDate d = QDate ( seda.year(), 1,1);
1378 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday 1381 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1379 if ( seda.addDays(6).year() != seda.year() ) { 1382 if ( seda.addDays(6).year() != seda.year() ) {
1380 if ( seda.year() != d.year() ) { 1383 if ( seda.year() != d.year() ) {
1381 if ( d.dayOfWeek() > 4 ) 1384 if ( d.dayOfWeek() > 4 )
1382 d = QDate ( seda.year(), 1,1); 1385 d = QDate ( seda.year(), 1,1);
1383 else 1386 else
1384 weekNum = 1; 1387 weekNum = 1;
1385 } else { 1388 } else {
1386 QDate dd( seda.year()+1, 1,1); 1389 QDate dd( seda.year()+1, 1,1);
1387 if ( dd.dayOfWeek() <= 4 ) 1390 if ( dd.dayOfWeek() <= 4 )
1388 weekNum = 1; 1391 weekNum = 1;
1389 } 1392 }
1390 } 1393 }
1391 if ( weekNum == 0 ){ 1394 if ( weekNum == 0 ){
1392 int dow = d.dayOfWeek(); 1395 int dow = d.dayOfWeek();
1393 if ( dow <= 4 ) 1396 if ( dow <= 4 )
1394 d = d.addDays( 1-dow ); 1397 d = d.addDays( 1-dow );
1395 else // 5,6,7 1398 else // 5,6,7
1396 d = d.addDays( 8-dow ); 1399 d = d.addDays( 8-dow );
1397 // we have the first week of the year.we are on monday 1400 // we have the first week of the year.we are on monday
1398 weekNum = d.daysTo( seda ) / 7 +1; 1401 weekNum = d.daysTo( seda ) / 7 +1;
1399 } 1402 }
1400 1403
1401 mWeekPixmap.fill( mWeekBgColor ); 1404 mWeekPixmap.fill( mWeekBgColor );
1402 QPainter p ( &mWeekPixmap ); 1405 QPainter p ( &mWeekPixmap );
1403 p.setFont( mWeekFont ); 1406 p.setFont( mWeekFont );
1404 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1407 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1405 p.end(); 1408 p.end();
1406 QIconSet icon3 ( mWeekPixmap ); 1409 QIconSet icon3 ( mWeekPixmap );
1407 mWeekAction->setIconSet ( icon3 ); 1410 mWeekAction->setIconSet ( icon3 );
1408 1411
1409} 1412}
1410void MainWindow::updateWeekNum(const DateList &selectedDates) 1413void MainWindow::updateWeekNum(const DateList &selectedDates)
1411{ 1414{
1412 updateWeek( selectedDates.first() ); 1415 updateWeek( selectedDates.first() );
1413} 1416}
1414void MainWindow::processIncidenceSelection( Incidence *incidence ) 1417void MainWindow::processIncidenceSelection( Incidence *incidence )
1415{ 1418{
1416 1419
1417 if ( !incidence ) { 1420 if ( !incidence ) {
1418 enableIncidenceActions( false ); 1421 enableIncidenceActions( false );
1419 1422
1420 mNewSubTodoAction->setEnabled( false ); 1423 mNewSubTodoAction->setEnabled( false );
1421 setCaptionToDates(); 1424 setCaptionToDates();
1422 return; 1425 return;
1423 1426
1424 } 1427 }
1425 1428
1426 //KGlobal::locale()->formatDateTime(nextA, true); 1429 //KGlobal::locale()->formatDateTime(nextA, true);
1427 QString startString = ""; 1430 QString startString = "";
1428 if ( incidence->type() != "Todo" ) { 1431 if ( incidence->type() != "Todo" ) {
1429 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1432 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1430 if ( incidence->doesFloat() ) { 1433 if ( incidence->doesFloat() ) {
1431 startString += ": "+incidence->dtStartDateStr( true ); 1434 startString += ": "+incidence->dtStartDateStr( true );
1432 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1435 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1433 1436
1434 } else { 1437 } else {
1435 startString = ": "+incidence->dtStartStr(true); 1438 startString = ": "+incidence->dtStartStr(true);
1436 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1439 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1437 1440
1438 } 1441 }
1439 1442
1440 } else { 1443 } else {
1441 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1444 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1442 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1445 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1443 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1446 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1444 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1447 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1445 bool ok; 1448 bool ok;
1446 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1449 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1447 if ( ok ) { 1450 if ( ok ) {
1448 int years = noc.date().year() - incidence->dtStart().date().year(); 1451 int years = noc.date().year() - incidence->dtStart().date().year();
1449 startString += i18n(" (%1 y.)"). arg( years ); 1452 startString += i18n(" (%1 y.)"). arg( years );
1450 } 1453 }
1451 } 1454 }
1452 else 1455 else
1453 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1456 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1454 } 1457 }
1455 1458
1456 } 1459 }
1457 else 1460 else
1458 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1461 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1459 if ( !incidence->location().isEmpty() ) 1462 if ( !incidence->location().isEmpty() )
1460 startString += " (" +incidence->location()+")"; 1463 startString += " (" +incidence->location()+")";
1461 setCaption( incidence->summary()+startString); 1464 setCaption( incidence->summary()+startString);
1462 1465
1463 enableIncidenceActions( true ); 1466 enableIncidenceActions( true );
1464 1467
1465 if ( incidence->type() == "Event" ) { 1468 if ( incidence->type() == "Event" ) {
1466 mShowAction->setText( i18n("Show Event...") ); 1469 mShowAction->setText( i18n("Show Event...") );
1467 mEditAction->setText( i18n("Edit Event...") ); 1470 mEditAction->setText( i18n("Edit Event...") );
1468 mDeleteAction->setText( i18n("Delete Event...") ); 1471 mDeleteAction->setText( i18n("Delete Event...") );
1469 1472
1470 mNewSubTodoAction->setEnabled( false ); 1473 mNewSubTodoAction->setEnabled( false );
1471 } else if ( incidence->type() == "Todo" ) { 1474 } else if ( incidence->type() == "Todo" ) {
1472 mShowAction->setText( i18n("Show Todo...") ); 1475 mShowAction->setText( i18n("Show Todo...") );
1473 mEditAction->setText( i18n("Edit Todo...") ); 1476 mEditAction->setText( i18n("Edit Todo...") );
1474 mDeleteAction->setText( i18n("Delete Todo...") ); 1477 mDeleteAction->setText( i18n("Delete Todo...") );
1475 1478
1476 mNewSubTodoAction->setEnabled( true ); 1479 mNewSubTodoAction->setEnabled( true );
1477 } else { 1480 } else {
1478 mShowAction->setText( i18n("Show...") ); 1481 mShowAction->setText( i18n("Show...") );
1479 mShowAction->setText( i18n("Edit...") ); 1482 mShowAction->setText( i18n("Edit...") );
1480 mShowAction->setText( i18n("Delete...") ); 1483 mShowAction->setText( i18n("Delete...") );
1481 1484
1482 mNewSubTodoAction->setEnabled( false ); 1485 mNewSubTodoAction->setEnabled( false );
1483 } 1486 }
1484} 1487}
1485 1488
1486void MainWindow::enableIncidenceActions( bool enabled ) 1489void MainWindow::enableIncidenceActions( bool enabled )
1487{ 1490{
1488 mShowAction->setEnabled( enabled ); 1491 mShowAction->setEnabled( enabled );
1489 mEditAction->setEnabled( enabled ); 1492 mEditAction->setEnabled( enabled );
1490 mDeleteAction->setEnabled( enabled ); 1493 mDeleteAction->setEnabled( enabled );
1491 1494
1492 mCloneAction->setEnabled( enabled ); 1495 mCloneAction->setEnabled( enabled );
1493 mMoveAction->setEnabled( enabled ); 1496 mMoveAction->setEnabled( enabled );
1494 mBeamAction->setEnabled( enabled ); 1497 mBeamAction->setEnabled( enabled );
1495 mCancelAction->setEnabled( enabled ); 1498 mCancelAction->setEnabled( enabled );
1496} 1499}
1497 1500
1498void MainWindow::importOL() 1501void MainWindow::importOL()
1499{ 1502{
1500#ifdef _OL_IMPORT_ 1503#ifdef _OL_IMPORT_
1501 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1504 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1502 id->exec(); 1505 id->exec();
1503 delete id; 1506 delete id;
1504 mView->updateView(); 1507 mView->updateView();
1505#endif 1508#endif
1506} 1509}
1507void MainWindow::importBday() 1510void MainWindow::importBday()
1508{ 1511{
1509 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1512 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1510 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1513 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1511 i18n("Import!"), i18n("Cancel"), 0, 1514 i18n("Import!"), i18n("Cancel"), 0,
1512 0, 1 ); 1515 0, 1 );
1513 if ( result == 0 ) { 1516 if ( result == 0 ) {
1514 mView->importBday(); 1517 mView->importBday();
1515 1518
1516 } 1519 }
1517 1520
1518 1521
1519} 1522}
1520void MainWindow::importQtopia() 1523void MainWindow::importQtopia()
1521{ 1524{
1522 //#ifndef DESKTOP_VERSION 1525 //#ifndef DESKTOP_VERSION
1523 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"); 1526 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");
1524#ifdef DESKTOP_VERSION 1527#ifdef DESKTOP_VERSION
1525 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"); 1528 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");
1526#endif 1529#endif
1527 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1530 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1528 i18n("Import!"), i18n("Cancel"), 0, 1531 i18n("Import!"), i18n("Cancel"), 0,
1529 0, 1 ); 1532 0, 1 );
1530 if ( result == 0 ) { 1533 if ( result == 0 ) {
1531#ifndef DESKTOP_VERSION 1534#ifndef DESKTOP_VERSION
1532 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1535 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1533 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1536 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1534 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1537 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1535#else 1538#else
1536 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1539 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1537 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1540 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1538 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1541 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1539#endif 1542#endif
1540 mView->importQtopia( categories, datebook, todolist ); 1543 mView->importQtopia( categories, datebook, todolist );
1541 } 1544 }
1542#if 0 1545#if 0
1543 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1546 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1544 i18n("Not supported \non desktop!\n"), 1547 i18n("Not supported \non desktop!\n"),
1545 i18n("Ok"), i18n("Cancel"), 0, 1548 i18n("Ok"), i18n("Cancel"), 0,
1546 0, 1 ); 1549 0, 1 );
1547 1550
1548#endif 1551#endif
1549} 1552}
1550 1553
1551void MainWindow::saveOnClose() 1554void MainWindow::saveOnClose()
1552{ 1555{
1553 KOPrefs *p = KOPrefs::instance(); 1556 KOPrefs *p = KOPrefs::instance();
1554 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1557 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1555 p->mToolBarUp = iconToolBar->x() > width()/2 || 1558 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1556 iconToolBar->y() > height()/2; 1559 iconToolBar->y() > height()/2;
1557 mView->writeSettings(); 1560 mView->writeSettings();
1558 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1561 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1559 save(); 1562 save();
1560} 1563}
1561void MainWindow::slotModifiedChanged( bool changed ) 1564void MainWindow::slotModifiedChanged( bool changed )
1562{ 1565{
1563 if ( mBlockAtStartup ) 1566 if ( mBlockAtStartup )
1564 return; 1567 return;
1565 1568
1566 int msec; 1569 int msec;
1567 // we store the changes after 1 minute, 1570 // we store the changes after 1 minute,
1568 // and for safety reasons after 10 minutes again 1571 // and for safety reasons after 10 minutes again
1569 if ( !mSyncManager->blockSave() ) 1572 if ( !mSyncManager->blockSave() )
1570 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1573 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1571 else 1574 else
1572 msec = 1000 * 600; 1575 msec = 1000 * 600;
1573 mSaveTimer.start( msec, true ); // 1 minute 1576 mSaveTimer.start( msec, true ); // 1 minute
1574 qDebug("KO: Saving File in %d secs!", msec/1000); 1577 qDebug("KO: Saving File in %d secs!", msec/1000);
1575 mCalendarModifiedFlag = true; 1578 mCalendarModifiedFlag = true;
1576} 1579}
1577void MainWindow::saveStopTimer() 1580void MainWindow::saveStopTimer()
1578{ 1581{
1579 mSaveTimer.stop(); 1582 mSaveTimer.stop();
1580 if (mSaveTimer.isActive() ) 1583 if (mSaveTimer.isActive() )
1581 qDebug("ti active "); 1584 qDebug("ti active ");
1582 else 1585 else
1583 qDebug("KO: Save timer stopped"); 1586 qDebug("KO: Save timer stopped");
1584} 1587}
1585void MainWindow::save() 1588void MainWindow::save()
1586{ 1589{
1587 if ( !mCalendarModifiedFlag ) { 1590 if ( !mCalendarModifiedFlag ) {
1588 qDebug("KO: Calendar not modified. Nothing saved."); 1591 qDebug("KO: Calendar not modified. Nothing saved.");
1589 return; 1592 return;
1590 } 1593 }
1591 if ( mSyncManager->blockSave() ) 1594 if ( mSyncManager->blockSave() )
1592 return; 1595 return;
1593 mSyncManager->setBlockSave(true); 1596 mSyncManager->setBlockSave(true);
1594 if ( mView->checkFileVersion( defaultFileName()) ) { 1597 if ( mView->checkFileVersion( defaultFileName()) ) {
1595 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1598 QTime neededSaveTime = QDateTime::currentDateTime().time();
1596 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1599 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1597 qDebug("KO: Start saving data to file!"); 1600 qDebug("KO: Start saving data to file!");
1598 mView->saveCalendar( defaultFileName() ); 1601 mView->saveCalendar( defaultFileName() );
1599 mCalendarModifiedFlag = false; 1602 mCalendarModifiedFlag = false;
1600 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1603 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1601 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1604 qDebug("KO: Needed %d ms for saving.",msNeeded );
1602 QString savemes; 1605 QString savemes;
1603 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1606 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1604 setCaption(savemes); 1607 setCaption(savemes);
1605 } else 1608 } else
1606 setCaption(i18n("Saving cancelled!")); 1609 setCaption(i18n("Saving cancelled!"));
1607 mSyncManager->setBlockSave( false ); 1610 mSyncManager->setBlockSave( false );
1608} 1611}
1609 1612
1610void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1613void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1611{ 1614{
1612 if ( !e->isAutoRepeat() ) { 1615 if ( !e->isAutoRepeat() ) {
1613 mFlagKeyPressed = false; 1616 mFlagKeyPressed = false;
1614 } 1617 }
1615} 1618}
1616void MainWindow::keyPressEvent ( QKeyEvent * e ) 1619void MainWindow::keyPressEvent ( QKeyEvent * e )
1617{ 1620{
1618 qApp->processEvents(); 1621 qApp->processEvents();
1619 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1622 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1620 e->ignore(); 1623 e->ignore();
1621 // qDebug(" ignore %d",e->isAutoRepeat() ); 1624 // qDebug(" ignore %d",e->isAutoRepeat() );
1622 return; 1625 return;
1623 } 1626 }
1624 if (! e->isAutoRepeat() ) 1627 if (! e->isAutoRepeat() )
1625 mFlagKeyPressed = true; 1628 mFlagKeyPressed = true;
1626 KOPrefs *p = KOPrefs::instance(); 1629 KOPrefs *p = KOPrefs::instance();
1627 bool showSelectedDates = false; 1630 bool showSelectedDates = false;
1628 int size; 1631 int size;
1629 int pro = 0; 1632 int pro = 0;
1630 //qDebug("MainWindow::keyPressEvent "); 1633 //qDebug("MainWindow::keyPressEvent ");
1631 switch ( e->key() ) { 1634 switch ( e->key() ) {
1632 case Qt::Key_Right: 1635 case Qt::Key_Right:
1633 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1636 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1634 mView->goNextMonth(); 1637 mView->goNextMonth();
1635 else 1638 else
1636 mView->goNext(); 1639 mView->goNext();
1637 showSelectedDates = true; 1640 showSelectedDates = true;
1638 break; 1641 break;
1639 case Qt::Key_Left: 1642 case Qt::Key_Left:
1640 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1643 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1641 mView->goPreviousMonth(); 1644 mView->goPreviousMonth();
1642 else 1645 else
1643 mView->goPrevious(); 1646 mView->goPrevious();
1644 showSelectedDates = true; 1647 showSelectedDates = true;
1645 break; 1648 break;
1646 case Qt::Key_Down: 1649 case Qt::Key_Down:
1647 mView->viewManager()->agendaView()->scrollOneHourDown(); 1650 mView->viewManager()->agendaView()->scrollOneHourDown();
1648 break; 1651 break;
1649 case Qt::Key_Up: 1652 case Qt::Key_Up:
1650 mView->viewManager()->agendaView()->scrollOneHourUp(); 1653 mView->viewManager()->agendaView()->scrollOneHourUp();
1651 break; 1654 break;
1652 case Qt::Key_K: 1655 case Qt::Key_K:
1653 mView->viewManager()->showMonthViewWeek(); 1656 mView->viewManager()->showMonthViewWeek();
1654 break; 1657 break;
1655 case Qt::Key_I: 1658 case Qt::Key_I:
1656 mView->showIncidence(); 1659 mView->showIncidence();
1657 break; 1660 break;
1658 case Qt::Key_Delete: 1661 case Qt::Key_Delete:
1659 case Qt::Key_Backspace: 1662 case Qt::Key_Backspace:
1660 mView->deleteIncidence(); 1663 mView->deleteIncidence();
1661 break; 1664 break;
1662 case Qt::Key_D: 1665 case Qt::Key_D:
1663 mView->viewManager()->showDayView(); 1666 mView->viewManager()->showDayView();
1664 showSelectedDates = true; 1667 showSelectedDates = true;
1665 break; 1668 break;
1666 case Qt::Key_O: 1669 case Qt::Key_O:
1667 mView->toggleFilerEnabled( ); 1670 mView->toggleFilerEnabled( );
1668 break; 1671 break;
1669 case Qt::Key_0: 1672 case Qt::Key_0:
1670 case Qt::Key_1: 1673 case Qt::Key_1:
1671 case Qt::Key_2: 1674 case Qt::Key_2:
1672 case Qt::Key_3: 1675 case Qt::Key_3:
1673 case Qt::Key_4: 1676 case Qt::Key_4:
1674 case Qt::Key_5: 1677 case Qt::Key_5:
1675 case Qt::Key_6: 1678 case Qt::Key_6:
1676 case Qt::Key_7: 1679 case Qt::Key_7:
1677 case Qt::Key_8: 1680 case Qt::Key_8:
1678 case Qt::Key_9: 1681 case Qt::Key_9:
1679 pro = e->key()-48; 1682 pro = e->key()-48;
1680 if ( pro == 0 ) 1683 if ( pro == 0 )
1681 pro = 10; 1684 pro = 10;
1682 if ( e->state() == Qt::ControlButton) 1685 if ( e->state() == Qt::ControlButton)
1683 pro += 10; 1686 pro += 10;
1684 break; 1687 break;
1685 case Qt::Key_M: 1688 case Qt::Key_M:
1686 mView->viewManager()->showMonthView(); 1689 mView->viewManager()->showMonthView();
1687 showSelectedDates = true; 1690 showSelectedDates = true;
1688 break; 1691 break;
1689 case Qt::Key_Insert: 1692 case Qt::Key_Insert:
1690 mView->newEvent(); 1693 mView->newEvent();
1691 break; 1694 break;
1692 case Qt::Key_S : 1695 case Qt::Key_S :
1693 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1696 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1694 mView->newSubTodo(); 1697 mView->newSubTodo();
1695 else 1698 else
1696 mView->dialogManager()->showSearchDialog(); 1699 mView->dialogManager()->showSearchDialog();
1697 break; 1700 break;
1698 case Qt::Key_Y : 1701 case Qt::Key_Y :
1699 case Qt::Key_Z : 1702 case Qt::Key_Z :
1700 mView->viewManager()->showWorkWeekView(); 1703 mView->viewManager()->showWorkWeekView();
1701 showSelectedDates = true; 1704 showSelectedDates = true;
1702 break; 1705 break;
1703 case Qt::Key_U : 1706 case Qt::Key_U :
1704 mView->viewManager()->showWeekView(); 1707 mView->viewManager()->showWeekView();
1705 showSelectedDates = true; 1708 showSelectedDates = true;
1706 break; 1709 break;
1707 case Qt::Key_H : 1710 case Qt::Key_H :
1708 keyBindings(); 1711 keyBindings();
1709 break; 1712 break;
1710 case Qt::Key_W: 1713 case Qt::Key_W:
1711 mView->viewManager()->showWhatsNextView(); 1714 mView->viewManager()->showWhatsNextView();
1712 break; 1715 break;
1713 case Qt::Key_L: 1716 case Qt::Key_L:
1714 mView->viewManager()->showListView(); 1717 mView->viewManager()->showListView();
1715 break; 1718 break;
1716 case Qt::Key_N: 1719 case Qt::Key_N:
1717 mView->viewManager()->showNextXView(); 1720 mView->viewManager()->showNextXView();
1718 showSelectedDates = true; 1721 showSelectedDates = true;
1719 break; 1722 break;
1720 case Qt::Key_V: 1723 case Qt::Key_V:
1721 mView->viewManager()->showTodoView(); 1724 mView->viewManager()->showTodoView();
1722 break; 1725 break;
1723 case Qt::Key_C: 1726 case Qt::Key_C:
1724 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1727 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1725 break; 1728 break;
1726 case Qt::Key_P: 1729 case Qt::Key_P:
1727 mView->showDatePicker( ); 1730 mView->showDatePicker( );
1728 break; 1731 break;
1729 case Qt::Key_F: 1732 case Qt::Key_F:
1730 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1733 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1731 mView->editFilters(); 1734 mView->editFilters();
1732 else 1735 else
1733 mView->toggleFilter(); 1736 mView->toggleFilter();
1734 break; 1737 break;
1735 case Qt::Key_X: 1738 case Qt::Key_X:
1736 mView->toggleDateNavigatorWidget(); 1739 mView->toggleDateNavigatorWidget();
1737 break; 1740 break;
1738 case Qt::Key_Space: 1741 case Qt::Key_Space:
1739 mView->toggleExpand(); 1742 mView->toggleExpand();
1740 break; 1743 break;
1741 case Qt::Key_A: 1744 case Qt::Key_A:
1742 mView->toggleAllDaySize(); 1745 mView->toggleAllDaySize();
1743 break; 1746 break;
1744 case Qt::Key_T: 1747 case Qt::Key_T:
1745 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1748 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1746 mView->newTodo(); 1749 mView->newTodo();
1747 else { 1750 else {
1748 mView->goToday(); 1751 mView->goToday();
1749 showSelectedDates = true; 1752 showSelectedDates = true;
1750 } 1753 }
1751 break; 1754 break;
1752 case Qt::Key_J: 1755 case Qt::Key_J:
1753 mView->viewManager()->showJournalView(); 1756 mView->viewManager()->showJournalView();
1754 break; 1757 break;
1755 case Qt::Key_B: 1758 case Qt::Key_B:
1756 mView->editIncidenceDescription();; 1759 mView->editIncidenceDescription();;
1757 break; 1760 break;
1758 // case Qt::Key_Return: 1761 // case Qt::Key_Return:
1759 case Qt::Key_E: 1762 case Qt::Key_E:
1760 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1763 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1761 mView->newEvent(); 1764 mView->newEvent();
1762 else 1765 else
1763 mView->editIncidence(); 1766 mView->editIncidence();
1764 break; 1767 break;
1765 case Qt::Key_Plus: 1768 case Qt::Key_Plus:
1766 size = p->mHourSize +2; 1769 size = p->mHourSize +2;
1767 if ( size <= 22 ) 1770 if ( size <= 22 )
1768 configureAgenda( size ); 1771 configureAgenda( size );
1769 break; 1772 break;
1770 case Qt::Key_Minus: 1773 case Qt::Key_Minus:
1771 size = p->mHourSize - 2; 1774 size = p->mHourSize - 2;
1772 if ( size >= 4 ) 1775 if ( size >= 4 )
1773 configureAgenda( size ); 1776 configureAgenda( size );
1774 break; 1777 break;
1775 1778
1776 1779
1777 default: 1780 default:
1778 e->ignore(); 1781 e->ignore();
1779 } 1782 }
1780 if ( pro > 0 ) { 1783 if ( pro > 0 ) {
1781 mView->selectFilter( pro-1 ); 1784 mView->selectFilter( pro-1 );
1782 } 1785 }
1783 if ( showSelectedDates ) { 1786 if ( showSelectedDates ) {
1784 ;// setCaptionToDates(); 1787 ;// setCaptionToDates();
1785 } 1788 }
1786 1789
1787} 1790}
1788 1791
1789void MainWindow::fillFilterMenu() 1792void MainWindow::fillFilterMenu()
1790{ 1793{
1791 selectFilterMenu->clear(); 1794 selectFilterMenu->clear();
1792 bool disable = false; 1795 bool disable = false;
1793 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1796 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1794 selectFilterMenu->insertSeparator(); 1797 selectFilterMenu->insertSeparator();
1795 if ( mView->filterView()->filtersEnabled() ) { 1798 if ( mView->filterView()->filtersEnabled() ) {
1796 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1799 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1797 } 1800 }
1798 else { 1801 else {
1799 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1802 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1800 disable = true; 1803 disable = true;
1801 } 1804 }
1802 selectFilterMenu->insertSeparator(); 1805 selectFilterMenu->insertSeparator();
1803 QPtrList<CalFilter> fili = mView->filters(); 1806 QPtrList<CalFilter> fili = mView->filters();
1804 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1807 CalFilter *curfilter = mView->filterView()->selectedFilter();
1805 CalFilter *filter = fili.first(); 1808 CalFilter *filter = fili.first();
1806 int iii = 2; 1809 int iii = 2;
1807 while(filter) { 1810 while(filter) {
1808 selectFilterMenu->insertItem( filter->name(), iii ); 1811 selectFilterMenu->insertItem( filter->name(), iii );
1809 if ( filter == curfilter) 1812 if ( filter == curfilter)
1810 selectFilterMenu->setItemChecked( iii, true ); 1813 selectFilterMenu->setItemChecked( iii, true );
1811 if ( disable ) 1814 if ( disable )
1812 selectFilterMenu->setItemEnabled( iii, false ); 1815 selectFilterMenu->setItemEnabled( iii, false );
1813 filter = fili.next(); 1816 filter = fili.next();
1814 ++iii; 1817 ++iii;
1815 } 1818 }
1816} 1819}
1817void MainWindow::selectFilter( int fil ) 1820void MainWindow::selectFilter( int fil )
1818{ 1821{
1819 if ( fil == 0 ) { 1822 if ( fil == 0 ) {
1820 mView->editFilters( ); 1823 mView->editFilters( );
1821 } else if ( fil == 1 ){ 1824 } else if ( fil == 1 ){
1822 mView->toggleFilerEnabled( ); 1825 mView->toggleFilerEnabled( );
1823 } else { 1826 } else {
1824 mView->selectFilter( fil-2 ); 1827 mView->selectFilter( fil-2 );
1825 } 1828 }
1826} 1829}
1827void MainWindow::configureToolBar( int item ) 1830void MainWindow::configureToolBar( int item )
1828{ 1831{
1829 1832
1830 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1833 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1831 KOPrefs *p = KOPrefs::instance(); 1834 KOPrefs *p = KOPrefs::instance();
1832 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1835 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1833 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1836 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1834 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1837 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1835 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1838 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1836 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1839 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1837 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1840 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1838 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1841 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1839 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 1842 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
1840 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1843 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1841 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1844 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1842 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1845 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1843 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1846 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1844 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1847 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1845 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1848 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1846 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1849 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1847 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1850 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1848 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1851 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1849 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1852 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1850 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1853 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1851 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1854 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1852 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 1855 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
1853 // initActions(); 1856 // initActions();
1854} 1857}
1855void MainWindow::setCaption ( const QString & c ) 1858void MainWindow::setCaption ( const QString & c )
1856{ 1859{
1857 QString cap = c; 1860 QString cap = c;
1858 cap.replace( QRegExp("\n"), " " ); 1861 cap.replace( QRegExp("\n"), " " );
1859 cap = cap.stripWhiteSpace(); 1862 cap = cap.stripWhiteSpace();
1860 if ( cap.isEmpty() ) 1863 if ( cap.isEmpty() )
1861 cap = "KO/Pi"; 1864 cap = "KO/Pi";
1862 QWidget::setCaption( cap ); 1865 QWidget::setCaption( cap );
1863} 1866}
1864void MainWindow::setCaptionToDates() 1867void MainWindow::setCaptionToDates()
1865{ 1868{
1866 QString selDates; 1869 QString selDates;
1867 QDate date = mView->startDate(); 1870 QDate date = mView->startDate();
1868 if ( ! date.isValid() ) { 1871 if ( ! date.isValid() ) {
1869 setCaption(""); 1872 setCaption("");
1870 return; 1873 return;
1871 } 1874 }
1872 selDates = KGlobal::locale()->formatDate( date, true); 1875 selDates = KGlobal::locale()->formatDate( date, true);
1873 if (mView->startDate() < mView->endDate() ) 1876 if (mView->startDate() < mView->endDate() )
1874 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1877 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1875 else { 1878 else {
1876 QString addString; 1879 QString addString;
1877 if ( date == QDateTime::currentDateTime().date() ) 1880 if ( date == QDateTime::currentDateTime().date() )
1878 addString = i18n("Today"); 1881 addString = i18n("Today");
1879 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 1882 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
1880 addString = i18n("Tomorrow"); 1883 addString = i18n("Tomorrow");
1881 if ( !addString.isEmpty() ) 1884 if ( !addString.isEmpty() )
1882 selDates = addString+", "+selDates ; 1885 selDates = addString+", "+selDates ;
1883 } 1886 }
1884 setCaption( i18n("Dates: ") + selDates ); 1887 setCaption( i18n("Dates: ") + selDates );
1885 1888
1886} 1889}
1887void MainWindow::showConfigureAgenda( ) 1890void MainWindow::showConfigureAgenda( )
1888{ 1891{
1889 int iii; 1892 int iii;
1890 for ( iii = 1;iii<= 10 ;++iii ){ 1893 for ( iii = 1;iii<= 10 ;++iii ){
1891 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1894 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1892 } 1895 }
1893 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 1896 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1894} 1897}
1895void MainWindow::configureAgenda( int item ) 1898void MainWindow::configureAgenda( int item )
1896{ 1899{
1897 if ( KOPrefs::instance()->mHourSize == item ) 1900 if ( KOPrefs::instance()->mHourSize == item )
1898 return; 1901 return;
1899 KOPrefs::instance()->mHourSize=item; 1902 KOPrefs::instance()->mHourSize=item;
1900 mView->viewManager()->agendaView()->updateConfig(); 1903 mView->viewManager()->agendaView()->updateConfig();
1901} 1904}
1902 1905
1903void MainWindow::saveCalendar() 1906void MainWindow::saveCalendar()
1904{ 1907{
1905 QString fn = KOPrefs::instance()->mLastSaveFile; 1908 QString fn = KOPrefs::instance()->mLastSaveFile;
1906 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1909 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1907 1910
1908 if ( fn == "" ) 1911 if ( fn == "" )
1909 return; 1912 return;
1910 QFileInfo info; 1913 QFileInfo info;
1911 info.setFile( fn ); 1914 info.setFile( fn );
1912 QString mes; 1915 QString mes;
1913 bool createbup = true; 1916 bool createbup = true;
1914 if ( info. exists() ) { 1917 if ( info. exists() ) {
1915 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1918 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1916 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1919 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1917 i18n("Overwrite!"), i18n("Cancel"), 0, 1920 i18n("Overwrite!"), i18n("Cancel"), 0,
1918 0, 1 ); 1921 0, 1 );
1919 if ( result != 0 ) { 1922 if ( result != 0 ) {
1920 createbup = false; 1923 createbup = false;
1921 } 1924 }
1922 } 1925 }
1923 if ( createbup ) { 1926 if ( createbup ) {
1924 mView->saveCalendar( fn ); 1927 mView->saveCalendar( fn );
1925 mes = i18n("KO/Pi:Saved %1").arg(fn); 1928 mes = i18n("KO/Pi:Saved %1").arg(fn);
1926 KOPrefs::instance()->mLastSaveFile = fn; 1929 KOPrefs::instance()->mLastSaveFile = fn;
1927 setCaption(mes); 1930 setCaption(mes);
1928 } 1931 }
1929} 1932}
1930void MainWindow::loadCalendar() 1933void MainWindow::loadCalendar()
1931{ 1934{
1932 1935
1933 QString fn = KOPrefs::instance()->mLastLoadFile; 1936 QString fn = KOPrefs::instance()->mLastLoadFile;
1934 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1937 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1935 1938
1936 if ( fn == "" ) 1939 if ( fn == "" )
1937 return; 1940 return;
1938 QFileInfo info; 1941 QFileInfo info;
1939 info.setFile( fn ); 1942 info.setFile( fn );
1940 QString mess; 1943 QString mess;
1941 bool loadbup = true; 1944 bool loadbup = true;
1942 if ( info. exists() ) { 1945 if ( info. exists() ) {
1943 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1946 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1944 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1947 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1945 mess, 1948 mess,
1946 i18n("Load!"), i18n("Cancel"), 0, 1949 i18n("Load!"), i18n("Cancel"), 0,
1947 0, 1 ); 1950 0, 1 );
1948 if ( result != 0 ) { 1951 if ( result != 0 ) {
1949 loadbup = false; 1952 loadbup = false;
1950 } 1953 }
1951 } else { 1954 } else {
1952 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1955 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1953 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1956 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1954 0, 1 ); 1957 0, 1 );
1955 1958
1956 return; 1959 return;
1957 } 1960 }
1958 if ( loadbup ) { 1961 if ( loadbup ) {
1959 mView->openCalendar( fn ); 1962 mView->openCalendar( fn );
1960 KOPrefs::instance()->mLastLoadFile = fn; 1963 KOPrefs::instance()->mLastLoadFile = fn;
1961 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1964 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1962 setCaption(mess); 1965 setCaption(mess);
1963 } 1966 }
1964 1967
1965} 1968}
1966void MainWindow::quickImportIcal() 1969void MainWindow::quickImportIcal()
1967{ 1970{
1968 importFile( KOPrefs::instance()->mLastImportFile, false ); 1971 importFile( KOPrefs::instance()->mLastImportFile, false );
1969} 1972}
1970void MainWindow::importFile( QString fn, bool quick ) 1973void MainWindow::importFile( QString fn, bool quick )
1971{ 1974{
1972 QFileInfo info; 1975 QFileInfo info;
1973 info.setFile( fn ); 1976 info.setFile( fn );
1974 QString mess; 1977 QString mess;
1975 bool loadbup = true; 1978 bool loadbup = true;
1976 if ( !info. exists() ) { 1979 if ( !info. exists() ) {
1977 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1980 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1978 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1981 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1979 mess ); 1982 mess );
1980 return; 1983 return;
1981 } 1984 }
1982 int result = 0; 1985 int result = 0;
1983 if ( !quick ) { 1986 if ( !quick ) {
1984 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1987 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1985 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1988 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1986 mess, 1989 mess,
1987 "Import", "Cancel", 0, 1990 "Import", "Cancel", 0,
1988 0, 1 ); 1991 0, 1 );
1989 } 1992 }
1990 if ( result == 0 ) { 1993 if ( result == 0 ) {
1991 if ( mView->openCalendar( fn, true )) { 1994 if ( mView->openCalendar( fn, true )) {
1992 KOPrefs::instance()->mLastImportFile = fn; 1995 KOPrefs::instance()->mLastImportFile = fn;
1993 setCaption(i18n("Imported file successfully")); 1996 setCaption(i18n("Imported file successfully"));
1994 } else { 1997 } else {
1995 setCaption(i18n("Error importing file")); 1998 setCaption(i18n("Error importing file"));
1996 } 1999 }
1997 } 2000 }
1998} 2001}
1999 2002
2000void MainWindow::importIcal() 2003void MainWindow::importIcal()
2001{ 2004{
2002 2005
2003 QString fn =KOPrefs::instance()->mLastImportFile; 2006 QString fn =KOPrefs::instance()->mLastImportFile;
2004 2007
2005 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2008 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2006 if ( fn == "" ) 2009 if ( fn == "" )
2007 return; 2010 return;
2008 importFile( fn, true ); 2011 importFile( fn, true );
2009 2012
2010} 2013}
2011 2014
2012void MainWindow::exportVCalendar() 2015void MainWindow::exportVCalendar()
2013{ 2016{
2014 QString fn = KOPrefs::instance()->mLastVcalFile; 2017 QString fn = KOPrefs::instance()->mLastVcalFile;
2015 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2018 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2016 if ( fn == "" ) 2019 if ( fn == "" )
2017 return; 2020 return;
2018 QFileInfo info; 2021 QFileInfo info;
2019 info.setFile( fn ); 2022 info.setFile( fn );
2020 QString mes; 2023 QString mes;
2021 bool createbup = true; 2024 bool createbup = true;
2022 if ( info. exists() ) { 2025 if ( info. exists() ) {
2023 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2026 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2024 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2027 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2025 i18n("Overwrite!"), i18n("Cancel"), 0, 2028 i18n("Overwrite!"), i18n("Cancel"), 0,
2026 0, 1 ); 2029 0, 1 );
2027 if ( result != 0 ) { 2030 if ( result != 0 ) {
2028 createbup = false; 2031 createbup = false;
2029 } 2032 }
2030 } 2033 }
2031 if ( createbup ) { 2034 if ( createbup ) {
2032 if ( mView->exportVCalendar( fn ) ) { 2035 if ( mView->exportVCalendar( fn ) ) {
2033 KOPrefs::instance()->mLastVcalFile = fn; 2036 KOPrefs::instance()->mLastVcalFile = fn;
2034 if ( fn.length() > 20 ) 2037 if ( fn.length() > 20 )
2035 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2038 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2036 else 2039 else
2037 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2040 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2038 setCaption(mes); 2041 setCaption(mes);
2039 } 2042 }
2040 } 2043 }
2041 2044
2042} 2045}
2043QString MainWindow::sentSyncFile() 2046QString MainWindow::sentSyncFile()
2044{ 2047{
2045#ifdef DESKTOP_VERSION 2048#ifdef DESKTOP_VERSION
2046 return locateLocal( "tmp", "copysynccal.ics" ); 2049 return locateLocal( "tmp", "copysynccal.ics" );
2047#else 2050#else
2048 return QString( "/tmp/copysynccal.ics" ); 2051 return QString( "/tmp/copysynccal.ics" );
2049#endif 2052#endif
2050} 2053}
2051 2054
2052void MainWindow::syncFileRequest() 2055void MainWindow::syncFileRequest()
2053{ 2056{
2054 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2057 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2055 mSyncManager->slotSyncMenu( 999 ); 2058 mSyncManager->slotSyncMenu( 999 );
2056 } 2059 }
2057 2060
2058 setCaption(i18n("Saving Data to temp file ..." )); 2061 setCaption(i18n("Saving Data to temp file ..." ));
2059 mView->saveCalendar( sentSyncFile() ); 2062 mView->saveCalendar( sentSyncFile() );
2060 setCaption(i18n("Data saved to temp file!" )); 2063 setCaption(i18n("Data saved to temp file!" ));
2061 2064
2062} 2065}
2063void MainWindow::getFile( bool success ) 2066void MainWindow::getFile( bool success )
2064{ 2067{
2065 if ( ! success ) { 2068 if ( ! success ) {
2066 setCaption( i18n("Error receiving file. Nothing changed!") ); 2069 setCaption( i18n("Error receiving file. Nothing changed!") );
2067 return; 2070 return;
2068 } 2071 }
2069 mView->openCalendar( sentSyncFile() ); 2072 mView->openCalendar( sentSyncFile() );
2070 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2073 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2071 mSyncManager->slotSyncMenu( 999 ); 2074 mSyncManager->slotSyncMenu( 999 );
2072 } 2075 }
2073 setCaption( i18n("Pi-Sync successful!") ); 2076 setCaption( i18n("Pi-Sync successful!") );
2074} 2077}
2075 2078
2076void MainWindow::printSel( ) 2079void MainWindow::printSel( )
2077{ 2080{
2078 mView->viewManager()->agendaView()->agenda()->printSelection(); 2081 mView->viewManager()->agendaView()->agenda()->printSelection();
2079} 2082}
2080 2083
2081void MainWindow::printCal() 2084void MainWindow::printCal()
2082{ 2085{
2083 mView->print();//mCp->showDialog(); 2086 mView->print();//mCp->showDialog();
2084} 2087}
2085 2088
2086 2089
2087#include "libkdepim/kdatepicker.h" 2090#include "libkdepim/kdatepicker.h"
2088#include <kdatetbl.h> 2091#include <kdatetbl.h>
2089void MainWindow::weekAction() 2092void MainWindow::weekAction()
2090{ 2093{
2091 int month; 2094 int month;
2092 KPopupFrame* popup = new KPopupFrame(this); 2095 KPopupFrame* popup = new KPopupFrame(this);
2093 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2096 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2094 // ----- 2097 // -----
2095 picker->resize(picker->sizeHint()); 2098 picker->resize(picker->sizeHint());
2096 popup->setMainWidget(picker); 2099 popup->setMainWidget(picker);
2097 picker->setFocus(); 2100 picker->setFocus();
2098 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2101 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2099 int x = 0; 2102 int x = 0;
2100 int y = iconToolBar->height(); 2103 int y = iconToolBar->height();
2101 int dX = 0; 2104 int dX = 0;
2102 int dY = 0; 2105 int dY = 0;
2103 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2106 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2104 if ( iconToolBar->y() > height()/2 ) { 2107 if ( iconToolBar->y() > height()/2 ) {
2105 dY = picker->sizeHint().height()+8; 2108 dY = picker->sizeHint().height()+8;
2106 y = 0; 2109 y = 0;
2107 } 2110 }
2108 } else { 2111 } else {
2109 if ( iconToolBar->x() > width()/2 ) { // right side 2112 if ( iconToolBar->x() > width()/2 ) { // right side
2110 x=0; 2113 x=0;
2111 dX= picker->sizeHint().width()+8; 2114 dX= picker->sizeHint().width()+8;
2112 y = 0; 2115 y = 0;
2113 } else { 2116 } else {
2114 x= iconToolBar->width(); 2117 x= iconToolBar->width();
2115 y = 0; 2118 y = 0;
2116 } 2119 }
2117 } 2120 }
2118 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2121 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2119 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2122 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2120 { 2123 {
2121 month = picker->getResult(); 2124 month = picker->getResult();
2122 emit selectWeek ( month ); 2125 emit selectWeek ( month );
2123 //qDebug("weekSelected %d ", month); 2126 //qDebug("weekSelected %d ", month);
2124 } 2127 }
2125 delete popup; 2128 delete popup;
2126} 2129}