summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-27 10:15:45 (UTC)
committer zautrix <zautrix>2005-01-27 10:15:45 (UTC)
commit1501a5d8a25e3474fb450d7e0b272feb14821d1c (patch) (unidiff)
tree70a8fcafed89f6dc8225af9908e845c0feecd7d9 /korganizer
parente4beb835276376646307bea74430008c332bd387 (diff)
downloadkdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.zip
kdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.tar.gz
kdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp855
-rw-r--r--korganizer/komonthview.h2
-rw-r--r--korganizer/koviewmanager.cpp4
-rw-r--r--korganizer/mainwindow.cpp2
4 files changed, 447 insertions, 416 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 437debe..10e4f1d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1129 +1,1154 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtooltip.h> 27#include <qtooltip.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.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 35
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45#include "calprinter.h" 45#include "calprinter.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
49#include "kocore.h" 49#include "kocore.h"
50#endif 50#endif
51#include "koglobals.h" 51#include "koglobals.h"
52#include <libkcal/kincidenceformatter.h> 52#include <libkcal/kincidenceformatter.h>
53 53
54#include "komonthview.h" 54#include "komonthview.h"
55 55
56#define PIXMAP_SIZE 5 56#define PIXMAP_SIZE 5
57#ifdef DESKTOP_VERSION 57#ifdef DESKTOP_VERSION
58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 58QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
59#endif 59#endif
60class KNOWhatsThis :public QWhatsThis 60class KNOWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
64 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 64 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
65 65
66protected: 66protected:
67 virtual QString text( const QPoint& p) 67 virtual QString text( const QPoint& p)
68 { 68 {
69 return _wid->getWhatsThisText(p) ; 69 return _wid->getWhatsThisText(p) ;
70 }; 70 };
71private: 71private:
72 KNoScrollListBox* _wid; 72 KNoScrollListBox* _wid;
73 73
74}; 74};
75 75
76 76
77KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 77KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
78 : QListBox(parent, name, WRepaintNoErase) 78 : QListBox(parent, name, WRepaintNoErase)
79{ 79{
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
82#endif 82#endif
83 mWT = new KNOWhatsThis(this); 83 mWT = new KNOWhatsThis(this);
84} 84}
85KNoScrollListBox::~KNoScrollListBox() 85KNoScrollListBox::~KNoScrollListBox()
86{ 86{
87 87
88} 88}
89QString KNoScrollListBox::getWhatsThisText(QPoint p) 89QString KNoScrollListBox::getWhatsThisText(QPoint p)
90{ 90{
91 QListBoxItem* item = itemAt ( p ); 91 QListBoxItem* item = itemAt ( p );
92 if ( ! item ) { 92 if ( ! item ) {
93 return i18n("Click in the cell\nto add an event!"); 93 return i18n("Click in the cell\nto add an event!");
94 } 94 }
95 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 95 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
96} 96}
97void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 97void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
98{ 98{
99 99
100 switch(e->key()) { 100 switch(e->key()) {
101 case Key_Right: 101 case Key_Right:
102 // if ( e->state() == Qt::ControlButton ) 102 // if ( e->state() == Qt::ControlButton )
103 { 103 {
104 e->ignore(); 104 e->ignore();
105 return; 105 return;
106 } 106 }
107 scrollBy(4,0); 107 scrollBy(4,0);
108 break; 108 break;
109 case Key_Left: 109 case Key_Left:
110 // if ( e->state() == Qt::ControlButton ) 110 // if ( e->state() == Qt::ControlButton )
111 { 111 {
112 e->ignore(); 112 e->ignore();
113 return; 113 return;
114 } 114 }
115 scrollBy(-4,0); 115 scrollBy(-4,0);
116 break; 116 break;
117 case Key_Up: 117 case Key_Up:
118 if(!count()) break; 118 if(count() < 2) {
119 setCurrentItem((currentItem()+count()-1)%count()); 119 e->ignore();
120 if(!itemVisible(currentItem())) { 120 break;
121 if((unsigned int) currentItem() == (count()-1)) {
122 setTopItem(currentItem()-numItemsVisible()+1);
123 } else {
124 setTopItem(topItem()-1);
125 } 121 }
126 } 122 setCurrentItem((currentItem()+count()-1)%count());
127 break; 123 if(!itemVisible(currentItem())) {
124 if((unsigned int) currentItem() == (count()-1)) {
125 setTopItem(currentItem()-numItemsVisible()+1);
126 } else {
127 setTopItem(topItem()-1);
128 }
129 }
130 break;
128 case Key_Down: 131 case Key_Down:
129 if(!count()) break; 132 if(count() < 2) {
130 setCurrentItem((currentItem()+1)%count()); 133 e->ignore();
131 if(!itemVisible(currentItem())) { 134 break;
132 if(currentItem() == 0) {
133 setTopItem(0);
134 } else {
135 setTopItem(topItem()+1);
136 } 135 }
137 } 136 setCurrentItem((currentItem()+1)%count());
138 break; 137 if(!itemVisible(currentItem())) {
138 if(currentItem() == 0) {
139 setTopItem(0);
140 } else {
141 setTopItem(topItem()+1);
142 }
143 }
144 break;
139 case Key_Shift: 145 case Key_Shift:
140 emit shiftDown(); 146 emit shiftDown();
141 break; 147 break;
142 default: 148 default:
143 e->ignore(); 149 e->ignore();
144 break; 150 break;
145 } 151 }
146} 152}
147 153
148void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 154void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
149{ 155{
150 switch(e->key()) { 156 switch(e->key()) {
151 case Key_Shift: 157 case Key_Shift:
152 emit shiftUp(); 158 emit shiftUp();
153 break; 159 break;
154 default: 160 default:
155 break; 161 break;
156 } 162 }
157} 163}
158 164
159void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 165void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
160{ 166{
161 QListBox::mousePressEvent(e); 167 QListBox::mousePressEvent(e);
162 168
163 if(e->button() == RightButton) { 169 if(e->button() == RightButton) {
164 emit rightClick(); 170 emit rightClick();
165 } 171 }
166} 172}
167 173
168MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 174MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
169 : QListBoxItem() 175 : QListBoxItem()
170{ 176{
171 setText( s ); 177 setText( s );
172 178
173 mIncidence = incidence; 179 mIncidence = incidence;
174 mDate = qd; 180 mDate = qd;
175 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 181 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
176 mRecur = false; 182 mRecur = false;
177 mAlarm = false; 183 mAlarm = false;
178 mReply = false; 184 mReply = false;
179 mInfo = false; 185 mInfo = false;
180} 186}
181 187
182void MonthViewItem::paint(QPainter *p) 188void MonthViewItem::paint(QPainter *p)
183{ 189{
184#if QT_VERSION >= 0x030000 190#if QT_VERSION >= 0x030000
185 bool sel = isSelected(); 191 bool sel = isSelected();
186#else 192#else
187 bool sel = selected(); 193 bool sel = selected();
188#endif 194#endif
189 195
190 196
191 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 197 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
192 { 198 {
193 p->setBackgroundColor( palette().color( QPalette::Normal, \ 199 p->setBackgroundColor( palette().color( QPalette::Normal, \
194 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 200 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
195 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 201 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
196 } 202 }
197 int x = 1; 203 int x = 1;
198 int y = 3;//(height() - mRecurPixmap.height()) /2; 204 int y = 3;//(height() - mRecurPixmap.height()) /2;
199 int size = PIXMAP_SIZE; 205 int size = PIXMAP_SIZE;
200 if ( QApplication::desktop()->width() < 300 ) 206 if ( QApplication::desktop()->width() < 300 )
201 size = 3; 207 size = 3;
202 if ( KOPrefs::instance()->mMonthShowIcons ) { 208 if ( KOPrefs::instance()->mMonthShowIcons ) {
203 if ( mInfo ) { 209 if ( mInfo ) {
204 p->fillRect ( x, y,size,size, Qt::darkGreen ); 210 p->fillRect ( x, y,size,size, Qt::darkGreen );
205 x += size + 1; 211 x += size + 1;
206 } 212 }
207 if ( mRecur ) { 213 if ( mRecur ) {
208 p->fillRect ( x, y,size,size, Qt::blue ); 214 p->fillRect ( x, y,size,size, Qt::blue );
209 x += size + 1; 215 x += size + 1;
210 } 216 }
211 if ( mAlarm ) { 217 if ( mAlarm ) {
212 p->fillRect ( x, y,size,size, Qt::red ); 218 p->fillRect ( x, y,size,size, Qt::red );
213 x += size + 1; 219 x += size + 1;
214 } 220 }
215 if ( mReply ) { 221 if ( mReply ) {
216 p->fillRect ( x, y,size,size, Qt::yellow ); 222 p->fillRect ( x, y,size,size, Qt::yellow );
217 x += size + 1; 223 x += size + 1;
218 } 224 }
219 } 225 }
220 QFontMetrics fm = p->fontMetrics(); 226 QFontMetrics fm = p->fontMetrics();
221 int yPos; 227 int yPos;
222 int pmheight = size; 228 int pmheight = size;
223 if( pmheight < fm.height() ) 229 if( pmheight < fm.height() )
224 yPos = fm.ascent() + fm.leading()/2; 230 yPos = fm.ascent() + fm.leading()/2;
225 else 231 else
226 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 232 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
227 p->setPen( palette().color( QPalette::Normal, sel ? \ 233 p->setPen( palette().color( QPalette::Normal, sel ? \
228 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 234 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
229 p->drawText( x, yPos, text() ); 235 p->drawText( x, yPos, text() );
230 if ( mIncidence->cancelled() ) { 236 if ( mIncidence->cancelled() ) {
231 int wid = fm.width( text() ); 237 int wid = fm.width( text() );
232 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 238 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
233 } 239 }
234 240
235} 241}
236 242
237int MonthViewItem::height(const QListBox *lb) const 243int MonthViewItem::height(const QListBox *lb) const
238{ 244{
239 return lb->fontMetrics().lineSpacing()+1; 245 return lb->fontMetrics().lineSpacing()+1;
240} 246}
241 247
242int MonthViewItem::width(const QListBox *lb) const 248int MonthViewItem::width(const QListBox *lb) const
243{ 249{
244 int size = PIXMAP_SIZE; 250 int size = PIXMAP_SIZE;
245 if ( QApplication::desktop()->width() < 300 ) 251 if ( QApplication::desktop()->width() < 300 )
246 size = 3; 252 size = 3;
247 int x = 1; 253 int x = 1;
248 if ( mInfo ) { 254 if ( mInfo ) {
249 x += size + 1; 255 x += size + 1;
250 } 256 }
251 if( mRecur ) { 257 if( mRecur ) {
252 x += size+1; 258 x += size+1;
253 } 259 }
254 if( mAlarm ) { 260 if( mAlarm ) {
255 x += size+1; 261 x += size+1;
256 } 262 }
257 if( mReply ) { 263 if( mReply ) {
258 x += size+1; 264 x += size+1;
259 } 265 }
260 266
261 return( x + lb->fontMetrics().width( text() ) + 1 ); 267 return( x + lb->fontMetrics().width( text() ) + 1 );
262} 268}
263 269
264 270
265MonthViewCell::MonthViewCell( KOMonthView *parent) 271MonthViewCell::MonthViewCell( KOMonthView *parent)
266 : QWidget( parent ), 272 : QWidget( parent ),
267 mMonthView( parent ) 273 mMonthView( parent )
268{ 274{
269 275
270 QVBoxLayout *topLayout = new QVBoxLayout( this ); 276 QVBoxLayout *topLayout = new QVBoxLayout( this );
271 277
272 // mLabel = new QLabel( this );QPushButton 278 // mLabel = new QLabel( this );QPushButton
273 mLabel = new QPushButton( this ); 279 mLabel = new QPushButton( this );
274 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 280 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
275 //mLabel->setLineWidth( 1 ); 281 //mLabel->setLineWidth( 1 );
276 //mLabel->setAlignment( AlignCenter ); 282 //mLabel->setAlignment( AlignCenter );
277 mLabel->setFlat( true ); 283 mLabel->setFlat( true );
278 mItemList = new KNoScrollListBox( this ); 284 mItemList = new KNoScrollListBox( this );
279 mItemList->setMinimumSize( 10, 10 ); 285 mItemList->setMinimumSize( 10, 10 );
280 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 286 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
281 mItemList->setLineWidth( 1 ); 287 mItemList->setLineWidth( 1 );
282 topLayout->addWidget( mItemList ); 288 topLayout->addWidget( mItemList );
283 mLabel->raise(); 289 mLabel->raise();
284 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 290 // QColor( 0,0,255 ) QColor( 160,1600,255 )
285 mStandardPalette = palette(); 291 mStandardPalette = palette();
286 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 292 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
287 293
288 enableScrollBars( false ); 294 enableScrollBars( false );
289 updateConfig(); 295 updateConfig();
290 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 296 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
291 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 297 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
292 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 298 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
293 SLOT( defaultAction( QListBoxItem * ) ) ); 299 SLOT( defaultAction( QListBoxItem * ) ) );
294 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 300 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
295 const QPoint &) ), 301 const QPoint &) ),
296 SLOT( contextMenu( QListBoxItem * ) ) ); 302 SLOT( contextMenu( QListBoxItem * ) ) );
297 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 303 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
298 SLOT( selection( QListBoxItem * ) ) ); 304 SLOT( selection( QListBoxItem * ) ) );
299 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 305 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
300 SLOT( cellClicked( QListBoxItem * ) ) ); 306 SLOT( cellClicked( QListBoxItem * ) ) );
301 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 307 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
302 SLOT( selection( QListBoxItem * ) ) ); 308 SLOT( selection( QListBoxItem * ) ) );
303} 309}
304#ifdef DESKTOP_VERSION 310#ifdef DESKTOP_VERSION
305QToolTipGroup *MonthViewCell::toolTipGroup() 311QToolTipGroup *MonthViewCell::toolTipGroup()
306{ 312{
307 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 313 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
308 return mToolTipGroup; 314 return mToolTipGroup;
309} 315}
310#endif 316#endif
311 317
312void MonthViewCell::setDate( const QDate &date ) 318void MonthViewCell::setDate( const QDate &date )
313{ 319{
314// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 320 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
315 mDate = date; 321 mDate = date;
316 322
317 323
318 324
319 //resizeEvent( 0 ); 325 //resizeEvent( 0 );
320} 326}
321 327
322QDate MonthViewCell::date() const 328QDate MonthViewCell::date() const
323{ 329{
324 return mDate; 330 return mDate;
325} 331}
326 332
327void MonthViewCell::setPrimary( bool primary ) 333void MonthViewCell::setPrimary( bool primary )
328{ 334{
329 mPrimary = primary; 335 mPrimary = primary;
330 //setMyPalette(); 336 //setMyPalette();
331} 337}
332void MonthViewCell::setMyPalette() 338void MonthViewCell::setMyPalette()
333{ 339{
334 340
335 if ( mHoliday) { 341 if ( mHoliday) {
336 setPalette( mHolidayPalette ); 342 setPalette( mHolidayPalette );
337 } else { 343 } else {
338 if ( mPrimary ) { 344 if ( mPrimary ) {
339 setPalette( mPrimaryPalette ); 345 setPalette( mPrimaryPalette );
340 } else { 346 } else {
341 setPalette( mNonPrimaryPalette ); 347 setPalette( mNonPrimaryPalette );
342 } 348 }
343 } 349 }
344 QPalette pal = palette(); 350 QPalette pal = palette();
345 351
346 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 352 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
347} 353}
348QPalette MonthViewCell::getPalette () 354QPalette MonthViewCell::getPalette ()
349{ 355{
350 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 356 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
351 return mStandardPalette; 357 return mStandardPalette;
352 if ( mHoliday) { 358 if ( mHoliday) {
353 return mHolidayPalette ; 359 return mHolidayPalette ;
354 } else { 360 } else {
355 if ( mPrimary ) { 361 if ( mPrimary ) {
356 return mPrimaryPalette ; 362 return mPrimaryPalette ;
357 } 363 }
358 } 364 }
359 return mNonPrimaryPalette; 365 return mNonPrimaryPalette;
360} 366}
361bool MonthViewCell::isPrimary() const 367bool MonthViewCell::isPrimary() const
362{ 368{
363 return mPrimary; 369 return mPrimary;
364} 370}
365 371
366void MonthViewCell::setHoliday( bool holiday ) 372void MonthViewCell::setHoliday( bool holiday )
367{ 373{
368 mHoliday = holiday; 374 mHoliday = holiday;
369 //setMyPalette(); 375 //setMyPalette();
370} 376}
371 377
372void MonthViewCell::setHoliday( const QString &holiday ) 378void MonthViewCell::setHoliday( const QString &holiday )
373{ 379{
374 mHolidayString = holiday; 380 mHolidayString = holiday;
375 381
376 if ( !holiday.isEmpty() ) { 382 if ( !holiday.isEmpty() ) {
377 setHoliday( true ); 383 setHoliday( true );
378 } 384 }
379} 385}
380void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 386void MonthViewCell::keyPressEvent ( QKeyEvent * e )
381{ 387{
382 388
383 e->ignore(); 389 e->ignore();
384 390
385} 391}
386void MonthViewCell::clear() 392void MonthViewCell::clear()
387{ 393{
388 mItemList->clear(); 394 mItemList->clear();
389 QApplication::removePostedEvents ( mItemList ); 395 QApplication::removePostedEvents ( mItemList );
390 QApplication::removePostedEvents ( mLabel ); 396 QApplication::removePostedEvents ( mLabel );
391 QApplication::removePostedEvents ( this ); 397 QApplication::removePostedEvents ( this );
392} 398}
393void MonthViewCell::updateCell() 399void MonthViewCell::updateCell()
394{ 400{
395 if ( !mMonthView->isUpdatePossible() ) 401 if ( !mMonthView->isUpdatePossible() )
396 return; 402 return;
397 /* 403 /*
398 if ( !isVisible() ){ 404 if ( !isVisible() ){
399 return; 405 return;
400 } 406 }
401 */ 407 */
402 // qDebug("MonthViewCell::updateCell() "); 408 // qDebug("MonthViewCell::updateCell() ");
403 setPrimary( mDate.month()%2 ); 409 setPrimary( mDate.month()%2 );
404 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 410 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
405 if ( mDate == QDate::currentDate() ) { 411 if ( mDate == QDate::currentDate() ) {
406 mItemList->setLineWidth( 3 ); 412 mItemList->setLineWidth( 3 );
407 } else { 413 } else {
408 mItemList->setLineWidth( 1 ); 414 mItemList->setLineWidth( 1 );
409 } 415 }
410 mItemList->clear(); 416 mItemList->clear();
411 417
412#ifdef DESKTOP_VERSION 418#ifdef DESKTOP_VERSION
413 QToolTip::remove(this); 419 QToolTip::remove(this);
414#endif 420#endif
415 QString tipText(""); 421 QString tipText("");
416 //qApp->processEvents(); 422 //qApp->processEvents();
417 if ( !mHolidayString.isEmpty() ) { 423 if ( !mHolidayString.isEmpty() ) {
418 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 424 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
419 item->setPalette( mHolidayPalette ); 425 item->setPalette( mHolidayPalette );
420 mItemList->insertItem( item ); 426 mItemList->insertItem( item );
421 tipText += mHolidayString+"\n"; 427 tipText += mHolidayString+"\n";
422 } 428 }
423 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 429 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
424 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 430 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
425 Event *event; 431 Event *event;
426 for( event = events.first(); event; event = events.next() ) { // for event 432 for( event = events.first(); event; event = events.next() ) { // for event
427 433
428 if ( !(event->doesRecur() == Recurrence::rNone) ) { 434 if ( !(event->doesRecur() == Recurrence::rNone) ) {
429 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 435 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
430 continue; 436 continue;
431 else 437 else
432 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 438 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
433 continue; 439 continue;
434 } 440 }
435 441
436 if ( event->categories().contains("Holiday") || 442 if ( event->categories().contains("Holiday") ||
437 event->categories().contains(i18n("Holiday"))) { 443 event->categories().contains(i18n("Holiday"))) {
438 setHoliday( true ); 444 setHoliday( true );
439 if ( mDate.dayOfWeek() == 7 ) 445 if ( mDate.dayOfWeek() == 7 )
440 mItemList->setLineWidth( 3 ); 446 mItemList->setLineWidth( 3 );
441 } 447 }
442 QString text; 448 QString text;
443 if (event->isMultiDay()) { 449 if (event->isMultiDay()) {
444 QString prefix = "<->"; 450 QString prefix = "<->";
445 if ( event->doesRecur() ) { 451 if ( event->doesRecur() ) {
446 if ( event->recursOn( mDate) ) 452 if ( event->recursOn( mDate) )
447 prefix ="->" ; 453 prefix ="->" ;
448 else { 454 else {
449 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 455 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
450 if ( event->recursOn( mDate.addDays( -days)) ) 456 if ( event->recursOn( mDate.addDays( -days)) )
451 prefix ="<-" ; 457 prefix ="<-" ;
452 } 458 }
453 459
454 } else { 460 } else {
455 if (mDate == event->dtStart().date()) { 461 if (mDate == event->dtStart().date()) {
456 prefix ="->" ; 462 prefix ="->" ;
457 } else if (mDate == event->dtEnd().date()) { 463 } else if (mDate == event->dtEnd().date()) {
458 prefix ="<-" ; 464 prefix ="<-" ;
459 } 465 }
460 } 466 }
461 text = prefix + event->summary(); 467 text = prefix + event->summary();
462 tipText += text; 468 tipText += text;
463 } else { 469 } else {
464 if (event->doesFloat()) { 470 if (event->doesFloat()) {
465 text = event->summary(); 471 text = event->summary();
466 tipText += text; 472 tipText += text;
467 } 473 }
468 else { 474 else {
469 text = KGlobal::locale()->formatTime(event->dtStart().time()); 475 text = KGlobal::locale()->formatTime(event->dtStart().time());
470 text += " " + event->summary(); 476 text += " " + event->summary();
471 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 477 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
472 } 478 }
473 } 479 }
474 480
475 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 481 MonthViewItem *item = new MonthViewItem( event, mDate, text );
476 QPalette pal; 482 QPalette pal;
477 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 483 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
478 QStringList categories = event->categories(); 484 QStringList categories = event->categories();
479 QString cat = categories.first(); 485 QString cat = categories.first();
480 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 486 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
481 pal = getPalette(); 487 pal = getPalette();
482 if (cat.isEmpty()) { 488 if (cat.isEmpty()) {
483 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 489 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
484 } else { 490 } else {
485 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 491 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
486 } 492 }
487 493
488 } else { 494 } else {
489 if (cat.isEmpty()) { 495 if (cat.isEmpty()) {
490 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 496 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
491 } else { 497 } else {
492 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 498 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
493 } 499 }
494 } 500 }
495 501
496 } else { 502 } else {
497 pal = mStandardPalette ; 503 pal = mStandardPalette ;
498 } 504 }
499 item->setPalette( pal ); 505 item->setPalette( pal );
500 item->setRecur( event->recurrence()->doesRecur() ); 506 item->setRecur( event->recurrence()->doesRecur() );
501 item->setAlarm( event->isAlarmEnabled() ); 507 item->setAlarm( event->isAlarmEnabled() );
502 item->setMoreInfo( event->description().length() > 0 ); 508 item->setMoreInfo( event->description().length() > 0 );
503#ifdef DESKTOP_VERSION 509#ifdef DESKTOP_VERSION
504 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 510 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
505 KOPrefs::instance()->email()); 511 KOPrefs::instance()->email());
506 if ( me != 0 ) { 512 if ( me != 0 ) {
507 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 513 if ( me->status() == Attendee::NeedsAction && me->RSVP())
508 item->setReply(true); 514 item->setReply(true);
509 else 515 else
510 item->setReply(false); 516 item->setReply(false);
511 } else 517 } else
512 item->setReply(false); 518 item->setReply(false);
513#endif 519#endif
514 mItemList->insertItem( item ); 520 mItemList->insertItem( item );
515 tipText += "\n"; 521 tipText += "\n";
516 522
517 } 523 }
518 524
519 // insert due todos 525 // insert due todos
520 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 526 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
521 Todo *todo; 527 Todo *todo;
522 for(todo = todos.first(); todo; todo = todos.next()) { 528 for(todo = todos.first(); todo; todo = todos.next()) {
523 QString text; 529 QString text;
524 if (todo->hasDueDate()) { 530 if (todo->hasDueDate()) {
525 if (!todo->doesFloat()) { 531 if (!todo->doesFloat()) {
526 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 532 text += KGlobal::locale()->formatTime(todo->dtDue().time());
527 text += " "; 533 text += " ";
528 } 534 }
529 } 535 }
530 text += i18n("To-Do: %1").arg(todo->summary()); 536 text += i18n("To-Do: %1").arg(todo->summary());
531 537
532 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 538 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
533 //item->setPalette( mStandardPalette ); 539 //item->setPalette( mStandardPalette );
534 QPalette pal; 540 QPalette pal;
535 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 541 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
536 QStringList categories = todo->categories(); 542 QStringList categories = todo->categories();
537 QString cat = categories.first(); 543 QString cat = categories.first();
538 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 544 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
539 pal = getPalette(); 545 pal = getPalette();
540 if (cat.isEmpty()) { 546 if (cat.isEmpty()) {
541 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 547 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
542 } else { 548 } else {
543 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 549 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
544 } 550 }
545 551
546 } else { 552 } else {
547 if (cat.isEmpty()) { 553 if (cat.isEmpty()) {
548 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 554 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
549 } else { 555 } else {
550 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 556 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
551 } 557 }
552 } 558 }
553 559
554 } else { 560 } else {
555 pal = mStandardPalette ; 561 pal = mStandardPalette ;
556 } 562 }
557 item->setPalette( pal ); 563 item->setPalette( pal );
558 mItemList->insertItem( item ); 564 mItemList->insertItem( item );
559 tipText += text+"\n"; 565 tipText += text+"\n";
560 } 566 }
561#ifdef DESKTOP_VERSION 567#ifdef DESKTOP_VERSION
562 if (tipText != "") 568 if (tipText != "")
563 QToolTip::add(this,tipText,toolTipGroup(),""); 569 QToolTip::add(this,tipText,toolTipGroup(),"");
564#endif 570#endif
565 571
566 //setMyPalette(); 572 //setMyPalette();
567 setMyPalette(); 573 setMyPalette();
568 QString text; 574 QString text;
569 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 575 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
570 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 576 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
571 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 577 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
572 mLabel->resize( mLabelBigSize ); 578 mLabel->resize( mLabelBigSize );
573 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 579 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
574 } else { 580 } else {
575 mLabel->resize( mLabelSize ); 581 mLabel->resize( mLabelSize );
576 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 582 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
577 } 583 }
578 584
579 mLabel->setText( text ); 585 mLabel->setText( text );
580 resizeEvent( 0 ); 586 resizeEvent( 0 );
581 // if ( isVisible()) 587 // if ( isVisible())
582 //qApp->processEvents(); 588 //qApp->processEvents();
583} 589}
584 590
585void MonthViewCell::updateConfig() 591void MonthViewCell::updateConfig()
586{ 592{
587 593
588 setFont( KOPrefs::instance()->mMonthViewFont ); 594 setFont( KOPrefs::instance()->mMonthViewFont );
589 595
590 QFontMetrics fm( font() ); 596 QFontMetrics fm( font() );
591 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 597 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
592 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 598 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
593 mHolidayPalette = mStandardPalette; 599 mHolidayPalette = mStandardPalette;
594 mPrimaryPalette = mStandardPalette; 600 mPrimaryPalette = mStandardPalette;
595 mNonPrimaryPalette = mStandardPalette; 601 mNonPrimaryPalette = mStandardPalette;
596 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 602 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
597 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 603 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
598 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 604 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
599 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 605 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
600 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 606 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
601 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 607 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
602 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 608 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
603 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 609 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
604 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 610 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
605 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 611 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
606 } 612 }
607 updateCell(); 613 updateCell();
608} 614}
609 615
610void MonthViewCell::enableScrollBars( bool enabled ) 616void MonthViewCell::enableScrollBars( bool enabled )
611{ 617{
612 if ( enabled ) { 618 if ( enabled ) {
613 mItemList->setVScrollBarMode(QScrollView::Auto); 619 mItemList->setVScrollBarMode(QScrollView::Auto);
614 mItemList->setHScrollBarMode(QScrollView::Auto); 620 mItemList->setHScrollBarMode(QScrollView::Auto);
615 } else { 621 } else {
616 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 622 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
617 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 623 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
618 } 624 }
619} 625}
620 626
621Incidence *MonthViewCell::selectedIncidence() 627Incidence *MonthViewCell::selectedIncidence()
622{ 628{
623 int index = mItemList->currentItem(); 629 int index = mItemList->currentItem();
624 if ( index < 0 ) return 0; 630 if ( index < 0 ) return 0;
625 631
626 MonthViewItem *item = 632 MonthViewItem *item =
627 static_cast<MonthViewItem *>( mItemList->item( index ) ); 633 static_cast<MonthViewItem *>( mItemList->item( index ) );
628 634
629 if ( !item ) return 0; 635 if ( !item ) return 0;
630 636
631 return item->incidence(); 637 return item->incidence();
632} 638}
633 639
634QDate MonthViewCell::selectedIncidenceDate() 640QDate MonthViewCell::selectedIncidenceDate()
635{ 641{
636 QDate qd; 642 QDate qd;
637 int index = mItemList->currentItem(); 643 int index = mItemList->currentItem();
638 if ( index < 0 ) return qd; 644 if ( index < 0 ) return qd;
639 645
640 MonthViewItem *item = 646 MonthViewItem *item =
641 static_cast<MonthViewItem *>( mItemList->item( index ) ); 647 static_cast<MonthViewItem *>( mItemList->item( index ) );
642 648
643 if ( !item ) return qd; 649 if ( !item ) return qd;
644 650
645 return item->incidenceDate(); 651 return item->incidenceDate();
646} 652}
647 653
648void MonthViewCell::deselect() 654void MonthViewCell::deselect()
649{ 655{
650 mItemList->clearSelection(); 656 mItemList->clearSelection();
651 enableScrollBars( false ); 657 enableScrollBars( false );
652 // updateCell(); 658 // updateCell();
653} 659}
654void MonthViewCell::select() 660void MonthViewCell::select()
655{ 661{
656 ;// updateCell(); 662 ;// updateCell();
657} 663}
658 664
659void MonthViewCell::resizeEvent ( QResizeEvent * ) 665void MonthViewCell::resizeEvent ( QResizeEvent * )
660{ 666{
661 if ( !mMonthView->isUpdatePossible() ) 667 if ( !mMonthView->isUpdatePossible() )
662 return; 668 return;
663#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
664 if ( !isVisible() ){ 670 if ( !isVisible() ){
665 return; 671 return;
666 } 672 }
667#endif 673#endif
668 int size = height() - mLabel->height(); 674 int size = height() - mLabel->height();
669 if ( size > 0 ) 675 if ( size > 0 )
670 mItemList->verticalScrollBar()->setMaximumHeight( size ); 676 mItemList->verticalScrollBar()->setMaximumHeight( size );
671 size = width() - mLabel->width(); 677 size = width() - mLabel->width();
672 if ( size > 0 ) 678 if ( size > 0 )
673 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 679 mItemList->horizontalScrollBar()->setMaximumWidth( size );
674 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 680 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
675 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 681 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
676} 682}
677 683
678void MonthViewCell::defaultAction( QListBoxItem *item ) 684void MonthViewCell::defaultAction( QListBoxItem *item )
679{ 685{
680 if ( !item ) return; 686 if ( !item ) return;
681 687
682 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 688 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
683 Incidence *incidence = eventItem->incidence(); 689 Incidence *incidence = eventItem->incidence();
684 if ( incidence ) mMonthView->defaultAction( incidence ); 690 if ( incidence ) mMonthView->defaultAction( incidence );
685} 691}
686void MonthViewCell::showDay() 692void MonthViewCell::showDay()
687{ 693{
688 emit showDaySignal( date() ); 694 emit showDaySignal( date() );
689} 695}
690void MonthViewCell::newEvent() 696void MonthViewCell::newEvent()
691{ 697{
692 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 698 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
693 emit newEventSignal( dt ); 699 emit newEventSignal( dt );
694} 700}
695void MonthViewCell::cellClicked( QListBoxItem *item ) 701void MonthViewCell::cellClicked( QListBoxItem *item )
696{ 702{
697 static QListBoxItem * lastClicked = 0; 703 static QListBoxItem * lastClicked = 0;
698 if ( item == 0 ) { 704 if ( item == 0 ) {
699 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 705 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
700 emit newEventSignal( dt ); 706 emit newEventSignal( dt );
701 return; 707 return;
702 } 708 }
703 /* 709 /*
704 if ( lastClicked ) 710 if ( lastClicked )
705 if ( ! item ) { 711 if ( ! item ) {
706 if ( lastClicked->listBox() != item->listBox() ) 712 if ( lastClicked->listBox() != item->listBox() )
707 lastClicked->listBox()->clearSelection(); 713 lastClicked->listBox()->clearSelection();
708 } 714 }
709 */ 715 */
710 716
711 mMonthView->setSelectedCell( this ); 717 mMonthView->setSelectedCell( this );
712 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 718 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
713 select(); 719 select();
714} 720}
715 721
716void MonthViewCell::contextMenu( QListBoxItem *item ) 722void MonthViewCell::contextMenu( QListBoxItem *item )
717{ 723{
718 if ( !item ) return; 724 if ( !item ) return;
719 725
720 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 726 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
721 Incidence *incidence = eventItem->incidence(); 727 Incidence *incidence = eventItem->incidence();
722 if ( incidence ) mMonthView->showContextMenu( incidence ); 728 if ( incidence ) mMonthView->showContextMenu( incidence );
723} 729}
724 730
725void MonthViewCell::selection( QListBoxItem *item ) 731void MonthViewCell::selection( QListBoxItem *item )
726{ 732{
727 if ( !item ) return; 733 if ( !item ) return;
728 734
729 mMonthView->setSelectedCell( this ); 735 mMonthView->setSelectedCell( this );
730} 736}
731 737
732 738
733// ******************************************************************************* 739// *******************************************************************************
734// ******************************************************************************* 740// *******************************************************************************
735// ******************************************************************************* 741// *******************************************************************************
736 742
737 743
738KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 744KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
739 : KOEventView( calendar, parent, name ), 745 : KOEventView( calendar, parent, name ),
740 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 746 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
741 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 747 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
742{ 748{
743 749
744 updatePossible = false; 750 updatePossible = false;
745 mCells.setAutoDelete( true ); 751 mCells.setAutoDelete( true );
746 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 752 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
747 // mDayLayout = new QGridLayout( this ); 753 // mDayLayout = new QGridLayout( this );
748 // create the day of the week labels (Sun, Mon, etc) and add them to 754 // create the day of the week labels (Sun, Mon, etc) and add them to
749 // the layout. 755 // the layout.
750 mDayLabels.resize( mDaysPerWeek ); 756 mDayLabels.resize( mDaysPerWeek );
751 QFont bfont = font(); 757 QFont bfont = font();
752 if ( QApplication::desktop()->width() < 650 ) { 758 if ( QApplication::desktop()->width() < 650 ) {
753 bfont.setPointSize( bfont.pointSize() - 2 ); 759 bfont.setPointSize( bfont.pointSize() - 2 );
754 } 760 }
755 bfont.setBold( true ); 761 bfont.setBold( true );
756 int i; 762 int i;
757 763
758 for( i = 0; i < mDaysPerWeek; i++ ) { 764 for( i = 0; i < mDaysPerWeek; i++ ) {
759 QLabel *label = new QLabel( this ); 765 QLabel *label = new QLabel( this );
760 label->setFont(bfont); 766 label->setFont(bfont);
761 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 767 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
762 label->setLineWidth(1); 768 label->setLineWidth(1);
763 label->setAlignment(AlignCenter); 769 label->setAlignment(AlignCenter);
764 mDayLabels.insert( i, label ); 770 mDayLabels.insert( i, label );
765 }
766
767 bfont.setBold( false );
768 mWeekLabels.resize( mNumWeeks+1 );
769 for( i = 0; i < mNumWeeks+1; i++ ) {
770 KOWeekButton *label = new KOWeekButton( this );
771 label->setFont(bfont);
772 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
773 label->setFlat(true);
774 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
775 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
776 //label->setLineWidth(1);
777 //label->setAlignment(AlignCenter);
778 mWeekLabels.insert( i, label );
779 }
780 mWeekLabels[mNumWeeks]->setText( i18n("W"));
781 int row, col;
782 mCells.resize( mNumCells );
783 for( row = 0; row < mNumWeeks; ++row ) {
784 for( col = 0; col < mDaysPerWeek; ++col ) {
785 MonthViewCell *cell = new MonthViewCell( this );
786 mCells.insert( row * mDaysPerWeek + col, cell );
787
788 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
789 SLOT( defaultAction( Incidence * ) ) );
790 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
791 SIGNAL( newEventSignal( QDateTime ) ) );
792 connect( cell, SIGNAL( showDaySignal( QDate ) ),
793 SIGNAL( showDaySignal( QDate ) ) );
794 } 771 }
795 }
796 772
797 mContextMenu = eventPopup(); 773 bfont.setBold( false );
798 // updateConfig(); //useless here 774 mWeekLabels.resize( mNumWeeks+1 );
775 for( i = 0; i < mNumWeeks+1; i++ ) {
776 KOWeekButton *label = new KOWeekButton( this );
777 label->setFont(bfont);
778 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
779 label->setFlat(true);
780 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
781 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
782 //label->setLineWidth(1);
783 //label->setAlignment(AlignCenter);
784 mWeekLabels.insert( i, label );
785 }
786 mWeekLabels[mNumWeeks]->setText( i18n("W"));
787 int row, col;
788 mCells.resize( mNumCells );
789 for( row = 0; row < mNumWeeks; ++row ) {
790 for( col = 0; col < mDaysPerWeek; ++col ) {
791 MonthViewCell *cell = new MonthViewCell( this );
792 mCells.insert( row * mDaysPerWeek + col, cell );
793
794 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
795 SLOT( defaultAction( Incidence * ) ) );
796 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
797 SIGNAL( newEventSignal( QDateTime ) ) );
798 connect( cell, SIGNAL( showDaySignal( QDate ) ),
799 SIGNAL( showDaySignal( QDate ) ) );
800 }
801 }
799 802
800 emit incidenceSelected( 0 ); 803 mContextMenu = eventPopup();
804 // updateConfig(); //useless here
805
806 emit incidenceSelected( 0 );
801} 807}
802 808
803KOMonthView::~KOMonthView() 809KOMonthView::~KOMonthView()
804{ 810{
805 delete mContextMenu; 811 delete mContextMenu;
806} 812}
807 813
808int KOMonthView::maxDatesHint() 814int KOMonthView::maxDatesHint()
809{ 815{
810 return mNumCells; 816 return mNumCells;
811} 817}
812 818
813int KOMonthView::currentDateCount() 819int KOMonthView::currentDateCount()
814{ 820{
815 return mNumCells; 821 return mNumCells;
816} 822}
817 823
818QPtrList<Incidence> KOMonthView::selectedIncidences() 824QPtrList<Incidence> KOMonthView::selectedIncidences()
819{ 825{
820 QPtrList<Incidence> selected; 826 QPtrList<Incidence> selected;
821 827
822 if ( mSelectedCell ) { 828 if ( mSelectedCell ) {
823 Incidence *incidence = mSelectedCell->selectedIncidence(); 829 Incidence *incidence = mSelectedCell->selectedIncidence();
824 if ( incidence ) selected.append( incidence ); 830 if ( incidence ) selected.append( incidence );
825 } 831 }
826 832
827 return selected; 833 return selected;
828} 834}
829 835
830DateList KOMonthView::selectedDates() 836DateList KOMonthView::selectedDates()
831{ 837{
832 DateList selected; 838 DateList selected;
833 839
834 if ( mSelectedCell ) { 840 if ( mSelectedCell ) {
835 QDate qd = mSelectedCell->selectedIncidenceDate(); 841 QDate qd = mSelectedCell->selectedIncidenceDate();
836 if ( qd.isValid() ) selected.append( qd ); 842 if ( qd.isValid() ) selected.append( qd );
837 } 843 }
838 844
839 return selected; 845 return selected;
840} 846}
841 847
842void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 848void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
843 const QDate &td) 849 const QDate &td)
844{ 850{
845#ifndef KORG_NOPRINTER 851#ifndef KORG_NOPRINTER
846 calPrinter->preview(CalPrinter::Month, fd, td); 852 calPrinter->preview(CalPrinter::Month, fd, td);
847#endif 853#endif
848} 854}
849 855
850void KOMonthView::updateConfig() 856void KOMonthView::updateConfig()
851{ 857{
852 858
853 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 859 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
854 860
855 QFontMetrics fontmetric(mDayLabels[0]->font()); 861 QFontMetrics fontmetric(mDayLabels[0]->font());
856 mWidthLongDayLabel = 0; 862 mWidthLongDayLabel = 0;
857 863
858 for (int i = 0; i < 7; i++) { 864 for (int i = 0; i < 7; i++) {
859 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 865 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
860 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 866 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
861 } 867 }
862 bool temp = mShowSatSunComp ; 868 bool temp = mShowSatSunComp ;
863 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 869 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
864 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 870 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
865 computeLayout(); 871 computeLayout();
866 updateDayLabels(); 872 updateDayLabels();
867 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 873 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
868 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 874 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
869 //resizeEvent( 0 ); 875 //resizeEvent( 0 );
870 for (uint i = 0; i < mCells.count(); ++i) { 876 for (uint i = 0; i < mCells.count(); ++i) {
871 mCells[i]->updateConfig(); 877 mCells[i]->updateConfig();
872 } 878 }
873#ifdef DESKTOP_VERSION 879#ifdef DESKTOP_VERSION
874 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 880 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
875#endif 881#endif
876} 882}
877 883
878void KOMonthView::updateDayLabels() 884void KOMonthView::updateDayLabels()
879{ 885{
880 886
881 for (int i = 0; i < 7; i++) { 887 for (int i = 0; i < 7; i++) {
882 if (mWeekStartsMonday) { 888 if (mWeekStartsMonday) {
883 bool show = mShortDayLabels; 889 bool show = mShortDayLabels;
884 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 890 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
885 show = true; 891 show = true;
886 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 892 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
887 } else { 893 } else {
888 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 894 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
889 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 895 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
890 896
897 }
891 } 898 }
892 }
893} 899}
894 900
895void KOMonthView::showDates(const QDate &start, const QDate &) 901void KOMonthView::showDates(const QDate &start, const QDate &)
896{ 902{
897// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 903 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
898 904
899 905
900 mStartDate = start; 906 mStartDate = start;
901 907
902 int startWeekDay = mWeekStartsMonday ? 1 : 7; 908 int startWeekDay = mWeekStartsMonday ? 1 : 7;
903 909
904 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 910 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
905 mStartDate = mStartDate.addDays( -1 ); 911 mStartDate = mStartDate.addDays( -1 );
906 } 912 }
907 913
908 bool primary = false; 914 bool primary = false;
909 uint i; 915 uint i;
910 for( i = 0; i < mCells.size(); ++i ) { 916 for( i = 0; i < mCells.size(); ++i ) {
911 QDate date = mStartDate.addDays( i ); 917 QDate date = mStartDate.addDays( i );
912 mCells[i]->setDate( date ); 918 mCells[i]->setDate( date );
913 919
914#ifndef KORG_NOPLUGINS 920#ifndef KORG_NOPLUGINS
915 // add holiday, if present 921 // add holiday, if present
916 QString hstring(KOCore::self()->holiday(date)); 922 QString hstring(KOCore::self()->holiday(date));
917 mCells[i]->setHoliday( hstring ); 923 mCells[i]->setHoliday( hstring );
918#endif 924#endif
919 925
920 } 926 }
921 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 927 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
922 for( i = 0; i < 6; ++i ) { 928 for( i = 0; i < 6; ++i ) {
923 int wno; 929 int wno;
924 // remember, according to ISO 8601, the first week of the year is the 930 // remember, according to ISO 8601, the first week of the year is the
925 // first week that contains a thursday. Thus we must subtract off 4, 931 // first week that contains a thursday. Thus we must subtract off 4,
926 // not just 1. 932 // not just 1.
927 int dayOfYear = date.dayOfYear(); 933 int dayOfYear = date.dayOfYear();
928 if (dayOfYear % 7 != 0) 934 if (dayOfYear % 7 != 0)
929 wno = dayOfYear / 7 + 1; 935 wno = dayOfYear / 7 + 1;
930 else 936 else
931 wno =dayOfYear / 7; 937 wno =dayOfYear / 7;
932 mWeekLabels[i]->setWeekNum( wno ); 938 mWeekLabels[i]->setWeekNum( wno );
933 date = date.addDays( 7 ); 939 date = date.addDays( 7 );
934 } 940 }
935 updateView(); 941 updateView();
936} 942}
937 943
938void KOMonthView::showEvents(QPtrList<Event>) 944void KOMonthView::showEvents(QPtrList<Event>)
939{ 945{
940 qDebug("KOMonthView::selectEvents is not implemented yet. "); 946 qDebug("KOMonthView::selectEvents is not implemented yet. ");
941} 947}
942 948
943void KOMonthView::changeEventDisplay(Event *, int) 949void KOMonthView::changeEventDisplay(Event *, int)
944{ 950{
945 // this should be re-written to be much more efficient, but this 951 // this should be re-written to be much more efficient, but this
946 // quick-and-dirty-hack gets the job done for right now. 952 // quick-and-dirty-hack gets the job done for right now.
947 updateView(); 953 updateView();
948} 954}
949 955
950void KOMonthView::updateView() 956void KOMonthView::updateView()
951{ 957{
958
952 if ( !updatePossible ) 959 if ( !updatePossible )
953 return; 960 return;
954 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 961 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
955 int i; 962 int i;
956 for( i = 0; i < mCells.count(); ++i ) { 963 for( i = 0; i < mCells.count(); ++i ) {
957 mCells[i]->updateCell(); 964 mCells[i]->updateCell();
958 } 965 }
959 966
960 //qDebug("KOMonthView::updateView() "); 967 //qDebug("KOMonthView::updateView() ");
961 processSelectionChange(); 968 processSelectionChange();
962 // qDebug("---------------------------------------------------------------------+ "); 969 // qDebug("---------------------------------------------------------------------+ ");
970 setFocus();
963} 971}
964 972
965void KOMonthView::resizeEvent(QResizeEvent * e) 973void KOMonthView::resizeEvent(QResizeEvent * e)
966{ 974{
967 computeLayout(); 975 computeLayout();
968} 976}
969void KOMonthView::computeLayout() 977void KOMonthView::computeLayout()
970{ 978{
971 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 979 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
972 // note this only changes the text if the requested size crosses the 980 // note this only changes the text if the requested size crosses the
973 // threshold between big enough to support the full name and not big 981 // threshold between big enough to support the full name and not big
974 // enough. 982 // enough.
975 983
976 int daysToShow = 7; 984 int daysToShow = 7;
977 bool combinedSatSun = false; 985 bool combinedSatSun = false;
978 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 986 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
979 daysToShow = 6; 987 daysToShow = 6;
980 combinedSatSun = true; 988 combinedSatSun = true;
981 } 989 }
982 int tWid = topLevelWidget()->size().width(); 990 int tWid = topLevelWidget()->size().width();
983 int tHei = topLevelWidget()->size().height(); 991 int tHei = topLevelWidget()->size().height();
984 992
985 int wid = size().width();//e 993 int wid = size().width();//e
986 int hei = size().height()-1; 994 int hei = size().height()-1;
987 995
988 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 996 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
989 return; 997 return;
990 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 998 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
991 QFontMetrics fm ( mWeekLabels[0]->font() ); 999 QFontMetrics fm ( mWeekLabels[0]->font() );
992 int weeklabelwid = fm.width( "888" ); 1000 int weeklabelwid = fm.width( "888" );
993 wid -= weeklabelwid; 1001 wid -= weeklabelwid;
994 1002
995 int colWid = wid / daysToShow; 1003 int colWid = wid / daysToShow;
996 int lastCol = wid - ( colWid*6 ); 1004 int lastCol = wid - ( colWid*6 );
997 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1005 int dayLabelHei = mDayLabels[0]->sizeHint().height();
998 int cellHei = (hei - dayLabelHei) /6; 1006 int cellHei = (hei - dayLabelHei) /6;
999 int colModulo = wid % daysToShow; 1007 int colModulo = wid % daysToShow;
1000 int rowModulo = (hei- dayLabelHei) % 6; 1008 int rowModulo = (hei- dayLabelHei) % 6;
1001 //qDebug("rowmod %d ", rowModulo); 1009 //qDebug("rowmod %d ", rowModulo);
1002 int i; 1010 int i;
1003 int x,y,w,h; 1011 int x,y,w,h;
1004 x= 0; 1012 x= 0;
1005 y= 0; 1013 y= 0;
1006 w = colWid; 1014 w = colWid;
1007 h = dayLabelHei ; 1015 h = dayLabelHei ;
1008 for ( i = 0; i < 7; i++) { 1016 for ( i = 0; i < 7; i++) {
1009 if ( i == daysToShow-colModulo ) 1017 if ( i == daysToShow-colModulo )
1010 ++w; 1018 ++w;
1011 if ( combinedSatSun ) { 1019 if ( combinedSatSun ) {
1012 if ( i >= daysToShow-1 ) { 1020 if ( i >= daysToShow-1 ) {
1013 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1021 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1014 x -= w/2 ; 1022 x -= w/2 ;
1015 } 1023 }
1016 else 1024 else
1017 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1025 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1018 } else 1026 } else
1019 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1027 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1020 x += w; 1028 x += w;
1021 } 1029 }
1022 x= 0; 1030 x= 0;
1023 y= dayLabelHei; 1031 y= dayLabelHei;
1024 w = colWid; 1032 w = colWid;
1025 h = cellHei ; 1033 h = cellHei ;
1026 for ( i = 0; i < mCells.count(); ++i) { 1034 for ( i = 0; i < mCells.count(); ++i) {
1027 1035
1028 w = colWid; 1036 w = colWid;
1029 if ( ((i) % 7) >= 7-colModulo ) { 1037 if ( ((i) % 7) >= 7-colModulo ) {
1030 ++w; 1038 ++w;
1031 } 1039 }
1032 if ( i == (6-rowModulo)*7) 1040 if ( i == (6-rowModulo)*7)
1033 ++h; 1041 ++h;
1034 if ( combinedSatSun ) { 1042 if ( combinedSatSun ) {
1035 if ( (i)%7 >= daysToShow-1 ) { 1043 if ( (i)%7 >= daysToShow-1 ) {
1036 if ( (i)%7 == daysToShow-1 ) { 1044 if ( (i)%7 == daysToShow-1 ) {
1037 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1045 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1038 x -= w ;y += h/2; 1046 x -= w ;y += h/2;
1039 } else { 1047 } else {
1040 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1048 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1041 y -= h/2; 1049 y -= h/2;
1042 } 1050 }
1043 } else 1051 } else
1044 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1052 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1045 1053
1046 } 1054 }
1047 else 1055 else
1048 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1056 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1049 x += w; 1057 x += w;
1050 if ( x + w/2 > wid ) { 1058 if ( x + w/2 > wid ) {
1051 x = 0; 1059 x = 0;
1052 y += h; 1060 y += h;
1053 } 1061 }
1054 } 1062 }
1055 y= dayLabelHei; 1063 y= dayLabelHei;
1056 h = cellHei ; 1064 h = cellHei ;
1057 for ( i = 0; i < 6; i++) { 1065 for ( i = 0; i < 6; i++) {
1058 if ( i == (6-rowModulo)) 1066 if ( i == (6-rowModulo))
1059 ++h; 1067 ++h;
1060 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1068 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1061 y += h; 1069 y += h;
1062 } 1070 }
1063 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1071 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1064 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1072 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1065 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1073 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1066 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1074 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1067 updateDayLabels(); 1075 updateDayLabels();
1068 bool forceUpdate = !updatePossible; 1076 bool forceUpdate = !updatePossible;
1069 updatePossible = true; 1077 updatePossible = true;
1070 if ( forceUpdate ) 1078 if ( forceUpdate )
1071 updateView(); 1079 updateView();
1072} 1080}
1073 1081
1074void KOMonthView::showContextMenu( Incidence *incidence ) 1082void KOMonthView::showContextMenu( Incidence *incidence )
1075{ 1083{
1076 mContextMenu->showIncidencePopup(incidence); 1084 mContextMenu->showIncidencePopup(incidence);
1077 /* 1085 /*
1078 if( incidence && incidence->type() == "Event" ) { 1086 if( incidence && incidence->type() == "Event" ) {
1079 Event *event = static_cast<Event *>(incidence); 1087 Event *event = static_cast<Event *>(incidence);
1080 mContextMenu->showEventPopup(event); 1088 mContextMenu->showEventPopup(event);
1081 } else { 1089 } else {
1082 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1090 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1083 } 1091 }
1084 */ 1092 */
1085} 1093}
1086MonthViewCell * KOMonthView::selectedCell( ) 1094MonthViewCell * KOMonthView::selectedCell( )
1087{ 1095{
1088 return mSelectedCell; 1096 return mSelectedCell;
1089} 1097}
1090void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1098void KOMonthView::setSelectedCell( MonthViewCell *cell )
1091{ 1099{
1092 // qDebug("KOMonthView::setSelectedCell "); 1100 // qDebug("KOMonthView::setSelectedCell ");
1093 if ( mSelectedCell && mSelectedCell != cell ) { 1101 if ( mSelectedCell && mSelectedCell != cell ) {
1094 MonthViewCell * mvc = mSelectedCell; 1102 MonthViewCell * mvc = mSelectedCell;
1095 mSelectedCell = cell; 1103 mSelectedCell = cell;
1096 mvc->deselect(); 1104 mvc->deselect();
1097 } else 1105 } else
1098 mSelectedCell = cell; 1106 mSelectedCell = cell;
1099 // if ( mSelectedCell ) 1107 // if ( mSelectedCell )
1100// mSelectedCell->select(); 1108 // mSelectedCell->select();
1101 if ( !mSelectedCell ) 1109 if ( !mSelectedCell )
1102 emit incidenceSelected( 0 ); 1110 emit incidenceSelected( 0 );
1103 else 1111 else
1104 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1112 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1105} 1113}
1106 1114
1107void KOMonthView::processSelectionChange() 1115void KOMonthView::processSelectionChange()
1108{ 1116{
1109 QPtrList<Incidence> incidences = selectedIncidences(); 1117 QPtrList<Incidence> incidences = selectedIncidences();
1110 if (incidences.count() > 0) { 1118 if (incidences.count() > 0) {
1111 emit incidenceSelected( incidences.first() ); 1119 emit incidenceSelected( incidences.first() );
1112 } else { 1120 } else {
1113 emit incidenceSelected( 0 ); 1121 emit incidenceSelected( 0 );
1114 } 1122 }
1115} 1123}
1116 1124
1117void KOMonthView::clearSelection() 1125void KOMonthView::clearSelection()
1118{ 1126{
1119 if ( mSelectedCell ) { 1127 if ( mSelectedCell ) {
1120 mSelectedCell->deselect(); 1128 mSelectedCell->deselect();
1121 mSelectedCell = 0; 1129 mSelectedCell = 0;
1122 } 1130 }
1123} 1131}
1124void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1132void KOMonthView::keyPressEvent ( QKeyEvent * e )
1125{ 1133{
1126 1134 switch(e->key()) {
1127 e->ignore(); 1135 break;
1128 1136 case Key_Up:
1137 {
1138 emit prevMonth();
1139 setFocus();
1140 }
1141 e->accept();
1142 break;
1143 case Key_Down:
1144 {
1145 emit nextMonth();
1146 setFocus();
1147 }
1148 e->accept();
1149 break;
1150 default:
1151 e->ignore();
1152 break;
1153 }
1129} 1154}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a965bf3..50903b3 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,272 +1,274 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qintdict.h> 29#include <qintdict.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qptrvector.h> 32#include <qptrvector.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35#include <libkcal/event.h> 35#include <libkcal/event.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39#ifdef DESKTOP_VERSION 39#ifdef DESKTOP_VERSION
40class QToolTipGroup; 40class QToolTipGroup;
41#endif 41#endif
42 42
43class KNOWhatsThis; 43class KNOWhatsThis;
44class KOWeekButton : public QPushButton 44class KOWeekButton : public QPushButton
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 48 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
49 QPushButton( parent, name) 49 QPushButton( parent, name)
50 { 50 {
51 connect( this, SIGNAL( clicked() ), 51 connect( this, SIGNAL( clicked() ),
52 SLOT( bottonClicked() )); 52 SLOT( bottonClicked() ));
53 mNumber = -1; 53 mNumber = -1;
54 } 54 }
55 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 55 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
56 signals: 56 signals:
57 void selectWeekNum ( int ); 57 void selectWeekNum ( int );
58private: 58private:
59 int mNumber; 59 int mNumber;
60private slots : 60private slots :
61 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 61 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
62}; 62};
63 63
64class KNoScrollListBox: public QListBox 64class KNoScrollListBox: public QListBox
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67 public: 67 public:
68 KNoScrollListBox(QWidget *parent=0, const char *name=0); 68 KNoScrollListBox(QWidget *parent=0, const char *name=0);
69 ~KNoScrollListBox(); 69 ~KNoScrollListBox();
70 QString getWhatsThisText(QPoint p) ; 70 QString getWhatsThisText(QPoint p) ;
71 71
72 signals: 72 signals:
73 void shiftDown(); 73 void shiftDown();
74 void shiftUp(); 74 void shiftUp();
75 void rightClick(); 75 void rightClick();
76 76
77 protected slots: 77 protected slots:
78 void keyPressEvent(QKeyEvent *); 78 void keyPressEvent(QKeyEvent *);
79 void keyReleaseEvent(QKeyEvent *); 79 void keyReleaseEvent(QKeyEvent *);
80 void mousePressEvent(QMouseEvent *); 80 void mousePressEvent(QMouseEvent *);
81 81
82 private: 82 private:
83 KNOWhatsThis * mWT; 83 KNOWhatsThis * mWT;
84}; 84};
85 85
86 86
87class MonthViewItem: public QListBoxItem 87class MonthViewItem: public QListBoxItem
88{ 88{
89 public: 89 public:
90 MonthViewItem( Incidence *, QDate qd, const QString & title ); 90 MonthViewItem( Incidence *, QDate qd, const QString & title );
91 91
92 void setRecur(bool on) { mRecur = on; } 92 void setRecur(bool on) { mRecur = on; }
93 void setAlarm(bool on) { mAlarm = on; } 93 void setAlarm(bool on) { mAlarm = on; }
94 void setReply(bool on) { mReply = on; } 94 void setReply(bool on) { mReply = on; }
95 void setMoreInfo(bool on) { mInfo = on; } 95 void setMoreInfo(bool on) { mInfo = on; }
96 96
97 97
98 void setPalette(const QPalette &p) { mPalette = p; } 98 void setPalette(const QPalette &p) { mPalette = p; }
99 QPalette palette() const { return mPalette; } 99 QPalette palette() const { return mPalette; }
100 100
101 Incidence *incidence() const { return mIncidence; } 101 Incidence *incidence() const { return mIncidence; }
102 QDate incidenceDate() { return mDate; } 102 QDate incidenceDate() { return mDate; }
103 103
104 protected: 104 protected:
105 virtual void paint(QPainter *); 105 virtual void paint(QPainter *);
106 virtual int height(const QListBox *) const; 106 virtual int height(const QListBox *) const;
107 virtual int width(const QListBox *) const; 107 virtual int width(const QListBox *) const;
108 108
109 private: 109 private:
110 bool mRecur; 110 bool mRecur;
111 bool mAlarm; 111 bool mAlarm;
112 bool mReply; 112 bool mReply;
113 bool mInfo; 113 bool mInfo;
114 114
115 QPalette mPalette; 115 QPalette mPalette;
116 QDate mDate; 116 QDate mDate;
117 117
118 Incidence *mIncidence; 118 Incidence *mIncidence;
119}; 119};
120 120
121 121
122class KOMonthView; 122class KOMonthView;
123 123
124class MonthViewCell : public QWidget 124class MonthViewCell : public QWidget
125{ 125{
126 Q_OBJECT 126 Q_OBJECT
127 public: 127 public:
128 MonthViewCell( KOMonthView * ); 128 MonthViewCell( KOMonthView * );
129 129
130 void setDate( const QDate & ); 130 void setDate( const QDate & );
131 QDate date() const; 131 QDate date() const;
132 132
133 void setPrimary( bool ); 133 void setPrimary( bool );
134 bool isPrimary() const; 134 bool isPrimary() const;
135 135
136 void setHoliday( bool ); 136 void setHoliday( bool );
137 void setHoliday( const QString & ); 137 void setHoliday( const QString & );
138 138
139 void updateCell(); 139 void updateCell();
140 140
141 void updateConfig(); 141 void updateConfig();
142 142
143 void enableScrollBars( bool ); 143 void enableScrollBars( bool );
144 144
145 Incidence *selectedIncidence(); 145 Incidence *selectedIncidence();
146 QDate selectedIncidenceDate(); 146 QDate selectedIncidenceDate();
147 147
148 void deselect(); 148 void deselect();
149 void select(); 149 void select();
150 void clear(); 150 void clear();
151 151
152#ifdef DESKTOP_VERSION 152#ifdef DESKTOP_VERSION
153 static QToolTipGroup *toolTipGroup(); 153 static QToolTipGroup *toolTipGroup();
154#endif 154#endif
155 signals: 155 signals:
156 void defaultAction( Incidence * ); 156 void defaultAction( Incidence * );
157 void newEventSignal( QDateTime ); 157 void newEventSignal( QDateTime );
158 void showDaySignal( QDate ); 158 void showDaySignal( QDate );
159 159
160 protected: 160 protected:
161 void resizeEvent( QResizeEvent * ); 161 void resizeEvent( QResizeEvent * );
162 162
163 protected slots: 163 protected slots:
164 void defaultAction( QListBoxItem * ); 164 void defaultAction( QListBoxItem * );
165 void contextMenu( QListBoxItem * ); 165 void contextMenu( QListBoxItem * );
166 void selection( QListBoxItem * ); 166 void selection( QListBoxItem * );
167 void cellClicked( QListBoxItem * ); 167 void cellClicked( QListBoxItem * );
168 void newEvent(); 168 void newEvent();
169 void showDay(); 169 void showDay();
170 170
171 private: 171 private:
172 KOMonthView *mMonthView; 172 KOMonthView *mMonthView;
173 173
174 QDate mDate; 174 QDate mDate;
175 bool mPrimary; 175 bool mPrimary;
176 bool mHoliday; 176 bool mHoliday;
177 QString mHolidayString; 177 QString mHolidayString;
178 178
179 //QLabel *mLabel; 179 //QLabel *mLabel;
180 QPushButton *mLabel; 180 QPushButton *mLabel;
181 QListBox *mItemList; 181 QListBox *mItemList;
182#ifdef DESKTOP_VERSION 182#ifdef DESKTOP_VERSION
183 static QToolTipGroup *mToolTipGroup; 183 static QToolTipGroup *mToolTipGroup;
184#endif 184#endif
185 QSize mLabelSize; 185 QSize mLabelSize;
186 QSize mLabelBigSize; 186 QSize mLabelBigSize;
187 QPalette mHolidayPalette; 187 QPalette mHolidayPalette;
188 QPalette mStandardPalette; 188 QPalette mStandardPalette;
189 QPalette mPrimaryPalette; 189 QPalette mPrimaryPalette;
190 QPalette mNonPrimaryPalette; 190 QPalette mNonPrimaryPalette;
191 void setMyPalette(); 191 void setMyPalette();
192 QPalette getPalette (); 192 QPalette getPalette ();
193 void keyPressEvent ( QKeyEvent * ) ; 193 void keyPressEvent ( QKeyEvent * ) ;
194 194
195}; 195};
196 196
197 197
198class KOMonthView: public KOEventView 198class KOMonthView: public KOEventView
199{ 199{
200 Q_OBJECT 200 Q_OBJECT
201 public: 201 public:
202 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 202 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
203 ~KOMonthView(); 203 ~KOMonthView();
204 204
205 /** Returns maximum number of days supported by the komonthview */ 205 /** Returns maximum number of days supported by the komonthview */
206 virtual int maxDatesHint(); 206 virtual int maxDatesHint();
207 207
208 /** Returns number of currently shown dates. */ 208 /** Returns number of currently shown dates. */
209 virtual int currentDateCount(); 209 virtual int currentDateCount();
210 210
211 /** returns the currently selected events */ 211 /** returns the currently selected events */
212 virtual QPtrList<Incidence> selectedIncidences(); 212 virtual QPtrList<Incidence> selectedIncidences();
213 213
214 /** returns dates of the currently selected events */ 214 /** returns dates of the currently selected events */
215 virtual DateList selectedDates(); 215 virtual DateList selectedDates();
216 216
217 virtual void printPreview(CalPrinter *calPrinter, 217 virtual void printPreview(CalPrinter *calPrinter,
218 const QDate &, const QDate &); 218 const QDate &, const QDate &);
219 bool isMonthView() { return true; } 219 bool isMonthView() { return true; }
220 bool isUpdatePossible() { return updatePossible; } 220 bool isUpdatePossible() { return updatePossible; }
221 221
222 MonthViewCell * selectedCell(); 222 MonthViewCell * selectedCell();
223 public slots: 223 public slots:
224 virtual void updateView(); 224 virtual void updateView();
225 virtual void updateConfig(); 225 virtual void updateConfig();
226 virtual void showDates(const QDate &start, const QDate &end); 226 virtual void showDates(const QDate &start, const QDate &end);
227 virtual void showEvents(QPtrList<Event> eventList); 227 virtual void showEvents(QPtrList<Event> eventList);
228 228
229 void changeEventDisplay(Event *, int); 229 void changeEventDisplay(Event *, int);
230 230
231 void clearSelection(); 231 void clearSelection();
232 232
233 void showContextMenu( Incidence * ); 233 void showContextMenu( Incidence * );
234 234
235 void setSelectedCell( MonthViewCell * ); 235 void setSelectedCell( MonthViewCell * );
236 236
237 protected slots: 237 protected slots:
238 void processSelectionChange(); 238 void processSelectionChange();
239 signals: 239 signals:
240 void nextMonth();
241 void prevMonth();
240 void selectWeekNum ( int ); 242 void selectWeekNum ( int );
241 void showDaySignal( QDate ); 243 void showDaySignal( QDate );
242 protected: 244 protected:
243 void resizeEvent(QResizeEvent *); 245 void resizeEvent(QResizeEvent *);
244 void viewChanged(); 246 void viewChanged();
245 void updateDayLabels(); 247 void updateDayLabels();
246 248
247 private: 249 private:
248 bool updatePossible; 250 bool updatePossible;
249 int mDaysPerWeek; 251 int mDaysPerWeek;
250 int mNumWeeks; 252 int mNumWeeks;
251 int mNumCells; 253 int mNumCells;
252 bool mWeekStartsMonday; 254 bool mWeekStartsMonday;
253 bool mShowSatSunComp; 255 bool mShowSatSunComp;
254 void computeLayout(); 256 void computeLayout();
255 257
256 QPtrVector<MonthViewCell> mCells; 258 QPtrVector<MonthViewCell> mCells;
257 QPtrVector<QLabel> mDayLabels; 259 QPtrVector<QLabel> mDayLabels;
258 QPtrVector<KOWeekButton> mWeekLabels; 260 QPtrVector<KOWeekButton> mWeekLabels;
259 261
260 bool mShortDayLabels; 262 bool mShortDayLabels;
261 int mWidthLongDayLabel; 263 int mWidthLongDayLabel;
262 264
263 QDate mStartDate; 265 QDate mStartDate;
264 266
265 MonthViewCell *mSelectedCell; 267 MonthViewCell *mSelectedCell;
266 268
267 KOEventPopupMenu *mContextMenu; 269 KOEventPopupMenu *mContextMenu;
268 void keyPressEvent ( QKeyEvent * ) ; 270 void keyPressEvent ( QKeyEvent * ) ;
269 271
270}; 272};
271 273
272#endif 274#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 94c459b..e8d5ab1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,590 +1,594 @@
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") showMonthView(); 91 else if (view == "Month") showMonthView();
92 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
96 else { 96 else {
97 showAgendaView(); 97 showAgendaView();
98 } 98 }
99} 99}
100 100
101void KOViewManager::writeSettings(KConfig *config) 101void KOViewManager::writeSettings(KConfig *config)
102{ 102{
103 config->setGroup("General"); 103 config->setGroup("General");
104 104
105 QString view; 105 QString view;
106 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 106 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
107 else if (mCurrentView == mMonthView) view = "Month"; 107 else if (mCurrentView == mMonthView) view = "Month";
108 else if (mCurrentView == mListView) view = "List"; 108 else if (mCurrentView == mListView) view = "List";
109 else if (mCurrentView == mJournalView) view = "Journal"; 109 else if (mCurrentView == mJournalView) view = "Journal";
110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
111 else if (mCurrentView == mTodoView) view = "Todo"; 111 else if (mCurrentView == mTodoView) view = "Todo";
112 else view = "Agenda"; 112 else view = "Agenda";
113 113
114 config->writeEntry("Current View",view); 114 config->writeEntry("Current View",view);
115 115
116 if (mAgendaView) { 116 if (mAgendaView) {
117 mAgendaView->writeSettings(config); 117 mAgendaView->writeSettings(config);
118 } 118 }
119 if (mTimeSpanView) { 119 if (mTimeSpanView) {
120 mTimeSpanView->writeSettings(config); 120 mTimeSpanView->writeSettings(config);
121 } 121 }
122 if (mListView) { 122 if (mListView) {
123 mListView->writeSettings(config); 123 mListView->writeSettings(config);
124 } 124 }
125 if (mTodoView) { 125 if (mTodoView) {
126 mTodoView->saveLayout(config,"Todo View"); 126 mTodoView->saveLayout(config,"Todo View");
127 } 127 }
128} 128}
129 129
130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
131{ 131{
132 132
133 //mFlagShowNextxDays = false; 133 //mFlagShowNextxDays = false;
134 //if(view == mCurrentView) return; 134 //if(view == mCurrentView) return;
135 if ( view == 0 ) { 135 if ( view == 0 ) {
136 view = mCurrentView; 136 view = mCurrentView;
137 if ( view == 0 ) 137 if ( view == 0 )
138 return; 138 return;
139 } 139 }
140 bool full = fullScreen; 140 bool full = fullScreen;
141 if(view == mCurrentView && view != mWhatsNextView ) { 141 if(view == mCurrentView && view != mWhatsNextView ) {
142 if ( mCurrentAgendaView < 0 ) 142 if ( mCurrentAgendaView < 0 )
143 return; 143 return;
144 full = mMainView->leftFrame()->isVisible(); 144 full = mMainView->leftFrame()->isVisible();
145 } else { 145 } else {
146 mCurrentView = view; 146 mCurrentView = view;
147 147
148 // bool full = fullScreen; 148 // bool full = fullScreen;
149 bool isFull = !mMainView->leftFrame()->isVisible(); 149 bool isFull = !mMainView->leftFrame()->isVisible();
150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
151 full = true; 151 full = true;
152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
153 full = false; 153 full = false;
154 } 154 }
155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
156 //raiseCurrentView( full ); 156 //raiseCurrentView( full );
157 mMainView->processIncidenceSelection( 0 ); 157 mMainView->processIncidenceSelection( 0 );
158 mMainView->updateView(); 158 mMainView->updateView();
159 raiseCurrentView( full ); 159 raiseCurrentView( full );
160 mMainView->adaptNavigationUnits(); 160 mMainView->adaptNavigationUnits();
161} 161}
162 162
163void KOViewManager::raiseCurrentView( bool fullScreen ) 163void KOViewManager::raiseCurrentView( bool fullScreen )
164{ 164{
165 //qDebug("raiseCurrentView "); 165 //qDebug("raiseCurrentView ");
166 mCurrentAgendaView = 0; 166 mCurrentAgendaView = 0;
167 int wid = mMainView->width() ; 167 int wid = mMainView->width() ;
168 int hei = mMainView->height(); 168 int hei = mMainView->height();
169 if ( mCurrentView == mMonthView ) { 169 if ( mCurrentView == mMonthView ) {
170 mMainView->navigatorBar()->show(); 170 mMainView->navigatorBar()->show();
171 hei -= mMainView->navigatorBar()->sizeHint().height(); 171 hei -= mMainView->navigatorBar()->sizeHint().height();
172 //mMainView->navigatorBar()->hide(); 172 //mMainView->navigatorBar()->hide();
173 } else { 173 } else {
174 mMainView->navigatorBar()->hide(); 174 mMainView->navigatorBar()->hide();
175 } 175 }
176 if ( fullScreen ) { 176 if ( fullScreen ) {
177 mMainView->leftFrame()->hide(); 177 mMainView->leftFrame()->hide();
178 } else { 178 } else {
179 mMainView->leftFrame()->show(); 179 mMainView->leftFrame()->show();
180 if ( KOPrefs::instance()->mVerticalScreen ) 180 if ( KOPrefs::instance()->mVerticalScreen )
181 hei -= mMainView->leftFrame()->height(); 181 hei -= mMainView->leftFrame()->height();
182 else 182 else
183 wid -= mMainView->leftFrame()->width(); 183 wid -= mMainView->leftFrame()->width();
184 } 184 }
185 emit signalFullScreen( !fullScreen ); 185 emit signalFullScreen( !fullScreen );
186 if ( globalFlagBlockAgenda == 5 ) { 186 if ( globalFlagBlockAgenda == 5 ) {
187 globalFlagBlockAgenda = 4; 187 globalFlagBlockAgenda = 4;
188 globalFlagBlockAgendaItemPaint = 1; 188 globalFlagBlockAgendaItemPaint = 1;
189 } 189 }
190 mMainView->viewStack()->raiseWidget(mCurrentView); 190 mMainView->viewStack()->raiseWidget(mCurrentView);
191 if ( globalFlagBlockAgenda == 4 ) { 191 if ( globalFlagBlockAgenda == 4 ) {
192 if ( mCurrentView == mAgendaView ) { 192 if ( mCurrentView == mAgendaView ) {
193 //globalFlagBlockAgenda =1 ; 193 //globalFlagBlockAgenda =1 ;
194 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 194 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
195 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 195 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
196 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 196 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
197 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 197 mAgendaView->setStartHour( QTime::currentTime ().hour() );
198 qApp->processEvents(); 198 qApp->processEvents();
199 //qDebug("qApp->processEvents() "); 199 //qDebug("qApp->processEvents() ");
200 globalFlagBlockAgenda = 0; 200 globalFlagBlockAgenda = 0;
201 mAgendaView->repaintAgenda(); 201 mAgendaView->repaintAgenda();
202 202
203 } 203 }
204 globalFlagBlockAgenda = 0; 204 globalFlagBlockAgenda = 0;
205 } 205 }
206 emit signalAgendaView( mCurrentView == mAgendaView ); 206 emit signalAgendaView( mCurrentView == mAgendaView );
207 //qDebug("raiseCurrentView ende "); 207 //qDebug("raiseCurrentView ende ");
208 208
209} 209}
210 210
211void KOViewManager::updateView() 211void KOViewManager::updateView()
212{ 212{
213 // qDebug("KOViewManager::updateView() "); 213 // qDebug("KOViewManager::updateView() ");
214 // if we are updating mTodoView, we get endless recursion 214 // if we are updating mTodoView, we get endless recursion
215 if ( mTodoView == mCurrentView ) 215 if ( mTodoView == mCurrentView )
216 return; 216 return;
217 if ( mCurrentView ) mCurrentView->updateView(); 217 if ( mCurrentView ) mCurrentView->updateView();
218 218
219} 219}
220 220
221void KOViewManager::updateView(const QDate &start, const QDate &end) 221void KOViewManager::updateView(const QDate &start, const QDate &end)
222{ 222{
223 // kdDebug() << "KOViewManager::updateView()" << endl; 223 // kdDebug() << "KOViewManager::updateView()" << endl;
224 224
225 if (mCurrentView) mCurrentView->showDates(start, end); 225 if (mCurrentView) mCurrentView->showDates(start, end);
226 226
227 if (mTodoView) mTodoView->updateView(); 227 if (mTodoView) mTodoView->updateView();
228} 228}
229 229
230 230
231void KOViewManager::updateWNview() 231void KOViewManager::updateWNview()
232{ 232{
233 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 233 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
234 mWhatsNextView->updateView(); 234 mWhatsNextView->updateView();
235 235
236} 236}
237void KOViewManager::showWhatsNextView() 237void KOViewManager::showWhatsNextView()
238{ 238{
239 if (!mWhatsNextView) { 239 if (!mWhatsNextView) {
240 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 240 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
241 "KOViewManager::WhatsNextView"); 241 "KOViewManager::WhatsNextView");
242 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 242 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
243 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 243 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
244 addView(mWhatsNextView); 244 addView(mWhatsNextView);
245 connect(this, SIGNAL( printWNV() ), 245 connect(this, SIGNAL( printWNV() ),
246 mWhatsNextView, SLOT( printMe() ) ); 246 mWhatsNextView, SLOT( printMe() ) );
247 } 247 }
248 globalFlagBlockAgenda = 1; 248 globalFlagBlockAgenda = 1;
249 showView(mWhatsNextView, true ); 249 showView(mWhatsNextView, true );
250 //mWhatsNextView->updateView(); 250 //mWhatsNextView->updateView();
251 251
252} 252}
253 253
254void KOViewManager::showListView() 254void KOViewManager::showListView()
255{ 255{
256 if (!mListView) { 256 if (!mListView) {
257 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 257 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
258 addView(mListView); 258 addView(mListView);
259 259
260 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 260 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
261 mMainView, SLOT(showIncidence(Incidence *))); 261 mMainView, SLOT(showIncidence(Incidence *)));
262 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 262 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
263 mMainView, SLOT(editIncidence(Incidence *))); 263 mMainView, SLOT(editIncidence(Incidence *)));
264 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 264 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
265 mMainView, SLOT(deleteIncidence(Incidence *))); 265 mMainView, SLOT(deleteIncidence(Incidence *)));
266 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 266 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
267 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 267 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
268 connect( mListView, SIGNAL( signalNewEvent() ), 268 connect( mListView, SIGNAL( signalNewEvent() ),
269 mMainView, SLOT( newEvent() ) ); 269 mMainView, SLOT( newEvent() ) );
270 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 270 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
271 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 271 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
272 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 272 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
273 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 273 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
274 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 274 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
275 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 275 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
276 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 276 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
277 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 277 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
278 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 278 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
279 } 279 }
280 // bool temp = mFlagShowNextxDays; 280 // bool temp = mFlagShowNextxDays;
281 //globalFlagBlockPainting = true; 281 //globalFlagBlockPainting = true;
282 globalFlagBlockAgenda = 1; 282 globalFlagBlockAgenda = 1;
283 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 283 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
284 mMainView->setBlockShowDates( true ); 284 mMainView->setBlockShowDates( true );
285 mMainView->dateNavigator()->selectMonth(); 285 mMainView->dateNavigator()->selectMonth();
286 mMainView->setBlockShowDates( false ); 286 mMainView->setBlockShowDates( false );
287 } 287 }
288 showView(mListView, KOPrefs::instance()->mFullViewTodo); 288 showView(mListView, KOPrefs::instance()->mFullViewTodo);
289 //mFlagShowNextxDays = temp; 289 //mFlagShowNextxDays = temp;
290} 290}
291 291
292void KOViewManager::showAgendaView( bool fullScreen ) 292void KOViewManager::showAgendaView( bool fullScreen )
293{ 293{
294 294
295 mMainView->dialogManager()->hideSearchDialog(); 295 mMainView->dialogManager()->hideSearchDialog();
296 // qDebug("KOViewManager::showAgendaView "); 296 // qDebug("KOViewManager::showAgendaView ");
297 bool full; 297 bool full;
298 full = fullScreen; 298 full = fullScreen;
299 if (!mAgendaView) { 299 if (!mAgendaView) {
300 full = false; 300 full = false;
301 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 301 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
302 addView(mAgendaView); 302 addView(mAgendaView);
303#ifndef DESKTOP_VERSION 303#ifndef DESKTOP_VERSION
304 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 304 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
305#endif 305#endif
306 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 306 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
307 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 307 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
308 308
309 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 309 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
310 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 310 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
311 mMainView, SLOT(newEvent(QDateTime))); 311 mMainView, SLOT(newEvent(QDateTime)));
312 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 312 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
313 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 313 // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
314 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 314 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
315 mMainView, SLOT(newEvent(QDate))); 315 mMainView, SLOT(newEvent(QDate)));
316 316
317 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 317 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
318 mMainView, SLOT(editIncidence(Incidence *))); 318 mMainView, SLOT(editIncidence(Incidence *)));
319 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 319 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
320 mMainView, SLOT(showIncidence(Incidence *))); 320 mMainView, SLOT(showIncidence(Incidence *)));
321 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 321 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
322 mMainView, SLOT(deleteIncidence(Incidence *))); 322 mMainView, SLOT(deleteIncidence(Incidence *)));
323 323
324 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 324 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
325 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 325 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
326 326
327 connect(mAgendaView, SIGNAL( toggleExpand() ), 327 connect(mAgendaView, SIGNAL( toggleExpand() ),
328 mMainView, SLOT( toggleExpand() ) ); 328 mMainView, SLOT( toggleExpand() ) );
329 329
330 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 330 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
331 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 331 mAgendaView, SLOT( setExpandedButton( bool ) ) );
332 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 332 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
333 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 333 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
334 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 334 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
335 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 335 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
336 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 336 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
337 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 337 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
338 SLOT( updateTodo( Todo *, int ) ) ); 338 SLOT( updateTodo( Todo *, int ) ) );
339 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 339 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
340 mMainView, SIGNAL( todoModified( Todo *, int ))); 340 mMainView, SIGNAL( todoModified( Todo *, int )));
341 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 341 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
342 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 342 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
343 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 343 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
344 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 344 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
345 mAgendaView->readSettings(); 345 mAgendaView->readSettings();
346 mAgendaView->updateConfig(); 346 mAgendaView->updateConfig();
347 } 347 }
348 348
349 showView( mAgendaView, full); 349 showView( mAgendaView, full);
350 350
351} 351}
352 352
353void KOViewManager::showDayView() 353void KOViewManager::showDayView()
354{ 354{
355 mFlagShowNextxDays = false; 355 mFlagShowNextxDays = false;
356 globalFlagBlockLabel = 1; 356 globalFlagBlockLabel = 1;
357 globalFlagBlockAgenda = 1; 357 globalFlagBlockAgenda = 1;
358 if ( mCurrentAgendaView != 1 ) 358 if ( mCurrentAgendaView != 1 )
359 mCurrentAgendaView = -1; 359 mCurrentAgendaView = -1;
360 showAgendaView(); 360 showAgendaView();
361 qApp->processEvents(); 361 qApp->processEvents();
362 globalFlagBlockAgenda = 2; 362 globalFlagBlockAgenda = 2;
363 globalFlagBlockLabel = 0; 363 globalFlagBlockLabel = 0;
364 mMainView->dateNavigator()->selectDates( 1 ); 364 mMainView->dateNavigator()->selectDates( 1 );
365 mCurrentAgendaView = 1 ; 365 mCurrentAgendaView = 1 ;
366 366
367} 367}
368 368
369void KOViewManager::showWorkWeekView() 369void KOViewManager::showWorkWeekView()
370{ 370{
371 mFlagShowNextxDays = false; 371 mFlagShowNextxDays = false;
372 globalFlagBlockAgenda = 1; 372 globalFlagBlockAgenda = 1;
373 globalFlagBlockLabel = 1; 373 globalFlagBlockLabel = 1;
374 if ( mCurrentAgendaView != 5 ) 374 if ( mCurrentAgendaView != 5 )
375 mCurrentAgendaView = -1; 375 mCurrentAgendaView = -1;
376 showAgendaView(); 376 showAgendaView();
377 qApp->processEvents(); 377 qApp->processEvents();
378 globalFlagBlockAgenda = 2; 378 globalFlagBlockAgenda = 2;
379 globalFlagBlockLabel = 0; 379 globalFlagBlockLabel = 0;
380 mMainView->dateNavigator()->selectWorkWeek(); 380 mMainView->dateNavigator()->selectWorkWeek();
381 mCurrentAgendaView = 5 ; 381 mCurrentAgendaView = 5 ;
382 382
383} 383}
384 384
385void KOViewManager::showWeekView() 385void KOViewManager::showWeekView()
386{ 386{
387 /* 387 /*
388 globalFlagBlockAgenda = 2; 388 globalFlagBlockAgenda = 2;
389 qDebug("4globalFlagBlockAgenda = 2; "); 389 qDebug("4globalFlagBlockAgenda = 2; ");
390 //globalFlagBlockPainting = true; 390 //globalFlagBlockPainting = true;
391 mMainView->dateNavigator()->selectWeek(); 391 mMainView->dateNavigator()->selectWeek();
392 showAgendaView(); 392 showAgendaView();
393 */ 393 */
394 394
395 395
396 mFlagShowNextxDays = false; 396 mFlagShowNextxDays = false;
397 globalFlagBlockAgenda = 1; 397 globalFlagBlockAgenda = 1;
398 globalFlagBlockLabel = 1; 398 globalFlagBlockLabel = 1;
399 if ( mCurrentAgendaView != 7 ) 399 if ( mCurrentAgendaView != 7 )
400 mCurrentAgendaView = -1; 400 mCurrentAgendaView = -1;
401 showAgendaView(); 401 showAgendaView();
402 qApp->processEvents(); 402 qApp->processEvents();
403 globalFlagBlockAgenda = 2; 403 globalFlagBlockAgenda = 2;
404 globalFlagBlockLabel = 0; 404 globalFlagBlockLabel = 0;
405 mMainView->dateNavigator()->selectWeek(); 405 mMainView->dateNavigator()->selectWeek();
406 mCurrentAgendaView = 7 ; 406 mCurrentAgendaView = 7 ;
407} 407}
408 408
409void KOViewManager::showNextXView() 409void KOViewManager::showNextXView()
410{ 410{
411 411
412 globalFlagBlockAgenda = 1; 412 globalFlagBlockAgenda = 1;
413 if ( mCurrentAgendaView != 3 ) 413 if ( mCurrentAgendaView != 3 )
414 mCurrentAgendaView = -1; 414 mCurrentAgendaView = -1;
415 showAgendaView(KOPrefs::instance()->mFullViewMonth); 415 showAgendaView(KOPrefs::instance()->mFullViewMonth);
416 globalFlagBlockAgenda = 2; 416 globalFlagBlockAgenda = 2;
417 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 417 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
418 KOPrefs::instance()->mNextXDays ); 418 KOPrefs::instance()->mNextXDays );
419 mFlagShowNextxDays = true; 419 mFlagShowNextxDays = true;
420 mCurrentAgendaView = 3 ; 420 mCurrentAgendaView = 3 ;
421} 421}
422bool KOViewManager::showsNextDays() 422bool KOViewManager::showsNextDays()
423{ 423{
424 return mFlagShowNextxDays; 424 return mFlagShowNextxDays;
425} 425}
426void KOViewManager::showMonthView() 426void KOViewManager::showMonthView()
427{ 427{
428 if (!mMonthView) { 428 if (!mMonthView) {
429 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 429 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
430 430
431 addView(mMonthView); 431 addView(mMonthView);
432 // mMonthView->show(); 432 // mMonthView->show();
433 // SIGNALS/SLOTS FOR MONTH VIEW 433 // SIGNALS/SLOTS FOR MONTH VIEW
434 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 434 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
435 mMainView, SLOT(newEvent(QDateTime))); 435 mMainView, SLOT(newEvent(QDateTime)));
436 436
437 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 437 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
438 mMainView, SLOT(showIncidence(Incidence *))); 438 mMainView, SLOT(showIncidence(Incidence *)));
439 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 439 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
440 mMainView, SLOT(editIncidence(Incidence *))); 440 mMainView, SLOT(editIncidence(Incidence *)));
441 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 441 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
442 mMainView, SLOT(deleteIncidence(Incidence *))); 442 mMainView, SLOT(deleteIncidence(Incidence *)));
443 443
444 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 444 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
445 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 445 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
446 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 446 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
447 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 447 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
448 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 448 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
449 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 449 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
450 450
451 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 451 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
452 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 452 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
453 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 453 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
454 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 454 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
455 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 455 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
456 mMainView, SLOT ( selectWeekNum( int ) ) ); 456 mMainView, SLOT ( selectWeekNum( int ) ) );
457 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 457 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
458 mMainView, SLOT ( showDay( QDate ) ) ); 458 mMainView, SLOT ( showDay( QDate ) ) );
459 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 459 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
460 connect( mMonthView, SIGNAL(nextMonth() ),
461 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) );
462 connect( mMonthView, SIGNAL(prevMonth() ),
463 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
460 mMonthView->updateConfig(); 464 mMonthView->updateConfig();
461 } 465 }
462 466
463 globalFlagBlockAgenda = 1; 467 globalFlagBlockAgenda = 1;
464 //mFlagShowNextxDays = false; 468 //mFlagShowNextxDays = false;
465 // if(mMonthView == mCurrentView) return; 469 // if(mMonthView == mCurrentView) return;
466 mMainView->dateNavigator()->selectMonth(); 470 mMainView->dateNavigator()->selectMonth();
467 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 471 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
468 //mMonthView->showDates(tmpList.first(), tmpList.last()); 472 //mMonthView->showDates(tmpList.first(), tmpList.last());
469 473
470 showView(mMonthView, true ); 474 showView(mMonthView, true );
471 475
472} 476}
473 477
474void KOViewManager::showTodoView() 478void KOViewManager::showTodoView()
475{ 479{
476 //mFlagShowNextxDays = false; 480 //mFlagShowNextxDays = false;
477 if ( !mTodoView ) { 481 if ( !mTodoView ) {
478 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 482 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
479 "KOViewManager::TodoView" ); 483 "KOViewManager::TodoView" );
480 484
481 addView( mTodoView ); 485 addView( mTodoView );
482 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 486 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
483 487
484 // SIGNALS/SLOTS FOR TODO VIEW 488 // SIGNALS/SLOTS FOR TODO VIEW
485 connect( mTodoView, SIGNAL( newTodoSignal() ), 489 connect( mTodoView, SIGNAL( newTodoSignal() ),
486 mMainView, SLOT( newTodo() ) ); 490 mMainView, SLOT( newTodo() ) );
487 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 491 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
488 mMainView, SLOT( newSubTodo( Todo *) ) ); 492 mMainView, SLOT( newSubTodo( Todo *) ) );
489 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 493 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
490 mMainView, SLOT( showTodo( Todo * ) ) ); 494 mMainView, SLOT( showTodo( Todo * ) ) );
491 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 495 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
492 mMainView, SLOT( editTodo( Todo * ) ) ); 496 mMainView, SLOT( editTodo( Todo * ) ) );
493 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 497 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
494 mMainView, SLOT( deleteTodo( Todo * ) ) ); 498 mMainView, SLOT( deleteTodo( Todo * ) ) );
495 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 499 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
496 mMainView, SLOT( purgeCompleted() ) ); 500 mMainView, SLOT( purgeCompleted() ) );
497 501
498 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 502 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
499 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 503 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
500 504
501 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 505 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
502 SLOT( updateConfig() ) ); 506 SLOT( updateConfig() ) );
503 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 507 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
504 SLOT( updateTodo( Todo *, int ) ) ); 508 SLOT( updateTodo( Todo *, int ) ) );
505 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 509 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
506 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 510 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
507 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 511 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
508 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 512 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
509 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 513 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
510 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 514 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
511 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 515 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
512 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 516 mMainView, SLOT ( todo_unsub( Todo * ) ) );
513 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 517 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
514 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 518 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
515 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 519 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
516 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 520 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
517 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 521 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
518 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 522 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
519 KConfig *config = KOGlobals::config(); 523 KConfig *config = KOGlobals::config();
520 mTodoView->restoreLayout(config,"Todo View"); 524 mTodoView->restoreLayout(config,"Todo View");
521 mTodoView->setNavigator( mMainView->dateNavigator() ); 525 mTodoView->setNavigator( mMainView->dateNavigator() );
522 } 526 }
523 527
524 globalFlagBlockAgenda = 1; 528 globalFlagBlockAgenda = 1;
525 showView( mTodoView, true ); 529 showView( mTodoView, true );
526 530
527} 531}
528 532
529void KOViewManager::showJournalView() 533void KOViewManager::showJournalView()
530{ 534{
531 //mFlagShowNextxDays = false; 535 //mFlagShowNextxDays = false;
532 if (!mJournalView) { 536 if (!mJournalView) {
533 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 537 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
534 "KOViewManager::JournalView"); 538 "KOViewManager::JournalView");
535 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 539 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
536 SLOT( updateConfig() ) ); 540 SLOT( updateConfig() ) );
537 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 541 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
538 addView(mJournalView); 542 addView(mJournalView);
539 } 543 }
540 544
541 showView(mJournalView); 545 showView(mJournalView);
542} 546}
543 547
544void KOViewManager::showTimeSpanView() 548void KOViewManager::showTimeSpanView()
545{ 549{
546 //mFlagShowNextxDays = false; 550 //mFlagShowNextxDays = false;
547 if (!mTimeSpanView) { 551 if (!mTimeSpanView) {
548 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 552 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
549 "KOViewManager::TimeSpanView"); 553 "KOViewManager::TimeSpanView");
550 addView(mTimeSpanView); 554 addView(mTimeSpanView);
551 555
552 mTimeSpanView->readSettings(); 556 mTimeSpanView->readSettings();
553 } 557 }
554 558
555 showView(mTimeSpanView); 559 showView(mTimeSpanView);
556} 560}
557 561
558Incidence *KOViewManager::currentSelection() 562Incidence *KOViewManager::currentSelection()
559{ 563{
560 if (!mCurrentView) return 0; 564 if (!mCurrentView) return 0;
561 if ( mCurrentView == mListView ) { 565 if ( mCurrentView == mListView ) {
562 if ( mListView->currentItem() ) 566 if ( mListView->currentItem() )
563 return mListView->currentItem(); 567 return mListView->currentItem();
564 } 568 }
565 return mCurrentView->selectedIncidences().first(); 569 return mCurrentView->selectedIncidences().first();
566} 570}
567 571
568QDate KOViewManager::currentSelectionDate() 572QDate KOViewManager::currentSelectionDate()
569{ 573{
570 QDate qd; 574 QDate qd;
571 if (mCurrentView) { 575 if (mCurrentView) {
572 DateList qvl = mCurrentView->selectedDates(); 576 DateList qvl = mCurrentView->selectedDates();
573 if (!qvl.isEmpty()) qd = qvl.first(); 577 if (!qvl.isEmpty()) qd = qvl.first();
574 } 578 }
575 return qd; 579 return qd;
576} 580}
577 581
578void KOViewManager::addView(KOrg::BaseView *view) 582void KOViewManager::addView(KOrg::BaseView *view)
579{ 583{
580#if QT_VERSION >= 0x030000 584#if QT_VERSION >= 0x030000
581 mMainView->viewStack()->addWidget( view ); 585 mMainView->viewStack()->addWidget( view );
582#else 586#else
583 mMainView->viewStack()->addWidget( view, 1 ); 587 mMainView->viewStack()->addWidget( view, 1 );
584#endif 588#endif
585} 589}
586 590
587void KOViewManager::setDocumentId( const QString &id ) 591void KOViewManager::setDocumentId( const QString &id )
588{ 592{
589 if (mTodoView) mTodoView->setDocumentId( id ); 593 if (mTodoView) mTodoView->setDocumentId( id );
590} 594}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 145b36c..950d2ec 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1919 +1,1919 @@
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
75class KOex2phonePrefs : public QDialog 75class KOex2phonePrefs : public QDialog
76{ 76{
77 public: 77 public:
78 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 78 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
79 QDialog( parent, name, true ) 79 QDialog( parent, name, true )
80 { 80 {
81 setCaption( i18n("Export to phone options") ); 81 setCaption( i18n("Export to phone options") );
82 QVBoxLayout* lay = new QVBoxLayout( this ); 82 QVBoxLayout* lay = new QVBoxLayout( this );
83 lay->setSpacing( 3 ); 83 lay->setSpacing( 3 );
84 lay->setMargin( 3 ); 84 lay->setMargin( 3 );
85 QLabel *lab; 85 QLabel *lab;
86 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 86 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
87 lab->setAlignment (AlignHCenter ); 87 lab->setAlignment (AlignHCenter );
88 QHBox* temphb; 88 QHBox* temphb;
89 temphb = new QHBox( this ); 89 temphb = new QHBox( this );
90 new QLabel( i18n("I/O device: "), temphb ); 90 new QLabel( i18n("I/O device: "), temphb );
91 mPhoneDevice = new QLineEdit( temphb); 91 mPhoneDevice = new QLineEdit( temphb);
92 lay->addWidget( temphb ); 92 lay->addWidget( temphb );
93 temphb = new QHBox( this ); 93 temphb = new QHBox( this );
94 new QLabel( i18n("Connection: "), temphb ); 94 new QLabel( i18n("Connection: "), temphb );
95 mPhoneConnection = new QLineEdit( temphb); 95 mPhoneConnection = new QLineEdit( temphb);
96 lay->addWidget( temphb ); 96 lay->addWidget( temphb );
97 temphb = new QHBox( this ); 97 temphb = new QHBox( this );
98 new QLabel( i18n("Model(opt.): "), temphb ); 98 new QLabel( i18n("Model(opt.): "), temphb );
99 mPhoneModel = new QLineEdit( temphb); 99 mPhoneModel = new QLineEdit( temphb);
100 lay->addWidget( temphb ); 100 lay->addWidget( temphb );
101 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 101 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
102 mWriteBackFuture->setChecked( true ); 102 mWriteBackFuture->setChecked( true );
103 lay->addWidget( mWriteBackFuture ); 103 lay->addWidget( mWriteBackFuture );
104 temphb = new QHBox( this ); 104 temphb = new QHBox( this );
105 new QLabel( i18n("Max. weeks in future: ") , temphb ); 105 new QLabel( i18n("Max. weeks in future: ") , temphb );
106 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 106 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
107 mWriteBackFutureWeeks->setValue( 8 ); 107 mWriteBackFutureWeeks->setValue( 8 );
108 lay->addWidget( temphb ); 108 lay->addWidget( temphb );
109 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 109 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
110 lab->setAlignment (AlignHCenter ); 110 lab->setAlignment (AlignHCenter );
111 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 111 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
112 lay->addWidget( ok ); 112 lay->addWidget( ok );
113 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 113 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
114 lay->addWidget( cancel ); 114 lay->addWidget( cancel );
115 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 115 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
116 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 116 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
117 resize( 220, 240 ); 117 resize( 220, 240 );
118 qApp->processEvents(); 118 qApp->processEvents();
119 int dw = QApplication::desktop()->width(); 119 int dw = QApplication::desktop()->width();
120 int dh = QApplication::desktop()->height(); 120 int dh = QApplication::desktop()->height();
121 move( (dw-width())/2, (dh - height() )/2 ); 121 move( (dw-width())/2, (dh - height() )/2 );
122 } 122 }
123 123
124public: 124public:
125 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 125 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
126 QCheckBox* mWriteBackFuture; 126 QCheckBox* mWriteBackFuture;
127 QSpinBox* mWriteBackFutureWeeks; 127 QSpinBox* mWriteBackFutureWeeks;
128}; 128};
129 129
130int globalFlagBlockStartup; 130int globalFlagBlockStartup;
131MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 131MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
132 QMainWindow( parent, name ) 132 QMainWindow( parent, name )
133{ 133{
134 134
135#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
136 setFont( QFont("Arial"), 14 ); 136 setFont( QFont("Arial"), 14 );
137#endif 137#endif
138 mClosed = false; 138 mClosed = false;
139 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 139 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
140 QString confFile = locateLocal("config","korganizerrc"); 140 QString confFile = locateLocal("config","korganizerrc");
141 QFileInfo finf ( confFile ); 141 QFileInfo finf ( confFile );
142 bool showWarning = !finf.exists(); 142 bool showWarning = !finf.exists();
143 setIcon(SmallIcon( "ko24" ) ); 143 setIcon(SmallIcon( "ko24" ) );
144 mBlockAtStartup = true; 144 mBlockAtStartup = true;
145 mFlagKeyPressed = false; 145 mFlagKeyPressed = false;
146 setCaption("KOrganizer/Pi"); 146 setCaption("KOrganizer/Pi");
147 KOPrefs *p = KOPrefs::instance(); 147 KOPrefs *p = KOPrefs::instance();
148 KPimGlobalPrefs::instance()->setGlobalConfig(); 148 KPimGlobalPrefs::instance()->setGlobalConfig();
149 if ( p->mHourSize > 18 ) 149 if ( p->mHourSize > 18 )
150 p->mHourSize = 18; 150 p->mHourSize = 18;
151 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
154 tbd = Bottom; 154 tbd = Bottom;
155 else 155 else
156 tbd = Top; 156 tbd = Top;
157 } 157 }
158 else { 158 else {
159 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
160 tbd = Right; 160 tbd = Right;
161 else 161 else
162 tbd = Left; 162 tbd = Left;
163 } 163 }
164 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
169 mCalendarModifiedFlag = false; 169 mCalendarModifiedFlag = false;
170 170
171 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 171 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
172 splash->setAlignment ( AlignCenter ); 172 splash->setAlignment ( AlignCenter );
173 setCentralWidget( splash ); 173 setCentralWidget( splash );
174#ifndef DESKTOP_VERSION 174#ifndef DESKTOP_VERSION
175 showMaximized(); 175 showMaximized();
176#endif 176#endif
177 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 177 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
178 setDefaultPreferences(); 178 setDefaultPreferences();
179 mCalendar = new CalendarLocal(); 179 mCalendar = new CalendarLocal();
180 mView = new CalendarView( mCalendar, this,"mCalendar " ); 180 mView = new CalendarView( mCalendar, this,"mCalendar " );
181 mView->hide(); 181 mView->hide();
182 //mView->resize(splash->size() ); 182 //mView->resize(splash->size() );
183 initActions(); 183 initActions();
184 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 184 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
185 mSyncManager->setBlockSave(false); 185 mSyncManager->setBlockSave(false);
186 mView->setSyncManager(mSyncManager); 186 mView->setSyncManager(mSyncManager);
187#ifndef DESKTOP_VERSION 187#ifndef DESKTOP_VERSION
188 iconToolBar->show(); 188 iconToolBar->show();
189 qApp->processEvents(); 189 qApp->processEvents();
190#endif 190#endif
191 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 191 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
192 int vh = height() ; 192 int vh = height() ;
193 int vw = width(); 193 int vw = width();
194 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 194 //qDebug("Toolbar hei %d ",iconToolBar->height() );
195 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 195 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
196 vh -= iconToolBar->height(); 196 vh -= iconToolBar->height();
197 } else { 197 } else {
198 vw -= iconToolBar->height(); 198 vw -= iconToolBar->height();
199 } 199 }
200 //mView->setMaximumSize( splash->size() ); 200 //mView->setMaximumSize( splash->size() );
201 //mView->resize( splash->size() ); 201 //mView->resize( splash->size() );
202 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 202 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
203 mView->readSettings(); 203 mView->readSettings();
204 bool newFile = false; 204 bool newFile = false;
205 if( !QFile::exists( defaultFileName() ) ) { 205 if( !QFile::exists( defaultFileName() ) ) {
206 QFileInfo finfo ( defaultFileName() ); 206 QFileInfo finfo ( defaultFileName() );
207 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 207 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
208 qDebug("oldfile %s ", oldFile.latin1()); 208 qDebug("oldfile %s ", oldFile.latin1());
209 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"; 209 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";
210 finfo.setFile( oldFile ); 210 finfo.setFile( oldFile );
211 if (finfo.exists() ) { 211 if (finfo.exists() ) {
212 KMessageBox::information( this, message); 212 KMessageBox::information( this, message);
213 mView->openCalendar( oldFile ); 213 mView->openCalendar( oldFile );
214 qApp->processEvents(); 214 qApp->processEvents();
215 } else { 215 } else {
216 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 216 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
217 finfo.setFile( oldFile ); 217 finfo.setFile( oldFile );
218 if (finfo.exists() ) { 218 if (finfo.exists() ) {
219 KMessageBox::information( this, message); 219 KMessageBox::information( this, message);
220 mView->openCalendar( oldFile ); 220 mView->openCalendar( oldFile );
221 qApp->processEvents(); 221 qApp->processEvents();
222 } 222 }
223 } 223 }
224 mView->saveCalendar( defaultFileName() ); 224 mView->saveCalendar( defaultFileName() );
225 newFile = true; 225 newFile = true;
226 } 226 }
227 227
228 QTime neededSaveTime = QDateTime::currentDateTime().time(); 228 QTime neededSaveTime = QDateTime::currentDateTime().time();
229 mView->openCalendar( defaultFileName() ); 229 mView->openCalendar( defaultFileName() );
230 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 230 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
231 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 231 qDebug("KO: Calendar loading time: %d ms",msNeeded );
232 232
233 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 233 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
234 KOPrefs::instance()->setCategoryDefaults(); 234 KOPrefs::instance()->setCategoryDefaults();
235 int count = mView->addCategories(); 235 int count = mView->addCategories();
236 } 236 }
237 processIncidenceSelection( 0 ); 237 processIncidenceSelection( 0 );
238 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 238 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
239 SLOT( processIncidenceSelection( Incidence * ) ) ); 239 SLOT( processIncidenceSelection( Incidence * ) ) );
240 connect( mView, SIGNAL( modifiedChanged( bool ) ), 240 connect( mView, SIGNAL( modifiedChanged( bool ) ),
241 SLOT( slotModifiedChanged( bool ) ) ); 241 SLOT( slotModifiedChanged( bool ) ) );
242 242
243 243
244 connect( mView, SIGNAL( tempDisableBR(bool) ), 244 connect( mView, SIGNAL( tempDisableBR(bool) ),
245 SLOT( disableBR(bool) ) ); 245 SLOT( disableBR(bool) ) );
246 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 246 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
247 mView->setModified( false ); 247 mView->setModified( false );
248 mBlockAtStartup = false; 248 mBlockAtStartup = false;
249 mView->setModified( false ); 249 mView->setModified( false );
250 setCentralWidget( mView ); 250 setCentralWidget( mView );
251 globalFlagBlockStartup = 0; 251 globalFlagBlockStartup = 0;
252 mView->show(); 252 mView->show();
253 delete splash; 253 delete splash;
254 if ( newFile ) 254 if ( newFile )
255 mView->updateConfig(); 255 mView->updateConfig();
256 // qApp->processEvents(); 256 // qApp->processEvents();
257 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 257 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
258 //fillSyncMenu(); 258 //fillSyncMenu();
259 259
260 260
261 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 261 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
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( defaultFileName()); 264 mSyncManager->setDefaultFileName( defaultFileName());
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 285
286 mBRdisabled = false; 286 mBRdisabled = false;
287 //toggleBeamReceive(); 287 //toggleBeamReceive();
288} 288}
289MainWindow::~MainWindow() 289MainWindow::~MainWindow()
290{ 290{
291 //qDebug("MainWindow::~MainWindow() "); 291 //qDebug("MainWindow::~MainWindow() ");
292 //save toolbar location 292 //save toolbar location
293 delete mCalendar; 293 delete mCalendar;
294 delete mSyncManager; 294 delete mSyncManager;
295#ifndef DESKTOP_VERSION 295#ifndef DESKTOP_VERSION
296 if ( infrared ) 296 if ( infrared )
297 delete infrared; 297 delete infrared;
298#endif 298#endif
299 299
300 300
301} 301}
302 302
303void MainWindow::disableBR(bool b) 303void MainWindow::disableBR(bool b)
304{ 304{
305#ifndef DESKTOP_VERSION 305#ifndef DESKTOP_VERSION
306 if ( b ) { 306 if ( b ) {
307 if ( infrared ) { 307 if ( infrared ) {
308 toggleBeamReceive(); 308 toggleBeamReceive();
309 mBRdisabled = true; 309 mBRdisabled = true;
310 } 310 }
311 mBRdisabled = true; 311 mBRdisabled = true;
312 } else { 312 } else {
313 if ( mBRdisabled ) { 313 if ( mBRdisabled ) {
314 mBRdisabled = false; 314 mBRdisabled = false;
315 //makes no sense,because other cal ap is probably running 315 //makes no sense,because other cal ap is probably running
316 // toggleBeamReceive(); 316 // toggleBeamReceive();
317 } 317 }
318 } 318 }
319#endif 319#endif
320 320
321} 321}
322bool MainWindow::beamReceiveEnabled() 322bool MainWindow::beamReceiveEnabled()
323{ 323{
324#ifndef DESKTOP_VERSION 324#ifndef DESKTOP_VERSION
325 return ( infrared != 0 ); 325 return ( infrared != 0 );
326#endif 326#endif
327 return false; 327 return false;
328} 328}
329 329
330void MainWindow::toggleBeamReceive() 330void MainWindow::toggleBeamReceive()
331{ 331{
332 if ( mBRdisabled ) 332 if ( mBRdisabled )
333 return; 333 return;
334#ifndef DESKTOP_VERSION 334#ifndef DESKTOP_VERSION
335 if ( infrared ) { 335 if ( infrared ) {
336 qDebug("disable BeamReceive "); 336 qDebug("disable BeamReceive ");
337 delete infrared; 337 delete infrared;
338 infrared = 0; 338 infrared = 0;
339 brAction->setOn(false); 339 brAction->setOn(false);
340 return; 340 return;
341 } 341 }
342 qDebug("enable BeamReceive "); 342 qDebug("enable BeamReceive ");
343 brAction->setOn(true); 343 brAction->setOn(true);
344 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 344 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
345 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 345 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
346#endif 346#endif
347} 347}
348void MainWindow::showMaximized () 348void MainWindow::showMaximized ()
349{ 349{
350#ifndef DESKTOP_VERSION 350#ifndef DESKTOP_VERSION
351 if ( ! globalFlagBlockStartup ) 351 if ( ! globalFlagBlockStartup )
352 if ( mClosed ) 352 if ( mClosed )
353 mView->goToday(); 353 mView->goToday();
354#endif 354#endif
355 QWidget::showMaximized () ; 355 QWidget::showMaximized () ;
356 mClosed = false; 356 mClosed = false;
357} 357}
358void MainWindow::closeEvent( QCloseEvent* ce ) 358void MainWindow::closeEvent( QCloseEvent* ce )
359{ 359{
360 360
361 361
362 362
363 if ( ! KOPrefs::instance()->mAskForQuit ) { 363 if ( ! KOPrefs::instance()->mAskForQuit ) {
364 saveOnClose(); 364 saveOnClose();
365 mClosed = true; 365 mClosed = true;
366 ce->accept(); 366 ce->accept();
367 return; 367 return;
368 368
369 } 369 }
370 370
371 switch( QMessageBox::information( this, "KO/Pi", 371 switch( QMessageBox::information( this, "KO/Pi",
372 i18n("Do you really want\nto close KO/Pi?"), 372 i18n("Do you really want\nto close KO/Pi?"),
373 i18n("Close"), i18n("No"), 373 i18n("Close"), i18n("No"),
374 0, 0 ) ) { 374 0, 0 ) ) {
375 case 0: 375 case 0:
376 saveOnClose(); 376 saveOnClose();
377 mClosed = true; 377 mClosed = true;
378 ce->accept(); 378 ce->accept();
379 break; 379 break;
380 case 1: 380 case 1:
381 ce->ignore(); 381 ce->ignore();
382 break; 382 break;
383 case 2: 383 case 2:
384 384
385 default: 385 default:
386 break; 386 break;
387 } 387 }
388 388
389 389
390} 390}
391 391
392void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 392void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
393{ 393{
394 QDataStream stream( data, IO_ReadOnly ); 394 QDataStream stream( data, IO_ReadOnly );
395 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 395 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
396 //QString datamess; 396 //QString datamess;
397 //qDebug("message "); 397 //qDebug("message ");
398 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 398 qDebug("KO: QCOP message received: %s ", cmsg.data() );
399 399
400 if ( cmsg == "setDocument(QString)" ) { 400 if ( cmsg == "setDocument(QString)" ) {
401 QDataStream stream( data, IO_ReadOnly ); 401 QDataStream stream( data, IO_ReadOnly );
402 QString fileName; 402 QString fileName;
403 stream >> fileName; 403 stream >> fileName;
404 //qDebug("filename %s ", fileName.latin1()); 404 //qDebug("filename %s ", fileName.latin1());
405 showMaximized(); 405 showMaximized();
406 raise(); 406 raise();
407 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 407 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
408 mSyncManager->slotSyncMenu( 1002 ); 408 mSyncManager->slotSyncMenu( 1002 );
409 return; 409 return;
410 } 410 }
411 411
412 if ( cmsg == "-writeFile" ) { 412 if ( cmsg == "-writeFile" ) {
413 // I made from the "-writeFile" an "-writeAlarm" 413 // I made from the "-writeFile" an "-writeAlarm"
414 mView->viewManager()->showWhatsNextView(); 414 mView->viewManager()->showWhatsNextView();
415 mCalendar->checkAlarmForIncidence( 0, true); 415 mCalendar->checkAlarmForIncidence( 0, true);
416 showMaximized(); 416 showMaximized();
417 raise(); 417 raise();
418 return; 418 return;
419 419
420 } 420 }
421 if ( cmsg == "-writeFileSilent" ) { 421 if ( cmsg == "-writeFileSilent" ) {
422 // I made from the "-writeFile" an "-writeAlarm" 422 // I made from the "-writeFile" an "-writeAlarm"
423 // mView->viewManager()->showWhatsNextView(); 423 // mView->viewManager()->showWhatsNextView();
424 mCalendar->checkAlarmForIncidence( 0, true); 424 mCalendar->checkAlarmForIncidence( 0, true);
425 //showMaximized(); 425 //showMaximized();
426 //raise(); 426 //raise();
427 hide(); 427 hide();
428 return; 428 return;
429 } 429 }
430 if ( cmsg == "-newCountdown" ) { 430 if ( cmsg == "-newCountdown" ) {
431 qDebug("newCountdown "); 431 qDebug("newCountdown ");
432 432
433 } 433 }
434 QString msg ; 434 QString msg ;
435 QString allmsg = cmsg; 435 QString allmsg = cmsg;
436 while ( allmsg.length() > 0 ) { 436 while ( allmsg.length() > 0 ) {
437 int nextC = allmsg.find( "-", 1 ); 437 int nextC = allmsg.find( "-", 1 );
438 if ( nextC == -1 ) { 438 if ( nextC == -1 ) {
439 msg = allmsg; 439 msg = allmsg;
440 allmsg = ""; 440 allmsg = "";
441 } else{ 441 } else{
442 msg = allmsg.left( nextC ); 442 msg = allmsg.left( nextC );
443 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 443 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
444 } 444 }
445 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 445 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
446 if ( msg == "-newEvent" ) { 446 if ( msg == "-newEvent" ) {
447 mView->newEvent(); 447 mView->newEvent();
448 } 448 }
449 if ( msg == "-newTodo" ) { 449 if ( msg == "-newTodo" ) {
450 mView->newTodo(); 450 mView->newTodo();
451 451
452 } 452 }
453 if ( msg == "-showWN" ) { 453 if ( msg == "-showWN" ) {
454 mView->viewManager()->showWhatsNextView(); 454 mView->viewManager()->showWhatsNextView();
455 } 455 }
456 if ( msg == "-showTodo" ) { 456 if ( msg == "-showTodo" ) {
457 mView->viewManager()->showTodoView(); 457 mView->viewManager()->showTodoView();
458 } 458 }
459 if ( msg == "-showList" ) { 459 if ( msg == "-showList" ) {
460 mView->viewManager()->showListView(); 460 mView->viewManager()->showListView();
461 } 461 }
462 else if ( msg == "-showDay" ) { 462 else if ( msg == "-showDay" ) {
463 mView->viewManager()->showDayView(); 463 mView->viewManager()->showDayView();
464 } 464 }
465 else if ( msg == "-showWWeek" ) { 465 else if ( msg == "-showWWeek" ) {
466 mView->viewManager()->showWorkWeekView(); 466 mView->viewManager()->showWorkWeekView();
467 } 467 }
468 else if ( msg == "-ringSync" ) { 468 else if ( msg == "-ringSync" ) {
469 mSyncManager->multiSync( false ); 469 mSyncManager->multiSync( false );
470 } 470 }
471 else if ( msg == "-showWeek" ) { 471 else if ( msg == "-showWeek" ) {
472 mView->viewManager()->showWeekView(); 472 mView->viewManager()->showWeekView();
473 } 473 }
474 else if ( msg == "-showTodo" ) { 474 else if ( msg == "-showTodo" ) {
475 mView->viewManager()->showTodoView(); 475 mView->viewManager()->showTodoView();
476 } 476 }
477 else if ( msg == "-showJournal" ) { 477 else if ( msg == "-showJournal" ) {
478 mView->dateNavigator()->selectDates( 1 ); 478 mView->dateNavigator()->selectDates( 1 );
479 mView->dateNavigator()->selectToday(); 479 mView->dateNavigator()->selectToday();
480 mView->viewManager()->showJournalView(); 480 mView->viewManager()->showJournalView();
481 } 481 }
482 else if ( msg == "-showKO" ) { 482 else if ( msg == "-showKO" ) {
483 mView->viewManager()->showNextXView(); 483 mView->viewManager()->showNextXView();
484 } 484 }
485 else if ( msg == "-showWNext" || msg == "nextView()" ) { 485 else if ( msg == "-showWNext" || msg == "nextView()" ) {
486 mView->viewManager()->showWhatsNextView(); 486 mView->viewManager()->showWhatsNextView();
487 } 487 }
488 else if ( msg == "-showNextXView" ) { 488 else if ( msg == "-showNextXView" ) {
489 mView->viewManager()->showNextXView(); 489 mView->viewManager()->showNextXView();
490 } 490 }
491 491
492 492
493 } 493 }
494 494
495 showMaximized(); 495 showMaximized();
496 raise(); 496 raise();
497} 497}
498 498
499QPixmap MainWindow::loadPixmap( QString name ) 499QPixmap MainWindow::loadPixmap( QString name )
500{ 500{
501 return SmallIcon( name ); 501 return SmallIcon( name );
502 502
503} 503}
504void MainWindow::initActions() 504void MainWindow::initActions()
505{ 505{
506 //KOPrefs::instance()->mShowFullMenu 506 //KOPrefs::instance()->mShowFullMenu
507 iconToolBar->clear(); 507 iconToolBar->clear();
508 KOPrefs *p = KOPrefs::instance(); 508 KOPrefs *p = KOPrefs::instance();
509 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 509 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
510 510
511 QPopupMenu *viewMenu = new QPopupMenu( this ); 511 QPopupMenu *viewMenu = new QPopupMenu( this );
512 QPopupMenu *actionMenu = new QPopupMenu( this ); 512 QPopupMenu *actionMenu = new QPopupMenu( this );
513 QPopupMenu *importMenu = new QPopupMenu( this ); 513 QPopupMenu *importMenu = new QPopupMenu( this );
514 selectFilterMenu = new QPopupMenu( this ); 514 selectFilterMenu = new QPopupMenu( this );
515 selectFilterMenu->setCheckable( true ); 515 selectFilterMenu->setCheckable( true );
516 syncMenu = new QPopupMenu( this ); 516 syncMenu = new QPopupMenu( this );
517 configureAgendaMenu = new QPopupMenu( this ); 517 configureAgendaMenu = new QPopupMenu( this );
518 configureToolBarMenu = new QPopupMenu( this ); 518 configureToolBarMenu = new QPopupMenu( this );
519 QPopupMenu *helpMenu = new QPopupMenu( this ); 519 QPopupMenu *helpMenu = new QPopupMenu( this );
520 if ( KOPrefs::instance()->mShowFullMenu ) { 520 if ( KOPrefs::instance()->mShowFullMenu ) {
521 QMenuBar *menuBar1; 521 QMenuBar *menuBar1;
522 menuBar1 = menuBar(); 522 menuBar1 = menuBar();
523 menuBar1->insertItem( i18n("File"), importMenu ); 523 menuBar1->insertItem( i18n("File"), importMenu );
524 menuBar1->insertItem( i18n("View"), viewMenu ); 524 menuBar1->insertItem( i18n("View"), viewMenu );
525 menuBar1->insertItem( i18n("Actions"), actionMenu ); 525 menuBar1->insertItem( i18n("Actions"), actionMenu );
526 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 526 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
527 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 527 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
528 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 528 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
529 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 529 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
530 menuBar1->insertItem( i18n("Help"), helpMenu ); 530 menuBar1->insertItem( i18n("Help"), helpMenu );
531 } else { 531 } else {
532 QPEMenuBar *menuBar1; 532 QPEMenuBar *menuBar1;
533 menuBar1 = new QPEMenuBar( iconToolBar ); 533 menuBar1 = new QPEMenuBar( iconToolBar );
534 QPopupMenu *menuBar = new QPopupMenu( this ); 534 QPopupMenu *menuBar = new QPopupMenu( this );
535 menuBar1->insertItem( i18n("ME"), menuBar); 535 menuBar1->insertItem( i18n("ME"), menuBar);
536 menuBar->insertItem( i18n("File"), importMenu ); 536 menuBar->insertItem( i18n("File"), importMenu );
537 menuBar->insertItem( i18n("View"), viewMenu ); 537 menuBar->insertItem( i18n("View"), viewMenu );
538 menuBar->insertItem( i18n("Actions"), actionMenu ); 538 menuBar->insertItem( i18n("Actions"), actionMenu );
539 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 539 menuBar->insertItem( i18n("Synchronize"), syncMenu );
540 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 540 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
541 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 541 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
542 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 542 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
543 menuBar->insertItem( i18n("Help"), helpMenu ); 543 menuBar->insertItem( i18n("Help"), helpMenu );
544 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 544 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
545 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 545 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
546 } 546 }
547 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 547 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
548 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 548 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
549 549
550 // ****************** 550 // ******************
551 QAction *action; 551 QAction *action;
552 QIconSet icon; 552 QIconSet icon;
553 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 553 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
554 configureToolBarMenu->setCheckable( true ); 554 configureToolBarMenu->setCheckable( true );
555 555
556 QString pathString = ""; 556 QString pathString = "";
557 if ( !p->mToolBarMiniIcons ) { 557 if ( !p->mToolBarMiniIcons ) {
558 if ( QApplication::desktop()->width() < 480 ) 558 if ( QApplication::desktop()->width() < 480 )
559 pathString += "icons16/"; 559 pathString += "icons16/";
560 } else 560 } else
561 pathString += "iconsmini/"; 561 pathString += "iconsmini/";
562 configureAgendaMenu->setCheckable( true ); 562 configureAgendaMenu->setCheckable( true );
563 int iii ; 563 int iii ;
564 for ( iii = 1;iii<= 10 ;++iii ){ 564 for ( iii = 1;iii<= 10 ;++iii ){
565 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 565 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
566 } 566 }
567 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 567 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
568 568
569 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 569 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
570 this, SLOT( showConfigureAgenda( ) ) ); 570 this, SLOT( showConfigureAgenda( ) ) );
571 571
572 icon = loadPixmap( pathString + "configure" ); 572 icon = loadPixmap( pathString + "configure" );
573 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 573 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
574 action->addTo( actionMenu ); 574 action->addTo( actionMenu );
575 connect( action, SIGNAL( activated() ), 575 connect( action, SIGNAL( activated() ),
576 mView, SLOT( edit_options() ) ); 576 mView, SLOT( edit_options() ) );
577 actionMenu->insertSeparator(); 577 actionMenu->insertSeparator();
578 578
579 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 579 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
580 action->addTo( actionMenu ); 580 action->addTo( actionMenu );
581 connect( action, SIGNAL( activated() ), 581 connect( action, SIGNAL( activated() ),
582 mView, SLOT( undo_delete() ) ); 582 mView, SLOT( undo_delete() ) );
583 actionMenu->insertSeparator(); 583 actionMenu->insertSeparator();
584 584
585 icon = loadPixmap( pathString + "newevent" ); 585 icon = loadPixmap( pathString + "newevent" );
586 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 586 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
587 configureToolBarMenu->insertSeparator(); 587 configureToolBarMenu->insertSeparator();
588 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 588 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
589 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 589 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
590 ne_action->addTo( actionMenu ); 590 ne_action->addTo( actionMenu );
591 connect( ne_action, SIGNAL( activated() ), 591 connect( ne_action, SIGNAL( activated() ),
592 mView, SLOT( newEvent() ) ); 592 mView, SLOT( newEvent() ) );
593 icon = loadPixmap( pathString + "newtodo" ); 593 icon = loadPixmap( pathString + "newtodo" );
594 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 594 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
595 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 595 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
596 nt_action->addTo( actionMenu ); 596 nt_action->addTo( actionMenu );
597 connect( nt_action, SIGNAL( activated() ), 597 connect( nt_action, SIGNAL( activated() ),
598 mView, SLOT( newTodo() ) ); 598 mView, SLOT( newTodo() ) );
599 icon = loadPixmap( pathString + "navi" ); 599 icon = loadPixmap( pathString + "navi" );
600 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 600 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
601 action->addTo( viewMenu ); 601 action->addTo( viewMenu );
602 connect( action, SIGNAL( activated() ), 602 connect( action, SIGNAL( activated() ),
603 mView, SLOT( toggleDateNavigatorWidget() ) ); 603 mView, SLOT( toggleDateNavigatorWidget() ) );
604 mToggleNav = action ; 604 mToggleNav = action ;
605 icon = loadPixmap( pathString + "filter" ); 605 icon = loadPixmap( pathString + "filter" );
606 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 606 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
607 action->addTo( viewMenu ); 607 action->addTo( viewMenu );
608 connect( action, SIGNAL( activated() ), 608 connect( action, SIGNAL( activated() ),
609 mView, SLOT( toggleFilter() ) ); 609 mView, SLOT( toggleFilter() ) );
610 mToggleFilter = action; 610 mToggleFilter = action;
611 icon = loadPixmap( pathString + "allday" ); 611 icon = loadPixmap( pathString + "allday" );
612 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 612 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
613 action->addTo( viewMenu ); 613 action->addTo( viewMenu );
614 connect( action, SIGNAL( activated() ), 614 connect( action, SIGNAL( activated() ),
615 mView, SLOT( toggleAllDaySize() ) ); 615 mView, SLOT( toggleAllDaySize() ) );
616 mToggleAllday = action; 616 mToggleAllday = action;
617 617
618 618
619 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 619 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
620 mToggleNav, SLOT( setEnabled ( bool ) ) ); 620 mToggleNav, SLOT( setEnabled ( bool ) ) );
621 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 621 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
622 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 622 mToggleFilter, SLOT( setEnabled ( bool ) ) );
623 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 623 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
624 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 624 mToggleAllday, SLOT( setEnabled ( bool ) ) );
625 625
626 viewMenu->insertSeparator(); 626 viewMenu->insertSeparator();
627 icon = loadPixmap( pathString + "picker" ); 627 icon = loadPixmap( pathString + "picker" );
628 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 628 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
629 action->addTo( viewMenu ); 629 action->addTo( viewMenu );
630 connect( action, SIGNAL( activated() ), 630 connect( action, SIGNAL( activated() ),
631 mView, SLOT( showDatePicker() ) ); 631 mView, SLOT( showDatePicker() ) );
632 action->addTo( iconToolBar ); 632 action->addTo( iconToolBar );
633 viewMenu->insertSeparator(); 633 viewMenu->insertSeparator();
634 icon = loadPixmap( pathString + "list" ); 634 icon = loadPixmap( pathString + "list" );
635 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 635 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
636 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 636 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
637 showlist_action->addTo( viewMenu ); 637 showlist_action->addTo( viewMenu );
638 connect( showlist_action, SIGNAL( activated() ), 638 connect( showlist_action, SIGNAL( activated() ),
639 mView->viewManager(), SLOT( showListView() ) ); 639 mView->viewManager(), SLOT( showListView() ) );
640 640
641 641
642 icon = loadPixmap( pathString + "day" ); 642 icon = loadPixmap( pathString + "day" );
643 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 643 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
644 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 644 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
645 day1_action->addTo( viewMenu ); 645 day1_action->addTo( viewMenu );
646 // action->addTo( toolBar ); 646 // action->addTo( toolBar );
647 connect( day1_action, SIGNAL( activated() ), 647 connect( day1_action, SIGNAL( activated() ),
648 mView->viewManager(), SLOT( showDayView() ) ); 648 mView->viewManager(), SLOT( showDayView() ) );
649 649
650 icon = loadPixmap( pathString + "workweek" ); 650 icon = loadPixmap( pathString + "workweek" );
651 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 651 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
652 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 652 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
653 day5_action->addTo( viewMenu ); 653 day5_action->addTo( viewMenu );
654 connect( day5_action, SIGNAL( activated() ), 654 connect( day5_action, SIGNAL( activated() ),
655 mView->viewManager(), SLOT( showWorkWeekView() ) ); 655 mView->viewManager(), SLOT( showWorkWeekView() ) );
656 656
657 icon = loadPixmap( pathString + "week" ); 657 icon = loadPixmap( pathString + "week" );
658 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 658 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
659 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 659 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
660 day7_action->addTo( viewMenu ); 660 day7_action->addTo( viewMenu );
661 connect( day7_action, SIGNAL( activated() ), 661 connect( day7_action, SIGNAL( activated() ),
662 mView->viewManager(), SLOT( showWeekView() ) ); 662 mView->viewManager(), SLOT( showWeekView() ) );
663 663
664 icon = loadPixmap( pathString + "month" ); 664 icon = loadPixmap( pathString + "month" );
665 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 665 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
666 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 666 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
667 month_action->addTo( viewMenu ); 667 month_action->addTo( viewMenu );
668 connect( month_action, SIGNAL( activated() ), 668 connect( month_action, SIGNAL( activated() ),
669 mView->viewManager(), SLOT( showMonthView() ) ); 669 mView->viewManager(), SLOT( showMonthView() ) );
670 670
671 icon = loadPixmap( pathString + "todo" ); 671 icon = loadPixmap( pathString + "todo" );
672 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 672 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
673 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 673 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
674 todoview_action->addTo( viewMenu ); 674 todoview_action->addTo( viewMenu );
675 connect( todoview_action, SIGNAL( activated() ), 675 connect( todoview_action, SIGNAL( activated() ),
676 mView->viewManager(), SLOT( showTodoView() ) ); 676 mView->viewManager(), SLOT( showTodoView() ) );
677 677
678 icon = loadPixmap( pathString + "journal" ); 678 icon = loadPixmap( pathString + "journal" );
679 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 679 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
680 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 680 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
681 viewjournal_action->addTo( viewMenu ); 681 viewjournal_action->addTo( viewMenu );
682 connect( viewjournal_action, SIGNAL( activated() ), 682 connect( viewjournal_action, SIGNAL( activated() ),
683 mView->viewManager(), SLOT( showJournalView() ) ); 683 mView->viewManager(), SLOT( showJournalView() ) );
684 684
685 icon = loadPixmap( pathString + "xdays" ); 685 icon = loadPixmap( pathString + "xdays" );
686 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 686 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
687 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 687 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
688 xdays_action->addTo( viewMenu ); 688 xdays_action->addTo( viewMenu );
689 connect( xdays_action, SIGNAL( activated() ), 689 connect( xdays_action, SIGNAL( activated() ),
690 mView->viewManager(), SLOT( showNextXView() ) ); 690 mView->viewManager(), SLOT( showNextXView() ) );
691 691
692 icon = loadPixmap( pathString + "whatsnext" ); 692 icon = loadPixmap( pathString + "whatsnext" );
693 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 693 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
694 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 694 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
695 whatsnext_action->addTo( viewMenu ); 695 whatsnext_action->addTo( viewMenu );
696 connect( whatsnext_action, SIGNAL( activated() ), 696 connect( whatsnext_action, SIGNAL( activated() ),
697 mView->viewManager(), SLOT( showWhatsNextView() ) ); 697 mView->viewManager(), SLOT( showWhatsNextView() ) );
698 698
699#if 0 699#if 0
700 action = new QAction( "view_timespan", "Time Span", 0, this ); 700 action = new QAction( "view_timespan", "Time Span", 0, this );
701 action->addTo( viewMenu ); 701 action->addTo( viewMenu );
702 connect( action, SIGNAL( activated() ), 702 connect( action, SIGNAL( activated() ),
703 mView->viewManager(), SLOT( showTimeSpanView() ) ); 703 mView->viewManager(), SLOT( showTimeSpanView() ) );
704#endif 704#endif
705 705
706 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 706 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
707 this ); 707 this );
708 mNewSubTodoAction->addTo( actionMenu ); 708 mNewSubTodoAction->addTo( actionMenu );
709 connect( mNewSubTodoAction, SIGNAL( activated() ), 709 connect( mNewSubTodoAction, SIGNAL( activated() ),
710 mView, SLOT( newSubTodo() ) ); 710 mView, SLOT( newSubTodo() ) );
711 711
712 actionMenu->insertSeparator(); 712 actionMenu->insertSeparator();
713 713
714 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 714 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
715 mShowAction->addTo( actionMenu ); 715 mShowAction->addTo( actionMenu );
716 connect( mShowAction, SIGNAL( activated() ), 716 connect( mShowAction, SIGNAL( activated() ),
717 mView, SLOT( showIncidence() ) ); 717 mView, SLOT( showIncidence() ) );
718 718
719 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 719 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
720 mEditAction->addTo( actionMenu ); 720 mEditAction->addTo( actionMenu );
721 connect( mEditAction, SIGNAL( activated() ), 721 connect( mEditAction, SIGNAL( activated() ),
722 mView, SLOT( editIncidence() ) ); 722 mView, SLOT( editIncidence() ) );
723 723
724 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 724 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
725 mDeleteAction->addTo( actionMenu ); 725 mDeleteAction->addTo( actionMenu );
726 connect( mDeleteAction, SIGNAL( activated() ), 726 connect( mDeleteAction, SIGNAL( activated() ),
727 mView, SLOT( deleteIncidence() ) ); 727 mView, SLOT( deleteIncidence() ) );
728 728
729 729
730 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 730 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
731 mCloneAction->addTo( actionMenu ); 731 mCloneAction->addTo( actionMenu );
732 connect( mCloneAction, SIGNAL( activated() ), 732 connect( mCloneAction, SIGNAL( activated() ),
733 mView, SLOT( cloneIncidence() ) ); 733 mView, SLOT( cloneIncidence() ) );
734 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 734 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
735 mMoveAction->addTo( actionMenu ); 735 mMoveAction->addTo( actionMenu );
736 connect( mMoveAction, SIGNAL( activated() ), 736 connect( mMoveAction, SIGNAL( activated() ),
737 mView, SLOT( moveIncidence() ) ); 737 mView, SLOT( moveIncidence() ) );
738 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 738 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
739 mBeamAction->addTo( actionMenu ); 739 mBeamAction->addTo( actionMenu );
740 connect( mBeamAction, SIGNAL( activated() ), 740 connect( mBeamAction, SIGNAL( activated() ),
741 mView, SLOT( beamIncidence() ) ); 741 mView, SLOT( beamIncidence() ) );
742 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 742 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
743 mCancelAction->addTo( actionMenu ); 743 mCancelAction->addTo( actionMenu );
744 connect( mCancelAction, SIGNAL( activated() ), 744 connect( mCancelAction, SIGNAL( activated() ),
745 mView, SLOT( toggleCancelIncidence() ) ); 745 mView, SLOT( toggleCancelIncidence() ) );
746 746
747 actionMenu->insertSeparator(); 747 actionMenu->insertSeparator();
748 748
749 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 749 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
750 this ); 750 this );
751 action->addTo( actionMenu ); 751 action->addTo( actionMenu );
752 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 752 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
753 753
754 icon = loadPixmap( pathString + "search" ); 754 icon = loadPixmap( pathString + "search" );
755 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 755 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
756 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 756 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
757 search_action->addTo( actionMenu ); 757 search_action->addTo( actionMenu );
758 connect( search_action, SIGNAL( activated() ), 758 connect( search_action, SIGNAL( activated() ),
759 mView->dialogManager(), SLOT( showSearchDialog() ) ); 759 mView->dialogManager(), SLOT( showSearchDialog() ) );
760 760
761 icon = loadPixmap( pathString + "today" ); 761 icon = loadPixmap( pathString + "today" );
762 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 762 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
763 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 763 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
764 today_action->addTo( actionMenu ); 764 today_action->addTo( actionMenu );
765 connect( today_action, SIGNAL( activated() ), 765 connect( today_action, SIGNAL( activated() ),
766 mView, SLOT( goToday() ) ); 766 mView, SLOT( goToday() ) );
767 767
768 if ( KOPrefs::instance()->mShowFullMenu ) { 768 if ( KOPrefs::instance()->mShowFullMenu ) {
769 actionMenu->insertSeparator(); 769 actionMenu->insertSeparator();
770 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 770 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
771 771
772 } 772 }
773 // actionMenu->insertSeparator(); 773 // actionMenu->insertSeparator();
774 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 774 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
775 this ); 775 this );
776 action->addTo( importMenu ); 776 action->addTo( importMenu );
777 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 777 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
778 action = new QAction( "import_quick", i18n("Import last file"), 0, 778 action = new QAction( "import_quick", i18n("Import last file"), 0,
779 this ); 779 this );
780 action->addTo( importMenu ); 780 action->addTo( importMenu );
781 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 781 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
782 importMenu->insertSeparator(); 782 importMenu->insertSeparator();
783 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 783 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
784 this ); 784 this );
785 action->addTo( importMenu ); 785 action->addTo( importMenu );
786 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 786 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
787#ifndef DESKTOP_VERSION 787#ifndef DESKTOP_VERSION
788 importMenu->insertSeparator(); 788 importMenu->insertSeparator();
789 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 789 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
790 this ); 790 this );
791 action->addTo( importMenu ); 791 action->addTo( importMenu );
792 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 792 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
793#else 793#else
794#ifdef _OL_IMPORT_ 794#ifdef _OL_IMPORT_
795 importMenu->insertSeparator(); 795 importMenu->insertSeparator();
796 action = new QAction( "import_ol", i18n("Import from OL"), 0, 796 action = new QAction( "import_ol", i18n("Import from OL"), 0,
797 this ); 797 this );
798 action->addTo( importMenu ); 798 action->addTo( importMenu );
799 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 799 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
800#endif 800#endif
801#endif 801#endif
802 802
803 importMenu->insertSeparator(); 803 importMenu->insertSeparator();
804 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 804 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
805 this ); 805 this );
806 action->addTo( importMenu ); 806 action->addTo( importMenu );
807 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 807 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
808 808
809 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 809 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
810 this ); 810 this );
811 action->addTo( importMenu ); 811 action->addTo( importMenu );
812 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 812 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
813 813
814 importMenu->insertSeparator(); 814 importMenu->insertSeparator();
815 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 815 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
816 this ); 816 this );
817 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 817 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
818 818
819 819
820 //LR 820 //LR
821 QPopupMenu *ex2phone = new QPopupMenu( this ); 821 QPopupMenu *ex2phone = new QPopupMenu( this );
822 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 822 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
823 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 823 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
824 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 824 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
825 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 825 importMenu->insertItem( i18n("Export to phone"), ex2phone );
826 826
827 importMenu->insertSeparator(); 827 importMenu->insertSeparator();
828 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 828 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
829 this ); 829 this );
830 action->addTo( importMenu ); 830 action->addTo( importMenu );
831 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 831 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
832#ifndef DESKTOP_VERSION 832#ifndef DESKTOP_VERSION
833 importMenu->insertSeparator(); 833 importMenu->insertSeparator();
834 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 834 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
835 this ); 835 this );
836 brAction->addTo( importMenu ); 836 brAction->addTo( importMenu );
837 brAction->setToggleAction (true ) ; 837 brAction->setToggleAction (true ) ;
838 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 838 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
839 839
840 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 840 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
841 this ); 841 this );
842 action->addTo( importMenu ); 842 action->addTo( importMenu );
843 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 843 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
844 844
845 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 845 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
846 this ); 846 this );
847 action->addTo( importMenu ); 847 action->addTo( importMenu );
848 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 848 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
849#else 849#else
850 importMenu->insertSeparator(); 850 importMenu->insertSeparator();
851 icon = loadPixmap( pathString + "print" ); 851 icon = loadPixmap( pathString + "print" );
852 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 852 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
853 action->addTo( importMenu ); 853 action->addTo( importMenu );
854 connect( action, SIGNAL( activated() ), 854 connect( action, SIGNAL( activated() ),
855 this, SLOT( printCal() ) ); 855 this, SLOT( printCal() ) );
856 856
857 icon = loadPixmap( pathString + "print" ); 857 icon = loadPixmap( pathString + "print" );
858 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 858 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
859 action->addTo( importMenu ); 859 action->addTo( importMenu );
860 connect( action, SIGNAL( activated() ), 860 connect( action, SIGNAL( activated() ),
861 this, SLOT( printSel() ) ); 861 this, SLOT( printSel() ) );
862 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 862 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
863 action->addTo( importMenu ); 863 action->addTo( importMenu );
864 connect( action, SIGNAL( activated() ), 864 connect( action, SIGNAL( activated() ),
865 mView->viewManager(), SIGNAL( printWNV() ) ); 865 mView->viewManager(), SIGNAL( printWNV() ) );
866#endif 866#endif
867 importMenu->insertSeparator(); 867 importMenu->insertSeparator();
868 action = new QAction( "beam all", i18n("Save"), 0, 868 action = new QAction( "beam all", i18n("Save"), 0,
869 this ); 869 this );
870 action->addTo( importMenu ); 870 action->addTo( importMenu );
871 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 871 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
872 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 872 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
873 this ); 873 this );
874 action->addTo( importMenu ); 874 action->addTo( importMenu );
875 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 875 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
876 876
877 //menuBar->insertItem( "Configure",configureMenu ); 877 //menuBar->insertItem( "Configure",configureMenu );
878 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 878 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
879 icon = loadPixmap( "korganizer/korganizer" ); 879 icon = loadPixmap( "korganizer/korganizer" );
880 880
881 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 881 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
882 action->addTo( helpMenu ); 882 action->addTo( helpMenu );
883 connect( action, SIGNAL( activated() ), 883 connect( action, SIGNAL( activated() ),
884 SLOT( whatsNew() ) ); 884 SLOT( whatsNew() ) );
885 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 885 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
886 action->addTo( helpMenu ); 886 action->addTo( helpMenu );
887 connect( action, SIGNAL( activated() ), 887 connect( action, SIGNAL( activated() ),
888 SLOT( features() ) ); 888 SLOT( features() ) );
889 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 889 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
890 action->addTo( helpMenu ); 890 action->addTo( helpMenu );
891 connect( action, SIGNAL( activated() ), 891 connect( action, SIGNAL( activated() ),
892 SLOT( keyBindings() ) ); 892 SLOT( keyBindings() ) );
893 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 893 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
894 action->addTo( helpMenu ); 894 action->addTo( helpMenu );
895 connect( action, SIGNAL( activated() ), 895 connect( action, SIGNAL( activated() ),
896 SLOT( synchowto() ) ); 896 SLOT( synchowto() ) );
897 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 897 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
898 action->addTo( helpMenu ); 898 action->addTo( helpMenu );
899 connect( action, SIGNAL( activated() ), 899 connect( action, SIGNAL( activated() ),
900 SLOT( kdesynchowto() ) ); 900 SLOT( kdesynchowto() ) );
901 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 901 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
902 action->addTo( helpMenu ); 902 action->addTo( helpMenu );
903 connect( action, SIGNAL( activated() ), 903 connect( action, SIGNAL( activated() ),
904 SLOT( multisynchowto() ) ); 904 SLOT( multisynchowto() ) );
905 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 905 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
906 action->addTo( helpMenu ); 906 action->addTo( helpMenu );
907 connect( action, SIGNAL( activated() ), 907 connect( action, SIGNAL( activated() ),
908 SLOT( aboutAutoSaving() ) ); 908 SLOT( aboutAutoSaving() ) );
909 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 909 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
910 action->addTo( helpMenu ); 910 action->addTo( helpMenu );
911 connect( action, SIGNAL( activated() ), 911 connect( action, SIGNAL( activated() ),
912 SLOT( aboutKnownBugs() ) ); 912 SLOT( aboutKnownBugs() ) );
913 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 913 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
914 action->addTo( helpMenu ); 914 action->addTo( helpMenu );
915 connect( action, SIGNAL( activated() ), 915 connect( action, SIGNAL( activated() ),
916 SLOT( usertrans() ) ); 916 SLOT( usertrans() ) );
917 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 917 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
918 action->addTo( helpMenu ); 918 action->addTo( helpMenu );
919 connect( action, SIGNAL( activated() ), 919 connect( action, SIGNAL( activated() ),
920 SLOT( faq() ) ); 920 SLOT( faq() ) );
921 action = new QAction( "licence", i18n("Licence..."), 0, this ); 921 action = new QAction( "licence", i18n("Licence..."), 0, this );
922 action->addTo( helpMenu ); 922 action->addTo( helpMenu );
923 connect( action, SIGNAL( activated() ), 923 connect( action, SIGNAL( activated() ),
924 SLOT( licence() ) ); 924 SLOT( licence() ) );
925 action = new QAction( "about", i18n("About..."), 0, this ); 925 action = new QAction( "about", i18n("About..."), 0, this );
926 action->addTo( helpMenu ); 926 action->addTo( helpMenu );
927 connect( action, SIGNAL( activated() ), 927 connect( action, SIGNAL( activated() ),
928 SLOT( about() ) ); 928 SLOT( about() ) );
929 //menuBar->insertSeparator(); 929 //menuBar->insertSeparator();
930 930
931 // ****************************************************** 931 // ******************************************************
932 // menubar icons 932 // menubar icons
933 933
934 934
935 iconToolBar->setHorizontalStretchable (true ); 935 iconToolBar->setHorizontalStretchable (true );
936 //menuBar->insertItem( iconToolBar ); 936 //menuBar->insertItem( iconToolBar );
937 //xdays_action 937 //xdays_action
938 if (p-> mShowIconNewEvent) 938 if (p-> mShowIconNewEvent)
939 ne_action->addTo( iconToolBar ); 939 ne_action->addTo( iconToolBar );
940 if (p->mShowIconNewTodo ) 940 if (p->mShowIconNewTodo )
941 nt_action->addTo( iconToolBar ); 941 nt_action->addTo( iconToolBar );
942 if (p-> mShowIconSearch) 942 if (p-> mShowIconSearch)
943 search_action->addTo( iconToolBar ); 943 search_action->addTo( iconToolBar );
944 if (p-> mShowIconNext) 944 if (p-> mShowIconNext)
945 whatsnext_action->addTo( iconToolBar ); 945 whatsnext_action->addTo( iconToolBar );
946 if (p-> mShowIconNextDays) 946 if (p-> mShowIconNextDays)
947 xdays_action->addTo( iconToolBar ); 947 xdays_action->addTo( iconToolBar );
948 if (p-> mShowIconList) 948 if (p-> mShowIconList)
949 showlist_action->addTo( iconToolBar ); 949 showlist_action->addTo( iconToolBar );
950 if (p-> mShowIconDay1) 950 if (p-> mShowIconDay1)
951 day1_action->addTo( iconToolBar ); 951 day1_action->addTo( iconToolBar );
952 if (p-> mShowIconDay5) 952 if (p-> mShowIconDay5)
953 day5_action->addTo( iconToolBar ); 953 day5_action->addTo( iconToolBar );
954 if (p-> mShowIconDay7) 954 if (p-> mShowIconDay7)
955 day7_action->addTo( iconToolBar ); 955 day7_action->addTo( iconToolBar );
956 if (p-> mShowIconMonth) 956 if (p-> mShowIconMonth)
957 month_action->addTo( iconToolBar ); 957 month_action->addTo( iconToolBar );
958 if (p-> mShowIconTodoview) 958 if (p-> mShowIconTodoview)
959 todoview_action->addTo( iconToolBar ); 959 todoview_action->addTo( iconToolBar );
960 if (p-> mShowIconJournal) 960 if (p-> mShowIconJournal)
961 viewjournal_action->addTo( iconToolBar ); 961 viewjournal_action->addTo( iconToolBar );
962 icon = loadPixmap( pathString + "2leftarrowB" ); 962 icon = loadPixmap( pathString + "2leftarrowB" );
963 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 963 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
964 if (p-> mShowIconBackFast) { 964 if (p-> mShowIconBackFast) {
965 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 965 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
966 connect( action, SIGNAL( activated() ), 966 connect( action, SIGNAL( activated() ),
967 mView, SLOT( goPreviousMonth() ) ); 967 mView, SLOT( goPreviousMonth() ) );
968 action->addTo( iconToolBar ); 968 action->addTo( iconToolBar );
969 } 969 }
970 icon = loadPixmap( pathString + "1leftarrowB" ); 970 icon = loadPixmap( pathString + "1leftarrowB" );
971 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 971 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
972 if (p-> mShowIconBack) { 972 if (p-> mShowIconBack) {
973 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 973 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
974 connect( action, SIGNAL( activated() ), 974 connect( action, SIGNAL( activated() ),
975 mView, SLOT( goPrevious() ) ); 975 mView, SLOT( goPrevious() ) );
976 action->addTo( iconToolBar ); 976 action->addTo( iconToolBar );
977 } 977 }
978 if (p-> mShowIconToday) 978 if (p-> mShowIconToday)
979 today_action->addTo( iconToolBar ); 979 today_action->addTo( iconToolBar );
980 icon = loadPixmap( pathString + "1rightarrowB" ); 980 icon = loadPixmap( pathString + "1rightarrowB" );
981 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 981 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
982 if (p-> mShowIconForward) { 982 if (p-> mShowIconForward) {
983 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 983 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
984 connect( action, SIGNAL( activated() ), 984 connect( action, SIGNAL( activated() ),
985 mView, SLOT( goNext() ) ); 985 mView, SLOT( goNext() ) );
986 action->addTo( iconToolBar ); 986 action->addTo( iconToolBar );
987 } 987 }
988 icon = loadPixmap( pathString + "2rightarrowB" ); 988 icon = loadPixmap( pathString + "2rightarrowB" );
989 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 989 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
990 if (p-> mShowIconForwardFast) { 990 if (p-> mShowIconForwardFast) {
991 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 991 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
992 connect( action, SIGNAL( activated() ), 992 connect( action, SIGNAL( activated() ),
993 mView, SLOT( goNextMonth() ) ); 993 mView, SLOT( goNextMonth() ) );
994 action->addTo( iconToolBar ); 994 action->addTo( iconToolBar );
995 } 995 }
996 996
997 997
998 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 998 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
999 999
1000 if (p-> mShowIconNewEvent) 1000 if (p-> mShowIconNewEvent)
1001 configureToolBarMenu->setItemChecked( 10, true ); 1001 configureToolBarMenu->setItemChecked( 10, true );
1002 if (p->mShowIconNewTodo ) 1002 if (p->mShowIconNewTodo )
1003 configureToolBarMenu->setItemChecked( 20, true ); 1003 configureToolBarMenu->setItemChecked( 20, true );
1004 if (p-> mShowIconSearch) 1004 if (p-> mShowIconSearch)
1005 configureToolBarMenu->setItemChecked( 120, true ); 1005 configureToolBarMenu->setItemChecked( 120, true );
1006 if (p-> mShowIconList) 1006 if (p-> mShowIconList)
1007 configureToolBarMenu->setItemChecked( 30, true ); 1007 configureToolBarMenu->setItemChecked( 30, true );
1008 if (p-> mShowIconDay1) 1008 if (p-> mShowIconDay1)
1009 configureToolBarMenu->setItemChecked( 40, true ); 1009 configureToolBarMenu->setItemChecked( 40, true );
1010 if (p-> mShowIconDay5) 1010 if (p-> mShowIconDay5)
1011 configureToolBarMenu->setItemChecked( 50, true ); 1011 configureToolBarMenu->setItemChecked( 50, true );
1012 if (p-> mShowIconDay7) 1012 if (p-> mShowIconDay7)
1013 configureToolBarMenu->setItemChecked( 60, true ); 1013 configureToolBarMenu->setItemChecked( 60, true );
1014 if (p-> mShowIconMonth) 1014 if (p-> mShowIconMonth)
1015 configureToolBarMenu->setItemChecked( 70, true ); 1015 configureToolBarMenu->setItemChecked( 70, true );
1016 if (p-> mShowIconTodoview) 1016 if (p-> mShowIconTodoview)
1017 configureToolBarMenu->setItemChecked( 80, true ); 1017 configureToolBarMenu->setItemChecked( 80, true );
1018 if (p-> mShowIconBackFast) 1018 if (p-> mShowIconBackFast)
1019 configureToolBarMenu->setItemChecked( 200, true ); 1019 configureToolBarMenu->setItemChecked( 200, true );
1020 if (p-> mShowIconBack) 1020 if (p-> mShowIconBack)
1021 configureToolBarMenu->setItemChecked( 210, true ); 1021 configureToolBarMenu->setItemChecked( 210, true );
1022 if (p-> mShowIconToday) 1022 if (p-> mShowIconToday)
1023 configureToolBarMenu->setItemChecked( 130, true ); 1023 configureToolBarMenu->setItemChecked( 130, true );
1024 if (p-> mShowIconForward) 1024 if (p-> mShowIconForward)
1025 configureToolBarMenu->setItemChecked( 220, true ); 1025 configureToolBarMenu->setItemChecked( 220, true );
1026 if (p-> mShowIconForwardFast) 1026 if (p-> mShowIconForwardFast)
1027 configureToolBarMenu->setItemChecked( 230, true ); 1027 configureToolBarMenu->setItemChecked( 230, true );
1028 if (p-> mShowIconNextDays) 1028 if (p-> mShowIconNextDays)
1029 configureToolBarMenu->setItemChecked( 100, true ); 1029 configureToolBarMenu->setItemChecked( 100, true );
1030 if (p-> mShowIconNext) 1030 if (p-> mShowIconNext)
1031 configureToolBarMenu->setItemChecked( 110, true ); 1031 configureToolBarMenu->setItemChecked( 110, true );
1032 if (p-> mShowIconJournal) 1032 if (p-> mShowIconJournal)
1033 configureToolBarMenu->setItemChecked( 90, true ); 1033 configureToolBarMenu->setItemChecked( 90, true );
1034 if (p-> mShowIconWhatsThis) 1034 if (p-> mShowIconWhatsThis)
1035 configureToolBarMenu->setItemChecked( 300, true ); 1035 configureToolBarMenu->setItemChecked( 300, true );
1036 1036
1037 QLabel* dummy = new QLabel( iconToolBar ); 1037 QLabel* dummy = new QLabel( iconToolBar );
1038 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1038 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1039 if (!p-> mShowIconStretch) 1039 if (!p-> mShowIconStretch)
1040 iconToolBar->setStretchableWidget ( dummy ) ; 1040 iconToolBar->setStretchableWidget ( dummy ) ;
1041 else 1041 else
1042 configureToolBarMenu->setItemChecked( 5, true ); 1042 configureToolBarMenu->setItemChecked( 5, true );
1043 if (p-> mShowIconWhatsThis) 1043 if (p-> mShowIconWhatsThis)
1044 QWhatsThis::whatsThisButton ( iconToolBar ); 1044 QWhatsThis::whatsThisButton ( iconToolBar );
1045 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1045 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1046 configureAgenda( p->mHourSize ); 1046 configureAgenda( p->mHourSize );
1047 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1047 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1048} 1048}
1049 1049
1050void MainWindow::exportToPhone( int mode ) 1050void MainWindow::exportToPhone( int mode )
1051{ 1051{
1052 1052
1053 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1053 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1054 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1054 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1055 KOex2phonePrefs ex2phone; 1055 KOex2phonePrefs ex2phone;
1056 1056
1057 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1057 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1058 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1058 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1059 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1059 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1060 if ( mode == 1 ) 1060 if ( mode == 1 )
1061 ex2phone.setCaption(i18n("Export complete calendar")); 1061 ex2phone.setCaption(i18n("Export complete calendar"));
1062 if ( mode == 2 ) 1062 if ( mode == 2 )
1063 ex2phone.setCaption(i18n("Export filtered calendar")); 1063 ex2phone.setCaption(i18n("Export filtered calendar"));
1064 1064
1065 if ( !ex2phone.exec() ) { 1065 if ( !ex2phone.exec() ) {
1066 return; 1066 return;
1067 } 1067 }
1068 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1068 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1069 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1069 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1070 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1070 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1071 1071
1072 int inFuture = 0; 1072 int inFuture = 0;
1073 if ( ex2phone.mWriteBackFuture->isChecked() ) 1073 if ( ex2phone.mWriteBackFuture->isChecked() )
1074 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1074 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1075 QPtrList<Incidence> delSel; 1075 QPtrList<Incidence> delSel;
1076 if ( mode == 1 ) 1076 if ( mode == 1 )
1077 delSel = mCalendar->rawIncidences(); 1077 delSel = mCalendar->rawIncidences();
1078 if ( mode == 2 ) 1078 if ( mode == 2 )
1079 delSel = mCalendar->incidences(); 1079 delSel = mCalendar->incidences();
1080 CalendarLocal* cal = new CalendarLocal(); 1080 CalendarLocal* cal = new CalendarLocal();
1081 cal->setLocalTime(); 1081 cal->setLocalTime();
1082 Incidence *incidence = delSel.first(); 1082 Incidence *incidence = delSel.first();
1083 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1083 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1084 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1084 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1085 while ( incidence ) { 1085 while ( incidence ) {
1086 if ( incidence->type() != "Journal" ) { 1086 if ( incidence->type() != "Journal" ) {
1087 bool add = true; 1087 bool add = true;
1088 if ( inFuture ) { 1088 if ( inFuture ) {
1089 QDateTime dt; 1089 QDateTime dt;
1090 if ( incidence->type() == "Todo" ) { 1090 if ( incidence->type() == "Todo" ) {
1091 Todo * t = (Todo*)incidence; 1091 Todo * t = (Todo*)incidence;
1092 if ( t->hasDueDate() ) 1092 if ( t->hasDueDate() )
1093 dt = t->dtDue(); 1093 dt = t->dtDue();
1094 else 1094 else
1095 dt = cur.addSecs( 62 ); 1095 dt = cur.addSecs( 62 );
1096 } 1096 }
1097 else { 1097 else {
1098 bool ok; 1098 bool ok;
1099 dt = incidence->getNextOccurence( cur, &ok ); 1099 dt = incidence->getNextOccurence( cur, &ok );
1100 if ( !ok ) 1100 if ( !ok )
1101 dt = cur.addSecs( -62 ); 1101 dt = cur.addSecs( -62 );
1102 } 1102 }
1103 if ( dt < cur || dt > end ) { 1103 if ( dt < cur || dt > end ) {
1104 add = false; 1104 add = false;
1105 } 1105 }
1106 } 1106 }
1107 if ( add ) { 1107 if ( add ) {
1108 Incidence *in = incidence->clone(); 1108 Incidence *in = incidence->clone();
1109 cal->addIncidence( in ); 1109 cal->addIncidence( in );
1110 } 1110 }
1111 } 1111 }
1112 incidence = delSel.next(); 1112 incidence = delSel.next();
1113 } 1113 }
1114 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1114 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1115 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1115 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1116 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1116 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1117 1117
1118 setCaption( i18n("Writing to phone...")); 1118 setCaption( i18n("Writing to phone..."));
1119 if ( PhoneFormat::writeToPhone( cal ) ) 1119 if ( PhoneFormat::writeToPhone( cal ) )
1120 setCaption( i18n("Export to phone successful!")); 1120 setCaption( i18n("Export to phone successful!"));
1121 else 1121 else
1122 setCaption( i18n("Error exporting to phone!")); 1122 setCaption( i18n("Error exporting to phone!"));
1123 delete cal; 1123 delete cal;
1124} 1124}
1125 1125
1126 1126
1127void MainWindow::setDefaultPreferences() 1127void MainWindow::setDefaultPreferences()
1128{ 1128{
1129 KOPrefs *p = KOPrefs::instance(); 1129 KOPrefs *p = KOPrefs::instance();
1130 1130
1131 p->mCompactDialogs = true; 1131 p->mCompactDialogs = true;
1132 p->mConfirm = true; 1132 p->mConfirm = true;
1133 // p->mEnableQuickTodo = false; 1133 // p->mEnableQuickTodo = false;
1134 1134
1135} 1135}
1136 1136
1137QString MainWindow::resourcePath() 1137QString MainWindow::resourcePath()
1138{ 1138{
1139 return KGlobal::iconLoader()->iconPath(); 1139 return KGlobal::iconLoader()->iconPath();
1140} 1140}
1141 1141
1142void MainWindow::displayText( QString text ,QString cap ) 1142void MainWindow::displayText( QString text ,QString cap )
1143{ 1143{
1144 QDialog dia( this, "name", true ); ; 1144 QDialog dia( this, "name", true ); ;
1145 dia.setCaption( cap ); 1145 dia.setCaption( cap );
1146 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1146 QVBoxLayout* lay = new QVBoxLayout( &dia );
1147 lay->setSpacing( 3 ); 1147 lay->setSpacing( 3 );
1148 lay->setMargin( 3 ); 1148 lay->setMargin( 3 );
1149 QTextBrowser tb ( &dia ); 1149 QTextBrowser tb ( &dia );
1150 lay->addWidget( &tb ); 1150 lay->addWidget( &tb );
1151 tb.setText( text ); 1151 tb.setText( text );
1152#ifdef DESKTOP_VERSION 1152#ifdef DESKTOP_VERSION
1153 dia.resize( 640, 480); 1153 dia.resize( 640, 480);
1154#else 1154#else
1155 dia.showMaximized(); 1155 dia.showMaximized();
1156#endif 1156#endif
1157 dia.exec(); 1157 dia.exec();
1158} 1158}
1159 1159
1160void MainWindow::features() 1160void MainWindow::features()
1161{ 1161{
1162 1162
1163 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1163 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1164} 1164}
1165 1165
1166void MainWindow::usertrans() 1166void MainWindow::usertrans()
1167{ 1167{
1168 1168
1169 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1169 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1170} 1170}
1171 1171
1172void MainWindow::kdesynchowto() 1172void MainWindow::kdesynchowto()
1173{ 1173{
1174 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1174 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1175} 1175}
1176void MainWindow::multisynchowto() 1176void MainWindow::multisynchowto()
1177{ 1177{
1178 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1178 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1179} 1179}
1180void MainWindow::synchowto() 1180void MainWindow::synchowto()
1181{ 1181{
1182 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1182 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1183} 1183}
1184void MainWindow::faq() 1184void MainWindow::faq()
1185{ 1185{
1186 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1186 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1187 1187
1188} 1188}
1189void MainWindow::whatsNew() 1189void MainWindow::whatsNew()
1190{ 1190{
1191 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1191 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1192 1192
1193} 1193}
1194void MainWindow::licence() 1194void MainWindow::licence()
1195{ 1195{
1196 KApplication::showLicence(); 1196 KApplication::showLicence();
1197 1197
1198} 1198}
1199void MainWindow::about() 1199void MainWindow::about()
1200{ 1200{
1201 QString version; 1201 QString version;
1202#include <../version> 1202#include <../version>
1203 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1203 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1204 i18n("KOrganizer/Platform-independent\n") + 1204 i18n("KOrganizer/Platform-independent\n") +
1205 "(KO/Pi) " + version + " - " + 1205 "(KO/Pi) " + version + " - " +
1206 1206
1207#ifdef DESKTOP_VERSION 1207#ifdef DESKTOP_VERSION
1208 i18n("Desktop Edition\n") + 1208 i18n("Desktop Edition\n") +
1209#else 1209#else
1210 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1210 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1211#endif 1211#endif
1212 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1212 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1213} 1213}
1214void MainWindow::keyBindings() 1214void MainWindow::keyBindings()
1215{ 1215{
1216 QString cap = i18n("KO/Pi Keys + Colors"); 1216 QString cap = i18n("KO/Pi Keys + Colors");
1217 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1217 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1218 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1218 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1219 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1219 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1220 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1220 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1221 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1221 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1222 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1222 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1223 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1223 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1224 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1224 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1225 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1225 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1226 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1226 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1227 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1227 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1228 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1228 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1229 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1229 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1230 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1230 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1231 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1231 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1232 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1232 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1233 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1233 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1234 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1234 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1235 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1235 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1236 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1236 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1237 i18n("<p><h3>In agenda view:</h3></p>\n") + 1237 i18n("<p><h3>In agenda view:</h3></p>\n") +
1238 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1238 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1239 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1239 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1240 i18n("<p><h3>In todo view:</h3></p>\n") + 1240 i18n("<p><h3>In todo view:</h3></p>\n") +
1241 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1241 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1242 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1242 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1243 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1243 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1244 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1244 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1245 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1245 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1246 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1246 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1247 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1247 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1248 i18n("<p><h3>In list view:</h3></p>\n") + 1248 i18n("<p><h3>In list view:</h3></p>\n") +
1249 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1249 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1250 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1250 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1251 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1251 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1252 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1252 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1253 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1253 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1254 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1254 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1255 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1255 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1256 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1256 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1257 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1257 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1258 i18n("<p><b>E</b>: Edit item</p>\n") + 1258 i18n("<p><b>E</b>: Edit item</p>\n") +
1259 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1259 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1260 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1260 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1261 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1261 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1262 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1262 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1263 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1263 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1264 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1264 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1265 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1265 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1266 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1266 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1267 i18n("<p><b>White</b>: Item readonly</p>\n"); 1267 i18n("<p><b>White</b>: Item readonly</p>\n");
1268 displayText( text, cap); 1268 displayText( text, cap);
1269} 1269}
1270void MainWindow::aboutAutoSaving() 1270void MainWindow::aboutAutoSaving()
1271{ 1271{
1272 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"); 1272 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");
1273 1273
1274 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1274 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1275 1275
1276} 1276}
1277void MainWindow::aboutKnownBugs() 1277void MainWindow::aboutKnownBugs()
1278{ 1278{
1279 QMessageBox* msg; 1279 QMessageBox* msg;
1280 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1280 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1281 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")+ 1281 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")+
1282 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1282 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1283 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1283 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1284 i18n("\nor report them in the bugtracker on\n") + 1284 i18n("\nor report them in the bugtracker on\n") +
1285 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1285 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1286 QMessageBox::NoIcon, 1286 QMessageBox::NoIcon,
1287 QMessageBox::Ok, 1287 QMessageBox::Ok,
1288 QMessageBox::NoButton, 1288 QMessageBox::NoButton,
1289 QMessageBox::NoButton); 1289 QMessageBox::NoButton);
1290 msg->exec(); 1290 msg->exec();
1291 delete msg; 1291 delete msg;
1292 1292
1293} 1293}
1294 1294
1295QString MainWindow::defaultFileName() 1295QString MainWindow::defaultFileName()
1296{ 1296{
1297 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1297 return locateLocal( "data", "korganizer/mycalendar.ics" );
1298} 1298}
1299QString MainWindow::syncFileName() 1299QString MainWindow::syncFileName()
1300{ 1300{
1301#ifdef DESKTOP_VERSION 1301#ifdef DESKTOP_VERSION
1302 return locateLocal( "tmp", "synccalendar.ics" ); 1302 return locateLocal( "tmp", "synccalendar.ics" );
1303#else 1303#else
1304 return QString( "/tmp/synccalendar.ics" ); 1304 return QString( "/tmp/synccalendar.ics" );
1305#endif 1305#endif
1306} 1306}
1307 1307
1308void MainWindow::processIncidenceSelection( Incidence *incidence ) 1308void MainWindow::processIncidenceSelection( Incidence *incidence )
1309{ 1309{
1310 if ( !incidence ) { 1310 if ( !incidence ) {
1311 enableIncidenceActions( false ); 1311 enableIncidenceActions( false );
1312 1312
1313 mNewSubTodoAction->setEnabled( false ); 1313 mNewSubTodoAction->setEnabled( false );
1314 setCaptionToDates(); 1314 setCaptionToDates();
1315 return; 1315 return;
1316 1316
1317 } 1317 }
1318 1318
1319 //KGlobal::locale()->formatDateTime(nextA, true); 1319 //KGlobal::locale()->formatDateTime(nextA, true);
1320 QString startString = ""; 1320 QString startString = "";
1321 if ( incidence->type() != "Todo" ) { 1321 if ( incidence->type() != "Todo" ) {
1322 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1322 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1323 if ( incidence->doesFloat() ) { 1323 if ( incidence->doesFloat() ) {
1324 startString += ": "+incidence->dtStartDateStr( true ); 1324 startString += ": "+incidence->dtStartDateStr( true );
1325 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1325 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1326 1326
1327 } else { 1327 } else {
1328 startString = ": "+incidence->dtStartStr(true); 1328 startString = ": "+incidence->dtStartStr(true);
1329 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1329 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1330 1330
1331 } 1331 }
1332 1332
1333 } else { 1333 } else {
1334 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1334 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1335 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1335 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1336 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1336 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1337 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1337 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1338 } 1338 }
1339 1339
1340 } 1340 }
1341 else 1341 else
1342 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1342 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1343 if ( !incidence->location().isEmpty() ) 1343 if ( !incidence->location().isEmpty() )
1344 startString += " (" +incidence->location()+")"; 1344 startString += " (" +incidence->location()+")";
1345 setCaption( incidence->summary()+startString); 1345 setCaption( incidence->summary()+startString);
1346 1346
1347 enableIncidenceActions( true ); 1347 enableIncidenceActions( true );
1348 1348
1349 if ( incidence->type() == "Event" ) { 1349 if ( incidence->type() == "Event" ) {
1350 mShowAction->setText( i18n("Show Event...") ); 1350 mShowAction->setText( i18n("Show Event...") );
1351 mEditAction->setText( i18n("Edit Event...") ); 1351 mEditAction->setText( i18n("Edit Event...") );
1352 mDeleteAction->setText( i18n("Delete Event...") ); 1352 mDeleteAction->setText( i18n("Delete Event...") );
1353 1353
1354 mNewSubTodoAction->setEnabled( false ); 1354 mNewSubTodoAction->setEnabled( false );
1355 } else if ( incidence->type() == "Todo" ) { 1355 } else if ( incidence->type() == "Todo" ) {
1356 mShowAction->setText( i18n("Show Todo...") ); 1356 mShowAction->setText( i18n("Show Todo...") );
1357 mEditAction->setText( i18n("Edit Todo...") ); 1357 mEditAction->setText( i18n("Edit Todo...") );
1358 mDeleteAction->setText( i18n("Delete Todo...") ); 1358 mDeleteAction->setText( i18n("Delete Todo...") );
1359 1359
1360 mNewSubTodoAction->setEnabled( true ); 1360 mNewSubTodoAction->setEnabled( true );
1361 } else { 1361 } else {
1362 mShowAction->setText( i18n("Show...") ); 1362 mShowAction->setText( i18n("Show...") );
1363 mShowAction->setText( i18n("Edit...") ); 1363 mShowAction->setText( i18n("Edit...") );
1364 mShowAction->setText( i18n("Delete...") ); 1364 mShowAction->setText( i18n("Delete...") );
1365 1365
1366 mNewSubTodoAction->setEnabled( false ); 1366 mNewSubTodoAction->setEnabled( false );
1367 } 1367 }
1368} 1368}
1369 1369
1370void MainWindow::enableIncidenceActions( bool enabled ) 1370void MainWindow::enableIncidenceActions( bool enabled )
1371{ 1371{
1372 mShowAction->setEnabled( enabled ); 1372 mShowAction->setEnabled( enabled );
1373 mEditAction->setEnabled( enabled ); 1373 mEditAction->setEnabled( enabled );
1374 mDeleteAction->setEnabled( enabled ); 1374 mDeleteAction->setEnabled( enabled );
1375 1375
1376 mCloneAction->setEnabled( enabled ); 1376 mCloneAction->setEnabled( enabled );
1377 mMoveAction->setEnabled( enabled ); 1377 mMoveAction->setEnabled( enabled );
1378 mBeamAction->setEnabled( enabled ); 1378 mBeamAction->setEnabled( enabled );
1379 mCancelAction->setEnabled( enabled ); 1379 mCancelAction->setEnabled( enabled );
1380} 1380}
1381 1381
1382void MainWindow::importOL() 1382void MainWindow::importOL()
1383{ 1383{
1384#ifdef _OL_IMPORT_ 1384#ifdef _OL_IMPORT_
1385 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1385 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1386 id->exec(); 1386 id->exec();
1387 delete id; 1387 delete id;
1388 mView->updateView(); 1388 mView->updateView();
1389#endif 1389#endif
1390} 1390}
1391void MainWindow::importBday() 1391void MainWindow::importBday()
1392{ 1392{
1393 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1393 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1394 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1394 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1395 i18n("Import!"), i18n("Cancel"), 0, 1395 i18n("Import!"), i18n("Cancel"), 0,
1396 0, 1 ); 1396 0, 1 );
1397 if ( result == 0 ) { 1397 if ( result == 0 ) {
1398 mView->importBday(); 1398 mView->importBday();
1399 1399
1400 } 1400 }
1401 1401
1402 1402
1403} 1403}
1404void MainWindow::importQtopia() 1404void MainWindow::importQtopia()
1405{ 1405{
1406#ifndef DESKTOP_VERSION 1406#ifndef DESKTOP_VERSION
1407 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1407 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1408 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"), 1408 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"),
1409 i18n("Import!"), i18n("Cancel"), 0, 1409 i18n("Import!"), i18n("Cancel"), 0,
1410 0, 1 ); 1410 0, 1 );
1411 if ( result == 0 ) { 1411 if ( result == 0 ) {
1412 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1412 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1413 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1413 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1414 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1414 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1415 mView->importQtopia( categories, datebook, todolist ); 1415 mView->importQtopia( categories, datebook, todolist );
1416 } 1416 }
1417#else 1417#else
1418 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1418 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1419 i18n("Not supported \non desktop!\n"), 1419 i18n("Not supported \non desktop!\n"),
1420 i18n("Ok"), i18n("Cancel"), 0, 1420 i18n("Ok"), i18n("Cancel"), 0,
1421 0, 1 ); 1421 0, 1 );
1422 1422
1423#endif 1423#endif
1424} 1424}
1425 1425
1426void MainWindow::saveOnClose() 1426void MainWindow::saveOnClose()
1427{ 1427{
1428 KOPrefs *p = KOPrefs::instance(); 1428 KOPrefs *p = KOPrefs::instance();
1429 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1429 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1430 p->mToolBarUp = iconToolBar->x() > width()/2 || 1430 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1431 iconToolBar->y() > height()/2; 1431 iconToolBar->y() > height()/2;
1432 mView->writeSettings(); 1432 mView->writeSettings();
1433 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1433 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1434 save(); 1434 save();
1435} 1435}
1436void MainWindow::slotModifiedChanged( bool changed ) 1436void MainWindow::slotModifiedChanged( bool changed )
1437{ 1437{
1438 if ( mBlockAtStartup ) 1438 if ( mBlockAtStartup )
1439 return; 1439 return;
1440 int msec; 1440 int msec;
1441 // we store the changes after 1 minute, 1441 // we store the changes after 1 minute,
1442 // and for safety reasons after 10 minutes again 1442 // and for safety reasons after 10 minutes again
1443 if ( !mSyncManager->blockSave() ) 1443 if ( !mSyncManager->blockSave() )
1444 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1444 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1445 else 1445 else
1446 msec = 1000 * 600; 1446 msec = 1000 * 600;
1447 mSaveTimer.start( msec, true ); // 1 minute 1447 mSaveTimer.start( msec, true ); // 1 minute
1448 qDebug("KO: Saving File in %d secs!", msec/1000); 1448 qDebug("KO: Saving File in %d secs!", msec/1000);
1449 mCalendarModifiedFlag = true; 1449 mCalendarModifiedFlag = true;
1450} 1450}
1451void MainWindow::save() 1451void MainWindow::save()
1452{ 1452{
1453 if ( mSyncManager->blockSave() ) 1453 if ( mSyncManager->blockSave() )
1454 return; 1454 return;
1455 mSyncManager->setBlockSave(true); 1455 mSyncManager->setBlockSave(true);
1456 if ( mView->checkFileVersion( defaultFileName()) ) { 1456 if ( mView->checkFileVersion( defaultFileName()) ) {
1457 1457
1458 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1458 QTime neededSaveTime = QDateTime::currentDateTime().time();
1459 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1459 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1460 qDebug("KO: Start saving data to file!"); 1460 qDebug("KO: Start saving data to file!");
1461 mView->saveCalendar( defaultFileName() ); 1461 mView->saveCalendar( defaultFileName() );
1462 1462
1463 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1463 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1464 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1464 qDebug("KO: Needed %d ms for saving.",msNeeded );
1465 QString savemes; 1465 QString savemes;
1466 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1466 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1467 setCaption(savemes); 1467 setCaption(savemes);
1468 } else 1468 } else
1469 setCaption(i18n("Saving cancelled!")); 1469 setCaption(i18n("Saving cancelled!"));
1470 mCalendarModifiedFlag = false; 1470 mCalendarModifiedFlag = false;
1471 mSyncManager->setBlockSave( false ); 1471 mSyncManager->setBlockSave( false );
1472} 1472}
1473 1473
1474void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1474void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1475{ 1475{
1476 if ( !e->isAutoRepeat() ) { 1476 if ( !e->isAutoRepeat() ) {
1477 mFlagKeyPressed = false; 1477 mFlagKeyPressed = false;
1478 } 1478 }
1479} 1479}
1480void MainWindow::keyPressEvent ( QKeyEvent * e ) 1480void MainWindow::keyPressEvent ( QKeyEvent * e )
1481{ 1481{
1482 qApp->processEvents(); 1482 qApp->processEvents();
1483 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1483 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1484 e->ignore(); 1484 e->ignore();
1485 // qDebug(" ignore %d",e->isAutoRepeat() ); 1485 // qDebug(" ignore %d",e->isAutoRepeat() );
1486 return; 1486 return;
1487 } 1487 }
1488 if (! e->isAutoRepeat() ) 1488 if (! e->isAutoRepeat() )
1489 mFlagKeyPressed = true; 1489 mFlagKeyPressed = true;
1490 KOPrefs *p = KOPrefs::instance(); 1490 KOPrefs *p = KOPrefs::instance();
1491 bool showSelectedDates = false; 1491 bool showSelectedDates = false;
1492 int size; 1492 int size;
1493 int pro = 0; 1493 int pro = 0;
1494 //qDebug("MainWindow::keyPressEvent "); 1494 //qDebug("MainWindow::keyPressEvent ");
1495 switch ( e->key() ) { 1495 switch ( e->key() ) {
1496 case Qt::Key_Right: 1496 case Qt::Key_Right:
1497 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1497 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1498 mView->goNextMonth(); 1498 mView->goNextMonth();
1499 else 1499 else
1500 mView->goNext(); 1500 mView->goNext();
1501 showSelectedDates = true; 1501 showSelectedDates = true;
1502 break; 1502 break;
1503 case Qt::Key_Left: 1503 case Qt::Key_Left:
1504 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1504 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1505 mView->goPreviousMonth(); 1505 mView->goPreviousMonth();
1506 else 1506 else
1507 mView->goPrevious(); 1507 mView->goPrevious();
1508 showSelectedDates = true; 1508 showSelectedDates = true;
1509 break; 1509 break;
1510 case Qt::Key_Down: 1510 case Qt::Key_Down:
1511 mView->viewManager()->agendaView()->scrollOneHourDown(); 1511 mView->viewManager()->agendaView()->scrollOneHourDown();
1512 break; 1512 break;
1513 case Qt::Key_Up: 1513 case Qt::Key_Up:
1514 mView->viewManager()->agendaView()->scrollOneHourUp(); 1514 mView->viewManager()->agendaView()->scrollOneHourUp();
1515 break; 1515 break;
1516 case Qt::Key_I: 1516 case Qt::Key_I:
1517 mView->showIncidence(); 1517 mView->showIncidence();
1518 break; 1518 break;
1519 case Qt::Key_Delete: 1519 case Qt::Key_Delete:
1520 case Qt::Key_Backspace: 1520 case Qt::Key_Backspace:
1521 mView->deleteIncidence(); 1521 mView->deleteIncidence();
1522 break; 1522 break;
1523 case Qt::Key_D: 1523 case Qt::Key_D:
1524 mView->viewManager()->showDayView(); 1524 mView->viewManager()->showDayView();
1525 showSelectedDates = true; 1525 showSelectedDates = true;
1526 break; 1526 break;
1527 case Qt::Key_O: 1527 case Qt::Key_O:
1528 mView->toggleFilerEnabled( ); 1528 mView->toggleFilerEnabled( );
1529 break; 1529 break;
1530 case Qt::Key_0: 1530 case Qt::Key_0:
1531 case Qt::Key_1: 1531 case Qt::Key_1:
1532 case Qt::Key_2: 1532 case Qt::Key_2:
1533 case Qt::Key_3: 1533 case Qt::Key_3:
1534 case Qt::Key_4: 1534 case Qt::Key_4:
1535 case Qt::Key_5: 1535 case Qt::Key_5:
1536 case Qt::Key_6: 1536 case Qt::Key_6:
1537 case Qt::Key_7: 1537 case Qt::Key_7:
1538 case Qt::Key_8: 1538 case Qt::Key_8:
1539 case Qt::Key_9: 1539 case Qt::Key_9:
1540 pro = e->key()-48; 1540 pro = e->key()-48;
1541 if ( pro == 0 ) 1541 if ( pro == 0 )
1542 pro = 10; 1542 pro = 10;
1543 if ( e->state() == Qt::ControlButton) 1543 if ( e->state() == Qt::ControlButton)
1544 pro += 10; 1544 pro += 10;
1545 break; 1545 break;
1546 case Qt::Key_M: 1546 case Qt::Key_M:
1547 mView->viewManager()->showMonthView(); 1547 mView->viewManager()->showMonthView();
1548 showSelectedDates = true; 1548 showSelectedDates = true;
1549 break; 1549 break;
1550 case Qt::Key_Insert: 1550 case Qt::Key_Insert:
1551 mView->newEvent(); 1551 mView->newEvent();
1552 break; 1552 break;
1553 case Qt::Key_S : 1553 case Qt::Key_S :
1554 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1554 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1555 mView->newSubTodo(); 1555 mView->newSubTodo();
1556 else 1556 else
1557 mView->dialogManager()->showSearchDialog(); 1557 mView->dialogManager()->showSearchDialog();
1558 break; 1558 break;
1559 case Qt::Key_Y : 1559 case Qt::Key_Y :
1560 case Qt::Key_Z : 1560 case Qt::Key_Z :
1561 mView->viewManager()->showWorkWeekView(); 1561 mView->viewManager()->showWorkWeekView();
1562 showSelectedDates = true; 1562 showSelectedDates = true;
1563 break; 1563 break;
1564 case Qt::Key_U : 1564 case Qt::Key_U :
1565 mView->viewManager()->showWeekView(); 1565 mView->viewManager()->showWeekView();
1566 showSelectedDates = true; 1566 showSelectedDates = true;
1567 break; 1567 break;
1568 case Qt::Key_H : 1568 case Qt::Key_H :
1569 keyBindings(); 1569 keyBindings();
1570 break; 1570 break;
1571 case Qt::Key_W: 1571 case Qt::Key_W:
1572 mView->viewManager()->showWhatsNextView(); 1572 mView->viewManager()->showWhatsNextView();
1573 break; 1573 break;
1574 case Qt::Key_L: 1574 case Qt::Key_L:
1575 mView->viewManager()->showListView(); 1575 mView->viewManager()->showListView();
1576 break; 1576 break;
1577 case Qt::Key_N: 1577 case Qt::Key_N:
1578 mView->viewManager()->showNextXView(); 1578 mView->viewManager()->showNextXView();
1579 showSelectedDates = true; 1579 showSelectedDates = true;
1580 break; 1580 break;
1581 case Qt::Key_V: 1581 case Qt::Key_V:
1582 mView->viewManager()->showTodoView(); 1582 mView->viewManager()->showTodoView();
1583 break; 1583 break;
1584 case Qt::Key_C: 1584 case Qt::Key_C:
1585 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1585 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1586 break; 1586 break;
1587 case Qt::Key_P: 1587 case Qt::Key_P:
1588 mView->showDatePicker( ); 1588 mView->showDatePicker( );
1589 break; 1589 break;
1590 case Qt::Key_F: 1590 case Qt::Key_F:
1591 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1591 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1592 mView->editFilters(); 1592 mView->editFilters();
1593 else 1593 else
1594 mView->toggleFilter(); 1594 mView->toggleFilter();
1595 break; 1595 break;
1596 case Qt::Key_X: 1596 case Qt::Key_X:
1597 mView->toggleDateNavigatorWidget(); 1597 mView->toggleDateNavigatorWidget();
1598 break; 1598 break;
1599 case Qt::Key_Space: 1599 case Qt::Key_Space:
1600 mView->toggleExpand(); 1600 mView->toggleExpand();
1601 break; 1601 break;
1602 case Qt::Key_A: 1602 case Qt::Key_A:
1603 mView->toggleAllDaySize(); 1603 mView->toggleAllDaySize();
1604 break; 1604 break;
1605 case Qt::Key_T: 1605 case Qt::Key_T:
1606 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1606 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1607 mView->newTodo(); 1607 mView->newTodo();
1608 else { 1608 else {
1609 mView->goToday(); 1609 mView->goToday();
1610 showSelectedDates = true; 1610 showSelectedDates = true;
1611 } 1611 }
1612 break; 1612 break;
1613 case Qt::Key_J: 1613 case Qt::Key_J:
1614 mView->viewManager()->showJournalView(); 1614 mView->viewManager()->showJournalView();
1615 break; 1615 break;
1616 case Qt::Key_B: 1616 case Qt::Key_B:
1617 mView->editIncidenceDescription();; 1617 mView->editIncidenceDescription();;
1618 break; 1618 break;
1619 // case Qt::Key_Return: 1619 // case Qt::Key_Return:
1620 case Qt::Key_E: 1620 case Qt::Key_E:
1621 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1621 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1622 mView->newEvent(); 1622 mView->newEvent();
1623 else 1623 else
1624 mView->editIncidence(); 1624 mView->editIncidence();
1625 break; 1625 break;
1626 case Qt::Key_Plus: 1626 case Qt::Key_Plus:
1627 size = p->mHourSize +2; 1627 size = p->mHourSize +2;
1628 if ( size <= 18 ) 1628 if ( size <= 18 )
1629 configureAgenda( size ); 1629 configureAgenda( size );
1630 break; 1630 break;
1631 case Qt::Key_Minus: 1631 case Qt::Key_Minus:
1632 size = p->mHourSize - 2; 1632 size = p->mHourSize - 2;
1633 if ( size >= 4 ) 1633 if ( size >= 4 )
1634 configureAgenda( size ); 1634 configureAgenda( size );
1635 break; 1635 break;
1636 1636
1637 1637
1638 default: 1638 default:
1639 e->ignore(); 1639 e->ignore();
1640 } 1640 }
1641 if ( pro > 0 ) { 1641 if ( pro > 0 ) {
1642 mView->selectFilter( pro-1 ); 1642 mView->selectFilter( pro-1 );
1643 } 1643 }
1644 if ( showSelectedDates ) { 1644 if ( showSelectedDates ) {
1645 ;// setCaptionToDates(); 1645 ;// setCaptionToDates();
1646 } 1646 }
1647 1647
1648} 1648}
1649 1649
1650void MainWindow::fillFilterMenu() 1650void MainWindow::fillFilterMenu()
1651{ 1651{
1652 selectFilterMenu->clear(); 1652 selectFilterMenu->clear();
1653 bool disable = false; 1653 bool disable = false;
1654 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1654 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1655 selectFilterMenu->insertSeparator(); 1655 selectFilterMenu->insertSeparator();
1656 if ( mView->filterView()->filtersEnabled() ) { 1656 if ( mView->filterView()->filtersEnabled() ) {
1657 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1657 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1658 } 1658 }
1659 else { 1659 else {
1660 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1660 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1661 disable = true; 1661 disable = true;
1662 } 1662 }
1663 selectFilterMenu->insertSeparator(); 1663 selectFilterMenu->insertSeparator();
1664 QPtrList<CalFilter> fili = mView->filters(); 1664 QPtrList<CalFilter> fili = mView->filters();
1665 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1665 CalFilter *curfilter = mView->filterView()->selectedFilter();
1666 CalFilter *filter = fili.first(); 1666 CalFilter *filter = fili.first();
1667 int iii = 2; 1667 int iii = 2;
1668 while(filter) { 1668 while(filter) {
1669 selectFilterMenu->insertItem( filter->name(), iii ); 1669 selectFilterMenu->insertItem( filter->name(), iii );
1670 if ( filter == curfilter) 1670 if ( filter == curfilter)
1671 selectFilterMenu->setItemChecked( iii, true ); 1671 selectFilterMenu->setItemChecked( iii, true );
1672 if ( disable ) 1672 if ( disable )
1673 selectFilterMenu->setItemEnabled( iii, false ); 1673 selectFilterMenu->setItemEnabled( iii, false );
1674 filter = fili.next(); 1674 filter = fili.next();
1675 ++iii; 1675 ++iii;
1676 } 1676 }
1677} 1677}
1678void MainWindow::selectFilter( int fil ) 1678void MainWindow::selectFilter( int fil )
1679{ 1679{
1680 if ( fil == 0 ) { 1680 if ( fil == 0 ) {
1681 mView->editFilters( ); 1681 mView->editFilters( );
1682 } else if ( fil == 1 ){ 1682 } else if ( fil == 1 ){
1683 mView->toggleFilerEnabled( ); 1683 mView->toggleFilerEnabled( );
1684 } else { 1684 } else {
1685 mView->selectFilter( fil-2 ); 1685 mView->selectFilter( fil-2 );
1686 } 1686 }
1687} 1687}
1688void MainWindow::configureToolBar( int item ) 1688void MainWindow::configureToolBar( int item )
1689{ 1689{
1690 1690
1691 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1691 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1692 KOPrefs *p = KOPrefs::instance(); 1692 KOPrefs *p = KOPrefs::instance();
1693 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1693 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1694 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1694 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1695 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1695 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1696 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1696 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1697 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1697 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1698 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1698 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1699 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1699 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1700 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1700 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1701 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1701 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1702 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1702 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1703 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1703 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1704 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1704 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1705 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1705 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1706 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1706 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1707 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1707 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1708 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1708 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1709 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1709 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1710 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1710 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1711 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1711 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1712 // initActions(); 1712 // initActions();
1713} 1713}
1714 1714
1715void MainWindow::setCaptionToDates() 1715void MainWindow::setCaptionToDates()
1716{ 1716{
1717 QString selDates; 1717 QString selDates;
1718 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1718 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1719 if (mView->startDate() < mView->endDate() ) 1719 if (mView->startDate() < mView->endDate() )
1720 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1720 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1721 else { 1721 else {
1722 QString addString; 1722 QString addString;
1723 if ( mView->startDate() == QDateTime::currentDateTime().date() ) 1723 if ( mView->startDate() == QDateTime::currentDateTime().date() )
1724 addString = i18n("Today"); 1724 addString = i18n("Today");
1725 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) 1725 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) )
1726 addString = i18n("Tomorrow"); 1726 addString = i18n("Tomorrow");
1727 if ( !addString.isEmpty() ) 1727 if ( !addString.isEmpty() )
1728 selDates = addString+", "+selDates ; 1728 selDates = addString+", "+selDates ;
1729 } 1729 }
1730 setCaption( i18n("Dates: ") + selDates ); 1730 setCaption( i18n("Dates: ") + selDates );
1731 1731
1732} 1732}
1733void MainWindow::showConfigureAgenda( ) 1733void MainWindow::showConfigureAgenda( )
1734{ 1734{
1735 int iii; 1735 int iii;
1736 for ( iii = 1;iii<= 10 ;++iii ){ 1736 for ( iii = 1;iii<= 10 ;++iii ){
1737 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1737 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1738 } 1738 }
1739 configureAgendaMenu->setItemChecked( KOPrefs::instance()->mHourSize, true ); 1739 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1740} 1740}
1741void MainWindow::configureAgenda( int item ) 1741void MainWindow::configureAgenda( int item )
1742{ 1742{
1743 if ( KOPrefs::instance()->mHourSize == item ) 1743 if ( KOPrefs::instance()->mHourSize == item )
1744 return; 1744 return;
1745 KOPrefs::instance()->mHourSize=item; 1745 KOPrefs::instance()->mHourSize=item;
1746 mView->viewManager()->agendaView()->updateConfig(); 1746 mView->viewManager()->agendaView()->updateConfig();
1747} 1747}
1748 1748
1749void MainWindow::saveCalendar() 1749void MainWindow::saveCalendar()
1750{ 1750{
1751 QString fn = KOPrefs::instance()->mLastSaveFile; 1751 QString fn = KOPrefs::instance()->mLastSaveFile;
1752 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1752 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1753 1753
1754 if ( fn == "" ) 1754 if ( fn == "" )
1755 return; 1755 return;
1756 QFileInfo info; 1756 QFileInfo info;
1757 info.setFile( fn ); 1757 info.setFile( fn );
1758 QString mes; 1758 QString mes;
1759 bool createbup = true; 1759 bool createbup = true;
1760 if ( info. exists() ) { 1760 if ( info. exists() ) {
1761 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1761 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1762 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1762 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1763 i18n("Overwrite!"), i18n("Cancel"), 0, 1763 i18n("Overwrite!"), i18n("Cancel"), 0,
1764 0, 1 ); 1764 0, 1 );
1765 if ( result != 0 ) { 1765 if ( result != 0 ) {
1766 createbup = false; 1766 createbup = false;
1767 } 1767 }
1768 } 1768 }
1769 if ( createbup ) { 1769 if ( createbup ) {
1770 mView->saveCalendar( fn ); 1770 mView->saveCalendar( fn );
1771 mes = i18n("KO/Pi:Saved %1").arg(fn); 1771 mes = i18n("KO/Pi:Saved %1").arg(fn);
1772 KOPrefs::instance()->mLastSaveFile = fn; 1772 KOPrefs::instance()->mLastSaveFile = fn;
1773 setCaption(mes); 1773 setCaption(mes);
1774 } 1774 }
1775} 1775}
1776void MainWindow::loadCalendar() 1776void MainWindow::loadCalendar()
1777{ 1777{
1778 1778
1779 QString fn = KOPrefs::instance()->mLastLoadFile; 1779 QString fn = KOPrefs::instance()->mLastLoadFile;
1780 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1780 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1781 1781
1782 if ( fn == "" ) 1782 if ( fn == "" )
1783 return; 1783 return;
1784 QFileInfo info; 1784 QFileInfo info;
1785 info.setFile( fn ); 1785 info.setFile( fn );
1786 QString mess; 1786 QString mess;
1787 bool loadbup = true; 1787 bool loadbup = true;
1788 if ( info. exists() ) { 1788 if ( info. exists() ) {
1789 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1789 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1790 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1790 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1791 mess, 1791 mess,
1792 i18n("Load!"), i18n("Cancel"), 0, 1792 i18n("Load!"), i18n("Cancel"), 0,
1793 0, 1 ); 1793 0, 1 );
1794 if ( result != 0 ) { 1794 if ( result != 0 ) {
1795 loadbup = false; 1795 loadbup = false;
1796 } 1796 }
1797 } else { 1797 } else {
1798 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1798 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1799 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1799 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1800 0, 1 ); 1800 0, 1 );
1801 1801
1802 return; 1802 return;
1803 } 1803 }
1804 if ( loadbup ) { 1804 if ( loadbup ) {
1805 mView->openCalendar( fn ); 1805 mView->openCalendar( fn );
1806 KOPrefs::instance()->mLastLoadFile = fn; 1806 KOPrefs::instance()->mLastLoadFile = fn;
1807 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1807 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1808 setCaption(mess); 1808 setCaption(mess);
1809 } 1809 }
1810 1810
1811} 1811}
1812void MainWindow::quickImportIcal() 1812void MainWindow::quickImportIcal()
1813{ 1813{
1814 importFile( KOPrefs::instance()->mLastImportFile, false ); 1814 importFile( KOPrefs::instance()->mLastImportFile, false );
1815} 1815}
1816void MainWindow::importFile( QString fn, bool quick ) 1816void MainWindow::importFile( QString fn, bool quick )
1817{ 1817{
1818 QFileInfo info; 1818 QFileInfo info;
1819 info.setFile( fn ); 1819 info.setFile( fn );
1820 QString mess; 1820 QString mess;
1821 bool loadbup = true; 1821 bool loadbup = true;
1822 if ( !info. exists() ) { 1822 if ( !info. exists() ) {
1823 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1823 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1824 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1824 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1825 mess ); 1825 mess );
1826 return; 1826 return;
1827 } 1827 }
1828 int result = 0; 1828 int result = 0;
1829 if ( !quick ) { 1829 if ( !quick ) {
1830 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 )); 1830 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 ));
1831 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1831 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1832 mess, 1832 mess,
1833 "Import", "Cancel", 0, 1833 "Import", "Cancel", 0,
1834 0, 1 ); 1834 0, 1 );
1835 } 1835 }
1836 if ( result == 0 ) { 1836 if ( result == 0 ) {
1837 if ( mView->openCalendar( fn, true )) { 1837 if ( mView->openCalendar( fn, true )) {
1838 KOPrefs::instance()->mLastImportFile = fn; 1838 KOPrefs::instance()->mLastImportFile = fn;
1839 setCaption(i18n("Imported file successfully")); 1839 setCaption(i18n("Imported file successfully"));
1840 } else { 1840 } else {
1841 setCaption(i18n("Error importing file")); 1841 setCaption(i18n("Error importing file"));
1842 } 1842 }
1843 } 1843 }
1844} 1844}
1845 1845
1846void MainWindow::importIcal() 1846void MainWindow::importIcal()
1847{ 1847{
1848 1848
1849 QString fn =KOPrefs::instance()->mLastImportFile; 1849 QString fn =KOPrefs::instance()->mLastImportFile;
1850 1850
1851 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1851 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1852 if ( fn == "" ) 1852 if ( fn == "" )
1853 return; 1853 return;
1854 importFile( fn, true ); 1854 importFile( fn, true );
1855 1855
1856} 1856}
1857 1857
1858void MainWindow::exportVCalendar() 1858void MainWindow::exportVCalendar()
1859{ 1859{
1860 QString fn = KOPrefs::instance()->mLastVcalFile; 1860 QString fn = KOPrefs::instance()->mLastVcalFile;
1861 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1861 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1862 if ( fn == "" ) 1862 if ( fn == "" )
1863 return; 1863 return;
1864 QFileInfo info; 1864 QFileInfo info;
1865 info.setFile( fn ); 1865 info.setFile( fn );
1866 QString mes; 1866 QString mes;
1867 bool createbup = true; 1867 bool createbup = true;
1868 if ( info. exists() ) { 1868 if ( info. exists() ) {
1869 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1869 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1870 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1870 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1871 i18n("Overwrite!"), i18n("Cancel"), 0, 1871 i18n("Overwrite!"), i18n("Cancel"), 0,
1872 0, 1 ); 1872 0, 1 );
1873 if ( result != 0 ) { 1873 if ( result != 0 ) {
1874 createbup = false; 1874 createbup = false;
1875 } 1875 }
1876 } 1876 }
1877 if ( createbup ) { 1877 if ( createbup ) {
1878 if ( mView->exportVCalendar( fn ) ) { 1878 if ( mView->exportVCalendar( fn ) ) {
1879 KOPrefs::instance()->mLastVcalFile = fn; 1879 KOPrefs::instance()->mLastVcalFile = fn;
1880 if ( fn.length() > 20 ) 1880 if ( fn.length() > 20 )
1881 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1881 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1882 else 1882 else
1883 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1883 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1884 setCaption(mes); 1884 setCaption(mes);
1885 } 1885 }
1886 } 1886 }
1887 1887
1888} 1888}
1889 1889
1890void MainWindow::syncFileRequest() 1890void MainWindow::syncFileRequest()
1891{ 1891{
1892 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 1892 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
1893 mSyncManager->slotSyncMenu( 999 ); 1893 mSyncManager->slotSyncMenu( 999 );
1894 } 1894 }
1895 save(); 1895 save();
1896} 1896}
1897void MainWindow::getFile( bool success ) 1897void MainWindow::getFile( bool success )
1898{ 1898{
1899 if ( ! success ) { 1899 if ( ! success ) {
1900 setCaption( i18n("Error receiving file. Nothing changed!") ); 1900 setCaption( i18n("Error receiving file. Nothing changed!") );
1901 return; 1901 return;
1902 } 1902 }
1903 mView->openCalendar( defaultFileName() ); 1903 mView->openCalendar( defaultFileName() );
1904 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 1904 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
1905 mSyncManager->slotSyncMenu( 999 ); 1905 mSyncManager->slotSyncMenu( 999 );
1906 } 1906 }
1907 setCaption( i18n("Pi-Sync successful!") ); 1907 setCaption( i18n("Pi-Sync successful!") );
1908} 1908}
1909 1909
1910void MainWindow::printSel( ) 1910void MainWindow::printSel( )
1911{ 1911{
1912 mView->viewManager()->agendaView()->agenda()->printSelection(); 1912 mView->viewManager()->agendaView()->agenda()->printSelection();
1913} 1913}
1914 1914
1915void MainWindow::printCal() 1915void MainWindow::printCal()
1916{ 1916{
1917 mView->print();//mCp->showDialog(); 1917 mView->print();//mCp->showDialog();
1918} 1918}
1919 1919