summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-09-25 02:09:22 (UTC)
committer zautrix <zautrix>2005-09-25 02:09:22 (UTC)
commit3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6 (patch) (unidiff)
tree0d88d48dc1b9198c9c2deed6b55c70deffcfeadd
parent181bc87d92ecc48cb07c288cb2d135d8fde56716 (diff)
downloadkdepimpi-3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6.zip
kdepimpi-3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6.tar.gz
kdepimpi-3bbc14431e854bc3d8870b5ba12d64f6e1af6eb6.tar.bz2
todo timer fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/main.cpp3
-rw-r--r--korganizer/mainwindow.cpp15
-rw-r--r--libkcal/todo.cpp12
3 files changed, 26 insertions, 4 deletions
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index a96f7c2..9410c6a 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -1,114 +1,117 @@
1 1
2 2
3#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qcopchannel_qws.h> 5#include <qcopchannel_qws.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#else 8#else
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qstring.h> 10#include <qstring.h>
11#include <qwindowsstyle.h> 11#include <qwindowsstyle.h>
12#include <qplatinumstyle.h> 12#include <qplatinumstyle.h>
13#include <qsgistyle.h> 13#include <qsgistyle.h>
14#include <stdlib.h> 14#include <stdlib.h>
15#endif 15#endif
16#include <qtextcodec.h> 16#include <qtextcodec.h>
17 17
18#include <qdir.h> 18#include <qdir.h>
19#include <kstandarddirs.h> 19#include <kstandarddirs.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <stdio.h> 21#include <stdio.h>
22#include "mainwindow.h" 22#include "mainwindow.h"
23#include <libkdepim/kpimglobalprefs.h> 23#include <libkdepim/kpimglobalprefs.h>
24void dumpMissing(); 24void dumpMissing();
25 25
26 26
27int main( int argc, char **argv ) 27int main( int argc, char **argv )
28{ 28{
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30 QPEApplication a( argc, argv ); 30 QPEApplication a( argc, argv );
31 a.setKeepRunning (); 31 a.setKeepRunning ();
32#else 32#else
33 QApplication a( argc, argv ); 33 QApplication a( argc, argv );
34 QApplication::setStyle( new QPlatinumStyle ()); 34 QApplication::setStyle( new QPlatinumStyle ());
35#ifdef _WIN32_ 35#ifdef _WIN32_
36 QString hdir ( getenv( "HOME") ); 36 QString hdir ( getenv( "HOME") );
37 if ( hdir.isEmpty() ) { 37 if ( hdir.isEmpty() ) {
38 QString hd ("C:/" ); 38 QString hd ("C:/" );
39 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); 39 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd );
40 if ( QDir::homeDirPath().lower() == hd.lower() ) { 40 if ( QDir::homeDirPath().lower() == hd.lower() ) {
41 _putenv( "HOME=C:"); 41 _putenv( "HOME=C:");
42 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); 42 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) );
43 } 43 }
44 } else { 44 } else {
45 QDir app_dir; 45 QDir app_dir;
46 if ( !app_dir.exists(hdir) ) 46 if ( !app_dir.exists(hdir) )
47 app_dir.mkdir (hdir); 47 app_dir.mkdir (hdir);
48 } 48 }
49#endif 49#endif
50#endif 50#endif
51 bool exitHelp = false; 51 bool exitHelp = false;
52 if ( argc > 1 ) { 52 if ( argc > 1 ) {
53 QString command = argv[1]; 53 QString command = argv[1];
54 if ( command == "-help" ){ 54 if ( command == "-help" ){
55 printf("KO/Pi command line commands:\n"); 55 printf("KO/Pi command line commands:\n");
56 printf(" no command: Start KO/Pi in usual way\n"); 56 printf(" no command: Start KO/Pi in usual way\n");
57 printf(" -help: This output\n"); 57 printf(" -help: This output\n");
58 printf("Next Option: Open or Show after start:\n"); 58 printf("Next Option: Open or Show after start:\n");
59 printf(" -newTodo: New Todo dialog\n"); 59 printf(" -newTodo: New Todo dialog\n");
60 printf(" -newEvent: New Event dialog\n"); 60 printf(" -newEvent: New Event dialog\n");
61 printf(" -showList: List view\n"); 61 printf(" -showList: List view\n");
62 printf(" -showDay: Day view\n"); 62 printf(" -showDay: Day view\n");
63 printf(" -showWWeek: Work Week view\n"); 63 printf(" -showWWeek: Work Week view\n");
64 printf(" -showWeek: Week view\n"); 64 printf(" -showWeek: Week view\n");
65 printf(" -showTodo: Todo view\n"); 65 printf(" -showTodo: Todo view\n");
66 printf(" -showJournal: Journal view\n"); 66 printf(" -showJournal: Journal view\n");
67 printf(" -showKO: Next Days view\n"); 67 printf(" -showKO: Next Days view\n");
68 printf(" -showWNext: What's Next view\n"); 68 printf(" -showWNext: What's Next view\n");
69 printf(" -showNextXView: Next X View\n"); 69 printf(" -showNextXView: Next X View\n");
70 printf(" -new[Y] and -show[X] may be used togehther\n"); 70 printf(" -new[Y] and -show[X] may be used togehther\n");
71 printf(" KO/Pi is exiting now. Bye!\n"); 71 printf(" KO/Pi is exiting now. Bye!\n");
72 exitHelp = true; 72 exitHelp = true;
73 } 73 }
74 } 74 }
75 if ( ! exitHelp ) { 75 if ( ! exitHelp ) {
76 KGlobal::setAppName( "korganizer" ); 76 KGlobal::setAppName( "korganizer" );
77 QString fileName ; 77 QString fileName ;
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 fileName = getenv("QPEDIR"); 79 fileName = getenv("QPEDIR");
80 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 80 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
81#else 81#else
82 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; 82 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
83 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 83 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
84#endif 84#endif
85 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); 85 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
86 86
87 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); 87 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont );
88 KPimGlobalPrefs::instance()->setGlobalConfig(); 88 KPimGlobalPrefs::instance()->setGlobalConfig();
89 MainWindow m; 89 MainWindow m;
90#ifndef DESKTOP_VERSION 90#ifndef DESKTOP_VERSION
91 91
92 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(receiveStart( const QCString&, const QByteArray& ))); 92 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(receiveStart( const QCString&, const QByteArray& )));
93 a.showMainWidget(&m ); 93 a.showMainWidget(&m );
94#else 94#else
95 a.setMainWidget(&m ); 95 a.setMainWidget(&m );
96 m.show(); 96 m.show();
97 //m.resize( 800, 600 ); 97 //m.resize( 800, 600 );
98 //QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 98 //QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
99#endif 99#endif
100 if ( argc > 1 ) { 100 if ( argc > 1 ) {
101 QCString command = argv[1]; 101 QCString command = argv[1];
102 if ( argc > 2 ) 102 if ( argc > 2 )
103 command += argv[2]; 103 command += argv[2];
104 m.recieve(command, QByteArray() ); 104 m.recieve(command, QByteArray() );
105 105
106 } 106 }
107 107
108#ifndef DESKTOP_VERSION
109 QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable );
110#endif
108 a.exec(); 111 a.exec();
109 dumpMissing(); 112 dumpMissing();
110 113
111 KPimGlobalPrefs::instance()->writeConfig(); 114 KPimGlobalPrefs::instance()->writeConfig();
112 } 115 }
113 qDebug("KO: Bye! "); 116 qDebug("KO: Bye! ");
114} 117}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d1e369c..05e5087 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,797 +1,797 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qtopia/alarmserver.h> 27#include <qtopia/alarmserver.h>
28#include <qtopia/qcopenvelope_qws.h> 28#include <qtopia/qcopenvelope_qws.h>
29#include <unistd.h> // for sleep 29//#include <unistd.h> // for sleep
30#else 30#else
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkcal/phoneformat.h> 38#include <libkcal/phoneformat.h>
39#include <libkdepim/ksyncprofile.h> 39#include <libkdepim/ksyncprofile.h>
40#include <libkdepim/phoneaccess.h> 40#include <libkdepim/phoneaccess.h>
41#include <libkcal/kincidenceformatter.h> 41#include <libkcal/kincidenceformatter.h>
42#include <libkdepim/kpimglobalprefs.h> 42#include <libkdepim/kpimglobalprefs.h>
43 43
44#include "calendarview.h" 44#include "calendarview.h"
45#include "koviewmanager.h" 45#include "koviewmanager.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47#include "koagendaview.h" 47#include "koagendaview.h"
48#include "kojournalview.h" 48#include "kojournalview.h"
49#include "koagenda.h" 49#include "koagenda.h"
50#include "kodialogmanager.h" 50#include "kodialogmanager.h"
51#include "kdialogbase.h" 51#include "kdialogbase.h"
52#include "kapplication.h" 52#include "kapplication.h"
53#include "kofilterview.h" 53#include "kofilterview.h"
54#include "kstandarddirs.h" 54#include "kstandarddirs.h"
55#include "koprefs.h" 55#include "koprefs.h"
56#include "kfiledialog.h" 56#include "kfiledialog.h"
57#include "koglobals.h" 57#include "koglobals.h"
58#include "kglobal.h" 58#include "kglobal.h"
59#include "ktoolbar.h" 59#include "ktoolbar.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "externalapphandler.h" 62#include "externalapphandler.h"
63#include <kglobalsettings.h> 63#include <kglobalsettings.h>
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131QPixmap* sgListViewCompletedPix[6]; 131QPixmap* sgListViewCompletedPix[6];
132QPixmap* sgListViewJournalPix; 132QPixmap* sgListViewJournalPix;
133 133
134 134
135int globalFlagBlockStartup; 135int globalFlagBlockStartup;
136MainWindow::MainWindow( QWidget *parent, const char *name ) : 136MainWindow::MainWindow( QWidget *parent, const char *name ) :
137 QMainWindow( parent, name ) 137 QMainWindow( parent, name )
138{ 138{
139 sgListViewCompletedPix[5] = &listviewPix; 139 sgListViewCompletedPix[5] = &listviewPix;
140 sgListViewCompletedPix[0] = &listviewPix0; 140 sgListViewCompletedPix[0] = &listviewPix0;
141 sgListViewCompletedPix[1] = &listviewPix20; 141 sgListViewCompletedPix[1] = &listviewPix20;
142 sgListViewCompletedPix[2] = &listviewPix40; 142 sgListViewCompletedPix[2] = &listviewPix40;
143 sgListViewCompletedPix[3] = &listviewPix60; 143 sgListViewCompletedPix[3] = &listviewPix60;
144 sgListViewCompletedPix[4] = &listviewPix80; 144 sgListViewCompletedPix[4] = &listviewPix80;
145 //int size = 12; 145 //int size = 12;
146 { 146 {
147 sgListViewCompletedPix[5]->resize( 11, 11 ); 147 sgListViewCompletedPix[5]->resize( 11, 11 );
148 sgListViewCompletedPix[5]->fill( Qt::white ); 148 sgListViewCompletedPix[5]->fill( Qt::white );
149 QPainter p ( sgListViewCompletedPix[5] ); 149 QPainter p ( sgListViewCompletedPix[5] );
150 p.drawRect( 0,0,11,11); 150 p.drawRect( 0,0,11,11);
151 p.drawLine ( 2, 5, 4 , 7 ) ; 151 p.drawLine ( 2, 5, 4 , 7 ) ;
152 p.drawLine ( 4 , 7 , 8, 3) ; 152 p.drawLine ( 4 , 7 , 8, 3) ;
153 int iii = 0; 153 int iii = 0;
154 for ( iii = 0; iii < 5; ++iii ) { 154 for ( iii = 0; iii < 5; ++iii ) {
155 sgListViewCompletedPix[iii]->resize( 11, 11 ); 155 sgListViewCompletedPix[iii]->resize( 11, 11 );
156 sgListViewCompletedPix[iii]->fill( Qt::white ); 156 sgListViewCompletedPix[iii]->fill( Qt::white );
157 QPainter p ( sgListViewCompletedPix[iii] ); 157 QPainter p ( sgListViewCompletedPix[iii] );
158 p.drawRect( 0,0,11,11); 158 p.drawRect( 0,0,11,11);
159 if ( iii ) 159 if ( iii )
160 p.fillRect( 1,1,iii*2,9,Qt::gray ); 160 p.fillRect( 1,1,iii*2,9,Qt::gray );
161 } 161 }
162 sgListViewJournalPix = &journalPix; 162 sgListViewJournalPix = &journalPix;
163 sgListViewJournalPix->resize( 11, 11 ); 163 sgListViewJournalPix->resize( 11, 11 );
164 sgListViewJournalPix->fill( Qt::white ); 164 sgListViewJournalPix->fill( Qt::white );
165 { 165 {
166 QPainter p ( sgListViewJournalPix ); 166 QPainter p ( sgListViewJournalPix );
167 p.drawRect( 0,0,11,11); 167 p.drawRect( 0,0,11,11);
168 p.drawLine( 2,3,5,3); 168 p.drawLine( 2,3,5,3);
169 p.drawLine( 2,5,8,5); 169 p.drawLine( 2,5,8,5);
170 p.drawLine( 2,7,6,7); 170 p.drawLine( 2,7,6,7);
171 } 171 }
172 } 172 }
173 mClosed = false; 173 mClosed = false;
174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
175 QString confFile = locateLocal("config","korganizerrc"); 175 QString confFile = locateLocal("config","korganizerrc");
176 QFileInfo finf ( confFile ); 176 QFileInfo finf ( confFile );
177 bool showWarning = !finf.exists(); 177 bool showWarning = !finf.exists();
178 setIcon(SmallIcon( "ko24" ) ); 178 setIcon(SmallIcon( "ko24" ) );
179 mBlockAtStartup = true; 179 mBlockAtStartup = true;
180 mFlagKeyPressed = false; 180 mFlagKeyPressed = false;
181 setCaption("KO/Pi"); 181 setCaption("KO/Pi");
182 KOPrefs *p = KOPrefs::instance(); 182 KOPrefs *p = KOPrefs::instance();
183 //KPimGlobalPrefs::instance()->setGlobalConfig(); 183 //KPimGlobalPrefs::instance()->setGlobalConfig();
184 p->mCurrentDisplayedView = 0; 184 p->mCurrentDisplayedView = 0;
185 if ( p->mHourSize > 22 ) 185 if ( p->mHourSize > 22 )
186 p->mHourSize = 22; 186 p->mHourSize = 22;
187 QMainWindow::ToolBarDock tbd; 187 QMainWindow::ToolBarDock tbd;
188 if ( p->mToolBarHor ) { 188 if ( p->mToolBarHor ) {
189 if ( p->mToolBarUp ) 189 if ( p->mToolBarUp )
190 tbd = Bottom; 190 tbd = Bottom;
191 else 191 else
192 tbd = Top; 192 tbd = Top;
193 } 193 }
194 else { 194 else {
195 if ( p->mToolBarUp ) 195 if ( p->mToolBarUp )
196 tbd = Right; 196 tbd = Right;
197 else 197 else
198 tbd = Left; 198 tbd = Left;
199 } 199 }
200 if ( KOPrefs::instance()->mUseAppColors ) 200 if ( KOPrefs::instance()->mUseAppColors )
201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
202 globalFlagBlockStartup = 1; 202 globalFlagBlockStartup = 1;
203 iconToolBar = new QPEToolBar( this ); 203 iconToolBar = new QPEToolBar( this );
204 addToolBar (iconToolBar , tbd ); 204 addToolBar (iconToolBar , tbd );
205 205
206#ifdef DESKTOP_VERSION 206#ifdef DESKTOP_VERSION
207 if ( KOPrefs::instance()->mShowIconFilter ) 207 if ( KOPrefs::instance()->mShowIconFilter )
208#else 208#else
209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) 209 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) )
210#endif 210#endif
211 211
212{ 212{
213 if ( p->mToolBarHorF ) { 213 if ( p->mToolBarHorF ) {
214 if ( p->mToolBarUpF ) 214 if ( p->mToolBarUpF )
215 tbd = Bottom; 215 tbd = Bottom;
216 else 216 else
217 tbd = Top; 217 tbd = Top;
218 } 218 }
219 else { 219 else {
220 if ( p->mToolBarUpF ) 220 if ( p->mToolBarUpF )
221 tbd = Right; 221 tbd = Right;
222 else 222 else
223 tbd = Left; 223 tbd = Left;
224 } 224 }
225 filterToolBar = new QPEToolBar ( this ); 225 filterToolBar = new QPEToolBar ( this );
226 filterMenubar = new KMenuBar( 0 ); 226 filterMenubar = new KMenuBar( 0 );
227 QFontMetrics fm ( filterMenubar->font() ); 227 QFontMetrics fm ( filterMenubar->font() );
228#ifndef DESKTOP_VERSION 228#ifndef DESKTOP_VERSION
229 filterToolBar->setFocusPolicy( NoFocus ); 229 filterToolBar->setFocusPolicy( NoFocus );
230 filterMenubar->setFocusPolicy( NoFocus ); 230 filterMenubar->setFocusPolicy( NoFocus );
231#endif 231#endif
232 filterPopupMenu = new QPopupMenu( this ); 232 filterPopupMenu = new QPopupMenu( this );
233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 233 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
234 QString addTest = "A"; 234 QString addTest = "A";
235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 235 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
236#ifdef DESKTOP_VERSION 236#ifdef DESKTOP_VERSION
237 addTest = "AAAAAABBBCCCx"; 237 addTest = "AAAAAABBBCCCx";
238#else 238#else
239 addTest = "AAAAAx"; 239 addTest = "AAAAAx";
240#endif 240#endif
241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 241 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
242 addToolBar (filterToolBar , tbd ); 242 addToolBar (filterToolBar , tbd );
243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 243 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 244 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 245 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
246 filterToolBar->hide(); 246 filterToolBar->hide();
247 } else { 247 } else {
248 filterToolBar = 0; 248 filterToolBar = 0;
249 filterMenubar = 0; 249 filterMenubar = 0;
250 filterPopupMenu = 0; 250 filterPopupMenu = 0;
251 } 251 }
252 if ( p->mShowIconOnetoolbar ) { 252 if ( p->mShowIconOnetoolbar ) {
253 viewToolBar = iconToolBar ; 253 viewToolBar = iconToolBar ;
254 navigatorToolBar = iconToolBar ; 254 navigatorToolBar = iconToolBar ;
255 } else { 255 } else {
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 setToolBarsMovable( false ); 257 setToolBarsMovable( false );
258#endif 258#endif
259 if ( p->mToolBarHorV ) { 259 if ( p->mToolBarHorV ) {
260 if ( p->mToolBarUpV ) 260 if ( p->mToolBarUpV )
261 tbd = Bottom; 261 tbd = Bottom;
262 else 262 else
263 tbd = Top; 263 tbd = Top;
264 } 264 }
265 else { 265 else {
266 if ( p->mToolBarUpV ) 266 if ( p->mToolBarUpV )
267 tbd = Right; 267 tbd = Right;
268 else 268 else
269 tbd = Left; 269 tbd = Left;
270 } 270 }
271 viewToolBar = new QPEToolBar( this ); 271 viewToolBar = new QPEToolBar( this );
272 addToolBar (viewToolBar , tbd ); 272 addToolBar (viewToolBar , tbd );
273 if ( p->mToolBarHorN ) { 273 if ( p->mToolBarHorN ) {
274 if ( p->mToolBarUpN ) 274 if ( p->mToolBarUpN )
275 tbd = Bottom; 275 tbd = Bottom;
276 else 276 else
277 tbd = Top; 277 tbd = Top;
278 } 278 }
279 else { 279 else {
280 if ( p->mToolBarUpN ) 280 if ( p->mToolBarUpN )
281 tbd = Right; 281 tbd = Right;
282 else 282 else
283 tbd = Left; 283 tbd = Left;
284 } 284 }
285 navigatorToolBar = new QPEToolBar( this ); 285 navigatorToolBar = new QPEToolBar( this );
286 addToolBar (navigatorToolBar , tbd ); 286 addToolBar (navigatorToolBar , tbd );
287 } 287 }
288 288
289 289
290 290
291 mCalendarModifiedFlag = false; 291 mCalendarModifiedFlag = false;
292 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 292 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
293 //splash->setAlignment ( AlignCenter ); 293 //splash->setAlignment ( AlignCenter );
294 //setCentralWidget( splash ); 294 //setCentralWidget( splash );
295#ifndef DESKTOP_VERSION 295#ifndef DESKTOP_VERSION
296 //showMaximized(); 296 //showMaximized();
297#endif 297#endif
298 298
299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 299 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
300 setDefaultPreferences(); 300 setDefaultPreferences();
301 mCalendar = new CalendarLocal(); 301 mCalendar = new CalendarLocal();
302 mView = new CalendarView( mCalendar, this,"mCalendar " ); 302 mView = new CalendarView( mCalendar, this,"mCalendar " );
303 setCentralWidget( mView ); 303 setCentralWidget( mView );
304 //mView->hide(); 304 //mView->hide();
305 //mView->resize(splash->size() ); 305 //mView->resize(splash->size() );
306 initActions(); 306 initActions();
307 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 307 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
308 mSyncManager->setBlockSave(false); 308 mSyncManager->setBlockSave(false);
309 mView->setSyncManager(mSyncManager); 309 mView->setSyncManager(mSyncManager);
310#ifndef DESKTOP_VERSION 310#ifndef DESKTOP_VERSION
311 iconToolBar->show(); 311 iconToolBar->show();
312 qApp->processEvents(); 312 qApp->processEvents();
313#endif 313#endif
314 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 314 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
315 int vh = height() ; 315 int vh = height() ;
316 int vw = width(); 316 int vw = width();
317 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 317 //qDebug("Toolbar hei %d ",iconToolBar->height() );
318 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 318 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
319 vh -= iconToolBar->height(); 319 vh -= iconToolBar->height();
320 } else { 320 } else {
321 vw -= iconToolBar->height(); 321 vw -= iconToolBar->height();
322 } 322 }
323 //mView->setMaximumSize( splash->size() ); 323 //mView->setMaximumSize( splash->size() );
324 //mView->resize( splash->size() ); 324 //mView->resize( splash->size() );
325 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 325 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
326 mView->readSettings(); 326 mView->readSettings();
327 bool newFile = false; 327 bool newFile = false;
328 if( !QFile::exists( defaultFileName() ) ) { 328 if( !QFile::exists( defaultFileName() ) ) {
329 QFileInfo finfo ( defaultFileName() ); 329 QFileInfo finfo ( defaultFileName() );
330 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 330 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
331 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 331 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
332 finfo.setFile( oldFile ); 332 finfo.setFile( oldFile );
333 if (finfo.exists() ) { 333 if (finfo.exists() ) {
334 KMessageBox::information( this, message); 334 KMessageBox::information( this, message);
335 mView->openCalendar( oldFile ); 335 mView->openCalendar( oldFile );
336 qApp->processEvents(); 336 qApp->processEvents();
337 } else { 337 } else {
338 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 338 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
339 finfo.setFile( oldFile ); 339 finfo.setFile( oldFile );
340 if (finfo.exists() ) { 340 if (finfo.exists() ) {
341 KMessageBox::information( this, message); 341 KMessageBox::information( this, message);
342 mView->openCalendar( oldFile ); 342 mView->openCalendar( oldFile );
343 qApp->processEvents(); 343 qApp->processEvents();
344 } 344 }
345 } 345 }
346 mView->saveCalendar( defaultFileName() ); 346 mView->saveCalendar( defaultFileName() );
347 newFile = true; 347 newFile = true;
348 } 348 }
349 349
350 //QTime neededSaveTime = QDateTime::currentDateTime().time(); 350 //QTime neededSaveTime = QDateTime::currentDateTime().time();
351 //mView->loadCalendars(); 351 //mView->loadCalendars();
352 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 352 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
353 //qDebug("KO: Calendar loading time: %d ms",msNeeded ); 353 //qDebug("KO: Calendar loading time: %d ms",msNeeded );
354 354
355 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 355 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
356 KOPrefs::instance()->setAllDefaults(); 356 KOPrefs::instance()->setAllDefaults();
357 } 357 }
358 358
359 359
360 connect( mView, SIGNAL( tempDisableBR(bool) ), 360 connect( mView, SIGNAL( tempDisableBR(bool) ),
361 SLOT( disableBR(bool) ) ); 361 SLOT( disableBR(bool) ) );
362 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 362 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
363 setCentralWidget( mView ); 363 setCentralWidget( mView );
364 globalFlagBlockStartup = 0; 364 globalFlagBlockStartup = 0;
365 //mView->show(); 365 //mView->show();
366 //delete splash; 366 //delete splash;
367 if ( newFile ) 367 if ( newFile )
368 mView->updateConfig(); 368 mView->updateConfig();
369 // qApp->processEvents(); 369 // qApp->processEvents();
370 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 370 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
371 //fillSyncMenu(); 371 //fillSyncMenu();
372 372
373 373
374 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 374 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
375 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 375 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
376 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 376 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
377 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 377 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
378 mSyncManager->setDefaultFileName( sentSyncFile()); 378 mSyncManager->setDefaultFileName( sentSyncFile());
379 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 379 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
380 mSyncManager->fillSyncMenu(); 380 mSyncManager->fillSyncMenu();
381 381
382 382
383 383
384 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 384 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
385 if ( showWarning ) { 385 if ( showWarning ) {
386 KMessageBox::information( this, 386 KMessageBox::information( this,
387 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 387 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
388 //qApp->processEvents(); 388 //qApp->processEvents();
389 mView->dialogManager()->showSyncOptions(); 389 mView->dialogManager()->showSyncOptions();
390 } 390 }
391 391
392 //US listen for result adressed from Ka/Pi 392 //US listen for result adressed from Ka/Pi
393 393
394#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
395 infrared = 0; 395 infrared = 0;
396#endif 396#endif
397 updateFilterToolbar(); 397 updateFilterToolbar();
398 updateWeek( mView->startDate() ); 398 updateWeek( mView->startDate() );
399 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 399 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
400 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 400 SLOT( updateWeekNum( const KCal::DateList & ) ) );
401 mBRdisabled = false; 401 mBRdisabled = false;
402 //toggleBeamReceive(); 402 //toggleBeamReceive();
403 403
404 setCaption(i18n("Loading calendar files ... please wait" )); 404 setCaption(i18n("Loading calendar files ... please wait" ));
405 mSaveDelay = 0; 405 mSaveDelay = 0;
406 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); 406 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() ));
407} 407}
408MainWindow::~MainWindow() 408MainWindow::~MainWindow()
409{ 409{
410 //qDebug("MainWindow::~MainWindow() "); 410 //qDebug("MainWindow::~MainWindow() ");
411 //save toolbar location 411 //save toolbar location
412 delete mCalendar; 412 delete mCalendar;
413 delete mSyncManager; 413 delete mSyncManager;
414#ifndef DESKTOP_VERSION 414#ifndef DESKTOP_VERSION
415 if ( infrared ) 415 if ( infrared )
416 delete infrared; 416 delete infrared;
417#endif 417#endif
418 418
419 419
420} 420}
421 421
422void MainWindow::loadDataAfterStart() 422void MainWindow::loadDataAfterStart()
423{ 423{
424 qDebug("KO: Start loading files..." ); 424 qDebug("KO: Start loading files..." );
425 QTime neededSaveTime = QDateTime::currentDateTime().time(); 425 QTime neededSaveTime = QDateTime::currentDateTime().time();
426 mView->loadCalendars(); 426 mView->loadCalendars();
427 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 427 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
428 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 428 qDebug("KO: Calendar loading time: %d ms",msNeeded );
429 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 429 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
430 mView->setModified( false ); 430 mView->setModified( false );
431 mBlockAtStartup = false; 431 mBlockAtStartup = false;
432 mView->setModified( false ); 432 mView->setModified( false );
433 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 433 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
434 processIncidenceSelection( 0 ); 434 processIncidenceSelection( 0 );
435 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 435 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
436 SLOT( processIncidenceSelection( Incidence * ) ) ); 436 SLOT( processIncidenceSelection( Incidence * ) ) );
437 connect( mView, SIGNAL( modifiedChanged( bool ) ), 437 connect( mView, SIGNAL( modifiedChanged( bool ) ),
438 SLOT( slotModifiedChanged( bool ) ) ); 438 SLOT( slotModifiedChanged( bool ) ) );
439#ifndef DESKTOP_VERSION 439#ifndef DESKTOP_VERSION
440 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 440 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
441 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); 441 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& )));
442 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); 442 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& )));
443 if ( !mCStringMess.isEmpty() ) 443 if ( !mCStringMess.isEmpty() )
444 recieve( mCStringMess, mByteData ); 444 recieve( mCStringMess, mByteData );
445#endif 445#endif
446 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 446 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
447} 447}
448 448
449void MainWindow::slotResetFocus() 449void MainWindow::slotResetFocus()
450{ 450{
451 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 451 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
452 mFocusLoop = 3; 452 mFocusLoop = 3;
453 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 453 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
454} 454}
455void MainWindow::slotResetFocusLoop() 455void MainWindow::slotResetFocusLoop()
456{ 456{
457 --mFocusLoop; 457 --mFocusLoop;
458 QWidget* fw = mView->viewManager()->currentView(); 458 QWidget* fw = mView->viewManager()->currentView();
459 if ( fw ) { 459 if ( fw ) {
460 //qDebug("loop "); 460 //qDebug("loop ");
461 fw->setFocus(); 461 fw->setFocus();
462 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 462 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
463 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 463 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
464 } 464 }
465 465
466} 466}
467void MainWindow::disableBR(bool b) 467void MainWindow::disableBR(bool b)
468{ 468{
469#ifndef DESKTOP_VERSION 469#ifndef DESKTOP_VERSION
470 if ( b ) { 470 if ( b ) {
471 if ( infrared ) { 471 if ( infrared ) {
472 toggleBeamReceive(); 472 toggleBeamReceive();
473 mBRdisabled = true; 473 mBRdisabled = true;
474 } 474 }
475 mBRdisabled = true; 475 mBRdisabled = true;
476 } else { 476 } else {
477 if ( mBRdisabled ) { 477 if ( mBRdisabled ) {
478 mBRdisabled = false; 478 mBRdisabled = false;
479 //makes no sense,because other cal ap is probably running 479 //makes no sense,because other cal ap is probably running
480 // toggleBeamReceive(); 480 // toggleBeamReceive();
481 } 481 }
482 } 482 }
483#endif 483#endif
484 484
485} 485}
486bool MainWindow::beamReceiveEnabled() 486bool MainWindow::beamReceiveEnabled()
487{ 487{
488#ifndef DESKTOP_VERSION 488#ifndef DESKTOP_VERSION
489 return ( infrared != 0 ); 489 return ( infrared != 0 );
490#endif 490#endif
491 return false; 491 return false;
492} 492}
493 493
494void MainWindow::toggleBeamReceive() 494void MainWindow::toggleBeamReceive()
495{ 495{
496 if ( mBRdisabled ) 496 if ( mBRdisabled )
497 return; 497 return;
498#ifndef DESKTOP_VERSION 498#ifndef DESKTOP_VERSION
499 if ( infrared ) { 499 if ( infrared ) {
500 qDebug("KO: Disable BeamReceive "); 500 qDebug("KO: Disable BeamReceive ");
501 delete infrared; 501 delete infrared;
502 infrared = 0; 502 infrared = 0;
503 brAction->setOn(false); 503 brAction->setOn(false);
504 return; 504 return;
505 } 505 }
506 qDebug("KO: Enable BeamReceive "); 506 qDebug("KO: Enable BeamReceive ");
507 brAction->setOn(true); 507 brAction->setOn(true);
508 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 508 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
509 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 509 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
510#endif 510#endif
511} 511}
512void MainWindow::showMaximized () 512void MainWindow::showMaximized ()
513{ 513{
514#ifndef DESKTOP_VERSION 514#ifndef DESKTOP_VERSION
515 if ( ! globalFlagBlockStartup ) 515 if ( ! globalFlagBlockStartup )
516 if ( mClosed ) 516 if ( mClosed )
517 mView->goToday(); 517 mView->goToday();
518#endif 518#endif
519 QWidget::showMaximized () ; 519 QWidget::showMaximized () ;
520 mClosed = false; 520 mClosed = false;
521} 521}
522 522
523bool MainWindow::askForQuitOnSaveError() 523bool MainWindow::askForQuitOnSaveError()
524{ 524{
525 bool retval = false; 525 bool retval = false;
526 switch( QMessageBox::information( this, "KO/Pi", 526 switch( QMessageBox::information( this, "KO/Pi",
527 i18n("Error saving data") + "!\n" + 527 i18n("Error saving data") + "!\n" +
528 i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" + 528 i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" +
529 i18n("Do you really want\nto close KO/Pi?"), 529 i18n("Do you really want\nto close KO/Pi?"),
530 i18n(" Yes, close "), i18n("No"), 530 i18n(" Yes, close "), i18n("No"),
531 0, 1 ) ) { 531 0, 1 ) ) {
532 case 0: 532 case 0:
533 retval = true; 533 retval = true;
534 break; 534 break;
535 default: 535 default:
536 break; 536 break;
537 } 537 }
538 return retval; 538 return retval;
539} 539}
540 540
541void MainWindow::closeEvent( QCloseEvent* ce ) 541void MainWindow::closeEvent( QCloseEvent* ce )
542{ 542{
543 543
544 544
545 545
546 if ( ! KOPrefs::instance()->mAskForQuit ) { 546 if ( ! KOPrefs::instance()->mAskForQuit ) {
547 saveOnClose(); 547 saveOnClose();
548 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { 548 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
549 ce->ignore(); 549 ce->ignore();
550 return; 550 return;
551 } 551 }
552 mClosed = true; 552 mClosed = true;
553 ce->accept(); 553 ce->accept();
554 return; 554 return;
555 555
556 } 556 }
557 557
558 switch( QMessageBox::information( this, "KO/Pi", 558 switch( QMessageBox::information( this, "KO/Pi",
559 i18n("Do you really want\nto close KO/Pi?"), 559 i18n("Do you really want\nto close KO/Pi?"),
560 i18n("Close"), i18n("No"), 560 i18n("Close"), i18n("No"),
561 0, 0 ) ) { 561 0, 0 ) ) {
562 case 0: 562 case 0:
563 saveOnClose(); 563 saveOnClose();
564 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { 564 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
565 ce->ignore(); 565 ce->ignore();
566 return; 566 return;
567 } 567 }
568 mClosed = true; 568 mClosed = true;
569 ce->accept(); 569 ce->accept();
570 break; 570 break;
571 case 1: 571 case 1:
572 ce->ignore(); 572 ce->ignore();
573 break; 573 break;
574 case 2: 574 case 2:
575 575
576 default: 576 default:
577 break; 577 break;
578 } 578 }
579 579
580 580
581} 581}
582void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) 582void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data )
583{ 583{
584 qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 584 qDebug("KO: QCOP start message received: %s ", cmsg.data() );
585 mCStringMess = cmsg; 585 mCStringMess = cmsg;
586 mByteData = data; 586 mByteData = data;
587} 587}
588void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 588void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
589{ 589{
590 QDataStream stream( data, IO_ReadOnly ); 590 QDataStream stream( data, IO_ReadOnly );
591 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 591 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
592 //QString datamess; 592 //QString datamess;
593 //qDebug("message "); 593 //qDebug("message ");
594 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 594 qDebug("KO: QCOP message received: %s ", cmsg.data() );
595 595
596 if ( cmsg == "setDocument(QString)" ) { 596 if ( cmsg == "setDocument(QString)" ) {
597 QDataStream stream( data, IO_ReadOnly ); 597 QDataStream stream( data, IO_ReadOnly );
598 QString fileName; 598 QString fileName;
599 stream >> fileName; 599 stream >> fileName;
600 //qDebug("filename %s ", fileName.latin1()); 600 //qDebug("filename %s ", fileName.latin1());
601 showMaximized(); 601 showMaximized();
602 raise(); 602 raise();
603 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 603 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
604 mSyncManager->slotSyncMenu( 1002 ); 604 mSyncManager->slotSyncMenu( 1002 );
605 return; 605 return;
606 } 606 }
607 607
608 if ( cmsg == "-writeFile" ) { 608 if ( cmsg == "-writeFile" ) {
609 // I made from the "-writeFile" an "-writeAlarm" 609 // I made from the "-writeFile" an "-writeAlarm"
610 mView->viewManager()->showWhatsNextView(); 610 mView->viewManager()->showWhatsNextView();
611 mCalendar->checkAlarmForIncidence( 0, true); 611 mCalendar->checkAlarmForIncidence( 0, true);
612 showMaximized(); 612 showMaximized();
613 raise(); 613 raise();
614 return; 614 return;
615 615
616 } 616 }
617 if ( cmsg == "-writeFileSilent" ) { 617 if ( cmsg == "-writeFileSilent" ) {
618 // I made from the "-writeFile" an "-writeAlarm" 618 // I made from the "-writeFile" an "-writeAlarm"
619 // mView->viewManager()->showWhatsNextView(); 619 // mView->viewManager()->showWhatsNextView();
620 mCalendar->checkAlarmForIncidence( 0, true); 620 mCalendar->checkAlarmForIncidence( 0, true);
621 //showMaximized(); 621 //showMaximized();
622 //raise(); 622 //raise();
623 //hide(); 623 //hide();
624 return; 624 return;
625 } 625 }
626 if ( cmsg == "-newCountdown" ) { 626 if ( cmsg == "-newCountdown" ) {
627 qDebug("newCountdown "); 627 qDebug("newCountdown ");
628 628
629 } 629 }
630 QString msg ; 630 QString msg ;
631 QString allmsg = cmsg; 631 QString allmsg = cmsg;
632 while ( allmsg.length() > 0 ) { 632 while ( allmsg.length() > 0 ) {
633 int nextC = allmsg.find( "-", 1 ); 633 int nextC = allmsg.find( "-", 1 );
634 if ( nextC == -1 ) { 634 if ( nextC == -1 ) {
635 msg = allmsg; 635 msg = allmsg;
636 allmsg = ""; 636 allmsg = "";
637 } else{ 637 } else{
638 msg = allmsg.left( nextC ); 638 msg = allmsg.left( nextC );
639 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 639 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
640 } 640 }
641 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 641 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
642 if ( msg == "-newEvent" ) { 642 if ( msg == "-newEvent" ) {
643 QTimer::singleShot( 0, mView, SLOT ( newEvent())); 643 QTimer::singleShot( 0, mView, SLOT ( newEvent()));
644 } 644 }
645 if ( msg == "-newTodo" ) { 645 if ( msg == "-newTodo" ) {
646 QTimer::singleShot( 0, mView, SLOT ( newTodo())); 646 QTimer::singleShot( 0, mView, SLOT ( newTodo()));
647 } 647 }
648 if ( msg == "-showWN" ) { 648 if ( msg == "-showWN" ) {
649 mView->viewManager()->showWhatsNextView(); 649 mView->viewManager()->showWhatsNextView();
650 } 650 }
651 if ( msg == "-showList" ) { 651 if ( msg == "-showList" ) {
652 mView->viewManager()->showListView(); 652 mView->viewManager()->showListView();
653 } 653 }
654 else if ( msg == "-showDay" ) { 654 else if ( msg == "-showDay" ) {
655 mView->viewManager()->showDayView(); 655 mView->viewManager()->showDayView();
656 } 656 }
657 else if ( msg == "-showWWeek" ) { 657 else if ( msg == "-showWWeek" ) {
658 mView->viewManager()->showWorkWeekView(); 658 mView->viewManager()->showWorkWeekView();
659 } 659 }
660 else if ( msg == "-ringSync" ) { 660 else if ( msg == "-ringSync" ) {
661 QTimer::singleShot( 0, this, SLOT (startMultiSync())); 661 QTimer::singleShot( 0, this, SLOT (startMultiSync()));
662 } 662 }
663 else if ( msg == "-showWeek" ) { 663 else if ( msg == "-showWeek" ) {
664 mView->viewManager()->showWeekView(); 664 mView->viewManager()->showWeekView();
665 } 665 }
666 else if ( msg == "-showTodo" ) { 666 else if ( msg == "-showTodo" ) {
667 mView->viewManager()->showTodoView(); 667 mView->viewManager()->showTodoView();
668 } 668 }
669 else if ( msg == "-showJournal" ) { 669 else if ( msg == "-showJournal" ) {
670 mView->dateNavigator()->selectDates( 1 ); 670 mView->dateNavigator()->selectDates( 1 );
671 mView->dateNavigator()->selectToday(); 671 mView->dateNavigator()->selectToday();
672 mView->viewManager()->showJournalView(); 672 mView->viewManager()->showJournalView();
673 } 673 }
674 else if ( msg == "-showKO" ) { 674 else if ( msg == "-showKO" ) {
675 mView->viewManager()->showNextXView(); 675 mView->viewManager()->showNextXView();
676 } 676 }
677 else if ( msg == "-showWNext" ) { 677 else if ( msg == "-showWNext" ) {
678 mView->viewManager()->showWhatsNextView(); 678 mView->viewManager()->showWhatsNextView();
679 } 679 }
680 else if ( msg == "nextView()" ) { 680 else if ( msg == "nextView()" ) {
681 mView->viewManager()->showNextView(); 681 mView->viewManager()->showNextView();
682 } 682 }
683 else if ( msg == "-showNextXView" ) { 683 else if ( msg == "-showNextXView" ) {
684 mView->viewManager()->showNextXView(); 684 mView->viewManager()->showNextXView();
685 } 685 }
686 686
687 687
688 } 688 }
689 689
690 showMaximized(); 690 showMaximized();
691 raise(); 691 raise();
692} 692}
693void MainWindow::startMultiSync() 693void MainWindow::startMultiSync()
694{ 694{
695 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 695 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
696 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), 696 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"),
697 question, 697 question,
698 i18n("Yes"), i18n("No"), 698 i18n("Yes"), i18n("No"),
699 0, 0 ) != 0 ) { 699 0, 0 ) != 0 ) {
700 setCaption(i18n("Aborted! Nothing synced!")); 700 setCaption(i18n("Aborted! Nothing synced!"));
701 return; 701 return;
702 } 702 }
703 mSyncManager->multiSync( false ); 703 mSyncManager->multiSync( false );
704#ifndef DESKTOP_VERSION 704#ifndef DESKTOP_VERSION
705 QCopEnvelope e("QPE/Application/kapi", "doRingSync"); 705 QCopEnvelope e("QPE/Application/kapi", "doRingSync");
706#endif 706#endif
707} 707}
708QPixmap MainWindow::loadPixmap( QString name ) 708QPixmap MainWindow::loadPixmap( QString name )
709{ 709{
710 return SmallIcon( name ); 710 return SmallIcon( name );
711 711
712} 712}
713void MainWindow::setUsesBigPixmaps ( bool b ) 713void MainWindow::setUsesBigPixmaps ( bool b )
714{ 714{
715 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 715 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
716 if ( b ) 716 if ( b )
717 qDebug("KO: BigPixmaps are not supported "); 717 qDebug("KO: BigPixmaps are not supported ");
718} 718}
719void MainWindow::initActions() 719void MainWindow::initActions()
720{ 720{
721 //KOPrefs::instance()->mShowFullMenu 721 //KOPrefs::instance()->mShowFullMenu
722 iconToolBar->clear(); 722 iconToolBar->clear();
723 KOPrefs *p = KOPrefs::instance(); 723 KOPrefs *p = KOPrefs::instance();
724 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 724 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
725 725
726 QPopupMenu *viewMenu = new QPopupMenu( this ); 726 QPopupMenu *viewMenu = new QPopupMenu( this );
727 QPopupMenu *actionMenu = new QPopupMenu( this ); 727 QPopupMenu *actionMenu = new QPopupMenu( this );
728 mCurrentItemMenu = new QPopupMenu ( this ); 728 mCurrentItemMenu = new QPopupMenu ( this );
729 QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); 729 QPopupMenu *nextConflictMenu = new QPopupMenu ( this );
730 QPopupMenu *importMenu = new QPopupMenu( this ); 730 QPopupMenu *importMenu = new QPopupMenu( this );
731 QPopupMenu *importMenu_X = new QPopupMenu( this ); 731 QPopupMenu *importMenu_X = new QPopupMenu( this );
732 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 732 QPopupMenu *exportMenu_X = new QPopupMenu( this );
733 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 733 QPopupMenu *beamMenu_X = new QPopupMenu( this );
734 selectFilterMenu = new QPopupMenu( this ); 734 selectFilterMenu = new QPopupMenu( this );
735 selectFilterMenu->setCheckable( true ); 735 selectFilterMenu->setCheckable( true );
736 syncMenu = new QPopupMenu( this ); 736 syncMenu = new QPopupMenu( this );
737 configureAgendaMenu = new QPopupMenu( this ); 737 configureAgendaMenu = new QPopupMenu( this );
738 configureToolBarMenu = new QPopupMenu( this ); 738 configureToolBarMenu = new QPopupMenu( this );
739 QPopupMenu *helpMenu = new QPopupMenu( this ); 739 QPopupMenu *helpMenu = new QPopupMenu( this );
740 QIconSet icon; 740 QIconSet icon;
741 int pixWid = 22, pixHei = 22; 741 int pixWid = 22, pixHei = 22;
742 QString pathString = ""; 742 QString pathString = "";
743 if ( !p->mToolBarMiniIcons ) { 743 if ( !p->mToolBarMiniIcons ) {
744 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 744 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
745 pathString += "icons16/"; 745 pathString += "icons16/";
746 pixWid = 18; pixHei = 16; 746 pixWid = 18; pixHei = 16;
747 } 747 }
748 } else { 748 } else {
749 pathString += "iconsmini/"; 749 pathString += "iconsmini/";
750 pixWid = 18; pixHei = 16; 750 pixWid = 18; pixHei = 16;
751 } 751 }
752 752
753 if ( KOPrefs::instance()->mShowFullMenu ) { 753 if ( KOPrefs::instance()->mShowFullMenu ) {
754 menuBar1 = new KMenuBar( this );//menuBar(); 754 menuBar1 = new KMenuBar( this );//menuBar();
755 //setMenuBar( menuBar1 ); 755 //setMenuBar( menuBar1 );
756 menuBar1->show(); 756 menuBar1->show();
757 menuBar1->insertItem( i18n("File"), importMenu ); 757 menuBar1->insertItem( i18n("File"), importMenu );
758 menuBar1->insertItem( i18n("View"), viewMenu ); 758 menuBar1->insertItem( i18n("View"), viewMenu );
759 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); 759 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu );
760 menuBar1->insertItem( i18n("Action"), actionMenu ); 760 menuBar1->insertItem( i18n("Action"), actionMenu );
761#ifdef DESKTOP_VERSION 761#ifdef DESKTOP_VERSION
762 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 762 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
763 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 763 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
764#else 764#else
765 menuBar1->insertItem( i18n("Sync"), syncMenu ); 765 menuBar1->insertItem( i18n("Sync"), syncMenu );
766 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 766 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
767#endif 767#endif
768 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 768 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
769 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 769 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
770 menuBar1->insertItem( i18n("Help"), helpMenu ); 770 menuBar1->insertItem( i18n("Help"), helpMenu );
771 } else { 771 } else {
772 menuBar1 = new KMenuBar( iconToolBar ); 772 menuBar1 = new KMenuBar( iconToolBar );
773 QPopupMenu *menuBar = new QPopupMenu( this ); 773 QPopupMenu *menuBar = new QPopupMenu( this );
774 icon = loadPixmap( pathString + "z_menu" ); 774 icon = loadPixmap( pathString + "z_menu" );
775 menuBar1->insertItem( icon.pixmap(), menuBar); 775 menuBar1->insertItem( icon.pixmap(), menuBar);
776 //menuBar1->insertItem( i18n("ME"), menuBar); 776 //menuBar1->insertItem( i18n("ME"), menuBar);
777 menuBar->insertItem( i18n("File"), importMenu ); 777 menuBar->insertItem( i18n("File"), importMenu );
778 menuBar->insertItem( i18n("View"), viewMenu ); 778 menuBar->insertItem( i18n("View"), viewMenu );
779 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); 779 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu );
780 menuBar->insertItem( i18n("Action"), actionMenu ); 780 menuBar->insertItem( i18n("Action"), actionMenu );
781 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 781 menuBar->insertItem( i18n("Synchronize"), syncMenu );
782 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 782 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
783 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 783 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
784 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 784 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
785 menuBar->insertItem( i18n("Help"), helpMenu ); 785 menuBar->insertItem( i18n("Help"), helpMenu );
786 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 786 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
787 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 787 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
788 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); 788 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) );
789 } 789 }
790 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 790 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
791 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 791 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
792 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 792 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
793 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 793 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
794 794
795 795
796 mWeekBgColor = iconToolBar->backgroundColor(); 796 mWeekBgColor = iconToolBar->backgroundColor();
797 mWeekPixmap.resize( pixWid , pixHei ); 797 mWeekPixmap.resize( pixWid , pixHei );
@@ -1280,1488 +1280,1499 @@ void MainWindow::initActions()
1280 connect( action, SIGNAL( activated() ), 1280 connect( action, SIGNAL( activated() ),
1281 SLOT( storagehowto() ) ); 1281 SLOT( storagehowto() ) );
1282 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1282 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1283 action->addTo( helpMenu ); 1283 action->addTo( helpMenu );
1284 connect( action, SIGNAL( activated() ), 1284 connect( action, SIGNAL( activated() ),
1285 SLOT( timetrackinghowto() ) ); 1285 SLOT( timetrackinghowto() ) );
1286 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1286 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1287 action->addTo( helpMenu ); 1287 action->addTo( helpMenu );
1288 connect( action, SIGNAL( activated() ), 1288 connect( action, SIGNAL( activated() ),
1289 SLOT( synchowto() ) ); 1289 SLOT( synchowto() ) );
1290 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1290 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1291 action->addTo( helpMenu ); 1291 action->addTo( helpMenu );
1292 connect( action, SIGNAL( activated() ), 1292 connect( action, SIGNAL( activated() ),
1293 SLOT( kdesynchowto() ) ); 1293 SLOT( kdesynchowto() ) );
1294 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1294 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1295 action->addTo( helpMenu ); 1295 action->addTo( helpMenu );
1296 connect( action, SIGNAL( activated() ), 1296 connect( action, SIGNAL( activated() ),
1297 SLOT( multisynchowto() ) ); 1297 SLOT( multisynchowto() ) );
1298 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1298 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1299 action->addTo( helpMenu ); 1299 action->addTo( helpMenu );
1300 connect( action, SIGNAL( activated() ), 1300 connect( action, SIGNAL( activated() ),
1301 SLOT( aboutAutoSaving() ) ); 1301 SLOT( aboutAutoSaving() ) );
1302 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1302 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1303 action->addTo( helpMenu ); 1303 action->addTo( helpMenu );
1304 connect( action, SIGNAL( activated() ), 1304 connect( action, SIGNAL( activated() ),
1305 SLOT( aboutKnownBugs() ) ); 1305 SLOT( aboutKnownBugs() ) );
1306 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1306 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1307 action->addTo( helpMenu ); 1307 action->addTo( helpMenu );
1308 connect( action, SIGNAL( activated() ), 1308 connect( action, SIGNAL( activated() ),
1309 SLOT( usertrans() ) ); 1309 SLOT( usertrans() ) );
1310 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1310 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1311 action->addTo( helpMenu ); 1311 action->addTo( helpMenu );
1312 connect( action, SIGNAL( activated() ), 1312 connect( action, SIGNAL( activated() ),
1313 SLOT( faq() ) ); 1313 SLOT( faq() ) );
1314 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1314 action = new QAction( "licence", i18n("Licence..."), 0, this );
1315 action->addTo( helpMenu ); 1315 action->addTo( helpMenu );
1316 connect( action, SIGNAL( activated() ), 1316 connect( action, SIGNAL( activated() ),
1317 SLOT( licence() ) ); 1317 SLOT( licence() ) );
1318 action = new QAction( "about", i18n("About..."), 0, this ); 1318 action = new QAction( "about", i18n("About..."), 0, this );
1319 action->addTo( helpMenu ); 1319 action->addTo( helpMenu );
1320 connect( action, SIGNAL( activated() ), 1320 connect( action, SIGNAL( activated() ),
1321 SLOT( about() ) ); 1321 SLOT( about() ) );
1322 //menuBar->insertSeparator(); 1322 //menuBar->insertSeparator();
1323 1323
1324 // ****************************************************** 1324 // ******************************************************
1325 // menubar icons 1325 // menubar icons
1326 1326
1327 1327
1328 1328
1329 //menuBar->insertItem( iconToolBar ); 1329 //menuBar->insertItem( iconToolBar );
1330 //xdays_action 1330 //xdays_action
1331 if (p-> mShowIconNewEvent) 1331 if (p-> mShowIconNewEvent)
1332 ne_action->addTo( iconToolBar ); 1332 ne_action->addTo( iconToolBar );
1333 if (p->mShowIconNewTodo ) 1333 if (p->mShowIconNewTodo )
1334 nt_action->addTo( iconToolBar ); 1334 nt_action->addTo( iconToolBar );
1335 if (p-> mShowIconSearch) 1335 if (p-> mShowIconSearch)
1336 search_action->addTo( iconToolBar ); 1336 search_action->addTo( iconToolBar );
1337 if (p-> mShowIconWhatsThis) 1337 if (p-> mShowIconWhatsThis)
1338 QWhatsThis::whatsThisButton ( iconToolBar ); 1338 QWhatsThis::whatsThisButton ( iconToolBar );
1339 if (p-> mShowIconNext) 1339 if (p-> mShowIconNext)
1340 whatsnext_action->addTo( viewToolBar ); 1340 whatsnext_action->addTo( viewToolBar );
1341 if (p-> mShowIconNextDays) 1341 if (p-> mShowIconNextDays)
1342 xdays_action->addTo( viewToolBar ); 1342 xdays_action->addTo( viewToolBar );
1343 if (p-> mShowIconJournal) 1343 if (p-> mShowIconJournal)
1344 viewjournal_action->addTo( viewToolBar ); 1344 viewjournal_action->addTo( viewToolBar );
1345 if (p-> mShowIconDay1) 1345 if (p-> mShowIconDay1)
1346 day1_action->addTo( viewToolBar ); 1346 day1_action->addTo( viewToolBar );
1347 if (p-> mShowIconDay5) 1347 if (p-> mShowIconDay5)
1348 day5_action->addTo( viewToolBar ); 1348 day5_action->addTo( viewToolBar );
1349 if (p-> mShowIconDay7) 1349 if (p-> mShowIconDay7)
1350 day7_action->addTo( viewToolBar ); 1350 day7_action->addTo( viewToolBar );
1351 if (p-> mShowIconDay6) 1351 if (p-> mShowIconDay6)
1352 day6_action->addTo( viewToolBar ); 1352 day6_action->addTo( viewToolBar );
1353 if (p-> mShowIconMonth) 1353 if (p-> mShowIconMonth)
1354 month_action->addTo( viewToolBar ); 1354 month_action->addTo( viewToolBar );
1355 if (p-> mShowIconList) 1355 if (p-> mShowIconList)
1356 showlist_action->addTo( viewToolBar ); 1356 showlist_action->addTo( viewToolBar );
1357 if (p-> mShowIconTodoview) 1357 if (p-> mShowIconTodoview)
1358 todoview_action->addTo( viewToolBar ); 1358 todoview_action->addTo( viewToolBar );
1359 1359
1360 icon = loadPixmap( pathString + "2leftarrowB" ); 1360 icon = loadPixmap( pathString + "2leftarrowB" );
1361 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1361 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1362 if (p-> mShowIconBackFast) { 1362 if (p-> mShowIconBackFast) {
1363 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1363 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1364 connect( action, SIGNAL( activated() ), 1364 connect( action, SIGNAL( activated() ),
1365 mView, SLOT( goPreviousMonth() ) ); 1365 mView, SLOT( goPreviousMonth() ) );
1366 action->addTo( navigatorToolBar ); 1366 action->addTo( navigatorToolBar );
1367 } 1367 }
1368 icon = loadPixmap( pathString + "1leftarrowB" ); 1368 icon = loadPixmap( pathString + "1leftarrowB" );
1369 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1369 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1370 if (p-> mShowIconBack) { 1370 if (p-> mShowIconBack) {
1371 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1371 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1372 connect( action, SIGNAL( activated() ), 1372 connect( action, SIGNAL( activated() ),
1373 mView, SLOT( goPrevious() ) ); 1373 mView, SLOT( goPrevious() ) );
1374 action->addTo( navigatorToolBar ); 1374 action->addTo( navigatorToolBar );
1375 } 1375 }
1376 icon = loadPixmap( pathString + "today" ); 1376 icon = loadPixmap( pathString + "today" );
1377 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1377 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1378 if (p-> mShowIconToday) 1378 if (p-> mShowIconToday)
1379 today_action->addTo( navigatorToolBar ); 1379 today_action->addTo( navigatorToolBar );
1380 icon = loadPixmap( pathString + "1rightarrowB" ); 1380 icon = loadPixmap( pathString + "1rightarrowB" );
1381 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1381 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1382 if (p-> mShowIconForward) { 1382 if (p-> mShowIconForward) {
1383 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1383 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1384 connect( action, SIGNAL( activated() ), 1384 connect( action, SIGNAL( activated() ),
1385 mView, SLOT( goNext() ) ); 1385 mView, SLOT( goNext() ) );
1386 action->addTo( navigatorToolBar ); 1386 action->addTo( navigatorToolBar );
1387 } 1387 }
1388 icon = loadPixmap( pathString + "2rightarrowB" ); 1388 icon = loadPixmap( pathString + "2rightarrowB" );
1389 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1389 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1390 if (p-> mShowIconForwardFast) { 1390 if (p-> mShowIconForwardFast) {
1391 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1391 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1392 connect( action, SIGNAL( activated() ), 1392 connect( action, SIGNAL( activated() ),
1393 mView, SLOT( goNextMonth() ) ); 1393 mView, SLOT( goNextMonth() ) );
1394 action->addTo( navigatorToolBar ); 1394 action->addTo( navigatorToolBar );
1395 } 1395 }
1396 1396
1397 1397
1398 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1398 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1399 1399
1400 1400
1401 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1401 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1402 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1402 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1403 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1403 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1404 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1404 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1405 1405
1406 if (p-> mShowIconNewEvent) 1406 if (p-> mShowIconNewEvent)
1407 configureToolBarMenu->setItemChecked( 10, true ); 1407 configureToolBarMenu->setItemChecked( 10, true );
1408 if (p->mShowIconNewTodo ) 1408 if (p->mShowIconNewTodo )
1409 configureToolBarMenu->setItemChecked( 20, true ); 1409 configureToolBarMenu->setItemChecked( 20, true );
1410 if (p-> mShowIconSearch) 1410 if (p-> mShowIconSearch)
1411 configureToolBarMenu->setItemChecked( 120, true ); 1411 configureToolBarMenu->setItemChecked( 120, true );
1412 if (p-> mShowIconList) 1412 if (p-> mShowIconList)
1413 configureToolBarMenu->setItemChecked( 30, true ); 1413 configureToolBarMenu->setItemChecked( 30, true );
1414 if (p-> mShowIconDay1) 1414 if (p-> mShowIconDay1)
1415 configureToolBarMenu->setItemChecked( 40, true ); 1415 configureToolBarMenu->setItemChecked( 40, true );
1416 if (p-> mShowIconDay5) 1416 if (p-> mShowIconDay5)
1417 configureToolBarMenu->setItemChecked( 50, true ); 1417 configureToolBarMenu->setItemChecked( 50, true );
1418 if (p-> mShowIconDay6) 1418 if (p-> mShowIconDay6)
1419 configureToolBarMenu->setItemChecked( 75, true ); 1419 configureToolBarMenu->setItemChecked( 75, true );
1420 if (p-> mShowIconDay7) 1420 if (p-> mShowIconDay7)
1421 configureToolBarMenu->setItemChecked( 60, true ); 1421 configureToolBarMenu->setItemChecked( 60, true );
1422 if (p-> mShowIconMonth) 1422 if (p-> mShowIconMonth)
1423 configureToolBarMenu->setItemChecked( 70, true ); 1423 configureToolBarMenu->setItemChecked( 70, true );
1424 if (p-> mShowIconTodoview) 1424 if (p-> mShowIconTodoview)
1425 configureToolBarMenu->setItemChecked( 80, true ); 1425 configureToolBarMenu->setItemChecked( 80, true );
1426 if (p-> mShowIconBackFast) 1426 if (p-> mShowIconBackFast)
1427 configureToolBarMenu->setItemChecked( 200, true ); 1427 configureToolBarMenu->setItemChecked( 200, true );
1428 if (p-> mShowIconBack) 1428 if (p-> mShowIconBack)
1429 configureToolBarMenu->setItemChecked( 210, true ); 1429 configureToolBarMenu->setItemChecked( 210, true );
1430 if (p-> mShowIconToday) 1430 if (p-> mShowIconToday)
1431 configureToolBarMenu->setItemChecked( 130, true ); 1431 configureToolBarMenu->setItemChecked( 130, true );
1432 if (p-> mShowIconForward) 1432 if (p-> mShowIconForward)
1433 configureToolBarMenu->setItemChecked( 220, true ); 1433 configureToolBarMenu->setItemChecked( 220, true );
1434 if (p-> mShowIconForwardFast) 1434 if (p-> mShowIconForwardFast)
1435 configureToolBarMenu->setItemChecked( 230, true ); 1435 configureToolBarMenu->setItemChecked( 230, true );
1436 if (p-> mShowIconNextDays) 1436 if (p-> mShowIconNextDays)
1437 configureToolBarMenu->setItemChecked( 100, true ); 1437 configureToolBarMenu->setItemChecked( 100, true );
1438 if (p-> mShowIconNext) 1438 if (p-> mShowIconNext)
1439 configureToolBarMenu->setItemChecked( 110, true ); 1439 configureToolBarMenu->setItemChecked( 110, true );
1440 if (p-> mShowIconJournal) 1440 if (p-> mShowIconJournal)
1441 configureToolBarMenu->setItemChecked( 90, true ); 1441 configureToolBarMenu->setItemChecked( 90, true );
1442 if (p-> mShowIconWhatsThis) 1442 if (p-> mShowIconWhatsThis)
1443 configureToolBarMenu->setItemChecked( 300, true ); 1443 configureToolBarMenu->setItemChecked( 300, true );
1444 if (p-> mShowIconWeekNum) 1444 if (p-> mShowIconWeekNum)
1445 configureToolBarMenu->setItemChecked( 400, true ); 1445 configureToolBarMenu->setItemChecked( 400, true );
1446 if (!p-> mShowIconStretch) { 1446 if (!p-> mShowIconStretch) {
1447 QLabel* dummy = new QLabel( iconToolBar ); 1447 QLabel* dummy = new QLabel( iconToolBar );
1448 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1448 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1449 dummy->setMinimumWidth( 0 ); 1449 dummy->setMinimumWidth( 0 );
1450 iconToolBar->setStretchableWidget ( dummy ) ; 1450 iconToolBar->setStretchableWidget ( dummy ) ;
1451 } 1451 }
1452 else { 1452 else {
1453 iconToolBar->setHorizontalStretchable (true ); 1453 iconToolBar->setHorizontalStretchable (true );
1454 viewToolBar->setHorizontalStretchable (true ); 1454 viewToolBar->setHorizontalStretchable (true );
1455 navigatorToolBar->setHorizontalStretchable (true ); 1455 navigatorToolBar->setHorizontalStretchable (true );
1456 iconToolBar->setVerticalStretchable (true ); 1456 iconToolBar->setVerticalStretchable (true );
1457 viewToolBar->setVerticalStretchable (true ); 1457 viewToolBar->setVerticalStretchable (true );
1458 navigatorToolBar->setVerticalStretchable (true ); 1458 navigatorToolBar->setVerticalStretchable (true );
1459 configureToolBarMenu->setItemChecked( 5, true ); 1459 configureToolBarMenu->setItemChecked( 5, true );
1460 } 1460 }
1461 if (p-> mShowIconFilter) 1461 if (p-> mShowIconFilter)
1462 configureToolBarMenu->setItemChecked( 7, true ); 1462 configureToolBarMenu->setItemChecked( 7, true );
1463 if (p-> mShowIconOnetoolbar) 1463 if (p-> mShowIconOnetoolbar)
1464 configureToolBarMenu->setItemChecked( 6, true ); 1464 configureToolBarMenu->setItemChecked( 6, true );
1465 1465
1466 1466
1467 if ( filterMenubar ) { 1467 if ( filterMenubar ) {
1468 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1468 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1469 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); 1469 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) );
1470 } 1470 }
1471 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1471 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1472 configureAgenda( p->mHourSize ); 1472 configureAgenda( p->mHourSize );
1473 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1473 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1474} 1474}
1475void MainWindow::calHint() 1475void MainWindow::calHint()
1476{ 1476{
1477 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>."); 1477 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>.");
1478 1478
1479 KMessageBox::information( this, message); 1479 KMessageBox::information( this, message);
1480} 1480}
1481void MainWindow::exportToPhone( int mode ) 1481void MainWindow::exportToPhone( int mode )
1482{ 1482{
1483 1483
1484 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1484 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1485 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1485 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1486 KOex2phonePrefs ex2phone; 1486 KOex2phonePrefs ex2phone;
1487 1487
1488 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1488 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1489 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1489 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1490 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1490 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1491 if ( mode == 1 ) 1491 if ( mode == 1 )
1492 ex2phone.setCaption(i18n("Export complete calendar")); 1492 ex2phone.setCaption(i18n("Export complete calendar"));
1493 if ( mode == 2 ) 1493 if ( mode == 2 )
1494 ex2phone.setCaption(i18n("Export filtered calendar")); 1494 ex2phone.setCaption(i18n("Export filtered calendar"));
1495 1495
1496 if ( !ex2phone.exec() ) { 1496 if ( !ex2phone.exec() ) {
1497 return; 1497 return;
1498 } 1498 }
1499 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1499 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1500 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1500 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1501 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1501 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1502 1502
1503 int inFuture = 0; 1503 int inFuture = 0;
1504 if ( ex2phone.mWriteBackFuture->isChecked() ) 1504 if ( ex2phone.mWriteBackFuture->isChecked() )
1505 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1505 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1506 QPtrList<Incidence> delSel; 1506 QPtrList<Incidence> delSel;
1507 if ( mode == 1 ) 1507 if ( mode == 1 )
1508 delSel = mCalendar->rawIncidences(); 1508 delSel = mCalendar->rawIncidences();
1509 if ( mode == 2 ) 1509 if ( mode == 2 )
1510 delSel = mCalendar->incidences(); 1510 delSel = mCalendar->incidences();
1511 CalendarLocal* cal = new CalendarLocal(); 1511 CalendarLocal* cal = new CalendarLocal();
1512 cal->setLocalTime(); 1512 cal->setLocalTime();
1513 Incidence *incidence = delSel.first(); 1513 Incidence *incidence = delSel.first();
1514 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1514 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1515 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1515 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1516 while ( incidence ) { 1516 while ( incidence ) {
1517 if ( incidence->typeID() != journalID ) { 1517 if ( incidence->typeID() != journalID ) {
1518 bool add = true; 1518 bool add = true;
1519 if ( inFuture ) { 1519 if ( inFuture ) {
1520 QDateTime dt; 1520 QDateTime dt;
1521 if ( incidence->typeID() == todoID ) { 1521 if ( incidence->typeID() == todoID ) {
1522 Todo * t = (Todo*)incidence; 1522 Todo * t = (Todo*)incidence;
1523 if ( t->hasDueDate() ) 1523 if ( t->hasDueDate() )
1524 dt = t->dtDue(); 1524 dt = t->dtDue();
1525 else 1525 else
1526 dt = cur.addSecs( 62 ); 1526 dt = cur.addSecs( 62 );
1527 } 1527 }
1528 else { 1528 else {
1529 bool ok; 1529 bool ok;
1530 dt = incidence->getNextOccurence( cur, &ok ); 1530 dt = incidence->getNextOccurence( cur, &ok );
1531 if ( !ok ) 1531 if ( !ok )
1532 dt = cur.addSecs( -62 ); 1532 dt = cur.addSecs( -62 );
1533 } 1533 }
1534 if ( dt < cur || dt > end ) { 1534 if ( dt < cur || dt > end ) {
1535 add = false; 1535 add = false;
1536 } 1536 }
1537 } 1537 }
1538 if ( add ) { 1538 if ( add ) {
1539 Incidence *in = incidence->clone(); 1539 Incidence *in = incidence->clone();
1540 cal->addIncidence( in ); 1540 cal->addIncidence( in );
1541 } 1541 }
1542 } 1542 }
1543 incidence = delSel.next(); 1543 incidence = delSel.next();
1544 } 1544 }
1545 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1545 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1546 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1546 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1547 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1547 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1548 1548
1549 setCaption( i18n("Writing to phone...")); 1549 setCaption( i18n("Writing to phone..."));
1550 if ( PhoneFormat::writeToPhone( cal ) ) 1550 if ( PhoneFormat::writeToPhone( cal ) )
1551 setCaption( i18n("Export to phone successful!")); 1551 setCaption( i18n("Export to phone successful!"));
1552 else 1552 else
1553 setCaption( i18n("Error exporting to phone!")); 1553 setCaption( i18n("Error exporting to phone!"));
1554 delete cal; 1554 delete cal;
1555} 1555}
1556 1556
1557 1557
1558void MainWindow::setDefaultPreferences() 1558void MainWindow::setDefaultPreferences()
1559{ 1559{
1560 KOPrefs *p = KOPrefs::instance(); 1560 KOPrefs *p = KOPrefs::instance();
1561 1561
1562 p->mCompactDialogs = true; 1562 p->mCompactDialogs = true;
1563 p->mConfirm = true; 1563 p->mConfirm = true;
1564 // p->mEnableQuickTodo = false; 1564 // p->mEnableQuickTodo = false;
1565 1565
1566} 1566}
1567 1567
1568QString MainWindow::resourcePath() 1568QString MainWindow::resourcePath()
1569{ 1569{
1570 return KGlobal::iconLoader()->iconPath(); 1570 return KGlobal::iconLoader()->iconPath();
1571} 1571}
1572 1572
1573void MainWindow::displayText( QString text ,QString cap ) 1573void MainWindow::displayText( QString text ,QString cap )
1574{ 1574{
1575 QDialog dia( this, "name", true ); ; 1575 QDialog dia( this, "name", true ); ;
1576 dia.setCaption( cap ); 1576 dia.setCaption( cap );
1577 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1577 QVBoxLayout* lay = new QVBoxLayout( &dia );
1578 lay->setSpacing( 3 ); 1578 lay->setSpacing( 3 );
1579 lay->setMargin( 3 ); 1579 lay->setMargin( 3 );
1580 QTextBrowser tb ( &dia ); 1580 QTextBrowser tb ( &dia );
1581 lay->addWidget( &tb ); 1581 lay->addWidget( &tb );
1582 tb.setText( text ); 1582 tb.setText( text );
1583#ifdef DESKTOP_VERSION 1583#ifdef DESKTOP_VERSION
1584 dia.resize( 640, 480); 1584 dia.resize( 640, 480);
1585#else 1585#else
1586 dia.showMaximized(); 1586 dia.showMaximized();
1587#endif 1587#endif
1588 dia.exec(); 1588 dia.exec();
1589} 1589}
1590 1590
1591void MainWindow::features() 1591void MainWindow::features()
1592{ 1592{
1593 1593
1594 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1594 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1595} 1595}
1596 1596
1597void MainWindow::usertrans() 1597void MainWindow::usertrans()
1598{ 1598{
1599 1599
1600 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1600 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1601} 1601}
1602 1602
1603void MainWindow::storagehowto() 1603void MainWindow::storagehowto()
1604{ 1604{
1605 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1605 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1606} 1606}
1607void MainWindow::timetrackinghowto() 1607void MainWindow::timetrackinghowto()
1608{ 1608{
1609 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1609 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1610} 1610}
1611void MainWindow::kdesynchowto() 1611void MainWindow::kdesynchowto()
1612{ 1612{
1613 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1613 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1614} 1614}
1615void MainWindow::multisynchowto() 1615void MainWindow::multisynchowto()
1616{ 1616{
1617 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1617 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1618} 1618}
1619void MainWindow::synchowto() 1619void MainWindow::synchowto()
1620{ 1620{
1621 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1621 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1622} 1622}
1623void MainWindow::faq() 1623void MainWindow::faq()
1624{ 1624{
1625 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1625 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1626 1626
1627} 1627}
1628void MainWindow::whatsNew() 1628void MainWindow::whatsNew()
1629{ 1629{
1630 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1630 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1631 1631
1632} 1632}
1633void MainWindow::licence() 1633void MainWindow::licence()
1634{ 1634{
1635 KApplication::showLicence(); 1635 KApplication::showLicence();
1636 1636
1637} 1637}
1638void MainWindow::about() 1638void MainWindow::about()
1639{ 1639{
1640 QString version; 1640 QString version;
1641#include <../version> 1641#include <../version>
1642 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1642 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1643 i18n("KOrganizer/Platform-independent\n") + 1643 i18n("KOrganizer/Platform-independent\n") +
1644 "(KO/Pi) " + version + " - " + 1644 "(KO/Pi) " + version + " - " +
1645 1645
1646#ifdef DESKTOP_VERSION 1646#ifdef DESKTOP_VERSION
1647 i18n("Desktop Edition\n") + 1647 i18n("Desktop Edition\n") +
1648#else 1648#else
1649 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1649 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1650#endif 1650#endif
1651 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1651 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1652} 1652}
1653void MainWindow::keyBindings() 1653void MainWindow::keyBindings()
1654{ 1654{
1655 QString cap = i18n("KO/Pi Keys + Colors"); 1655 QString cap = i18n("KO/Pi Keys + Colors");
1656 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1656 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1657 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1657 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1658 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1658 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1659 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1659 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1660 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1660 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1661 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1661 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1662 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1662 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1663 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1663 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1664 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1664 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1665 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1665 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1666 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ 1666 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+
1667 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1667 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1668 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1668 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1669 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1669 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1670 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1670 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1671 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1671 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1672 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1672 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1673 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1673 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1674 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1674 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1675 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1675 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1676 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1676 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1677 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1677 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1678 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1678 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1679 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1679 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1680 i18n("<p><h3>In agenda view:</h3></p>\n") + 1680 i18n("<p><h3>In agenda view:</h3></p>\n") +
1681 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1681 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1682 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1682 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1683 i18n("<p><h3>In todo view:</h3></p>\n") + 1683 i18n("<p><h3>In todo view:</h3></p>\n") +
1684 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1684 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1685 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1685 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1686 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1686 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1687 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1687 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1688 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1688 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1689 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1689 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1690 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1690 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1691 i18n("<p><h3>In list view:</h3></p>\n") + 1691 i18n("<p><h3>In list view:</h3></p>\n") +
1692 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1692 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1693 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1693 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1694 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1694 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1695 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1695 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1696 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1696 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1697 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1697 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1698 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1698 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1699 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1699 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1700 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1700 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1701 i18n("<p><b>E</b>: Edit item</p>\n") + 1701 i18n("<p><b>E</b>: Edit item</p>\n") +
1702 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1702 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1703 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1703 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1704 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1704 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1705 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1705 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1706 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1706 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1707 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1707 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1708 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1708 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1709 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1709 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1710 i18n("<p><b>White</b>: Item readonly</p>\n"); 1710 i18n("<p><b>White</b>: Item readonly</p>\n");
1711 displayText( text, cap); 1711 displayText( text, cap);
1712} 1712}
1713void MainWindow::aboutAutoSaving() 1713void MainWindow::aboutAutoSaving()
1714{ 1714{
1715 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"); 1715 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");
1716 1716
1717 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1717 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1718 1718
1719} 1719}
1720void MainWindow::aboutKnownBugs() 1720void MainWindow::aboutKnownBugs()
1721{ 1721{
1722 QMessageBox* msg; 1722 QMessageBox* msg;
1723 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1723 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1724 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")+ 1724 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")+
1725 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1725 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1726 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1726 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1727 i18n("\nor report them in the bugtracker on\n") + 1727 i18n("\nor report them in the bugtracker on\n") +
1728 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1728 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1729 QMessageBox::NoIcon, 1729 QMessageBox::NoIcon,
1730 QMessageBox::Ok, 1730 QMessageBox::Ok,
1731 QMessageBox::NoButton, 1731 QMessageBox::NoButton,
1732 QMessageBox::NoButton); 1732 QMessageBox::NoButton);
1733 msg->exec(); 1733 msg->exec();
1734 delete msg; 1734 delete msg;
1735 1735
1736} 1736}
1737 1737
1738QString MainWindow::defaultFileName() 1738QString MainWindow::defaultFileName()
1739{ 1739{
1740 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); 1740 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) );
1741} 1741}
1742QString MainWindow::syncFileName() 1742QString MainWindow::syncFileName()
1743{ 1743{
1744#ifdef DESKTOP_VERSION 1744#ifdef DESKTOP_VERSION
1745 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); 1745 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) );
1746#else 1746#else
1747 return QString( "/tmp/synccalendar.ics" ); 1747 return QString( "/tmp/synccalendar.ics" );
1748#endif 1748#endif
1749} 1749}
1750#include "koglobals.h" 1750#include "koglobals.h"
1751#include <kcalendarsystem.h> 1751#include <kcalendarsystem.h>
1752void MainWindow::updateWeek(QDate seda) 1752void MainWindow::updateWeek(QDate seda)
1753{ 1753{
1754 int weekNum = KGlobal::locale()->weekNum ( seda ); 1754 int weekNum = KGlobal::locale()->weekNum ( seda );
1755 mWeekPixmap.fill( mWeekBgColor ); 1755 mWeekPixmap.fill( mWeekBgColor );
1756 QPainter p ( &mWeekPixmap ); 1756 QPainter p ( &mWeekPixmap );
1757 p.setFont( mWeekFont ); 1757 p.setFont( mWeekFont );
1758 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1758 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1759 p.end(); 1759 p.end();
1760 QIconSet icon3 ( mWeekPixmap ); 1760 QIconSet icon3 ( mWeekPixmap );
1761 mWeekAction->setIconSet ( icon3 ); 1761 mWeekAction->setIconSet ( icon3 );
1762 1762
1763} 1763}
1764void MainWindow::updateWeekNum(const DateList &selectedDates) 1764void MainWindow::updateWeekNum(const DateList &selectedDates)
1765{ 1765{
1766 updateWeek( selectedDates.first() ); 1766 updateWeek( selectedDates.first() );
1767} 1767}
1768void MainWindow::processIncidenceSelection( Incidence *incidence ) 1768void MainWindow::processIncidenceSelection( Incidence *incidence )
1769{ 1769{
1770 if ( !incidence ) { 1770 if ( !incidence ) {
1771 mShowAction->setMenuText( i18n("Show") ); 1771 mShowAction->setMenuText( i18n("Show") );
1772 enableIncidenceActions( false ); 1772 enableIncidenceActions( false );
1773 mNewSubTodoAction->setEnabled( false ); 1773 mNewSubTodoAction->setEnabled( false );
1774 setCaptionToDates(); 1774 setCaptionToDates();
1775 return; 1775 return;
1776 } 1776 }
1777 QString startString = ""; 1777 QString startString = "";
1778 if ( incidence->typeID() != todoID ) { 1778 if ( incidence->typeID() != todoID ) {
1779 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1779 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1780 if ( incidence->doesFloat() ) { 1780 if ( incidence->doesFloat() ) {
1781 startString += ": "+incidence->dtStartDateStr( true ); 1781 startString += ": "+incidence->dtStartDateStr( true );
1782 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1782 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1783 } else { 1783 } else {
1784 startString = ": "+incidence->dtStartStr(true); 1784 startString = ": "+incidence->dtStartStr(true);
1785 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1785 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1786 } 1786 }
1787 } else { 1787 } else {
1788 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1788 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1789 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1789 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1790 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1790 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1791 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1791 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1792 bool ok; 1792 bool ok;
1793 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1793 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1794 if ( ok ) { 1794 if ( ok ) {
1795 int years = noc.date().year() - incidence->dtStart().date().year(); 1795 int years = noc.date().year() - incidence->dtStart().date().year();
1796 startString += i18n(" (%1 y.)"). arg( years ); 1796 startString += i18n(" (%1 y.)"). arg( years );
1797 } 1797 }
1798 } 1798 }
1799 else 1799 else
1800 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1800 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1801 } 1801 }
1802 } 1802 }
1803 else { 1803 else {
1804 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) 1804 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 )
1805 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); 1805 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) );
1806 else 1806 else
1807 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1807 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1808 } 1808 }
1809 if ( !incidence->location().isEmpty() ) 1809 if ( !incidence->location().isEmpty() )
1810 startString += " (" +incidence->location()+")"; 1810 startString += " (" +incidence->location()+")";
1811 setCaption( incidence->summary()+startString); 1811 setCaption( incidence->summary()+startString);
1812 enableIncidenceActions( true ); 1812 enableIncidenceActions( true );
1813 if ( incidence->typeID() == eventID ) { 1813 if ( incidence->typeID() == eventID ) {
1814 mShowAction->setMenuText( i18n("Show Event") ); 1814 mShowAction->setMenuText( i18n("Show Event") );
1815 mNewSubTodoAction->setEnabled( false ); 1815 mNewSubTodoAction->setEnabled( false );
1816 } else if ( incidence->typeID() == todoID ) { 1816 } else if ( incidence->typeID() == todoID ) {
1817 mShowAction->setMenuText( i18n("Show Todo") ); 1817 mShowAction->setMenuText( i18n("Show Todo") );
1818 mNewSubTodoAction->setEnabled( true ); 1818 mNewSubTodoAction->setEnabled( true );
1819 } else { 1819 } else {
1820 mShowAction->setMenuText( i18n("Show") ); 1820 mShowAction->setMenuText( i18n("Show") );
1821 mNewSubTodoAction->setEnabled( false ); 1821 mNewSubTodoAction->setEnabled( false );
1822 } 1822 }
1823#ifdef DESKTOP_VERSION 1823#ifdef DESKTOP_VERSION
1824 static QPixmap jP = SmallIcon( "journal" ); 1824 static QPixmap jP = SmallIcon( "journal" );
1825 static QPixmap eP = SmallIcon( "newevent" ); 1825 static QPixmap eP = SmallIcon( "newevent" );
1826 static QPixmap tP = SmallIcon( "newtodo" ); 1826 static QPixmap tP = SmallIcon( "newtodo" );
1827 QIconSet icon; 1827 QIconSet icon;
1828 if ( incidence->typeID() == todoID ) 1828 if ( incidence->typeID() == todoID )
1829 icon = QIconSet ( tP ); 1829 icon = QIconSet ( tP );
1830 else if ( incidence->typeID() == eventID ) 1830 else if ( incidence->typeID() == eventID )
1831 icon = QIconSet ( eP ); 1831 icon = QIconSet ( eP );
1832 else if ( incidence->typeID() == journalID ) 1832 else if ( incidence->typeID() == journalID )
1833 icon = QIconSet ( jP ); 1833 icon = QIconSet ( jP );
1834 mPrintSelAction->setIconSet ( icon ); 1834 mPrintSelAction->setIconSet ( icon );
1835#endif 1835#endif
1836} 1836}
1837 1837
1838void MainWindow::enableIncidenceActions( bool enabled ) 1838void MainWindow::enableIncidenceActions( bool enabled )
1839{ 1839{
1840 mShowAction->setEnabled( enabled ); 1840 mShowAction->setEnabled( enabled );
1841 mEditAction->setEnabled( enabled ); 1841 mEditAction->setEnabled( enabled );
1842 mDeleteAction->setEnabled( enabled ); 1842 mDeleteAction->setEnabled( enabled );
1843 1843
1844 mCloneAction->setEnabled( enabled ); 1844 mCloneAction->setEnabled( enabled );
1845 mMoveAction->setEnabled( enabled ); 1845 mMoveAction->setEnabled( enabled );
1846#ifndef DESKTOP_VERSION 1846#ifndef DESKTOP_VERSION
1847 mBeamAction->setEnabled( enabled ); 1847 mBeamAction->setEnabled( enabled );
1848#else 1848#else
1849 mPrintSelAction->setEnabled( enabled ); 1849 mPrintSelAction->setEnabled( enabled );
1850#endif 1850#endif
1851 mCancelAction->setEnabled( enabled ); 1851 mCancelAction->setEnabled( enabled );
1852} 1852}
1853 1853
1854void MainWindow::importOL() 1854void MainWindow::importOL()
1855{ 1855{
1856#ifdef _OL_IMPORT_ 1856#ifdef _OL_IMPORT_
1857 mView->clearAllViews(); 1857 mView->clearAllViews();
1858 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1858 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1859 id->exec(); 1859 id->exec();
1860 delete id; 1860 delete id;
1861 mView->calendar()->checkAlarmForIncidence( 0, true ); 1861 mView->calendar()->checkAlarmForIncidence( 0, true );
1862 mView->updateView(); 1862 mView->updateView();
1863#endif 1863#endif
1864} 1864}
1865void MainWindow::importBday() 1865void MainWindow::importBday()
1866{ 1866{
1867 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), 1867 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"),
1868 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1868 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1869 i18n("Import!"), i18n("Cancel"), 0, 1869 i18n("Import!"), i18n("Cancel"), 0,
1870 0, 1 ); 1870 0, 1 );
1871 if ( result == 0 ) { 1871 if ( result == 0 ) {
1872 mView->importBday(); 1872 mView->importBday();
1873 1873
1874 } 1874 }
1875 1875
1876 1876
1877} 1877}
1878void MainWindow::importQtopia() 1878void MainWindow::importQtopia()
1879{ 1879{
1880 //#ifndef DESKTOP_VERSION 1880 //#ifndef DESKTOP_VERSION
1881 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1881 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1882#ifdef DESKTOP_VERSION 1882#ifdef DESKTOP_VERSION
1883 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1883 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1884#endif 1884#endif
1885 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1885 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1886 i18n("Import!"), i18n("Cancel"), 0, 1886 i18n("Import!"), i18n("Cancel"), 0,
1887 0, 1 ); 1887 0, 1 );
1888 if ( result == 0 ) { 1888 if ( result == 0 ) {
1889#ifndef DESKTOP_VERSION 1889#ifndef DESKTOP_VERSION
1890 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1890 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1891 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1891 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1892 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1892 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1893#else 1893#else
1894 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1894 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1895 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1895 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1896 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1896 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1897#endif 1897#endif
1898 mView->importQtopia( categories, datebook, todolist ); 1898 mView->importQtopia( categories, datebook, todolist );
1899 } 1899 }
1900 mView->calendar()->reInitAlarmSettings(); 1900 mView->calendar()->reInitAlarmSettings();
1901#if 0 1901#if 0
1902 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1902 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1903 i18n("Not supported \non desktop!\n"), 1903 i18n("Not supported \non desktop!\n"),
1904 i18n("Ok"), i18n("Cancel"), 0, 1904 i18n("Ok"), i18n("Cancel"), 0,
1905 0, 1 ); 1905 0, 1 );
1906 1906
1907#endif 1907#endif
1908} 1908}
1909 1909
1910void MainWindow::saveOnClose() 1910void MainWindow::saveOnClose()
1911{ 1911{
1912 KOPrefs *p = KOPrefs::instance(); 1912 KOPrefs *p = KOPrefs::instance();
1913 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1913 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1914 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1914 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1915 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1915 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1916 if ( filterToolBar ) { 1916 if ( filterToolBar ) {
1917 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1917 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1918 } 1918 }
1919#ifdef DESKTOP_VERSION 1919#ifdef DESKTOP_VERSION
1920 1920
1921 QPoint myP; 1921 QPoint myP;
1922 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1922 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1923 if ( p->mToolBarHor ) 1923 if ( p->mToolBarHor )
1924 p->mToolBarUp = myP.y() > height()/2; 1924 p->mToolBarUp = myP.y() > height()/2;
1925 else 1925 else
1926 p->mToolBarUp = myP.x() > width()/2; 1926 p->mToolBarUp = myP.x() > width()/2;
1927 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1927 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1928 if ( p->mToolBarHorV ) 1928 if ( p->mToolBarHorV )
1929 p->mToolBarUpV = myP.y() > height()/2; 1929 p->mToolBarUpV = myP.y() > height()/2;
1930 else 1930 else
1931 p->mToolBarUpV = myP.x() > width()/2 ; 1931 p->mToolBarUpV = myP.x() > width()/2 ;
1932 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1932 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1933 if ( p->mToolBarHorN ) 1933 if ( p->mToolBarHorN )
1934 p->mToolBarUpN = myP.y() > height()/2; 1934 p->mToolBarUpN = myP.y() > height()/2;
1935 else 1935 else
1936 p->mToolBarUpN = myP.x() > width()/2 ; 1936 p->mToolBarUpN = myP.x() > width()/2 ;
1937 if ( filterToolBar ) { 1937 if ( filterToolBar ) {
1938 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1938 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1939 if ( p->mToolBarHorF ) 1939 if ( p->mToolBarHorF )
1940 p->mToolBarUpF = myP.y() > height()/2; 1940 p->mToolBarUpF = myP.y() > height()/2;
1941 else 1941 else
1942 p->mToolBarUpF = myP.x() > width()/2 ; 1942 p->mToolBarUpF = myP.x() > width()/2 ;
1943 } 1943 }
1944#else 1944#else
1945 if ( p->mToolBarHor ) 1945 if ( p->mToolBarHor )
1946 p->mToolBarUp = iconToolBar->y() > height()/2; 1946 p->mToolBarUp = iconToolBar->y() > height()/2;
1947 else 1947 else
1948 p->mToolBarUp = iconToolBar->x() > width()/2; 1948 p->mToolBarUp = iconToolBar->x() > width()/2;
1949 if ( p->mToolBarHorV ) 1949 if ( p->mToolBarHorV )
1950 p->mToolBarUpV = viewToolBar->y() > height()/2; 1950 p->mToolBarUpV = viewToolBar->y() > height()/2;
1951 else 1951 else
1952 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1952 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1953 1953
1954 if ( p->mToolBarHorN ) 1954 if ( p->mToolBarHorN )
1955 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1955 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1956 else 1956 else
1957 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1957 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1958 if ( filterToolBar ) { 1958 if ( filterToolBar ) {
1959 if ( p->mToolBarHorF ) 1959 if ( p->mToolBarHorF )
1960 p->mToolBarUpF = filterToolBar->y() > height()/2; 1960 p->mToolBarUpF = filterToolBar->y() > height()/2;
1961 else 1961 else
1962 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1962 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1963 } 1963 }
1964#endif 1964#endif
1965 save(); 1965 save();
1966 mView->writeSettings(); 1966 mView->writeSettings();
1967 mView->checkSuspendAlarm(); 1967 mView->checkSuspendAlarm();
1968} 1968}
1969void MainWindow::slotModifiedChanged( bool ) 1969void MainWindow::slotModifiedChanged( bool )
1970{ 1970{
1971 if ( mBlockAtStartup ) 1971 if ( mBlockAtStartup )
1972 return; 1972 return;
1973 1973
1974 int msec; 1974 int msec;
1975 if ( mCalendarModifiedFlag ) { 1975 if ( mCalendarModifiedFlag ) {
1976 //qDebug(" MainWindow timer is running "); 1976 //qDebug(" MainWindow timer is running ");
1977 return; 1977 return;
1978 } 1978 }
1979 // we store the changes after 1 minute, 1979 // we store the changes after 1 minute,
1980 // and for safety reasons after 10 minutes again 1980 // and for safety reasons after 10 minutes again
1981 if ( !mSyncManager->blockSave() ) 1981 if ( !mSyncManager->blockSave() )
1982 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1982 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1983 else 1983 else
1984 msec = 1000 * 600; 1984 msec = 1000 * 600;
1985 mSaveTimer.start( msec, true ); // 1 minute 1985 mSaveTimer.start( msec, true ); // 1 minute
1986 mSaveTimerStart = QDateTime::currentDateTime(); 1986 mSaveTimerStart = QDateTime::currentDateTime();
1987 mSaveDelay = msec/1000; 1987 mSaveDelay = msec/1000;
1988 qDebug("KO: Saving File in %d secs!", msec/1000); 1988 qDebug("KO: Saving File in %d secs!", msec/1000);
1989 mCalendarModifiedFlag = true; 1989 mCalendarModifiedFlag = true;
1990} 1990}
1991void MainWindow::saveStopTimer() 1991void MainWindow::saveStopTimer()
1992{ 1992{
1993 mSaveTimer.stop(); 1993 mSaveTimer.stop();
1994} 1994}
1995void MainWindow::backupAllFiles() 1995void MainWindow::backupAllFiles()
1996{ 1996{
1997 QDate reference ( 2000,1,1); 1997 QDate reference ( 2000,1,1);
1998 int daysTo = reference.daysTo ( QDate::currentDate() ); 1998 int daysTo = reference.daysTo ( QDate::currentDate() );
1999 setCaption(i18n("Creating backup ... please wait ..." )); 1999 setCaption(i18n("Creating backup ... please wait ..." ));
2000 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 2000 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
2001 // we need the file path, the backup dir and the number of bups as param 2001 // we need the file path, the backup dir and the number of bups as param
2002 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2002 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2003 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2003 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2004 bupDir = KGlobalSettings::backupDataDir(); 2004 bupDir = KGlobalSettings::backupDataDir();
2005 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 2005 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
2006 if ( retval == 0 ) { 2006 if ( retval == 0 ) {
2007 setCaption(i18n("Backup cancelled" )); 2007 setCaption(i18n("Backup cancelled" ));
2008 qDebug("KO: Backup cancelled. Will try again tomorrow "); 2008 qDebug("KO: Backup cancelled. Will try again tomorrow ");
2009 // retval == 0 : backup skipped for today, try again tomorrow 2009 // retval == 0 : backup skipped for today, try again tomorrow
2010 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 2010 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
2011 } else if ( retval == 1 ){ 2011 } else if ( retval == 1 ){
2012 qDebug("KO: Backup created."); 2012 qDebug("KO: Backup created.");
2013 // backup ok 2013 // backup ok
2014 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2014 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2015 KopiCalendarFile * cal = calendars.first(); 2015 KopiCalendarFile * cal = calendars.first();
2016 cal = calendars.next(); 2016 cal = calendars.next();
2017 while ( cal ) { 2017 while ( cal ) {
2018 if ( !cal->mErrorOnLoad ) { 2018 if ( !cal->mErrorOnLoad ) {
2019 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 2019 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
2020 } 2020 }
2021 cal = calendars.next(); 2021 cal = calendars.next();
2022 } 2022 }
2023 KOPrefs::instance()->mLastBackupDate = daysTo; 2023 KOPrefs::instance()->mLastBackupDate = daysTo;
2024 setCaption(i18n("Backup succesfully finished" )); 2024 setCaption(i18n("Backup succesfully finished" ));
2025 } else if ( retval == 2 ){ 2025 } else if ( retval == 2 ){
2026 setCaption(i18n("Backup globally disabled" )); 2026 setCaption(i18n("Backup globally disabled" ));
2027 qDebug("KO: Backup globally cancelled."); 2027 qDebug("KO: Backup globally cancelled.");
2028 // backup globally cancelled 2028 // backup globally cancelled
2029 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2029 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2030 } 2030 }
2031 // retval == 3: do nothing, try again later 2031 // retval == 3: do nothing, try again later
2032} 2032}
2033void MainWindow::save() 2033void MainWindow::save()
2034{ 2034{
2035 if ( mSaveDelay ) { 2035 if ( mSaveDelay ) {
2036 int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); 2036 int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() );
2037 if ( mSaveDelay < elapsed ) { 2037 if ( mSaveDelay < elapsed ) {
2038 qDebug("KO: Pending save after wakeup from suspend detected."); 2038 qDebug("KO: Pending save after wakeup from suspend detected.");
2039 qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); 2039 qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed );
2040 qDebug("KO: Restarting save timer to save in 10 sec."); 2040 qDebug("KO: Restarting save timer to save in 10 sec.");
2041 int msec = 10000; 2041 int msec = 10000;
2042 mSaveTimer.start( msec, true ); 2042 mSaveTimer.start( msec, true );
2043 mSaveTimerStart = QDateTime::currentDateTime(); 2043 mSaveTimerStart = QDateTime::currentDateTime();
2044 mSaveDelay = msec/1000; 2044 mSaveDelay = msec/1000;
2045 return; 2045 return;
2046 } 2046 }
2047 } 2047 }
2048
2049 if ( mView->viewManager()->journalView() ) 2048 if ( mView->viewManager()->journalView() )
2050 mView->viewManager()->journalView()->checkModified(); 2049 mView->viewManager()->journalView()->checkModified();
2051 if ( !mCalendarModifiedFlag ) { 2050 if ( !mCalendarModifiedFlag ) {
2052 qDebug("KO: Calendar not modified. Nothing saved."); 2051 qDebug("KO: Calendar not modified. Nothing saved.");
2053 return; 2052 return;
2054 } 2053 }
2055 if ( mSyncManager->blockSave() ) { 2054 if ( mSyncManager->blockSave() ) {
2056 slotModifiedChanged( true ); 2055 slotModifiedChanged( true );
2057 return; 2056 return;
2058 } 2057 }
2058#ifndef DESKTOP_VERSION
2059 QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable );
2060#endif
2059 mSaveDelay = 0; 2061 mSaveDelay = 0;
2060 mSyncManager->setBlockSave(true); 2062 mSyncManager->setBlockSave(true);
2061 if ( mView->checkAllFileVersions() ) { 2063 if ( mView->checkAllFileVersions() ) {
2062 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 2064 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
2063 QDate reference ( 2000,1,1); 2065 QDate reference ( 2000,1,1);
2064 int daysTo = reference.daysTo ( QDate::currentDate() ); 2066 int daysTo = reference.daysTo ( QDate::currentDate() );
2065 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 2067 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
2066 backupAllFiles(); 2068 backupAllFiles();
2067 } 2069 }
2068 ; // KPimGlobalPrefs::instance()->mLastBackupDate 2070 ; // KPimGlobalPrefs::instance()->mLastBackupDate
2069 } 2071 }
2070 QTime neededSaveTime; 2072 QTime neededSaveTime;
2071 neededSaveTime.start(); 2073 neededSaveTime.start();
2072 if ( !isMinimized () ) 2074 if ( !isMinimized () )
2073 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 2075 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
2074 qDebug("KO: Start saving data to file!"); 2076 qDebug("KO: Start saving data to file!");
2075 if ( mView->saveCalendars() ) 2077 if ( mView->saveCalendars() )
2076 mCalendarModifiedFlag = false; 2078 mCalendarModifiedFlag = false;
2077 int msNeeded = neededSaveTime.elapsed(); 2079 int msNeeded = neededSaveTime.elapsed();
2078 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2080 qDebug("KO: Needed %d ms for saving.",msNeeded );
2079 QString savemes; 2081 QString savemes;
2080 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2082 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2081 if ( !isMinimized () ) 2083 if ( !isMinimized () )
2082 setCaption(savemes); 2084 setCaption(savemes);
2083 else 2085 else
2084 qDebug(savemes); 2086 qDebug(savemes);
2085 } else { 2087 } else {
2086 setCaption(i18n("Saving cancelled!")); 2088 setCaption(i18n("Saving cancelled!"));
2087 mCalendarModifiedFlag = false; 2089 mCalendarModifiedFlag = false;
2088 slotModifiedChanged( true ); 2090 slotModifiedChanged( true );
2089 } 2091 }
2090 mSyncManager->setBlockSave( false ); 2092 mSyncManager->setBlockSave( false );
2093#ifndef DESKTOP_VERSION
2094 QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable );
2095#endif
2091} 2096}
2092 2097
2093void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2098void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2094{ 2099{
2095 if ( !e->isAutoRepeat() ) { 2100 if ( !e->isAutoRepeat() ) {
2096 mFlagKeyPressed = false; 2101 mFlagKeyPressed = false;
2097 } 2102 }
2098} 2103}
2099void MainWindow::keyPressEvent ( QKeyEvent * e ) 2104void MainWindow::keyPressEvent ( QKeyEvent * e )
2100{ 2105{
2101 qApp->processEvents(); 2106 qApp->processEvents();
2102 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2107 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2103 e->ignore(); 2108 e->ignore();
2104 // qDebug(" ignore %d",e->isAutoRepeat() ); 2109 // qDebug(" ignore %d",e->isAutoRepeat() );
2105 return; 2110 return;
2106 } 2111 }
2107 if (! e->isAutoRepeat() ) 2112 if (! e->isAutoRepeat() )
2108 mFlagKeyPressed = true; 2113 mFlagKeyPressed = true;
2109 KOPrefs *p = KOPrefs::instance(); 2114 KOPrefs *p = KOPrefs::instance();
2110 bool showSelectedDates = false; 2115 bool showSelectedDates = false;
2111 int size; 2116 int size;
2112 int pro = 0; 2117 int pro = 0;
2113 //qDebug("MainWindow::keyPressEvent "); 2118 //qDebug("MainWindow::keyPressEvent ");
2114 switch ( e->key() ) { 2119 switch ( e->key() ) {
2115 case Qt::Key_Right: 2120 case Qt::Key_Right:
2116 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2121 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2117 mView->goNextMonth(); 2122 mView->goNextMonth();
2118 else 2123 else
2119 mView->goNext(); 2124 mView->goNext();
2120 showSelectedDates = true; 2125 showSelectedDates = true;
2121 break; 2126 break;
2122 case Qt::Key_Left: 2127 case Qt::Key_Left:
2123 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2128 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2124 mView->goPreviousMonth(); 2129 mView->goPreviousMonth();
2125 else 2130 else
2126 mView->goPrevious(); 2131 mView->goPrevious();
2127 showSelectedDates = true; 2132 showSelectedDates = true;
2128 break; 2133 break;
2129 case Qt::Key_Down: 2134 case Qt::Key_Down:
2130 mView->viewManager()->agendaView()->scrollOneHourDown(); 2135 mView->viewManager()->agendaView()->scrollOneHourDown();
2131 break; 2136 break;
2132 case Qt::Key_Up: 2137 case Qt::Key_Up:
2133 mView->viewManager()->agendaView()->scrollOneHourUp(); 2138 mView->viewManager()->agendaView()->scrollOneHourUp();
2134 break; 2139 break;
2135 case Qt::Key_K: 2140 case Qt::Key_K:
2136 mView->viewManager()->showMonthViewWeek(); 2141 mView->viewManager()->showMonthViewWeek();
2137 break; 2142 break;
2138 case Qt::Key_I: 2143 case Qt::Key_I:
2139 mView->showIncidence(); 2144 mView->showIncidence();
2140 break; 2145 break;
2141 case Qt::Key_Delete: 2146 case Qt::Key_Delete:
2142 case Qt::Key_Backspace: 2147 case Qt::Key_Backspace:
2143 mView->deleteIncidence(); 2148 mView->deleteIncidence();
2144 break; 2149 break;
2145 case Qt::Key_D: 2150 case Qt::Key_D:
2146 mView->viewManager()->showDayView(); 2151 mView->viewManager()->showDayView();
2147 showSelectedDates = true; 2152 showSelectedDates = true;
2148 break; 2153 break;
2149 case Qt::Key_O: 2154 case Qt::Key_O:
2150 mView->toggleFilerEnabled( ); 2155 mView->toggleFilerEnabled( );
2151 break; 2156 break;
2152 case Qt::Key_0: 2157 case Qt::Key_0:
2153 case Qt::Key_1: 2158 case Qt::Key_1:
2154 case Qt::Key_2: 2159 case Qt::Key_2:
2155 case Qt::Key_3: 2160 case Qt::Key_3:
2156 case Qt::Key_4: 2161 case Qt::Key_4:
2157 case Qt::Key_5: 2162 case Qt::Key_5:
2158 case Qt::Key_6: 2163 case Qt::Key_6:
2159 case Qt::Key_7: 2164 case Qt::Key_7:
2160 case Qt::Key_8: 2165 case Qt::Key_8:
2161 case Qt::Key_9: 2166 case Qt::Key_9:
2162 pro = e->key()-48; 2167 pro = e->key()-48;
2163 if ( pro == 0 ) 2168 if ( pro == 0 )
2164 pro = 10; 2169 pro = 10;
2165 if ( e->state() == Qt::ControlButton) 2170 if ( e->state() == Qt::ControlButton)
2166 pro += 10; 2171 pro += 10;
2167 break; 2172 break;
2168 case Qt::Key_M: 2173 case Qt::Key_M:
2169 mView->viewManager()->showMonthView(); 2174 mView->viewManager()->showMonthView();
2170 showSelectedDates = true; 2175 showSelectedDates = true;
2171 break; 2176 break;
2172 case Qt::Key_Insert: 2177 case Qt::Key_Insert:
2173 mView->newEvent(); 2178 mView->newEvent();
2174 break; 2179 break;
2175 case Qt::Key_S : 2180 case Qt::Key_S :
2176 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2181 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2177 mView->newSubTodo(); 2182 mView->newSubTodo();
2178 else 2183 else
2179 mView->dialogManager()->showSearchDialog(); 2184 mView->dialogManager()->showSearchDialog();
2180 break; 2185 break;
2181 case Qt::Key_Y : 2186 case Qt::Key_Y :
2182 case Qt::Key_Z : 2187 case Qt::Key_Z :
2183 mView->viewManager()->showWorkWeekView(); 2188 mView->viewManager()->showWorkWeekView();
2184 showSelectedDates = true; 2189 showSelectedDates = true;
2185 break; 2190 break;
2186 case Qt::Key_U : 2191 case Qt::Key_U :
2187 mView->viewManager()->showWeekView(); 2192 mView->viewManager()->showWeekView();
2188 showSelectedDates = true; 2193 showSelectedDates = true;
2189 break; 2194 break;
2190 case Qt::Key_H : 2195 case Qt::Key_H :
2191 keyBindings(); 2196 keyBindings();
2192 break; 2197 break;
2193 case Qt::Key_W: 2198 case Qt::Key_W:
2194 mView->viewManager()->showWhatsNextView(); 2199 mView->viewManager()->showWhatsNextView();
2195 break; 2200 break;
2196 case Qt::Key_L: 2201 case Qt::Key_L:
2197 mView->viewManager()->showListView(); 2202 mView->viewManager()->showListView();
2198 break; 2203 break;
2199 case Qt::Key_N: 2204 case Qt::Key_N:
2200 mView->viewManager()->showNextView(); 2205 mView->viewManager()->showNextView();
2201 break; 2206 break;
2202 case Qt::Key_V: 2207 case Qt::Key_V:
2203 mView->viewManager()->showTodoView(); 2208 mView->viewManager()->showTodoView();
2204 break; 2209 break;
2205 case Qt::Key_C: 2210 case Qt::Key_C:
2206 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 2211 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
2207 break; 2212 break;
2208 case Qt::Key_P: 2213 case Qt::Key_P:
2209 mView->showDatePicker( ); 2214 mView->showDatePicker( );
2210 break; 2215 break;
2211 case Qt::Key_F: 2216 case Qt::Key_F:
2212 mView->editFilters(); 2217 mView->editFilters();
2213 break; 2218 break;
2214 case Qt::Key_R: 2219 case Qt::Key_R:
2215 mView->toggleFilter(); 2220 mView->toggleFilter();
2216 break; 2221 break;
2217 case Qt::Key_X: 2222 case Qt::Key_X:
2218 if ( e->state() == Qt::ControlButton ) 2223 if ( e->state() == Qt::ControlButton )
2219 mView->toggleDateNavigatorWidget(); 2224 mView->toggleDateNavigatorWidget();
2220 else { 2225 else {
2221 mView->viewManager()->showNextXView(); 2226 mView->viewManager()->showNextXView();
2222 showSelectedDates = true; 2227 showSelectedDates = true;
2223 } 2228 }
2224 break; 2229 break;
2225 case Qt::Key_Space: 2230 case Qt::Key_Space:
2226 mView->toggleExpand(); 2231 mView->toggleExpand();
2227 break; 2232 break;
2228 case Qt::Key_A: 2233 case Qt::Key_A:
2229 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2234 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2230 mView->showNextAlarms(); 2235 mView->showNextAlarms();
2231 else 2236 else
2232 mView->toggleAllDaySize(); 2237 mView->toggleAllDaySize();
2233 break; 2238 break;
2234 case Qt::Key_T: 2239 case Qt::Key_T:
2235 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2240 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2236 mView->newTodo(); 2241 mView->newTodo();
2237 else { 2242 else {
2238 mView->goToday(); 2243 mView->goToday();
2239 showSelectedDates = true; 2244 showSelectedDates = true;
2240 } 2245 }
2241 break; 2246 break;
2242 case Qt::Key_Q: 2247 case Qt::Key_Q:
2243 if ( e->state() == Qt::ControlButton ) 2248 if ( e->state() == Qt::ControlButton )
2244 mView->conflictNotAll(); 2249 mView->conflictNotAll();
2245 else if ( e->state() == Qt::ShiftButton ) 2250 else if ( e->state() == Qt::ShiftButton )
2246 mView->conflictAllday(); 2251 mView->conflictAllday();
2247 else 2252 else
2248 mView->conflictAll(); 2253 mView->conflictAll();
2249 break; 2254 break;
2250 case Qt::Key_J: 2255 case Qt::Key_J:
2251 mView->viewManager()->showJournalView(); 2256 mView->viewManager()->showJournalView();
2252 break; 2257 break;
2253 case Qt::Key_B: 2258 case Qt::Key_B:
2254 mView->editIncidenceDescription();; 2259 mView->editIncidenceDescription();;
2255 break; 2260 break;
2256 // case Qt::Key_Return: 2261 // case Qt::Key_Return:
2257 case Qt::Key_E: 2262 case Qt::Key_E:
2258 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2263 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2259 mView->newEvent(); 2264 mView->newEvent();
2260 else 2265 else
2261 mView->editIncidence(); 2266 mView->editIncidence();
2262 break; 2267 break;
2263 case Qt::Key_Plus: 2268 case Qt::Key_Plus:
2264 size = p->mHourSize +2; 2269 size = p->mHourSize +2;
2265 if ( size <= 22 ) 2270 if ( size <= 22 )
2266 configureAgenda( size ); 2271 configureAgenda( size );
2267 break; 2272 break;
2268 case Qt::Key_Minus: 2273 case Qt::Key_Minus:
2269 size = p->mHourSize - 2; 2274 size = p->mHourSize - 2;
2270 if ( size >= 4 ) 2275 if ( size >= 4 )
2271 configureAgenda( size ); 2276 configureAgenda( size );
2272 break; 2277 break;
2273 2278
2274 2279
2275 default: 2280 default:
2276 e->ignore(); 2281 e->ignore();
2277 } 2282 }
2278 if ( pro > 0 ) { 2283 if ( pro > 0 ) {
2279 selectFilter( pro+1 ); 2284 selectFilter( pro+1 );
2280 } 2285 }
2281 if ( showSelectedDates ) { 2286 if ( showSelectedDates ) {
2282 ;// setCaptionToDates(); 2287 ;// setCaptionToDates();
2283 } 2288 }
2284 2289
2285} 2290}
2286void MainWindow::fillFilterMenuTB() 2291void MainWindow::fillFilterMenuTB()
2287{ 2292{
2288 selectFilterMenuTB->clear(); 2293 selectFilterMenuTB->clear();
2289 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2294 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2290 selectFilterMenuTB->insertSeparator(); 2295 selectFilterMenuTB->insertSeparator();
2291 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2296 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2292 2297
2293 selectFilterMenuTB->insertSeparator(); 2298 selectFilterMenuTB->insertSeparator();
2294 QPtrList<CalFilter> fili = mView->filters(); 2299 QPtrList<CalFilter> fili = mView->filters();
2295 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2300 CalFilter *curfilter = mView->filterView()->selectedFilter();
2296 CalFilter *filter = fili.first(); 2301 CalFilter *filter = fili.first();
2297 int iii = 2; 2302 int iii = 2;
2298 bool checkitem = mView->filterView()->filtersEnabled(); 2303 bool checkitem = mView->filterView()->filtersEnabled();
2299 while(filter) { 2304 while(filter) {
2300 selectFilterMenuTB->insertItem( filter->name(), iii ); 2305 selectFilterMenuTB->insertItem( filter->name(), iii );
2301 if ( filter == curfilter) 2306 if ( filter == curfilter)
2302 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2307 selectFilterMenuTB->setItemChecked( iii, checkitem );
2303 filter = fili.next(); 2308 filter = fili.next();
2304 ++iii; 2309 ++iii;
2305 } 2310 }
2306 if ( !checkitem ) 2311 if ( !checkitem )
2307 selectFilterMenuTB->setItemChecked( 1, true ); 2312 selectFilterMenuTB->setItemChecked( 1, true );
2308 2313
2309 int x = 0; 2314 int x = 0;
2310 int y = iconToolBar->height(); 2315 int y = iconToolBar->height();
2311 int dX = 0; 2316 int dX = 0;
2312 int dY = 0; 2317 int dY = 0;
2313 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2318 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2314 if ( iconToolBar->y() > height()/2 ) { 2319 if ( iconToolBar->y() > height()/2 ) {
2315 dY = selectFilterMenuTB->sizeHint().height()+8; 2320 dY = selectFilterMenuTB->sizeHint().height()+8;
2316 y = 0; 2321 y = 0;
2317 } 2322 }
2318 } else { 2323 } else {
2319 if ( iconToolBar->x() > width()/2 ) { // right side 2324 if ( iconToolBar->x() > width()/2 ) { // right side
2320 x=0; 2325 x=0;
2321 dX= selectFilterMenuTB->sizeHint().width()+8; 2326 dX= selectFilterMenuTB->sizeHint().width()+8;
2322 y = 0; 2327 y = 0;
2323 } else { 2328 } else {
2324 x= iconToolBar->width(); 2329 x= iconToolBar->width();
2325 y = 0; 2330 y = 0;
2326 } 2331 }
2327 } 2332 }
2328 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2333 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2329 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2334 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2330} 2335}
2331void MainWindow::fillFilterMenu() 2336void MainWindow::fillFilterMenu()
2332{ 2337{
2333 selectFilterMenu->clear(); 2338 selectFilterMenu->clear();
2334 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2339 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2335 selectFilterMenu->insertSeparator(); 2340 selectFilterMenu->insertSeparator();
2336 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2341 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2337 2342
2338 selectFilterMenu->insertSeparator(); 2343 selectFilterMenu->insertSeparator();
2339 QPtrList<CalFilter> fili = mView->filters(); 2344 QPtrList<CalFilter> fili = mView->filters();
2340 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2345 CalFilter *curfilter = mView->filterView()->selectedFilter();
2341 CalFilter *filter = fili.first(); 2346 CalFilter *filter = fili.first();
2342 int iii = 2; 2347 int iii = 2;
2343 bool checkitem = mView->filterView()->filtersEnabled(); 2348 bool checkitem = mView->filterView()->filtersEnabled();
2344 while(filter) { 2349 while(filter) {
2345 selectFilterMenu->insertItem( filter->name(), iii ); 2350 selectFilterMenu->insertItem( filter->name(), iii );
2346 if ( filter == curfilter) 2351 if ( filter == curfilter)
2347 selectFilterMenu->setItemChecked( iii, checkitem ); 2352 selectFilterMenu->setItemChecked( iii, checkitem );
2348 filter = fili.next(); 2353 filter = fili.next();
2349 ++iii; 2354 ++iii;
2350 } 2355 }
2351 if ( !checkitem ) 2356 if ( !checkitem )
2352 selectFilterMenu->setItemChecked( 1, true ); 2357 selectFilterMenu->setItemChecked( 1, true );
2353} 2358}
2354void MainWindow::fillFilterMenuPopup() 2359void MainWindow::fillFilterMenuPopup()
2355{ 2360{
2356 filterPopupMenu->clear(); 2361 filterPopupMenu->clear();
2357 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2362 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2358 2363
2359 filterPopupMenu->insertSeparator(); 2364 filterPopupMenu->insertSeparator();
2360 QPtrList<CalFilter> fili = mView->filters(); 2365 QPtrList<CalFilter> fili = mView->filters();
2361 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2366 CalFilter *curfilter = mView->filterView()->selectedFilter();
2362 CalFilter *filter = fili.first(); 2367 CalFilter *filter = fili.first();
2363 int iii = 1; 2368 int iii = 1;
2364 bool checkitem = mView->filterView()->filtersEnabled(); 2369 bool checkitem = mView->filterView()->filtersEnabled();
2365 while(filter) { 2370 while(filter) {
2366 filterPopupMenu->insertItem( filter->name(), iii ); 2371 filterPopupMenu->insertItem( filter->name(), iii );
2367 if ( filter == curfilter) 2372 if ( filter == curfilter)
2368 filterPopupMenu->setItemChecked( iii, checkitem ); 2373 filterPopupMenu->setItemChecked( iii, checkitem );
2369 filter = fili.next(); 2374 filter = fili.next();
2370 ++iii; 2375 ++iii;
2371 } 2376 }
2372 if ( !checkitem ) 2377 if ( !checkitem )
2373 filterPopupMenu->setItemChecked( 0, true ); 2378 filterPopupMenu->setItemChecked( 0, true );
2374} 2379}
2375void MainWindow::selectFilter( int fil ) 2380void MainWindow::selectFilter( int fil )
2376{ 2381{
2377 2382
2378 if ( fil == 0 ) { 2383 if ( fil == 0 ) {
2379 mView->editFilters( ); 2384 mView->editFilters( );
2380 } else if ( fil == 1 ){ 2385 } else if ( fil == 1 ){
2381 if ( mView->filterView()->filtersEnabled() ) 2386 if ( mView->filterView()->filtersEnabled() )
2382 mView->toggleFilerEnabled( ); 2387 mView->toggleFilerEnabled( );
2383 } else { 2388 } else {
2384 if ( !mView->filterView()->filtersEnabled() ) { 2389 if ( !mView->filterView()->filtersEnabled() ) {
2385 mView->filterView()->blockSignals( true ); 2390 mView->filterView()->blockSignals( true );
2386 mView->toggleFilerEnabled( ); 2391 mView->toggleFilerEnabled( );
2387 mView->filterView()->blockSignals( false ); 2392 mView->filterView()->blockSignals( false );
2388 } 2393 }
2389 mView->selectFilter( fil-2 ); 2394 mView->selectFilter( fil-2 );
2390 } 2395 }
2391} 2396}
2392void MainWindow::updateFilterToolbar() 2397void MainWindow::updateFilterToolbar()
2393{ 2398{
2394 if ( filterMenubar ) { 2399 if ( filterMenubar ) {
2395 if ( !mView->filterView()->filtersEnabled() ) { 2400 if ( !mView->filterView()->filtersEnabled() ) {
2396 filterMenubar->changeItem( 0, i18n("No Filter") ); 2401 filterMenubar->changeItem( 0, i18n("No Filter") );
2397 } else { 2402 } else {
2398 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2403 CalFilter *curfilter = mView->filterView()->selectedFilter();
2399 if ( curfilter ) { 2404 if ( curfilter ) {
2400 QString name = curfilter->name(); 2405 QString name = curfilter->name();
2401 if ( name.length() > 12 ) 2406 if ( name.length() > 12 )
2402 name = name.left(10)+"..."; 2407 name = name.left(10)+"...";
2403 filterMenubar->changeItem( 0, name ); 2408 filterMenubar->changeItem( 0, name );
2404 } 2409 }
2405 } 2410 }
2406 } 2411 }
2407} 2412}
2408void MainWindow::selectFilterPopup( int fil ) 2413void MainWindow::selectFilterPopup( int fil )
2409{ 2414{
2410 selectFilter( fil + 1 ); 2415 selectFilter( fil + 1 );
2411 2416
2412} 2417}
2413void MainWindow::configureToolBar( int item ) 2418void MainWindow::configureToolBar( int item )
2414{ 2419{
2415 2420
2416 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2421 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2417 KOPrefs *p = KOPrefs::instance(); 2422 KOPrefs *p = KOPrefs::instance();
2418 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2423 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2419 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2424 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2420 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2425 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2421 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2426 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2422 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2427 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2423 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2428 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2424 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2429 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2425 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2430 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2426 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2431 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2427 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2432 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2428 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2433 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2429 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2434 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2430 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2435 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2431 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2436 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2432 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2437 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2433 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2438 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2434 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2439 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2435 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2440 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2436 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2441 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2437 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2442 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2438 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2443 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2439 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2444 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2440 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2445 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2441 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2446 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2442 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2447 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2443 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2448 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2444 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2449 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2445 // initActions(); 2450 // initActions();
2446 setCaption ( i18n("Toolbar changes needs a restart!") ); 2451 setCaption ( i18n("Toolbar changes needs a restart!") );
2447} 2452}
2448void MainWindow::setCaption ( const QString & c ) 2453void MainWindow::setCaption ( const QString & c )
2449{ 2454{
2450 QString cap = c; 2455 QString cap = c;
2451 cap.replace( QRegExp("\n"), " " ); 2456 cap.replace( QRegExp("\n"), " " );
2452 cap = cap.stripWhiteSpace(); 2457 cap = cap.stripWhiteSpace();
2453 if ( cap.isEmpty() ) 2458 if ( cap.isEmpty() )
2454 cap = "KO/Pi"; 2459 cap = "KO/Pi";
2455 QWidget::setCaption( cap ); 2460 QWidget::setCaption( cap );
2456} 2461}
2457void MainWindow::setCaptionToDates() 2462void MainWindow::setCaptionToDates()
2458{ 2463{
2459 QString selDates; 2464 QString selDates;
2460 QDate date = mView->startDate(); 2465 QDate date = mView->startDate();
2461 if ( ! date.isValid() ) { 2466 if ( ! date.isValid() ) {
2462 setCaption(""); 2467 setCaption("");
2463 return; 2468 return;
2464 } 2469 }
2465 selDates = KGlobal::locale()->formatDate( date, true); 2470 selDates = KGlobal::locale()->formatDate( date, true);
2466 if (mView->startDate() < mView->endDate() ) 2471 if (mView->startDate() < mView->endDate() )
2467 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2472 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2468 else { 2473 else {
2469 QString addString; 2474 QString addString;
2470 if ( date == QDateTime::currentDateTime().date() ) 2475 if ( date == QDateTime::currentDateTime().date() )
2471 addString = i18n("Today"); 2476 addString = i18n("Today");
2472 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2477 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2473 addString = i18n("Tomorrow"); 2478 addString = i18n("Tomorrow");
2474 if ( !addString.isEmpty() ) 2479 if ( !addString.isEmpty() )
2475 selDates = addString+", "+selDates ; 2480 selDates = addString+", "+selDates ;
2476 } 2481 }
2477 setCaption( i18n("Dates: ") + selDates ); 2482 setCaption( i18n("Dates: ") + selDates );
2478 2483
2479} 2484}
2480void MainWindow::showConfigureAgenda( ) 2485void MainWindow::showConfigureAgenda( )
2481{ 2486{
2482 int iii; 2487 int iii;
2483 for ( iii = 1;iii<= 10 ;++iii ){ 2488 for ( iii = 1;iii<= 10 ;++iii ){
2484 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2489 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2485 } 2490 }
2486 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2491 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2487} 2492}
2488void MainWindow::configureAgenda( int item ) 2493void MainWindow::configureAgenda( int item )
2489{ 2494{
2490 if ( KOPrefs::instance()->mHourSize == item ) 2495 if ( KOPrefs::instance()->mHourSize == item )
2491 return; 2496 return;
2492 KOPrefs::instance()->mHourSize=item; 2497 KOPrefs::instance()->mHourSize=item;
2493 mView->viewManager()->agendaView()->updateConfig(); 2498 mView->viewManager()->agendaView()->updateConfig();
2494} 2499}
2495 2500
2496void MainWindow::saveCalendar() 2501void MainWindow::saveCalendar()
2497{ 2502{
2498 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2503 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2499 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2504 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2500 bupDir = KGlobalSettings::backupDataDir(); 2505 bupDir = KGlobalSettings::backupDataDir();
2501 bupDir = KGlobal::formatMessage ( bupDir, 0 ); 2506 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2502 QString bupHint; 2507 QString bupHint;
2503 if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) 2508 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2504 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); 2509 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2505 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; 2510 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return;
2506 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; 2511 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled;
2507 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2512 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2508 save(); 2513 save();
2514#ifndef DESKTOP_VERSION
2515 QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable );
2516#endif
2509 KPimGlobalPrefs::instance()->mBackupEnabled = enabled; 2517 KPimGlobalPrefs::instance()->mBackupEnabled = enabled;
2510 backupAllFiles(); 2518 backupAllFiles();
2519#ifndef DESKTOP_VERSION
2520 QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable );
2521#endif
2511} 2522}
2512void MainWindow::loadCalendar() 2523void MainWindow::loadCalendar()
2513{ 2524{
2514 2525
2515 2526
2516#if 0 2527#if 0
2517 QString fn = KOPrefs::instance()->mLastLoadFile; 2528 QString fn = KOPrefs::instance()->mLastLoadFile;
2518 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2529 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2519 2530
2520 if ( fn == "" ) 2531 if ( fn == "" )
2521 return; 2532 return;
2522 QFileInfo info; 2533 QFileInfo info;
2523 info.setFile( fn ); 2534 info.setFile( fn );
2524 QString mess; 2535 QString mess;
2525 bool loadbup = true; 2536 bool loadbup = true;
2526 if ( info. exists() ) { 2537 if ( info. exists() ) {
2527 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2538 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2528 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2539 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2529 mess, 2540 mess,
2530 i18n("Load!"), i18n("Cancel"), 0, 2541 i18n("Load!"), i18n("Cancel"), 0,
2531 0, 1 ); 2542 0, 1 );
2532 if ( result != 0 ) { 2543 if ( result != 0 ) {
2533 loadbup = false; 2544 loadbup = false;
2534 } 2545 }
2535 } else { 2546 } else {
2536 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2547 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2537 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2548 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2538 0, 1 ); 2549 0, 1 );
2539 2550
2540 return; 2551 return;
2541 } 2552 }
2542 if ( loadbup ) { 2553 if ( loadbup ) {
2543 mView->openCalendar( fn ); 2554 mView->openCalendar( fn );
2544 KOPrefs::instance()->mLastLoadFile = fn; 2555 KOPrefs::instance()->mLastLoadFile = fn;
2545 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2556 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2546 setCaption(mess); 2557 setCaption(mess);
2547 } 2558 }
2548#endif 2559#endif
2549 2560
2550} 2561}
2551void MainWindow::quickImportIcal() 2562void MainWindow::quickImportIcal()
2552{ 2563{
2553 importFile( KOPrefs::instance()->mLastImportFile, false ); 2564 importFile( KOPrefs::instance()->mLastImportFile, false );
2554} 2565}
2555void MainWindow::importFile( QString fn, bool quick ) 2566void MainWindow::importFile( QString fn, bool quick )
2556{ 2567{
2557 QFileInfo info; 2568 QFileInfo info;
2558 info.setFile( fn ); 2569 info.setFile( fn );
2559 QString mess; 2570 QString mess;
2560 if ( !info. exists() ) { 2571 if ( !info. exists() ) {
2561 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2572 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2562 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2573 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2563 mess ); 2574 mess );
2564 return; 2575 return;
2565 } 2576 }
2566 int result = 0; 2577 int result = 0;
2567 if ( !quick ) { 2578 if ( !quick ) {
2568 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 )); 2579 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 ));
2569 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2580 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2570 mess, 2581 mess,
2571 "Import", "Cancel", 0, 2582 "Import", "Cancel", 0,
2572 0, 1 ); 2583 0, 1 );
2573 } 2584 }
2574 if ( result == 0 ) { 2585 if ( result == 0 ) {
2575 if ( mView->openCalendar( fn, true )) { 2586 if ( mView->openCalendar( fn, true )) {
2576 KOPrefs::instance()->mLastImportFile = fn; 2587 KOPrefs::instance()->mLastImportFile = fn;
2577 setCaption(i18n("Imported file successfully")); 2588 setCaption(i18n("Imported file successfully"));
2578 } else { 2589 } else {
2579 setCaption(i18n("Error importing file")); 2590 setCaption(i18n("Error importing file"));
2580 } 2591 }
2581 mView->updateView(); 2592 mView->updateView();
2582 } 2593 }
2583} 2594}
2584 2595
2585void MainWindow::importIcal() 2596void MainWindow::importIcal()
2586{ 2597{
2587 2598
2588 QString fn =KOPrefs::instance()->mLastImportFile; 2599 QString fn =KOPrefs::instance()->mLastImportFile;
2589 2600
2590 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2601 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2591 if ( fn == "" ) 2602 if ( fn == "" )
2592 return; 2603 return;
2593 importFile( fn, true ); 2604 importFile( fn, true );
2594 2605
2595} 2606}
2596void MainWindow::exportCalendar( bool iCalFormat ) 2607void MainWindow::exportCalendar( bool iCalFormat )
2597{ 2608{
2598 QString fn = KOPrefs::instance()->mLastVcalFile; 2609 QString fn = KOPrefs::instance()->mLastVcalFile;
2599 if ( iCalFormat ) { 2610 if ( iCalFormat ) {
2600 fn = QDir::homeDirPath()+"/kopiexport.ics"; 2611 fn = QDir::homeDirPath()+"/kopiexport.ics";
2601 fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); 2612 fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this );
2602 } 2613 }
2603 else 2614 else
2604 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2615 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2605 if ( fn == "" ) 2616 if ( fn == "" )
2606 return; 2617 return;
2607 QFileInfo info; 2618 QFileInfo info;
2608 info.setFile( fn ); 2619 info.setFile( fn );
2609 QString mes; 2620 QString mes;
2610 bool createbup = true; 2621 bool createbup = true;
2611 if ( info. exists() ) { 2622 if ( info. exists() ) {
2612 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2623 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2613 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2624 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2614 i18n("Overwrite!"), i18n("Cancel"), 0, 2625 i18n("Overwrite!"), i18n("Cancel"), 0,
2615 0, 1 ); 2626 0, 1 );
2616 if ( result != 0 ) { 2627 if ( result != 0 ) {
2617 createbup = false; 2628 createbup = false;
2618 } 2629 }
2619 } 2630 }
2620 if ( createbup ) { 2631 if ( createbup ) {
2621 bool success = false; 2632 bool success = false;
2622 if ( iCalFormat ) 2633 if ( iCalFormat )
2623 success = mView->exportICalendar( fn ); 2634 success = mView->exportICalendar( fn );
2624 else 2635 else
2625 success = mView->exportVCalendar( fn ); 2636 success = mView->exportVCalendar( fn );
2626 if ( success ) { 2637 if ( success ) {
2627 if ( fn.length() > 20 ) 2638 if ( fn.length() > 20 )
2628 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2639 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2629 else 2640 else
2630 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2641 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2631 setCaption(mes); 2642 setCaption(mes);
2632 } 2643 }
2633 } 2644 }
2634 2645
2635} 2646}
2636void MainWindow::exportICalendar() 2647void MainWindow::exportICalendar()
2637{ 2648{
2638 exportCalendar( true ); 2649 exportCalendar( true );
2639} 2650}
2640void MainWindow::exportVCalendar() 2651void MainWindow::exportVCalendar()
2641{ 2652{
2642 exportCalendar( false ); 2653 exportCalendar( false );
2643} 2654}
2644QString MainWindow::sentSyncFile() 2655QString MainWindow::sentSyncFile()
2645{ 2656{
2646#ifdef DESKTOP_VERSION 2657#ifdef DESKTOP_VERSION
2647 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); 2658 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) );
2648#else 2659#else
2649 return QString( "/tmp/copysynccal.ics" ); 2660 return QString( "/tmp/copysynccal.ics" );
2650#endif 2661#endif
2651} 2662}
2652 2663
2653void MainWindow::syncFileRequest() 2664void MainWindow::syncFileRequest()
2654{ 2665{
2655 while ( mSyncManager->blockSave() ) { 2666 while ( mSyncManager->blockSave() ) {
2656 qApp->processEvents(); 2667 qApp->processEvents();
2657 } 2668 }
2658 mSyncManager->setBlockSave(true); 2669 mSyncManager->setBlockSave(true);
2659 2670
2660 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2671 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2661 mSyncManager->slotSyncMenu( 999 ); 2672 mSyncManager->slotSyncMenu( 999 );
2662 } 2673 }
2663 2674
2664 setCaption(i18n("Saving Data to temp file ..." )); 2675 setCaption(i18n("Saving Data to temp file ..." ));
2665 mView->saveCalendar( sentSyncFile() ); 2676 mView->saveCalendar( sentSyncFile() );
2666 setCaption(i18n("Data saved to temp file!" )); 2677 setCaption(i18n("Data saved to temp file!" ));
2667 mSyncManager->setBlockSave( false ); 2678 mSyncManager->setBlockSave( false );
2668 2679
2669} 2680}
2670void MainWindow::getFile( bool success ) 2681void MainWindow::getFile( bool success )
2671{ 2682{
2672 if ( ! success ) { 2683 if ( ! success ) {
2673 setCaption( i18n("Error receiving file. Nothing changed!") ); 2684 setCaption( i18n("Error receiving file. Nothing changed!") );
2674 return; 2685 return;
2675 } 2686 }
2676 mView->mergeFile( sentSyncFile() ); 2687 mView->mergeFile( sentSyncFile() );
2677 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2688 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2678 mSyncManager->slotSyncMenu( 999 ); 2689 mSyncManager->slotSyncMenu( 999 );
2679 } 2690 }
2680 setCaption( i18n("Pi-Sync successful!") ); 2691 setCaption( i18n("Pi-Sync successful!") );
2681} 2692}
2682void MainWindow::printListView() 2693void MainWindow::printListView()
2683{ 2694{
2684 2695
2685 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); 2696 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
2686 2697
2687 KMessageBox::information( this, message); 2698 KMessageBox::information( this, message);
2688} 2699}
2689void MainWindow::printSel( ) 2700void MainWindow::printSel( )
2690{ 2701{
2691 mView->viewManager()->agendaView()->agenda()->printSelection(); 2702 mView->viewManager()->agendaView()->agenda()->printSelection();
2692} 2703}
2693 2704
2694void MainWindow::printCal() 2705void MainWindow::printCal()
2695{ 2706{
2696 mView->print();//mCp->showDialog(); 2707 mView->print();//mCp->showDialog();
2697} 2708}
2698 2709
2699 2710
2700#include "libkdepim/kdatepicker.h" 2711#include "libkdepim/kdatepicker.h"
2701#include <kdatetbl.h> 2712#include <kdatetbl.h>
2702 2713
2703void MainWindow::weekAction() 2714void MainWindow::weekAction()
2704{ 2715{
2705 int month; 2716 int month;
2706 KPopupFrame* popup = new KPopupFrame(this); 2717 KPopupFrame* popup = new KPopupFrame(this);
2707 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2718 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2708 // ----- 2719 // -----
2709 picker->resize(picker->sizeHint()); 2720 picker->resize(picker->sizeHint());
2710 popup->setMainWidget(picker); 2721 popup->setMainWidget(picker);
2711 picker->setFocus(); 2722 picker->setFocus();
2712 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2723 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2713 int x = 0; 2724 int x = 0;
2714 int y = iconToolBar->height(); 2725 int y = iconToolBar->height();
2715 int dX = 0; 2726 int dX = 0;
2716 int dY = 0; 2727 int dY = 0;
2717 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2728 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2718 if ( iconToolBar->y() > height()/2 ) { 2729 if ( iconToolBar->y() > height()/2 ) {
2719 dY = picker->sizeHint().height()+8; 2730 dY = picker->sizeHint().height()+8;
2720 y = 0; 2731 y = 0;
2721 } 2732 }
2722 } else { 2733 } else {
2723 if ( iconToolBar->x() > width()/2 ) { // right side 2734 if ( iconToolBar->x() > width()/2 ) { // right side
2724 x=0; 2735 x=0;
2725 dX= picker->sizeHint().width()+8; 2736 dX= picker->sizeHint().width()+8;
2726 y = 0; 2737 y = 0;
2727 } else { 2738 } else {
2728 x= iconToolBar->width(); 2739 x= iconToolBar->width();
2729 y = 0; 2740 y = 0;
2730 } 2741 }
2731 } 2742 }
2732 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2743 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2733 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2744 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2734 { 2745 {
2735 month = picker->getResult(); 2746 month = picker->getResult();
2736 emit selectWeek ( month ); 2747 emit selectWeek ( month );
2737 //qDebug("weekSelected %d ", month); 2748 //qDebug("weekSelected %d ", month);
2738 } 2749 }
2739 delete popup; 2750 delete popup;
2740} 2751}
2741 2752
2742void MainWindow::hideEvent ( QHideEvent * ) 2753void MainWindow::hideEvent ( QHideEvent * )
2743{ 2754{
2744 QString message; 2755 QString message;
2745 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2756 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2746 if ( nextA.isValid() ) { 2757 if ( nextA.isValid() ) {
2747 QString sum = mCalendar->nextSummary(); 2758 QString sum = mCalendar->nextSummary();
2748 2759
2749 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2760 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2750 setCaption( message ); 2761 setCaption( message );
2751 } 2762 }
2752} 2763}
2753 2764
2754void MainWindow::resizeEvent( QResizeEvent* e) 2765void MainWindow::resizeEvent( QResizeEvent* e)
2755{ 2766{
2756#ifndef DESKTOP_VERSION 2767#ifndef DESKTOP_VERSION
2757 if ( filterToolBar ) { 2768 if ( filterToolBar ) {
2758 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2769 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2759 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2770 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2760 filterToolBar->hide(); 2771 filterToolBar->hide();
2761 else 2772 else
2762 filterToolBar->show(); 2773 filterToolBar->show();
2763 } 2774 }
2764 } 2775 }
2765#endif 2776#endif
2766 QMainWindow::resizeEvent( e); 2777 QMainWindow::resizeEvent( e);
2767} 2778}
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index f7d40ad..70a7711 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,666 +1,674 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27 27
28#include "calendarlocal.h" 28#include "calendarlocal.h"
29#include "icalformat.h" 29#include "icalformat.h"
30#include "todo.h" 30#include "todo.h"
31 31
32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h>
34#endif
35
32#define SAVETIMER_TIMEOUT_SECONDS 300 36#define SAVETIMER_TIMEOUT_SECONDS 300
33//#define SAVETIMER_TIMEOUT_SECONDS 8 37//#define SAVETIMER_TIMEOUT_SECONDS 8
34#define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 38#define SAVETIMER_TIMEOUT_RETRY_SECONDS 5
35 39
36using namespace KCal; 40using namespace KCal;
37 41
38Todo::Todo(): QObject(), Incidence() 42Todo::Todo(): QObject(), Incidence()
39{ 43{
40// mStatus = TENTATIVE; 44// mStatus = TENTATIVE;
41 45
42 mHasDueDate = false; 46 mHasDueDate = false;
43 setHasStartDate( false ); 47 setHasStartDate( false );
44 mCompleted = getEvenTime(QDateTime::currentDateTime()); 48 mCompleted = getEvenTime(QDateTime::currentDateTime());
45 mHasCompletedDate = false; 49 mHasCompletedDate = false;
46 mPercentComplete = 0; 50 mPercentComplete = 0;
47 mRunning = false; 51 mRunning = false;
48 mRunSaveTimer = 0; 52 mRunSaveTimer = 0;
49 setFloats( true ); 53 setFloats( true );
50 mCurrentTimerDelay = 0; 54 mCurrentTimerDelay = 0;
51} 55}
52 56
53Todo::Todo(const Todo &t) : QObject(),Incidence(t) 57Todo::Todo(const Todo &t) : QObject(),Incidence(t)
54{ 58{
55 mDtDue = t.mDtDue; 59 mDtDue = t.mDtDue;
56 mHasDueDate = t.mHasDueDate; 60 mHasDueDate = t.mHasDueDate;
57 mCompleted = t.mCompleted; 61 mCompleted = t.mCompleted;
58 mHasCompletedDate = t.mHasCompletedDate; 62 mHasCompletedDate = t.mHasCompletedDate;
59 mPercentComplete = t.mPercentComplete; 63 mPercentComplete = t.mPercentComplete;
60 mRunning = false; 64 mRunning = false;
61 mRunSaveTimer = 0; 65 mRunSaveTimer = 0;
62 mCurrentTimerDelay = 0; 66 mCurrentTimerDelay = 0;
63} 67}
64 68
65Todo::~Todo() 69Todo::~Todo()
66{ 70{
67 setRunning( false ); 71 setRunning( false );
68 //qDebug("Todo::~Todo() "); 72 //qDebug("Todo::~Todo() ");
69} 73}
70 74
71void Todo::setRunningFalse( QString s ) 75void Todo::setRunningFalse( QString s )
72{ 76{
73 if ( ! mRunning ) 77 if ( ! mRunning )
74 return; 78 return;
75 mRunning = false; 79 mRunning = false;
76 if ( mRunSaveTimer ) 80 if ( mRunSaveTimer )
77 mRunSaveTimer->stop(); 81 mRunSaveTimer->stop();
78 saveRunningInfoToFile( s ); 82 saveRunningInfoToFile( s );
79} 83}
80void Todo::stopRunning() 84void Todo::stopRunning()
81{ 85{
82 if ( !mRunning ) 86 if ( !mRunning )
83 return; 87 return;
84 if ( mRunSaveTimer ) 88 if ( mRunSaveTimer )
85 mRunSaveTimer->stop(); 89 mRunSaveTimer->stop();
86 mRunning = false; 90 mRunning = false;
87} 91}
88void Todo::setRunning( bool run ) 92void Todo::setRunning( bool run )
89{ 93{
90 if ( run == mRunning ) 94 if ( run == mRunning )
91 return; 95 return;
92 //qDebug("Todo::setRunning %d ", run); 96 //qDebug("Todo::setRunning %d ", run);
93 if ( !mRunSaveTimer ) { 97 if ( !mRunSaveTimer ) {
94 mRunSaveTimer = new QTimer ( this ); 98 mRunSaveTimer = new QTimer ( this );
95 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); 99 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) );
96 } 100 }
97 mRunning = run; 101 mRunning = run;
98 mRunLastSave = QDateTime::currentDateTime(); 102 mRunLastSave = QDateTime::currentDateTime();
99 if ( mRunning ) { 103 if ( mRunning ) {
100 restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); 104 restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS );
101 mRunStart = QDateTime::currentDateTime(); 105 mRunStart = QDateTime::currentDateTime();
102 } else { 106 } else {
103 mRunSaveTimer->stop(); 107 mRunSaveTimer->stop();
104 saveRunningInfoToFile(); 108 saveRunningInfoToFile();
105 } 109 }
106} 110}
107void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) 111void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
108{ 112{
109 if ( !mRunning) return; 113 if ( !mRunning) return;
110 mRunning = false; 114 mRunning = false;
111 mRunStart = start; 115 mRunStart = start;
112 mRunEnd = end; 116 mRunEnd = end;
113 saveRunningInfoToFile( comment ); 117 saveRunningInfoToFile( comment );
114} 118}
115void Todo::restartSaveTimer( int secs ) 119void Todo::restartSaveTimer( int secs )
116{ 120{
117 mRunSaveTimer->start( secs * 1000 ); 121 mRunSaveTimer->start( secs * 1000 );
118 mRunLastSave = QDateTime::currentDateTime(); 122 mRunLastSave = QDateTime::currentDateTime();
119 mCurrentTimerDelay = secs; 123 mCurrentTimerDelay = secs;
120} 124}
121void Todo::timerSlotSaveRunningInfoToFile() 125void Todo::timerSlotSaveRunningInfoToFile()
122{ 126{
123 mRunEnd = QDateTime::currentDateTime(); 127 mRunEnd = QDateTime::currentDateTime();
124 int secsTo = mRunLastSave.secsTo( mRunEnd ); 128 int secsTo = mRunLastSave.secsTo( mRunEnd );
125 //if( secsTo == 8 ) ++secsTo; 129 //if( secsTo == 8 ) ++secsTo;
126 qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); 130 qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay );
127 if ( secsTo > mCurrentTimerDelay ) { 131 if ( secsTo > mCurrentTimerDelay ) {
128 qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); 132 qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS );
129 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); 133 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
130 return; 134 return;
131 } 135 }
132 int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); 136 int msecs = mRunLastSave.time().msecsTo( mRunEnd.time());
133 if ( msecs < 0 ) { 137 if ( msecs < 0 ) {
134 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); 138 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
135 return; 139 return;
136 } 140 }
137 // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); 141 // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) );
138 if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { 142 if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) {
139 qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); 143 qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) );
140 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); 144 restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS );
141 return; 145 return;
142
143 } 146 }
144 restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); 147 restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS );
145 saveRunningInfoToFile( QString::null ); 148 saveRunningInfoToFile( QString::null );
146} 149}
147void Todo::saveRunningInfoToFile() 150void Todo::saveRunningInfoToFile()
148{ 151{
149 mRunEnd = QDateTime::currentDateTime(); 152 mRunEnd = QDateTime::currentDateTime();
150 saveRunningInfoToFile( QString::null ); 153 saveRunningInfoToFile( QString::null );
151} 154}
152void Todo::saveRunningInfoToFile( QString comment ) 155void Todo::saveRunningInfoToFile( QString comment )
153{ 156{
157#ifndef DESKTOP_VERSION
158 QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable );
159#endif
154 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 160 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
155 if ( mRunStart.secsTo ( mRunEnd) < 15 ) { 161 if ( mRunStart.secsTo ( mRunEnd) < 15 ) {
156 qDebug("Running time < 15 seconds. Skipped. "); 162 qDebug("Running time < 15 seconds. Skipped. ");
157 return; 163 return;
158 } 164 }
159 QString dir = KGlobalSettings::timeTrackerDir(); 165 QString dir = KGlobalSettings::timeTrackerDir();
160 //qDebug("%s ", dir.latin1()); 166 //qDebug("%s ", dir.latin1());
161 QString file = "%1%2%3-%4%5%6-"; 167 QString file = "%1%2%3-%4%5%6-";
162 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 168 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
163 file.replace ( QRegExp (" "), "0" ); 169 file.replace ( QRegExp (" "), "0" );
164 file += uid(); 170 file += uid();
165 //qDebug("File %s ",file.latin1() ); 171 //qDebug("File %s ",file.latin1() );
166 CalendarLocal cal; 172 CalendarLocal cal;
167 cal.setLocalTime(); 173 cal.setLocalTime();
168 Todo * to = (Todo*) clone(); 174 Todo * to = (Todo*) clone();
169 to->setFloats( false ); 175 to->setFloats( false );
170 to->setDtStart( mRunStart ); 176 to->setDtStart( mRunStart );
171 to->setHasStartDate( true ); 177 to->setHasStartDate( true );
172 to->setDtDue( mRunEnd ); 178 to->setDtDue( mRunEnd );
173 to->setHasDueDate( true ); 179 to->setHasDueDate( true );
174 to->setUid( file ); 180 to->setUid( file );
175 if ( !comment.isEmpty() ) { 181 if ( !comment.isEmpty() ) {
176 QString des = to->description(); 182 QString des = to->description();
177 if ( des.isEmpty () ) 183 if ( des.isEmpty () )
178 to->setDescription( "TT-Note: " + comment ); 184 to->setDescription( "TT-Note: " + comment );
179 else 185 else
180 to->setDescription( "TT-Note: " + comment +"\n" + des ); 186 to->setDescription( "TT-Note: " + comment +"\n" + des );
181 } 187 }
182 cal.addIncidence( to ); 188 cal.addIncidence( to );
183 ICalFormat format( false ); 189 ICalFormat format( false );
184 file = dir +"/" +file +".ics"; 190 file = dir +"/" +file +".ics";
185 format.save( &cal, file ); 191 format.save( &cal, file );
186 saveParents(); 192 saveParents();
187 193#ifndef DESKTOP_VERSION
194 QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable );
195#endif
188} 196}
189void Todo::saveParents() 197void Todo::saveParents()
190{ 198{
191 if (!relatedTo() ) 199 if (!relatedTo() )
192 return; 200 return;
193 Incidence * inc = relatedTo(); 201 Incidence * inc = relatedTo();
194 if ( inc->typeID() != todoID ) 202 if ( inc->typeID() != todoID )
195 return; 203 return;
196 Todo* to = (Todo*)inc; 204 Todo* to = (Todo*)inc;
197 bool saveTodo = false; 205 bool saveTodo = false;
198 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 206 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
199 QFileInfo fi ( file ); 207 QFileInfo fi ( file );
200 if ( fi.exists() ) { 208 if ( fi.exists() ) {
201 if ( fi.lastModified () < to->lastModified ()) 209 if ( fi.lastModified () < to->lastModified ())
202 saveTodo = true; 210 saveTodo = true;
203 } else { 211 } else {
204 saveTodo = true; 212 saveTodo = true;
205 } 213 }
206 if ( saveTodo ) { 214 if ( saveTodo ) {
207 CalendarLocal cal; 215 CalendarLocal cal;
208 cal.setLocalTime(); 216 cal.setLocalTime();
209 Todo * par = (Todo *) to->clone(); 217 Todo * par = (Todo *) to->clone();
210 cal.addIncidence( par ); 218 cal.addIncidence( par );
211 ICalFormat format( false ); 219 ICalFormat format( false );
212 format.save( &cal, file ); 220 format.save( &cal, file );
213 } 221 }
214 to->saveParents(); 222 to->saveParents();
215} 223}
216 224
217int Todo::runTime() 225int Todo::runTime()
218{ 226{
219 if ( !mRunning ) 227 if ( !mRunning )
220 return 0; 228 return 0;
221 return mRunStart.secsTo( QDateTime::currentDateTime() ); 229 return mRunStart.secsTo( QDateTime::currentDateTime() );
222} 230}
223bool Todo::hasRunningSub() 231bool Todo::hasRunningSub()
224{ 232{
225 if ( mRunning ) 233 if ( mRunning )
226 return true; 234 return true;
227 Incidence *aTodo; 235 Incidence *aTodo;
228 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 236 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
229 if ( ((Todo*)aTodo)->hasRunningSub() ) 237 if ( ((Todo*)aTodo)->hasRunningSub() )
230 return true; 238 return true;
231 } 239 }
232 return false; 240 return false;
233} 241}
234Incidence *Todo::clone() 242Incidence *Todo::clone()
235{ 243{
236 return new Todo(*this); 244 return new Todo(*this);
237} 245}
238 246
239bool Todo::contains ( Todo* from ) 247bool Todo::contains ( Todo* from )
240{ 248{
241 249
242 if ( !from->summary().isEmpty() ) 250 if ( !from->summary().isEmpty() )
243 if ( !summary().startsWith( from->summary() )) 251 if ( !summary().startsWith( from->summary() ))
244 return false; 252 return false;
245 if ( from->hasStartDate() ) { 253 if ( from->hasStartDate() ) {
246 if ( !hasStartDate() ) 254 if ( !hasStartDate() )
247 return false; 255 return false;
248 if ( from->dtStart() != dtStart()) 256 if ( from->dtStart() != dtStart())
249 return false; 257 return false;
250 } 258 }
251 if ( from->hasDueDate() ){ 259 if ( from->hasDueDate() ){
252 if ( !hasDueDate() ) 260 if ( !hasDueDate() )
253 return false; 261 return false;
254 if ( from->dtDue() != dtDue()) 262 if ( from->dtDue() != dtDue())
255 return false; 263 return false;
256 } 264 }
257 if ( !from->location().isEmpty() ) 265 if ( !from->location().isEmpty() )
258 if ( !location().startsWith( from->location() ) ) 266 if ( !location().startsWith( from->location() ) )
259 return false; 267 return false;
260 if ( !from->description().isEmpty() ) 268 if ( !from->description().isEmpty() )
261 if ( !description().startsWith( from->description() )) 269 if ( !description().startsWith( from->description() ))
262 return false; 270 return false;
263 if ( from->alarms().count() ) { 271 if ( from->alarms().count() ) {
264 Alarm *a = from->alarms().first(); 272 Alarm *a = from->alarms().first();
265 if ( a->enabled() ){ 273 if ( a->enabled() ){
266 if ( !alarms().count() ) 274 if ( !alarms().count() )
267 return false; 275 return false;
268 Alarm *b = alarms().first(); 276 Alarm *b = alarms().first();
269 if( ! b->enabled() ) 277 if( ! b->enabled() )
270 return false; 278 return false;
271 if ( ! (a->offset() == b->offset() )) 279 if ( ! (a->offset() == b->offset() ))
272 return false; 280 return false;
273 } 281 }
274 } 282 }
275 283
276 QStringList cat = categories(); 284 QStringList cat = categories();
277 QStringList catFrom = from->categories(); 285 QStringList catFrom = from->categories();
278 QString nCat; 286 QString nCat;
279 unsigned int iii; 287 unsigned int iii;
280 for ( iii = 0; iii < catFrom.count();++iii ) { 288 for ( iii = 0; iii < catFrom.count();++iii ) {
281 nCat = catFrom[iii]; 289 nCat = catFrom[iii];
282 if ( !nCat.isEmpty() ) 290 if ( !nCat.isEmpty() )
283 if ( !cat.contains( nCat )) { 291 if ( !cat.contains( nCat )) {
284 return false; 292 return false;
285 } 293 }
286 } 294 }
287 if ( from->isCompleted() ) { 295 if ( from->isCompleted() ) {
288 if ( !isCompleted() ) 296 if ( !isCompleted() )
289 return false; 297 return false;
290 } 298 }
291 if( priority() != from->priority() ) 299 if( priority() != from->priority() )
292 return false; 300 return false;
293 301
294 302
295 return true; 303 return true;
296 304
297} 305}
298bool KCal::operator==( const Todo& t1, const Todo& t2 ) 306bool KCal::operator==( const Todo& t1, const Todo& t2 )
299{ 307{
300 308
301 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 309 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
302 if ( ! ret ) 310 if ( ! ret )
303 return false; 311 return false;
304 if ( t1.hasDueDate() == t2.hasDueDate() ) { 312 if ( t1.hasDueDate() == t2.hasDueDate() ) {
305 if ( t1.hasDueDate() ) { 313 if ( t1.hasDueDate() ) {
306 if ( t1.doesFloat() == t2.doesFloat() ) { 314 if ( t1.doesFloat() == t2.doesFloat() ) {
307 if ( t1.doesFloat() ) { 315 if ( t1.doesFloat() ) {
308 if ( t1.dtDue().date() != t2.dtDue().date() ) 316 if ( t1.dtDue().date() != t2.dtDue().date() )
309 return false; 317 return false;
310 } else 318 } else
311 if ( t1.dtDue() != t2.dtDue() ) 319 if ( t1.dtDue() != t2.dtDue() )
312 return false; 320 return false;
313 } else 321 } else
314 return false;// float != 322 return false;// float !=
315 } 323 }
316 324
317 } else 325 } else
318 return false; 326 return false;
319 if ( t1.percentComplete() != t2.percentComplete() ) 327 if ( t1.percentComplete() != t2.percentComplete() )
320 return false; 328 return false;
321 if ( t1.isCompleted() ) { 329 if ( t1.isCompleted() ) {
322 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 330 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
323 if ( t1.hasCompletedDate() ) { 331 if ( t1.hasCompletedDate() ) {
324 if ( t1.completed() != t2.completed() ) 332 if ( t1.completed() != t2.completed() )
325 return false; 333 return false;
326 } 334 }
327 335
328 } else 336 } else
329 return false; 337 return false;
330 } 338 }
331 return true; 339 return true;
332 340
333} 341}
334 342
335void Todo::setDtDue(const QDateTime &dtDue) 343void Todo::setDtDue(const QDateTime &dtDue)
336{ 344{
337 //int diffsecs = mDtDue.secsTo(dtDue); 345 //int diffsecs = mDtDue.secsTo(dtDue);
338 346
339 /*if (mReadOnly) return; 347 /*if (mReadOnly) return;
340 const QPtrList<Alarm>& alarms = alarms(); 348 const QPtrList<Alarm>& alarms = alarms();
341 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 349 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
342 if (alarm->enabled()) { 350 if (alarm->enabled()) {
343 alarm->setTime(alarm->time().addSecs(diffsecs)); 351 alarm->setTime(alarm->time().addSecs(diffsecs));
344 } 352 }
345 }*/ 353 }*/
346 mDtDue = getEvenTime(dtDue); 354 mDtDue = getEvenTime(dtDue);
347 355
348 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 356 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
349 357
350 /*const QPtrList<Alarm>& alarms = alarms(); 358 /*const QPtrList<Alarm>& alarms = alarms();
351 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 359 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
352 alarm->setAlarmStart(mDtDue);*/ 360 alarm->setAlarmStart(mDtDue);*/
353 updated(); 361 updated();
354} 362}
355 363
356QDateTime Todo::dtDue() const 364QDateTime Todo::dtDue() const
357{ 365{
358 return mDtDue; 366 return mDtDue;
359} 367}
360 368
361QString Todo::dtDueTimeStr() const 369QString Todo::dtDueTimeStr() const
362{ 370{
363 return KGlobal::locale()->formatTime(mDtDue.time()); 371 return KGlobal::locale()->formatTime(mDtDue.time());
364} 372}
365 373
366QString Todo::dtDueDateStr(bool shortfmt) const 374QString Todo::dtDueDateStr(bool shortfmt) const
367{ 375{
368 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 376 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
369} 377}
370 378
371QString Todo::dtDueStr(bool shortfmt) const 379QString Todo::dtDueStr(bool shortfmt) const
372{ 380{
373 if ( doesFloat() ) 381 if ( doesFloat() )
374 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 382 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
375 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); 383 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
376} 384}
377// retval 0 : no found 385// retval 0 : no found
378// 1 : due for date found 386// 1 : due for date found
379// 2 : overdue for date found 387// 2 : overdue for date found
380int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) 388int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
381{ 389{
382 int retval = 0; 390 int retval = 0;
383 if ( isCompleted() ) 391 if ( isCompleted() )
384 return 0; 392 return 0;
385 if ( hasDueDate() ) { 393 if ( hasDueDate() ) {
386 if ( dtDue().date() < date ) 394 if ( dtDue().date() < date )
387 return 2; 395 return 2;
388 // we do not return, because we may find an overdue sub todo 396 // we do not return, because we may find an overdue sub todo
389 if ( dtDue().date() == date ) 397 if ( dtDue().date() == date )
390 retval = 1; 398 retval = 1;
391 } 399 }
392 if ( checkSubtodos ) { 400 if ( checkSubtodos ) {
393 Incidence *aTodo; 401 Incidence *aTodo;
394 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 402 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
395 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); 403 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
396 if ( ret == 2 ) 404 if ( ret == 2 )
397 return 2; 405 return 2;
398 if ( ret == 1) 406 if ( ret == 1)
399 retval = 1; 407 retval = 1;
400 } 408 }
401 } 409 }
402 return retval; 410 return retval;
403} 411}
404int Todo::hasDueSubTodo( bool checkSubtodos ) //= true 412int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
405{ 413{
406 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); 414 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
407} 415}
408bool Todo::hasDueDate() const 416bool Todo::hasDueDate() const
409{ 417{
410 return mHasDueDate; 418 return mHasDueDate;
411} 419}
412 420
413void Todo::setHasDueDate(bool f) 421void Todo::setHasDueDate(bool f)
414{ 422{
415 if (mReadOnly) return; 423 if (mReadOnly) return;
416 mHasDueDate = f; 424 mHasDueDate = f;
417 updated(); 425 updated();
418} 426}
419 427
420 428
421#if 0 429#if 0
422void Todo::setStatus(const QString &statStr) 430void Todo::setStatus(const QString &statStr)
423{ 431{
424 if (mReadOnly) return; 432 if (mReadOnly) return;
425 QString ss(statStr.upper()); 433 QString ss(statStr.upper());
426 434
427 if (ss == "X-ACTION") 435 if (ss == "X-ACTION")
428 mStatus = NEEDS_ACTION; 436 mStatus = NEEDS_ACTION;
429 else if (ss == "NEEDS ACTION") 437 else if (ss == "NEEDS ACTION")
430 mStatus = NEEDS_ACTION; 438 mStatus = NEEDS_ACTION;
431 else if (ss == "ACCEPTED") 439 else if (ss == "ACCEPTED")
432 mStatus = ACCEPTED; 440 mStatus = ACCEPTED;
433 else if (ss == "SENT") 441 else if (ss == "SENT")
434 mStatus = SENT; 442 mStatus = SENT;
435 else if (ss == "TENTATIVE") 443 else if (ss == "TENTATIVE")
436 mStatus = TENTATIVE; 444 mStatus = TENTATIVE;
437 else if (ss == "CONFIRMED") 445 else if (ss == "CONFIRMED")
438 mStatus = CONFIRMED; 446 mStatus = CONFIRMED;
439 else if (ss == "DECLINED") 447 else if (ss == "DECLINED")
440 mStatus = DECLINED; 448 mStatus = DECLINED;
441 else if (ss == "COMPLETED") 449 else if (ss == "COMPLETED")
442 mStatus = COMPLETED; 450 mStatus = COMPLETED;
443 else if (ss == "DELEGATED") 451 else if (ss == "DELEGATED")
444 mStatus = DELEGATED; 452 mStatus = DELEGATED;
445 453
446 updated(); 454 updated();
447} 455}
448 456
449void Todo::setStatus(int status) 457void Todo::setStatus(int status)
450{ 458{
451 if (mReadOnly) return; 459 if (mReadOnly) return;
452 mStatus = status; 460 mStatus = status;
453 updated(); 461 updated();
454} 462}
455 463
456int Todo::status() const 464int Todo::status() const
457{ 465{
458 return mStatus; 466 return mStatus;
459} 467}
460 468
461QString Todo::statusStr() const 469QString Todo::statusStr() const
462{ 470{
463 switch(mStatus) { 471 switch(mStatus) {
464 case NEEDS_ACTION: 472 case NEEDS_ACTION:
465 return QString("NEEDS ACTION"); 473 return QString("NEEDS ACTION");
466 break; 474 break;
467 case ACCEPTED: 475 case ACCEPTED:
468 return QString("ACCEPTED"); 476 return QString("ACCEPTED");
469 break; 477 break;
470 case SENT: 478 case SENT:
471 return QString("SENT"); 479 return QString("SENT");
472 break; 480 break;
473 case TENTATIVE: 481 case TENTATIVE:
474 return QString("TENTATIVE"); 482 return QString("TENTATIVE");
475 break; 483 break;
476 case CONFIRMED: 484 case CONFIRMED:
477 return QString("CONFIRMED"); 485 return QString("CONFIRMED");
478 break; 486 break;
479 case DECLINED: 487 case DECLINED:
480 return QString("DECLINED"); 488 return QString("DECLINED");
481 break; 489 break;
482 case COMPLETED: 490 case COMPLETED:
483 return QString("COMPLETED"); 491 return QString("COMPLETED");
484 break; 492 break;
485 case DELEGATED: 493 case DELEGATED:
486 return QString("DELEGATED"); 494 return QString("DELEGATED");
487 break; 495 break;
488 } 496 }
489 return QString(""); 497 return QString("");
490} 498}
491#endif 499#endif
492 500
493bool Todo::isCompleted() const 501bool Todo::isCompleted() const
494{ 502{
495 if (mPercentComplete == 100) { 503 if (mPercentComplete == 100) {
496 return true; 504 return true;
497 } 505 }
498 else return false; 506 else return false;
499} 507}
500 508
501void Todo::setCompleted(bool completed) 509void Todo::setCompleted(bool completed)
502{ 510{
503 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { 511 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
504 if ( !setRecurDates() ) 512 if ( !setRecurDates() )
505 completed = false; 513 completed = false;
506 } 514 }
507 if (completed) mPercentComplete = 100; 515 if (completed) mPercentComplete = 100;
508 else { 516 else {
509 mPercentComplete = 0; 517 mPercentComplete = 0;
510 mHasCompletedDate = false; 518 mHasCompletedDate = false;
511 } 519 }
512 updated(); 520 updated();
513} 521}
514 522
515QDateTime Todo::completed() const 523QDateTime Todo::completed() const
516{ 524{
517 return mCompleted; 525 return mCompleted;
518} 526}
519 527
520QString Todo::completedStr( bool shortF ) const 528QString Todo::completedStr( bool shortF ) const
521{ 529{
522 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 530 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
523} 531}
524 532
525void Todo::setCompleted(const QDateTime &completed) 533void Todo::setCompleted(const QDateTime &completed)
526{ 534{
527 //qDebug("Todo::setCompleted "); 535 //qDebug("Todo::setCompleted ");
528 if ( mHasCompletedDate ) { 536 if ( mHasCompletedDate ) {
529 // qDebug("has completed data - return "); 537 // qDebug("has completed data - return ");
530 return; 538 return;
531 } 539 }
532 mHasCompletedDate = true; 540 mHasCompletedDate = true;
533 mPercentComplete = 100; 541 mPercentComplete = 100;
534 mCompleted = getEvenTime(completed); 542 mCompleted = getEvenTime(completed);
535 updated(); 543 updated();
536} 544}
537 545
538bool Todo::hasCompletedDate() const 546bool Todo::hasCompletedDate() const
539{ 547{
540 return mHasCompletedDate; 548 return mHasCompletedDate;
541} 549}
542 550
543int Todo::percentComplete() const 551int Todo::percentComplete() const
544{ 552{
545 return mPercentComplete; 553 return mPercentComplete;
546} 554}
547bool Todo::setRecurDates() 555bool Todo::setRecurDates()
548{ 556{
549 if ( !mHasRecurrenceID ) 557 if ( !mHasRecurrenceID )
550 return true; 558 return true;
551 int secs = mDtStart.secsTo( dtDue() ); 559 int secs = mDtStart.secsTo( dtDue() );
552 bool ok; 560 bool ok;
553 qDebug("T:setRecurDates() "); 561 qDebug("T:setRecurDates() ");
554 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 562 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
555 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 563 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
556 if ( ok ) { 564 if ( ok ) {
557 mRecurrenceID = next; 565 mRecurrenceID = next;
558 mDtStart = next; 566 mDtStart = next;
559 setDtDue( next.addSecs( secs ) ); 567 setDtDue( next.addSecs( secs ) );
560 if ( QDateTime::currentDateTime() > next) 568 if ( QDateTime::currentDateTime() > next)
561 return false; 569 return false;
562 } else { 570 } else {
563 setHasRecurrenceID( false ); 571 setHasRecurrenceID( false );
564 recurrence()->unsetRecurs(); 572 recurrence()->unsetRecurs();
565 } 573 }
566 return true; 574 return true;
567} 575}
568void Todo::setPercentComplete(int v) 576void Todo::setPercentComplete(int v)
569{ 577{
570 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 578 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
571 if ( !setRecurDates() ) 579 if ( !setRecurDates() )
572 v = 0; 580 v = 0;
573 } 581 }
574 mPercentComplete = v; 582 mPercentComplete = v;
575 if ( v != 100 ) 583 if ( v != 100 )
576 mHasCompletedDate = false; 584 mHasCompletedDate = false;
577 updated(); 585 updated();
578} 586}
579QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 587QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
580{ 588{
581 *ok = false; 589 *ok = false;
582 if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { 590 if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) {
583 return QDateTime (); 591 return QDateTime ();
584 } 592 }
585 // if the recurring todo is set to complete and requested time < start time of todo 593 // if the recurring todo is set to complete and requested time < start time of todo
586 // we want to get the alarm. 594 // we want to get the alarm.
587 bool iscompleted = isCompleted(); 595 bool iscompleted = isCompleted();
588 if ( iscompleted && doesRecur() ) { 596 if ( iscompleted && doesRecur() ) {
589 Todo * to = (Todo*) this; 597 Todo * to = (Todo*) this;
590 to->checkSetCompletedFalse(); 598 to->checkSetCompletedFalse();
591 iscompleted = isCompleted(); 599 iscompleted = isCompleted();
592 if ( hasStartDate() && start_dt < dtStart() ){ 600 if ( hasStartDate() && start_dt < dtStart() ){
593 iscompleted = false; 601 iscompleted = false;
594 } 602 }
595 } 603 }
596 if ( iscompleted ) { 604 if ( iscompleted ) {
597 return QDateTime (); 605 return QDateTime ();
598 } 606 }
599 QDateTime incidenceStart; 607 QDateTime incidenceStart;
600 incidenceStart = dtDue(); 608 incidenceStart = dtDue();
601 bool enabled = false; 609 bool enabled = false;
602 Alarm* alarm; 610 Alarm* alarm;
603 int off = 0; 611 int off = 0;
604 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 612 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
605 // if ( QDateTime::currentDateTime() > incidenceStart ){ 613 // if ( QDateTime::currentDateTime() > incidenceStart ){
606// *ok = false; 614// *ok = false;
607// return incidenceStart; 615// return incidenceStart;
608// } 616// }
609 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 617 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
610 if (alarm->enabled()) { 618 if (alarm->enabled()) {
611 if ( alarm->hasTime () ) { 619 if ( alarm->hasTime () ) {
612 if ( alarm->time() < alarmStart ) { 620 if ( alarm->time() < alarmStart ) {
613 alarmStart = alarm->time(); 621 alarmStart = alarm->time();
614 enabled = true; 622 enabled = true;
615 off = alarmStart.secsTo( incidenceStart ); 623 off = alarmStart.secsTo( incidenceStart );
616 } 624 }
617 625
618 } else { 626 } else {
619 int secs = alarm->startOffset().asSeconds(); 627 int secs = alarm->startOffset().asSeconds();
620 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 628 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
621 alarmStart = incidenceStart.addSecs( secs ); 629 alarmStart = incidenceStart.addSecs( secs );
622 enabled = true; 630 enabled = true;
623 off = -secs; 631 off = -secs;
624 } 632 }
625 } 633 }
626 } 634 }
627 } 635 }
628 if ( enabled ) { 636 if ( enabled ) {
629 if ( alarmStart > start_dt ) { 637 if ( alarmStart > start_dt ) {
630 *ok = true; 638 *ok = true;
631 * offset = off; 639 * offset = off;
632 return alarmStart; 640 return alarmStart;
633 } 641 }
634 } 642 }
635 *ok = false; 643 *ok = false;
636 return QDateTime (); 644 return QDateTime ();
637 645
638} 646}
639 647
640void Todo::checkSetCompletedFalse() 648void Todo::checkSetCompletedFalse()
641{ 649{
642 if ( !mHasRecurrenceID ) { 650 if ( !mHasRecurrenceID ) {
643 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 651 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
644 return; 652 return;
645 } 653 }
646 // qDebug("Todo::checkSetCompletedFalse()"); 654 // qDebug("Todo::checkSetCompletedFalse()");
647 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 655 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
648 if ( mPercentComplete == 100 ) { 656 if ( mPercentComplete == 100 ) {
649 QDateTime dt = QDateTime::currentDateTime(); 657 QDateTime dt = QDateTime::currentDateTime();
650 if ( dt > mDtStart && dt > mRecurrenceID ) { 658 if ( dt > mDtStart && dt > mRecurrenceID ) {
651 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 659 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
652 setCompleted( false ); 660 setCompleted( false );
653 qDebug("Todo::checkSetCompletedFalse "); 661 qDebug("Todo::checkSetCompletedFalse ");
654 } 662 }
655 } 663 }
656} 664}
657QString Todo::durationText() 665QString Todo::durationText()
658{ 666{
659 if ( mHasDueDate && hasStartDate() ) { 667 if ( mHasDueDate && hasStartDate() ) {
660 int sec = dtStart().secsTo( dtDue() ); 668 int sec = dtStart().secsTo( dtDue() );
661 if ( doesFloat() ) 669 if ( doesFloat() )
662 sec += 86400; 670 sec += 86400;
663 return durationText4Time( sec ); 671 return durationText4Time( sec );
664 } 672 }
665 return "---"; 673 return "---";
666} 674}