summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/alarmclient.h60
-rw-r--r--korganizer/baseview.moc0
-rw-r--r--korganizer/calendarview.cpp3476
-rw-r--r--korganizer/calendarview.h586
-rw-r--r--korganizer/calendarview.moc0
-rw-r--r--korganizer/calendarviewbase.moc0
-rw-r--r--korganizer/calprintbase.cpp1304
-rw-r--r--korganizer/calprintbase.h379
-rw-r--r--korganizer/calprintdayconfig_base.ui252
-rw-r--r--korganizer/calprinter.cpp299
-rw-r--r--korganizer/calprinter.h142
-rw-r--r--korganizer/calprinter.moc0
-rw-r--r--korganizer/calprintmonthconfig_base.ui172
-rw-r--r--korganizer/calprintplugins.cpp669
-rw-r--r--korganizer/calprintplugins.h151
-rw-r--r--korganizer/calprinttodoconfig_base.ui239
-rw-r--r--korganizer/calprintweekconfig_base.ui318
-rw-r--r--korganizer/categoryeditdialog.moc0
-rw-r--r--korganizer/categoryselectdialog.moc0
-rw-r--r--korganizer/cellitem.cpp98
-rw-r--r--korganizer/cellitem.h66
-rw-r--r--korganizer/customlistviewitem.h38
-rw-r--r--korganizer/datenavigator.cpp287
-rw-r--r--korganizer/datenavigator.h89
-rw-r--r--korganizer/datenavigator.moc0
-rw-r--r--korganizer/docprefs.cpp64
-rw-r--r--korganizer/docprefs.h44
-rw-r--r--korganizer/filteredit_base.cpp128
-rw-r--r--korganizer/filteredit_base.cpp.emb97
-rw-r--r--korganizer/filteredit_base.h66
-rw-r--r--korganizer/filteredit_base.h.emb57
-rw-r--r--korganizer/filteredit_base.ui201
-rw-r--r--korganizer/filtereditdialog.cpp270
-rw-r--r--korganizer/filtereditdialog.h86
-rw-r--r--korganizer/filtereditdialog.moc0
-rw-r--r--korganizer/incomingdialog.cpp527
-rw-r--r--korganizer/incomingdialog.h110
-rw-r--r--korganizer/incomingdialog.moc0
-rw-r--r--korganizer/incomingdialog_base.cpp137
-rw-r--r--korganizer/incomingdialog_base.h51
-rw-r--r--korganizer/incomingdialog_base.moc0
-rw-r--r--korganizer/interfaces/korganizer/baseview.h192
-rw-r--r--korganizer/interfaces/korganizer/calendarviewbase.h65
-rw-r--r--korganizer/journalentry.cpp170
-rw-r--r--korganizer/journalentry.h73
-rw-r--r--korganizer/journalentry.moc0
-rw-r--r--korganizer/kdatenavigator.cpp364
-rw-r--r--korganizer/kdatenavigator.h148
-rw-r--r--korganizer/kdatenavigator.moc0
-rw-r--r--korganizer/koagenda.cpp1932
-rw-r--r--korganizer/koagenda.h286
-rw-r--r--korganizer/koagenda.moc0
-rw-r--r--korganizer/koagendaitem.cpp720
-rw-r--r--korganizer/koagendaitem.h160
-rw-r--r--korganizer/koagendaitem.moc0
-rw-r--r--korganizer/koagendaview.cpp1436
-rw-r--r--korganizer/koagendaview.h252
-rw-r--r--korganizer/koagendaview.moc0
-rw-r--r--korganizer/kocounterdialog.cpp66
-rw-r--r--korganizer/kocounterdialog.h50
-rw-r--r--korganizer/kocounterdialog.moc0
-rw-r--r--korganizer/kodaymatrix.cpp597
-rw-r--r--korganizer/kodaymatrix.h308
-rw-r--r--korganizer/kodaymatrix.moc0
-rw-r--r--korganizer/kodialogmanager.cpp343
-rw-r--r--korganizer/kodialogmanager.h100
-rw-r--r--korganizer/kodialogmanager.moc0
-rw-r--r--korganizer/koeditordetails.cpp398
-rw-r--r--korganizer/koeditordetails.h103
-rw-r--r--korganizer/koeditordetails.moc0
-rw-r--r--korganizer/koeditorgeneral.cpp505
-rw-r--r--korganizer/koeditorgeneral.h112
-rw-r--r--korganizer/koeditorgeneral.moc0
-rw-r--r--korganizer/koeditorgeneralevent.cpp443
-rw-r--r--korganizer/koeditorgeneralevent.h108
-rw-r--r--korganizer/koeditorgeneralevent.moc0
-rw-r--r--korganizer/koeditorgeneraltodo.cpp467
-rw-r--r--korganizer/koeditorgeneraltodo.h105
-rw-r--r--korganizer/koeditorgeneraltodo.moc0
-rw-r--r--korganizer/koeditorrecurrence.cpp1117
-rw-r--r--korganizer/koeditorrecurrence.h321
-rw-r--r--korganizer/koeditorrecurrence.moc0
-rw-r--r--korganizer/koeventeditor.cpp378
-rw-r--r--korganizer/koeventeditor.h118
-rw-r--r--korganizer/koeventeditor.moc0
-rw-r--r--korganizer/koeventpopupmenu.cpp114
-rw-r--r--korganizer/koeventpopupmenu.h73
-rw-r--r--korganizer/koeventpopupmenu.moc0
-rw-r--r--korganizer/koeventview.cpp133
-rw-r--r--korganizer/koeventview.h172
-rw-r--r--korganizer/koeventview.moc0
-rw-r--r--korganizer/koeventviewer.cpp510
-rw-r--r--korganizer/koeventviewer.h73
-rw-r--r--korganizer/koeventviewer.moc0
-rw-r--r--korganizer/koeventviewerdialog.cpp240
-rw-r--r--korganizer/koeventviewerdialog.h70
-rw-r--r--korganizer/koeventviewerdialog.moc0
-rw-r--r--korganizer/kofilterview.cpp96
-rw-r--r--korganizer/kofilterview.h57
-rw-r--r--korganizer/kofilterview.moc0
-rw-r--r--korganizer/kofilterview_base.cpp62
-rw-r--r--korganizer/kofilterview_base.h40
-rw-r--r--korganizer/kofilterview_base.ui96
-rw-r--r--korganizer/koglobals.cpp143
-rw-r--r--korganizer/koglobals.h59
-rw-r--r--korganizer/koincidenceeditor.cpp187
-rw-r--r--korganizer/koincidenceeditor.h105
-rw-r--r--korganizer/koincidenceeditor.moc0
-rw-r--r--korganizer/kojournalview.cpp113
-rw-r--r--korganizer/kojournalview.h67
-rw-r--r--korganizer/kojournalview.moc0
-rw-r--r--korganizer/kolistview.cpp1062
-rw-r--r--korganizer/kolistview.h167
-rw-r--r--korganizer/kolistview.moc0
-rw-r--r--korganizer/kolocationbox.cpp96
-rw-r--r--korganizer/kolocationbox.h55
-rw-r--r--korganizer/komonthview.cpp1057
-rw-r--r--korganizer/komonthview.h252
-rw-r--r--korganizer/komonthview.moc0
-rw-r--r--korganizer/koprefs.cpp555
-rw-r--r--korganizer/koprefs.h299
-rw-r--r--korganizer/koprefsdialog.cpp1610
-rw-r--r--korganizer/koprefsdialog.h161
-rw-r--r--korganizer/koprefsdialog.moc0
-rw-r--r--korganizer/korganizer.desktop8
-rw-r--r--korganizer/korganizer.pro172
-rw-r--r--korganizer/korganizer.pro.back133
-rw-r--r--korganizer/korganizerE.pro151
-rw-r--r--korganizer/kosyncprefsdialog.cpp453
-rw-r--r--korganizer/kosyncprefsdialog.h109
-rw-r--r--korganizer/kosyncprefsdialog.moc0
-rw-r--r--korganizer/kotimespanview.cpp110
-rw-r--r--korganizer/kotimespanview.h41
-rw-r--r--korganizer/kotimespanview.moc0
-rw-r--r--korganizer/kotodoeditor.cpp373
-rw-r--r--korganizer/kotodoeditor.h102
-rw-r--r--korganizer/kotodoeditor.moc0
-rw-r--r--korganizer/kotodoview.cpp1028
-rw-r--r--korganizer/kotodoview.h230
-rw-r--r--korganizer/kotodoview.moc0
-rw-r--r--korganizer/kotodoviewitem.cpp432
-rw-r--r--korganizer/kotodoviewitem.h93
-rw-r--r--korganizer/koviewmanager.cpp570
-rw-r--r--korganizer/koviewmanager.h113
-rw-r--r--korganizer/koviewmanager.moc0
-rw-r--r--korganizer/kowhatsnextview.cpp650
-rw-r--r--korganizer/kowhatsnextview.h91
-rw-r--r--korganizer/kowhatsnextview.moc0
-rw-r--r--korganizer/kprefsdialog.moc0
-rw-r--r--korganizer/ktimeedit.cpp528
-rw-r--r--korganizer/ktimeedit.h97
-rw-r--r--korganizer/ktimeedit.moc0
-rw-r--r--korganizer/lineview.cpp94
-rw-r--r--korganizer/lineview.h36
-rw-r--r--korganizer/lineview.moc0
-rw-r--r--korganizer/main.cpp107
-rw-r--r--korganizer/mainwindow.cpp1974
-rw-r--r--korganizer/mainwindow.h115
-rw-r--r--korganizer/navigatorbar.cpp199
-rw-r--r--korganizer/navigatorbar.h66
-rw-r--r--korganizer/navigatorbar.moc0
-rw-r--r--korganizer/outgoingdialog.cpp394
-rw-r--r--korganizer/outgoingdialog.h88
-rw-r--r--korganizer/outgoingdialog.moc0
-rw-r--r--korganizer/outgoingdialog_base.cpp109
-rw-r--r--korganizer/outgoingdialog_base.h47
-rw-r--r--korganizer/outgoingdialog_base.moc0
-rw-r--r--korganizer/publishdialog.cpp152
-rw-r--r--korganizer/publishdialog.h55
-rw-r--r--korganizer/publishdialog.moc0
-rw-r--r--korganizer/publishdialog_base.cpp162
-rw-r--r--korganizer/publishdialog_base.h60
-rw-r--r--korganizer/publishdialog_base.moc0
-rw-r--r--korganizer/resourceview.h8
-rw-r--r--korganizer/savetemplatedialog.cpp76
-rw-r--r--korganizer/savetemplatedialog.h53
-rw-r--r--korganizer/savetemplatedialog.moc0
-rw-r--r--korganizer/searchdialog.cpp396
-rw-r--r--korganizer/searchdialog.h93
-rw-r--r--korganizer/searchdialog.moc0
-rw-r--r--korganizer/simplealarmclient.cpp111
-rw-r--r--korganizer/simplealarmclient.h57
-rw-r--r--korganizer/statusdialog.cpp67
-rw-r--r--korganizer/statusdialog.h43
-rw-r--r--korganizer/statusdialog.moc0
-rw-r--r--korganizer/timeline.cpp63
-rw-r--r--korganizer/timeline.h33
-rw-r--r--korganizer/timeline.moc0
-rw-r--r--korganizer/timespanview.cpp158
-rw-r--r--korganizer/timespanview.h60
-rw-r--r--korganizer/timespanview.moc0
-rw-r--r--korganizer/version.h29
-rw-r--r--korganizer/wordsgerman.h840
193 files changed, 40853 insertions, 0 deletions
diff --git a/korganizer/alarmclient.h b/korganizer/alarmclient.h
new file mode 100644
index 0000000..dac4776
--- a/dev/null
+++ b/korganizer/alarmclient.h
@@ -0,0 +1,60 @@
1/*
2 This file is part of the KOrganizer interfaces.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
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
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20#ifndef ALARMCLIENT_H
21#define ALARMCLIENT_H
22
23#include <qstring.h>
24#include <qstringlist.h>
25
26/**
27 This class provides the abstract interface for communicating with the alarm
28 daemon. It has to be implemented by subclasses for specific daemons. The
29 default implementation does nothing.
30*/
31class AlarmClient
32{
33 public:
34 /**
35 Start alarm daemon.
36 */
37 virtual void startDaemon() = 0;
38
39 /**
40 Set the list of monitored calendars. Deletes previous settings.
41 */
42 virtual bool setCalendars( const QStringList & ) = 0;
43
44 /**
45 Add calendar for monitoring by alarm daemon.
46 */
47 virtual bool addCalendar( const QString & ) = 0;
48
49 /**
50 Remove calendar from monitoring by alarm daemon.
51 */
52 virtual bool removeCalendar( const QString & ) = 0;
53
54 /**
55 Reload calendar at URL.
56 */
57 virtual bool reloadCalendar( const QString & ) = 0;
58};
59
60#endif
diff --git a/korganizer/baseview.moc b/korganizer/baseview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/baseview.moc
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
new file mode 100644
index 0000000..7292dcd
--- a/dev/null
+++ b/korganizer/calendarview.cpp
@@ -0,0 +1,3476 @@
1/*
2 This file is part of KOrganizer.
3
4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively
6
7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu)
12
13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org>
15
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version.
20
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/
30
31#include <stdlib.h>
32
33#include <qapplication.h>
34#include <qradiobutton.h>
35#include <qbuttongroup.h>
36#include <qlayout.h>
37#include <qclipboard.h>
38#include <qcursor.h>
39#include <qmessagebox.h>
40#include <qprogressbar.h>
41#include <qmultilineedit.h>
42#include <qtimer.h>
43#include <qwidgetstack.h>
44#include <qptrlist.h>
45#include <qregexp.h>
46#include <qgroupbox.h>
47#include <qfile.h>
48#include <qdir.h>
49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h>
51#endif
52
53#include <kglobal.h>
54#include <kdebug.h>
55#include <kstandarddirs.h>
56#include <kfiledialog.h>
57#include <kmessagebox.h>
58#include <knotifyclient.h>
59#include <kconfig.h>
60
61#include "kosyncprefsdialog.h"
62#include <krun.h>
63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h>
66
67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h"
82
83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h>
85#endif
86#ifndef KORG_NOMAIL
87#include "komailclient.h"
88#endif
89#ifndef KORG_NOPRINTER
90#include "calprinter.h"
91#endif
92#ifndef KORG_NOPLUGINS
93#include "kocore.h"
94#endif
95#include "koeventeditor.h"
96#include "kotodoeditor.h"
97#include "koprefs.h"
98#include "koeventviewerdialog.h"
99#include "publishdialog.h"
100#include "kofilterview.h"
101#include "koglobals.h"
102#include "koviewmanager.h"
103#include "koagendaview.h"
104#include "kodialogmanager.h"
105#include "outgoingdialog.h"
106#include "incomingdialog.h"
107#include "statusdialog.h"
108#include "kdatenavigator.h"
109#include "kotodoview.h"
110#include "datenavigator.h"
111#include "resourceview.h"
112#include "navigatorbar.h"
113#include "searchdialog.h"
114#include "mainwindow.h"
115
116#include "calendarview.h"
117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h>
119#endif
120#ifndef _WIN32_
121#include <stdlib.h>
122#include <stdio.h>
123#include <unistd.h>
124#else
125#include <qprocess.h>
126#endif
127using namespace KOrg;
128extern int globalFlagBlockAgenda;
129extern int globalFlagBlockStartup;
130
131#define SYNC_MODE_NORMAL 0
132#define SYNC_MODE_SHARP 1
133#define SYNC_MODE_QTOPIA 2
134
135class KOBeamPrefs : public QDialog
136{
137 public:
138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
139 QDialog( parent, name, true )
140 {
141 setCaption( i18n("Beam Options") );
142 QVBoxLayout* lay = new QVBoxLayout( this );
143 lay->setSpacing( 3 );
144 lay->setMargin( 3 );
145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
146 lay->addWidget( format );
147 format->setExclusive ( true ) ;
148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
149 lay->addWidget( time ); time->setExclusive ( true ) ;
150 vcal = new QRadioButton(" vCalendar ", format );
151 ical = new QRadioButton(" iCalendar ", format );
152 vcal->setChecked( true );
153 tz = new QRadioButton(i18n(" With timezone "), time );
154 local = new QRadioButton(i18n(" Local time "), time );
155 tz->setChecked( true );
156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
157 lay->addWidget( ok );
158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
159 lay->addWidget( cancel );
160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
162 resize( 200, 200 );
163 }
164
165 bool beamVcal() { return vcal->isChecked(); }
166 bool beamLocal() { return local->isChecked(); }
167private:
168 QRadioButton* vcal, *ical, *local, *tz;
169};
170class KOCatPrefs : public QDialog
171{
172 public:
173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true )
175 {
176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 );
179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format );
184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from Events/Todos"), format );
187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 );
195 }
196
197 bool addCat() { return addCatBut->isChecked(); }
198private:
199 QRadioButton* addCatBut;
200};
201
202
203
204CalendarView::CalendarView( CalendarResources *calendar,
205 QWidget *parent, const char *name )
206 : CalendarViewBase( parent, name ),
207 mCalendar( calendar ),
208 mResourceManager( calendar->resourceManager() )
209{
210
211 mEventEditor = 0;
212 mTodoEditor = 0;
213
214 init();
215}
216
217CalendarView::CalendarView( Calendar *calendar,
218 QWidget *parent, const char *name )
219 : CalendarViewBase( parent, name ),
220 mCalendar( calendar ),
221 mResourceManager( 0 )
222{
223
224 mEventEditor = 0;
225 mTodoEditor = 0;
226 init();}
227
228void CalendarView::init()
229{
230 beamDialog = new KOBeamPrefs();
231 mDatePickerMode = 0;
232 mCurrentSyncDevice = "";
233 writeLocale();
234 mViewManager = new KOViewManager( this );
235 mDialogManager = new KODialogManager( this );
236 mEventViewerDialog = 0;
237 mModified = false;
238 mReadOnly = false;
239 mSelectedIncidence = 0;
240 mSyncProfiles.setAutoDelete(true);
241 mCalPrinter = 0;
242 mFilters.setAutoDelete(true);
243
244 mCalendar->registerObserver( this );
245 // TODO: Make sure that view is updated, when calendar is changed.
246
247 mStorage = new FileStorage( mCalendar );
248 mNavigator = new DateNavigator( this, "datevav", mViewManager );
249
250 QBoxLayout *topLayout = (QBoxLayout*)layout();
251#ifndef KORG_NOSPLITTER
252 // create the main layout frames.
253 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
254 topLayout->addWidget(mPanner);
255
256 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
257 "CalendarView::LeftFrame");
258 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
259
260 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
261 "CalendarView::DateNavigator", QDate::currentDate() );
262 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
263 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
264 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
265
266#ifdef KORG_NORESOURCEVIEW
267 mResourceView = 0;
268#else
269 if ( mResourceManager ) {
270 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
271 mResourceView->updateView();
272 connect( mResourceView, SIGNAL( resourcesChanged() ),
273 SLOT( updateView() ) );
274 } else {
275 mResourceView = 0;
276 }
277#endif
278 QWidget *rightBox = new QWidget( mPanner );
279 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
280
281 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
282 rightLayout->addWidget( mNavigatorBar );
283
284 mRightFrame = new QWidgetStack( rightBox );
285 rightLayout->addWidget( mRightFrame, 1 );
286
287 mLeftFrame = mLeftSplitter;
288#else
289 QWidget *mainBox = new QWidget( this );
290 QWidget *leftFrame = new QWidget( mainBox );
291
292 QBoxLayout * mainBoxLayout;
293 QBoxLayout * leftFrameLayout;
294 if ( KOPrefs::instance()->mVerticalScreen ) {
295 mainBoxLayout = new QVBoxLayout(mainBox);
296 leftFrameLayout = new QHBoxLayout(leftFrame );
297 } else {
298 mainBoxLayout = new QHBoxLayout(mainBox);
299 leftFrameLayout = new QVBoxLayout(leftFrame );
300 }
301 topLayout->addWidget( mainBox );
302 mainBoxLayout->addWidget (leftFrame);
303 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
304 "CalendarView::DateNavigator", QDate::currentDate());
305 // mDateNavigator->blockSignals( true );
306 leftFrameLayout->addWidget( mDateNavigator );
307 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
308 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
309
310 if ( QApplication::desktop()->width() < 480 ) {
311 leftFrameLayout->addWidget(mFilterView);
312 leftFrameLayout->addWidget(mTodoList, 2 );
313
314 } else {
315 leftFrameLayout->addWidget(mTodoList,2 );
316 leftFrameLayout->addWidget(mFilterView );
317 }
318 mFilterView->hide();
319 QWidget *rightBox = new QWidget( mainBox );
320 mainBoxLayout->addWidget ( rightBox, 10 );
321 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
322 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
323 mRightFrame = new QWidgetStack( rightBox );
324 rightLayout->addWidget( mNavigatorBar );
325 rightLayout->addWidget( mRightFrame, 10 );
326
327 mLeftFrame = leftFrame;
328 if ( KOPrefs::instance()->mVerticalScreen ) {
329 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
330 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
331 } else {
332 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
333 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
334 }
335
336 //qDebug("Calendarview Size %d %d ", width(), height());
337#endif
338
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 SLOT( showDates( const KCal::DateList & ) ) );
341 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
342 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
343
344 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
345 mNavigator, SLOT( selectPreviousYear() ) );
346 connect( mNavigatorBar, SIGNAL( goNextYear() ),
347 mNavigator, SLOT( selectNextYear() ) );
348 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
349 mNavigator, SLOT( selectPreviousMonth() ) );
350 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
351 mNavigator, SLOT( selectNextMonth() ) );
352
353 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
354 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
355
356 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
357 mNavigator, SLOT( selectWeek( const QDate & ) ) );
358
359 connect( mDateNavigator, SIGNAL( goPrevYear() ),
360 mNavigator, SLOT( selectPreviousYear() ) );
361 connect( mDateNavigator, SIGNAL( goNextYear() ),
362 mNavigator, SLOT( selectNextYear() ) );
363 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
364 mNavigator, SLOT( selectPreviousMonth() ) );
365 connect( mDateNavigator, SIGNAL( goNextMonth() ),
366 mNavigator, SLOT( selectNextMonth() ) );
367
368 connect( mDateNavigator, SIGNAL( goPrevious() ),
369 mNavigator, SLOT( selectPrevious() ) );
370 connect( mDateNavigator, SIGNAL( goNext() ),
371 mNavigator, SLOT( selectNext() ) );
372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
375 mNavigator, SLOT( slotMonthSelect( int ) ) );
376
377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
379
380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
381 SLOT( eventAdded( Event *) ) );
382
383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
384
385 connect( this, SIGNAL( configChanged() ),
386 mDateNavigator, SLOT( updateConfig() ) );
387
388 connect( mTodoList, SIGNAL( newTodoSignal() ),
389 SLOT( newTodo() ) );
390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
391 SLOT( newSubTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
393 SLOT( editTodo( Todo * ) ) );
394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
395 SLOT( showTodo( Todo *) ) );
396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
397 SLOT( deleteTodo( Todo *) ) );
398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
400 SLOT( purgeCompleted() ) );
401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
402 SIGNAL( todoModified( Todo *, int ) ) );
403
404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
405 this, SLOT ( cloneIncidence( Incidence * ) ) );
406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
407 this, SLOT (cancelIncidence( Incidence * ) ) );
408
409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
410 this, SLOT ( moveIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
412 this, SLOT ( beamIncidence( Incidence * ) ) );
413
414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
415 this, SLOT ( todo_unsub( Todo * ) ) );
416
417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
418 SLOT( updateTodo( Todo *, int ) ) );
419 connect( this, SIGNAL( todoModified( Todo *, int )), this,
420 SLOT( changeTodoDisplay( Todo *, int ) ) );
421
422
423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
427
428
429
430
431
432 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
433 SLOT(checkClipboard()));
434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
435 SLOT( processTodoListSelection( Incidence * ) ) );
436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
437
438 // kdDebug() << "CalendarView::CalendarView() done" << endl;
439
440 mDateFrame = new QVBox(0,0,WType_Popup);
441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
443 mDateFrame->setLineWidth(3);
444 mDateFrame->hide();
445 mDateFrame->setCaption( i18n( "Pick a date to display"));
446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
447
448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
449
450 mEventEditor = mDialogManager->getEventEditor();
451 mTodoEditor = mDialogManager->getTodoEditor();
452
453 mFlagEditDescription = false;
454
455 mSuspendTimer = new QTimer( this );
456 mAlarmTimer = new QTimer( this );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463}
464
465
466CalendarView::~CalendarView()
467{
468 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager;
471 delete mViewManager;
472 delete mStorage;
473 delete mDateFrame ;
474 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl;
476}
477void CalendarView::timerAlarm()
478{
479 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification );
481}
482
483void CalendarView::suspendAlarm()
484{
485 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification );
487
488}
489
490void CalendarView::startAlarm( QString mess , QString filename)
491{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493
494}
495
496
497void CalendarView::computeAlarm( QString msg )
498{
499
500 QString mess = msg;
501 QString mAlarmMessage = mess.mid( 9 );
502 QString filename = MainWindow::resourcePath();
503 filename += "koalarm.wav";
504 QString tempfilename;
505 if ( mess.left( 13 ) == "suspend_alarm") {
506 bool error = false;
507 int len = mess.mid( 13 ).find("+++");
508 if ( len < 2 )
509 error = true;
510 else {
511 tempfilename = mess.mid( 13, len );
512 if ( !QFile::exists( tempfilename ) )
513 error = true;
514 }
515 if ( ! error ) {
516 filename = tempfilename;
517 }
518 mAlarmMessage = mess.mid( 13+len+3 );
519 //qDebug("suspend file %s ",tempfilename.latin1() );
520 startAlarm( mAlarmMessage, filename);
521 return;
522 }
523 if ( mess.left( 11 ) == "timer_alarm") {
524 //mTimerTime = 0;
525 startAlarm( mess.mid( 11 ), filename );
526 return;
527 }
528 if ( mess.left( 10 ) == "proc_alarm") {
529 bool error = false;
530 int len = mess.mid( 10 ).find("+++");
531 if ( len < 2 )
532 error = true;
533 else {
534 tempfilename = mess.mid( 10, len );
535 if ( !QFile::exists( tempfilename ) )
536 error = true;
537 }
538 if ( error ) {
539 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
540 mAlarmMessage += mess.mid( 10+len+3+9 );
541 } else {
542 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
543 //qDebug("-----system command %s ",tempfilename.latin1() );
544#ifndef _WIN32_
545 if ( vfork () == 0 ) {
546 execl ( tempfilename.latin1(), 0 );
547 return;
548 }
549#else
550 QProcess* p = new QProcess();
551 p->addArgument( tempfilename.latin1() );
552 p->start();
553 return;
554#endif
555
556 return;
557 }
558
559 //qDebug("+++++++system command %s ",tempfilename.latin1() );
560 }
561 if ( mess.left( 11 ) == "audio_alarm") {
562 bool error = false;
563 int len = mess.mid( 11 ).find("+++");
564 if ( len < 2 )
565 error = true;
566 else {
567 tempfilename = mess.mid( 11, len );
568 if ( !QFile::exists( tempfilename ) )
569 error = true;
570 }
571 if ( ! error ) {
572 filename = tempfilename;
573 }
574 mAlarmMessage = mess.mid( 11+len+3+9 );
575 //qDebug("audio file command %s ",tempfilename.latin1() );
576 }
577 if ( mess.left( 9 ) == "cal_alarm") {
578 mAlarmMessage = mess.mid( 9 ) ;
579 }
580
581 startAlarm( mAlarmMessage, filename );
582
583
584}
585
586void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
587{
588 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
589
590 mSuspendAlarmNotification = noti;
591 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
592 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
593 mSuspendTimer->start( ms , true );
594
595}
596
597void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
598{
599 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
600 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
601#ifndef DESKTOP_VERSION
602 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
603#endif
604 return;
605 }
606 mAlarmNotification = noti;
607 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
608 //qDebug("Alarm timer started with secs: %d ", ms/1000);
609 mAlarmTimer->start( ms , true );
610
611}
612void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
613{
614 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
615 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
616#ifndef DESKTOP_VERSION
617 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
618#endif
619 return;
620 }
621 mAlarmTimer->stop();
622}
623void CalendarView::selectWeekNum ( int num )
624{
625 dateNavigator()->selectWeek( num );
626 mViewManager->showWeekView();
627}
628KOViewManager *CalendarView::viewManager()
629{
630 return mViewManager;
631}
632
633KODialogManager *CalendarView::dialogManager()
634{
635 return mDialogManager;
636}
637
638QDate CalendarView::startDate()
639{
640 DateList dates = mNavigator->selectedDates();
641
642 return dates.first();
643}
644
645QDate CalendarView::endDate()
646{
647 DateList dates = mNavigator->selectedDates();
648
649 return dates.last();
650}
651
652
653void CalendarView::createPrinter()
654{
655#ifndef KORG_NOPRINTER
656 if (!mCalPrinter) {
657 mCalPrinter = new CalPrinter(this, mCalendar);
658 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
659 }
660#endif
661}
662
663void CalendarView::confSync()
664{
665 static KOSyncPrefsDialog* sp = 0;
666 if ( ! sp ) {
667 sp = new KOSyncPrefsDialog( this, "syncprefs", true );
668 }
669 sp->usrReadConfig();
670#ifndef DESKTOP_VERSION
671 sp->showMaximized();
672#else
673 sp->show();
674#endif
675 sp->exec();
676
677}
678
679
680//KOPrefs::instance()->mWriteBackFile
681//KOPrefs::instance()->mWriteBackExistingOnly
682
683// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
684// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
685// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
686// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
687// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
688// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
689
690int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
691{
692
693 //void setZaurusId(int id);
694 // int zaurusId() const;
695 // void setZaurusUid(int id);
696 // int zaurusUid() const;
697 // void setZaurusStat(int id);
698 // int zaurusStat() const;
699 // 0 equal
700 // 1 take local
701 // 2 take remote
702 // 3 cancel
703 QDateTime lastSync = mLastCalendarSync;
704 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
705 bool remCh, locCh;
706 remCh = ( remote->zaurusUid() != local->zaurusUid() );
707 locCh = ( local->zaurusStat() != local->revision() );
708 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
709 if ( !remCh && ! locCh ) {
710 //qDebug("both not changed ");
711 lastSync = local->lastModified().addDays(1);
712 } else {
713 if ( locCh ) {
714 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
715 lastSync = local->lastModified().addDays( -1 );
716 if ( !remCh )
717 remote->setLastModified( lastSync.addDays( -1 ) );
718 } else {
719 //qDebug(" not loc changed ");
720 lastSync = local->lastModified().addDays( 1 );
721 if ( remCh )
722 remote->setLastModified( lastSync.addDays( 1 ) );
723
724 }
725 }
726 full = true;
727 if ( mode < 3 )
728 mode = 3;
729 } else {
730 if ( local->lastModified() == remote->lastModified() )
731 if ( local->revision() == remote->revision() )
732 return 0;
733
734 }
735 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
736
737 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
738 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
739 //full = true; //debug only
740 if ( full ) {
741 bool equ = false;
742 if ( local->type() == "Event" ) {
743 equ = (*((Event*) local) == *((Event*) remote));
744 }
745 else if ( local->type() =="Todo" )
746 equ = (*((Todo*) local) == (*(Todo*) remote));
747 else if ( local->type() =="Journal" )
748 equ = (*((Journal*) local) == *((Journal*) remote));
749 if ( equ ) {
750 //qDebug("equal ");
751 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
752 local->setZaurusUid( remote->zaurusUid() );
753 }
754 if ( mode < 4 )
755 return 0;
756
757 }//else //debug only
758 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
759 }
760 int result;
761 bool localIsNew;
762 if ( full && mode < 2 )
763 mode = 3;
764
765 switch( mode ) {
766 case 0:
767 if ( lastSync > remote->lastModified() )
768 return 1;
769 if ( lastSync > local->lastModified() )
770 return 2;
771 return 1;
772 break;
773 case 1:
774 if ( lastSync > remote->lastModified() )
775 return 1;
776 if ( lastSync > local->lastModified() )
777 return 2;
778 return 2;
779 break;
780 case 2:
781 if ( local->lastModified() > remote->lastModified() )
782 return 1;
783 else
784 return 2;
785 break;
786 case 3:
787 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
788 if ( lastSync > remote->lastModified() )
789 return 1;
790 if ( lastSync > local->lastModified() )
791 return 2;
792 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
793 localIsNew = local->lastModified() > remote->lastModified();
794 if ( localIsNew )
795 getEventViewerDialog()->setColorMode( 1 );
796 else
797 getEventViewerDialog()->setColorMode( 2 );
798 getEventViewerDialog()->setIncidence(local);
799 if ( localIsNew )
800 getEventViewerDialog()->setColorMode( 2 );
801 else
802 getEventViewerDialog()->setColorMode( 1 );
803 getEventViewerDialog()->addIncidence(remote);
804 getEventViewerDialog()->setColorMode( 0 );
805 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
806 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
807 getEventViewerDialog()->showMe();
808 result = getEventViewerDialog()->executeS( localIsNew );
809 return result;
810
811 break;
812 case 4:
813 return 1;
814 break;
815 case 5:
816 return 2;
817 break;
818
819 default:
820 break;
821 }
822 return 0;
823}
824Event* CalendarView::getLastSyncEvent()
825{
826 Event* lse;
827 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
828 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
829 if (!lse) {
830 lse = new Event();
831 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
832 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
833 lse->setDtStart( mLastCalendarSync );
834 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
835 lse->setCategories( i18n("SyncEvent") );
836 lse->setReadOnly( true );
837 mCalendar->addEvent( lse );
838 }
839
840 return lse;
841
842}
843void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
844{
845 if ( ! lastSync )
846 return;
847 if ( toDelete->zaurusId() < 0 )
848 return;
849 if ( toDelete->type() == "Journal" )
850 return;
851 QString des = lastSync->description();
852 QString pref = "e";
853 if ( toDelete->type() == "Todo" )
854 pref = "t";
855 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
856 lastSync->setReadOnly( false );
857 lastSync->setDescription( des );
858 lastSync->setReadOnly( true );
859
860}
861bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
862{
863 bool syncOK = true;
864 int addedEvent = 0;
865 int addedEventR = 0;
866 int deletedEventR = 0;
867 int deletedEventL = 0;
868 int changedLocal = 0;
869 int changedRemote = 0;
870 //QPtrList<Event> el = local->rawEvents();
871 Event* eventR;
872 QString uid;
873 int take;
874 Event* eventL;
875 Event* eventRSync;
876 Event* eventLSync;
877 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
878 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
879 bool fullDateRange = false;
880 mLastCalendarSync = QDateTime::currentDateTime();
881 QDateTime modifiedCalendar = mLastCalendarSync;;
882 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
883 if ( eventR ) {
884 eventRSync = (Event*) eventR->clone();
885 remote->deleteEvent(eventR );
886
887 } else {
888 fullDateRange = true;
889 eventRSync = new Event();
890 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
891 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
892 eventRSync->setDtStart( mLastCalendarSync );
893 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
894 eventRSync->setCategories( i18n("SyncEvent") );
895 }
896 eventLSync = getLastSyncEvent();
897 if ( eventLSync->dtStart() == mLastCalendarSync )
898 fullDateRange = true;
899
900 if ( ! fullDateRange ) {
901 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
902
903 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
904 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
905 fullDateRange = true;
906 }
907 }
908 if ( fullDateRange )
909 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
910 else
911 mLastCalendarSync = eventLSync->dtStart();
912 // for resyncing if own file has changed
913 if ( mCurrentSyncDevice == "deleteaftersync" ) {
914 mLastCalendarSync = loadedFileVersion;
915 qDebug("setting mLastCalendarSync ");
916 }
917 //qDebug("*************************** ");
918 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
919 QPtrList<Incidence> er = remote->rawIncidences();
920 Incidence* inR = er.first();
921 Incidence* inL;
922 QProgressBar bar( er.count(),0 );
923 bar.setCaption (i18n("Syncing - close to abort!") );
924
925 int w = 300;
926 if ( QApplication::desktop()->width() < 320 )
927 w = 220;
928 int h = bar.sizeHint().height() ;
929 int dw = QApplication::desktop()->width();
930 int dh = QApplication::desktop()->height();
931 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
932 bar.show();
933 int modulo = (er.count()/10)+1;
934 int incCounter = 0;
935 while ( inR ) {
936 if ( ! bar.isVisible() )
937 return false;
938 if ( incCounter % modulo == 0 )
939 bar.setProgress( incCounter );
940 ++incCounter;
941 uid = inR->uid();
942 bool skipIncidence = false;
943 if ( uid.left(21) == QString("last-syncEvent-device") )
944 skipIncidence = true;
945
946 qApp->processEvents();
947 if ( !skipIncidence ) {
948 inL = local->incidence( uid );
949 if ( inL ) { // maybe conflict - same uid in both calendars
950 int maxrev = inL->revision();
951 if ( maxrev < inR->revision() )
952 maxrev = inR->revision();
953 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
954 //qDebug("take %d %s ", take, inL->summary().latin1());
955 if ( take == 3 )
956 return false;
957 if ( take == 1 ) {// take local
958 inL->setZaurusUid( inR->zaurusUid() );
959 remote->deleteIncidence( inR );
960 if ( inL->revision() < maxrev )
961 inL->setRevision( maxrev );
962 remote->addIncidence( inL->clone() );
963 ++changedRemote;
964 } else {
965 if ( inR->revision() < maxrev )
966 inR->setRevision( maxrev );
967 local->deleteIncidence( inL );
968 local->addIncidence( inR->clone() );
969 ++changedLocal;
970 }
971 }
972 } else { // no conflict
973 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
974 QString des = eventLSync->description();
975 QString pref = "e";
976 if ( inR->type() == "Todo" )
977 pref = "t";
978 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
979 inR->setZaurusStat( -3 );
980 //remote->deleteIncidence( inR );
981 ++deletedEventR;
982 } else {
983 inR->setLastModified( modifiedCalendar );
984 local->addIncidence( inR->clone() );
985 ++addedEvent;
986 }
987 } else {
988 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
989 inR->setLastModified( modifiedCalendar );
990 local->addIncidence( inR->clone() );
991 ++addedEvent;
992 } else {
993 checkSharpEvent(eventRSyncSharp, inR);
994 remote->deleteIncidence( inR );
995 ++deletedEventR;
996 }
997 }
998 }
999 }
1000 inR = er.next();
1001 }
1002 QPtrList<Incidence> el = local->rawIncidences();
1003 inL = el.first();
1004 modulo = (el.count()/10)+1;
1005 bar.setCaption (i18n("Add / remove events") );
1006 bar.setTotalSteps ( el.count() ) ;
1007 bar.show();
1008 incCounter = 0;
1009
1010 while ( inL ) {
1011
1012 qApp->processEvents();
1013 if ( ! bar.isVisible() )
1014 return false;
1015 if ( incCounter % modulo == 0 )
1016 bar.setProgress( incCounter );
1017 ++incCounter;
1018 uid = inL->uid();
1019 bool skipIncidence = false;
1020 if ( uid.left(21) == QString("last-syncEvent-device") )
1021 skipIncidence = true;
1022 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" )
1023 skipIncidence = true;
1024 if ( !skipIncidence ) {
1025 inR = remote->incidence( uid );
1026 if ( ! inR ) {
1027 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
1028 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1029 local->deleteIncidence( inL );
1030 ++deletedEventL;
1031 } else {
1032 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1033 inL->setZaurusId( -1 );
1034 ++addedEventR;
1035 inL->setLastModified( modifiedCalendar );
1036 remote->addIncidence( inL->clone() );
1037 }
1038 }
1039 } else {
1040 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1041 checkSharpEvent(eventLSyncSharp, inL);
1042 local->deleteIncidence( inL );
1043 ++deletedEventL;
1044 } else {
1045 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1046 ++addedEventR;
1047 inL->setLastModified( modifiedCalendar );
1048 remote->addIncidence( inL->clone() );
1049 }
1050 }
1051 }
1052 }
1053 }
1054 inL = el.next();
1055 }
1056
1057 bar.hide();
1058 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1059 eventLSync->setReadOnly( false );
1060 eventLSync->setDtStart( mLastCalendarSync );
1061 eventRSync->setDtStart( mLastCalendarSync );
1062 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1063 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1064 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1065 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1066 eventLSync->setReadOnly( true );
1067 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1068 remote->addEvent( eventRSync );
1069 QString mes;
1070 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1071 if ( KOPrefs::instance()->mShowSyncSummary ) {
1072 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1073 }
1074 qDebug( mes );
1075 mCalendar->checkAlarmForIncidence( 0, true );
1076 return syncOK;
1077}
1078
1079void CalendarView::setSyncDevice( QString s )
1080{
1081 mCurrentSyncDevice= s;
1082}
1083void CalendarView::setSyncName( QString s )
1084{
1085 mCurrentSyncName= s;
1086}
1087bool CalendarView::syncCalendar(QString filename, int mode)
1088{
1089 mGlobalSyncMode = SYNC_MODE_NORMAL;
1090 CalendarLocal* calendar = new CalendarLocal();
1091 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1092 FileStorage* storage = new FileStorage( calendar );
1093 bool syncOK = false;
1094 storage->setFileName( filename );
1095 // qDebug("loading ... ");
1096 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1097 getEventViewerDialog()->setSyncMode( true );
1098 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1099 getEventViewerDialog()->setSyncMode( false );
1100 if ( syncOK ) {
1101 if ( KOPrefs::instance()->mWriteBackFile )
1102 {
1103 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1104 storage->save();
1105 }
1106 }
1107 setModified( true );
1108 }
1109 delete storage;
1110 delete calendar;
1111 if ( syncOK )
1112 updateView();
1113 return syncOK;
1114}
1115void CalendarView::syncSharp()
1116{
1117#ifndef DESKTOP_VERSION
1118 mGlobalSyncMode = SYNC_MODE_SHARP;
1119 //mCurrentSyncDevice = "sharp-DTM";
1120 if ( KOPrefs::instance()->mAskForPreferences )
1121 edit_sync_options();
1122 qApp->processEvents();
1123 CalendarLocal* calendar = new CalendarLocal();
1124 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1125 bool syncOK = false;
1126 SharpFormat sharpFormat;
1127 if ( sharpFormat.load( calendar, mCalendar ) ) {
1128 getEventViewerDialog()->setSyncMode( true );
1129 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1130 getEventViewerDialog()->setSyncMode( false );
1131 qApp->processEvents();
1132 if ( syncOK ) {
1133 if ( KOPrefs::instance()->mWriteBackFile )
1134 {
1135 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1136 Incidence* inc = iL.first();
1137 while ( inc ) {
1138 inc->setZaurusStat( inc->revision () );
1139 inc = iL.next();
1140 }
1141 // pending: clean last sync event description
1142 sharpFormat.save(calendar);
1143 iL = calendar->rawIncidences();
1144 inc = iL.first();
1145 Incidence* loc;
1146 while ( inc ) {
1147 if ( inc->zaurusStat() == -4 ) {
1148 loc = mCalendar->incidence(inc->uid() );
1149 if ( loc ) {
1150 loc->setZaurusId( inc->zaurusId() );
1151 loc->setZaurusUid( inc->zaurusUid() );
1152 }
1153 }
1154 inc = iL.next();
1155 }
1156 Incidence* lse = getLastSyncEvent();
1157 if ( lse ) {
1158 lse->setReadOnly( false );
1159 lse->setDescription( "" );
1160 lse->setReadOnly( true );
1161 }
1162 }
1163 }
1164 setModified( true );
1165 } else {
1166 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1167 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1168 question, i18n("Ok")) ;
1169
1170 }
1171 delete calendar;
1172 updateView();
1173 return ;//syncOK;
1174#endif
1175}
1176
1177
1178#include <kabc/stdaddressbook.h>
1179bool CalendarView::importBday()
1180{
1181 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1182 KABC::AddressBook::Iterator it;
1183 int count = 0;
1184 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1185 ++count;
1186 }
1187 QProgressBar bar(count,0 );
1188 int w = 300;
1189 if ( QApplication::desktop()->width() < 320 )
1190 w = 220;
1191 int h = bar.sizeHint().height() ;
1192 int dw = QApplication::desktop()->width();
1193 int dh = QApplication::desktop()->height();
1194 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1195 bar.show();
1196 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1197 qApp->processEvents();
1198 count = 0;
1199 int addCount = 0;
1200 KCal::Attendee* a = 0;
1201 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1202 if ( ! bar.isVisible() )
1203 return false;
1204 bar.setProgress( count++ );
1205 qApp->processEvents();
1206 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1207 if ( (*it).birthday().date().isValid() ){
1208 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1209 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1210 ++addCount;
1211 }
1212 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1213 if ( anni.isValid() ){
1214 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1215 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1216 ++addCount;
1217 }
1218 }
1219 updateView();
1220 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1221 return true;
1222}
1223
1224bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1225{
1226 //qDebug("addAnni ");
1227 Event * ev = new Event();
1228 if ( a ) {
1229 ev->addAttendee( a );
1230 }
1231 QString kind;
1232 if ( birthday )
1233 kind = i18n( "Birthday" );
1234 else
1235 kind = i18n( "Anniversary" );
1236 ev->setSummary( name + " - " + kind );
1237 ev->setOrganizer( "nobody@nowhere" );
1238 ev->setCategories( kind );
1239 ev->setDtStart( QDateTime(date) );
1240 ev->setDtEnd( QDateTime(date) );
1241 ev->setFloats( true );
1242 Recurrence * rec = ev->recurrence();
1243 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1244 rec->addYearlyNum( date.month() );
1245 if ( !mCalendar->addEventNoDup( ev ) ) {
1246 delete ev;
1247 return false;
1248 }
1249 return true;
1250
1251}
1252bool CalendarView::importQtopia( const QString &categories,
1253 const QString &datebook,
1254 const QString &todolist )
1255{
1256
1257 QtopiaFormat qtopiaFormat;
1258 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1259 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1260 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1261 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1262
1263 updateView();
1264 return true;
1265
1266#if 0
1267 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1268 mCurrentSyncDevice = "qtopia-XML";
1269 if ( KOPrefs::instance()->mAskForPreferences )
1270 edit_sync_options();
1271 qApp->processEvents();
1272 CalendarLocal* calendar = new CalendarLocal();
1273 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1274 bool syncOK = false;
1275 QtopiaFormat qtopiaFormat;
1276 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1277 bool loadOk = true;
1278 if ( !categories.isEmpty() )
1279 loadOk = qtopiaFormat.load( calendar, categories );
1280 if ( loadOk && !datebook.isEmpty() )
1281 loadOk = qtopiaFormat.load( calendar, datebook );
1282 if ( loadOk && !todolist.isEmpty() )
1283 loadOk = qtopiaFormat.load( calendar, todolist );
1284
1285 if ( loadOk ) {
1286 getEventViewerDialog()->setSyncMode( true );
1287 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1288 getEventViewerDialog()->setSyncMode( false );
1289 qApp->processEvents();
1290 if ( syncOK ) {
1291 if ( KOPrefs::instance()->mWriteBackFile )
1292 {
1293 // write back XML file
1294
1295 }
1296 setModified( true );
1297 }
1298 } else {
1299 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1300 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1301 question, i18n("Ok")) ;
1302 }
1303 delete calendar;
1304 updateView();
1305 return syncOK;
1306
1307
1308#endif
1309
1310}
1311
1312void CalendarView::setSyncEventsReadOnly()
1313{
1314 Event * ev;
1315 QPtrList<Event> eL = mCalendar->rawEvents();
1316 ev = eL.first();
1317 while ( ev ) {
1318 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1319 ev->setReadOnly( true );
1320 ev = eL.next();
1321 }
1322}
1323bool CalendarView::openCalendar(QString filename, bool merge)
1324{
1325
1326 if (filename.isEmpty()) {
1327 return false;
1328 }
1329
1330 if (!QFile::exists(filename)) {
1331 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1332 return false;
1333 }
1334
1335 globalFlagBlockAgenda = 1;
1336 if (!merge) mCalendar->close();
1337
1338 mStorage->setFileName( filename );
1339
1340 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1341 if ( merge ) ;//setModified( true );
1342 else {
1343 //setModified( true );
1344 mViewManager->setDocumentId( filename );
1345 mDialogManager->setDocumentId( filename );
1346 mTodoList->setDocumentId( filename );
1347 }
1348 globalFlagBlockAgenda = 2;
1349 // if ( getLastSyncEvent() )
1350 // getLastSyncEvent()->setReadOnly( true );
1351 mCalendar->reInitAlarmSettings();
1352 setSyncEventsReadOnly();
1353 updateUnmanagedViews();
1354 updateView();
1355 if ( filename != MainWindow::defaultFileName() )
1356 saveCalendar( MainWindow::defaultFileName() );
1357 loadedFileVersion = QDateTime::currentDateTime();
1358 return true;
1359 } else {
1360 // while failing to load, the calendar object could
1361 // have become partially populated. Clear it out.
1362 if ( !merge ) mCalendar->close();
1363
1364 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1365
1366 globalFlagBlockAgenda = 2;
1367 updateView();
1368 }
1369 return false;
1370}
1371void CalendarView::setLoadedFileVersion(QDateTime dt)
1372{
1373 loadedFileVersion = dt;
1374}
1375bool CalendarView::checkFileChanged(QString fn)
1376{
1377 QFileInfo finf ( fn );
1378 if ( !finf.exists() )
1379 return true;
1380 QDateTime dt = finf.lastModified ();
1381 if ( dt <= loadedFileVersion )
1382 return false;
1383 return true;
1384
1385}
1386bool CalendarView::checkFileVersion(QString fn)
1387{
1388 QFileInfo finf ( fn );
1389 if ( !finf.exists() )
1390 return true;
1391 QDateTime dt = finf.lastModified ();
1392 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1393 //qDebug("file on disk version %s",dt.toString().latin1());
1394 if ( dt <= loadedFileVersion )
1395 return true;
1396 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1397 i18n("KO/Pi Warning"),i18n("Overwrite"),
1398 i18n("Sync+save"));
1399
1400 if ( km == KMessageBox::Cancel )
1401 return false;
1402 if ( km == KMessageBox::Yes )
1403 return true;
1404
1405 setSyncDevice("deleteaftersync" );
1406 KOPrefs::instance()->mAskForPreferences = true;
1407 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1408 KOPrefs::instance()->mWriteBackFile = false;
1409 KOPrefs::instance()->mWriteBackExistingOnly = false;
1410 KOPrefs::instance()->mShowSyncSummary = false;
1411 syncCalendar( fn, 3 );
1412 Event * e = getLastSyncEvent();
1413 mCalendar->deleteEvent ( e );
1414 updateView();
1415 return true;
1416}
1417
1418bool CalendarView::saveCalendar( QString filename )
1419{
1420
1421 // Store back all unsaved data into calendar object
1422 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1423 if ( mViewManager->currentView() )
1424 mViewManager->currentView()->flushView();
1425
1426 //mStorage->setFileName( filename );
1427
1428 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1429 mStorage->setFileName( filename );
1430 bool success;
1431 success = mStorage->save();
1432 if ( !success ) {
1433 return false;
1434 }
1435
1436 return true;
1437}
1438
1439void CalendarView::closeCalendar()
1440{
1441
1442 // child windows no longer valid
1443 emit closingDown();
1444
1445 mCalendar->close();
1446 setModified(false);
1447 updateView();
1448}
1449
1450void CalendarView::archiveCalendar()
1451{
1452 mDialogManager->showArchiveDialog();
1453}
1454
1455
1456void CalendarView::readSettings()
1457{
1458
1459
1460 // mViewManager->showAgendaView();
1461 QString str;
1462 //qDebug("CalendarView::readSettings() ");
1463 // read settings from the KConfig, supplying reasonable
1464 // defaults where none are to be found
1465 KConfig *config = KOGlobals::config();
1466#ifndef KORG_NOSPLITTER
1467 config->setGroup("KOrganizer Geometry");
1468
1469 QValueList<int> sizes = config->readIntListEntry("Separator1");
1470 if (sizes.count() != 2) {
1471 sizes << mDateNavigator->minimumSizeHint().width();
1472 sizes << 300;
1473 }
1474 mPanner->setSizes(sizes);
1475
1476 sizes = config->readIntListEntry("Separator2");
1477 if ( ( mResourceView && sizes.count() == 4 ) ||
1478 ( !mResourceView && sizes.count() == 3 ) ) {
1479 mLeftSplitter->setSizes(sizes);
1480 }
1481#endif
1482 globalFlagBlockAgenda = 1;
1483 mViewManager->showAgendaView();
1484 //mViewManager->readSettings( config );
1485 mTodoList->restoreLayout(config,QString("Todo Layout"));
1486 readFilterSettings(config);
1487 config->setGroup( "Views" );
1488 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1489 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1490 else if ( dateCount == 7 ) mNavigator->selectWeek();
1491 else mNavigator->selectDates( dateCount );
1492 // mViewManager->readSettings( config );
1493 updateConfig();
1494 globalFlagBlockAgenda = 2;
1495 mViewManager->readSettings( config );
1496#ifdef DESKTOP_VERSION
1497 config->setGroup("WidgetLayout");
1498 QStringList list;
1499 list = config->readListEntry("MainLayout");
1500 int x,y,w,h;
1501 if ( ! list.isEmpty() ) {
1502 x = list[0].toInt();
1503 y = list[1].toInt();
1504 w = list[2].toInt();
1505 h = list[3].toInt();
1506 topLevelWidget()->setGeometry(x,y,w,h);
1507
1508 } else {
1509 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1510 }
1511 list = config->readListEntry("EditEventLayout");
1512 if ( ! list.isEmpty() ) {
1513 x = list[0].toInt();
1514 y = list[1].toInt();
1515 w = list[2].toInt();
1516 h = list[3].toInt();
1517 mEventEditor->setGeometry(x,y,w,h);
1518
1519 }
1520 list = config->readListEntry("EditTodoLayout");
1521 if ( ! list.isEmpty() ) {
1522 x = list[0].toInt();
1523 y = list[1].toInt();
1524 w = list[2].toInt();
1525 h = list[3].toInt();
1526 mTodoEditor->setGeometry(x,y,w,h);
1527
1528 }
1529 list = config->readListEntry("ViewerLayout");
1530 if ( ! list.isEmpty() ) {
1531 x = list[0].toInt();
1532 y = list[1].toInt();
1533 w = list[2].toInt();
1534 h = list[3].toInt();
1535 getEventViewerDialog()->setGeometry(x,y,w,h);
1536 }
1537#endif
1538
1539
1540 // pending read sync settings;
1541 mSyncProfileNames.clear();
1542 mSyncProfileNames << "Profile_1";
1543 mSyncProfileNames << "Profile_2";
1544 mSyncProfileNames << "Profile_3";
1545 mSyncProfileNames << "Profile_4";
1546 mSyncProfileNames << "Profile_5";
1547 KSyncProfile* temp = new KSyncProfile ();
1548 temp->setName("Profile_1" );
1549 mSyncProfiles.append( temp );
1550 temp = new KSyncProfile ();
1551 temp->setName("Profile_2" );
1552 mSyncProfiles.append( temp );
1553 temp = new KSyncProfile ();
1554 temp->setName("Profile_3" );
1555 mSyncProfiles.append( temp );
1556 temp = new KSyncProfile ();
1557 temp->setName("Profile_4" );
1558 mSyncProfiles.append( temp );
1559 temp = new KSyncProfile ();
1560 temp->setName("Profile_5" );
1561 mSyncProfiles.append( temp );
1562}
1563
1564
1565void CalendarView::writeSettings()
1566{
1567 // kdDebug() << "CalendarView::writeSettings" << endl;
1568
1569 KConfig *config = KOGlobals::config();
1570
1571#ifndef KORG_NOSPLITTER
1572 config->setGroup("KOrganizer Geometry");
1573
1574 QValueList<int> list = mPanner->sizes();
1575 config->writeEntry("Separator1",list);
1576
1577 list = mLeftSplitter->sizes();
1578 config->writeEntry("Separator2",list);
1579#endif
1580
1581 mViewManager->writeSettings( config );
1582 mTodoList->saveLayout(config,QString("Todo Layout"));
1583 mDialogManager->writeSettings( config );
1584 //KOPrefs::instance()->usrWriteConfig();
1585 KOPrefs::instance()->writeConfig();
1586
1587 writeFilterSettings(config);
1588
1589 config->setGroup( "Views" );
1590 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1591
1592#ifdef DESKTOP_VERSION
1593 config->setGroup("WidgetLayout");
1594 QStringList list ;//= config->readListEntry("MainLayout");
1595 int x,y,w,h;
1596 QWidget* wid;
1597 wid = topLevelWidget();
1598 x = wid->geometry().x();
1599 y = wid->geometry().y();
1600 w = wid->width();
1601 h = wid->height();
1602 list.clear();
1603 list << QString::number( x );
1604 list << QString::number( y );
1605 list << QString::number( w );
1606 list << QString::number( h );
1607 config->writeEntry("MainLayout",list );
1608
1609 wid = mEventEditor;
1610 x = wid->geometry().x();
1611 y = wid->geometry().y();
1612 w = wid->width();
1613 h = wid->height();
1614 list.clear();
1615 list << QString::number( x );
1616 list << QString::number( y );
1617 list << QString::number( w );
1618 list << QString::number( h );
1619 config->writeEntry("EditEventLayout",list );
1620
1621 wid = mTodoEditor;
1622 x = wid->geometry().x();
1623 y = wid->geometry().y();
1624 w = wid->width();
1625 h = wid->height();
1626 list.clear();
1627 list << QString::number( x );
1628 list << QString::number( y );
1629 list << QString::number( w );
1630 list << QString::number( h );
1631 config->writeEntry("EditTodoLayout",list );
1632 wid = getEventViewerDialog();
1633 x = wid->geometry().x();
1634 y = wid->geometry().y();
1635 w = wid->width();
1636 h = wid->height();
1637 list.clear();
1638 list << QString::number( x );
1639 list << QString::number( y );
1640 list << QString::number( w );
1641 list << QString::number( h );
1642 config->writeEntry("ViewerLayout",list );
1643 wid = mDialogManager->getSearchDialog();
1644 if ( wid ) {
1645 x = wid->geometry().x();
1646 y = wid->geometry().y();
1647 w = wid->width();
1648 h = wid->height();
1649 list.clear();
1650 list << QString::number( x );
1651 list << QString::number( y );
1652 list << QString::number( w );
1653 list << QString::number( h );
1654 config->writeEntry("SearchLayout",list );
1655 }
1656#endif
1657
1658
1659 config->sync();
1660}
1661
1662void CalendarView::readFilterSettings(KConfig *config)
1663{
1664 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1665
1666 mFilters.clear();
1667
1668 config->setGroup("General");
1669 QStringList filterList = config->readListEntry("CalendarFilters");
1670
1671 QStringList::ConstIterator it = filterList.begin();
1672 QStringList::ConstIterator end = filterList.end();
1673 while(it != end) {
1674 // kdDebug() << " filter: " << (*it) << endl;
1675
1676 CalFilter *filter;
1677 filter = new CalFilter(*it);
1678 config->setGroup("Filter_" + (*it));
1679 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1680 filter->setCriteria(config->readNumEntry("Criteria",0));
1681 filter->setCategoryList(config->readListEntry("CategoryList"));
1682 mFilters.append(filter);
1683
1684 ++it;
1685 }
1686
1687 if (mFilters.count() == 0) {
1688 CalFilter *filter = new CalFilter(i18n("Default"));
1689 mFilters.append(filter);
1690 }
1691 mFilterView->updateFilters();
1692 config->setGroup("FilterView");
1693
1694 mFilterView->blockSignals(true);
1695 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1696 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1697 mFilterView->blockSignals(false);
1698 // We do it manually to avoid it being done twice by the above calls
1699 updateFilter();
1700}
1701
1702void CalendarView::writeFilterSettings(KConfig *config)
1703{
1704 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1705
1706 QStringList filterList;
1707
1708 CalFilter *filter = mFilters.first();
1709 while(filter) {
1710 // kdDebug() << " fn: " << filter->name() << endl;
1711 filterList << filter->name();
1712 config->setGroup("Filter_" + filter->name());
1713 config->writeEntry("Criteria",filter->criteria());
1714 config->writeEntry("CategoryList",filter->categoryList());
1715 filter = mFilters.next();
1716 }
1717 config->setGroup("General");
1718 config->writeEntry("CalendarFilters",filterList);
1719
1720 config->setGroup("FilterView");
1721 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1722 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1723}
1724
1725
1726void CalendarView::goToday()
1727{
1728 mNavigator->selectToday();
1729}
1730
1731void CalendarView::goNext()
1732{
1733 mNavigator->selectNext();
1734}
1735
1736void CalendarView::goPrevious()
1737{
1738 mNavigator->selectPrevious();
1739}
1740void CalendarView::goNextMonth()
1741{
1742 mNavigator->selectNextMonth();
1743}
1744
1745void CalendarView::goPreviousMonth()
1746{
1747 mNavigator->selectPreviousMonth();
1748}
1749void CalendarView::writeLocale()
1750{
1751 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1752 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1753 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
1754 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1755 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1756 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1757 dummy = KOPrefs::instance()->mUserDateFormatShort;
1758 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1759 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1760 KOPrefs::instance()->mDaylightsavingStart,
1761 KOPrefs::instance()->mDaylightsavingEnd );
1762 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1763}
1764void CalendarView::updateConfig()
1765{
1766 writeLocale();
1767 if ( KOPrefs::instance()->mUseAppColors )
1768 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1769 emit configChanged();
1770 mTodoList->updateConfig();
1771 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1772 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1773 // To make the "fill window" configurations work
1774 //mViewManager->raiseCurrentView();
1775}
1776
1777
1778void CalendarView::eventChanged(Event *event)
1779{
1780 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1781 //updateUnmanagedViews();
1782}
1783
1784void CalendarView::eventAdded(Event *event)
1785{
1786 changeEventDisplay(event,KOGlobals::EVENTADDED);
1787}
1788
1789void CalendarView::eventToBeDeleted(Event *)
1790{
1791 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1792}
1793
1794void CalendarView::eventDeleted()
1795{
1796 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1797}
1798void CalendarView::changeTodoDisplay(Todo *which, int action)
1799{
1800 changeIncidenceDisplay((Incidence *)which, action);
1801}
1802void CalendarView::checkZaurusId( int id, bool todo )
1803{
1804 if ( id >= 0 ) {
1805 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM");
1806 if ( lse ) {
1807 QString des = lse->description();
1808 QString pref = "e";
1809 if ( todo )
1810 pref = "t";
1811 des += pref+ QString::number ( id ) + ",";
1812 lse->setReadOnly( false );
1813 lse->setDescription( des );
1814 lse->setReadOnly( true );
1815 }
1816 }
1817}
1818void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1819{
1820 updateUnmanagedViews();
1821 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1822 if ( action == KOGlobals::EVENTDELETED ) { //delete
1823 mCalendar->checkAlarmForIncidence( 0, true );
1824 if ( mEventViewerDialog )
1825 mEventViewerDialog->hide();
1826 }
1827 else
1828 mCalendar->checkAlarmForIncidence( which , false );
1829}
1830
1831// most of the changeEventDisplays() right now just call the view's
1832// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1833void CalendarView::changeEventDisplay(Event *which, int action)
1834{
1835 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1836 changeIncidenceDisplay((Incidence *)which, action);
1837 mDateNavigator->updateView();
1838 //mDialogManager->updateSearchDialog();
1839
1840 if (which) {
1841 // If there is an event view visible update the display
1842 mViewManager->currentView()->changeEventDisplay(which,action);
1843 // TODO: check, if update needed
1844 // if (which->getTodoStatus()) {
1845 mTodoList->updateView();
1846 // }
1847 } else {
1848 mViewManager->currentView()->updateView();
1849 }
1850}
1851
1852
1853void CalendarView::updateTodoViews()
1854{
1855
1856 mTodoList->updateView();
1857 mViewManager->currentView()->updateView();
1858
1859}
1860
1861
1862void CalendarView::updateView(const QDate &start, const QDate &end)
1863{
1864 mTodoList->updateView();
1865 mViewManager->updateView(start, end);
1866 //mDateNavigator->updateView();
1867}
1868
1869void CalendarView::updateView()
1870{
1871 DateList tmpList = mNavigator->selectedDates();
1872
1873 // We assume that the navigator only selects consecutive days.
1874 updateView( tmpList.first(), tmpList.last() );
1875}
1876
1877void CalendarView::updateUnmanagedViews()
1878{
1879 mDateNavigator->updateDayMatrix();
1880}
1881
1882int CalendarView::msgItemDelete()
1883{
1884 return KMessageBox::warningContinueCancel(this,
1885 i18n("This item will be\npermanently deleted."),
1886 i18n("KO/Pi Confirmation"),i18n("Delete"));
1887}
1888
1889
1890void CalendarView::edit_cut()
1891{
1892 Event *anEvent=0;
1893
1894 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1895
1896 if (mViewManager->currentView()->isEventView()) {
1897 if ( incidence && incidence->type() == "Event" ) {
1898 anEvent = static_cast<Event *>(incidence);
1899 }
1900 }
1901
1902 if (!anEvent) {
1903 KNotifyClient::beep();
1904 return;
1905 }
1906 DndFactory factory( mCalendar );
1907 factory.cutEvent(anEvent);
1908 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1909}
1910
1911void CalendarView::edit_copy()
1912{
1913 Event *anEvent=0;
1914
1915 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1916
1917 if (mViewManager->currentView()->isEventView()) {
1918 if ( incidence && incidence->type() == "Event" ) {
1919 anEvent = static_cast<Event *>(incidence);
1920 }
1921 }
1922
1923 if (!anEvent) {
1924 KNotifyClient::beep();
1925 return;
1926 }
1927 DndFactory factory( mCalendar );
1928 factory.copyEvent(anEvent);
1929}
1930
1931void CalendarView::edit_paste()
1932{
1933 QDate date = mNavigator->selectedDates().first();
1934
1935 DndFactory factory( mCalendar );
1936 Event *pastedEvent = factory.pasteEvent( date );
1937
1938 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1939}
1940
1941void CalendarView::edit_options()
1942{
1943 mDialogManager->showOptionsDialog();
1944 //writeSettings();
1945}
1946void CalendarView::edit_sync_options()
1947{
1948 //mDialogManager->showSyncOptions();
1949 //KOPrefs::instance()->mSyncAlgoPrefs
1950 QDialog dia( this, "dia", true );
1951 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1952 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1953 QVBoxLayout lay ( &dia );
1954 lay.setSpacing( 2 );
1955 lay.setMargin( 3 );
1956 lay.addWidget(&gr);
1957 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1958 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1959 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1960 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1961 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1962 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1963 //QRadioButton both( i18n("Take both on conflict"), &gr );
1964 QPushButton pb ( "OK", &dia);
1965 lay.addWidget( &pb );
1966 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1967 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1968 case 0:
1969 loc.setChecked( true);
1970 break;
1971 case 1:
1972 rem.setChecked( true );
1973 break;
1974 case 2:
1975 newest.setChecked( true);
1976 break;
1977 case 3:
1978 ask.setChecked( true);
1979 break;
1980 case 4:
1981 f_loc.setChecked( true);
1982 break;
1983 case 5:
1984 f_rem.setChecked( true);
1985 break;
1986 case 6:
1987 // both.setChecked( true);
1988 break;
1989 default:
1990 break;
1991 }
1992 if ( dia.exec() ) {
1993 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
1994 }
1995
1996}
1997
1998void CalendarView::slotSelectPickerDate( QDate d)
1999{
2000 mDateFrame->hide();
2001 if ( mDatePickerMode == 1 ) {
2002 mNavigator->slotDaySelect( d );
2003 } else if ( mDatePickerMode == 2 ) {
2004 if ( mMoveIncidence->type() == "Todo" ) {
2005 Todo * to = (Todo *) mMoveIncidence;
2006 QTime tim;
2007 if ( to->hasDueDate() )
2008 tim = to->dtDue().time();
2009 else {
2010 tim = QTime ( 0,0,0 );
2011 to->setFloats( true );
2012 to->setHasDueDate( true );
2013 }
2014 QDateTime dt ( d,tim );
2015 to->setDtDue( dt );
2016 todoChanged( to );
2017 } else {
2018 QTime tim = mMoveIncidence->dtStart().time();
2019 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2020 QDateTime dt ( d,tim );
2021 mMoveIncidence->setDtStart( dt );
2022 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2023 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2024 }
2025
2026 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2027 }
2028}
2029
2030void CalendarView::removeCategories()
2031{
2032 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2033 QStringList catList = KOPrefs::instance()->mCustomCategories;
2034 QStringList catIncList;
2035 QStringList newCatList;
2036 Incidence* inc = incList.first();
2037 int i;
2038 int count = 0;
2039 while ( inc ) {
2040 newCatList.clear();
2041 catIncList = QStringList::split (",", inc->categoriesStr() );
2042 for( i = 0; i< catIncList.count(); ++i ) {
2043 if ( catList.contains (catIncList[i]))
2044 newCatList.append( catIncList[i] );
2045 }
2046 newCatList.sort();
2047 inc->setCategories( newCatList.join(",") );
2048 inc = incList.next();
2049 }
2050}
2051
2052int CalendarView::addCategories()
2053{
2054 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2055 QStringList catList = KOPrefs::instance()->mCustomCategories;
2056 QStringList catIncList;
2057 Incidence* inc = incList.first();
2058 int i;
2059 int count = 0;
2060 while ( inc ) {
2061 catIncList = QStringList::split (",", inc->categoriesStr() );
2062 for( i = 0; i< catIncList.count(); ++i ) {
2063 if ( !catList.contains (catIncList[i])) {
2064 catList.append( catIncList[i] );
2065 //qDebug("add cat %s ", catIncList[i].latin1());
2066 ++count;
2067 }
2068 }
2069 inc = incList.next();
2070 }
2071 catList.sort();
2072 KOPrefs::instance()->mCustomCategories = catList;
2073 return count;
2074}
2075
2076void CalendarView::manageCategories()
2077{
2078 KOCatPrefs* cp = new KOCatPrefs();
2079 cp->show();
2080 int w =cp->sizeHint().width() ;
2081 int h = cp->sizeHint().height() ;
2082 int dw = QApplication::desktop()->width();
2083 int dh = QApplication::desktop()->height();
2084 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2085 if ( !cp->exec() ) {
2086 delete cp;
2087 return;
2088 }
2089 int count = 0;
2090 if ( cp->addCat() ) {
2091 count = addCategories();
2092 if ( count ) {
2093 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2094 writeSettings();
2095 }
2096 } else {
2097 removeCategories();
2098 updateView();
2099 }
2100 delete cp;
2101}
2102
2103void CalendarView::beamIncidence(Incidence * Inc)
2104{
2105 QPtrList<Incidence> delSel ;
2106 delSel.append(Inc);
2107 beamIncidenceList( delSel );
2108}
2109void CalendarView::beamCalendar()
2110{
2111 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2112 //qDebug("beamCalendar() ");
2113 beamIncidenceList( delSel );
2114}
2115void CalendarView::beamFilteredCalendar()
2116{
2117 QPtrList<Incidence> delSel = mCalendar->incidences();
2118 //qDebug("beamFilteredCalendar() ");
2119 beamIncidenceList( delSel );
2120}
2121void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2122{
2123 if ( beamDialog->exec () == QDialog::Rejected )
2124 return;
2125
2126 QString fn = "/tmp/kopibeamfile";
2127 QString mes;
2128 bool createbup = true;
2129 if ( createbup ) {
2130 QString description = "\n";
2131 CalendarLocal* cal = new CalendarLocal();
2132 if ( beamDialog->beamLocal() )
2133 cal->setLocalTime();
2134 else
2135 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2136 Incidence *incidence = delSel.first();
2137 bool addText = false;
2138 if ( delSel.count() < 10 )
2139 addText = true;
2140 else {
2141 description.sprintf(i18n(" %d items?"),delSel.count() );
2142 }
2143 while ( incidence ) {
2144 Incidence *in = incidence->clone();
2145 if ( addText )
2146 description += in->summary() + "\n";
2147 cal->addIncidence( in );
2148 incidence = delSel.next();
2149 }
2150 if ( beamDialog->beamVcal() ) {
2151 fn += ".vcs";
2152 FileStorage storage( cal, fn, new VCalFormat );
2153 storage.save();
2154 } else {
2155 fn += ".ics";
2156 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2157 storage.save();
2158 }
2159 delete cal;
2160 mes = i18n("KO/Pi: Ready for beaming");
2161 setCaption(mes);
2162
2163#ifndef DESKTOP_VERSION
2164 Ir *ir = new Ir( this );
2165 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2166 ir->send( fn, description, "text/x-vCalendar" );
2167#endif
2168 }
2169}
2170void CalendarView::beamDone( Ir *ir )
2171{
2172#ifndef DESKTOP_VERSION
2173 delete ir;
2174#endif
2175}
2176
2177void CalendarView::moveIncidence(Incidence * inc )
2178{
2179 if ( !inc ) return;
2180 // qDebug("showDatePickerForIncidence( ) ");
2181 if ( mDateFrame->isVisible() )
2182 mDateFrame->hide();
2183 else {
2184 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2185 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2186 int dw = QApplication::desktop()->width();
2187 int dh = QApplication::desktop()->height();
2188 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2189 mDateFrame->show();
2190 }
2191 mDatePickerMode = 2;
2192 mMoveIncidence = inc ;
2193 QDate da;
2194 if ( mMoveIncidence->type() == "Todo" ) {
2195 Todo * to = (Todo *) mMoveIncidence;
2196 if ( to->hasDueDate() )
2197 da = to->dtDue().date();
2198 else
2199 da = QDate::currentDate();
2200 } else {
2201 da = mMoveIncidence->dtStart().date();
2202 }
2203 mDatePicker->setDate( da );
2204}
2205void CalendarView::showDatePicker( )
2206{
2207 //qDebug("CalendarView::showDatePicker( ) ");
2208 if ( mDateFrame->isVisible() )
2209 mDateFrame->hide();
2210 else {
2211 int w =mDatePicker->sizeHint().width() ;
2212 int h = mDatePicker->sizeHint().height() ;
2213 int dw = QApplication::desktop()->width();
2214 int dh = QApplication::desktop()->height();
2215 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2216 mDateFrame->show();
2217 }
2218 mDatePickerMode = 1;
2219 mDatePicker->setDate( mNavigator->selectedDates().first() );
2220}
2221
2222void CalendarView::showEventEditor()
2223{
2224#ifdef DESKTOP_VERSION
2225 mEventEditor->show();
2226#else
2227 mEventEditor->showMaximized();
2228#endif
2229}
2230void CalendarView::showTodoEditor()
2231{
2232#ifdef DESKTOP_VERSION
2233 mTodoEditor->show();
2234#else
2235 mTodoEditor->showMaximized();
2236#endif
2237}
2238void CalendarView::cancelIncidence(Incidence * inc )
2239{
2240 inc->setCancelled( ! inc->cancelled() );
2241 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2242 updateView();
2243}
2244void CalendarView::cloneIncidence(Incidence * orgInc )
2245{
2246 Incidence * newInc = orgInc->clone();
2247 newInc->recreate();
2248
2249 if ( newInc->type() == "Todo" ) {
2250 Todo* t = (Todo*) newInc;
2251 mTodoEditor->editTodo( t );
2252 showTodoEditor();
2253 if ( mTodoEditor->exec() ) {
2254 mCalendar->addTodo( t );
2255 updateView();
2256 } else {
2257 delete t;
2258 }
2259 }
2260 else {
2261 Event* e = (Event*) newInc;
2262 mEventEditor->editEvent( e );
2263 showEventEditor();
2264 if ( mEventEditor->exec() ) {
2265 mCalendar->addEvent( e );
2266 updateView();
2267 } else {
2268 delete e;
2269 }
2270 }
2271}
2272
2273void CalendarView::newEvent()
2274{
2275 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2276 KOAgendaView *aView = mViewManager->agendaView();
2277 if (aView) {
2278 if (aView->selectionStart().isValid()) {
2279 if (aView->selectedIsAllDay()) {
2280 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2281 } else {
2282 newEvent(aView->selectionStart(),aView->selectionEnd());
2283 }
2284 return;
2285 }
2286 }
2287
2288 QDate date = mNavigator->selectedDates().first();
2289 QDateTime current = QDateTime::currentDateTime();
2290 if ( date <= current.date() ) {
2291 int hour = current.time().hour() +1;
2292 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2293 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2294 } else
2295 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2296 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2297 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2298}
2299
2300void CalendarView::newEvent(QDateTime fh)
2301{
2302 newEvent(fh,
2303 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2304}
2305
2306void CalendarView::newEvent(QDate dt)
2307{
2308 newEvent(QDateTime(dt, QTime(0,0,0)),
2309 QDateTime(dt, QTime(0,0,0)), true);
2310}
2311
2312void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2313{
2314
2315 mEventEditor->newEvent(fromHint,toHint,allDay);
2316 if ( mFilterView->filtersEnabled() ) {
2317 CalFilter *filter = mFilterView->selectedFilter();
2318 if (filter && filter->showCategories()) {
2319 mEventEditor->setCategories(filter->categoryList().join(",") );
2320 }
2321 if ( filter )
2322 mEventEditor->setSecrecy( filter->getSecrecy() );
2323 }
2324 showEventEditor();
2325}
2326void CalendarView::todoAdded(Todo * t)
2327{
2328
2329 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2330 updateTodoViews();
2331}
2332void CalendarView::todoChanged(Todo * t)
2333{
2334 emit todoModified( t, 4 );
2335 // updateTodoViews();
2336}
2337void CalendarView::todoToBeDeleted(Todo *)
2338{
2339 //qDebug("todoToBeDeleted(Todo *) ");
2340 updateTodoViews();
2341}
2342void CalendarView::todoDeleted()
2343{
2344 //qDebug(" todoDeleted()");
2345 updateTodoViews();
2346}
2347
2348
2349
2350void CalendarView::newTodo()
2351{
2352
2353 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2354 if ( mFilterView->filtersEnabled() ) {
2355 CalFilter *filter = mFilterView->selectedFilter();
2356 if (filter && filter->showCategories()) {
2357 mTodoEditor->setCategories(filter->categoryList().join(",") );
2358 }
2359 if ( filter )
2360 mTodoEditor->setSecrecy( filter->getSecrecy() );
2361 }
2362 showTodoEditor();
2363}
2364
2365void CalendarView::newSubTodo()
2366{
2367 Todo *todo = selectedTodo();
2368 if ( todo ) newSubTodo( todo );
2369}
2370
2371void CalendarView::newSubTodo(Todo *parentEvent)
2372{
2373
2374 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2375 showTodoEditor();
2376}
2377
2378void CalendarView::newFloatingEvent()
2379{
2380 DateList tmpList = mNavigator->selectedDates();
2381 QDate date = tmpList.first();
2382
2383 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2384 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2385}
2386
2387
2388void CalendarView::editEvent( Event *event )
2389{
2390
2391 if ( !event ) return;
2392 if ( event->isReadOnly() ) {
2393 showEvent( event );
2394 return;
2395 }
2396 mEventEditor->editEvent( event , mFlagEditDescription);
2397 showEventEditor();
2398}
2399void CalendarView::editJournal( Journal *jour )
2400{
2401 if ( !jour ) return;
2402 mDialogManager->hideSearchDialog();
2403 mViewManager->showJournalView();
2404 mNavigator->slotDaySelect( jour->dtStart().date() );
2405}
2406void CalendarView::editTodo( Todo *todo )
2407{
2408 if ( !todo ) return;
2409
2410 if ( todo->isReadOnly() ) {
2411 showTodo( todo );
2412 return;
2413 }
2414 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2415 showTodoEditor();
2416
2417}
2418
2419KOEventViewerDialog* CalendarView::getEventViewerDialog()
2420{
2421 if ( !mEventViewerDialog ) {
2422 mEventViewerDialog = new KOEventViewerDialog(this);
2423 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2424 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2425 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2426 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2427 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2428 viewManager(), SLOT( showAgendaView( bool ) ) );
2429 mEventViewerDialog->resize( 640, 480 );
2430
2431 }
2432 return mEventViewerDialog;
2433}
2434void CalendarView::showEvent(Event *event)
2435{
2436 getEventViewerDialog()->setEvent(event);
2437 getEventViewerDialog()->showMe();
2438}
2439
2440void CalendarView::showTodo(Todo *event)
2441{
2442 getEventViewerDialog()->setTodo(event);
2443 getEventViewerDialog()->showMe();
2444}
2445void CalendarView::showJournal( Journal *jour )
2446{
2447 getEventViewerDialog()->setJournal(jour);
2448 getEventViewerDialog()->showMe();
2449
2450}
2451// void CalendarView::todoModified (Todo *event, int changed)
2452// {
2453// // if (mDialogList.find (event) != mDialogList.end ()) {
2454// // kdDebug() << "Todo modified and open" << endl;
2455// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2456// // temp->modified (changed);
2457
2458// // }
2459
2460// mViewManager->updateView();
2461// }
2462
2463void CalendarView::appointment_show()
2464{
2465 Event *anEvent = 0;
2466
2467 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2468
2469 if (mViewManager->currentView()->isEventView()) {
2470 if ( incidence && incidence->type() == "Event" ) {
2471 anEvent = static_cast<Event *>(incidence);
2472 }
2473 }
2474
2475 if (!anEvent) {
2476 KNotifyClient::beep();
2477 return;
2478 }
2479
2480 showEvent(anEvent);
2481}
2482
2483void CalendarView::appointment_edit()
2484{
2485 Event *anEvent = 0;
2486
2487 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2488
2489 if (mViewManager->currentView()->isEventView()) {
2490 if ( incidence && incidence->type() == "Event" ) {
2491 anEvent = static_cast<Event *>(incidence);
2492 }
2493 }
2494
2495 if (!anEvent) {
2496 KNotifyClient::beep();
2497 return;
2498 }
2499
2500 editEvent(anEvent);
2501}
2502
2503void CalendarView::appointment_delete()
2504{
2505 Event *anEvent = 0;
2506
2507 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2508
2509 if (mViewManager->currentView()->isEventView()) {
2510 if ( incidence && incidence->type() == "Event" ) {
2511 anEvent = static_cast<Event *>(incidence);
2512 }
2513 }
2514
2515 if (!anEvent) {
2516 KNotifyClient::beep();
2517 return;
2518 }
2519
2520 deleteEvent(anEvent);
2521}
2522
2523void CalendarView::todo_unsub(Todo *anTodo )
2524{
2525 // Todo *anTodo = selectedTodo();
2526 if (!anTodo) return;
2527 if (!anTodo->relatedTo()) return;
2528 anTodo->relatedTo()->removeRelation(anTodo);
2529 anTodo->setRelatedTo(0);
2530 anTodo->updated();
2531 anTodo->setRelatedToUid("");
2532 setModified(true);
2533 updateView();
2534}
2535
2536void CalendarView::deleteTodo(Todo *todo)
2537{
2538 if (!todo) {
2539 KNotifyClient::beep();
2540 return;
2541 }
2542 if (KOPrefs::instance()->mConfirm) {
2543 switch (msgItemDelete()) {
2544 case KMessageBox::Continue: // OK
2545 if (!todo->relations().isEmpty()) {
2546 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2547 i18n("Delete To-Do"));
2548 } else {
2549 checkZaurusId( todo->zaurusId(), true );
2550 calendar()->deleteTodo(todo);
2551 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2552 updateView();
2553 }
2554 break;
2555 } // switch
2556 } else {
2557 if (!todo->relations().isEmpty()) {
2558 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2559 i18n("Delete To-Do"));
2560 } else {
2561 checkZaurusId( todo->zaurusId(), true );
2562 mCalendar->deleteTodo(todo);
2563 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2564 updateView();
2565 }
2566 }
2567 emit updateSearchDialog();
2568}
2569void CalendarView::deleteJournal(Journal *jour)
2570{
2571 if (!jour) {
2572 KNotifyClient::beep();
2573 return;
2574 }
2575 if (KOPrefs::instance()->mConfirm) {
2576 switch (msgItemDelete()) {
2577 case KMessageBox::Continue: // OK
2578 calendar()->deleteJournal(jour);
2579 updateView();
2580 break;
2581 } // switch
2582 } else {
2583 calendar()->deleteJournal(jour);;
2584 updateView();
2585 }
2586 emit updateSearchDialog();
2587}
2588
2589void CalendarView::deleteEvent(Event *anEvent)
2590{
2591 if (!anEvent) {
2592 KNotifyClient::beep();
2593 return;
2594 }
2595
2596 if (anEvent->recurrence()->doesRecur()) {
2597 QDate itemDate = mViewManager->currentSelectionDate();
2598 int km;
2599 if (!itemDate.isValid()) {
2600 //kdDebug() << "Date Not Valid" << endl;
2601 if (KOPrefs::instance()->mConfirm) {
2602 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2603 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2604 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2605 if ( km == KMessageBox::Continue )
2606 km = KMessageBox::No; // No = all below
2607 } else
2608 km = KMessageBox::No;
2609 } else {
2610 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2611 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2612 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2613 i18n("KO/Pi Confirmation"),i18n("Current"),
2614 i18n("All"));
2615 }
2616 switch(km) {
2617
2618 case KMessageBox::No: // Continue // all
2619 //qDebug("KMessageBox::No ");
2620 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2621 schedule(Scheduler::Cancel,anEvent);
2622
2623 checkZaurusId( anEvent->zaurusId());
2624 mCalendar->deleteEvent(anEvent);
2625 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2626 break;
2627
2628 // Disabled because it does not work
2629 //#if 0
2630 case KMessageBox::Yes: // just this one
2631 //QDate qd = mNavigator->selectedDates().first();
2632 //if (!qd.isValid()) {
2633 // kdDebug() << "no date selected, or invalid date" << endl;
2634 // KNotifyClient::beep();
2635 // return;
2636 //}
2637 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2638 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2639 anEvent->addExDate(itemDate);
2640 int duration = anEvent->recurrence()->duration();
2641 if ( duration > 0 ) {
2642 anEvent->recurrence()->setDuration( duration - 1 );
2643 }
2644 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2645 }
2646 break;
2647 //#endif
2648 } // switch
2649 } else {
2650 if (KOPrefs::instance()->mConfirm) {
2651 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2652 i18n("\nAre you sure you want\nto delete this event?"),
2653 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2654 case KMessageBox::Continue: // OK
2655 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2656 schedule(Scheduler::Cancel,anEvent);
2657 checkZaurusId( anEvent->zaurusId());
2658 mCalendar->deleteEvent(anEvent);
2659 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2660 break;
2661 } // switch
2662 } else {
2663 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2664 schedule(Scheduler::Cancel,anEvent);
2665 checkZaurusId( anEvent->zaurusId());
2666 mCalendar->deleteEvent(anEvent);
2667 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2668 }
2669 } // if-else
2670 emit updateSearchDialog();
2671}
2672
2673bool CalendarView::deleteEvent(const QString &uid)
2674{
2675 Event *ev = mCalendar->event(uid);
2676 if (ev) {
2677 deleteEvent(ev);
2678 return true;
2679 } else {
2680 return false;
2681 }
2682}
2683
2684/*****************************************************************************/
2685
2686void CalendarView::action_mail()
2687{
2688#ifndef KORG_NOMAIL
2689 KOMailClient mailClient;
2690
2691 Incidence *incidence = currentSelection();
2692
2693 if (!incidence) {
2694 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2695 return;
2696 }
2697 if(incidence->attendeeCount() == 0 ) {
2698 KMessageBox::sorry(this,
2699 i18n("Can't generate mail:\nNo attendees defined.\n"));
2700 return;
2701 }
2702
2703 CalendarLocal cal_tmp;
2704 Event *event = 0;
2705 Event *ev = 0;
2706 if ( incidence && incidence->type() == "Event" ) {
2707 event = static_cast<Event *>(incidence);
2708 ev = new Event(*event);
2709 cal_tmp.addEvent(ev);
2710 }
2711 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2712 QString attachment = mForm.toString( &cal_tmp );
2713 if (ev) delete(ev);
2714
2715 mailClient.mailAttendees(currentSelection(), attachment);
2716
2717#endif
2718
2719#if 0
2720 Event *anEvent = 0;
2721 if (mViewManager->currentView()->isEventView()) {
2722 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2723 }
2724
2725 if (!anEvent) {
2726 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2727 return;
2728 }
2729 if(anEvent->attendeeCount() == 0 ) {
2730 KMessageBox::sorry(this,
2731 i18n("Can't generate mail:\nNo attendees defined.\n"));
2732 return;
2733 }
2734
2735 mailobject.emailEvent(anEvent);
2736#endif
2737}
2738
2739
2740void CalendarView::schedule_publish(Incidence *incidence)
2741{
2742 Event *event = 0;
2743 Todo *todo = 0;
2744
2745 if (incidence == 0) {
2746 incidence = mViewManager->currentView()->selectedIncidences().first();
2747 if (incidence == 0) {
2748 incidence = mTodoList->selectedIncidences().first();
2749 }
2750 }
2751 if ( incidence && incidence->type() == "Event" ) {
2752 event = static_cast<Event *>(incidence);
2753 } else {
2754 if ( incidence && incidence->type() == "Todo" ) {
2755 todo = static_cast<Todo *>(incidence);
2756 }
2757 }
2758
2759 if (!event && !todo) {
2760 KMessageBox::sorry(this,i18n("No event selected."));
2761 return;
2762 }
2763
2764 PublishDialog *publishdlg = new PublishDialog();
2765 if (incidence->attendeeCount()>0) {
2766 QPtrList<Attendee> attendees = incidence->attendees();
2767 attendees.first();
2768 while ( attendees.current()!=0 ) {
2769 publishdlg->addAttendee(attendees.current());
2770 attendees.next();
2771 }
2772 }
2773 bool send = true;
2774 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2775 if ( publishdlg->exec() != QDialog::Accepted )
2776 send = false;
2777 }
2778 if ( send ) {
2779 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2780 if ( event ) {
2781 Event *ev = new Event(*event);
2782 ev->registerObserver(0);
2783 ev->clearAttendees();
2784 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2785 delete(ev);
2786 }
2787 } else {
2788 if ( todo ) {
2789 Todo *ev = new Todo(*todo);
2790 ev->registerObserver(0);
2791 ev->clearAttendees();
2792 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2793 delete(ev);
2794 }
2795 }
2796 }
2797 }
2798 delete publishdlg;
2799}
2800
2801void CalendarView::schedule_request(Incidence *incidence)
2802{
2803 schedule(Scheduler::Request,incidence);
2804}
2805
2806void CalendarView::schedule_refresh(Incidence *incidence)
2807{
2808 schedule(Scheduler::Refresh,incidence);
2809}
2810
2811void CalendarView::schedule_cancel(Incidence *incidence)
2812{
2813 schedule(Scheduler::Cancel,incidence);
2814}
2815
2816void CalendarView::schedule_add(Incidence *incidence)
2817{
2818 schedule(Scheduler::Add,incidence);
2819}
2820
2821void CalendarView::schedule_reply(Incidence *incidence)
2822{
2823 schedule(Scheduler::Reply,incidence);
2824}
2825
2826void CalendarView::schedule_counter(Incidence *incidence)
2827{
2828 schedule(Scheduler::Counter,incidence);
2829}
2830
2831void CalendarView::schedule_declinecounter(Incidence *incidence)
2832{
2833 schedule(Scheduler::Declinecounter,incidence);
2834}
2835
2836void CalendarView::schedule_publish_freebusy(int daysToPublish)
2837{
2838 QDateTime start = QDateTime::currentDateTime();
2839 QDateTime end = start.addDays(daysToPublish);
2840
2841 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2842 freebusy->setOrganizer(KOPrefs::instance()->email());
2843
2844
2845 PublishDialog *publishdlg = new PublishDialog();
2846 if ( publishdlg->exec() == QDialog::Accepted ) {
2847 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2848 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2849 delete(freebusy);
2850 }
2851 }
2852 delete publishdlg;
2853}
2854
2855void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2856{
2857 Event *event = 0;
2858 Todo *todo = 0;
2859
2860 if (incidence == 0) {
2861 incidence = mViewManager->currentView()->selectedIncidences().first();
2862 if (incidence == 0) {
2863 incidence = mTodoList->selectedIncidences().first();
2864 }
2865 }
2866 if ( incidence && incidence->type() == "Event" ) {
2867 event = static_cast<Event *>(incidence);
2868 }
2869 if ( incidence && incidence->type() == "Todo" ) {
2870 todo = static_cast<Todo *>(incidence);
2871 }
2872
2873 if (!event && !todo) {
2874 KMessageBox::sorry(this,i18n("No event selected."));
2875 return;
2876 }
2877
2878 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2879 KMessageBox::sorry(this,i18n("The event has no attendees."));
2880 return;
2881 }
2882
2883 Event *ev = 0;
2884 if (event) ev = new Event(*event);
2885 Todo *to = 0;
2886 if (todo) to = new Todo(*todo);
2887
2888 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2889 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2890 if (!me) {
2891 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2892 return;
2893 }
2894 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2895 StatusDialog *statdlg = new StatusDialog(this);
2896 if (!statdlg->exec()==QDialog::Accepted) return;
2897 me->setStatus( statdlg->status() );
2898 delete(statdlg);
2899 }
2900 Attendee *menew = new Attendee(*me);
2901 if (ev) {
2902 ev->clearAttendees();
2903 ev->addAttendee(menew,false);
2904 } else {
2905 if (to) {
2906 todo->clearAttendees();
2907 todo->addAttendee(menew,false);
2908 }
2909 }
2910 }
2911
2912 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2913 if (ev) {
2914 if ( !dlg->addMessage(ev,method) ) delete(ev);
2915 } else {
2916 if (to) {
2917 if ( !dlg->addMessage(to,method) ) delete(to);
2918 }
2919 }
2920}
2921
2922void CalendarView::openAddressbook()
2923{
2924 KRun::runCommand("kaddressbook");
2925}
2926
2927void CalendarView::setModified(bool modified)
2928{
2929 if ( modified )
2930 emit signalmodified();
2931 if (mModified != modified) {
2932 mModified = modified;
2933 emit modifiedChanged(mModified);
2934 }
2935}
2936
2937bool CalendarView::isReadOnly()
2938{
2939 return mReadOnly;
2940}
2941
2942void CalendarView::setReadOnly(bool readOnly)
2943{
2944 if (mReadOnly != readOnly) {
2945 mReadOnly = readOnly;
2946 emit readOnlyChanged(mReadOnly);
2947 }
2948}
2949
2950bool CalendarView::isModified()
2951{
2952 return mModified;
2953}
2954
2955void CalendarView::printSetup()
2956{
2957#ifndef KORG_NOPRINTER
2958 createPrinter();
2959
2960 mCalPrinter->setupPrinter();
2961#endif
2962}
2963
2964void CalendarView::print()
2965{
2966#ifndef KORG_NOPRINTER
2967 createPrinter();
2968
2969 DateList tmpDateList = mNavigator->selectedDates();
2970 mCalPrinter->print(CalPrinter::Month,
2971 tmpDateList.first(), tmpDateList.last());
2972#endif
2973}
2974
2975void CalendarView::printPreview()
2976{
2977#ifndef KORG_NOPRINTER
2978 kdDebug() << "CalendarView::printPreview()" << endl;
2979
2980 createPrinter();
2981
2982 DateList tmpDateList = mNavigator->selectedDates();
2983
2984 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
2985 tmpDateList.last());
2986#endif
2987}
2988
2989void CalendarView::exportICalendar()
2990{
2991 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
2992
2993 // Force correct extension
2994 if (filename.right(4) != ".ics") filename += ".ics";
2995
2996 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2997 storage.save();
2998}
2999
3000bool CalendarView::exportVCalendar( QString filename )
3001{
3002 if (mCalendar->journals().count() > 0) {
3003 int result = KMessageBox::warningContinueCancel(this,
3004 i18n("The journal entries can not be\nexported to a vCalendar file."),
3005 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3006 true);
3007 if (result != KMessageBox::Continue) return false;
3008 }
3009
3010 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3011
3012 // Force correct extension
3013 if (filename.right(4) != ".vcs") filename += ".vcs";
3014
3015 FileStorage storage( mCalendar, filename, new VCalFormat );
3016 return storage.save();
3017
3018}
3019
3020void CalendarView::eventUpdated(Incidence *)
3021{
3022 setModified();
3023 // Don't call updateView here. The code, which has caused the update of the
3024 // event is responsible for updating the view.
3025 // updateView();
3026}
3027
3028void CalendarView::adaptNavigationUnits()
3029{
3030 if (mViewManager->currentView()->isEventView()) {
3031 int days = mViewManager->currentView()->currentDateCount();
3032 if (days == 1) {
3033 emit changeNavStringPrev(i18n("&Previous Day"));
3034 emit changeNavStringNext(i18n("&Next Day"));
3035 } else {
3036 emit changeNavStringPrev(i18n("&Previous Week"));
3037 emit changeNavStringNext(i18n("&Next Week"));
3038 }
3039 }
3040}
3041
3042void CalendarView::processMainViewSelection( Incidence *incidence )
3043{
3044 if ( incidence ) mTodoList->clearSelection();
3045 processIncidenceSelection( incidence );
3046}
3047
3048void CalendarView::processTodoListSelection( Incidence *incidence )
3049{
3050 if ( incidence && mViewManager->currentView() ) {
3051 mViewManager->currentView()->clearSelection();
3052 }
3053 processIncidenceSelection( incidence );
3054}
3055
3056void CalendarView::processIncidenceSelection( Incidence *incidence )
3057{
3058 if ( incidence == mSelectedIncidence ) return;
3059
3060 mSelectedIncidence = incidence;
3061
3062 emit incidenceSelected( mSelectedIncidence );
3063
3064 if ( incidence && incidence->type() == "Event" ) {
3065 Event *event = static_cast<Event *>( incidence );
3066 if ( event->organizer() == KOPrefs::instance()->email() ) {
3067 emit organizerEventsSelected( true );
3068 } else {
3069 emit organizerEventsSelected(false);
3070 }
3071 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3072 KOPrefs::instance()->email() ) ) {
3073 emit groupEventsSelected( true );
3074 } else {
3075 emit groupEventsSelected(false);
3076 }
3077 return;
3078 } else {
3079 if ( incidence && incidence->type() == "Todo" ) {
3080 emit todoSelected( true );
3081 Todo *event = static_cast<Todo *>( incidence );
3082 if ( event->organizer() == KOPrefs::instance()->email() ) {
3083 emit organizerEventsSelected( true );
3084 } else {
3085 emit organizerEventsSelected(false);
3086 }
3087 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3088 KOPrefs::instance()->email() ) ) {
3089 emit groupEventsSelected( true );
3090 } else {
3091 emit groupEventsSelected(false);
3092 }
3093 return;
3094 } else {
3095 emit todoSelected( false );
3096 emit organizerEventsSelected(false);
3097 emit groupEventsSelected(false);
3098 }
3099 return;
3100 }
3101
3102 /* if ( incidence && incidence->type() == "Todo" ) {
3103 emit todoSelected( true );
3104 } else {
3105 emit todoSelected( false );
3106 }*/
3107}
3108
3109
3110void CalendarView::checkClipboard()
3111{
3112#ifndef KORG_NODND
3113 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3114 emit pasteEnabled(true);
3115 } else {
3116 emit pasteEnabled(false);
3117 }
3118#endif
3119}
3120
3121void CalendarView::showDates(const DateList &selectedDates)
3122{
3123 // kdDebug() << "CalendarView::selectDates()" << endl;
3124
3125 if ( mViewManager->currentView() ) {
3126 updateView( selectedDates.first(), selectedDates.last() );
3127 } else {
3128 mViewManager->showAgendaView();
3129 }
3130
3131 QString selDates;
3132 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3133 if (selectedDates.first() < selectedDates.last() )
3134 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3135 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3136
3137}
3138
3139void CalendarView::editFilters()
3140{
3141 // kdDebug() << "CalendarView::editFilters()" << endl;
3142
3143 CalFilter *filter = mFilters.first();
3144 while(filter) {
3145 kdDebug() << " Filter: " << filter->name() << endl;
3146 filter = mFilters.next();
3147 }
3148
3149 mDialogManager->showFilterEditDialog(&mFilters);
3150}
3151void CalendarView::toggleFilter()
3152{
3153 showFilter(! mFilterView->isVisible());
3154}
3155
3156void CalendarView::selectFilter( int fil )
3157{
3158 mFilterView->setSelectedFilter( fil );
3159}
3160void CalendarView::showFilter(bool visible)
3161{
3162 if (visible) mFilterView->show();
3163 else mFilterView->hide();
3164}
3165void CalendarView::toggleFilerEnabled( )
3166{
3167 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3168 if ( !mFilterView->filtersEnabled() )
3169 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3170
3171}
3172void CalendarView::updateFilter()
3173{
3174 CalFilter *filter = mFilterView->selectedFilter();
3175 if (filter) {
3176 if (mFilterView->filtersEnabled()) {
3177 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3178 filter->setEnabled(true);
3179 }
3180 else filter->setEnabled(false);
3181 mCalendar->setFilter(filter);
3182 updateView();
3183 }
3184}
3185
3186void CalendarView::filterEdited()
3187{
3188 mFilterView->updateFilters();
3189 updateFilter();
3190 writeSettings();
3191}
3192
3193
3194void CalendarView::takeOverEvent()
3195{
3196 Incidence *incidence = currentSelection();
3197
3198 if (!incidence) return;
3199
3200 incidence->setOrganizer(KOPrefs::instance()->email());
3201 incidence->recreate();
3202 incidence->setReadOnly(false);
3203
3204 updateView();
3205}
3206
3207void CalendarView::takeOverCalendar()
3208{
3209 // TODO: Create Calendar::allIncidences() function and use it here
3210
3211 QPtrList<Event> events = mCalendar->events();
3212 for(uint i=0; i<events.count(); ++i) {
3213 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3214 events.at(i)->recreate();
3215 events.at(i)->setReadOnly(false);
3216 }
3217
3218 QPtrList<Todo> todos = mCalendar->todos();
3219 for(uint i=0; i<todos.count(); ++i) {
3220 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3221 todos.at(i)->recreate();
3222 todos.at(i)->setReadOnly(false);
3223 }
3224
3225 QPtrList<Journal> journals = mCalendar->journals();
3226 for(uint i=0; i<journals.count(); ++i) {
3227 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3228 journals.at(i)->recreate();
3229 journals.at(i)->setReadOnly(false);
3230 }
3231
3232 updateView();
3233}
3234
3235void CalendarView::showIntro()
3236{
3237 kdDebug() << "To be implemented." << endl;
3238}
3239
3240QWidgetStack *CalendarView::viewStack()
3241{
3242 return mRightFrame;
3243}
3244
3245QWidget *CalendarView::leftFrame()
3246{
3247 return mLeftFrame;
3248}
3249
3250DateNavigator *CalendarView::dateNavigator()
3251{
3252 return mNavigator;
3253}
3254
3255KDateNavigator* CalendarView::dateNavigatorWidget()
3256{
3257 return mDateNavigator;
3258}
3259void CalendarView::toggleDateNavigatorWidget()
3260{
3261 if (mDateNavigator->isVisible())
3262 mDateNavigator->hide();
3263 else
3264 mDateNavigator->show();
3265}
3266void CalendarView::addView(KOrg::BaseView *view)
3267{
3268 mViewManager->addView(view);
3269}
3270
3271void CalendarView::showView(KOrg::BaseView *view)
3272{
3273 mViewManager->showView(view, mLeftFrame->isVisible());
3274}
3275
3276Incidence *CalendarView::currentSelection()
3277{
3278 return mViewManager->currentSelection();
3279}
3280void CalendarView::toggleAllDaySize()
3281{
3282 /*
3283 if ( KOPrefs::instance()->mAllDaySize > 47 )
3284 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3285 else
3286 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3287 */
3288 viewManager()->agendaView()->toggleAllDay();
3289}
3290void CalendarView::toggleExpand()
3291{
3292 // if ( mLeftFrame->isHidden() ) {
3293 // mLeftFrame->show();
3294 // emit calendarViewExpanded( false );
3295 // } else {
3296 // mLeftFrame->hide();
3297 // emit calendarViewExpanded( true );
3298 // }
3299
3300 globalFlagBlockAgenda = 1;
3301 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3302 globalFlagBlockAgenda = 5;
3303 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3304 //mViewManager->showView( 0, true );
3305}
3306
3307void CalendarView::calendarModified( bool modified, Calendar * )
3308{
3309 setModified( modified );
3310}
3311
3312Todo *CalendarView::selectedTodo()
3313{
3314 Incidence *incidence = currentSelection();
3315 if ( incidence && incidence->type() == "Todo" ) {
3316 return static_cast<Todo *>( incidence );
3317 }
3318
3319 incidence = mTodoList->selectedIncidences().first();
3320 if ( incidence && incidence->type() == "Todo" ) {
3321 return static_cast<Todo *>( incidence );
3322 }
3323
3324 return 0;
3325}
3326
3327void CalendarView::dialogClosing(Incidence *in)
3328{
3329 // mDialogList.remove(in);
3330}
3331
3332void CalendarView::showIncidence()
3333{
3334 Incidence *incidence = currentSelection();
3335 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3336 if ( incidence ) {
3337 ShowIncidenceVisitor v;
3338 v.act( incidence, this );
3339 }
3340}
3341void CalendarView::editIncidenceDescription()
3342{
3343 mFlagEditDescription = true;
3344 editIncidence();
3345 mFlagEditDescription = false;
3346}
3347void CalendarView::editIncidence()
3348{
3349 // qDebug("editIncidence() ");
3350 Incidence *incidence = currentSelection();
3351 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3352 if ( incidence ) {
3353 EditIncidenceVisitor v;
3354 v.act( incidence, this );
3355 }
3356}
3357
3358void CalendarView::deleteIncidence()
3359{
3360 Incidence *incidence = currentSelection();
3361 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3362 if ( incidence ) {
3363 deleteIncidence(incidence);
3364 }
3365}
3366
3367void CalendarView::showIncidence(Incidence *incidence)
3368{
3369 if ( incidence ) {
3370 ShowIncidenceVisitor v;
3371 v.act( incidence, this );
3372 }
3373}
3374
3375void CalendarView::editIncidence(Incidence *incidence)
3376{
3377 if ( incidence ) {
3378
3379 EditIncidenceVisitor v;
3380 v.act( incidence, this );
3381
3382 }
3383}
3384
3385void CalendarView::deleteIncidence(Incidence *incidence)
3386{
3387 //qDebug(" CalendarView::deleteIncidence ");
3388 if ( incidence ) {
3389 DeleteIncidenceVisitor v;
3390 v.act( incidence, this );
3391 }
3392}
3393
3394
3395void CalendarView::lookForOutgoingMessages()
3396{
3397 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3398 ogd->loadMessages();
3399}
3400
3401void CalendarView::lookForIncomingMessages()
3402{
3403 IncomingDialog *icd = mDialogManager->incomingDialog();
3404 icd->retrieve();
3405}
3406
3407bool CalendarView::removeCompletedSubTodos( Todo* t )
3408{
3409 bool deleteTodo = true;
3410 QPtrList<Incidence> subTodos;
3411 Incidence *aTodo;
3412 subTodos = t->relations();
3413 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3414 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3415 deleteTodo = false;
3416 }
3417 if ( deleteTodo ) {
3418 if ( t->isCompleted() ) {
3419 checkZaurusId( t->zaurusId(), true );
3420 mCalendar->deleteTodo( t );
3421 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3422 }
3423 else
3424 deleteTodo = false;
3425 }
3426 return deleteTodo;
3427
3428}
3429void CalendarView::purgeCompleted()
3430{
3431 int result = KMessageBox::warningContinueCancel(this,
3432 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3433
3434 if (result == KMessageBox::Continue) {
3435
3436 QPtrList<Todo> todoCal;
3437 QPtrList<Todo> rootTodos;
3438 //QPtrList<Incidence> rel;
3439 Todo *aTodo;//, *rTodo;
3440 Incidence *rIncidence;
3441 bool childDelete = false;
3442 bool deletedOne = true;
3443 todoCal = calendar()->todos();
3444 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3445 if ( !aTodo->relatedTo() )
3446 rootTodos.append( aTodo );
3447 }
3448 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3449 removeCompletedSubTodos( aTodo );
3450 }
3451
3452 updateView();
3453 }
3454}
3455
3456void CalendarView::slotCalendarChanged()
3457{
3458 ;
3459}
3460
3461NavigatorBar *CalendarView::navigatorBar()
3462{
3463 return mNavigatorBar;
3464}
3465
3466
3467
3468void CalendarView::keyPressEvent ( QKeyEvent *e)
3469{
3470 //qDebug(" alendarView::keyPressEvent ");
3471 e->ignore();
3472}
3473
3474#include "calendarview.moc"
3475
3476#include "calendarviewbase.moc"
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
new file mode 100644
index 0000000..e7aa351
--- a/dev/null
+++ b/korganizer/calendarview.h
@@ -0,0 +1,586 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H
26
27#include <qframe.h>
28#include <qlayout.h>
29#include <qwidget.h>
30#include <qptrlist.h>
31#include <qvbox.h>
32#include <qmap.h>
33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h>
35#else
36#define Ir char
37#endif
38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h>
42
43#include <korganizer/calendarviewbase.h>
44
45class QWidgetStack;
46class QSplitter;
47
48class CalPrinter;
49class KOFilterView;
50class KOViewManager;
51class KODialogManager;
52class KOTodoView;
53class KDateNavigator;
54class DateNavigator;
55class KOIncidenceEditor;
56class KDatePicker;
57class ResourceView;
58class NavigatorBar;
59class KOEventEditor;
60class KOTodoEditor ;
61class KOEventViewerDialog;
62class KOBeamPrefs;
63class KSyncProfile;
64class AlarmDialog;
65class KCal::Attendee;
66
67namespace KCal { class FileStorage; }
68
69using namespace KCal;
70
71/**
72 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc.
76
77 @short main calendar view widget
78 @author Cornelius Schumacher
79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{
82 Q_OBJECT
83 public:
84 /**
85 Constructs a new calendar view widget.
86
87 @param calendar calendar document
88 @param parent parent window
89 @param name Qt internal widget object name
90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 );
95 virtual ~CalendarView();
96
97 Calendar *calendar() { return mCalendar; }
98
99 KOViewManager *viewManager();
100 KODialogManager *dialogManager();
101
102 QDate startDate();
103 QDate endDate();
104
105 QWidgetStack *viewStack();
106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar();
108
109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget();
111
112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection();
116
117 signals:
118 /** This todo has been modified */
119 void todoModified(Todo *, int);
120
121 /** when change is made to options dialog, the topwidget will catch this
122 * and emit this signal which notifies all widgets which have registered
123 * for notification to update their settings. */
124 void configChanged();
125 /** emitted when the topwidget is closing down, so that any attached
126 child windows can also close. */
127 void closingDown();
128 /** emitted right before we die */
129 void closed(QWidget *);
130
131 /** Emitted when state of modified flag changes */
132 void modifiedChanged(bool);
133 void signalmodified();
134
135 /** Emitted when state of read-only flag changes */
136 void readOnlyChanged(bool);
137
138 /** Emitted when the unit of navigation changes */
139 void changeNavStringPrev(const QString &);
140 void changeNavStringNext(const QString &);
141
142 /** Emitted when state of events selection has changed and user is organizer*/
143 void organizerEventsSelected(bool);
144 /** Emitted when state of events selection has changed and user is attendee*/
145 void groupEventsSelected(bool);
146 /**
147 Emitted when an incidence gets selected. If the selection is cleared the
148 signal is emitted with 0 as argument.
149 */
150 void incidenceSelected( Incidence * );
151 /** Emitted, when a todoitem is selected or deselected. */
152 void todoSelected( bool );
153
154 /**
155 Emitted, when clipboard content changes. Parameter indicates if paste
156 is possible or not.
157 */
158 void pasteEnabled(bool);
159
160 /** Emitted, when the number of incoming messages has changed. */
161 void numIncomingChanged(int);
162
163 /** Emitted, when the number of outgoing messages has changed. */
164 void numOutgoingChanged(int);
165
166 /** Send status message, which can e.g. be displayed in the status bar. */
167 void statusMessage(const QString &);
168
169 void calendarViewExpanded( bool );
170 void updateSearchDialog();
171
172
173 public slots:
174
175 void addAlarm(const QDateTime &qdt, const QString &noti );
176 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
177 void removeAlarm(const QDateTime &qdt, const QString &noti );
178
179 /** options dialog made a changed to the configuration. we catch this
180 * and notify all widgets which need to update their configuration. */
181 void updateConfig();
182
183 /**
184 Load calendar from file \a filename. If \a merge is true, load
185 calendar into existing one, if it is false, clear calendar, before
186 loading. Return true, if calendar could be successfully loaded.
187 */
188 bool openCalendar(QString filename, bool merge=false);
189 bool syncCalendar(QString filename,int mode = 0 );
190
191 /**
192 Save calendar data to file. Return true if calendar could be
193 successfully saved.
194 */
195 bool saveCalendar(QString filename);
196
197 /**
198 Close calendar. Clear calendar data and reset views to display an empty
199 calendar.
200 */
201 void closeCalendar();
202
203 /** Archive old events of calendar */
204 void archiveCalendar();
205
206 void showIncidence();
207 void editIncidence();
208 void editIncidenceDescription();
209 void deleteIncidence();
210
211 /** create an editeventwin with supplied date/time, and if bool is true,
212 * make the event take all day. */
213 void newEvent(QDateTime, QDateTime, bool allDay = false);
214 void newEvent(QDateTime fh);
215 void newEvent(QDate dt);
216 /** create new event without having a date hint. Takes current date as
217 default hint. */
218 void newEvent();
219 void newFloatingEvent();
220
221 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
222 void showIncidence(Incidence *);
223 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
224 void editIncidence(Incidence *);
225 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
226 void deleteIncidence(Incidence *);
227 void cloneIncidence(Incidence *);
228 void cancelIncidence(Incidence *);
229 /** Create an editor for the supplied event. */
230 void editEvent(Event *);
231 /** Delete the supplied event. */
232 void deleteEvent(Event *);
233 /** Delete the event with the given unique ID. Returns false, if event wasn't
234 found. */
235 bool deleteEvent(const QString &uid);
236 /** Create a read-only viewer dialog for the supplied event. */
237 void showEvent(Event *);
238
239 void editJournal(Journal *);
240 void showJournal(Journal *);
241 void deleteJournal(Journal *);
242 /** Create an editor dialog for a todo */
243 void editTodo(Todo *);
244 /** Create a read-only viewer dialog for the supplied todo */
245 void showTodo(Todo *);
246 /** create new todo */
247 void newTodo();
248 /** create new todo with a parent todo */
249 void newSubTodo();
250 /** create new todo with a parent todo */
251 void newSubTodo(Todo *);
252 /** Delete todo */
253 void deleteTodo(Todo *);
254
255
256 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
257 * emitted as result. */
258 void checkClipboard();
259
260 /** using the KConfig associated with the kapp variable, read in the
261 * settings from the config file.
262 */
263 void readSettings();
264
265 /** write current state to config file. */
266 void writeSettings();
267
268 /** read settings for calendar filters */
269 void readFilterSettings(KConfig *config);
270
271 /** write settings for calendar filters */
272 void writeFilterSettings(KConfig *config);
273
274 /** passes on the message that an event has changed to the currently
275 * activated view so that it can make appropriate display changes. */
276 void changeEventDisplay(Event *, int);
277 void changeIncidenceDisplay(Incidence *, int);
278 void changeTodoDisplay(Todo *, int);
279
280 void eventAdded(Event *);
281 void eventChanged(Event *);
282 void eventToBeDeleted(Event *);
283 void eventDeleted();
284
285 void todoAdded(Todo *);
286 void todoChanged(Todo *);
287 void todoToBeDeleted(Todo *);
288 void todoDeleted();
289
290 void updateView(const QDate &start, const QDate &end);
291 void updateView();
292
293 /** Full update of visible todo views */
294 void updateTodoViews();
295
296 void updateUnmanagedViews();
297
298 /** cut the current appointment to the clipboard */
299 void edit_cut();
300
301 /** copy the current appointment(s) to the clipboard */
302 void edit_copy();
303
304 /** paste the current vobject(s) in the clipboard buffer into calendar */
305 void edit_paste();
306
307 /** edit viewing and configuration options. */
308 void edit_options();
309 void edit_sync_options();
310 /**
311 Functions for printing, previewing a print, and setting up printing
312 parameters.
313 */
314 void print();
315 void printSetup();
316 void printPreview();
317
318 /** Export as iCalendar file */
319 void exportICalendar();
320
321 /** Export as vCalendar file */
322 bool exportVCalendar( QString fn);
323
324 /** pop up a dialog to show an existing appointment. */
325 void appointment_show();
326 /**
327 * pop up an Appointment Dialog to edit an existing appointment.Get
328 * information on the appointment from the list of unique IDs that is
329 * currently in the View, called currIds.
330 */
331 void appointment_edit();
332 /**
333 * pop up dialog confirming deletion of currently selected event in the
334 * View.
335 */
336 void appointment_delete();
337
338 /** mails the currently selected event to a particular user as a vCalendar
339 attachment. */
340 void action_mail();
341
342 /* frees a subtodo from it's relation */
343 void todo_unsub( Todo * );
344
345 /** Take ownership of selected event. */
346 void takeOverEvent();
347
348 /** Take ownership of all events in calendar. */
349 void takeOverCalendar();
350
351 /** query whether or not the calendar is "dirty". */
352 bool isModified();
353 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
354 void setModified(bool modified=true);
355
356 /** query if the calendar is read-only. */
357 bool isReadOnly();
358 /** set state of calendar to read-only */
359 void setReadOnly(bool readOnly=true);
360
361 void eventUpdated(Incidence *);
362
363 /* iTIP scheduling actions */
364 void schedule_publish(Incidence *incidence = 0);
365 void schedule_request(Incidence *incidence = 0);
366 void schedule_refresh(Incidence *incidence = 0);
367 void schedule_cancel(Incidence *incidence = 0);
368 void schedule_add(Incidence *incidence = 0);
369 void schedule_reply(Incidence *incidence = 0);
370 void schedule_counter(Incidence *incidence = 0);
371 void schedule_declinecounter(Incidence *incidence = 0);
372 void schedule_publish_freebusy(int daysToPublish = 30);
373
374 void openAddressbook();
375
376 void editFilters();
377 void toggleFilerEnabled();
378
379 void toggleFilter();
380 void showFilter(bool visible);
381 void updateFilter();
382 void filterEdited();
383 void selectFilter( int );
384
385 void showIntro();
386
387 /** Move the curdatepient view date to today */
388 void goToday();
389
390 /** Move to the next date(s) in the current view */
391 void goNext();
392
393 /** Move to the previous date(s) in the current view */
394 void goPrevious();
395 /** Move to the next date(s) in the current view */
396 void goNextMonth();
397
398 /** Move to the previous date(s) in the current view */
399 void goPreviousMonth();
400
401 void toggleExpand();
402 void toggleDateNavigatorWidget();
403 void toggleAllDaySize();
404 void dialogClosing(Incidence *);
405
406 /** Look for new messages in the inbox */
407 void lookForIncomingMessages();
408 /** Look for new messages in the outbox */
409 void lookForOutgoingMessages();
410
411 void processMainViewSelection( Incidence * );
412 void processTodoListSelection( Incidence * );
413
414 void processIncidenceSelection( Incidence * );
415
416 void purgeCompleted();
417 bool removeCompletedSubTodos( Todo* );
418 void slotCalendarChanged();
419 bool importBday();
420 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
421 bool importQtopia( const QString &categoriesFile,
422 const QString &datebookFile,
423 const QString &tasklistFile );
424 void syncSharp( );
425 void slotSelectPickerDate( QDate ) ;
426 void showDatePicker( ) ;
427 void moveIncidence(Incidence *) ;
428 void beamIncidence(Incidence *) ;
429 void beamCalendar() ;
430 void beamFilteredCalendar() ;
431 void beamIncidenceList(QPtrList<Incidence>) ;
432 void manageCategories();
433 int addCategories();
434 void removeCategories();
435 void setSyncDevice( QString );
436 void setSyncName( QString );
437 protected slots:
438 void timerAlarm();
439 void suspendAlarm();
440 void beamDone( Ir *ir );
441 /** Select a view or adapt the current view to display the specified dates. */
442 void showDates( const KCal::DateList & );
443 void selectWeekNum ( int );
444
445 public:
446 // show a standard warning
447 // returns KMsgBox::yesNoCancel()
448 int msgCalModified();
449 void confSync();
450 void setLoadedFileVersion(QDateTime);
451 bool checkFileVersion(QString fn);
452 bool checkFileChanged(QString fn);
453 Event* getLastSyncEvent();
454 /** Adapt navigation units correpsonding to step size of navigation of the
455 * current view.
456 */
457 void adaptNavigationUnits();
458 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
459 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
460 //Attendee* getYourAttendee(Event *event);
461 protected:
462 void schedule(Scheduler::Method, Incidence *incidence = 0);
463
464 // returns KMsgBox::OKCandel()
465 int msgItemDelete();
466 void showEventEditor();
467 void showTodoEditor();
468 void writeLocale();
469 Todo *selectedTodo();
470
471 private:
472 AlarmDialog * mAlarmDialog;
473 QString mAlarmNotification;
474 QString mSuspendAlarmNotification;
475 QTimer* mSuspendTimer;
476 QTimer* mAlarmTimer;
477 void computeAlarm( QString );
478 void startAlarm( QString, QString );
479 void setSyncEventsReadOnly();
480
481 QDateTime loadedFileVersion;
482 void checkSharpEvent( Event* lastSync, Incidence* toDelete );
483 QPtrList<KSyncProfile> mSyncProfiles;
484 QStringList mSyncProfileNames;
485 void checkZaurusId( int id, bool todo = false );
486 int mGlobalSyncMode;
487 QString mCurrentSyncDevice;
488 QString mCurrentSyncName;
489 KOBeamPrefs* beamDialog;
490 void init();
491 int mDatePickerMode;
492 bool mFlagEditDescription;
493 QDateTime mLastCalendarSync;
494 void createPrinter();
495
496 void calendarModified( bool, Calendar * );
497
498 CalPrinter *mCalPrinter;
499
500 QSplitter *mPanner;
501 QSplitter *mLeftSplitter;
502 QWidget *mLeftFrame;
503 QWidgetStack *mRightFrame;
504
505 KDatePicker* mDatePicker;
506 QVBox* mDateFrame;
507 NavigatorBar *mNavigatorBar;
508
509 KDateNavigator *mDateNavigator; // widget showing small month view.
510
511 KOFilterView *mFilterView;
512
513 ResourceView *mResourceView;
514
515 // calendar object for this viewing instance
516 Calendar *mCalendar;
517
518 CalendarResourceManager *mResourceManager;
519
520 FileStorage *mStorage;
521
522 DateNavigator *mNavigator;
523
524 KOViewManager *mViewManager;
525 KODialogManager *mDialogManager;
526
527 // Calendar filters
528 QPtrList<CalFilter> mFilters;
529
530 // various housekeeping variables.
531 bool mModified; // flag indicating if calendar is modified
532 bool mReadOnly; // flag indicating if calendar is read-only
533 QDate mSaveSingleDate;
534
535 Incidence *mSelectedIncidence;
536 Incidence *mMoveIncidence;
537
538 KOTodoView *mTodoList;
539 KOEventEditor * mEventEditor;
540 KOTodoEditor * mTodoEditor;
541 KOEventViewerDialog * mEventViewerDialog;
542 void keyPressEvent ( QKeyEvent *e) ;
543 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
544};
545
546
547class CalendarViewVisitor : public Incidence::Visitor
548{
549 public:
550 CalendarViewVisitor() : mView( 0 ) {}
551
552 bool act( Incidence *incidence, CalendarView *view )
553 {
554 mView = view;
555 return incidence->accept( *this );
556 }
557
558 protected:
559 CalendarView *mView;
560};
561
562class ShowIncidenceVisitor : public CalendarViewVisitor
563{
564 protected:
565 bool visit( Event *event ) { mView->showEvent( event ); return true; }
566 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
567 bool visit( Journal * j ) { mView->showJournal( j );return true; }
568};
569
570class EditIncidenceVisitor : public CalendarViewVisitor
571{
572 protected:
573 bool visit( Event *event ) { mView->editEvent( event ); return true; }
574 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
575 bool visit( Journal *j ) { mView->editJournal( j); return true; }
576};
577
578class DeleteIncidenceVisitor : public CalendarViewVisitor
579{
580 protected:
581 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
582 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
583 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
584};
585
586#endif
diff --git a/korganizer/calendarview.moc b/korganizer/calendarview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/calendarview.moc
diff --git a/korganizer/calendarviewbase.moc b/korganizer/calendarviewbase.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/calendarviewbase.moc
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp
new file mode 100644
index 0000000..af32ebc
--- a/dev/null
+++ b/korganizer/calprintbase.cpp
@@ -0,0 +1,1304 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution.
24*/
25
26#include <qpainter.h>
27#include <qlayout.h>
28#include <qframe.h>
29#include <qlabel.h>
30#include <qptrlist.h>
31#include <qintdict.h>
32#include <qfontmetrics.h>
33
34#include <kglobal.h>
35#include <klocale.h>
36#include <kdebug.h>
37#include <kconfig.h>
38#include <kcalendarsystem.h>
39#include <kprinter.h>
40
41#include <libkcal/todo.h>
42#include <libkcal/event.h>
43#include <libkcal/calendar.h>
44
45#include "koprefs.h"
46#include "koglobals.h"
47#ifndef KORG_NOPLUGINS
48#include "kocore.h"
49#endif
50#include "cellitem.h"
51
52#include "calprintbase.h"
53
54#ifndef KORG_NOPRINTER
55//#include "calprintbase.moc"
56
57int CalPrintBase::mHeaderHeight=90;
58int CalPrintBase::mSubHeaderHeight=20;
59int CalPrintBase::mMargin=36;
60
61
62
63class CalPrintBase::TodoParentStart
64{
65 public:
66 TodoParentStart( QRect pt = QRect(), bool page = true )
67 : mRect( pt ), mSamePage( page ) {}
68
69 QRect mRect;
70 bool mSamePage;
71};
72
73class PrintCellItem : public KOrg::CellItem
74{
75 public:
76 PrintCellItem( Event *event, const QDate &day )
77 : mEvent( event ), mDay( day )
78 {
79 }
80
81 Event *event() const { return mEvent; }
82
83 QString label() const { return mEvent->summary(); }
84
85 bool overlaps( KOrg::CellItem *o ) const
86 {
87 PrintCellItem *other = static_cast<PrintCellItem *>( o );
88
89 QDateTime start = event()->dtStart();
90 QDateTime end = event()->dtEnd();
91 if ( event()->doesRecur() ) {
92 start.setDate( mDay );
93 end.setDate( mDay );
94 }
95 QDateTime otherStart = other->event()->dtStart();
96 QDateTime otherEnd = other->event()->dtEnd();
97 if ( other->event()->doesRecur() ) {
98 otherStart.setDate( mDay );
99 otherEnd.setDate( mDay );
100 }
101
102#if 0
103 kdDebug() << "PrintCellItem::overlaps() " << event()->summary()
104 << " <-> " << other->event()->summary() << endl;
105 kdDebug() << " start : " << start.toString() << endl;
106 kdDebug() << " end : " << end.toString() << endl;
107 kdDebug() << " otherStart: " << otherStart.toString() << endl;
108 kdDebug() << " otherEnd : " << otherEnd.toString() << endl;
109#endif
110
111 return !( otherStart >= end || otherEnd <= start );
112 }
113
114 private:
115 Event *mEvent;
116 QDate mDay;
117};
118
119void setCategoryColors( QPainter &p, Incidence *incidence)
120{
121 QColor bgColor;
122 QStringList categories = incidence->categories();
123 QString cat = categories.first();
124 if (cat.isEmpty())
125 bgColor = KOPrefs::instance()->mEventColor;
126 else
127 bgColor = *(KOPrefs::instance()->categoryColor(cat));
128 QColor textColor = Qt::black;//getTextColor(bgColor);
129 p.setPen( textColor );
130 p.setBrush( bgColor );
131}
132
133
134
135CalPrintBase::CalPrintBase( KPrinter *printer, Calendar *cal, KConfig *cfg )
136 : QObject(), mPrinter( printer ), mCalendar( cal ), mConfig( cfg )
137{
138}
139
140CalPrintBase::~CalPrintBase()
141{
142}
143
144
145
146QWidget *CalPrintBase::configWidget( QWidget *w )
147{
148 QFrame *wdg = new QFrame( w );
149 QVBoxLayout *layout = new QVBoxLayout( wdg );
150
151 QLabel *title = new QLabel( description(), wdg );
152 QFont titleFont( title->font() );
153 titleFont.setPointSize( 20 );
154 titleFont.setBold( true );
155 title->setFont( titleFont );
156
157 layout->addWidget( title );
158 layout->addWidget( new QLabel( longDescription(), wdg ) );
159 layout->addSpacing( 20 );
160 layout->addWidget( new QLabel( i18n("This printing style does not "
161 "have any configuration options."),
162 wdg ) );
163 layout->addStretch();
164 return wdg;
165}
166#include <qapplication.h>
167void CalPrintBase::doPrint()
168{
169 QPainter p;
170
171 mPrinter->setColorMode( (mUseColors)?(KPrinter::Color):(KPrinter::GrayScale));
172 //#define DUMMY_PRINTER
173#ifdef DUMMY_PRINTER
174
175 static QWidget* dummy = 0;
176 if ( ! dummy )
177 dummy = new QWidget( );
178 else {
179 delete dummy;
180 dummy = new QWidget( );
181
182 }
183 dummy->resize( 1024, 1024 );
184 dummy->repaint();
185 dummy->show();
186 dummy->raise();
187 dummy->setBackgroundColor( Qt::white);
188 qApp->processEvents();
189 p.begin(dummy);
190#else
191 p.begin(mPrinter);
192#endif
193 // the painter initially begins at 72 dpi per the Qt docs.
194 // we want half-inch margins.
195 p.setViewport(mMargin, mMargin,
196 p.viewport().width()-mMargin,
197 p.viewport().height()-mMargin);
198 int pageWidth = p.viewport().width();
199 int pageHeight = p.viewport().height();
200
201 print(p, pageWidth, pageHeight);
202
203 p.end();
204}
205
206void CalPrintBase::doLoadConfig()
207{
208 if ( mConfig ) {
209 mConfig->setGroup(description());
210 //KConfigGroupSaver saver( mConfig, description() );
211 mConfig->sync();
212 QDateTime currDate( QDate::currentDate() );
213 mFromDate = mConfig->readDateTimeEntry( "FromDate", &currDate ).date();
214 mToDate = mConfig->readDateTimeEntry( "ToDate" ).date();
215 mUseColors = mConfig->readBoolEntry( "UseColors", false );
216 loadConfig();
217 } else {
218 qDebug("no config in CalPrintBase::doLoadConfig ");
219 }
220}
221
222void CalPrintBase::doSaveConfig()
223{
224 if ( mConfig ) {
225 mConfig->setGroup(description());
226 // KConfigGroupSaver saver( mConfig, description() );
227 saveConfig();
228 mConfig->writeEntry( "FromDate", QDateTime( mFromDate ) );
229 mConfig->writeEntry( "ToDate", QDateTime( mToDate ) );
230 mConfig->writeEntry( "UseColors", mUseColors );
231 mConfig->sync();
232 } else {
233 qDebug("no config in CalPrintBase::doSveConfig ");
234 }
235}
236
237///////////////////////////////////////////////////////////////////////////////
238
239void CalPrintBase::drawHeader( QPainter &p, QString title,
240 const QDate &month1, const QDate &month2,
241 int x, int y, int width, int height )
242{
243 p.drawRect(x, y, width, height);
244 // p.fillRect( x+1, y+1,
245// width-2,height-2,
246// QBrush(Dense7Pattern) );
247
248 QString myOwner(mCalendar->getOwner());
249
250 int right=x+width;
251
252 // print previous month for month view, print current for todo, day and week
253 int smallMonthWidth=width/4-10;
254 if (smallMonthWidth>100) smallMonthWidth=100;
255 if (month2.isValid()) {
256 right -= (10+smallMonthWidth);
257 drawSmallMonth(p, QDate(month2.year(), month2.month(), 1),
258 right, y+2, smallMonthWidth, height-4);
259 right-=10;
260 }
261 if (month1.isValid()) {
262 right -= (10+smallMonthWidth);
263 drawSmallMonth(p, QDate(month1.year(), month1.month(), 1),
264 right, y+2, smallMonthWidth, height-4);
265 right-=10;
266 }
267
268 // Print the titles...
269 QFont font("helvetica", 18, QFont::Bold);
270 p.setFont(font);
271 QRect textRect( x+5, y+5, right-10-x, height-10 );
272 p.drawText( textRect, Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak, title );
273}
274
275
276void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd,
277 int x, int y, int width, int height)
278{
279 bool firstCol = true;
280 QDate monthDate(QDate(qd.year(), qd.month(), 1));
281 QDate monthDate2;
282 int month = monthDate.month();
283
284 // draw the title
285 p.setFont(QFont("helvetica", 7, QFont::Bold));
286 // int lineSpacing = p.fontMetrics().lineSpacing();
287 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
288 p.drawText(x, y, width, height/4, AlignCenter, calSys->monthName( qd ) );
289
290 int cellWidth = width/7;
291 int cellHeight = height/8;
292 QString tmpStr;
293
294 // correct begin of week
295 int weekdayCol = weekdayColumn( qd.dayOfWeek() );
296 monthDate2 = monthDate.addDays(-weekdayCol);
297
298 // draw days of week
299 p.setFont(QFont("helvetica", 7, QFont::Bold));
300 for (int col = 0; col < 7; col++) {
301 // tmpStr.sprintf("%c",(const char*)monthDate2.dayName(monthDate2.dayOfWeek()));
302 tmpStr=calSys->weekDayName( monthDate2 )[0].upper();
303 p.drawText(x+col*cellWidth, y+height/4, cellWidth, cellHeight,
304 AlignCenter, tmpStr);
305 monthDate2 = monthDate2.addDays(1);
306 }
307
308 // draw separator line
309 p.drawLine(x, y+height/4+cellHeight, x+width, y+height/4+cellHeight);
310
311 for (int row = 0; row < 5; row++) {
312 for (int col = 0; col < 7; col++) {
313 if (monthDate.month() != month)
314 break;
315 if (firstCol) {
316 firstCol = true;
317 col = weekdayColumn( monthDate.dayOfWeek() );
318 }
319 p.drawText( x+col*cellWidth,
320 y+height/4+cellHeight+(row*cellHeight),
321 cellWidth, cellHeight, AlignCenter,
322 tmpStr.setNum(monthDate.day()) );
323 monthDate = monthDate.addDays(1);
324 }
325 }
326}
327
328
329///////////////////////////////////////////////////////////////////////////////
330
331/*
332 * This routine draws a header box over the main part of the calendar
333 * containing the days of the week.
334 */
335void CalPrintBase::drawDaysOfWeek(QPainter &p,
336 const QDate &fromDate, const QDate &toDate,
337 int x, int y, int width, int height)
338{
339 int cellWidth = width/(fromDate.daysTo( toDate )+1);
340 int currx=x;
341 QDate cellDate(fromDate);
342
343 while (cellDate<=toDate) {
344 drawDaysOfWeekBox(p, cellDate, currx, y, cellWidth, height);
345 currx+=cellWidth;
346 cellDate = cellDate.addDays(1);
347 }
348}
349
350
351void CalPrintBase::drawDaysOfWeekBox(QPainter &p, const QDate &qd,
352 int x, int y, int width, int height)
353{
354 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
355
356 p.setFont( QFont( "helvetica", 10, QFont::Bold ) );
357 p.drawRect( x, y, width, height );
358// p.fillRect( x+1, y+1,
359// width-2, height-2,
360// QBrush( Dense7Pattern ) );
361 p.drawText( x+5, y, width-10, height, AlignCenter | AlignVCenter,
362 calSys->weekDayName( qd ) );
363}
364
365
366void CalPrintBase::drawTimeLine(QPainter &p,
367 const QTime &fromTime, const QTime &toTime,
368 int x, int y, int width, int height)
369{
370 p.drawRect(x, y, width, height);
371
372 int totalsecs=fromTime.secsTo(toTime);
373 float minlen=(float)height*60./(float)totalsecs;
374 float cellHeight=(60.*(float)minlen);
375 float currY=y;
376
377 QTime curTime( fromTime );
378 QTime endTime( toTime );
379 if ( fromTime.minute() > 30 )
380 curTime = QTime( fromTime.hour()+1, 0, 0 );
381 else if ( fromTime.minute() > 0 ) {
382 curTime = QTime( fromTime.hour(), 30, 0 );
383 float yy = currY + minlen*(float)fromTime.secsTo( curTime )/60.;
384 p.drawLine( x+width/2, (int)yy, x+width, (int)yy );
385 curTime = QTime( fromTime.hour()+1, 0, 0 );
386 }
387 currY += ( fromTime.secsTo(curTime)*minlen/60 );
388
389 while ( curTime < endTime ) {
390 p.drawLine( x, (int)currY, x+width, (int)currY );
391 int newY=(int)(currY+cellHeight/2.);
392 QString numStr;
393 if (newY < y+height) {
394 p.drawLine(x+width/2, (int)newY, x+width, (int)newY);
395 // draw the time:
396 if ( !KGlobal::locale()->use12Clock() ) {
397 numStr.setNum(curTime.hour());
398 if (cellHeight > 30) {
399 p.setFont(QFont("helvetica", 16, QFont::Bold));
400 } else {
401 p.setFont(QFont("helvetica", 12, QFont::Bold));
402 }
403 p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight,
404 AlignTop|AlignRight, numStr);
405 p.setFont(QFont("helvetica", 10, QFont::Normal));
406 p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3,
407 AlignTop | AlignLeft, "00");
408 } else {
409 QTime time( curTime.hour(), 0 );
410 numStr = KGlobal::locale()->formatTime( time );
411 p.setFont(QFont("helvetica", 14, QFont::Bold));
412 p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3,
413 AlignTop|AlignLeft, numStr);
414 }
415 currY+=cellHeight;
416 } // enough space for half-hour line and time
417 if (curTime.secsTo(endTime)>3600)
418 curTime=curTime.addSecs(3600);
419 else curTime=endTime;
420 } // currTime<endTime
421}
422
423
424///////////////////////////////////////////////////////////////////////////////
425
426/** prints the all-day box for the agenda print view. if expandable is set,
427 height is the cell height of a single cell, and the returned height will
428 be the total height used for the all-day events. If !expandable, only one
429 cell will be used, and multiple events are concatenated using ", ".
430*/
431void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList,
432 const QDate &qd, bool expandable,
433 int x, int y, int width, int &height)
434{
435 Event::List::Iterator it, itold;
436
437 int offset=y;
438
439 //p.setBrush(QBrush(Dense7Pattern));
440 QPen oldPen(p.pen());
441 QColor oldBgColor(p.backgroundColor());
442 QBrush oldBrush(p.brush());
443 QString multiDayStr;
444
445 it = eventList.begin();
446#ifndef KORG_NOPLUGINS
447 QString hstring(KOCore::self()->holiday(qd));
448 if (!hstring.isEmpty()) {
449 Event*holiday=new Event();
450 holiday->setDtStart(qd);
451 holiday->setDtEnd(qd);
452 holiday->setFloats(true);
453 holiday->setCategories(i18n("Holiday"));
454 eventList.prepend(holiday);
455 }
456#endif
457 Event *currEvent = 0;
458 // First, print all floating events
459 while( it!=eventList.end() ) {
460 currEvent=*it;
461 itold=it;
462 ++it;
463 if ( currEvent->doesFloat() ) {
464 // set the colors according to the categories
465 QString text = currEvent->summary() ;
466 if ( ! currEvent->location().isEmpty() )
467 text += " ("+currEvent->location()+")";
468 if (expandable) {
469 if (mUseColors)
470 setCategoryColors(p, currEvent);
471
472 p.drawRect( x, offset, width, height );
473
474 p.drawText( x+5, offset+5, width-10, height-10,
475 AlignCenter | AlignVCenter | AlignJustify | WordBreak,
476 text );
477 // reset the colors
478 p.setBrush( oldBrush );
479 p.setPen( oldPen );
480 p.setBackgroundColor(oldBgColor);
481
482 offset += height;
483 } else {
484 //if (!multiDayStr.isEmpty()) multiDayStr+=", ";
485 multiDayStr += text+"\n";
486 }
487 eventList.remove( itold );
488 }
489 }
490
491 if (!expandable) {
492 p.drawRect(x, offset, width, height);
493 if (!multiDayStr.isEmpty()) {
494 // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) );
495 p.drawText( x+5, offset+5, width-10, height-10,
496 AlignLeft | AlignTop | AlignJustify ,
497 multiDayStr);
498 }
499 } else {
500 height=offset-y;
501 }
502}
503
504
505void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events,
506 const QDate &qd, bool expandable,
507 QTime &fromTime, QTime &toTime,
508 int x, int y, int width, int height )
509{
510 p.drawRect( x, y, width, height );
511
512 Event *event;
513
514 if ( expandable ) {
515 // Adapt start/end times to include complete events
516 Event::List::ConstIterator it;
517 for ( it = events.begin(); it != events.end(); ++it ) {
518 event = *it;
519 if ( event->dtStart().time() < fromTime )
520 fromTime = event->dtStart().time();
521 if ( event->dtEnd().time() > toTime )
522 toTime = event->dtEnd().time();
523 }
524 }
525
526 // Show at least one hour
527 if ( fromTime.secsTo( toTime ) < 3600 ) {
528 fromTime = QTime( fromTime.hour(), 0, 0 );
529 toTime = fromTime.addSecs( 3600 );
530 }
531
532 // calculate the height of a cell and of a minute
533 int totalsecs = fromTime.secsTo( toTime );
534 float minlen = height * 60. / totalsecs;
535 float cellHeight = 60. * minlen;
536 float currY = y;
537
538 // print grid:
539 QTime curTime( QTime( fromTime.hour(), 0, 0 ) );
540 currY += fromTime.secsTo( curTime ) * minlen / 60;
541
542 while ( curTime < toTime && curTime.isValid() ) {
543 if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) );
544 currY += cellHeight / 2;
545 if ( ( currY > y ) && ( currY < y + height ) ) {
546 QPen oldPen( p.pen() );
547 p.setPen( QColor( 192, 192, 192 ) );
548 p.drawLine( x, int( currY ), x + width, int( currY ) );
549 p.setPen( oldPen );
550 } // enough space for half-hour line
551 if ( curTime.secsTo( toTime ) > 3600 )
552 curTime = curTime.addSecs( 3600 );
553 else curTime = toTime;
554 currY += cellHeight / 2;
555 }
556
557 QDateTime startPrintDate = QDateTime( qd, fromTime );
558 QDateTime endPrintDate = QDateTime( qd, toTime );
559
560 // Calculate horizontal positions and widths of events taking into account
561 // overlapping events
562
563 QPtrList<KOrg::CellItem> cells;
564 cells.setAutoDelete( true );
565
566 Event::List::ConstIterator itEvents;
567 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) {
568 cells.append( new PrintCellItem( *itEvents, qd ) );
569 }
570
571 QPtrListIterator<KOrg::CellItem> it1( cells );
572 for( it1.toFirst(); it1.current(); ++it1 ) {
573 KOrg::CellItem *placeItem = it1.current();
574
575 KOrg::CellItem::placeItem( cells, placeItem );
576 }
577
578 QPen oldPen = p.pen();
579 QColor oldBgColor = p.backgroundColor();
580 QBrush oldBrush = p.brush();
581
582 p.setFont( QFont( "helvetica", 10 ) );
583 //p.setBrush( QBrush( Dense7Pattern ) );
584
585 for( it1.toFirst(); it1.current(); ++it1 ) {
586 PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() );
587
588 drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x,
589 y, width );
590
591 p.setBrush( oldBrush );
592 p.setPen( oldPen );
593 p.setBackgroundColor( oldBgColor );
594 }
595
596 p.setBrush( QBrush( NoBrush ) );
597}
598
599
600void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p,
601 const QDate &qd,
602 const QDateTime &startPrintDate,
603 const QDateTime &endPrintDate,
604 float minlen, int x, int y, int width )
605{
606 Event *event = item->event();
607
608 // set the colors according to the categories
609 if ( mUseColors ) setCategoryColors( p, event );
610 else p.setBrush( Qt::white );
611 // start/end of print area for event
612 QDateTime startTime = event->dtStart();
613 QDateTime endTime = event->dtEnd();
614 if ( event->doesRecur() ) {
615 startTime.setDate( qd );
616 endTime.setDate( qd );
617 }
618 if ( ( startTime < endPrintDate && endTime > startPrintDate ) ||
619 ( endTime > startPrintDate && startTime < endPrintDate ) ) {
620 if ( startTime < startPrintDate ) startTime = startPrintDate;
621 if ( endTime > endPrintDate ) endTime = endPrintDate;
622 int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen );
623 int currentyPos = int( y + startPrintDate.secsTo( startTime ) *
624 minlen / 60. );
625 int currentWidth = width / item->subCells();
626 int currentX = x + item->subCell() * currentWidth;
627 QString text = KGlobal::locale()->formatTime(event->dtStart().time())+
628 "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+
629 " "+event->summary();
630 if ( !event->location().isEmpty() )
631 text += " (" +event->location()+")";
632 // p.save();
633 QPen pe = p.pen();
634 pe.setWidth( 2 );
635 p.setPen( pe );
636 p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 );
637 p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3,
638 AlignLeft | AlignTop | AlignJustify | WordBreak,
639 text);
640 // p.restore();
641 }
642}
643
644void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd,
645 int x, int y, int width, int height,
646 bool fullDate)
647{
648 QString dayNumStr;
649 QString ampm;
650 const KLocale*local = KGlobal::locale();
651
652
653 // This has to be localized
654 if (fullDate) {
655 /*int index;
656 dayNumStr= qd.toString();
657 index = dayNumStr.find(' ');
658 dayNumStr.remove(0, index);
659 index = dayNumStr.findRev(' ');
660 dayNumStr.truncate(index);*/
661
662 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
663 dayNumStr = i18n("weekday month date", "%1 %2 %3")
664 .arg( calSys->weekDayName( qd ) )
665 .arg( calSys->monthName( qd ) )
666 .arg( qd.day() );
667// dayNumStr = local->formatDate(qd);
668 } else {
669 dayNumStr = QString::number( qd.day() );
670 }
671
672 p.eraseRect( x, y, width, height );
673 p.drawRect( x, y, width, height );
674 // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) );
675 p.drawRect( x, y, width, mSubHeaderHeight );
676 //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) );
677 QString hstring;
678#ifndef KORG_NOPLUGINS
679 hstring=KOCore::self()->holiday(qd);
680#endif
681
682 if (!hstring.isEmpty()) {
683 p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) );
684
685 p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter,
686 hstring );
687 }
688 p.setFont(QFont("helvetica", 10, QFont::Bold));
689 p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter,
690 dayNumStr);
691 Event::List eventList;
692 eventList.fill( mCalendar->events( qd, true ));
693 Todo::List todos;
694 todos.fill( mCalendar->todos( qd ));
695 QString outStr;
696 p.setFont( QFont( "helvetica", 8 ) );
697 int lineSpacing = p.fontMetrics().lineSpacing();
698
699 int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry
700 Event::List::ConstIterator it;
701 int entryCount = eventList.count() +todos.count();
702 if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) {
703 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) {
704 p.setFont( QFont( "helvetica", 7 ) );
705 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY )
706 p.setFont( QFont( "helvetica", 6 ) );
707 }
708 lineSpacing = p.fontMetrics().lineSpacing()-1;
709 }
710 // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY );
711 for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) {
712 Event *currEvent = *it;
713 if (currEvent->doesFloat() || currEvent->isMultiDay())
714 outStr = currEvent->summary();
715
716 else {
717 if ( fullDate ) {
718 outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+
719 "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+
720 " "+ currEvent->summary();
721 if ( ! currEvent->location().isEmpty() )
722 outStr += " (" + currEvent->location()+")";
723 } else {
724 QTime t1 = currEvent->dtStart().time();
725
726 outStr = local->formatTime(t1);
727 outStr += " " + currEvent->summary();
728 }
729
730 } // doesFloat
731
732 p.drawText(x+5, y+textY, width-10, lineSpacing,
733 AlignLeft|AlignBottom, outStr);
734 textY+=lineSpacing;
735 }
736
737 if ( textY<height ) {
738
739 Todo::List::ConstIterator it2;
740 for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) {
741 Todo *todo = *it2;
742 QString text;
743 if (todo->hasDueDate()) {
744 if (!todo->doesFloat()) {
745 text += KGlobal::locale()->formatTime(todo->dtDue().time());
746 text += " ";
747 }
748 }
749 text += i18n("To-Do: %1").arg(todo->summary());
750
751 p.drawText(x+5, y+textY, width-10, lineSpacing,
752 AlignLeft|AlignBottom, text);
753 textY+=lineSpacing;
754 }
755 }
756}
757
758
759///////////////////////////////////////////////////////////////////////////////
760
761void CalPrintBase::drawWeek(QPainter &p, const QDate &qd,
762 int x, int y, int width, int height)
763{
764 QDate weekDate = qd;
765 bool portrait = ( mPrinter->orientation() == KPrinter::Portrait );
766 int cellWidth, cellHeight;
767 int vcells;
768 if (portrait) {
769 cellWidth = width/2;
770 vcells=3;
771 } else {
772 cellWidth = width/6;
773 vcells=1;
774 }
775 cellHeight = height/vcells;
776
777 // correct begin of week
778 int weekdayCol = weekdayColumn( qd.dayOfWeek() );
779 weekDate = qd.addDays( -weekdayCol );
780
781 for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) {
782 if (i<5) {
783 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells),
784 cellWidth, cellHeight, true);
785 } else if (i==5) {
786 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells),
787 cellWidth, cellHeight/2, true);
788 } else if (i==6) {
789 drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells),
790 y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true);
791 }
792 } // for i through all weekdays
793}
794
795
796void CalPrintBase::drawTimeTable(QPainter &p,
797 const QDate &fromDate, const QDate &toDate,
798 QTime &fromTime, QTime &toTime,
799 int x, int y, int width, int height)
800{
801 // timeline is 1.5 hours:
802 int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) );
803 int timelineWidth = 60;
804 int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) );
805 int currY=y;
806 int currX=x;
807
808 drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight);
809 currY+=mSubHeaderHeight;
810 drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight,
811 timelineWidth, height-mSubHeaderHeight-alldayHeight );
812
813 currX=x+timelineWidth;
814 // draw each day
815 QDate curDate(fromDate);
816 while (curDate<=toDate) {Event::List eventList;
817 eventList.fill( mCalendar->events(curDate, true));
818 drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight);
819 drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX,
820 currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight );
821 currX+=cellWidth;
822 curDate=curDate.addDays(1);
823 }
824
825}
826
827
828///////////////////////////////////////////////////////////////////////////////
829
830void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers,
831 int x, int y, int width, int height)
832{
833
834 int yoffset = mSubHeaderHeight;
835 int xoffset = 0;
836
837 QDate monthDate(QDate(qd.year(), qd.month(), 1));
838 QDate monthFirst(monthDate);
839 QDate monthLast(monthDate.addMonths(1).addDays(-1));
840
841
842 int weekdayCol = weekdayColumn( monthDate.dayOfWeek() );
843 monthDate = monthDate.addDays(-weekdayCol);
844
845 int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1;
846 int cellHeight = (height-yoffset) / rows;
847
848 if (weeknumbers) {
849 QFont oldFont(p.font());
850 QFont newFont(p.font());
851 newFont.setPointSize(7);
852 p.setFont(newFont);
853 xoffset += 18;
854 QDate weekDate(monthDate);
855 for (int row = 0; row<rows; row++) {
856 int calWeek = weekDate.weekNumber();
857 QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight);
858 p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) );
859 weekDate = weekDate.addDays(7);
860 }
861 p.setFont(oldFont);
862 }
863
864 drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight );
865 int cellWidth = (width-xoffset) / 7;
866
867 QColor back = p.backgroundColor();
868 bool darkbg = false;
869 for (int row = 0; row < rows; row++) {
870 for (int col = 0; col < 7; col++) {
871 // show days from previous/next month with a grayed background
872 if ( (monthDate < monthFirst) || (monthDate > monthLast) ) {
873 p.setBackgroundColor( QColor( 240, 240, 240) );
874 darkbg = true;
875 }
876 drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight);
877 if ( darkbg ) {
878 p.setBackgroundColor( back );
879 darkbg = false;
880 }
881 monthDate = monthDate.addDays(1);
882 }
883 }
884}
885
886
887///////////////////////////////////////////////////////////////////////////////
888
889void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos,
890 bool desc, int pospriority, int possummary, int posDueDt, int level,
891 int x, int &y, int width, int &height, int pageHeight,
892 TodoParentStart *r )
893{
894 if ( !completed && item->isCompleted() )
895 return;
896 QString outStr;
897// int fontHeight = 10;
898 const KLocale *local = KGlobal::locale();
899 int priority=item->priority();
900 int posdue=posDueDt;
901 if (posdue<0) posdue=x+width;
902 QRect rect;
903 TodoParentStart startpt;
904 // This list keeps all starting points of the parent todos so the connection
905 // lines of the tree can easily be drawn (needed if a new page is started)
906 static QPtrList<TodoParentStart> startPoints;
907 if (level<1) {
908 startPoints.clear();
909 }
910
911 // size of item
912 outStr=item->summary();
913 if ( ! item->location().isEmpty() )
914 outStr += " ("+item->location()+")";
915 if ( item->hasDueDate() && posDueDt>=0 ) {
916 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]";
917 }
918 int left = possummary+(level*10);
919 rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr);
920 if ( !item->description().isEmpty() && !desc ) {
921 outStr = item->description();
922 rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1,
923 WordBreak, outStr );
924 }
925 // if too big make new page
926 if ( rect.bottom() > y+height) {
927 // first draw the connection lines from parent todos:
928 if (level > 0 && connectSubTodos) {
929 TodoParentStart *rct;
930 for ( rct = startPoints.first(); rct; rct = startPoints.next() ) {
931 int start;
932 int center = rct->mRect.left() + (rct->mRect.width()/2);
933 int to = p.viewport().bottom();
934
935 // draw either from start point of parent or from top of the page
936 if (rct->mSamePage)
937 start = rct->mRect.bottom() + 1;
938 else
939 start = p.viewport().top();
940 p.moveTo( center, start );
941 p.lineTo( center, to );
942 rct->mSamePage=false;
943 }
944 }
945 y=0;
946 height=pageHeight-y;
947 mPrinter->newPage();
948 }
949
950 // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up
951 //to the RH side of the parent item's priority
952 if (r && pospriority >= 0 ) {
953 pospriority = r->mRect.right() + 1;
954 }
955
956 // Priority
957 outStr.setNum(priority);
958 rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr);
959 // Make it a more reasonable size
960 rect.setWidth(19);
961 rect.setHeight(19);
962 if ( priority > 0 && pospriority>=0 ) {
963 p.drawText(rect, AlignCenter, outStr);
964 p.drawRect(rect);
965 // cross out the rectangle for completed items
966 if ( item->isCompleted() ) {
967 p.drawLine( rect.topLeft(), rect.bottomRight() );
968 p.drawLine( rect.topRight(), rect.bottomLeft() );
969 }
970 }
971 startpt.mRect = rect; //save for later
972
973 // Connect the dots
974 if (level > 0 && connectSubTodos) {
975 int bottom;
976 int center( r->mRect.left() + (r->mRect.width()/2)+1 );
977 if (r->mSamePage )
978 bottom = r->mRect.bottom();//lutz + 1;
979 else
980 bottom = 0;
981 int to( rect.top() + (rect.height()/2)+1 );
982 int endx( rect.left() );
983 p.moveTo(center, bottom);
984 p.lineTo(center, to);
985 p.lineTo(endx, to);
986 }
987
988 // if completed, use strike out font
989 QFont ft=p.font();
990 ft.setStrikeOut( item->isCompleted() );
991 p.setFont( ft );
992 // summary
993 outStr=item->summary();
994 if ( ! item->location().isEmpty() )
995 outStr += " ("+item->location()+")";
996 if ( item->hasDueDate() && posDueDt>=0 ) {
997 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]";
998 }
999 rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)),
1000 -1, WordBreak, outStr);
1001 QRect newrect;
1002 p.drawText( rect, WordBreak, outStr, -1, &newrect );
1003 ft.setStrikeOut(false);
1004 p.setFont(ft);
1005
1006 // due
1007 // if ( item->hasDueDate() && posDueDt>=0 ) {
1008// outStr = local->formatDate(item->dtDue().date(),true);
1009// rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr);
1010// p.drawText(rect, AlignTop|AlignLeft, outStr);
1011// }
1012
1013 if ( !item->description().isEmpty() && desc ) {
1014 y=newrect.bottom() + 5;
1015 outStr = item->description();
1016 rect = p.boundingRect( left+20, y, x+width-(left+10), -1,
1017 WordBreak, outStr );
1018 p.drawText( rect, WordBreak, outStr, -1, &newrect );
1019 }
1020
1021 // Set the new line position
1022 y=newrect.bottom() + 10; //set the line position
1023
1024 // If the item has subitems, we need to call ourselves recursively
1025 Incidence::List l;l.fill( item->relations());
1026 Incidence::List::ConstIterator it;
1027 startPoints.append( &startpt );
1028 for( it = l.begin(); it != l.end(); ++it ) {
1029 count++;
1030 drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos,
1031 desc, pospriority, possummary, posDueDt, level+1,
1032 x, y, width, height, pageHeight, &startpt);
1033 }
1034 startPoints.remove(&startpt);
1035}
1036
1037int CalPrintBase::weekdayColumn( int weekday )
1038{
1039 return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7;
1040}
1041
1042void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd,
1043 const QDate &td )
1044{
1045 QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek;
1046
1047 mPrinter->setOrientation(KPrinter::Portrait);
1048
1049 int minus = 0;
1050 if (KGlobal::locale()->weekStartsMonday()) {
1051 // correct to monday
1052 fromWeek = fd.addDays(-(fd.dayOfWeek()-1));
1053 // correct to sunday
1054 toWeek = td.addDays(7-fd.dayOfWeek());
1055 minus = 1;
1056 } else {
1057 // correct to sunday
1058 fromWeek = fd.addDays(-(fd.dayOfWeek()%7));
1059 // correct to saturday
1060 toWeek = td.addDays(6-td.dayOfWeek());
1061 }
1062
1063 fromDay = fd;
1064 curDay = fd;
1065 toDay = td;
1066 p.setFont( QFont("Helvetica") );
1067 // the painter initially begins at 72 dpi per the Qt docs.
1068 int pageWidth = p.viewport().width();
1069 int pageHeight = p.viewport().height();
1070 int margin=0;
1071 mHeaderHeight = 110;
1072 mSubHeaderHeight = 20;
1073
1074 p.setViewport(margin, margin,
1075 p.viewport().width()-margin,
1076 p.viewport().height()-margin);
1077
1078 curWeek = fromWeek.addDays(6);
1079
1080 int columnWidth = int( pageWidth / 4.5 );
1081
1082 do {
1083
1084 // if ( (curDay.dayOfWeek()-1)%7 < 3 )
1085 switch((curDay.dayOfWeek()-minus)%7){
1086 case 0:
1087 drawSplitTimes( p, pageWidth, columnWidth, pageHeight );
1088 drawSplitDay( p, curDay, columnWidth, pageHeight,
1089 int( columnWidth * 0.5 ) );
1090 break;
1091 case 1:
1092 drawSplitDay( p, curDay, columnWidth, pageHeight,
1093 int( columnWidth * 1.5 ) );
1094 break;
1095 case 2:
1096 drawSplitDay( p, curDay, columnWidth, pageHeight,
1097 int( columnWidth * 2.5 ) );
1098 break;
1099 case 3:
1100 drawSplitDay( p, curDay, columnWidth, pageHeight,
1101 int( columnWidth * 3.5 ) );
1102 mPrinter->newPage();
1103 break;
1104 case 4:
1105 drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth,
1106 pageHeight );
1107 drawSplitDay( p, curDay, columnWidth, pageHeight,
1108 int( columnWidth * 0.5 ) );
1109 drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek,
1110 curWeek, pageWidth, mHeaderHeight );
1111 break;
1112 case 5:
1113 drawSplitDay( p, curDay, columnWidth, pageHeight,
1114 int( columnWidth * 1.5 ) );
1115 break;
1116 case 6:
1117 drawSplitDay( p, curDay, columnWidth, pageHeight,
1118 int( columnWidth * 2.5 ) );
1119 if ( curDay < toDay )
1120 mPrinter->newPage();
1121 curWeek = curWeek.addDays( 7 );
1122 break;
1123 }
1124 curDay = curDay.addDays(1);
1125
1126 } while (curDay <= toDay);
1127
1128}
1129
1130void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd,
1131 const QDate &td,
1132 const QDate &,
1133 int width, int )
1134{
1135 int tempStore = mSubHeaderHeight;
1136 mSubHeaderHeight+= mSubHeaderHeight;
1137 KLocale *local = KGlobal::locale();
1138 QFont font("helvetica", 18, QFont::Bold);
1139 QPen penA( black,0);
1140 QPen penB( black,3);
1141 p.setFont(font);
1142 int lineSpacing = p.fontMetrics().lineSpacing();
1143 QString title;
1144 QString myOwner(mCalendar->getOwner());
1145 if ( fd.month() == td.month() ) {
1146 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' '
1147 + '-' + ' ' + QString::number(td.day());
1148 } else {
1149 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' '
1150 + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day());
1151 }
1152
1153// Grrrrrrr! why can't I set the font to a serif font?!?!?
1154 QFont serifFont("Helvetica", 30);
1155// serifFont.setFamily("Serif");
1156// serifFont.setWeight(87);
1157// serifFont.setItalic(true);
1158 p.setFont(serifFont);
1159 QFontInfo info(p.font());
1160
1161 lineSpacing = p.fontMetrics().lineSpacing();
1162 p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title );
1163
1164 title.truncate(0);
1165
1166 p.setPen(penB );
1167 p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1);
1168 p.setPen(penA );
1169
1170 p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE));
1171 title += QString::number(fd.year());
1172 p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title );
1173 mSubHeaderHeight = tempStore ;
1174}
1175
1176void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width,
1177 int height, int offsetLeft )
1178{
1179 int tempStore = mSubHeaderHeight;
1180 mSubHeaderHeight+= mSubHeaderHeight;
1181 int startHour = KOPrefs::instance()->mDayBegins;
1182 int endHour = 20;
1183 int offset = mHeaderHeight + mSubHeaderHeight + 10;
1184 Event::List eventList; eventList.fill( mCalendar->events( qd, true ));
1185 Event::List::Iterator it;
1186 Event *currEvent;
1187 KLocale *local = KGlobal::locale();
1188 QString dayName;
1189
1190 dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day());
1191 //p.setBrush(QBrush(black));
1192// width+1 to make sure there's a continuous, black bar across the top.
1193 p.setPen( QPen(Qt::black,2));
1194 p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight);
1195 p.setPen( Qt::black);
1196 p.setFont(QFont("helvetica", 12, QFont::Bold, true));
1197 p.drawText(offsetLeft, mHeaderHeight + 5,
1198 width, mSubHeaderHeight, AlignHCenter | AlignVCenter,
1199 dayName);
1200
1201 p.setPen( QPen(Qt::black,2));
1202 p.setFont(QFont("helvetica", 12));
1203 p.setBrush(Qt::white);
1204 it = eventList.begin();
1205 int allDays = 0;
1206 /*
1207 while( it != eventList.end() ) {
1208 Event *currEvent = *it;
1209 if ( currEvent->doesFloat() ) {
1210 p.drawRect( offsetLeft, offset, width, 35 );
1211 p.drawText( offsetLeft + 5, offset + 10, width - 10, 30,
1212 AlignLeft | AlignTop, currEvent->summary() );
1213 offset += 40;
1214 allDays++;
1215 it = eventList.remove( it );
1216 } else {
1217 ++it;
1218 }
1219 }
1220 */
1221 //p.setBrush(QBrush());
1222 int tmpEnd;
1223 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1224 Event *currEvent = *it;
1225 tmpEnd = currEvent->dtEnd().time().hour();
1226 if (currEvent->dtEnd().time().minute() > 0)
1227 tmpEnd++;
1228 if (tmpEnd > endHour)
1229 endHour = tmpEnd;
1230 }
1231 int hours = endHour - startHour;
1232 int cellHeight = (height-offset) / hours; // hour increments.
1233
1234 p.setFont(QFont("helvetica", 12));
1235 //p.setBrush(QBrush(Dense7Pattern));
1236 p.setBrush(Qt::white);
1237 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1238 Event *currEvent = *it;
1239 int startTime = currEvent->dtStart().time().hour();
1240 int endTime = currEvent->dtEnd().time().hour();
1241 float minuteInc = cellHeight / 60.0;
1242 if ((startTime >= startHour) && (endTime <= (startHour + hours))) {
1243 startTime -= startHour;
1244 int startMinuteOff = (int) (minuteInc *
1245 currEvent->dtStart().time().minute());
1246 QString text = currEvent->summary() ;
1247 if ( ! currEvent->location().isEmpty() )
1248 text += "\n("+currEvent->location()+")";
1249 int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute());
1250 int cheight = (int) (minuteInc *
1251 currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 );
1252 p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight,
1253 width-4, cheight);
1254 p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24,
1255 cheight-10, AlignHCenter | AlignTop, text);
1256 }
1257 }
1258 p.setBrush(QBrush(NoBrush));
1259 mSubHeaderHeight = tempStore ;
1260}
1261
1262void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth,
1263 int height )
1264{
1265 int tempStore = mSubHeaderHeight;
1266 mSubHeaderHeight+= mSubHeaderHeight;
1267 int startHour = KOPrefs::instance()->mDayBegins;
1268 int endHour = 20;
1269 int offset = mHeaderHeight + mSubHeaderHeight + 10;
1270 int hours = endHour - startHour;
1271 int cellHeight = (height-offset) / hours; // hour increments.
1272
1273 QString numStr;
1274 for (int i = 0; i < hours; i++) {
1275 p.setPen(QPen(black,1));
1276 p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight);
1277 p.setPen(QPen(gray,0));
1278 p.drawLine(37, offset+i*cellHeight+(cellHeight/2),
1279 width, offset+i*cellHeight+(cellHeight/2));
1280 p.setPen(QPen(black,0));
1281
1282 if ( !KGlobal::locale()->use12Clock() ) {
1283 numStr.setNum(i+startHour);
1284 if (cellHeight > 40) {
1285 p.setFont(QFont("helvetica", 16, QFont::Bold));
1286 } else {
1287 p.setFont(QFont("helvetica", 14, QFont::Bold));
1288 }
1289 p.drawText(0, offset+i*cellHeight, 33, cellHeight/2,
1290 AlignTop|AlignRight, numStr);
1291 p.setFont(QFont("helvetica", 12, QFont::Bold));
1292 p.drawText(37, offset+i*cellHeight, 45, cellHeight/2,
1293 AlignTop | AlignLeft, "00");
1294 } else {
1295 QTime time( i + startHour, 0 );
1296 numStr = KGlobal::locale()->formatTime( time );
1297 p.setFont(QFont("helvetica", 12, QFont::Bold));
1298 p.drawText(4, offset+i*cellHeight, 70, cellHeight/2,
1299 AlignTop|AlignLeft, numStr);
1300 }
1301 } mSubHeaderHeight = tempStore ;
1302}
1303
1304#endif
diff --git a/korganizer/calprintbase.h b/korganizer/calprintbase.h
new file mode 100644
index 0000000..7409143
--- a/dev/null
+++ b/korganizer/calprintbase.h
@@ -0,0 +1,379 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution.
24*/
25#ifndef CALPRINTBASE_H
26#define CALPRINTBASE_H
27// #define KORG_NOPRINTER
28
29#ifndef KORG_NOPRINTER
30
31#include <qwidget.h>
32#include <qdatetime.h>
33#include <kprinter.h>
34#include <kconfig.h>
35#include <libkcal/event.h>
36
37class PrintCellItem;
38
39namespace KCal {
40class Calendar;
41class Todo;
42}
43
44using namespace KCal;
45
46/**
47 Base class for KOrganizer printing classes. Each sub class represents one
48 calendar print format.
49*/
50class CalPrintBase : public QObject
51{
52 Q_OBJECT
53 public:
54 /**
55 Constructor
56
57 \param pr KPrinter object used to print.
58 \param cal Calendar to be printed.
59 \param cfg KConfig object for reading/writing printing configuration
60 */
61 CalPrintBase( KPrinter *pr, Calendar *cal, KConfig *cfg );
62 virtual ~CalPrintBase();
63
64 /**
65 Returns short description of print format.
66 */
67 virtual QString description() = 0;
68 /**
69 Returns long description of print format.
70 */
71 virtual QString longDescription() = 0;
72
73 /**
74 Returns widget for configuring the print format.
75 */
76 virtual QWidget *configWidget( QWidget * );
77
78 /**
79 Actually do the printing.
80
81 \param p QPainter the print result is painted to
82 \param width Width of printable area
83 \param height Height of printable area
84 */
85 virtual void print( QPainter &p, int width, int height ) = 0;
86 /**
87 Start printing.
88 */
89 virtual void doPrint();
90
91 /**
92 Orientation of printout. Default is Portrait. If your plugin wants
93 to use some other orientation as default (e.g. depending on some
94 config settings), implement this function in your subclass and
95 return the desired orientation.
96 */
97 virtual KPrinter::Orientation orientation() { return KPrinter::Portrait; }
98
99 /**
100 Load print format configuration from config file.
101 */
102 virtual void loadConfig() = 0;
103 /**
104 Write print format configuration to config file.
105 */
106 virtual void saveConfig() = 0;
107
108 /**
109 Load complete config. This also calls loadConfig() of the derived class.
110 */
111 void doLoadConfig();
112 /**
113 Save complete config. This also calls saveConfig() of the derived class.
114 */
115 void doSaveConfig();
116
117
118 public slots:
119 /**
120 Read settings from configuration widget and apply them to current object.
121 */
122 virtual void readSettingsWidget() {}
123 /**
124 Set configuration widget to reflect settings of current object.
125 */
126 virtual void setSettingsWidget() {}
127
128 /**
129 Set date range which should be printed.
130 */
131 virtual void setDateRange( const QDate &from, const QDate &to )
132 {
133 mFromDate = from;
134 mToDate = to;
135 }
136
137 protected:
138 int weekdayColumn( int weekday );
139
140 QDate mFromDate;
141 QDate mToDate;
142 bool mUseColors;
143
144 public:
145 /**
146 Internal class representing the start of a todo.
147 */
148 class TodoParentStart;
149
150 protected:
151 /**
152 Draw the gray header bar of the printout to the QPainter.
153 It prints the given text and optionally one or two small
154 month views, as specified by the two QDate. The printed
155 text can also contain a line feed.
156 If month2 is invalid, only the month that contains month1
157 is printed.
158 E.g. the filofax week view draws just the current month,
159 while the month view draws the previous and the next month.
160 \param p QPainter of the printout
161 \param title The string printed as the title of the page
162 (e.g. the date, date range or todo list title)
163 \param month1 Date specifying the month for the left one of
164 the small month views in the title bar. If left
165 empty, only month2 will be printed (or none,
166 it that is invalid as well).
167 \param month2 Date specifying the month for the right one of
168 the small month views in the title bar. If left
169 empty, only month1 will be printed (or none,
170 it that is invalid as well).
171 \param x x-coordinate of the upper left coordinate of the title bar
172 \param y y-coordinate of the upper left coordinate of the title bar
173 \param width width of the title bar
174 \param height height of the title bar
175 */
176 void drawHeader( QPainter &p, QString title,
177 const QDate &month1, const QDate &month2,
178 int x, int y, int width, int height );
179 /**
180 Draw a small calendar with the days of a month into the given area.
181 Used for example in the title bar of the sheet.
182 \param p QPainter of the printout
183 \param qd Arbitrary Date within the month to be printed.
184 \param x x-coordinate of the upper left coordinate of the small calendar
185 \param y y-coordinate of the upper left coordinate of the small calendar
186 \param width width of the small calendar
187 \param height height of the small calendar
188 */
189 void drawSmallMonth( QPainter &p, const QDate &qd,
190 int x, int y, int width, int height );
191
192 /**
193 Draw a horizontal bar with the weekday names of the given date range
194 in the given area of the painter.
195 This is used for the weekday-bar on top of the timetable view and the month view.
196 \param p QPainter of the printout
197 \param fromDate First date of the printed dates
198 \param toDate Last date of the printed dates
199 */
200 void drawDaysOfWeek( QPainter &p,
201 const QDate &fromDate, const QDate &toDate,
202 int x, int y, int width, int height );
203 /**
204 Draw a single weekday name in a box inside the given area of the painter.
205 This is called in a loop by drawDaysOfWeek.
206 \param p QPainter of the printout
207 \param qd Date of the printed day
208 */
209 void drawDaysOfWeekBox( QPainter &p, const QDate &qd,
210 int x, int y, int width, int height );
211 /**
212 Draw a (vertical) time scale from time fromTime to toTime inside the given area of the painter.
213 Every hour will have a one-pixel line over the whole width, every
214 half-hour the line will only span the left half of the width.
215 This is used in the day and timetable print styles
216 \param p QPainter of the printout
217 \param fromTime Start time of the time range to display
218 \param toTime End time of the time range to display
219 */
220 void drawTimeLine( QPainter &p,
221 const QTime &fromTime, const QTime &toTime,
222 int x, int y, int width, int height );
223 /**
224 Draw the all-day box for the agenda print view (the box on top which
225 doesn't have a time on the time scale associated). If expandable is set,
226 height is the cell height of a single cell, and the returned height will
227 be the total height used for the all-day events. If !expandable, only one
228 cell will be used, and multiple events are concatenated using ", ".
229 \param p QPainter of the printout
230 \param eventList The list of all-day events that are supposed to be printed
231 inside this box
232 \param qd The date of the currently printed day
233 \param expandable If true, height is the height of one single cell, the printout
234 will use as many cells as events in the list and return the total height
235 needed for all of them. If false, height specifies the total height
236 allowed for all events, and the events are displayed in one cell,
237 with their summaries concatenated by ", ".
238 */
239 void drawAllDayBox( QPainter &p, Event::List &eventList,
240 const QDate &qd, bool expandable,
241 int x, int y, int width, int &height );
242 /**
243 Draw the agenda box for the day print style (the box showing all events of that day).
244 Also draws a grid with half-hour spacing of the grid lines.
245 \param p QPainter of the printout
246 \param eventList The list of the events that are supposed to be printed
247 inside this box
248 \param qd The date of the currently printed day
249 \param expandable If true, the start and end times are adjusted to include
250 the whole range of all events of that day, not just of the given time range.
251 The height of the box will not be affected by this (but the height
252 of one hour will be scaled down so that the whole range fits into
253 the box. fromTime and toTime receive the actual time range printed
254 by this function).
255 \param fromTime Start of the time range to be printed. Might be adjusted
256 to include all events if expandable==true
257 \param toTime End of the time range to be printed. Might be adjusted
258 to include all events if expandable==true
259 */
260 void drawAgendaDayBox( QPainter &p, Event::List &eventList,
261 const QDate &qd, bool expandable,
262 QTime &fromTime, QTime &toTime,
263 int x, int y, int width, int height);
264
265 void drawAgendaItem( PrintCellItem *item, QPainter &p, const QDate &,
266 const QDateTime &startPrintDate,
267 const QDateTime &endPrintDate,
268 float minlen, int x, int y, int width );
269 /**
270 Draw the box containing a list of all events of the given day (with their times,
271 of course). Used in the Filofax and the month print style.
272 \param p QPainter of the printout
273 \param qd The date of the currently printed day. All events of the calendar
274 that appear on that day will be printed.
275 \param fullDate Whether the title bar of the box should contain the full
276 date string or just a short.
277 */
278 void drawDayBox( QPainter &p, const QDate &qd,
279 int x, int y, int width, int height,
280 bool fullDate = false );
281 /**
282 Draw the week (filofax) table of the week containing the date qd. The first
283 three days of the week will be shown in the first column (using drawDayBox),
284 the remaining four in the second column, where the last two days of the week
285 (typically Saturday and Sunday) only get half the height of the other day boxes.
286 \param p QPainter of the printout
287 \param qd Arbitrary date within the week to be printed.
288 */
289 void drawWeek( QPainter &p, const QDate &qd,
290 int x, int y, int width, int height );
291 /**
292 Draw the timetable view of the given time range from fromDate to toDate.
293 On the left side the time scale is printed (using drawTimeLine), then each
294 day gets one column (printed using drawAgendaDayBox),
295 and the events are displayed as boxes (like in korganizer's day/week view).
296 The first cell of each column contains the all-day events (using
297 drawAllDayBox with expandable=false).
298 The given time range cannot be expanded to include all events.
299 \param p QPainter of the printout
300 \param fromDate First day to be included in the page
301 \param toDate Last day to be included in the page
302 \param fromTime Start time of the displayed time range
303 \param toTime End time of the displayed time range
304 */
305 void drawTimeTable( QPainter &p, const QDate &fromDate, const QDate &toDate,
306 QTime &fromTime, QTime &toTime,
307 int x, int y, int width, int height );
308
309 /**
310 Draw the month table of the month containing the date qd. Each day gets one
311 box (using drawDayBox) that contains a list of all events on that day. They are arranged
312 in a matrix, with the first column being the first day of the
313 week (so it might display some days of the previous and the next month).
314 Above the matrix there is a bar showing the weekdays (drawn using drawDaysOfWeek).
315 \param p QPainter of the printout
316 \param qd Arbitrary date within the month to be printed.
317 \param weeknumbers Whether the week numbers are printed left of each row of the matrix
318 */
319 void drawMonth( QPainter &p, const QDate &qd, bool weeknumbers,
320 int x, int y, int width, int height );
321
322 /**
323 Draws single todo item and its (intented) subitems, optionally connects them by a tree-like line,
324 and optionally shows due date, summary, description and priority.
325 \param count The number of the currently printed todo (count will be incremented for each drawn item)
326 \param item The item to be printed. It's subitems are recursively
327 drawn, so drawTodo should only be called on the
328 items of the highest level.
329 \param p QPainter of the printout
330 \param connectSubTodos Whether subtodos shall be connected with their parent by a line (tree-like).
331 \param desc Whether to print the whole description of the item (the summary is always printed).
332 \param pospriority x-coordinate where the priority is supposed to be printed. If <0, no priority will be printed.
333 \param possummary x-coordinate where the summary of the item is supposed to be printed.
334 \param posDueDt x-coordinate where the due date is supposed to the be printed. If <0, no due date will be printed.
335 \param level Level of the current item in the todo hierarchy (0 means highest
336 level of printed items, 1 are their subtodos, etc.)
337 \param x x-coordinate of the upper left coordinate of the first item
338 \param y y-coordinate of the upper left coordinate of the first item
339 \param width width of the whole todo list
340 \param height Space left on the first page of the todo list
341 \param pageHeight Total height allowed for the todo list on a page. The first page uses height,
342 but at each line break the current position is reset to 0 and the
343 height is set to pageHeight.
344 \param r Internal (used when printing sub items to give information about its parent)
345 */
346 void drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos,
347 bool desc, int pospriority, int possummary, int posDueDt,
348 int level, int x, int &y, int width, int &height,
349 int pageHeight, TodoParentStart *r = 0 );
350
351 void drawSplitWeek( QPainter &p, const QDate &fd, const QDate &td );
352 void drawSplitHeaderRight( QPainter &p, const QDate &fd, const QDate &td,
353 const QDate &cd, int width, int height );
354 void drawSplitDay( QPainter &p, const QDate &qd, int width, int height,
355 int offsetLeft );
356 void drawSplitTimes( QPainter &p, int width, int timeWidth, int height );
357
358 /**
359 Determines the column of the given weekday ( 1=Monday, 7=Sunday ), taking the
360 start of the week setting into account as given in kcontrol.
361 \param weekday Index of the weekday
362 */
363 int weekDayColumn( int weekday );
364
365 KPrinter *mPrinter;
366 Calendar *mCalendar;
367 KConfig *mConfig;
368 //QWidget *mConfigWidget;
369
370 protected:
371 // TODO_RK: move these to the appropriate subclasses or set them globally.
372 static int mSubHeaderHeight;
373 static int mHeaderHeight;
374 static int mMargin;
375};
376
377#endif
378
379#endif
diff --git a/korganizer/calprintdayconfig_base.ui b/korganizer/calprintdayconfig_base.ui
new file mode 100644
index 0000000..2625593
--- a/dev/null
+++ b/korganizer/calprintdayconfig_base.ui
@@ -0,0 +1,252 @@
1<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
2<class>CalPrintDayConfig_Base</class>
3<comment>Configuration page for the print day mode.</comment>
4<author>Reinhold Kainhofer &lt;reinhold@kainhofer.com&gt;</author>
5<widget class="QWidget">
6 <property name="name">
7 <cstring>CalPrintDay_Base</cstring>
8 </property>
9 <property name="geometry">
10 <rect>
11 <x>0</x>
12 <y>0</y>
13 <width>407</width>
14 <height>175</height>
15 </rect>
16 </property>
17 <property name="caption">
18 <string>CalPrintDay_Base</string>
19 </property>
20 <vbox>
21 <property name="name">
22 <cstring>unnamed</cstring>
23 </property>
24 <property name="margin">
25 <number>0</number>
26 </property>
27 <widget class="QGroupBox">
28 <property name="name">
29 <cstring>mDateRangeGroup</cstring>
30 </property>
31 <property name="title">
32 <string>Date &amp;&amp; Time Range</string>
33 </property>
34 <grid>
35 <property name="name">
36 <cstring>unnamed</cstring>
37 </property>
38 <widget class="QLabel" row="0" column="2">
39 <property name="name">
40 <cstring>mToDateLabel</cstring>
41 </property>
42 <property name="sizePolicy">
43 <sizepolicy>
44 <hsizetype>1</hsizetype>
45 <vsizetype>5</vsizetype>
46 <horstretch>0</horstretch>
47 <verstretch>0</verstretch>
48 </sizepolicy>
49 </property>
50 <property name="text">
51 <string>&amp;End date:</string>
52 </property>
53 <property name="buddy" stdset="0">
54 <cstring>mToDate</cstring>
55 </property>
56 </widget>
57 <widget class="QLabel" row="0" column="0">
58 <property name="name">
59 <cstring>mFromDateLabel</cstring>
60 </property>
61 <property name="sizePolicy">
62 <sizepolicy>
63 <hsizetype>1</hsizetype>
64 <vsizetype>5</vsizetype>
65 <horstretch>0</horstretch>
66 <verstretch>0</verstretch>
67 </sizepolicy>
68 </property>
69 <property name="text">
70 <string>&amp;Start date:</string>
71 </property>
72 <property name="buddy" stdset="0">
73 <cstring>mFromDate</cstring>
74 </property>
75 </widget>
76 <widget class="QLabel" row="1" column="0">
77 <property name="name">
78 <cstring>mFromTimeLabel</cstring>
79 </property>
80 <property name="sizePolicy">
81 <sizepolicy>
82 <hsizetype>1</hsizetype>
83 <vsizetype>5</vsizetype>
84 <horstretch>1</horstretch>
85 <verstretch>0</verstretch>
86 </sizepolicy>
87 </property>
88 <property name="text">
89 <string>Start &amp;time:</string>
90 </property>
91 <property name="buddy" stdset="0">
92 <cstring>mFromTime</cstring>
93 </property>
94 </widget>
95 <widget class="QLabel" row="1" column="2">
96 <property name="name">
97 <cstring>mToTimeLabel</cstring>
98 </property>
99 <property name="sizePolicy">
100 <sizepolicy>
101 <hsizetype>1</hsizetype>
102 <vsizetype>5</vsizetype>
103 <horstretch>1</horstretch>
104 <verstretch>0</verstretch>
105 </sizepolicy>
106 </property>
107 <property name="text">
108 <string>End ti&amp;me:</string>
109 </property>
110 <property name="buddy" stdset="0">
111 <cstring>mToTime</cstring>
112 </property>
113 </widget>
114 <widget class="QTimeEdit" row="1" column="1">
115 <property name="name">
116 <cstring>mFromTime</cstring>
117 </property>
118 <property name="sizePolicy">
119 <sizepolicy>
120 <hsizetype>1</hsizetype>
121 <vsizetype>0</vsizetype>
122 <horstretch>3</horstretch>
123 <verstretch>0</verstretch>
124 </sizepolicy>
125 </property>
126 <property name="time">
127 <time>
128 <hour>0</hour>
129 <minute>8</minute>
130 <second>0</second>
131 </time>
132 </property>
133 </widget>
134 <widget class="QTimeEdit" row="1" column="3">
135 <property name="name">
136 <cstring>mToTime</cstring>
137 </property>
138 <property name="sizePolicy">
139 <sizepolicy>
140 <hsizetype>1</hsizetype>
141 <vsizetype>0</vsizetype>
142 <horstretch>3</horstretch>
143 <verstretch>0</verstretch>
144 </sizepolicy>
145 </property>
146 <property name="time">
147 <time>
148 <hour>18</hour>
149 <minute>0</minute>
150 <second>0</second>
151 </time>
152 </property>
153 </widget>
154 <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="4">
155 <property name="name">
156 <cstring>mIncludeAllEvents</cstring>
157 </property>
158 <property name="text">
159 <string>E&amp;xtend time range to include all events</string>
160 </property>
161 </widget>
162 <widget class="KDateEdit" row="0" column="3">
163 <property name="name">
164 <cstring>mToDate</cstring>
165 </property>
166 <property name="focusPolicy">
167 <enum>StrongFocus</enum>
168 </property>
169 </widget>
170 <widget class="KDateEdit" row="0" column="1">
171 <property name="name">
172 <cstring>mFromDate</cstring>
173 </property>
174 <property name="focusPolicy">
175 <enum>StrongFocus</enum>
176 </property>
177 </widget>
178 </grid>
179 </widget>
180 <widget class="QCheckBox">
181 <property name="name">
182 <cstring>mIncludeTodos</cstring>
183 </property>
184 <property name="enabled">
185 <bool>false</bool>
186 </property>
187 <property name="text">
188 <string>Include to&amp;dos that are due on the printed day(s)</string>
189 </property>
190 <property name="accel">
191 <string>Alt+D</string>
192 </property>
193 </widget>
194 <widget class="QCheckBox">
195 <property name="name">
196 <cstring>mColors</cstring>
197 </property>
198 <property name="text">
199 <string>&amp;Use colors</string>
200 </property>
201 <property name="accel">
202 <string>Alt+U</string>
203 </property>
204 </widget>
205 <spacer>
206 <property name="name">
207 <cstring>spacer4</cstring>
208 </property>
209 <property name="orientation">
210 <enum>Vertical</enum>
211 </property>
212 <property name="sizeType">
213 <enum>Expanding</enum>
214 </property>
215 <property name="sizeHint">
216 <size>
217 <width>20</width>
218 <height>51</height>
219 </size>
220 </property>
221 </spacer>
222 </vbox>
223</widget>
224<customwidgets>
225 <customwidget>
226 <class>KDateEdit</class>
227 <header location="local">libkdepim/kdateedit.h</header>
228 <sizehint>
229 <width>-1</width>
230 <height>-1</height>
231 </sizehint>
232 <container>0</container>
233 <sizepolicy>
234 <hordata>5</hordata>
235 <verdata>5</verdata>
236 <horstretch>0</horstretch>
237 <verstretch>0</verstretch>
238 </sizepolicy>
239 <pixmap>image0</pixmap>
240 </customwidget>
241</customwidgets>
242<images>
243 <image name="image0">
244 <data format="PNG" length="826">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000030149444154789cb59531681b5718c77f0e377c070e3c810a3a70e0041eac51852e0a19e45134830a1d9a4c69a04bc8928e990a693a640e1d0c8642b08742321894c1507991b484c890902bb8701a047760c3bd21701fe4201dde49b6a41a32b8df72dcbbeffdbefffbbfefbd5b1b0c07cce266ebe667ae2006c3c1dada0cdc3be87d6e6c35b0d692a409d9c7ec8b20d65ae29398d19b1114e7e3de4ce98b3f5e10dc0053cf0951b4506496e1b964bf7ce6c585d9054c62d01d617ca48be0596553cf496d8f2c8b01c5f795fc93904e85ec4c01a152857a5d9175d0b2805c872080f18595ccc1499a10a225d4e2fbc2877786fe81253ab6c04c8d106e09db5d43ab0d146e5c64d1a23938fb98a185cea1c33eecfd9eba49eb427dcb201e245365f2b7b2fb5b4a3a31dcb927178afe07d86901df870fefa4842aed6f6b74ba42e52b4014d580e1eb9cbd9d94de7e4aad16d2f9be02d805f0b5e532f927a1ffcacea1777f122a8105b164a7c25faf323a5d9f1f1fd600e1e5bec59e2d4b5c7ef5209d0ad17b8b31864e57c0b3e0815ac3ee33253ab664a770ff5185d1a1cb8d2267d3e58aa1dc7d2508cbe597d0e74fdd269aaaf0f52d414c4ea3e9762c996869e42560d7a72e41c4799a2586e74f95e8d8151481fa86efbe7b3398ac58b1a2b8527589f15451ad303ac2293542ad6648a796278f13a27185e4c4754310facb98c53a79e19a3fdc1426ff28c3d7399d1f7cb25343eb96106cf83c790ce9c4f2eb831855c55485663327992eb6dc8a6259874ed700b0b793323cccb9ffa842b30d6133e3e75fea989ac15a8b16ca76b746b0b92278d919774c5b6d48a78697fb29bbcf52468742a32120909c24e899ce67beed5be2db01e22d1e9485bb620e47f9ee9e606a21bd3f5d3744c7e7c54d55e87443867d8b554515ac5db4620e8e4f62263170fd1cdee90aad7640141992891b0f367c9adfe4049bb07d3b7022bd8c687c0978f46684ee084150b65ac1fcca94591b7a90a496e4c095164fb016a2b192a497795cc0f84817aebe25f7bf70ccc54a575c555c03f78ffa5fc0570d1f0c076bff0232285a0901e2257b0000000049454e44ae426082</data>
245 </image>
246</images>
247<layoutdefaults spacing="6" margin="11"/>
248<includehints>
249 <includehint>kdateedit.h</includehint>
250 <includehint>kdateedit.h</includehint>
251</includehints>
252</UI>
diff --git a/korganizer/calprinter.cpp b/korganizer/calprinter.cpp
new file mode 100644
index 0000000..6b5b0fe
--- a/dev/null
+++ b/korganizer/calprinter.cpp
@@ -0,0 +1,299 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qvbuttongroup.h>
25#include <qwidgetstack.h>
26#include <qradiobutton.h>
27#include <qlayout.h>
28#include <qpushbutton.h>
29#include <qcombobox.h>
30#include <qlabel.h>
31#include <qvbox.h>
32#include <qsplitter.h>
33
34#include <kprinter.h>
35#include <kglobal.h>
36#include <ksimpleconfig.h>
37#include <kmessagebox.h>
38#include <kdebug.h>
39//#include <kdeversion.h>
40
41#include "koprefsdialog.h"
42
43#include "calprinter.h"
44#ifndef KORG_NOPRINTER
45//#include "calprinter.moc"
46
47#include "calprintplugins.h"
48
49CalPrinter::CalPrinter( QWidget *parent, Calendar *calendar )
50 : QObject( parent, "CalPrinter" )
51{
52 mCalendar = calendar;
53 mParent = parent;
54 mPrinter = new KPrinter;
55 mPrinter->setOrientation( KPrinter::Portrait );
56 mConfig = new KConfig(locateLocal("config","korganizer_printing.rc" ));
57 //KSimpleConfig( "korganizer_printing.rc" );
58
59 init( mPrinter, calendar );
60}
61
62CalPrinter::~CalPrinter()
63{
64 kdDebug() << "~CalPrinter()" << endl;
65
66 CalPrintBase *plug = mPrintPlugins.first();
67 while ( plug ) {
68 plug->doSaveConfig();
69 plug = mPrintPlugins.next();
70 }
71 mConfig->sync();
72 delete mConfig;
73 delete mPrintDialog;
74 delete mPrinter;
75}
76
77void CalPrinter::init( KPrinter *printer, Calendar *calendar )
78{
79 mPrintPlugins.setAutoDelete( true );
80 mPrintPlugins.append( new CalPrintDay( printer, calendar, mConfig ) );
81 mPrintPlugins.append( new CalPrintWeek( printer, calendar, mConfig ) );
82 mPrintPlugins.append( new CalPrintMonth( printer, calendar, mConfig ) );
83 mPrintPlugins.append( new CalPrintTodos( printer, calendar, mConfig ) );
84
85 // TODO_RK: Add a plugin interface here
86 mPrintDialog = new CalPrintDialog( mPrintPlugins, mPrinter, mParent );
87
88 CalPrintBase *plug = mPrintPlugins.first();
89 while ( plug ) {
90 connect( mPrintDialog, SIGNAL( okClicked() ),
91 plug, SLOT( readSettingsWidget() ) );
92
93 plug->doLoadConfig();
94
95 plug = mPrintPlugins.next();
96 }
97}
98
99void CalPrinter::setupPrinter()
100{
101 KMessageBox::sorry( mParent, i18n("Not implemented.") );
102#if 0
103 KOPrefsDialog *optionsDlg = new KOPrefsDialog(mParent);
104 optionsDlg->readConfig();
105 optionsDlg->showPrinterTab();
106 connect(optionsDlg, SIGNAL(configChanged()),
107 mParent, SLOT(updateConfig()));
108 optionsDlg->show();
109#endif
110}
111
112void CalPrinter::setDateRange( const QDate &fd, const QDate &td )
113{
114 CalPrintBase *plug = mPrintPlugins.first();
115 while ( plug ) {
116 plug->setDateRange( fd, td );
117 plug = mPrintPlugins.next();
118 }
119}
120
121void CalPrinter::preview( PrintType type, const QDate &fd, const QDate &td )
122{
123 mPrintDialog->setPreview( true );
124 mPrintDialog->setPrintType( int( type ) );
125 setDateRange( fd, td );
126
127 if ( mPrintDialog->exec() == QDialog::Accepted ) {
128 doPrint( mPrintDialog->selectedPlugin(), true );
129 }
130}
131
132void CalPrinter::print( PrintType type, const QDate &fd, const QDate &td )
133{
134 mPrintDialog->resize( 640, 380 );
135 mPrintDialog->setPreview( false );
136 mPrintDialog->setPrintType( int( type ) );
137 setDateRange( fd, td );
138
139 if ( mPrintDialog->exec() == QDialog::Accepted ) {
140 doPrint( mPrintDialog->selectedPlugin(), false );
141 }
142}
143
144void CalPrinter::doPrint( CalPrintBase *selectedStyle, bool preview )
145{
146 // FIXME: add a better caption to the Printingdialog
147 //mPrinter->setPreviewOnly( preview );
148 if ( preview || mPrinter->setup( mParent ) ) {
149 switch ( mPrintDialog->orientation() ) {
150 case eOrientPlugin:
151 mPrinter->setOrientation( selectedStyle->orientation());
152 break;
153 case eOrientPortrait:
154 mPrinter->setOrientation( KPrinter::Portrait );
155 break;
156 case eOrientLandscape:
157 mPrinter->setOrientation( KPrinter::Landscape );
158 break;
159 case eOrientPrinter:
160 default:
161 break;
162 }
163 selectedStyle->doPrint();
164 }
165 //mPrinter->setPreviewOnly( false );
166}
167
168///////////////////////////////////////////////////////////////////////////////
169
170void CalPrinter::updateConfig()
171{
172}
173
174
175/****************************************************************************/
176
177CalPrintDialog::CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p,
178 QWidget *parent, const char *name )
179 : KDialogBase( parent, name, /*modal*/true, i18n("Print"), Ok | Cancel ),
180 mPrinter( p ), mPrintPlugins( plugins )
181{
182 QVBox *page = new QVBox(this);//makeVBoxMainWidget();
183 setMainWidget( page );
184 QHBox *printerLayout = new QHBox( page );
185
186 mPrinterLabel = new QLabel( printerLayout );
187 QPushButton *setupButton = new QPushButton( i18n("&Setup Printer..."),
188 printerLayout );
189 setupButton->setSizePolicy( QSizePolicy(
190 (QSizePolicy::SizeType)4, (QSizePolicy::SizeType)0,
191 0, 0, setupButton->sizePolicy().hasHeightForWidth() ) );
192
193 QSplitter *splitter = new QSplitter( page );
194 splitter->setOrientation( QSplitter::Horizontal );
195
196 mTypeGroup = new QVButtonGroup( i18n("View Type"), splitter, "buttonGroup" );
197 // use the minimal width possible = max width of the radio buttons, not extensible
198/* mTypeGroup->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)4,
199 (QSizePolicy::SizeType)5, 0, 0,
200 mTypeGroup->sizePolicy().hasHeightForWidth() ) );*/
201
202 QWidget *splitterRight = new QWidget( splitter, "splitterRight" );
203 QGridLayout *splitterRightLayout = new QGridLayout( splitterRight );
204 splitterRightLayout->setMargin( marginHint() );
205 splitterRightLayout->setSpacing( spacingHint() );
206
207 mConfigArea = new QWidgetStack( splitterRight, "configWidgetStack" );
208 splitterRightLayout->addMultiCellWidget( mConfigArea, 0,0, 0,1 );
209
210 QLabel *orientationLabel = new QLabel( i18n("Page &orientation:"),
211 splitterRight, "orientationLabel" );
212 splitterRightLayout->addWidget( orientationLabel, 1, 0 );
213
214 mOrientationSelection = new QComboBox( splitterRight, "orientationCombo" );
215 mOrientationSelection->insertItem( i18n("Use Default of Selected Style") );
216 mOrientationSelection->insertItem( i18n("Use Default Setting of Printer") );
217 mOrientationSelection->insertItem( i18n("Portrait") );
218 mOrientationSelection->insertItem( i18n("Landscape") );
219 splitterRightLayout->addWidget( mOrientationSelection, 1, 1 );
220
221 // signals and slots connections
222 connect( setupButton, SIGNAL( clicked() ), SLOT( setupPrinter() ) );
223 connect( mTypeGroup, SIGNAL( clicked( int ) ), SLOT( setPrintType( int ) ) );
224
225 // buddies
226 orientationLabel->setBuddy( mOrientationSelection );
227
228 CalPrintBase *plug = mPrintPlugins.first();
229 QRadioButton *radioButton;
230 int id = 0;
231 while ( plug ) {
232 radioButton = new QRadioButton( plug->description(), mTypeGroup );
233 mTypeGroup->insert( radioButton, id );
234 //radioButton->setMinimumHeight( radioButton->sizeHint().height() - 5 );
235
236 mConfigArea->addWidget( plug->configWidget( mConfigArea ), id );
237
238 plug = mPrintPlugins.next();
239 id++;
240 }
241
242 // setMinimumSize( minimumSizeHint() );
243 //resize( minimumSizeHint() );
244}
245
246CalPrintDialog::~CalPrintDialog()
247{
248}
249
250void CalPrintDialog::setupPrinter()
251{
252 if ( mPrinter->setup( this ) ) {
253 setPrinterLabel();
254 }
255}
256
257void CalPrintDialog::setPreview(bool preview)
258{
259
260 setButtonText(KDialogBase::Ok, preview ? i18n("&Preview") : i18n("&Print...") );
261
262 mPreviewText = preview ? i18n("<qt>Preview for printer <b>%1</b></qt>")
263 : i18n( "<qt>Printing on printer <b>%1</b></qt>");
264 setPrinterLabel();
265}
266
267void CalPrintDialog::setPrinterLabel()
268{
269 QString printerName( mPrinter->printerName() );
270 if ( printerName.isEmpty() )
271 mPrinterLabel->setText( mPreviewText.arg( i18n("[Unconfigured]") ) );
272 else
273 mPrinterLabel->setText( mPreviewText.arg( printerName ) );
274}
275
276void CalPrintDialog::setPrintType( int i )
277{
278 // TODO: Make a safe correlation between type and the radio button
279
280 mTypeGroup->setButton( i );
281 mConfigArea->raiseWidget( i );
282}
283
284CalPrintBase *CalPrintDialog::selectedPlugin()
285{
286 int pos = mTypeGroup->id( mTypeGroup->selected() );
287 if ( pos < 0 ) return 0;
288 CalPrintBase *retval = mPrintPlugins.at( pos );
289 return retval;
290}
291
292void CalPrintDialog::slotOk()
293{
294 mOrientation = (CalPrinter::ePrintOrientation)mOrientationSelection->currentItem();
295 KDialogBase::slotOk();
296 emit okClicked();
297}
298
299#endif
diff --git a/korganizer/calprinter.h b/korganizer/calprinter.h
new file mode 100644
index 0000000..7b58f4f
--- a/dev/null
+++ b/korganizer/calprinter.h
@@ -0,0 +1,142 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 1998 Preston Brown
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef _CALPRINTER_H
25#define _CALPRINTER_H
26
27// #define KORG_NOPRINTER
28
29#ifndef KORG_NOPRINTER
30
31#include <qptrlist.h>
32
33#include <kdialogbase.h>
34
35#include <korganizer/baseview.h>
36
37#include "calprintbase.h"
38
39using namespace KCal;
40
41class QVButtonGroup;
42class QWidgetStack;
43class KPrinter;
44class CalPrintDialog;
45class KConfig;
46class QComboBox;
47class QLabel;
48
49
50/**
51 CalPrinter is a class for printing Calendars. It can print in several
52 different formats (day, week, month). It also provides a way for setting
53 up the printer and remembering these preferences.
54*/
55class CalPrinter : public QObject, public KOrg::CalPrinterBase
56{
57 Q_OBJECT
58
59 public:
60 enum ePrintOrientation {
61 eOrientPlugin=0,
62 eOrientPrinter,
63 eOrientPortrait,
64 eOrientLandscape
65 };
66 public:
67 /**
68 \param par parent widget for dialogs
69 \param cal calendar to be printed
70 */
71 CalPrinter( QWidget *par, Calendar *cal );
72 virtual ~CalPrinter();
73
74 void init( KPrinter *printer, Calendar *calendar );
75
76 void setupPrinter();
77
78 /**
79 Set date range to be printed.
80
81 \param start Start date
82 \param end End date
83 */
84 void setDateRange( const QDate &start, const QDate &end );
85
86 public slots:
87 void updateConfig();
88
89 private slots:
90 void doPrint( CalPrintBase *selectedStyle, bool preview );
91
92 public:
93 void preview( PrintType type, const QDate &fd, const QDate &td );
94 void print( PrintType type, const QDate &fd, const QDate &td );
95
96 protected:
97 QPtrList<CalPrintBase> mPrintPlugins;
98
99 private:
100 KPrinter *mPrinter;
101 Calendar *mCalendar;
102 QWidget *mParent;
103 KConfig *mConfig;
104
105 CalPrintDialog *mPrintDialog;
106};
107
108class CalPrintDialog : public KDialogBase
109{
110 Q_OBJECT
111 public:
112 CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p,
113 QWidget *parent = 0, const char *name = 0 );
114 virtual ~CalPrintDialog();
115 CalPrintBase *selectedPlugin();
116 CalPrinter::ePrintOrientation orientation() { return mOrientation; }
117
118 public slots:
119 void setPrintType( int );
120 void setPreview( bool );
121
122 protected slots:
123 void slotOk();
124 void setupPrinter();
125 void setPrinterLabel();
126signals:
127 void okClicked();
128 private:
129 KPrinter *mPrinter;
130 QVButtonGroup *mTypeGroup;
131 QWidgetStack *mConfigArea;
132 QPtrList<CalPrintBase> mPrintPlugins;
133 QLabel *mPrinterLabel;
134 QString mPreviewText;
135 QComboBox *mOrientationSelection;
136
137 CalPrinter::ePrintOrientation mOrientation;
138};
139
140#endif
141
142#endif
diff --git a/korganizer/calprinter.moc b/korganizer/calprinter.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/calprinter.moc
diff --git a/korganizer/calprintmonthconfig_base.ui b/korganizer/calprintmonthconfig_base.ui
new file mode 100644
index 0000000..734a559
--- a/dev/null
+++ b/korganizer/calprintmonthconfig_base.ui
@@ -0,0 +1,172 @@
1<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
2<class>CalPrintMonthConfig_Base</class>
3<comment>Configuration page for the print day mode.</comment>
4<author>Reinhold Kainhofer &lt;reinhold@kainhofer.com&gt;</author>
5<widget class="QWidget">
6 <property name="name">
7 <cstring>CalPrintMonth_Base</cstring>
8 </property>
9 <property name="geometry">
10 <rect>
11 <x>0</x>
12 <y>0</y>
13 <width>357</width>
14 <height>112</height>
15 </rect>
16 </property>
17 <property name="caption">
18 <string>CalPrintMonth_Base</string>
19 </property>
20 <grid>
21 <property name="name">
22 <cstring>unnamed</cstring>
23 </property>
24 <property name="margin">
25 <number>0</number>
26 </property>
27 <spacer row="4" column="0">
28 <property name="name">
29 <cstring>spacer2</cstring>
30 </property>
31 <property name="orientation">
32 <enum>Vertical</enum>
33 </property>
34 <property name="sizeType">
35 <enum>Expanding</enum>
36 </property>
37 <property name="sizeHint">
38 <size>
39 <width>21</width>
40 <height>20</height>
41 </size>
42 </property>
43 </spacer>
44 <widget class="QGroupBox" row="0" column="0">
45 <property name="name">
46 <cstring>mDateRangeGroup</cstring>
47 </property>
48 <property name="title">
49 <string>Date &amp;&amp; Time Range</string>
50 </property>
51 <hbox>
52 <property name="name">
53 <cstring>unnamed</cstring>
54 </property>
55 <widget class="QLabel">
56 <property name="name">
57 <cstring>mFromDateLabel</cstring>
58 </property>
59 <property name="text">
60 <string>&amp;Start month:</string>
61 </property>
62 <property name="buddy" stdset="0">
63 <cstring>mFromDate</cstring>
64 </property>
65 </widget>
66 <widget class="KDateEdit">
67 <property name="name">
68 <cstring>mFromDate</cstring>
69 </property>
70 <property name="sizePolicy">
71 <sizepolicy>
72 <hsizetype>5</hsizetype>
73 <vsizetype>5</vsizetype>
74 <horstretch>3</horstretch>
75 <verstretch>0</verstretch>
76 </sizepolicy>
77 </property>
78 <property name="minimumSize">
79 <size>
80 <width>50</width>
81 <height>0</height>
82 </size>
83 </property>
84 <property name="focusPolicy">
85 <enum>StrongFocus</enum>
86 </property>
87 </widget>
88 <widget class="QLabel">
89 <property name="name">
90 <cstring>mToDateLabel</cstring>
91 </property>
92 <property name="text">
93 <string>&amp;End month:</string>
94 </property>
95 <property name="buddy" stdset="0">
96 <cstring>mToDate</cstring>
97 </property>
98 </widget>
99 <widget class="KDateEdit">
100 <property name="name">
101 <cstring>mToDate</cstring>
102 </property>
103 <property name="sizePolicy">
104 <sizepolicy>
105 <hsizetype>5</hsizetype>
106 <vsizetype>5</vsizetype>
107 <horstretch>3</horstretch>
108 <verstretch>0</verstretch>
109 </sizepolicy>
110 </property>
111 <property name="minimumSize">
112 <size>
113 <width>50</width>
114 <height>0</height>
115 </size>
116 </property>
117 <property name="focusPolicy">
118 <enum>StrongFocus</enum>
119 </property>
120 </widget>
121 </hbox>
122 </widget>
123 <widget class="QCheckBox" row="2" column="0">
124 <property name="name">
125 <cstring>mIncludeTodos</cstring>
126 </property>
127 <property name="enabled">
128 <bool>false</bool>
129 </property>
130 <property name="text">
131 <string>Include to&amp;dos that are due on the printed day(s)</string>
132 </property>
133 </widget>
134 <widget class="QCheckBox" row="1" column="0">
135 <property name="name">
136 <cstring>mWeekNumbers</cstring>
137 </property>
138 <property name="text">
139 <string>Print week &amp;numbers</string>
140 </property>
141 </widget>
142 </grid>
143</widget>
144<customwidgets>
145 <customwidget>
146 <class>KDateEdit</class>
147 <header location="local">libkdepim/kdateedit.h</header>
148 <sizehint>
149 <width>-1</width>
150 <height>-1</height>
151 </sizehint>
152 <container>0</container>
153 <sizepolicy>
154 <hordata>5</hordata>
155 <verdata>5</verdata>
156 <horstretch>0</horstretch>
157 <verstretch>0</verstretch>
158 </sizepolicy>
159 <pixmap>image0</pixmap>
160 </customwidget>
161</customwidgets>
162<images>
163 <image name="image0">
164 <data format="PNG" length="826">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000030149444154789cb59531681b5718c77f0e377c070e3c810a3a70e0041eac51852e0a19e45134830a1d9a4c69a04bc8928e990a693a640e1d0c8642b08742321894c1507991b484c890902bb8701a047760c3bd21701fe4201dde49b6a41a32b8df72dcbbeffdbefffbbfefbd5b1b0c07cce266ebe667ae2006c3c1dada0cdc3be87d6e6c35b0d692a409d9c7ec8b20d65ae29398d19b1114e7e3de4ce98b3f5e10dc0053cf0951b4506496e1b964bf7ce6c585d9054c62d01d617ca48be0596553cf496d8f2c8b01c5f795fc93904e85ec4c01a152857a5d9175d0b2805c872080f18595ccc1499a10a225d4e2fbc2877786fe81253ab6c04c8d106e09db5d43ab0d146e5c64d1a23938fb98a185cea1c33eecfd9eba49eb427dcb201e245365f2b7b2fb5b4a3a31dcb927178afe07d86901df870fefa4842aed6f6b74ba42e52b4014d580e1eb9cbd9d94de7e4aad16d2f9be02d805f0b5e532f927a1ffcacea1777f122a8105b164a7c25faf323a5d9f1f1fd600e1e5bec59e2d4b5c7ef5209d0ad17b8b31864e57c0b3e0815ac3ee33253ab664a770ff5185d1a1cb8d2267d3e58aa1dc7d2508cbe597d0e74fdd269aaaf0f52d414c4ea3e9762c996869e42560d7a72e41c4799a2586e74f95e8d8151481fa86efbe7b3398ac58b1a2b8527589f15451ad303ac2293542ad6648a796278f13a27185e4c4754310facb98c53a79e19a3fdc1426ff28c3d7399d1f7cb25343eb96106cf83c790ce9c4f2eb831855c55485663327992eb6dc8a6259874ed700b0b793323cccb9ffa842b30d6133e3e75fea989ac15a8b16ca76b746b0b92278d919774c5b6d48a78697fb29bbcf52468742a32120909c24e899ce67beed5be2db01e22d1e9485bb620e47f9ee9e606a21bd3f5d3744c7e7c54d55e87443867d8b554515ac5db4620e8e4f62263170fd1cdee90aad7640141992891b0f367c9adfe4049bb07d3b7022bd8c687c0978f46684ee084150b65ac1fcca94591b7a90a496e4c095164fb016a2b192a497795cc0f84817aebe25f7bf70ccc54a575c555c03f78ffa5fc0570d1f0c076bff0232285a0901e2257b0000000049454e44ae426082</data>
165 </image>
166</images>
167<layoutdefaults spacing="6" margin="11"/>
168<includehints>
169 <includehint>kdateedit.h</includehint>
170 <includehint>kdateedit.h</includehint>
171</includehints>
172</UI>
diff --git a/korganizer/calprintplugins.cpp b/korganizer/calprintplugins.cpp
new file mode 100644
index 0000000..bc35ca4
--- a/dev/null
+++ b/korganizer/calprintplugins.cpp
@@ -0,0 +1,669 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
25*/
26
27#include <qpainter.h>
28#include <qdatetimeedit.h>
29#include <qdatetime.h>
30#include <qcheckbox.h>
31#include <qlineedit.h>
32#include <qbuttongroup.h>
33
34#include <kglobal.h>
35#include <klocale.h>
36#include <kdebug.h>
37#include <kprinter.h>
38#include <kconfig.h>
39#include <kcalendarsystem.h>
40
41#include <libkcal/todo.h>
42#include <libkcal/calendar.h>
43
44#include <libkdepim/kdateedit.h>
45
46#include "koprefs.h"
47#include "koglobals.h"
48#include "calprintplugins.h"
49#ifndef KORG_NOPRINTER
50
51//#include "calprintplugins.moc"
52
53#define LEFT_DISTANCE 45
54
55/**************************************************************
56 * Print Day
57 **************************************************************/
58
59CalPrintDay::CalPrintDay( KPrinter *printer, Calendar *cal, KConfig *cfg )
60 : CalPrintBase( printer, cal, cfg )
61{
62}
63
64CalPrintDay::~CalPrintDay()
65{
66}
67
68QWidget *CalPrintDay::configWidget( QWidget *w )
69{
70 mConfigWidget = new CalPrintDayConfig_Base( w );
71 setSettingsWidget();
72 return mConfigWidget;
73}
74
75void CalPrintDay::readSettingsWidget()
76{
77 CalPrintDayConfig_Base *cfg = mConfigWidget;
78 if ( cfg ) {
79 mFromDate = cfg->mFromDate->date();
80 mToDate = cfg->mToDate->date();
81
82 mStartTime = cfg->mFromTime->time();
83 mEndTime = cfg->mToTime->time();
84 mIncludeAllEvents = cfg->mIncludeAllEvents->isChecked();
85
86 mIncludeTodos = cfg->mIncludeTodos->isChecked();
87 mUseColors = cfg->mColors->isChecked();
88 }
89}
90
91void CalPrintDay::setSettingsWidget()
92{
93 CalPrintDayConfig_Base *cfg =( mConfigWidget );
94 if ( cfg ) {
95 cfg->mFromDate->setDate( mFromDate );
96 cfg->mToDate->setDate( mToDate );
97
98 cfg->mFromTime->setTime( mStartTime );
99 cfg->mToTime->setTime( mEndTime );
100 cfg->mIncludeAllEvents->setChecked( mIncludeAllEvents );
101
102 cfg->mIncludeTodos->setChecked( mIncludeTodos );
103 cfg->mColors->setChecked( mUseColors );
104 }
105}
106
107void CalPrintDay::loadConfig()
108{
109 if ( mConfig ) {
110 QDate dt;
111 QTime tm1 = QTime( KOPrefs::instance()->mDayBegins, 0,0 );
112 QDateTime startTm( dt, tm1 );
113 QDateTime endTm( dt, tm1.addSecs( 12 * 60 * 60 ) );
114 mStartTime = mConfig->readDateTimeEntry( "Start time", &startTm ).time();
115 mEndTime = mConfig->readDateTimeEntry( "End time", &endTm ).time();
116 mIncludeTodos = mConfig->readBoolEntry( "Include todos", false );
117 mIncludeAllEvents = mConfig->readBoolEntry( "Include all events", false );
118 }
119 setSettingsWidget();
120}
121
122void CalPrintDay::saveConfig()
123{
124 readSettingsWidget();
125 if ( mConfig ) {
126 mConfig->writeEntry( "Start time", QDateTime( QDate(), mStartTime ) );
127 mConfig->writeEntry( "End time", QDateTime( QDate(), mEndTime ) );
128 mConfig->writeEntry( "Include todos", mIncludeTodos );
129 mConfig->writeEntry( "Include all events", mIncludeAllEvents );
130 }
131}
132
133void CalPrintDay::setDateRange( const QDate& from, const QDate& to )
134{
135 CalPrintBase::setDateRange( from, to );
136 CalPrintDayConfig_Base *cfg = mConfigWidget ;
137 if ( cfg ) {
138 cfg->mFromDate->setDate( from );
139 cfg->mToDate->setDate( to );
140 }
141}
142
143void CalPrintDay::print( QPainter &p, int width, int height )
144{
145 QDate curDay( mFromDate );
146 int yoffset = 0, xoffset = 0;
147 if ( width > height ) {
148 yoffset += LEFT_DISTANCE;
149 } else {
150 xoffset += LEFT_DISTANCE;
151 }
152 width -= xoffset;
153 height -= yoffset;
154 do {
155 int x = 0;
156 int y = 0;
157
158
159 int currHeight=( height - y ) / 20;
160 QTime curStartTime( mStartTime );
161 QTime curEndTime( mEndTime );
162 if ( curStartTime.secsTo( curEndTime ) <= 3600 ) {
163 if ( curStartTime.hour() == 0 ) {
164 curStartTime = QTime( 0, 0, 0 );
165 curEndTime = curStartTime.addSecs( 3600 );
166 } else if ( curEndTime.hour() == 23 ) {
167 curEndTime=QTime( 23, 59, 59 );
168 if ( curStartTime > QTime( 23, 0, 0 ) ) {
169 curStartTime = QTime( 23, 0, 0 );
170 }
171 } else {
172 curStartTime = curStartTime.addSecs( -1200 );
173 }
174 curEndTime = curEndTime.addSecs( 1200 );
175 }
176
177 KLocale *local = KGlobal::locale();
178 drawHeader( p, local->formatDate( curDay, false ),
179 curDay, QDate(), xoffset, yoffset, width, mHeaderHeight );
180
181 y += mHeaderHeight + 5;
182 x = 80;
183 Event::List eventList; eventList.fill( mCalendar->events( curDay, true ));
184
185 p.setFont( QFont( "helvetica", 10 ) );
186 currHeight = p.fontMetrics().lineSpacing()*3/2;
187 drawAllDayBox( p, eventList, curDay, true, x+xoffset, y+yoffset, width - x, currHeight );
188 y += currHeight;
189 drawAgendaDayBox( p, eventList, curDay, mIncludeAllEvents,
190 curStartTime, curEndTime, x+xoffset, y+yoffset, width - x, height - y );
191 drawTimeLine( p, curStartTime, curEndTime, xoffset, y+yoffset, x - 5, height - y );
192 curDay = curDay.addDays( 1 );
193 if ( curDay <= mToDate ) mPrinter->newPage();
194 } while ( curDay <= mToDate );
195}
196
197
198
199/**************************************************************
200 * Print Week
201 **************************************************************/
202
203CalPrintWeek::CalPrintWeek(KPrinter *printer, Calendar *cal, KConfig *cfg)
204 :CalPrintBase(printer,cal,cfg)
205{
206}
207
208CalPrintWeek::~CalPrintWeek()
209{
210}
211
212QWidget *CalPrintWeek::configWidget( QWidget *w )
213{
214 mConfigWidget = new CalPrintWeekConfig_Base( w );
215 setSettingsWidget();
216 return mConfigWidget;
217}
218
219void CalPrintWeek::readSettingsWidget()
220{
221 CalPrintWeekConfig_Base *cfg =( mConfigWidget );
222 if ( cfg ) {
223 mFromDate = cfg->mFromDate->date();
224 mToDate = cfg->mToDate->date();
225
226 mWeekPrintType = (eWeekPrintType)( cfg->mPrintType->id(
227 cfg->mPrintType->selected() ) );
228
229 mStartTime = cfg->mFromTime->time();
230 mEndTime = cfg->mToTime->time();
231
232 mIncludeTodos = cfg->mIncludeTodos->isChecked();
233 mUseColors = cfg->mColors->isChecked();
234 }
235}
236
237void CalPrintWeek::setSettingsWidget()
238{
239 CalPrintWeekConfig_Base *cfg =( mConfigWidget );
240 if ( cfg ) {
241 cfg->mFromDate->setDate( mFromDate );
242 cfg->mToDate->setDate( mToDate );
243
244 cfg->mPrintType->setButton( mWeekPrintType );
245
246 cfg->mFromTime->setTime( mStartTime );
247 cfg->mToTime->setTime( mEndTime );
248
249 cfg->mIncludeTodos->setChecked( mIncludeTodos );
250 cfg->mColors->setChecked( mUseColors );
251 }
252}
253
254void CalPrintWeek::loadConfig()
255{
256 if ( mConfig ) {
257 QDate dt;
258 QTime tm1 = QTime( KOPrefs::instance()->mDayBegins, 0,0);
259 QDateTime startTm( dt, tm1 );
260 QDateTime endTm( dt, tm1.addSecs( 43200 ) );
261 mStartTime = mConfig->readDateTimeEntry( "Start time", &startTm ).time();
262 mEndTime = mConfig->readDateTimeEntry( "End time", &endTm ).time();
263 mIncludeTodos = mConfig->readBoolEntry( "Include todos", false );
264 mWeekPrintType =(eWeekPrintType)( mConfig->readNumEntry( "Print type", (int)Filofax ) );
265 }
266 setSettingsWidget();
267}
268
269void CalPrintWeek::saveConfig()
270{
271 readSettingsWidget();
272 if ( mConfig ) {
273 mConfig->writeEntry( "Start time", QDateTime( QDate(), mStartTime ) );
274 mConfig->writeEntry( "End time", QDateTime( QDate(), mEndTime ) );
275 mConfig->writeEntry( "Include todos", mIncludeTodos );
276 mConfig->writeEntry( "Print type", int( mWeekPrintType ) );
277 }
278}
279
280KPrinter::Orientation CalPrintWeek::orientation()
281{
282 if ( mWeekPrintType == Filofax || mWeekPrintType == SplitWeek ) return KPrinter::Portrait;
283 else return KPrinter::Landscape;
284}
285
286void CalPrintWeek::setDateRange( const QDate &from, const QDate &to )
287{
288 CalPrintBase::setDateRange( from, to );
289 CalPrintWeekConfig_Base *cfg =( mConfigWidget );
290 if ( cfg ) {
291 cfg->mFromDate->setDate( from );
292 cfg->mToDate->setDate( to );
293 }
294}
295
296void CalPrintWeek::print( QPainter &p, int width, int height )
297{
298 QDate curWeek, fromWeek, toWeek;
299 int yoffset = 0, xoffset = 0;
300 //width = height -1;//test only
301 if ( width > height ) {
302 yoffset += LEFT_DISTANCE;
303 } else {
304 xoffset += LEFT_DISTANCE;
305 }
306 width -= xoffset;
307 height -= yoffset;
308 // correct begin and end to first and last day of week
309 int weekdayCol = weekdayColumn( mFromDate.dayOfWeek() );
310 fromWeek = mFromDate.addDays( -weekdayCol );
311 weekdayCol = weekdayColumn( mFromDate.dayOfWeek() );
312 toWeek = mToDate.addDays( 6 - weekdayCol );
313
314 curWeek = fromWeek.addDays( 6 );
315 KLocale *local = KGlobal::locale();
316
317 switch ( mWeekPrintType ) {
318 case Filofax:
319 do {
320 QString line1( local->formatDate( curWeek.addDays( -6 ) ) );
321 QString line2( local->formatDate( curWeek ) );
322 drawHeader( p, line1 + "\n" + line2, curWeek.addDays( -6 ), QDate(),
323 0+xoffset, 0+yoffset, width, mHeaderHeight );
324 int top = mHeaderHeight + 10;
325 drawWeek( p, curWeek, 0+xoffset, top+yoffset, width, height - top );
326 curWeek = curWeek.addDays( 7 );
327 if ( curWeek <= toWeek )
328 mPrinter->newPage();
329 } while ( curWeek <= toWeek );
330 break;
331
332 case Timetable:
333 default:
334 do {
335 QString line1( local->formatDate( curWeek.addDays( -6 ) ) );
336 QString line2( local->formatDate( curWeek ) );
337 //int hh = int(mHeaderHeight * 2./3.);
338 int hh = mHeaderHeight;
339 if ( yoffset )
340 drawHeader( p, i18n("date from - to", "%1 - %2").arg( line1 ).arg( line2 ),
341 curWeek, QDate(), 0+xoffset, 0+yoffset, width, hh );
342 else
343 drawHeader( p, i18n("date from - to", "%1 -\n%2").arg( line1 ).arg( line2 ),
344 curWeek, QDate(), 0+xoffset, 0+yoffset, width, hh );
345 drawTimeTable( p, fromWeek, curWeek,
346 mStartTime, mEndTime, 0+xoffset, hh + 5+yoffset,
347 width, height - hh - 5 );
348 fromWeek = fromWeek.addDays( 7 );
349 curWeek = fromWeek.addDays( 6 );
350 if ( curWeek <= toWeek )
351 mPrinter->newPage();
352 } while ( curWeek <= toWeek );
353 break;
354
355 case SplitWeek:
356 drawSplitWeek( p, fromWeek, toWeek );
357 break;
358 }
359}
360
361
362
363
364/**************************************************************
365 * Print Month
366 **************************************************************/
367
368CalPrintMonth::CalPrintMonth( KPrinter *printer, Calendar *cal, KConfig *cfg )
369 : CalPrintBase( printer, cal, cfg )
370{
371}
372
373CalPrintMonth::~CalPrintMonth()
374{
375}
376
377QWidget *CalPrintMonth::configWidget( QWidget *w )
378{
379 mConfigWidget = new CalPrintMonthConfig_Base( w );
380 return mConfigWidget;
381}
382
383void CalPrintMonth::readSettingsWidget()
384{
385 CalPrintMonthConfig_Base *cfg =( mConfigWidget );
386 if ( cfg ) {
387 mFromDate = cfg->mFromDate->date();
388 mToDate = cfg->mToDate->date();
389
390 mWeekNumbers = cfg->mWeekNumbers->isChecked();
391
392 mIncludeTodos = cfg->mIncludeTodos->isChecked();
393// mUseColors = cfg->mColors->isChecked();
394 }
395}
396
397void CalPrintMonth::setSettingsWidget()
398{
399 CalPrintMonthConfig_Base *cfg =( mConfigWidget );
400 if ( cfg ) {
401 cfg->mFromDate->setDate( mFromDate );
402 cfg->mToDate->setDate( mToDate );
403
404 cfg->mWeekNumbers->setChecked( mWeekNumbers );
405
406 cfg->mIncludeTodos->setChecked( mIncludeTodos );
407// cfg->mColors->setChecked( mUseColors );
408 }
409}
410
411void CalPrintMonth::loadConfig()
412{
413 if ( mConfig ) {
414 mWeekNumbers = mConfig->readBoolEntry( "Print week numbers", true );
415 mIncludeTodos = mConfig->readBoolEntry( "Include todos", false );
416 }
417 setSettingsWidget();
418}
419
420void CalPrintMonth::saveConfig()
421{
422 readSettingsWidget();
423 if ( mConfig ) {
424 mConfig->writeEntry( "Print week numbers", mWeekNumbers );
425 mConfig->writeEntry( "Include todos", mIncludeTodos );
426 }
427}
428
429void CalPrintMonth::setDateRange( const QDate &from, const QDate &to )
430{
431 CalPrintBase::setDateRange( from, to );
432 CalPrintMonthConfig_Base *cfg =( mConfigWidget );
433 if ( cfg ) {
434 cfg->mFromDate->setDate( from );
435 cfg->mToDate->setDate( to );
436 }
437}
438
439void CalPrintMonth::print( QPainter &p, int width, int height )
440{
441 QDate curMonth, fromMonth, toMonth;
442 /*
443 if ( width > height ) {
444 // for debug only
445 int te = height;
446 height = width;
447 width = te;
448 }
449 */
450 int yoffset = 0, xoffset = 0;
451 if ( width > height ) {
452 yoffset += LEFT_DISTANCE;
453 } else {
454 xoffset += LEFT_DISTANCE;
455 }
456 width -= xoffset;
457 height -= yoffset;
458 fromMonth = mFromDate.addDays( -( mFromDate.day() - 1 ) );
459 toMonth = mToDate.addDays( mToDate.daysInMonth() - mToDate.day() );
460
461 curMonth = fromMonth;
462 do {
463 QString title( i18n("monthname year", "%1 %2") );
464 title = title.arg( KOGlobals::self()->calendarSystem()->monthName( curMonth ) )
465 .arg( curMonth.year() );
466 QDate tmp( fromMonth );
467 int weekdayCol = weekdayColumn( tmp.dayOfWeek() );
468 tmp = tmp.addDays( -weekdayCol );
469
470 drawHeader( p, title,
471 curMonth.addMonths( -1 ), curMonth.addMonths( 1 ),
472 xoffset, yoffset, width, mHeaderHeight );
473 drawMonth( p, curMonth, mWeekNumbers, xoffset, mHeaderHeight + 5+yoffset,
474 width, height - mHeaderHeight - 5 );
475 curMonth = curMonth.addDays( curMonth.daysInMonth() );
476 if ( curMonth <= toMonth ) mPrinter->newPage();
477 } while ( curMonth <= toMonth );
478
479}
480
481
482
483
484/**************************************************************
485 * Print Todos
486 **************************************************************/
487
488CalPrintTodos::CalPrintTodos( KPrinter *printer, Calendar *cal, KConfig *cfg )
489 : CalPrintBase( printer, cal, cfg )
490{
491}
492
493CalPrintTodos::~CalPrintTodos()
494{
495}
496
497QWidget *CalPrintTodos::configWidget( QWidget *w )
498{
499 mConfigWidget = new CalPrintTodoConfig_Base( w );
500 return mConfigWidget;
501}
502
503void CalPrintTodos::readSettingsWidget()
504{
505 CalPrintTodoConfig_Base *cfg =( mConfigWidget );
506 if ( cfg ) {
507 mPageTitle = cfg->mTitle->text();
508
509 mTodoPrintType = (eTodoPrintType)( cfg->mPrintType->id(
510 cfg->mPrintType->selected() ) );
511
512 mFromDate = cfg->mFromDate->date();
513 mToDate = cfg->mToDate->date();
514
515 mIncludeDescription = cfg->mDescription->isChecked();
516 mIncludePriority = cfg->mPriority->isChecked();
517 mIncludeDueDate = cfg->mDueDate->isChecked();
518 mConnectSubTodos = cfg->mConnectSubTodos->isChecked();
519 }
520}
521
522void CalPrintTodos::setSettingsWidget()
523{
524 CalPrintTodoConfig_Base *cfg =( mConfigWidget );
525 if ( cfg ) {
526 cfg->mTitle->setText( mPageTitle );
527
528 cfg->mPrintType->setButton( mTodoPrintType );
529
530 cfg->mFromDate->setDate( mFromDate );
531 cfg->mToDate->setDate( mToDate );
532
533 cfg->mDescription->setChecked( mIncludeDescription );
534 cfg->mPriority->setChecked( mIncludePriority );
535 cfg->mDueDate->setChecked( mIncludeDueDate );
536 cfg->mConnectSubTodos->setChecked( mConnectSubTodos );
537 }
538}
539
540void CalPrintTodos::loadConfig()
541{
542 if ( mConfig ) {
543 mPageTitle = mConfig->readEntry( "Page title", i18n("Todo list") );
544 mTodoPrintType = (eTodoPrintType)mConfig->readNumEntry( "Print type", (int)TodosAll );
545 mIncludeDescription = mConfig->readBoolEntry( "Include description", true );
546 mIncludePriority = mConfig->readBoolEntry( "Include priority", true );
547 mIncludeDueDate = mConfig->readBoolEntry( "Include due date", true );
548 mConnectSubTodos = mConfig->readBoolEntry( "Connect subtodos", true );
549 mTodoPrintType = (eTodoPrintType) mConfig->readNumEntry( "Printing type", 0 );
550 }
551 setSettingsWidget();
552}
553
554void CalPrintTodos::saveConfig()
555{
556 readSettingsWidget();
557 if ( mConfig ) {
558 mConfig->writeEntry( "Page title", mPageTitle );
559 mConfig->writeEntry( "Print type", int( mTodoPrintType ) );
560 mConfig->writeEntry( "Include description", mIncludeDescription );
561 mConfig->writeEntry( "Include priority", mIncludePriority );
562 mConfig->writeEntry( "Include due date", mIncludeDueDate );
563 mConfig->writeEntry( "Connect subtodos", mConnectSubTodos );
564 mConfig->writeEntry( "Printing type", mTodoPrintType );
565 }
566}
567
568void CalPrintTodos::print( QPainter &p, int width, int height )
569{
570 bool printCompleted = true;
571 if ( mTodoPrintType == 1 )
572 printCompleted = false;
573 int yoffset = 0, xoffset = 0;
574 //width = height -1;//test only
575 if ( width > height ) {
576 yoffset += LEFT_DISTANCE;
577 } else {
578 xoffset += LEFT_DISTANCE;
579 }
580 width -= xoffset;
581 height -= yoffset;
582
583 int pospriority = 5+xoffset;
584 int possummary = 70+xoffset;
585 int posdue = width - 145;
586 int lineSpacing = 15;
587 int fontHeight = 10;
588
589
590 drawHeader( p, mPageTitle, mFromDate, QDate(),
591 0+xoffset, 0+yoffset, width, mHeaderHeight );
592
593 int mCurrentLinePos = mHeaderHeight + 5+yoffset;
594 QString outStr;
595
596 p.setFont( QFont( "helvetica", 10 ) );
597 lineSpacing = p.fontMetrics().lineSpacing();
598 mCurrentLinePos += lineSpacing;
599 // draw the headers
600 p.setFont( QFont("helvetica", 10, QFont::Bold ) );
601 if ( mIncludePriority ) {
602 outStr += i18n("Priority");
603 p.drawText( pospriority, mCurrentLinePos - 2, outStr);
604 } else {
605 possummary = 10;
606 pospriority = -1;
607 }
608
609 outStr.truncate( 0 );
610 outStr += i18n("Summary");
611 if ( mIncludeDueDate )
612 outStr += i18n(" (Due)");
613
614 p.drawText( possummary, mCurrentLinePos - 2, outStr );
615
616 if ( mIncludeDueDate ) {
617 // outStr.truncate( 0 );
618// outStr += i18n("Due");
619// p.drawText( posdue, mCurrentLinePos - 2, outStr );
620 } else {
621 posdue = -1;
622 }
623
624 p.setFont( QFont( "helvetica", 10 ) );
625
626 fontHeight = p.fontMetrics().height();
627
628 Todo::List todoList;
629// if (mTodoPrintType==TodosSelected) {
630// todoList.append(selectedTodoo);
631// } else {
632 todoList.fill(mCalendar->todos());
633// }
634 // TODO_RK: filter out todos
635
636 int count = 0;
637 for( int cprior = 1; cprior <= 6; cprior++ ) {
638 Todo::List::ConstIterator it;
639 for( it = todoList.begin(); it != todoList.end(); ++it ) {
640 Todo *currEvent = *it;
641
642 // Filter out the subitems.
643 if ( currEvent->relatedTo() ) {
644 continue;
645 }
646
647 QDate start = currEvent->dtStart().date();
648 // if it is not to start yet, skip.
649 // if ( ( !start.isValid() ) && ( start >= mToDate ) ) {
650 // continue;
651 //}
652 // priority
653 int priority = currEvent->priority();
654 // 6 is the lowest priority (the unspecified one)
655 if ( ( priority != cprior ) ||
656 ( ( cprior == 6 ) && ( priority == 0 ) ) ) {
657 continue;
658 }
659 count++;
660 int todoHeight = height - mCurrentLinePos;
661 drawTodo( printCompleted, count, currEvent, p, mConnectSubTodos,
662 mIncludeDescription, pospriority, possummary, posdue, 0,
663 0, mCurrentLinePos, width, todoHeight, height );
664 }
665 }
666}
667
668
669#endif
diff --git a/korganizer/calprintplugins.h b/korganizer/calprintplugins.h
new file mode 100644
index 0000000..7c56131
--- a/dev/null
+++ b/korganizer/calprintplugins.h
@@ -0,0 +1,151 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution.
24*/
25#ifndef CALPRINTPLUGINS_H
26#define CALPRINTPLUGINS_H
27
28
29#include <klocale.h>
30#include "calprintbase.h"
31#include "calprintdayconfig_base.h"
32#include "calprintweekconfig_base.h"
33#include "calprintmonthconfig_base.h"
34#include "calprinttodoconfig_base.h"
35
36#ifndef KORG_NOPRINTER
37namespace KCal {
38class Calendar;
39}
40
41using namespace KCal;
42
43class CalPrintDay : public CalPrintBase
44{
45 Q_OBJECT
46 public:
47 CalPrintDay(KPrinter *printer, Calendar *cal, KConfig *cfg);
48 virtual ~CalPrintDay();
49 virtual QString description() { return i18n("Print day"); }
50 virtual QString longDescription() { return i18n("Prints all events of a single day on one page"); }
51 virtual QWidget *configWidget( QWidget* );
52
53 public slots:
54 void print(QPainter &p, int width, int height);
55 virtual void readSettingsWidget();
56 virtual void setSettingsWidget();
57 virtual void loadConfig();
58 virtual void saveConfig();
59 virtual void setDateRange( const QDate& from, const QDate& to );
60
61 protected:
62 QTime mStartTime, mEndTime;
63 bool mIncludeTodos;
64 bool mIncludeAllEvents;
65 CalPrintDayConfig_Base *mConfigWidget;
66};
67
68class CalPrintWeek : public CalPrintBase
69{
70 Q_OBJECT
71 public:
72 CalPrintWeek(KPrinter *printer, Calendar *cal, KConfig *cfg);
73 virtual ~CalPrintWeek();
74 virtual QString description() { return i18n("Print week"); }
75 virtual QString longDescription() { return i18n("Prints all events of one week on one page"); }
76 virtual QWidget *configWidget(QWidget*);
77 virtual KPrinter::Orientation orientation();
78
79 public slots:
80 void print(QPainter &p, int width, int height);
81 virtual void readSettingsWidget();
82 virtual void setSettingsWidget();
83 virtual void loadConfig();
84 virtual void saveConfig();
85 virtual void setDateRange( const QDate& from, const QDate& to );
86
87 protected:
88 enum eWeekPrintType { Filofax=0, Timetable, SplitWeek } mWeekPrintType;
89 QTime mStartTime, mEndTime;
90 bool mIncludeTodos;
91 CalPrintWeekConfig_Base *mConfigWidget;
92};
93
94class CalPrintMonth : public CalPrintBase
95{
96 Q_OBJECT
97 public:
98 CalPrintMonth(KPrinter *printer, Calendar *cal, KConfig *cfg);
99 virtual ~CalPrintMonth();
100 virtual QString description() { return i18n("Print month"); }
101 virtual QString longDescription() { return i18n("Prints all events of one month on one page"); }
102 virtual QWidget *configWidget(QWidget*);
103 virtual KPrinter::Orientation orientation() { return KPrinter::Landscape; }
104
105 public slots:
106 void print(QPainter &p, int width, int height);
107 virtual void readSettingsWidget();
108 virtual void setSettingsWidget();
109 virtual void loadConfig();
110 virtual void saveConfig();
111 virtual void setDateRange( const QDate& from, const QDate& to );
112
113 protected:
114 bool mWeekNumbers;
115 bool mIncludeTodos;
116 CalPrintMonthConfig_Base *mConfigWidget;
117};
118
119class CalPrintTodos : public CalPrintBase
120{
121 Q_OBJECT
122 public:
123 CalPrintTodos(KPrinter *printer, Calendar *cal, KConfig *cfg);
124 virtual ~CalPrintTodos();
125 virtual QString description() { return i18n("Print todos"); }
126 virtual QString longDescription() { return i18n("Prints all todos in a (tree-like) list"); }
127 virtual QWidget *configWidget(QWidget*);
128
129 public slots:
130 void print(QPainter &p, int width, int height);
131 virtual void readSettingsWidget();
132 virtual void setSettingsWidget();
133 virtual void loadConfig();
134 virtual void saveConfig();
135
136 protected:
137 QString mPageTitle;
138
139 enum eTodoPrintType {
140 TodosAll = 0, TodosUnfinished, TodosDueRange
141 } mTodoPrintType;
142
143 bool mIncludeDescription;
144 bool mIncludePriority;
145 bool mIncludeDueDate;
146 bool mConnectSubTodos;
147 CalPrintTodoConfig_Base *mConfigWidget ;
148};
149
150#endif
151#endif
diff --git a/korganizer/calprinttodoconfig_base.ui b/korganizer/calprinttodoconfig_base.ui
new file mode 100644
index 0000000..010a489
--- a/dev/null
+++ b/korganizer/calprinttodoconfig_base.ui
@@ -0,0 +1,239 @@
1<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
2<class>CalPrintTodoConfig_Base</class>
3<comment>Configuration page for the print day mode.</comment>
4<author>Reinhold Kainhofer &lt;reinhold@kainhofer.com&gt;</author>
5<widget class="QWidget">
6 <property name="name">
7 <cstring>CalPrintTodoConfig_Base</cstring>
8 </property>
9 <property name="geometry">
10 <rect>
11 <x>0</x>
12 <y>0</y>
13 <width>361</width>
14 <height>271</height>
15 </rect>
16 </property>
17 <property name="caption">
18 <string>CalPrintTodoConfig_Base</string>
19 </property>
20 <grid>
21 <property name="name">
22 <cstring>unnamed</cstring>
23 </property>
24 <property name="margin">
25 <number>0</number>
26 </property>
27 <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2">
28 <property name="name">
29 <cstring>mDescription</cstring>
30 </property>
31 <property name="text">
32 <string>Include &amp;description of the item</string>
33 </property>
34 </widget>
35 <widget class="QCheckBox" row="4" column="0" rowspan="1" colspan="2">
36 <property name="name">
37 <cstring>mDueDate</cstring>
38 </property>
39 <property name="text">
40 <string>Include d&amp;ue date of the item</string>
41 </property>
42 </widget>
43 <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="2">
44 <property name="name">
45 <cstring>mPriority</cstring>
46 </property>
47 <property name="text">
48 <string>Include &amp;priority of the item</string>
49 </property>
50 </widget>
51 <widget class="QButtonGroup" row="1" column="0" rowspan="1" colspan="2">
52 <property name="name">
53 <cstring>mPrintType</cstring>
54 </property>
55 <property name="title">
56 <string>Items to Print</string>
57 </property>
58 <grid>
59 <property name="name">
60 <cstring>unnamed</cstring>
61 </property>
62 <widget class="QLabel" row="4" column="1">
63 <property name="name">
64 <cstring>mFromDateLabel</cstring>
65 </property>
66 <property name="text">
67 <string>&amp;From:</string>
68 </property>
69 <property name="buddy" stdset="0">
70 <cstring>mFromDate</cstring>
71 </property>
72 </widget>
73 <widget class="QLabel" row="4" column="3">
74 <property name="name">
75 <cstring>mToDateLabel</cstring>
76 </property>
77 <property name="text">
78 <string>&amp;To:</string>
79 </property>
80 <property name="buddy" stdset="0">
81 <cstring>mToDate</cstring>
82 </property>
83 </widget>
84 <spacer row="4" column="5">
85 <property name="name">
86 <cstring>spacer1</cstring>
87 </property>
88 <property name="orientation">
89 <enum>Horizontal</enum>
90 </property>
91 <property name="sizeType">
92 <enum>Expanding</enum>
93 </property>
94 <property name="sizeHint">
95 <size>
96 <width>16</width>
97 <height>21</height>
98 </size>
99 </property>
100 </spacer>
101 <spacer row="4" column="0">
102 <property name="name">
103 <cstring>spacer2</cstring>
104 </property>
105 <property name="orientation">
106 <enum>Horizontal</enum>
107 </property>
108 <property name="sizeType">
109 <enum>Fixed</enum>
110 </property>
111 <property name="sizeHint">
112 <size>
113 <width>16</width>
114 <height>20</height>
115 </size>
116 </property>
117 </spacer>
118 <widget class="QRadioButton" row="0" column="0" rowspan="1" colspan="5">
119 <property name="name">
120 <cstring>mPrintAll</cstring>
121 </property>
122 <property name="text">
123 <string>Print &amp;all todo items</string>
124 </property>
125 <property name="checked">
126 <bool>true</bool>
127 </property>
128 </widget>
129 <widget class="QRadioButton" row="1" column="0" rowspan="1" colspan="5">
130 <property name="name">
131 <cstring>mPrintUnfinished</cstring>
132 </property>
133 <property name="enabled">
134 <bool>true</bool>
135 </property>
136 <property name="text">
137 <string>Print only &amp;uncompleted items</string>
138 </property>
139 <property name="accel">
140 <string>Alt+U</string>
141 </property>
142 </widget>
143 <widget class="QDateEdit" row="4" column="4">
144 <property name="name">
145 <cstring>mToDate</cstring>
146 </property>
147 <property name="enabled">
148 <bool>false</bool>
149 </property>
150 <property name="order">
151 <enum>DMY</enum>
152 </property>
153 </widget>
154 <widget class="QDateEdit" row="4" column="2">
155 <property name="name">
156 <cstring>mFromDate</cstring>
157 </property>
158 <property name="enabled">
159 <bool>false</bool>
160 </property>
161 <property name="order">
162 <enum>DMY</enum>
163 </property>
164 </widget>
165 <widget class="QRadioButton" row="3" column="0" rowspan="1" colspan="5">
166 <property name="name">
167 <cstring>mPrintDueRange</cstring>
168 </property>
169 <property name="enabled">
170 <bool>false</bool>
171 </property>
172 <property name="text">
173 <string>Only items due in the &amp;range:</string>
174 </property>
175 </widget>
176 </grid>
177 </widget>
178 <widget class="QLineEdit" row="0" column="1">
179 <property name="name">
180 <cstring>mTitle</cstring>
181 </property>
182 <property name="text">
183 <string>Todo List</string>
184 </property>
185 </widget>
186 <widget class="QLabel" row="0" column="0">
187 <property name="name">
188 <cstring>mTitleLabel</cstring>
189 </property>
190 <property name="text">
191 <string>&amp;Title:</string>
192 </property>
193 <property name="buddy" stdset="0">
194 <cstring>mTitle</cstring>
195 </property>
196 </widget>
197 <widget class="QCheckBox" row="5" column="0" rowspan="1" colspan="2">
198 <property name="name">
199 <cstring>mConnectSubTodos</cstring>
200 </property>
201 <property name="text">
202 <string>Co&amp;nnect subtodos with its parent</string>
203 </property>
204 </widget>
205 <spacer row="6" column="1">
206 <property name="name">
207 <cstring>spacer3</cstring>
208 </property>
209 <property name="orientation">
210 <enum>Vertical</enum>
211 </property>
212 <property name="sizeType">
213 <enum>Expanding</enum>
214 </property>
215 <property name="sizeHint">
216 <size>
217 <width>20</width>
218 <height>0</height>
219 </size>
220 </property>
221 </spacer>
222 </grid>
223</widget>
224<connections>
225 <connection>
226 <sender>mPrintDueRange</sender>
227 <signal>toggled(bool)</signal>
228 <receiver>mFromDate</receiver>
229 <slot>setEnabled(bool)</slot>
230 </connection>
231 <connection>
232 <sender>mPrintDueRange</sender>
233 <signal>toggled(bool)</signal>
234 <receiver>mToDate</receiver>
235 <slot>setEnabled(bool)</slot>
236 </connection>
237</connections>
238<layoutdefaults spacing="6" margin="11"/>
239</UI>
diff --git a/korganizer/calprintweekconfig_base.ui b/korganizer/calprintweekconfig_base.ui
new file mode 100644
index 0000000..c770239
--- a/dev/null
+++ b/korganizer/calprintweekconfig_base.ui
@@ -0,0 +1,318 @@
1<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
2<class>CalPrintWeekConfig_Base</class>
3<comment>Configuration page for the print week mode.</comment>
4<author>Reinhold Kainhofer &lt;reinhold@kainhofer.com&gt;</author>
5<widget class="QWidget">
6 <property name="name">
7 <cstring>CalPrintWeek_Base</cstring>
8 </property>
9 <property name="geometry">
10 <rect>
11 <x>0</x>
12 <y>0</y>
13 <width>374</width>
14 <height>252</height>
15 </rect>
16 </property>
17 <property name="caption">
18 <string>CalPrintWeek_Base</string>
19 </property>
20 <grid>
21 <property name="name">
22 <cstring>unnamed</cstring>
23 </property>
24 <property name="margin">
25 <number>0</number>
26 </property>
27 <spacer row="4" column="0">
28 <property name="name">
29 <cstring>spacer3</cstring>
30 </property>
31 <property name="orientation">
32 <enum>Vertical</enum>
33 </property>
34 <property name="sizeType">
35 <enum>Expanding</enum>
36 </property>
37 <property name="sizeHint">
38 <size>
39 <width>21</width>
40 <height>27</height>
41 </size>
42 </property>
43 </spacer>
44 <widget class="QGroupBox" row="0" column="0">
45 <property name="name">
46 <cstring>mDateRangeGroup</cstring>
47 </property>
48 <property name="title">
49 <string>Date &amp;&amp; Time Range</string>
50 </property>
51 <grid>
52 <property name="name">
53 <cstring>unnamed</cstring>
54 </property>
55 <widget class="QLabel" row="0" column="2">
56 <property name="name">
57 <cstring>mToDateLabel</cstring>
58 </property>
59 <property name="text">
60 <string>&amp;End date:</string>
61 </property>
62 <property name="buddy" stdset="0">
63 <cstring>mToDate</cstring>
64 </property>
65 </widget>
66 <widget class="QLabel" row="0" column="0">
67 <property name="name">
68 <cstring>mFromDateLabel</cstring>
69 </property>
70 <property name="text">
71 <string>&amp;Start date:</string>
72 </property>
73 <property name="buddy" stdset="0">
74 <cstring>mFromDate</cstring>
75 </property>
76 </widget>
77 <widget class="KDateEdit" row="0" column="1">
78 <property name="name">
79 <cstring>mFromDate</cstring>
80 </property>
81 <property name="sizePolicy">
82 <sizepolicy>
83 <hsizetype>5</hsizetype>
84 <vsizetype>5</vsizetype>
85 <horstretch>3</horstretch>
86 <verstretch>0</verstretch>
87 </sizepolicy>
88 </property>
89 <property name="minimumSize">
90 <size>
91 <width>50</width>
92 <height>0</height>
93 </size>
94 </property>
95 <property name="focusPolicy">
96 <enum>StrongFocus</enum>
97 </property>
98 </widget>
99 <widget class="KDateEdit" row="0" column="3">
100 <property name="name">
101 <cstring>mToDate</cstring>
102 </property>
103 <property name="sizePolicy">
104 <sizepolicy>
105 <hsizetype>5</hsizetype>
106 <vsizetype>5</vsizetype>
107 <horstretch>3</horstretch>
108 <verstretch>0</verstretch>
109 </sizepolicy>
110 </property>
111 <property name="minimumSize">
112 <size>
113 <width>50</width>
114 <height>0</height>
115 </size>
116 </property>
117 <property name="focusPolicy">
118 <enum>StrongFocus</enum>
119 </property>
120 </widget>
121 </grid>
122 </widget>
123 <widget class="QCheckBox" row="3" column="0">
124 <property name="name">
125 <cstring>mColors</cstring>
126 </property>
127 <property name="text">
128 <string>Use &amp;colors</string>
129 </property>
130 </widget>
131 <widget class="QButtonGroup" row="1" column="0">
132 <property name="name">
133 <cstring>mPrintType</cstring>
134 </property>
135 <property name="title">
136 <string>Type of View</string>
137 </property>
138 <grid>
139 <property name="name">
140 <cstring>unnamed</cstring>
141 </property>
142 <widget class="QRadioButton" row="0" column="0" rowspan="1" colspan="6">
143 <property name="name">
144 <cstring>mPrintTypeButton1</cstring>
145 </property>
146 <property name="text">
147 <string>Print as &amp;Filofax page</string>
148 </property>
149 <property name="accel">
150 <string>Alt+F</string>
151 </property>
152 <property name="checked">
153 <bool>true</bool>
154 </property>
155 </widget>
156 <widget class="QRadioButton" row="1" column="0" rowspan="1" colspan="6">
157 <property name="name">
158 <cstring>mPrintTypeButton2</cstring>
159 </property>
160 <property name="text">
161 <string>Print as &amp;timetable view:</string>
162 </property>
163 <property name="accel">
164 <string>Alt+T</string>
165 </property>
166 </widget>
167 <spacer row="2" column="0">
168 <property name="name">
169 <cstring>spacer2</cstring>
170 </property>
171 <property name="orientation">
172 <enum>Horizontal</enum>
173 </property>
174 <property name="sizeType">
175 <enum>Fixed</enum>
176 </property>
177 <property name="sizeHint">
178 <size>
179 <width>16</width>
180 <height>21</height>
181 </size>
182 </property>
183 </spacer>
184 <widget class="QLabel" row="2" column="1">
185 <property name="name">
186 <cstring>mFromTimeLabel</cstring>
187 </property>
188 <property name="text">
189 <string>Start &amp;time:</string>
190 </property>
191 <property name="buddy" stdset="0">
192 <cstring>mFromTime</cstring>
193 </property>
194 </widget>
195 <widget class="QTimeEdit" row="2" column="2">
196 <property name="name">
197 <cstring>mFromTime</cstring>
198 </property>
199 <property name="enabled">
200 <bool>false</bool>
201 </property>
202 <property name="time">
203 <time>
204 <hour>0</hour>
205 <minute>8</minute>
206 <second>0</second>
207 </time>
208 </property>
209 </widget>
210 <widget class="QLabel" row="2" column="3">
211 <property name="name">
212 <cstring>mToTimeLabel</cstring>
213 </property>
214 <property name="text">
215 <string>End ti&amp;me:</string>
216 </property>
217 <property name="buddy" stdset="0">
218 <cstring>mToTime</cstring>
219 </property>
220 </widget>
221 <widget class="QTimeEdit" row="2" column="4">
222 <property name="name">
223 <cstring>mToTime</cstring>
224 </property>
225 <property name="enabled">
226 <bool>false</bool>
227 </property>
228 <property name="time">
229 <time>
230 <hour>16</hour>
231 <minute>0</minute>
232 <second>0</second>
233 </time>
234 </property>
235 </widget>
236 <spacer row="2" column="5">
237 <property name="name">
238 <cstring>spacer4</cstring>
239 </property>
240 <property name="orientation">
241 <enum>Horizontal</enum>
242 </property>
243 <property name="sizeType">
244 <enum>Expanding</enum>
245 </property>
246 <property name="sizeHint">
247 <size>
248 <width>16</width>
249 <height>20</height>
250 </size>
251 </property>
252 </spacer>
253 <widget class="QRadioButton" row="3" column="0" rowspan="1" colspan="4">
254 <property name="name">
255 <cstring>radioButton3</cstring>
256 </property>
257 <property name="text">
258 <string>Print as split week view</string>
259 </property>
260 </widget>
261 </grid>
262 </widget>
263 <widget class="QCheckBox" row="2" column="0">
264 <property name="name">
265 <cstring>mIncludeTodos</cstring>
266 </property>
267 <property name="enabled">
268 <bool>false</bool>
269 </property>
270 <property name="text">
271 <string>Include to&amp;dos that are due on the printed day(s)</string>
272 </property>
273 </widget>
274 </grid>
275</widget>
276<customwidgets>
277 <customwidget>
278 <class>KDateEdit</class>
279 <header location="local">libkdepim/kdateedit.h</header>
280 <sizehint>
281 <width>-1</width>
282 <height>-1</height>
283 </sizehint>
284 <container>0</container>
285 <sizepolicy>
286 <hordata>5</hordata>
287 <verdata>5</verdata>
288 <horstretch>0</horstretch>
289 <verstretch>0</verstretch>
290 </sizepolicy>
291 <pixmap>image0</pixmap>
292 </customwidget>
293</customwidgets>
294<images>
295 <image name="image0">
296 <data format="PNG" length="826">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000030149444154789cb59531681b5718c77f0e377c070e3c810a3a70e0041eac51852e0a19e45134830a1d9a4c69a04bc8928e990a693a640e1d0c8642b08742321894c1507991b484c890902bb8701a047760c3bd21701fe4201dde49b6a41a32b8df72dcbbeffdbefffbbfefbd5b1b0c07cce266ebe667ae2006c3c1dada0cdc3be87d6e6c35b0d692a409d9c7ec8b20d65ae29398d19b1114e7e3de4ce98b3f5e10dc0053cf0951b4506496e1b964bf7ce6c585d9054c62d01d617ca48be0596553cf496d8f2c8b01c5f795fc93904e85ec4c01a152857a5d9175d0b2805c872080f18595ccc1499a10a225d4e2fbc2877786fe81253ab6c04c8d106e09db5d43ab0d146e5c64d1a23938fb98a185cea1c33eecfd9eba49eb427dcb201e245365f2b7b2fb5b4a3a31dcb927178afe07d86901df870fefa4842aed6f6b74ba42e52b4014d580e1eb9cbd9d94de7e4aad16d2f9be02d805f0b5e532f927a1ffcacea1777f122a8105b164a7c25faf323a5d9f1f1fd600e1e5bec59e2d4b5c7ef5209d0ad17b8b31864e57c0b3e0815ac3ee33253ab664a770ff5185d1a1cb8d2267d3e58aa1dc7d2508cbe597d0e74fdd269aaaf0f52d414c4ea3e9762c996869e42560d7a72e41c4799a2586e74f95e8d8151481fa86efbe7b3398ac58b1a2b8527589f15451ad303ac2293542ad6648a796278f13a27185e4c4754310facb98c53a79e19a3fdc1426ff28c3d7399d1f7cb25343eb96106cf83c790ce9c4f2eb831855c55485663327992eb6dc8a6259874ed700b0b793323cccb9ffa842b30d6133e3e75fea989ac15a8b16ca76b746b0b92278d919774c5b6d48a78697fb29bbcf52468742a32120909c24e899ce67beed5be2db01e22d1e9485bb620e47f9ee9e606a21bd3f5d3744c7e7c54d55e87443867d8b554515ac5db4620e8e4f62263170fd1cdee90aad7640141992891b0f367c9adfe4049bb07d3b7022bd8c687c0978f46684ee084150b65ac1fcca94591b7a90a496e4c095164fb016a2b192a497795cc0f84817aebe25f7bf70ccc54a575c555c03f78ffa5fc0570d1f0c076bff0232285a0901e2257b0000000049454e44ae426082</data>
297 </image>
298</images>
299<connections>
300 <connection>
301 <sender>mPrintTypeButton2</sender>
302 <signal>toggled(bool)</signal>
303 <receiver>mFromTime</receiver>
304 <slot>setEnabled(bool)</slot>
305 </connection>
306 <connection>
307 <sender>mPrintTypeButton2</sender>
308 <signal>toggled(bool)</signal>
309 <receiver>mToTime</receiver>
310 <slot>setEnabled(bool)</slot>
311 </connection>
312</connections>
313<layoutdefaults spacing="6" margin="11"/>
314<includehints>
315 <includehint>kdateedit.h</includehint>
316 <includehint>kdateedit.h</includehint>
317</includehints>
318</UI>
diff --git a/korganizer/categoryeditdialog.moc b/korganizer/categoryeditdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/categoryeditdialog.moc
diff --git a/korganizer/categoryselectdialog.moc b/korganizer/categoryselectdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/categoryselectdialog.moc
diff --git a/korganizer/cellitem.cpp b/korganizer/cellitem.cpp
new file mode 100644
index 0000000..61d06ac
--- a/dev/null
+++ b/korganizer/cellitem.cpp
@@ -0,0 +1,98 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24
25#include "cellitem.h"
26
27#include <klocale.h>
28#include <kdebug.h>
29
30#include <qintdict.h>
31
32using namespace KOrg;
33
34QString CellItem::label() const
35{
36 return i18n("<undefined>");
37}
38
39QPtrList<CellItem> CellItem::placeItem( QPtrList<CellItem> cells,
40 CellItem *placeItem )
41{
42 kdDebug(5855) << "Placing " << placeItem->label() << endl;
43
44 QPtrList<KOrg::CellItem> conflictItems;
45 int maxSubCells = 0;
46 QIntDict<KOrg::CellItem> subCellDict;
47
48 // Find all items which are in same cell
49 QPtrListIterator<KOrg::CellItem> it2( cells );
50 for( it2.toFirst(); it2.current(); ++it2 ) {
51 KOrg::CellItem *item = it2.current();
52 if ( item == placeItem ) continue;
53
54 if ( item->overlaps( placeItem ) ) {
55 kdDebug(5855) << " Overlaps: " << item->label() << endl;
56
57 conflictItems.append( item );
58 if ( item->subCells() > maxSubCells ) maxSubCells = item->subCells();
59 subCellDict.insert( item->subCell(), item );
60 }
61 }
62
63 if ( conflictItems.count() > 0 ) {
64 // Look for unused sub cell and insert item
65 int i;
66 for( i = 0; i < maxSubCells; ++i ) {
67 kdDebug(5855) << " Trying subcell " << i << endl;
68 if ( !subCellDict.find( i ) ) {
69 kdDebug(5855) << " Use subcell " << i << endl;
70 placeItem->setSubCell( i );
71 break;
72 }
73 }
74 if ( i == maxSubCells ) {
75 kdDebug(5855) << " New subcell " << i << endl;
76 placeItem->setSubCell( maxSubCells );
77 maxSubCells++; // add new item to number of sub cells
78 }
79
80 kdDebug(5855) << " Sub cells: " << maxSubCells << endl;
81
82 // Write results to item to be placed
83 conflictItems.append( placeItem );
84 placeItem->setSubCells( maxSubCells );
85
86 QPtrListIterator<KOrg::CellItem> it3( conflictItems );
87 for( it3.toFirst(); it3.current(); ++it3 ) {
88 (*it3)->setSubCells( maxSubCells );
89 }
90 // Todo: Adapt subCells of items conflicting with conflicting items
91 } else {
92 kdDebug(5855) << " no conflicts" << endl;
93 placeItem->setSubCell( 0 );
94 placeItem->setSubCells( 1 );
95 }
96
97 return conflictItems;
98}
diff --git a/korganizer/cellitem.h b/korganizer/cellitem.h
new file mode 100644
index 0000000..72773d0
--- a/dev/null
+++ b/korganizer/cellitem.h
@@ -0,0 +1,66 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef KORG_CELLITEM_H
25#define KORG_CELLITEM_H
26
27#include <qstring.h>
28#include <qptrlist.h>
29
30namespace KOrg {
31
32class CellItem
33{
34 public:
35 CellItem()
36 : mSubCells( 0 ), mSubCell( -1 )
37 {
38 }
39
40 void setSubCells( int v ) { mSubCells = v; }
41 int subCells() const { return mSubCells; }
42
43 void setSubCell( int v ) { mSubCell = v; }
44 int subCell() const { return mSubCell; }
45
46 virtual bool overlaps( CellItem *other ) const = 0;
47
48 virtual QString label() const;
49
50 /**
51 Place item \arg placeItem into stripe containing items \arg cells in a
52 way that items don't overlap.
53
54 \return Placed items
55 */
56 static QPtrList<CellItem> placeItem( QPtrList<CellItem> cells,
57 CellItem *placeItem );
58
59 private:
60 int mSubCells;
61 int mSubCell;
62};
63
64}
65
66#endif
diff --git a/korganizer/customlistviewitem.h b/korganizer/customlistviewitem.h
new file mode 100644
index 0000000..94e5bce
--- a/dev/null
+++ b/korganizer/customlistviewitem.h
@@ -0,0 +1,38 @@
1#ifndef CUSTOMLISTVIEWITEM_H
2#define CUSTOMLISTVIEWITEM_H
3
4#include <qmap.h>
5#include <qstring.h>
6#include <klistview.h>
7
8template<class T>
9class CustomListViewItem : public KListViewItem
10{
11 public:
12 CustomListViewItem( T data, KListView *parent ) :
13 KListViewItem( parent ), mData( data ) { updateItem(); };
14 ~CustomListViewItem() {};
15
16 void updateItem() {};
17
18 T data() const { return mData; }
19
20 QString key(int column, bool) const
21 {
22 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
23 if (it == mKeyMap.end()) return text(column);
24 else return *it;
25 }
26
27 void setSortKey(int column,const QString &key)
28 {
29 mKeyMap.insert(column,key);
30 }
31
32 private:
33 T mData;
34
35 QMap<int,QString> mKeyMap;
36};
37
38#endif
diff --git a/korganizer/datenavigator.cpp b/korganizer/datenavigator.cpp
new file mode 100644
index 0000000..8d35c42
--- a/dev/null
+++ b/korganizer/datenavigator.cpp
@@ -0,0 +1,287 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include "datenavigator.h"
25
26#include "koglobals.h"
27
28#include <kcalendarsystem.h>
29
30#include <kdebug.h>
31#include <kglobal.h>
32#include <klocale.h>
33
34using namespace KCal;
35
36DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager * v)
37 : QObject( parent, name )
38{
39 mViewManager = v;
40 mSelectedDates.append( QDate::currentDate() );
41}
42
43DateNavigator::~DateNavigator()
44{
45}
46
47void DateNavigator::slotMonthSelect( int m )
48{
49 QDate firstSelected = mSelectedDates.first();
50 int weekDay = firstSelected.dayOfWeek();
51 int diff = m - firstSelected.month() ;
52 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff );
53
54 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
55 selectMonthByDate( firstSelected );
56 else
57 selectWeekByDay( weekDay, firstSelected );
58
59}
60
61void DateNavigator::slotDaySelect( QDate d )
62{
63 QDate firstSelected = mSelectedDates.first();
64 int weekDay = firstSelected.dayOfWeek();
65 //int diff = firstSelected.daysTo( d ) ;
66 firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) );
67
68 selectWeekByDay( weekDay, firstSelected );
69
70}
71
72void DateNavigator::selectMonthByDate( const QDate & firstSelected )
73{
74
75 int monthDay = firstSelected.day();
76 QDate date = firstSelected.addDays( 1-monthDay );
77 selectDates( date , date.daysInMonth ());
78
79}
80void DateNavigator::selectMonth()
81{
82
83 QDate date =mSelectedDates.first();
84 selectMonthByDate( date );
85}
86
87DateList DateNavigator::selectedDates()
88{
89 return mSelectedDates;
90}
91
92int DateNavigator::datesCount() const
93{
94 return mSelectedDates.count();
95}
96
97void DateNavigator::selectDates( const DateList& dateList )
98{
99 if (dateList.count() > 0) {
100 mSelectedDates = dateList;
101 emitSelected();
102 }
103}
104
105void DateNavigator::selectDate( const QDate &date )
106{
107 QDate d = date;
108
109 if ( !d.isValid() ) {
110 d = QDate::currentDate();
111 }
112
113 mSelectedDates.clear();
114 mSelectedDates.append( d );
115
116 emitSelected();
117}
118
119void DateNavigator::selectDates( int count )
120{
121
122 QDate d = mSelectedDates.first();
123 selectDates( d, count );
124}
125
126void DateNavigator::selectDates( const QDate &d, int count )
127{
128 DateList dates;
129
130 int i;
131 for( i = 0; i < count; ++i ) {
132 dates.append( d.addDays( i ) );
133 }
134
135 mSelectedDates = dates;
136
137 emitSelected();
138}
139
140void DateNavigator::selectWeekByDay( int weekDay, const QDate &d )
141{
142 // qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1());
143 int dateCount = mSelectedDates.count();
144 bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() );
145 if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d );
146 else if ( weekStart && dateCount == 7 ) selectWeek( d );
147 else selectDates( d, dateCount );
148}
149
150void DateNavigator::selectWeek()
151{
152 QDate d = mSelectedDates.first();
153 selectWeek( d );
154}
155void DateNavigator::selectWeek( int num )
156{
157 int year = mSelectedDates.first().year();
158 if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 )
159 ++year;
160 if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 )
161 --year;
162 QDate d = QDate ( year, 1,1);
163 while ( d.dayOfWeek() != 4 )
164 d = d.addDays( 1 );
165 selectWeek( d.addDays ( (num-1) *7 ) );
166}
167void DateNavigator::selectWeek( const QDate &d )
168{
169 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
170
171 int weekStart = KGlobal::locale()->weekStartDay();
172 QDate firstDate = d.addDays( weekStart - dayOfWeek );
173
174 if ( weekStart != 1 && dayOfWeek < weekStart ) {
175 firstDate = firstDate.addDays(-7 );
176 }
177
178
179 selectDates( firstDate, 7 );
180}
181
182void DateNavigator::selectWorkWeek()
183{
184 QDate d = mSelectedDates.first();
185 selectWorkWeek( d );
186}
187
188void DateNavigator::selectWorkWeek( const QDate &d )
189{
190 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
191
192 QDate firstDate = d.addDays( 1 - dayOfWeek );
193
194 int weekStart = KGlobal::locale()->weekStartDay();
195 if ( weekStart != 1 && dayOfWeek >= weekStart ) {
196 firstDate = firstDate.addDays( 7 );
197 }
198
199 selectDates( firstDate, 5 );
200}
201
202void DateNavigator::selectToday()
203{
204 QDate d = QDate::currentDate();
205
206 int dateCount = mSelectedDates.count();
207
208 if ( dateCount == 5 ) selectWorkWeek( d );
209 else if ( dateCount == 7 ) selectWeek( d );
210 else selectDates( d, dateCount );
211}
212
213void DateNavigator::selectPreviousYear()
214{
215 QDate firstSelected = mSelectedDates.first();
216 int weekDay = firstSelected.dayOfWeek();
217 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 );
218
219 selectWeekByDay( weekDay, firstSelected );
220}
221
222void DateNavigator::selectPreviousMonth()
223{
224 QDate firstSelected = mSelectedDates.first();
225 int weekDay = firstSelected.dayOfWeek();
226 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 );
227
228
229 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
230 selectMonthByDate( firstSelected );
231 else
232 selectWeekByDay( weekDay, firstSelected );
233}
234
235void DateNavigator::selectNextMonth()
236{
237 QDate firstSelected = mSelectedDates.first();
238 int weekDay = firstSelected.dayOfWeek();
239
240 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 );
241
242 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
243 selectMonthByDate( firstSelected );
244 else
245 selectWeekByDay( weekDay, firstSelected );
246
247}
248
249void DateNavigator::selectNextYear()
250{
251 QDate firstSelected = mSelectedDates.first();
252 int weekDay = firstSelected.dayOfWeek();
253 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 );
254
255 selectWeekByDay( weekDay, firstSelected );
256}
257
258void DateNavigator::selectPrevious()
259{
260 int offset = -7;
261 if ( datesCount() == 1 ) {
262 offset = -1;
263 }
264 if ( mViewManager )
265 if ( mViewManager->showsNextDays() )
266 offset = -datesCount();
267 selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
268}
269
270void DateNavigator::selectNext()
271{
272 int offset = 7;
273 if ( datesCount() == 1 ) {
274 offset = 1;
275 }
276 if ( mViewManager )
277 if ( mViewManager->showsNextDays() )
278 offset = datesCount();
279 selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
280}
281
282void DateNavigator::emitSelected()
283{
284 emit datesSelected( mSelectedDates );
285}
286
287#include "datenavigator.moc"
diff --git a/korganizer/datenavigator.h b/korganizer/datenavigator.h
new file mode 100644
index 0000000..747e3d3
--- a/dev/null
+++ b/korganizer/datenavigator.h
@@ -0,0 +1,89 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef DATENAVIGATOR_H
24#define DATENAVIGATOR_H
25
26#include <libkcal/incidencebase.h>
27
28#include <qobject.h>
29#include "koviewmanager.h"
30
31/**
32 This class controls date navigation. All requests to move the views to another
33 date are sent to the DateNavigator. The DateNavigator processes the new
34 selection of dates and emits the required signals for the views.
35*/
36class DateNavigator : public QObject
37{
38 Q_OBJECT
39 public:
40 DateNavigator( QObject *parent = 0, const char *name = 0 , KOViewManager * v = 0);
41 ~DateNavigator();
42
43 KCal::DateList selectedDates();
44
45 int datesCount() const;
46
47 public slots:
48 void selectDates( const KCal::DateList & );
49 void selectDate( const QDate & );
50
51 void selectDates( int count );
52 void selectDates( const QDate &, int count );
53
54 void selectWeek();
55 void selectWeek( int weeknum );
56 void selectWeek( const QDate & );
57
58 void selectWorkWeek();
59 void selectWorkWeek( const QDate & );
60
61 void selectWeekByDay( int weekDay, const QDate & );
62
63 void selectToday();
64
65 void selectPreviousYear();
66 void selectPreviousMonth();
67 void selectNextMonth();
68 void selectNextYear();
69
70 void selectMonth();
71 void selectMonthByDate( const QDate & );
72
73 void selectPrevious();
74 void selectNext();
75 void slotMonthSelect( int );
76 void slotDaySelect( QDate d );
77
78 signals:
79 void datesSelected( const KCal::DateList & );
80
81 protected:
82 void emitSelected();
83
84 private:
85 KOViewManager * mViewManager;
86 KCal::DateList mSelectedDates;
87};
88
89#endif
diff --git a/korganizer/datenavigator.moc b/korganizer/datenavigator.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/datenavigator.moc
diff --git a/korganizer/docprefs.cpp b/korganizer/docprefs.cpp
new file mode 100644
index 0000000..f849aaa
--- a/dev/null
+++ b/korganizer/docprefs.cpp
@@ -0,0 +1,64 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <ksimpleconfig.h>
21#include <kstandarddirs.h>
22#include <kdebug.h>
23#include <stdlib.h>
24
25#include "docprefs.h"
26
27KSimpleConfig *DocPrefs::mConfig = 0;
28
29DocPrefs::DocPrefs( const QString &type )
30{
31 if ( !mConfig ) {
32 mConfig = new KSimpleConfig( locateLocal( "config", "docprefs." + type ) );
33 }
34}
35
36DocPrefs::~DocPrefs()
37{
38 mConfig->sync();
39}
40
41void DocPrefs::setDoc( const QString &identifier )
42{
43 mDocId = identifier;
44}
45
46QString DocPrefs::doc() const
47{
48 return mDocId;
49}
50
51bool DocPrefs::readBoolEntry( const QString &id ) const
52{
53 mConfig->setGroup( mDocId );
54 bool result = mConfig->readBoolEntry( id, false );
55// kdDebug() << "DocPrefs::readEntry(): " << id << " : " << (result ? "True" : "False" ) << endl;
56 return result;
57}
58
59void DocPrefs::writeEntry( const QString &id, bool value )
60{
61// kdDebug() << "DocPrefs::writeEntry(): " << id << " : " << (value ? "True" : "False" ) << endl;
62 mConfig->setGroup( mDocId );
63 mConfig->writeEntry( id, value );
64}
diff --git a/korganizer/docprefs.h b/korganizer/docprefs.h
new file mode 100644
index 0000000..88751fe
--- a/dev/null
+++ b/korganizer/docprefs.h
@@ -0,0 +1,44 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef DOCPREFS_H
20#define DOCPREFS_H
21
22#include <qstring.h>
23
24class KSimpleConfig;
25
26class DocPrefs
27{
28 public:
29 DocPrefs( const QString &type="general" );
30 ~DocPrefs();
31
32 void setDoc( const QString &identifier );
33 QString doc() const;
34
35 bool readBoolEntry( const QString &identifier ) const;
36 void writeEntry( const QString &identifier, bool value );
37
38 private:
39 static KSimpleConfig *mConfig;
40
41 QString mDocId;
42};
43
44#endif
diff --git a/korganizer/filteredit_base.cpp b/korganizer/filteredit_base.cpp
new file mode 100644
index 0000000..21a0954
--- a/dev/null
+++ b/korganizer/filteredit_base.cpp
@@ -0,0 +1,128 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'filteredit_base.ui'
3**
4** Created: Di Mai 4 15:30:31 2004
5** by: The User Interface Compiler ($Id$)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9
10#include "filteredit_base.h"
11
12#include <qvariant.h>
13#include <qpushbutton.h>
14#include <qframe.h>
15#include <qbuttongroup.h>
16#include <qradiobutton.h>
17#include <qlistbox.h>
18#include <qlabel.h>
19#include <qcheckbox.h>
20#include <qlayout.h>
21#include <qtooltip.h>
22#include <qwhatsthis.h>
23
24/*
25 * Constructs a FilterEdit_base as a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'.
27 */
28FilterEdit_base::FilterEdit_base( QWidget* parent, const char* name, WFlags fl )
29 : QWidget( parent, name, fl )
30{
31 if ( !name )
32 setName( "FilterEdit_base" );
33 FilterEdit_baseLayout = new QVBoxLayout( this, 0, 0, "FilterEdit_baseLayout");
34
35 mCriteriaFrame = new QFrame( this, "mCriteriaFrame" );
36 mCriteriaFrame->setFrameShape( QFrame::StyledPanel );
37 mCriteriaFrame->setFrameShadow( QFrame::Raised );
38 mCriteriaFrameLayout = new QGridLayout( mCriteriaFrame, 1, 1, 3, 2, "mCriteriaFrameLayout");
39
40 ButtonGroup1 = new QButtonGroup( mCriteriaFrame, "ButtonGroup1" );
41 ButtonGroup1->setColumnLayout(0, Qt::Vertical );
42 ButtonGroup1->layout()->setSpacing( 6 );
43 ButtonGroup1->layout()->setMargin( 11 );
44 ButtonGroup1Layout = new QVBoxLayout( ButtonGroup1->layout() );
45 ButtonGroup1Layout->setAlignment( Qt::AlignTop );
46
47 mCatShowCheck = new QRadioButton( ButtonGroup1, "mCatShowCheck" );
48 ButtonGroup1Layout->addWidget( mCatShowCheck );
49
50 mCatHideCheck = new QRadioButton( ButtonGroup1, "mCatHideCheck" );
51 ButtonGroup1Layout->addWidget( mCatHideCheck );
52
53 mCatList = new QListBox( ButtonGroup1, "mCatList" );
54 ButtonGroup1Layout->addWidget( mCatList );
55
56 mCatEditButton = new QPushButton( ButtonGroup1, "mCatEditButton" );
57 ButtonGroup1Layout->addWidget( mCatEditButton );
58
59 mCriteriaFrameLayout->addWidget( ButtonGroup1, 0, 0 );
60
61 layout1 = new QHBoxLayout( 0, 0, 0, "layout1");
62
63 textLabel1 = new QLabel( mCriteriaFrame, "textLabel1" );
64 layout1->addWidget( textLabel1 );
65
66 mRecurringCheck = new QCheckBox( mCriteriaFrame, "mRecurringCheck" );
67 layout1->addWidget( mRecurringCheck );
68
69 mCompletedCheck = new QCheckBox( mCriteriaFrame, "mCompletedCheck" );
70 layout1->addWidget( mCompletedCheck );
71
72 mCriteriaFrameLayout->addLayout( layout1, 1, 0 );
73
74 layout2 = new QHBoxLayout( 0, 0, 0, "layout2");
75
76 textLabel2 = new QLabel( mCriteriaFrame, "textLabel2" );
77 layout2->addWidget( textLabel2 );
78
79 mPublicCheck = new QCheckBox( mCriteriaFrame, "mPublicCheck" );
80 layout2->addWidget( mPublicCheck );
81
82 mPrivateCheck = new QCheckBox( mCriteriaFrame, "mPrivateCheck" );
83 layout2->addWidget( mPrivateCheck );
84
85 mConfidentialCheck = new QCheckBox( mCriteriaFrame, "mConfidentialCheck" );
86 mConfidentialCheck->setChecked( FALSE );
87 layout2->addWidget( mConfidentialCheck );
88
89 mCriteriaFrameLayout->addLayout( layout2, 2, 0 );
90 FilterEdit_baseLayout->addWidget( mCriteriaFrame );
91 languageChange();
92 resize( QSize(284, 241).expandedTo(minimumSizeHint()) );
93 clearWState( WState_Polished );
94}
95
96/*
97 * Destroys the object and frees any allocated resources
98 */
99FilterEdit_base::~FilterEdit_base()
100{
101 // no need to delete child widgets, Qt does it all for us
102}
103
104/*
105 * Sets the strings of the subwidgets using the current
106 * language.
107 */
108void FilterEdit_base::languageChange()
109{
110 setCaption( tr( "FilterEditor" ) );
111 ButtonGroup1->setTitle( tr( "Categories" ) );
112 mCatShowCheck->setText( tr( "Show only selected" ) );
113 mCatHideCheck->setText( tr( "Show all but selected" ) );
114 mCatEditButton->setText( tr( "Edit Selection..." ) );
115 textLabel1->setText( tr( "Hide" ) );
116 mRecurringCheck->setText( tr( "recurring events" ) );
117 mCompletedCheck->setText( tr( "completed to-dos" ) );
118 textLabel2->setText( tr( "Show" ) );
119 mPublicCheck->setText( tr( "public" ) );
120 mPrivateCheck->setText( tr( "private" ) );
121 mConfidentialCheck->setText( tr( "confidential" ) );
122}
123
124void FilterEdit_base::updateFilter()
125{
126 qWarning( "FilterEdit_base::updateFilter(): Not implemented yet" );
127}
128
diff --git a/korganizer/filteredit_base.cpp.emb b/korganizer/filteredit_base.cpp.emb
new file mode 100644
index 0000000..9e32851
--- a/dev/null
+++ b/korganizer/filteredit_base.cpp.emb
@@ -0,0 +1,97 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'filteredit_base.ui'
3**
4** Created: Do Jan 22 23:56:40 2004
5** by: The User Interface Compiler ($Id$)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9
10#include "filteredit_base.h"
11
12#include <qvariant.h>
13#include <qpushbutton.h>
14#include <qframe.h>
15#include <qbuttongroup.h>
16#include <qradiobutton.h>
17#include <qlistbox.h>
18#include <qcheckbox.h>
19#include <qlayout.h>
20#include <qtooltip.h>
21#include <qwhatsthis.h>
22
23/*
24 * Constructs a FilterEdit_base as a child of 'parent', with the
25 * name 'name' and widget flags set to 'f'.
26 */
27FilterEdit_base::FilterEdit_base( QWidget* parent, const char* name, WFlags fl )
28 : QWidget( parent, name, fl )
29{
30 if ( !name )
31 setName( "FilterEdit_base" );
32 FilterEdit_baseLayout = new QVBoxLayout( this, 0, 0, "FilterEdit_baseLayout");
33
34 mCriteriaFrame = new QFrame( this, "mCriteriaFrame" );
35 mCriteriaFrame->setFrameShape( QFrame::StyledPanel );
36 mCriteriaFrame->setFrameShadow( QFrame::Raised );
37 mCriteriaFrameLayout = new QVBoxLayout( mCriteriaFrame, 11, 6, "mCriteriaFrameLayout");
38
39 ButtonGroup1 = new QButtonGroup( mCriteriaFrame, "ButtonGroup1" );
40 ButtonGroup1->setColumnLayout(0, Qt::Vertical );
41 ButtonGroup1->layout()->setSpacing( 6 );
42 ButtonGroup1->layout()->setMargin( 11 );
43 ButtonGroup1Layout = new QVBoxLayout( ButtonGroup1->layout() );
44 ButtonGroup1Layout->setAlignment( Qt::AlignTop );
45
46 mCatShowCheck = new QRadioButton( ButtonGroup1, "mCatShowCheck" );
47 ButtonGroup1Layout->addWidget( mCatShowCheck );
48
49 mCatHideCheck = new QRadioButton( ButtonGroup1, "mCatHideCheck" );
50 ButtonGroup1Layout->addWidget( mCatHideCheck );
51
52 mCatList = new QListBox( ButtonGroup1, "mCatList" );
53 ButtonGroup1Layout->addWidget( mCatList );
54
55 mCatEditButton = new QPushButton( ButtonGroup1, "mCatEditButton" );
56 ButtonGroup1Layout->addWidget( mCatEditButton );
57 mCriteriaFrameLayout->addWidget( ButtonGroup1 );
58
59 mRecurringCheck = new QCheckBox( mCriteriaFrame, "mRecurringCheck" );
60 mCriteriaFrameLayout->addWidget( mRecurringCheck );
61
62 mCompletedCheck = new QCheckBox( mCriteriaFrame, "mCompletedCheck" );
63 mCriteriaFrameLayout->addWidget( mCompletedCheck );
64 FilterEdit_baseLayout->addWidget( mCriteriaFrame );
65 languageChange();
66 resize( QSize(196, 257).expandedTo(minimumSizeHint()) );
67 clearWState( WState_Polished );
68}
69
70/*
71 * Destroys the object and frees any allocated resources
72 */
73FilterEdit_base::~FilterEdit_base()
74{
75 // no need to delete child widgets, Qt does it all for us
76}
77
78/*
79 * Sets the strings of the subwidgets using the current
80 * language.
81 */
82void FilterEdit_base::languageChange()
83{
84 setCaption( tr( "FilterEditor" ) );
85 ButtonGroup1->setTitle( tr( "Categories" ) );
86 mCatShowCheck->setText( tr( "Show only selected" ) );
87 mCatHideCheck->setText( tr( "Show all but selected" ) );
88 mCatEditButton->setText( tr( "Edit Selection..." ) );
89 mRecurringCheck->setText( tr( "Hide recurring events" ) );
90 mCompletedCheck->setText( tr( "Hide completed to-dos" ) );
91}
92
93void FilterEdit_base::updateFilter()
94{
95 qWarning( "FilterEdit_base::updateFilter(): Not implemented yet" );
96}
97
diff --git a/korganizer/filteredit_base.h b/korganizer/filteredit_base.h
new file mode 100644
index 0000000..664598a
--- a/dev/null
+++ b/korganizer/filteredit_base.h
@@ -0,0 +1,66 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'filteredit_base.ui'
3**
4** Created: Di Mai 4 15:24:50 2004
5** by: The User Interface Compiler ($Id$)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9
10#ifndef FILTEREDIT_BASE_H
11#define FILTEREDIT_BASE_H
12
13#include <qvariant.h>
14#include <qwidget.h>
15
16class QVBoxLayout;
17class QHBoxLayout;
18class QGridLayout;
19class QSpacerItem;
20class QFrame;
21class QButtonGroup;
22class QRadioButton;
23class QListBox;
24class QListBoxItem;
25class QPushButton;
26class QLabel;
27class QCheckBox;
28
29class FilterEdit_base : public QWidget
30{
31 Q_OBJECT
32
33public:
34 FilterEdit_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
35 ~FilterEdit_base();
36
37 QFrame* mCriteriaFrame;
38 QButtonGroup* ButtonGroup1;
39 QRadioButton* mCatShowCheck;
40 QRadioButton* mCatHideCheck;
41 QListBox* mCatList;
42 QPushButton* mCatEditButton;
43 QLabel* textLabel1;
44 QCheckBox* mRecurringCheck;
45 QCheckBox* mCompletedCheck;
46 QLabel* textLabel2;
47 QCheckBox* mPublicCheck;
48 QCheckBox* mPrivateCheck;
49 QCheckBox* mConfidentialCheck;
50
51public slots:
52 virtual void updateFilter();
53
54protected:
55 QVBoxLayout* FilterEdit_baseLayout;
56 QGridLayout* mCriteriaFrameLayout;
57 QVBoxLayout* ButtonGroup1Layout;
58 QHBoxLayout* layout1;
59 QHBoxLayout* layout2;
60
61protected slots:
62 virtual void languageChange();
63
64};
65
66#endif // FILTEREDIT_BASE_H
diff --git a/korganizer/filteredit_base.h.emb b/korganizer/filteredit_base.h.emb
new file mode 100644
index 0000000..8befd6b
--- a/dev/null
+++ b/korganizer/filteredit_base.h.emb
@@ -0,0 +1,57 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'filteredit_base.ui'
3**
4** Created: Do Jan 22 23:56:38 2004
5** by: The User Interface Compiler ($Id$)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9
10#ifndef FILTEREDIT_BASE_H
11#define FILTEREDIT_BASE_H
12
13#include <qvariant.h>
14#include <qwidget.h>
15
16class QVBoxLayout;
17class QHBoxLayout;
18class QGridLayout;
19class QFrame;
20class QButtonGroup;
21class QRadioButton;
22class QListBox;
23class QListBoxItem;
24class QPushButton;
25class QCheckBox;
26
27class FilterEdit_base : public QWidget
28{
29 Q_OBJECT
30
31public:
32 FilterEdit_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
33 ~FilterEdit_base();
34
35 QFrame* mCriteriaFrame;
36 QButtonGroup* ButtonGroup1;
37 QRadioButton* mCatShowCheck;
38 QRadioButton* mCatHideCheck;
39 QListBox* mCatList;
40 QPushButton* mCatEditButton;
41 QCheckBox* mRecurringCheck;
42 QCheckBox* mCompletedCheck;
43
44public slots:
45 virtual void updateFilter();
46
47protected:
48 QVBoxLayout* FilterEdit_baseLayout;
49 QVBoxLayout* mCriteriaFrameLayout;
50 QVBoxLayout* ButtonGroup1Layout;
51
52protected slots:
53 virtual void languageChange();
54
55};
56
57#endif // FILTEREDIT_BASE_H
diff --git a/korganizer/filteredit_base.ui b/korganizer/filteredit_base.ui
new file mode 100644
index 0000000..b7cbb59
--- a/dev/null
+++ b/korganizer/filteredit_base.ui
@@ -0,0 +1,201 @@
1<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
2<class>FilterEdit_base</class>
3<widget class="QWidget">
4 <property name="name">
5 <cstring>FilterEdit_base</cstring>
6 </property>
7 <property name="geometry">
8 <rect>
9 <x>0</x>
10 <y>0</y>
11 <width>284</width>
12 <height>241</height>
13 </rect>
14 </property>
15 <property name="caption">
16 <string>FilterEditor</string>
17 </property>
18 <property name="layoutMargin" stdset="0">
19 </property>
20 <property name="layoutSpacing" stdset="0">
21 </property>
22 <vbox>
23 <property name="name">
24 <cstring>unnamed</cstring>
25 </property>
26 <property name="margin">
27 <number>0</number>
28 </property>
29 <property name="spacing">
30 <number>0</number>
31 </property>
32 <widget class="QFrame">
33 <property name="name">
34 <cstring>mCriteriaFrame</cstring>
35 </property>
36 <property name="frameShape">
37 <enum>StyledPanel</enum>
38 </property>
39 <property name="frameShadow">
40 <enum>Raised</enum>
41 </property>
42 <property name="layoutMargin" stdset="0">
43 </property>
44 <grid>
45 <property name="name">
46 <cstring>unnamed</cstring>
47 </property>
48 <property name="margin">
49 <number>3</number>
50 </property>
51 <property name="spacing">
52 <number>2</number>
53 </property>
54 <widget class="QButtonGroup" row="0" column="0">
55 <property name="name">
56 <cstring>ButtonGroup1</cstring>
57 </property>
58 <property name="title">
59 <string>Categories</string>
60 </property>
61 <vbox>
62 <property name="name">
63 <cstring>unnamed</cstring>
64 </property>
65 <property name="margin">
66 <number>11</number>
67 </property>
68 <property name="spacing">
69 <number>6</number>
70 </property>
71 <widget class="QRadioButton">
72 <property name="name">
73 <cstring>mCatShowCheck</cstring>
74 </property>
75 <property name="text">
76 <string>Show only selected</string>
77 </property>
78 </widget>
79 <widget class="QRadioButton">
80 <property name="name">
81 <cstring>mCatHideCheck</cstring>
82 </property>
83 <property name="text">
84 <string>Show all but selected</string>
85 </property>
86 </widget>
87 <widget class="QListBox">
88 <property name="name">
89 <cstring>mCatList</cstring>
90 </property>
91 </widget>
92 <widget class="QPushButton">
93 <property name="name">
94 <cstring>mCatEditButton</cstring>
95 </property>
96 <property name="text">
97 <string>Edit Selection...</string>
98 </property>
99 </widget>
100 </vbox>
101 </widget>
102 <widget class="QLayoutWidget" row="1" column="0">
103 <property name="name">
104 <cstring>layout1</cstring>
105 </property>
106 <hbox>
107 <property name="name">
108 <cstring>unnamed</cstring>
109 </property>
110 <property name="margin">
111 <number>0</number>
112 </property>
113 <property name="spacing">
114 <number>0</number>
115 </property>
116 <widget class="QLabel">
117 <property name="name">
118 <cstring>textLabel1</cstring>
119 </property>
120 <property name="text">
121 <string>Hide</string>
122 </property>
123 </widget>
124 <widget class="QCheckBox">
125 <property name="name">
126 <cstring>mRecurringCheck</cstring>
127 </property>
128 <property name="text">
129 <string>recurring events</string>
130 </property>
131 </widget>
132 <widget class="QCheckBox">
133 <property name="name">
134 <cstring>mCompletedCheck</cstring>
135 </property>
136 <property name="text">
137 <string>completed to-dos</string>
138 </property>
139 </widget>
140 </hbox>
141 </widget>
142 <widget class="QLayoutWidget" row="2" column="0">
143 <property name="name">
144 <cstring>layout2</cstring>
145 </property>
146 <hbox>
147 <property name="name">
148 <cstring>unnamed</cstring>
149 </property>
150 <property name="margin">
151 <number>0</number>
152 </property>
153 <property name="spacing">
154 <number>0</number>
155 </property>
156 <widget class="QLabel">
157 <property name="name">
158 <cstring>textLabel2</cstring>
159 </property>
160 <property name="text">
161 <string>Show</string>
162 </property>
163 </widget>
164 <widget class="QCheckBox">
165 <property name="name">
166 <cstring>mPublicCheck</cstring>
167 </property>
168 <property name="text">
169 <string>public</string>
170 </property>
171 </widget>
172 <widget class="QCheckBox">
173 <property name="name">
174 <cstring>mPrivateCheck</cstring>
175 </property>
176 <property name="text">
177 <string>private</string>
178 </property>
179 </widget>
180 <widget class="QCheckBox">
181 <property name="name">
182 <cstring>mConfidentialCheck</cstring>
183 </property>
184 <property name="text">
185 <string>confidential</string>
186 </property>
187 <property name="checked">
188 <bool>false</bool>
189 </property>
190 </widget>
191 </hbox>
192 </widget>
193 </grid>
194 </widget>
195 </vbox>
196</widget>
197<slots>
198 <slot>updateFilter()</slot>
199</slots>
200<layoutdefaults spacing="6" margin="11"/>
201</UI>
diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp
new file mode 100644
index 0000000..2943e41
--- a/dev/null
+++ b/korganizer/filtereditdialog.cpp
@@ -0,0 +1,270 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qlayout.h>
25#include <qpushbutton.h>
26#include <qcombobox.h>
27#include <qcheckbox.h>
28#include <qradiobutton.h>
29#include <qlistbox.h>
30#include <qapplication.h>
31
32#include <kdebug.h>
33#include <klocale.h>
34#include <klineeditdlg.h>
35#include <kmessagebox.h>
36
37#include <libkdepim/categoryselectdialog.h>
38
39#include "koprefs.h"
40#include "filteredit_base.h"
41
42#include "filtereditdialog.h"
43#include "filtereditdialog.moc"
44
45// TODO: Make dialog work on a copy of the filters objects.
46
47class ComboFilterBox: public QComboBox
48{
49public:
50 ComboFilterBox( QWidget *parent=0, const char *name=0) :
51 QComboBox( parent,name ) { }
52 void popupBox() { popup(); }
53
54};
55
56FilterEditDialog::FilterEditDialog(QPtrList<CalFilter> *filters,QWidget *parent,
57 const char *name) :
58 KDialogBase(parent,name,true,i18n("Edit Calendar Filters"),
59 Ok|Apply|Cancel)
60{
61 mFilters = filters;
62
63 QWidget *mainWidget = new QWidget(this);
64 setMainWidget(mainWidget);
65
66 mSelectionCombo = new ComboFilterBox(mainWidget);
67 connect(mSelectionCombo,SIGNAL(activated(int)),SLOT(filterSelected()));
68 // mSelectionCombo->setEditable ( true );
69 QPushButton *addButton = new QPushButton(i18n("Add Filter"),mainWidget);
70 connect(addButton,SIGNAL(clicked()),SLOT(slotAdd()));
71 addButton->setMaximumSize( addButton->sizeHint());
72 mRemoveButton = new QPushButton( i18n("Remove"), mainWidget );
73 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotRemove() ) );
74 mRemoveButton->setMaximumSize( mRemoveButton->sizeHint());
75
76 QPushButton *upButton = new QPushButton(i18n("Up"),mainWidget);
77 upButton->setMaximumSize( upButton->sizeHint());
78 connect(upButton,SIGNAL(clicked()),SLOT(slotUp()));
79
80
81 mEditor = new FilterEdit_base(mainWidget);
82
83 QGridLayout *topLayout = new QGridLayout(mainWidget,2,2);
84 topLayout->setSpacing(spacingHint());
85 topLayout->addWidget(mSelectionCombo,0,0);
86 topLayout->addWidget(upButton,0,1);
87 topLayout->addWidget(addButton,0,2);
88 topLayout->addWidget(mRemoveButton,0,3);
89 topLayout->addMultiCellWidget(mEditor,1,1,0,3);
90 mSelectionCombo->setMaximumWidth ( QApplication::desktop()->width() -
91 addButton->maximumWidth() -
92 mRemoveButton->maximumWidth() -
93 upButton->maximumWidth() -
94 spacingHint() * 5 );
95 connect(mEditor->mCatEditButton,SIGNAL(clicked()),
96 SLOT(editCategorySelection()));
97
98 // Clicking cancel exits the dialog without saving
99 connect(this,SIGNAL(cancelClicked()),SLOT(reject()));
100 updateFilterList();
101}
102
103FilterEditDialog::~FilterEditDialog()
104{
105}
106void FilterEditDialog::slotUp()
107{
108
109 if ( mFilters->count() <= 1 ) return;
110 if ( mSelectionCombo->currentItem() == 0 ) return;
111 int num = mSelectionCombo->currentItem();
112 CalFilter* f = new CalFilter( );
113 *f = *(mFilters->at( num ));
114 mFilters->remove( num );
115 mFilters->insert( num-1, f );
116 updateFilterList();
117 mSelectionCombo->setCurrentItem( num-1 );
118 readFilter(f);
119 //qApp->processEvents();
120 //mSelectionCombo->popupBox();
121}
122void FilterEditDialog::updateFilterList()
123{
124 mSelectionCombo->clear();
125
126 CalFilter *filter = mFilters->first();
127
128 if (!filter) {
129 enableButtonOK(false);
130 enableButtonApply(false);
131 } else {
132 while(filter) {
133 mSelectionCombo->insertItem(filter->name());
134 filter = mFilters->next();
135 }
136 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
137 if (f) readFilter(f);
138
139 enableButtonOK(true);
140 enableButtonApply(true);
141 }
142
143 mRemoveButton->setEnabled( mFilters->count() > 1 );
144}
145
146void FilterEditDialog::slotDefault()
147{
148}
149
150void FilterEditDialog::slotApply()
151{
152 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
153 writeFilter(f);
154 emit filterChanged();
155}
156void FilterEditDialog::accept()
157{
158 slotOk();
159}
160void FilterEditDialog::slotOk()
161{
162 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
163 writeFilter(f);
164 emit filterChanged();
165 QDialog::accept();
166}
167
168void FilterEditDialog::slotAdd()
169{
170 KLineEditDlg dlg(i18n("Enter filter name:"), "New Filter", this);
171 dlg.setCaption(i18n("Add Filter"));
172 if (dlg.exec()) {
173 if ( dlg.text().length() > 0 ) {
174 mFilters->append(new CalFilter(dlg.text()));
175 updateFilterList();
176 int num = mSelectionCombo->count() -1 ;
177 mSelectionCombo->setCurrentItem( num );
178 readFilter(mFilters->at( num ) );
179 }
180 }
181}
182
183void FilterEditDialog::slotRemove()
184{
185 int currentItem = mSelectionCombo->currentItem();
186 if ( currentItem < 0 ) return;
187
188 // We need at least a default filter object.
189 if ( mFilters->count() <= 1 ) return;
190
191 int result = KMessageBox::questionYesNo( this,
192 i18n("This item will be\npermanently deleted.") );
193
194 if ( result != KMessageBox::Yes ) {
195 return;
196 }
197
198 mFilters->remove( currentItem );
199 updateFilterList();
200 emit filterChanged();
201}
202
203void FilterEditDialog::editCategorySelection()
204{
205 KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog(
206 KOPrefs::instance(), this, "filterCatSelect", true );
207 dlg->setSelected(mCategories);
208
209 connect(dlg,SIGNAL(categoriesSelected(const QStringList &)),
210 SLOT(updateCategorySelection(const QStringList &)));
211
212 dlg->exec();
213}
214
215void FilterEditDialog::updateCategorySelection(const QStringList &categories)
216{
217 mCategories = categories;
218
219 mEditor->mCatList->clear();
220 mEditor->mCatList->insertStringList(mCategories);
221}
222
223void FilterEditDialog::filterSelected()
224{
225 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
226 if (f) readFilter(f);
227}
228
229void FilterEditDialog::readFilter(CalFilter *filter)
230{
231 int c = filter->criteria();
232
233 mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted);
234 mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring);
235 mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic);
236 mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate);
237 mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential);
238
239 if (c & CalFilter::ShowCategories) {
240 mEditor->mCatShowCheck->setChecked(true);
241 } else {
242 mEditor->mCatHideCheck->setChecked(true);
243 }
244
245 mEditor->mCatList->clear();
246 mEditor->mCatList->insertStringList(filter->categoryList());
247 mCategories = filter->categoryList();
248
249 setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 ));
250}
251
252void FilterEditDialog::writeFilter(CalFilter *filter)
253{
254 int c = 0;
255
256 if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted;
257 if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring;
258 if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories;
259 if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic;
260 if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate;
261 if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential;
262
263 filter->setCriteria(c);
264
265 QStringList categoryList;
266 for(uint i=0;i<mEditor->mCatList->count();++i) {
267 categoryList.append(mEditor->mCatList->text(i));
268 }
269 filter->setCategoryList(categoryList);
270}
diff --git a/korganizer/filtereditdialog.h b/korganizer/filtereditdialog.h
new file mode 100644
index 0000000..42aa3da
--- a/dev/null
+++ b/korganizer/filtereditdialog.h
@@ -0,0 +1,86 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _FILTEREDITDIALOG_H
24#define _FILTEREDITDIALOG_H
25
26#include <qptrlist.h>
27
28#include <kdialogbase.h>
29
30#include <libkcal/calfilter.h>
31
32class QComboBox;
33class ComboFilterBox;
34class QPushButton;
35class FilterEdit_base;
36
37using namespace KCal;
38
39/**
40 This is the class to add/edit a calendar filter.
41
42 @short Creates a dialog box to create/edit a calendar filter
43 @author Cornelius Schumacher
44*/
45class FilterEditDialog : public KDialogBase
46{
47 Q_OBJECT
48 public:
49 FilterEditDialog(QPtrList<CalFilter> *,QWidget *parent=0, const char *name=0);
50 virtual ~FilterEditDialog();
51
52 public slots:
53 void updateFilterList();
54
55 signals:
56 void filterChanged();
57
58 protected slots:
59 void slotDefault();
60 void slotApply();
61 void slotOk();
62 void accept();
63
64 void slotAdd();
65 void slotUp();
66 void slotRemove();
67
68 void filterSelected();
69 void editCategorySelection();
70 void updateCategorySelection(const QStringList &categories);
71
72 protected:
73 void readFilter(CalFilter *);
74 void writeFilter(CalFilter *);
75
76 private:
77 QPtrList<CalFilter> *mFilters;
78
79 ComboFilterBox *mSelectionCombo;
80 QPushButton *mRemoveButton;
81 FilterEdit_base *mEditor;
82
83 QStringList mCategories;
84};
85
86#endif
diff --git a/korganizer/filtereditdialog.moc b/korganizer/filtereditdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/filtereditdialog.moc
diff --git a/korganizer/incomingdialog.cpp b/korganizer/incomingdialog.cpp
new file mode 100644
index 0000000..490d21e
--- a/dev/null
+++ b/korganizer/incomingdialog.cpp
@@ -0,0 +1,527 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <qlistview.h>
21#include <qfile.h>
22#include <qdir.h>
23#include <qmap.h>
24
25#include <kglobal.h>
26#include <klocale.h>
27#include <kdebug.h>
28#include <kstandarddirs.h>
29#include <kmessagebox.h>
30
31#include <libkcal/incidence.h>
32#include <libkcal/event.h>
33#include <libkcal/calendar.h>
34#include <libkcal/freebusy.h>
35#include <libkcal/attendee.h>
36#include <libkcal/calendarresources.h>
37#include <libkcal/resourcecalendar.h>
38#include <kresources/resourceselectdialog.h>
39
40#ifndef KORG_NOMAIL
41#include "mailscheduler.h"
42#else
43#include <libkcal/dummyscheduler.h>
44#endif
45
46
47#include "incomingdialog.h"
48#include "koeventviewerdialog.h"
49#include "kocounterdialog.h"
50#include "koprefs.h"
51
52#ifndef KORG_NOKABC
53#include <kabc/stdaddressbook.h>
54#define size count
55#endif
56
57
58ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev,
59 Scheduler::Method method,ScheduleMessage::Status status)
60 : QListViewItem(parent)
61{
62 mIncidence = ev;
63 mMethod = method;
64 mStatus = status;
65 setText(6,Scheduler::translatedMethodName(mMethod)+" ");
66 setText(7,ScheduleMessage::statusName(status));
67}
68
69
70/* Visitor */
71ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item)
72{
73 mItem = item;
74}
75
76ScheduleItemVisitor::~ScheduleItemVisitor()
77{
78}
79
80bool ScheduleItemVisitor::visit(Event *e)
81{
82 mItem->setText(0,e->summary());
83 mItem->setText(1,e->dtStartDateStr());
84 if (e->doesFloat()) {
85 mItem->setText(2,i18n("no time "));
86 mItem->setText(4,i18n("no time "));
87 }
88 else {
89 mItem->setText(2,e->dtStartTimeStr());
90 mItem->setText(4,e->dtEndTimeStr());
91 }
92 if (e->hasEndDate()) {
93 mItem->setText(3,e->dtEndDateStr());
94 }
95 else {
96 mItem->setText(3,"");
97 }
98 mItem->setText(5,e->organizer()+" ");
99
100 return true;
101}
102
103bool ScheduleItemVisitor::visit(Todo *e)
104{
105 mItem->setText(0,e->summary());
106 if (e->hasStartDate()) {
107 mItem->setText(1,e->dtStartDateStr());
108 if (!e->doesFloat()) {
109 mItem->setText(2,e->dtStartTimeStr());
110 }
111 }
112 if (e->hasDueDate()) {
113 mItem->setText(1,e->dtDueDateStr());
114 if (!e->doesFloat()) {
115 mItem->setText(2,e->dtDueTimeStr());
116 }
117 }
118 mItem->setText(5,e->organizer()+" ");
119
120 return true;
121}
122
123bool ScheduleItemVisitor::visit(Journal *)
124{
125 return false;
126}
127
128
129/*
130 * Constructs a IncomingDialog which is a child of 'parent', with the
131 * name 'name' and widget flags set to 'f'
132 *
133 * The dialog will by default be modeless, unless you set 'modal' to
134 * TRUE to construct a modal dialog.
135 */
136IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing,
137 QWidget* parent,const char* name,bool modal,WFlags fl) :
138 IncomingDialog_base(parent,name,modal,fl)
139{
140 mCalendar = calendar;
141 mOutgoing = outgoing;
142#ifndef KORG_NOMAIL
143 mScheduler = new MailScheduler(mCalendar);
144#else
145 mScheduler = new DummyScheduler(mCalendar);
146#endif
147 mMessageListView->setColumnAlignment(1,AlignHCenter);
148 mMessageListView->setColumnAlignment(2,AlignHCenter);
149 mMessageListView->setColumnAlignment(3,AlignHCenter);
150 mMessageListView->setColumnAlignment(4,AlignHCenter);
151 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)),
152 this,SLOT(showEvent(QListViewItem *)));
153 retrieve();
154}
155
156/*
157 * Destroys the object and frees any allocated resources
158 */
159IncomingDialog::~IncomingDialog()
160{
161 // no need to delete child widgets, Qt does it all for us
162}
163
164void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing)
165{
166 mOutgoing = outgoing;
167}
168
169void IncomingDialog::retrieve()
170{
171 QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions();
172
173 ScheduleMessage *message;
174 for(message = messages.first();message;message = messages.next()) {
175 IncidenceBase *inc = message->event();
176 Scheduler::Method method = (Scheduler::Method)message->method();
177 ScheduleMessage::Status status = message->status();
178
179 ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status);
180 if(inc->type()!="FreeBusy") {
181 Incidence *incidence = static_cast<Incidence *>(inc);
182 ScheduleItemVisitor v(item);
183 if (!incidence->accept(v)) delete item;
184 } else {
185 FreeBusy *fb = static_cast<FreeBusy *>(item->event());
186 item->setText(0, "FreeBusy");
187 item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) );
188 item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) );
189 item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) );
190 item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) );
191 item->setText(5, fb->organizer());
192 }
193 automaticAction(item);
194 }
195 emit numMessagesChanged(mMessageListView->childCount());
196}
197
198void IncomingDialog::acceptAllMessages()
199{
200 bool success = false;
201
202 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild();
203 while(item) {
204 ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling());
205 if (acceptMessage(item)) success = true;
206 item = nextitem;
207 }
208
209 if (success) emit calendarUpdated();
210}
211
212void IncomingDialog::acceptMessage()
213{
214 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem();
215 if (item) {
216 if (acceptMessage(item)) emit calendarUpdated();
217 }
218}
219
220bool IncomingDialog::acceptMessage(ScheduleItemIn *item)
221{
222 switch (item->method()) {
223 case Scheduler::Refresh:
224 return incomeRefresh(item);
225 break;
226 case Scheduler::Counter:
227 return incomeCounter(item);
228 break;
229 case Scheduler::Declinecounter:
230 return incomeDeclineCounter(item);
231 break;
232 case Scheduler::Add:
233 return incomeAdd(item);
234 break;
235 case Scheduler::Request:
236 return incomeRequest(item);
237 break;
238 default:
239 return incomeDefault(item);
240 }
241 return false;
242}
243
244void IncomingDialog::rejectMessage()
245{
246 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem();
247 if (item) {
248 mScheduler->deleteTransaction(item->event());
249 delete item;
250 emit numMessagesChanged(mMessageListView->childCount());
251 }
252}
253
254void IncomingDialog::showEvent(QListViewItem *item)
255{
256 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
257 if( incidence && incidence->type() == "Event" ) {
258 Event *event = static_cast<Event *>(incidence);
259 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this);
260 eventViewer->setEvent(event);
261 eventViewer->show();
262 }
263}
264
265bool IncomingDialog::incomeRefresh(ScheduleItemIn *item)
266{
267 Event *ev = mCalendar->event(item->event()->uid());
268 if (ev) {
269 //user interaction before??
270 Attendee *att;
271 QPtrList<Attendee> attlist = ev->attendees();
272 for (att=attlist.first(); att; att=attlist.next()) {
273 Event *event = new Event(*ev);
274 mOutgoing->addMessage(event,Scheduler::Request,att->email());
275 delete(event);
276 }
277 mScheduler->deleteTransaction(item->event());
278 delete item;
279 emit numMessagesChanged(mMessageListView->childCount());
280 return true;
281 }
282 mScheduler->deleteTransaction(item->event());
283 delete item;
284 emit numMessagesChanged(mMessageListView->childCount());
285 return false;
286}
287
288bool IncomingDialog::incomeCounter(ScheduleItemIn *item)
289{
290 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
291 // currently only events supportet - attetion at insertion below!
292 if ( incidence->type() != "Event" ) return false;
293
294 Event *counterEvent = static_cast<Event *>( incidence );
295
296 Event *even = mCalendar->event(counterEvent->uid());
297
298 KOCounterDialog *eventViewer = new KOCounterDialog(this);
299 eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>"));
300 eventViewer->addEvent(counterEvent);
301 eventViewer->addText("<hr>");
302 eventViewer->addText(i18n("<b>Original event:</b><p>"));
303 if (even) eventViewer->addEvent(even);
304 else eventViewer->addText(i18n("A corresponding event is missing in your calendar!"));
305 eventViewer->addText("<hr>");
306 eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event"));
307 eventViewer->show();
308
309 eventViewer->exec();
310 if (eventViewer->result()) {
311 kdDebug() << "IncomingDialog::Counter:Accept" << endl;
312 int revision = 0;
313 if (even) {
314 revision = even->revision();
315 mCalendar->deleteEvent(even);
316 }
317 mCalendar->addIncidence(counterEvent);
318
319 even = mCalendar->event(item->event()->uid());
320 if (even) {
321 if (revision < even->revision())
322 even->setRevision(even->revision()+1);
323 else
324 even->setRevision(revision+1);
325 Event *ev = new Event(*even);
326 mOutgoing->addMessage(ev,Scheduler::Request);
327 delete(ev);
328 }
329 mScheduler->deleteTransaction(item->event());
330 delete item;
331 emit numMessagesChanged(mMessageListView->childCount());
332 return true;
333 } else {
334 kdDebug() << "IncomingDialog::Counter:Decline" << endl;
335 //the counter-sender's email is missing...
336 //now every attendee gets an declinecounter :-(
337 mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter);
338 delete item;
339 emit numMessagesChanged(mMessageListView->childCount());
340 mScheduler->deleteTransaction(item->event());
341 delete item;
342 emit numMessagesChanged(mMessageListView->childCount());
343 return true;
344 }
345 //mScheduler->deleteTransaction(item->event());
346 delete item;
347 emit numMessagesChanged(mMessageListView->childCount());
348 return false;
349}
350
351bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item)
352{
353 Event *even = mCalendar->event(item->event()->uid());
354 if (even) {
355 mOutgoing->addMessage(even,Scheduler::Refresh);
356 mScheduler->deleteTransaction(item->event());
357 delete item;
358 emit numMessagesChanged(mMessageListView->childCount());
359 return true;
360 }
361 mScheduler->deleteTransaction(item->event());
362 delete item;
363 emit numMessagesChanged(mMessageListView->childCount());
364 return false;
365}
366
367bool IncomingDialog::incomeAdd(ScheduleItemIn *item)
368{
369 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
370 if (incidence->type() == "Event" ) {
371 Event *refr = static_cast<Event *>( incidence );
372 mOutgoing->addMessage(refr,Scheduler::Refresh);
373 mScheduler->deleteTransaction( incidence );
374 delete item;
375 emit numMessagesChanged(mMessageListView->childCount());
376 return true;
377 }
378 else {
379 kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl;
380 mScheduler->deleteTransaction( incidence );
381 delete item;
382 emit numMessagesChanged(mMessageListView->childCount());
383 return false;
384 }
385}
386
387bool IncomingDialog::incomeDefault(ScheduleItemIn *item)
388{
389 if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) {
390 delete item;
391 emit numMessagesChanged(mMessageListView->childCount());
392 return true;
393 }
394 else {
395 KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses."));
396 kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl;
397 return false;
398 }
399 return false;
400}
401
402bool IncomingDialog::incomeRequest(ScheduleItemIn *item)
403{
404 if (item->event()->type()=="FreeBusy") {
405 //handel freebusy request
406 IncidenceBase *inc = item->event();
407 QDateTime start = inc->dtStart();
408 QDateTime end = start.addDays(inc->duration()/86400);
409
410 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
411 freebusy->setOrganizer(inc->organizer());
412 Attendee *att = new Attendee(KOPrefs::instance()->fullName(),
413 KOPrefs::instance()->email());
414 freebusy->addAttendee(att);
415
416 kdDebug() << "calendarview: schedule_publish_freebusy: startDate: "
417 << KGlobal::locale()->formatDateTime( start ) << " End Date: "
418 << KGlobal::locale()->formatDateTime( end ) << endl;
419
420 if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) {
421 delete item;
422 emit numMessagesChanged(mMessageListView->childCount());
423 delete(freebusy);
424 return true;
425 }
426 return false;
427 } else {
428 return incomeDefault(item);
429 }
430 return false;
431}
432
433bool IncomingDialog::automaticAction(ScheduleItemIn *item)
434{
435 bool autoAction = false;
436 IncidenceBase *inc = item->event();
437 Scheduler::Method method = item->method();
438
439 if( inc->type()=="FreeBusy" ) {
440 if ( method==Scheduler::Request ) {
441 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
442 // reply freebusy information
443 if ( checkOrganizerInAddressbook(inc->organizer()) ) {
444 incomeRequest(item);
445 }
446 } else return false;
447 } else {
448
449 if ( method==Scheduler::Reply ) {
450 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
451 // insert freebusy information
452 //if ( checkAttendeesInAddressbook(inc) )
453
454 } else return false;
455 } else {
456 if ( method==Scheduler::Publish) {
457 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
458 // insert freebusy information
459 //if ( checkOrganizerInAddressbook(inc->organizer()) )
460
461 }
462 } else return false;
463 }
464 }
465 }
466
467 if ( inc->type()=="Event" ) {
468 if ( method==Scheduler::Request || method==Scheduler::Publish ) {
469 if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) {
470 // insert event
471 if ( checkOrganizerInAddressbook(inc->organizer()) )
472 autoAction = acceptMessage(item);
473 } else return false;
474 } else {
475
476 if ( method==Scheduler::Reply ) {
477 if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) {
478 // update event information
479 if ( checkAttendeesInAddressbook(inc) )
480 autoAction = acceptMessage(item);
481 } else return false;
482 } else {
483
484 if ( method==Scheduler::Refresh ) {
485 if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) {
486 // send refresh-information
487 if ( checkAttendeesInAddressbook(inc) )
488 autoAction = acceptMessage(item);
489 else return false;
490 } else return false;
491 } else return false;
492 }
493 }
494 }
495 return autoAction;
496}
497
498bool IncomingDialog::checkOrganizerInAddressbook(QString organizer)
499{
500 bool inBook = false;
501#ifndef KORG_NOKABC
502 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
503 KABC::Addressee::List addressList;
504 addressList = add_book->findByEmail(organizer);
505 if ( addressList.size()>0 ) inBook = true;
506#endif
507 return inBook;
508}
509
510bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc)
511{
512 bool inBook = false;
513#ifndef KORG_NOKABC
514 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
515 KABC::Addressee::List addressList;
516 QPtrList <Attendee> attendees;
517 Attendee *att;
518 attendees = inc->attendees();
519 for (att=attendees.first();att;att=attendees.next()) {
520 addressList = add_book->findByEmail(att->email());
521 if (addressList.size()>0 ) inBook = true;
522 }
523#endif
524 return inBook;
525}
526
527#include "incomingdialog.moc"
diff --git a/korganizer/incomingdialog.h b/korganizer/incomingdialog.h
new file mode 100644
index 0000000..413ce6a
--- a/dev/null
+++ b/korganizer/incomingdialog.h
@@ -0,0 +1,110 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef INCOMINGDIALOG_H
20#define INCOMINGDIALOG_H
21
22#include <qlistview.h>
23
24#include <libkcal/calendar.h>
25#include <libkcal/scheduler.h>
26
27#include "incomingdialog_base.h"
28#include "outgoingdialog.h"
29
30using namespace KCal;
31
32class ScheduleItemIn : public QListViewItem
33{
34 public:
35 ScheduleItemIn(QListView *parent,IncidenceBase *ev,Scheduler::Method method,
36 ScheduleMessage::Status status);
37 virtual ~ScheduleItemIn() {}
38
39 IncidenceBase *event() { return mIncidence; }
40 Scheduler::Method method() { return mMethod; }
41 ScheduleMessage::Status status() { return mStatus; }
42
43 private:
44 IncidenceBase *mIncidence;
45 Scheduler::Method mMethod;
46 ScheduleMessage::Status mStatus;
47};
48
49
50/**
51 This class provides the initialisation of a ScheduleItemIn for calendar
52 components using the Incidence::Visitor.
53*/
54class ScheduleItemVisitor : public Incidence::Visitor
55{
56 public:
57 ScheduleItemVisitor(ScheduleItemIn *);
58 ~ScheduleItemVisitor();
59
60 bool visit(Event *);
61 bool visit(Todo *);
62 bool visit(Journal *);
63
64 private:
65 ScheduleItemIn *mItem;
66};
67
68
69
70class IncomingDialog : public IncomingDialog_base
71{
72 Q_OBJECT
73 public:
74 IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing,
75 QWidget* parent=0,const char* name=0,bool modal=false,WFlags fl=0);
76 ~IncomingDialog();
77
78 void setOutgoingDialog(OutgoingDialog *outgoing);
79
80 signals:
81 void calendarUpdated();
82 void numMessagesChanged(int);
83 public slots:
84 void retrieve();
85
86 protected slots:
87 void acceptAllMessages();
88 void acceptMessage();
89 void rejectMessage();
90 void showEvent(QListViewItem *);
91
92 protected:
93 bool acceptMessage(ScheduleItemIn *item);
94 bool incomeRefresh(ScheduleItemIn *item);
95 bool incomeCounter(ScheduleItemIn *item);
96 bool incomeDeclineCounter(ScheduleItemIn *item);
97 bool incomeAdd(ScheduleItemIn *item);
98 bool incomeRequest(ScheduleItemIn *item);
99 bool incomeDefault(ScheduleItemIn *item);
100 bool automaticAction(ScheduleItemIn *item);
101
102 private:
103 bool checkAttendeesInAddressbook(IncidenceBase *inc);
104 bool checkOrganizerInAddressbook(QString organizer);
105 Calendar *mCalendar;
106 Scheduler *mScheduler;
107 OutgoingDialog *mOutgoing;
108};
109
110#endif // INCOMINGDIALOG_H
diff --git a/korganizer/incomingdialog.moc b/korganizer/incomingdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/incomingdialog.moc
diff --git a/korganizer/incomingdialog_base.cpp b/korganizer/incomingdialog_base.cpp
new file mode 100644
index 0000000..91740a4
--- a/dev/null
+++ b/korganizer/incomingdialog_base.cpp
@@ -0,0 +1,137 @@
1#include <klocale.h>
2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/incomingdialog_base.ui'
4**
5** Created: Sat Mar 29 22:31:27 2003
6** by: The User Interface Compiler ()
7**
8** WARNING! All changes made in this file will be lost!
9****************************************************************************/
10
11#include "incomingdialog_base.h"
12
13#include <qvariant.h>
14#include <qheader.h>
15#include <qlistview.h>
16#include <qpushbutton.h>
17#include <qlayout.h>
18#include <qtooltip.h>
19#include <qwhatsthis.h>
20
21/*
22 * Constructs a IncomingDialog_base as a child of 'parent', with the
23 * name 'name' and widget flags set to 'f'.
24 *
25 * The dialog will by default be modeless, unless you set 'modal' to
26 * TRUE to construct a modal dialog.
27 */
28IncomingDialog_base::IncomingDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
29 : QDialog( parent, name, modal, fl )
30
31{
32 if ( !name )
33 setName( "IncomingDialog_base" );
34 IncomingDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "IncomingDialog_baseLayout");
35
36 PushButton4 = new QPushButton( this, "PushButton4" );
37
38 IncomingDialog_baseLayout->addWidget( PushButton4, 0, 1 );
39
40 PushButton7 = new QPushButton( this, "PushButton7" );
41 PushButton7->setDefault( TRUE );
42
43 IncomingDialog_baseLayout->addWidget( PushButton7, 5, 1 );
44
45 mMessageListView = new QListView( this, "mMessageListView" );
46 mMessageListView->addColumn( tr2i18n( "Summary" ) );
47 mMessageListView->addColumn( tr2i18n( "Start Date" ) );
48 mMessageListView->addColumn( tr2i18n( "Start Time" ) );
49 mMessageListView->addColumn( tr2i18n( "End Date" ) );
50 mMessageListView->addColumn( tr2i18n( "End Time" ) );
51 mMessageListView->addColumn( tr2i18n( "Organizer" ) );
52 mMessageListView->addColumn( tr2i18n( "Method" ) );
53 mMessageListView->addColumn( tr2i18n( "Status" ) );
54 mMessageListView->setAllColumnsShowFocus( FALSE );
55
56 IncomingDialog_baseLayout->addMultiCellWidget( mMessageListView, 0, 5, 0, 0 );
57
58 PushButton7_2 = new QPushButton( this, "PushButton7_2" );
59
60 IncomingDialog_baseLayout->addWidget( PushButton7_2, 3, 1 );
61
62 PushButton8 = new QPushButton( this, "PushButton8" );
63
64 IncomingDialog_baseLayout->addWidget( PushButton8, 1, 1 );
65
66 PushButton9 = new QPushButton( this, "PushButton9" );
67
68 IncomingDialog_baseLayout->addWidget( PushButton9, 2, 1 );
69 QSpacerItem* spacer = new QSpacerItem( 20, 70, QSizePolicy::Minimum, QSizePolicy::Expanding );
70 IncomingDialog_baseLayout->addItem( spacer, 4, 1 );
71 languageChange();
72 resize( QSize(525, 262).expandedTo(minimumSizeHint()) );
73
74 // signals and slots connections
75 connect( PushButton7, SIGNAL( clicked() ), this, SLOT( accept() ) );
76 connect( PushButton4, SIGNAL( clicked() ), this, SLOT( retrieve() ) );
77 connect( PushButton7_2, SIGNAL( clicked() ), this, SLOT( acceptAllMessages() ) );
78
79 // tab order
80 setTabOrder( PushButton7, PushButton4 );
81 setTabOrder( PushButton4, PushButton7_2 );
82 setTabOrder( PushButton7_2, mMessageListView );
83 setTabOrder( mMessageListView, PushButton8 );
84 setTabOrder( PushButton8, PushButton9 );
85}
86
87/*
88 * Destroys the object and frees any allocated resources
89 */
90IncomingDialog_base::~IncomingDialog_base()
91{
92 // no need to delete child widgets, Qt does it all for us
93}
94
95/*
96 * Sets the strings of the subwidgets using the current
97 * language.
98 */
99void IncomingDialog_base::languageChange()
100{
101 setCaption( tr2i18n( "Scheduler - Incoming Messages" ) );
102 PushButton4->setText( tr2i18n( "Retrieve &Messages" ) );
103 PushButton7->setText( tr2i18n( "&Close" ) );
104 mMessageListView->header()->setLabel( 0, tr2i18n( "Summary" ) );
105 mMessageListView->header()->setLabel( 1, tr2i18n( "Start Date" ) );
106 mMessageListView->header()->setLabel( 2, tr2i18n( "Start Time" ) );
107 mMessageListView->header()->setLabel( 3, tr2i18n( "End Date" ) );
108 mMessageListView->header()->setLabel( 4, tr2i18n( "End Time" ) );
109 mMessageListView->header()->setLabel( 5, tr2i18n( "Organizer" ) );
110 mMessageListView->header()->setLabel( 6, tr2i18n( "Method" ) );
111 mMessageListView->header()->setLabel( 7, tr2i18n( "Status" ) );
112 PushButton7_2->setText( tr2i18n( "Accept A&ll" ) );
113 PushButton8->setText( tr2i18n( "&Accept" ) );
114 PushButton9->setText( tr2i18n( "&Reject" ) );
115}
116
117void IncomingDialog_base::acceptAllMessages()
118{
119 qWarning( "IncomingDialog_base::acceptAllMessages(): Not implemented yet" );
120}
121
122void IncomingDialog_base::acceptMessage()
123{
124 qWarning( "IncomingDialog_base::acceptMessage(): Not implemented yet" );
125}
126
127void IncomingDialog_base::rejectMessage()
128{
129 qWarning( "IncomingDialog_base::rejectMessage(): Not implemented yet" );
130}
131
132void IncomingDialog_base::retrieve()
133{
134 qWarning( "IncomingDialog_base::retrieve(): Not implemented yet" );
135}
136
137#include "incomingdialog_base.moc"
diff --git a/korganizer/incomingdialog_base.h b/korganizer/incomingdialog_base.h
new file mode 100644
index 0000000..7732384
--- a/dev/null
+++ b/korganizer/incomingdialog_base.h
@@ -0,0 +1,51 @@
1/****************************************************************************
2** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/incomingdialog_base.ui'
3**
4** Created: Sat Mar 29 22:24:26 2003
5** by: The User Interface Compiler ()
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9
10#ifndef INCOMINGDIALOG_BASE_H
11#define INCOMINGDIALOG_BASE_H
12
13#include <qvariant.h>
14#include <qdialog.h>
15
16class QVBoxLayout;
17class QHBoxLayout;
18class QGridLayout;
19class QListView;
20class QListViewItem;
21class QPushButton;
22
23class IncomingDialog_base : public QDialog
24{
25 Q_OBJECT
26
27public:
28 IncomingDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
29 ~IncomingDialog_base();
30
31 QPushButton* PushButton4;
32 QPushButton* PushButton7;
33 QListView* mMessageListView;
34 QPushButton* PushButton7_2;
35 QPushButton* PushButton8;
36 QPushButton* PushButton9;
37
38protected:
39 QGridLayout* IncomingDialog_baseLayout;
40
41protected slots:
42 virtual void languageChange();
43
44 virtual void acceptAllMessages();
45 virtual void acceptMessage();
46 virtual void rejectMessage();
47 virtual void retrieve();
48
49};
50
51#endif // INCOMINGDIALOG_BASE_H
diff --git a/korganizer/incomingdialog_base.moc b/korganizer/incomingdialog_base.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/incomingdialog_base.moc
diff --git a/korganizer/interfaces/korganizer/baseview.h b/korganizer/interfaces/korganizer/baseview.h
new file mode 100644
index 0000000..09f8ba3
--- a/dev/null
+++ b/korganizer/interfaces/korganizer/baseview.h
@@ -0,0 +1,192 @@
1/*
2 This file is part of the KOrganizer interfaces.
3 Copyright (c) 1999 Cornelius Schumacher <schumacher@kde.org>
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21#ifndef KORG_BASEVIEW_H
22#define KORG_BASEVIEW_H
23// $Id$
24// KOBaseView is the abstract base class of all calendar views.
25
26#include <qwidget.h>
27#include <qptrlist.h>
28#include <qvaluelist.h>
29
30#include <klocale.h>
31#include <kdebug.h>
32#include <kmessagebox.h>
33
34#include <libkcal/event.h>
35#include <libkcal/calendar.h>
36
37using namespace KCal;
38
39class CalPrinter;
40
41namespace KOrg {
42
43class CalPrinterBase
44{
45 public:
46 enum PrintType { Day, Week, Month, Todolist };
47};
48
49
50/**
51 This class provides an interface for all views being displayed within the main
52 calendar view. It has functions to update the view, to specify date range and
53 other display parameter and to return selected objects. An important class,
54 which inherits KOBaseView is KOEventView, which provides the interface for all
55 views of event data like the agenda or the month view.
56
57 @short Base class for calendar views
58 @author Preston Brown, Cornelius Schumacher
59 @see KOTodoView, KOEventView, KOListView, KOAgendaView, KOMonthView
60*/
61class BaseView : public QWidget
62{
63 Q_OBJECT
64 public:
65 /**
66 Constructs a view.
67
68 @param cal Pointer to the calendar object from which events
69 will be retrieved for display.
70 @param parent parent widget.
71 @param name name of this widget.
72 */
73 BaseView(Calendar *cal, QWidget *parent = 0, const char *name = 0) :
74 QWidget(parent, name), mCalendar(cal) {}
75
76 /**
77 Destructor. Views will do view-specific cleanups here.
78 */
79 virtual ~BaseView() {}
80
81 /**
82 Return calendar object of this view.
83 */
84 Calendar *calendar() { return mCalendar; }
85
86 /**
87 @return a list of selected events. Most views can probably only
88 select a single event at a time, but some may be able to select
89 more than one.
90 */
91 virtual QPtrList<Incidence> selectedIncidences() = 0;
92
93 /**
94 @return a list of the dates of selected events. Most views can probably only
95 select a single event at a time, but some may be able to select
96 more than one.
97 */
98 virtual DateList selectedDates() = 0;
99
100 /**
101 Generate a print preview of this event view.
102
103 @param calPrinter Calendar printer object used for printing
104 @param fd from date
105 @param td to date
106 */
107/*
108 The date parameters should be determined by the view itself and not given as
109 parameters. At the moment I just move the code from the topwidget to the
110 individual views.
111*/
112 virtual void printPreview(CalPrinter *,
113 const QDate &, const QDate &)
114 {
115 KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n"
116 "that view yet.\n"));
117 }
118
119 /**
120 Print this view.
121
122 @param calPrinter Calendar printer object used for printing
123 */
124 virtual void print(CalPrinter *)
125 {
126 KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n"
127 "that view yet.\n"));
128 }
129
130 /**
131 Return number of currently shown dates. A return value of 0 means no idea.
132 */
133 virtual int currentDateCount() = 0;
134
135 /** Return if this view is a view for displaying events. */
136 virtual bool isEventView() { return false; }
137
138 public slots:
139 /**
140 Show incidences for the given date range. The date range actually shown may be
141 different from the requested range, depending on the particular requirements
142 of the view.
143
144 @param start Start of date range.
145 @param end End of date range.
146 */
147 virtual void showDates( const QDate &start, const QDate &end ) = 0;
148
149 /**
150 Show given events. Depending on the actual view it might not be possible to
151 show all given events.
152
153 @param eventList a list of events to show.
154 */
155 virtual void showEvents(QPtrList<Event> eventList) = 0;
156
157 /**
158 Updates the current display to reflect changes that may have happened
159 in the calendar since the last display refresh.
160 */
161 virtual void updateView() = 0;
162
163 /**
164 Write all unsaved data back to calendar store.
165 */
166 virtual void flushView() {}
167
168 /**
169 Updates the current display to reflect the changes to one particular event.
170 */
171 virtual void changeEventDisplay(Event *, int) = 0;
172
173 /**
174 Re-reads the KOrganizer configuration and picks up relevant
175 changes which are applicable to the view.
176 */
177 virtual void updateConfig() {}
178
179 /**
180 Clear selection. The incidenceSelected signal is not emitted.
181 */
182 virtual void clearSelection() {}
183
184 signals:
185 void incidenceSelected( Incidence * );
186
187 protected:
188 Calendar *mCalendar;
189};
190
191}
192#endif
diff --git a/korganizer/interfaces/korganizer/calendarviewbase.h b/korganizer/interfaces/korganizer/calendarviewbase.h
new file mode 100644
index 0000000..3c715b1
--- a/dev/null
+++ b/korganizer/interfaces/korganizer/calendarviewbase.h
@@ -0,0 +1,65 @@
1/*
2 This file is part of the KOrganizer interfaces.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
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
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20#ifndef KORG_CALENDARVIEWBASE_H
21#define KORG_CALENDARVIEWBASE_H
22// $Id$
23
24#include <qwidget.h>
25#include <qlayout.h>
26
27
28#include <libkcal/calendar.h>
29
30#include <korganizer/baseview.h>
31
32namespace KOrg {
33
34/**
35 @short interface for main calendar view widget
36 @author Cornelius Schumacher
37*/
38class CalendarViewBase : public QWidget
39{
40 Q_OBJECT
41 public:
42 CalendarViewBase(QWidget *parent, const char *name) :
43 QWidget(parent,name) {new QVBoxLayout(this);}
44 virtual ~CalendarViewBase() {};
45
46 virtual KCal::Calendar *calendar() = 0;
47
48 virtual QDate startDate() = 0;
49 virtual QDate endDate() = 0;
50
51 virtual Incidence *currentSelection() = 0;
52
53 virtual void addView(KOrg::BaseView *) = 0;
54
55 /** changes the view to be the currently selected view */
56 virtual void showView(KOrg::BaseView *) = 0;
57
58 public slots:
59 virtual void updateView() = 0;
60
61};
62
63}
64
65#endif
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
new file mode 100644
index 0000000..d1d7946
--- a/dev/null
+++ b/korganizer/journalentry.cpp
@@ -0,0 +1,170 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24//
25// Journal Entry
26
27#include <qlabel.h>
28#include <qlayout.h>
29
30#include <kdebug.h>
31#include <kglobal.h>
32#include <klocale.h>
33#include <ktextedit.h>
34#include "koprefs.h"
35
36#include <libkcal/journal.h>
37#include <libkcal/calendarresources.h>
38#include <libkcal/resourcecalendar.h>
39#include <kresources/resourceselectdialog.h>
40
41#include "journalentry.h"
42#include "journalentry.moc"
43#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h>
45#endif
46JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
47 QFrame(parent)
48{
49 mCalendar = calendar;
50 mJournal = 0;
51 mDirty = false;
52
53 mTitleLabel = new QLabel(i18n("Title"),this);
54 mTitleLabel->setMargin(2);
55 mTitleLabel->setAlignment(AlignCenter);
56
57 mEditor = new KTextEdit(this);
58 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty()));
59#ifndef DESKTOP_VERSION
60 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
61#endif
62 mEditor->setWordWrap( KTextEdit::WidgetWidth );
63 QBoxLayout *topLayout = new QVBoxLayout(this);
64 topLayout->addWidget(mTitleLabel);
65 topLayout->addWidget(mEditor);
66 mEditor->installEventFilter(this);
67}
68
69JournalEntry::~JournalEntry()
70{
71}
72
73void JournalEntry::setDate(const QDate &date)
74{
75 writeJournal();
76
77 mTitleLabel->setText(KGlobal::locale()->formatDate(date));
78
79
80 mDate = date;
81}
82
83void JournalEntry::setJournal(Journal *journal)
84{
85 writeJournal();
86
87 mJournal = journal;
88
89 mEditor->setText(mJournal->description());
90
91 mDirty = false;
92}
93
94Journal *JournalEntry::journal() const
95{
96 return mJournal;
97}
98
99void JournalEntry::setDirty()
100{
101 mDirty = true;
102
103// kdDebug() << "JournalEntry::setDirty()" << endl;
104}
105
106void JournalEntry::clear()
107{
108 mJournal = 0;
109 mEditor->setText("");
110}
111
112bool JournalEntry::eventFilter( QObject *o, QEvent *e )
113{
114// kdDebug() << "JournalEntry::event received " << e->type() << endl;
115
116 if ( e->type() == QEvent::FocusOut ) {
117 writeJournal();
118 }
119 if ( e->type() == QEvent::KeyPress ) {
120 QKeyEvent * k = (QKeyEvent *) e;
121 if ( k->state() == Qt::ControlButton ) {
122 k->ignore();
123 //return true;
124 }
125 }
126
127 return QFrame::eventFilter( o, e ); // standard event processing
128}
129
130void JournalEntry::writeJournal()
131{
132// kdDebug() << "JournalEntry::writeJournal()" << endl;
133 if (!mDirty) return;
134
135 if (mEditor->text().isEmpty()) {
136 if ( mJournal ) {
137 mDirty = false;
138 bool conf = KOPrefs::instance()->mConfirm;
139 KOPrefs::instance()->mConfirm = false;
140 emit deleteJournal(mJournal);
141 KOPrefs::instance()->mConfirm = conf;
142 mJournal = 0;
143 }
144 return;
145 }
146
147// kdDebug() << "JournalEntry::writeJournal()..." << endl;
148
149 if (!mJournal) {
150 mJournal = new Journal;
151 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
152 mCalendar->addJournal(mJournal);
153 }
154
155 mJournal->setDescription(mEditor->text());
156
157 mDirty = false;
158}
159
160void JournalEntry::flushEntry()
161{
162 if (!mDirty) return;
163
164 writeJournal();
165}
166void JournalEntry::keyPressEvent ( QKeyEvent * e )
167{
168 e->ignore();
169
170}
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
new file mode 100644
index 0000000..1f784f4
--- a/dev/null
+++ b/korganizer/journalentry.h
@@ -0,0 +1,73 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef JOURNALENTRY_H
24#define JOURNALENTRY_H
25//
26// Widget showing one Journal entry
27
28#include <qframe.h>
29
30#include <libkcal/calendar.h>
31
32class QLabel;
33class KTextEdit;
34
35using namespace KCal;
36
37class JournalEntry : public QFrame {
38 Q_OBJECT
39 public:
40 JournalEntry(Calendar *,QWidget *parent);
41 virtual ~JournalEntry();
42
43 void setJournal(Journal *);
44 Journal *journal() const;
45
46 void setDate(const QDate &);
47
48 void clear();
49
50 void flushEntry();
51
52 protected slots:
53 void setDirty();
54 signals:
55 void deleteJournal(Journal *);
56
57 protected:
58 bool eventFilter( QObject *o, QEvent *e );
59
60 void writeJournal();
61
62 private:
63 Calendar *mCalendar;
64 Journal *mJournal;
65 QDate mDate;
66 void keyPressEvent ( QKeyEvent * ) ;
67 QLabel *mTitleLabel;
68 KTextEdit *mEditor;
69
70 bool mDirty;
71};
72
73#endif
diff --git a/korganizer/journalentry.moc b/korganizer/journalentry.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/journalentry.moc
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
new file mode 100644
index 0000000..12e983b
--- a/dev/null
+++ b/korganizer/kdatenavigator.cpp
@@ -0,0 +1,364 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qstring.h>
25#include <qkeycode.h>
26#include <qlayout.h>
27#include <qtimer.h>
28#include <qframe.h>
29#include <qlabel.h>
30#include <qapplication.h>
31
32#include <kdebug.h>
33#include <klocale.h>
34#include <kglobal.h>
35
36#include "koglobals.h"
37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS
39#include "kocore.h"
40#endif
41
42#include <kcalendarsystem.h>
43
44#include "navigatorbar.h"
45
46#include "kdatenavigator.h"
47
48KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar,
49 bool show_week_nums, const char *name,
50 QDate startDate )
51 : QFrame(parent, name),
52 updateTimer(0L)
53{
54 mCalendar = calendar;
55
56 setFrameStyle(QFrame::NoFrame);
57
58 QGridLayout *topLayout = new QGridLayout(this,8,8);
59
60 if (! startDate.isValid()) {
61 kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl;
62 startDate = QDate::currentDate();
63 }
64
65 mSelectedDates.append(startDate);
66 m_MthYr = startDate;
67 m_bShowWeekNums = show_week_nums;
68
69 setFont( KOPrefs::instance()->mDateNavigatorFont );
70 mNavigatorBar = new NavigatorBar( startDate, this );
71 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
72 //mNavigatorBar->resize( 1,1);
73 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
74 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
75 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
76 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
77 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
78
79 // get the day of the week on the first day
80 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
81 m_fstDayOfWk = dayone.dayOfWeek();
82
83 int i;
84
85 // Set up the heading fields.
86 for( i = 0; i < 7; i++ ) {
87 headings[i] = new QLabel("",this);
88 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
89 headings[i]->setAlignment(AlignCenter);
90
91 topLayout->addWidget(headings[i],1,i+1);
92 }
93
94 // Create the weeknumber labels
95 for( i = 0; i < 6; i++ ) {
96 weeknos[i] = new QLabel(this);
97 weeknos[i]->setAlignment(AlignCenter);
98 //weeknos[i]->setFont(QFont("Arial", 10));
99 if(!show_week_nums) {
100 weeknos[i]->hide();
101 }
102 weeknos[i]->installEventFilter(this);
103
104 topLayout->addWidget(weeknos[i],i+2,0);
105 }
106
107 daymatrix = new KODayMatrix( this, mCalendar, dayone,
108 "KDateNavigator::DayMatrix");
109 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
110 daymatrix->setLineWidth(1);
111
112 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
113 SIGNAL( datesSelected( const KCal::DateList & ) ) );
114
115 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
116 SIGNAL( eventDropped( Event * ) ) );
117
118 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
119
120 // read settings from configuration file.
121 updateConfig();
122 enableRollover(FollowMonth);
123 setFixedSize ( sizeHint() );
124}
125
126void KDateNavigator::enableRollover(RolloverType r)
127{
128 switch(r)
129 {
130 case None :
131 if (updateTimer)
132 {
133 updateTimer->stop();
134 delete updateTimer;
135 updateTimer=0L;
136 }
137 break;
138 case FollowDay :
139 case FollowMonth :
140 if (!updateTimer)
141 {
142 updateTimer = new QTimer(this);
143 QObject::connect(updateTimer,SIGNAL(timeout()),
144 this,SLOT(possiblyPastMidnight()));
145 }
146 updateTimer->start(0,true);
147 lastDayChecked = QDate::currentDate();
148 }
149 updateRollover=r;
150}
151
152
153KDateNavigator::~KDateNavigator()
154{
155}
156
157
158void KDateNavigator::passedMidnight()
159{
160 QDate today = QDate::currentDate();
161 bool emitMonth = false;
162
163 if (today.month() != lastDayChecked.month())
164 {
165 if (updateRollover==FollowMonth &&
166 daymatrix->isEndOfMonth()) {
167 goNextMonth();
168 emitMonth=true;
169 }
170 }
171 daymatrix->recalculateToday();
172 daymatrix->repaint();
173 emit dayPassed(today);
174 if (emitMonth) { emit monthPassed(today); }
175}
176
177/* slot */ void KDateNavigator::possiblyPastMidnight()
178{
179 if (lastDayChecked!=QDate::currentDate())
180 {
181 passedMidnight();
182 lastDayChecked=QDate::currentDate();
183 }
184 // Set the timer to go off 1 second after midnight
185 // or after 8 minutes, whichever comes first.
186 if (updateTimer)
187 {
188 QTime now = QTime::currentTime();
189 QTime midnight = QTime(23,59,59);
190 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
191
192 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
193 //.arg(now.toString()).arg(midnight.toString()));
194
195 updateTimer->stop();
196 updateTimer->start(msecsWait,true);
197 }
198}
199
200void KDateNavigator::updateDates()
201{
202 // Find the first day of the week of the current month.
203 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
204 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
205 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
206 //int di = d1 - d2 + 1;
207 dayone = dayone.addDays( -d2 + 1 );
208
209 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
210
211 // If month begins on Monday and Monday is first day of week,
212 // month should begin on second line. Sunday doesn't have this problem.
213 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
214 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
215
216 // update the matrix dates
217 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
218
219
220 daymatrix->updateView(dayone.addDays(index));
221//each updateDates is followed by an updateView -> repaint is issued there !
222// daymatrix->repaint();
223}
224
225void KDateNavigator::updateDayMatrix()
226{
227 daymatrix->updateView();
228 daymatrix->repaint();
229}
230
231
232void KDateNavigator::updateView()
233{
234
235 setUpdatesEnabled( false );
236
237 int i;
238
239// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
240 daymatrix->updateView();
241
242 // set the week numbers.
243 for(i = 0; i < 6; i++) {
244 QString weeknum;
245 // remember, according to ISO 8601, the first week of the year is the
246 // first week that contains a thursday. Thus we must subtract off 4,
247 // not just 1.
248
249 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
250 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
251
252 if (dayOfYear % 7 != 0)
253 weeknum.setNum(dayOfYear / 7 + 1);
254 else
255 weeknum.setNum(dayOfYear / 7);
256 weeknos[i]->setText(weeknum);
257 }
258
259 setUpdatesEnabled( true );
260// kdDebug() << "updateView() -> repaint()" << endl;
261 repaint();
262 daymatrix->repaint();
263}
264
265void KDateNavigator::updateConfig()
266{
267 int day;
268 for(int i=0; i<7; i++) {
269 // take the first letter of the day name to be the abbreviation
270 if (KGlobal::locale()->weekStartsMonday()) {
271 day = i+1;
272 } else {
273 if (i==0) day = 7;
274 else day = i;
275 }
276 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
277 true );
278 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
279 headings[i]->setText( dayName );
280 }
281 updateDates();
282 updateView();
283}
284
285void KDateNavigator::setShowWeekNums(bool enabled)
286{
287 m_bShowWeekNums = enabled;
288 for(int i=0; i<6; i++) {
289 if(enabled)
290 weeknos[i]->show();
291 else
292 weeknos[i]->hide();
293 }
294 resize(size());
295}
296
297void KDateNavigator::selectDates(const DateList& dateList)
298{
299
300 if (dateList.count() > 0) {
301 mNavigatorBar->selectDates( dateList );
302 mSelectedDates = dateList;
303
304 // set our record of the month and year that this datetbl is
305 // displaying.
306 m_MthYr = mSelectedDates.first();
307
308
309 // set our record of the first day of the week of the current
310 // month. This needs to be done before calling dayToIndex, since it
311 // relies on this information being up to date.
312 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
313 m_fstDayOfWk = dayone.dayOfWeek();
314
315 updateDates();
316
317 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
318
319 updateView();
320 }
321}
322
323int KDateNavigator::dayNum(int row, int col)
324{
325 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
326}
327
328int KDateNavigator::dayToIndex(int dayNum)
329{
330 int row, col;
331
332 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
333 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
334 row++;
335 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
336 return row * 7 + col;
337}
338
339void KDateNavigator::wheelEvent (QWheelEvent *e)
340{
341 if(e->delta()>0) emit goPrevious();
342 else emit goNext();
343
344 e->accept();
345}
346
347bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
348{
349 if (e->type() == QEvent::MouseButtonPress) {
350 int i;
351 for(i=0;i<6;++i) {
352 if (o == weeknos[i]) {
353 QDate weekstart = daymatrix->getDate(i*7);
354 emit weekClicked(weekstart);
355 break;
356 }
357 }
358 return true;
359 } else {
360 return false;
361 }
362}
363
364#include "kdatenavigator.moc"
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h
new file mode 100644
index 0000000..3ae1648
--- a/dev/null
+++ b/korganizer/kdatenavigator.h
@@ -0,0 +1,148 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KDATENAVIGATOR_H
24#define KDATENAVIGATOR_H
25
26#include <qframe.h>
27#include <qdatetime.h>
28#include <qlabel.h>
29
30#include <libkcal/calendar.h>
31
32#include "kodaymatrix.h"
33
34class QPushButton;
35class QTimer;
36
37class KCalendarSystem;
38
39class NavigatorBar;
40
41class KDateNavigator: public QFrame
42{
43 Q_OBJECT
44 public:
45 KDateNavigator( QWidget *parent = 0, Calendar *calendar = 0,
46 bool show_week_numbers = false, const char *name = 0,
47 QDate date = QDate::currentDate() );
48 ~KDateNavigator();
49
50 /** The DateNavigator automatically checks for
51 * the passage of midnight. If rollover type is
52 * set to None, no signals are emitted and no
53 * processing is done. With rollover set to
54 * FollowDay, the day highlighter changes at
55 * midnight and dayPassed() is emitted.
56 * With FollowMonth, it has the same effect
57 * as FollowDay but also adjusts the month that is
58 * visible and emits monthPassed() when the month changes.
59 */
60 enum RolloverType { None, FollowDay, FollowMonth } ;
61 void enableRollover( RolloverType );
62
63 void setShowWeekNums( bool enabled );
64
65 public slots:
66 void selectDates( const KCal::DateList & );
67 void updateView();
68 void updateConfig();
69 void updateDayMatrix();
70
71 signals:
72 void datesSelected( const KCal::DateList & );
73 void eventDropped( Event * );
74 void weekClicked( const QDate &);
75
76 void goPrevious();
77 void goNext();
78
79 void goNextMonth();
80 void goPrevMonth();
81 void goNextYear();
82 void goPrevYear();
83 void monthSelected( int );
84
85 // Signals emitted at midnight carrying the new date.
86 void dayPassed( QDate );
87 void monthPassed( QDate );
88
89 protected slots:
90
91 /**
92 * Called regularly to see if we need to update the view
93 * wrt. the today box and the month box. Only important
94 * if you leave KOrganizer idle for long periods of time.
95 *
96 * Until we have a reliable way of setting QTimers to go
97 * off at a particular wall-clock time, we need this,
98 * which calls passedMidnight() at the right moments.
99 */
100 void possiblyPastMidnight();
101
102 /** handles updating the view when midnight has come by due to idle time.
103 *
104 */
105 void passedMidnight();
106
107 protected:
108 void updateDates();
109
110 void wheelEvent (QWheelEvent *);
111
112 bool eventFilter (QObject *,QEvent *);
113
114 private:
115 NavigatorBar *mNavigatorBar;
116
117 QFrame *headingSep;
118 QFrame *weeknumSep;
119 QLabel *headings[7];
120 QLabel *weeknos[7];
121 KODayMatrix *daymatrix;
122
123 KCal::DateList mSelectedDates;
124 QDate m_MthYr;
125 int m_fstDayOfWk;
126 bool m_bShowWeekNums;
127
128 int dayNum(int row, int col);
129 int dayToIndex(int dayNum);
130
131 Calendar *mCalendar;
132 KCalendarSystem *mCalendarSystem;
133
134 const QString *curHeaders;
135
136 /** used to update the day view periodically, in particular every
137 * midnight to move the "today" rectangle.
138 */
139 QTimer *updateTimer;
140 QDate lastDayChecked;
141 RolloverType updateRollover;
142
143 // Disabling copy constructor and assignment operator
144 KDateNavigator(const KDateNavigator & );
145 KDateNavigator &operator=(const KDateNavigator &);
146};
147
148#endif
diff --git a/korganizer/kdatenavigator.moc b/korganizer/kdatenavigator.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kdatenavigator.moc
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
new file mode 100644
index 0000000..607c250
--- a/dev/null
+++ b/korganizer/koagenda.cpp
@@ -0,0 +1,1932 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
25*/
26
27#ifndef _WIN32_
28#define protected public
29#include <qwidget.h>
30#undef protected
31#endif
32#include <qintdict.h>
33#include <qdatetime.h>
34#include <qapplication.h>
35#include <qpopupmenu.h>
36#include <qcursor.h>
37#include <qpainter.h>
38
39#include <kdebug.h>
40#include <klocale.h>
41#include <kiconloader.h>
42#include <kglobal.h>
43
44#include "koagendaitem.h"
45#include "koprefs.h"
46#include "koglobals.h"
47
48#include "koagenda.h"
49#include "koagenda.moc"
50
51#include <libkcal/event.h>
52#include <libkcal/todo.h>
53
54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h>
56#endif
57
58//extern bool globalFlagBlockPainting;
59extern int globalFlagBlockAgenda;
60extern int globalFlagBlockAgendaItemPaint;
61extern int globalFlagBlockAgendaItemUpdate;
62extern int globalFlagBlockStartup;
63
64////////////////////////////////////////////////////////////////////////////
65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
66 : QFrame(_agenda->viewport(),name), agenda(_agenda)
67{
68 setLineWidth(0);
69 setMargin(0);
70 setBackgroundColor(Qt::red);
71 minutes = new QTimer(this);
72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
73 minutes->start(0, true);
74
75 mTimeBox = new QLabel(this);
76 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
77 QPalette pal = mTimeBox->palette();
78 pal.setColor(QColorGroup::Foreground, Qt::red);
79 mTimeBox->setPalette(pal);
80 //mTimeBox->setAutoMask(true);
81
82 agenda->addChild(mTimeBox);
83
84 oldToday = -1;
85}
86
87MarcusBains::~MarcusBains()
88{
89 delete minutes;
90}
91
92int MarcusBains::todayColumn()
93{
94 QDate currentDate = QDate::currentDate();
95
96 DateList dateList = agenda->dateList();
97 DateList::ConstIterator it;
98 int col = 0;
99 for(it = dateList.begin(); it != dateList.end(); ++it) {
100 if((*it) == currentDate)
101 return KOGlobals::self()->reverseLayout() ?
102 agenda->columns() - 1 - col : col;
103 ++col;
104 }
105
106 return -1;
107}
108void MarcusBains::updateLoc()
109{
110 updateLocation();
111}
112void MarcusBains::updateLocation(bool recalculate)
113{
114
115 QTime tim = QTime::currentTime();
116 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
117 if((tim.hour() == 0) && (oldTime.hour()==23))
118 recalculate = true;
119
120 int mins = tim.hour()*60 + tim.minute();
121 int minutesPerCell = 24 * 60 / agenda->rows();
122 int y = mins*agenda->gridSpacingY()/minutesPerCell;
123 int today = recalculate ? todayColumn() : oldToday;
124 int x = agenda->gridSpacingX()*today;
125 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
126
127 oldTime = tim;
128 oldToday = today;
129
130 if(disabled || (today<0)) {
131 hide(); mTimeBox->hide();
132 return;
133 } else {
134 show(); mTimeBox->show();
135 }
136
137 if(recalculate)
138 setFixedSize(agenda->gridSpacingX(),1);
139 agenda->moveChild(this, x, y);
140 raise();
141
142 if(recalculate)
143 //mTimeBox->setFont(QFont("helvetica",10));
144 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
145
146 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
147 mTimeBox->adjustSize();
148 // the -2 below is there because there is a bug in this program
149 // somewhere, where the last column of this widget is a few pixels
150 // narrower than the other columns.
151 int offs = (today==agenda->columns()-1) ? -4 : 0;
152 agenda->moveChild(mTimeBox,
153 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
154 y-mTimeBox->height());
155
156 mTimeBox->raise();
157 //mTimeBox->setAutoMask(true);
158 minutes->start(5000,true);
159}
160
161
162////////////////////////////////////////////////////////////////////////////
163
164
165/*
166 Create an agenda widget with rows rows and columns columns.
167*/
168KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
169 const char *name,WFlags f) :
170 QScrollView(parent,name,f)
171{
172
173 mColumns = columns;
174 mRows = rows;
175 mGridSpacingY = rowSize;
176 mAllDayMode = false;
177#ifndef DESKTOP_VERSION
178 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif
180 mHolidayMask = 0;
181 init();
182}
183
184/*
185 Create an agenda widget with columns columns and one row. This is used for
186 all-day events.
187*/
188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
189 QScrollView(parent,name,f)
190{
191
192 blockResize = false;
193 mColumns = columns;
194 mRows = 1;
195 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
196 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
197 mAllDayMode = true;
198#ifndef DESKTOP_VERSION
199 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
200#endif
201 mHolidayMask = 0;
202 init();
203}
204
205
206KOAgenda::~KOAgenda()
207{
208 if(mMarcusBains) delete mMarcusBains;
209
210}
211
212Incidence *KOAgenda::selectedIncidence() const
213{
214 return (mSelectedItem ? mSelectedItem->incidence() : 0);
215}
216
217
218QDate KOAgenda::selectedIncidenceDate() const
219{
220 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
221}
222
223
224void KOAgenda::init()
225{
226#ifndef _WIN32_
227 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
228 viewport()->setWFlags ( wflags);
229#endif
230 mGridSpacingX = 80;
231 mResizeBorderWidth = 8;
232 mScrollBorderWidth = 8;
233 mScrollDelay = 30;
234 mScrollOffset = 10;
235 mPaintPixmap.resize( 20,20);
236 //enableClipper(true);
237
238 // Grab key strokes for keyboard navigation of agenda. Seems to have no
239 // effect. Has to be fixed.
240 setFocusPolicy(WheelFocus);
241
242 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
243 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
244 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
245
246 mStartCellX = 0;
247 mStartCellY = 0;
248 mCurrentCellX = 0;
249 mCurrentCellY = 0;
250
251 mSelectionCellX = 0;
252 mSelectionYTop = 0;
253 mSelectionHeight = 0;
254
255 mOldLowerScrollValue = -1;
256 mOldUpperScrollValue = -1;
257
258 mClickedItem = 0;
259
260 mActionItem = 0;
261 mActionType = NOP;
262 mItemMoved = false;
263
264 mSelectedItem = 0;
265
266 // mItems.setAutoDelete(true);
267
268 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
269
270 viewport()->update();
271
272 setMinimumSize(30, 1);
273// setMaximumHeight(mGridSpacingY * mRows + 5);
274
275 // Disable horizontal scrollbar. This is a hack. The geometry should be
276 // controlled in a way that the contents horizontally always fits. Then it is
277 // not necessary to turn off the scrollbar.
278 setHScrollBarMode(AlwaysOff);
279 if ( ! mAllDayMode )
280 setVScrollBarMode(AlwaysOn);
281 else
282 setVScrollBarMode(AlwaysOff);
283
284 setStartHour(KOPrefs::instance()->mDayBegins);
285
286 calculateWorkingHours();
287
288 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
289 SLOT(checkScrollBoundaries(int)));
290
291 // Create the Marcus Bains line.
292 if(mAllDayMode)
293 mMarcusBains = 0;
294 else {
295 mMarcusBains = new MarcusBains(this);
296 addChild(mMarcusBains);
297 }
298}
299
300void KOAgenda::clear()
301{
302 KOAgendaItem *item;
303 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
304 mUnusedItems.append( item );
305 //item->hide();
306 }
307 mItems.clear();
308 mSelectedItem = 0;
309 clearSelection();
310}
311
312void KOAgenda::clearSelection()
313{
314 mSelectionCellX = 0;
315 mSelectionYTop = 0;
316 mSelectionHeight = 0;
317}
318
319void KOAgenda::marcus_bains()
320{
321 if(mMarcusBains) mMarcusBains->updateLocation(true);
322}
323
324
325void KOAgenda::changeColumns(int columns)
326{
327 if (columns == 0) {
328 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
329 return;
330 }
331
332 clear();
333
334 mColumns = columns;
335// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
336// init();
337// update();
338 //qDebug("KOAgenda::changeColumns ");
339 computeSizes();
340 // QResizeEvent event( size(), size() );
341
342 //QApplication::sendEvent( this, &event );
343}
344
345/*
346 This is the eventFilter function, which gets all events from the KOAgendaItems
347 contained in the agenda. It has to handle moving and resizing for all items.
348*/
349bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
350{
351// kdDebug() << "KOAgenda::eventFilter" << endl;
352 switch(event->type()) {
353 case QEvent::MouseButtonPress:
354 case QEvent::MouseButtonDblClick:
355 case QEvent::MouseButtonRelease:
356 case QEvent::MouseMove:
357 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
358
359 case (QEvent::Leave):
360 if (!mActionItem)
361 setCursor(arrowCursor);
362 return true;
363
364 default:
365 return QScrollView::eventFilter(object,event);
366 }
367}
368
369
370bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
371{
372 //qDebug("KOAgenda::eventFilter_mous ");
373 QPoint viewportPos;
374 if (object != viewport()) {
375 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
376 } else {
377 viewportPos = me->pos();
378 }
379 static int startX = 0;
380 static int startY = 0;
381 static bool block = true;
382 switch (me->type()) {
383 case QEvent::MouseButtonPress:
384 //qDebug("QEvent::MouseButtonPress: ");
385 // kdDebug() << "koagenda: filtered button press" << endl;
386 if (object != viewport()) {
387 if (me->button() == RightButton) {
388
389 mClickedItem = (KOAgendaItem *)object;
390 if (mClickedItem) {
391 selectItem(mClickedItem);
392 // emit showIncidencePopupSignal(mClickedItem->incidence());
393 }
394 //mItemPopup->popup(QCursor::pos());
395 } else {
396 mActionItem = (KOAgendaItem *)object;
397 if (mActionItem) {
398 if ( mSelectionHeight > 0 ) {
399 int selectionCellX = mSelectionCellX * mGridSpacingX;
400 int selectionYTop = mSelectionYTop;
401 int gridSpacingX = mGridSpacingX;
402 int selectionHeight = mSelectionHeight;
403 clearSelection();
404 repaintContents( selectionCellX, selectionYTop,
405 gridSpacingX, selectionHeight,false );
406 }
407 selectItem(mActionItem);
408 Incidence *incidence = mActionItem->incidence();
409 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
410 mActionItem = 0;
411 } else {
412 startItemAction(viewportPos);
413 startX = viewportPos.x();
414 startY = viewportPos.y();
415 block = true;
416 }
417 }
418 }
419 } else {
420 selectItem(0);
421 mActionItem = 0;
422 setCursor(arrowCursor);
423 startSelectAction(viewportPos);
424 }
425 break;
426
427 case QEvent::MouseButtonRelease:
428 //qDebug("QEvent::MouseButtonRelease: ");
429 if (me->button() == RightButton && block ) {
430 if (object != viewport()) {
431 mClickedItem = (KOAgendaItem *)object;
432 if (mActionItem ) {
433 endItemAction();
434 }
435 if (mClickedItem) {
436 selectItem(mClickedItem);
437 emit showIncidencePopupSignal(mClickedItem->incidence());
438 }
439 }
440 break;
441 }
442 block = true;
443 if (mActionItem) {
444 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
445 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
446 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
447 mScrollUpTimer.stop();
448 mScrollDownTimer.stop();
449 mActionItem->resetMove();
450 placeSubCells( mActionItem );
451 // emit startDragSignal( mActionItem->incidence() );
452 setCursor( arrowCursor );
453 mActionItem = 0;
454 mActionType = NOP;
455 mItemMoved = 0;
456 return true;
457 }
458 endItemAction();
459 } else if ( mActionType == SELECT ) {
460 endSelectAction();
461 }
462 break;
463
464 case QEvent::MouseMove:
465 if (object != viewport()) {
466 KOAgendaItem *moveItem = (KOAgendaItem *)object;
467 //qDebug("moveItem %d ",moveItem );
468 if (!moveItem->incidence()->isReadOnly() /*&&
469 !moveItem->incidence()->recurrence()->doesRecur()*/ )
470 if (!mActionItem)
471 setNoActionCursor(moveItem,viewportPos);
472 else {
473 if ( block ) {
474 int dX, dY;
475 dX = startX - viewportPos.x();
476 if ( dX < 0 )
477 dX = -dX;
478 dY = viewportPos.y() - startY;
479 if ( dY < 0 )
480 dY = -dY;
481 int diff = 30;
482 if ( QApplication::desktop()->width() < 480 )
483 diff = 15;
484 // qDebug(" %d %d ",dX, dY );
485 if ( dX > diff || dY > diff ) {
486 block = false;
487 }
488 }
489 if ( !block )
490 performItemAction(viewportPos);
491 }
492 } else {
493 if ( mActionType == SELECT ) {
494 performSelectAction( viewportPos );
495 }
496 }
497 break;
498
499 case QEvent::MouseButtonDblClick:
500 if (object == viewport()) {
501 selectItem(0);
502 int x,y;
503 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
504 int gx,gy;
505 contentsToGrid(x,y,gx,gy);
506 emit newEventSignal(gx,gy);
507 } else {
508 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
509 selectItem(doubleClickedItem);
510 if ( KOPrefs::instance()->mEditOnDoubleClick )
511 emit editIncidenceSignal(doubleClickedItem->incidence());
512 else
513 emit showIncidenceSignal(doubleClickedItem->incidence());
514 }
515 break;
516
517 default:
518 break;
519 }
520
521 return true;
522}
523
524void KOAgenda::startSelectAction(QPoint viewportPos)
525{
526 //emit newStartSelectSignal();
527
528 mActionType = SELECT;
529
530 int x,y;
531 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
532 int gx,gy;
533 contentsToGrid(x,y,gx,gy);
534
535 mStartCellX = gx;
536 mStartCellY = gy;
537 mCurrentCellX = gx;
538 mCurrentCellY = gy;
539
540 // Store coordinates of old selection
541 int selectionX = mSelectionCellX * mGridSpacingX;
542 int selectionYTop = mSelectionYTop;
543 int selectionHeight = mSelectionHeight;
544
545 // Store new selection
546 mSelectionCellX = gx;
547 mSelectionYTop = gy * mGridSpacingY;
548 mSelectionHeight = mGridSpacingY;
549
550 // Clear old selection
551 repaintContents( selectionX, selectionYTop,
552 mGridSpacingX, selectionHeight,false );
553
554 // Paint new selection
555 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
556 // mGridSpacingX, mSelectionHeight );
557}
558
559void KOAgenda::performSelectAction(QPoint viewportPos)
560{
561 int x,y;
562 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
563 int gx,gy;
564 contentsToGrid(x,y,gx,gy);
565
566 QPoint clipperPos = clipper()->
567 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
568
569 // Scroll if cursor was moved to upper or lower end of agenda.
570 if (clipperPos.y() < mScrollBorderWidth) {
571 mScrollUpTimer.start(mScrollDelay);
572 } else if (visibleHeight() - clipperPos.y() <
573 mScrollBorderWidth) {
574 mScrollDownTimer.start(mScrollDelay);
575 } else {
576 mScrollUpTimer.stop();
577 mScrollDownTimer.stop();
578 }
579
580 if ( gy > mCurrentCellY ) {
581 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
582
583#if 0
584 // FIXME: Repaint only the newly selected region
585 repaintContents( mSelectionCellX * mGridSpacingX,
586 mCurrentCellY + mGridSpacingY,
587 mGridSpacingX,
588 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
589#else
590 repaintContents( (KOGlobals::self()->reverseLayout() ?
591 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
592 mGridSpacingX, mSelectionYTop,
593 mGridSpacingX, mSelectionHeight , false);
594#endif
595
596 mCurrentCellY = gy;
597 } else if ( gy < mCurrentCellY ) {
598 if ( gy >= mStartCellY ) {
599 int selectionHeight = mSelectionHeight;
600 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
601
602 repaintContents( (KOGlobals::self()->reverseLayout() ?
603 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
604 mGridSpacingX, mSelectionYTop,
605 mGridSpacingX, selectionHeight,false );
606
607 mCurrentCellY = gy;
608 } else {
609 }
610 }
611}
612
613void KOAgenda::endSelectAction()
614{
615 mActionType = NOP;
616 mScrollUpTimer.stop();
617 mScrollDownTimer.stop();
618
619 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
620}
621
622void KOAgenda::startItemAction(QPoint viewportPos)
623{
624 int x,y;
625 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
626 int gx,gy;
627 contentsToGrid(x,y,gx,gy);
628
629 mStartCellX = gx;
630 mStartCellY = gy;
631 mCurrentCellX = gx;
632 mCurrentCellY = gy;
633
634 if (mAllDayMode) {
635 int gridDistanceX = (x - gx * mGridSpacingX);
636 if (gridDistanceX < mResizeBorderWidth &&
637 mActionItem->cellX() == mCurrentCellX) {
638 mActionType = RESIZELEFT;
639 setCursor(sizeHorCursor);
640 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
641 mActionItem->cellXWidth() == mCurrentCellX) {
642 mActionType = RESIZERIGHT;
643 setCursor(sizeHorCursor);
644 } else {
645 mActionType = MOVE;
646 mActionItem->startMove();
647 setCursor(sizeAllCursor);
648 }
649 } else {
650 int gridDistanceY = (y - gy * mGridSpacingY);
651 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
652 if (allowResize && gridDistanceY < mResizeBorderWidth &&
653 mActionItem->cellYTop() == mCurrentCellY &&
654 !mActionItem->firstMultiItem()) {
655 mActionType = RESIZETOP;
656 setCursor(sizeVerCursor);
657 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
658 mActionItem->cellYBottom() == mCurrentCellY &&
659 !mActionItem->lastMultiItem()) {
660 mActionType = RESIZEBOTTOM;
661 setCursor(sizeVerCursor);
662 } else {
663 mActionType = MOVE;
664 mActionItem->startMove();
665 setCursor(sizeAllCursor);
666 }
667 }
668}
669
670void KOAgenda::performItemAction(QPoint viewportPos)
671{
672// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
673// QPoint point = viewport()->mapToGlobal(viewportPos);
674// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
675// point = clipper()->mapFromGlobal(point);
676// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
677// kdDebug() << "visible height: " << visibleHeight() << endl;
678 int x,y;
679 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
680// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
681 int gx,gy;
682 contentsToGrid(x,y,gx,gy);
683 QPoint clipperPos = clipper()->
684 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
685
686 // Cursor left active agenda area.
687 // This starts a drag.
688 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
689 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
690 if ( mActionType == MOVE ) {
691 mScrollUpTimer.stop();
692 mScrollDownTimer.stop();
693 mActionItem->resetMove();
694 placeSubCells( mActionItem );
695 // emit startDragSignal( mActionItem->incidence() );
696 setCursor( arrowCursor );
697 mActionItem = 0;
698 mActionType = NOP;
699 mItemMoved = 0;
700 return;
701 }
702 } else {
703 switch ( mActionType ) {
704 case MOVE:
705 setCursor( sizeAllCursor );
706 break;
707 case RESIZETOP:
708 case RESIZEBOTTOM:
709 setCursor( sizeVerCursor );
710 break;
711 case RESIZELEFT:
712 case RESIZERIGHT:
713 setCursor( sizeHorCursor );
714 break;
715 default:
716 setCursor( arrowCursor );
717 }
718 }
719
720 // Scroll if item was moved to upper or lower end of agenda.
721 if (clipperPos.y() < mScrollBorderWidth) {
722 mScrollUpTimer.start(mScrollDelay);
723 } else if (visibleHeight() - clipperPos.y() <
724 mScrollBorderWidth) {
725 mScrollDownTimer.start(mScrollDelay);
726 } else {
727 mScrollUpTimer.stop();
728 mScrollDownTimer.stop();
729 }
730
731 // Move or resize item if necessary
732 if (mCurrentCellX != gx || mCurrentCellY != gy) {
733 mItemMoved = true;
734 mActionItem->raise();
735 if (mActionType == MOVE) {
736 // Move all items belonging to a multi item
737 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
738 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
739 if (!moveItem) moveItem = mActionItem;
740 while (moveItem) {
741 int dy;
742 if (isMultiItem) dy = 0;
743 else dy = gy - mCurrentCellY;
744 moveItem->moveRelative(gx - mCurrentCellX,dy);
745 int x,y;
746 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
747 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
748 mGridSpacingY * moveItem->cellHeight());
749 moveChild(moveItem,x,y);
750 moveItem = moveItem->nextMultiItem();
751 }
752 } else if (mActionType == RESIZETOP) {
753 if (mCurrentCellY <= mActionItem->cellYBottom()) {
754 mActionItem->expandTop(gy - mCurrentCellY);
755 mActionItem->resize(mActionItem->width(),
756 mGridSpacingY * mActionItem->cellHeight());
757 int x,y;
758 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
759 //moveChild(mActionItem,childX(mActionItem),y);
760 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
761 }
762 } else if (mActionType == RESIZEBOTTOM) {
763 if (mCurrentCellY >= mActionItem->cellYTop()) {
764 mActionItem->expandBottom(gy - mCurrentCellY);
765 mActionItem->resize(mActionItem->width(),
766 mGridSpacingY * mActionItem->cellHeight());
767 }
768 } else if (mActionType == RESIZELEFT) {
769 if (mCurrentCellX <= mActionItem->cellXWidth()) {
770 mActionItem->expandLeft(gx - mCurrentCellX);
771 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
772 mActionItem->height());
773 int x,y;
774 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
775 moveChild(mActionItem,x,childY(mActionItem));
776 }
777 } else if (mActionType == RESIZERIGHT) {
778 if (mCurrentCellX >= mActionItem->cellX()) {
779 mActionItem->expandRight(gx - mCurrentCellX);
780 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
781 mActionItem->height());
782 }
783 }
784 mCurrentCellX = gx;
785 mCurrentCellY = gy;
786 }
787}
788
789void KOAgenda::endItemAction()
790{
791
792 if ( mItemMoved ) {
793 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
794 if ( !placeItem ) {
795 placeItem = mActionItem;
796 }
797 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
798 Incidence* oldInc = placeItem->incidence();
799 placeItem->recreateIncidence();
800 emit addToCalSignal(placeItem->incidence(), oldInc );
801 }
802 int type = mActionType;
803 if ( mAllDayMode )
804 type = -1;
805 KOAgendaItem *modifiedItem = placeItem;
806 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
807 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
808 KOAgendaItem *item;
809
810 if ( placeItem->incidence()->type() == "Todo" ) {
811 mSelectedItem = 0;
812 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
813 modifiedItem->mLastMoveXPos = mCurrentCellX;
814 emit itemModified( modifiedItem, mActionType );
815 }
816 else {
817#if 0
818 for ( item=oldconflictItems.first(); item != 0;
819 item=oldconflictItems.next() ) {
820 placeSubCells(item);
821 }
822 while ( placeItem ) {
823 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
824 placeSubCells( placeItem );
825 placeItem = placeItem->nextMultiItem();
826 }
827#endif
828
829 globalFlagBlockAgendaItemPaint = 1;
830 for ( item=oldconflictItems.first(); item != 0;
831 item=oldconflictItems.next() ) {
832 placeSubCells(item);
833 }
834 while ( placeItem ) {
835 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
836 oldconflictItems = placeItem->conflictItems();
837 for ( item=oldconflictItems.first(); item != 0;
838 item=oldconflictItems.next() ) {
839 placeSubCells(item);
840 }
841 placeSubCells( placeItem );
842 placeItem = placeItem->nextMultiItem();
843 }
844 globalFlagBlockAgendaItemPaint = 0;
845 for ( item=oldconflictItems.first(); item != 0;
846 item=oldconflictItems.next() ) {
847 globalFlagBlockAgendaItemUpdate = 0;
848 item->repaintMe();
849 globalFlagBlockAgendaItemUpdate = 1;
850 item->repaint( false );
851 }
852 placeItem = modifiedItem;
853
854 while ( placeItem ) {
855 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
856 globalFlagBlockAgendaItemUpdate = 0;
857 placeItem->repaintMe();
858 globalFlagBlockAgendaItemUpdate = 1;
859 placeItem->repaint(false);
860 placeItem = placeItem->nextMultiItem();
861 }
862 emit itemModified( modifiedItem, mActionType );
863
864
865 placeItem = modifiedItem;
866 while ( placeItem ) {
867 oldconflictItems = placeItem->conflictItems();
868 for ( item=oldconflictItems.first(); item != 0;
869 item=oldconflictItems.next() ) {
870 placeSubCells(item);
871 }
872 placeSubCells( placeItem );
873 placeItem = placeItem->nextMultiItem();
874
875 }
876 placeItem = modifiedItem;
877 while ( placeItem ) {
878 oldconflictItems = placeItem->conflictItems();
879 for ( item=oldconflictItems.first(); item != 0;
880 item=oldconflictItems.next() ) {
881 globalFlagBlockAgendaItemUpdate = 0;
882 item->repaintMe();
883 globalFlagBlockAgendaItemUpdate = 1;
884 item->repaint(false);
885 }
886 placeItem = placeItem->nextMultiItem();
887 }
888 /*
889
890 oldconflictItems = modifiedItem->conflictItems();
891 for ( item=oldconflictItems.first(); item != 0;
892 item=oldconflictItems.next() ) {
893 globalFlagBlockAgendaItemUpdate = 0;
894 item->paintMe(false);
895 globalFlagBlockAgendaItemUpdate = 1;
896 item->repaint(false);
897 }
898 */
899
900
901 }
902
903 }
904
905 mScrollUpTimer.stop();
906 mScrollDownTimer.stop();
907 setCursor( arrowCursor );
908 mActionItem = 0;
909 mActionType = NOP;
910 mItemMoved = 0;
911
912}
913
914void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
915{
916// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
917// QPoint point = viewport()->mapToGlobal(viewportPos);
918// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
919// point = clipper()->mapFromGlobal(point);
920// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
921
922 int x,y;
923 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
924// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
925 int gx,gy;
926 contentsToGrid(x,y,gx,gy);
927
928 // Change cursor to resize cursor if appropriate
929 if (mAllDayMode) {
930 int gridDistanceX = (x - gx * mGridSpacingX);
931 if (gridDistanceX < mResizeBorderWidth &&
932 moveItem->cellX() == gx) {
933 setCursor(sizeHorCursor);
934 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
935 moveItem->cellXWidth() == gx) {
936 setCursor(sizeHorCursor);
937 } else {
938 setCursor(arrowCursor);
939 }
940 } else {
941 int gridDistanceY = (y - gy * mGridSpacingY);
942 if (gridDistanceY < mResizeBorderWidth &&
943 moveItem->cellYTop() == gy &&
944 !moveItem->firstMultiItem()) {
945 setCursor(sizeVerCursor);
946 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
947 moveItem->cellYBottom() == gy &&
948 !moveItem->lastMultiItem()) {
949 setCursor(sizeVerCursor);
950 } else {
951 setCursor(arrowCursor);
952 }
953 }
954}
955
956
957/*
958 Place item in cell and take care that multiple items using the same cell do
959 not overlap. This method is not yet optimal. It doesn´t use the maximum space
960 it can get in all cases.
961 At the moment the method has a bug: When an item is placed only the sub cell
962 widths of the items are changed, which are within the Y region the item to
963 place spans. When the sub cell width change of one of this items affects a
964 cell, where other items are, which do not overlap in Y with the item to place,
965 the display gets corrupted, although the corruption looks quite nice.
966*/
967void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
968{
969
970 QPtrList<KOAgendaItem> conflictItems;
971 int maxSubCells = 0;
972 QIntDict<KOAgendaItem> subCellDict(5);
973
974 KOAgendaItem *item;
975 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
976 if (item != placeItem) {
977 if (placeItem->cellX() <= item->cellXWidth() &&
978 placeItem->cellXWidth() >= item->cellX()) {
979 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
980 (placeItem->cellYBottom() >= item->cellYTop())) {
981 conflictItems.append(item);
982 if (item->subCells() > maxSubCells)
983 maxSubCells = item->subCells();
984 subCellDict.insert(item->subCell(),item);
985 }
986 }
987 }
988 }
989
990 if (conflictItems.count() > 0) {
991 // Look for unused sub cell and insert item
992 int i;
993 for(i=0;i<maxSubCells;++i) {
994 if (!subCellDict.find(i)) {
995 placeItem->setSubCell(i);
996 break;
997 }
998 }
999 if (i == maxSubCells) {
1000 placeItem->setSubCell(maxSubCells);
1001 maxSubCells++; // add new item to number of sub cells
1002 }
1003
1004 // Prepare for sub cell geometry adjustment
1005 int newSubCellWidth;
1006 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1007 else newSubCellWidth = mGridSpacingX / maxSubCells;
1008 conflictItems.append(placeItem);
1009
1010
1011 // Adjust sub cell geometry of all items
1012 for ( item=conflictItems.first(); item != 0;
1013 item=conflictItems.next() ) {
1014 item->setSubCells(maxSubCells);
1015 if (mAllDayMode) {
1016 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1017 } else {
1018 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1019 }
1020 int x,y;
1021 gridToContents(item->cellX(),item->cellYTop(),x,y);
1022 if (mAllDayMode) {
1023 y += item->subCell() * newSubCellWidth;
1024 } else {
1025 x += item->subCell() * newSubCellWidth;
1026 }
1027 moveChild(item,x,y);
1028 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1029 //item->updateItem();
1030 }
1031
1032 } else {
1033 placeItem->setSubCell(0);
1034 placeItem->setSubCells(1);
1035 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1036 else placeItem->resize(mGridSpacingX,placeItem->height());
1037 int x,y;
1038 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1039 moveChild(placeItem,x,y);
1040 }
1041 placeItem->setConflictItems(conflictItems);
1042 // for ( item=conflictItems.first(); item != 0;
1043// item=conflictItems.next() ) {
1044// //item->updateItem();
1045// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1046// }
1047// placeItem->updateItem();
1048}
1049
1050void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1051{
1052 if ( globalFlagBlockAgenda )
1053 return;
1054 //qDebug("KOAgenda::drawContents ");
1055 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1056 ;//drawContentsToPainter();
1057
1058 QPaintDevice* pd = p->device();
1059 p->end();
1060 int vx, vy;
1061 int selectionX = KOGlobals::self()->reverseLayout() ?
1062 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1063 mSelectionCellX * mGridSpacingX;
1064 contentsToViewport ( cx, cy, vx,vy);
1065 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1066 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1067 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1068
1069 if ( mSelectionHeight > 0 ) {
1070 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1071 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1072 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1073 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1074 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1075 }
1076 }
1077 //qDebug("btbl ");
1078 p->begin( pd );
1079 //qDebug("end ");
1080}
1081
1082void KOAgenda::finishUpdate()
1083{
1084
1085 KOAgendaItem *item;
1086 globalFlagBlockAgendaItemPaint = 1;
1087 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1088 if ( !item->isVisible() )
1089 item->show();
1090
1091 }
1092 globalFlagBlockAgendaItemUpdate = 0;
1093 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1094 item->repaintMe( );
1095 }
1096 globalFlagBlockAgendaItemUpdate = 1;
1097 qApp->processEvents();
1098 globalFlagBlockAgendaItemPaint = 0;
1099 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1100 item->repaint( false );
1101 }
1102
1103}
1104
1105/*
1106 Draw grid in the background of the agenda.
1107*/
1108void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1109{
1110
1111
1112 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1113 return;
1114 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1115 return;
1116 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1117 if ( ch < 1 )
1118 ch = 1;
1119 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1120 mPaintPixmap.resize( contentsWidth()+42, ch );
1121 }
1122 mCurPixWid = contentsWidth();
1123 mCurPixHei = ch;
1124 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1125 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1126 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1127 }
1128 mPixPainter.begin( &mPaintPixmap) ;
1129 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1130 QPainter * p ;
1131 if (paint == 0) {
1132 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1133 p = &mPixPainter;
1134 }
1135 else
1136 p = paint ;
1137 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1138
1139 //--cx;++cw;
1140 int lGridSpacingY = mGridSpacingY*2;
1141 int selDay;
1142 if ( !backgroundOnly )
1143 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1144 {
1145 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1146 int x1 = cx;
1147 int y1 = 0;
1148 if (y1 < cy) y1 = cy;
1149 int x2 = cx+cw-1;
1150 int y2 = contentsHeight();
1151 if (y2 > cy+ch-1) y2=cy+ch-1;
1152 if (x2 >= x1 && y2 >= y1) {
1153 int gxStart = selDay;
1154 int gxEnd = gxStart ;
1155 int xStart = KOGlobals::self()->reverseLayout() ?
1156 (mColumns - 1 - gxStart)*mGridSpacingX :
1157 gxStart*mGridSpacingX;
1158 if (xStart < x1) xStart = x1;
1159 int xEnd = KOGlobals::self()->reverseLayout() ?
1160 (mColumns - gxStart)*mGridSpacingX-1 :
1161 (gxStart+1)*mGridSpacingX-1;
1162 if (xEnd > x2) xEnd = x2;
1163 if ( KOPrefs::instance()->mUseHighlightLightColor )
1164 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1165 KOPrefs::instance()->mAgendaBgColor.light());
1166 else
1167 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1168 KOPrefs::instance()->mAgendaBgColor.dark());
1169
1170 }
1171 }
1172 }
1173 // Highlight working hours
1174
1175 if ( !backgroundOnly )
1176 if (mWorkingHoursEnable) {
1177 int x1 = cx;
1178 int y1 = mWorkingHoursYTop;
1179 if (y1 < cy) y1 = cy;
1180 int x2 = cx+cw-1;
1181 // int x2 = mGridSpacingX * 5 - 1;
1182 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1183 int y2 = mWorkingHoursYBottom;
1184 if (y2 > cy+ch-1) y2=cy+ch-1;
1185
1186 if (x2 >= x1 && y2 >= y1) {
1187 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1188 int gxStart = x1/mGridSpacingX;
1189 int gxEnd = x2/mGridSpacingX;
1190 while(gxStart <= gxEnd) {
1191 if (gxStart < int(mHolidayMask->count()) &&
1192 !mHolidayMask->at(gxStart)) {
1193 int xStart = KOGlobals::self()->reverseLayout() ?
1194 (mColumns - 1 - gxStart)*mGridSpacingX :
1195 gxStart*mGridSpacingX;
1196 if (xStart < x1) xStart = x1;
1197 int xEnd = KOGlobals::self()->reverseLayout() ?
1198 (mColumns - gxStart)*mGridSpacingX-1 :
1199 (gxStart+1)*mGridSpacingX-1;
1200 if (xEnd > x2) xEnd = x2;
1201 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1202 if ( KOPrefs::instance()->mUseHighlightLightColor )
1203 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1204 KOPrefs::instance()->mWorkingHoursColor.light());
1205 else
1206 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1207 KOPrefs::instance()->mWorkingHoursColor.dark());
1208 } else {
1209 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1210 KOPrefs::instance()->mWorkingHoursColor);
1211 }
1212 }
1213 ++gxStart;
1214 }
1215 }
1216 }
1217 /*
1218 int selectionX = KOGlobals::self()->reverseLayout() ?
1219 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1220 mSelectionCellX * mGridSpacingX;
1221
1222 // Draw selection
1223 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1224 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1225 // TODO: paint only part within cx,cy,cw,ch
1226 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1227 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1228 }
1229 */
1230 // Draw vertical lines of grid
1231
1232 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1233 if ( mGridSpacingX > 0 ) {
1234 while (x < cx + cw) {
1235 p->drawLine(x,cy,x,cy+ch);
1236 x+=mGridSpacingX;
1237 }
1238 }
1239 // Draw horizontal lines of grid
1240 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1241 if ( lGridSpacingY > 0 ) {
1242 while (y < cy + ch) {
1243 p->drawLine(cx,y,cx+cw,y);
1244 y+=lGridSpacingY;
1245 }
1246 }
1247 mPixPainter.end() ;
1248}
1249
1250/*
1251 Convert srcollview contents coordinates to agenda grid coordinates.
1252*/
1253void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1254{
1255 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1256 x/mGridSpacingX;
1257 gy = y/mGridSpacingY;
1258}
1259
1260/*
1261 Convert agenda grid coordinates to scrollview contents coordinates.
1262*/
1263void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1264{
1265 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1266 gx*mGridSpacingX;
1267 y = gy*mGridSpacingY;
1268}
1269
1270
1271/*
1272 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1273 the grid.
1274*/
1275int KOAgenda::timeToY(const QTime &time)
1276{
1277 int minutesPerCell = 24 * 60 / mRows;
1278 int timeMinutes = time.hour() * 60 + time.minute();
1279 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1280 return Y;
1281}
1282
1283
1284/*
1285 Return time corresponding to cell y coordinate. Coordinates are rounded to
1286 fit into the grid.
1287*/
1288QTime KOAgenda::gyToTime(int gy)
1289{
1290
1291 int secondsPerCell = 24 * 60 * 60/ mRows;
1292
1293 int timeSeconds = secondsPerCell * gy;
1294
1295 QTime time( 0, 0, 0 );
1296 if ( timeSeconds < 24 * 60 * 60 ) {
1297 time = time.addSecs(timeSeconds);
1298 } else {
1299 time.setHMS( 23, 59, 59 );
1300 }
1301
1302 return time;
1303}
1304
1305void KOAgenda::setStartHour(int startHour)
1306{
1307 int startCell = startHour * mRows / 24;
1308 setContentsPos(0,startCell * gridSpacingY());
1309}
1310void KOAgenda::hideUnused()
1311{
1312 // experimental only
1313 // return;
1314 KOAgendaItem *item;
1315 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1316 item->hide();
1317 }
1318}
1319
1320
1321KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1322{
1323
1324 KOAgendaItem *fi;
1325 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1326 if ( fi->incidence() == event ) {
1327 mUnusedItems.remove();
1328 fi->init( event, qd );
1329 return fi;
1330 }
1331 }
1332 fi=mUnusedItems.first();
1333 if ( fi ) {
1334 mUnusedItems.remove();
1335 fi->init( event, qd );
1336 return fi;
1337 }
1338 // qDebug("new KOAgendaItem ");
1339
1340 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1341 agendaItem->installEventFilter(this);
1342 addChild(agendaItem,0,0);
1343 return agendaItem;
1344}
1345KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1346{
1347 KOAgendaItem *item;
1348 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1349 if ( item->incidence() == todo ) {
1350 mItems.remove();
1351 return item;
1352 }
1353 }
1354 return 0;
1355}
1356
1357
1358void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1359{
1360
1361 KOAgendaItem *item;
1362 item = getItemForTodo ( todo );
1363 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1364 if ( item ) {
1365 blockSignals( true );
1366 //qDebug("item found ");
1367 item->hide();
1368 item->setCellX(-2, -1 );
1369 item->select(false);
1370 mUnusedItems.append( item );
1371 mItems.remove( item );
1372 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1373 KOAgendaItem *itemit;
1374 //globalFlagBlockAgendaItemPaint = 1;
1375 for ( itemit=oldconflictItems.first(); itemit != 0;
1376 itemit=oldconflictItems.next() ) {
1377 if ( itemit != item )
1378 placeSubCells(itemit);
1379 }
1380 qApp->processEvents();
1381 //globalFlagBlockAgendaItemPaint = 0;
1382 for ( itemit=oldconflictItems.first(); itemit != 0;
1383 itemit=oldconflictItems.next() ) {
1384 globalFlagBlockAgendaItemUpdate = 0;
1385 if ( itemit != item )
1386 itemit->repaintMe();
1387 globalFlagBlockAgendaItemUpdate = 1;
1388 itemit->repaint();
1389 }
1390 blockSignals( false );
1391 }
1392 if ( remove ) {
1393 //qDebug("remove****************************************** ");
1394 return;
1395 }
1396 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1397 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1398 QDate currentDate;
1399 if ( overdue ) {
1400 currentDate = QDate::currentDate();
1401 days += todo->dtDue().date().daysTo( currentDate );
1402 }
1403 else
1404 currentDate = todo->dtDue().date();
1405
1406 if ( todo->doesFloat() || overdue ) {
1407 if ( ! mAllDayMode ) return;
1408 // aldayagenda
1409 globalFlagBlockAgendaItemPaint = 1;
1410 item = insertAllDayItem(todo, currentDate,days, days);
1411 item->show();
1412
1413 }
1414 else {
1415 if ( mAllDayMode ) return;
1416 // mAgenda
1417 globalFlagBlockAgendaItemPaint = 1;
1418 int endY = timeToY(todo->dtDue().time()) - 1;
1419 int hi = 12/KOPrefs::instance()->mHourSize;
1420 int startY = endY - 1-hi;
1421 item = insertItem(todo,currentDate,days,startY,endY);
1422 item->show();
1423 }
1424 qApp->processEvents();
1425 globalFlagBlockAgendaItemPaint = 0;
1426 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1427 KOAgendaItem *itemit;
1428 for ( itemit=oldconflictItems.first(); itemit != 0;
1429 itemit=oldconflictItems.next() ) {
1430 globalFlagBlockAgendaItemUpdate = 0;
1431 itemit->repaintMe();
1432 globalFlagBlockAgendaItemUpdate = 1;
1433 itemit->repaint();
1434 }
1435 globalFlagBlockAgendaItemUpdate = 0;
1436 item->repaintMe();
1437 globalFlagBlockAgendaItemUpdate = 1;
1438 item->repaint();
1439}
1440/*
1441 Insert KOAgendaItem into agenda.
1442*/
1443KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1444{
1445 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl;
1446
1447 if (mAllDayMode) {
1448 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
1449 return 0;
1450 }
1451
1452 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1453 //agendaItem->setFrameStyle(WinPanel|Raised);
1454
1455 int YSize = YBottom - YTop + 1;
1456 if (YSize < 0) {
1457 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1458 YSize = 1;
1459 }
1460 int iheight = mGridSpacingY * YSize;
1461
1462 agendaItem->resize(mGridSpacingX,iheight );
1463 agendaItem->setCellXY(X,YTop,YBottom);
1464 agendaItem->setCellXWidth(X);
1465
1466 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1467 mItems.append(agendaItem);
1468
1469 placeSubCells(agendaItem);
1470
1471 //agendaItem->show();
1472
1473 marcus_bains();
1474
1475 return agendaItem;
1476}
1477
1478
1479/*
1480 Insert all-day KOAgendaItem into agenda.
1481*/
1482KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1483{
1484 if (!mAllDayMode) {
1485 return 0;
1486 }
1487
1488 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1489
1490 agendaItem->setCellXY(XBegin,0,0);
1491 agendaItem->setCellXWidth(XEnd);
1492 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1493
1494 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1495 mItems.append(agendaItem);
1496
1497 placeSubCells(agendaItem);
1498
1499 //agendaItem->show();
1500
1501 return agendaItem;
1502}
1503
1504
1505void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1506 int YTop,int YBottom)
1507{
1508 if (mAllDayMode) {
1509 ;
1510 return;
1511 }
1512
1513 int cellX,cellYTop,cellYBottom;
1514 QString newtext;
1515 int width = XEnd - XBegin + 1;
1516 int count = 0;
1517 KOAgendaItem *current = 0;
1518 QPtrList<KOAgendaItem> multiItems;
1519 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1520 if (cellX == XBegin) cellYTop = YTop;
1521 else cellYTop = 0;
1522 if (cellX == XEnd) cellYBottom = YBottom;
1523 else cellYBottom = rows() - 1;
1524 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1525 newtext.append(event->summary());
1526 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1527 current->setText(newtext);
1528 multiItems.append(current);
1529 }
1530
1531 KOAgendaItem *next = 0;
1532 KOAgendaItem *last = multiItems.last();
1533 KOAgendaItem *first = multiItems.first();
1534 KOAgendaItem *setFirst,*setLast;
1535 current = first;
1536 while (current) {
1537 next = multiItems.next();
1538 if (current == first) setFirst = 0;
1539 else setFirst = first;
1540 if (current == last) setLast = 0;
1541 else setLast = last;
1542
1543 current->setMultiItem(setFirst,next,setLast);
1544 current = next;
1545 }
1546
1547 marcus_bains();
1548}
1549
1550
1551//QSizePolicy KOAgenda::sizePolicy() const
1552//{
1553 // Thought this would make the all-day event agenda minimum size and the
1554 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1555 // don´t seem to think that an Expanding widget needs more space than a
1556 // Preferred one.
1557 // But it doesn´t hurt, so it stays.
1558// if (mAllDayMode) {
1559// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1560// } else {
1561// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1562// }
1563//}
1564void KOAgenda::finishResize ( )
1565{
1566 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1567 if ( globalFlagBlockAgenda == 0 ) {
1568 finishUpdate();
1569 //qDebug("finishUpdate() called ");
1570 }
1571}
1572/*
1573 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1574*/
1575void KOAgenda::resizeEvent ( QResizeEvent *ev )
1576{
1577
1578 mResizeTimer.start( 150 , true );
1579 computeSizes();
1580 return;
1581
1582}
1583void KOAgenda::computeSizes()
1584{
1585 if ( globalFlagBlockStartup )
1586 return;
1587
1588 if (mAllDayMode) {
1589 mGridSpacingX = (width()-3) / mColumns;
1590 mGridSpacingY = height() - 2 * frameWidth() - 1;
1591 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1592// mGridSpacingY = height();
1593// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1594
1595 KOAgendaItem *item;
1596 int subCellWidth;
1597 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1598 subCellWidth = mGridSpacingY / item->subCells();
1599 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1600 moveChild(item,KOGlobals::self()->reverseLayout() ?
1601 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1602 item->cellX() * mGridSpacingX,
1603 item->subCell() * subCellWidth);
1604 }
1605 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1606 } else {
1607 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
1608 if (height() > mGridSpacingY * mRows + 1 ) {
1609 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1610 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1611 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1612 emit resizedSignal();
1613 } else
1614 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1615 KOAgendaItem *item;
1616 int subCellWidth;
1617
1618 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1619 subCellWidth = mGridSpacingX / item->subCells();
1620 item->resize(subCellWidth,item->height());
1621 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1622 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1623 item->cellX() * mGridSpacingX) +
1624 item->subCell() * subCellWidth,childY(item));
1625 }
1626 }
1627 int cw = contentsWidth();
1628 int ch = contentsHeight();
1629 if ( mAllDayMode ) {
1630 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1631 if ( paintPixAll->width() < cw || paintPixAll->height() < ch )
1632 paintPixAll->resize( cw, ch );
1633 } else {
1634 QPixmap* paintPix = KOAgendaItem::paintPix();
1635 if ( paintPix->width() < cw || paintPix->height() < ch )
1636 KOAgendaItem::resizePixmap( cw , ch );
1637 }
1638
1639 checkScrollBoundaries();
1640 marcus_bains();
1641 drawContentsToPainter();
1642 viewport()->repaint(false);
1643}
1644
1645void KOAgenda::scrollUp()
1646{
1647 scrollBy(0,-mScrollOffset);
1648}
1649
1650
1651void KOAgenda::scrollDown()
1652{
1653 scrollBy(0,mScrollOffset);
1654}
1655
1656void KOAgenda::popupAlarm()
1657{
1658 if (!mClickedItem) {
1659 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl;
1660 return;
1661 }
1662// TODO: deal correctly with multiple alarms
1663 Alarm* alarm;
1664 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1665 for(alarm=list.first();alarm;alarm=list.next()) {
1666 alarm->toggleAlarm();
1667 }
1668 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1669 mClickedItem->paintMe( true );
1670 mClickedItem->repaint( false );
1671}
1672
1673/*
1674 Calculates the minimum width
1675*/
1676int KOAgenda::minimumWidth() const
1677{
1678 // TODO:: develop a way to dynamically determine the minimum width
1679 int min = 100;
1680
1681 return min;
1682}
1683
1684void KOAgenda::updateConfig()
1685{
1686 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1687 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1688 if ( mAllDayMode ) {
1689 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1690 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1691 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1692 // setMaximumHeight( mGridSpacingY+1 );
1693 viewport()->repaint( false );
1694 //setFixedHeight( mGridSpacingY+1 );
1695 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1696 }
1697 else {
1698 mGridSpacingY = KOPrefs::instance()->mHourSize;
1699 calculateWorkingHours();
1700 marcus_bains();
1701 }
1702}
1703
1704void KOAgenda::checkScrollBoundaries()
1705{
1706 // Invalidate old values to force update
1707 mOldLowerScrollValue = -1;
1708 mOldUpperScrollValue = -1;
1709
1710 checkScrollBoundaries(verticalScrollBar()->value());
1711}
1712
1713void KOAgenda::checkScrollBoundaries(int v)
1714{
1715 if ( mGridSpacingY == 0 )
1716 return;
1717 int yMin = v/mGridSpacingY;
1718 int yMax = (v+visibleHeight())/mGridSpacingY;
1719
1720// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
1721
1722 if (yMin != mOldLowerScrollValue) {
1723 mOldLowerScrollValue = yMin;
1724 emit lowerYChanged(yMin);
1725 }
1726 if (yMax != mOldUpperScrollValue) {
1727 mOldUpperScrollValue = yMax;
1728 emit upperYChanged(yMax);
1729 }
1730}
1731
1732void KOAgenda::deselectItem()
1733{
1734 if (mSelectedItem.isNull()) return;
1735 mSelectedItem->select(false);
1736 mSelectedItem = 0;
1737}
1738
1739void KOAgenda::selectItem(KOAgendaItem *item)
1740{
1741 if ((KOAgendaItem *)mSelectedItem == item) return;
1742 deselectItem();
1743 if (item == 0) {
1744 emit incidenceSelected( 0 );
1745 return;
1746 }
1747 mSelectedItem = item;
1748 mSelectedItem->select();
1749 emit incidenceSelected( mSelectedItem->incidence() );
1750}
1751
1752// This function seems never be called.
1753void KOAgenda::keyPressEvent( QKeyEvent *kev )
1754{
1755 switch(kev->key()) {
1756 case Key_PageDown:
1757 verticalScrollBar()->addPage();
1758 break;
1759 case Key_PageUp:
1760 verticalScrollBar()->subtractPage();
1761 break;
1762 case Key_Down:
1763 verticalScrollBar()->addLine();
1764 break;
1765 case Key_Up:
1766 verticalScrollBar()->subtractLine();
1767 break;
1768 default:
1769 ;
1770 }
1771}
1772
1773void KOAgenda::calculateWorkingHours()
1774{
1775// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
1776 mWorkingHoursEnable = !mAllDayMode;
1777
1778 mWorkingHoursYTop = mGridSpacingY *
1779 KOPrefs::instance()->mWorkingHoursStart * 4;
1780 mWorkingHoursYBottom = mGridSpacingY *
1781 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
1782}
1783
1784
1785DateList KOAgenda::dateList() const
1786{
1787 return mSelectedDates;
1788}
1789
1790void KOAgenda::setDateList(const DateList &selectedDates)
1791{
1792 mSelectedDates = selectedDates;
1793 marcus_bains();
1794}
1795
1796void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
1797{
1798 mHolidayMask = mask;
1799
1800/*
1801 kdDebug() << "HolidayMask: ";
1802 for(uint i=0;i<mask->count();++i) {
1803 kdDebug() << (mask->at(i) ? "*" : "o");
1804 }
1805 kdDebug() << endl;
1806*/
1807}
1808
1809void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
1810{
1811
1812 QScrollView::contentsMousePressEvent(event);
1813}
1814
1815void KOAgenda::storePosition()
1816{
1817 //mContentPosition
1818 int max = mGridSpacingY*4*24;
1819 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
1820 mContentPosition = 0;
1821 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
1822 mContentPosition = -1.0;
1823 else
1824 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
1825 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
1826
1827}
1828void KOAgenda::restorePosition()
1829{
1830 int posY;
1831 int max = mGridSpacingY*4*24;
1832 if ( mContentPosition < 0 )
1833 posY = max-viewport()->height();
1834 else
1835 if ( mContentPosition == 0 )
1836 posY = 0;
1837 else
1838 posY = (max/mContentPosition)-(viewport()->height()/2);
1839 setContentsPos (0, posY );
1840 //qDebug("posY %d hei %d", posY, max);
1841
1842}
1843void KOAgenda::moveChild( QWidget *w, int x , int y )
1844{
1845 ++x;
1846 QScrollView::moveChild( w, x , y );
1847}
1848#include <qmessagebox.h>
1849#ifdef DESKTOP_VERSION
1850#include <qprinter.h>
1851#include <qpainter.h>
1852#include <qpaintdevicemetrics.h>
1853
1854#endif
1855void KOAgenda::printSelection()
1856{
1857#ifdef DESKTOP_VERSION
1858 if ( mStartCellY == mCurrentCellY ) {
1859 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1860 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
1861 i18n("OK"), 0, 0,
1862 0, 1 );
1863 return;
1864 }
1865
1866 float dx, dy;
1867 int x,y,w,h;
1868 x= 0;
1869 w= contentsWidth()+2;
1870 // h= contentsHeight();
1871 y = mGridSpacingY*mStartCellY;
1872 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
1873
1874 //return;
1875 QPrinter* printer = new QPrinter();
1876 if ( !printer->setup()) {
1877 delete printer;
1878 return;
1879 }
1880 QPainter p( printer );
1881 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
1882 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
1883 date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
1884 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
1885 // p.drawText( 0, 0, date );
1886 int offset = m.width()/8;
1887 // compute the scale
1888 dx = ((float) m.width()-offset) / (float)w;
1889 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
1890 float scale;
1891 // scale to fit the width or height of the paper
1892 if ( dx < dy )
1893 scale = dx;
1894 else
1895 scale = dy;
1896 // set the scale
1897 p.drawText( offset* scale, offset* scale*3/4, date );
1898
1899 int selDay;
1900 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
1901 float startX = 1;
1902 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1903 {
1904 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
1905 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) );
1906 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
1907 startX += widOffset;
1908
1909 }
1910 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
1911 p.scale( scale, scale );
1912 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale );
1913 // now printing with y offset: 2 hei
1914 // p.translate( 0, -y*scale);
1915
1916 drawContentsToPainter(&p, true );
1917 globalFlagBlockAgendaItemUpdate = false;
1918 KOAgendaItem *item;
1919 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1920 item->select(false);
1921 item->paintMe( false, &p );
1922 }
1923 globalFlagBlockAgendaItemUpdate = true;
1924 p.end();
1925 delete printer;
1926#else
1927 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1928 i18n("Not supported \non PDA!\n"),
1929 i18n("OK"), 0, 0,
1930 0, 1 );
1931#endif
1932}
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
new file mode 100644
index 0000000..111242f
--- a/dev/null
+++ b/korganizer/koagenda.h
@@ -0,0 +1,286 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOAGENDA_H
24#define KOAGENDA_H
25
26#include <qscrollview.h>
27#include <qtimer.h>
28#include <qmemarray.h>
29#include <qpainter.h>
30#include <qpixmap.h>
31#include <qguardedptr.h>
32
33#include "koagendaitem.h"
34
35class QPopupMenu;
36class QTime;
37class KConfig;
38class QFrame;
39class KOAgenda;
40class KCal::Event;
41class KCal::Todo;
42
43using namespace KCal;
44
45class MarcusBains : public QFrame {
46 Q_OBJECT
47 public:
48 MarcusBains(KOAgenda *agenda=0,const char *name=0);
49 virtual ~MarcusBains();
50
51 public slots:
52 void updateLocation(bool recalculate=false);
53 void updateLoc();
54
55 private:
56 int todayColumn();
57 QTimer *minutes;
58 QLabel *mTimeBox;
59 KOAgenda *agenda;
60 QTime oldTime;
61 int oldToday;
62};
63
64
65class KOAgenda : public QScrollView
66{
67 Q_OBJECT
68 public:
69 enum MouseActionType { NOP, MOVE, SELECT,
70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
71
72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
73 const char * name=0, WFlags f=0 );
74 KOAgenda ( int columns, QWidget * parent=0,
75 const char * name=0, WFlags f=0 );
76 virtual ~KOAgenda();
77
78 Incidence *selectedIncidence() const;
79 QDate selectedIncidenceDate() const;
80
81 virtual bool eventFilter ( QObject *, QEvent * );
82
83 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y);
85
86 int timeToY (const QTime &time);
87 QTime gyToTime (int y);
88
89 void setStartHour(int startHour);
90
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom);
95
96 void changeColumns(int columns);
97
98 int columns() { return mColumns; }
99 int rows() { return mRows; }
100
101 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; }
103
104// virtual QSizePolicy sizePolicy() const;
105
106 void clear();
107
108 void clearSelection();
109 void hideUnused();
110
111 /** Calculates the minimum width */
112 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */
114 void updateConfig();
115
116 void checkScrollBoundaries();
117
118 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates);
120 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate();
123 void printSelection();
124 void storePosition();
125 void restorePosition();
126
127
128 public slots:
129 void moveChild( QWidget *, int, int );
130 void scrollUp();
131 void scrollDown();
132 void updateTodo( Todo * t, int , bool );
133 void popupAlarm();
134
135 void checkScrollBoundaries(int);
136
137 /** Deselect selected items. This function does not emit any signals. */
138 void deselectItem();
139 /** Select item. If the argument is 0, the currently selected item gets
140 deselected. This function emits the itemSelected(bool) signal to inform
141 about selection/deseelction of events. */
142 void selectItem(KOAgendaItem *);
143 void finishResize();
144
145 signals:
146 void newEventSignal();
147 void newEventSignal(int gx,int gy);
148 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
149 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
150 void newStartSelectSignal();
151 void showIncidenceSignal(Incidence *);
152 void editIncidenceSignal(Incidence *);
153 void deleteIncidenceSignal(Incidence *);
154 void showIncidencePopupSignal(Incidence *);
155
156 void itemModified(KOAgendaItem *item, int );
157 void incidenceSelected(Incidence *);
158
159 void lowerYChanged(int);
160 void upperYChanged(int);
161
162 void startDragSignal(Incidence *);
163 void addToCalSignal(Incidence *, Incidence *);
164 void resizedSignal();
165
166 protected:
167 QPainter mPixPainter;
168 QPixmap mPaintPixmap;
169 QPixmap mHighlightPixmap;
170 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
171 virtual void resizeEvent ( QResizeEvent * );
172
173 /** Handles mouse events. Called from eventFilter */
174 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
175
176 /** Start selecting time span. */
177 void startSelectAction(QPoint viewportPos);
178
179 /** Select time span. */
180 void performSelectAction(QPoint viewportPos);
181
182 /** Emd selecting time span. */
183 void endSelectAction();
184
185 /** Start moving/resizing agenda item */
186 void startItemAction(QPoint viewportPos);
187
188 /** Move/resize agenda item */
189 void performItemAction(QPoint viewportPos);
190
191 /** End moving/resizing agenda item */
192 void endItemAction();
193
194 /** Set cursor, when no item action is in progress */
195 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
196
197 /** Place agenda item in agenda and adjust other cells if necessary */
198 void placeSubCells(KOAgendaItem *placeItem);
199
200 /** Process the keyevent, including the ignored keyevents of eventwidgets.
201 * Implements pgup/pgdn and cursor key navigation in the view.
202 */
203 void keyPressEvent( QKeyEvent * );
204
205 void calculateWorkingHours();
206
207 virtual void contentsMousePressEvent ( QMouseEvent * );
208
209 private:
210 void init();
211 void marcus_bains();
212 bool mAllDayMode;
213 bool blockResize;
214 QTimer mResizeTimer;
215 double mContentPosition;
216
217 // Width and height of agenda cells
218 int mGridSpacingX;
219 int mGridSpacingY;
220
221 // size of border, where mouse action will resize the KOAgendaItem
222 int mResizeBorderWidth;
223
224 // size of border, where mouse mve will cause a scroll of the agenda
225 int mScrollBorderWidth;
226 int mScrollDelay;
227 int mScrollOffset;
228
229 QTimer mScrollUpTimer;
230 QTimer mScrollDownTimer;
231
232 // Number of Columns/Rows of agenda grid
233 int mColumns;
234 int mRows;
235
236 // Cells to store Move and Resize coordiantes
237 int mStartCellX;
238 int mStartCellY;
239 int mCurrentCellX;
240 int mCurrentCellY;
241
242 // Working Hour coordiantes
243 bool mWorkingHoursEnable;
244 int mWorkingHoursYTop;
245 int mWorkingHoursYBottom;
246
247 // Selection
248 int mSelectionCellX;
249 int mSelectionYTop;
250 int mSelectionHeight;
251
252 // List of dates to be displayed
253 DateList mSelectedDates;
254
255 // The KOAgendaItem, which has been right-clicked last
256 KOAgendaItem *mClickedItem;
257
258 // The KOAgendaItem, which is being moved/resized
259 QGuardedPtr<KOAgendaItem> mActionItem;
260
261 // Currently selected item
262 QGuardedPtr<KOAgendaItem> mSelectedItem;
263
264 // The Marcus Bains Line widget.
265 MarcusBains *mMarcusBains;
266 void computeSizes();
267
268 MouseActionType mActionType;
269
270 bool mItemMoved;
271
272 // List of all Items contained in agenda
273 QPtrList<KOAgendaItem> mItems;
274 QPtrList<KOAgendaItem> mUnusedItems;
275 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
276 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
277
278 int mOldLowerScrollValue;
279 int mOldUpperScrollValue;
280 KOAgendaItem * getItemForTodo ( Todo * todo );
281 QMemArray<bool> *mHolidayMask;
282 int mCurPixWid;
283 int mCurPixHei;
284};
285
286#endif // KOAGENDA_H
diff --git a/korganizer/koagenda.moc b/korganizer/koagenda.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koagenda.moc
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
new file mode 100644
index 0000000..02fd33b
--- a/dev/null
+++ b/korganizer/koagendaitem.cpp
@@ -0,0 +1,720 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <qlabel.h>
21#include <qlayout.h>
22#include <qhbox.h>
23#include <qvbox.h>
24#include <qtooltip.h>
25#include <qwhatsthis.h>
26#include <qdragobject.h>
27#include <qdrawutil.h>
28#include <qpainter.h>
29
30#include <kiconloader.h>
31#include <kdebug.h>
32#include <kglobal.h>
33#include <klocale.h>
34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5
37#else
38#define AGENDA_ICON_SIZE 7
39#endif
40#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h>
42#include <libkdepim/kincidenceformatter.h>
43extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate;
46
47#include "koprefs.h"
48
49#include "koagendaitem.h"
50#include "koagendaitem.moc"
51
52
53//--------------------------------------------------------------------------
54
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56
57//--------------------------------------------------------------------------
58
59KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
60 const char *name,WFlags) :
61 QWidget(parent, name), mIncidence(incidence), mDate(qd)
62{
63#ifndef DESKTOP_VERSION
64 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
65#endif
66 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
67 setWFlags ( wflags);
68 mAllDay = allday;
69 init ( incidence, qd );
70 setMouseTracking(true);
71 //setAcceptDrops(true);
72 xPaintCoord = -1;
73 yPaintCoord = -1;
74}
75
76void KOAgendaItem::init ( Incidence *incidence, QDate qd )
77{
78 mIncidence = incidence;
79 mDate = qd;
80 mFirstMultiItem = 0;
81 mNextMultiItem = 0;
82 mLastMultiItem = 0;
83 computeText();
84
85 if ( (incidence->type() == "Todo") &&
86 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
87 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
88 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
89 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
90 else
91 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
92 }
93 else {
94 QStringList categories = mIncidence->categories();
95 QString cat = categories.first();
96 if (cat.isEmpty()) {
97 mBackgroundColor =KOPrefs::instance()->mEventColor;
98 } else {
99 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
100 }
101 }
102 mColorGroup = QColorGroup( mBackgroundColor.light(),
103 mBackgroundColor.dark(),mBackgroundColor.light(),
104 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
105 setBackgroundColor( mBackgroundColor );
106
107 setCellXY(0,0,1);
108 setCellXWidth(0);
109 setSubCell(0);
110 setSubCells(1);
111 setMultiItem(0,0,0);
112 startMove();
113 mSelected = true;
114 select(false);
115 QString tipText = mIncidence->summary();
116 // QToolTip::add(this,tipText);
117 QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
118 if ( !mIncidence->doesFloat() )
119 if ( mIncidence->type() == "Event" ) {
120 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
121 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
122 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
123 }
124 else {
125 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
126 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
127 }
128 }
129 else if ( mIncidence->type() == "Todo" ) {
130 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr();
131 }
132
133 if (!mIncidence->location().isEmpty()) {
134 tipText += "\n"+i18n("Location: ")+mIncidence->location();
135 }
136 QToolTip::add(this,tipText,toolTipGroup(),"");
137 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
138 mFontPixelSize = fontinf.height();;
139 hide();
140 xPaintCoord = -1;
141 yPaintCoord = -1;
142}
143
144
145KOAgendaItem::~KOAgendaItem()
146{
147 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
148
149}
150
151void KOAgendaItem::recreateIncidence()
152{
153 Incidence* newInc = mIncidence->clone();
154 newInc->recreate();
155 if ( mIncidence->doesRecur() ) {
156 mIncidence->addExDate( mDate );
157 newInc->recurrence()->unsetRecurs();
158 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
159 QTime tim = mIncidence->dtStart().time();
160 newInc->setDtStart( QDateTime(mDate, tim) );
161 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
162 }
163 mIncidence = newInc;
164}
165bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
166{
167 int size = AGENDA_ICON_SIZE;
168
169 int yOff = 0;
170 int xOff = 0;
171 int x = pos().x() +3;
172 int y;
173 if ( mAllDay )
174 y = pos().y()+3;
175 else
176 y = mCellYTop * ( height() / cellHeight() ) +3;
177 if (mIncidence->cancelled()) {
178 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
179 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
180 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
181 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
182 if ( horLayout )
183 ++xOff;
184 else
185 ++yOff;
186 }
187 if (mIncidence->isAlarmEnabled()) {
188 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
189 if ( horLayout )
190 ++xOff;
191 else
192 ++yOff;
193 }
194 if (mIncidence->recurrence()->doesRecur()) {
195 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
196 if ( horLayout )
197 ++xOff;
198 else
199 ++yOff;
200 }
201 if (mIncidence->description().length() > 0) {
202 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
203 if ( horLayout )
204 ++xOff;
205 else
206 ++yOff;
207 }
208 if (mIncidence->isReadOnly()) {
209 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
210 if ( horLayout )
211 ++xOff;
212 else
213 ++yOff;
214 }
215
216 if (mIncidence->attendeeCount()>0) {
217
218 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
219 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
220 if ( horLayout )
221 ++xOff;
222 else
223 ++yOff;
224 } else {
225 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
226 if (me!=0) {
227
228
229 } else {
230 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
231 if ( horLayout )
232 ++xOff;
233 else
234 ++yOff;
235
236 }
237 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
238 if ( horLayout )
239 ++xOff;
240 else
241 ++yOff;
242
243 }
244
245 }
246 return ( yOff || xOff );
247}
248
249
250void KOAgendaItem::select(bool selected)
251{
252 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
253 if (mSelected == selected) return;
254 mSelected = selected;
255 if ( ! isVisible() )
256 return;
257 if ( firstMultiItem() )
258 firstMultiItem()->select( selected );
259 if ( !firstMultiItem() && nextMultiItem() ) {
260 KOAgendaItem * placeItem = nextMultiItem();
261 while ( placeItem ) {
262 placeItem->select( selected );
263 placeItem = placeItem->nextMultiItem();
264 }
265 }
266 globalFlagBlockAgendaItemUpdate = 0;
267 paintMe( selected );
268 globalFlagBlockAgendaItemUpdate = 1;
269 repaint( false );
270}
271
272
273/*
274 The eventFilter has to filter the mouse events of the agenda item childs. The
275 events are fed into the event handling method of KOAgendaItem. This allows the
276 KOAgenda to handle the KOAgendaItems by using an eventFilter.
277*/
278bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
279{
280 if (e->type() == QEvent::MouseButtonPress ||
281 e->type() == QEvent::MouseButtonDblClick ||
282 e->type() == QEvent::MouseButtonRelease ||
283 e->type() == QEvent::MouseMove) {
284 QMouseEvent *me = (QMouseEvent *)e;
285 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
286 mapToGlobal(me->pos()));
287 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
288 return event(&returnEvent);
289 } else {
290 return false;
291 }
292}
293void KOAgendaItem::repaintMe( )
294{
295 paintMe ( mSelected );
296}
297void KOAgendaItem::paintMe( bool selected, QPainter* paint )
298{
299 if ( globalFlagBlockAgendaItemUpdate && ! selected)
300 return;
301 QPainter pa;
302
303 if ( mSelected ) {
304 pa.begin( paintPixSel() );
305 } else {
306 if ( mAllDay )
307 pa.begin( paintPixAllday() );
308 else
309 pa.begin( paintPix() );
310 }
311 int x, yy, w, h;
312 float nfh;
313 x = pos().x(); w = width(); h = height ();
314 if ( mAllDay )
315 yy = y();
316 else
317 yy = mCellYTop * ( height() / cellHeight() );
318 xPaintCoord= x;
319 yPaintCoord = yy;
320 wPaintCoord = width();
321 hPaintCoord = height();
322 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
323 if ( paint == 0 )
324 paint = &pa;
325 bool horLayout = ( w < h );
326 int maxhei = mFontPixelSize+4;
327 if ( horLayout )
328 maxhei += AGENDA_ICON_SIZE -4;
329 bool small = ( h < maxhei );
330 if ( ! small )
331 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
332 else {
333 QFont f = KOPrefs::instance()->mAgendaViewFont;
334 f.setBold( false );
335 int fh = f.pointSize();
336 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
337 if ( nfh < 6 )
338 nfh = 6;
339 f.setPointSize( nfh );
340 paint->setFont(f);
341 }
342 paint->fillRect ( x, yy, w, h, mBackgroundColor );
343 static const QPixmap completedPxmp = SmallIcon("greenhook16");
344 static const QPixmap overduePxmp = SmallIcon("redcross16");
345 if ( mIncidence->type() == "Todo" ) {
346 Todo* tempTodo = static_cast<Todo*>(mIncidence);
347 int xx = pos().x()+(width()-completedPxmp.width()-3 );
348 int yyy = yy+3;
349 if ( tempTodo->isCompleted() )
350 paint->drawPixmap ( xx, yyy, completedPxmp );
351 else {
352 paint->drawPixmap ( xx, yyy, overduePxmp );
353
354 }
355 }
356 bool addIcon = false;
357 if ( ! small || w > 3 * h || h > 3* w )
358 addIcon = updateIcons( paint, horLayout );
359
360 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
361 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
362 if ( ! small ) {
363 x += 3; yy += 3;w -= 6; h-= 5;
364 } else {
365 x += 2; yy += 1;w -= 4; h-= 4;
366 if ( nfh < 6.01 ) {
367 yy -= 2;
368 h += 4;
369 }
370 else
371 if ( nfh < h -2 )
372 ++yy;
373 }
374 int align;
375#ifndef DESKTOP_VERSION
376 align = ( AlignLeft|WordBreak|AlignTop);
377#else
378 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
379#endif
380 if ( addIcon ) {
381 if ( ! horLayout ) {
382 x += AGENDA_ICON_SIZE+3;
383 w -= (AGENDA_ICON_SIZE+3);
384 }
385 else {
386 yy+= AGENDA_ICON_SIZE+2;
387 h -=(AGENDA_ICON_SIZE+3);
388 }
389 }
390 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
391 if ( colsum < 250 )
392 paint->setPen ( white);
393 if ( x < 0 ) {
394 w = w+x-3;
395 x = 3;
396 if ( w > parentWidget()->width() ){
397 w = parentWidget()->width() - 6;
398#ifndef DESKTOP_VERSION
399 align = ( AlignCenter|WordBreak);
400#else
401 align = ( AlignCenter|BreakAnywhere|WordBreak);
402#endif
403
404 }
405 }
406 QRect dr;
407 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
408 if ( mIncidence->cancelled() ){
409 if ( ! small ) {
410 QFontMetrics fm ( paint->font() );
411 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
412 }
413
414 }
415 pa.end();
416
417}
418void KOAgendaItem::resizePixmap( int w , int h )
419{
420 paintPix()->resize( w, h );
421 paintPixSel()->resize( w, h );
422
423}
424QPixmap * KOAgendaItem::paintPix()
425{
426 static QPixmap* mPaintPix = 0;
427 if ( ! mPaintPix )
428 mPaintPix = new QPixmap();
429 return mPaintPix ;
430}
431QPixmap * KOAgendaItem::paintPixAllday()
432{
433 static QPixmap* mPaintPixA = 0;
434 if ( ! mPaintPixA )
435 mPaintPixA = new QPixmap();
436 return mPaintPixA ;
437}
438QPixmap * KOAgendaItem::paintPixSel()
439{
440 static QPixmap* mPaintPixSel = 0;
441 if ( ! mPaintPixSel )
442 mPaintPixSel = new QPixmap();
443 return mPaintPixSel ;
444}
445void KOAgendaItem::paintEvent ( QPaintEvent *e )
446{
447
448 if ( globalFlagBlockAgendaItemPaint )
449 return;
450 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
451 return;
452 int yy;
453 if ( mAllDay )
454 yy = y();
455 else
456 yy = mCellYTop * ( height() / cellHeight() );
457 int xx = x();
458 if ( xPaintCoord != xx || yPaintCoord != yy ||
459 wPaintCoord != width() || hPaintCoord != height()) {
460 xPaintCoord= xx;
461 yPaintCoord = yy;
462 wPaintCoord = width();
463 hPaintCoord = height();
464 globalFlagBlockAgendaItemUpdate = 0;
465 paintMe( mSelected );
466 //qDebug("calling paintMe ");
467 globalFlagBlockAgendaItemUpdate = 1;
468 }
469 int rx, ry, rw, rh;
470 rx = e->rect().x();
471 ry = e->rect().y();
472 rw = e->rect().width();
473 rh = e->rect().height();
474 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
475
476 QPixmap* paintFrom ;
477 if ( mSelected ) {
478 paintFrom = paintPixSel();
479 } else {
480 if ( mAllDay )
481 paintFrom = paintPixAllday();
482 else
483 paintFrom = paintPix();
484 }
485 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP);
486}
487void KOAgendaItem::computeText()
488{
489 mDisplayedText = mIncidence->summary();
490 if ( (mIncidence->type() == "Todo") ) {
491 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
492 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
493 else if ( !(mIncidence->doesFloat()))
494 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
495
496
497
498 } else {
499 if ( !(mIncidence->doesFloat()))
500 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
501
502 if ( mAllDay ) {
503 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
504 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
505 }
506 }
507
508 }
509
510 if ( !mIncidence->location().isEmpty() ) {
511 if ( mAllDay )
512 mDisplayedText += " (";
513 else
514 mDisplayedText += "\n(";
515 mDisplayedText += mIncidence->location() +")";
516 }
517}
518void KOAgendaItem::updateItem()
519{
520 computeText();
521
522 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
523 paintMe( mSelected );
524 repaint( false);
525}
526
527void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
528{
529 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
530 paintMe( mSelected );
531 repaint( false );
532}
533
534/*
535 Return height of item in units of agenda cells
536*/
537int KOAgendaItem::cellHeight()
538{
539 int ret = mCellYBottom - mCellYTop + 1;
540 if ( ret <= 0 ) {
541 ret = 1;
542 mCellYBottom = 0;
543 mCellYTop = 0;
544 }
545 return ret;
546}
547
548/*
549 Return height of item in units of agenda cells
550*/
551int KOAgendaItem::cellWidth()
552{
553 return mCellXWidth - mCellX + 1;
554}
555
556void KOAgendaItem::setItemDate(QDate qd)
557{
558 mDate = qd;
559}
560
561void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
562{
563 mCellX = X;
564 mCellYTop = YTop;
565 mCellYBottom = YBottom;
566}
567
568void KOAgendaItem::setCellXWidth(int xwidth)
569{
570 mCellXWidth = xwidth;
571}
572
573void KOAgendaItem::setCellX(int XLeft, int XRight)
574{
575 mCellX = XLeft;
576 mCellXWidth = XRight;
577}
578
579void KOAgendaItem::setCellY(int YTop, int YBottom)
580{
581 mCellYTop = YTop;
582 mCellYBottom = YBottom;
583}
584
585void KOAgendaItem::setSubCell(int subCell)
586{
587 mSubCell = subCell;
588}
589
590void KOAgendaItem::setSubCells(int subCells)
591{
592 mSubCells = subCells;
593}
594
595void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
596 KOAgendaItem *last)
597{
598 mFirstMultiItem = first;
599 mNextMultiItem = next;
600 mLastMultiItem = last;
601}
602
603void KOAgendaItem::startMove()
604{
605 mStartCellX = mCellX;
606 mStartCellXWidth = mCellXWidth;
607 mStartCellYTop = mCellYTop;
608 mStartCellYBottom = mCellYBottom;
609}
610
611void KOAgendaItem::resetMove()
612{
613 mCellX = mStartCellX;
614 mCellXWidth = mStartCellXWidth;
615 mCellYTop = mStartCellYTop;
616 mCellYBottom = mStartCellYBottom;
617}
618
619void KOAgendaItem::moveRelative(int dx, int dy)
620{
621 int newX = cellX() + dx;
622 int newXWidth = cellXWidth() + dx;
623 int newYTop = cellYTop() + dy;
624 int newYBottom = cellYBottom() + dy;
625 setCellXY(newX,newYTop,newYBottom);
626 setCellXWidth(newXWidth);
627}
628
629void KOAgendaItem::expandTop(int dy)
630{
631 int newYTop = cellYTop() + dy;
632 int newYBottom = cellYBottom();
633 if (newYTop > newYBottom) newYTop = newYBottom;
634 setCellY(newYTop, newYBottom);
635}
636
637void KOAgendaItem::expandBottom(int dy)
638{
639 int newYTop = cellYTop();
640 int newYBottom = cellYBottom() + dy;
641 if (newYBottom < newYTop) newYBottom = newYTop;
642 setCellY(newYTop, newYBottom);
643}
644
645void KOAgendaItem::expandLeft(int dx)
646{
647 int newX = cellX() + dx;
648 int newXWidth = cellXWidth();
649 if (newX > newXWidth) newX = newXWidth;
650 setCellX(newX,newXWidth);
651}
652
653void KOAgendaItem::expandRight(int dx)
654{
655 int newX = cellX();
656 int newXWidth = cellXWidth() + dx;
657 if (newXWidth < newX) newXWidth = newX;
658 setCellX(newX,newXWidth);
659}
660
661QToolTipGroup *KOAgendaItem::toolTipGroup()
662{
663 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
664 return mToolTipGroup;
665}
666
667void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
668{
669#ifndef KORG_NODND
670 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
671 !QTextDrag::canDecode( e ) ) {
672 e->ignore();
673 return;
674 }
675 e->accept();
676#endif
677}
678
679void KOAgendaItem::dropEvent( QDropEvent *e )
680{
681#ifndef KORG_NODND
682 QString text;
683 if(QTextDrag::decode(e,text))
684 {
685 kdDebug() << "Dropped : " << text << endl;
686 QStringList emails = QStringList::split(",",text);
687 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
688 kdDebug() << " Email: " << (*it) << endl;
689 int pos = (*it).find("<");
690 QString name = (*it).left(pos);
691 QString email = (*it).mid(pos);
692 if (!email.isEmpty()) {
693 mIncidence->addAttendee(new Attendee(name,email));
694 }
695 }
696 }
697#endif
698}
699
700
701QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
702{
703 return mConflictItems;
704}
705
706void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
707{
708 mConflictItems = ci;
709 KOAgendaItem *item;
710 for ( item=mConflictItems.first(); item != 0;
711 item=mConflictItems.next() ) {
712 item->addConflictItem(this);
713 }
714}
715
716void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
717{
718 if (mConflictItems.find(ci)<0)
719 mConflictItems.append(ci);
720}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
new file mode 100644
index 0000000..7321af2
--- a/dev/null
+++ b/korganizer/koagendaitem.h
@@ -0,0 +1,160 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H
21
22#include <qframe.h>
23#include <qlabel.h>
24#include <qpixmap.h>
25#include <qdatetime.h>
26#include <qpalette.h>
27
28#include <libkcal/incidence.h>
29
30class QToolTipGroup;
31class QDragEnterEvent;
32class QDropEvent;
33
34using namespace KCal;
35
36/*
37 The KOAgendaItem has to make sure that it receives all mouse events, which are
38 to be used for dragging and resizing. That means it has to be installed as
39 eventfiler for its children, if it has children, and it has to pass mouse
40 events from the cildren to itself. See eventFilter().
41*/
42class KOAgendaItem : public QWidget
43{
44 Q_OBJECT
45 public:
46 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
47 WFlags f=0 );
48 ~KOAgendaItem();
49 void init ( Incidence *incidence, QDate qd );
50 int cellX() { return mCellX; }
51 int cellXWidth() { return mCellXWidth; }
52 int cellYTop() { return mCellYTop; }
53 int cellYBottom() { return mCellYBottom; }
54 int cellHeight();
55 int cellWidth();
56 int subCell() { return mSubCell; }
57 int subCells() { return mSubCells; }
58
59 void setCellXY(int X, int YTop, int YBottom);
60 void setCellY(int YTop, int YBottom);
61 void setCellX(int XLeft, int XRight);
62 void setCellXWidth(int xwidth);
63 void setSubCell(int subCell);
64 void setSubCells(int subCells);
65
66 /** Start movement */
67 void startMove();
68 /** Reset to original values */
69 void resetMove();
70
71 void moveRelative(int dx,int dy);
72 void expandTop(int dy);
73 void expandBottom(int dy);
74 void expandLeft(int dx);
75 void expandRight(int dx);
76 int mLastMoveXPos;
77
78 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
79 KOAgendaItem *last);
80 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
81 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
82 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
83
84 Incidence *incidence() const { return mIncidence; }
85 QDate itemDate() { return mDate; }
86
87 /** Update the date of this item's occurence (not in the event) */
88 void setItemDate(QDate qd);
89
90 void setText ( const QString & text ) { mDisplayedText = text; }
91 QString text () { return mDisplayedText; }
92
93 virtual bool eventFilter ( QObject *, QEvent * );
94
95 static QToolTipGroup *toolTipGroup();
96
97 QPtrList<KOAgendaItem> conflictItems();
98 void setConflictItems(QPtrList<KOAgendaItem>);
99 void addConflictItem(KOAgendaItem *ci);
100 void paintMe( bool, QPainter* painter = 0 );
101 void repaintMe();
102 static void resizePixmap( int, int );
103 static QPixmap * paintPix();
104 static QPixmap * paintPixSel();
105 static QPixmap * paintPixAllday();
106 void updateItem();
107 void computeText();
108 void recreateIncidence();
109 public slots:
110 bool updateIcons( QPainter *, bool );
111 void select(bool=true);
112
113 protected:
114 void dragEnterEvent(QDragEnterEvent *e);
115 void dropEvent(QDropEvent *e);
116 void paintEvent ( QPaintEvent * );
117 void resizeEvent ( QResizeEvent *ev );
118
119 private:
120 bool mAllDay;
121 int mCellX;
122 int mCellXWidth;
123 int mCellYTop,mCellYBottom;
124 int mSubCell; // subcell number of this item
125 int mSubCells; // Total number of subcells in cell of this item
126 int xPaintCoord;
127 int yPaintCoord;
128 int wPaintCoord;
129 int hPaintCoord;
130 // Variables to remember start position
131 int mStartCellX;
132 int mStartCellXWidth;
133 int mStartCellYTop,mStartCellYBottom;
134 int mLastMovePos;
135
136 // Multi item pointers
137 KOAgendaItem *mFirstMultiItem;
138 KOAgendaItem *mNextMultiItem;
139 KOAgendaItem *mLastMultiItem;
140
141 int mFontPixelSize;
142 Incidence *mIncidence; // corresponding event or todo
143 QDate mDate; //date this events occurs (for recurrence)
144 //void showIcon( QLabel*, int );
145 //QLabel *mTodoIconLabel;
146 //QLabel *mItemLabel;
147 //QWidget *mIconBox;
148 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
149 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
150 //QLabel *mIconMoreInfo;
151 static QToolTipGroup *mToolTipGroup;
152
153 QColor mBackgroundColor;
154 QColorGroup mColorGroup;
155 QString mDisplayedText;
156 bool mSelected;
157 QPtrList<KOAgendaItem> mConflictItems;
158};
159
160#endif // KOAGENDAITEM_H
diff --git a/korganizer/koagendaitem.moc b/korganizer/koagendaitem.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koagendaitem.moc
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
new file mode 100644
index 0000000..9e057e4
--- a/dev/null
+++ b/korganizer/koagendaview.cpp
@@ -0,0 +1,1436 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qhbox.h>
25#include <qvbox.h>
26#include <qlabel.h>
27#include <qframe.h>
28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h>
31#endif
32#include <qfont.h>
33#include <qfontmetrics.h>
34#include <qpopupmenu.h>
35#include <qtooltip.h>
36#include <qpainter.h>
37#include <qpushbutton.h>
38#include <qapplication.h>
39
40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h>
43#include <kstandarddirs.h>
44#include <kiconloader.h>
45#include <klocale.h>
46#include <kconfig.h>
47#include <kglobal.h>
48#include "calendarview.h"
49#include "koviewmanager.h"
50
51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h>
54
55#include <kcalendarsystem.h>
56
57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS
59#include "kocore.h"
60#endif
61#include "koprefs.h"
62#include "koagenda.h"
63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER
65#include "calprinter.h"
66#endif
67
68#include "koagendaview.h"
69#include "koagendaview.moc"
70
71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel;
77using namespace KOrg;
78
79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
80 QScrollView(parent,name,f)
81{
82 mRows = rows;
83
84 setMinimumHeight( 20 );
85 mCellHeight = KOPrefs::instance()->mHourSize*4;
86
87 enableClipper(true);
88
89 setHScrollBarMode(AlwaysOff);
90 setVScrollBarMode(AlwaysOff);
91
92 resizeContents(50,mRows * mCellHeight);
93
94 viewport()->setBackgroundMode( PaletteBackground );
95}
96
97void TimeLabels::setCellHeight(int height)
98{
99 mCellHeight = height;
100}
101
102/*
103 Optimization so that only the "dirty" portion of the scroll view
104 is redrawn. Unfortunately, this is not called by default paintEvent() method.
105*/
106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
107{
108
109 // if ( globalFlagBlockAgenda )
110 // return;
111 // bug: the parameters cx, cy, cw, ch are the areas that need to be
112 // redrawn, not the area of the widget. unfortunately, this
113 // code assumes the latter...
114
115 // now, for a workaround...
116 // these two assignments fix the weird redraw bug
117 cx = contentsX() + 2;
118 cw = contentsWidth() - 2;
119 // end of workaround
120
121 int cell = ((int)(cy/mCellHeight));
122 int y = cell * mCellHeight;
123 QFontMetrics fm = fontMetrics();
124 QString hour;
125 QString suffix;
126 QString fullTime;
127 int tW = fm.width("24:00i");
128
129 while (y < cy + ch) {
130 p->drawLine(cx,y,cx+tW,y);
131 hour.setNum(cell);
132 suffix = "am";
133
134 // handle 24h and am/pm time formats
135 if (KGlobal::locale()->use12Clock()) {
136 if (cell > 11) suffix = "pm";
137 if (cell == 0) hour.setNum(12);
138 if (cell > 12) hour.setNum(cell - 12);
139 } else {
140 suffix = ":00";
141 }
142
143 // create string in format of "XX:XX" or "XXpm/am"
144 fullTime = hour + suffix;
145
146 // center and draw the time label
147 int timeWidth = fm.width(fullTime+"i");
148 int offset = this->width() - timeWidth;
149 int borderWidth = 5;
150 int timeHeight = fm.height();
151 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
153
154 // increment indices
155 y += mCellHeight;
156 cell++;
157 }
158}
159
160/**
161 Calculates the minimum width.
162*/
163int TimeLabels::minimumWidth() const
164{
165 QFontMetrics fm = fontMetrics();
166
167 //TODO: calculate this value
168 int borderWidth = 4;
169
170 // the maximum width possible
171 int width = fm.width("88:88x") + borderWidth;
172
173 return width;
174}
175
176/** updates widget's internal state */
177void TimeLabels::updateConfig()
178{
179 // set the font
180 // config->setGroup("Fonts");
181 // QFont font = config->readFontEntry("TimeBar Font");
182 setFont(KOPrefs::instance()->mTimeBarFont);
183
184 // update geometry restrictions based on new settings
185 setFixedWidth(minimumWidth());
186
187 // update HourSize
188 mCellHeight = KOPrefs::instance()->mHourSize*4;
189 resizeContents(50,mRows * mCellHeight);
190}
191
192/** update time label positions */
193void TimeLabels::positionChanged()
194{
195 int adjustment = mAgenda->contentsY();
196 setContentsPos(0, adjustment);
197}
198
199/** */
200void TimeLabels::setAgenda(KOAgenda* agenda)
201{
202 mAgenda = agenda;
203}
204
205
206/** This is called in response to repaint() */
207void TimeLabels::paintEvent(QPaintEvent*)
208{
209
210 // kdDebug() << "paintevent..." << endl;
211 // this is another hack!
212 // QPainter painter(this);
213 //QString c
214 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
215}
216
217////////////////////////////////////////////////////////////////////////////
218
219EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
220 : QFrame(parent,name)
221{
222 mColumns = 1;
223 mTopBox = 0;
224 mLocation = loc;
225 mTopLayout = 0;
226 mPaintWidget = 0;
227 mXOffset = 0;
228 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
229 else mPixmap = SmallIcon("1downarrow");
230 mEnabled.resize(mColumns);
231 if (mLocation == Top)
232 setMaximumHeight(0);
233 else
234 setMinimumHeight(mPixmap.height());
235}
236
237EventIndicator::~EventIndicator()
238{
239}
240
241void EventIndicator::drawContents(QPainter *p)
242{
243
244 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
245 KDGanttSplitterHandle* han = 0;
246 if ( mPaintWidget )
247 han = mPaintWidget->firstHandle();
248 if ( ! han ) {
249 int i;
250 for(i=0;i<mColumns;++i) {
251 if (mEnabled[i]) {
252 int cellWidth = contentsRect().right()/mColumns;
253 int xOffset = KOGlobals::self()->reverseLayout() ?
254 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
255 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
256 p->drawPixmap(QPoint(xOffset,0),mPixmap);
257 }
258 }
259 } else {
260 han->repaint();
261 //mPaintWidget->setBackgroundColor( red );
262
263 QPainter pa( han );
264 int i;
265 bool setColor = false;
266 for(i=0;i<mColumns;++i) {
267 if (mEnabled[i]) {
268 setColor = true;
269
270 int cellWidth = contentsRect().right()/mColumns;
271 int xOffset = KOGlobals::self()->reverseLayout() ?
272 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
273 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
274 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
275 //qDebug("222draw pix %d ",xOffset );
276
277 }
278
279 }
280 pa.end();
281
282 }
283}
284
285void EventIndicator::setXOffset( int x )
286{
287 mXOffset = x;
288}
289void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
290{
291 mPaintWidget = w;
292}
293void EventIndicator::changeColumns(int columns)
294{
295 mColumns = columns;
296 mEnabled.resize(mColumns);
297
298 update();
299}
300
301void EventIndicator::enableColumn(int column, bool enable)
302{
303 mEnabled[column] = enable;
304}
305
306
307////////////////////////////////////////////////////////////////////////////
308////////////////////////////////////////////////////////////////////////////
309////////////////////////////////////////////////////////////////////////////
310
311KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
312 KOEventView (cal,parent,name)
313{
314 mBlockUpdating = true;
315 mStartHour = 8;
316 mSelectedDates.append(QDate::currentDate());
317
318 mLayoutDayLabels = 0;
319 mDayLabelsFrame = 0;
320 mDayLabels = 0;
321 bool isRTL = KOGlobals::self()->reverseLayout();
322
323 if ( KOPrefs::instance()->mVerticalScreen ) {
324 mExpandedPixmap = SmallIcon( "1downarrow" );
325 mNotExpandedPixmap = SmallIcon( "1uparrow" );
326 } else {
327 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
328 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
329 }
330
331 QBoxLayout *topLayout = new QVBoxLayout(this);
332
333 // Create day name labels for agenda columns
334 mDayLabelsFrame = new QHBox(this);
335 topLayout->addWidget(mDayLabelsFrame);
336 mDayLabels = new QFrame (mDayLabelsFrame);
337 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
338 // Create agenda splitter
339#ifndef KORG_NOSPLITTER
340 mSplitterAgenda = new QSplitter(Vertical,this);
341 topLayout->addWidget(mSplitterAgenda);
342 mSplitterAgenda->setOpaqueResize();
343
344 mAllDayFrame = new QHBox(mSplitterAgenda);
345
346 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
347#else
348#if 0
349 QWidget *mainBox = new QWidget( this );
350 topLayout->addWidget( mainBox );
351 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
352 mAllDayFrame = new QHBox(mainBox);
353 mainLayout->addWidget(mAllDayFrame);
354 mainLayout->setStretchFactor( mAllDayFrame, 0 );
355 mAllDayFrame->setFocusPolicy(NoFocus);
356 QWidget *agendaFrame = new QWidget(mainBox);
357 mainLayout->addWidget(agendaFrame);
358 mainLayout->setStretchFactor( agendaFrame, 10 );
359
360 agendaFrame->setFocusPolicy(NoFocus);
361#endif
362 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
363 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
364 topLayout->addWidget( mSplitterAgenda );
365 mAllDayFrame = new QHBox(mSplitterAgenda);
366 mAllDayFrame->setFocusPolicy(NoFocus);
367 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
368 agendaFrame->setFocusPolicy(NoFocus);
369
370#endif
371
372 // Create all-day agenda widget
373 mDummyAllDayLeft = new QVBox( mAllDayFrame );
374
375 mExpandButton = new QPushButton(mDummyAllDayLeft);
376 mExpandButton->setPixmap( mNotExpandedPixmap );
377 mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
378 QSizePolicy::Fixed ) );
379 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
380 mExpandButton->setFocusPolicy(NoFocus);
381 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
382 mAllDayAgenda->setFocusPolicy(NoFocus);
383 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
384
385 // Create event context menu for all day agenda
386 mAllDayAgendaPopup = eventPopup();
387 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
388 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
389
390 // Create agenda frame
391 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
392 // QHBox *agendaFrame = new QHBox(splitterAgenda);
393
394 // create event indicator bars
395 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
396 agendaLayout->addWidget(mEventIndicatorTop,0,1);
397 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
398 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
399 agendaFrame);
400 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
401 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
402 agendaLayout->addWidget(dummyAgendaRight,0,2);
403
404 // Create time labels
405 mTimeLabels = new TimeLabels(24,agendaFrame);
406 agendaLayout->addWidget(mTimeLabels,1,0);
407
408 // Create agenda
409 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
410 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
411 agendaLayout->setColStretch(1,1);
412 mAgenda->setFocusPolicy(NoFocus);
413 // Create event context menu for agenda
414 mAgendaPopup = eventPopup();
415
416 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
417 i18n("Toggle Alarm"),mAgenda,
418 SLOT(popupAlarm()),true);
419
420
421 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
422 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
423
424 // make connections between dependent widgets
425 mTimeLabels->setAgenda(mAgenda);
426
427 // Update widgets to reflect user preferences
428 // updateConfig();
429
430 // createDayLabels();
431
432 // these blank widgets make the All Day Event box line up with the agenda
433 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
434 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
435 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
436
437 // Scrolling
438 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
439 mTimeLabels, SLOT(positionChanged()));
440 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
441 SLOT(setContentsPos(int)));
442
443 // Create/Show/Edit/Delete Event
444 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
445 SLOT(newEvent(int,int)));
446 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
447 SLOT(newEvent(int,int,int,int)));
448 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
449 SLOT(newEventAllDay(int,int)));
450 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
451 SLOT(newEventAllDay(int,int)));
452 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
453 SLOT(newTimeSpanSelected(int,int,int,int)));
454 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
455 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
456 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
457 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
458
459 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
460 SIGNAL(editIncidenceSignal(Incidence *)));
461 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
462 SIGNAL(editIncidenceSignal(Incidence *)));
463 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
464 SIGNAL(showIncidenceSignal(Incidence *)));
465 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
466 SIGNAL(showIncidenceSignal(Incidence *)));
467 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
468 SIGNAL(deleteIncidenceSignal(Incidence *)));
469 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
470 SIGNAL(deleteIncidenceSignal(Incidence *)));
471
472 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
473 SLOT(updateEventDates(KOAgendaItem *, int )));
474 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
475 SLOT(updateEventDates(KOAgendaItem *, int)));
476
477 // event indicator update
478 connect(mAgenda,SIGNAL(lowerYChanged(int)),
479 SLOT(updateEventIndicatorTop(int)));
480 connect(mAgenda,SIGNAL(upperYChanged(int)),
481 SLOT(updateEventIndicatorBottom(int)));
482 // drag signals
483 /*
484 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
485 SLOT(startDrag(Event *)));
486 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
487 SLOT(startDrag(Event *)));
488 */
489 // synchronize selections
490 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
491 mAllDayAgenda, SLOT( deselectItem() ) );
492 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
493 mAgenda, SLOT( deselectItem() ) );
494 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
495 SIGNAL( incidenceSelected( Incidence * ) ) );
496 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
497 SIGNAL( incidenceSelected( Incidence * ) ) );
498 connect( mAgenda, SIGNAL( resizedSignal() ),
499 SLOT( updateConfig( ) ) );
500 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
501 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
502 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
503 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
504 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
505 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
506
507
508}
509
510void KOAgendaView::toggleAllDay()
511{
512 if ( mSplitterAgenda->firstHandle() )
513 mSplitterAgenda->firstHandle()->toggle();
514}
515void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
516{
517 calendar()->addIncidence( inc );
518
519 if ( incOld ) {
520 if ( incOld->type() == "Todo" )
521 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
522 else
523 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
524 }
525
526}
527
528KOAgendaView::~KOAgendaView()
529{
530 delete mAgendaPopup;
531 delete mAllDayAgendaPopup;
532 delete KOAgendaItem::paintPix();
533 delete KOAgendaItem::paintPixSel();
534}
535void KOAgendaView::resizeEvent( QResizeEvent* e )
536{
537 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
538 bool uc = false;
539 int ow = e->oldSize().width();
540 int oh = e->oldSize().height();
541 int w = e->size().width();
542 int h = e->size().height();
543 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
544 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
545 uc = true;
546 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
547 }
548 mUpcomingWidth = e->size().width() ;
549 if ( mBlockUpdating || uc ) {
550 mBlockUpdating = false;
551 //mAgenda->setMinimumSize(800 , 600 );
552 //qDebug("mAgenda->resize+++++++++++++++ ");
553 updateConfig();
554 //qDebug("KOAgendaView::Updating now possible ");
555 } else
556 createDayLabels();
557 //qDebug("resizeEvent end ");
558
559}
560void KOAgendaView::createDayLabels()
561{
562
563 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
564 // qDebug(" KOAgendaView::createDayLabels() blocked ");
565 return;
566
567 }
568 int newHight;
569
570 // ### Before deleting and recreating we could check if mSelectedDates changed...
571 // It would remove some flickering and gain speed (since this is called by
572 // each updateView() call)
573
574 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
575 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
576 if ( maxWid < 0 )
577 maxWid = 20;
578
579 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
580 QFontMetrics fm ( dlf );
581 int selCount = mSelectedDates.count();
582 QString dayTest = "Mon 20";
583 int wid = fm.width( dayTest );
584 maxWid -= ( selCount * 3 );
585 if ( maxWid < 0 )
586 maxWid = 20;
587 int needWid = wid * selCount;
588 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
589 //if ( needWid > maxWid )
590 // qDebug("DAYLABELS TOOOOOOO BIG ");
591 while ( needWid > maxWid ) {
592 dayTest = dayTest.left( dayTest.length() - 1 );
593 wid = fm.width( dayTest );
594 needWid = wid * selCount;
595 }
596 int maxLen = dayTest.length();
597 int fontPoint = dlf.pointSize();
598 if ( maxLen < 2 ) {
599 int fontPoint = dlf.pointSize();
600 while ( fontPoint > 4 ) {
601 --fontPoint;
602 dlf.setPointSize( fontPoint );
603 QFontMetrics f( dlf );
604 wid = f.width( "20" );
605 needWid = wid * selCount;
606 if ( needWid < maxWid )
607 break;
608 }
609 maxLen = 2;
610 }
611 //qDebug("Max len %d ", dayTest.length() );
612
613 QFontMetrics tempF( dlf );
614 newHight = tempF.height();
615 mDayLabels->setFont( dlf );
616 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
617 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
618 //mLayoutDayLabels->addSpacing( 2 );
619 // QFont lFont = dlf;
620 bool appendLabels = false;
621 QLabel *dayLabel;
622 dayLabel = mDayLabelsList.first();
623 if ( !dayLabel ) {
624 appendLabels = true;
625 dayLabel = new QLabel(mDayLabels);
626 mDayLabelsList.append( dayLabel );
627 mLayoutDayLabels->addWidget(dayLabel);
628 }
629 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
630 dayLabel->setFont( dlf );
631 dayLabel->setAlignment(QLabel::AlignHCenter);
632 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
633 dayLabel->show();
634 DateList::ConstIterator dit;
635 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
636 QDate date = *dit;
637 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
638 if ( ! appendLabels ) {
639 dayLabel = mDayLabelsList.next();
640 if ( !dayLabel )
641 appendLabels = true;
642 }
643 if ( appendLabels ) {
644 dayLabel = new QLabel(mDayLabels);
645 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel);
647 }
648 dayLabel->setMinimumWidth( 1 );
649 dayLabel->setMaximumWidth( 2048 );
650 dayLabel->setFont( dlf );
651 dayLabel->show();
652 QString str;
653 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
654 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
655 switch ( maxLen ) {
656 case 2:
657 str = QString::number( date.day() );
658 break;
659
660 case 3:
661 str = dayName.left( 1 ) +QString::number( date.day());
662
663 break;
664 case 4:
665 str = dayName.left( 1 ) + " " +QString::number( date.day());
666
667 break;
668 case 5:
669 str = dayName.left( 2 ) + " " +QString::number( date.day());
670
671 break;
672 case 6:
673 str = dayName.left( 3 ) + " " +QString::number( date.day());
674 break;
675
676 default:
677 break;
678 }
679
680 dayLabel->setText(str);
681 dayLabel->setAlignment(QLabel::AlignHCenter);
682 if (date == QDate::currentDate()) {
683 QFont bFont = dlf;
684 bFont.setBold( true );
685 dayLabel->setFont(bFont);
686 }
687 //dayLayout->addWidget(dayLabel);
688
689#ifndef KORG_NOPLUGINS
690 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
691 CalendarDecoration *it;
692 for(it = cds.first(); it; it = cds.next()) {
693 QString text = it->shortText( date );
694 if ( !text.isEmpty() ) {
695 QLabel *label = new QLabel(text,mDayLabels);
696 label->setAlignment(AlignCenter);
697 dayLayout->addWidget(label);
698 }
699 }
700
701 for(it = cds.first(); it; it = cds.next()) {
702 QWidget *wid = it->smallWidget(mDayLabels,date);
703 if ( wid ) {
704 // wid->setHeight(20);
705 dayLayout->addWidget(wid);
706 }
707 }
708#endif
709 }
710 if ( ! appendLabels ) {
711 dayLabel = mDayLabelsList.next();
712 if ( !dayLabel )
713 appendLabels = true;
714 }
715 if ( appendLabels ) {
716 dayLabel = new QLabel(mDayLabels);
717 mDayLabelsList.append( dayLabel );
718 mLayoutDayLabels->addWidget(dayLabel);
719 }
720 //dayLabel->hide();//test only
721
722 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
723 if ( offset < 0 ) offset = 0;
724 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
725 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) );
726 dayLabel->show();
727 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
728 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
729 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
730 if ( !appendLabels ) {
731 dayLabel = mDayLabelsList.next();
732 while ( dayLabel ) {
733 //qDebug("!dayLabel %d",dayLabel );
734 dayLabel->hide();
735 dayLabel = mDayLabelsList.next();
736 }
737 }
738 //mDayLabelsFrame->show();
739 //mDayLabels->show();
740 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
741 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
742 mDayLabelsFrame->setFixedHeight( newHight );
743}
744
745int KOAgendaView::maxDatesHint()
746{
747 // Not sure about the max number of events, so return 0 for now.
748 return 0;
749}
750
751int KOAgendaView::currentDateCount()
752{
753 return mSelectedDates.count();
754}
755
756QPtrList<Incidence> KOAgendaView::selectedIncidences()
757{
758 QPtrList<Incidence> selected;
759 Incidence *incidence;
760
761 incidence = mAgenda->selectedIncidence();
762 if (incidence) selected.append(incidence);
763
764 incidence = mAllDayAgenda->selectedIncidence();
765 if (incidence) selected.append(incidence);
766
767 return selected;
768}
769
770DateList KOAgendaView::selectedDates()
771{
772 DateList selected;
773 QDate qd;
774
775 qd = mAgenda->selectedIncidenceDate();
776 if (qd.isValid()) selected.append(qd);
777
778 qd = mAllDayAgenda->selectedIncidenceDate();
779 if (qd.isValid()) selected.append(qd);
780
781 return selected;
782}
783
784
785void KOAgendaView::updateView()
786{
787 if ( mBlockUpdating )
788 return;
789 // kdDebug() << "KOAgendaView::updateView()" << endl;
790 fillAgenda();
791
792}
793
794
795/*
796 Update configuration settings for the agenda view. This method is not
797 complete.
798*/
799void KOAgendaView::updateConfig()
800{
801 if ( mBlockUpdating )
802 return;
803 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
804
805 // update config for children
806 mTimeLabels->updateConfig();
807 mAgenda->storePosition();
808 mAgenda->updateConfig();
809 mAllDayAgenda->updateConfig();
810 // widget synchronization
811 //TODO: find a better way, maybe signal/slot
812 mTimeLabels->positionChanged();
813
814 // for some reason, this needs to be called explicitly
815 mTimeLabels->repaint();
816
817 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
818
819 // ToolTips displaying summary of events
820 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
821 ->mEnableToolTips);
822
823 //setHolidayMasks();
824
825 //createDayLabels(); called by via updateView();
826 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
827 updateView();
828 mAgenda->restorePosition();
829}
830
831
832void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
833{
834 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
835 //qDebug("KOAgendaView::updateEventDates ");
836 QDateTime startDt,endDt;
837 QDate startDate;
838 int lenInSecs;
839 // if ( type == KOAgenda::RESIZETOP )
840 // qDebug("RESIZETOP ");
841 // if ( type == KOAgenda::RESIZEBOTTOM )
842 // qDebug("RESIZEBOTTOM ");
843 // if ( type == KOAgenda::MOVE )
844 // qDebug("MOVE ");
845 if ( item->incidence()->type() == "Event" ) {
846 startDt =item->incidence()->dtStart();
847 endDt = item->incidence()->dtEnd();
848 lenInSecs = startDt.secsTo( endDt );
849 }
850
851 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
852
853 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
854 startDate = mSelectedDates[item->mLastMoveXPos];
855 } else {
856 if (item->cellX() < 0) {
857 startDate = (mSelectedDates.first()).addDays(item->cellX());
858 } else {
859 startDate = mSelectedDates[item->cellX()];
860 }
861 }
862 startDt.setDate(startDate);
863
864 if (item->incidence()->doesFloat()) {
865 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
866 } else {
867 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
868 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
869 if ( item->incidence()->type() == "Event" ) {
870 if ( type == KOAgenda::MOVE ) {
871 endDt = startDt.addSecs(lenInSecs);
872
873 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
874 if (item->lastMultiItem()) {
875 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
876 endDt.setDate(startDate.
877 addDays(item->lastMultiItem()->cellX() - item->cellX()));
878 } else {
879 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
880 endDt.setDate(startDate);
881 }
882 }
883 } else {
884 // todo
885 if (item->lastMultiItem()) {
886 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
887 endDt.setDate(startDate.
888 addDays(item->lastMultiItem()->cellX() - item->cellX()));
889 } else {
890 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
891 if ( item->cellYBottom() > 0 )
892 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
893 else
894 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
895 endDt.setDate(startDate);
896 }
897 }
898 }
899
900
901 if ( item->incidence()->type() == "Event" ) {
902 item->incidence()->setDtStart(startDt);
903 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
904 } else if ( item->incidence()->type() == "Todo" ) {
905 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
906 }
907 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
908 item->incidence()->setRevision(item->incidence()->revision()+1);
909 item->setItemDate(startDt.date());
910 //item->updateItem();
911 if ( item->incidence()->type() == "Todo" ) {
912 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
913
914 }
915 else
916 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
917 item->updateItem();
918}
919
920void KOAgendaView::showDates( const QDate &start, const QDate &end )
921{
922 // kdDebug() << "KOAgendaView::selectDates" << endl;
923
924 mSelectedDates.clear();
925 // qDebug("KOAgendaView::showDates ");
926 QDate d = start;
927 while (d <= end) {
928 mSelectedDates.append(d);
929 d = d.addDays( 1 );
930 }
931
932 // and update the view
933 fillAgenda();
934}
935
936
937void KOAgendaView::showEvents(QPtrList<Event>)
938{
939 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
940}
941
942void KOAgendaView::changeEventDisplay(Event *, int)
943{
944 // qDebug("KOAgendaView::changeEventDisplay ");
945 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
946 // this should be re-written to be MUCH smarter. Right now we
947 // are just playing dumb.
948 fillAgenda();
949}
950
951void KOAgendaView::fillAgenda(const QDate &)
952{
953 // qDebug("KOAgendaView::fillAgenda ");
954 fillAgenda();
955}
956
957void KOAgendaView::fillAgenda()
958{
959 if ( globalFlagBlockStartup )
960 return;
961 if ( globalFlagBlockAgenda == 1 )
962 return;
963 //if ( globalFlagBlockAgenda == 2 )
964 //globalFlagBlockAgenda = 0;
965 // globalFlagBlockPainting = false;
966 if ( globalFlagBlockAgenda == 0 )
967 globalFlagBlockAgenda = 1;
968 // clearView();
969 //qDebug("fillAgenda()++++ ");
970 globalFlagBlockAgendaItemPaint = 1;
971 mAllDayAgenda->changeColumns(mSelectedDates.count());
972 mAgenda->changeColumns(mSelectedDates.count());
973 qApp->processEvents();
974 mEventIndicatorTop->changeColumns(mSelectedDates.count());
975 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
976 setHolidayMasks();
977
978 //mAgenda->hideUnused();
979 //mAllDayAgenda->hideUnused();
980
981 // mAgenda->blockNextRepaint( false );
982 // mAgenda->viewport()->repaint();
983 // mAgenda->blockNextRepaint( true );
984 mMinY.resize(mSelectedDates.count());
985 mMaxY.resize(mSelectedDates.count());
986
987 QPtrList<Event> dayEvents;
988
989 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
990 // Therefore, get all of them.
991 QPtrList<Todo> todos = calendar()->todos();
992
993 mAgenda->setDateList(mSelectedDates);
994
995 QDate today = QDate::currentDate();
996
997 DateList::ConstIterator dit;
998 int curCol = 0;
999 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1000 QDate currentDate = *dit;
1001 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1002 // << endl;
1003
1004 dayEvents = calendar()->events(currentDate,true);
1005
1006 // Default values, which can never be reached
1007 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1008 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1009
1010 unsigned int numEvent;
1011 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1012 Event *event = dayEvents.at(numEvent);
1013 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(21) == QString("last-syncEvent-device") )
1014 continue;
1015 // kdDebug() << " Event: " << event->summary() << endl;
1016
1017 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1018 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1019
1020 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1021
1022 if (event->doesFloat()) {
1023 if (event->recurrence()->doesRecur()) {
1024 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1025 } else {
1026 if (beginX <= 0 && curCol == 0) {
1027 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1028 } else if (beginX == curCol) {
1029 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1030 }
1031 }
1032 } else if (event->isMultiDay()) {
1033 if ( event->doesRecur () ) {
1034 QDate dateit = currentDate;
1035 int count = 0;
1036 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1037 while (! event->recursOn( dateit ) && count <= max ) {
1038 ++count;
1039 dateit = dateit.addDays( -1 );
1040 }
1041 bool ok;
1042 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1043 if ( ok )
1044 {
1045 int secs = event->dtStart().secsTo( event->dtEnd() );
1046 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1047 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1048 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1049
1050 }
1051 }
1052 int startY = mAgenda->timeToY(event->dtStart().time());
1053 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1054 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1055 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1056 //qDebug("insert!!! ");
1057 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1058 }
1059 if (beginX == curCol) {
1060 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1061 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1062 } else if (endX == curCol) {
1063 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1064 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1065 } else {
1066 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1068 }
1069 } else {
1070 int startY = mAgenda->timeToY(event->dtStart().time());
1071 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1072 if (endY < startY) endY = startY;
1073 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1074 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1075 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1076 }
1077 }
1078 // ---------- [display Todos --------------
1079 unsigned int numTodo;
1080 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1081 Todo *todo = todos.at(numTodo);
1082
1083 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1084
1085 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1086 // Already completed items can be displayed on their original due date
1087 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1088 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1089
1090 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1091 ((currentDate == today) && overdue) ) {
1092 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1093 if ( KOPrefs::instance()->mShowTodoInAgenda )
1094 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1095 }
1096 else {
1097
1098 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1099 int hi = (18/KOPrefs::instance()->mHourSize);
1100 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1101 int startY = endY -hi;
1102
1103 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1104
1105 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1106 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1107 }
1108 }
1109 }
1110 // ---------- display Todos] --------------
1111
1112 ++curCol;
1113 }
1114 mAgenda->hideUnused();
1115 mAllDayAgenda->hideUnused();
1116 mAgenda->checkScrollBoundaries();
1117
1118 deleteSelectedDateTime();
1119
1120 createDayLabels();
1121 emit incidenceSelected( 0 );
1122
1123 if ( globalFlagBlockAgenda == 2 ) {
1124 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1125 setStartHour( KOPrefs::instance()->mDayBegins );
1126 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1127 setStartHour( QTime::currentTime ().hour() );
1128 // qApp->processEvents();
1129 }
1130 qApp->processEvents();
1131 //qDebug("qApp->processEvents(); END ");
1132 globalFlagBlockAgenda = 0;
1133
1134 // mAgenda->hideUnused();
1135 //mAllDayAgenda->hideUnused();
1136 mAllDayAgenda->drawContentsToPainter();
1137 mAgenda->drawContentsToPainter();
1138 repaintAgenda();
1139 // mAgenda->finishUpdate();
1140 //mAllDayAgenda->finishUpdate();
1141
1142 // repaintAgenda();
1143 //qApp->processEvents();
1144 // globalFlagBlockAgenda = 0;
1145}
1146void KOAgendaView::repaintAgenda()
1147{
1148 // mAllDayAgenda->drawContentsToPainter();
1149// mAllDayAgenda->viewport()->repaint( false );
1150// mAgenda->drawContentsToPainter();
1151// mAgenda->viewport()->repaint( false );
1152// qApp->processEvents();
1153
1154 //qDebug("KOAgendaView::repaintAgenda() ");
1155 //qApp->processEvents();
1156 mAgenda->viewport()->repaint( false );
1157 mAllDayAgenda->viewport()->repaint( false );
1158 mAgenda->finishUpdate();
1159 mAllDayAgenda->finishUpdate();
1160}
1161
1162
1163void KOAgendaView::clearView()
1164{
1165 // kdDebug() << "ClearView" << endl;
1166 mAllDayAgenda->clear();
1167 mAgenda->clear();
1168}
1169
1170void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1171 const QDate &td)
1172{
1173#ifndef KORG_NOPRINTER
1174 if (fd == td)
1175 calPrinter->preview(CalPrinter::Day, fd, td);
1176 else
1177 calPrinter->preview(CalPrinter::Week, fd, td);
1178#endif
1179}
1180
1181// void KOAgendaView::updateMovedTodo()
1182// {
1183// // updateConfig();
1184// // emit updateTodoViews();
1185// }
1186
1187void KOAgendaView::newEvent(int gx, int gy)
1188{
1189 if (!mSelectedDates.count()) return;
1190
1191 QDate day = mSelectedDates[gx];
1192
1193 QTime time = mAgenda->gyToTime(gy);
1194 QDateTime dt(day,time);
1195 // if ( dt < QDateTime::currentDateTime () )
1196 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1197 emit newEventSignal(dt);
1198}
1199
1200void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1201{
1202 if (!mSelectedDates.count()) return;
1203
1204 QDate dayStart = mSelectedDates[gxStart];
1205 QDate dayEnd = mSelectedDates[gxEnd];
1206
1207 QTime timeStart = mAgenda->gyToTime(gyStart);
1208 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1209
1210 QDateTime dtStart(dayStart,timeStart);
1211 QDateTime dtEnd(dayEnd,timeEnd);
1212
1213 emit newEventSignal(dtStart,dtEnd);
1214}
1215
1216void KOAgendaView::newEventAllDay(int gx, int )
1217{
1218 if (!mSelectedDates.count()) return;
1219
1220 QDate day = mSelectedDates[gx];
1221
1222 emit newEventSignal(day);
1223}
1224
1225void KOAgendaView::updateEventIndicatorTop(int newY)
1226{
1227 uint i;
1228 for(i=0;i<mMinY.size();++i) {
1229 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1230 else mEventIndicatorTop->enableColumn(i,false);
1231 }
1232
1233 mEventIndicatorTop->update();
1234}
1235
1236void KOAgendaView::updateEventIndicatorBottom(int newY)
1237{
1238 uint i;
1239 for(i=0;i<mMaxY.size();++i) {
1240 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1241 else mEventIndicatorBottom->enableColumn(i,false);
1242 }
1243
1244 mEventIndicatorBottom->update();
1245}
1246
1247void KOAgendaView::startDrag(Event *event)
1248{
1249#ifndef KORG_NODND
1250 DndFactory factory( calendar() );
1251 ICalDrag *vd = factory.createDrag(event,this);
1252 if (vd->drag()) {
1253 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1254 }
1255#endif
1256}
1257
1258void KOAgendaView::readSettings()
1259{
1260 readSettings(KOGlobals::config());
1261}
1262
1263void KOAgendaView::readSettings(KConfig *config)
1264{
1265 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1266
1267 config->setGroup("Views");
1268
1269 //#ifndef KORG_NOSPLITTER
1270 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1271 if (sizes.count() == 2) {
1272 if ( sizes[0] < 20 ) {
1273 sizes[1] = sizes[1] +20 - sizes[0];
1274 sizes[0] = 20;
1275 }
1276 mSplitterAgenda->setSizes(sizes);
1277 // qDebug("read %d %d ",sizes[0],sizes[1] );
1278 }
1279 //#endif
1280
1281 // updateConfig();
1282}
1283
1284void KOAgendaView::writeSettings(KConfig *config)
1285{
1286 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1287
1288 config->setGroup("Views");
1289
1290 //#ifndef KORG_NOSPLITTER
1291 QValueList<int> list = mSplitterAgenda->sizes();
1292 config->writeEntry("Separator AgendaView",list);
1293 //qDebug("write %d %d ", list[0],list[1] );
1294 //#endif
1295}
1296
1297void KOAgendaView::setHolidayMasks()
1298{
1299 mHolidayMask.resize(mSelectedDates.count());
1300
1301 uint i;
1302 for(i=0;i<mSelectedDates.count();++i) {
1303 QDate date = mSelectedDates[i];
1304 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1305 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1306#ifndef KORG_NOPLUGINS
1307 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1308 !KOCore::self()->holiday(date).isEmpty();
1309 bool showDay = showSaturday || showSunday || showHoliday;
1310#else
1311 bool showDay = showSaturday || showSunday;
1312#endif
1313 if (showDay) {
1314 mHolidayMask.at(i) = true;
1315 } else {
1316 mHolidayMask.at(i) = false;
1317 }
1318 }
1319
1320 mAgenda->setHolidayMask(&mHolidayMask);
1321 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1322}
1323
1324void KOAgendaView::setContentsPos(int y)
1325{
1326 mAgenda->setContentsPos(0,y);
1327}
1328
1329void KOAgendaView::setExpandedButton( bool expanded )
1330{
1331 if ( expanded ) {
1332 mExpandButton->setPixmap( mExpandedPixmap );
1333 } else {
1334 mExpandButton->setPixmap( mNotExpandedPixmap );
1335 }
1336}
1337
1338void KOAgendaView::clearSelection()
1339{
1340 mAgenda->deselectItem();
1341 mAllDayAgenda->deselectItem();
1342}
1343
1344void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1345 int gxEnd, int gyEnd)
1346{
1347 mTimeSpanInAllDay = true;
1348 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1349}
1350
1351
1352
1353
1354void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1355 int gxEnd, int gyEnd)
1356{
1357 if (!mSelectedDates.count()) return;
1358
1359 QDate dayStart = mSelectedDates[gxStart];
1360 QDate dayEnd = mSelectedDates[gxEnd];
1361
1362 QTime timeStart = mAgenda->gyToTime(gyStart);
1363 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1364
1365 QDateTime dtStart(dayStart,timeStart);
1366 QDateTime dtEnd(dayEnd,timeEnd);
1367
1368 mTimeSpanBegin = dtStart;
1369 mTimeSpanEnd = dtEnd;
1370
1371}
1372
1373void KOAgendaView::deleteSelectedDateTime()
1374{
1375 mTimeSpanBegin.setDate(QDate());
1376 mTimeSpanEnd.setDate(QDate());
1377 mTimeSpanInAllDay = false;
1378}
1379
1380void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1381{
1382 e->ignore();
1383}
1384
1385void KOAgendaView::scrollOneHourUp()
1386{
1387
1388 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1389}
1390void KOAgendaView::scrollOneHourDown()
1391{
1392 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1393}
1394
1395void KOAgendaView::setStartHour( int h )
1396{
1397 mAgenda->setStartHour( h );
1398
1399}
1400
1401void KOAgendaView::updateTodo( Todo * t, int )
1402{
1403
1404 bool remove = false;
1405 bool removeAD = false;
1406 if ( ! t->hasDueDate() ) {
1407 remove = true;
1408 removeAD = true;
1409 }
1410 else {
1411 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1412 if ( overdue &&
1413 QDate::currentDate() >= mSelectedDates.first() &&
1414 QDate::currentDate() <= mSelectedDates.last()) {
1415 removeAD = false;
1416 remove = true;
1417 }
1418 else {
1419 if ( t->dtDue().date() < mSelectedDates.first() ||
1420 t->dtDue().date() > mSelectedDates.last() ) {
1421 remove = true;
1422 removeAD = true;
1423 } else {
1424 remove = t->doesFloat();
1425 removeAD = !remove;
1426 }
1427 }
1428 }
1429 int days = mSelectedDates.first().daysTo( t->dtDue().date() );
1430 // qDebug("daysto %d ", days );
1431 mAgenda->updateTodo( t , days, remove);
1432 if ( KOPrefs::instance()->mShowTodoInAgenda )
1433 mAllDayAgenda->updateTodo( t , days, removeAD);
1434 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1435
1436}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
new file mode 100644
index 0000000..0079253
--- a/dev/null
+++ b/korganizer/koagendaview.h
@@ -0,0 +1,252 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H
25
26#include <qscrollview.h>
27#include <qdatetime.h>
28#include <qlayout.h>
29#ifndef DESKTOP_VERSION
30#include <qksplitter.h>
31#else
32#include <qsplitter.h>
33#endif
34#include <qmemarray.h>
35
36#include "koeventview.h"
37
38
39class QHBox;
40class QFrame;
41class QLabel;
42class QPushButton;
43class CalendarView;
44class KOAgenda;
45class KOAgendaItem;
46class KConfig;
47class KDGanttMinimizeSplitter;
48class TimeLabels : public QScrollView {
49 Q_OBJECT
50 public:
51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
52
53 void setCellHeight(int height);
54
55 /** Calculates the minimum width */
56 virtual int minimumWidth() const;
57
58 /** updates widget's internal state */
59 void updateConfig();
60
61 /** */
62 void setAgenda(KOAgenda* agenda);
63
64 /** */
65 virtual void paintEvent(QPaintEvent* e);
66
67 public slots:
68 /** update time label positions */
69 void positionChanged();
70
71 protected:
72 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
73
74 private:
75 int mRows;
76 int mCellHeight;
77
78 /** */
79 KOAgenda* mAgenda;
80};
81
82class EventIndicator : public QFrame {
83 Q_OBJECT
84 public:
85 enum Location { Top, Bottom };
86 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
87 virtual ~EventIndicator();
88
89 void changeColumns(int columns);
90 void setPaintWidget( KDGanttMinimizeSplitter* );
91 void setXOffset( int );
92 void enableColumn(int column, bool enable);
93
94 protected:
95 void drawContents(QPainter *);
96
97 private:
98 int mXOffset;
99 KDGanttMinimizeSplitter* mPaintWidget;
100 int mColumns;
101 QHBox *mTopBox;
102 QBoxLayout *mTopLayout;
103 Location mLocation;
104 QPixmap mPixmap;
105 QMemArray<bool> mEnabled;
106};
107
108/**
109 KOAgendaView is the agenda-like view used to display events in an one or
110 multi-day view.
111*/
112class KOAgendaView : public KOEventView {
113 Q_OBJECT
114 public:
115 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
116 virtual ~KOAgendaView();
117 void setStartHour( int );
118 void toggleAllDay();
119
120
121 /** Returns maximum number of days supported by the koagendaview */
122 virtual int maxDatesHint();
123
124 /** Returns number of currently shown dates. */
125 virtual int currentDateCount();
126
127 /** returns the currently selected events */
128 virtual QPtrList<Incidence> selectedIncidences();
129
130 /** returns the currently selected events */
131 virtual DateList selectedDates();
132
133 /** Remove all events from view */
134 void clearView();
135 KOAgenda *agenda() { return mAgenda;}
136 virtual void printPreview(CalPrinter *calPrinter,
137 const QDate &, const QDate &);
138
139 /** start-datetime of selection */
140 QDateTime selectionStart() {return mTimeSpanBegin;}
141 /** end-datetime of selection */
142 QDateTime selectionEnd() {return mTimeSpanEnd;}
143 /** returns true if selection is for whole day */
144 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
145 /** make selected start/end invalid */
146 void deleteSelectedDateTime();
147 void repaintAgenda();
148 public slots:
149 virtual void updateView();
150 virtual void updateConfig();
151 virtual void showDates(const QDate &start, const QDate &end);
152 virtual void showEvents(QPtrList<Event> eventList);
153
154 void updateTodo( Todo *, int );
155 void changeEventDisplay(Event *, int);
156
157 void clearSelection();
158
159 void newEvent(int gx,int gy);
160 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
161 void newEventAllDay(int gx, int gy);
162
163 void startDrag(Event *);
164
165 void readSettings();
166 void readSettings(KConfig *);
167 void writeSettings(KConfig *);
168
169 void setContentsPos(int y);
170
171 void setExpandedButton( bool expanded );
172 void scrollOneHourUp();
173 void scrollOneHourDown();
174 void addToCalSlot(Incidence *, Incidence *);
175
176 signals:
177 void toggleExpand();
178 void todoMoved( Todo *, int );
179 void incidenceChanged(Incidence * , int );
180 // void cloneIncidenceSignal(Incidence *);
181
182 protected:
183 bool mBlockUpdating;
184 int mUpcomingWidth;
185 /** Fill agenda beginning with date startDate */
186 void fillAgenda(const QDate &startDate);
187 void resizeEvent( QResizeEvent* e );
188 /** Fill agenda using the current set value for the start date */
189 void fillAgenda();
190
191 /** Create labels for the selected dates. */
192 void createDayLabels();
193
194 /**
195 Set the masks on the agenda widgets indicating, which days are holidays.
196 */
197 void setHolidayMasks();
198
199 protected slots:
200 /** Update event belonging to agenda item */
201 void updateEventDates(KOAgendaItem *item, int mode = -1);
202 //void updateMovedTodo();
203
204 void updateEventIndicatorTop(int newY);
205 void updateEventIndicatorBottom(int newY);
206
207 /** Updates data for selected timespan */
208 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
209 /** Updates data for selected timespan for all day event*/
210 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
211
212 private:
213 // view widgets
214 QFrame *mDayLabels;
215 QHBox *mDayLabelsFrame;
216 QBoxLayout *mLayoutDayLabels;
217 QFrame *mAllDayFrame;
218 KOAgenda *mAllDayAgenda;
219 KOAgenda *mAgenda;
220 TimeLabels *mTimeLabels;
221 QWidget *mDummyAllDayLeft;
222
223 KDGanttMinimizeSplitter* mSplitterAgenda;
224 QPushButton *mExpandButton;
225
226 DateList mSelectedDates; // List of dates to be displayed
227 int mViewType;
228
229 bool mWeekStartsMonday;
230 int mStartHour;
231
232 KOEventPopupMenu *mAgendaPopup;
233 KOEventPopupMenu *mAllDayAgendaPopup;
234
235 EventIndicator *mEventIndicatorTop;
236 EventIndicator *mEventIndicatorBottom;
237
238 QMemArray<int> mMinY;
239 QMemArray<int> mMaxY;
240
241 QMemArray<bool> mHolidayMask;
242
243 QPixmap mExpandedPixmap;
244 QPixmap mNotExpandedPixmap;
245 QPtrList<QLabel> mDayLabelsList;
246 QDateTime mTimeSpanBegin;
247 QDateTime mTimeSpanEnd;
248 bool mTimeSpanInAllDay;
249 void keyPressEvent ( QKeyEvent * e );
250};
251
252#endif // KOAGENDAVIEW_H
diff --git a/korganizer/koagendaview.moc b/korganizer/koagendaview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koagendaview.moc
diff --git a/korganizer/kocounterdialog.cpp b/korganizer/kocounterdialog.cpp
new file mode 100644
index 0000000..8a9ae44
--- a/dev/null
+++ b/korganizer/kocounterdialog.cpp
@@ -0,0 +1,66 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20
21#include <klocale.h>
22
23#include <libkcal/event.h>
24#include "koeventviewer.h"
25
26#include "kocounterdialog.h"
27#include "kocounterdialog.moc"
28
29KOCounterDialog::KOCounterDialog(QWidget *parent,const char *name)
30 : KDialogBase(parent,name,false,i18n("Counter-event Viewer"),User1|User2,User1,
31 false,i18n("Decline"),i18n("Accept"))
32{
33 mEventViewer = new KOEventViewer(this);
34 setMainWidget(mEventViewer);
35
36 connect(this,SIGNAL(user1Clicked()),this,SLOT(slotCancel()));
37 connect(this,SIGNAL(user2Clicked()),this,SLOT(slotOk()));
38
39 // TODO: Set a sensible size (based on the content?).
40 setMinimumSize(300,200);
41 resize(320,300);
42}
43
44KOCounterDialog::~KOCounterDialog()
45{
46}
47
48void KOCounterDialog::setEvent(Event *event)
49{
50 mEventViewer->setEvent(event);
51}
52
53void KOCounterDialog::addEvent(Event *event)
54{
55 mEventViewer->addEvent(event);
56}
57
58void KOCounterDialog::setTodo(Todo *event)
59{
60 mEventViewer->setTodo(event);
61}
62
63void KOCounterDialog::addText(QString text)
64{
65 mEventViewer->addText(text);
66}
diff --git a/korganizer/kocounterdialog.h b/korganizer/kocounterdialog.h
new file mode 100644
index 0000000..c8dcf45
--- a/dev/null
+++ b/korganizer/kocounterdialog.h
@@ -0,0 +1,50 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef KOCOUNTERDIALOG_H
20#define KOCOUNTERDIALOG_H
21//
22// Viewer dialog for counter events.
23//
24
25#include <qtextview.h>
26
27#include <kdialogbase.h>
28
29#include <libkcal/event.h>
30
31using namespace KCal;
32
33class KOEventViewer;
34
35class KOCounterDialog : public KDialogBase {
36 Q_OBJECT
37 public:
38 KOCounterDialog(QWidget *parent=0,const char *name=0);
39 virtual ~KOCounterDialog();
40
41 void setEvent(Event *event);
42 void addEvent(Event *event);
43 void setTodo(Todo *event);
44 void addText(QString text);
45
46 private:
47 KOEventViewer *mEventViewer;
48};
49
50#endif
diff --git a/korganizer/kocounterdialog.moc b/korganizer/kocounterdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kocounterdialog.moc
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
new file mode 100644
index 0000000..779d67c
--- a/dev/null
+++ b/korganizer/kodaymatrix.cpp
@@ -0,0 +1,597 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24
25#include <qevent.h>
26#include <qpainter.h>
27#include <qptrlist.h>
28
29#include <kglobal.h>
30#include <kdebug.h>
31#include <klocale.h>
32
33#include <libkcal/vcaldrag.h>
34#include <libkcal/icaldrag.h>
35#include <libkcal/dndfactory.h>
36#include <libkcal/calendarresources.h>
37#include <libkcal/resourcecalendar.h>
38#include <kresources/resourceselectdialog.h>
39
40#include <kcalendarsystem.h>
41
42#ifndef KORG_NOPLUGINS
43#include "kocore.h"
44#endif
45#include "koprefs.h"
46#include "koglobals.h"
47
48#include "kodaymatrix.h"
49#include "kodaymatrix.moc"
50
51// ============================================================================
52// D Y N A M I C T I P
53// ============================================================================
54
55DynamicTip::DynamicTip( QWidget * parent )
56 : QToolTip( parent )
57{
58 matrix = (KODayMatrix*)parent;
59}
60
61
62void DynamicTip::maybeTip( const QPoint &pos )
63{
64 //calculate which cell of the matrix the mouse is in
65 QRect sz = matrix->frameRect();
66 int dheight = sz.height()*7 / 42;
67 int dwidth = sz.width() / 7;
68 int row = pos.y()/dheight;
69 int col = pos.x()/dwidth;
70
71 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
72
73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
74// col << "][" << row << "] => " <<(col+row*7) << endl;
75
76 //show holiday names only
77 QString str = matrix->getHolidayLabel(col+row*7);
78 if (str.isEmpty()) return;
79 tip(rct, str);
80}
81
82
83// ============================================================================
84// K O D A Y M A T R I X
85// ============================================================================
86
87const int KODayMatrix::NOSELECTION = -1000;
88const int KODayMatrix::NUMDAYS = 42;
89
90KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
91 QFrame(parent, name)
92{
93 mCalendar = calendar;
94
95 // initialize dynamic arrays
96 days = new QDate[NUMDAYS];
97 daylbls = new QString[NUMDAYS];
98 events = new int[NUMDAYS];
99 mToolTip = new DynamicTip(this);
100
101 // set default values used for drawing the matrix
102 mDefaultBackColor = palette().active().base();
103 mDefaultTextColor = palette().active().foreground();
104 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
105 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
106 mSelectedDaysColor = QColor("white");
107 mTodayMarginWidth = 2;
108 mSelEnd = mSelStart = NOSELECTION;
109
110 setAcceptDrops(true);
111 //setFont( QFont("Arial", 10) );
112 updateView(date);
113}
114
115QColor KODayMatrix::getShadedColor(QColor color)
116{
117 QColor shaded;
118 int h=0;
119 int s=0;
120 int v=0;
121 color.hsv(&h,&s,&v);
122 s = s/4;
123 v = 192+v/4;
124 shaded.setHsv(h,s,v);
125
126 return shaded;
127}
128
129KODayMatrix::~KODayMatrix()
130{
131 delete [] days;
132 delete [] daylbls;
133 delete [] events;
134 delete mToolTip;
135}
136
137/*
138void KODayMatrix::setStartDate(QDate start)
139{
140 updateView(start);
141}
142*/
143
144void KODayMatrix::addSelectedDaysTo(DateList& selDays)
145{
146 kdDebug() << "KODayMatrix::addSelectedDaysTo() - " << "mSelStart:" << mSelStart << endl;
147
148 if (mSelStart == NOSELECTION) {
149 return;
150 }
151
152 //cope with selection being out of matrix limits at top (< 0)
153 int i0 = mSelStart;
154 if (i0 < 0) {
155 for (int i = i0; i < 0; i++) {
156 selDays.append(days[0].addDays(i));
157 }
158 i0 = 0;
159 }
160
161 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
162 if (mSelEnd > NUMDAYS-1) {
163 for (int i = i0; i <= NUMDAYS-1; i++) {
164 selDays.append(days[i]);
165 }
166 for (int i = NUMDAYS; i < mSelEnd; i++) {
167 selDays.append(days[0].addDays(i));
168 }
169
170 // apply normal routine to selection being entirely within matrix limits
171 } else {
172 for (int i = i0; i <= mSelEnd; i++) {
173 selDays.append(days[i]);
174 }
175 }
176}
177
178void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
179{
180 mSelStart = startdate.daysTo(start);
181 mSelEnd = startdate.daysTo(end);
182}
183
184
185void KODayMatrix::recalculateToday()
186{
187 today = -1;
188 for (int i=0; i<NUMDAYS; i++) {
189 days[i] = startdate.addDays(i);
190 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
191
192 // if today is in the currently displayed month, hilight today
193 if (days[i].year() == QDate::currentDate().year() &&
194 days[i].month() == QDate::currentDate().month() &&
195 days[i].day() == QDate::currentDate().day()) {
196 today = i;
197 }
198 }
199 // qDebug(QString("Today is visible at %1.").arg(today));
200}
201
202void KODayMatrix::updateView()
203{
204 updateView(startdate);
205}
206
207void KODayMatrix::updateView(QDate actdate)
208{
209
210// kdDebug() << "KODayMatrix::updateView() " << actdate.toString() << endl;
211
212 //flag to indicate if the starting day of the matrix has changed by this call
213 bool daychanged = false;
214 // if a new startdate is to be set then apply Cornelius's calculation
215 // of the first day to be shown
216 if (actdate != startdate) {
217 // reset index of selection according to shift of starting date from startdate to actdate
218 if (mSelStart != NOSELECTION) {
219 int tmp = actdate.daysTo(startdate);
220 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
221 // shift selection if new one would be visible at least partly !
222
223 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
224 // nested if is required for next X display pushed from a different month - correction required
225 // otherwise, for month forward and backward, it must be avoided
226 if( mSelStart > NUMDAYS || mSelStart < 0 )
227 mSelStart = mSelStart + tmp;
228 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
229 mSelEnd = mSelEnd + tmp;
230 }
231 }
232
233 startdate = actdate;
234 daychanged = true;
235 }
236
237 if (daychanged) {
238 recalculateToday();
239 }
240
241 for(int i = 0; i < NUMDAYS; i++) {
242
243 // if events are set for the day then remember to draw it bold
244 QPtrList<Event> eventlist = mCalendar->events(days[i]);
245 Event *event;
246 int numEvents = eventlist.count();
247
248 for(event=eventlist.first();event != 0;event=eventlist.next()) {
249 ushort recurType = event->recurrence()->doesRecur();
250
251 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
252 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
253 numEvents--;
254 }
255 }
256 events[i] = numEvents;
257
258 //if it is a holy day then draw it red. Sundays are consider holidays, too
259#ifndef KORG_NOPLUGINS
260 QString holiStr = KOCore::self()->holiday(days[i]);
261#else
262 QString holiStr = QString::null;
263#endif
264 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
265 !holiStr.isEmpty()) {
266 if (holiStr.isNull()) holiStr = "";
267 mHolidays[i] = holiStr;
268
269 } else {
270 mHolidays[i] = QString::null;
271 }
272 }
273}
274
275const QDate& KODayMatrix::getDate(int offset)
276{
277 if (offset < 0 || offset > NUMDAYS-1) {
278 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getDate(int)" << endl;
279 return days[0];
280 }
281 return days[offset];
282}
283
284QString KODayMatrix::getHolidayLabel(int offset)
285{
286 if (offset < 0 || offset > NUMDAYS-1) {
287 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getHolidayLabel(int)" << endl;
288 return 0;
289 }
290 return mHolidays[offset];
291}
292
293int KODayMatrix::getDayIndexFrom(int x, int y)
294{
295 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
296 6 - x/daysize.width() : x/daysize.width());
297}
298
299// ----------------------------------------------------------------------------
300// M O U S E E V E N T H A N D L I N G
301// ----------------------------------------------------------------------------
302
303void KODayMatrix::mousePressEvent (QMouseEvent* e)
304{
305 mSelStart = getDayIndexFrom(e->x(), e->y());
306 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
307 mSelInit = mSelStart;
308}
309
310void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
311{
312
313 int tmp = getDayIndexFrom(e->x(), e->y());
314 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
315
316 if (mSelInit > tmp) {
317 mSelEnd = mSelInit;
318 if (tmp != mSelStart) {
319 mSelStart = tmp;
320 repaint();
321 }
322 } else {
323 mSelStart = mSelInit;
324
325 //repaint only if selection has changed
326 if (tmp != mSelEnd) {
327 mSelEnd = tmp;
328 repaint();
329 }
330 }
331
332 DateList daylist;
333 if ( mSelStart < 0 )
334 mSelStart = 0;
335 for (int i = mSelStart; i <= mSelEnd; i++) {
336 daylist.append(days[i]);
337 }
338 emit selected((const DateList)daylist);
339
340}
341
342void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
343{
344 int tmp = getDayIndexFrom(e->x(), e->y());
345 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
346
347 if (mSelInit > tmp) {
348 mSelEnd = mSelInit;
349 if (tmp != mSelStart) {
350 mSelStart = tmp;
351 repaint();
352 }
353 } else {
354 mSelStart = mSelInit;
355
356 //repaint only if selection has changed
357 if (tmp != mSelEnd) {
358 mSelEnd = tmp;
359 repaint();
360 }
361 }
362}
363
364// ----------------------------------------------------------------------------
365// D R A G ' N D R O P H A N D L I N G
366// ----------------------------------------------------------------------------
367
368void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
369{
370#ifndef KORG_NODND
371 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
372 e->ignore();
373 return;
374 }
375
376 // some visual feedback
377// oldPalette = palette();
378// setPalette(my_HilitePalette);
379// update();
380#endif
381}
382
383void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
384{
385#ifndef KORG_NODND
386 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
387 e->ignore();
388 return;
389 }
390
391 e->accept();
392#endif
393}
394
395void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
396{
397#ifndef KORG_NODND
398// setPalette(oldPalette);
399// update();
400#endif
401}
402
403void KODayMatrix::dropEvent(QDropEvent *e)
404{
405#ifndef KORG_NODND
406// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
407
408 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
409 e->ignore();
410 return;
411 }
412
413 DndFactory factory( mCalendar );
414 Event *event = factory.createDrop(e);
415
416 if (event) {
417 e->acceptAction();
418
419 Event *existingEvent = mCalendar->event(event->uid());
420
421 if(existingEvent) {
422 // uniquify event
423 event->recreate();
424/*
425 KMessageBox::sorry(this,
426 i18n("Event already exists in this calendar."),
427 i18n("Drop Event"));
428 delete event;
429 return;
430*/
431 }
432// kdDebug() << "Drop new Event" << endl;
433 // Adjust date
434 QDateTime start = event->dtStart();
435 QDateTime end = event->dtEnd();
436 int duration = start.daysTo(end);
437 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
438
439 start.setDate(days[idx]);
440 end.setDate(days[idx].addDays(duration));
441
442 event->setDtStart(start);
443 event->setDtEnd(end);
444 mCalendar->addEvent(event);
445
446 emit eventDropped(event);
447 } else {
448// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
449 e->ignore();
450 }
451#endif
452}
453
454// ----------------------------------------------------------------------------
455// P A I N T E V E N T H A N D L I N G
456// ----------------------------------------------------------------------------
457
458void KODayMatrix::paintEvent(QPaintEvent * pevent)
459{
460//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl;
461
462 QPainter p(this);
463
464 QRect sz = frameRect();
465 int dheight = daysize.height();
466 int dwidth = daysize.width();
467 int row,col;
468 int selw, selh;
469 bool isRTL = KOGlobals::self()->reverseLayout();
470
471 // draw background and topleft frame
472 p.fillRect(pevent->rect(), mDefaultBackColor);
473 p.setPen(mDefaultTextColor);
474 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
475
476 // draw selected days with highlighted background color
477 if (mSelStart != NOSELECTION) {
478
479 row = mSelStart/7;
480 col = mSelStart -row*7;
481 QColor selcol = KOPrefs::instance()->mHighlightColor;
482
483 if (row == mSelEnd/7) {
484 // Single row selection
485 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth,
486 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol);
487 } else {
488 // draw first row to the right
489 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
490 dheight, selcol);
491 // draw full block till last line
492 selh = mSelEnd/7-row;
493 if (selh > 1) {
494 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
495 }
496 // draw last block from left to mSelEnd
497 selw = mSelEnd-7*(mSelEnd/7)+1;
498 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
499 selw*dwidth, dheight, selcol);
500 }
501 }
502
503 // iterate over all days in the matrix and draw the day label in appropriate colors
504 QColor actcol = mDefaultTextColorShaded;
505 p.setPen(actcol);
506 QPen tmppen;
507 for(int i = 0; i < NUMDAYS; i++) {
508 row = i/7;
509 col = isRTL ? 6-(i-row*7) : i-row*7;
510
511 // if it is the first day of a month switch color from normal to shaded and vice versa
512 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
513 if (actcol == mDefaultTextColorShaded) {
514 actcol = mDefaultTextColor;
515 } else {
516 actcol = mDefaultTextColorShaded;
517 }
518 p.setPen(actcol);
519 }
520
521 //Reset pen color after selected days block
522 if (i == mSelEnd+1) {
523 p.setPen(actcol);
524 }
525
526 // if today then draw rectangle around day
527 if (today == i) {
528 tmppen = p.pen();
529 QPen mTodayPen(p.pen());
530
531 mTodayPen.setWidth(mTodayMarginWidth);
532 //draw red rectangle for holidays
533 if (!mHolidays[i].isNull()) {
534 if (actcol == mDefaultTextColor) {
535 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
536 } else {
537 mTodayPen.setColor(mHolidayColorShaded);
538 }
539 }
540 //draw gray rectangle for today if in selection
541 if (i >= mSelStart && i <= mSelEnd) {
542 QColor grey("grey");
543 mTodayPen.setColor(grey);
544 }
545 p.setPen(mTodayPen);
546 p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
547 p.setPen(tmppen);
548 }
549
550 // if any events are on that day then draw it using a bold font
551 if (events[i] > 0) {
552 QFont myFont = font();
553 myFont.setBold(true);
554 p.setFont(myFont);
555 }
556
557 // if it is a holiday then use the default holiday color
558 if (!mHolidays[i].isNull()) {
559 if (actcol == mDefaultTextColor) {
560 p.setPen(KOPrefs::instance()->mHolidayColor);
561 } else {
562 p.setPen(mHolidayColorShaded);
563 }
564 }
565
566 // draw selected days with special color
567 // DO NOT specially highlight holidays in selection !
568 if (i >= mSelStart && i <= mSelEnd) {
569 p.setPen(mSelectedDaysColor);
570 }
571
572 p.drawText(col*dwidth, row*dheight, dwidth, dheight,
573 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
574
575 // reset color to actual color
576 if (!mHolidays[i].isNull()) {
577 p.setPen(actcol);
578 }
579 // reset bold font to plain font
580 if (events[i] > 0) {
581 QFont myFont = font();
582 myFont.setBold(false);
583 p.setFont(myFont);
584 }
585 }
586}
587
588// ----------------------------------------------------------------------------
589// R E SI Z E E V E N T H A N D L I N G
590// ----------------------------------------------------------------------------
591
592void KODayMatrix::resizeEvent(QResizeEvent *)
593{
594 QRect sz = frameRect();
595 daysize.setHeight(sz.height()*7 / NUMDAYS);
596 daysize.setWidth(sz.width() / 7);
597}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
new file mode 100644
index 0000000..b4eb2a8
--- a/dev/null
+++ b/korganizer/kodaymatrix.h
@@ -0,0 +1,308 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KODAYMAT_H
24#define _KODAYMAT_H
25
26#include <libkcal/calendar.h>
27
28#include <qstring.h>
29#include <qframe.h>
30#include <qcolor.h>
31#include <qpen.h>
32#include <qdatetime.h>
33#include <qtooltip.h>
34
35#include <qmap.h>
36
37class QDragEnterEvent;
38class QDragMoveEvent;
39class QDragLeaveEvent;
40class QDropEvent;
41
42class KODayMatrix;
43
44using namespace KCal;
45
46
47/**
48 * small helper class to dynamically show tooltips inside the day matrix.
49 * This class asks the day matrix object for a appropriate label which
50 * is in our special case the name of the holiday or null if this day is no holiday.
51 */
52class DynamicTip : public QToolTip
53{
54public:
55
56 /**
57 * Constructor that expects a KODayMatrix object as parent.
58 *
59 * @param parent the parent KODayMatrix control.
60 */
61 DynamicTip(QWidget* parent );
62
63protected:
64
65 /**
66 * Qt's callback to ask the object to provide an approrpiate text for the
67 * tooltip to be shown.
68 *
69 * @param pos coordinates of the mouse.
70 */
71 void maybeTip( const QPoint & pos);
72
73private:
74
75 /** the parent control this tooltip is designed for. */
76 KODayMatrix* matrix;
77};
78
79/**
80 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
81 * Cornelius thought this was a waste of memory and a lot of overhead.
82 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame
83 * that draws the labels and allows for dragging selection while maintaining nearly full
84 * compatibility in behaviour with its predecessor.
85 *
86 * The following functionality has been changed:
87 *
88 * o when shifting events in the agenda view from one day to another the day matrix is updated now
89 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date.
90 * o no support for Ctrl+click to create groups of dates
91 * (This has not really been supported in the predecessor. It was not very intuitive nor was it
92 * user friendly.)
93 * This feature has been replaced with dragging a selection on the matrix. The matrix will
94 * automatically choose the appropriate selection (e.g. you are not any longer able to select
95 * two distinct groups of date selections as in the old class)
96 * o now that you can select more then a week it can happen that not all selected days are
97 * displayed in the matrix. However this is preferred to the alternative which would mean to
98 * adjust the selection and leave some days undisplayed while scrolling through the months
99 *
100 * @short day matrix widget of the KDateNavigator
101 *
102 * @author Eitzenberger Thomas
103 */
104class KODayMatrix: public QFrame {
105
106 Q_OBJECT
107
108public:
109
110 /** constructor to create a day matrix widget.
111 *
112 * @param parent widget that is the parent of the day matrix. Normally this should
113 * be a KDateNavigator
114 * @param calendar instance of a calendar on which all calculations are based
115 * @param date start date of the matrix (is expected to be already fixed). It is
116 * assumed that this date is the first week day to be shown in the matrix.
117 * @param name name of the widget
118 */
119 KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
120
121 /** destructor that deallocates all dynamically allocated private members.
122 */
123 ~KODayMatrix();
124
125 /** updates the day matrix to start with the given date. Does all the necessary
126 * checks for holidays or events on a day and stores them for display later on.
127 * Does NOT update the view visually. Call repaint() for this.
128 *
129 * @param actdate recalculates the day matrix to show NUMDAYS starting from this
130 * date.
131 */
132 void updateView(QDate actdate);
133
134 /** returns the QDate object associated with day indexed by the
135 * supplied offset.
136 */
137 const QDate& getDate(int offset);
138
139 /** returns the official name of this holy day or 0 if there is no label
140 * for this day.
141 */
142 QString getHolidayLabel(int offset);
143
144 /** adds all actual selected days from mSelStart to mSelEnd to the supplied
145 * DateList.
146 */
147 void addSelectedDaysTo(DateList&);
148
149 /** sets the actual to be displayed selection in the day matrix starting from
150 * start and ending with end. Theview must be manually updated by calling
151 * repaint. (?)
152 */
153 void setSelectedDaysFrom(const QDate& start, const QDate& end);
154
155
156 /** Is today visible in the view? Keep this in sync with
157 * the values today (below) can take.
158 */
159 bool isTodayVisible() const { return today>=0; } ;
160
161 /** If today is visible, then we can find out if today is
162 * near the beginning or the end of the month.
163 * This is dependent on today remaining the index
164 * in the array of visible dates and going from
165 * top left (0) to bottom right (41).
166 */
167 bool isBeginningOfMonth() const { return today<=8; } ;
168 bool isEndOfMonth() const { return today>=27; } ;
169
170public slots:
171 /** Recalculates all the flags of the days in the matrix like holidays or events
172 * on a day (Actually calls above method with the actual startdate).
173 */
174 void updateView();
175
176 /**
177 * Calculate which square in the matrix should be
178 * hilighted to indicate it's today.
179 */
180 void recalculateToday();
181
182/*
183 void setStartDate(QDate);
184*/
185
186signals:
187
188 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
189 * inside the matrix
190 *
191 * @param daylist list of days that have been selected by the user
192 */
193 void selected( const KCal::DateList &daylist );
194
195 /** emitted if the user has dropped an event inside the matrix
196 *
197 * @param event the dropped calendar event
198 */
199 void eventDropped(Event *event);
200
201protected:
202
203 void paintEvent(QPaintEvent *ev);
204
205 void mousePressEvent (QMouseEvent* e);
206
207 void mouseReleaseEvent (QMouseEvent* e);
208
209 void mouseMoveEvent (QMouseEvent* e);
210
211 void dragEnterEvent(QDragEnterEvent *);
212
213 void dragMoveEvent(QDragMoveEvent *);
214
215 void dragLeaveEvent(QDragLeaveEvent *);
216
217 void dropEvent(QDropEvent *);
218
219 void resizeEvent(QResizeEvent *);
220
221private:
222
223 /** returns the index of the day located at the matrix's widget (x,y) position.
224 *
225 * @param x horizontal coordinate
226 * @param y vertical coordinate
227 */
228 int getDayIndexFrom(int x, int y);
229
230 /** calculates a "shaded" color from the supplied color object.
231 * (Copied from Cornelius's kdpdatebutton.cpp)
232 *
233 * @param color source based on which a shaded color should be calculated.
234 */
235 QColor getShadedColor(QColor color);
236
237 /** number of days to be displayed. For now there is no support for any other number then 42.
238 so change it at your own risk :o) */
239 static const int NUMDAYS;
240
241 /** calendar instance to be queried for holidays, events, ... */
242 Calendar *mCalendar;
243
244 /** starting date of the matrix */
245 QDate startdate;
246
247 /** array of day labels to optimeize drawing performance. */
248 QString *daylbls;
249
250 /** array of days displayed to reduce memory consumption by
251 subsequently calling QDate::addDays(). */
252 QDate *days;
253
254 /** array of storing the number of events on a given day.
255 * used for drawing a bold font if there is at least one event on that day.
256 */
257 int *events;
258
259 /** stores holiday names of the days shown in the matrix. */
260 QMap<int,QString> mHolidays;
261
262 /** indey of today or -1 if today is not visible in the matrix. */
263 int today;
264
265 /** index of day where dragged selection was initiated.
266 used to detect "negative" timely selections */
267 int mSelInit;
268
269 /** if mSelStart has this value it indicates that there is no
270 actual selection in the matrix. */
271 static const int NOSELECTION;
272
273 /** index of first selected day. */
274 int mSelStart;
275
276 /** index of last selected day. */
277 int mSelEnd;
278
279 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */
280 DynamicTip* mToolTip;
281
282
283 /** default background colour of the matrix. */
284 QColor mDefaultBackColor;
285
286 /** default text color of the matrix. */
287 QColor mDefaultTextColor;
288
289 /** default text color for days not in the actual month. */
290 QColor mDefaultTextColorShaded;
291
292 /** default text color for holidays not in the actual month. */
293 QColor mHolidayColorShaded;
294
295 /** text color for selected days. */
296 QColor mSelectedDaysColor;
297
298 /** default width of the frame drawn around today if it is visible in the matrix. */
299 int mTodayMarginWidth;
300
301 /** stores actual size of each day in the widget so that I dont need to ask this data
302 * on every repaint.
303 */
304 QRect daysize;
305
306};
307
308#endif
diff --git a/korganizer/kodaymatrix.moc b/korganizer/kodaymatrix.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kodaymatrix.moc
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
new file mode 100644
index 0000000..caf7599
--- a/dev/null
+++ b/korganizer/kodialogmanager.cpp
@@ -0,0 +1,343 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20*/
21
22#include <libkdepim/categoryeditdialog.h>
23
24#include "calendarview.h"
25#include "incomingdialog.h"
26#include "outgoingdialog.h"
27#include "koprefsdialog.h"
28#include "koeventeditor.h"
29#include "koprefs.h"
30#include "datenavigator.h"
31#include "kotodoeditor.h"
32#include "searchdialog.h"
33#include "filtereditdialog.h"
34#ifndef KORG_NOPLUGINS
35#include "plugindialog.h"
36#endif
37#ifndef KORG_NOARCHIVE
38#include "archivedialog.h"
39#endif
40
41#include "kconfig.h"
42#include "kodialogmanager.h"
43#include "kodialogmanager.moc"
44
45KODialogManager::KODialogManager( CalendarView *mainView ) :
46 QObject(), mMainView( mainView )
47{
48 mOutgoingDialog = 0;
49 mIncomingDialog = 0;
50 mOptionsDialog = 0;
51 mSearchDialog = 0;
52 mArchiveDialog = 0;
53 mFilterEditDialog = 0;
54 mPluginDialog = 0;
55
56 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView);
57 //KOGlobals::fitDialogToScreen( mCategoryEditDialog );
58}
59
60KODialogManager::~KODialogManager()
61{
62 delete mOutgoingDialog;
63 delete mIncomingDialog;
64 delete mOptionsDialog;
65 delete mSearchDialog;
66#ifndef KORG_NOARCHIVE
67 delete mArchiveDialog;
68#endif
69 delete mFilterEditDialog;
70#ifndef KORG_NOPLUGINS
71 delete mPluginDialog;
72#endif
73}
74
75OutgoingDialog *KODialogManager::outgoingDialog()
76{
77 createOutgoingDialog();
78 return mOutgoingDialog;
79}
80
81void KODialogManager::createOutgoingDialog()
82{
83 if (!mOutgoingDialog) {
84 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView);
85 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog);
86 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)),
87 mMainView,SIGNAL(numOutgoingChanged(int)));
88 }
89}
90
91void KODialogManager::showOptionsDialog( bool showSync )
92{
93 int curLanguage = KOPrefs::instance()->mPreferredLanguage;
94 if (!mOptionsDialog) {
95 mOptionsDialog = new KOPrefsDialog(mMainView);
96 //mOptionsDialog->readConfig();
97 connect(mOptionsDialog,SIGNAL(configChanged()),
98 mMainView,SLOT(updateConfig()));
99 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
100 // mOptionsDialog,SLOT(updateCategories()));
101
102 }
103 mOptionsDialog->readConfig();
104#ifndef DESKTOP_VERSION
105 mOptionsDialog->showMaximized();
106#else
107 mOptionsDialog->show();
108#endif
109 if ( showSync )
110 mOptionsDialog->showSyncPage();
111 mOptionsDialog->exec();
112 if ( curLanguage != KOPrefs::instance()->mPreferredLanguage )
113 KOPrefs::instance()->mLanguageChanged = true;
114}
115void KODialogManager::showSyncOptions()
116{
117 showOptionsDialog( true );
118
119}
120void KODialogManager::showOutgoingDialog()
121{
122 createOutgoingDialog();
123 mOutgoingDialog->show();
124 mOutgoingDialog->raise();
125}
126
127IncomingDialog *KODialogManager::incomingDialog()
128{
129 createOutgoingDialog();
130 if (!mIncomingDialog) {
131 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
132 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
133 mMainView,SIGNAL(numIncomingChanged(int)));
134 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
135 mMainView,SLOT(updateView()));
136 }
137 return mIncomingDialog;
138}
139
140void KODialogManager::createIncomingDialog()
141{
142 createOutgoingDialog();
143 if (!mIncomingDialog) {
144 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
145 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
146 mMainView,SIGNAL(numIncomingChanged(int)));
147 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
148 mMainView,SLOT(updateView()));
149 }
150}
151
152void KODialogManager::showIncomingDialog()
153{
154 createIncomingDialog();
155 mIncomingDialog->show();
156 mIncomingDialog->raise();
157}
158/*
159void KODialogManager::showCategoryEditDialog()
160{
161 mCategoryEditDialog->show();
162}
163*/
164void KODialogManager::hideSearchDialog()
165{
166 if (mSearchDialog)
167 mSearchDialog->hide();
168}
169
170void KODialogManager::showSearchDialog()
171{
172 if (!mSearchDialog) {
173 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView);
174 KOListView * lview = mSearchDialog->listview();
175
176 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)),
177 mMainView, SLOT(showIncidence(Incidence *)));
178 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)),
179 mMainView, SLOT(editIncidence(Incidence *)));
180 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)),
181 mMainView, SLOT(deleteIncidence(Incidence *)));
182 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)),
183 mMainView, SLOT(cloneIncidence(Incidence *)));
184 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)),
185 mMainView, SLOT(beamIncidence(Incidence *)));
186 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)),
187 mMainView, SLOT(moveIncidence(Incidence *)));
188 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )),
189 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> )));
190
191 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig()));
192 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList()));
193 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ),
194 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
195#ifndef DESKTOP_VERSION
196 mSearchDialog->setMaximumSize( 640, 480 );
197 //mSearchDialog->setGeometry( 40,40, 400, 300);
198 mSearchDialog->showMaximized();
199#else
200 KConfig *config = KOGlobals::config();
201 config->setGroup("WidgetLayout");
202 QStringList list;
203 list = config->readListEntry("SearchLayout");
204 int x,y,w,h;
205 if ( ! list.isEmpty() ) {
206 x = list[0].toInt();
207 y = list[1].toInt();
208 w = list[2].toInt();
209 h = list[3].toInt();
210 mSearchDialog->setGeometry(x,y,w,h);
211
212 }
213
214#endif
215 }
216 // make sure the widget is on top again
217 mSearchDialog->show();
218 mSearchDialog->raise();
219}
220
221SearchDialog * KODialogManager::getSearchDialog()
222{
223 return mSearchDialog;
224}
225void KODialogManager::showArchiveDialog()
226{
227#ifndef KORG_NOARCHIVE
228 if (!mArchiveDialog) {
229 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView);
230 connect(mArchiveDialog,SIGNAL(eventsDeleted()),
231 mMainView,SLOT(updateView()));
232 }
233 mArchiveDialog->show();
234 mArchiveDialog->raise();
235
236 // Workaround.
237 QApplication::restoreOverrideCursor();
238#endif
239}
240
241void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters)
242{
243 if (!mFilterEditDialog) {
244 mFilterEditDialog = new FilterEditDialog(filters,mMainView);
245 connect(mFilterEditDialog,SIGNAL(filterChanged()),
246 mMainView,SLOT(filterEdited()));
247
248 }
249
250#ifndef DESKTOP_VERSION
251 mFilterEditDialog->showMaximized();
252#else
253 mFilterEditDialog->show();
254#endif
255 mFilterEditDialog->raise();
256}
257
258void KODialogManager::showPluginDialog()
259{
260#ifndef KORG_NOPLUGINS
261 if (!mPluginDialog) {
262 mPluginDialog = new PluginDialog(mMainView);
263 connect(mPluginDialog,SIGNAL(configChanged()),
264 mMainView,SLOT(updateConfig()));
265 }
266 mPluginDialog->show();
267 mPluginDialog->raise();
268#endif
269}
270
271KOEventEditor *KODialogManager::getEventEditor()
272{
273 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(),
274 mMainView );
275
276 connect(eventEditor,SIGNAL(eventAdded(Event *)),
277 mMainView,SLOT(eventAdded(Event *)));
278 connect(eventEditor,SIGNAL(eventChanged(Event *)),
279 mMainView,SLOT(eventChanged(Event *)));
280 connect(eventEditor,SIGNAL(eventDeleted()),
281 mMainView,SLOT(eventDeleted()));
282 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)),
283 mMainView,SLOT(schedule_cancel(Incidence *)));
284 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)),
285 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
286 connect( eventEditor, SIGNAL( showAgendaView( bool)),
287 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
288
289 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
290 // eventEditor,SLOT(updateCategoryConfig()));
291 // connect(eventEditor,SIGNAL(editCategories()),
292 // mCategoryEditDialog,SLOT(show()));
293 connect(eventEditor,SIGNAL(dialogClose(Incidence*)),
294 mMainView,SLOT(dialogClosing(Incidence*)));
295
296 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject()));
297
298 return eventEditor;
299}
300
301KOTodoEditor *KODialogManager::getTodoEditor()
302{
303 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(),
304 mMainView );
305
306 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
307 // todoEditor,SLOT(updateCategoryConfig()));
308 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show()));
309
310 connect(todoEditor,SIGNAL(todoAdded(Todo *)),
311 mMainView,SLOT(todoAdded(Todo *)));
312 connect(todoEditor,SIGNAL(todoChanged(Todo *)),
313 mMainView,SLOT(todoChanged(Todo *)));
314 connect(todoEditor,SIGNAL(todoDeleted()),
315 mMainView,SLOT(todoDeleted()));
316 connect(todoEditor,SIGNAL(dialogClose(Incidence*)),
317 mMainView,SLOT(dialogClosing(Incidence*)));
318 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)),
319 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
320 connect( todoEditor, SIGNAL( showAgendaView( bool)),
321 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
322 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)),
323 // mMainView,SLOT(schedule_cancel(Incidence *)));
324 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject()));
325
326 return todoEditor;
327}
328
329void KODialogManager::updateSearchDialog()
330{
331 if (mSearchDialog) mSearchDialog->updateView();
332}
333
334void KODialogManager::setDocumentId( const QString &id )
335{
336 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id );
337}
338
339void KODialogManager::writeSettings( KConfig *config )
340{
341 if (mSearchDialog)
342 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout");
343}
diff --git a/korganizer/kodialogmanager.h b/korganizer/kodialogmanager.h
new file mode 100644
index 0000000..a6cc621
--- a/dev/null
+++ b/korganizer/kodialogmanager.h
@@ -0,0 +1,100 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001
4 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef KODIALOGMANAGER_H
25#define KODIALOGMANAGER_H
26
27#include <qobject.h>
28#include <qptrlist.h>
29
30#include <libkcal/calfilter.h>
31
32class CalendarView;
33class OutgoingDialog;
34class IncomingDialog;
35class KOPrefsDialog;
36//namespace KPIM { class CategoryEditDialog; }
37class KOEventEditor;
38class KOTodoEditor;
39class SearchDialog;
40class ArchiveDialog;
41class PluginDialog;
42class KConfig;
43class FilterEditDialog;
44
45using namespace KCal;
46
47/**
48 This class manages the dialogs used by the calendar view. It owns the objects
49 and handles creation and selection.
50*/
51class KODialogManager : public QObject
52{
53 Q_OBJECT
54 public:
55 KODialogManager( CalendarView * );
56 virtual ~KODialogManager();
57
58 /** Get an editor dialog for an Event. */
59 KOEventEditor *getEventEditor();
60
61 /** Get an editor dialog for a Todo. */
62 KOTodoEditor *getTodoEditor();
63
64 OutgoingDialog *outgoingDialog();
65
66 IncomingDialog *incomingDialog();
67 void writeSettings( KConfig *config);
68 void updateSearchDialog();
69 SearchDialog * getSearchDialog();
70 void setDocumentId( const QString &id );
71
72 public slots:
73 void showOptionsDialog( bool showSync = false);
74 void showSyncOptions();
75 void showIncomingDialog();
76 void showOutgoingDialog();
77 // void showCategoryEditDialog();
78 void showSearchDialog();
79 void showArchiveDialog();
80 void showFilterEditDialog(QPtrList<CalFilter> *filters);
81 void showPluginDialog();
82 void hideSearchDialog();
83
84 private:
85 void createOutgoingDialog();
86 void createIncomingDialog();
87
88 CalendarView *mMainView;
89
90 OutgoingDialog *mOutgoingDialog;
91 IncomingDialog *mIncomingDialog;
92 KOPrefsDialog *mOptionsDialog;
93 // KPIM::CategoryEditDialog *mCategoryEditDialog;
94 SearchDialog *mSearchDialog;
95 ArchiveDialog *mArchiveDialog;
96 FilterEditDialog *mFilterEditDialog;
97 PluginDialog *mPluginDialog;
98};
99
100#endif
diff --git a/korganizer/kodialogmanager.moc b/korganizer/kodialogmanager.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kodialogmanager.moc
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp
new file mode 100644
index 0000000..7c4c382
--- a/dev/null
+++ b/korganizer/koeditordetails.cpp
@@ -0,0 +1,398 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in thse hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qtooltip.h>
25#include <qfiledialog.h>
26#include <qlayout.h>
27#include <qvbox.h>
28#include <qbuttongroup.h>
29#include <qvgroupbox.h>
30#include <qwidgetstack.h>
31#include <qdatetime.h>
32#include <qapp.h>
33
34#include <klocale.h>
35#include <kglobal.h>
36#include <kiconloader.h>
37#include <kstandarddirs.h>
38#include <kmessagebox.h>
39#ifndef KORG_NOKABC
40#include <kabc/addresseedialog.h>
41#endif
42
43#include <libkcal/incidence.h>
44
45#include "koprefs.h"
46
47#include "koeditordetails.h"
48#include "koeditordetails.moc"
49
50template <>
51CustomListViewItem<class Attendee *>::~CustomListViewItem()
52{
53 delete mData;
54}
55
56template <>
57void CustomListViewItem<class Attendee *>::updateItem()
58{
59 setText(0,mData->name());
60 setText(1,mData->email());
61 setText(2,mData->roleStr());
62 setText(3,mData->statusStr());
63 if (mData->RSVP() && !mData->email().isEmpty())
64 setPixmap(4,SmallIcon("mailappt"));
65 else
66 setPixmap(4,SmallIcon("nomailappt"));
67}
68
69
70KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name)
71 : QWidget( parent, name), mDisableItemUpdate( false )
72{
73 QGridLayout *topLayout = new QGridLayout(this);
74 topLayout->setSpacing(spacing);
75
76 QString organizer = KOPrefs::instance()->email();
77 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this);
78
79 mListView = new KListView(this,"mListView");
80 mListView->addColumn(i18n("Name"),180);
81 mListView->addColumn(i18n("Email"),180);
82 mListView->addColumn(i18n("Role"),60);
83 mListView->addColumn(i18n("Status"),100);
84 mListView->addColumn(i18n("RSVP"),35);
85 if ( KOPrefs::instance()->mCompactDialogs ) {
86 //mListView->setFixedHeight(78);
87 }
88
89 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)),
90 SLOT(updateAttendeeInput()));
91
92 QLabel *attendeeLabel = new QLabel(this);
93 attendeeLabel->setText(i18n("Name:"));
94 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() );
95 mNameEdit = new QLineEdit(this);
96 connect(mNameEdit,SIGNAL(textChanged(const QString &)),
97 SLOT(updateAttendeeItem()));
98
99 mUidEdit = new QLineEdit(0);
100 mUidEdit->setText("");
101
102 QLabel *emailLabel = new QLabel(this);
103 emailLabel->setText(i18n("Email:"));
104 mEmailEdit = new QLineEdit(this);
105 connect(mEmailEdit,SIGNAL(textChanged(const QString &)),
106 SLOT(updateAttendeeItem()));
107
108 QLabel *attendeeRoleLabel = new QLabel(this);
109 attendeeRoleLabel->setText(i18n("Role:"));
110 mRoleCombo = new QComboBox(false,this);
111 mRoleCombo->insertStringList(Attendee::roleList());
112 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
113
114 QLabel *statusLabel = new QLabel(this);
115 statusLabel->setText( i18n("Status:") );
116
117 mStatusCombo = new QComboBox(false,this);
118 mStatusCombo->insertStringList(Attendee::statusList());
119 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
120
121 mRsvpButton = new QCheckBox(this);
122 mRsvpButton->setText(i18n("Request response"));
123 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem()));
124 QWidget *buttonBox = new QWidget(this);
125 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox);
126
127 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox);
128 buttonLayout->addWidget(newButton);
129 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee()));
130
131 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox);
132 buttonLayout->addWidget(mRemoveButton);
133 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee()));
134
135 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this);
136 // buttonLayout->addWidget(mAddressBookButton);
137 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook()));
138 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () );
139
140 if (qApp->desktop()->width() < 300 ) {
141 mListView->setFixedHeight(80);
142 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3);
143 topLayout->addMultiCellWidget(mListView,1,1,0,3);
144 topLayout->addWidget(attendeeLabel,3,0);
145 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2);
146 topLayout->addWidget(emailLabel,4,0);
147 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2);
148 topLayout->addWidget(attendeeRoleLabel,5,0);
149 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
150 topLayout->addWidget(statusLabel,6,0);
151 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,2);
152 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3);
153 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
154 topLayout->addMultiCellWidget(buttonBox,3,4,3,3);
155 topLayout->setRowStretch(1,2);
156 topLayout->setColStretch(0,0);
157 topLayout->setColStretch(1,2);
158 topLayout->setColStretch(2,1);
159 topLayout->setColStretch(3,1);
160
161 } else {
162 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5);
163 topLayout->addMultiCellWidget(mListView,1,1,0,5);
164 topLayout->addWidget(attendeeLabel,3,0);
165 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4);
166 topLayout->addWidget(emailLabel,4,0);
167 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4);
168 topLayout->addWidget(attendeeRoleLabel,5,0);
169 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
170 topLayout->addWidget(statusLabel,5,3);
171 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5);
172 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5);
173 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
174 topLayout->addMultiCellWidget(buttonBox,3,4,5,5);
175 topLayout->setRowStretch(1,5);
176 topLayout->setColStretch(0,0);
177 }
178// #if 0
179// topLayout->setColStretch(2,1);
180// topLayout->addWidget(statusLabel,3,3);
181// topLayout->addWidget(mStatusCombo,3,4);
182// #else
183// topLayout->addWidget(statusLabel,4,3);
184// // topLayout->addWidget(mStatusCombo,4,3);
185// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5);
186
187// #endif
188// // topLayout->setRowStretch(5,1);
189// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1);
190// topLayout->addMultiCellWidget(buttonBox,2,3,5,5);
191// topLayout->setRowStretch(1,5);
192// topLayout->setColStretch(0,0);
193
194#ifdef KORG_NOKABC
195 mAddressBookButton->hide();
196#endif
197
198 updateAttendeeInput();
199}
200
201KOEditorDetails::~KOEditorDetails()
202{
203}
204
205void KOEditorDetails::removeAttendee()
206{
207 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem();
208 if (!aItem) return;
209
210 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(),
211 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(),
212 aItem->data()->uid());
213 mdelAttendees.append(delA);
214
215 delete aItem;
216
217 updateAttendeeInput();
218}
219
220
221void KOEditorDetails::openAddressBook()
222{
223#ifndef KORG_NOKABC
224
225 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
226 uint i=0;
227 for (i=0; i < list.count(); i++) {
228 insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) );
229 }
230
231#if 0
232 KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
233 if (!a.isEmpty()) {
234 insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) );
235 }
236#endif
237#endif
238}
239
240
241void KOEditorDetails::addNewAttendee()
242{
243#if 0
244 // this is cool. If they didn't enter an email address,
245 // try to look it up in the address book and fill it in for them.
246 if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) {
247 KabAPI addrBook;
248 QString name;
249 std::list<AddressBook::Entry> entries;
250 name = mNameEdit->text();
251 if (addrBook.init() == AddressBook::NoError) {
252 if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) {
253 kdDebug() << "positive match" << endl;
254 // take first email address
255 if (!entries.front().emails.isEmpty() &&
256 entries.front().emails.first().length()>0)
257 mEmailEdit->setText(entries.front().emails.first());
258 }
259 }
260 }
261#endif
262
263 Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)"));
264 insertAttendee(a);
265}
266
267
268void KOEditorDetails::insertAttendee(Attendee *a)
269{
270 AttendeeListItem *item = new AttendeeListItem(a,mListView);
271 mListView->setSelected( item, true );
272}
273
274void KOEditorDetails::setDefaults()
275{
276 mRsvpButton->setChecked(true);
277 mListView->clear();
278 mdelAttendees.clear();
279 clearAttendeeInput();
280 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email()));
281
282 mNameEdit->setText("");
283 mUidEdit->setText("");
284 mEmailEdit->setText("");
285 mRoleCombo->setCurrentItem( 0 );
286 mStatusCombo->setCurrentItem( 0 );
287
288}
289
290void KOEditorDetails::readEvent(Incidence *event)
291{
292 setDefaults();
293 //mListView->clear();
294 //mdelAttendees.clear();
295 QPtrList<Attendee> tmpAList = event->attendees();
296 Attendee *a;
297 for (a = tmpAList.first(); a; a = tmpAList.next())
298 insertAttendee(new Attendee(*a));
299
300 mListView->setSelected( mListView->firstChild(), true );
301 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer()));
302}
303
304void KOEditorDetails::writeEvent(Incidence *event)
305{
306 event->clearAttendees();
307 QListViewItem *item;
308 AttendeeListItem *a;
309 for (item = mListView->firstChild(); item;
310 item = item->nextSibling()) {
311 a = (AttendeeListItem *)item;
312 event->addAttendee(new Attendee(*(a->data())));
313 }
314 event->setOrganizer(KOPrefs::instance()->email());
315}
316
317void KOEditorDetails::cancelAttendeeEvent(Incidence *event)
318{
319 event->clearAttendees();
320 Attendee * att;
321 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) {
322 event->addAttendee(new Attendee(*att));
323 }
324 mdelAttendees.clear();
325}
326
327bool KOEditorDetails::validateInput()
328{
329 return true;
330}
331
332void KOEditorDetails::updateAttendeeInput()
333{
334 QListViewItem *item = mListView->selectedItem();
335 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
336 if (aItem) {
337 fillAttendeeInput( aItem );
338 } else {
339 clearAttendeeInput();
340 }
341}
342
343void KOEditorDetails::clearAttendeeInput()
344{
345 mNameEdit->setText("");
346 mUidEdit->setText("");
347 mEmailEdit->setText("");
348 mRoleCombo->setCurrentItem(0);
349 mStatusCombo->setCurrentItem(0);
350 mRsvpButton->setChecked(true);
351 setEnabledAttendeeInput( false );
352}
353
354void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem )
355{
356 Attendee *a = aItem->data();
357 mDisableItemUpdate = true;
358 mNameEdit->setText(a->name());
359 mUidEdit->setText(a->uid());
360 mEmailEdit->setText(a->email());
361 mRoleCombo->setCurrentItem(a->role());
362 mStatusCombo->setCurrentItem(a->status());
363 mRsvpButton->setChecked(a->RSVP());
364
365 mDisableItemUpdate = false;
366
367 setEnabledAttendeeInput( true );
368}
369
370void KOEditorDetails::setEnabledAttendeeInput( bool enabled )
371{
372 mNameEdit->setEnabled( enabled );
373 mEmailEdit->setEnabled( enabled );
374 mRoleCombo->setEnabled( enabled );
375 mStatusCombo->setEnabled( enabled );
376 mRsvpButton->setEnabled( enabled );
377
378 mRemoveButton->setEnabled( enabled );
379}
380
381void KOEditorDetails::updateAttendeeItem()
382{
383 if (mDisableItemUpdate) return;
384
385 QListViewItem *item = mListView->selectedItem();
386 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
387 if ( !aItem ) return;
388
389 Attendee *a = aItem->data();
390
391 a->setName( mNameEdit->text() );
392 a->setUid( mUidEdit->text() );
393 a->setEmail( mEmailEdit->text() );
394 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) );
395 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) );
396 a->setRSVP( mRsvpButton->isChecked() );
397 aItem->updateItem();
398}
diff --git a/korganizer/koeditordetails.h b/korganizer/koeditordetails.h
new file mode 100644
index 0000000..930b296
--- a/dev/null
+++ b/korganizer/koeditordetails.h
@@ -0,0 +1,103 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOEDITORDETAILS_H
24#define _KOEDITORDETAILS_H
25
26#include <qframe.h>
27#include <qlabel.h>
28#include <qcheckbox.h>
29#include <qpushbutton.h>
30#include <qgroupbox.h>
31#include <qlineedit.h>
32#include <qcombobox.h>
33#include <qmultilineedit.h>
34#include <klistview.h>
35#include <qradiobutton.h>
36#include <qptrlist.h>
37
38#include <kapplication.h>
39
40#include <libkcal/event.h>
41
42#include "ktimeedit.h"
43#include "customlistviewitem.h"
44
45class KDateEdit;
46
47using namespace KCal;
48
49typedef CustomListViewItem<Attendee *> AttendeeListItem;
50
51
52class KOEditorDetails : public QWidget
53{
54 Q_OBJECT
55 public:
56 KOEditorDetails (int spacing = 8,QWidget* parent = 0, const char* name = 0);
57 virtual ~KOEditorDetails();
58
59 /** Set widgets to default values */
60 void setDefaults();
61 /** Read event object and setup widgets accordingly */
62 void readEvent(Incidence *);
63 /** Write event settings to event object */
64 void writeEvent(Incidence *);
65
66 /** return a clone of the event with attendees to be canceld*/
67 void cancelAttendeeEvent(Incidence *);
68 /** Check if the input is valid. */
69 bool validateInput();
70
71 public slots:
72 void insertAttendee(Attendee *);
73
74 protected slots:
75 void addNewAttendee();
76 void removeAttendee();
77 void openAddressBook();
78 void updateAttendeeInput();
79 void clearAttendeeInput();
80 void fillAttendeeInput(AttendeeListItem *);
81 void updateAttendeeItem();
82 void setEnabledAttendeeInput(bool);
83
84 private:
85 bool mDisableItemUpdate;
86
87 QLineEdit *mNameEdit;
88 QLineEdit *mUidEdit;
89 QLineEdit *mEmailEdit;
90 KListView *mListView;
91 QComboBox* mRoleCombo;
92 QCheckBox* mRsvpButton;
93 QComboBox* mStatusCombo;
94 QLabel *mOrganizerLabel;
95
96 QPushButton* mAddButton;
97 QPushButton* mRemoveButton;
98 QPushButton* mAddressBookButton;
99
100 QPtrList<Attendee> mdelAttendees;
101};
102
103#endif
diff --git a/korganizer/koeditordetails.moc b/korganizer/koeditordetails.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeditordetails.moc
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
new file mode 100644
index 0000000..ad1389f
--- a/dev/null
+++ b/korganizer/koeditorgeneral.cpp
@@ -0,0 +1,505 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qwidget.h>
25#include <qtooltip.h>
26#include <qlayout.h>
27#include <qvbox.h>
28#include <qbuttongroup.h>
29#include <qvgroupbox.h>
30#include <qwidgetstack.h>
31#include <qdatetime.h>
32#include <qfile.h>
33
34
35#include <kglobal.h>
36#include <kdebug.h>
37#include <klocale.h>
38#include <kiconloader.h>
39#include <kmessagebox.h>
40#include <kfiledialog.h>
41#include <kstandarddirs.h>
42
43#include <libkcal/todo.h>
44#include <libkcal/event.h>
45#include <libkdepim/categoryselectdialog.h>
46#include <libkdepim/kdateedit.h>
47
48#include "koprefs.h"
49#include "koglobals.h"
50
51#include "koeditorgeneral.h"
52#include "kolocationbox.h"
53#include "koeditorgeneral.moc"
54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h>
56#else
57#include <qapplication.h>
58#endif
59
60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
61 QObject( parent, name)
62{
63}
64
65KOEditorGeneral::~KOEditorGeneral()
66{
67}
68
69void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
70{
71 QGridLayout *headerLayout = new QGridLayout(topLayout);
72
73#if 0
74 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
75 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
76#endif
77
78 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
79 headerLayout->addWidget(summaryLabel,1,0);
80
81 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
82 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
83 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
84 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
85 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
86 if ( QApplication::desktop()->width() > 320 )
87 mSummaryEdit->setMaximumHeight( hei +6 );
88 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
89 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
90 // mSummaryEdit = new QLineEdit(parent);
91 headerLayout->addWidget(mSummaryEdit,1,1);
92 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
93
94 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
95 headerLayout->addWidget(locationLabel,2,0);
96
97 mLocationEdit = new KOLocationBox(TRUE,parent,10);
98 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
99 if ( QApplication::desktop()->width() > 320 )
100 mLocationEdit->setMaximumHeight( hei + 6);
101
102 // mLocationEdit = new QLineEdit(parent);
103 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
104 headerLayout->addWidget(mLocationEdit,2,1);
105 headerLayout->setColStretch( 1, 10);
106}
107void KOEditorGeneral::setFocusOn( int i )
108{
109 qApp->processEvents();
110 if ( i == 1 ) {
111 mDescriptionEdit->setFocus();
112 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
113 }
114 if ( i == 2 ) {
115 mSummaryEdit->setFocus();
116 }
117
118}
119void KOEditorGeneral::editCategories()
120{
121 // qDebug("KOEditorGeneral::editCategories() ");
122 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
123 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
124 //KOGlobals::fitDialogToScreen( csd );
125 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
126 csd->exec();
127 delete csd;
128}
129void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
130{
131 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
132
133 mCategoriesButton = new QPushButton(parent);
134 mCategoriesButton->setText(i18n("Categories..."));
135 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
136 categoriesLayout->addWidget(mCategoriesButton);
137
138 mCategoriesLabel = new QLabel(parent);
139 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
140 categoriesLayout->addWidget(mCategoriesLabel,1);
141}
142
143void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
144{
145 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
146
147 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
148 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
149 secrecyLayout->addWidget(mCancelBox);
150 secrecyLayout->addWidget(secrecyLabel);
151
152 mSecrecyCombo = new QComboBox(parent);
153 mSecrecyCombo->insertStringList(Incidence::secrecyList());
154 secrecyLayout->addWidget(mSecrecyCombo);
155}
156
157void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
158{
159 mDescriptionEdit = new KTextEdit(parent);
160 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
161 mDescriptionEdit->append("");
162 mDescriptionEdit->setReadOnly(false);
163 mDescriptionEdit->setOverwriteMode(false);
164 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
165 topLayout->addWidget(mDescriptionEdit);
166#ifndef DESKTOP_VERSION
167 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
168#endif
169
170}
171
172void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
173{
174 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
175
176 //mAlarmBell = new QLabel(parent);
177 //mAlarmBell->setPixmap(SmallIcon("bell"));
178 //alarmLayout->addWidget(mAlarmBell);
179 if ( QApplication::desktop()->width() < 320 )
180 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
181 else
182 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
183
184 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
185 alarmLayout->addWidget(mAlarmButton);
186
187 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
188 alarmLayout->addWidget(mAlarmTimeEdit);
189 mAlarmIncrCombo = new QComboBox(false, parent);
190 if ( QApplication::desktop()->width() < 320 ) {
191 mAlarmIncrCombo->insertItem(i18n("min"));
192 mAlarmIncrCombo->insertItem(i18n("hou"));
193 mAlarmIncrCombo->insertItem(i18n("day"));
194 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
195 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
196 } else {
197 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
198 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
199 mAlarmIncrCombo->insertItem(i18n("day(s)"));
200 }
201
202 // mAlarmIncrCombo->setMinimumHeight(20);
203 alarmLayout->addWidget(mAlarmIncrCombo);
204 mAlarmSoundButton = new QPushButton(parent);
205 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
206 mAlarmSoundButton->setToggleButton(true);
207 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
208 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
209 alarmLayout->addWidget(mAlarmSoundButton);
210
211 mAlarmProgramButton = new QPushButton(parent);
212 mAlarmProgramButton->setPixmap(SmallIcon("run"));
213 mAlarmProgramButton->setToggleButton(true);
214 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
215 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
216 alarmLayout->addWidget(mAlarmProgramButton);
217 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
218 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
219 // if ( KOPrefs::instance()->mCompactDialogs ) {
220 // mAlarmSoundButton->hide();
221 // mAlarmProgramButton->hide();
222 // }
223}
224
225void KOEditorGeneral::pickAlarmSound()
226{
227
228 //QString prefix = mAlarmSound;
229 if (!mAlarmSoundButton->isOn()) {
230 //mAlarmSound = "";
231 QToolTip::remove(mAlarmSoundButton);
232 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
233 mAlarmProgramButton->setOn(true);
234 mAlarmSoundButton->setOn(false);
235 } else {
236 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
237 i18n("*.wav|Wav Files"), 0));
238 if (!fileName.isEmpty()) {
239 mAlarmSound = fileName;
240 QToolTip::remove(mAlarmSoundButton);
241 QString dispStr = i18n("Playing '%1'").arg(fileName);
242 QToolTip::add(mAlarmSoundButton, dispStr);
243 mAlarmProgramButton->setOn(false);
244 mAlarmSoundButton->setOn(true);
245 } else {
246 mAlarmProgramButton->setOn(true);
247 mAlarmSoundButton->setOn(false);
248
249 }
250 }
251
252 if (mAlarmProgramButton->isOn())
253 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
254 if ( mAlarmSoundButton->isOn())
255 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + mAlarmSound );
256}
257
258void KOEditorGeneral::pickAlarmProgram()
259{
260 if (!mAlarmProgramButton->isOn()) {
261 //mAlarmProgram = "";
262 QToolTip::remove(mAlarmProgramButton);
263 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
264 mAlarmProgramButton->setOn(false);
265 mAlarmSoundButton->setOn(true);
266 } else {
267 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
268 if (!fileName.isEmpty()) {
269 mAlarmProgram = fileName;
270 QToolTip::remove(mAlarmProgramButton);
271 QString dispStr = i18n("Running '%1'").arg(fileName);
272 QToolTip::add(mAlarmProgramButton, dispStr);
273 mAlarmSoundButton->setOn(false);
274 mAlarmProgramButton->setOn(true);
275 } else {
276 mAlarmProgramButton->setOn(false);
277 mAlarmSoundButton->setOn(true);
278 }
279 }
280 if (mAlarmProgramButton->isOn())
281 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
282 if ( mAlarmSoundButton->isOn())
283 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound );
284}
285
286
287
288void KOEditorGeneral::enableAlarmEdit(bool enable)
289{
290 if ( enable ) {
291 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
292 mAlarmSoundButton->setOn( true );
293 if ( mAlarmSound.isEmpty() )
294 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
295 else {
296 if ( ! QFile::exists( mAlarmSound ) )
297 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
298 }
299 }
300 if (mAlarmProgramButton->isOn())
301 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
302 if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
303 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound );
304 }
305 else {
306 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled"));
307
308 }
309 mAlarmTimeEdit->setEnabled(enable);
310 mAlarmSoundButton->setEnabled(enable);
311 mAlarmProgramButton->setEnabled(enable);
312 mAlarmIncrCombo->setEnabled(enable);
313}
314
315void KOEditorGeneral::disableAlarmEdit(bool disable)
316{
317 enableAlarmEdit( !disable );
318}
319
320void KOEditorGeneral::enableAlarm( bool enable )
321{
322 enableAlarmEdit( enable );
323}
324
325void KOEditorGeneral::alarmDisable(bool disable)
326{
327 if (!disable) {
328 //mAlarmBell->setEnabled(true);
329 mAlarmButton->setEnabled(true);
330 } else {
331 //mAlarmBell->setEnabled(false);
332 mAlarmButton->setEnabled(false);
333 mAlarmButton->setChecked(false);
334 mAlarmTimeEdit->setEnabled(false);
335 mAlarmSoundButton->setEnabled(false);
336 mAlarmProgramButton->setEnabled(false);
337 mAlarmIncrCombo->setEnabled(false);
338 }
339}
340
341void KOEditorGeneral::setCategories(const QString &str)
342{
343 mCategoriesLabel->setText(str);
344}
345
346void KOEditorGeneral::setDefaults(bool allDay)
347{
348#if 0
349 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
350#endif
351
352 enableAlarmEdit( !allDay );
353
354 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
355 int alarmTime;
356 int a[] = { 1,5,10,15,30,60,180, 1440 };
357 int index = KOPrefs::instance()->mAlarmTime;
358 if (index < 0 || index > 7) {
359 alarmTime = 15;
360 } else {
361 alarmTime = a[index];
362 }
363 mAlarmButton ->setChecked( false );
364 mAlarmTimeEdit->setValue(alarmTime);
365 mAlarmIncrCombo->setCurrentItem(0);
366 enableAlarmEdit( false );
367 //alarmDisable (false);
368 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
369 mCancelBox->setChecked( false );
370 mSummaryEdit->setEditText("");
371 mLocationEdit->setEditText("");
372 mDescriptionEdit->setText("");
373 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
374 setCategories("");
375}
376void KOEditorGeneral::setSecrecy( int num )
377{
378 mSecrecyCombo->setCurrentItem(num);
379}
380void KOEditorGeneral::readIncidence(Incidence *event)
381{
382
383 mAlarmIncrCombo->setCurrentItem(0);
384 mSummaryEdit->setEditText(event->summary());
385 mLocationEdit->setEditText(event->location());
386 mDescriptionEdit->setText(event->description());
387
388#if 0
389 // organizer information
390 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
391#endif
392
393 enableAlarmEdit( event->isAlarmEnabled() );
394 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
395 if(!event->isAlarmEnabled()) {
396 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
397 int alarmTime;
398 int a[] = { 1,5,10,15,30,60,180, 1440 };
399 int index = KOPrefs::instance()->mAlarmTime;
400 if (index < 0 || index > 7) {
401 alarmTime = 15;
402 } else {
403 alarmTime = a[index];
404 }
405 mAlarmTimeEdit->setValue(alarmTime);
406 }
407 mAlarmButton->setChecked( event->isAlarmEnabled() );
408 mSecrecyCombo->setCurrentItem(event->secrecy());
409 mCancelBox->setChecked( event->cancelled() );
410 mAlarmProgramButton->setOn(false);
411 mAlarmSoundButton->setOn(false);
412
413 // set up alarm stuff
414 QPtrList<Alarm> alarms = event->alarms();
415 Alarm* alarm;
416 mAlarmIncrCombo->setCurrentItem(0);
417 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
418 int offset;
419 if ( alarm->hasTime() ) {
420 QDateTime t = alarm->time();
421 offset = event->dtStart().secsTo( t );
422 } else {
423 offset = alarm->startOffset().asSeconds();
424 }
425 if ( offset != 0 ) {
426 offset = offset / -60; // make minutes
427 if (offset % 60 == 0) { // divides evenly into hours?
428 offset = offset / 60;
429 mAlarmIncrCombo->setCurrentItem(1);
430 if (offset % 24 == 0) { // divides evenly into days?
431 offset = offset / 24;
432 mAlarmIncrCombo->setCurrentItem(2);
433 }
434 }
435 }
436 mAlarmTimeEdit->setValue( offset );
437 if (alarm->type() == Alarm::Procedure) {
438
439 mAlarmProgram = alarm->programFile();
440 mAlarmProgramButton->setOn(true);
441 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
442 QToolTip::add(mAlarmProgramButton, dispStr);
443 }
444 else if (alarm->type() == Alarm::Audio) {
445 mAlarmSound = alarm->audioFile();
446 if ( ! QFile::exists( mAlarmSound ) )
447 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
448 mAlarmSoundButton->setOn(true);
449 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
450 QToolTip::add(mAlarmSoundButton, dispStr);
451 }
452 mAlarmButton->setChecked(alarm->enabled());
453 enableAlarmEdit( alarm->enabled() );
454 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
455 // TODO: Deal with multiple alarms
456 break; // For now, stop after the first alarm
457 }
458
459 setCategories(event->categoriesStr());
460}
461
462void KOEditorGeneral::writeIncidence(Incidence *event)
463{
464 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
465 mLocationEdit->save(KOLocationBox::LOCATION);
466 event->setSummary(mSummaryEdit->currentText());
467 event->setLocation(mLocationEdit->currentText());
468 event->setDescription(mDescriptionEdit->text());
469 event->setCategories(mCategoriesLabel->text());
470 event->setSecrecy(mSecrecyCombo->currentItem());
471 event->setCancelled(mCancelBox->isChecked() );;
472 // alarm stuff
473 if (mAlarmButton->isChecked()) {
474 if (event->alarms().count() == 0)
475 event->newAlarm();
476 QPtrList<Alarm> alarms = event->alarms();
477 Alarm *alarm;
478 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
479 alarm->setEnabled(true);
480 int j = mAlarmTimeEdit->value()* -60;
481 if (mAlarmIncrCombo->currentItem() == 1)
482 j = j * 60;
483 else if (mAlarmIncrCombo->currentItem() == 2)
484 j = j * (60 * 24);
485 alarm->setStartOffset( j );
486
487 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
488 alarm->setProcedureAlarm(mAlarmProgram);
489 }
490 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
491 alarm->setAudioAlarm(mAlarmSound);
492 else
493 alarm->setType(Alarm::Invalid);
494 //alarm->setAudioAlarm("default");
495 // TODO: Deal with multiple alarms
496 break; // For now, stop after the first alarm
497 }
498 } else {
499 Alarm* alarm = event->alarms().first();
500 if ( alarm ) {
501 alarm->setEnabled(false);
502 alarm->setType(Alarm::Invalid);
503 }
504 }
505}
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h
new file mode 100644
index 0000000..c58335e
--- a/dev/null
+++ b/korganizer/koeditorgeneral.h
@@ -0,0 +1,112 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOEDITORGENERAL_H
24#define KOEDITORGENERAL_H
25
26#include <qframe.h>
27#include <qlabel.h>
28#include <qcheckbox.h>
29#include <qpushbutton.h>
30#include <qgroupbox.h>
31#include <qlineedit.h>
32#include <qcombobox.h>
33#include <qlistview.h>
34#include <qradiobutton.h>
35#include <qlayout.h>
36#include <qspinbox.h>
37
38#include <ktextedit.h>
39#include <krestrictedline.h>
40
41#include <libkcal/incidence.h>
42
43#include "ktimeedit.h"
44
45class KDateEdit;
46class KOLocationBox;
47using namespace KCal;
48
49class KOEditorGeneral : public QObject
50{
51 Q_OBJECT
52 public:
53 KOEditorGeneral (QObject* parent=0,const char* name=0);
54 virtual ~KOEditorGeneral();
55 void setFocusOn( int i );
56 void initHeader(QWidget *,QBoxLayout *);
57 void initDescription(QWidget *,QBoxLayout *);
58 void initSecrecy(QWidget *,QBoxLayout *);
59 void initCategories(QWidget *,QBoxLayout *);
60 void initAlarm(QWidget *,QBoxLayout *);
61
62 /** Set widgets to default values */
63 void setDefaults(bool allDay);
64 /** Read event object and setup widgets accordingly */
65 void readIncidence(Incidence *);
66 /** Write event settings to event object */
67 void writeIncidence(Incidence *);
68
69 /** Check if the input is valid. */
70 bool validateInput() { return true; }
71
72 void enableAlarm( bool enable );
73 void setSecrecy( int num );
74 public slots:
75 void setCategories(const QString &);
76 void editCategories();
77
78 protected slots:
79 void enableAlarmEdit( bool enable );
80 void disableAlarmEdit( bool disable );
81 void alarmDisable( bool disable );
82 void pickAlarmSound();
83 void pickAlarmProgram();
84
85 signals:
86 void openCategoryDialog();
87 void allAccepted();
88
89 protected:
90 //QLineEdit *mSummaryEdit;
91 //QLineEdit *mLocationEdit;
92 KOLocationBox *mSummaryEdit;
93 KOLocationBox *mLocationEdit;
94 QLabel *mAlarmBell;
95 QCheckBox *mAlarmButton;
96 QSpinBox *mAlarmTimeEdit;
97 QPushButton *mAlarmSoundButton;
98 QPushButton *mAlarmProgramButton;
99 QComboBox *mAlarmIncrCombo;
100 KTextEdit *mDescriptionEdit;
101 QLabel *mOwnerLabel;
102 QComboBox *mSecrecyCombo;
103 QCheckBox *mCancelBox;
104 QPushButton *mCategoriesButton;
105 QLabel *mCategoriesLabel;
106
107 private:
108 QString mAlarmSound;
109 QString mAlarmProgram;
110};
111
112#endif
diff --git a/korganizer/koeditorgeneral.moc b/korganizer/koeditorgeneral.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeditorgeneral.moc
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp
new file mode 100644
index 0000000..9b93e7e
--- a/dev/null
+++ b/korganizer/koeditorgeneralevent.cpp
@@ -0,0 +1,443 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qtooltip.h>
25#include <qlayout.h>
26#include <qvbox.h>
27#include <qbuttongroup.h>
28#include <qvgroupbox.h>
29#include <qwidgetstack.h>
30#include <qdatetime.h>
31
32#include <kdebug.h>
33#include <kglobal.h>
34#include <klocale.h>
35#include <kiconloader.h>
36#include <kmessagebox.h>
37#include <kfiledialog.h>
38#include <kstandarddirs.h>
39
40#include <libkcal/event.h>
41
42#include <libkdepim/kdateedit.h>
43
44#include "koprefs.h"
45
46#include "koeditorgeneralevent.h"
47#include "kolocationbox.h"
48#include "koeditorgeneralevent.moc"
49
50KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent,
51 const char* name) :
52 KOEditorGeneral( parent, name)
53{
54 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
55 SLOT(setDuration()));
56 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
57 SLOT(emitDateTimeStr()));
58}
59
60KOEditorGeneralEvent::~KOEditorGeneralEvent()
61{
62}
63
64void KOEditorGeneralEvent::finishSetup()
65{
66
67 //disabled
68// QWidget::setTabOrder( mSummaryEdit, mLocationEdit );
69// QWidget::setTabOrder( mLocationEdit, mStartDateEdit );
70// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit );
71// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit );
72// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit );
73// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton );
74// QWidget::setTabOrder( mNoTimeButton, mAlarmButton );
75// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit );
76// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton );
77// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo );
78// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit );
79
80
81
82 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
83 mSummaryEdit->setFocus();
84}
85
86void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout)
87{
88 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
89
90 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
91 i18n("Date && Time"),parent);
92 timeLayout->addWidget(timeGroupBox);
93
94 timeGroupBox->layout()->setSpacing( 0 );
95 timeGroupBox->layout()->setMargin( 5 );
96 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
97
98 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3);
99 layoutTimeBox->setSpacing(topLayout->spacing());
100
101 mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame);
102 layoutTimeBox->addWidget(mStartDateLabel,0,0);
103
104 mStartDateEdit = new KDateEdit(timeBoxFrame);
105 layoutTimeBox->addWidget(mStartDateEdit,0,1);
106
107 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
108 layoutTimeBox->addWidget(mStartTimeEdit,0,2);
109
110
111 mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame);
112 layoutTimeBox->addWidget(mEndDateLabel,1,0);
113
114 mEndDateEdit = new KDateEdit(timeBoxFrame);
115 layoutTimeBox->addWidget(mEndDateEdit,1,1);
116
117 mEndTimeEdit = new KOTimeEdit(timeBoxFrame);
118 layoutTimeBox->addWidget(mEndTimeEdit,1,2);
119 QWidget* duration = new QWidget( timeBoxFrame );
120 QHBoxLayout *flagsBox = new QHBoxLayout( duration );
121 mNoTimeButton = new QCheckBox(i18n("Allday"),duration);
122 flagsBox->addWidget(mNoTimeButton);
123 connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool)));
124 mDurationLabel = new QLabel( duration );
125 // if ( KOPrefs::instance()->mCompactDialogs ) {
126 //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 );
127 //} else {
128 flagsBox->addWidget( mDurationLabel );
129 //}
130 flagsBox->setStretchFactor(mDurationLabel, 10 );
131 mDurationLabel->setAlignment( AlignRight | AlignVCenter);
132 layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 );
133
134 // time widgets are checked if they contain a valid time
135 connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)),
136 this, SLOT(startTimeChanged(QTime)));
137 connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)),
138 this, SLOT(endTimeChanged(QTime)));
139
140 // date widgets are checked if they contain a valid date
141 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
142 this, SLOT(startDateChanged(QDate)));
143 connect(mEndDateEdit, SIGNAL(dateChanged(QDate)),
144 this, SLOT(endDateChanged(QDate)));
145}
146
147void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout)
148{
149 QBoxLayout *classLayout = new QHBoxLayout(topLayout);
150
151 QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent);
152 classLayout->addWidget(freeTimeLabel);
153
154 mFreeTimeCombo = new QComboBox(false, parent);
155 mFreeTimeCombo->insertItem(i18n("Busy"));
156 mFreeTimeCombo->insertItem(i18n("Free"));
157 classLayout->addWidget(mFreeTimeCombo);
158}
159
160void KOEditorGeneralEvent::timeStuffDisable(bool disable)
161{
162 mStartTimeEdit->setEnabled( !disable );
163 mEndTimeEdit->setEnabled( !disable );
164
165 setDuration();
166 emitDateTimeStr();
167}
168
169void KOEditorGeneralEvent::dontAssociateTime(bool noTime)
170{
171 timeStuffDisable(noTime);
172 //if(alarmButton->isChecked()) alarmStuffDisable(noTime);
173 allDayChanged(noTime);
174}
175
176void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end)
177{
178// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl;
179
180 mStartDateEdit->setDate(start.date());
181 // KTimeEdit seems to emit some signals when setTime() is called.
182 mStartTimeEdit->blockSignals( true );
183 mStartTimeEdit->setTime(start.time());
184 mStartTimeEdit->blockSignals( false );
185 mEndDateEdit->setDate(end.date());
186 mEndTimeEdit->setTime(end.time());
187
188 mCurrStartDateTime = start;
189 mCurrEndDateTime = end;
190
191 setDuration();
192 emitDateTimeStr();
193}
194
195void KOEditorGeneralEvent::startTimeChanged(QTime newtime)
196{
197 kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl;
198
199 int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime);
200
201 mCurrStartDateTime.setTime(newtime);
202
203 // adjust end time so that the event has the same duration as before.
204 mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep);
205 mEndTimeEdit->setTime(mCurrEndDateTime.time());
206 mEndDateEdit->setDate(mCurrEndDateTime.date());
207
208 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
209}
210
211void KOEditorGeneralEvent::endTimeChanged(QTime newtime)
212{
213// kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl;
214
215 QDateTime newdt(mCurrEndDateTime.date(), newtime);
216 mCurrEndDateTime = newdt;
217
218 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
219}
220
221void KOEditorGeneralEvent::startDateChanged(QDate newdate)
222{
223 int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime);
224
225 mCurrStartDateTime.setDate(newdate);
226
227 // adjust end date so that the event has the same duration as before
228 mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep));
229 mEndDateEdit->setDate(mCurrEndDateTime.date());
230
231 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
232}
233
234void KOEditorGeneralEvent::endDateChanged(QDate newdate)
235{
236 QDateTime newdt(newdate, mCurrEndDateTime.time());
237
238 if(newdt < mCurrStartDateTime) {
239 // oops, we can't let that happen.
240 newdt = mCurrStartDateTime;
241 mEndDateEdit->setDate(newdt.date());
242 mEndTimeEdit->setTime(newdt.time());
243 }
244 mCurrEndDateTime = newdt;
245
246 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
247}
248
249void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay)
250{
251 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
252 mLocationEdit->load(KOLocationBox::LOCATION);
253 KOEditorGeneral::setDefaults(allDay);
254
255 mNoTimeButton->setChecked(allDay);
256 timeStuffDisable(allDay);
257 mFreeTimeCombo->setCurrentItem( 0 );
258 setDateTimes(from,to);
259}
260
261void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl )
262{
263 QString tmpStr;
264
265 if ( !tmpl ) {
266 // the rest is for the events only
267 mNoTimeButton->setChecked(event->doesFloat());
268 timeStuffDisable(event->doesFloat());
269
270 setDateTimes(event->dtStart(),event->dtEnd());
271 }
272
273 switch( event->transparency() ) {
274 case Event::Transparent:
275 mFreeTimeCombo->setCurrentItem(1);
276 break;
277 case Event::Opaque:
278 mFreeTimeCombo->setCurrentItem(0);
279 break;
280 }
281
282 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
283 mLocationEdit->load(KOLocationBox::LOCATION);
284 readIncidence(event);
285}
286
287void KOEditorGeneralEvent::writeEvent(Event *event)
288{
289// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl;
290
291 writeIncidence(event);
292
293 QDate tmpDate;
294 QTime tmpTime;
295 QDateTime tmpDT;
296
297 // temp. until something better happens.
298 QString tmpStr;
299
300 if (mNoTimeButton->isChecked()) {
301 event->setFloats(true);
302 // need to change this.
303 tmpDate = mStartDateEdit->date();
304 tmpTime.setHMS(0,0,0);
305 tmpDT.setDate(tmpDate);
306 tmpDT.setTime(tmpTime);
307 event->setDtStart(tmpDT);
308
309 tmpDate = mEndDateEdit->date();
310 tmpTime.setHMS(0,0,0);
311 tmpDT.setDate(tmpDate);
312 tmpDT.setTime(tmpTime);
313 event->setDtEnd(tmpDT);
314 } else {
315 event->setFloats(false);
316
317 // set date/time end
318 tmpDate = mEndDateEdit->date();
319 tmpTime = mEndTimeEdit->getTime();
320 tmpDT.setDate(tmpDate);
321 tmpDT.setTime(tmpTime);
322 event->setDtEnd(tmpDT);
323
324 // set date/time start
325 tmpDate = mStartDateEdit->date();
326 tmpTime = mStartTimeEdit->getTime();
327 tmpDT.setDate(tmpDate);
328 tmpDT.setTime(tmpTime);
329 event->setDtStart(tmpDT);
330 } // check for float
331 mSummaryEdit->save(KOLocationBox::SUMMARYEVENT);
332
333 event->setTransparency(mFreeTimeCombo->currentItem() > 0
334 ? KCal::Event::Transparent
335 : KCal::Event::Opaque);
336
337// kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl;
338}
339
340void KOEditorGeneralEvent::setDuration()
341{
342 QString tmpStr = "", catStr;
343 int hourdiff, minutediff;
344 // end<date is an accepted temporary state while typing, but don't show
345 // any duration if this happens
346 if(mCurrEndDateTime >= mCurrStartDateTime) {
347
348 if (mNoTimeButton->isChecked()) {
349 int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1;
350 tmpStr = i18n("Duration: ");
351 tmpStr.append(i18n("1 Day","%n Days",daydiff));
352 } else {
353 int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime );
354 hourdiff = secto / 3600;
355 minutediff = (secto/60 ) % 60;
356 if (hourdiff || minutediff){
357 tmpStr = i18n("Duration: ");
358 if (hourdiff){
359 catStr = i18n("1 h","%n h",hourdiff);
360 tmpStr.append(catStr);
361 }
362 if (hourdiff && minutediff){
363 tmpStr += i18n(", ");
364 }
365 if (minutediff){
366 catStr = i18n("1 min","%n min",minutediff);
367 tmpStr += catStr;
368 }
369 } else tmpStr = "";
370 }
371 }
372 mDurationLabel->setText(tmpStr);
373}
374
375void KOEditorGeneralEvent::emitDateTimeStr()
376{
377 KLocale *l = KGlobal::locale();
378
379 QString from,to;
380 if (mNoTimeButton->isChecked()) {
381 from = l->formatDate(mCurrStartDateTime.date());
382 to = l->formatDate(mCurrEndDateTime.date());
383 } else {
384 from = l->formatDateTime(mCurrStartDateTime);
385 to = l->formatDateTime(mCurrEndDateTime);
386 }
387
388 QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to)
389 .arg(mDurationLabel->text());
390
391 emit dateTimeStrChanged(str);
392}
393
394bool KOEditorGeneralEvent::validateInput()
395{
396// kdDebug() << "KOEditorGeneralEvent::validateInput()" << endl;
397
398 if (!mNoTimeButton->isChecked()) {
399 if (!mStartTimeEdit->inputIsValid()) {
400 KMessageBox::sorry( 0,
401 i18n("Please specify a valid start time, for example '%1'.")
402 .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) );
403 return false;
404 }
405
406 if (!mEndTimeEdit->inputIsValid()) {
407 KMessageBox::sorry( 0,
408 i18n("Please specify a valid end time, for example '%1'.")
409 .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) );
410 return false;
411 }
412 }
413
414 if (!mStartDateEdit->inputIsValid()) {
415 KMessageBox::sorry( 0,
416 i18n("Please specify a valid start date, for example '%1'.")
417 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) );
418 return false;
419 }
420
421 if (!mEndDateEdit->inputIsValid()) {
422 KMessageBox::sorry( 0,
423 i18n("Please specify a valid end date, for example '%1'.")
424 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) );
425 return false;
426 }
427
428 QDateTime startDt,endDt;
429 startDt.setDate(mStartDateEdit->date());
430 endDt.setDate(mEndDateEdit->date());
431 if (!mNoTimeButton->isChecked()) {
432 startDt.setTime(mStartTimeEdit->getTime());
433 endDt.setTime(mEndTimeEdit->getTime());
434 }
435
436 if (startDt > endDt) {
437 KMessageBox::sorry(0,i18n("The event ends before it starts.\n"
438 "Please correct dates and times."));
439 return false;
440 }
441
442 return KOEditorGeneral::validateInput();
443}
diff --git a/korganizer/koeditorgeneralevent.h b/korganizer/koeditorgeneralevent.h
new file mode 100644
index 0000000..188dc93
--- a/dev/null
+++ b/korganizer/koeditorgeneralevent.h
@@ -0,0 +1,108 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOEDITORGENERALEVENT_H
24#define _KOEDITORGENERALEVENT_H
25
26#include <qframe.h>
27#include <qlabel.h>
28#include <qcheckbox.h>
29#include <qpushbutton.h>
30#include <qgroupbox.h>
31#include <qlineedit.h>
32#include <qcombobox.h>
33#include <qmultilineedit.h>
34#include <qlistview.h>
35#include <qradiobutton.h>
36
37#include <krestrictedline.h>
38
39#include "koeditorgeneral.h"
40
41#include "ktimeedit.h"
42
43class KDateEdit;
44
45using namespace KCal;
46
47class KOEditorGeneralEvent : public KOEditorGeneral
48{
49 Q_OBJECT
50 public:
51 KOEditorGeneralEvent (QObject* parent=0,const char* name=0);
52 virtual ~KOEditorGeneralEvent();
53
54 void initTime(QWidget *,QBoxLayout *);
55 void initClass(QWidget *,QBoxLayout *);
56
57 void finishSetup();
58
59 /** Set widgets to default values */
60 void setDefaults(QDateTime from,QDateTime to,bool allDay);
61 /**
62 Read event object and setup widgets accordingly. If templ is true, the
63 event is read as template, i.e. the time and date information isn't set.
64 */
65 void readEvent( Event *, bool tmpl = false );
66 /** Write event settings to event object */
67 void writeEvent(Event *);
68
69 /** Check if the input is valid. */
70 bool validateInput();
71
72 public slots:
73 void setDateTimes(QDateTime start, QDateTime end);
74 void setDuration();
75
76 protected slots:
77 void timeStuffDisable(bool disable);
78 void dontAssociateTime(bool noTime);
79
80 void startTimeChanged(QTime);
81 void startDateChanged(QDate);
82 void endTimeChanged(QTime);
83 void endDateChanged(QDate);
84
85 void emitDateTimeStr();
86
87 signals:
88 void dateTimesChanged(QDateTime start,QDateTime end);
89 void allDayChanged(bool);
90 void dateTimeStrChanged(const QString &);
91
92 private:
93 QLabel *mStartDateLabel;
94 QLabel *mEndDateLabel;
95 KDateEdit *mStartDateEdit;
96 KDateEdit *mEndDateEdit;
97 KOTimeEdit *mStartTimeEdit;
98 KOTimeEdit *mEndTimeEdit;
99 QLabel *mDurationLabel;
100 QCheckBox *mNoTimeButton;
101 QComboBox *mFreeTimeCombo;
102
103 // current start and end date and time
104 QDateTime mCurrStartDateTime;
105 QDateTime mCurrEndDateTime;
106};
107
108#endif
diff --git a/korganizer/koeditorgeneralevent.moc b/korganizer/koeditorgeneralevent.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeditorgeneralevent.moc
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
new file mode 100644
index 0000000..57837bb
--- a/dev/null
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -0,0 +1,467 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qtooltip.h>
25#include <qfiledialog.h>
26#include <qlayout.h>
27#include <qvbox.h>
28#include <qbuttongroup.h>
29#include <qvgroupbox.h>
30#include <qwidgetstack.h>
31#include <qdatetime.h>
32
33#include <kglobal.h>
34#include <klocale.h>
35#include <kiconloader.h>
36#include <kmessagebox.h>
37#include <kdebug.h>
38#include <krestrictedline.h>
39#include <kstandarddirs.h>
40#include <kfiledialog.h>
41
42#include <libkcal/todo.h>
43
44#include <libkdepim/kdateedit.h>
45
46#include "koprefs.h"
47#include "ktimeedit.h"
48
49#include "koeditorgeneraltodo.h"
50#include "kolocationbox.h"
51#include "koeditorgeneraltodo.moc"
52
53KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent,
54 const char* name)
55 : KOEditorGeneral( parent, name)
56{
57}
58
59KOEditorGeneralTodo::~KOEditorGeneralTodo()
60{
61}
62
63void KOEditorGeneralTodo::finishSetup()
64{
65
66// QWidget::setTabOrder(mSummaryEdit, mLocationEdit);
67// QWidget::setTabOrder(mLocationEdit, mDueCheck);
68// QWidget::setTabOrder(mDueCheck, mDueDateEdit);
69// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit);
70// QWidget::setTabOrder(mDueTimeEdit, mStartCheck);
71// QWidget::setTabOrder(mStartCheck, mStartDateEdit);
72// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit);
73// QWidget::setTabOrder(mStartTimeEdit, mTimeButton);
74// QWidget::setTabOrder(mTimeButton, mCompletedCombo);
75// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo);
76// QWidget::setTabOrder(mPriorityCombo, mAlarmButton);
77// QWidget::setTabOrder(mAlarmButton, mCategoriesButton);
78// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo);
79// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit);
80 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
81 mSummaryEdit->setFocus();
82}
83
84void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout)
85{
86 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
87
88 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
89 i18n("Date && Time"),parent);
90 timeLayout->addWidget(timeGroupBox);
91 timeGroupBox->layout()->setSpacing( 0 );
92 timeGroupBox->layout()->setMargin( 5 );
93 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
94
95 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3);
96 layoutTimeBox->setSpacing(topLayout->spacing());
97 layoutTimeBox->setColStretch( 1, 1 );
98
99 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame);
100 layoutTimeBox->addWidget(mDueCheck,0,0);
101 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool)));
102 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm()));
103
104
105 mDueDateEdit = new KDateEdit(timeBoxFrame);
106 layoutTimeBox->addWidget(mDueDateEdit,0,1);
107
108 mDueTimeEdit = new KOTimeEdit(timeBoxFrame);
109 layoutTimeBox->addWidget(mDueTimeEdit,0,2);
110
111
112 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame);
113 layoutTimeBox->addWidget(mStartCheck,1,0);
114 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool)));
115
116 mStartDateEdit = new KDateEdit(timeBoxFrame);
117 layoutTimeBox->addWidget(mStartDateEdit,1,1);
118
119 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
120 layoutTimeBox->addWidget(mStartTimeEdit,1,2);
121
122
123 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame);
124 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1);
125
126 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool)));
127
128 // some more layouting
129 //layoutTimeBox->setColStretch(3,1);
130}
131
132
133void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout)
134{
135 mCompletedCombo = new QComboBox(parent);
136 // xgettext:no-c-format
137 mCompletedCombo->insertItem(i18n(" 0 %"));
138 // xgettext:no-c-format
139 mCompletedCombo->insertItem(i18n(" 20 %"));
140 // xgettext:no-c-format
141 mCompletedCombo->insertItem(i18n(" 40 %"));
142 // xgettext:no-c-format
143 mCompletedCombo->insertItem(i18n(" 60 %"));
144 // xgettext:no-c-format
145 mCompletedCombo->insertItem(i18n(" 80 %"));
146 // xgettext:no-c-format
147 mCompletedCombo->insertItem(i18n("100 %"));
148 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int)));
149 topLayout->addWidget(mCompletedCombo);
150
151 mCompletedLabel = new QLabel(i18n("completed"),parent);
152 topLayout->addWidget(mCompletedLabel);
153}
154
155void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout)
156{
157
158 QHBox* h = new QHBox ( parent );
159 topLayout->addWidget( h );
160 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h);
161 // topLayout->addWidget(priorityLabel);
162
163 mPriorityCombo = new QComboBox( h );
164 mPriorityCombo->insertItem(i18n("1 (high)"));
165 mPriorityCombo->insertItem(i18n("2"));
166 mPriorityCombo->insertItem(i18n("3"));
167 mPriorityCombo->insertItem(i18n("4"));
168 mPriorityCombo->insertItem(i18n("5 (low)"));
169 //topLayout->addWidget(mPriorityCombo);
170}
171
172void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout)
173{
174 QBoxLayout *statusLayout = new QHBoxLayout(topLayout);
175
176 initCompletion( parent, statusLayout );
177
178 statusLayout->addStretch( 1 );
179
180 initPriority( parent, statusLayout );
181}
182
183void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
184{
185
186 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
187 mLocationEdit->load(KOLocationBox::LOCATION);
188 KOEditorGeneral::setDefaults(allDay);
189
190 mTimeButton->setChecked( !allDay );
191 if(mTimeButton->isChecked()) {
192 mTimeButton->setEnabled(true);
193 }
194 else {
195 mTimeButton->setEnabled(false);
196 }
197
198 enableTimeEdits( !allDay );
199
200 mDueCheck->setChecked(false);
201 enableDueEdit(false);
202
203 alarmDisable(true);
204
205 mStartCheck->setChecked(false);
206 enableStartEdit(false);
207
208 mDueDateEdit->setDate(due.date());
209 mDueTimeEdit->setTime(due.time());
210
211 mStartDateEdit->setDate(QDate::currentDate());
212 mStartTimeEdit->setTime(QTime::currentTime());
213
214 mPriorityCombo->setCurrentItem(2);
215 mCompletedLabel->setText(i18n("completed"));;
216 mCompletedCombo->setCurrentItem(0);
217}
218
219void KOEditorGeneralTodo::readTodo(Todo *todo)
220{
221
222 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
223 mLocationEdit->load(KOLocationBox::LOCATION);
224 KOEditorGeneral::readIncidence(todo);
225
226 QDateTime dueDT;
227
228 if (todo->hasDueDate()) {
229 enableAlarmEdit(true);
230 dueDT = todo->dtDue();
231 mDueDateEdit->setDate(todo->dtDue().date());
232 mDueTimeEdit->setTime(todo->dtDue().time());
233 mDueCheck->setChecked(true);
234 } else {
235 alarmDisable(true);
236 mDueDateEdit->setEnabled(false);
237 mDueTimeEdit->setEnabled(false);
238 mDueDateEdit->setDate(QDate::currentDate());
239 mDueTimeEdit->setTime(QTime::currentTime());
240 mDueCheck->setChecked(false);
241 }
242
243 if (todo->hasStartDate()) {
244 mStartDateEdit->setDate(todo->dtStart().date());
245 mStartTimeEdit->setTime(todo->dtStart().time());
246 mStartCheck->setChecked(true);
247 } else {
248 mStartDateEdit->setEnabled(false);
249 mStartTimeEdit->setEnabled(false);
250 mStartDateEdit->setDate(QDate::currentDate());
251 mStartTimeEdit->setTime(QTime::currentTime());
252 mStartCheck->setChecked(false);
253 }
254
255 mTimeButton->setChecked( !todo->doesFloat() );
256
257 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
258 if (todo->isCompleted() && todo->hasCompletedDate()) {
259 mCompleted = todo->completed();
260 }
261 setCompletedDate();
262
263 mPriorityCombo->setCurrentItem(todo->priority()-1);
264}
265
266void KOEditorGeneralTodo::writeTodo(Todo *todo)
267{
268 KOEditorGeneral::writeIncidence(todo);
269
270 // temp. until something better happens.
271 QString tmpStr;
272
273 todo->setHasDueDate(mDueCheck->isChecked());
274 todo->setHasStartDate(mStartCheck->isChecked());
275
276 QDate tmpDate;
277 QTime tmpTime;
278 QDateTime tmpDT;
279 if ( mTimeButton->isChecked() ) {
280 todo->setFloats(false);
281
282 // set due date/time
283 tmpDate = mDueDateEdit->date();
284 tmpTime = mDueTimeEdit->getTime();
285 tmpDT.setDate(tmpDate);
286 tmpDT.setTime(tmpTime);
287 todo->setDtDue(tmpDT);
288
289 // set start date/time
290 tmpDate = mStartDateEdit->date();
291 tmpTime = mStartTimeEdit->getTime();
292 tmpDT.setDate(tmpDate);
293 tmpDT.setTime(tmpTime);
294 todo->setDtStart(tmpDT);
295 } else {
296 todo->setFloats(true);
297
298 // need to change this.
299 tmpDate = mDueDateEdit->date();
300 tmpTime.setHMS(0,0,0);
301 tmpDT.setDate(tmpDate);
302 tmpDT.setTime(tmpTime);
303 todo->setDtDue(tmpDT);
304
305 tmpDate = mStartDateEdit->date();
306 tmpTime.setHMS(0,0,0);
307 tmpDT.setDate(tmpDate);
308 tmpDT.setTime(tmpTime);
309 todo->setDtStart(tmpDT);
310 }
311
312 todo->setPriority(mPriorityCombo->currentItem()+1);
313
314 // set completion state
315 todo->setPercentComplete(mCompletedCombo->currentItem() * 20);
316
317 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) {
318 todo->setCompleted(mCompleted);
319 }
320 mSummaryEdit->save(KOLocationBox::SUMMARYTODO);
321}
322
323void KOEditorGeneralTodo::enableDueEdit(bool enable)
324{
325 mDueDateEdit->setEnabled( enable );
326
327 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
328 mTimeButton->setEnabled(true);
329 }
330 else {
331 mTimeButton->setEnabled(false);
332 mTimeButton->setChecked(false);
333 }
334
335 if (enable) {
336 mDueTimeEdit->setEnabled( mTimeButton->isChecked() );
337 } else {
338 mDueTimeEdit->setEnabled( false );
339 }
340}
341
342void KOEditorGeneralTodo::enableStartEdit( bool enable )
343{
344 mStartDateEdit->setEnabled( enable );
345
346 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
347 mTimeButton->setEnabled(true);
348 }
349 else {
350 mTimeButton->setEnabled(false);
351 mTimeButton->setChecked(false);
352 }
353
354 if (enable) {
355 mStartTimeEdit->setEnabled( mTimeButton->isChecked() );
356 } else {
357 mStartTimeEdit->setEnabled( false );
358 }
359}
360
361void KOEditorGeneralTodo::enableTimeEdits(bool enable)
362{
363 if(mStartCheck->isChecked()) {
364 mStartTimeEdit->setEnabled( enable );
365 }
366 if(mDueCheck->isChecked()) {
367 mDueTimeEdit->setEnabled( enable );
368 }
369}
370
371void KOEditorGeneralTodo::showAlarm()
372{
373 if ( mDueCheck->isChecked() ) {
374 alarmDisable(false);
375 }
376 else {
377 alarmDisable(true);
378 }
379}
380
381bool KOEditorGeneralTodo::validateInput()
382{
383 if (mDueCheck->isChecked()) {
384 if (!mDueDateEdit->inputIsValid()) {
385 KMessageBox::sorry(0,i18n("Please specify a valid due date."));
386 return false;
387 }
388 if (mTimeButton->isChecked()) {
389 if (!mDueTimeEdit->inputIsValid()) {
390 KMessageBox::sorry(0,i18n("Please specify a valid due time."));
391 return false;
392 }
393 }
394 }
395
396 if (mStartCheck->isChecked()) {
397 if (!mStartDateEdit->inputIsValid()) {
398 KMessageBox::sorry(0,i18n("Please specify a valid start date."));
399 return false;
400 }
401 if (mTimeButton->isChecked()) {
402 if (!mStartTimeEdit->inputIsValid()) {
403 KMessageBox::sorry(0,i18n("Please specify a valid start time."));
404 return false;
405 }
406 }
407 }
408
409 if (mStartCheck->isChecked() && mDueCheck->isChecked()) {
410 QDateTime startDate;
411 QDateTime dueDate;
412 startDate.setDate(mStartDateEdit->date());
413 dueDate.setDate(mDueDateEdit->date());
414 if (mTimeButton->isChecked()) {
415 startDate.setTime(mStartTimeEdit->getTime());
416 dueDate.setTime(mDueTimeEdit->getTime());
417 }
418 if (startDate > dueDate) {
419 KMessageBox::sorry(0,
420 i18n("The start date cannot be after the due date."));
421 return false;
422 }
423 }
424
425 return KOEditorGeneral::validateInput();
426}
427
428void KOEditorGeneralTodo::completedChanged(int index)
429{
430 if (index == 5) {
431 mCompleted = QDateTime::currentDateTime();
432 }
433 setCompletedDate();
434}
435
436void KOEditorGeneralTodo::setCompletedDate()
437{
438 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) {
439 mCompletedLabel->setText(i18n("completed on %1")
440 .arg(KGlobal::locale()->formatDateTime(mCompleted)));
441 } else {
442 mCompletedLabel->setText(i18n("completed"));
443 }
444}
445
446void KOEditorGeneralTodo::modified (Todo* todo, int modification)
447{
448 switch (modification) {
449 case KOGlobals::PRIORITY_MODIFIED:
450 mPriorityCombo->setCurrentItem(todo->priority()-1);
451 break;
452 case KOGlobals::COMPLETION_MODIFIED:
453 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
454 if (todo->isCompleted() && todo->hasCompletedDate()) {
455 mCompleted = todo->completed();
456 }
457 setCompletedDate();
458 break;
459 case KOGlobals::CATEGORY_MODIFIED:
460 setCategories (todo->categoriesStr ());
461 break;
462 case KOGlobals::UNKNOWN_MODIFIED: // fall through
463 default:
464 readTodo( todo );
465 break;
466 }
467}
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h
new file mode 100644
index 0000000..f6c30f8
--- a/dev/null
+++ b/korganizer/koeditorgeneraltodo.h
@@ -0,0 +1,105 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOEDITORGENERALTODO_H
24#define _KOEDITORGENERALTODO_H
25
26#include <qframe.h>
27#include <qlabel.h>
28#include <qcheckbox.h>
29#include <qpushbutton.h>
30#include <qgroupbox.h>
31#include <qlineedit.h>
32#include <qcombobox.h>
33#include <qmultilineedit.h>
34#include <qlistview.h>
35#include <qradiobutton.h>
36
37#include "koeditorgeneral.h"
38#include "koglobals.h"
39
40class KRestrictedLine;
41
42class KDateEdit;
43
44using namespace KCal;
45
46class KOEditorGeneralTodo : public KOEditorGeneral
47{
48 Q_OBJECT
49 public:
50 KOEditorGeneralTodo (QObject* parent=0,const char* name=0);
51 virtual ~KOEditorGeneralTodo();
52
53 void initTime(QWidget *, QBoxLayout *);
54 void initStatus(QWidget *, QBoxLayout *);
55 void initCompletion(QWidget *, QBoxLayout *);
56 void initPriority(QWidget *, QBoxLayout *);
57
58 void finishSetup();
59
60 /** Set widgets to default values */
61 void setDefaults(QDateTime due,bool allDay);
62 /** Read todo object and setup widgets accordingly */
63 void readTodo(Todo *);
64 /** Write todo settings to event object */
65 void writeTodo(Todo *);
66
67 /** Check if the input is valid. */
68 bool validateInput();
69
70 /** The todo has been modified externally */
71 void modified (Todo*, int);
72
73 signals:
74 void openCategoryDialog();
75
76 protected slots:
77 void completedChanged(int);
78
79 void enableDueEdit( bool enable );
80 void enableStartEdit( bool enable );
81 void enableTimeEdits( bool enable );
82 void showAlarm();
83
84 protected:
85 void setCompletedDate();
86
87 private:
88 KDateEdit *mStartDateEdit;
89 KOTimeEdit *mStartTimeEdit;
90 QCheckBox *mTimeButton;
91 QCheckBox *mDueCheck;
92 KDateEdit *mDueDateEdit;
93 KOTimeEdit *mDueTimeEdit;
94 QComboBox *mCompletedCombo;
95 QLabel *mCompletedLabel;
96 QLabel *mPriorityLabel;
97 QComboBox *mPriorityCombo;
98
99 QCheckBox *mStartCheck;
100
101 QDateTime mCompleted;
102};
103
104
105#endif
diff --git a/korganizer/koeditorgeneraltodo.moc b/korganizer/koeditorgeneraltodo.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeditorgeneraltodo.moc
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
new file mode 100644
index 0000000..d82172f
--- a/dev/null
+++ b/korganizer/koeditorrecurrence.cpp
@@ -0,0 +1,1117 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qtooltip.h>
25#include <qfiledialog.h>
26#include <qlayout.h>
27#include <qvbox.h>
28#include <qbuttongroup.h>
29#include <qvgroupbox.h>
30#include <qwidgetstack.h>
31#include <qdatetime.h>
32#include <qlistbox.h>
33#include <qspinbox.h>
34#include <qcheckbox.h>
35#include <qapplication.h>
36
37#include <kdialog.h>
38#include <kglobal.h>
39#include <klocale.h>
40#include <kiconloader.h>
41#include <kdebug.h>
42#include <knumvalidator.h>
43
44#include <libkcal/event.h>
45
46#include <libkdepim/kdateedit.h>
47
48#include "koprefs.h"
49
50#include "koeditorrecurrence.h"
51#include "koeditorrecurrence.moc"
52
53/////////////////////////// RecurBase ///////////////////////////////
54
55RecurBase::RecurBase( QWidget *parent, const char *name ) :
56 QWidget( parent, name )
57{
58 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this );
59 mFrequencyEdit->setValue( 1 );
60}
61
62QWidget *RecurBase::frequencyEdit()
63{
64 return mFrequencyEdit;
65}
66
67void RecurBase::setFrequency( int f )
68{
69 if ( f < 1 ) f = 1;
70
71 mFrequencyEdit->setValue( f );
72}
73
74int RecurBase::frequency()
75{
76 return mFrequencyEdit->value();
77}
78
79/////////////////////////// RecurDaily ///////////////////////////////
80
81RecurDaily::RecurDaily( QWidget *parent, const char *name ) :
82 RecurBase( parent, name )
83{
84 QBoxLayout *topLayout = new QHBoxLayout( this );
85 topLayout->setSpacing( KDialog::spacingHint() );
86
87 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
88 topLayout->addWidget( preLabel );
89
90 topLayout->addWidget( frequencyEdit() );
91
92 QLabel *postLabel = new QLabel( i18n("day(s)"), this );
93 topLayout->addWidget( postLabel );
94}
95
96
97/////////////////////////// RecurWeekly ///////////////////////////////
98
99RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) :
100 RecurBase( parent, name )
101{
102 QBoxLayout *topLayout = new QVBoxLayout( this );
103 topLayout->setSpacing( KDialog::spacingHint() );
104
105 topLayout->addStretch( 1 );
106
107 QBoxLayout *weeksLayout = new QHBoxLayout( topLayout );
108
109 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
110 weeksLayout->addWidget( preLabel );
111
112 weeksLayout->addWidget( frequencyEdit() );
113
114 QLabel *postLabel = new QLabel( i18n("week(s) on:"), this );
115 weeksLayout->addWidget( postLabel );
116
117 QHBox *dayBox = new QHBox( this );
118 topLayout->addWidget( dayBox, 1, AlignVCenter );
119 // TODO: Respect start of week setting
120 for ( int i = 0; i < 7; ++i ) {
121 QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true );
122 if ( KOPrefs::instance()->mCompactDialogs ) {
123 weekDayName = weekDayName.left( 1 );
124 }
125 mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox );
126 }
127
128 topLayout->addStretch( 1 );
129}
130
131void RecurWeekly::setDays( const QBitArray &days )
132{
133 for ( int i = 0; i < 7; ++i ) {
134 mDayBoxes[ i ]->setChecked( days.testBit( i ) );
135 }
136}
137
138QBitArray RecurWeekly::days()
139{
140 QBitArray days( 7 );
141
142 for ( int i = 0; i < 7; ++i ) {
143 days.setBit( i, mDayBoxes[ i ]->isChecked() );
144 }
145
146 return days;
147}
148
149/////////////////////////// RecurMonthly ///////////////////////////////
150
151RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) :
152 RecurBase( parent, name )
153{
154 QBoxLayout *topLayout = new QVBoxLayout( this );
155 topLayout->setSpacing( KDialog::spacingHint() );
156
157
158 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
159
160 QLabel *preLabel = new QLabel( i18n("every"), this );
161 freqLayout->addWidget( preLabel );
162
163 freqLayout->addWidget( frequencyEdit() );
164
165 QLabel *postLabel = new QLabel( i18n("month(s)"), this );
166 freqLayout->addWidget( postLabel );
167
168
169 QButtonGroup *buttonGroup = new QButtonGroup( this );
170 buttonGroup->setFrameStyle( QFrame::NoFrame );
171 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
172
173 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
174 buttonLayout->setSpacing( KDialog::spacingHint() );
175
176
177 QString recurOnText;
178 if ( !KOPrefs::instance()->mCompactDialogs ) {
179 recurOnText = i18n("Recur on the");
180 }
181
182 mByDayRadio = new QRadioButton( recurOnText, buttonGroup );
183 buttonLayout->addWidget( mByDayRadio, 0, 0 );
184
185 mByDayCombo = new QComboBox( buttonGroup );
186 mByDayCombo->setSizeLimit( 7 );
187 mByDayCombo->insertItem( i18n("1st") );
188 mByDayCombo->insertItem( i18n("2nd") );
189 mByDayCombo->insertItem( i18n("3rd") );
190 mByDayCombo->insertItem( i18n("4th") );
191 mByDayCombo->insertItem( i18n("5th") );
192 mByDayCombo->insertItem( i18n("6th") );
193 mByDayCombo->insertItem( i18n("7th") );
194 mByDayCombo->insertItem( i18n("8th") );
195 mByDayCombo->insertItem( i18n("9th") );
196 mByDayCombo->insertItem( i18n("10th") );
197 mByDayCombo->insertItem( i18n("11th") );
198 mByDayCombo->insertItem( i18n("12th") );
199 mByDayCombo->insertItem( i18n("13th") );
200 mByDayCombo->insertItem( i18n("14th") );
201 mByDayCombo->insertItem( i18n("15th") );
202 mByDayCombo->insertItem( i18n("16th") );
203 mByDayCombo->insertItem( i18n("17th") );
204 mByDayCombo->insertItem( i18n("18th") );
205 mByDayCombo->insertItem( i18n("19th") );
206 mByDayCombo->insertItem( i18n("20th") );
207 mByDayCombo->insertItem( i18n("21st") );
208 mByDayCombo->insertItem( i18n("22nd") );
209 mByDayCombo->insertItem( i18n("23rd") );
210 mByDayCombo->insertItem( i18n("24th") );
211 mByDayCombo->insertItem( i18n("25th") );
212 mByDayCombo->insertItem( i18n("26th") );
213 mByDayCombo->insertItem( i18n("27th") );
214 mByDayCombo->insertItem( i18n("28th") );
215 mByDayCombo->insertItem( i18n("29th") );
216 mByDayCombo->insertItem( i18n("30th") );
217 mByDayCombo->insertItem( i18n("31st") );
218 buttonLayout->addWidget( mByDayCombo, 0, 1 );
219
220 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup );
221 buttonLayout->addWidget( byDayLabel, 0, 2 );
222
223
224 mByPosRadio = new QRadioButton( recurOnText, buttonGroup);
225 buttonLayout->addWidget( mByPosRadio, 1, 0 );
226
227 mByPosCountCombo = new QComboBox( buttonGroup );
228 mByPosCountCombo->insertItem( i18n("1st") );
229 mByPosCountCombo->insertItem( i18n("2nd") );
230 mByPosCountCombo->insertItem( i18n("3rd") );
231 mByPosCountCombo->insertItem( i18n("4th") );
232 mByPosCountCombo->insertItem( i18n("5th") );
233 buttonLayout->addWidget( mByPosCountCombo, 1, 1 );
234
235 mByPosWeekdayCombo = new QComboBox( buttonGroup );
236 mByPosWeekdayCombo->insertItem( i18n("Monday") );
237 mByPosWeekdayCombo->insertItem( i18n("Tuesday") );
238 mByPosWeekdayCombo->insertItem( i18n("Wednesday") );
239 mByPosWeekdayCombo->insertItem( i18n("Thursday") );
240 mByPosWeekdayCombo->insertItem( i18n("Friday") );
241 mByPosWeekdayCombo->insertItem( i18n("Saturday") );
242 mByPosWeekdayCombo->insertItem( i18n("Sunday") );
243 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 );
244}
245
246void RecurMonthly::setByDay( int day )
247{
248 mByDayRadio->setChecked( true );
249 mByDayCombo->setCurrentItem( day );
250}
251
252void RecurMonthly::setByPos( int count, int weekday )
253{
254 mByPosRadio->setChecked( true );
255 mByPosCountCombo->setCurrentItem( count );
256 mByPosWeekdayCombo->setCurrentItem( weekday );
257}
258
259bool RecurMonthly::byDay()
260{
261 return mByDayRadio->isChecked();
262}
263
264bool RecurMonthly::byPos()
265{
266 return mByPosRadio->isChecked();
267}
268
269int RecurMonthly::day()
270{
271 return mByDayCombo->currentItem() + 1;
272}
273
274int RecurMonthly::count()
275{
276 return mByPosCountCombo->currentItem() + 1;
277}
278
279int RecurMonthly::weekday()
280{
281 return mByPosWeekdayCombo->currentItem();
282}
283
284/////////////////////////// RecurYearly ///////////////////////////////
285
286RecurYearly::RecurYearly( QWidget *parent, const char *name ) :
287 RecurBase( parent, name )
288{
289 QBoxLayout *topLayout = new QVBoxLayout( this );
290 topLayout->setSpacing( KDialog::spacingHint() );
291
292
293 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
294
295 QLabel *preLabel = new QLabel( i18n("every"), this );
296 freqLayout->addWidget( preLabel );
297
298 freqLayout->addWidget( frequencyEdit() );
299
300 QLabel *postLabel = new QLabel( i18n("year(s)"), this );
301 freqLayout->addWidget( postLabel );
302
303
304 QButtonGroup *buttonGroup = new QButtonGroup( this );
305 buttonGroup->setFrameStyle( QFrame::NoFrame );
306 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
307
308 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
309
310 QString recurInMonthText;
311 if ( !KOPrefs::instance()->mCompactDialogs ) {
312 recurInMonthText = i18n("Recur in the month of");
313 }
314
315 mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup);
316 buttonLayout->addWidget( mByMonthRadio, 0, 0 );
317
318 mByMonthCombo = new QComboBox( buttonGroup );
319 mByMonthCombo->insertItem( i18n("January") );
320 mByMonthCombo->insertItem( i18n("February") );
321 mByMonthCombo->insertItem( i18n("March") );
322 mByMonthCombo->insertItem( i18n("April") );
323 mByMonthCombo->insertItem( i18n("May") );
324 mByMonthCombo->insertItem( i18n("June") );
325 mByMonthCombo->insertItem( i18n("July") );
326 mByMonthCombo->insertItem( i18n("August") );
327 mByMonthCombo->insertItem( i18n("September") );
328 mByMonthCombo->insertItem( i18n("October") );
329 mByMonthCombo->insertItem( i18n("November") );
330 mByMonthCombo->insertItem( i18n("December") );
331 buttonLayout->addWidget( mByMonthCombo, 0, 1 );
332
333 mByMonthCombo->setSizeLimit( 6 );
334
335 buttonLayout->setRowStretch( 1, 1 );
336
337 QString recurOnDayText;
338 if ( KOPrefs::instance()->mCompactDialogs ) {
339 recurOnDayText = i18n("This day");
340 } else {
341 recurOnDayText = i18n("Recur on this day");
342 }
343
344 mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup);
345 buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 );
346}
347
348void RecurYearly::setByDay()
349{
350 mByDayRadio->setChecked( true );
351}
352
353void RecurYearly::setByMonth( int month )
354{
355 mByMonthRadio->setChecked( true );
356 mByMonthCombo->setCurrentItem( month - 1 );
357}
358
359bool RecurYearly::byMonth()
360{
361 return mByMonthRadio->isChecked();
362}
363
364bool RecurYearly::byDay()
365{
366 return mByDayRadio->isChecked();
367}
368
369int RecurYearly::month()
370{
371 return mByMonthCombo->currentItem() + 1;
372}
373
374//////////////////////////// ExceptionsWidget //////////////////////////
375
376ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) :
377 QWidget( parent, name )
378{
379 QBoxLayout *topLayout = new QVBoxLayout( this );
380
381 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"),
382 this );
383 topLayout->addWidget( groupBox );
384
385 QWidget *box = new QWidget( groupBox );
386
387 QGridLayout *boxLayout = new QGridLayout( box );
388
389 mExceptionDateEdit = new KDateEdit( box );
390 boxLayout->addWidget( mExceptionDateEdit, 0, 0 );
391
392 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box );
393 boxLayout->addWidget( addExceptionButton, 1, 0 );
394 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box );
395 boxLayout->addWidget( changeExceptionButton, 2, 0 );
396 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box );
397 boxLayout->addWidget( deleteExceptionButton, 3, 0 );
398
399 mExceptionList = new QListBox( box );
400 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 );
401
402 boxLayout->setRowStretch( 4, 1 );
403 boxLayout->setColStretch( 1, 3 );
404
405 connect( addExceptionButton, SIGNAL( clicked() ),
406 SLOT( addException() ) );
407 connect( changeExceptionButton, SIGNAL( clicked() ),
408 SLOT( changeException() ) );
409 connect( deleteExceptionButton, SIGNAL( clicked() ),
410 SLOT( deleteException() ) );
411 if ( QApplication::desktop()->width() < 480 ) {
412 setMinimumWidth( 220 );
413 } else {
414 setMinimumWidth( 440 );
415 mExceptionDateEdit->setMinimumWidth( 200 );
416 }
417}
418
419void ExceptionsWidget::setDefaults( const QDateTime &from )
420{
421 mExceptionDateEdit->setDate( from.date() );
422}
423
424void ExceptionsWidget::addException()
425{
426 QDate date = mExceptionDateEdit->date();
427 QString dateStr = KGlobal::locale()->formatDate( date );
428 if( !mExceptionList->findItem( dateStr ) ) {
429 mExceptionDates.append( date );
430 mExceptionList->insertItem( dateStr );
431 }
432}
433
434void ExceptionsWidget::changeException()
435{
436 int pos = mExceptionList->currentItem();
437 if ( pos < 0 ) return;
438
439 QDate date = mExceptionDateEdit->date();
440 mExceptionDates[ pos ] = date;
441 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
442}
443
444void ExceptionsWidget::deleteException()
445{
446 int pos = mExceptionList->currentItem();
447 if ( pos < 0 ) return;
448
449 mExceptionDates.remove( mExceptionDates.at( pos ) );
450 mExceptionList->removeItem( pos );
451}
452
453void ExceptionsWidget::setDates( const DateList &dates )
454{
455 mExceptionList->clear();
456 mExceptionDates.clear();
457 DateList::ConstIterator dit;
458 for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
459 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
460 mExceptionDates.append( *dit );
461 }
462}
463
464DateList ExceptionsWidget::dates()
465{
466 return mExceptionDates;
467}
468
469///////////////////////// ExceptionsDialog ///////////////////////////
470
471ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
472 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel )
473{
474 mExceptions = new ExceptionsWidget( this );
475 setMainWidget( mExceptions );
476 resize(220,10);
477}
478
479void ExceptionsDialog::setDefaults( const QDateTime &from )
480{
481 mExceptions->setDefaults( from );
482}
483
484void ExceptionsDialog::setDates( const DateList &dates )
485{
486 mExceptions->setDates( dates );
487}
488
489DateList ExceptionsDialog::dates()
490{
491 return mExceptions->dates();
492}
493
494///////////////////////// RecurrenceRangeWidget ///////////////////////////
495
496RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
497 const char *name )
498 : QWidget( parent, name )
499{
500 QBoxLayout *topLayout = new QVBoxLayout( this );
501
502 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
503 this );
504 topLayout->addWidget( mRangeGroupBox );
505
506 QWidget *rangeBox = new QWidget( mRangeGroupBox );
507 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
508 rangeLayout->setSpacing( KDialog::spacingHint() );
509
510 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
511 rangeLayout->addWidget( mStartDateLabel );
512
513 QButtonGroup *rangeButtonGroup = new QButtonGroup;
514
515 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox );
516 rangeButtonGroup->insert( mNoEndDateButton );
517 rangeLayout->addWidget( mNoEndDateButton );
518
519 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
520 durationLayout->setSpacing( KDialog::spacingHint() );
521
522 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox );
523 rangeButtonGroup->insert( mEndDurationButton );
524 durationLayout->addWidget( mEndDurationButton );
525
526 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
527 durationLayout->addWidget( mEndDurationEdit );
528
529 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox );
530 durationLayout ->addWidget( endDurationLabel );
531
532 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
533 endDateLayout->setSpacing( KDialog::spacingHint() );
534
535 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox );
536 rangeButtonGroup->insert( mEndDateButton );
537 endDateLayout->addWidget( mEndDateButton );
538
539 mEndDateEdit = new KDateEdit( rangeBox );
540 endDateLayout->addWidget( mEndDateEdit );
541
542 endDateLayout->addStretch( 1 );
543
544 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
545 SLOT( showCurrentRange() ) );
546 connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
547 SLOT( showCurrentRange() ) );
548 connect( mEndDateButton, SIGNAL( toggled( bool ) ),
549 SLOT( showCurrentRange() ) );
550}
551
552void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
553{
554 mNoEndDateButton->setChecked( true );
555
556 setDateTimes( from );
557 mEndDateEdit->setDate( from.date() );
558}
559
560void RecurrenceRangeWidget::setDuration( int duration )
561{
562 if ( duration == -1 ) {
563 mNoEndDateButton->setChecked( true );
564 } else if ( duration == 0 ) {
565 mEndDateButton->setChecked( true );
566 } else {
567 mEndDurationButton->setChecked( true );
568 mEndDurationEdit->setValue( duration );
569 }
570}
571
572int RecurrenceRangeWidget::duration()
573{
574 if ( mNoEndDateButton->isChecked() ) {
575 return -1;
576 } else if ( mEndDurationButton->isChecked() ) {
577 return mEndDurationEdit->value();
578 } else {
579 return 0;
580 }
581}
582
583void RecurrenceRangeWidget::setEndDate( const QDate &date )
584{
585 mEndDateEdit->setDate( date );
586}
587
588QDate RecurrenceRangeWidget::endDate()
589{
590 return mEndDateEdit->date();
591}
592
593void RecurrenceRangeWidget::showCurrentRange()
594{
595 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
596 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
597}
598
599void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
600 const QDateTime & )
601{
602 mStartDateLabel->setText( i18n("Start date: %1")
603 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
604
605 if(!mEndDateButton->isChecked())
606 mEndDateEdit->setDate( start.date() );
607}
608
609///////////////////////// RecurrenceRangeDialog ///////////////////////////
610
611RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
612 const char *name ) :
613 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
614{
615 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
616 setMainWidget( mRecurrenceRangeWidget );
617}
618
619void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
620{
621 mRecurrenceRangeWidget->setDefaults( from );
622}
623
624void RecurrenceRangeDialog::setDuration( int duration )
625{
626 mRecurrenceRangeWidget->setDuration( duration );
627}
628
629int RecurrenceRangeDialog::duration()
630{
631 return mRecurrenceRangeWidget->duration();
632}
633
634void RecurrenceRangeDialog::setEndDate( const QDate &date )
635{
636 mRecurrenceRangeWidget->setEndDate( date );
637}
638
639QDate RecurrenceRangeDialog::endDate()
640{
641 return mRecurrenceRangeWidget->endDate();
642}
643
644void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
645 const QDateTime &end )
646{
647 mRecurrenceRangeWidget->setDateTimes( start, end );
648}
649
650//////////////////////////// RecurrenceChooser ////////////////////////
651
652RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) :
653 QWidget( parent, name )
654{
655 QBoxLayout *topLayout = new QVBoxLayout( this );
656
657 if ( KOPrefs::instance()->mCompactDialogs ) {
658 mTypeCombo = new QComboBox( this );
659 mTypeCombo->insertItem( i18n("Daily") );
660 mTypeCombo->insertItem( i18n("Weekly") );
661 mTypeCombo->insertItem( i18n("Monthly") );
662 mTypeCombo->insertItem( i18n("Yearly") );
663
664 topLayout->addWidget( mTypeCombo );
665
666 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) );
667 } else {
668 mTypeCombo = 0;
669
670 QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this );
671 ruleButtonGroup->setFrameStyle( QFrame::NoFrame );
672 topLayout->addWidget( ruleButtonGroup );
673
674 mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup );
675 mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup );
676 mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup );
677 mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup );
678
679 connect( mDailyButton, SIGNAL( toggled( bool ) ),
680 SLOT( emitChoice() ) );
681 connect( mWeeklyButton, SIGNAL( toggled( bool ) ),
682 SLOT( emitChoice() ) );
683 connect( mMonthlyButton, SIGNAL( toggled( bool ) ),
684 SLOT( emitChoice() ) );
685 connect( mYearlyButton, SIGNAL( toggled( bool ) ),
686 SLOT( emitChoice() ) );
687 }
688}
689
690int RecurrenceChooser::type()
691{
692 if ( mTypeCombo ) {
693 return mTypeCombo->currentItem();
694 } else {
695 if ( mDailyButton->isChecked() ) return Daily;
696 else if ( mWeeklyButton->isChecked() ) return Weekly;
697 else if ( mMonthlyButton->isChecked() ) return Monthly;
698 else return Yearly;
699 }
700}
701
702void RecurrenceChooser::setType( int type )
703{
704 if ( mTypeCombo ) {
705 mTypeCombo->setCurrentItem( type );
706 } else {
707 switch ( type ) {
708 case Daily:
709 mDailyButton->setChecked( true );
710 break;
711 case Weekly:
712 mWeeklyButton->setChecked( true );
713 break;
714 case Monthly:
715 mMonthlyButton->setChecked( true );
716 break;
717 case Yearly:
718 default:
719 mYearlyButton->setChecked( true );
720 break;
721 }
722 }
723}
724
725void RecurrenceChooser::emitChoice()
726{
727 emit chosen ( type() );
728}
729
730/////////////////////////////// Main Widget /////////////////////////////
731
732KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
733 QWidget( parent, name )
734{
735 QGridLayout *topLayout = new QGridLayout( this, 2,2 );
736 topLayout->setSpacing( KDialog::spacingHint() );
737
738 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this );
739 connect( mEnabledCheck, SIGNAL( toggled( bool ) ),
740 SLOT( setEnabled( bool ) ) );
741 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
742
743
744 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "),
745 this );
746 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
747
748 if ( KOPrefs::instance()->mCompactDialogs ) {
749 mTimeGroupBox->hide();
750 }
751
752// QFrame *timeFrame = new QFrame( mTimeGroupBox );
753// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame );
754// layoutTimeFrame->setSpacing( KDialog::spacingHint() );
755
756 mDateTimeLabel = new QLabel( mTimeGroupBox );
757// mDateTimeLabel = new QLabel( timeFrame );
758// layoutTimeFrame->addWidget( mDateTimeLabel );
759
760 Qt::Orientation orientation;
761 if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal;
762 else orientation = Vertical;
763
764 mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this );
765 if ( KOPrefs::instance()->mCompactDialogs ) {
766 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
767 } else {
768 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
769 }
770
771 mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
772 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
773 SLOT( showCurrentRule( int ) ) );
774
775 if ( !KOPrefs::instance()->mCompactDialogs ) {
776 QFrame *ruleSepFrame = new QFrame( mRuleBox );
777 ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken );
778 }
779
780 mRuleStack = new QWidgetStack( mRuleBox );
781
782 mDaily = new RecurDaily( mRuleStack );
783 mRuleStack->addWidget( mDaily, 0 );
784
785 mWeekly = new RecurWeekly( mRuleStack );
786 mRuleStack->addWidget( mWeekly, 0 );
787
788 mMonthly = new RecurMonthly( mRuleStack );
789 mRuleStack->addWidget( mMonthly, 0 );
790
791 mYearly = new RecurYearly( mRuleStack );
792 mRuleStack->addWidget( mYearly, 0 );
793
794 showCurrentRule( mRecurrenceChooser->type() );
795
796 if ( KOPrefs::instance()->mCompactDialogs ) {
797 mRecurrenceRangeWidget = 0;
798 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
799 mRecurrenceRange = mRecurrenceRangeDialog;
800 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
801 this );
802
803 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
804 SLOT( showRecurrenceRangeDialog() ) );
805
806 mExceptionsWidget = 0;
807 mExceptionsDialog = new ExceptionsDialog( this );
808 mExceptions = mExceptionsDialog;
809 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
810 if ( QApplication::desktop()->width() < 320 ) {
811 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 );
812 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 );
813 } else {
814 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
815 topLayout->addWidget( mExceptionsButton, 3, 1 );
816 }
817 connect( mExceptionsButton, SIGNAL( clicked() ),
818 SLOT( showExceptionsDialog() ) );
819
820 } else {
821 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
822 mRecurrenceRangeDialog = 0;
823 mRecurrenceRange = mRecurrenceRangeWidget;
824 mRecurrenceRangeButton = 0;
825 topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 );
826
827 mExceptionsWidget = new ExceptionsWidget( this );
828 mExceptionsDialog = 0;
829 mExceptions = mExceptionsWidget;
830 mExceptionsButton = 0;
831 topLayout->addWidget( mExceptionsWidget, 3, 1 );
832 }
833}
834
835KOEditorRecurrence::~KOEditorRecurrence()
836{
837}
838
839void KOEditorRecurrence::setEnabled( bool enabled )
840{
841// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl;
842
843 mTimeGroupBox->setEnabled( enabled );
844 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
845 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
846 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
847 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
848}
849
850void KOEditorRecurrence::showCurrentRule( int current )
851{
852 switch ( current ) {
853 case Daily:
854 mRuleStack->raiseWidget( mDaily );
855 break;
856 case Weekly:
857 mRuleStack->raiseWidget( mWeekly );
858 break;
859 case Monthly:
860 mRuleStack->raiseWidget( mMonthly );
861 break;
862 default:
863 case Yearly:
864 mRuleStack->raiseWidget( mYearly );
865 break;
866 }
867}
868
869void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
870{
871// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl;
872
873 mRecurrenceRange->setDateTimes( start, end );
874 mExceptions->setDefaults( end );
875
876}
877
878void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
879{
880
881 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
882 setDateTimes( from, to );
883
884 bool enabled = false;
885 mEnabledCheck->setChecked( enabled );
886 setEnabled( enabled );
887
888 mExceptions->setDefaults( to );
889 mRecurrenceRange->setDefaults( to );
890
891 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
892 showCurrentRule( mRecurrenceChooser->type() );
893
894 mDaily->setFrequency( 1 );
895
896 mWeekly->setFrequency( 1 );
897 QBitArray days( 7 );
898 days.fill( 0 );
899 mWeekly->setDays( days );
900
901 mMonthly->setFrequency( 1 );
902 mMonthly->setByDay( from.date().day()-1 );
903
904 mYearly->setFrequency( 1 );
905 mYearly->setByDay();
906}
907
908void KOEditorRecurrence::readEvent(Event *event)
909{
910 QBitArray rDays( 7 );
911 QPtrList<Recurrence::rMonthPos> rmp;
912 QPtrList<int> rmd;
913 int day = 0;
914 int count = 0;
915 int month = 0;
916 setDateTimes( event->dtStart(), event->dtEnd() );
917
918 Recurrence *r = event->recurrence();
919 int f = r->frequency();
920
921 int recurs = r->doesRecur();
922
923 mEnabledCheck->setChecked( recurs );
924 setEnabled( recurs );
925
926 int recurrenceType = RecurrenceChooser::Weekly;
927
928 switch ( recurs ) {
929 case Recurrence::rNone:
930 setDefaults( event->dtStart(), event->dtEnd(), true );
931 break;
932 case Recurrence::rDaily:
933 recurrenceType = RecurrenceChooser::Daily;
934 mDaily->setFrequency( f );
935 break;
936 case Recurrence::rWeekly:
937 recurrenceType = RecurrenceChooser::Weekly;
938 mWeekly->setFrequency( f );
939 mWeekly->setDays( r->days() );
940 break;
941 case Recurrence::rMonthlyPos:
942 // we only handle one possibility in the list right now,
943 // so I have hardcoded calls with first(). If we make the GUI
944 // more extended, this can be changed.
945 recurrenceType = RecurrenceChooser::Monthly;
946
947 rmp = r->monthPositions();
948 if ( rmp.first()->negative )
949 count = 5 - rmp.first()->rPos - 1;
950 else
951 count = rmp.first()->rPos - 1;
952 day = 0;
953 while ( !rmp.first()->rDays.testBit( day ) ) ++day;
954 mMonthly->setByPos( count, day );
955
956 mMonthly->setFrequency( f );
957
958 break;
959 case Recurrence::rMonthlyDay:
960 recurrenceType = RecurrenceChooser::Monthly;
961
962 rmd = r->monthDays();
963 day = *rmd.first() - 1;
964 mMonthly->setByDay( day );
965
966 mMonthly->setFrequency( f );
967
968 break;
969 case Recurrence::rYearlyMonth:
970 case Recurrence::rYearlyDay:
971 recurrenceType = RecurrenceChooser::Yearly;
972
973 rmd = r->yearNums();
974 month = *rmd.first();
975 if ( month == event->dtStart().date().month() ) {
976 mYearly->setByDay();
977 } else {
978 mYearly->setByMonth( month );
979 }
980
981 mYearly->setFrequency( f );
982 break;
983 default:
984 setDefaults( event->dtStart(), event->dtEnd(), true );
985 break;
986 }
987
988 mRecurrenceChooser->setType( recurrenceType );
989 showCurrentRule( recurrenceType );
990
991 mRecurrenceRange->setDateTimes( event->dtStart() );
992
993 if ( r->doesRecur() ) {
994 mRecurrenceRange->setDuration( r->duration() );
995 if ( r->duration() == 0 )
996 {
997 if ( r->endDate() < event->dtStart().date() )
998 mRecurrenceRange->setEndDate( event->dtStart().date() );
999 else
1000 mRecurrenceRange->setEndDate( r->endDate() );
1001 } else
1002 mRecurrenceRange->setEndDate( event->dtStart().date() );
1003 }
1004
1005 mExceptions->setDates( event->exDates() );
1006}
1007
1008void KOEditorRecurrence::writeEvent( Event *event )
1009{
1010 Recurrence *r = event->recurrence();
1011
1012 // clear out any old settings;
1013 r->unsetRecurs();
1014
1015 if ( mEnabledCheck->isChecked() ) {
1016 int duration = mRecurrenceRange->duration();
1017 QDate endDate;
1018 if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
1019
1020 int recurrenceType = mRecurrenceChooser->type();
1021
1022 if ( recurrenceType == RecurrenceChooser::Daily ) {
1023 int freq = mDaily->frequency();
1024 if ( duration != 0 ) r->setDaily( freq, duration );
1025 else r->setDaily( freq, endDate );
1026 } else if ( recurrenceType == RecurrenceChooser::Weekly ) {
1027 int freq = mWeekly->frequency();
1028 QBitArray days = mWeekly->days();
1029 int j;
1030 bool found = false;
1031 for (j = 0; j < 7 ; ++j ) {
1032 found |=days.at(j);
1033 }
1034 if ( !found ) {
1035 days.setBit( event->dtStart().date().dayOfWeek()-1);
1036 qDebug("bit set %d ");
1037 }
1038 if ( duration != 0 ) r->setWeekly( freq, days, duration );
1039 else r->setWeekly( freq, days, endDate );
1040 } else if ( recurrenceType == RecurrenceChooser::Monthly ) {
1041 int freq = mMonthly->frequency();
1042 if ( mMonthly->byPos() ) {
1043 int pos = mMonthly->count();
1044
1045 QBitArray days( 7 );
1046 days.fill( false );
1047
1048 days.setBit( mMonthly->weekday() );
1049 if ( duration != 0 )
1050 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
1051 else
1052 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
1053 r->addMonthlyPos( pos, days );
1054 } else {
1055 // it's by day
1056 int day = mMonthly->day();
1057
1058 if ( duration != 0 ) {
1059 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
1060 } else {
1061 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
1062 }
1063 r->addMonthlyDay( day );
1064 }
1065 } else if ( recurrenceType == RecurrenceChooser::Yearly ) {
1066 int freq = mYearly->frequency();
1067
1068 int month;
1069 if ( mYearly->byMonth() ) {
1070 month = mYearly->month();
1071 } else {
1072 month = event->dtStart().date().month();
1073 }
1074 if ( duration != 0 ) {
1075 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
1076 } else {
1077 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
1078 }
1079
1080 r->addYearlyNum( month );
1081 }
1082
1083 event->setExDates( mExceptions->dates() );
1084 }
1085}
1086
1087void KOEditorRecurrence::setDateTimeStr( const QString &str )
1088{
1089 mDateTimeLabel->setText( str );
1090}
1091
1092bool KOEditorRecurrence::validateInput()
1093{
1094 // Check input here
1095
1096 return true;
1097}
1098
1099void KOEditorRecurrence::showExceptionsDialog()
1100{
1101 DateList dates = mExceptions->dates();
1102 int result = mExceptionsDialog->exec();
1103 if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
1104}
1105
1106void KOEditorRecurrence::showRecurrenceRangeDialog()
1107{
1108 int duration = mRecurrenceRange->duration();
1109 QDate endDate = mRecurrenceRange->endDate();
1110
1111 int result = mRecurrenceRangeDialog->exec();
1112 if ( result == QDialog::Rejected ) {
1113 mRecurrenceRange->setDuration( duration );
1114 mRecurrenceRange->setEndDate( endDate );
1115 }
1116
1117}
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h
new file mode 100644
index 0000000..4f0f0b2
--- a/dev/null
+++ b/korganizer/koeditorrecurrence.h
@@ -0,0 +1,321 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOEDITORRECURRENCE_H
24#define _KOEDITORRECURRENCE_H
25
26#include <qframe.h>
27#include <qlabel.h>
28#include <qcheckbox.h>
29#include <qpushbutton.h>
30#include <qgroupbox.h>
31#include <qlineedit.h>
32#include <qcombobox.h>
33#include <qmultilineedit.h>
34#include <qlistview.h>
35#include <qradiobutton.h>
36
37#include <kdialogbase.h>
38
39#include <libkcal/event.h>
40
41#include "ktimeedit.h"
42
43class QWidgetStack;
44class QSpinBox;
45
46class KDateEdit;
47
48using namespace KCal;
49
50class RecurBase : public QWidget
51{
52 public:
53 RecurBase( QWidget *parent = 0, const char *name = 0 );
54
55 void setFrequency( int );
56 int frequency();
57
58 QWidget *frequencyEdit();
59
60 private:
61 QSpinBox *mFrequencyEdit;
62};
63
64class RecurDaily : public RecurBase
65{
66 public:
67 RecurDaily( QWidget *parent = 0, const char *name = 0 );
68};
69
70class RecurWeekly : public RecurBase
71{
72 public:
73 RecurWeekly( QWidget *parent = 0, const char *name = 0 );
74
75 void setDays( const QBitArray & );
76 QBitArray days();
77
78 private:
79 QCheckBox *mDayBoxes[7];
80};
81
82class RecurMonthly : public RecurBase
83{
84 public:
85 RecurMonthly( QWidget *parent = 0, const char *name = 0 );
86
87 void setByDay( int day );
88 void setByPos( int count, int weekday );
89
90 bool byDay();
91 bool byPos();
92
93 int day();
94
95 int count();
96 int weekday();
97
98 private:
99 QRadioButton *mByDayRadio;
100 QComboBox *mByDayCombo;
101
102 QRadioButton *mByPosRadio;
103 QComboBox *mByPosCountCombo;
104 QComboBox *mByPosWeekdayCombo;
105};
106
107class RecurYearly : public RecurBase
108{
109 public:
110 RecurYearly( QWidget *parent = 0, const char *name = 0 );
111
112 void setByDay();
113 void setByMonth( int month );
114
115 bool byMonth();
116 bool byDay();
117
118 int month();
119
120 private:
121 QRadioButton *mByMonthRadio;
122 QComboBox *mByMonthCombo;
123
124 QRadioButton *mByDayRadio;
125};
126
127class RecurrenceChooser : public QWidget
128{
129 Q_OBJECT
130 public:
131 RecurrenceChooser( QWidget *parent = 0, const char *name = 0 );
132
133 enum { Daily, Weekly, Monthly, Yearly };
134
135 void setType( int );
136 int type();
137
138 signals:
139 void chosen( int );
140
141 protected slots:
142 void emitChoice();
143
144 private:
145 QComboBox *mTypeCombo;
146
147 QRadioButton *mDailyButton;
148 QRadioButton *mWeeklyButton;
149 QRadioButton *mMonthlyButton;
150 QRadioButton *mYearlyButton;
151};
152
153class ExceptionsBase
154{
155 public:
156 virtual void setDefaults( const QDateTime &from ) = 0;
157 virtual void setDates( const DateList & ) = 0;
158 virtual DateList dates() = 0;
159};
160
161class ExceptionsWidget : public QWidget, public ExceptionsBase
162{
163 Q_OBJECT
164 public:
165 ExceptionsWidget( QWidget *parent = 0, const char *name = 0 );
166
167 void setDefaults( const QDateTime &from );
168
169 void setDates( const DateList & );
170 DateList dates();
171
172 protected slots:
173 void addException();
174 void changeException();
175 void deleteException();
176
177 private:
178 KDateEdit *mExceptionDateEdit;
179 QListBox *mExceptionList;
180 DateList mExceptionDates;
181};
182
183class ExceptionsDialog : public KDialogBase, public ExceptionsBase
184{
185 public:
186 ExceptionsDialog( QWidget *parent, const char *name = 0 );
187
188 void setDefaults( const QDateTime &from );
189
190 void setDates( const DateList & );
191 DateList dates();
192
193 private:
194 ExceptionsWidget *mExceptions;
195};
196
197class RecurrenceRangeBase
198{
199 public:
200 virtual void setDefaults( const QDateTime &from ) = 0;
201
202 virtual void setDuration( int ) = 0;
203 virtual int duration() = 0;
204
205 virtual void setEndDate( const QDate & ) = 0;
206 virtual QDate endDate() = 0;
207
208 virtual void setDateTimes( const QDateTime &start,
209 const QDateTime &end = QDateTime() ) = 0;
210};
211
212class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase
213{
214 Q_OBJECT
215 public:
216 RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 );
217
218 void setDefaults( const QDateTime &from );
219
220 void setDuration( int );
221 int duration();
222
223 void setEndDate( const QDate & );
224 QDate endDate();
225
226 void setDateTimes( const QDateTime &start,
227 const QDateTime &end = QDateTime() );
228
229 protected slots:
230 void showCurrentRange();
231
232 private:
233 QGroupBox *mRangeGroupBox;
234 QLabel *mStartDateLabel;
235 QRadioButton *mNoEndDateButton;
236 QRadioButton *mEndDurationButton;
237 QSpinBox *mEndDurationEdit;
238 QRadioButton *mEndDateButton;
239 KDateEdit *mEndDateEdit;
240};
241
242class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase
243{
244 public:
245 RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 );
246
247 void setDefaults( const QDateTime &from );
248
249 void setDuration( int );
250 int duration();
251
252 void setEndDate( const QDate & );
253 QDate endDate();
254
255 void setDateTimes( const QDateTime &start,
256 const QDateTime &end = QDateTime() );
257
258 private:
259 RecurrenceRangeWidget *mRecurrenceRangeWidget;
260};
261
262class KOEditorRecurrence : public QWidget
263{
264 Q_OBJECT
265 public:
266 KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 );
267 virtual ~KOEditorRecurrence();
268
269 enum { Daily, Weekly, Monthly, Yearly };
270
271 /** Set widgets to default values */
272 void setDefaults( QDateTime from, QDateTime to, bool allday );
273 /** Read event object and setup widgets accordingly */
274 void readEvent( Event * );
275 /** Write event settings to event object */
276 void writeEvent( Event * );
277
278 /** Check if the input is valid. */
279 bool validateInput();
280
281 public slots:
282 void setEnabled( bool );
283 void setDateTimes( QDateTime start, QDateTime end );
284 void setDateTimeStr( const QString & );
285
286 signals:
287 void dateTimesChanged( QDateTime start, QDateTime end );
288
289 protected slots:
290 void showCurrentRule( int );
291 void showExceptionsDialog();
292 void showRecurrenceRangeDialog();
293
294 private:
295 QCheckBox *mEnabledCheck;
296
297 QGroupBox *mTimeGroupBox;
298 QLabel *mDateTimeLabel;
299
300 QGroupBox *mRuleBox;
301 QWidgetStack *mRuleStack;
302 RecurrenceChooser *mRecurrenceChooser;
303
304 RecurDaily *mDaily;
305 RecurWeekly *mWeekly;
306 RecurMonthly *mMonthly;
307 RecurYearly *mYearly;
308
309 RecurrenceRangeBase *mRecurrenceRange;
310 RecurrenceRangeWidget *mRecurrenceRangeWidget;
311 RecurrenceRangeDialog *mRecurrenceRangeDialog;
312 QPushButton *mRecurrenceRangeButton;
313
314 ExceptionsBase *mExceptions;
315 ExceptionsDialog *mExceptionsDialog;
316 ExceptionsWidget *mExceptionsWidget;
317 QPushButton *mExceptionsButton;
318
319};
320
321#endif
diff --git a/korganizer/koeditorrecurrence.moc b/korganizer/koeditorrecurrence.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeditorrecurrence.moc
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp
new file mode 100644
index 0000000..b3edec6
--- a/dev/null
+++ b/korganizer/koeventeditor.cpp
@@ -0,0 +1,378 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qtooltip.h>
25#include <qframe.h>
26#include <qpixmap.h>
27#include <qhbox.h>
28#include <qdir.h>
29#include <qlayout.h>
30#include <qwidgetstack.h>
31#include <qapplication.h>
32
33#include <kiconloader.h>
34#include <kstandarddirs.h>
35#include <kdebug.h>
36#include <klocale.h>
37#include <kfiledialog.h>
38#include <kmessagebox.h>
39#include <libkcal/calendarresources.h>
40#include <libkcal/resourcecalendar.h>
41#include <kresources/resourceselectdialog.h>
42
43#include <libkdepim/categoryselectdialog.h>
44#include <libkcal/calendarlocal.h>
45#include <libkcal/icalformat.h>
46
47#include "koprefs.h"
48
49#include "koeventeditor.h"
50#include "koeventeditor.moc"
51extern int globalFlagBlockAgenda;
52
53KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) :
54 KOIncidenceEditor( i18n("Edit Event"), calendar, parent )
55{
56 mEvent = 0;
57 init();
58}
59
60KOEventEditor::~KOEventEditor()
61{
62 //emit dialogClose( mEvent );
63}
64
65void KOEventEditor::init()
66{
67
68 setupGeneral();
69 setupAttendeesTab();
70 setupRecurrence();
71
72 // Propagate date time settings to recurrence tab
73 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
74 mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime)));
75 connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)),
76 mRecurrence,SLOT(setDateTimeStr(const QString &)));
77
78 // Category dialog
79 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
80 //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)),
81 // mGeneral,SLOT(setCategories(const QString &)));
82
83
84}
85
86void KOEventEditor::reload()
87{
88 if ( mEvent ) readEvent( mEvent );
89}
90
91void KOEventEditor::setSecrecy( int sec )
92{
93 mGeneral->setSecrecy( sec );
94}
95void KOEventEditor::setCategories( QString s )
96{
97 mGeneral->setCategories(s);
98
99}
100void KOEventEditor::setupGeneral()
101{
102 mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" );
103 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
104
105 if( KOPrefs::instance()->mCompactDialogs ) {
106 QFrame *topFrame = addPage(i18n("General"));
107 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
108 topLayout->setSpacing(spacingHint()-1);
109 topLayout->setMargin(marginHint()-1);
110 mGeneral->initHeader(topFrame,topLayout);
111 mGeneral->initTime(topFrame,topLayout);
112// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
113 mGeneral->initAlarm(topFrame,topLayout);
114 mGeneral->enableAlarm( false );
115
116 QBoxLayout *buttonLayout;
117 if ( QApplication::desktop()->width() < 500 )
118 buttonLayout = new QVBoxLayout( topLayout );
119 else
120 buttonLayout = new QHBoxLayout( topLayout );
121 QHBox* buttonWidget = new QHBox (topFrame);
122 QIconSet icon;
123 if ( QApplication::desktop()->width() < 321 )
124 icon = SmallIcon("fileexport16");
125 else
126 icon = SmallIcon("fileexport");
127 QPushButton * loadTemplate = new QPushButton( buttonWidget);
128 QPushButton * saveTemplate = new QPushButton( buttonWidget);
129 saveTemplate->setIconSet (icon ) ;
130 int size = saveTemplate->sizeHint().height();
131 saveTemplate->setFixedSize( size, size );
132 if ( QApplication::desktop()->width() < 321 )
133 icon = SmallIcon("fileimport16");
134 else
135 icon = SmallIcon("fileimport");
136 loadTemplate->setIconSet (icon ) ;
137 loadTemplate->setFixedSize( size, size );
138 buttonLayout->addWidget( buttonWidget );
139 mGeneral->initCategories( topFrame, buttonLayout );
140
141 topLayout->addStretch( 1 );
142
143 QFrame *topFrame2 = addPage(i18n("Details"));
144
145 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
146 topLayout2->setSpacing(spacingHint());
147
148 mGeneral->initClass(topFrame2,topLayout2);
149 mGeneral->initSecrecy( topFrame2, topLayout2 );
150 mGeneral->initDescription(topFrame2,topLayout2);
151
152 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
153 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
154 } else {
155 QFrame *topFrame = addPage(i18n("General"));
156
157 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
158 topLayout->setSpacing(spacingHint());
159
160 mGeneral->initHeader(topFrame,topLayout);
161 mGeneral->initTime(topFrame,topLayout);
162 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
163 mGeneral->initAlarm(topFrame,alarmLineLayout);
164 mGeneral->initClass(topFrame,alarmLineLayout);
165 mGeneral->initDescription(topFrame,topLayout);
166 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
167 mGeneral->initCategories( topFrame, detailsLayout );
168 mGeneral->initSecrecy( topFrame, detailsLayout );
169 }
170
171 mGeneral->finishSetup();
172
173}
174
175void KOEventEditor::setupRecurrence()
176{
177 QFrame *topFrame = addPage( i18n("Recurrence") );
178 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
179
180 mRecurrence = new KOEditorRecurrence( topFrame );
181 topLayout->addWidget( mRecurrence );
182}
183
184void KOEventEditor::editEvent(Event *event, bool showDescription)
185{
186 // init();
187
188 mEvent = event;
189 readEvent(mEvent);
190 qApp->processEvents();
191 if ( showDescription ) {
192 showPage( 1 );
193 mGeneral->setFocusOn( 1 );
194 } else {
195 showPage( 0 );
196 mGeneral->setFocusOn( 2 );
197 }
198}
199
200void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay )
201{
202 // init();
203
204 mEvent = 0;
205 setDefaults(from,to,allDay);
206}
207
208void KOEventEditor::loadDefaults()
209{
210 int fmt = KOPrefs::instance()->mStartTime;
211
212 QDateTime from(QDate::currentDate(), QTime(fmt,0,0));
213 QDateTime to(QDate::currentDate(),
214 QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0));
215
216 setDefaults(from,to,false);
217}
218
219bool KOEventEditor::processInput( bool emitTime )
220{
221 if (!validateInput()) return false;
222
223 Event *event = 0;
224
225 if (mEvent) event = mEvent;
226 else {
227 event = new Event;
228 event->setOrganizer(KOPrefs::instance()->email());
229 }
230
231 writeEvent(event);
232 if ( emitTime ) {
233 globalFlagBlockAgenda = 1;
234 emit showAgendaView( false );
235 emit jumpToTime( event->dtStart().date() );
236 globalFlagBlockAgenda = 2;
237
238 }
239 if (mEvent) {
240 event->setRevision(event->revision()+1);
241 emit eventChanged(event);
242 } else {
243 mCalendar->addEvent(event);
244 mEvent = event;
245 emit eventAdded(event);
246 }
247
248 return true;
249}
250
251void KOEventEditor::deleteEvent()
252{
253 kdDebug() << "Delete event" << endl;
254
255 if (mEvent) {
256 if (KOPrefs::instance()->mConfirm) {
257 switch (msgItemDelete()) {
258 case KMessageBox::Continue: // OK
259 emit eventToBeDeleted(mEvent);
260 emit dialogClose(mEvent);
261 mCalendar->deleteEvent(mEvent);
262 emit eventDeleted();
263 reject();
264 break;
265 }
266 }
267 else {
268 emit eventToBeDeleted(mEvent);
269 emit dialogClose(mEvent);
270 mCalendar->deleteEvent(mEvent);
271 emit eventDeleted();
272 reject();
273 }
274 } else {
275 reject();
276 }
277}
278
279void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay)
280{
281 mGeneral->setDefaults(from,to,allDay);
282 mDetails->setDefaults();
283 mRecurrence->setDefaults(from,to,allDay);
284 showPage( 0 );
285 mGeneral->setFocusOn( 2 );
286}
287
288void KOEventEditor::readEvent( Event *event, bool tmpl )
289{
290 mGeneral->readEvent( event, tmpl );
291 mDetails->readEvent( event );
292 mRecurrence->readEvent( event );
293
294 // categories
295 //mCategoryDialog->setSelected( event->categories() );
296}
297
298void KOEventEditor::writeEvent(Event *event)
299{
300 mGeneral->writeEvent( event );
301 mDetails->writeEvent( event );
302
303 if ( event->organizer() == KOPrefs::instance()->email() ) {
304 Event *ev = new Event( *event );
305 ev->registerObserver(0);
306 mDetails->cancelAttendeeEvent( ev );
307 if ( ev->attendeeCount() > 0 ) {
308 emit deleteAttendee( ev );
309 }
310 delete(ev);
311 }
312
313 mRecurrence->writeEvent(event);
314}
315
316bool KOEventEditor::validateInput()
317{
318 if (!mGeneral->validateInput()) return false;
319 if (!mDetails->validateInput()) return false;
320 if (!mRecurrence->validateInput()) return false;
321 return true;
322}
323
324int KOEventEditor::msgItemDelete()
325{
326 return KMessageBox::warningContinueCancel(this,
327 i18n("This item will be permanently deleted."),
328 i18n("KOrganizer Confirmation"),i18n("Delete"));
329}
330
331void KOEventEditor::slotLoadTemplate()
332{
333
334 QString fileName =locateLocal( "templates", "events" );
335 QDir t_dir;
336 if ( !t_dir.exists(fileName) )
337 t_dir.mkdir ( fileName );
338 fileName += "/event";
339 fileName = KFileDialog::getSaveFileName( fileName , "Load Event template", this );
340 if ( fileName.length() == 0 )
341 return;
342 CalendarLocal cal;
343 ICalFormat format;
344 if ( !format.load( &cal, fileName ) ) {
345 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
346 .arg( fileName ) );
347 return ;
348 }
349 QPtrList<Event> events = cal.events();
350 Event* event = events.first();
351 if ( !event ) {
352 KMessageBox::error( this,
353 i18n("Template does not contain\na valid Event."));
354 } else {
355 kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl;
356 readEvent( event, true );
357 }
358}
359
360
361void KOEventEditor::slotSaveTemplate()
362{
363 QString fileName =locateLocal( "templates", "events" );
364 QDir t_dir;
365 if ( !t_dir.exists(fileName) )
366 t_dir.mkdir ( fileName );
367 fileName += "/event";
368 fileName = KFileDialog::getSaveFileName( fileName , "Save as Event template", this );
369 if ( fileName.length() > 0 )
370 saveTemplate( fileName );
371}
372
373void KOEventEditor::saveTemplate( const QString &templateName )
374{
375 Event *event = new Event;
376 writeEvent( event );
377 saveAsTemplate( event, templateName );
378}
diff --git a/korganizer/koeventeditor.h b/korganizer/koeventeditor.h
new file mode 100644
index 0000000..5303c27
--- a/dev/null
+++ b/korganizer/koeventeditor.h
@@ -0,0 +1,118 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOEVENTEDITOR_H
24#define _KOEVENTEDITOR_H
25
26#include <kdialogbase.h>
27
28#include <qdatetime.h>
29
30#include <libkcal/calendar.h>
31
32#include "koeditorgeneralevent.h"
33#include "koeditordetails.h"
34#include "koeditorrecurrence.h"
35#include "koincidenceeditor.h"
36
37class SaveTemplateDialog;
38
39using namespace KCal;
40
41/**
42 This class provides a dialog for editing an event.
43*/
44class KOEventEditor : public KOIncidenceEditor
45{
46 Q_OBJECT
47 public:
48 /**
49 Construct new event editor.
50 */
51 KOEventEditor( Calendar *calendar, QWidget *parent );
52 virtual ~KOEventEditor(void);
53
54 void init();
55
56 void reload();
57
58 /**
59 Clear eventwin for new event, and preset the dates and times with hint
60 */
61 void newEvent( QDateTime from, QDateTime to, bool allDay = false );
62 /**
63 Edit an existing event.
64 */
65 void editEvent( Event * , bool showDescription = false);
66
67 /**
68 Set widgets to default values
69 */
70 void setDefaults( QDateTime from, QDateTime to, bool allDay );
71
72 /**
73 Read event object and setup widgets accordingly. If tmpl is true, the
74 event is read as template, i.e. the time and date information isn't set.
75 */
76 void readEvent( Event *, bool tmpl = false );
77 /**
78 Write event settings to event object
79 */
80 void writeEvent( Event * );
81
82 void setCategories( QString s );
83 void setSecrecy( int );
84 signals:
85 void eventAdded(Event *);
86 void eventChanged(Event *);
87 void eventToBeDeleted(Event *);
88 void eventDeleted();
89 void deleteAttendee(Incidence *);
90
91 protected slots:
92 void loadDefaults();
93 void deleteEvent();
94
95 void slotLoadTemplate();
96 void slotSaveTemplate();
97
98 void saveTemplate( const QString & );
99
100 protected:
101 void setupGeneral();
102 void setupRecurrence();
103
104 /** Check if the input is valid. */
105 bool validateInput();
106 /** Process user input and create or update event. Returns false if input
107 * is not valid */
108 bool processInput( bool );
109 int msgItemDelete();
110
111 private:
112 Event *mEvent;
113
114 KOEditorGeneralEvent *mGeneral;
115 KOEditorRecurrence *mRecurrence;
116};
117
118#endif
diff --git a/korganizer/koeventeditor.moc b/korganizer/koeventeditor.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeventeditor.moc
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
new file mode 100644
index 0000000..410bceb
--- a/dev/null
+++ b/korganizer/koeventpopupmenu.cpp
@@ -0,0 +1,114 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qcursor.h>
25
26#include <klocale.h>
27#include <kdebug.h>
28#include <kiconloader.h>
29
30#include <libkcal/event.h>
31
32#include "koeventpopupmenu.h"
33#include "koeventpopupmenu.moc"
34
35KOEventPopupMenu::KOEventPopupMenu()
36{
37 mCurrentIncidence = 0;
38 mHasAdditionalItems = false;
39
40 insertItem (i18n("&Show"),this,SLOT(popupShow()));
41 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
42 mEditOnlyItems.append(insertItem (i18n("&Delete"),
43 this,SLOT(popupDelete())));
44 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
45 this,SLOT(popupClone())));
46 mEditOnlyItems.append(insertItem (i18n("&Move..."),
47 this,SLOT(popupMove())));
48#ifndef DESKTOP_VERSION
49 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
50 this,SLOT(popupBeam())));
51#endif
52 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
53 this,SLOT(popupCancel())));
54}
55
56void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
57{
58 mCurrentIncidence = incidence;
59
60 if (mCurrentIncidence) {
61 // Enable/Disabled menu items only valid for editable events.
62 QValueList<int>::Iterator it;
63 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
64 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
65 }
66 popup(QCursor::pos());
67 } else {
68 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
69 }
70}
71
72void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
73 const QObject *receiver, const char *member,
74 bool editOnly)
75{
76 if (!mHasAdditionalItems) {
77 mHasAdditionalItems = true;
78 insertSeparator();
79 }
80 int id = insertItem(icon,text,receiver,member);
81 if (editOnly) mEditOnlyItems.append(id);
82}
83
84void KOEventPopupMenu::popupShow()
85{
86 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
87}
88
89void KOEventPopupMenu::popupEdit()
90{
91 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
92}
93
94void KOEventPopupMenu::popupDelete()
95{
96 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
97}
98void KOEventPopupMenu::popupClone()
99{
100 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
101}
102void KOEventPopupMenu::popupCancel()
103{
104 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
105}
106void KOEventPopupMenu::popupMove()
107{
108 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
109}
110
111void KOEventPopupMenu::popupBeam()
112{
113 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
114}
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h
new file mode 100644
index 0000000..6993899
--- a/dev/null
+++ b/korganizer/koeventpopupmenu.h
@@ -0,0 +1,73 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOEVENTPOPUPMENU_H
24#define KOEVENTPOPUPMENU_H
25//
26// Context menu for event views with standard event actions
27//
28
29#include <qpopupmenu.h>
30
31#include <libkcal/incidence.h>
32
33using namespace KCal;
34
35class KOEventPopupMenu : public QPopupMenu {
36 Q_OBJECT
37 public:
38 KOEventPopupMenu();
39
40 void addAdditionalItem(const QIconSet &icon,const QString &text,
41 const QObject *receiver, const char *member,
42 bool editOnly=false);
43
44
45 public slots:
46 void showIncidencePopup(Incidence *);
47
48 protected slots:
49 void popupShow();
50 void popupEdit();
51 void popupDelete();
52 void popupClone();
53 void popupCancel();
54 void popupMove();
55 void popupBeam();
56
57 signals:
58 void editIncidenceSignal(Incidence *);
59 void showIncidenceSignal(Incidence *);
60 void deleteIncidenceSignal(Incidence *);
61 void cloneIncidenceSignal(Incidence *);
62 void cancelIncidenceSignal(Incidence *);
63 void moveIncidenceSignal(Incidence *);
64 void beamIncidenceSignal(Incidence *);
65
66 private:
67 Incidence *mCurrentIncidence;
68
69 bool mHasAdditionalItems;
70 QValueList<int> mEditOnlyItems;
71};
72
73#endif
diff --git a/korganizer/koeventpopupmenu.moc b/korganizer/koeventpopupmenu.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeventpopupmenu.moc
diff --git a/korganizer/koeventview.cpp b/korganizer/koeventview.cpp
new file mode 100644
index 0000000..4553b0b
--- a/dev/null
+++ b/korganizer/koeventview.cpp
@@ -0,0 +1,133 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qpopupmenu.h>
25#include <qcursor.h>
26
27#include <klocale.h>
28#include <kdebug.h>
29#include <kiconloader.h>
30#include <kmessagebox.h>
31
32#include <libkcal/calendar.h>
33#include "koprefs.h"
34#include "koeventview.h"
35using namespace KOrg;
36#include "koeventview.moc"
37
38//---------------------------------------------------------------------------
39
40KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name)
41 : KOrg::BaseView(cal,parent,name)
42{
43}
44
45//---------------------------------------------------------------------------
46
47KOEventView::~KOEventView()
48{
49}
50
51//---------------------------------------------------------------------------
52
53KOEventPopupMenu *KOEventView::eventPopup()
54{
55 KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
56
57 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)),
58 SIGNAL(editIncidenceSignal(Incidence *)));
59 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)),
60 SIGNAL(showIncidenceSignal(Incidence *)));
61 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)),
62 SIGNAL(deleteIncidenceSignal(Incidence *)));
63 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)),
64 SIGNAL(cancelIncidenceSignal(Incidence *)));
65 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)),
66 SIGNAL(cloneIncidenceSignal(Incidence *)));
67 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)),
68 SIGNAL(beamIncidenceSignal(Incidence *)));
69 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)),
70 SIGNAL(moveIncidenceSignal(Incidence *)));
71
72 return eventPopup;
73}
74
75//---------------------------------------------------------------------------
76
77void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event)
78{
79 mCurrentIncidence = event;
80 if (event) popup->popup(QCursor::pos());
81 else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl;
82}
83
84//---------------------------------------------------------------------------
85
86void KOEventView::popupShow()
87{
88 emit showIncidenceSignal(mCurrentIncidence);
89}
90
91//---------------------------------------------------------------------------
92
93void KOEventView::popupEdit()
94{
95 emit editIncidenceSignal(mCurrentIncidence);
96}
97
98//---------------------------------------------------------------------------
99
100void KOEventView::popupDelete()
101{
102 emit deleteIncidenceSignal(mCurrentIncidence);
103}
104void KOEventView::popupClone()
105{
106 emit cloneIncidenceSignal(mCurrentIncidence);
107}
108void KOEventView::popupCancel()
109{
110 emit cancelIncidenceSignal(mCurrentIncidence);
111}
112
113//---------------------------------------------------------------------------
114
115void KOEventView::defaultAction( Incidence *incidence )
116{
117
118 if ( !incidence ) return;
119
120 if ( incidence->isReadOnly() )
121 emit showIncidenceSignal(incidence);
122 else {
123 if ( KOPrefs::instance()->mEditOnDoubleClick )
124 emit editIncidenceSignal(incidence);
125 else
126 emit showIncidenceSignal(incidence);
127 }
128}
129
130//---------------------------------------------------------------------------
131
132#include "baseview.moc"
133
diff --git a/korganizer/koeventview.h b/korganizer/koeventview.h
new file mode 100644
index 0000000..77ec111
--- a/dev/null
+++ b/korganizer/koeventview.h
@@ -0,0 +1,172 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef _KOEVENTVIEW_H
25#define _KOEVENTVIEW_H
26
27#include <libkcal/calendar.h>
28#include <libkcal/event.h>
29
30#include <korganizer/baseview.h>
31
32#include "koeventpopupmenu.h"
33
34using namespace KCal;
35
36class CalPrinter;
37
38/**
39 KOEventView is the abstract base class from which all other
40 calendar views for event data are derived. It provides methods for
41 displaying
42 appointments and events on one or more days. The actual number of
43 days that a view actually supports is not defined by this abstract class;
44 that is up to the classes that inherit from it. It also provides
45 methods for updating the display, retrieving the currently selected
46 event (or events), and the like.
47
48 @short Abstract class from which all event views are derived.
49 @author Preston Brown <pbrown@kde.org>
50 @see KOListView, KOAgendaView, KOWeekView, KOMonthView
51*/
52class KOEventView : public KOrg::BaseView
53{
54 Q_OBJECT
55
56 public:
57 /**
58 * Constructs a view.
59 * @param cal is a pointer to the calendar object from which events
60 * will be retrieved for display.
61 */
62 KOEventView(Calendar *cal,QWidget *parent=0,const char *name=0);
63
64 /**
65 * Destructor. Views will do view-specific cleanups here.
66 */
67 virtual ~KOEventView();
68
69 /**
70 * provides a hint back to the caller on the maximum number of dates
71 * that the view supports. A return value of 0 means no maximum.
72 */
73 virtual int maxDatesHint() = 0;
74
75 /**
76 * Construct a standard context menu for an event.
77 */
78 KOEventPopupMenu *eventPopup();
79
80 /** This view is an view for displaying events. */
81 bool isEventView() { return true; }
82
83 public slots:
84
85 /**
86 * Show context menu for event.
87 * @param event event, which is to be manipulated by the menu actions
88 * @param popup a popop menu created with eventPopup()
89 */
90 void showIncidencePopup(QPopupMenu *popup, Incidence *event);
91
92 /**
93 Perform the default action for an incidence, e.g. open the event editor,
94 when double-clicking an event in the agenda view.
95 */
96 void defaultAction( Incidence * );
97
98 signals:
99 /**
100 * when the view changes the dates that are selected in one way or
101 * another, this signal is emitted. It should be connected back to
102 * the @see KDateNavigator object so that it changes appropriately,
103 * and any other objects that need to be aware that the list of
104 * selected dates has changed.
105 */
106 void datesSelected(const DateList);
107
108 /**
109 * instructs the receiver to show the incidence in read-only mode.
110 */
111 void showIncidenceSignal(Incidence *);
112
113 /**
114 * instructs the receiver to begin editing the incidence specified in
115 * some manner. Doesn't make sense to connect to more than one
116 * receiver.
117 */
118 void editIncidenceSignal(Incidence *);
119 void cloneIncidenceSignal(Incidence *);
120 void cancelIncidenceSignal(Incidence *);
121 void beamIncidenceSignal(Incidence *);
122 void moveIncidenceSignal(Incidence *);
123
124 /**
125 * instructs the receiver to delete the Incidence in some manner; some
126 * possibilities include automatically, with a confirmation dialog
127 * box, etc. Doesn't make sense to connect to more than one receiver.
128 */
129 void deleteIncidenceSignal(Incidence *);
130
131 /**
132 * instructs the receiver to create a new event. Doesn't make
133 * sense to connect to more than one receiver.
134 */
135 void newEventSignal();
136 /**
137 * instructs the receiver to create a new event with the specified beginning
138 * time. Doesn't make sense to connect to more than one receiver.
139 */
140 void newEventSignal(QDate);
141 /**
142 * instructs the receiver to create a new event with the specified beginning
143 * time. Doesn't make sense to connect to more than one receiver.
144 */
145 void newEventSignal(QDateTime);
146 /**
147 * instructs the receiver to create a new event, with the specified
148 * beginning end ending times. Doesn't make sense to connect to more
149 * than one receiver.
150 */
151 void newEventSignal(QDateTime, QDateTime);
152
153 //ET CVS MERGE !
154 /**
155 * Emitted when an event is moved using the mouse in an agenda
156 * view (week / month).
157 */
158 void shiftedEvent(const QDate& olddate, const QDate& newdate);
159
160
161 protected slots:
162 void popupShow();
163 void popupEdit();
164 void popupDelete();
165 void popupClone();
166 void popupCancel();
167
168 protected:
169 Incidence *mCurrentIncidence; // Incidence selected e.g. for a context menu
170};
171
172#endif
diff --git a/korganizer/koeventview.moc b/korganizer/koeventview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeventview.moc
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
new file mode 100644
index 0000000..9f8bd9b
--- a/dev/null
+++ b/korganizer/koeventviewer.cpp
@@ -0,0 +1,510 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <qcstring.h>
21#include <qwhatsthis.h>
22#include <qdialog.h>
23#include <qapplication.h>
24#include <qlabel.h>
25#include <qlayout.h>
26
27#include <klocale.h>
28#include <kapplication.h>
29#include <libkcal/event.h>
30#include <libkcal/todo.h>
31#include <kdebug.h>
32#include <kiconloader.h>
33#include <krun.h>
34#include <kglobal.h>
35#include <kprocess.h>
36#include "koprefs.h"
37
38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h>
40
41#ifndef KORG_NODCOP
42#include <dcopclient.h>
43#include "korganizer.h"
44#include "koprefs.h"
45#include "actionmanager.h"
46#endif
47
48#include "koeventviewer.h"
49#include "koeventviewer.moc"
50#ifndef KORG_NOKABC
51#include <kabc/stdaddressbook.h>
52#define size count
53#endif
54KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
55 : QTextBrowser(parent,name)
56{
57 mSyncMode = false;
58 mColorMode = 0;
59}
60
61KOEventViewer::~KOEventViewer()
62{
63}
64
65void KOEventViewer::setSource(const QString& n)
66{
67 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
68 KABC::AddressBook::Iterator it;
69 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
70 // LR I do not understand, why the uid string is different on zaurus and desktop
71#ifdef DESKTOP_VERSION
72 QString uid = "uid://"+(*it).uid();
73#else
74 QString uid = "uid:"+(*it).uid();
75#endif
76 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
77 if (n == uid ) {
78 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
79 QDialog dia( this,"dia123", true );
80 dia.setCaption( i18n("Details of attendee") );
81 QVBoxLayout lay ( &dia );
82 KPIM::AddresseeView av ( &dia );
83 av.setAddressee( (*it) );
84 lay.addWidget( &av );
85 if ( QApplication::desktop()->width() < 480 )
86 dia.resize( 220, 240);
87 else {
88 dia.resize( 400,400);
89
90 }
91 dia.exec();
92 break;
93 }
94 }
95
96
97#ifndef KORG_NODCOP
98 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
99 QString tmpStr;
100 if (n.startsWith("mailto:")) {
101 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
102 //emit showIncidence(n);
103 return;
104 } else if (n.startsWith("uid:")) {
105 DCOPClient *client = KApplication::kApplication()->dcopClient();
106 const QByteArray noParamData;
107 const QByteArray paramData;
108 QByteArray replyData;
109 QCString replyTypeStr;
110#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
111 bool foundAbbrowser = PING_ABBROWSER;
112
113 if (foundAbbrowser) {
114 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
115 //client->send("kaddressbook","KAddressBookIface",
116 QDataStream arg(paramData, IO_WriteOnly);
117 arg << n.mid(6);
118 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
119 return;
120 } else {
121 /*
122 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
123 We start it without its main interface
124 */
125 KIconLoader* iconLoader = new KIconLoader();
126 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
127 ActionManager::setStartedKAddressBook(true);
128 tmpStr = "kaddressbook --editor-only --uid ";
129 tmpStr += KProcess::quote(n.mid(6));
130 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
131 return;
132 }
133 } else {
134 //QTextBrowser::setSource(n);
135 }
136#endif
137}
138
139void KOEventViewer::addTag(const QString & tag,const QString & text)
140{
141 int number=text.contains("\n");
142 QString str = "<" + tag + ">";
143 QString tmpText=text;
144 QString tmpStr=str;
145 if(number !=-1)
146 {
147 if (number > 0) {
148 int pos=0;
149 QString tmp;
150 for(int i=0;i<=number;i++) {
151 pos=tmpText.find("\n");
152 tmp=tmpText.left(pos);
153 tmpText=tmpText.right(tmpText.length()-pos-1);
154 tmpStr+=tmp+"<br>";
155 }
156 }
157 else tmpStr += tmpText;
158 tmpStr+="</" + tag + ">";
159 mText.append(tmpStr);
160 }
161 else
162 {
163 str += text + "</" + tag + ">";
164 mText.append(str);
165 }
166}
167
168void KOEventViewer::setColorMode( int m )
169{
170 mColorMode = m;
171}
172void KOEventViewer::appendEvent(Event *event, int mode )
173{
174 mCurrentIncidence = event;
175 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
176 topLevelWidget()->setCaption(i18n("Event Viewer"));
177 if ( mode == 0 ) {
178 addTag("h2",event->summary());
179 }
180 else {
181 if ( mColorMode == 1 ) {
182 mText +="<font color=\"#00A000\">";
183 }
184 if ( mColorMode == 2 ) {
185 mText +="<font color=\"#C00000\">";
186 }
187 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
188 if ( mode == 1 ) {
189 addTag("h2",i18n( "Local: " ) +event->summary());
190 } else {
191 addTag("h2",i18n( "Remote: " ) +event->summary());
192 }
193 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
194 if ( mColorMode )
195 mText += "</font>";
196 }
197 if (event->cancelled ()) {
198 mText +="<font color=\"#B00000\">";
199 addTag("i",i18n("This event has been cancelled!"));
200 mText.append("<br>");
201 mText += "</font>";
202 }
203 if (!event->location().isEmpty()) {
204 addTag("b",i18n("Location: "));
205 mText.append(event->location()+"<br>");
206 }
207 if (event->doesFloat()) {
208 if (event->isMultiDay()) {
209 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
210 .arg(event->dtStartDateStr(shortDate))
211 .arg(event->dtEndDateStr(shortDate)));
212 } else {
213 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
214 }
215 } else {
216 if (event->isMultiDay()) {
217 mText.append(i18n("<p><b>From:</b> %1</p> ")
218 .arg(event->dtStartStr( shortDate)));
219 mText.append(i18n("<p><b>To:</b> %1</p>")
220 .arg(event->dtEndStr(shortDate)));
221 } else {
222 mText.append(i18n("<p><b>On:</b> %1</p> ")
223 .arg(event->dtStartDateStr( shortDate )));
224 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
225 .arg(event->dtStartTimeStr())
226 .arg(event->dtEndTimeStr()));
227 }
228 }
229
230 if (event->recurrence()->doesRecur()) {
231
232 QString recurText = event->recurrence()->recurrenceText();
233 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
234 bool last;
235 QDate start = QDate::currentDate();
236 QDate next;
237 next = event->recurrence()->getPreviousDate( start , &last );
238 if ( !last ) {
239 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
240 addTag("p",i18n("<b>Next recurrence is on:</b>") );
241 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
242 } else {
243 addTag("p",i18n("<b>Last recurrence was on:</b>") );
244 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
245 }
246 }
247
248
249 if (event->isAlarmEnabled()) {
250 Alarm *alarm =event->alarms().first() ;
251 QDateTime t = alarm->time();
252 int min = t.secsTo( event->dtStart() )/60;
253 QString s =i18n("( %1 min before )").arg( min );
254 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
255 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
256 //addTag("p",s);
257 }
258
259 addTag("b",i18n("Access: "));
260 mText.append(event->secrecyStr()+"<br>");
261 if (!event->description().isEmpty()) {
262 addTag("p",i18n("<b>Details: </b>"));
263 addTag("p",event->description());
264 }
265
266 formatCategories(event);
267
268 formatReadOnly(event);
269 formatAttendees(event);
270
271 setText(mText);
272 //QWhatsThis::add(this,mText);
273
274}
275
276void KOEventViewer::appendTodo(Todo *event, int mode )
277{
278 mCurrentIncidence = event;
279 topLevelWidget()->setCaption(i18n("Todo Viewer"));
280 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
281 if (mode == 0 )
282 addTag("h2",event->summary());
283 else {
284 if ( mColorMode == 1 ) {
285 mText +="<font color=\"#00A000\">";
286 }
287 if ( mColorMode == 2 ) {
288 mText +="<font color=\"#B00000\">";
289 }
290 if ( mode == 1 ) {
291 addTag("h2",i18n( "Local: " ) +event->summary());
292 } else {
293 addTag("h2",i18n( "Remote: " ) +event->summary());
294 }
295 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
296 if ( mColorMode )
297 mText += "</font>";
298 }
299 if (event->cancelled ()) {
300 mText +="<font color=\"#B00000\">";
301 addTag("i",i18n("This todo has been cancelled!"));
302 mText.append("<br>");
303 mText += "</font>";
304 }
305
306 if (!event->location().isEmpty()) {
307 addTag("b",i18n("Location: "));
308 mText.append(event->location()+"<br>");
309 }
310 if (event->hasDueDate()) {
311 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
312 }
313 addTag("b",i18n("Access: "));
314 mText.append(event->secrecyStr()+"<br>");
315 if (!event->description().isEmpty()) {
316 addTag("p",i18n("<b>Details: </b>"));
317 addTag("p",event->description());
318 }
319
320 formatCategories(event);
321
322 mText.append(i18n("<p><b>Priority:</b> %2</p>")
323 .arg(QString::number(event->priority())));
324
325 mText.append(i18n("<p><i>%1 % completed</i></p>")
326 .arg(event->percentComplete()));
327
328 formatReadOnly(event);
329 formatAttendees(event);
330
331 setText(mText);
332}
333
334void KOEventViewer::formatCategories(Incidence *event)
335{
336 if (!event->categoriesStr().isEmpty()) {
337 if (event->categories().count() == 1) {
338 addTag("h3",i18n("Category"));
339 } else {
340 addTag("h3",i18n("Categories"));
341 }
342 addTag("p",event->categoriesStr());
343 }
344}
345void KOEventViewer::formatAttendees(Incidence *event)
346{
347 QPtrList<Attendee> attendees = event->attendees();
348 if (attendees.count()) {
349
350
351 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
352 addTag("h3",i18n("Organizer"));
353 mText.append("<ul><li>");
354#ifndef KORG_NOKABC
355
356 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
357 KABC::Addressee::List addressList;
358 addressList = add_book->findByEmail(event->organizer());
359 KABC::Addressee o = addressList.first();
360 if (!o.isEmpty() && addressList.size()<2) {
361 mText += "<a href=\"uid:" + o.uid() + "\">";
362 mText += o.formattedName();
363 mText += "</a>\n";
364 } else {
365 mText.append(event->organizer());
366 }
367#else
368 mText.append(event->organizer());
369#endif
370
371 if (iconPath) {
372 mText += " <a href=\"mailto:" + event->organizer() + "\">";
373 mText += "<IMG src=\"" + iconPath + "\">";
374 mText += "</a>\n";
375 }
376 mText.append("</li></ul>");
377
378 addTag("h3",i18n("Attendees"));
379 Attendee *a;
380 mText.append("<ul>");
381 for(a=attendees.first();a;a=attendees.next()) {
382#ifndef KORG_NOKABC
383 if (a->name().isEmpty()) {
384 addressList = add_book->findByEmail(a->email());
385 KABC::Addressee o = addressList.first();
386 if (!o.isEmpty() && addressList.size()<2) {
387 mText += "<a href=\"uid:" + o.uid() + "\">";
388 mText += o.formattedName();
389 mText += "</a>\n";
390 } else {
391 mText += "<li>";
392 mText.append(a->email());
393 mText += "\n";
394 }
395 } else {
396 mText += "<li><a href=\"uid:" + a->uid() + "\">";
397 if (!a->name().isEmpty()) mText += a->name();
398 else mText += a->email();
399 mText += "</a>\n";
400 }
401#else
402 //qDebug("nokabc ");
403 mText += "<li><a href=\"uid:" + a->uid() + "\">";
404 if (!a->name().isEmpty()) mText += a->name();
405 else mText += a->email();
406 mText += "</a>\n";
407#endif
408
409 if (!a->email().isEmpty()) {
410 if (iconPath) {
411 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
412 mText += "<IMG src=\"" + iconPath + "\">";
413 mText += "</a>\n";
414 }
415 }
416 if (a->status() != Attendee::NeedsAction )
417 mText +="[" + a->statusStr() + "] ";
418 if (a->role() == Attendee::Chair )
419 mText +="(" + a->roleStr().left(1) + ".)";
420 }
421 mText.append("</li></ul>");
422 }
423
424}
425void KOEventViewer::appendJournal(Journal *jour, int mode )
426{
427 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
428 if (mode == 0 )
429 addTag("h2",i18n("Journal from: "));
430 else {
431 if ( mode == 1 ) {
432 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
433 } else {
434 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
435 }
436 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
437 }
438 topLevelWidget()->setCaption("Journal Viewer");
439 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
440 if (!jour->description().isEmpty()) {
441 addTag("p",jour->description());
442 }
443 setText(mText);
444}
445
446void KOEventViewer::formatReadOnly(Incidence *event)
447{
448 if (event->isReadOnly()) {
449 addTag("p","<em>(" + i18n("read-only") + ")</em>");
450 }
451}
452void KOEventViewer::setSyncMode( bool b )
453{
454 mSyncMode = b;
455}
456
457
458void KOEventViewer::setTodo(Todo *event, bool clearV )
459{
460 if ( clearV )
461 clearEvents();
462 if ( mSyncMode ) {
463 if ( clearV )
464 appendTodo(event,1 );
465 else
466 appendTodo(event,2);
467 } else
468 appendTodo(event);
469}
470void KOEventViewer::setJournal(Journal *event, bool clearV )
471{
472 if ( clearV )
473 clearEvents();
474 if ( mSyncMode ) {
475 if ( clearV )
476 appendJournal(event, 1);
477 else
478 appendJournal(event, 2);
479 } else
480 appendJournal(event);
481}
482
483void KOEventViewer::setEvent(Event *event)
484{
485 clearEvents();
486 if ( mSyncMode )
487 appendEvent(event, 1);
488 else
489 appendEvent(event);
490}
491
492void KOEventViewer::addEvent(Event *event)
493{
494 if ( mSyncMode )
495 appendEvent(event, 2);
496 else
497 appendEvent(event);
498}
499
500void KOEventViewer::clearEvents(bool now)
501{
502 mText = "";
503 if (now) setText(mText);
504}
505
506void KOEventViewer::addText(QString text)
507{
508 mText.append(text);
509 setText(mText);
510}
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h
new file mode 100644
index 0000000..74f1135
--- a/dev/null
+++ b/korganizer/koeventviewer.h
@@ -0,0 +1,73 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef KOEVENTVIEWER_H
20#define KOEVENTVIEWER_H
21//
22// Viewer widget for events.
23//
24
25#include <qtextbrowser.h>
26
27#include <libkcal/event.h>
28#include <libkcal/journal.h>
29
30
31using namespace KCal;
32
33class KOEventViewer : public QTextBrowser {
34 Q_OBJECT
35 public:
36 KOEventViewer(QWidget *parent=0,const char *name=0);
37 virtual ~KOEventViewer();
38
39 void setSource(const QString &);
40 void setEvent(Event *event);
41 void addEvent(Event *event);
42 void setTodo(Todo *event, bool clearV = true );
43 void setJournal(Journal *jour, bool clearV = true );
44
45 void appendEvent(Event *event, int mode = 0 );
46 void appendTodo(Todo *event, int mode = 0 );
47 void appendJournal(Journal *jour, int mode = 0 );
48
49 void clearEvents(bool now=false);
50
51 void addText(QString text);
52 void setSyncMode( bool );
53 void setColorMode( int );
54
55 protected:
56 int mColorMode;
57 void addTag(const QString & tag,const QString & text);
58
59 void formatCategories(Incidence *event);
60 void formatAttendees(Incidence *event);
61 void formatReadOnly(Incidence *event);
62
63 private:
64 QTextBrowser *mEventTextView;
65 bool mSyncMode;
66
67 QString mText;
68 Incidence* mCurrentIncidence;
69 signals:
70 void launchaddressbook(QString uid);
71};
72
73#endif
diff --git a/korganizer/koeventviewer.moc b/korganizer/koeventviewer.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeventviewer.moc
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
new file mode 100644
index 0000000..64ab94d
--- a/dev/null
+++ b/korganizer/koeventviewerdialog.cpp
@@ -0,0 +1,240 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <klocale.h>
21
22#include <libkcal/event.h>
23#include <qpushbutton.h>
24
25#include "koeventviewer.h"
26#include "koprefs.h"
27#include <libkcal/todo.h>
28#include "qapp.h"
29
30#include "koeventviewerdialog.h"
31#include "koeventviewerdialog.moc"
32extern int globalFlagBlockAgenda;
33
34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
35 : KDialogBase(parent,name,
36#ifndef DESKTOP_VERSION
37 true ,
38#else
39 false,
40#endif
41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
42{
43
44 mEventViewer = new KOEventViewer(this);
45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
46 setMainWidget(mEventViewer);
47 setButtonText(Ok, i18n("Edit") );
48
49 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
50 SLOT(editIncidence()));
51 QObject::connect(this,SIGNAL(user1Clicked()),
52 SLOT(showIncidence()));
53 mIncidence = 0;
54 // TODO: Set a sensible size (based on the content?).
55 //showMaximized();
56 //qDebug("++++++++++++KOEventViewerDialog() ");
57 // if ( KOPrefs::instance()->mCompactDialogs ) {
58// setFixedSize( 240,284 );
59// move( 0, 15 );
60// } else {
61// setMinimumSize(300,200);
62// resize(320,300);
63// }
64 mSyncMode = false;
65 mSyncResult = 0;
66
67}
68
69KOEventViewerDialog::~KOEventViewerDialog()
70{
71 //qDebug("-------~KOEventViewerDialog() ");
72}
73void KOEventViewerDialog::showMe()
74{
75
76#ifdef DESKTOP_VERSION
77 show();
78#else
79 showMaximized();
80#endif
81 setFocus();
82 setActiveWindow();
83
84}
85void KOEventViewerDialog::setSyncMode( bool b )
86{
87 mSyncMode = b;
88 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
89 if ( mSyncMode ) {
90 findButton( Close )->setText( i18n("Cancel Sync"));
91 findButton( Ok )->setText( i18n("Remote"));
92 findButton( User1 )->setText( i18n("Local"));
93 } else {
94 findButton( Close )->setText( i18n("Close"));
95 findButton( Ok )->setText( i18n("Edit"));
96 findButton( User1 )->setText( i18n("Agenda"));
97 }
98 mEventViewer->setSyncMode( b );
99}
100void KOEventViewerDialog::setColorMode( int m )
101{
102 mEventViewer->setColorMode( m );
103}
104int KOEventViewerDialog::executeS( bool local )
105{
106 mSyncResult = 3;
107 if ( local )
108 findButton( User1 )->setFocus();
109 else
110 findButton( Ok )->setFocus();
111 exec();
112 return mSyncResult;
113}
114
115void KOEventViewerDialog::updateConfig()
116{
117 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
118
119}
120void KOEventViewerDialog::setEvent(Event *event)
121{
122 mEventViewer->setEvent(event);
123 mIncidence = event;
124 findButton( Close )->setFocus();
125}
126void KOEventViewerDialog::setIncidence(Incidence *in )
127{
128 if ( in->type() == "Event" )
129 setEvent( (Event*) in );
130 else if ( in->type() =="Todo" )
131 setTodo( (Todo*) in );
132 else if ( in->type() =="Journal" )
133 setJournal( (Journal*) in );
134}
135void KOEventViewerDialog::addIncidence(Incidence *in)
136{
137 if ( in->type() == "Event" )
138 addEvent( (Event*) in );
139 else if ( in->type() =="Todo" )
140 mEventViewer->setTodo( (Todo*) in, false );
141 else if ( in->type() =="Journal" )
142 mEventViewer->setJournal( (Journal*) in, false );
143 if ( mSyncMode ) {
144 findButton( User1 )->setFocus();
145 setCaption(i18n("Conflict! Please choose entry"));
146 }
147}
148
149void KOEventViewerDialog::addEvent(Event *event)
150{
151 mEventViewer->addEvent(event);
152 mIncidence = event;
153 findButton( Close )->setFocus();
154}
155
156void KOEventViewerDialog::setTodo(Todo *event)
157{
158 mEventViewer->setTodo(event);
159 mIncidence = (Incidence*)event;
160 findButton( Close )->setFocus();
161}
162void KOEventViewerDialog::setJournal(Journal *j)
163{
164 mEventViewer->setJournal(j);
165 mIncidence = (Incidence*)j;
166 findButton( Close )->setFocus();
167}
168
169void KOEventViewerDialog::addText(QString text)
170{
171 mEventViewer->addText(text);
172 findButton( Close )->setFocus();
173}
174void KOEventViewerDialog::editIncidence()
175{
176 if ( mSyncMode ) {
177 mSyncResult = 2;
178 accept();
179 return;
180 }
181 if ( mIncidence ){
182#ifndef DESKTOP_VERSION
183 hide();
184#endif
185 emit editIncidence( mIncidence );
186 }
187}
188void KOEventViewerDialog::showIncidence()
189{
190
191 if ( mSyncMode ) {
192 mSyncResult = 1;
193 accept();
194 return;
195 }
196
197 if ( mIncidence ){
198#ifndef DESKTOP_VERSION
199 hide();
200#endif
201 QDate date;
202 if ( mIncidence->type() == "Todo" ) {
203 if ( ((Todo*)mIncidence)->hasDueDate() )
204 date = ((Todo*)mIncidence)->dtDue().date();
205 else {
206 globalFlagBlockAgenda = 2;
207 emit showAgendaView( false );
208 return;
209 }
210 } else
211 date = mIncidence->dtStart().date();
212 globalFlagBlockAgenda = 1;
213 emit showAgendaView( false );
214 globalFlagBlockAgenda = 2;
215 emit jumpToTime( date );
216 }
217}
218void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
219{
220 switch ( e->key() ) {
221
222 case Qt::Key_A :
223 case Qt::Key_L :
224 showIncidence();
225 break;
226 case Qt::Key_E :
227 case Qt::Key_R :
228 editIncidence();
229 break;
230 case Qt::Key_C:
231 close();
232 break;
233 case Qt::Key_I:
234 accept();
235 break;
236 default:
237 break;
238 }
239
240}
diff --git a/korganizer/koeventviewerdialog.h b/korganizer/koeventviewerdialog.h
new file mode 100644
index 0000000..21cb3ee
--- a/dev/null
+++ b/korganizer/koeventviewerdialog.h
@@ -0,0 +1,70 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef KOEVENTVIEWERDIALOG_H
20#define KOEVENTVIEWERDIALOG_H
21//
22// Viewer dialog for events.
23//
24
25#include <qtextview.h>
26
27#include <kdialogbase.h>
28
29#include <libkcal/event.h>
30
31using namespace KCal;
32
33class KOEventViewer;
34
35class KOEventViewerDialog : public KDialogBase {
36 Q_OBJECT
37 public:
38 KOEventViewerDialog(QWidget *parent=0,const char *name=0);
39 virtual ~KOEventViewerDialog();
40
41 void setEvent(Event *event);
42 void addEvent(Event *event);
43 void setTodo(Todo *event);
44 void setJournal(Journal *journal);
45 void setIncidence(Incidence *inc);
46 void addIncidence(Incidence *inc);
47 void addText(QString text);
48 void showMe();
49 void setSyncMode( bool );
50 void setColorMode( int m );
51 int executeS( bool );
52 public slots:
53 void updateConfig();
54 signals:
55 void editIncidence( Incidence* );
56 void jumpToTime( const QDate &);
57 void showAgendaView( bool );
58private slots:
59 void editIncidence();
60 void showIncidence();
61
62 private:
63 bool mSyncMode;
64 int mSyncResult;
65 KOEventViewer *mEventViewer;
66 Incidence* mIncidence;
67 void keyPressEvent ( QKeyEvent * e );
68};
69
70#endif
diff --git a/korganizer/koeventviewerdialog.moc b/korganizer/koeventviewerdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koeventviewerdialog.moc
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
new file mode 100644
index 0000000..b22bc54
--- a/dev/null
+++ b/korganizer/kofilterview.cpp
@@ -0,0 +1,96 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qcheckbox.h>
25#include <qcombobox.h>
26#include <qpushbutton.h>
27
28#include <libkcal/calfilter.h>
29
30#include "kofilterview.h"
31#include "kofilterview.moc"
32
33KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
34 const char* name,WFlags fl )
35 : KOFilterView_base(parent,name,fl)
36{
37 mFilters = filterList;
38
39 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
40 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
41 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
42}
43
44KOFilterView::~KOFilterView()
45{
46 // no need to delete child widgets, Qt does it all for us
47}
48
49bool KOFilterView::filtersEnabled()
50{
51 return mEnabledCheck->isChecked();
52}
53
54void KOFilterView::setFiltersEnabled(bool set)
55{
56 mEnabledCheck->setChecked(set);
57 emit filterChanged();
58}
59
60
61void KOFilterView::updateFilters()
62{
63 mSelectionCombo->clear();
64
65 CalFilter *filter = mFilters->first();
66 while(filter) {
67 mSelectionCombo->insertItem(filter->name());
68 filter = mFilters->next();
69 }
70}
71
72CalFilter *KOFilterView::selectedFilter()
73{
74 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
75 return f;
76}
77
78void KOFilterView::setSelectedFilter(QString filterName)
79{
80 int filter_num = mSelectionCombo->count();
81 int i;
82 for (i=0;i<filter_num;i++) {
83 if (mSelectionCombo->text(i)==filterName)
84 mSelectionCombo->setCurrentItem(i);
85 }
86 emit filterChanged();
87}
88void KOFilterView::setSelectedFilter( int fil )
89{
90 if ( fil >= mSelectionCombo->count() )
91 return;
92 mSelectionCombo->setCurrentItem( fil );
93 emit filterChanged();
94}
95
96
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h
new file mode 100644
index 0000000..9ba2673
--- a/dev/null
+++ b/korganizer/kofilterview.h
@@ -0,0 +1,57 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOFILTERVIEW_H
24#define KOFILTERVIEW_H
25
26#include <qstring.h>
27
28#include "kofilterview_base.h"
29
30#include <libkcal/calfilter.h>
31
32using namespace KCal;
33
34class KOFilterView : public KOFilterView_base
35{
36 Q_OBJECT
37 public:
38 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0);
39 ~KOFilterView();
40
41 void updateFilters();
42
43 bool filtersEnabled();
44 void setFiltersEnabled(bool);
45 CalFilter *selectedFilter();
46 void setSelectedFilter(QString);
47 void setSelectedFilter( int );
48
49 signals:
50 void filterChanged();
51 void editFilters();
52
53 private:
54 QPtrList<CalFilter> *mFilters;
55};
56
57#endif // KOFILTERVIEW_H
diff --git a/korganizer/kofilterview.moc b/korganizer/kofilterview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kofilterview.moc
diff --git a/korganizer/kofilterview_base.cpp b/korganizer/kofilterview_base.cpp
new file mode 100644
index 0000000..6709630
--- a/dev/null
+++ b/korganizer/kofilterview_base.cpp
@@ -0,0 +1,62 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'kofilterview_base.ui'
3**
4** Created: Sat Jun 26 17:24:07 2004
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "kofilterview_base.h"
10
11#include <qcheckbox.h>
12#include <qcombobox.h>
13#include <qframe.h>
14#include <qpushbutton.h>
15#include <qlayout.h>
16#include <qvariant.h>
17#include <qtooltip.h>
18#include <qwhatsthis.h>
19
20/*
21 * Constructs a KOFilterView_base which is a child of 'parent', with the
22 * name 'name' and widget flags set to 'f'
23 */
24KOFilterView_base::KOFilterView_base( QWidget* parent, const char* name, WFlags fl )
25 : QWidget( parent, name, fl )
26{
27 if ( !name )
28 setName( "KOFilterView_base" );
29 resize( 100, 100 );
30 setCaption( tr( "Form2" ) );
31 KOFilterView_baseLayout = new QVBoxLayout( this );
32 KOFilterView_baseLayout->setSpacing( 2 );
33 KOFilterView_baseLayout->setMargin( 2 );
34
35 Frame11 = new QFrame( this, "Frame11" );
36 Frame11->setFrameShadow( QFrame::Raised );
37 Frame11->setFrameShape( QFrame::StyledPanel );
38 Frame11Layout = new QVBoxLayout( Frame11 );
39 Frame11Layout->setSpacing( 1 );
40 Frame11Layout->setMargin( 2 );
41
42 mEnabledCheck = new QCheckBox( Frame11, "mEnabledCheck" );
43 mEnabledCheck->setText( tr( "Filter enabled" ) );
44 Frame11Layout->addWidget( mEnabledCheck );
45
46 mSelectionCombo = new QComboBox( FALSE, Frame11, "mSelectionCombo" );
47 Frame11Layout->addWidget( mSelectionCombo );
48 KOFilterView_baseLayout->addWidget( Frame11 );
49
50 mEditButton = new QPushButton( this, "mEditButton" );
51 mEditButton->setText( tr( "Edit Filters" ) );
52 KOFilterView_baseLayout->addWidget( mEditButton );
53}
54
55/*
56 * Destroys the object and frees any allocated resources
57 */
58KOFilterView_base::~KOFilterView_base()
59{
60 // no need to delete child widgets, Qt does it all for us
61}
62
diff --git a/korganizer/kofilterview_base.h b/korganizer/kofilterview_base.h
new file mode 100644
index 0000000..ed084ce
--- a/dev/null
+++ b/korganizer/kofilterview_base.h
@@ -0,0 +1,40 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'kofilterview_base.ui'
3**
4** Created: Sat Jun 26 17:22:53 2004
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef KOFILTERVIEW_BASE_H
10#define KOFILTERVIEW_BASE_H
11
12#include <qvariant.h>
13#include <qwidget.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QCheckBox;
18class QComboBox;
19class QFrame;
20class QPushButton;
21
22class KOFilterView_base : public QWidget
23{
24 Q_OBJECT
25
26public:
27 KOFilterView_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
28 ~KOFilterView_base();
29
30 QFrame* Frame11;
31 QCheckBox* mEnabledCheck;
32 QComboBox* mSelectionCombo;
33 QPushButton* mEditButton;
34
35protected:
36 QVBoxLayout* KOFilterView_baseLayout;
37 QVBoxLayout* Frame11Layout;
38};
39
40#endif // KOFILTERVIEW_BASE_H
diff --git a/korganizer/kofilterview_base.ui b/korganizer/kofilterview_base.ui
new file mode 100644
index 0000000..b1b7c61
--- a/dev/null
+++ b/korganizer/kofilterview_base.ui
@@ -0,0 +1,96 @@
1<!DOCTYPE UI><UI>
2<class>KOFilterView_base</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>KOFilterView_base</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>100</width>
15 <height>100</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Form2</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <vbox>
29 <property stdset="1">
30 <name>margin</name>
31 <number>2</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>2</number>
36 </property>
37 <widget>
38 <class>QFrame</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>Frame11</cstring>
42 </property>
43 <property stdset="1">
44 <name>frameShadow</name>
45 <enum>Raised</enum>
46 </property>
47 <property stdset="1">
48 <name>frameShape</name>
49 <enum>StyledPanel</enum>
50 </property>
51 <property>
52 <name>layoutMargin</name>
53 </property>
54 <vbox>
55 <property stdset="1">
56 <name>margin</name>
57 <number>2</number>
58 </property>
59 <property stdset="1">
60 <name>spacing</name>
61 <number>1</number>
62 </property>
63 <widget>
64 <class>QCheckBox</class>
65 <property stdset="1">
66 <name>name</name>
67 <cstring>mEnabledCheck</cstring>
68 </property>
69 <property stdset="1">
70 <name>text</name>
71 <string>Filter enabled</string>
72 </property>
73 </widget>
74 <widget>
75 <class>QComboBox</class>
76 <property stdset="1">
77 <name>name</name>
78 <cstring>mSelectionCombo</cstring>
79 </property>
80 </widget>
81 </vbox>
82 </widget>
83 <widget>
84 <class>QPushButton</class>
85 <property stdset="1">
86 <name>name</name>
87 <cstring>mEditButton</cstring>
88 </property>
89 <property stdset="1">
90 <name>text</name>
91 <string>Edit Filters</string>
92 </property>
93 </widget>
94 </vbox>
95</widget>
96</UI>
diff --git a/korganizer/koglobals.cpp b/korganizer/koglobals.cpp
new file mode 100644
index 0000000..8016034
--- a/dev/null
+++ b/korganizer/koglobals.cpp
@@ -0,0 +1,143 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qapplication.h>
25
26#include <kdebug.h>
27#include <kglobal.h>
28#include <kconfig.h>
29#include <kstandarddirs.h>
30#include <kglobalsettings.h>
31#include <klocale.h>
32
33#include <kcalendarsystem.h>
34
35#ifndef KORG_NOKALARMD
36#include "kalarmdclient.h"
37#endif
38#include "simplealarmclient.h"
39
40#include "koglobals.h"
41#include "koprefs.h"
42
43class NopAlarmClient : public AlarmClient
44{
45 public:
46 void startDaemon() {}
47 bool setCalendars( const QStringList & ) { return false; }
48 bool addCalendar( const QString & ) { return false; }
49 bool removeCalendar( const QString & ) { return false; }
50 bool reloadCalendar( const QString & ) { return false; }
51};
52
53KOGlobals *KOGlobals::mSelf = 0;
54
55KOGlobals *KOGlobals::self()
56{
57 if (!mSelf) {
58 mSelf = new KOGlobals;
59 }
60
61 return mSelf;
62}
63
64KOGlobals::KOGlobals()
65{
66 KConfig *cfg = KOGlobals::config();
67
68 cfg->setGroup("General");
69 mCalendarSystem = KGlobal::locale()->calendar();
70
71 cfg->setGroup("AlarmDaemon");
72 QString alarmClient = cfg->readEntry( "Daemon", "kalarmd" );
73 if ( alarmClient == "simple" ) {
74 mAlarmClient = new SimpleAlarmClient;
75#ifndef KORG_NOKALARMD
76 } else if ( alarmClient == "kalarmd" ) {
77 mAlarmClient = new KalarmdClient;
78#endif
79 } else {
80 mAlarmClient = new NopAlarmClient;
81 }
82}
83
84KConfig* KOGlobals::config()
85{
86 static KConfig *mConfig = 0;
87 if (!mConfig) {
88 KOPrefs *p = KOPrefs::instance();
89 mConfig = p->getConfig();
90 //mConfig = new KConfig( locateLocal( "config", "korganizerrc" ) );
91 }
92 return mConfig;
93}
94
95KOGlobals::~KOGlobals()
96{
97 delete mAlarmClient;
98}
99
100const KCalendarSystem *KOGlobals::calendarSystem() const
101{
102 return mCalendarSystem;
103}
104
105AlarmClient *KOGlobals::alarmClient() const
106{
107 return mAlarmClient;
108}
109
110void KOGlobals::fitDialogToScreen( QWidget *wid, bool force )
111{
112 bool resized = false;
113
114 int w = wid->frameSize().width();
115 int h = wid->frameSize().height();
116
117 QRect desk = KGlobalSettings::desktopGeometry(wid);
118 if ( w > desk.width() ) {
119 w = desk.width();
120 resized = true;
121 }
122 // Yuck this hack is ugly. Is the -30 really to circumvent the size of
123 // kicker?!
124 if ( h > desk.height() - 30 ) {
125 h = desk.height() - 30;
126 resized = true;
127 }
128
129 if ( resized || force ) {
130 wid->resize( w, h );
131 wid->move( desk.x(), desk.y()+15 );
132 if ( force ) wid->setFixedSize( w, h );
133 }
134}
135
136bool KOGlobals::reverseLayout()
137{
138#if QT_VERSION >= 0x030000
139 return QApplication::reverseLayout();
140#else
141 return false;
142#endif
143}
diff --git a/korganizer/koglobals.h b/korganizer/koglobals.h
new file mode 100644
index 0000000..357ff5f
--- a/dev/null
+++ b/korganizer/koglobals.h
@@ -0,0 +1,59 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KORG_GLOBALS_H
24#define KORG_GLOBALS_H
25
26class KCalendarSystem;
27class AlarmClient;
28
29class KConfig;
30
31class KOGlobals
32{
33 public:
34 static KOGlobals *self();
35
36 enum { EVENTADDED, EVENTEDITED, EVENTDELETED };
37 enum { PRIORITY_MODIFIED, COMPLETION_MODIFIED, CATEGORY_MODIFIED, UNKNOWN_MODIFIED };
38
39 static void fitDialogToScreen( QWidget *widget, bool force=false );
40 static KConfig *config();
41
42 static bool reverseLayout();
43
44 const KCalendarSystem *calendarSystem() const;
45
46 AlarmClient *alarmClient() const;
47
48 protected:
49 KOGlobals();
50 ~KOGlobals();
51
52 private:
53 static KOGlobals *mSelf;
54
55 const KCalendarSystem *mCalendarSystem;
56 AlarmClient *mAlarmClient;
57};
58
59#endif
diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp
new file mode 100644
index 0000000..e10a188
--- a/dev/null
+++ b/korganizer/koincidenceeditor.cpp
@@ -0,0 +1,187 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qtooltip.h>
25#include <qframe.h>
26#include <qpixmap.h>
27#include <qlayout.h>
28#include <qwidgetstack.h>
29#include <qdatetime.h>
30#include <qdir.h>
31
32#include <kdebug.h>
33#include <klocale.h>
34#include <kstandarddirs.h>
35#include <kmessagebox.h>
36#include <kfiledialog.h>
37
38#include <libkdepim/categoryselectdialog.h>
39#include <libkdepim/kinputdialog.h>
40
41#include <libkcal/calendarlocal.h>
42#include <libkcal/icalformat.h>
43
44#include "koprefs.h"
45#include "koglobals.h"
46
47#include "koincidenceeditor.h"
48#include "koincidenceeditor.moc"
49
50KOIncidenceEditor::KOIncidenceEditor( const QString &caption,
51 Calendar *calendar, QWidget *parent ) :
52 KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok,
53 parent, caption, true, false ),
54 mSaveTemplateDialog( 0 )
55{
56 mCalendar = calendar;
57
58 setButtonText( Default, i18n("Template...") );
59
60 QString saveTemplateText;
61 // if ( KOPrefs::instance()->mCompactDialogs ) {
62// showButton( User1, false );
63// showButton( Apply, false );
64// } else {
65 showButton( Apply, false );
66 saveTemplateText = i18n("Ok+Agenda");
67 // }
68 setButtonText( User1, saveTemplateText );
69
70 //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this );
71 // KOGlobals::fitDialogToScreen( mCategoryDialog );
72
73 //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories()));
74
75 //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) );
76 // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) );
77 connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) );
78}
79
80KOIncidenceEditor::~KOIncidenceEditor()
81{
82 //delete mCategoryDialog;
83}
84
85void KOIncidenceEditor::setupAttendeesTab()
86{
87 QFrame *topFrame = addPage(i18n("Attendees"));
88
89 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
90
91 mDetails = new KOEditorDetails(spacingHint(),topFrame);
92 topLayout->addWidget(mDetails);
93}
94
95
96void KOIncidenceEditor::slotApply()
97{
98 processInput( false );
99}
100void KOIncidenceEditor::accept()
101{
102 slotOk();
103}
104void KOIncidenceEditor::slotOk()
105{
106 if ( processInput( false ) ) QDialog::accept();
107}
108
109void KOIncidenceEditor::updateCategoryConfig()
110{
111 qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! ");
112 //mCategoryDialog->updateCategoryConfig();
113}
114
115void KOIncidenceEditor::slotCancel()
116{
117 reject();
118}
119
120void KOIncidenceEditor::slotLoadTemplate()
121{
122 kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl;
123}
124void KOIncidenceEditor::slotShowIncidence()
125{
126
127 if ( processInput(true ) ) {
128 accept();
129 }
130}
131
132void KOIncidenceEditor::slotSaveTemplate()
133{
134 kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl;
135}
136
137void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type )
138{
139 if ( !mSaveTemplateDialog ) {
140 mSaveTemplateDialog = new SaveTemplateDialog( type, this );
141 connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ),
142 SLOT( saveTemplate( const QString & ) ) );
143 }
144 mSaveTemplateDialog->show();
145 mSaveTemplateDialog->raise();
146}
147
148void KOIncidenceEditor::saveAsTemplate( Incidence *incidence,
149 const QString &templateName )
150{
151 CalendarLocal cal;
152 cal.addIncidence( incidence );
153 ICalFormat format;
154 format.save( &cal, templateName );
155}
156
157QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type,
158 const QStringList &templates )
159{
160 // bool ok = false;
161// QString templateName = KInputDialog::getItem( i18n("Load Template"),
162// i18n("Select a template to load:"), templates, 0, &ok );
163// if ( !ok || templateName.isEmpty() ) return QString::null;
164
165// QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" +
166// templateName );
167// fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this );
168
169 // QString fileName;// =locateLocal( "templates", incidence->type() );
170// fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this );
171// if ( fileNamelength() == 0)
172// return QString::null;
173// if ( fileName.isEmpty() ) {
174// KMessageBox::error( this, i18n("Unable to find template '%1'.")
175// .arg( fileName ) );
176// return QString::null;
177// } else {
178// ICalFormat format;
179// if ( !format.load( cal, fileName ) ) {
180// KMessageBox::error( this, i18n("Error loading template file '%1'.")
181// .arg( fileName ) );
182// return QString::null;
183// }
184// }
185
186 return "";
187}
diff --git a/korganizer/koincidenceeditor.h b/korganizer/koincidenceeditor.h
new file mode 100644
index 0000000..bfd6cc6
--- a/dev/null
+++ b/korganizer/koincidenceeditor.h
@@ -0,0 +1,105 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOINCIDENCEEDITOR_H
24#define KOINCIDENCEEDITOR_H
25
26#include <kdialogbase.h>
27
28#include <libkcal/calendar.h>
29
30#include "koeditordetails.h"
31#include "savetemplatedialog.h"
32
33class QDateTime;
34namespace KPIM { class CategorySelectDialog; }
35
36using namespace KCal;
37
38/**
39 This is the base class for the calendar component editors.
40*/
41class KOIncidenceEditor : public KDialogBase
42{
43 Q_OBJECT
44 public:
45 /**
46 Construct new IncidenceEditor.
47 */
48 KOIncidenceEditor( const QString &caption, Calendar *calendar,
49 QWidget *parent );
50 virtual ~KOIncidenceEditor();
51
52 /** Initialize editor. This function creates the tab widgets. */
53 virtual void init() = 0;
54 void accept();
55 virtual void setCategories( QString )= 0;
56
57 virtual void reload() = 0;
58
59 public slots:
60 void updateCategoryConfig();
61
62 signals:
63 void editCategories();
64 void showAgendaView( bool );
65 void dialogClose( Incidence * );
66 void jumpToTime( const QDate & );
67
68 protected slots:
69 void slotApply();
70 void slotOk();
71 void slotCancel();
72 void slotShowIncidence();
73
74 virtual void slotLoadTemplate();
75 virtual void slotSaveTemplate();
76
77 virtual void saveTemplate( const QString & ) = 0;
78
79 protected:
80 void setupAttendeesTab();
81
82 void createSaveTemplateDialog( SaveTemplateDialog::IncidenceType );
83
84 QString loadTemplate( Calendar *cal, const QString &type,
85 const QStringList &templates );
86 void saveAsTemplate( Incidence *, const QString &name );
87
88 /**
89 Process user input and create or update event. Returns false if input is invalid.
90 */
91 virtual bool processInput( bool emitTime ) { return false; }
92
93 Calendar *mCalendar;
94
95 //KPIM::CategorySelectDialog *mCategoryDialog;
96
97 KOEditorDetails *mDetails;
98
99 private:
100 SaveTemplateDialog *mSaveTemplateDialog;
101};
102
103#endif
104
105
diff --git a/korganizer/koincidenceeditor.moc b/korganizer/koincidenceeditor.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koincidenceeditor.moc
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
new file mode 100644
index 0000000..579f24d
--- a/dev/null
+++ b/korganizer/kojournalview.cpp
@@ -0,0 +1,113 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24//
25// View of Journal entries
26
27#include <qlayout.h>
28#include <qpopupmenu.h>
29
30#include <klocale.h>
31#include <kdebug.h>
32#include "koprefs.h"
33
34#include <libkcal/calendar.h>
35
36#include "journalentry.h"
37
38#include "kojournalview.h"
39using namespace KOrg;
40#include "kojournalview.moc"
41
42KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
43 const char *name)
44 : KOrg::BaseView(calendar, parent, name)
45{
46 mEntry = new JournalEntry(calendar,this);
47 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
48 QBoxLayout *topLayout = new QVBoxLayout(this);
49 topLayout->addWidget(mEntry);
50 connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
51}
52
53KOJournalView::~KOJournalView()
54{
55}
56
57int KOJournalView::currentDateCount()
58{
59 return 0;
60}
61
62QPtrList<Incidence> KOJournalView::selectedIncidences()
63{
64 QPtrList<Incidence> eventList;
65
66 return eventList;
67}
68void KOJournalView::updateConfig()
69{
70 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
71}
72void KOJournalView::updateView()
73{
74 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
75}
76
77void KOJournalView::flushView()
78{
79 mEntry->flushEntry();
80}
81
82void KOJournalView::showDates(const QDate &start, const QDate &)
83{
84// kdDebug() << "KOJournalView::selectDates()" << endl;
85
86 mEntry->setDate(start);
87
88 Journal *j = calendar()->journal(start);
89 if (j) mEntry->setJournal(j);
90 else mEntry->clear();
91
92// emit incidenceSelected( 0 );
93}
94
95void KOJournalView::showEvents(QPtrList<Event>)
96{
97 // After new creation of list view no events are selected.
98// emit incidenceSelected( 0 );
99}
100
101void KOJournalView::changeEventDisplay(Event *, int /*action*/)
102{
103 updateView();
104}
105
106void KOJournalView::keyPressEvent ( QKeyEvent * e )
107{
108 //qDebug("keyPressEven ");
109 if ( e->state() == Qt::ControlButton ) {
110 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
111 e->ignore();
112 }
113}
diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h
new file mode 100644
index 0000000..1c0be82
--- a/dev/null
+++ b/korganizer/kojournalview.h
@@ -0,0 +1,67 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOJOURNALVIEW_H
24#define _KOJOURNALVIEW_H
25
26#include <korganizer/baseview.h>
27
28class JournalEntry;
29
30/**
31 * This class provides a journal view.
32
33 * @short View for Journal components.
34 * @author Cornelius Schumacher <schumacher@kde.org>
35 * @see KOBaseView
36 */
37class KOJournalView : public KOrg::BaseView
38{
39 Q_OBJECT
40 public:
41 KOJournalView(Calendar *calendar, QWidget *parent = 0,
42 const char *name = 0);
43 ~KOJournalView();
44
45 virtual int currentDateCount();
46 virtual QPtrList<Incidence> selectedIncidences();
47 DateList selectedDates()
48 {DateList q;
49 return q;};
50 signals:
51 void deleteJournal(Journal *);
52 public slots:
53 void updateView();
54 void flushView();
55 void updateConfig();
56 void showDates( const QDate &start, const QDate &end );
57 void showEvents(QPtrList<Event> eventList);
58
59 void changeEventDisplay(Event *, int);
60
61 private:
62 JournalEntry *mEntry;
63 void keyPressEvent ( QKeyEvent * ) ;
64
65};
66
67#endif
diff --git a/korganizer/kojournalview.moc b/korganizer/kojournalview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kojournalview.moc
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
new file mode 100644
index 0000000..b6061d0
--- a/dev/null
+++ b/korganizer/kolistview.cpp
@@ -0,0 +1,1062 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24
25#include <qlistview.h>
26#include <qlayout.h>
27#include <qlabel.h>
28#include <qpopupmenu.h>
29#include <qprogressbar.h>
30#include <qfileinfo.h>
31#include <qmessagebox.h>
32#include <qdialog.h>
33#include <qtextstream.h>
34#include <qdir.h>
35
36#include <klocale.h>
37#include <kdebug.h>
38#include <kiconloader.h>
39#include <kglobal.h>
40
41#include <libkcal/calendar.h>
42#include <libkcal/calendarlocal.h>
43#include <libkcal/icalformat.h>
44#include <libkcal/vcalformat.h>
45#include <libkcal/recurrence.h>
46#include <libkcal/filestorage.h>
47#include <libkdepim/categoryselectdialog.h>
48#ifndef DESKTOP_VERSION
49#include <qpe/qpeapplication.h>
50#else
51#include <qapplication.h>
52#endif
53
54#ifndef KORG_NOPRINTER
55#include "calprinter.h"
56#endif
57#include "koglobals.h"
58#include "koprefs.h"
59#include "kfiledialog.h"
60
61#include "kolistview.h"
62#include "kolistview.moc"
63
64ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
65{
66 mItem = item;
67 mDate = date;
68}
69
70ListItemVisitor::~ListItemVisitor()
71{
72}
73
74bool ListItemVisitor::visit(Event *e)
75{
76
77 bool ok = false;
78 QString start, end;
79 if ( e->doesRecur() ) {
80 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
81 if ( ok ) {
82 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
83 start = KGlobal::locale()->formatDate(d,true);
84 end = KGlobal::locale()->formatDate(d.addDays( days),true);
85 }
86
87 }
88 if ( ! ok ) {
89 start =e->dtStartDateStr();
90 end = e->dtEndDateStr();
91 }
92 mItem->setText(0,e->summary());
93 mItem->setText(1,start);
94 mItem->setText(2,e->dtStartTimeStr());
95 mItem->setText(3,end);
96 mItem->setText(4,e->dtEndTimeStr());
97 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
98 mItem->setText(6, e->recurrence()->recurrenceText());
99 mItem->setText(7,"---");
100 mItem->setText(8,"---");
101 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
102 mItem->setText(10,e->categoriesStr());
103
104 QString key;
105 QDate d = e->dtStart().date();
106 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
107 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
108 mItem->setSortKey(1,key);
109
110 d = e->dtEnd().date();
111 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
112 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
113 mItem->setSortKey(3,key);
114
115 return true;
116}
117
118bool ListItemVisitor::visit(Todo *t)
119{
120 mItem->setText(0,i18n("To-Do: %1").arg(t->summary()));
121 if (t->hasStartDate()) {
122 mItem->setText(1,t->dtStartDateStr());
123 if (t->doesFloat()) {
124 mItem->setText(2,"---");
125 } else {
126 mItem->setText(2,t->dtStartTimeStr());
127 }
128 } else {
129 mItem->setText(1,"---");
130 mItem->setText(2,"---");
131 }
132 mItem->setText(3,"---");
133 mItem->setText(4,"---");
134 mItem->setText(5,"---");
135 mItem->setText(6,"---");
136 if (t->hasDueDate()) {
137 mItem->setText(7,t->dtDueDateStr());
138 if (t->doesFloat()) {
139 mItem->setText(8,"---");
140 } else {
141 mItem->setText(8,t->dtDueTimeStr());
142 }
143 } else {
144 mItem->setText(7,"---");
145 mItem->setText(8,"---");
146 }
147 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
148 mItem->setText(10,t->categoriesStr());
149
150 QString key;
151 QDate d;
152 if (t->hasDueDate()) {
153 d = t->dtDue().date();
154 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
155 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
156 mItem->setSortKey(7,key);
157 }
158 if ( t->hasStartDate() ) {
159 d = t->dtStart().date();
160 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
161 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
162 mItem->setSortKey(1,key);
163 }
164 return true;
165}
166
167bool ListItemVisitor::visit(Journal * j)
168{
169 mItem->setText(0,i18n("Journal"));
170 mItem->setText(1,j->dtStartDateStr());
171 mItem->setText(2,"---");
172 mItem->setText(3,"---");
173 mItem->setText(4,"---");
174 mItem->setText(5,"---");
175 mItem->setText(6,"---");
176 mItem->setText(7,j->dtStartDateStr());
177 mItem->setText(8,"---");
178 mItem->setText(9,"---");
179
180 QString key;
181 QDate d = j->dtStart().date();
182 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
183 mItem->setSortKey(1,key);
184 mItem->setSortKey(7,key);
185
186 return true;
187}
188
189KOListView::KOListView(Calendar *calendar, QWidget *parent,
190 const char *name)
191 : KOEventView(calendar, parent, name)
192{
193 mActiveItem = 0;
194 mListView = new KOListViewListView(this);
195 mListView->addColumn(i18n("Summary"));
196 mListView->addColumn(i18n("Start Date"));
197 mListView->addColumn(i18n("Start Time"));
198 mListView->addColumn(i18n("End Date"));
199 mListView->addColumn(i18n("End Time"));
200 mListView->addColumn(i18n("Alarm")); // alarm set?
201 mListView->addColumn(i18n("Recurs")); // recurs?
202 mListView->addColumn(i18n("Due Date"));
203 mListView->addColumn(i18n("Due Time"));
204 mListView->addColumn(i18n("Cancelled"));
205 mListView->addColumn(i18n("Categories"));
206
207 mListView->setColumnAlignment(0,AlignLeft);
208 mListView->setColumnAlignment(1,AlignLeft);
209 mListView->setColumnAlignment(2,AlignHCenter);
210 mListView->setColumnAlignment(3,AlignLeft);
211 mListView->setColumnAlignment(4,AlignHCenter);
212 mListView->setColumnAlignment(5,AlignLeft);
213 mListView->setColumnAlignment(6,AlignLeft);
214 mListView->setColumnAlignment(7,AlignLeft);
215 mListView->setColumnAlignment(8,AlignLeft);
216 mListView->setColumnAlignment(9,AlignLeft);
217 mListView->setColumnAlignment(10,AlignLeft);
218
219 int iii = 0;
220 for ( iii = 0; iii< 10 ; ++iii )
221 mListView->setColumnWidthMode( iii, QListView::Manual );
222
223 QBoxLayout *layoutTop = new QVBoxLayout(this);
224 layoutTop->addWidget(mListView);
225 mListView->setFont ( KOPrefs::instance()->mListViewFont );
226 mPopupMenu = eventPopup();
227 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
228 i18n("Select all"),this,
229 SLOT(allSelection()),true);
230 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
231 i18n("Deselect All"),this,
232 SLOT(clearSelection()),true);
233 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
234 i18n("Delete all selected"),this,
235 SLOT(deleteAll()),true);
236 mPopupMenu->insertSeparator();
237 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
238 i18n("Save selected to file..."),this,
239 SLOT(saveToFile()),true);
240 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
241 i18n("Save Journal/Description..."),this,
242 SLOT(saveDescriptionToFile()),true);
243 mPopupMenu->insertSeparator();
244 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
245 i18n("Add Categ. to selected..."),this,
246 SLOT(addCat()),true);
247 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
248 i18n("Set Categ. for selected..."),this,
249 SLOT(setCat()),true);
250 mPopupMenu->insertSeparator();
251
252
253#ifndef DESKTOP_VERSION
254 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
255 i18n("Beam selected via IR"),this,
256 SLOT(beamSelected()),true);
257#endif
258 /*
259 mPopupMenu = new QPopupMenu;
260 mPopupMenu->insertItem(i18n("Edit Event"), this,
261 SLOT (editEvent()));
262 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
263 SLOT (deleteEvent()));
264 mPopupMenu->insertSeparator();
265 mPopupMenu->insertItem(i18n("Show Dates"), this,
266 SLOT(showDates()));
267 mPopupMenu->insertItem(i18n("Hide Dates"), this,
268 SLOT(hideDates()));
269 */
270 QObject::connect(mListView,SIGNAL( newEvent()),
271 this,SIGNAL(signalNewEvent()));
272 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
273 this,SLOT(defaultItemAction(QListViewItem *)));
274 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *,
275 const QPoint &, int )),
276 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
277 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
278 SLOT(processSelectionChange(QListViewItem *)));
279 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
280 SIGNAL(showIncidenceSignal(Incidence *)) );
281
282 readSettings(KOGlobals::config(),"KOListView Layout");
283}
284
285KOListView::~KOListView()
286{
287 delete mPopupMenu;
288}
289
290void KOListView::updateList()
291{
292 // qDebug(" KOListView::updateList() ");
293
294}
295
296void KOListView::addCat( )
297{
298 setCategories( false );
299}
300void KOListView::setCat()
301{
302 setCategories( true );
303}
304void KOListView::setCategories( bool removeOld )
305{
306
307 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
308 if (! csd->exec()) {
309 delete csd;
310 return;
311 }
312 QStringList catList = csd->selectedCategories();
313 delete csd;
314 // if ( catList.count() == 0 )
315 // return;
316 catList.sort();
317 QString categoriesStr = catList.join(",");
318 int i;
319 QStringList itemList;
320 QPtrList<KOListViewItem> sel ;
321 QListViewItem *qitem = mListView->firstChild ();
322 while ( qitem ) {
323 if ( qitem->isSelected() ) {
324 sel.append(((KOListViewItem *)qitem));
325 }
326 qitem = qitem->nextSibling();
327 }
328 KOListViewItem * item, *temp;
329 item = sel.first();
330 Incidence* inc;
331 while ( item ) {
332 inc = item->data();
333 if ( removeOld ) {
334 inc->setCategories( categoriesStr );
335 } else {
336 itemList = QStringList::split (",", inc->categoriesStr() );
337 for( i = 0; i< catList.count(); ++i ) {
338 if ( !itemList.contains (catList[i]))
339 itemList.append( catList[i] );
340 }
341 itemList.sort();
342 inc->setCategories( itemList.join(",") );
343 }
344 temp = item;
345 item = sel.next();
346 mUidDict.remove( inc->uid() );
347 delete temp;;
348 addIncidence( inc );
349 }
350}
351
352void KOListView::beamSelected()
353{
354 int icount = 0;
355 QPtrList<Incidence> delSel ;
356 QListViewItem *item = mListView->firstChild ();
357 while ( item ) {
358 if ( item->isSelected() ) {
359 delSel.append(((KOListViewItem *)item)->data());
360 ++icount;
361 }
362
363 item = item->nextSibling();
364 }
365 if ( icount ) {
366 emit beamIncidenceList( delSel );
367 return;
368 QString fn ;
369 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
370 QString mes;
371 bool createbup = true;
372 if ( createbup ) {
373 QString description = "\n";
374 CalendarLocal* cal = new CalendarLocal();
375 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
376 Incidence *incidence = delSel.first();
377 while ( incidence ) {
378 Incidence *in = incidence->clone();
379 description += in->summary() + "\n";
380 cal->addIncidence( in );
381 incidence = delSel.next();
382 }
383 FileStorage storage( cal, fn, new VCalFormat );
384 storage.save();
385 delete cal;
386 mes = i18n("KO/Pi: Ready for beaming");
387 topLevelWidget()->setCaption(mes);
388
389#ifndef DESKTOP_VERSION
390 Ir *ir = new Ir( this );
391 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
392 ir->send( fn, description, "text/x-vCalendar" );
393#endif
394 }
395 }
396}
397void KOListView::beamDone( Ir *ir )
398{
399#ifndef DESKTOP_VERSION
400 delete ir;
401#endif
402 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
403}
404
405void KOListView::saveDescriptionToFile()
406{
407
408 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
409 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
410 i18n("Continue"), i18n("Cancel"), 0,
411 0, 1 );
412 if ( result != 0 ) {
413 return;
414 }
415 int icount = 0;
416 QPtrList<Incidence> delSel ;
417 QListViewItem *item = mListView->firstChild ();
418 while ( item ) {
419 if ( item->isSelected() ) {
420 delSel.append(((KOListViewItem *)item)->data());
421 ++icount;
422 }
423
424 item = item->nextSibling();
425 }
426 if ( icount ) {
427 QString fn = KOPrefs::instance()->mLastSaveFile;
428 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
429
430 if ( fn == "" )
431 return;
432 QFileInfo info;
433 info.setFile( fn );
434 QString mes;
435 bool createbup = true;
436 if ( info. exists() ) {
437 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
438 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
439 i18n("Overwrite!"), i18n("Cancel"), 0,
440 0, 1 );
441 if ( result != 0 ) {
442 createbup = false;
443 }
444 }
445 if ( createbup ) {
446 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
447 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
448 Incidence *incidence = delSel.first();
449 icount = 0;
450 while ( incidence ) {
451 if ( incidence->type() == "Journal" ) {
452 text += "\n************************************\n";
453 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
454 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
455 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
456 ++icount;
457
458 } else {
459 if ( !incidence->description().isEmpty() ) {
460 text += "\n************************************\n";
461 if ( incidence->type() == "Todo" )
462 text += i18n("To-Do: ");
463 text += incidence->summary();
464 if ( incidence->hasStartDate() )
465 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
466 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
467 if ( !incidence->location().isEmpty() )
468 text += "\n" +i18n("Location: ") + incidence->location();
469 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
470 ++icount;
471
472 }
473 }
474 incidence = delSel.next();
475 }
476 QFile file( fn );
477 if (!file.open( IO_WriteOnly ) ) {
478 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
479 return;
480 }
481 QTextStream ts( &file );
482 ts << text;
483 file.close();
484 //qDebug("%s ", text.latin1());
485 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
486 KOPrefs::instance()->mLastSaveFile = fn;
487 topLevelWidget()->setCaption(mes);
488 }
489 }
490}
491void KOListView::saveToFile()
492{
493
494 int icount = 0;
495 QPtrList<Incidence> delSel ;
496 QListViewItem *item = mListView->firstChild ();
497 while ( item ) {
498 if ( item->isSelected() ) {
499 delSel.append(((KOListViewItem *)item)->data());
500 ++icount;
501 }
502
503 item = item->nextSibling();
504 }
505 if ( icount ) {
506 QString fn = KOPrefs::instance()->mLastSaveFile;
507 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
508
509 if ( fn == "" )
510 return;
511 QFileInfo info;
512 info.setFile( fn );
513 QString mes;
514 bool createbup = true;
515 if ( info. exists() ) {
516 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
517 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
518 i18n("Overwrite!"), i18n("Cancel"), 0,
519 0, 1 );
520 if ( result != 0 ) {
521 createbup = false;
522 }
523 }
524 if ( createbup ) {
525 CalendarLocal cal;
526 cal.setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
527 Incidence *incidence = delSel.first();
528 while ( incidence ) {
529 cal.addIncidence( incidence->clone() );
530 incidence = delSel.next();
531 }
532 ICalFormat format;
533 format.save( &cal, fn );
534 mes = i18n("KO/Pi:Saved %1").arg(fn );
535 KOPrefs::instance()->mLastSaveFile = fn;
536 topLevelWidget()->setCaption(mes);
537 }
538 }
539}
540void KOListView::deleteAll()
541{
542 int icount = 0;
543 QPtrList<Incidence> delSel ;
544 QListViewItem *item = mListView->firstChild ();
545 while ( item ) {
546 if ( item->isSelected() ) {
547 delSel.append(((KOListViewItem *)item)->data());
548 ++icount;
549 }
550
551 item = item->nextSibling();
552 }
553 if ( icount ) {
554 Incidence *incidence = delSel.first();
555 Incidence *toDelete;
556 KOPrefs *p = KOPrefs::instance();
557 bool confirm = p->mConfirm;
558 QString mess;
559 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
560 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
561 p->mConfirm = false;
562 int delCounter = 0;
563 QDialog dia ( this, "p-dialog", true );
564 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
565 QVBoxLayout lay( &dia );
566 lay.setMargin(7);
567 lay.setSpacing(7);
568 lay.addWidget( &lab);
569 QProgressBar bar( icount, &dia );
570 lay.addWidget( &bar);
571 int w = 220;
572 int h = 50;
573 int dw = QApplication::desktop()->width();
574 int dh = QApplication::desktop()->height();
575 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
576 //dia.resize( 240,50 );
577 dia.show();
578
579 while ( incidence ) {
580 bar.setProgress( delCounter );
581 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
582 dia.setCaption( mess );
583 qApp->processEvents();
584 toDelete = (incidence);
585 incidence = delSel.next();
586 emit deleteIncidenceSignal(toDelete );
587 if ( dia.result() != 0 )
588 break;
589
590 }
591 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
592 topLevelWidget ()->setCaption( mess );
593 p->mConfirm = confirm;
594 }
595 }
596
597
598}
599int KOListView::maxDatesHint()
600{
601 return 0;
602}
603
604int KOListView::currentDateCount()
605{
606 return 0;
607}
608
609QPtrList<Incidence> KOListView::selectedIncidences()
610{
611 QPtrList<Incidence> eventList;
612 QListViewItem *item = mListView->firstChild ();
613 while ( item ) {
614 if ( item->isSelected() ) {
615 eventList.append(((KOListViewItem *)item)->data());
616 }
617
618 item = item->nextSibling();
619 }
620
621 // // QListViewItem *item = mListView->selectedItem();
622 //if (item) eventList.append(((KOListViewItem *)item)->data());
623
624 return eventList;
625}
626
627DateList KOListView::selectedDates()
628{
629 DateList eventList;
630 return eventList;
631}
632
633void KOListView::showDates(bool show)
634{
635 // Shouldn't we set it to a value greater 0? When showDates is called with
636 // show == true at first, then the columnwidths are set to zero.
637 static int oldColWidth1 = 0;
638 static int oldColWidth3 = 0;
639
640 if (!show) {
641 oldColWidth1 = mListView->columnWidth(1);
642 oldColWidth3 = mListView->columnWidth(3);
643 mListView->setColumnWidth(1, 0);
644 mListView->setColumnWidth(3, 0);
645 } else {
646 mListView->setColumnWidth(1, oldColWidth1);
647 mListView->setColumnWidth(3, oldColWidth3);
648 }
649 mListView->repaint();
650}
651
652void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
653 const QDate &td)
654{
655#ifndef KORG_NOPRINTER
656 calPrinter->preview(CalPrinter::Day, fd, td);
657#endif
658}
659
660void KOListView::showDates()
661{
662 showDates(true);
663}
664
665void KOListView::hideDates()
666{
667 showDates(false);
668}
669
670void KOListView::updateView()
671{
672 mListView->setFocus();
673 if ( mListView->firstChild () )
674 mListView->setCurrentItem( mListView->firstChild () );
675}
676void KOListView::updateConfig()
677{
678
679 mListView->setFont ( KOPrefs::instance()->mListViewFont );
680 updateView();
681
682}
683void KOListView::setStartDate(const QDate &start)
684{
685 mStartDate = start;
686}
687
688void KOListView::showDates(const QDate &start, const QDate &end)
689{
690 clear();
691 mStartDate = start;
692 QDate date = start;
693 while( date <= end ) {
694 addEvents(calendar()->events(date));
695 addTodos(calendar()->todos(date));
696 date = date.addDays( 1 );
697 }
698 emit incidenceSelected( 0 );
699 updateView();
700
701}
702
703void KOListView::addEvents(QPtrList<Event> eventList)
704{
705 Event *ev;
706 for(ev = eventList.first(); ev; ev = eventList.next()) {
707 addIncidence(ev);
708 }
709 if ( !mListView->currentItem() ){
710 updateView();
711 }
712}
713
714void KOListView::addTodos(QPtrList<Todo> eventList)
715{
716 Todo *ev;
717 for(ev = eventList.first(); ev; ev = eventList.next()) {
718 addIncidence(ev);
719 }
720 if ( !mListView->currentItem() ){
721 updateView();
722 }
723}
724void KOListView::addJournals(QPtrList<Journal> eventList)
725{
726 Journal *ev;
727 for(ev = eventList.first(); ev; ev = eventList.next()) {
728 addIncidence(ev);
729 }
730 if ( !mListView->currentItem() ){
731 updateView();
732 }
733}
734
735void KOListView::addIncidence(Incidence *incidence)
736{
737 if ( mUidDict.find( incidence->uid() ) ) return;
738
739 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
740 mUidDict.insert( incidence->uid(), incidence );
741
742 KOListViewItem *item = new KOListViewItem( incidence, mListView );
743 ListItemVisitor v(item, mStartDate );
744 if (incidence->accept(v)) return;
745 else delete item;
746 //qDebug("delete item ");
747}
748
749void KOListView::showEvents(QPtrList<Event> eventList)
750{
751 clear();
752
753 addEvents(eventList);
754
755 // After new creation of list view no events are selected.
756 emit incidenceSelected( 0 );
757}
758int KOListView::count()
759{
760 return mListView->childCount();
761}
762
763void KOListView::changeEventDisplay(Event *event, int action)
764{
765 KOListViewItem *item;
766
767 switch(action) {
768 case KOGlobals::EVENTADDED:
769 addIncidence( event );
770 break;
771 case KOGlobals::EVENTEDITED:
772 item = getItemForEvent(event);
773 if (item) {
774 mUidDict.remove( event->uid() );
775 delete item;
776 addIncidence( event );
777 }
778 break;
779 case KOGlobals::EVENTDELETED:
780 item = getItemForEvent(event);
781 if (item) {
782 mUidDict.remove( event->uid() );
783 delete item;
784 }
785 break;
786 default:
787 ;
788 }
789}
790
791KOListViewItem *KOListView::getItemForEvent(Event *event)
792{
793 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
794 while (item) {
795 if (item->data() == event) return item;
796 item = (KOListViewItem *)item->nextSibling();
797 }
798 return 0;
799}
800
801void KOListView::defaultItemAction(QListViewItem *i)
802{
803 KOListViewItem *item = static_cast<KOListViewItem *>( i );
804 if ( item ) defaultAction( item->data() );
805
806}
807
808void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
809{
810 mActiveItem = (KOListViewItem *)item;
811 if (mActiveItem) {
812 Incidence *incidence = mActiveItem->data();
813 mPopupMenu->showIncidencePopup(incidence);
814
815 /*
816 if ( incidence && incidence->type() == "Event" ) {
817 Event *event = static_cast<Event *>( incidence );
818 mPopupMenu->showEventPopup(event);
819 }
820 */
821 }
822}
823
824void KOListView::readSettings(KConfig *config, QString setting)
825{
826 // qDebug("KOListView::readSettings ");
827 mListView->restoreLayout(config,setting);
828}
829
830void KOListView::writeSettings(KConfig *config, QString setting)
831{
832 // qDebug("KOListView::writeSettings ");
833 mListView->saveLayout(config, setting);
834}
835
836void KOListView::processSelectionChange(QListViewItem *)
837{
838
839 KOListViewItem *item =
840 static_cast<KOListViewItem *>( mListView->currentItem() );
841
842 if ( !item ) {
843 emit incidenceSelected( 0 );
844 } else {
845 emit incidenceSelected( item->data() );
846 }
847}
848
849void KOListView::clearSelection()
850{
851 mListView->selectAll( false );
852}
853void KOListView::allSelection()
854{
855 mListView->selectAll( true );
856}
857
858void KOListView::clear()
859{
860 mListView->clear();
861 mUidDict.clear();
862}
863
864Incidence* KOListView::currentItem()
865{
866 if ( mListView->currentItem() )
867 return ((KOListViewItem*) mListView->currentItem())->data();
868 return 0;
869}
870void KOListView::keyPressEvent ( QKeyEvent *e)
871{
872
873 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
874 deleteAll();
875 return;
876 }
877
878 e->ignore();
879}
880void KOListViewListView::keyPressEvent ( QKeyEvent *e)
881{
882
883 switch ( e->key() ) {
884 case Qt::Key_Down:
885 if ( e->state() == ShiftButton ) {
886 QListViewItem* cn = currentItem();
887 if ( !cn )
888 cn = firstChild();
889 if ( !cn )
890 return;
891 while ( cn->nextSibling() )
892 cn = cn->nextSibling();
893 setCurrentItem ( cn );
894 ensureItemVisible ( cn );
895
896 e->accept();
897 return;
898 }
899 if ( e->state() == ControlButton ) {
900 int count = childCount ();
901 int jump = count / 5;
902 QListViewItem* cn;
903 cn = currentItem();
904 if ( ! cn )
905 return;
906 if ( jump == 0 )
907 jump = 1;
908 while ( jump && cn->nextSibling() ) {
909 cn = cn->nextSibling();
910 --jump;
911 }
912 setCurrentItem ( cn );
913 ensureItemVisible ( cn );
914
915 } else
916 QListView::keyPressEvent ( e ) ;
917 e->accept();
918 break;
919
920 case Qt::Key_Up:
921 if ( e->state() == ShiftButton ) {
922 QListViewItem* cn = firstChild();
923 if ( cn ) {
924 setCurrentItem ( cn );
925 ensureItemVisible ( cn );
926 }
927 e->accept();
928 return;
929 }
930 if ( e->state() == ControlButton ) {
931 int count = childCount ();
932 int jump = count / 5;
933 QListViewItem* cn;
934 cn = currentItem();
935 if ( ! cn )
936 return;
937 if ( jump == 0 )
938 jump = 1;
939 while ( jump && cn->itemAbove ()) {
940 cn = cn->itemAbove ();
941 --jump;
942 }
943 setCurrentItem ( cn );
944 ensureItemVisible ( cn );
945 } else
946 QListView::keyPressEvent ( e ) ;
947 e->accept();
948 break;
949 case Qt::Key_I: {
950 QListViewItem* cn;
951 cn = currentItem();
952 if ( cn ) {
953 KOListViewItem* ci = (KOListViewItem*)( cn );
954 if ( ci ){
955 emit showIncidence( ci->data());
956 cn = cn->nextSibling();
957 if ( cn ) {
958 setCurrentItem ( cn );
959 ensureItemVisible ( cn );
960 }
961 }
962 }
963 e->accept();
964 }
965 break;
966 case Qt::Key_Return:
967 case Qt::Key_Enter:
968 {
969 QListViewItem* cn;
970 cn = currentItem();
971 if ( cn ) {
972 KOListViewItem* ci = (KOListViewItem*)( cn );
973 if ( ci ){
974 if ( e->state() == ShiftButton )
975 ci->setSelected( false );
976 else
977 ci->setSelected( true );
978 cn = cn->nextSibling();
979 if ( cn ) {
980 setCurrentItem ( cn );
981 ensureItemVisible ( cn );
982 }
983 }
984 }
985 e->accept();
986 }
987 break;
988 default:
989 e->ignore();
990 }
991}
992KOListViewListView::KOListViewListView(KOListView * lv )
993 : KListView( lv )
994{
995#ifndef DESKTOP_VERSION
996 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
997#endif
998 setSelectionMode( QListView::Multi );
999 setMultiSelection( true);
1000 mAllowPopupMenu = true;
1001 mMouseDown = false;
1002
1003}
1004void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1005{
1006 if (!e) return;
1007 QPoint vp = contentsToViewport(e->pos());
1008 QListViewItem *item = itemAt(vp);
1009 if (!item) {
1010 emit newEvent();
1011 return;
1012 }
1013 KListView::contentsMouseDoubleClickEvent(e);
1014}
1015
1016
1017void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1018{
1019 //qDebug("contentsMousePressEvent++++ ");
1020 if (! mMouseDown ) {
1021 mAllowPopupMenu = true;
1022 mYMousePos = mapToGlobal( (e->pos())).y();
1023 }
1024 if ( e->button() == RightButton && mMouseDown )
1025 return;
1026 if ( e->button() == LeftButton )
1027 mMouseDown = true;
1028 KListView::contentsMousePressEvent( e );
1029}
1030void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1031{
1032 //qDebug("contentsMouseReleaseEv---- ");
1033 if ( ! mMouseDown ) {
1034 if ( e->button() == RightButton && ! mAllowPopupMenu )
1035 return;
1036 QListViewItem* ci = currentItem();
1037 if ( ci )
1038 ci->setSelected( true );
1039 KListView::contentsMouseReleaseEvent(e);
1040 return;
1041 }
1042 if ( e->button() == LeftButton )
1043 mMouseDown = false;
1044 if ( e->button() == RightButton && ! mAllowPopupMenu )
1045 return;
1046 if ( e->button() == RightButton ) {
1047 QListViewItem* ci = currentItem();
1048 if ( ci )
1049 ci->setSelected( true );
1050 }
1051 KListView::contentsMouseReleaseEvent(e);
1052}
1053void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1054{
1055 // qDebug("contentsMouseMoveEv....... ");
1056 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1057 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1058 if ( diff < 0 ) diff = -diff;
1059 if ( diff > 20 )
1060 mAllowPopupMenu = false;
1061 KListView::contentsMouseMoveEvent(e);
1062}
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
new file mode 100644
index 0000000..23afdb1
--- a/dev/null
+++ b/korganizer/kolistview.h
@@ -0,0 +1,167 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef _KOLISTVIEW_H
25#define _KOLISTVIEW_H
26
27#include <qlistview.h>
28#include <qmap.h>
29#include <qdict.h>
30
31#include <klistview.h>
32
33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h>
35#else
36#define Ir char
37#endif
38#include <libkcal/incidence.h>
39
40#include "koeventview.h"
41#include "customlistviewitem.h"
42
43using namespace KCal;
44
45typedef CustomListViewItem<Incidence *> KOListViewItem;
46
47/**
48 This class provides the initialisation of a KOListViewItem for calendar
49 components using the Incidence::Visitor.
50*/
51class ListItemVisitor : public Incidence::Visitor
52{
53 public:
54 ListItemVisitor(KOListViewItem *, QDate d);
55 ~ListItemVisitor();
56
57 bool visit(Event *);
58 bool visit(Todo *);
59 bool visit(Journal *);
60
61 private:
62 KOListViewItem *mItem;
63 QDate mDate;
64};
65
66/**
67 This class provides a multi-column list view of events. It can
68 display events from one particular day or several days, it doesn't
69 matter. To use a view that only handles one day at a time, use
70 KODayListView.
71
72 @short multi-column list view of various events.
73 @author Preston Brown <pbrown@kde.org>
74 @see KOBaseView, KODayListView
75*/
76class KOListView;
77
78class KOListViewListView : public KListView
79{
80 Q_OBJECT
81 public:
82 KOListViewListView(KOListView * lv );
83 signals:
84 void newEvent();
85 void showIncidence( Incidence* );
86 private:
87 void keyPressEvent ( QKeyEvent * ) ;
88 void contentsMouseDoubleClickEvent(QMouseEvent *e);
89 void contentsMousePressEvent(QMouseEvent *e);
90 void contentsMouseReleaseEvent(QMouseEvent *e);
91 void contentsMouseMoveEvent(QMouseEvent *e);
92 bool mAllowPopupMenu;
93 bool mMouseDown;
94 int mYMousePos;
95};
96
97class KOListView : public KOEventView
98{
99 Q_OBJECT
100 public:
101 KOListView(Calendar *calendar, QWidget *parent = 0,
102 const char *name = 0);
103 ~KOListView();
104
105 virtual int maxDatesHint();
106 virtual int currentDateCount();
107 virtual QPtrList<Incidence> selectedIncidences();
108 virtual DateList selectedDates();
109
110 void showDates(bool show);
111 Incidence* currentItem();
112 void addTodos(QPtrList<Todo> eventList);
113 void addJournals(QPtrList<Journal> eventList);
114 virtual void printPreview(CalPrinter *calPrinter,
115 const QDate &, const QDate &);
116
117 void readSettings(KConfig *config, QString setting = "KOListView Layout");
118 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
119 void updateList();
120 void setStartDate(const QDate &start);
121 int count();
122 signals:
123 void signalNewEvent();
124 void beamIncidenceList(QPtrList<Incidence>);
125
126 public slots:
127 virtual void updateView();
128 virtual void showDates(const QDate &start, const QDate &end);
129 virtual void showEvents(QPtrList<Event> eventList);
130 void clearSelection();
131 void allSelection();
132
133 void clear();
134 void beamDone( Ir *ir );
135 void showDates();
136 void hideDates();
137 void deleteAll();
138 void saveToFile();
139 void saveDescriptionToFile();
140 void beamSelected();
141 void updateConfig();
142 void addCat();
143 void setCat();
144 void setCategories( bool removeOld );
145 void changeEventDisplay(Event *, int);
146
147 void defaultItemAction(QListViewItem *item);
148 void popupMenu(QListViewItem *item,const QPoint &,int);
149
150 protected slots:
151 void processSelectionChange(QListViewItem *);
152
153 protected:
154 void addEvents(QPtrList<Event> eventList);
155 void addIncidence(Incidence *);
156 KOListViewItem *getItemForEvent(Event *event);
157
158 private:
159 KOListViewListView *mListView;
160 KOEventPopupMenu *mPopupMenu;
161 KOListViewItem *mActiveItem;
162 QDict<Incidence> mUidDict;
163 QDate mStartDate;
164 void keyPressEvent ( QKeyEvent * ) ;
165};
166
167#endif
diff --git a/korganizer/kolistview.moc b/korganizer/kolistview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kolistview.moc
diff --git a/korganizer/kolocationbox.cpp b/korganizer/kolocationbox.cpp
new file mode 100644
index 0000000..f8fee2e
--- a/dev/null
+++ b/korganizer/kolocationbox.cpp
@@ -0,0 +1,96 @@
1/*
2 Copyright (c) 2004 Dirk Loesche <dirk.loesche@bigfoot.de>
3
4 This file is part of KOrganizer/PI
5 KOrganizer Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
6 KOrganizer/PI Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
25*/
26
27#include "kolocationbox.h"
28#include <qstring.h>
29#include <qlineedit.h>
30#include <qapplication.h>
31
32
33KOLocationBox::KOLocationBox( bool rw , QWidget *parent , int _maxItems) :
34 QComboBox( rw , parent )
35{
36 maxItems = _maxItems;
37 maxItems = 50; // sorry - hack from me to set maxitems globally to 30
38 setInsertionPolicy(AtTop);
39 setDuplicatesEnabled( FALSE );
40 setMaxCount( maxItems );
41 setAutoCompletion( TRUE );
42
43}
44
45KOLocationBox::~KOLocationBox()
46{
47}
48
49void KOLocationBox::load(int what)
50{
51 clear();
52 // qDebug("load %d ",what );
53 switch(what) {
54 case LOCATION:
55 insertStringList( KOPrefs::instance()->mLocationDefaults, 0 );
56// insertStringList( KOPrefs::instance()->mLocationUserDefaults, 0 );
57 break; // don't disable
58 case SUMMARYEVENT:
59 insertStringList( KOPrefs::instance()->mEventSummaryUser, 0 );
60 break; // don't disable
61 case SUMMARYTODO:
62 insertStringList( KOPrefs::instance()->mTodoSummaryUser, 0 );
63 break; // don't disable
64 }
65}
66
67void KOLocationBox::save(int what)
68{
69 strlist.clear();
70 for( int l = 0; l < count() ; l++ ) {
71 strlist << text( l );
72 }
73 // strlist.sort();
74 QString currentLine = lineEdit()->text();
75 if ( !strlist.contains( currentLine ) )
76 strlist.prepend( currentLine );
77 // qDebug("save %d ", what);
78 switch(what) {
79 case LOCATION:
80 KOPrefs::instance()->mLocationDefaults = strlist;
81// KOPrefs::instance()->mLocationUserDefaults = strlist;
82 break; // don't disable
83 case SUMMARYEVENT:
84 KOPrefs::instance()->mEventSummaryUser = strlist;
85 break; // don't disable
86 case SUMMARYTODO:
87 KOPrefs::instance()->mTodoSummaryUser = strlist;
88 break; // don't disable
89 }
90}
91
92void KOLocationBox::clearItems(int what)
93{
94 clear();
95 save(what);
96}
diff --git a/korganizer/kolocationbox.h b/korganizer/kolocationbox.h
new file mode 100644
index 0000000..be8ea86
--- a/dev/null
+++ b/korganizer/kolocationbox.h
@@ -0,0 +1,55 @@
1/*
2 File Copyright (c) 2004 Dirk Loesche <dirk.loesche@bigfoot.de>
3
4 This file is part of KOrganizer/PI
5 KOrganizer Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
6 KOrganizer/PI Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
25*/
26
27#ifndef KOLOCATIONBOX_H
28#define KOLOCATIONBOX_H
29
30#include <qcombobox.h>
31#include "koprefs.h"
32
33class KOLocationBox : public QComboBox
34{
35 public:
36 KOLocationBox( bool rw , QWidget *parent , int _maxItems );
37 virtual ~KOLocationBox();
38
39 enum {LOCATION, SUMMARYEVENT, SUMMARYTODO};
40
41 public slots:
42 void load(int);
43 void save(int);
44 void clearItems(int); // clear listbox and config rc items
45
46 protected:
47// void focusOutEvent( QFocusEvent * );
48// void timerEvent( QTimerEvent * );
49
50 private:
51 int maxItems; // maximal listbox items
52 QStringList strlist; // temporary stringlist
53};
54
55#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
new file mode 100644
index 0000000..c4bc51b
--- a/dev/null
+++ b/korganizer/komonthview.cpp
@@ -0,0 +1,1057 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <qpopupmenu.h>
21#include <qfont.h>
22#include <qfontmetrics.h>
23#include <qkeycode.h>
24#include <qhbox.h>
25#include <qvbox.h>
26#include <qpushbutton.h>
27#include <qtooltip.h>
28#include <qpainter.h>
29#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h>
32#else
33#include <qapplication.h>
34#endif
35
36#include <kdebug.h>
37#include <klocale.h>
38#include <kglobal.h>
39#include <kconfig.h>
40#include <kiconloader.h>
41
42#include <kcalendarsystem.h>
43
44#ifndef KORG_NOPRINTER
45#include "calprinter.h"
46#endif
47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS
49#include "kocore.h"
50#endif
51#include "koglobals.h"
52#include <libkdepim/kincidenceformatter.h>
53
54#include "komonthview.h"
55#include "komonthview.moc"
56
57#define PIXMAP_SIZE 5
58
59class KNOWhatsThis :public QWhatsThis
60{
61public:
62 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
63
64protected:
65 virtual QString text( const QPoint& p)
66 {
67 return _wid->getWhatsThisText(p) ;
68 };
69private:
70 KNoScrollListBox* _wid;
71
72};
73
74
75KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
76 : QListBox(parent, name)
77{
78#ifndef DESKTOP_VERSION
79 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
80#endif
81 new KNOWhatsThis(this);
82}
83
84QString KNoScrollListBox::getWhatsThisText(QPoint p)
85{
86 QListBoxItem* item = itemAt ( p );
87 if ( ! item ) {
88 return i18n("Click in the cell or\non the date label\nto add an event!");
89 }
90 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
91}
92void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
93{
94
95 switch(e->key()) {
96 case Key_Right:
97 // if ( e->state() == Qt::ControlButton )
98 {
99 e->ignore();
100 return;
101 }
102 scrollBy(4,0);
103 break;
104 case Key_Left:
105 // if ( e->state() == Qt::ControlButton )
106 {
107 e->ignore();
108 return;
109 }
110 scrollBy(-4,0);
111 break;
112 case Key_Up:
113 if(!count()) break;
114 setCurrentItem((currentItem()+count()-1)%count());
115 if(!itemVisible(currentItem())) {
116 if((unsigned int) currentItem() == (count()-1)) {
117 setTopItem(currentItem()-numItemsVisible()+1);
118 } else {
119 setTopItem(topItem()-1);
120 }
121 }
122 break;
123 case Key_Down:
124 if(!count()) break;
125 setCurrentItem((currentItem()+1)%count());
126 if(!itemVisible(currentItem())) {
127 if(currentItem() == 0) {
128 setTopItem(0);
129 } else {
130 setTopItem(topItem()+1);
131 }
132 }
133 break;
134 case Key_Shift:
135 emit shiftDown();
136 break;
137 default:
138 e->ignore();
139 break;
140 }
141}
142
143void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
144{
145 switch(e->key()) {
146 case Key_Shift:
147 emit shiftUp();
148 break;
149 default:
150 break;
151 }
152}
153
154void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
155{
156 QListBox::mousePressEvent(e);
157
158 if(e->button() == RightButton) {
159 emit rightClick();
160 }
161}
162
163MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
164 : QListBoxItem()
165{
166 setText( s );
167
168 mIncidence = incidence;
169 mDate = qd;
170 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
171 mRecur = false;
172 mAlarm = false;
173 mReply = false;
174 mInfo = false;
175}
176
177void MonthViewItem::paint(QPainter *p)
178{
179#if QT_VERSION >= 0x030000
180 bool sel = isSelected();
181#else
182 bool sel = selected();
183#endif
184
185
186 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
187 {
188 p->setBackgroundColor( palette().color( QPalette::Normal, \
189 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
190 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
191 }
192 int x = 1;
193 int y = 3;//(height() - mRecurPixmap.height()) /2;
194 int size = PIXMAP_SIZE;
195 if ( QApplication::desktop()->width() < 300 )
196 size = 3;
197 if ( KOPrefs::instance()->mMonthShowIcons ) {
198 if ( mInfo ) {
199 p->fillRect ( x, y,size,size, Qt::darkGreen );
200 x += size + 1;
201 }
202 if ( mRecur ) {
203 p->fillRect ( x, y,size,size, Qt::blue );
204 x += size + 1;
205 }
206 if ( mAlarm ) {
207 p->fillRect ( x, y,size,size, Qt::red );
208 x += size + 1;
209 }
210 if ( mReply ) {
211 p->fillRect ( x, y,size,size, Qt::yellow );
212 x += size + 1;
213 }
214 }
215 QFontMetrics fm = p->fontMetrics();
216 int yPos;
217 int pmheight = size;
218 if( pmheight < fm.height() )
219 yPos = fm.ascent() + fm.leading()/2;
220 else
221 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
222 p->setPen( palette().color( QPalette::Normal, sel ? \
223 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
224 p->drawText( x, yPos, text() );
225 if ( mIncidence->cancelled() ) {
226 int wid = fm.width( text() );
227 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
228 }
229
230}
231
232int MonthViewItem::height(const QListBox *lb) const
233{
234 return lb->fontMetrics().lineSpacing()+1;
235}
236
237int MonthViewItem::width(const QListBox *lb) const
238{
239 int size = PIXMAP_SIZE;
240 if ( QApplication::desktop()->width() < 300 )
241 size = 3;
242 int x = 1;
243 if ( mInfo ) {
244 x += size + 1;
245 }
246 if( mRecur ) {
247 x += size+1;
248 }
249 if( mAlarm ) {
250 x += size+1;
251 }
252 if( mReply ) {
253 x += size+1;
254 }
255
256 return( x + lb->fontMetrics().width( text() ) + 1 );
257}
258
259
260MonthViewCell::MonthViewCell( KOMonthView *parent)
261 : QWidget( parent ),
262 mMonthView( parent )
263{
264
265 QVBoxLayout *topLayout = new QVBoxLayout( this );
266
267 // mLabel = new QLabel( this );QPushButton
268 mLabel = new QPushButton( this );
269 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
270 //mLabel->setLineWidth( 1 );
271 //mLabel->setAlignment( AlignCenter );
272 mLabel->setFlat( true );
273 mItemList = new KNoScrollListBox( this );
274 mItemList->setMinimumSize( 10, 10 );
275 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
276 mItemList->setLineWidth( 1 );
277 topLayout->addWidget( mItemList );
278 mLabel->raise();
279 // QColor( 0,0,255 ) QColor( 160,1600,255 )
280 mStandardPalette = palette();
281 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
282
283 enableScrollBars( false );
284 updateConfig();
285 connect( mLabel, SIGNAL( clicked( )),
286 SLOT( newEvent() ));
287 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
288 SLOT( defaultAction( QListBoxItem * ) ) );
289 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
290 const QPoint &) ),
291 SLOT( contextMenu( QListBoxItem * ) ) );
292 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
293 SLOT( selection( QListBoxItem * ) ) );
294 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
295 SLOT( cellClicked( QListBoxItem * ) ) );
296 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
297 SLOT( selection( QListBoxItem * ) ) );
298}
299
300void MonthViewCell::setDate( const QDate &date )
301{
302// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
303
304 mDate = date;
305
306 QString text;
307 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
308 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
309 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " ";
310 mLabel->resize( mLabelBigSize );
311 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
312 } else {
313 mLabel->resize( mLabelSize );
314 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
315 }
316 mLabel->setText( text );
317
318 //resizeEvent( 0 );
319}
320
321QDate MonthViewCell::date() const
322{
323 return mDate;
324}
325
326void MonthViewCell::setPrimary( bool primary )
327{
328 mPrimary = primary;
329 //setMyPalette();
330}
331void MonthViewCell::setMyPalette()
332{
333
334 if ( mHoliday) {
335 setPalette( mHolidayPalette );
336 } else {
337 if ( mPrimary ) {
338 setPalette( mPrimaryPalette );
339 } else {
340 setPalette( mNonPrimaryPalette );
341 }
342 }
343 QPalette pal = palette();
344
345 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
346}
347QPalette MonthViewCell::getPalette ()
348{
349 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
350 return mStandardPalette;
351 if ( mHoliday) {
352 return mHolidayPalette ;
353 } else {
354 if ( mPrimary ) {
355 return mPrimaryPalette ;
356 }
357 }
358 return mNonPrimaryPalette;
359}
360bool MonthViewCell::isPrimary() const
361{
362 return mPrimary;
363}
364
365void MonthViewCell::setHoliday( bool holiday )
366{
367 mHoliday = holiday;
368 //setMyPalette();
369}
370
371void MonthViewCell::setHoliday( const QString &holiday )
372{
373 mHolidayString = holiday;
374
375 if ( !holiday.isEmpty() ) {
376 setHoliday( true );
377 }
378}
379void MonthViewCell::keyPressEvent ( QKeyEvent * e )
380{
381
382 e->ignore();
383
384}
385void MonthViewCell::updateCell()
386{
387
388 setPrimary( mDate.month()%2 );
389 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() );
390 if ( mDate == QDate::currentDate() ) {
391 mItemList->setLineWidth( 3 );
392 } else {
393 mItemList->setLineWidth( 1 );
394 }
395 mItemList->clear();
396 //qApp->processEvents();
397 if ( !mHolidayString.isEmpty() ) {
398 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
399 item->setPalette( mHolidayPalette );
400 mItemList->insertItem( item );
401 }
402 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
403 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
404 Event *event;
405 for( event = events.first(); event; event = events.next() ) {
406 if ( event->categories().contains("Holiday") ||
407 event->categories().contains(i18n("Holiday"))) {
408 setHoliday( true );
409 if ( mDate.dayOfWeek() == 7 )
410 mItemList->setLineWidth( 3 );
411 }
412 QString text;
413 if (event->isMultiDay()) {
414 QString prefix = "<->";
415 if ( event->doesRecur() ) {
416 if ( event->recursOn( mDate) )
417 prefix ="->" ;
418 else {
419 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
420 if ( event->recursOn( mDate.addDays( -days)) )
421 prefix ="<-" ;
422 }
423
424 } else {
425 if (mDate == event->dtStart().date()) {
426 prefix ="->" ;
427 } else if (mDate == event->dtEnd().date()) {
428 prefix ="<-" ;
429 }
430 }
431 text = prefix + event->summary();
432 } else {
433 if (event->doesFloat())
434 text = event->summary();
435 else {
436 text = KGlobal::locale()->formatTime(event->dtStart().time());
437 text += " " + event->summary();
438 }
439 }
440
441 MonthViewItem *item = new MonthViewItem( event, mDate, text );
442 QPalette pal;
443 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
444 QStringList categories = event->categories();
445 QString cat = categories.first();
446 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
447 pal = getPalette();
448 if (cat.isEmpty()) {
449 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
450 } else {
451 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
452 }
453
454 } else {
455 if (cat.isEmpty()) {
456 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
457 } else {
458 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
459 }
460 }
461
462 } else {
463 pal = mStandardPalette ;
464 }
465 item->setPalette( pal );
466 item->setRecur( event->recurrence()->doesRecur() );
467 item->setAlarm( event->isAlarmEnabled() );
468 item->setMoreInfo( event->description().length() > 0 );
469 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
470 KOPrefs::instance()->email());
471 if ( me != 0 ) {
472 if ( me->status() == Attendee::NeedsAction && me->RSVP())
473 item->setReply(true);
474 else
475 item->setReply(false);
476 } else
477 item->setReply(false);
478 bool insert = true;
479 if ( !(event->doesRecur() == Recurrence::rNone) ) {
480 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
481 insert = false;
482 else
483 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
484 insert = false;
485
486 }
487 if ( insert )
488 mItemList->insertItem( item );
489 }
490
491 // insert due todos
492 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
493 Todo *todo;
494 for(todo = todos.first(); todo; todo = todos.next()) {
495 QString text;
496 if (todo->hasDueDate()) {
497 if (!todo->doesFloat()) {
498 text += KGlobal::locale()->formatTime(todo->dtDue().time());
499 text += " ";
500 }
501 }
502 text += i18n("To-Do: %1").arg(todo->summary());
503
504 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
505 //item->setPalette( mStandardPalette );
506 QPalette pal;
507 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
508 QStringList categories = todo->categories();
509 QString cat = categories.first();
510 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
511 pal = getPalette();
512 if (cat.isEmpty()) {
513 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
514 } else {
515 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
516 }
517
518 } else {
519 if (cat.isEmpty()) {
520 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
521 } else {
522 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
523 }
524 }
525
526 } else {
527 pal = mStandardPalette ;
528 }
529 item->setPalette( pal );
530 mItemList->insertItem( item );
531 }
532 //setMyPalette();
533 setMyPalette();
534 resizeEvent( 0 );
535 // if ( isVisible())
536 // qApp->processEvents();
537}
538
539void MonthViewCell::updateConfig()
540{
541
542 setFont( KOPrefs::instance()->mMonthViewFont );
543
544 QFontMetrics fm( font() );
545 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
546 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
547 mHolidayPalette = mStandardPalette;
548 mPrimaryPalette = mStandardPalette;
549 mNonPrimaryPalette = mStandardPalette;
550 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
551 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
552 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
553 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
554 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
555 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
556 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
557 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
558 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
559 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
560 }
561 updateCell();
562}
563
564void MonthViewCell::enableScrollBars( bool enabled )
565{
566 if ( enabled ) {
567 mItemList->setVScrollBarMode(QScrollView::Auto);
568 mItemList->setHScrollBarMode(QScrollView::Auto);
569 } else {
570 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
571 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
572 }
573}
574
575Incidence *MonthViewCell::selectedIncidence()
576{
577 int index = mItemList->currentItem();
578 if ( index < 0 ) return 0;
579
580 MonthViewItem *item =
581 static_cast<MonthViewItem *>( mItemList->item( index ) );
582
583 if ( !item ) return 0;
584
585 return item->incidence();
586}
587
588QDate MonthViewCell::selectedIncidenceDate()
589{
590 QDate qd;
591 int index = mItemList->currentItem();
592 if ( index < 0 ) return qd;
593
594 MonthViewItem *item =
595 static_cast<MonthViewItem *>( mItemList->item( index ) );
596
597 if ( !item ) return qd;
598
599 return item->incidenceDate();
600}
601
602void MonthViewCell::deselect()
603{
604 mItemList->clearSelection();
605 enableScrollBars( false );
606 // updateCell();
607}
608void MonthViewCell::select()
609{
610 ;// updateCell();
611}
612
613void MonthViewCell::resizeEvent ( QResizeEvent * )
614{
615 int size = height() - mLabel->height();
616 if ( size > 0 )
617 mItemList->verticalScrollBar()->setMaximumHeight( size );
618 size = width() - mLabel->width();
619 if ( size > 0 )
620 mItemList->horizontalScrollBar()->setMaximumWidth( size );
621 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
622 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
623}
624
625void MonthViewCell::defaultAction( QListBoxItem *item )
626{
627 if ( !item ) return;
628
629 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
630 Incidence *incidence = eventItem->incidence();
631 if ( incidence ) mMonthView->defaultAction( incidence );
632}
633void MonthViewCell::newEvent()
634{
635 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
636 emit newEventSignal( dt );
637}
638void MonthViewCell::cellClicked( QListBoxItem *item )
639{
640 static QListBoxItem * lastClicked = 0;
641 if ( item == 0 ) {
642 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
643 emit newEventSignal( dt );
644 return;
645 }
646 /*
647 if ( lastClicked )
648 if ( ! item ) {
649 if ( lastClicked->listBox() != item->listBox() )
650 lastClicked->listBox()->clearSelection();
651 }
652 */
653
654 mMonthView->setSelectedCell( this );
655 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
656 select();
657}
658
659void MonthViewCell::contextMenu( QListBoxItem *item )
660{
661 if ( !item ) return;
662
663 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
664 Incidence *incidence = eventItem->incidence();
665 if ( incidence ) mMonthView->showContextMenu( incidence );
666}
667
668void MonthViewCell::selection( QListBoxItem *item )
669{
670 if ( !item ) return;
671
672 mMonthView->setSelectedCell( this );
673}
674
675
676// *******************************************************************************
677// *******************************************************************************
678// *******************************************************************************
679
680
681KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
682 : KOEventView( calendar, parent, name ),
683 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
684 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
685{
686 mCells.setAutoDelete( true );
687 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
688 // mDayLayout = new QGridLayout( this );
689 // create the day of the week labels (Sun, Mon, etc) and add them to
690 // the layout.
691 mDayLabels.resize( mDaysPerWeek );
692 QFont bfont = font();
693 if ( QApplication::desktop()->width() < 650 ) {
694 bfont.setPointSize( bfont.pointSize() - 2 );
695 }
696 bfont.setBold( true );
697 int i;
698
699 for( i = 0; i < mDaysPerWeek; i++ ) {
700 QLabel *label = new QLabel( this );
701 label->setFont(bfont);
702 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
703 label->setLineWidth(1);
704 label->setAlignment(AlignCenter);
705 mDayLabels.insert( i, label );
706 }
707
708 bfont.setBold( false );
709 mWeekLabels.resize( mNumWeeks+1 );
710 for( i = 0; i < mNumWeeks+1; i++ ) {
711 KOWeekButton *label = new KOWeekButton( this );
712 label->setFont(bfont);
713 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
714 label->setFlat(true);
715 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
716 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
717 //label->setLineWidth(1);
718 //label->setAlignment(AlignCenter);
719 mWeekLabels.insert( i, label );
720 }
721 mWeekLabels[mNumWeeks]->setText( i18n("W"));
722 int row, col;
723 mCells.resize( mNumCells );
724 for( row = 0; row < mNumWeeks; ++row ) {
725 for( col = 0; col < mDaysPerWeek; ++col ) {
726 MonthViewCell *cell = new MonthViewCell( this );
727 mCells.insert( row * mDaysPerWeek + col, cell );
728
729 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
730 SLOT( defaultAction( Incidence * ) ) );
731 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
732 SIGNAL( newEventSignal( QDateTime ) ) );
733 }
734 }
735
736 mContextMenu = eventPopup();
737 // updateConfig(); //useless here
738
739 emit incidenceSelected( 0 );
740}
741
742KOMonthView::~KOMonthView()
743{
744 delete mContextMenu;
745}
746
747int KOMonthView::maxDatesHint()
748{
749 return mNumCells;
750}
751
752int KOMonthView::currentDateCount()
753{
754 return mNumCells;
755}
756
757QPtrList<Incidence> KOMonthView::selectedIncidences()
758{
759 QPtrList<Incidence> selected;
760
761 if ( mSelectedCell ) {
762 Incidence *incidence = mSelectedCell->selectedIncidence();
763 if ( incidence ) selected.append( incidence );
764 }
765
766 return selected;
767}
768
769DateList KOMonthView::selectedDates()
770{
771 DateList selected;
772
773 if ( mSelectedCell ) {
774 QDate qd = mSelectedCell->selectedIncidenceDate();
775 if ( qd.isValid() ) selected.append( qd );
776 }
777
778 return selected;
779}
780
781void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
782 const QDate &td)
783{
784#ifndef KORG_NOPRINTER
785 calPrinter->preview(CalPrinter::Month, fd, td);
786#endif
787}
788
789void KOMonthView::updateConfig()
790{
791
792 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
793
794 QFontMetrics fontmetric(mDayLabels[0]->font());
795 mWidthLongDayLabel = 0;
796
797 for (int i = 0; i < 7; i++) {
798 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
799 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
800 }
801 bool temp = mShowSatSunComp ;
802 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
803 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
804 computeLayout();
805 updateDayLabels();
806 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
807 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
808 //resizeEvent( 0 );
809 for (uint i = 0; i < mCells.count(); ++i) {
810 mCells[i]->updateConfig();
811 }
812}
813
814void KOMonthView::updateDayLabels()
815{
816
817 for (int i = 0; i < 7; i++) {
818 if (mWeekStartsMonday) {
819 bool show = mShortDayLabels;
820 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
821 show = true;
822 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
823 } else {
824 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
825 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
826
827 }
828 }
829}
830
831void KOMonthView::showDates(const QDate &start, const QDate &)
832{
833// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
834
835
836 mStartDate = start;
837
838 int startWeekDay = mWeekStartsMonday ? 1 : 7;
839
840 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
841 mStartDate = mStartDate.addDays( -1 );
842 }
843
844 bool primary = false;
845 uint i;
846 for( i = 0; i < mCells.size(); ++i ) {
847 QDate date = mStartDate.addDays( i );
848 mCells[i]->setDate( date );
849
850#ifndef KORG_NOPLUGINS
851 // add holiday, if present
852 QString hstring(KOCore::self()->holiday(date));
853 mCells[i]->setHoliday( hstring );
854#endif
855
856 }
857 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
858 for( i = 0; i < 6; ++i ) {
859 int wno;
860 // remember, according to ISO 8601, the first week of the year is the
861 // first week that contains a thursday. Thus we must subtract off 4,
862 // not just 1.
863 int dayOfYear = date.dayOfYear();
864 if (dayOfYear % 7 != 0)
865 wno = dayOfYear / 7 + 1;
866 else
867 wno =dayOfYear / 7;
868 mWeekLabels[i]->setWeekNum( wno );
869 date = date.addDays( 7 );
870 }
871 updateView();
872}
873
874void KOMonthView::showEvents(QPtrList<Event>)
875{
876 qDebug("KOMonthView::selectEvents is not implemented yet. ");
877}
878
879void KOMonthView::changeEventDisplay(Event *, int)
880{
881 // this should be re-written to be much more efficient, but this
882 // quick-and-dirty-hack gets the job done for right now.
883 updateView();
884}
885
886void KOMonthView::updateView()
887{
888
889 uint i;
890 for( i = 0; i < mCells.count(); ++i ) {
891 mCells[i]->updateCell();
892 }
893 //qDebug("KOMonthView::updateView() ");
894 processSelectionChange();
895}
896
897void KOMonthView::resizeEvent(QResizeEvent * e)
898{
899 computeLayout();
900}
901void KOMonthView::computeLayout()
902{
903 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
904 // note this only changes the text if the requested size crosses the
905 // threshold between big enough to support the full name and not big
906 // enough.
907
908 int daysToShow = 7;
909 bool combinedSatSun = false;
910 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
911 daysToShow = 6;
912 combinedSatSun = true;
913 }
914 int tWid = topLevelWidget()->size().width();
915 int tHei = topLevelWidget()->size().height();
916
917 int wid = size().width();//e
918 int hei = size().height()-1;
919
920 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
921 return;
922
923 QFontMetrics fm ( mWeekLabels[0]->font() );
924 int weeklabelwid = fm.width( "888" );
925 wid -= weeklabelwid;
926
927 int colWid = wid / daysToShow;
928 int lastCol = wid - ( colWid*6 );
929 int dayLabelHei = mDayLabels[0]->sizeHint().height();
930 int cellHei = (hei - dayLabelHei) /6;
931 int colModulo = wid % daysToShow;
932 int rowModulo = (hei- dayLabelHei) % 6;
933 //qDebug("rowmod %d ", rowModulo);
934 int i;
935 int x,y,w,h;
936 x= 0;
937 y= 0;
938 w = colWid;
939 h = dayLabelHei ;
940 for ( i = 0; i < 7; i++) {
941 if ( i == daysToShow-colModulo )
942 ++w;
943 if ( combinedSatSun ) {
944 if ( i >= daysToShow-1 ) {
945 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
946 x -= w/2 ;
947 }
948 else
949 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
950 } else
951 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
952 x += w;
953 }
954 x= 0;
955 y= dayLabelHei;
956 w = colWid;
957 h = cellHei ;
958 for ( i = 0; i < mCells.count(); ++i) {
959
960 w = colWid;
961 if ( ((i) % 7) >= 7-colModulo ) {
962 ++w;
963 }
964 if ( i == (6-rowModulo)*7)
965 ++h;
966 if ( combinedSatSun ) {
967 if ( (i)%7 >= daysToShow-1 ) {
968 if ( (i)%7 == daysToShow-1 ) {
969 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
970 x -= w ;y += h/2;
971 } else {
972 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
973 y -= h/2;
974 }
975 } else
976 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
977
978 }
979 else
980 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
981 x += w;
982 if ( x + w/2 > wid ) {
983 x = 0;
984 y += h;
985 }
986 }
987 y= dayLabelHei;
988 h = cellHei ;
989 for ( i = 0; i < 6; i++) {
990 if ( i == (6-rowModulo))
991 ++h;
992 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
993 y += h;
994 }
995 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
996 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
997 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
998 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
999 updateDayLabels();
1000}
1001
1002void KOMonthView::showContextMenu( Incidence *incidence )
1003{
1004 mContextMenu->showIncidencePopup(incidence);
1005 /*
1006 if( incidence && incidence->type() == "Event" ) {
1007 Event *event = static_cast<Event *>(incidence);
1008 mContextMenu->showEventPopup(event);
1009 } else {
1010 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1011 }
1012 */
1013}
1014MonthViewCell * KOMonthView::selectedCell( )
1015{
1016 return mSelectedCell;
1017}
1018void KOMonthView::setSelectedCell( MonthViewCell *cell )
1019{
1020 // qDebug("KOMonthView::setSelectedCell ");
1021 if ( mSelectedCell && mSelectedCell != cell ) {
1022 MonthViewCell * mvc = mSelectedCell;
1023 mSelectedCell = cell;
1024 mvc->deselect();
1025 } else
1026 mSelectedCell = cell;
1027 // if ( mSelectedCell )
1028// mSelectedCell->select();
1029 if ( !mSelectedCell )
1030 emit incidenceSelected( 0 );
1031 else
1032 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1033}
1034
1035void KOMonthView::processSelectionChange()
1036{
1037 QPtrList<Incidence> incidences = selectedIncidences();
1038 if (incidences.count() > 0) {
1039 emit incidenceSelected( incidences.first() );
1040 } else {
1041 emit incidenceSelected( 0 );
1042 }
1043}
1044
1045void KOMonthView::clearSelection()
1046{
1047 if ( mSelectedCell ) {
1048 mSelectedCell->deselect();
1049 mSelectedCell = 0;
1050 }
1051}
1052void KOMonthView::keyPressEvent ( QKeyEvent * e )
1053{
1054
1055 e->ignore();
1056
1057}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
new file mode 100644
index 0000000..d976246
--- a/dev/null
+++ b/korganizer/komonthview.h
@@ -0,0 +1,252 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H
22
23#include <qlabel.h>
24#include <qframe.h>
25#include <qdatetime.h>
26#include <qlistbox.h>
27#include <qpoint.h>
28#include <qlayout.h>
29#include <qintdict.h>
30#include <qpushbutton.h>
31#include <qvaluelist.h>
32#include <qptrvector.h>
33
34#include <libkcal/calendar.h>
35#include <libkcal/event.h>
36
37#include "koeventview.h"
38
39class KOWeekButton : public QPushButton
40{
41 Q_OBJECT
42 public:
43 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
44 QPushButton( parent, name)
45 {
46 connect( this, SIGNAL( clicked() ),
47 SLOT( bottonClicked() ));
48 mNumber = -1;
49 }
50 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
51 signals:
52 void selectWeekNum ( int );
53private:
54 int mNumber;
55private slots :
56 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
57};
58
59class KNoScrollListBox: public QListBox
60{
61 Q_OBJECT
62 public:
63 KNoScrollListBox(QWidget *parent=0, const char *name=0);
64 ~KNoScrollListBox() {}
65 QString getWhatsThisText(QPoint p) ;
66
67 signals:
68 void shiftDown();
69 void shiftUp();
70 void rightClick();
71
72 protected slots:
73 void keyPressEvent(QKeyEvent *);
74 void keyReleaseEvent(QKeyEvent *);
75 void mousePressEvent(QMouseEvent *);
76};
77
78
79class MonthViewItem: public QListBoxItem
80{
81 public:
82 MonthViewItem( Incidence *, QDate qd, const QString & title );
83
84 void setRecur(bool on) { mRecur = on; }
85 void setAlarm(bool on) { mAlarm = on; }
86 void setReply(bool on) { mReply = on; }
87 void setMoreInfo(bool on) { mInfo = on; }
88
89
90 void setPalette(const QPalette &p) { mPalette = p; }
91 QPalette palette() const { return mPalette; }
92
93 Incidence *incidence() const { return mIncidence; }
94 QDate incidenceDate() { return mDate; }
95
96 protected:
97 virtual void paint(QPainter *);
98 virtual int height(const QListBox *) const;
99 virtual int width(const QListBox *) const;
100
101 private:
102 bool mRecur;
103 bool mAlarm;
104 bool mReply;
105 bool mInfo;
106
107 QPalette mPalette;
108 QDate mDate;
109
110 Incidence *mIncidence;
111};
112
113
114class KOMonthView;
115
116class MonthViewCell : public QWidget
117{
118 Q_OBJECT
119 public:
120 MonthViewCell( KOMonthView * );
121
122 void setDate( const QDate & );
123 QDate date() const;
124
125 void setPrimary( bool );
126 bool isPrimary() const;
127
128 void setHoliday( bool );
129 void setHoliday( const QString & );
130
131 void updateCell();
132
133 void updateConfig();
134
135 void enableScrollBars( bool );
136
137 Incidence *selectedIncidence();
138 QDate selectedIncidenceDate();
139
140 void deselect();
141 void select();
142
143 signals:
144 void defaultAction( Incidence * );
145 void newEventSignal( QDateTime );
146
147 protected:
148 void resizeEvent( QResizeEvent * );
149
150 protected slots:
151 void defaultAction( QListBoxItem * );
152 void contextMenu( QListBoxItem * );
153 void selection( QListBoxItem * );
154 void cellClicked( QListBoxItem * );
155 void newEvent();
156
157 private:
158 KOMonthView *mMonthView;
159
160 QDate mDate;
161 bool mPrimary;
162 bool mHoliday;
163 QString mHolidayString;
164
165 //QLabel *mLabel;
166 QPushButton *mLabel;
167 QListBox *mItemList;
168
169 QSize mLabelSize;
170 QSize mLabelBigSize;
171 QPalette mHolidayPalette;
172 QPalette mStandardPalette;
173 QPalette mPrimaryPalette;
174 QPalette mNonPrimaryPalette;
175 void setMyPalette();
176 QPalette getPalette ();
177 void keyPressEvent ( QKeyEvent * ) ;
178
179};
180
181
182class KOMonthView: public KOEventView
183{
184 Q_OBJECT
185 public:
186 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
187 ~KOMonthView();
188
189 /** Returns maximum number of days supported by the komonthview */
190 virtual int maxDatesHint();
191
192 /** Returns number of currently shown dates. */
193 virtual int currentDateCount();
194
195 /** returns the currently selected events */
196 virtual QPtrList<Incidence> selectedIncidences();
197
198 /** returns dates of the currently selected events */
199 virtual DateList selectedDates();
200
201 virtual void printPreview(CalPrinter *calPrinter,
202 const QDate &, const QDate &);
203
204 MonthViewCell * selectedCell();
205 public slots:
206 virtual void updateView();
207 virtual void updateConfig();
208 virtual void showDates(const QDate &start, const QDate &end);
209 virtual void showEvents(QPtrList<Event> eventList);
210
211 void changeEventDisplay(Event *, int);
212
213 void clearSelection();
214
215 void showContextMenu( Incidence * );
216
217 void setSelectedCell( MonthViewCell * );
218
219 protected slots:
220 void processSelectionChange();
221 signals:
222 void selectWeekNum ( int );
223 protected:
224 void resizeEvent(QResizeEvent *);
225 void viewChanged();
226 void updateDayLabels();
227
228 private:
229 int mDaysPerWeek;
230 int mNumWeeks;
231 int mNumCells;
232 bool mWeekStartsMonday;
233 bool mShowSatSunComp;
234 void computeLayout();
235
236 QPtrVector<MonthViewCell> mCells;
237 QPtrVector<QLabel> mDayLabels;
238 QPtrVector<KOWeekButton> mWeekLabels;
239
240 bool mShortDayLabels;
241 int mWidthLongDayLabel;
242
243 QDate mStartDate;
244
245 MonthViewCell *mSelectedCell;
246
247 KOEventPopupMenu *mContextMenu;
248 void keyPressEvent ( QKeyEvent * ) ;
249
250};
251
252#endif
diff --git a/korganizer/komonthview.moc b/korganizer/komonthview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/komonthview.moc
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
new file mode 100644
index 0000000..2900a40
--- a/dev/null
+++ b/korganizer/koprefs.cpp
@@ -0,0 +1,555 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <time.h>
25#ifndef _WIN32_
26#include <unistd.h>
27#endif
28#include <qdir.h>
29#include <qtextstream.h>
30#include <qtextcodec.h>
31#include <qstring.h>
32#include <qfont.h>
33#include <qcolor.h>
34#include <qstringlist.h>
35#include <stdlib.h>
36
37#include <kglobal.h>
38#include <kconfig.h>
39#include <klocale.h>
40#include <kdebug.h>
41#include <kemailsettings.h>
42#include <kstaticdeleter.h>
43
44#include "koprefs.h"
45#include "mainwindow.h"
46
47const char *germanwords[][2] = {
48#include "wordsgerman.h"
49 "", ""
50};
51
52KOPrefs *KOPrefs::mInstance = 0;
53static KStaticDeleter<KOPrefs> insd;
54
55KOPrefs::KOPrefs() :
56 KPimPrefs("korganizerrc")
57{
58 mCategoryColors.setAutoDelete(true);
59 mLocaleDict = 0;
60 fillMailDefaults();
61 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
62 QColor defaultHolidayColor = QColor(255,0,0);
63 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
64 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
65 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
66 QColor defaultTodoDueTodayColor = QColor(255,220,100);
67 QColor defaultTodoOverdueColor = QColor(255,153,125);
68
69 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
70 mDefaultViewFont = QFont("helvetica",10);
71 mDefaultMonthViewFont = QFont("helvetica",8);
72 mMarcusBainsFont= QFont("helvetica",10);
73 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
74 mEditBoxFont = QFont("helvetica",12);
75 mJornalViewFont = QFont("helvetica",12);
76
77 KPrefs::setCurrentGroup("General");
78 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
79
80 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
81 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
82 addItemBool("ShowIconSearch",&mShowIconSearch,true);
83 addItemBool("ShowIconList",&mShowIconList,true);
84 addItemBool("ShowIconDay1",&mShowIconDay1,true);
85 addItemBool("ShowIconDay5",&mShowIconDay5,true);
86 addItemBool("ShowIconDay7",&mShowIconDay7,true);
87 addItemBool("ShowIconMonth",&mShowIconMonth,true);
88 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
89 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
90 addItemBool("ShowIconBack",&mShowIconBack,true);
91 addItemBool("ShowIconToday",&mShowIconToday,true);
92 addItemBool("ShowIconForward",&mShowIconForward,true);
93 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
94 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
95 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
96 addItemBool("ShowIconNext",&mShowIconNext,true);
97 addItemBool("ShowIconJournal",&mShowIconJournal,true);
98 addItemBool("ShowIconStretch",&mShowIconStretch,true);
99 addItemBool("LanguageChanged",&mLanguageChanged,false);
100
101 addItemBool("AskForQuit",&mAskForQuit,false);
102
103#ifndef DESKTOP_VERSION
104 addItemBool("ShowFullMenu",&mShowFullMenu,false);
105#else
106 addItemBool("ShowFullMenu",&mShowFullMenu,true);
107#endif
108 addItemBool("ToolBarHor",&mToolBarHor, true );
109 addItemBool("ToolBarUp",&mToolBarUp, false );
110 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
111 addItemInt("Whats Next Days",&mWhatsNextDays,3);
112 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
113
114 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
115 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
116 addItemInt("AllDay Size",&mAllDaySize,28);
117 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
118 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
119
120 addItemStringList("LocationDefaults",&mLocationDefaults );
121 addItemStringList("EventSummary User",&mEventSummaryUser);
122 addItemStringList("TodoSummary User",&mTodoSummaryUser);
123
124 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
125 addItemBool("Enable Project View",&mEnableProjectView,false);
126 addItemBool("Auto Save",&mAutoSave,false);
127 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
128 addItemBool("Confirm Deletes",&mConfirm,true);
129 addItemString("Archive File",&mArchiveFile);
130 addItemString("Html Export File",&mHtmlExportFile,
131 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
132 addItemBool("Html With Save",&mHtmlWithSave,false);
133
134 KPrefs::setCurrentGroup("Personal Settings");
135
136 addItemInt("Mail Client",&mMailClient,MailClientKMail);
137 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
138 addItemBool("Bcc",&mBcc,false);
139
140 KPrefs::setCurrentGroup("Time & Date");
141
142 // addItemString("Time Zone",&mTimeZone,"+0100");
143 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
144 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
145 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
146 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
147 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
148
149
150 addItemInt("Default Start Time",&mStartTime,10);
151 addItemInt("Default Duration",&mDefaultDuration,2);
152 addItemInt("Default Alarm Time",&mAlarmTime,3);
153 addItemInt("Daylight Savings",&mDaylightSavings,0);
154 KPrefs::setCurrentGroup("AlarmSettings");
155 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
156 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
157 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
158 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
159
160
161 KPrefs::setCurrentGroup("Calendar");
162
163 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
164
165 KPrefs::setCurrentGroup("Fonts");
166 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
167 addItemFont("TimeBar Font",&mTimeBarFont);
168 addItemFont("MonthView Font",&mMonthViewFont);
169 addItemFont("AgendaView Font",&mAgendaViewFont);
170 addItemFont("MarcusBains Font",&mMarcusBainsFont);
171 addItemFont("TimeLabels Font",&mTimeLabelsFont);
172 addItemFont("TodoView Font",&mTodoViewFont);
173 addItemFont("ListView Font",&mListViewFont);
174 addItemFont("DateNavigator Font",&mDateNavigatorFont);
175 addItemFont("EditBox Font",&mEditBoxFont);
176 addItemFont("JournalView Font",&mJornalViewFont);
177 addItemFont("WhatsNextView Font",&mWhatsNextFont);
178 addItemFont("EventView Font",&mEventViewFont);
179
180 KPrefs::setCurrentGroup("SyncProfiles");
181 addItemString("LocalMachineName",&mLocalMachineName, "undefined");
182 addItemStringList("SyncProfileNames",&mSyncProfileNames);
183
184 KPrefs::setCurrentGroup("RemoteSyncing");
185 addItemBool("UsePasswd",&mUsePassWd,false);
186 addItemBool("WriteBackFile",&mWriteBackFile,true);
187 addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
188 addItemBool("AskForPreferences",&mAskForPreferences,true);
189 addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
190 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
191 addItemInt("LastSyncTime",&mLastSyncTime,0);
192 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
193 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
194
195#ifdef _WIN32_
196 QString hdp= locateLocal("data","korganizer")+"\\\\";
197#else
198 QString hdp= locateLocal("data","korganizer")+"/";
199#endif
200 addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
201 addItemString("RemoteUser",&mRemoteUser, "zaurus");
202 addItemString("RemotePassWd",&mRemotePassWd, "");
203 addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
204 addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
205
206
207 KPrefs::setCurrentGroup("LoadSaveFileNames");
208
209 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
210 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
211 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
212 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
213 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
214
215
216 KPrefs::setCurrentGroup("Locale");
217 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
218 addItemInt("PreferredTime",&mPreferredTime,0);
219 addItemInt("PreferredDate",&mPreferredDate,0);
220 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
221 addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
222 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
223 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
224 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
225
226
227 KPrefs::setCurrentGroup("Colors");
228 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
229 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
230 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
231 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
232 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
233 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
234 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
235 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
236 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
237 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
238 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
239 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
240 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
241 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
242 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
243 addItemBool("UseAppColors",&mUseAppColors,false);
244
245
246
247 KPrefs::setCurrentGroup("Views");
248 addItemInt("Hour Size",&mHourSize,8);
249 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
250 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
251 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
252 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
253 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
254 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
255 addItemBool("Enable ToolTips",&mEnableToolTips,false);
256 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
257 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
258 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
259 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
260 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
261 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
262 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
263 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
264 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
265 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
266 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
267 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
268 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
269 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
270 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
271 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
272 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
273 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
274 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
275 addItemInt("Day Begins",&mDayBegins,7);
276 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
277 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
278 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
279 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
280
281 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
282 addItemBool("Full View Month",&mFullViewMonth,true);
283 addItemBool("Full View Todo",&mFullViewTodo,true);
284 addItemBool("Quick Todo",&mEnableQuickTodo,false);
285
286 addItemInt("Next X Days",&mNextXDays,3);
287
288 KPrefs::setCurrentGroup("Printer");
289
290 KPrefs::setCurrentGroup("Layout");
291
292 addItemBool("CompactDialogs",&mCompactDialogs,false);
293 addItemBool("VerticalScreen",&mVerticalScreen,true);
294
295 KPrefs::setCurrentGroup("KOrganizer Plugins");
296
297 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
298
299 KPrefs::setCurrentGroup("Group Scheduling");
300
301 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
302 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
303 addItemStringList("AdditionalMails",&mAdditionalMails,"");
304 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
305 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
306 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
307 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
308 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
309
310 KPrefs::setCurrentGroup( "Editors" );
311
312 addItemStringList( "EventTemplates", &mEventTemplates );
313 addItemStringList( "TodoTemplates", &mTodoTemplates );
314
315 addItemInt("DestinationPolicy",&mDestination,standardDestination);
316
317
318
319}
320
321
322KOPrefs::~KOPrefs()
323{
324 if (mInstance == this)
325 mInstance = insd.setObject(0);
326 setLocaleDict( 0 );
327 if ( mLocaleDict )
328 delete mLocaleDict;
329 //qDebug("KOPrefs::~KOPrefs() ");
330}
331
332
333KOPrefs *KOPrefs::instance()
334{
335 if (!mInstance) {
336 mInstance = insd.setObject(new KOPrefs());
337 mInstance->readConfig();
338 }
339
340 return mInstance;
341}
342
343void KOPrefs::usrSetDefaults()
344{
345
346}
347
348void KOPrefs::fillMailDefaults()
349{
350 if (mName.isEmpty()) mName = i18n("Anonymous");
351 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
352}
353
354void KOPrefs::setTimeZoneIdDefault()
355{
356 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
357}
358
359void KOPrefs::setCategoryDefaults()
360{
361 mCustomCategories.clear();
362 mCustomCategories = getDefaultList();
363
364 QStringList::Iterator it;
365 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
366 setCategoryColor(*it,mDefaultCategoryColor);
367 }
368}
369
370QStringList KOPrefs::getDefaultList()
371{
372 QStringList retval ;
373 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
374 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
375 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
376 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
377 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
378 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
379 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
380 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
381 retval.sort();
382 return retval;
383}
384
385void KOPrefs::usrReadConfig()
386{
387 mLocaleDict = 0;
388 // pending LR fix translation
389 // qDebug("KOPrefs::usrReadConfig() fix translation ");
390 if ( mPreferredLanguage == 1 ) {
391 mLocaleDict = new QDict<QString>;
392 int i = 0;
393 QString fw ( germanwords[i] [0]);
394 while ( !fw.isEmpty() ) {
395 mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
396 ++i;
397 fw = germanwords[i] [0];
398 }
399
400 setLocaleDict( mLocaleDict );
401 }
402 if ( mPreferredLanguage == 3 ) {
403 QString fileName = MainWindow::resourcePath()+"usertranslation.txt";
404 QFile file( fileName );
405 if (file.open( IO_ReadOnly ) ) {
406 QTextStream ts( &file );
407 ts.setCodec( QTextCodec::codecForLocale() );
408 QString text = ts.read();
409 file.close();
410
411 QString line;
412 QString we;
413 QString wt;
414 int br = 0;
415 int nbr;
416 nbr = text.find ( "},", br );
417 line = text.mid( br, nbr - br );
418 br = nbr+1;
419 int se, ee, st, et;
420 mLocaleDict = new QDict<QString>;
421 QString end = "{ \"\",\"\" }";
422 while ( (line != end) && (br > 1) ) {
423 //qDebug("%d *%s* ", br, line.latin1());
424 se = line.find("\"")+1;
425 et = line.findRev("\"",-1);
426 ee = line.find("\",\"");
427 st = ee+3;
428 we = line.mid( se, ee-se );
429 wt = line.mid( st, et-st );
430 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
431 mLocaleDict->insert( we, new QString (wt) );
432 nbr = text.find ( "}", br );
433 line = text.mid( br, nbr - br );
434 br = nbr+1;
435 }
436 //qDebug("end *%s* ", end.latin1());
437
438 setLocaleDict( mLocaleDict );
439 } else {
440 qDebug("KO: Cannot find translation file usertranslation.txt");
441 }
442 }
443 config()->setGroup("General");
444
445 mCustomCategories = config()->readListEntry("Custom Categories");
446 if ( KOPrefs::instance()->mLanguageChanged ) {
447 mLocationDefaults.clear();
448 mEventSummaryUser.clear();
449 mTodoSummaryUser.clear();
450 }
451 if (mLocationDefaults.isEmpty()) {
452 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Libary") << i18n("School") << i18n("Doctor") << i18n("Beach")
453 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarden")
454 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
455 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
456 mLocationDefaults.sort();
457 }
458
459 if (mEventSummaryUser.isEmpty()) {
460 mEventSummaryUser = getDefaultList() ;
461 }
462 if (mTodoSummaryUser.isEmpty()) {
463 mTodoSummaryUser = getDefaultList() ;
464 }
465
466 if (mCustomCategories.isEmpty()) setCategoryDefaults();
467
468 config()->setGroup("Personal Settings");
469 mName = config()->readEntry("user_name","");
470 mEmail = config()->readEntry("user_email","");
471 fillMailDefaults();
472
473 config()->setGroup("Category Colors");
474 QStringList::Iterator it;
475 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
476 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
477
478 }
479
480 if (mTimeZoneId.isEmpty()) {
481 setTimeZoneIdDefault();
482 }
483 KPimPrefs::usrReadConfig();
484}
485
486
487void KOPrefs::usrWriteConfig()
488{
489 config()->setGroup("General");
490 config()->writeEntry("Custom Categories",mCustomCategories);
491
492 config()->setGroup("Personal Settings");
493 config()->writeEntry("user_name",mName);
494 config()->writeEntry("user_email",mEmail);
495
496 config()->setGroup("Category Colors");
497 QDictIterator<QColor> it(mCategoryColors);
498 while (it.current()) {
499 config()->writeEntry(it.currentKey(),*(it.current()));
500 ++it;
501 }
502
503
504 KPimPrefs::usrWriteConfig();
505}
506
507void KOPrefs::setCategoryColor(QString cat,const QColor & color)
508{
509 mCategoryColors.replace(cat,new QColor(color));
510}
511
512QColor *KOPrefs::categoryColor(QString cat)
513{
514 QColor *color = 0;
515
516 if (!cat.isEmpty()) color = mCategoryColors[cat];
517
518 if (color) return color;
519 else return &mDefaultCategoryColor;
520}
521
522void KOPrefs::setFullName(const QString &name)
523{
524 mName = name;
525}
526
527void KOPrefs::setEmail(const QString &email)
528{
529 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
530 mEmail = email;
531}
532
533QString KOPrefs::fullName()
534{
535 if (mEmailControlCenter) {
536 KEMailSettings settings;
537 return settings.getSetting(KEMailSettings::RealName);
538 } else {
539 return mName;
540 }
541}
542
543QString KOPrefs::email()
544{
545 if (mEmailControlCenter) {
546 KEMailSettings settings;
547 return settings.getSetting(KEMailSettings::EmailAddress);
548 } else {
549 return mEmail;
550 }
551}
552KConfig* KOPrefs::getConfig()
553{
554 return config();
555}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
new file mode 100644
index 0000000..fe044e6
--- a/dev/null
+++ b/korganizer/koprefs.h
@@ -0,0 +1,299 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOPREFS_H
24#define KOPREFS_H
25
26#include <qdict.h>
27
28#include <libkdepim/kpimprefs.h>
29
30class KConfig;
31class QFont;
32class QColor;
33class QStringList;
34
35class KOPrefs : public KPimPrefs
36{
37 public:
38 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination };
44
45 virtual ~KOPrefs();
46
47 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */
49 static KOPrefs *instance();
50
51 /** Set preferences to default values */
52 void usrSetDefaults();
53
54 /** Read preferences from config file */
55 void usrReadConfig();
56
57 /** Write preferences to config file */
58 void usrWriteConfig();
59 void setCategoryDefaults();
60
61 protected:
62 void setTimeZoneIdDefault();
63
64 /** Fill empty mail fields with default values. */
65 void fillMailDefaults();
66
67 private:
68 /** Constructor disabled for public. Use instance() to create a KOPrefs
69 object. */
70 KOPrefs();
71
72 static KOPrefs *mInstance;
73 QDict<QString> *mLocaleDict;
74 QStringList getDefaultList();
75 public:
76 // preferences data
77 KConfig* getConfig();
78 void setFullName(const QString &);
79 QString fullName();
80 void setEmail(const QString &);
81 QString email();
82
83 QString mAdditional;
84
85 bool mEmailControlCenter;
86
87 bool mBcc;
88 bool mAutoSave;
89 int mAutoSaveInterval;
90 bool mConfirm;
91
92 bool mEnableGroupScheduling;
93 bool mEnableProjectView;
94
95 int mDefaultFormat;
96 int mMailClient;
97
98 QString mTimeZone;
99 QString mTimeZoneId;
100 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius
101 //int mTimeZoneOffset; // e.g. -240 min
102 bool mUseDaylightsaving;
103 int mDaylightsavingStart;
104 int mDaylightsavingEnd;
105 int mStartTime;
106 int mDefaultDuration;
107 int mAlarmTime;
108 int mDaylightSavings;
109
110 int mWorkingHoursStart;
111 int mWorkingHoursEnd;
112 bool mExcludeHolidays;
113 bool mExcludeSaturdays;
114 bool mMarcusBainsShowSeconds;
115
116 QFont mTimeBarFont;
117 QFont mMonthViewFont;
118 QFont mAgendaViewFont;
119 QFont mMarcusBainsFont;
120 QFont mTimeLabelsFont;
121 QFont mTodoViewFont;
122 QFont mListViewFont;
123 QFont mDateNavigatorFont;
124 QFont mEditBoxFont;
125 QFont mJornalViewFont;
126 QFont mWhatsNextFont;
127 QFont mEventViewFont;
128
129
130
131
132 QColor mHolidayColor;
133 QColor mHighlightColor;
134 QColor mEventColor;
135 QColor mAgendaBgColor;
136 QColor mWorkingHoursColor;
137 QColor mTodoDueTodayColor;
138 QColor mTodoOverdueColor;
139 QColor mMonthViewEvenColor;
140 QColor mMonthViewOddColor;
141 QColor mMonthViewHolidayColor;
142 bool mMonthViewUsesDayColors;
143 bool mMonthViewSatSunTog;
144 QColor mAppColor1;
145 QColor mAppColor2;
146 bool mUseAppColors;
147
148 int mDayBegins;
149 int mHourSize;
150 int mAllDaySize;
151 bool mShowFullMenu;
152 bool mDailyRecur;
153 bool mWeeklyRecur;
154 bool mMonthDailyRecur;
155 bool mMonthWeeklyRecur;
156 bool mMonthShowIcons;
157 bool mMonthShowShort;
158 bool mEnableToolTips;
159 bool mEnableMonthScroll;
160 bool mFullViewMonth;
161 bool mMonthViewUsesCategoryColor;
162 bool mFullViewTodo;
163 bool mShowCompletedTodo;
164 bool mMarcusBainsEnabled;
165 int mNextXDays;
166 int mWhatsNextDays;
167 int mWhatsNextPrios;
168 bool mEnableQuickTodo;
169 bool mLanguageChanged;
170
171 bool mCompactDialogs;
172 bool mVerticalScreen;
173
174 bool mShowIconNewTodo;
175 bool mShowIconNewEvent;
176 bool mShowIconSearch;
177 bool mShowIconList;
178 bool mShowIconDay1;
179 bool mShowIconDay5;
180 bool mShowIconDay7;
181 bool mShowIconMonth;
182 bool mShowIconTodoview;
183 bool mShowIconBackFast;
184 bool mShowIconBack;
185 bool mShowIconToday;
186 bool mShowIconForward;
187 bool mShowIconForwardFast;
188 bool mShowIconWhatsThis;
189 bool mShowIconNextDays;
190 bool mShowIconNext;
191 bool mShowIconJournal;
192
193 bool mShowIconStretch;
194
195 bool mToolBarHor;
196 bool mToolBarUp;
197 bool mToolBarMiniIcons;
198
199 bool mAskForQuit;
200 bool mUsePassWd;
201 bool mWriteBackFile;
202 bool mAskForPreferences;
203 bool mShowSyncSummary;
204 bool mShowSyncEvents;
205 bool mShowTodoInAgenda;
206 bool mWriteBackExistingOnly;
207
208 QString mRemoteIP;
209 QString mRemoteUser;
210 QString mRemotePassWd;
211 QString mRemoteFile;
212 QString mLocalTempFile;
213
214 int mLastSyncTime;
215 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames;
218 QString mLocalMachineName;
219 void setCategoryColor(QString cat,const QColor & color);
220 QColor *categoryColor(QString cat);
221
222 QString mArchiveFile;
223 QString mHtmlExportFile;
224 bool mHtmlWithSave;
225
226 QStringList mSelectedPlugins;
227
228 QString mLastImportFile;
229 QString mLastVcalFile;
230 QString mLastSaveFile;
231 QString mLastLoadFile;
232 QString mLastSyncedLocalFile;
233
234
235 QString mDefaultAlarmFile;
236 int mIMIPScheduler;
237 int mIMIPSend;
238 QStringList mAdditionalMails;
239 int mIMIPAutoRefresh;
240 int mIMIPAutoInsertReply;
241 int mIMIPAutoInsertRequest;
242 int mIMIPAutoFreeBusy;
243 int mIMIPAutoFreeBusyReply;
244
245 QStringList mTodoTemplates;
246 QStringList mEventTemplates;
247
248 int mDestination;
249
250
251 bool mEditOnDoubleClick;
252 bool mViewChangeHoldFullscreen;
253 bool mViewChangeHoldNonFullscreen;
254 bool mCenterOnCurrentTime;
255 bool mSetTimeToDayStartAt;
256 bool mHighlightCurrentDay;
257 bool mUseHighlightLightColor;
258 bool mListViewMonthTimespan;
259 bool mWNViewShowsParents;
260 bool mWNViewShowLocation;
261 bool mTodoViewShowsPercentage;
262 bool mTodoViewUsesCatColors;
263 bool mTodoViewUsesSmallFont;
264 bool mTodoViewUsesForegroundColor;
265 bool mMonthViewUsesForegroundColor;
266
267 bool mHightlightDateTimeEdit;
268 int mPreferredLanguage;
269 bool mUseQuicksave;
270 int mPreferredTime;
271 int mPreferredDate;
272 bool mWeekStartsOnSunday;
273 bool mShortDateInViewer;
274 QString mUserDateFormatLong;
275 QString mUserDateFormatShort;
276
277 QStringList mLocationDefaults;
278 QStringList mEventSummaryUser;
279 QStringList mTodoSummaryUser;
280
281 bool mUseInternalAlarmNotification;
282 int mAlarmPlayBeeps;
283 int mAlarmSuspendTime;
284 int mAlarmSuspendCount;
285 int mAlarmBeepInterval;
286
287 private:
288 QDict<QColor> mCategoryColors;
289 QColor mDefaultCategoryColor;
290
291 QFont mDefaultTimeBarFont;
292 QFont mDefaultViewFont;
293 QFont mDefaultMonthViewFont;
294
295 QString mName;
296 QString mEmail;
297};
298
299#endif
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp
new file mode 100644
index 0000000..04fffe2
--- a/dev/null
+++ b/korganizer/koprefsdialog.cpp
@@ -0,0 +1,1610 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qlayout.h>
25#include <qlabel.h>
26#include <qgroupbox.h>
27#include <qbuttongroup.h>
28#include <qlineedit.h>
29#include <qfont.h>
30#include <qslider.h>
31#include <qfile.h>
32#include <qtextstream.h>
33#include <qcombobox.h>
34#include <qvbox.h>
35#include <qhbox.h>
36#include <qregexp.h>
37#include <qspinbox.h>
38#include <qdatetime.h>
39#include <qcheckbox.h>
40#include <qradiobutton.h>
41#include <qpushbutton.h>
42#include <qstrlist.h>
43#include <qapplication.h>
44
45#include <kcolorbutton.h>
46#include <kdebug.h>
47#include <klocale.h>
48#include <kglobal.h>
49#include <kfontdialog.h>
50#include <kfiledialog.h>
51#include <kmessagebox.h>
52#include <kcolordialog.h>
53#include <kiconloader.h>
54#include <kemailsettings.h>
55#include <kstandarddirs.h>
56
57#include <kurlrequester.h>
58#include <klineedit.h>
59
60#if defined(USE_SOLARIS)
61#include <sys/param.h>
62
63#define ZONEINFODIR "/usr/share/lib/zoneinfo"
64#define INITFILE "/etc/default/init"
65#endif
66
67#include "koprefs.h"
68
69#include "koprefsdialog.h"
70#include "koprefsdialog.moc"
71
72
73KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) :
74 KPrefsDialog(KOPrefs::instance(),parent,name,true)
75{
76
77 setCaption( i18n("Preferences - some settings need a restart (nr)"));
78 mCategoryDict.setAutoDelete(true);
79
80 KGlobal::locale()->insertCatalogue("timezones");
81
82 setupMainTab();
83 setupLocaleTab();
84 setupTimeZoneTab();
85 setupTimeTab();
86 setupLocaleDateTab();
87 setupFontsTab();
88 setupColorsTab();
89 setupViewsTab();
90 //setupSyncTab();
91 //setupSyncAlgTab();
92 //setupPrinterTab();
93 //setupGroupSchedulingTab();
94 //setupGroupAutomationTab();
95}
96
97
98KOPrefsDialog::~KOPrefsDialog()
99{
100}
101
102void KOPrefsDialog::setupLocaleDateTab()
103{
104QFrame *topFrame = addPage(i18n("Date Format"),0,0);
105 QGridLayout *topLayout = new QGridLayout(topFrame,3,2);
106 topLayout->setSpacing(spacingHint());
107 topLayout->setMargin(marginHint());
108 int iii = 0;
109
110
111 KPrefsWidRadios *syncPrefsGroup =
112 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame);
113 QString format;
114 if ( QApplication::desktop()->width() < 480 )
115 format = "(%d.%m.%Y)";
116 else
117 format = "(%d.%m.%Y|%A %d %B %Y)";
118 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
119 if ( QApplication::desktop()->width() < 480 )
120 format = "(%m.%d.%Y)";
121 else
122 format = "(%m.%d.%Y|%A %B %d %Y)";
123 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
124 if ( QApplication::desktop()->width() < 480 )
125 format = "(%Y-%m-%d)";
126 else
127 format = "(%Y-%m-%d|%A %Y %B %d)";
128 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
129 syncPrefsGroup->addRadio(i18n("User defined"));
130 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
131 ++iii;
132 ++iii;
133 QLabel * lab;
134 mUserDateFormatLong = new QLineEdit(topFrame);
135 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
136 topLayout->addWidget(lab ,iii,0);
137 topLayout->addWidget(mUserDateFormatLong,iii,1);
138 ++iii;
139 mUserDateFormatShort = new QLineEdit(topFrame);
140 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
141 topLayout->addWidget(lab ,iii,0);
142 topLayout->addWidget(mUserDateFormatShort,iii,1);
143 ++iii;
144 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
145 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
146 ++iii;
147 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
148 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
149 ++iii;
150 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
151 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
152 ++iii;
153
154}
155
156void KOPrefsDialog::setupLocaleTab()
157{
158 QFrame *topFrame = addPage(i18n("Locale"),0,0);
159 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
160 topLayout->setSpacing(spacingHint());
161 topLayout->setMargin(marginHint());
162 int iii = 0;
163 KPrefsWidRadios *syncPrefsGroup =
164 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame);
165 syncPrefsGroup->addRadio(i18n("English"));
166 syncPrefsGroup->addRadio(i18n("German"));
167 syncPrefsGroup->addRadio(i18n("French(nyi)"));
168 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
169 if ( QApplication::desktop()->width() < 300 )
170 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
171 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
172 ++iii;
173
174 syncPrefsGroup =
175 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame);
176 if ( QApplication::desktop()->width() > 300 )
177 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
178 syncPrefsGroup->addRadio(i18n("24:00"));
179 syncPrefsGroup->addRadio(i18n("12:00am"));
180 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
181 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
182 ++iii;
183 KPrefsWidBool *sb;
184 if ( QApplication::desktop()->width() < 300 ) {
185 sb =
186 addWidBool(i18n("Week starts on Sunday"),
187 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame);
188 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
189 ++iii;
190 sb =
191 addWidBool(i18n("Use short date in (WN/E) view"),
192 &(KOPrefs::instance()->mShortDateInViewer),topFrame);
193 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
194 }
195 else {
196 QWidget * hb = new QWidget( topFrame );
197 QHBoxLayout *hbLayout = new QHBoxLayout(hb);
198 sb =
199 addWidBool(i18n("Week starts on Sunday"),
200 &(KOPrefs::instance()->mWeekStartsOnSunday),hb);
201 hbLayout->addWidget(sb->checkBox() );
202 sb =
203 addWidBool(i18n("Use short date in (WN/E) view"),
204 &(KOPrefs::instance()->mShortDateInViewer),hb);
205 hbLayout->addWidget(sb->checkBox() );
206 topLayout->addMultiCellWidget(hb, iii,iii,0,1);
207
208 }
209 //#ifndef DESKTOP_VERSION
210#if 0
211 ++iii;
212 sb =
213 addWidBool(i18n("Quick load/save (w/o Unicode)"),
214 &(KOPrefs::instance()->mUseQuicksave),topFrame);
215 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
216#endif
217}
218void KOPrefsDialog::showSyncPage()
219{
220 showPage ( 2 ) ;
221
222}
223void KOPrefsDialog::setupSyncAlgTab()
224{
225#if 0
226 QLabel * lab;
227 QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0);
228 mSetupSyncAlgTab = topFrame;
229 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
230 topLayout->setSpacing(spacingHint());
231 topLayout->setMargin(marginHint());
232 int iii = 0;
233
234 KPrefsWidBool *sb =
235 addWidBool(i18n("Ask for preferences before syncing"),
236 &(KOPrefs::instance()->mAskForPreferences),topFrame);
237 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
238
239 ++iii;
240
241 KPrefsWidRadios *syncPrefsGroup =
242 addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs),
243 topFrame);
244 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
245 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
246 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
247 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
248 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
249 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
250 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
251 ++iii;
252 sb =
253 addWidBool(i18n("Show summary after syncing"),
254 &(KOPrefs::instance()->mShowSyncSummary),topFrame);
255 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
256
257 ++iii;
258#endif
259
260
261
262}
263
264
265void KOPrefsDialog::setupSyncTab()
266{
267#if 0
268 QLabel * lab;
269 QFrame *topFrame = addPage(i18n("Sync Network"),0,0);
270 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
271 topLayout->setSpacing(spacingHint());
272 topLayout->setMargin(marginHint());
273 lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame);
274 int iii = 0;
275 topLayout->addMultiCellWidget(lab , iii,iii,0,1);
276 ++iii;
277
278 mRemoteIPEdit = new QLineEdit(topFrame);
279 lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame);
280 topLayout->addWidget(lab ,iii,0);
281 topLayout->addWidget(mRemoteIPEdit,iii,1);
282 ++iii;
283 mRemoteUser = new QLineEdit(topFrame);
284 lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame);
285 topLayout->addWidget(lab ,iii,0);
286 topLayout->addWidget(mRemoteUser, iii,1);
287 ++iii;
288
289 mRemoteFile = new QLineEdit(topFrame);
290 lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame);
291 topLayout->addWidget(lab ,iii,0);
292 topLayout->addWidget(mRemoteFile,iii,1);
293 ++iii;
294
295 mLocalTempFile = new QLineEdit(topFrame);
296 lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame);
297 topLayout->addWidget(lab ,iii,0);
298 topLayout->addWidget(mLocalTempFile,iii,1);
299 ++iii;
300
301 KPrefsWidBool *wb =
302 addWidBool(i18n("Write back synced file"),
303 &(KOPrefs::instance()->mWriteBackFile),topFrame);
304 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1);
305 ++iii;
306 wb =
307 addWidBool(i18n("Write back existing entries only"),
308 &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame);
309 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1);
310 ++iii;
311
312#endif
313}
314
315void KOPrefsDialog::setupMainTab()
316{
317 QFrame *topFrame = addPage(i18n("General"),0,0);
318 // DesktopIcon("identity",KIcon::SizeMedium));
319
320 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
321 topLayout->setSpacing(spacingHint());
322 topLayout->setMargin(marginHint());
323
324 // KPrefsWidBool *emailControlCenter =
325// addWidBool(i18n("&Use email settings from Control Center"),
326// &(KOPrefs::instance()->mEmailControlCenter),topFrame);
327// topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1);
328 // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)),
329 // SLOT(toggleEmailSettings(bool)));
330
331 mNameEdit = new QLineEdit(topFrame);
332 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
333 topLayout->addWidget(mNameLabel,0,0);
334 topLayout->addWidget(mNameEdit,0,1);
335
336 mEmailEdit = new QLineEdit(topFrame);
337 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
338 topLayout->addWidget(mEmailLabel,1,0);
339 topLayout->addWidget(mEmailEdit,1,1);
340 KPrefsWidBool *wb;
341 QHBox *dummy;
342 if ( QApplication::desktop()->width() > 480 ) {
343 dummy = new QHBox(topFrame);
344 } else {
345 dummy = new QVBox(topFrame);
346 }
347
348 topLayout->addMultiCellWidget(dummy, 2,2,0,1);
349 addWidBool(i18n("Full menu bar(nr)"),
350 &(KOPrefs::instance()->mShowFullMenu),dummy);
351
352
353 addWidBool(i18n("Mini icons in toolbar(nr)"),
354 &(KOPrefs::instance()->mToolBarMiniIcons),dummy);
355
356
357 dummy = new QHBox(topFrame);
358 new QLabel(i18n("Days in What's Next:"),dummy);
359 mWhatsNextSpin = new QSpinBox(1,14,1,dummy);
360
361 topLayout->addMultiCellWidget(dummy,3,3,0,1);
362
363
364
365 dummy = new QHBox(topFrame);
366 new QLabel(i18n("Days in Next-X-Days:"),dummy);
367 mNextXDaysSpin = new QSpinBox(2,14,1,dummy);
368
369 topLayout->addMultiCellWidget(dummy,4,4,0,1);
370
371 QHBox *prioBox = new QHBox(topFrame);
372 // intervalBox->setSpacing(spacingHint());
373 topLayout->addMultiCellWidget(prioBox,5,5,0,1);
374 QString messa = i18n("Show topmost todo prios in What's Next:");
375
376 if ( QApplication::desktop()->width() < 300 )
377 messa = i18n("Show topmost todo prios in What's N.:");
378 QLabel *prioLabel = new QLabel(messa, prioBox);
379 mPrioSpin = new QSpinBox(0,5,1,prioBox);
380 if ( QApplication::desktop()->width() < 300 )
381 mPrioSpin->setFixedWidth( 40 );
382
383 // KPrefsWidBool *bcc =
384// addWidBool(i18n("Send copy to owner when mailing events"),
385// &(KOPrefs::instance()->mBcc),topFrame);
386// topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1);
387
388
389 // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame);
390 //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1);
391
392 // addWidBool(i18n("Enable automatic saving of calendar"),
393 // &(KOPrefs::instance()->mAutoSave),autoSaveGroup);
394
395 QHBox *intervalBox = new QHBox(topFrame);
396 // intervalBox->setSpacing(spacingHint());
397 topLayout->addMultiCellWidget(intervalBox,6,6,0,1);
398 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox);
399 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox);
400 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin);
401 /*
402 QHBox * agendasize = new QHBox ( topFrame );
403
404 new QLabel (i18n("AllDayAgenda Height:"), agendasize );
405
406
407 mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize);
408 topLayout->addMultiCellWidget(agendasize,7,7,0,1);
409 */
410 KPrefsWidBool *verticalScreen =
411 addWidBool(i18n("Show vertical screen (Needs restart)"),
412 &(KOPrefs::instance()->mVerticalScreen),topFrame);
413 //topLayout->addWidget(verticalScreen->checkBox(),ii++,0);
414 topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1);
415
416 KPrefsWidBool *ask =
417 addWidBool(i18n("Ask for quit when closing KO/Pi"),
418 &(KOPrefs::instance()->mAskForQuit),topFrame);
419 topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1);
420
421
422 /*
423 KPrefsWidBool *confirmCheck =
424 addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm),
425 topFrame);
426 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1);
427
428
429 mEnableGroupScheduling =
430 addWidBool(i18n("Enable group scheduling"),
431 &(KOPrefs::instance()->mEnableGroupScheduling),topFrame);
432 topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0);
433 connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()),
434 SLOT(warningGroupScheduling()));
435
436 mEnableProjectView =
437 addWidBool(i18n("Enable project view"),
438 &(KOPrefs::instance()->mEnableProjectView),topFrame);
439 topLayout->addWidget(mEnableProjectView->checkBox(),9,0);
440 connect(mEnableProjectView->checkBox(),SIGNAL(clicked()),
441 SLOT(warningProjectView()));
442
443 // Can't be disabled anymore
444 mEnableGroupScheduling->checkBox()->hide();
445
446 // Disable setting, because this feature now becomes stable
447 mEnableProjectView->checkBox()->hide();
448
449 KPrefsWidRadios *defaultFormatGroup =
450 addWidRadios(i18n("Default Calendar Format"),
451 &(KOPrefs::instance()->mDefaultFormat),topFrame);
452 defaultFormatGroup->addRadio(i18n("vCalendar"));
453 defaultFormatGroup->addRadio(i18n("iCalendar"));
454
455 topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1);
456
457 // Default format unconditionally is iCalendar
458 defaultFormatGroup->groupBox()->hide();
459
460 KPrefsWidRadios *mailClientGroup =
461 addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient),
462 topFrame);
463 mailClientGroup->addRadio(i18n("KMail"));
464 mailClientGroup->addRadio(i18n("Sendmail"));
465 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1);
466
467 KPrefsWidBool *htmlsave =
468 addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave),
469 topFrame);
470 topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1);
471
472 KPrefsWidRadios *destinationGroup =
473 addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination),
474 topFrame);
475 destinationGroup->addRadio(i18n("be added to the standard resource"));
476 destinationGroup->addRadio(i18n("be asked which resource to use"));
477 topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1);
478
479 topLayout->setRowStretch(14,1);
480 */
481}
482
483
484void KOPrefsDialog::setupTimeTab()
485{
486 QFrame *topFrame = addPage(i18n("Time"),0,0);
487 // DesktopIcon("clock",KIcon::SizeMedium));
488
489 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
490 topLayout->setSpacing(spacingHint());
491 topLayout->setMargin(marginHint());
492
493 QHBox *dummy = new QHBox(topFrame);
494 KPrefsWidTime *dayBegins =
495 addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
496 dummy);
497 //topLayout->addWidget(dayBegins->label(),2,0);
498
499 //topLayout->addWidget(dayBegins->spinBox(),2,1);
500 topLayout->addMultiCellWidget(dummy,0,0,0,1);
501
502 topLayout->addWidget(new QLabel(i18n("Default appointment time:"),
503 topFrame),1,0);
504 mStartTimeSpin = new QSpinBox(0,23,1,topFrame);
505 mStartTimeSpin->setSuffix(":00");
506 topLayout->addWidget(mStartTimeSpin,1,1);
507
508 topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"),
509 topFrame),2,0);
510 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame);
511 mDefaultDurationSpin->setSuffix(":00");
512 topLayout->addWidget(mDefaultDurationSpin,2,1);
513
514 QStringList alarmList;
515 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes")
516 << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ;
517 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame),
518 3,0);
519 mAlarmTimeCombo = new QComboBox(topFrame);
520 mAlarmTimeCombo->insertStringList(alarmList);
521 topLayout->addWidget(mAlarmTimeCombo,3,1);
522
523
524 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal,
525 i18n("Working Hours"),
526 topFrame);
527 topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1);
528 workingHoursGroup->layout()->setSpacing( 0 );
529 workingHoursGroup->layout()->setMargin( 4 );
530 QHBox *workStartBox = new QHBox(workingHoursGroup);
531 // workStartBox->setMargin( 0 );
532 addWidTime(i18n("Daily starting hour:"),
533 &(KOPrefs::instance()->mWorkingHoursStart),workStartBox);
534
535 QHBox *workEndBox = new QHBox(workingHoursGroup);
536 //workEndBox->setMargin( 0 );
537 addWidTime(i18n("Daily ending hour:"),
538 &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox);
539 QVBox *excludeBox = new QVBox(workingHoursGroup);
540 //excludeBox->setMargin( 0 );
541 addWidBool(i18n("Exclude holidays"),
542 &(KOPrefs::instance()->mExcludeHolidays),excludeBox);
543
544 addWidBool(i18n("Exclude Saturdays"),
545 &(KOPrefs::instance()->mExcludeSaturdays),excludeBox);
546
547// KPrefsWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"),
548 // &(KOPrefs::instance()->mMarcusBainsShowSeconds),
549 // topFrame);
550// topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0);
551
552 // topLayout->setRowStretch(6,1);
553}
554
555
556void KOPrefsDialog::setupViewsTab()
557{
558
559 QFrame *topFrame = addPage(i18n("Views"),0,0);
560 // DesktopIcon("viewmag",KIcon::SizeMedium));
561
562 QGridLayout *topLayout = new QGridLayout(topFrame,6,1);
563 topLayout->setSpacing(spacingHint());
564 topLayout->setMargin(marginHint());
565
566// QBoxLayout *dayBeginsLayout = new QHBoxLayout;
567// topLayout->addLayout(dayBeginsLayout,0,0);
568
569// KPrefsWidTime *dayBegins =
570// addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
571// topFrame);
572// dayBeginsLayout->addWidget(dayBegins->label());
573// dayBeginsLayout->addStretch(1);
574// dayBeginsLayout->addWidget(dayBegins->spinBox());
575
576// QBoxLayout *nextDaysLayout = new QHBoxLayout;
577// topLayout->addLayout(nextDaysLayout,1,0);
578// nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame));
579// mNextXDaysSpin = new QSpinBox(2,14,1,topFrame);
580// nextDaysLayout->addStretch(1);
581// nextDaysLayout->addWidget(mNextXDaysSpin);
582
583
584 int ii = 0;
585 KPrefsWidBool *dummy =
586 addWidBool(i18n("Edit item on doubleclick (if not, show)"),
587 &(KOPrefs::instance()->mEditOnDoubleClick),topFrame);
588 topLayout->addWidget(dummy->checkBox(),ii++,0);
589
590 dummy =
591 addWidBool(i18n("Highlight current day in agenda"),
592 &(KOPrefs::instance()->mHighlightCurrentDay),topFrame);
593 topLayout->addWidget(dummy->checkBox(),ii++,0);
594
595 dummy =
596 addWidBool(i18n("Use light color for highlight current day"),
597 &(KOPrefs::instance()->mUseHighlightLightColor),topFrame);
598 topLayout->addWidget(dummy->checkBox(),ii++,0);
599
600 KPrefsWidBool *dailyRecur =
601 addWidBool(i18n("Show events that recur daily in date nav."),
602 &(KOPrefs::instance()->mDailyRecur),topFrame);
603 topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
604
605 KPrefsWidBool *weeklyRecur =
606 addWidBool(i18n("Show ev. that recur weekly in date nav."),
607 &(KOPrefs::instance()->mWeeklyRecur),topFrame);
608 topLayout->addWidget(weeklyRecur->checkBox(),ii++,0);
609 if ( QApplication::desktop()->width() > 640 ) {
610
611 KPrefsWidBool *enableToolTips =
612 addWidBool(i18n("Enable tooltips displaying summary of ev."),
613 &(KOPrefs::instance()->mEnableToolTips),topFrame);
614 topLayout->addWidget(enableToolTips->checkBox(),ii++,0);
615
616 }
617 KPrefsWidBool *passwdk =
618 addWidBool(i18n("Show parent To-Do's in What's Next view"),
619 &(KOPrefs::instance()->mWNViewShowsParents),topFrame);
620 topLayout->addWidget(passwdk->checkBox(), ii++,0);
621
622 passwdk =
623 addWidBool(i18n("Show location in What's Next view"),
624 &(KOPrefs::instance()->mWNViewShowLocation),topFrame);
625 topLayout->addWidget(passwdk->checkBox(), ii++,0);
626
627 passwdk =
628 addWidBool(i18n("Show Sync Events in WN/Agenda view"),
629 &(KOPrefs::instance()->mShowSyncEvents),topFrame);
630 topLayout->addWidget(passwdk->checkBox(), ii++,0);
631
632
633 KPrefsWidBool *marcusBainsEnabled =
634 addWidBool(i18n("Show Marcus Bains line"),
635 &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame);
636 topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0);
637
638
639 // topLayout->addWidget(hourSizeGroup,ii++,0);
640 // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0);
641 //topLayout->setRowStretch(11,1);
642
643
644
645
646
647
648 topFrame = addPage(i18n("ViewChange"),0,0);
649 // DesktopIcon("viewmag",KIcon::SizeMedium));
650
651 topLayout = new QGridLayout(topFrame,6,1);
652 topLayout->setSpacing(spacingHint());
653 topLayout->setMargin(marginHint());
654 ii = 0;
655
656
657 dummy =
658 addWidBool(i18n("Hold fullscreen on view change"),
659 &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame);
660 topLayout->addWidget(dummy->checkBox(),ii++,0);
661
662 dummy =
663 addWidBool(i18n("Hold non-fullscreen on view change"),
664 &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame);
665 topLayout->addWidget(dummy->checkBox(),ii++,0);
666
667
668 KPrefsWidBool *fullViewTodo =
669 addWidBool(i18n("Event list view uses full window"),
670 &(KOPrefs::instance()->mFullViewTodo),topFrame);
671 topLayout->addWidget(fullViewTodo->checkBox(),ii++,0);
672
673 KPrefsWidBool *fullViewMonth =
674 addWidBool(i18n("Next days view uses full window"),
675 &(KOPrefs::instance()->mFullViewMonth),topFrame);
676 topLayout->addWidget(fullViewMonth->checkBox(),ii++,0);
677
678 dummy =
679 addWidBool(i18n("Set agenda to DayBeginsAt on change"),
680 &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame);
681 topLayout->addWidget(dummy->checkBox(),ii++,0);
682
683 dummy =
684 addWidBool(i18n("Set agenda to current time on change"),
685 &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame);
686 topLayout->addWidget(dummy->checkBox(),ii++,0);
687
688 dummy =
689 addWidBool(i18n("Listview uses monthly timespan"),
690 &(KOPrefs::instance()->mListViewMonthTimespan),topFrame);
691 topLayout->addWidget(dummy->checkBox(),ii++,0);
692 dummy =
693 addWidBool(i18n("Highlight selection in Time Edit"),
694 &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame);
695 topLayout->addWidget( dummy->checkBox(), ii++,0);
696
697
698
699
700
701 topFrame = addPage(i18n("Month View"),0,0);
702 // DesktopIcon("viewmag",KIcon::SizeMedium));
703
704 topLayout = new QGridLayout(topFrame,5,1);
705 topLayout->setSpacing(spacingHint());
706 topLayout->setMargin(marginHint());
707 ii = 0;
708 QLabel *lab;
709 QHBox *habo = new QHBox( topFrame );
710 if ( QApplication::desktop()->width() < 320 ) {
711 lab = new QLabel ( i18n("Show events that recur "), topFrame );
712 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
713 ii++;
714
715 } else {
716 new QLabel ( i18n("Show events that recur "), habo );
717
718 }
719 dailyRecur =
720 addWidBool(i18n("daily"),
721 &(KOPrefs::instance()->mMonthDailyRecur),habo);
722 // topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
723
724 weeklyRecur =
725 addWidBool(i18n("weekly"),
726 &(KOPrefs::instance()->mMonthWeeklyRecur),habo);
727 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
728 ii++;
729
730
731 habo = new QHBox( topFrame );
732 if ( QApplication::desktop()->width() < 320 ) {
733 lab = new QLabel (i18n("Show in every cell ") , topFrame );
734 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
735 ii++;
736
737 } else {
738 new QLabel ( i18n("Show in every cell "), habo );
739 }
740 weeklyRecur =
741 addWidBool(i18n("short month"),
742 &(KOPrefs::instance()->mMonthShowShort),habo);
743 weeklyRecur =
744 addWidBool(i18n("icons"),
745 &(KOPrefs::instance()->mMonthShowIcons),habo);
746
747 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
748 ii++;
749#ifdef DESKTOP_VERSION
750 KPrefsWidBool *enableMonthScroll =
751 addWidBool(i18n("Enable scrollbars in month view cells"),
752 &(KOPrefs::instance()->mEnableMonthScroll),topFrame);
753 topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0);
754#endif
755
756 dummy =
757 addWidBool(i18n("Show Sat/Sun together"),
758 &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame);
759 topLayout->addWidget(dummy->checkBox(),ii++,0);
760
761 KPrefsWidBool *coloredCategoriesInMonthView =
762 addWidBool(i18n("Month view uses category colors"),
763 &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame);
764 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
765
766 dummy =
767 addWidBool(i18n("Categorie colors are applied to text"),
768 &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame);
769 topLayout->addWidget(dummy->checkBox(),ii++,0);
770 coloredCategoriesInMonthView =
771 addWidBool(i18n("Month view uses day colors"),
772 &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame);
773 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
774
775 KPrefsWidColor *holidayColor =
776 addWidColor(i18n("Day color odd months"),
777 &(KOPrefs::instance()->mMonthViewOddColor),topFrame);
778 topLayout->addWidget(holidayColor->label(),ii,0);
779 topLayout->addWidget(holidayColor->button(),ii++,1);
780
781 holidayColor =
782 addWidColor(i18n("Day color even months"),
783 &(KOPrefs::instance()->mMonthViewEvenColor),topFrame);
784 topLayout->addWidget(holidayColor->label(),ii,0);
785 topLayout->addWidget(holidayColor->button(),ii++,1);
786
787
788 holidayColor =
789 addWidColor(i18n("Color for Sundays + category \"Holiday\""),
790 &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame);
791 topLayout->addWidget(holidayColor->label(),ii,0);
792 topLayout->addWidget(holidayColor->button(),ii++,1);
793
794 // *********************** Todo View
795
796 topFrame = addPage(i18n("Todo View"),0,0);
797 // DesktopIcon("viewmag",KIcon::SizeMedium));
798
799 topLayout = new QGridLayout(topFrame,4,1);
800 topLayout->setSpacing(spacingHint());
801 topLayout->setMargin(marginHint());
802 ii = 0;
803
804 KPrefsWidBool *showCompletedTodo =
805 addWidBool(i18n("To-do view shows completed Todos"),
806 &(KOPrefs::instance()->mShowCompletedTodo),topFrame);
807 topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0);
808 dummy =
809 addWidBool(i18n("To-do view shows complete as 'xx %'"),
810 &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame);
811 topLayout->addWidget(dummy->checkBox(),ii++,0);
812
813 dummy =
814 addWidBool(i18n("Small To-do view uses smaller font"),
815 &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame);
816 topLayout->addWidget(dummy->checkBox(),ii++,0);
817
818
819
820 dummy =
821 addWidBool(i18n("Todo view uses category colors"),
822 &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame);
823 topLayout->addWidget(dummy->checkBox(),ii++,0);
824
825
826 QWidget* wid = new QWidget( topFrame );
827 // Todo due today color
828 KPrefsWidColor *todoDueTodayColor =
829 addWidColor(i18n("Todo due today color:"),
830 &(KOPrefs::instance()->mTodoDueTodayColor),wid);
831 QHBoxLayout *widLayout = new QHBoxLayout(wid);
832 widLayout->addWidget( todoDueTodayColor->label() );
833 widLayout->addWidget( todoDueTodayColor->button() );
834 topLayout->addWidget(wid,ii++,0);
835 //topLayout->addWidget(todoDueTodayColor->button(),ii++,1);
836
837 // Todo overdue color
838 wid = new QWidget( topFrame );
839 widLayout = new QHBoxLayout(wid);
840 KPrefsWidColor *todoOverdueColor =
841 addWidColor(i18n("Todo overdue color:"),
842 &(KOPrefs::instance()->mTodoOverdueColor),wid);
843 widLayout->addWidget(todoOverdueColor->label());
844 widLayout->addWidget(todoOverdueColor->button());
845 topLayout->addWidget(wid,ii++,0);
846
847 dummy =
848 addWidBool(i18n("Colors are applied to text"),
849 &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame);
850 topLayout->addWidget(dummy->checkBox(),ii++,0);
851
852 dummy =
853 addWidBool(i18n("Allday Agenda view shows todos"),
854 &(KOPrefs::instance()->mShowTodoInAgenda),topFrame);
855 topLayout->addWidget(dummy->checkBox(),ii++,0);
856
857
858
859
860 topFrame = addPage(i18n("Alarm"),0,0);
861 // DesktopIcon("viewmag",KIcon::SizeMedium));
862
863 topLayout = new QGridLayout(topFrame,2,1);
864 topLayout->setSpacing(spacingHint());
865 topLayout->setMargin(marginHint());
866 int iii = 0;
867
868 dummy =
869 addWidBool(i18n("Use internal alarm notification"),
870 &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame);
871 topLayout->addWidget(dummy->checkBox(),iii++,0);
872 lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame);
873
874 topLayout->addWidget(lab ,iii++,0);
875#ifndef DESKTOP_VERSION
876 lab->setAlignment( AlignLeft|WordBreak|AlignTop);
877#else
878 lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
879 lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
880#endif
881
882 QHBox* dummyBox = new QHBox(topFrame);
883 new QLabel(i18n("Play beeps count:"),dummyBox);
884 mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox);
885 topLayout->addWidget(dummyBox,iii++,0);
886
887 dummyBox = new QHBox(topFrame);
888 new QLabel(i18n("Beeps interval in sec:"),dummyBox);
889 mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox);
890 topLayout->addWidget(dummyBox,iii++,0);
891
892 dummyBox = new QHBox(topFrame);
893 new QLabel(i18n("Default suspend time in min:"),dummyBox);
894 mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox);
895 topLayout->addWidget(dummyBox,iii++,0);
896
897 dummyBox = new QHBox(topFrame);
898 new QLabel(i18n("Auto suspend count:"),dummyBox);
899 mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox);
900 topLayout->addWidget(dummyBox,iii++,0);
901
902
903
904
905
906
907
908 QHBox* hbo = new QHBox ( topFrame );
909 mDefaultAlarmFile = new QLineEdit(hbo);
910 QPushButton * loadTemplate = new QPushButton(hbo);
911 QPixmap icon;
912 if ( QApplication::desktop()->width() < 321 )
913 icon = SmallIcon("fileimport16");
914 else
915 icon = SmallIcon("fileimport");
916 loadTemplate->setIconSet (icon ) ;
917 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) );
918 int size = loadTemplate->sizeHint().height();
919 loadTemplate->setFixedSize( size, size );
920 //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame);
921 // topLayout->addWidget(lab ,iii++,0);
922 lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame);
923 topLayout->addWidget(lab ,iii++,0);
924 topLayout->addWidget(hbo,iii++,0);
925 // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame);
926
927// topLayout->addWidget(lab ,iii++,0);
928// #ifndef DESKTOP_VERSION
929// lab->setAlignment( AlignLeft|WordBreak|AlignTop);
930// #else
931// lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
932// lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
933// #endif
934
935
936}
937
938void KOPrefsDialog::selectSoundFile()
939{
940 QString fileName = mDefaultAlarmFile->text();
941 fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this );
942 if ( fileName.length() > 0 )
943 mDefaultAlarmFile->setText( fileName );
944}
945void KOPrefsDialog::setupFontsTab()
946{
947
948 QFrame *topFrame = addPage(i18n("Fonts"),0,0);
949 // DesktopIcon("fonts",KIcon::SizeMedium));
950
951 QGridLayout *topLayout = new QGridLayout(topFrame,7,3);
952 topLayout->setSpacing(1);
953 topLayout->setMargin(3);
954 KPrefsWidFont * tVFont;
955 int i = 0;
956 KPrefsWidFont *timeLabelsFont =
957 addWidFont(i18n("23"),i18n("DateNavigator:(nr)"),
958 &(KOPrefs::instance()->mDateNavigatorFont),topFrame);
959 topLayout->addWidget(timeLabelsFont->label(),i,0);
960 topLayout->addWidget(timeLabelsFont->preview(),i,1);
961 topLayout->addWidget(timeLabelsFont->button(),i,2);
962 ++i;
963
964
965 timeLabelsFont =
966 addWidFont(i18n("Mon 15"),i18n("Date Labels:"),
967 &(KOPrefs::instance()->mTimeLabelsFont),topFrame);
968 topLayout->addWidget(timeLabelsFont->label(),i,0);
969 topLayout->addWidget(timeLabelsFont->preview(),i,1);
970 topLayout->addWidget(timeLabelsFont->button(),i,2);
971 ++i;
972
973 KPrefsWidFont *timeBarFont =
974 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"),
975 &(KOPrefs::instance()->mTimeBarFont),topFrame);
976 topLayout->addWidget(timeBarFont->label(),i,0);
977 topLayout->addWidget(timeBarFont->preview(),i,1);
978 topLayout->addWidget(timeBarFont->button(),i,2);
979 ++i;
980
981
982 KPrefsWidFont *marcusBainsFont =
983 addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"),
984 &(KOPrefs::instance()->mMarcusBainsFont),topFrame);
985 topLayout->addWidget(marcusBainsFont->label(),i,0);
986 topLayout->addWidget(marcusBainsFont->preview(),i,1);
987 topLayout->addWidget(marcusBainsFont->button(),i,2);
988 ++i;
989
990 tVFont =
991 addWidFont(i18n("Summary"),i18n("Event Viewer:"),
992 &(KOPrefs::instance()->mEventViewFont),topFrame);
993 topLayout->addWidget(tVFont->label(),i,0);
994 topLayout->addWidget(tVFont->preview(),i,1);
995 topLayout->addWidget(tVFont->button(),i,2);
996 ++i;
997
998
999
1000 tVFont =
1001 addWidFont(i18n("Details"),i18n("EditorBox:"),
1002 &(KOPrefs::instance()->mEditBoxFont),topFrame);
1003 topLayout->addWidget(tVFont->label(),i,0);
1004 topLayout->addWidget(tVFont->preview(),i,1);
1005 topLayout->addWidget(tVFont->button(),i,2);
1006 ++i;
1007
1008
1009
1010 topLayout->setColStretch(1,1);
1011 topLayout->setRowStretch(4,1);
1012
1013
1014 i = 0;
1015 topFrame = addPage(i18n("View Fonts"),0,
1016 DesktopIcon("fonts",KIcon::SizeMedium));
1017
1018 topLayout = new QGridLayout(topFrame,7,3);
1019 topLayout->setSpacing(1);
1020 topLayout->setMargin(3);
1021
1022 tVFont =
1023 addWidFont(i18n("Configure KO"),i18n("What's Next View:"),
1024 &(KOPrefs::instance()->mWhatsNextFont),topFrame);
1025 topLayout->addWidget(tVFont->label(),i,0);
1026 topLayout->addWidget(tVFont->preview(),i,1);
1027 topLayout->addWidget(tVFont->button(),i,2);
1028 ++i;
1029 KPrefsWidFont *agendaViewFont =
1030 addWidFont(i18n("Event text"),i18n("Agenda view:"),
1031 &(KOPrefs::instance()->mAgendaViewFont),topFrame);
1032 topLayout->addWidget(agendaViewFont->label(),i,0);
1033 topLayout->addWidget(agendaViewFont->preview(),i,1);
1034 topLayout->addWidget(agendaViewFont->button(),i,2);
1035 ++i;
1036
1037
1038 KPrefsWidFont *monthViewFont =
1039 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"),
1040 i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame);
1041 topLayout->addWidget(monthViewFont->label(),i,0);
1042 topLayout->addWidget(monthViewFont->preview(),i,1);
1043 topLayout->addWidget(monthViewFont->button(),i,2);
1044 ++i;
1045
1046
1047 KPrefsWidFont *lVFont =
1048 addWidFont(i18n("Event"),i18n("List View:"),
1049 &(KOPrefs::instance()->mListViewFont),topFrame);
1050 topLayout->addWidget(lVFont->label(),i,0);
1051 topLayout->addWidget(lVFont->preview(),i,1);
1052 topLayout->addWidget(lVFont->button(),i,2);
1053 ++i;
1054
1055
1056 tVFont =
1057 addWidFont(i18n("ToDo"),i18n("ToDoView:"),
1058 &(KOPrefs::instance()->mTodoViewFont),topFrame);
1059 topLayout->addWidget(tVFont->label(),i,0);
1060 topLayout->addWidget(tVFont->preview(),i,1);
1061 topLayout->addWidget(tVFont->button(),i,2);
1062 ++i;
1063
1064
1065 tVFont =
1066 addWidFont(i18n("Today"),i18n("JournalView:"),
1067 &(KOPrefs::instance()->mJornalViewFont),topFrame);
1068 topLayout->addWidget(tVFont->label(),i,0);
1069 topLayout->addWidget(tVFont->preview(),i,1);
1070 topLayout->addWidget(tVFont->button(),i,2);
1071 ++i;
1072
1073
1074
1075
1076 topLayout->setColStretch(1,1);
1077 topLayout->setRowStretch(4,1);
1078
1079
1080
1081
1082}
1083
1084void KOPrefsDialog::setupColorsTab()
1085{
1086 QFrame *topFrame = addPage(i18n("Colors"),0,0);
1087 // DesktopIcon("colorize",KIcon::SizeMedium));
1088
1089 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
1090 // topLayout->setSpacing(spacingHint());
1091 // topLayout->setMargin(marginHint());
1092
1093 topLayout->setSpacing(2);
1094 topLayout->setMargin(3);
1095
1096 int ii = 1;
1097 QGroupBox *categoryGroup ;
1098
1099 categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"),
1100 topFrame);
1101 topLayout->addMultiCellWidget(categoryGroup,0,0,0,1);
1102
1103 mCategoryCombo = new QComboBox(categoryGroup);
1104 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1105 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor()));
1106
1107 mCategoryButton = new KColorButton(categoryGroup);
1108 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor()));
1109 updateCategoryColor();
1110
1111
1112 // Holiday Color
1113
1114 KPrefsWidColor *holidayColor =
1115 addWidColor(i18n("Holiday color:"),
1116 &(KOPrefs::instance()->mHolidayColor),topFrame);
1117 topLayout->addWidget(holidayColor->label(),ii,0);
1118 topLayout->addWidget(holidayColor->button(),ii++,1);
1119
1120 // Highlight Color
1121 KPrefsWidColor *highlightColor =
1122 addWidColor(i18n("Highlight color:"),
1123 &(KOPrefs::instance()->mHighlightColor),topFrame);
1124 topLayout->addWidget(highlightColor->label(),ii,0);
1125 topLayout->addWidget(highlightColor->button(),ii++,1);
1126
1127 // Event color
1128 KPrefsWidColor *eventColor =
1129 addWidColor(i18n("Default event color:"),
1130 &(KOPrefs::instance()->mEventColor),topFrame);
1131 topLayout->addWidget(eventColor->label(),ii,0);
1132 topLayout->addWidget(eventColor->button(),ii++,1);
1133
1134 // agenda view background color
1135 KPrefsWidColor *agendaBgColor =
1136 addWidColor(i18n("Agenda view background color:"),
1137 &(KOPrefs::instance()->mAgendaBgColor),topFrame);
1138 topLayout->addWidget(agendaBgColor->label(),ii,0);
1139 topLayout->addWidget(agendaBgColor->button(),ii++,1);
1140
1141 // working hours color
1142 KPrefsWidColor *workingHoursColor =
1143 addWidColor(i18n("Working hours color:"),
1144 &(KOPrefs::instance()->mWorkingHoursColor),topFrame);
1145 topLayout->addWidget(workingHoursColor->label(),ii,0);
1146 topLayout->addWidget(workingHoursColor->button(),ii++,1);
1147
1148 KPrefsWidBool *sb =
1149 addWidBool(i18n("Use colors for application:"),
1150 &(KOPrefs::instance()->mUseAppColors),topFrame);
1151 topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 );
1152
1153 ii++;
1154 KPrefsWidColor * workingHoursColor1 =
1155 addWidColor(i18n("Buttons, menus, etc.:"),
1156 &(KOPrefs::instance()->mAppColor1),topFrame);
1157 topLayout->addWidget(workingHoursColor1->label(),ii,0);
1158 topLayout->addWidget(workingHoursColor1->button(),ii++,1);
1159
1160 KPrefsWidColor * workingHoursColor2 =
1161 addWidColor(i18n("Frames, labels, etc.:"),
1162 &(KOPrefs::instance()->mAppColor2),topFrame);
1163 topLayout->addWidget(workingHoursColor2->label(),ii,0);
1164 topLayout->addWidget(workingHoursColor2->button(),ii++,1);
1165
1166
1167
1168}
1169
1170void KOPrefsDialog::setCategoryColor()
1171{
1172 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color()));
1173}
1174
1175void KOPrefsDialog::updateCategoryColor()
1176{
1177 QString cat = mCategoryCombo->currentText();
1178 QColor *color = mCategoryDict.find(cat);
1179 if (!color) {
1180 color = KOPrefs::instance()->categoryColor(cat);
1181 }
1182 if (color) {
1183 mCategoryButton->setColor(*color);
1184 }
1185}
1186
1187void KOPrefsDialog::setupPrinterTab()
1188{
1189 mPrinterTab = addPage(i18n("Printing"),0,
1190 DesktopIcon("fileprint",KIcon::SizeMedium));
1191
1192 QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2);
1193 topLayout->setSpacing(spacingHint());
1194 topLayout->setMargin(marginHint());
1195
1196 topLayout->setRowStretch(4,1);
1197}
1198
1199void KOPrefsDialog::setupGroupSchedulingTab()
1200{
1201#if 0
1202 QFrame *topFrame = addPage(i18n("Group Scheduling"),0,
1203 DesktopIcon("personal",KIcon::SizeMedium));
1204
1205 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
1206 topLayout->setSpacing(spacingHint());
1207 topLayout->setMargin(marginHint());
1208
1209#if 0
1210 KPrefsWidRadios *schedulerGroup =
1211 addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler),
1212 topFrame);
1213 schedulerGroup->addRadio("Dummy"); // Only for debugging
1214 schedulerGroup->addRadio(i18n("Mail client"));
1215
1216 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
1217#endif
1218
1219 KPrefsWidRadios *sendGroup =
1220 addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend),
1221 topFrame);
1222 sendGroup->addRadio(i18n("Send to outbox"));
1223 sendGroup->addRadio(i18n("Send directly"));
1224
1225 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1);
1226
1227 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1);
1228 mAMails = new QListView(topFrame);
1229 mAMails->addColumn(i18n("Email"),300);
1230 topLayout->addMultiCellWidget(mAMails,3,3,0,1);
1231
1232 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0);
1233 aEmailsEdit = new QLineEdit(topFrame);
1234 aEmailsEdit->setEnabled(false);
1235 topLayout->addWidget(aEmailsEdit,4,1);
1236
1237 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new");
1238 topLayout->addWidget(add,5,0);
1239 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove");
1240 topLayout->addWidget(del,5,1);
1241
1242 //topLayout->setRowStretch(2,1);
1243 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) );
1244 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) );
1245 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem()));
1246 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput()));
1247#endif
1248}
1249
1250void KOPrefsDialog::setupGroupAutomationTab()
1251{
1252 return;
1253 QFrame *topFrame = addPage(i18n("Group Automation"),0,
1254 DesktopIcon("personal",KIcon::SizeMedium));
1255
1256 QGridLayout *topLayout = new QGridLayout(topFrame,5,1);
1257 topLayout->setSpacing(spacingHint());
1258 topLayout->setMargin(marginHint());
1259
1260 KPrefsWidRadios *autoRefreshGroup =
1261 addWidRadios(i18n("Auto Send Refresh"),
1262 &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame);
1263 autoRefreshGroup->addRadio(i18n("Never"));
1264 autoRefreshGroup->addRadio(i18n("If attendee is in addressbook"));
1265 //autoRefreshGroup->addRadio(i18n("selected emails"));
1266 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0);
1267
1268 KPrefsWidRadios *autoInsertGroup =
1269 addWidRadios(i18n("Auto Insert IMIP Replies"),
1270 &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame);
1271 autoInsertGroup->addRadio(i18n("Never"));
1272 autoInsertGroup->addRadio(i18n("If attendee is in addressbook"));
1273 //autoInsertGroup->addRadio(i18n("selected emails"));
1274 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0);
1275
1276 KPrefsWidRadios *autoRequestGroup =
1277 addWidRadios(i18n("Auto Insert IMIP Requests"),
1278 &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame);
1279 autoRequestGroup->addRadio(i18n("Never"));
1280 autoRequestGroup->addRadio(i18n("If organizer is in addressbook"));
1281 //autoInsertGroup->addRadio(i18n("selected emails"));
1282 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0);
1283
1284 KPrefsWidRadios *autoFreeBusyGroup =
1285 addWidRadios(i18n("Auto Send FreeBusy Information"),
1286 &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame);
1287 autoFreeBusyGroup->addRadio(i18n("Never"));
1288 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook"));
1289 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1290 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0);
1291
1292 KPrefsWidRadios *autoFreeBusyReplyGroup =
1293 addWidRadios(i18n("Auto Save FreeBusy Replies"),
1294 &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame);
1295 autoFreeBusyReplyGroup->addRadio(i18n("Never"));
1296 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook"));
1297 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1298 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0);
1299}
1300
1301void KOPrefsDialog::showPrinterTab()
1302{
1303 showPage(pageIndex(mPrinterTab));
1304}
1305
1306
1307void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text,
1308 const QStringList *tags)
1309{
1310 if (tags) {
1311 int i = tags->findIndex(text);
1312 if (i > 0) combo->setCurrentItem(i);
1313 } else {
1314 for(int i=0;i<combo->count();++i) {
1315 if (combo->text(i) == text) {
1316 combo->setCurrentItem(i);
1317 break;
1318 }
1319 }
1320 }
1321}
1322
1323void KOPrefsDialog::usrReadConfig()
1324{
1325 mNameEdit->setText(KOPrefs::instance()->fullName());
1326 mEmailEdit->setText(KOPrefs::instance()->email());
1327
1328 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval);
1329 QDate current ( 2001, 1,1);
1330 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1));
1331 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1));
1332 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId));
1333 //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset);
1334 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime);
1335 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration);
1336 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime);
1337 // if (KOPrefs::instance()->mAllDaySize > 47 )
1338 // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2;
1339 //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize);
1340
1341 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays);
1342 mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays);
1343 mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios);
1344 // mAMails->clear();
1345 // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
1346// it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
1347// QListViewItem *item = new QListViewItem(mAMails);
1348// item->setText(0,*it);
1349// mAMails->insertItem(item);
1350// }
1351
1352 // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP);
1353 //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser);
1354 //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd);
1355 //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile);
1356
1357 //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile);
1358 mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile);
1359 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1360 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
1361 dummy = KOPrefs::instance()->mUserDateFormatShort;
1362 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
1363 updateCategories();
1364 mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps );
1365 mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime );
1366 mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount );
1367 mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval );
1368}
1369
1370
1371void KOPrefsDialog::usrWriteConfig()
1372{
1373
1374 // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text();
1375 //KOPrefs::instance()->mRemoteUser = mRemoteUser->text();
1376 //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text();
1377 //KOPrefs::instance()->mRemoteFile= mRemoteFile->text();
1378 //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text();
1379 KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text();
1380
1381 KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
1382 KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
1383 KOPrefs::instance()->setFullName(mNameEdit->text());
1384 KOPrefs::instance()->setEmail(mEmailEdit->text());
1385
1386 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value();
1387
1388 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
1389 QDate date;
1390 date = mStartDateSavingEdit->date();
1391 int sub = 0;
1392 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
1393 sub = 1;
1394 KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub;
1395 date = mEndDateSavingEdit->date();
1396 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
1397 sub = 1;
1398 else
1399 sub = 0;
1400 KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub;
1401 // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value();
1402
1403 KOPrefs::instance()->mStartTime = mStartTimeSpin->value();
1404 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value();
1405 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem();
1406
1407 //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value();
1408
1409 QDictIterator<QColor> it(mCategoryDict);
1410 while (it.current()) {
1411 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current());
1412 ++it;
1413 }
1414
1415 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value();
1416 KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value();
1417 KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value();
1418
1419 KOPrefs::instance()->mAdditionalMails.clear();
1420 // QListViewItem *item;
1421 // item = mAMails->firstChild();
1422 // while (item)
1423 // {
1424 // KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
1425 // item = item->nextSibling();
1426 // }
1427 KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value();
1428 KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ;
1429 KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ;
1430 KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ;
1431
1432}
1433
1434void KOPrefsDialog::updateCategories()
1435{
1436 mCategoryCombo->clear();
1437 mCategoryDict.clear();
1438 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1439 updateCategoryColor();
1440}
1441
1442void KOPrefsDialog::warningGroupScheduling()
1443{
1444 warningExperimental(mEnableGroupScheduling->checkBox()->isChecked());
1445}
1446
1447void KOPrefsDialog::warningProjectView()
1448{
1449 warningExperimental(mEnableProjectView->checkBox()->isChecked());
1450}
1451
1452void KOPrefsDialog::warningExperimental(bool on)
1453{
1454 if (on) {
1455 KMessageBox::information(this,i18n("This is an experimental feature. "
1456 "It may not work, it may do nothing useful and it may cause data loss. "
1457 "Use with care.\n"
1458 "You have to restart KOrganizer for this setting to take effect."));
1459 } else {
1460 KMessageBox::information(this,
1461 i18n("You have to restart KOrganizer for this setting to take effect."));
1462 }
1463}
1464
1465void KOPrefsDialog::toggleEmailSettings(bool on)
1466{
1467 if (on) {
1468 mEmailEdit->setEnabled(false);
1469 mNameEdit->setEnabled(false);
1470 mEmailLabel->setEnabled(false);
1471 mNameLabel->setEnabled(false);
1472
1473 KEMailSettings settings;
1474 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName));
1475 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress));
1476 } else {
1477 mEmailEdit->setEnabled(true);
1478 mNameEdit->setEnabled(true);
1479 mEmailLabel->setEnabled(true);
1480 mNameLabel->setEnabled(true);
1481 }
1482}
1483
1484void KOPrefsDialog::addItem()
1485{
1486 // aEmailsEdit->setEnabled(true);
1487// QListViewItem *item = new QListViewItem(mAMails);
1488// mAMails->insertItem(item);
1489// mAMails->setSelected(item,true);
1490// aEmailsEdit->setText(i18n("(EmptyEmail)"));
1491}
1492
1493void KOPrefsDialog::removeItem()
1494{
1495// QListViewItem *item;
1496// item = mAMails->selectedItem();
1497// if (!item) return;
1498// mAMails->takeItem(item);
1499// item = mAMails->selectedItem();
1500// if (!item) {
1501// aEmailsEdit->setText("");
1502// aEmailsEdit->setEnabled(false);
1503// }
1504// if (mAMails->childCount() == 0) {
1505// aEmailsEdit->setEnabled(false);
1506// }
1507}
1508
1509void KOPrefsDialog::updateItem()
1510{
1511 // QListViewItem *item;
1512// item = mAMails->selectedItem();
1513// if (!item) return;
1514// item->setText(0,aEmailsEdit->text());
1515}
1516
1517void KOPrefsDialog::updateInput()
1518{
1519// QListViewItem *item;
1520// item = mAMails->selectedItem();
1521// if (!item) return;
1522// aEmailsEdit->setEnabled(true);
1523// aEmailsEdit->setText(item->text(0));
1524}
1525void KOPrefsDialog::updateTimezoneOffset( int index )
1526{
1527 /*
1528 qDebug("updateTimezoneOffset %d ", index);
1529 if ( index < 24 ) {
1530 mTimezoneOffsetSpin->setEnabled ( false );
1531 mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 );
1532
1533
1534 } else {
1535 if ( index == 24 ) {
1536 mTimezoneOffsetSpin->setEnabled ( true );
1537 mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset);
1538
1539 } else {
1540 mTimezoneOffsetSpin->setEnabled ( false );
1541 mTimezoneOffsetSpin->setValue( 0 );
1542 }
1543 }
1544 */
1545}
1546
1547void KOPrefsDialog::setupTimeZoneTab()
1548{
1549 QFrame *topFrame = addPage(i18n("Time Zone"),0,0);
1550 // DesktopIcon("clock",KIcon::SizeMedium));
1551
1552 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
1553 topLayout->setSpacing(spacingHint());
1554 topLayout->setMargin(marginHint());
1555
1556 QHBox *timeZoneBox = new QHBox( topFrame );
1557 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
1558
1559 new QLabel( i18n("Timezone:"), timeZoneBox );
1560 mTimeZoneCombo = new QComboBox( timeZoneBox );
1561 if ( QApplication::desktop()->width() < 300 ) {
1562 mTimeZoneCombo->setMaximumWidth(150);
1563 }
1564
1565 QStringList list;
1566 list = KGlobal::locale()->timeZoneList();
1567 mTimeZoneCombo->insertStringList(list);
1568
1569 // find the currently set time zone and select it
1570 QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId;
1571 int nCurrentlySet = 11;
1572 for (int i = 0; i < mTimeZoneCombo->count(); i++)
1573 {
1574 if (mTimeZoneCombo->text(i) == sCurrentlySet)
1575 {
1576 nCurrentlySet = i;
1577 break;
1578 }
1579 }
1580 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
1581 int iii = 1;
1582 KPrefsWidBool *sb =
1583 addWidBool(i18n("Timezone has daylight saving"),
1584 &(KOPrefs::instance()->mUseDaylightsaving),topFrame);
1585 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
1586 ++iii;
1587 QLabel* lab = new QLabel( i18n("Actual start/end is the\nsunday before this date."), topFrame );
1588 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
1589 ++iii;
1590 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
1591 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
1592 ++iii;
1593 lab = new QLabel( i18n("Daylight start:"), topFrame );
1594 topLayout->addWidget(lab, iii,0);
1595 mStartDateSavingEdit = new KDateEdit(topFrame);
1596 topLayout->addWidget(mStartDateSavingEdit, iii,1);
1597 ++iii;
1598
1599 lab = new QLabel( i18n("Daylight end:"), topFrame );
1600 topLayout->addWidget(lab, iii,0);
1601 mEndDateSavingEdit = new KDateEdit(topFrame);
1602 topLayout->addWidget(mEndDateSavingEdit, iii,1);
1603 ++iii;
1604 QDate current ( 2001, 1,1);
1605 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1));
1606 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1));
1607
1608
1609}
1610
diff --git a/korganizer/koprefsdialog.h b/korganizer/koprefsdialog.h
new file mode 100644
index 0000000..fd651d0
--- a/dev/null
+++ b/korganizer/koprefsdialog.h
@@ -0,0 +1,161 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOPREFSDIALOG_H
24#define _KOPREFSDIALOG_H
25
26#include <qframe.h>
27#include <qdict.h>
28#include <qcolor.h>
29#include <qlistview.h>
30
31#include <kdialogbase.h>
32
33#include <libkdepim/kprefsdialog.h>
34#include <libkdepim/kdateedit.h>
35
36class KColorButton;
37class QSpinBox;
38class QSlider;
39class KURLRequester;
40class QComboBox;
41class QLineEdit;
42class QStringList;
43
44/** Dialog to change the korganizer configuration.
45 */
46class KOPrefsDialog : public KPrefsDialog
47{
48 Q_OBJECT
49 public:
50 /** Initialize dialog and pages */
51 KOPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
52 ~KOPrefsDialog();
53
54 public slots:
55 void showPrinterTab();
56
57 /** Update controls for categories */
58 void updateCategories();
59 void showSyncPage();
60 protected slots:
61 void selectSoundFile();
62 void setCategoryColor();
63 void updateCategoryColor();
64 void updateTimezoneOffset( int );
65
66
67 void warningExperimental(bool on);
68 void warningGroupScheduling();
69 void warningProjectView();
70
71 void toggleEmailSettings(bool);
72
73 //additional emails
74 void addItem();
75 void removeItem();
76 void updateItem();
77 void updateInput();
78
79 protected:
80 void usrReadConfig();
81 void usrWriteConfig();
82
83 void setupMainTab();
84 void setupTimeTab();
85 void setupTimeZoneTab();
86 void setupLocaleTab();
87 void setupLocaleDateTab();
88 void setupFontsTab();
89 void setupColorsTab();
90 void setupViewsTab();
91 void setupDisplayTab();
92 void setupPrinterTab();
93 void setupGroupSchedulingTab();
94 void setupGroupAutomationTab();
95 void setupSyncTab();
96 void setupSyncAlgTab();
97
98 void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0);
99
100
101 private:
102 KPrefsWidBool *mEnableGroupScheduling;
103 KPrefsWidBool *mEnableProjectView;
104
105 QFrame *mPrinterTab;
106
107 QLineEdit *nameEdit;
108 QLineEdit *emailEdit;
109
110 QComboBox *timeCombo;
111 QComboBox *tzCombo;
112
113 // widgets holding preferences data
114 QLineEdit *mNameEdit;
115 QLineEdit *mEmailEdit;
116 QLabel *mNameLabel;
117 QLabel *mEmailLabel;
118 QLineEdit *mAdditionalEdit;
119 QSpinBox *mAutoSaveIntervalSpin;
120 QSpinBox *mPrioSpin;
121 // QListView *mAMails;
122 QLineEdit *aEmailsEdit;
123
124 QComboBox *mTimeZoneCombo;
125 QStringList tzonenames;
126 QSpinBox *mStartTimeSpin;
127 QSpinBox *mDefaultDurationSpin;
128 QComboBox *mAlarmTimeCombo;
129
130 QComboBox *mCategoryCombo;
131 KColorButton *mCategoryButton;
132 QDict<QColor> mCategoryDict;
133
134 QSlider *mHourSizeSlider;
135
136 QSpinBox *mNextXDaysSpin;
137 QSpinBox *mWhatsNextSpin;
138
139 QLineEdit * mRemoteIPEdit;
140 QLineEdit * mRemoteUser;
141 QLineEdit * mRemotePassWd;
142 QLineEdit * mRemoteFile;
143 QLineEdit * mLocalTempFile;
144 QWidget* mSetupSyncAlgTab;
145 QLineEdit * mUserDateFormatLong;
146 QLineEdit * mUserDateFormatShort;
147
148 QSpinBox *mTimezoneOffsetSpin;
149 QSpinBox *mDaylightsavingStart;
150 QSpinBox *mDaylightsavingEnd;
151 KDateEdit* mStartDateSavingEdit;
152 KDateEdit* mEndDateSavingEdit;
153 QSpinBox * mAlarmPlayBeeps;
154 QSpinBox * mAlarmSuspendTime;
155 QSpinBox * mAlarmSuspendCount;
156 QSpinBox * mAlarmBeepInterval;
157
158 QLineEdit * mDefaultAlarmFile;
159};
160
161#endif
diff --git a/korganizer/koprefsdialog.moc b/korganizer/koprefsdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koprefsdialog.moc
diff --git a/korganizer/korganizer.desktop b/korganizer/korganizer.desktop
new file mode 100644
index 0000000..23672b2
--- a/dev/null
+++ b/korganizer/korganizer.desktop
@@ -0,0 +1,8 @@
1[Desktop Entry]
2Comment = KO/PI
3Display = 640x480/144dpi,480x640/144dpi
4Exec = kopi
5Icon = kdepim/korganizer/korganizer
6Name = KO/Pi
7Type = Application
8CanFastload = 1
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
new file mode 100644
index 0000000..fe2250e
--- a/dev/null
+++ b/korganizer/korganizer.pro
@@ -0,0 +1,172 @@
1 TEMPLATE= app
2 CONFIG = qt warn_on
3 TARGET = kopi
4OBJECTS_DIR = _obj/
5MOC_DIR = _moc
6DESTDIR= ../bin
7
8include( ../variables.pri )
9
10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile
11#../qtcompat
12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#KORG_NOPRINTER KORG_NOKABC
15DEFINES += KORG_NOLVALTERNATION
16DEFINES += DESKTOP_VERSION
17unix : {
18LIBS += ../bin/libmicrokdepim.so
19LIBS += ../bin/libmicrokcal.so
20LIBS += ../bin/libmicrokde.so
21LIBS += ../bin/libmicrokabc.so
22LIBS += -lldap
23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix
25}
26win32: {
27DEFINES += _WIN32_
28LIBS += ../bin/microkdepim.lib
29LIBS += ../bin/microkcal.lib
30LIBS += ../bin/microkde.lib
31LIBS += ../bin/microkabc.lib
32LIBS += ../libical/lib/ical.lib
33LIBS += ../libical/lib/icalss.lib
34QMAKE_LINK += /NODEFAULTLIB:LIBC
35OBJECTS_DIR = obj/win
36MOC_DIR = moc/win
37}
38
39
40INTERFACES = kofilterview_base.ui
41# filteredit_base.ui
42
43# kdateedit.h \
44
45HEADERS = \
46 filteredit_base.h \
47 alarmclient.h \
48 calendarview.h \
49 customlistviewitem.h \
50 datenavigator.h \
51 docprefs.h \
52 filtereditdialog.h \
53 incomingdialog.h \
54 incomingdialog_base.h \
55 interfaces/korganizer/baseview.h \
56 interfaces/korganizer/calendarviewbase.h \
57 journalentry.h \
58 kdatenavigator.h \
59 koagenda.h \
60 koagendaitem.h \
61 koagendaview.h \
62 kocounterdialog.h \
63 kodaymatrix.h \
64 kodialogmanager.h \
65 koeditordetails.h \
66 koeditorgeneral.h \
67 koeditorgeneralevent.h \
68 koeditorgeneraltodo.h \
69 koeditorrecurrence.h \
70 koeventeditor.h \
71 koeventpopupmenu.h \
72 koeventview.h \
73 koeventviewer.h \
74 koeventviewerdialog.h \
75 kofilterview.h \
76 koglobals.h \
77 koincidenceeditor.h \
78 kojournalview.h \
79 kolistview.h \
80 kolocationbox.h \
81 komonthview.h \
82 koprefs.h \
83 koprefsdialog.h \
84 kosyncprefsdialog.h \
85 kotimespanview.h \
86 kotodoeditor.h \
87 kotodoview.h \
88 kotodoviewitem.h \
89 koviewmanager.h \
90 kowhatsnextview.h \
91 ktimeedit.h \
92 lineview.h \
93 mainwindow.h \
94 navigatorbar.h \
95 outgoingdialog.h \
96 outgoingdialog_base.h \
97 publishdialog.h \
98 publishdialog_base.h \
99 savetemplatedialog.h \
100 searchdialog.h \
101 simplealarmclient.h \
102 statusdialog.h \
103 timeline.h \
104 timespanview.h \
105 version.h \
106 ../kalarmd/alarmdialog.h
107
108SOURCES = \
109filteredit_base.cpp \
110 calendarview.cpp \
111 datenavigator.cpp \
112 docprefs.cpp \
113 filtereditdialog.cpp \
114 incomingdialog.cpp \
115 incomingdialog_base.cpp \
116 journalentry.cpp \
117 kdatenavigator.cpp \
118 koagenda.cpp \
119 koagendaitem.cpp \
120 koagendaview.cpp \
121 kocounterdialog.cpp \
122 kodaymatrix.cpp \
123 kodialogmanager.cpp \
124 koeditordetails.cpp \
125 koeditorgeneral.cpp \
126 koeditorgeneralevent.cpp \
127 koeditorgeneraltodo.cpp \
128 koeditorrecurrence.cpp \
129 koeventeditor.cpp \
130 koeventpopupmenu.cpp \
131 koeventview.cpp \
132 koeventviewer.cpp \
133 koeventviewerdialog.cpp \
134 kofilterview.cpp \
135 koglobals.cpp \
136 koincidenceeditor.cpp \
137 kojournalview.cpp \
138 kolistview.cpp \
139 kolocationbox.cpp \
140 komonthview.cpp \
141 koprefs.cpp \
142 koprefsdialog.cpp \
143 kosyncprefsdialog.cpp \
144 kotimespanview.cpp \
145 kotodoeditor.cpp \
146 kotodoview.cpp \
147 kotodoviewitem.cpp \
148 koviewmanager.cpp \
149 kowhatsnextview.cpp \
150 ktimeedit.cpp \
151 lineview.cpp \
152 main.cpp \
153 mainwindow.cpp \
154 navigatorbar.cpp \
155 outgoingdialog.cpp \
156 outgoingdialog_base.cpp \
157 publishdialog.cpp \
158 publishdialog_base.cpp \
159 savetemplatedialog.cpp \
160 searchdialog.cpp \
161 simplealarmclient.cpp \
162 statusdialog.cpp \
163 timeline.cpp \
164 timespanview.cpp \
165 ../kalarmd/alarmdialog.cpp
166
167HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
168INTERFACES += calprintdayconfig_base.ui \
169 calprintmonthconfig_base.ui \
170 calprinttodoconfig_base.ui \
171 calprintweekconfig_base.ui
172SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
diff --git a/korganizer/korganizer.pro.back b/korganizer/korganizer.pro.back
new file mode 100644
index 0000000..8d23d66
--- a/dev/null
+++ b/korganizer/korganizer.pro.back
@@ -0,0 +1,133 @@
1 TEMPLATE= app
2 CONFIG = qt warn_on release
3 TARGET = korganizer
4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc
6DESTDIR=$(QPEDIR)/bin
7INCLUDEPATH += ../microkde ../qtcompat ../ interfaces
8DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOKABC KORG_NOARCHIVE KORG_NOMAIL
9DEFINES += KORG_NOPRINTER KORG_NOSPLITTER KORG_NODCOP KORG_NOKALARMD
10DEFINES += KORG_NOLVALTERNATION
11LIBS += -lkdepim
12LIBS += -lkcal
13LIBS += -lmicrokde
14LIBS += -lqtcompat
15LIBS += -lqpe
16INTERFACES = \
17 filteredit_base.ui \
18 kofilterview_base.ui \
19
20HEADERS = \
21 alarmclient.h \
22 calendarview.h \
23 customlistviewitem.h \
24 datenavigator.h \
25 docprefs.h \
26 filtereditdialog.h \
27 incomingdialog.h \
28 incomingdialog_base.h \
29 interfaces/korganizer/baseview.h \
30 journalentry.h \
31 kdateedit.h \
32 kdatenavigator.h \
33 koagenda.h \
34 koagendaitem.h \
35 koagendaview.h \
36 kocounterdialog.h \
37 kodaymatrix.h \
38 kodialogmanager.h \
39 koeditordetails.h \
40 koeditorgeneral.h \
41 koeditorgeneralevent.h \
42 koeditorgeneraltodo.h \
43 koeditorrecurrence.h \
44 koeventeditor.h \
45 koeventpopupmenu.h \
46 koeventview.h \
47 koeventviewer.h \
48 koeventviewerdialog.h \
49 kofilterview.h \
50 koglobals.h \
51 koincidenceeditor.h \
52 kojournalview.h \
53 kolistview.h \
54 komonthview.h \
55 koprefs.h \
56 koprefsdialog.h \
57 kotimespanview.h \
58 kotodoeditor.h \
59 kotodoview.h \
60 kotodoviewitem.h \
61 koviewmanager.h \
62 kowhatsnextview.h \
63 ktimeedit.h \
64 lineview.h \
65 mainwindow.h \
66 navigatorbar.h \
67 outgoingdialog.h \
68 outgoingdialog_base.h \
69 publishdialog.h \
70 publishdialog_base.h \
71 savetemplatedialog.h \
72 searchdialog.h \
73 simplealarmclient.h \
74 statusdialog.h \
75 timeline.h \
76 timespanview.h \
77 version.h \
78
79SOURCES = \
80 calendarview.cpp \
81 datenavigator.cpp \
82 docprefs.cpp \
83 filtereditdialog.cpp \
84 incomingdialog.cpp \
85 incomingdialog_base.cpp \
86 journalentry.cpp \
87 kdatenavigator.cpp \
88 koagenda.cpp \
89 koagendaitem.cpp \
90 koagendaview.cpp \
91 kocounterdialog.cpp \
92 kodaymatrix.cpp \
93 kodialogmanager.cpp \
94 koeditordetails.cpp \
95 koeditorgeneral.cpp \
96 koeditorgeneralevent.cpp \
97 koeditorgeneraltodo.cpp \
98 koeditorrecurrence.cpp \
99 koeventeditor.cpp \
100 koeventpopupmenu.cpp \
101 koeventview.cpp \
102 koeventviewer.cpp \
103 koeventviewerdialog.cpp \
104 kofilterview.cpp \
105 koglobals.cpp \
106 koincidenceeditor.cpp \
107 kojournalview.cpp \
108 kolistview.cpp \
109 komonthview.cpp \
110 koprefs.cpp \
111 koprefsdialog.cpp \
112 kotimespanview.cpp \
113 kotodoeditor.cpp \
114 kotodoview.cpp \
115 kotodoviewitem.cpp \
116 koviewmanager.cpp \
117 kowhatsnextview.cpp \
118 ktimeedit.cpp \
119 lineview.cpp \
120 main.cpp \
121 mainwindow.cpp \
122 navigatorbar.cpp \
123 outgoingdialog.cpp \
124 outgoingdialog_base.cpp \
125 publishdialog.cpp \
126 publishdialog_base.cpp \
127 savetemplatedialog.cpp \
128 searchdialog.cpp \
129 simplealarmclient.cpp \
130 statusdialog.cpp \
131 timeline.cpp \
132 timespanview.cpp \
133
diff --git a/korganizer/korganizerE.pro b/korganizer/korganizerE.pro
new file mode 100644
index 0000000..c379fac
--- a/dev/null
+++ b/korganizer/korganizerE.pro
@@ -0,0 +1,151 @@
1 TEMPLATE= app
2 CONFIG += qt warn_on
3 TARGET = kopi
4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM)
6DESTDIR=$(QPEDIR)/bin
7
8INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kdeui ../qtcompat ../ interfaces ../kabc $(QPEDIR)/include
9#../libkabcwrap
10DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
11DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
12DEFINES += KORG_NOLVALTERNATION
13#KORG_NOKABC
14LIBS += -lmicrokdepim
15LIBS += -lmicrokcal
16LIBS += -lmicrokde
17LIBS += -lmicroqtcompat
18LIBS += -lmicrokabc
19#LIBS += -lmicrokabcwrap
20LIBS += -lqpe
21LIBS += -ljpeg
22LIBS += $(QTOPIALIB)
23
24
25INTERFACES = kofilterview_base.ui
26#filteredit_base.ui
27
28HEADERS = \
29 wordsgerman.h \
30 filteredit_base.h \
31 alarmclient.h \
32 calendarview.h \
33 customlistviewitem.h \
34 datenavigator.h \
35 docprefs.h \
36 filtereditdialog.h \
37 incomingdialog.h \
38 incomingdialog_base.h \
39 interfaces/korganizer/baseview.h \
40 interfaces/korganizer/calendarviewbase.h \
41 journalentry.h \
42 kdateedit.h \
43 kdatenavigator.h \
44 koagenda.h \
45 koagendaitem.h \
46 koagendaview.h \
47 kocounterdialog.h \
48 kodaymatrix.h \
49 kodialogmanager.h \
50 koeditordetails.h \
51 koeditorgeneral.h \
52 koeditorgeneralevent.h \
53 koeditorgeneraltodo.h \
54 koeditorrecurrence.h \
55 koeventeditor.h \
56 koeventpopupmenu.h \
57 koeventview.h \
58 koeventviewer.h \
59 koeventviewerdialog.h \
60 kofilterview.h \
61 koglobals.h \
62 koincidenceeditor.h \
63 kojournalview.h \
64 kolistview.h \
65 kolocationbox.h \
66 komonthview.h \
67 koprefs.h \
68 koprefsdialog.h \
69 kosyncprefsdialog.h \
70 kotimespanview.h \
71 kotodoeditor.h \
72 kotodoview.h \
73 kotodoviewitem.h \
74 koviewmanager.h \
75 kowhatsnextview.h \
76 ktimeedit.h \
77 lineview.h \
78 mainwindow.h \
79 navigatorbar.h \
80 outgoingdialog.h \
81 outgoingdialog_base.h \
82 publishdialog.h \
83 publishdialog_base.h \
84 savetemplatedialog.h \
85 searchdialog.h \
86 simplealarmclient.h \
87 statusdialog.h \
88 timeline.h \
89 timespanview.h \
90 version.h \
91 ../kalarmd/alarmdialog.h
92
93SOURCES = \
94 filteredit_base.cpp \
95 calendarview.cpp \
96 datenavigator.cpp \
97 docprefs.cpp \
98 filtereditdialog.cpp \
99 incomingdialog.cpp \
100 incomingdialog_base.cpp \
101 journalentry.cpp \
102 kdatenavigator.cpp \
103 koagenda.cpp \
104 koagendaitem.cpp \
105 koagendaview.cpp \
106 kocounterdialog.cpp \
107 kodaymatrix.cpp \
108 kodialogmanager.cpp \
109 koeditordetails.cpp \
110 koeditorgeneral.cpp \
111 koeditorgeneralevent.cpp \
112 koeditorgeneraltodo.cpp \
113 koeditorrecurrence.cpp \
114 koeventeditor.cpp \
115 koeventpopupmenu.cpp \
116 koeventview.cpp \
117 koeventviewer.cpp \
118 koeventviewerdialog.cpp \
119 kofilterview.cpp \
120 koglobals.cpp \
121 koincidenceeditor.cpp \
122 kojournalview.cpp \
123 kolistview.cpp \
124 kolocationbox.cpp \
125 komonthview.cpp \
126 koprefs.cpp \
127 koprefsdialog.cpp \
128 kosyncprefsdialog.cpp \
129 kotimespanview.cpp \
130 kotodoeditor.cpp \
131 kotodoview.cpp \
132 kotodoviewitem.cpp \
133 koviewmanager.cpp \
134 kowhatsnextview.cpp \
135 ktimeedit.cpp \
136 lineview.cpp \
137 main.cpp \
138 mainwindow.cpp \
139 navigatorbar.cpp \
140 outgoingdialog.cpp \
141 outgoingdialog_base.cpp \
142 publishdialog.cpp \
143 publishdialog_base.cpp \
144 savetemplatedialog.cpp \
145 searchdialog.cpp \
146 simplealarmclient.cpp \
147 statusdialog.cpp \
148 timeline.cpp \
149 timespanview.cpp \
150 ../kalarmd/alarmdialog.cpp
151
diff --git a/korganizer/kosyncprefsdialog.cpp b/korganizer/kosyncprefsdialog.cpp
new file mode 100644
index 0000000..2e051f2
--- a/dev/null
+++ b/korganizer/kosyncprefsdialog.cpp
@@ -0,0 +1,453 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qlayout.h>
25#include <qlabel.h>
26#include <qgroupbox.h>
27#include <qbuttongroup.h>
28#include <qlineedit.h>
29#include <qfont.h>
30#include <qslider.h>
31#include <qfile.h>
32#include <qtextstream.h>
33#include <qcombobox.h>
34#include <qvbox.h>
35#include <qhbox.h>
36#include <qspinbox.h>
37#include <qdatetime.h>
38#include <qcheckbox.h>
39#include <qradiobutton.h>
40#include <qpushbutton.h>
41#include <qstrlist.h>
42#include <qapplication.h>
43
44#include <kcolorbutton.h>
45#include <kdebug.h>
46#include <klocale.h>
47#include <kglobal.h>
48#include <kfontdialog.h>
49#include <kmessagebox.h>
50#include <kcolordialog.h>
51#include <kiconloader.h>
52#include <kemailsettings.h>
53#include <kstandarddirs.h>
54#include <kfiledialog.h>
55#include <kmessagebox.h>
56
57#include <kurlrequester.h>
58#include <klineedit.h>
59#include <libkdepim/ksyncprofile.h>
60
61
62#include "koprefs.h"
63
64#include "kosyncprefsdialog.h"
65#include "koglobals.h"
66#include "kosyncprefsdialog.moc"
67
68
69KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
70 KDialog(parent,name,true)
71{
72
73 setCaption( i18n("Synchronization Preferences"));
74
75 mSyncProfiles.setAutoDelete( true );
76 setupSyncAlgTab();
77}
78
79
80KOSyncPrefsDialog::~KOSyncPrefsDialog()
81{
82}
83
84#include <qlayout.h>
85#include <qscrollview.h>
86void KOSyncPrefsDialog::setupSyncAlgTab()
87{
88 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox );
95
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint());
109
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii;
114
115 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii;
120
121 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126
127 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129
130 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132
133 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true );
135 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
136 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
137
138 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
139 topLayout->addWidget(lab ,iii,0);
140 topLayout->addWidget(mProfileBox, iii,1);
141 ++iii;
142
143 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame );
144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
145 ++iii;
146
147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
149 ++iii;
150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
151 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
152 ++iii;
153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
159 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
160
161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
163 ++iii;
164
165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame );
166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
167 ++iii;
168
169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame );
170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
171 ++iii;
172
173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
174 gr = proGr;
175 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
176 ++iii;
177 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
180
181 localFileWidget = new QVBox( topFrame);
182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
183 ++iii;
184 QHBox* temphb = new QHBox( localFileWidget );
185 lab = new QLabel( i18n("Local file:"), temphb);
186 mRemoteFile = new QLineEdit(localFileWidget);
187
188 button = new QPushButton( i18n("Choose..."), temphb );
189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
190
191
192 remoteFileWidget = new QVBox( topFrame);
193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
194 ++iii;
195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
196 mRemotePrecommand = new QLineEdit(remoteFileWidget);
197
198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
199 mLocalTempFile = new QLineEdit(remoteFileWidget);
200
201
202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
203 mRemotePostcommand = new QLineEdit(remoteFileWidget);
204
205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
206 temphb = new QHBox( remoteFileWidget );
207 button = new QPushButton( i18n("ssh/scp"), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
209 button = new QPushButton( i18n("ftp"), temphb );
210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
212
213
214}
215void KOSyncPrefsDialog::slotOK()
216{
217 if ( mMyMachineName->text() == "undefined" ) {
218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
219 return;
220 }
221 int i;
222 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
224 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
225 return;
226 }
227 }
228 usrWriteConfig();
229 QDialog::accept();
230}
231void KOSyncPrefsDialog::accept()
232{
233 slotOK();
234}
235void KOSyncPrefsDialog::chooseFile()
236{
237 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
238
239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
240 if ( fn == "" )
241 return;
242 mRemoteFile->setText( fn );
243}
244
245void KOSyncPrefsDialog::textChanged( const QString & s )
246{
247 if ( mProfileBox->count() == 0 )
248 return;
249 if ( currentSelection < 3 ) {
250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
251 mProfileBox->blockSignals( true );
252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
253 mProfileBox->blockSignals( false );
254 return;
255 }
256 //qDebug("cur i %d ",mProfileBox-> currentItem () );
257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
259 prof->setName( s );
260 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
261}
262void KOSyncPrefsDialog::profileChanged( int item )
263{
264 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item );
265 KSyncProfile* prof;
266 saveProfile();
267 currentSelection = item;
268 prof = mSyncProfiles.at(item) ;
269 mRemotePrecommand->setText(prof->getPreSyncCommand());
270 mRemotePostcommand->setText(prof->getPostSyncCommand());
271 mLocalTempFile->setText(prof->getLocalTempFile());
272 mRemoteFile->setText(prof->getRemoteFileName()) ;
273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
274 mAskForPreferences->setChecked( prof->getAskForPreferences());
275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
276 mWriteBackFile->setChecked( prof->getWriteBackFile());
277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
278
279 switch ( prof->getSyncPrefs() ) {
280 case 0:
281 loc->setChecked( true);
282 break;
283 case 1:
284 rem->setChecked( true );
285 break;
286 case 2:
287 newest->setChecked( true);
288 break;
289 case 3:
290 ask->setChecked( true);
291 break;
292 case 4:
293 f_loc->setChecked( true);
294 break;
295 case 5:
296 f_rem->setChecked( true);
297 break;
298 case 6:
299 //both->setChecked( true);
300 break;
301 default:
302 break;
303 }
304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
306 proGr->setEnabled( item > 2 );
307 if ( item < 3 ) {
308 localFileWidget->setEnabled(false);
309 remoteFileWidget->setEnabled(false);
310
311 } else
312 kindChanged( prof->getIsLocalFileSync() );
313}
314
315void KOSyncPrefsDialog::fillSSH()
316{
317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
318 mLocalTempFile->setText("/tmp/mycalendar.ics" );
319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
320}
321void KOSyncPrefsDialog::fillFTP()
322{
323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
324 mLocalTempFile->setText("/tmp/mycalendar.ics" );
325 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
326
327}
328void KOSyncPrefsDialog::kindChanged( bool b )
329{
330
331 localFileWidget->setEnabled(b);
332 remoteFileWidget->setEnabled(!b);
333
334}
335void KOSyncPrefsDialog::deleteProfile()
336{
337 //qDebug("KOSyncPrefsDialog::deleteProfile() ");
338 if ( currentSelection >= 0 ) {
339 if ( currentSelection < 3 ) {
340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
341 return;
342 }
343 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
344 mSyncProfiles.remove( temp );
345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
346 insertProfiles();
347 }
348}
349
350void KOSyncPrefsDialog::saveProfile()
351{
352 KSyncProfile* prof;
353 if ( currentSelection >= 0 ) {
354 prof = mSyncProfiles.at(currentSelection) ;
355 prof->setPreSyncCommand( mRemotePrecommand->text());
356 prof->setPostSyncCommand( mRemotePostcommand->text() );
357 prof->setLocalTempFile( mLocalTempFile->text());
358 prof->setRemoteFileName( mRemoteFile->text() );
359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
360 prof->setAskForPreferences( mAskForPreferences->isChecked());
361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
362 prof->setWriteBackFile( mWriteBackFile->isChecked());
363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
365 prof->setSyncPrefs( syncprefs);
366 prof->setIsLocalFileSync( mIsLocal->isChecked() );
367 }
368
369}
370
371void KOSyncPrefsDialog::insertProfiles()
372{
373 int curItem = mProfileBox->currentItem();
374 mProfileBox->blockSignals( true );
375 mProfileBox->clear();
376 mProfileBox->insertStringList (mSyncProfileNames );
377 int item = mSyncProfileNames.count() -1;
378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
379 mProfileBox->setCurrentItem( curItem );
380 else if ( item >= 0 ) {
381 mProfileBox->setCurrentItem( item );
382 }
383 currentSelection = -1;
384 if ( mSyncProfileNames.count() > 0 ) {
385 //qDebug(" profileChanged( mProfileBox->currentItem() ");
386 profileChanged( mProfileBox->currentItem() );
387 currentSelection = mProfileBox->currentItem();
388 }
389 mProfileBox->blockSignals( false );
390}
391
392void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp )
393{
394 saveProfile();
395 mSyncProfiles.append( temp );
396 mSyncProfileNames << temp->getName();
397 insertProfiles();
398 int last = mProfileBox->count() -1;
399 mProfileBox->blockSignals( true );
400 mProfileBox->setCurrentItem( last );
401 mProfileBox->blockSignals( false );
402 profileChanged(last);
403}
404void KOSyncPrefsDialog::newProfile()
405{
406 addProfile ( new KSyncProfile () );
407}
408
409void KOSyncPrefsDialog::cloneProfile()
410{
411 if ( currentSelection >= 0 )
412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
413 else
414 newProfile();
415}
416
417
418void KOSyncPrefsDialog::usrReadConfig()
419{
420 KConfig *config = KOGlobals::config();
421 config->setGroup("SyncProfiles");
422 mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames;
423 int i;
424 KSyncProfile* temp ;
425 mSyncProfiles.clear();
426 for ( i = 0; i < mSyncProfileNames.count();++i ) {
427 temp = new KSyncProfile ();
428 temp->setName( mSyncProfileNames[i] );
429 temp->readConfig( config );
430 mSyncProfiles.append( temp );
431 }
432 insertProfiles();
433 mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
434}
435
436
437void KOSyncPrefsDialog::usrWriteConfig()
438{
439 saveProfile();
440 if ( currentSelection >= 0 )
441 profileChanged(currentSelection);
442 KConfig *config = KOGlobals::config();
443 config->setGroup("SyncProfiles");
444 KSyncProfile* prof = mSyncProfiles.first();
445 while ( prof ) {
446 prof->writeConfig(config);
447 prof = mSyncProfiles.next();
448 }
449 KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
450 KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
451 config->writeEntry("SyncProfileNames",&mSyncProfileNames);
452}
453
diff --git a/korganizer/kosyncprefsdialog.h b/korganizer/kosyncprefsdialog.h
new file mode 100644
index 0000000..d2d8c6f
--- a/dev/null
+++ b/korganizer/kosyncprefsdialog.h
@@ -0,0 +1,109 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KOPREFSDIALOG_H
24#define _KOPREFSDIALOG_H
25
26//#include <qframe.h>
27//#include <qdict.h>
28#include <qvbox.h>
29#include <qhbox.h>
30//#include <qcolor.h>
31//#include <qlistview.h>
32
33#include <kdialogbase.h>
34
35#include <libkdepim/kprefsdialog.h>
36
37class KColorButton;
38class QSpinBox;;
39class QRadioButton;
40class QCheckBox;
41class QSlider;
42class KURLRequester;
43class QComboBox;
44class QLineEdit;
45class QStringList;
46class KSyncProfile;
47
48/** Dialog to change the korganizer configuration.
49 */
50class KOSyncPrefsDialog : public KDialog
51{
52 Q_OBJECT
53 public:
54 /** Initialize dialog and pages */
55 KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
56 ~KOSyncPrefsDialog();
57 void usrReadConfig();
58
59 public slots:
60 protected slots:
61 void accept();
62 void deleteProfile();
63 void newProfile();
64 void cloneProfile();
65 void kindChanged(bool);
66 void fillSSH();
67 void fillFTP();
68 void textChanged( const QString & );
69 void profileChanged( int );
70 void chooseFile();
71 void slotOK();
72
73 protected:
74 void usrWriteConfig();
75
76 void setupSyncAlgTab();
77
78 private:
79 int currentSelection;
80 QPtrList<KSyncProfile> mSyncProfiles;
81 QStringList mSyncProfileNames;
82 QLineEdit * mMyMachineName;
83 QComboBox * mProfileBox;
84 QRadioButton* mIsLocal;
85 QRadioButton* mIsNotLocal;
86 QCheckBox* mIncludeInRing;
87 void addProfile ( KSyncProfile* );
88 void insertProfiles();
89 void saveProfile();
90 QButtonGroup* proGr;
91
92 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
93
94
95 QLineEdit * mRemotePostcommand;
96 QLineEdit * mRemotePrecommand;
97 QLineEdit * mRemoteFile;
98 QLineEdit * mLocalTempFile;
99 QWidget* mSetupSyncAlgTab;
100
101 QVBox* localFileWidget;
102 QVBox* remoteFileWidget;
103 QCheckBox* mWriteBackFile;
104 QCheckBox* mWriteBackExisting;
105 QCheckBox* mAskForPreferences;
106 QCheckBox* mShowSummaryAfterSync;
107};
108
109#endif
diff --git a/korganizer/kosyncprefsdialog.moc b/korganizer/kosyncprefsdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kosyncprefsdialog.moc
diff --git a/korganizer/kotimespanview.cpp b/korganizer/kotimespanview.cpp
new file mode 100644
index 0000000..266a403
--- a/dev/null
+++ b/korganizer/kotimespanview.cpp
@@ -0,0 +1,110 @@
1#include <qlayout.h>
2
3#include <kconfig.h>
4
5#include "timespanview.h"
6#include "koglobals.h"
7
8#include "kotimespanview.h"
9#include "kotimespanview.moc"
10
11KOTimeSpanView::KOTimeSpanView(Calendar *calendar, QWidget *parent,
12 const char *name) :
13 KOEventView( calendar, parent, name )
14{
15 QBoxLayout *topLayout = new QVBoxLayout( this );
16
17 mTimeSpanView = new TimeSpanView( this );
18 topLayout->addWidget( mTimeSpanView );
19
20 connect( mTimeSpanView, SIGNAL( dateRangeChanged() ), SLOT( updateView() ) );
21}
22
23KOTimeSpanView::~KOTimeSpanView()
24{
25}
26
27void KOTimeSpanView::readSettings()
28{
29 readSettings(KOGlobals::config());
30}
31
32void KOTimeSpanView::readSettings(KConfig *config)
33{
34// kdDebug() << "KOTimeSpanView::readSettings()" << endl;
35
36 config->setGroup("Views");
37
38 QValueList<int> sizes = config->readIntListEntry("Separator TimeSpanView");
39 if (sizes.count() == 2) {
40 mTimeSpanView->setSplitterSizes(sizes);
41 }
42}
43
44void KOTimeSpanView::writeSettings(KConfig *config)
45{
46// kdDebug() << "KOTimeSpanView::writeSettings()" << endl;
47
48 config->setGroup("Views");
49
50 QValueList<int> list = mTimeSpanView->splitterSizes();
51 config->writeEntry("Separator TimeSpanView",list);
52}
53
54int KOTimeSpanView::maxDatesHint()
55{
56 return 0;
57}
58
59int KOTimeSpanView::currentDateCount()
60{
61 return 0;
62}
63
64QPtrList<Incidence> KOTimeSpanView::selectedIncidences()
65{
66 QPtrList<Incidence> selected;
67
68 return selected;
69}
70
71void KOTimeSpanView::updateView()
72{
73 insertItems( mTimeSpanView->startDateTime().date(),
74 mTimeSpanView->endDateTime().date() );
75}
76
77void KOTimeSpanView::showDates(const QDate &start, const QDate &end)
78{
79 QDate s = start.addDays( -2 );
80 QDate e = end.addDays( 2 );
81
82 insertItems( s, e );
83}
84
85void KOTimeSpanView::insertItems(const QDate &start, const QDate &end)
86{
87 mTimeSpanView->clear();
88 mTimeSpanView->setDateRange( start, end );
89
90 QPtrList<Event> events = calendar()->events( start, end );
91 Event *event = events.first();
92 while( event ) {
93// kdDebug() << "KOTimeSpanView::showDates() add event: " << event->summary()
94// << endl;
95
96 mTimeSpanView->addItem( event );
97
98 event = events.next();
99 }
100
101 mTimeSpanView->updateView();
102}
103
104void KOTimeSpanView::showEvents(QPtrList<Event> eventList)
105{
106}
107
108void KOTimeSpanView::changeEventDisplay(Event *, int)
109{
110}
diff --git a/korganizer/kotimespanview.h b/korganizer/kotimespanview.h
new file mode 100644
index 0000000..c682ed8
--- a/dev/null
+++ b/korganizer/kotimespanview.h
@@ -0,0 +1,41 @@
1#ifndef KOTIMESPANVIEW_H
2#define KOTIMESPANVIEW_H
3
4#include "koeventview.h"
5
6class KConfig;
7class TimeSpanView;
8
9class KOTimeSpanView : public KOEventView
10{
11 Q_OBJECT
12 public:
13 KOTimeSpanView(Calendar *calendar, QWidget *parent = 0,
14 const char *name = 0);
15 ~KOTimeSpanView();
16
17 virtual int maxDatesHint();
18 virtual int currentDateCount();
19 virtual QPtrList<Incidence> selectedIncidences();
20 DateList selectedDates()
21 {DateList q;
22 return q;}
23
24 void readSettings();
25 void readSettings( KConfig * );
26 void writeSettings( KConfig * );
27
28 public slots:
29 virtual void updateView();
30 virtual void showDates(const QDate &start, const QDate &end);
31 virtual void showEvents(QPtrList<Event> eventList);
32
33 void changeEventDisplay(Event *, int);
34
35 private:
36 void insertItems( const QDate &start, const QDate & end );
37
38 TimeSpanView *mTimeSpanView;
39};
40
41#endif
diff --git a/korganizer/kotimespanview.moc b/korganizer/kotimespanview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kotimespanview.moc
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
new file mode 100644
index 0000000..1c44f2b
--- a/dev/null
+++ b/korganizer/kotodoeditor.cpp
@@ -0,0 +1,373 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1997, 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24
25#include <qtooltip.h>
26#include <qframe.h>
27#include <qpixmap.h>
28#include <qlayout.h>
29#include <qhbox.h>
30#include <qdir.h>
31#include <qdatetime.h>
32#include <qapplication.h>
33
34#include <kiconloader.h>
35#include <klocale.h>
36#include <kfiledialog.h>
37#include <kstandarddirs.h>
38#include <kmessagebox.h>
39
40#include <libkdepim/categoryselectdialog.h>
41#include <libkcal/calendarlocal.h>
42#include <libkcal/calendarresources.h>
43#include <libkcal/resourcecalendar.h>
44#include <libkcal/icalformat.h>
45#include <kresources/resourceselectdialog.h>
46
47#include "koprefs.h"
48
49#include "kotodoeditor.h"
50#include "kotodoeditor.moc"
51extern int globalFlagBlockAgenda;
52
53KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
54 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
55{
56 mTodo = 0;
57 mRelatedTodo = 0;
58 findButton(User1)->hide();
59 init();
60}
61
62KOTodoEditor::~KOTodoEditor()
63{
64 emit dialogClose( mTodo );
65}
66
67void KOTodoEditor::init()
68{
69 setupGeneral();
70 setupAttendeesTab();
71}
72void KOTodoEditor::setCategories( QString s )
73{
74 mGeneral->setCategories(s);
75}
76void KOTodoEditor::setSecrecy( int sec )
77{
78 mGeneral->setSecrecy( sec );
79}
80void KOTodoEditor::reload()
81{
82 if ( mTodo ) readTodo( mTodo );
83}
84
85void KOTodoEditor::setupGeneral()
86{
87 mGeneral = new KOEditorGeneralTodo(this);
88 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
89
90 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
91 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
92 // mGeneral,SLOT(setCategories(const QString &)));
93
94 if (KOPrefs::instance()->mCompactDialogs) {
95 QFrame *topFrame = addPage(i18n("General"));
96
97 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
98 if ( QApplication::desktop()->width() < 480 ) {
99 topLayout->setMargin(1);
100 topLayout->setSpacing(1);
101 } else {
102 topLayout->setMargin(marginHint()-1);
103 topLayout->setSpacing(spacingHint()-1);
104 }
105 mGeneral->initHeader(topFrame,topLayout);
106 mGeneral->initTime(topFrame,topLayout);
107 mGeneral->initAlarm(topFrame,topLayout);
108 mGeneral->enableAlarm( false );
109
110
111 QBoxLayout *priorityLayout;
112 if ( QApplication::desktop()->width() < 500 )
113 priorityLayout = new QVBoxLayout( topLayout );
114 else
115 priorityLayout = new QHBoxLayout( topLayout );
116 QWidget* prioWidget = new QWidget (topFrame);
117 priorityLayout->addWidget( prioWidget );
118 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget);
119
120
121 QIconSet icon;
122 if ( QApplication::desktop()->width() < 321 )
123 icon = SmallIcon("fileexport16");
124 else
125 icon = SmallIcon("fileexport");
126 QPushButton * saveTemplate = new QPushButton( prioWidget);
127 saveTemplate->setIconSet (icon ) ;
128 int size = saveTemplate->sizeHint().height();
129 saveTemplate->setFixedSize( size, size );
130 if ( QApplication::desktop()->width() < 321 )
131 icon = SmallIcon("fileimport16");
132 else
133 icon = SmallIcon("fileimport");
134 QPushButton * loadTemplate = new QPushButton( prioWidget);
135 loadTemplate->setIconSet (icon ) ;
136 loadTemplate->setFixedSize( size, size );
137
138 priorityLayout2->addWidget(loadTemplate);
139 priorityLayout2->addWidget(saveTemplate);
140 mGeneral->initPriority(prioWidget,priorityLayout2);
141 mGeneral->initCategories( topFrame, priorityLayout );
142 topLayout->addStretch(1);
143
144 QFrame *topFrame2 = addPage(i18n("Details"));
145
146 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
147 topLayout2->setMargin(marginHint());
148 topLayout2->setSpacing(spacingHint());
149
150 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
151 mGeneral->initCompletion(topFrame2,completionLayout);
152
153
154 mGeneral->initSecrecy( topFrame2, topLayout2 );
155 mGeneral->initDescription(topFrame2,topLayout2);
156
157 // QHBox * hb = new QHBox ( topFrame2 );
158 // topLayout2->addWidget(hb);
159 // hb->setSpacing( 3 );
160
161 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
162 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
163
164 } else {
165 QFrame *topFrame = addPage(i18n("General"));
166
167 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
168 topLayout->setSpacing(spacingHint());
169
170 mGeneral->initHeader(topFrame,topLayout);
171 mGeneral->initTime(topFrame,topLayout);
172 mGeneral->initStatus(topFrame,topLayout);
173 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
174 mGeneral->initAlarm(topFrame,alarmLineLayout);
175 mGeneral->initDescription(topFrame,topLayout);
176 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
177 mGeneral->initCategories( topFrame, detailsLayout );
178 mGeneral->initSecrecy( topFrame, detailsLayout );
179 }
180 mGeneral->finishSetup();
181
182}
183
184void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
185{
186 //init();
187
188 mTodo = todo;
189 readTodo(mTodo);
190 if ( editDescription ) {
191 showPage( 1 );
192 mGeneral->setFocusOn( 1 );
193 } else {
194 showPage( 0 );
195 mGeneral->setFocusOn( 2 );
196 }
197}
198
199void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
200{
201 //init();
202
203 mTodo = 0;
204 setDefaults(due,relatedTodo,allDay);
205}
206
207void KOTodoEditor::loadDefaults()
208{
209 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
210}
211
212bool KOTodoEditor::processInput( bool emitTime )
213{
214 if (!validateInput()) return false;
215
216 Todo *todo = 0;
217
218 if (mTodo) todo = mTodo;
219 else {
220 todo = new Todo;
221 todo->setOrganizer(KOPrefs::instance()->email());
222 }
223
224 writeTodo(todo);
225 if ( emitTime ) {
226 globalFlagBlockAgenda = 1;
227 emit showAgendaView( false );
228 if ( todo->hasDueDate() )
229 emit jumpToTime( todo->dtDue().date() );
230 globalFlagBlockAgenda = 2;
231 }
232 if (mTodo) {
233 todo->setRevision(todo->revision()+1);
234 emit todoChanged(todo);
235 } else {
236 mCalendar->addTodo(todo);
237 mTodo = todo;
238 emit todoAdded(todo);
239 }
240
241 return true;
242}
243
244void KOTodoEditor::deleteTodo()
245{
246 if (mTodo) {
247 if (KOPrefs::instance()->mConfirm) {
248 switch (msgItemDelete()) {
249 case KMessageBox::Continue: // OK
250 emit todoToBeDeleted(mTodo);
251 emit dialogClose(mTodo);
252 mCalendar->deleteTodo(mTodo);
253 emit todoDeleted();
254 reject();
255 break;
256 }
257 }
258 else {
259 emit todoToBeDeleted(mTodo);
260 emit dialogClose(mTodo);
261 mCalendar->deleteTodo(mTodo);
262 emit todoDeleted();
263 reject();
264 }
265 } else {
266 reject();
267 }
268}
269
270void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
271{
272 mRelatedTodo = relatedEvent;
273
274 mGeneral->setDefaults(due,allDay);
275 mDetails->setDefaults();
276 showPage( 0 );
277 if ( mRelatedTodo )
278 mGeneral->setCategories (mRelatedTodo->categoriesStr ());
279 mGeneral->setFocusOn( 2 );
280}
281
282void KOTodoEditor::readTodo(Todo *todo)
283{
284 mGeneral->readTodo(todo);
285 mDetails->readEvent(todo);
286 mRelatedTodo = 0;//todo->relatedTo();
287 // categories
288 // mCategoryDialog->setSelected(todo->categories());
289
290 // We should handle read-only events here.
291}
292
293void KOTodoEditor::writeTodo(Todo *event)
294{
295 mGeneral->writeTodo(event);
296 mDetails->writeEvent(event);
297
298 // set related event, i.e. parent to-do in this case.
299 if (mRelatedTodo) {
300 event->setRelatedTo(mRelatedTodo);
301 }
302}
303
304bool KOTodoEditor::validateInput()
305{
306 if (!mGeneral->validateInput()) return false;
307 if (!mDetails->validateInput()) return false;
308 return true;
309}
310
311int KOTodoEditor::msgItemDelete()
312{
313 return KMessageBox::warningContinueCancel(this,
314 i18n("This item will be permanently deleted."),
315 i18n("KOrganizer Confirmation"),i18n("Delete"));
316}
317
318void KOTodoEditor::modified (int modification)
319{
320 if (modification == KOGlobals::CATEGORY_MODIFIED ||
321 KOGlobals::UNKNOWN_MODIFIED == modification )
322 // mCategoryDialog->setSelected (mTodo->categories ());
323 mGeneral->modified (mTodo, modification);
324
325}
326
327void KOTodoEditor::slotLoadTemplate()
328{
329
330 QString fileName =locateLocal( "templates", "todos" );
331 QDir t_dir;
332 if ( !t_dir.exists(fileName) )
333 t_dir.mkdir ( fileName );
334 fileName += "/todo";
335 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
336 if ( fileName.length() == 0 )
337 return;
338 CalendarLocal cal;
339 ICalFormat format;
340 if ( !format.load( &cal, fileName ) ) {
341 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
342 .arg( fileName ) );
343 return ;
344 }
345 QPtrList<Todo> todos = cal.todos();
346 Todo * todo = todos.first();
347 if ( !todo ) {
348 KMessageBox::error( this,
349 i18n("Template does not\ncontain a valid Todo."));
350 } else {
351 readTodo( todo );
352 }
353
354}
355
356void KOTodoEditor::slotSaveTemplate()
357{
358 QString fileName =locateLocal( "templates", "todos" );
359 QDir t_dir;
360 if ( !t_dir.exists(fileName) )
361 t_dir.mkdir ( fileName );
362 fileName += "/todo";
363 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
364 if ( fileName.length() > 0 )
365 saveTemplate( fileName );
366}
367
368void KOTodoEditor::saveTemplate( const QString &templateName )
369{
370 Todo *todo = new Todo;
371 writeTodo( todo );
372 saveAsTemplate( todo, templateName );
373}
diff --git a/korganizer/kotodoeditor.h b/korganizer/kotodoeditor.h
new file mode 100644
index 0000000..2657bd8
--- a/dev/null
+++ b/korganizer/kotodoeditor.h
@@ -0,0 +1,102 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1997, 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef _KOTODOEDITOR_H
25#define _KOTODOEDITOR_H
26
27#include <libkcal/calendar.h>
28
29#include "koeditorgeneraltodo.h"
30#include "koeditordetails.h"
31#include "koincidenceeditor.h"
32
33class QDateTime;
34
35/**
36 This class provides a dialog for editing a Todo.
37*/
38class KOTodoEditor : public KOIncidenceEditor
39{
40 Q_OBJECT
41 public:
42 /**
43 Constructs a new todo editor.
44 */
45 KOTodoEditor( Calendar *calendar, QWidget *parent );
46 virtual ~KOTodoEditor();
47
48 void init();
49
50 void reload();
51 void setSecrecy( int sec );
52 /**
53 Clear editor for new todo, and preset the dates and times with hint.
54 */
55 void newTodo(QDateTime due,Todo *relatedTodo=0,bool allDay=false);
56
57 /** Edit an existing todo. */
58 void editTodo(Todo * ,bool editDescription = false );
59
60 /** Set widgets to default values */
61 void setDefaults(QDateTime due,Todo *relatedTodo,bool allDay);
62 /** Read event object and setup widgets accordingly */
63 void readTodo(Todo *);
64 /** Write event settings to event object */
65 void writeTodo(Todo *);
66
67 /** Check if the input is valid. */
68 bool validateInput();
69 /** Process user input and create or update event. Returns false if input
70 * is not valid */
71 bool processInput( bool );
72
73 /** This todo has been modified externally */
74 void modified (int);
75 void setCategories( QString s );
76 signals:
77 void todoChanged(Todo *);
78 void todoAdded(Todo *);
79 void todoToBeDeleted(Todo *);
80 void todoDeleted();
81
82 protected slots:
83 void loadDefaults();
84 void deleteTodo();
85
86 void slotLoadTemplate();
87 void slotSaveTemplate();
88 void saveTemplate( const QString & );
89
90 protected:
91 void setupGeneral();
92 int msgItemDelete();
93
94 private:
95 Todo *mTodo;
96
97 Incidence *mRelatedTodo;
98
99 KOEditorGeneralTodo *mGeneral;
100};
101
102#endif
diff --git a/korganizer/kotodoeditor.moc b/korganizer/kotodoeditor.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kotodoeditor.moc
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
new file mode 100644
index 0000000..0708a69
--- a/dev/null
+++ b/korganizer/kotodoview.cpp
@@ -0,0 +1,1028 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qlayout.h>
25#include <qheader.h>
26#include <qcursor.h>
27
28#include <qvbox.h>
29#include <kdebug.h>
30#include "koprefs.h"
31#include <klocale.h>
32#include <kglobal.h>
33#include <kiconloader.h>
34#include <kmessagebox.h>
35
36#include <libkcal/icaldrag.h>
37#include <libkcal/vcaldrag.h>
38#include <libkcal/calfilter.h>
39#include <libkcal/dndfactory.h>
40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h>
42#include <kresources/resourceselectdialog.h>
43#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h>
45#else
46#include <qapplication.h>
47#endif
48#ifndef KORG_NOPRINTER
49#include "calprinter.h"
50#endif
51#include "docprefs.h"
52
53#include "kotodoview.h"
54using namespace KOrg;
55#include "kotodoview.moc"
56
57KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
58 const char *name) :
59 KListView(parent,name)
60{
61 mCalendar = calendar;
62#ifndef DESKTOP_VERSION
63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
64#endif
65 mOldCurrent = 0;
66 mMousePressed = false;
67
68 setAcceptDrops(true);
69 viewport()->setAcceptDrops(true);
70 int size = 16;
71 if (qApp->desktop()->width() < 300 )
72 size = 12;
73 setTreeStepSize( size + 6 );
74
75}
76
77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
78{
79#ifndef KORG_NODND
80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
82 !QTextDrag::canDecode( e ) ) {
83 e->ignore();
84 return;
85 }
86
87 mOldCurrent = currentItem();
88#endif
89}
90
91
92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
93{
94#ifndef KORG_NODND
95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
96
97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
98 !QTextDrag::canDecode( e ) ) {
99 e->ignore();
100 return;
101 }
102
103 e->accept();
104#endif
105}
106
107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
108{
109#ifndef KORG_NODND
110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
111
112 setCurrentItem(mOldCurrent);
113 setSelected(mOldCurrent,true);
114#endif
115}
116
117void KOTodoListView::contentsDropEvent(QDropEvent *e)
118{
119#ifndef KORG_NODND
120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
121
122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
123 !QTextDrag::canDecode( e ) ) {
124 e->ignore();
125 return;
126 }
127
128 DndFactory factory( mCalendar );
129 Todo *todo = factory.createDropTodo(e);
130
131 if (todo) {
132 e->acceptAction();
133
134 KOTodoViewItem *destination =
135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
136 Todo *destinationEvent = 0;
137 if (destination) destinationEvent = destination->todo();
138
139 Todo *existingTodo = mCalendar->todo(todo->uid());
140
141 if(existingTodo) {
142// kdDebug() << "Drop existing Todo" << endl;
143 Incidence *to = destinationEvent;
144 while(to) {
145 if (to->uid() == todo->uid()) {
146 KMessageBox::sorry(this,
147 i18n("Cannot move To-Do to itself or a child of itself"),
148 i18n("Drop To-Do"));
149 delete todo;
150 return;
151 }
152 to = to->relatedTo();
153 }
154 existingTodo->setRelatedTo(destinationEvent);
155 emit todoDropped(todo);
156 delete todo;
157 } else {
158// kdDebug() << "Drop new Todo" << endl;
159 todo->setRelatedTo(destinationEvent);
160 mCalendar->addTodo(todo);
161
162 emit todoDropped(todo);
163 }
164 }
165 else {
166 QString text;
167 if (QTextDrag::decode(e,text)) {
168 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
169 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
170 kdDebug() << "Dropped : " << text << endl;
171 QStringList emails = QStringList::split(",",text);
172 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
173 kdDebug() << " Email: " << (*it) << endl;
174 int pos = (*it).find("<");
175 QString name = (*it).left(pos);
176 QString email = (*it).mid(pos);
177 if (!email.isEmpty() && todoi) {
178 todoi->todo()->addAttendee(new Attendee(name,email));
179 }
180 }
181 }
182 else {
183 kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl;
184 e->ignore();
185 }
186 }
187#endif
188}
189
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
191{
192 QListView::contentsMousePressEvent(e);
193#ifndef KORG_NODND
194 QPoint p(contentsToViewport(e->pos()));
195 QListViewItem *i = itemAt(p);
196 if (i) {
197 // if the user clicked into the root decoration of the item, don't
198 // try to start a drag!
199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
201 itemMargin() ||
202 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
203 if (e->button()==Qt::LeftButton) {
204 mPressPos = e->pos();
205 mMousePressed = true;
206 }
207 }
208 }
209#endif
210}
211
212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
213{
214#ifndef KORG_NODND
215// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
216 QListView::contentsMouseMoveEvent(e);
217 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
218 QApplication::startDragDistance()) {
219 mMousePressed = false;
220 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
221 if (item) {
222// kdDebug() << "Start Drag for item " << item->text(0) << endl;
223 DndFactory factory( mCalendar );
224 ICalDrag *vd = factory.createDragTodo(
225 ((KOTodoViewItem *)item)->todo(),viewport());
226 if (vd->drag()) {
227 kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl;
228 }
229/*
230 QString source = fullPath(item);
231 if ( QFile::exists(source) ) {
232 QUriDrag* ud = new QUriDrag(viewport());
233 ud->setFilenames( source );
234 if ( ud->drag() )
235 QMessageBox::information( this, "Drag source",
236 QString("Delete ")+source, "Not implemented" );
237*/
238 }
239 }
240#endif
241}
242void KOTodoListView::keyPressEvent ( QKeyEvent * e )
243{
244
245 QListViewItem* cn;
246 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
247 cn = currentItem();
248 if ( cn ) {
249 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
250 if ( ci ){
251 if ( e->state() == ShiftButton )
252 ci->setOn( false );
253 else
254 ci->setOn( true );
255 cn = cn->nextSibling();
256 if ( cn ) {
257 setCurrentItem ( cn );
258 ensureItemVisible ( cn );
259 }
260
261 }
262 }
263
264 return;
265 }
266
267 // qDebug("KOTodoListView::keyPressEvent ");
268 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || ( height() > 150 && width() > 200 ) ) {
269 switch ( e->key() ) {
270 case Qt::Key_Down:
271 case Qt::Key_Up:
272 QListView::keyPressEvent ( e );
273 break;
274 default:
275 e->ignore();
276 break;
277 }
278 return;
279 }
280 e->ignore();
281}
282void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
283{
284 QListView::contentsMouseReleaseEvent(e);
285 mMousePressed = false;
286}
287
288void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
289{
290 if (!e) return;
291
292 QPoint vp = contentsToViewport(e->pos());
293
294 QListViewItem *item = itemAt(vp);
295
296 emit double_Clicked(item);
297 if (!item) return;
298
299 emit doubleClicked(item,vp,0);
300}
301
302/////////////////////////////////////////////////////////////////////////////
303
304KOQuickTodo::KOQuickTodo(QWidget *parent) :
305 QLineEdit(parent)
306{
307 setText(i18n("Click to add a new Todo"));
308}
309
310void KOQuickTodo::focusInEvent(QFocusEvent *ev)
311{
312 if ( text()==i18n("Click to add a new Todo") )
313 setText("");
314 QLineEdit::focusInEvent(ev);
315}
316
317void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
318{
319 setText(i18n("Click to add a new Todo"));
320 QLineEdit::focusOutEvent(ev);
321}
322
323/////////////////////////////////////////////////////////////////////////////
324
325KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
326 KOrg::BaseView(calendar,parent,name)
327{
328 QBoxLayout *topLayout = new QVBoxLayout(this);
329 mName = QString ( name );
330 mBlockUpdate = false;
331 mQuickAdd = new KOQuickTodo(this);
332 topLayout->addWidget(mQuickAdd);
333
334 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
335
336 mTodoListView = new KOTodoListView(calendar,this);
337 topLayout->addWidget(mTodoListView);
338 //mTodoListView->header()->setMaximumHeight(30);
339 mTodoListView->setRootIsDecorated(true);
340 mTodoListView->setAllColumnsShowFocus(true);
341
342 mTodoListView->setShowSortIndicator(true);
343
344 mTodoListView->addColumn(i18n("Todo"));
345 mTodoListView->addColumn(i18n("Prio"));
346 mTodoListView->setColumnAlignment(1,AlignHCenter);
347 mTodoListView->addColumn(i18n("Complete"));
348 mTodoListView->setColumnAlignment(2,AlignHCenter);
349 mTodoListView->addColumn(i18n("Due Date"));
350 mTodoListView->setColumnAlignment(3,AlignLeft);
351 mTodoListView->addColumn(i18n("Due Time"));
352 mTodoListView->setColumnAlignment(4,AlignHCenter);
353 mTodoListView->addColumn(i18n("Cancelled"));
354 mTodoListView->addColumn(i18n("Categories"));
355#if 0
356 mTodoListView->addColumn(i18n("Sort Id"));
357 mTodoListView->setColumnAlignment(4,AlignHCenter);
358#endif
359
360 mTodoListView->setMinimumHeight( 60 );
361 mTodoListView->setItemsRenameable( true );
362 mTodoListView->setRenameable( 0 );
363 mTodoListView->setColumnWidth( 0, 120 );
364 mTodoListView->setColumnWidthMode(0, QListView::Manual);
365 mTodoListView->setColumnWidthMode(1, QListView::Manual);
366 mTodoListView->setColumnWidthMode(2, QListView::Manual);
367 mTodoListView->setColumnWidthMode(3, QListView::Manual);
368 mTodoListView->setColumnWidthMode(4, QListView::Manual);
369 mTodoListView->setColumnWidthMode(5, QListView::Manual);
370 mTodoListView->setColumnAlignment( 2, AlignCenter );
371#if 0
372 mTodoListView->setColumnWidthMode(6, QListView::Manual);
373#endif
374
375 mPriorityPopupMenu = new QPopupMenu(this);
376 for (int i = 1; i <= 5; i++) {
377 QString label = QString ("%1").arg (i);
378 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
379 }
380 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
381
382 mPercentageCompletedPopupMenu = new QPopupMenu(this);
383 for (int i = 0; i <= 100; i+=20) {
384 QString label = QString ("%1 %").arg (i);
385 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
386 }
387 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
388
389
390
391 mItemPopupMenu = new QPopupMenu(this);
392 mItemPopupMenu->insertItem(i18n("Show..."), this,
393 SLOT (showTodo()));
394 mItemPopupMenu->insertItem(i18n("Edit..."), this,
395 SLOT (editTodo()));
396 mItemPopupMenu->insertItem( i18n("Delete"), this,
397 SLOT (deleteTodo()));
398 mItemPopupMenu->insertItem( i18n("Clone..."), this,
399 SLOT (cloneTodo()));
400 mItemPopupMenu->insertItem( i18n("Move..."), this,
401 SLOT (moveTodo()));
402 mItemPopupMenu->insertItem( i18n("Beam..."), this,
403 SLOT (beamTodo()));
404 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
405 SLOT (cancelTodo()));
406 mItemPopupMenu->insertSeparator();
407
408 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
409 SLOT (newTodo()));
410 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
411 SLOT (newSubTodo()));
412 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
413 SLOT (unparentTodo()));
414 mItemPopupMenu->insertSeparator();
415 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
416 this, SLOT( purgeCompleted() ) );
417 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
418 this, SLOT( toggleCompleted() ),0, 33 );
419 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
420 this, SLOT( toggleQuickTodo() ),0, 34 );
421
422 mPopupMenu = new QPopupMenu(this);
423 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
424 SLOT (newTodo()),0,1);
425 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
426 this, SLOT(purgeCompleted()),0,2);
427 mPopupMenu->insertItem(i18n("Show Completed"),
428 this, SLOT( toggleCompleted() ),0,3 );
429 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
430 this, SLOT( toggleQuickTodo() ),0,4 );
431 mDocPrefs = new DocPrefs( name );
432
433 mPopupMenu->setCheckable( true );
434 mItemPopupMenu->setCheckable( true );
435 // Double clicking conflicts with opening/closing the subtree
436 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
437 SLOT( editItem( QListViewItem *) ) );
438 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
439 const QPoint &,int ) ),
440 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
441 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
442 SLOT( itemClicked( QListViewItem * ) ) );
443 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
444 SLOT( itemDoubleClicked( QListViewItem * ) ) );
445 connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ),
446 SLOT( updateView() ) );
447 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
448 SLOT( itemStateChanged( QListViewItem * ) ) );
449 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
450 SLOT( itemStateChanged( QListViewItem * ) ) );
451
452#if 0
453 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
454 SLOT(selectionChanged(QListViewItem *)));
455 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
456 SLOT(selectionChanged(QListViewItem *)));
457 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
458 SLOT(selectionChanged(QListViewItem *)));
459#endif
460 connect( mTodoListView, SIGNAL(selectionChanged() ),
461 SLOT( processSelectionChange() ) );
462 connect( mQuickAdd, SIGNAL( returnPressed () ),
463 SLOT( addQuickTodo() ) );
464// if ( QApplication::desktop()->width() < 480 ) {
465// setNarrow();
466 // mTodoListView->setColumnWidth( 0, 100 );
467
468 // }
469
470}
471
472KOTodoView::~KOTodoView()
473{
474 delete mDocPrefs;
475}
476
477void KOTodoView::jumpToDate ()
478{
479 // if (mActiveItem) {
480// mActiveItem->todo());
481// if ( mActiveItem->todo()->hasDueDate() )
482// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
483}
484
485void KOTodoView::setNarrow()
486{
487 //mTodoListView->setColumnWidth( 0, 120 );
488 mTodoListView->setColumnWidth( 1, 35 );
489 mTodoListView->setColumnWidth( 2, 40 );
490 mTodoListView->setColumnWidth( 3, 80 );
491 mTodoListView->setColumnWidth( 4, 40 );
492 mTodoListView->setColumnWidth( 5, 90 );
493
494}
495void KOTodoView::updateView()
496{
497// kdDebug() << "KOTodoView::updateView()" << endl;
498 QFont fo = KOPrefs::instance()->mTodoViewFont;
499 mTodoListView->clear();
500 if ( mName == "todolistsmall" ) {
501 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
502 int ps = fo.pointSize() -2;
503 if ( ps > 12 )
504 ps -= 2;
505 fo.setPointSize( ps );
506 }
507 }
508
509 mTodoListView->setFont( fo );
510 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
511 //mTodoListView->header()->setMaximumHeight(fm.height());
512 QPtrList<Todo> todoList = calendar()->todos();
513
514/*
515 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
516 Event *t;
517 for(t = todoList.first(); t; t = todoList.next()) {
518 kdDebug() << " " << t->getSummary() << endl;
519
520 if (t->getRelatedTo()) {
521 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
522 }
523
524 QPtrList<Event> l = t->getRelations();
525 Event *c;
526 for(c=l.first();c;c=l.next()) {
527 kdDebug() << " - relation: " << c->getSummary() << endl;
528 }
529 }
530*/
531
532 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
533 // specific order of events. That means that we have to generate parent items
534 // recursively for proper hierarchical display of Todos.
535 mTodoMap.clear();
536 Todo *todo;
537 todo = todoList.first();// todo; todo = todoList.next()) {
538 while ( todo ) {
539 bool next = true;
540 // qDebug("todo %s ", todo->summary().latin1());
541 Incidence *incidence = todo->relatedTo();
542 while ( incidence ) {
543 if ( incidence->type() == "Todo") {
544 //qDebug("related %s ",incidence->summary().latin1() );
545 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
546 //qDebug("related not found ");
547 todoList.remove( );
548 todo = todoList.current();
549 next = false;
550 incidence = 0;
551
552 } else {
553 //qDebug("related found ");
554 incidence = incidence->relatedTo();
555 }
556 } else
557 incidence = 0;
558 }
559 if ( next )
560 todo = todoList.next();
561 }
562// qDebug("again .... ");
563// for(todo = todoList.first(); todo; todo = todoList.next()) {
564
565// qDebug("yytodo %s ", todo->summary().latin1());
566// }
567 //qDebug("for ");
568 for(todo = todoList.first(); todo; todo = todoList.next()) {
569 if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) )
570 {
571 insertTodoItem(todo);
572 }
573 }
574 //qDebug("for end ");
575 // Restore opened/closed state
576 mTodoListView->blockSignals( true );
577 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
578 mTodoListView->blockSignals( false );
579 mTodoListView->setFocus();
580 processSelectionChange();
581}
582
583void KOTodoView::restoreItemState( QListViewItem *item )
584{
585 while( item ) {
586 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
587 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
588 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
589 item = item->nextSibling();
590 }
591}
592
593
594QMap<Todo *,KOTodoViewItem *>::ConstIterator
595 KOTodoView::insertTodoItem(Todo *todo)
596{
597// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
598 // TODO: Check, if dynmaic cast is necessary
599
600
601 Incidence *incidence = todo->relatedTo();
602 if (incidence && incidence->type() == "Todo") {
603 Todo *relatedTodo = static_cast<Todo *>(incidence);
604
605// kdDebug() << " has Related" << endl;
606 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
607 itemIterator = mTodoMap.find(relatedTodo);
608 if (itemIterator == mTodoMap.end()) {
609// kdDebug() << " related not yet in list" << endl;
610 itemIterator = insertTodoItem (relatedTodo);
611 }
612 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
613 // and one into the map. Sure finding is more easy but why? -zecke
614 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
615 return mTodoMap.insert(todo,todoItem);
616 } else {
617// kdDebug() << " no Related" << endl;
618 // see above -zecke
619 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
620 return mTodoMap.insert(todo,todoItem);
621 }
622}
623
624
625void KOTodoView::updateConfig()
626{
627 updateView();
628 mTodoListView->repaintContents();
629}
630
631QPtrList<Incidence> KOTodoView::selectedIncidences()
632{
633 QPtrList<Incidence> selected;
634
635 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
636// if (!item) item = mActiveItem;
637 if (item) selected.append(item->todo());
638
639 return selected;
640}
641
642QPtrList<Todo> KOTodoView::selectedTodos()
643{
644 QPtrList<Todo> selected;
645
646 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
647// if (!item) item = mActiveItem;
648 if (item) selected.append(item->todo());
649
650 return selected;
651}
652
653void KOTodoView::changeEventDisplay(Event *, int)
654{
655 updateView();
656}
657
658void KOTodoView::showDates(const QDate &, const QDate &)
659{
660}
661
662void KOTodoView::showEvents(QPtrList<Event>)
663{
664 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
665}
666
667void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
668 const QDate &td)
669{
670#ifndef KORG_NOPRINTER
671 calPrinter->preview(CalPrinter::Todolist, fd, td);
672#endif
673}
674
675void KOTodoView::editItem(QListViewItem *item )
676{
677 // qDebug("editItem(QListViewItem *item ) ");
678 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
679}
680
681void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
682{
683 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
684}
685
686void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
687{
688
689 mActiveItem = (KOTodoViewItem *)item;
690 if (item) {
691 switch (column){
692 case 1:
693 mPriorityPopupMenu->popup(QCursor::pos ()); break;
694 case 2:
695 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
696 case 3:
697 moveTodo();
698 break;
699 case 6:
700 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
701 default:
702 mItemPopupMenu->popup(QCursor::pos());
703 }
704 } else mPopupMenu->popup(QCursor::pos());
705}
706void KOTodoView::newTodo()
707{
708 emit newTodoSignal();
709}
710
711void KOTodoView::newSubTodo()
712{
713 if (mActiveItem) {
714 emit newSubTodoSignal(mActiveItem->todo());
715 }
716}
717void KOTodoView::unparentTodo()
718{
719 if (mActiveItem) {
720 emit unparentTodoSignal(mActiveItem->todo());
721 }
722}
723void KOTodoView::editTodo()
724{
725 if (mActiveItem) {
726 emit editTodoSignal(mActiveItem->todo());
727 }
728}
729void KOTodoView::cloneTodo()
730{
731 if (mActiveItem) {
732 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
733 }
734}
735void KOTodoView::cancelTodo()
736{
737 if (mActiveItem) {
738 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
739 }
740}
741void KOTodoView::moveTodo()
742{
743 if (mActiveItem) {
744 emit moveTodoSignal((Incidence*)mActiveItem->todo());
745 }
746}
747void KOTodoView::beamTodo()
748{
749 if (mActiveItem) {
750 emit beamTodoSignal((Incidence*)mActiveItem->todo());
751 }
752}
753
754
755void KOTodoView::showTodo()
756{
757 if (mActiveItem) {
758 emit showTodoSignal(mActiveItem->todo());
759 }
760}
761
762void KOTodoView::deleteTodo()
763{
764 if (mActiveItem) {
765 if (mActiveItem->childCount()) {
766 KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."),
767 i18n("Delete To-Do"));
768 } else {
769 emit deleteTodoSignal(mActiveItem->todo());
770 }
771 }
772}
773
774void KOTodoView::setNewPriority(int index)
775{
776 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
777 mActiveItem->todo()->setPriority(mPriority[index]);
778 mActiveItem->construct();
779 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
780 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
781 }
782}
783
784void KOTodoView::setNewPercentage(int index)
785{
786 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
787 if (mPercentage[index] == 100) {
788 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
789 } else {
790 mActiveItem->todo()->setCompleted(false);
791 }
792 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
793 mActiveItem->construct();
794 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
795 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
796 }
797}
798
799
800QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
801{
802 QPopupMenu* tempMenu = new QPopupMenu (this);
803 QStringList checkedCategories = todoItem->todo()->categories ();
804
805 tempMenu->setCheckable (true);
806 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
807 it != KOPrefs::instance()->mCustomCategories.end ();
808 ++it) {
809 int index = tempMenu->insertItem (*it);
810 mCategory[index] = *it;
811 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
812 }
813
814 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
815 return tempMenu;
816
817
818}
819void KOTodoView::changedCategories(int index)
820{
821 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
822 QStringList categories = mActiveItem->todo()->categories ();
823 if (categories.find (mCategory[index]) != categories.end ())
824 categories.remove (mCategory[index]);
825 else
826 categories.insert (categories.end(), mCategory[index]);
827 categories.sort ();
828 mActiveItem->todo()->setCategories (categories);
829 mActiveItem->construct();
830 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
831 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
832 }
833}
834void KOTodoView::itemDoubleClicked(QListViewItem *item)
835{
836 if (!item) {
837 newTodo();
838 return;
839 }
840 if ( KOPrefs::instance()->mEditOnDoubleClick )
841 editItem( item );
842 else
843 showItem( item , QPoint(), 0 );
844}
845void KOTodoView::itemClicked(QListViewItem *item)
846{
847 if (!item) {
848 return;
849 }
850
851 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
852 int completed = todoItem->todo()->isCompleted(); // Completed or not?
853
854 if (todoItem->isOn()) {
855 if (!completed) {
856 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
857 }
858 } else {
859 if (completed) {
860 todoItem->todo()->setCompleted(false);
861 }
862 }
863}
864
865void KOTodoView::setDocumentId( const QString &id )
866{
867 kdDebug() << "KOTodoView::setDocumentId()" << endl;
868
869 mDocPrefs->setDoc( id );
870}
871
872void KOTodoView::itemStateChanged( QListViewItem *item )
873{
874 if (!item) return;
875
876 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
877
878// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
879
880 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
881}
882
883void KOTodoView::saveLayout(KConfig *config, const QString &group) const
884{
885 mTodoListView->saveLayout(config,group);
886}
887
888void KOTodoView::restoreLayout(KConfig *config, const QString &group)
889{
890 mTodoListView->restoreLayout(config,group);
891}
892
893void KOTodoView::processSelectionChange()
894{
895// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
896
897 KOTodoViewItem *item =
898 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
899
900 if ( !item ) {
901 emit incidenceSelected( 0 );
902 } else {
903 emit incidenceSelected( item->todo() );
904 }
905}
906
907void KOTodoView::modified(bool b)
908{
909 emit isModified(b);
910}
911void KOTodoView::setTodoModified( Todo* todo )
912{
913 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
914}
915void KOTodoView::clearSelection()
916{
917 mTodoListView->selectAll( false );
918}
919
920void KOTodoView::purgeCompleted()
921{
922 emit purgeCompletedSignal();
923}
924void KOTodoView::toggleQuickTodo()
925{
926 if ( mQuickAdd->isVisible() ) {
927 mQuickAdd->hide();
928 KOPrefs::instance()->mEnableQuickTodo = false;
929 }
930 else {
931 mQuickAdd->show();
932 KOPrefs::instance()->mEnableQuickTodo = true;
933 }
934 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
935 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
936}
937void KOTodoView::toggleCompleted()
938{
939 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
940 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
941 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
942 updateView();
943}
944
945void KOTodoView::addQuickTodo()
946{
947 Todo *todo = new Todo();
948 todo->setSummary(mQuickAdd->text());
949 todo->setOrganizer(KOPrefs::instance()->email());
950 CalFilter * cf = mCalendar->filter();
951 if ( cf ) {
952 if ( cf->isEnabled()&& cf->showCategories()) {
953 todo->setCategories(cf->categoryList());
954 }
955 if ( cf->isEnabled() )
956 todo->setSecrecy( cf->getSecrecy());
957 }
958 mCalendar->addTodo(todo);
959 mQuickAdd->setText("");
960 todoModified (todo, KOGlobals::EVENTADDED );
961 updateView();
962}
963void KOTodoView::keyPressEvent ( QKeyEvent * e )
964{
965 // e->ignore();
966 //return;
967 switch ( e->key() ) {
968 case Qt::Key_Down:
969 QWidget::keyPressEvent ( e );
970 break;
971
972 case Qt::Key_Up:
973 QWidget::keyPressEvent ( e );
974 break;
975 case Qt::Key_Q:
976 toggleQuickTodo();
977 break;
978
979 default:
980 e->ignore();
981 }
982
983 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || ( height() > 150 && width() > 200 ) ) {
984 if ( e->key() == Qt::Key_I ) {
985 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
986 if ( cn ) {
987 mActiveItem = cn;
988 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
989 if ( ci ){
990 showTodo();
991 cn = (KOTodoViewItem*)cn->itemBelow();
992 if ( cn ) {
993 mTodoListView->setCurrentItem ( cn );
994 mTodoListView->ensureItemVisible ( cn );
995 }
996
997 }
998 }
999 e->accept();
1000
1001 }
1002
1003 }
1004
1005}
1006void KOTodoView::updateTodo( Todo * t, int type )
1007{
1008 if ( mBlockUpdate)
1009 return;
1010
1011 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1012 itemIterator = mTodoMap.find(t);
1013 if (itemIterator != mTodoMap.end()) {
1014 (*itemIterator)->construct();
1015 } else {
1016 if ( type == KOGlobals::EVENTADDED ) {
1017 insertTodoItem( t );
1018 }
1019 }
1020
1021}
1022
1023void KOTodoView::todoModified(Todo * t , int p )
1024{
1025 mBlockUpdate = true;
1026 emit todoModifiedSignal ( t, p );
1027 mBlockUpdate = false;
1028}
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
new file mode 100644
index 0000000..4495702
--- a/dev/null
+++ b/korganizer/kotodoview.h
@@ -0,0 +1,230 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H
25
26#include <qfont.h>
27#include <qfontmetrics.h>
28#include <qlineedit.h>
29#include <qptrlist.h>
30#include <qstrlist.h>
31#include <qlistbox.h>
32#include <qpopupmenu.h>
33#include <qlabel.h>
34#include <qmap.h>
35#include <qlistview.h>
36#include <klistview.h>
37
38#include <libkcal/calendar.h>
39#include <libkcal/todo.h>
40
41#include <korganizer/baseview.h>
42
43#include "kotodoviewitem.h"
44#include "koprefs.h"
45#include "koglobals.h"
46
47class QDragEnterEvent;
48class QDragMoveEvent;
49class QDragLeaveEvent;
50class QDropEvent;
51
52class DocPrefs;
53
54class KOTodoListView : public KListView
55{
56 Q_OBJECT
57 public:
58 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
59 virtual ~KOTodoListView() {}
60
61 signals:
62 void todoDropped(Todo *);
63 void double_Clicked(QListViewItem *item);
64
65 protected:
66 void contentsDragEnterEvent(QDragEnterEvent *);
67 void contentsDragMoveEvent(QDragMoveEvent *);
68 void contentsDragLeaveEvent(QDragLeaveEvent *);
69 void contentsDropEvent(QDropEvent *);
70
71 void contentsMousePressEvent(QMouseEvent *);
72 void contentsMouseMoveEvent(QMouseEvent *);
73 void contentsMouseReleaseEvent(QMouseEvent *);
74 void contentsMouseDoubleClickEvent(QMouseEvent *);
75
76 private:
77 Calendar *mCalendar;
78 QPoint mPressPos;
79 bool mMousePressed;
80 QListViewItem *mOldCurrent;
81 void keyPressEvent ( QKeyEvent * ) ;
82};
83
84
85/**
86 This is the line-edit on top of the todoview for fast addition of new todos
87*/
88class KOQuickTodo : public QLineEdit
89{
90 public:
91 KOQuickTodo(QWidget *parent=0);
92 protected:
93 void focusInEvent(QFocusEvent *ev);
94 void focusOutEvent(QFocusEvent *ev);
95};
96
97
98/**
99 This class provides a multi-column list view of todo events.
100
101 @short multi-column list view of todo events.
102 @author Cornelius Schumacher <schumacher@kde.org>
103*/
104class KOTodoView : public KOrg::BaseView
105{
106 Q_OBJECT
107 public:
108 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
109 ~KOTodoView();
110
111 QPtrList<Incidence> selectedIncidences();
112 QPtrList<Todo> selectedTodos();
113
114 DateList selectedDates()
115 {DateList q;
116 return q;}
117
118 /** Return number of shown dates. TodoView does not show dates, */
119 int currentDateCount() { return 0; }
120 void setNarrow();
121
122 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
123
124 void setDocumentId( const QString & );
125
126 void saveLayout(KConfig *config, const QString &group) const;
127 void restoreLayout(KConfig *config, const QString &group);
128 /** Create a popup menu to set categories */
129 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
130
131 public slots:
132 void updateView();
133 void updateConfig();
134
135 void changeEventDisplay(Event *, int);
136
137 void showDates(const QDate &start, const QDate &end);
138 void showEvents(QPtrList<Event> eventList);
139
140 void clearSelection();
141 void jumpToDate ();
142
143 void editItem(QListViewItem *item);
144 void showItem(QListViewItem *item,const QPoint &,int);
145 void popupMenu(QListViewItem *item,const QPoint &,int);
146 void newTodo();
147 void newSubTodo();
148 void unparentTodo();
149 void showTodo();
150 void editTodo();
151 void cloneTodo();
152 void cancelTodo();
153 void moveTodo();
154 void beamTodo();
155 void deleteTodo();
156
157 void setNewPriority(int);
158 void setNewPercentage(int);
159 void changedCategories(int);
160
161 void purgeCompleted();
162 void toggleCompleted();
163 void toggleQuickTodo();
164 void updateTodo( Todo *, int );
165
166 void itemClicked(QListViewItem *);
167 void itemStateChanged(QListViewItem *);
168 void modified(bool);
169 void itemDoubleClicked(QListViewItem *item);
170
171 signals:
172 void newTodoSignal();
173 void newSubTodoSignal(Todo *);
174 void unparentTodoSignal(Todo *);
175 void showTodoSignal(Todo *);
176
177 void editTodoSignal(Todo *);
178 void deleteTodoSignal(Todo *);
179 void todoModifiedSignal (Todo *, int);
180
181 void isModified(bool);
182 void cloneTodoSignal( Incidence * );
183 void cancelTodoSignal( Incidence * );
184 void moveTodoSignal( Incidence * );
185 void beamTodoSignal( Incidence * );
186 void purgeCompletedSignal();
187
188 protected slots:
189 void processSelectionChange();
190 void addQuickTodo();
191
192 private:
193 /*
194 * the TodoEditor approach is rather unscaling in the long
195 * run.
196 * Korganizer keeps it in memory and we need to update
197 * 1. make KOTodoViewItem a QObject again?
198 * 2. add a public method for setting one todo modified?
199 * 3. add a private method for setting a todo modified + friend here?
200 * -- zecke 2002-07-08
201 */
202 friend class KOTodoViewItem;
203 void setTodoModified( Todo* );
204 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
205 void restoreItemState( QListViewItem * );
206
207 KOTodoListView *mTodoListView;
208 QPopupMenu *mItemPopupMenu;
209 QPopupMenu *mPopupMenu;
210 QPopupMenu *mPriorityPopupMenu;
211 QPopupMenu *mPercentageCompletedPopupMenu;
212 QPopupMenu *mCategoryPopupMenu;
213
214 QMap<int, int> mPercentage;
215 QMap<int, int> mPriority;
216 QMap<int, QString> mCategory;
217 KOTodoViewItem *mActiveItem;
218
219 QMap<Todo *,KOTodoViewItem *> mTodoMap;
220 QString mName;
221
222 DocPrefs *mDocPrefs;
223 QString mCurrentDoc;
224 KOQuickTodo *mQuickAdd;
225 bool mBlockUpdate;
226 void todoModified(Todo *, int );
227 void keyPressEvent ( QKeyEvent * ) ;
228};
229
230#endif
diff --git a/korganizer/kotodoview.moc b/korganizer/kotodoview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kotodoview.moc
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
new file mode 100644
index 0000000..85647b1
--- a/dev/null
+++ b/korganizer/kotodoviewitem.cpp
@@ -0,0 +1,432 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <klocale.h>
21#include <kdebug.h>
22#include <qapp.h>
23
24#include <kiconloader.h>
25#include "kotodoviewitem.h"
26#include "kotodoview.h"
27#include "koprefs.h"
28
29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
31{
32 construct();
33}
34
35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
37{
38 construct();
39}
40
41QString KOTodoViewItem::key(int column,bool) const
42{
43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
44 if (it == mKeyMap.end()) {
45 return text(column);
46 } else {
47 return *it;
48 }
49}
50
51void KOTodoViewItem:: setup()
52{
53
54 int h = 20;
55 if ( listView () ) {
56 QFontMetrics fm ( listView ()->font () );
57 h = fm.height();
58 }
59 setHeight( h );
60
61}
62void KOTodoViewItem::setSortKey(int column,const QString &key)
63{
64 mKeyMap.insert(column,key);
65}
66
67#if QT_VERSION >= 300
68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
69 int y,int h)
70{
71 QListViewItem::paintBranches(p,cg,w,y,h);
72}
73#else
74#endif
75
76void KOTodoViewItem::construct()
77{
78 // qDebug("KOTodoViewItem::construct() ");
79 m_init = true;
80 QString keyd = "==";
81 QString keyt = "==";
82
83 setOn(mTodo->isCompleted());
84 setText(0,mTodo->summary());
85 setText(1,QString::number(mTodo->priority()));
86 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
87 if (mTodo->percentComplete()<100) {
88 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
89 else setSortKey(2,QString::number(mTodo->percentComplete()));
90 }
91 else {
92 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
93 else setSortKey(2,QString::number(99));
94 }
95 if (mTodo->hasDueDate()) {
96 setText(3, mTodo->dtDueDateStr());
97 QDate d = mTodo->dtDue().date();
98 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
99 setSortKey(3,keyd);
100 if (mTodo->doesFloat()) {
101 setText(4,"");
102 }
103 else {
104 setText(4,mTodo->dtDueTimeStr());
105 QTime t = mTodo->dtDue().time();
106 keyt.sprintf("%02d%02d",t.hour(),t.minute());
107 setSortKey(4,keyt);
108 }
109 } else {
110 setText(3,"");
111 setText(4,"");
112 }
113 setSortKey(3,keyd);
114 setSortKey(4,keyt);
115
116 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
117 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
118
119 setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
120 setText(6,mTodo->categoriesStr());
121
122#if 0
123 // Find sort id in description. It's the text behind the last '#' character
124 // found in the description. White spaces are removed from beginning and end
125 // of sort id.
126 int pos = mTodo->description().findRev('#');
127 if (pos < 0) {
128 setText(6,"");
129 } else {
130 QString str = mTodo->description().mid(pos+1);
131 str.stripWhiteSpace();
132 setText(6,str);
133 }
134#endif
135
136 m_known = false;
137 m_init = false;
138
139 setMyPixmap();
140
141}
142void KOTodoViewItem::setMyPixmap()
143{
144 int size = 5;
145 QPixmap pixi = QPixmap( 1, 1 );
146 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
147// pixi = SmallIcon("redcross16");
148// } else {
149 QPainter p;
150
151 int pixSize = 0;
152 QPixmap pPix = QPixmap( size, size );
153 if ( mTodo->description().length() > 0 ) {
154 pixi.resize(size, pixSize+size);
155 pPix.fill( Qt::darkGreen );
156 p.begin( &pixi );
157 p. drawPixmap ( 0, pixSize, pPix);
158 p.end();
159 pixSize += size;
160 }
161 if ( mTodo->isAlarmEnabled() ) {
162 pixi.resize(size, pixSize+size);
163 pPix.fill( Qt::red );
164 p.begin( &pixi );
165 p. drawPixmap ( 0, pixSize, pPix);
166 p.end();
167 pixSize += size;
168 }
169 // }
170 if ( pixi.width() > 1 ) {
171 setPixmap ( 0,pixi ) ;
172 }
173
174
175}
176void KOTodoViewItem::stateChange(bool state)
177{
178 // qDebug("KOTodoViewItem::stateChange ");
179 // do not change setting on startup
180 if ( m_init ) return;
181
182 kdDebug() << "State changed, modified " << state << endl;
183 QString keyd = "==";
184 QString keyt = "==";
185
186 if (state) mTodo->setCompleted(state);
187 else mTodo->setPercentComplete(0);
188 if (isOn()!=state) {
189 setOn(state);
190 }
191
192 if (mTodo->hasDueDate()) {
193 setText(3, mTodo->dtDueDateStr());
194 QDate d = mTodo->dtDue().date();
195 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
196 setSortKey(3,keyd);
197 if (mTodo->doesFloat()) {
198 setText(4,"");
199 }
200 else {
201 setText(4,mTodo->dtDueTimeStr());
202 QTime t = mTodo->dtDue().time();
203 keyt.sprintf("%02d%02d",t.hour(),t.minute());
204 setSortKey(4,keyt);
205 }
206 }
207 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
208 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
209
210 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
211 if (mTodo->percentComplete()<100) {
212 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
213 else setSortKey(2,QString::number(mTodo->percentComplete()));
214 }
215 else {
216 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
217 else setSortKey(2,QString::number(99));
218 }
219 QListViewItem * myChild = firstChild();
220 KOTodoViewItem *item;
221 while( myChild ) {
222 item = static_cast<KOTodoViewItem*>(myChild);
223 item->stateChange(state);
224 myChild = myChild->nextSibling();
225 }
226 mTodoView->modified(true);
227 mTodoView->setTodoModified( mTodo );
228 setMyPixmap();
229}
230
231bool KOTodoViewItem::isAlternate()
232{
233#ifndef KORG_NOLVALTERNATION
234 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
235 if (lv && lv->alternateBackground().isValid())
236 {
237 KOTodoViewItem *above = 0;
238 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
239 m_known = above ? above->m_known : true;
240 if (m_known)
241 {
242 m_odd = above ? !above->m_odd : false;
243 }
244 else
245 {
246 KOTodoViewItem *item;
247 bool previous = true;
248 if (QListViewItem::parent())
249 {
250 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
251 if (item)
252 previous = item->m_odd;
253 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
254 }
255 else
256 {
257 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
258 }
259
260 while(item)
261 {
262 item->m_odd = previous = !previous;
263 item->m_known = true;
264 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
265 }
266 }
267 return m_odd;
268 }
269 return false;
270#else
271 return false;
272#endif
273}
274
275void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
276{
277 QColorGroup _cg = cg;
278 QColorGroup::ColorRole role;
279 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
280 role = QColorGroup::Text;
281 else
282 role = QColorGroup::Base;
283 //#ifndef KORG_NOLVALTERNATION
284 // if (isAlternate())
285 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
286 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
287 QColor colorToSet;
288 if ( setColor ) {
289 QStringList categories = mTodo->categories();
290 QString cat = categories.first();
291 if ( !cat.isEmpty()) {
292 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
293 } else
294 setColor = false;
295 }
296 if (mTodo->hasDueDate()) {
297 if (mTodo->dtDue().date()==QDate::currentDate() &&
298 !mTodo->isCompleted()) {
299 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor);
300 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
301 setColor = true;
302 }
303 if (mTodo->dtDue().date() < QDate::currentDate() &&
304 !mTodo->isCompleted()) {
305 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor);
306 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
307 setColor = true;
308 }
309 }
310
311 if ( setColor ) {
312 _cg.setColor(role,colorToSet );
313 if ( role == QColorGroup::Base) {
314 int rgb = colorToSet.red();
315 rgb += colorToSet.blue()/2;
316 rgb += colorToSet.green();
317 if ( rgb < 200 )
318 _cg.setColor(QColorGroup::Text,Qt::white );
319 }
320 }
321 //#endif
322 if ( column > 0 ){
323 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
324 p->save();
325 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
326
327 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
328 // p->setPen(Qt::black ); //border
329 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
330 QColor fc = KOPrefs::instance()->mHighlightColor;
331 if ( mTodo->percentComplete() == 100 )
332 fc = darkGreen;
333 p->drawRect( 2, 2, width-4, height()-4);
334 p->fillRect( 3, 3, progress, height()-6,
335 fc );
336 p->restore();
337 } else {
338 QCheckListItem::paintCell(p, _cg, column, width, alignment);
339 }
340 return;
341 }
342
343 int align = alignment;
344
345 if ( !p )
346 return;
347
348 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
349
350 QListView *lv = listView();
351 if ( !lv )
352 return;
353 int marg = 2;//lv->itemMargin();
354 int r = 0;
355 QCheckListItem::Type myType = QCheckListItem::CheckBox;
356 int BoxSize = 20;
357 int boxOffset = 2;
358 int xOffset = 2;
359 if (qApp->desktop()->width() < 300 ) {
360 BoxSize = 14;
361 boxOffset = -1;
362 xOffset = 1;
363 // marg = 0;
364 }
365 if ( height() < BoxSize ) {
366 boxOffset = boxOffset - ((BoxSize - height())/2) ;
367 // qDebug("boxOffset %d height %d", boxOffset, height() );
368 BoxSize = height();
369
370 }
371 //bool winStyle = lv->style() == WindowsStyle;
372
373 int lineStart = 5;
374 if ( myType == Controller ) {
375 if ( !pixmap( 0 ) )
376 r += BoxSize + 4;
377 } else {
378 ASSERT( lv ); //###
379 //QFontMetrics fm( lv->font() );
380 //int d = fm.height();
381 int x = 0;
382 int y = (height() - BoxSize) / 2;
383 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
384 if ( myType == CheckBox ) {
385 if ( isEnabled() )
386 p->setPen( QPen( _cg.text(), 1 ) );
387 else
388 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
389 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
390 lineStart = x+marg;
391 /////////////////////
392 x++;
393 y++;
394 if ( isOn() ) {
395 QPointArray a( 7*2 );
396 int i, xx, yy;
397 xx = x+xOffset+marg+(boxOffset/2);
398 yy = y+5+boxOffset;
399 for ( i=0; i<3; i++ ) {
400 a.setPoint( 2*i, xx, yy );
401 a.setPoint( 2*i+1, xx, yy+2 );
402 // qDebug(" ");
403 xx++; yy++;
404 }
405 yy -= 2;
406 for ( i=3; i<7; i++ ) {
407 a.setPoint( 2*i, xx, yy );
408 a.setPoint( 2*i+1, xx, yy+2 );
409 xx++; yy--;
410 }
411 p->setPen( darkGreen );
412 p->drawLineSegments( a );
413 }
414 ////////////////////////
415 }
416 r += BoxSize + 4;
417 }
418
419 p->translate( r, 0 );
420 p->setPen( QPen( _cg.text() ) );
421 QListViewItem::paintCell( p, _cg, column, width - r, align );
422 if ( mTodo->cancelled () ) {
423 p->setPen( black );
424 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
425 int wid = br.width() +lineStart;
426 if ( wid > width-3 )
427 wid = width-3;
428 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
429
430 }
431
432}
diff --git a/korganizer/kotodoviewitem.h b/korganizer/kotodoviewitem.h
new file mode 100644
index 0000000..74dbe98
--- a/dev/null
+++ b/korganizer/kotodoviewitem.h
@@ -0,0 +1,93 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef KOTODOVIEWITEM_H
20#define KOTODOVIEWITEM_H
21
22#include <qfont.h>
23#include <qfontmetrics.h>
24#include <qlineedit.h>
25#include <qptrlist.h>
26#include <qstrlist.h>
27#include <qlistbox.h>
28#include <qpopupmenu.h>
29#include <qlabel.h>
30#include <qmap.h>
31#include <qlistview.h>
32#include <qpainter.h>
33
34#include <libkcal/calendar.h>
35#include <libkcal/todo.h>
36
37using namespace KCal;
38
39class KOTodoView;
40
41/**
42 This class provides a way of displaying a single Event of Todo-Type in a
43 KTodoView.
44
45 @author Cornelius Schumacher <schumacher@kde.org>
46 @see KOTodoView
47*/
48class KOTodoViewItem : public QCheckListItem
49{
50 public:
51 /**
52 Constructor.
53
54 @param parent is the list view to which this item belongs.
55 @param ev is the event to have the item display information for.
56 */
57 KOTodoViewItem(QListView *parent, Todo *todo, KOTodoView *kotodo);
58 KOTodoViewItem(KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo);
59 //~KOTodoViewItem() { qDebug("~KOTodoViewItem() %s ", text(0).latin1() );}
60
61 void construct();
62
63 Todo *todo() { return mTodo; }
64
65 QString key(int, bool) const;
66
67 void setSortKey(int column,const QString &key);
68
69 bool isAlternate();
70
71 virtual void paintCell(QPainter *p, const QColorGroup &cg,
72 int column, int width, int alignment);
73 virtual void setup();
74 protected:
75#if QT_VERSION >= 300
76 void paintBranches(QPainter *p,const QColorGroup & cg,int w,int y,int h);
77#else
78#endif
79 virtual void stateChange(bool);
80 void setMyPixmap();
81
82 private:
83 Todo *mTodo;
84 KOTodoView *mTodoView;
85
86 QMap<int,QString> mKeyMap;
87 uint m_odd : 1;
88 uint m_known : 1;
89 uint m_unused : 30;
90 bool m_init;
91};
92
93#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
new file mode 100644
index 0000000..88d69c6
--- a/dev/null
+++ b/korganizer/koviewmanager.cpp
@@ -0,0 +1,570 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution.
24*/
25
26#include <qwidgetstack.h>
27
28#include <kconfig.h>
29#include <kglobal.h>
30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h>
32#else
33#include <qapplication.h>
34#endif
35#include "calendarview.h"
36#include "datenavigator.h"
37#include "kotodoview.h"
38#include "koagendaview.h"
39#include "kodialogmanager.h"
40#include "komonthview.h"
41#include "kolistview.h"
42#include "kowhatsnextview.h"
43#include "kojournalview.h"
44#include "kotimespanview.h"
45#include "koprefs.h"
46#include "navigatorbar.h"
47
48#include "koviewmanager.h"
49#include "koviewmanager.moc"
50//extern bool externFlagMonthviewBlockPainting;
51
52//bool globalFlagBlockPainting = false;
53int globalFlagBlockAgenda = 0;
54int globalFlagBlockLabel = 0;
55int globalFlagBlockAgendaItemPaint = 1;
56int globalFlagBlockAgendaItemUpdate = 1;
57
58
59KOViewManager::KOViewManager( CalendarView *mainView ) :
60 QObject(), mMainView( mainView )
61{
62 mCurrentView = 0;
63
64 mWhatsNextView = 0;
65 mTodoView = 0;
66 mAgendaView = 0;
67 mMonthView = 0;
68 mListView = 0;
69 mJournalView = 0;
70 mTimeSpanView = 0;
71 mCurrentAgendaView = 0 ;
72 mFlagShowNextxDays = false;
73}
74
75KOViewManager::~KOViewManager()
76{
77}
78
79
80KOrg::BaseView *KOViewManager::currentView()
81{
82 return mCurrentView;
83}
84
85void KOViewManager::readSettings(KConfig *config)
86{
87 config->setGroup("General");
88 QString view = config->readEntry("Current View");
89 if (view == "WhatsNext") showWhatsNextView();
90 else if (view == "Month") showMonthView();
91 else if (view == "List") showListView();
92 else if (view == "Journal") showJournalView();
93 else if (view == "TimeSpan") showTimeSpanView();
94 else if (view == "Todo") showTodoView();
95 else {
96 showAgendaView();
97 }
98}
99
100void KOViewManager::writeSettings(KConfig *config)
101{
102 config->setGroup("General");
103
104 QString view;
105 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
106 else if (mCurrentView == mMonthView) view = "Month";
107 else if (mCurrentView == mListView) view = "List";
108 else if (mCurrentView == mJournalView) view = "Journal";
109 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
110 else if (mCurrentView == mTodoView) view = "Todo";
111 else view = "Agenda";
112
113 config->writeEntry("Current View",view);
114
115 if (mAgendaView) {
116 mAgendaView->writeSettings(config);
117 }
118 if (mTimeSpanView) {
119 mTimeSpanView->writeSettings(config);
120 }
121 if (mListView) {
122 mListView->writeSettings(config);
123 }
124 if (mTodoView) {
125 mTodoView->saveLayout(config,"Todo View");
126 }
127}
128
129void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
130{
131
132 //mFlagShowNextxDays = false;
133 //if(view == mCurrentView) return;
134 if ( view == 0 ) {
135 view = mCurrentView;
136 if ( view == 0 )
137 return;
138 }
139 bool full = fullScreen;
140 if(view == mCurrentView && view != mWhatsNextView ) {
141 if ( mCurrentAgendaView < 0 )
142 return;
143 full = mMainView->leftFrame()->isVisible();
144 } else {
145 mCurrentView = view;
146
147 // bool full = fullScreen;
148 bool isFull = !mMainView->leftFrame()->isVisible();
149 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
150 full = true;
151 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
152 full = false;
153 }
154 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
155 raiseCurrentView( full );
156 mMainView->processIncidenceSelection( 0 );
157 mMainView->updateView();
158 mMainView->adaptNavigationUnits();
159}
160
161void KOViewManager::raiseCurrentView( bool fullScreen )
162{
163 //qDebug("raiseCurrentView ");
164 mCurrentAgendaView = 0;
165 int wid = mMainView->width() ;
166 int hei = mMainView->height();
167 if ( mCurrentView == mMonthView ) {
168 mMainView->navigatorBar()->show();
169 hei -= mMainView->navigatorBar()->sizeHint().height();
170 //mMainView->navigatorBar()->hide();
171 } else {
172 mMainView->navigatorBar()->hide();
173 }
174 if ( fullScreen ) {
175 mMainView->leftFrame()->hide();
176 } else {
177 mMainView->leftFrame()->show();
178 if ( KOPrefs::instance()->mVerticalScreen )
179 hei -= mMainView->leftFrame()->height();
180 else
181 wid -= mMainView->leftFrame()->width();
182 }
183
184 if ( globalFlagBlockAgenda == 5 ) {
185 globalFlagBlockAgenda = 4;
186 globalFlagBlockAgendaItemPaint = 1;
187 }
188 mMainView->viewStack()->raiseWidget(mCurrentView);
189 if ( globalFlagBlockAgenda == 4 ) {
190 if ( mCurrentView == mAgendaView ) {
191 //globalFlagBlockAgenda =1 ;
192 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
193 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
194 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
195 mAgendaView->setStartHour( QTime::currentTime ().hour() );
196 qApp->processEvents();
197 //qDebug("qApp->processEvents() ");
198 globalFlagBlockAgenda = 0;
199 mAgendaView->repaintAgenda();
200
201 }
202 globalFlagBlockAgenda = 0;
203 }
204 //qDebug("raiseCurrentView ende ");
205}
206
207void KOViewManager::updateView()
208{
209 // qDebug("KOViewManager::updateView() ");
210 // if we are updating mTodoView, we get endless recursion
211 if ( mTodoView == mCurrentView )
212 return;
213 if ( mCurrentView ) mCurrentView->updateView();
214
215}
216
217void KOViewManager::updateView(const QDate &start, const QDate &end)
218{
219 // kdDebug() << "KOViewManager::updateView()" << endl;
220
221 if (mCurrentView) mCurrentView->showDates(start, end);
222
223 if (mTodoView) mTodoView->updateView();
224}
225
226
227void KOViewManager::showWhatsNextView()
228{
229 if (!mWhatsNextView) {
230 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
231 "KOViewManager::WhatsNextView");
232 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
233 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
234 addView(mWhatsNextView);
235 }
236 globalFlagBlockAgenda = 1;
237 showView(mWhatsNextView, true );
238 mWhatsNextView->updateView();
239
240}
241
242void KOViewManager::showListView()
243{
244 if (!mListView) {
245 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
246 addView(mListView);
247
248 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
249 mMainView, SLOT(showIncidence(Incidence *)));
250 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
251 mMainView, SLOT(editIncidence(Incidence *)));
252 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
253 mMainView, SLOT(deleteIncidence(Incidence *)));
254 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
255 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
256 connect( mListView, SIGNAL( signalNewEvent() ),
257 mMainView, SLOT( newEvent() ) );
258 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
259 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
260 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
261 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
262 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
263 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
264 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
265 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
266 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
267 }
268 // bool temp = mFlagShowNextxDays;
269 //globalFlagBlockPainting = true;
270 globalFlagBlockAgenda = 1;
271 if ( KOPrefs::instance()->mListViewMonthTimespan )
272 mMainView->dateNavigator()->selectMonth();
273 showView(mListView, KOPrefs::instance()->mFullViewTodo);
274 //mFlagShowNextxDays = temp;
275}
276
277void KOViewManager::showAgendaView( bool fullScreen )
278{
279
280 mMainView->dialogManager()->hideSearchDialog();
281 // qDebug("KOViewManager::showAgendaView ");
282 bool full;
283 full = fullScreen;
284 if (!mAgendaView) {
285 full = false;
286 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
287 addView(mAgendaView);
288#ifndef DESKTOP_VERSION
289 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
290#endif
291 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
292 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
293
294 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
295 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
296 mMainView, SLOT(newEvent(QDateTime)));
297 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
298 // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
299 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
300 mMainView, SLOT(newEvent(QDate)));
301
302 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
303 mMainView, SLOT(editIncidence(Incidence *)));
304 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
305 mMainView, SLOT(showIncidence(Incidence *)));
306 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
307 mMainView, SLOT(deleteIncidence(Incidence *)));
308
309 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
310 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
311
312 connect(mAgendaView, SIGNAL( toggleExpand() ),
313 mMainView, SLOT( toggleExpand() ) );
314
315 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
316 mAgendaView, SLOT( setExpandedButton( bool ) ) );
317 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
318 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
319 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
320 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
321 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
322 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
323 SLOT( updateTodo( Todo *, int ) ) );
324 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
325 mMainView, SIGNAL( todoModified( Todo *, int )));
326 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
327 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
328 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
329 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
330 mAgendaView->readSettings();
331 mAgendaView->updateConfig();
332 }
333
334 showView( mAgendaView, full);
335
336}
337
338void KOViewManager::showDayView()
339{
340 mFlagShowNextxDays = false;
341 globalFlagBlockLabel = 1;
342 globalFlagBlockAgenda = 1;
343 if ( mCurrentAgendaView != 1 )
344 mCurrentAgendaView = -1;
345 showAgendaView();
346 qApp->processEvents();
347 globalFlagBlockAgenda = 2;
348 globalFlagBlockLabel = 0;
349 mMainView->dateNavigator()->selectDates( 1 );
350 mCurrentAgendaView = 1 ;
351
352}
353
354void KOViewManager::showWorkWeekView()
355{
356 mFlagShowNextxDays = false;
357 globalFlagBlockAgenda = 1;
358 globalFlagBlockLabel = 1;
359 if ( mCurrentAgendaView != 5 )
360 mCurrentAgendaView = -1;
361 showAgendaView();
362 qApp->processEvents();
363 globalFlagBlockAgenda = 2;
364 globalFlagBlockLabel = 0;
365 mMainView->dateNavigator()->selectWorkWeek();
366 mCurrentAgendaView = 5 ;
367
368}
369
370void KOViewManager::showWeekView()
371{
372 /*
373 globalFlagBlockAgenda = 2;
374 qDebug("4globalFlagBlockAgenda = 2; ");
375 //globalFlagBlockPainting = true;
376 mMainView->dateNavigator()->selectWeek();
377 showAgendaView();
378 */
379
380
381 mFlagShowNextxDays = false;
382 globalFlagBlockAgenda = 1;
383 globalFlagBlockLabel = 1;
384 if ( mCurrentAgendaView != 7 )
385 mCurrentAgendaView = -1;
386 showAgendaView();
387 qApp->processEvents();
388 globalFlagBlockAgenda = 2;
389 globalFlagBlockLabel = 0;
390 mMainView->dateNavigator()->selectWeek();
391 mCurrentAgendaView = 7 ;
392}
393
394void KOViewManager::showNextXView()
395{
396
397 globalFlagBlockAgenda = 1;
398 if ( mCurrentAgendaView != 3 )
399 mCurrentAgendaView = -1;
400 showAgendaView(KOPrefs::instance()->mFullViewMonth);
401 globalFlagBlockAgenda = 2;
402 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
403 KOPrefs::instance()->mNextXDays );
404 mFlagShowNextxDays = true;
405 mCurrentAgendaView = 3 ;
406}
407bool KOViewManager::showsNextDays()
408{
409 return mFlagShowNextxDays;
410}
411void KOViewManager::showMonthView()
412{
413 if (!mMonthView) {
414 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
415
416 addView(mMonthView);
417 // mMonthView->show();
418 // SIGNALS/SLOTS FOR MONTH VIEW
419 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
420 mMainView, SLOT(newEvent(QDateTime)));
421
422 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
423 mMainView, SLOT(showIncidence(Incidence *)));
424 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
425 mMainView, SLOT(editIncidence(Incidence *)));
426 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
427 mMainView, SLOT(deleteIncidence(Incidence *)));
428
429 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
430 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
431 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
432 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
433 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
434 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
435
436 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
437 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
438 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
439 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
440 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
441 mMainView, SLOT ( selectWeekNum( int ) ) );
442 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
443 mMonthView->updateConfig();
444 }
445
446 globalFlagBlockAgenda = 1;
447 //mFlagShowNextxDays = false;
448 // if(mMonthView == mCurrentView) return;
449 mMainView->dateNavigator()->selectMonth();
450 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
451 //mMonthView->showDates(tmpList.first(), tmpList.last());
452
453 showView(mMonthView, true );
454
455}
456
457void KOViewManager::showTodoView()
458{
459 //mFlagShowNextxDays = false;
460 if ( !mTodoView ) {
461 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
462 "KOViewManager::TodoView" );
463
464 addView( mTodoView );
465 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
466
467 // SIGNALS/SLOTS FOR TODO VIEW
468 connect( mTodoView, SIGNAL( newTodoSignal() ),
469 mMainView, SLOT( newTodo() ) );
470 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
471 mMainView, SLOT( newSubTodo( Todo *) ) );
472 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
473 mMainView, SLOT( showTodo( Todo * ) ) );
474 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
475 mMainView, SLOT( editTodo( Todo * ) ) );
476 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
477 mMainView, SLOT( deleteTodo( Todo * ) ) );
478 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
479 mMainView, SLOT( purgeCompleted() ) );
480
481 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
482 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
483
484 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
485 SLOT( updateConfig() ) );
486 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
487 SLOT( updateTodo( Todo *, int ) ) );
488 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
489 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
490 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
491 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
492 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
493 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
494 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
495 mMainView, SLOT ( todo_unsub( Todo * ) ) );
496 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
497 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
498 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
499 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
500 KConfig *config = KOGlobals::config();
501 mTodoView->restoreLayout(config,"Todo View");
502 }
503
504 globalFlagBlockAgenda = 1;
505 showView( mTodoView, true );
506
507}
508
509void KOViewManager::showJournalView()
510{
511 //mFlagShowNextxDays = false;
512 if (!mJournalView) {
513 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
514 "KOViewManager::JournalView");
515 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
516 SLOT( updateConfig() ) );
517 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
518 addView(mJournalView);
519 }
520
521 showView(mJournalView);
522}
523
524void KOViewManager::showTimeSpanView()
525{
526 //mFlagShowNextxDays = false;
527 if (!mTimeSpanView) {
528 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
529 "KOViewManager::TimeSpanView");
530 addView(mTimeSpanView);
531
532 mTimeSpanView->readSettings();
533 }
534
535 showView(mTimeSpanView);
536}
537
538Incidence *KOViewManager::currentSelection()
539{
540 if (!mCurrentView) return 0;
541 if ( mCurrentView == mListView ) {
542 if ( mListView->currentItem() )
543 return mListView->currentItem();
544 }
545 return mCurrentView->selectedIncidences().first();
546}
547
548QDate KOViewManager::currentSelectionDate()
549{
550 QDate qd;
551 if (mCurrentView) {
552 DateList qvl = mCurrentView->selectedDates();
553 if (!qvl.isEmpty()) qd = qvl.first();
554 }
555 return qd;
556}
557
558void KOViewManager::addView(KOrg::BaseView *view)
559{
560#if QT_VERSION >= 300
561 mMainView->viewStack()->addWidget( view );
562#else
563 mMainView->viewStack()->addWidget( view, 1 );
564#endif
565}
566
567void KOViewManager::setDocumentId( const QString &id )
568{
569 if (mTodoView) mTodoView->setDocumentId( id );
570}
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
new file mode 100644
index 0000000..f814c36
--- a/dev/null
+++ b/korganizer/koviewmanager.h
@@ -0,0 +1,113 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001
4 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef KOVIEWMANAGER_H
25#define KOVIEWMANAGER_H
26
27#include <qobject.h>
28
29#include <korganizer/baseview.h>
30
31class CalendarView;
32
33class KOListView;
34class KOAgendaView;
35class KOMonthView;
36class KOTimeSpanView;
37class KOTodoView;
38class KOWhatsNextView;
39class KOJournalView;
40
41using namespace KCal;
42
43/**
44 This class manages the views of the calendar. It owns the objects and handles
45 creation and selection.
46*/
47class KOViewManager : public QObject
48{
49 Q_OBJECT
50 public:
51 KOViewManager( CalendarView * );
52 virtual ~KOViewManager();
53
54 /** changes the view to be the currently selected view */
55 void showView(KOrg::BaseView *, bool fullScreen = false );
56
57 void readSettings(KConfig *config);
58 void writeSettings(KConfig *config);
59 bool showsNextDays();
60 /** Read which view was shown last from config file */
61 void readCurrentView(KConfig *);
62 /** Write which view is currently shown to config file */
63 void writeCurrentView(KConfig *);
64
65 KOrg::BaseView *currentView();
66
67 void setDocumentId( const QString & );
68
69 void updateView();
70 void updateView( const QDate &start, const QDate &end );
71
72 void raiseCurrentView( bool fullScreen = false );
73
74 void addView(KOrg::BaseView *);
75
76 Incidence *currentSelection();
77 QDate currentSelectionDate();
78
79 KOAgendaView *agendaView() const { return mAgendaView; }
80
81 public slots:
82 void showWhatsNextView();
83 void showListView();
84 void showAgendaView( bool fullScreen = false );
85 void showDayView();
86 void showWorkWeekView();
87 void showWeekView();
88 void showNextXView();
89 void showMonthView();
90 void showTodoView();
91 void showJournalView();
92 void showTimeSpanView();
93
94 private:
95 CalendarView *mMainView;
96
97 int mCurrentAgendaView;
98 KOAgendaView *mAgendaView;
99 KOListView *mListView;
100 KOMonthView *mMonthView;
101 KOTodoView *mTodoView;
102 KOWhatsNextView *mWhatsNextView;
103 KOJournalView *mJournalView;
104 KOTimeSpanView *mTimeSpanView;
105
106 KOrg::BaseView *mCurrentView; // currently active event view
107
108 int mAgendaViewMode;
109 bool mFlagShowNextxDays;
110
111};
112
113#endif
diff --git a/korganizer/koviewmanager.moc b/korganizer/koviewmanager.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/koviewmanager.moc
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
new file mode 100644
index 0000000..ffaea37
--- a/dev/null
+++ b/korganizer/kowhatsnextview.cpp
@@ -0,0 +1,650 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <qlayout.h>
21#include <qtextbrowser.h>
22#include <qtextcodec.h>
23#include <qfileinfo.h>
24#include <qlabel.h>
25
26#include <qapplication.h>
27
28#include <kglobal.h>
29#include <klocale.h>
30#include <kdebug.h>
31#include <kiconloader.h>
32#include <kmessagebox.h>
33
34#include <libkcal/calendar.h>
35
36#ifndef KORG_NOPRINTER
37#include "calprinter.h"
38#endif
39#include "koglobals.h"
40#include "koprefs.h"
41#include "koeventviewerdialog.h"
42
43#include "kowhatsnextview.h"
44using namespace KOrg;
45#include "kowhatsnextview.moc"
46
47void WhatsNextTextBrowser::setSource(const QString& n)
48{
49
50 if (n.startsWith("event:")) {
51 emit showIncidence(n);
52 return;
53 } else if (n.startsWith("todo:")) {
54 emit showIncidence(n);
55 return;
56 } else {
57 QTextBrowser::setSource(n);
58 }
59}
60
61KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
62 const char *name)
63 : KOrg::BaseView(calendar, parent, name)
64{
65 // mDateLabel =
66 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
67 // mDateLabel->setMargin(2);
68 // mDateLabel->setAlignment(AlignCenter);
69 setFont( KOPrefs::instance()->mWhatsNextFont );
70 mView = new WhatsNextTextBrowser(this);
71 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
72
73 mEventViewer = 0;
74
75 QBoxLayout *topLayout = new QVBoxLayout(this);
76 // topLayout->addWidget(mDateLabel);
77 topLayout->addWidget(mView);
78}
79
80KOWhatsNextView::~KOWhatsNextView()
81{
82}
83
84int KOWhatsNextView::maxDatesHint()
85{
86 return 0;
87}
88
89int KOWhatsNextView::currentDateCount()
90{
91 return 0;
92}
93
94QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
95{
96 QPtrList<Incidence> eventList;
97
98 return eventList;
99}
100
101
102void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
103 const QDate &td)
104{
105#ifndef KORG_NOPRINTER
106 calPrinter->preview(CalPrinter::Day, fd, td);
107#endif
108}
109void KOWhatsNextView::updateConfig()
110{
111 setFont( KOPrefs::instance()->mWhatsNextFont );
112 updateView();
113
114}
115void KOWhatsNextView::updateView()
116{
117
118 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
119 KIconLoader kil("korganizer");
120 QString ipath;// = new QString();
121 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
122 //<big><big><strong>" + date + "</strong></big></big>\n";
123 mText = "<table width=\"100%\">\n";
124 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
125#ifdef DESKTOP_VERSION
126 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
127#else
128 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
129#endif
130 // mText += "<img src=\"";
131 // mText += ipath;
132 // mText += "\">";
133 mEventDate = QDate::currentDate();
134#ifdef DESKTOP_VERSION
135 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
136#else
137 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
138#endif
139 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
140 int iii;
141 mTodos.clear();
142 QPtrList<Event> events;
143 QPtrList<Todo> todos = calendar()->todos();
144 Todo * todo;
145 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
146 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
147 bool itemAdded = false;
148 for ( iii = 0; iii < daysToShow; ++iii ) {
149 QString date;
150 itemAdded = false;
151 events = calendar()->events( mEventDate, true );
152
153 if ( iii == 0 ) { // today !!!
154 todo = todos.first();
155 while(todo) {
156 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
157 if ( ! itemAdded ) {
158 appendDay ( iii, mEventDate );
159 itemAdded = true;
160
161 }
162 appendEvent(todo);
163 }
164 todo = todos.next();
165 }
166 }
167
168
169 if (events.count() > 0) {
170 // mText += "<p></p>";
171 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
172 // mText += "<h2>";
173 //mText += " <img src=\"";
174 //mText += ipath;
175 //mText += "\">";
176 if ( ! itemAdded ) {
177 appendDay ( iii, mEventDate );
178 itemAdded = true;
179
180 }
181 Event *ev = events.first();
182 while(ev) {
183 //qDebug("+++++event append %s", ev->summary().latin1());
184 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
185 appendEvent(ev, false , iii!= 0 );
186 }
187 ev = events.next();
188 }
189
190 //mText += "</table>\n";
191 }
192
193 todo = todos.first();
194 while(todo) {
195 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
196 if ( ! itemAdded ) {
197 appendDay ( iii, mEventDate );
198 itemAdded = true;
199 }
200 appendEvent(todo);
201 }
202 todo = todos.next();
203 }
204 if ( !itemAdded && iii == 0 ) {
205 // appendDay ( iii, mEventDate );
206 //mText += "<table>";
207 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
208 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n";
209 //mText +="</table>";
210 }
211 if ( itemAdded )
212 mText += "</table>\n";
213 mEventDate = mEventDate.addDays( 1 );
214 }
215
216 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
217 if (todos.count() > 0 && topmostPrios > 0 ) {
218 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
219 // mText += "<h2>";
220 //<img src=\"";
221 // mText += ipath;
222 // mText += "\">";
223 // mText += i18n("Overdue To-Do:") + "</h2>\n";
224
225 //mText += "<ul>\n";
226 bool gotone = false;
227 int priority = 1;
228 int priosFound = 0;
229#ifdef DESKTOP_VERSION
230 mText +="<p></p>";
231#endif
232
233 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n";
234 mText += "<ul>\n";
235 while (!gotone && priority<6) {
236 todo = todos.first();
237 while(todo) {
238 if (!todo->isCompleted() && (todo->priority() == priority) ) {
239 if ( appendTodo(todo) )
240 gotone = true;
241 }
242 todo = todos.next();
243 }
244 if ( gotone ) {
245 gotone = false;
246 ++priosFound;
247 if ( priosFound == topmostPrios )
248 break;
249 }
250 priority++;
251 // kdDebug() << "adding the todos..." << endl;
252 }
253 mText += "</ul>\n";
254 }
255
256 int replys = 0;
257 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
258 if (events.count() > 0) {
259 Event *ev = events.first();
260 while(ev) {
261 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
262 if (me!=0) {
263 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
264 if (replys == 0) {
265 mText += "<p></p>";
266 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
267 mText += "<h2>";
268 //<img src=\"";
269 // mText += ipath;
270 // mText += "\">";
271 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
272 mText += "<table>\n";
273 }
274 replys++;
275 appendEvent(ev,true);
276 }
277 }
278 ev = events.next();
279 }
280 }
281 todos = calendar()->todos();
282 if (todos.count() > 0) {
283 Todo *to = todos.first();
284 while(to) {
285 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
286 if (me!=0) {
287 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
288 if (replys == 0) {
289 mText += "<p></p>";
290 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
291 mText += "<h2>";
292 //<img src=\"";
293 // mText += ipath;
294 // mText += "\">";
295 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
296 mText += "<table>\n";
297 }
298 replys++;
299 appendEvent(to);
300 }
301 }
302 kdDebug () << "check for todo-replys..." << endl;
303 to = todos.next();
304 }
305 }
306 if (replys > 0 ) mText += "</table>\n";
307
308
309 mText += "</td></tr>\n</table>\n";
310
311 kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl;
312 mView->setText(mText);
313 mView->setFocus();
314
315 // QPixmap bPix = SmallIcon( "back" );
316 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
317 // QWidget* test = new QWidget();
318 // test->setBackgroundMode(FixedPixmap );
319 // test->setBackgroundPixmap ( bPix );
320 // test->resize( 300, 400 );
321 // test->show();
322 // mView->setBackgroundMode(FixedPixmap );
323 // mView->setBackgroundPixmap ( bPix );
324}
325
326void KOWhatsNextView::appendDay( int i, QDate eventDate )
327{
328 QString date;
329 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
330 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
331 if ( i == 0 ) {
332 mText += "<table>\n";
333 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
334 }
335 else if ( i == 1 )
336 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
337 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
338 //mText += "<h2>" + date + "</h2>\n";
339 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
340 mText += "<table>\n";
341
342
343
344 } else {
345 if ( i == 0 ) {
346 mText += "<table>\n";
347 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
348 }
349
350#ifdef DESKTOP_VERSION
351 else if ( i == 1 ) {
352 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
353 }
354 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
355#else
356 else if ( i == 1 ) {
357 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
358 }
359 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
360
361#endif
362 //mText += "<h2>" + date + "</h2>\n";
363 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
364 mText += "<table>\n";
365 }
366}
367
368
369void KOWhatsNextView::showDates(const QDate &, const QDate &)
370{
371 updateView();
372}
373
374void KOWhatsNextView::showEvents(QPtrList<Event>)
375{
376}
377
378void KOWhatsNextView::changeEventDisplay(Event *, int action)
379{
380 switch(action) {
381 case KOGlobals::EVENTADDED:
382 updateView();
383 break;
384 case KOGlobals::EVENTEDITED:
385 updateView();
386 break;
387 case KOGlobals::EVENTDELETED:
388 updateView();
389 break;
390 default:
391 updateView();
392 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
393 }
394}
395
396void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed )
397{
398 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") )
399 return;
400 QDateTime cdt = QDateTime::currentDateTime();
401 mText += "<tr><td><b>";
402 if (ev->type()=="Event") {
403
404 if (!ev->doesFloat()) {
405 Event *event = static_cast<Event *>(ev);
406 QDateTime st,end;
407 if ( event->recurrence()->doesRecur() ) {
408 QDate recDate= mEventDate;
409 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
410 while ( ! event->recursOn( recDate ) ) {
411 recDate = recDate.addDays( -1 );
412
413 }
414 st = QDateTime ( recDate, event->dtStart().time() );
415 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
416 }
417 else {
418 st = event->dtStart();
419 end = event->dtEnd();
420 }
421
422 if (reply) mText += "on " + event->dtStartDateStr() + ": ";
423 QString dateText;
424 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
425 if ( st.date() < mEventDate )
426 dateText = "++:++-";
427 else
428 dateText = event->dtStartTimeStr() + "-";
429 if ( end.date() > mEventDate )
430 dateText += "++:++";
431 else
432 dateText += event->dtEndTimeStr();
433 if ( notRed )
434 mText += dateText;
435 else {
436 if ( end < cdt )
437 mText += "<font color=\"#F00000\">" + dateText + "</font>";
438 else if ( st < cdt )
439 mText += "<font color=\"#008000\">" + dateText + "</font>";
440 else
441 mText += dateText;
442 }
443
444 } else {
445 mText += i18n("Allday:");
446
447 }
448 } else {
449 mTodos.append( ev );
450 mText += i18n("ToDo:");
451 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
452 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
453 QString dfs = KGlobal::locale()->dateFormatShort();
454 KGlobal::locale()->setIntDateFormat( 3 );
455 KGlobal::locale()->setDateFormatShort("%d.%b");
456 mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "</font>";
457
458 KGlobal::locale()->setDateFormatShort(dfs);
459 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
460 } else {
461 if (!ev->doesFloat() )
462 if( ( (Todo*)ev)->dtDue() < cdt ) {
463 mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
464
465
466 } else
467 mText +=((Todo*)ev)->dtDueTimeStr();
468 mTodos.append( ev );
469 }
470 }
471 mText += "</b></td><td>";
472 bool needClose = false;
473 if ( ev->cancelled() ) {
474 mText += "<font color=\"#F00000\">[c";
475 needClose =true;
476
477 }
478 if ( ev->isAlarmEnabled() ) {
479 if ( !needClose)
480 mText +="[";
481 mText += "a";
482 needClose =true;
483
484 }
485 if ( ev->description().length() > 0 ) {
486 if ( !needClose)
487 mText +="[";
488 mText += "i";
489 needClose =true;
490 }
491 if ( ev->recurrence()->doesRecur() ) {
492 if ( !needClose)
493 mText +="[";
494 mText += "r";
495 needClose =true;
496 }
497 if ( needClose ) {
498 mText += "] ";
499 }
500 if ( ev->cancelled() )
501 mText += "</font>";
502 mText += "<a ";
503 if (ev->type()=="Event") mText += "href=\"event:";
504 if (ev->type()=="Todo") mText += "href=\"todo:";
505 mText += ev->uid() + "\">";
506 if ( ev->summary().length() > 0 )
507 mText += ev->summary();
508 else
509 mText += i18n("-no summary-");
510 mText += "</a>";
511 if ( KOPrefs::instance()->mWNViewShowLocation )
512 if ( !ev->location().isEmpty() )
513 mText += " ("+ev->location() +")";
514 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
515 mText += " ["+ev->relatedTo()->summary() +"]";
516 mText += "</td></tr>\n";
517}
518
519bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
520{
521 if ( mTodos.find( ev ) != mTodos.end() ) return false;
522
523 mTodos.append( ev );
524 if ( !isSub )
525 mText += "<p>";
526 else
527 mText += "<li>";
528 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
529
530
531 mText += ind;
532 bool needClose = false;
533 if ( ev->cancelled() ) {
534 mText += "<font color=\"#F00000\">[c";
535 needClose =true;
536
537 }
538 if ( ev->isAlarmEnabled() ) {
539 if ( !needClose)
540 mText +="[";
541 mText += "a";
542 needClose =true;
543
544 }
545
546 if ( ev->description().length() > 0 ) {
547 if ( !needClose)
548 mText +="[";
549 mText += "i";
550 needClose =true;
551 }
552 // if ( ev->recurrence()->doesRecur() ) {
553 // if ( !needClose)
554 // mText +="(";
555 // mText += "r";
556 // needClose =true;
557 // }
558 if ( needClose )
559 mText += "] ";
560 if ( ev->cancelled() )
561 mText += "</font>";
562 mText += "<a href=\"todo:" + ev->uid() + "\">";
563 mText += ev->summary();
564 mText += "</a>";
565 if ( ((Todo*)ev)->hasDueDate () ) {
566 QString year = "";
567 int ye = ((Todo*)ev)->dtDue().date().year();
568 if ( QDateTime::currentDateTime().date().year() != ye )
569 year = QString::number( ye );
570 QString dfs = KGlobal::locale()->dateFormatShort();
571 KGlobal::locale()->setIntDateFormat( 3 );
572 KGlobal::locale()->setDateFormatShort("%d.%b");
573 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "."+ year +"]</font>";
574
575 KGlobal::locale()->setDateFormatShort(dfs);
576 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
577 }
578 if ( KOPrefs::instance()->mWNViewShowLocation )
579 if ( !ev->location().isEmpty() )
580 mText += " ("+ev->location() +")";
581 if ( !isSub ) {
582 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
583 mText += " ["+ev->relatedTo()->summary() +"]";
584 mText += "</p>\n";
585 }
586 else {
587 ind += "-";
588 mText += "</li>\n";
589 }
590 QPtrList<Incidence> Relations = ev->relations();
591 Incidence *to;
592 for (to=Relations.first();to;to=Relations.next()) {
593 if (!((Todo*)to)->isCompleted())
594 appendTodo( to, ind , true );
595 }
596
597 return true;
598}
599
600/*
601 void KOWhatsNextView::createEventViewer()
602 {
603 if (!mEventViewer) {
604
605 mEventViewer = new KOEventViewerDialog(this);
606 }
607 }
608*/
609void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
610{
611 if ( mEventViewer )
612 delete mEventViewer;
613 mEventViewer = v;
614}
615
616// TODO: Create this function in CalendarView and remove it from here
617void KOWhatsNextView::showIncidence(const QString &uid)
618{
619 if ( !mEventViewer ) {
620 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
621 return;
622 }
623 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
624 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
625 if (uid.startsWith("event:")) {
626#ifdef DESKTOP_VERSION
627 Event *event = calendar()->event(uid.mid(8));
628#else
629 Event *event = calendar()->event(uid.mid(6));
630#endif
631 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
632 if (!event) return;
633 //createEventViewer();
634 mEventViewer->setEvent(event);
635 } else if (uid.startsWith("todo:")) {
636#ifdef DESKTOP_VERSION
637 Todo *todo = calendar()->todo(uid.mid(7));
638#else
639 Todo *todo = calendar()->todo(uid.mid(5));
640#endif
641 if (!todo) return;
642 //createEventViewer();
643 mEventViewer->setTodo(todo);
644 } else {
645 return;
646
647 }
648 mEventViewer->showMe();
649 mEventViewer->raise();
650}
diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h
new file mode 100644
index 0000000..fff769a
--- a/dev/null
+++ b/korganizer/kowhatsnextview.h
@@ -0,0 +1,91 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef KOWHATSNEXTVIEW_H
20#define KOWHATSNEXTVIEW_H
21
22#include <qtextbrowser.h>
23
24#include <korganizer/baseview.h>
25
26class QListView;
27class QLabel;
28
29class KOEventViewerDialog;
30
31class WhatsNextTextBrowser : public QTextBrowser {
32 Q_OBJECT
33 public:
34 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {}
35
36 void setSource(const QString &);
37
38 signals:
39 void showIncidence(const QString &uid);
40};
41
42
43/**
44 This class provides a view of the next events and todos
45*/
46class KOWhatsNextView : public KOrg::BaseView
47{
48 Q_OBJECT
49 public:
50 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0,
51 const char *name = 0);
52 ~KOWhatsNextView();
53
54 virtual int maxDatesHint();
55 virtual int currentDateCount();
56 void setEventViewer(KOEventViewerDialog* v );
57 virtual QPtrList<Incidence> selectedIncidences();
58 DateList selectedDates()
59 {DateList q;
60 return q;}
61 virtual void printPreview(CalPrinter *calPrinter,
62 const QDate &, const QDate &);
63
64 public slots:
65 virtual void updateView();
66 virtual void showDates(const QDate &start, const QDate &end);
67 virtual void showEvents(QPtrList<Event> eventList);
68 void updateConfig();
69 void changeEventDisplay(Event *, int);
70
71 protected:
72 void appendEvent(Incidence *, bool reply=false, bool notRed = true);
73 bool appendTodo(Incidence *, QString ind = "", bool isSub = false );
74 void appendDay( int i, QDate date );
75 QDate mEventDate;
76
77 private slots:
78 void showIncidence(const QString &);
79
80 private:
81 //void createEventViewer();
82
83 QTextBrowser *mView;
84 QString mText;
85 // QLabel *mDateLabel;
86 KOEventViewerDialog *mEventViewer;
87
88 QValueList<Incidence *> mTodos;
89};
90
91#endif
diff --git a/korganizer/kowhatsnextview.moc b/korganizer/kowhatsnextview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kowhatsnextview.moc
diff --git a/korganizer/kprefsdialog.moc b/korganizer/kprefsdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/kprefsdialog.moc
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
new file mode 100644
index 0000000..f9720f6
--- a/dev/null
+++ b/korganizer/ktimeedit.cpp
@@ -0,0 +1,528 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown, Ian Dawes
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qkeycode.h>
25#include <qcombobox.h>
26#include <qdatetime.h>
27#include <qlineedit.h>
28#include <qapplication.h>
29
30#include <kmessagebox.h>
31#include <kglobal.h>
32#include <kdebug.h>
33#include <klocale.h>
34
35#include "ktimeedit.h"
36#include "koprefs.h"
37#include <qvalidator.h>
38#include "ktimeedit.moc"
39
40// Validator for a time value with only hours and minutes (no seconds)
41// Mostly locale aware. Author: David Faure <faure@kde.org>
42class KOTimeValidator : public QValidator
43{
44public:
45 KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {}
46
47 virtual State validate(QString& str, int& /*cursorPos*/) const
48 {
49 return Acceptable;
50 bool ok = false;
51 // TODO use KLocale::WithoutSeconds in HEAD
52 /*QTime time =*/ KGlobal::locale()->readTime(str, &ok);
53 if ( ok )
54 return Acceptable;
55 // readTime doesn't help knowing when the string is "Intermediate".
56 int length = str.length();
57 if ( !str ) // empty string?
58 return Invalid; // there should always be a ':' in it, right?
59 // HACK. Not fully locale aware etc. (esp. the separator is '.' in sv_SE...)
60 QChar sep = ':';
61 // I want to allow "HH:", ":MM" and ":" to make editing easier
62 if ( str[0] == sep )
63 {
64 if ( length == 1 ) // just ":"
65 return Intermediate;
66 QString minutes = str.mid(1);
67 int m = minutes.toInt(&ok);
68 if ( ok && m >= 0 && m < 60 )
69 return Intermediate;
70 } else if ( str.at(str.length()-1) == sep )
71 {
72 QString hours = str.left(length-1);
73 int h = hours.toInt(&ok);
74 if ( ok && h >= 0 && h < 24 )
75 return Intermediate;
76 }
77 return Invalid;
78 }
79};
80
81// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox.
82// Difficult to get all in one...
83// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help.
84KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
85 : QComboBox(TRUE, parent, name)
86{
87 setInsertionPolicy(NoInsertion);
88 setValidator( new KOTimeValidator( this ) );
89 mFlagKeyPressed = false;
90
91 if ( QApplication::desktop()->width() < 650 )
92 setSizeLimit ( 6 );
93 mTime = qt;
94
95// mNoTimeString = i18n("No Time");
96// insertItem( mNoTimeString );
97
98 // Fill combo box with selection of times in localized format.
99 QTime timeEntry(0,0,0);
100 do {
101 insertItem(KGlobal::locale()->formatTime(timeEntry));
102 timeEntry = timeEntry.addSecs(60*15);
103 } while (!timeEntry.isNull());
104 // Add end of day.
105 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) );
106
107 updateText();
108 setFocusPolicy(QWidget::StrongFocus);
109
110 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int)));
111 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
112 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText()));
113 QFontMetrics fm ( font() );
114 QString timeString = "24:00";
115 if ( KOPrefs::instance()->mPreferredTime == 1 )
116 timeString = "02:00pm";
117 int addSpace = 32;
118 if ( QApplication::desktop()->width() > 320 )
119 timeString += ":00";
120 setFixedWidth(fm.width( timeString ) + 32 );
121
122 // Highlight Background and Textcolor change from default
123 QPalette palette = QWidget::palette();
124 unsigned char red, green, blue;
125 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10;
126 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10;
127 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10;
128 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) );
129 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) );
130 setPalette( palette );
131}
132
133KOTimeEdit::~KOTimeEdit()
134{
135}
136
137bool KOTimeEdit::hasTime() const
138{
139 // Can't happen
140 if ( currentText().isEmpty() ) return false;
141 //if ( currentText() == mNoTimeString ) return false;
142
143 return true; // always
144}
145
146QTime KOTimeEdit::getTime() const
147{
148 //kdDebug(5850) << "KOTimeEdit::getTime(), currentText() = " << currentText() << endl;
149 // TODO use KLocale::WithoutSeconds in HEAD
150 QTime time = KGlobal::locale()->readTime(currentText());
151 // kdDebug(5850) << "KOTimeEdit::getTime(): " << time.toString() << endl;
152 return time;
153}
154/*
155QSizePolicy KOTimeEdit::sizePolicy() const
156{
157 // Set size policy to Fixed, because edit cannot contain more text than the
158 // string representing the time. It doesn't make sense to provide more space.
159 QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
160
161 return sizePolicy;
162}
163*/
164void KOTimeEdit::setTime(QTime newTime)
165{
166 if ( mTime != newTime )
167 {
168 kdDebug(5850) << "KOTimeEdit::setTime(): " << newTime.toString() << endl;
169
170 mTime = newTime;
171 updateText();
172 }
173
174}
175
176void KOTimeEdit::activ(int i)
177{
178 // The last entry, 23:59, is a special case
179 if( i == count() - 1 )
180 mTime = QTime( 23, 59, 0 );
181 else
182 mTime = QTime(0,0,0).addSecs(i*15*60);
183 emit timeChanged(mTime);
184}
185
186void KOTimeEdit::hilit(int )
187{
188 // we don't currently need to do anything here.
189}
190
191void KOTimeEdit::addTime(QTime qt, bool update)
192{
193 // Calculate the new time.
194 //qDebug("add h %d min %d ", qt.hour(),qt.minute() );
195 mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600);
196 // if ( update )
197 updateText();
198 emit timeChanged(mTime);
199}
200
201void KOTimeEdit::subTime(QTime qt, bool update)
202{
203 int h, m;
204 //qDebug("sub h %d min %d ", qt.hour(),qt.minute() );
205
206 mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600));
207 // store the newly calculated time.
208 // mTime.setHMS(h, m, 0);
209 //if ( update )
210 updateText();
211 emit timeChanged(mTime);
212}
213
214// void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * )
215// {
216// qDebug("mouseReleaseEvent ( QMouseEvent * ) ");
217// }
218
219// void KOTimeEdit::focusInEvent ( QFocusEvent * )
220// {
221// qDebug("focusInEvent ( QFocusEvent * ) ");
222// }
223
224void KOTimeEdit::keyReleaseEvent(QKeyEvent *e)
225{
226 if ( !e->isAutoRepeat() ) {
227 mFlagKeyPressed = false;
228 }
229
230}
231void KOTimeEdit::setSelect( int from, int to )
232{
233 if ( KOPrefs::instance()->mHightlightDateTimeEdit)
234 lineEdit()->setSelection( from , to );
235}
236
237
238void KOTimeEdit::keyPressEvent(QKeyEvent *e)
239{
240
241 qApp->processEvents();
242 bool hour12Format = ( KOPrefs::instance()->mPreferredTime == 1 );
243 int maxpos = hour12Format?7:5;
244 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
245 e->ignore();
246 // qDebug(" ignore %d",e->isAutoRepeat() );
247 return;
248 }
249 if (! e->isAutoRepeat() ) {
250 mFlagKeyPressed = true;
251 }
252 // Tap -> Focus Next Widget
253 if ( e->key() == Key_Tab ) {
254 QComboBox::keyPressEvent(e);
255 return;
256 }
257
258 // save Text from QLineEdit and CursorPosition
259 QString text = lineEdit()->text();
260 int cpos = lineEdit()->cursorPosition();
261 // qDebug("cpos %d ", cpos);
262
263 // Switch for arrows, backspace and escape
264 switch(e->key()) {
265 case Key_Escape:
266 lineEdit()->deselect();
267 case Key_Tab:
268 QComboBox::keyPressEvent(e);
269 break;
270 case Key_Up:
271 if ( e->state () == Qt::ControlButton ) {
272 addTime(QTime(0,15,0), false );
273 lineEdit()->setCursorPosition(3);
274 setSelect( 3 , 2 );
275 }
276 else
277 if ( e->state () == Qt::ShiftButton ) {
278 addTime(QTime(1,0,0), false );
279 lineEdit()->setCursorPosition(0);
280 setSelect( 0 , 2 );
281 }
282 else
283 // switch time up, cursor location depend
284 switch (cpos) {
285 case 7:
286 case 6:
287 case 5:
288 if(!hour12Format) {
289 lineEdit()->setCursorPosition(cpos = 4);
290 } else {
291 addTime(QTime(12,0,0), false );
292 setSelect ( 5 , 2 );
293 break;
294 }
295 case 4:
296 addTime(QTime(0,1,0), false );
297 setSelect ( cpos , 1 );
298 break;
299 case 3:
300 addTime(QTime(0,10,0), false );
301 setSelect ( cpos , 1 );
302 break;
303 case 2:
304 lineEdit()->setCursorPosition(--cpos);
305 case 1:
306 case 0:
307 addTime(QTime(1,0,0), false );
308 setSelect ( 0, 2 );
309 break;
310 }
311 break;
312 case Key_Down:
313 if ( e->state () == Qt::ControlButton ) {
314 subTime(QTime(0,15,0), false );
315 lineEdit()->setCursorPosition(3);
316 setSelect( 3 , 2 );
317 }
318 else
319 if ( e->state () == Qt::ShiftButton ) {
320 subTime(QTime(1,0,0), false );
321 lineEdit()->setCursorPosition(0);
322 setSelect( 0 , 2 );
323 }
324 else
325 // switch time down, cursor location depend
326 switch (cpos) {
327 case 7:
328 case 6:
329 case 5:
330 if(!hour12Format) {
331 lineEdit()->setCursorPosition(cpos = 4);
332 } else {
333 subTime(QTime(12,0,0), false );
334 setSelect ( 5 , 2 );
335 break;
336 }
337 case 4:
338 subTime(QTime(0,1,0), false );
339 setSelect ( cpos , 1 );
340 break;
341 case 3:
342 subTime(QTime(0,10,0), false );
343 setSelect ( cpos , 1 );
344 break;
345 case 2:
346 lineEdit()->setCursorPosition(--cpos);
347 case 1:
348 case 0:
349 subTime(QTime(1,0,0), false );
350 setSelect ( 0 , 2 );
351 break;
352 }
353 break;
354 // set cursor to correct place
355 case Key_Left:
356 if ( cpos == 3 )
357 --cpos;
358 if ( cpos > 0) {
359 lineEdit()->setCursorPosition(--cpos);
360 setSelect ( cpos , 1 );
361 }
362 else
363 setSelect ( 0 , 1 );
364 break;
365 // set cursor to correct place
366 case Key_Right:
367 if ( cpos == 1 )
368 ++cpos;
369 if ( cpos < maxpos ) {
370 lineEdit()->setCursorPosition(++cpos);
371 setSelect ( cpos , 1 );
372 }
373 break;
374 // rest
375 case Key_Prior:
376 subTime(QTime(1,0,0));
377 break;
378 case Key_Next:
379 addTime(QTime(1,0,0));
380 break;
381 case Key_Backspace:
382 if ( cpos > 0) {
383 if ( cpos == 3 )
384 --cpos;
385 if ( cpos > 5)
386 cpos = 5;
387 text.at( cpos-1 ) = '0';
388 lineEdit()->setText( text );
389 lineEdit()->setCursorPosition(--cpos);
390 setSelect ( cpos , 1 );
391 changedText();
392 }
393 break;
394 } // switch arrows
395
396 // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos
397 if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) {
398 lineEdit()->deselect();
399 cpos = 0;
400 lineEdit()->setCursorPosition(cpos);
401 setSelect(cpos , 1);
402 }
403
404 if ( cpos == 2 ) {
405 lineEdit()->setCursorPosition(++cpos);
406 }
407
408 // num keys when cursorPos preEnd
409 if ( cpos < 5 ) {
410 // switch another keys
411 switch(e->key()) {
412 case Key_Delete:
413 text.at( cpos ) = '0';
414 lineEdit()->setText( text );
415 lineEdit()->setCursorPosition(cpos);
416 setSelect ( cpos , 1 );
417 changedText();
418 break;
419 case Key_9:
420 case Key_8:
421 case Key_7:
422 case Key_6:
423 if ( !(cpos == 1 || cpos == 4) )
424 return;
425 if ( cpos == 1 && text.at( 0 ) > '1')
426 text.at( 0 ) = '1';
427 case Key_5:
428 case Key_4:
429 case Key_3:
430 if ( cpos < 1 )
431 return;
432 if ( hour12Format && cpos == 1 )
433 return;
434 case Key_2:
435 if ( hour12Format && cpos == 0 )
436 return;
437 if ( cpos == 0 && text.at( 1 ) > '3')
438 text.at( 1 ) = '3';
439 case Key_1:
440 case Key_0:
441 if ( hour12Format ) {
442 if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' )
443 return;
444 if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' )
445 text.at( 1 ) = '1';
446 }
447 text.at( cpos ) = QChar ( e->key() );
448 lineEdit()->setText( text );
449 if ( cpos == 1 )
450 ++cpos;
451 if ( cpos < 5)
452 lineEdit()->setCursorPosition(++cpos);
453 setSelect( cpos , 1 );
454 changedText();
455 break;
456 case Key_Home:
457 lineEdit()->setCursorPosition(0);
458 setSelect( cpos , 1 );
459 break;
460 case Key_End:
461 lineEdit()->setCursorPosition(5);
462 lineEdit()->deselect();
463 break;
464 default:
465// QComboBox::keyPressEvent(e);
466 break;
467 } // switch num keys
468 } else if ( cpos == 5 ) {// if cpos < 5
469 if ( hour12Format ) {
470 if ( e->key() == Key_A ) {
471 text.at( 5 ) = 'a';
472 lineEdit()->setText( text );
473 lineEdit()->setCursorPosition(5);
474
475 } else if ( e->key() == Key_P ) {
476 text.at( 5 ) = 'p';
477 lineEdit()->setText( text );
478 lineEdit()->setCursorPosition(5);
479
480 }
481 }
482 }
483
484
485}
486
487void KOTimeEdit::updateText()
488{
489// kdDebug(5850) << "KOTimeEdit::updateText() " << endl
490 QString s = KGlobal::locale()->formatTime(mTime);
491 // Set the text but without emitting signals, nor losing the cursor position
492 QLineEdit *line = lineEdit();
493 line->blockSignals(true);
494 int pos = line->cursorPosition();
495 // qDebug(" settext *%s* ", s.latin1());
496 line->setText(s);
497 // line->setCursorPosition(pos);
498// line->blockSignals(false);
499
500// kdDebug(5850) << "KOTimeEdit::updateText(): " << s << endl;
501
502 if (!mTime.minute() % 15) {
503 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15));
504 }
505 line->setCursorPosition(pos);
506 line->blockSignals(false);
507
508}
509
510bool KOTimeEdit::inputIsValid() const
511{
512 int cursorPos = lineEdit()->cursorPosition();
513 QString str = currentText();
514 return validator()->validate( str, cursorPos ) == QValidator::Acceptable;
515}
516
517void KOTimeEdit::changedText()
518{
519 //kdDebug(5850) << "KOTimeEdit::changedText()" << endl;
520 if ( inputIsValid() )
521 {
522 int pos = lineEdit()->cursorPosition();
523 mTime = getTime();
524 // updateText();
525 emit timeChanged(mTime);
526 lineEdit()->setCursorPosition(pos);
527 }
528}
diff --git a/korganizer/ktimeedit.h b/korganizer/ktimeedit.h
new file mode 100644
index 0000000..7923070
--- a/dev/null
+++ b/korganizer/ktimeedit.h
@@ -0,0 +1,97 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown, Ian Dawes
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef _KTIMEEDIT_H
24#define _KTIMEEDIT_H
25
26#include <qevent.h>
27#include <qkeycode.h>
28#include <qstring.h>
29#include <qdatetime.h>
30#include <qcombobox.h>
31
32#include <kapplication.h>
33
34/**
35 This is a class that provides an easy, user friendly way to edit times.
36 up/down/ increase or decrease time, respectively.
37
38 @short Provides a way to edit times in a user-friendly manner.
39 @author Preston Brown, Ian Dawes
40*/
41class KOTimeEdit : public QComboBox
42{
43 Q_OBJECT
44 public:
45 /** constructs a new time edit. */
46 KOTimeEdit(QWidget *parent=0, QTime qt=QTime(12,0), const char *name=0);
47
48 virtual ~KOTimeEdit();
49
50 /**
51 Returns, if a time is selected. Can not return false anymore....
52 */
53 bool hasTime() const;
54
55 /** returns the time that is currently set in the timeLineEdit. */
56 QTime getTime() const;
57
58 /** returns the prefered size policy of the KOTimeEdit */
59 //QSizePolicy sizePolicy() const;
60
61 /** return true if input is a valid time and false if not */
62 bool inputIsValid() const;
63
64 signals:
65 /**
66 Emitted every time the time displayed changes. "newt" is the new
67 time.
68 */
69 void timeChanged(QTime newt);
70
71 public slots:
72 /** used to set the time which is displayed to a specific value. */
73 void setTime(QTime qt);
74
75 protected slots:
76 void activ(int);
77 void hilit(int);
78 void changedText();
79
80 protected:
81 void keyPressEvent(QKeyEvent *qke);
82 void keyReleaseEvent(QKeyEvent *qke);
83 void setSelect ( int, int );
84 bool mFlagKeyPressed;
85 void addTime(QTime qt, bool update = true );
86 void subTime(QTime qt, bool update = true );
87 // Update the lineedit text from mTime
88 void updateText();
89 // void mouseReleaseEvent ( QMouseEvent * ) ;
90 //void focusInEvent ( QFocusEvent * ) ;
91
92private:
93 QTime mTime; // the widget's displayed time.
94 //QString mNoTimeString;
95};
96
97#endif
diff --git a/korganizer/ktimeedit.moc b/korganizer/ktimeedit.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/ktimeedit.moc
diff --git a/korganizer/lineview.cpp b/korganizer/lineview.cpp
new file mode 100644
index 0000000..f1ff29f
--- a/dev/null
+++ b/korganizer/lineview.cpp
@@ -0,0 +1,94 @@
1#include <qpainter.h>
2
3#include <kdebug.h>
4
5#include "koprefs.h"
6
7#include "lineview.h"
8#include "lineview.moc"
9
10LineView::LineView( QWidget *parent, const char *name ) :
11 QScrollView( parent, name )
12{
13 mPixelWidth = 1000;
14
15 mLines.setAutoDelete( true );
16
17 resizeContents( mPixelWidth, contentsHeight() );
18
19 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
20}
21
22LineView::~LineView()
23{
24}
25
26int LineView::pixelWidth()
27{
28 return mPixelWidth;
29}
30
31void LineView::addLine( int start, int end )
32{
33 int count = mLines.count();
34
35 if( start < 0 ) start = 0;
36 if( end > mPixelWidth) end = mPixelWidth;
37
38 kdDebug() << "LineView::addLine() col: " << count << " start: " << start
39 << " end: " << end << endl;
40
41 mLines.append( new Line( count, start, end ) );
42}
43
44void LineView::clear()
45{
46 mLines.clear();
47 update();
48}
49
50void LineView::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
51{
52// kdDebug() << "LineView::drawContents()" << endl;
53
54 int mGridSpacingX = 10;
55 int mGridSpacingY = 20;
56
57#if 0
58 // Draw vertical lines of grid
59 // kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl;
60 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
61 while (x < cx + cw) {
62 p->drawLine(x,cy,x,cy+ch);
63 x+=mGridSpacingX;
64 }
65#endif
66
67 // Draw horizontal lines of grid
68 int y = ((int)(cy/mGridSpacingY))*mGridSpacingY + 10;
69 while (y < cy + ch) {
70// kdDebug() << " y: " << y << endl;
71 p->drawLine(cx,y,cx+cw,y);
72 y+=mGridSpacingY;
73 }
74
75 Line *line;
76 for( line = mLines.first(); line; line = mLines.next() ) {
77 int ctop = line->column * 20 + 10 - 5;
78 int cbottom = line->column * 20 + 10 + 5;
79 int s = line->start;
80 int e = line->end;
81// kdDebug() << " LineView::drawContents(): ctop: " << ctop << " cbottom: "
82// << cbottom << " s: " << s << " e: " << e << endl;
83 if ( ctop <= (cy+ch) && cbottom >= cy &&
84 s <= (cx+cw) && e >= cx ) {
85 if ( s < cx ) s = cx;
86 if ( e > (cx+cw) ) e = cx+cw;
87 if ( ctop < cy ) ctop = cy;
88 if ( cbottom > (cy+ch) ) cbottom = cy+ch;
89// kdDebug() << " drawContents(): ctop: " << ctop << " cbottom: "
90// << cbottom << " s: " << s << " e: " << e << endl;
91 p->fillRect( s, ctop, e - s + 1, cbottom - ctop + 1, QBrush("red") );
92 }
93 }
94}
diff --git a/korganizer/lineview.h b/korganizer/lineview.h
new file mode 100644
index 0000000..aa34dbc
--- a/dev/null
+++ b/korganizer/lineview.h
@@ -0,0 +1,36 @@
1#ifndef LINEVIEW_H
2#define LINEVIEW_H
3
4#include <qscrollview.h>
5#include <qptrlist.h>
6
7class LineView : public QScrollView
8{
9 Q_OBJECT
10 public:
11 LineView( QWidget *parent = 0, const char *name = 0 );
12 virtual ~LineView();
13
14 int pixelWidth();
15
16 void addLine( int start, int end );
17
18 void clear();
19
20 protected:
21 void drawContents(QPainter* p, int cx, int cy, int cw, int ch);
22
23 private:
24 struct Line {
25 Line( int c, int s, int e ) : column( c ), start( s ), end( e ) {}
26 int column;
27 int start;
28 int end;
29 };
30
31 QPtrList<Line> mLines;
32 int mPixelWidth;
33};
34
35#endif
36
diff --git a/korganizer/lineview.moc b/korganizer/lineview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/lineview.moc
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
new file mode 100644
index 0000000..6843595
--- a/dev/null
+++ b/korganizer/main.cpp
@@ -0,0 +1,107 @@
1
2
3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h>
5#include <qpe/global.h>
6#include <stdlib.h>
7#else
8#include <qapplication.h>
9#include <qstring.h>
10#include <qwindowsstyle.h>
11#include <qplatinumstyle.h>
12#include <qsgistyle.h>
13#endif
14
15#include <qdir.h>
16#include <kstandarddirs.h>
17#include <kglobal.h>
18#include <stdio.h>
19#include "mainwindow.h"
20
21int main( int argc, char **argv )
22{
23#ifndef DESKTOP_VERSION
24 QPEApplication a( argc, argv );
25 a.setKeepRunning ();
26#else
27 QApplication a( argc, argv );
28 QApplication::setStyle( new QPlatinumStyle ());
29#endif
30 bool exitHelp = false;
31 if ( argc > 1 ) {
32 QString command = argv[1];
33 if ( command == "-help" ){
34 printf("KO/Pi command line commands:\n");
35 printf(" no command: Start KO/Pi in usual way\n");
36 printf(" -help: This output\n");
37 printf("Next Option: Open or Show after start:\n");
38 printf(" -newTodo: New Todo dialog\n");
39 printf(" -newEvent: New Event dialog\n");
40 printf(" -showList: List view\n");
41 printf(" -showDay: Day view\n");
42 printf(" -showWWeek: Work Week view\n");
43 printf(" -showWeek: Week view\n");
44 printf(" -showTodo: Todo view\n");
45 printf(" -showJournal: Journal view\n");
46 printf(" -showKO: Next Days view\n");
47 printf(" -showWNext: What's Next view\n");
48 printf(" -showNextXView: Next X View\n");
49 printf(" -new[Y] and -show[X] may be used togehther\n");
50 printf(" KO/Pi is exiting now. Bye!\n");
51 exitHelp = true;
52 }
53 }
54 if ( ! exitHelp ) {
55 KGlobal::setAppName( "korganizer" );
56
57
58 QString fileName ;
59#ifndef DESKTOP_VERSION
60 KStandardDirs::setAppDir( Global::applicationFileName( "korganizer", "" ) );
61 fileName = getenv("QPEDIR");
62 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
63#else
64
65#ifndef _WIN32_
66 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
67#else
68 fileName = qApp->applicationDirPath () + "\\kdepim\\korganizer\\";
69#endif
70
71 KGlobal::iconLoader()->setIconPath(fileName);
72
73 QString appdir = QDir::homeDirPath();
74 //appdir = "C:\\";
75 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
76 appdir += "korganizer";
77 else
78 appdir += "/korganizer";
79 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
80 // qDebug(" %s ",KStandardDirs::appDir().latin1() );
81#endif
82 QDir app_dir;
83 if ( !app_dir.exists(KStandardDirs::appDir()) )
84 app_dir.mkdir (KStandardDirs::appDir());
85 MainWindow m;
86#ifndef DESKTOP_VERSION
87 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
88 a.showMainWidget(&m );
89#else
90 a.setMainWidget(&m );
91 m.show();
92 //m.resize( 800, 600 );
93 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
94#endif
95 if ( argc > 1 ) {
96 QCString command = argv[1];
97 if ( argc > 2 )
98 command += argv[2];
99 qApp->processEvents();
100 m.recieve(command, QByteArray() );
101
102 }
103 a.exec();
104
105 }
106 qDebug("KO: Bye! ");
107}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
new file mode 100644
index 0000000..40f2cf4
--- a/dev/null
+++ b/korganizer/mainwindow.cpp
@@ -0,0 +1,1974 @@
1#include <stdlib.h>
2
3#include <qaction.h>
4#include <qpopupmenu.h>
5#include <qpainter.h>
6#include <qwhatsthis.h>
7#include <qmessagebox.h>
8#include <qlineedit.h>
9#include <qfile.h>
10#include <qdir.h>
11#include <qapp.h>
12#include <qfileinfo.h>
13#include <qlabel.h>
14#include <qwmatrix.h>
15#include <qtextbrowser.h>
16#include <qtextstream.h>
17#ifndef DESKTOP_VERSION
18#include <qpe/global.h>
19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h>
23#include <qtopia/alarmserver.h>
24#include <qtopia/qcopenvelope_qws.h>
25#else
26#include <qmenubar.h>
27#include <qtoolbar.h>
28#include <qapplication.h>
29//#include <resource.h>
30
31#endif
32#include <libkcal/calendarlocal.h>
33#include <libkcal/todo.h>
34#include <libkdepim/ksyncprofile.h>
35#include <libkdepim/kincidenceformatter.h>
36
37#include "calendarview.h"
38#include "koviewmanager.h"
39#include "datenavigator.h"
40#include "koagendaview.h"
41#include "koagenda.h"
42#include "kodialogmanager.h"
43#include "kdialogbase.h"
44#include "kstandarddirs.h"
45#include "koprefs.h"
46#include "kfiledialog.h"
47#include "koglobals.h"
48#include "kglobal.h"
49#include "klocale.h"
50#include "kconfig.h"
51#include "simplealarmclient.h"
52
53using namespace KCal;
54#ifndef _WIN32_
55#include <unistd.h>
56#endif
57#include "mainwindow.h"
58
59int globalFlagBlockStartup;
60MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
61 QMainWindow( parent, name )
62{
63
64#ifdef DESKTOP_VERSION
65 setFont( QFont("Arial"), 14 );
66#endif
67
68 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
69 QString confFile = locateLocal("config","korganizerrc");
70 QFileInfo finf ( confFile );
71 bool showWarning = !finf.exists();
72 setIcon(SmallIcon( "ko24" ) );
73 mBlockAtStartup = true;
74 mFlagKeyPressed = false;
75 setCaption("KOrganizer/Pi");
76 KOPrefs *p = KOPrefs::instance();
77 // if ( QApplication::desktop()->height() > 480 ) {
78// if ( p->mHourSize == 4 )
79// p->mHourSize = 6;
80// }
81 if ( p->mHourSize > 18 )
82 p->mHourSize = 18;
83 QMainWindow::ToolBarDock tbd;
84 if ( p->mToolBarHor ) {
85 if ( p->mToolBarUp )
86 tbd = Bottom;
87 else
88 tbd = Top;
89 }
90 else {
91 if ( p->mToolBarUp )
92 tbd = Right;
93 else
94 tbd = Left;
95 }
96 if ( KOPrefs::instance()->mUseAppColors )
97 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
98 globalFlagBlockStartup = 1;
99 iconToolBar = new QPEToolBar( this );
100 addToolBar (iconToolBar , tbd );
101 mBlockSaveFlag = false;
102 mCalendarModifiedFlag = false;
103
104 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
105 splash->setAlignment ( AlignCenter );
106 setCentralWidget( splash );
107#ifndef DESKTOP_VERSION
108 showMaximized();
109#endif
110 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
111 setDefaultPreferences();
112 mCalendar = new CalendarLocal();
113 mView = new CalendarView( mCalendar, this,"mCalendar " );
114 mView->hide();
115 //mView->resize(splash->size() );
116 initActions();
117#ifndef DESKTOP_VERSION
118 iconToolBar->show();
119 qApp->processEvents();
120#endif
121 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
122 int vh = height() ;
123 int vw = width();
124 //qDebug("Toolbar hei %d ",iconToolBar->height() );
125 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
126 vh -= iconToolBar->height();
127 } else {
128 vw -= iconToolBar->height();
129 }
130 //mView->setMaximumSize( splash->size() );
131 //mView->resize( splash->size() );
132 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
133 mView->readSettings();
134 bool oldOpened = false;
135 bool newFile = false;
136 if( !QFile::exists( defaultFileName() ) ) {
137 QFileInfo finfo ( defaultFileName() );
138 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
139 qDebug("oldfile %s ", oldFile.latin1());
140 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";
141 finfo.setFile( oldFile );
142 if (finfo.exists() ) {
143 KMessageBox::information( this, message);
144 mView->openCalendar( oldFile );
145 qApp->processEvents();
146 } else {
147 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
148 finfo.setFile( oldFile );
149 if (finfo.exists() ) {
150 KMessageBox::information( this, message);
151 mView->openCalendar( oldFile );
152 qApp->processEvents();
153 }
154 }
155 mView->saveCalendar( defaultFileName() );
156 newFile = true;
157 }
158
159 QTime neededSaveTime = QDateTime::currentDateTime().time();
160 if ( ! oldOpened )
161 mView->openCalendar( defaultFileName() );
162 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
163 qDebug("KO: Calendar loading time: %d ms",msNeeded );
164
165 if ( KOPrefs::instance()->mLanguageChanged ) {
166 KOPrefs::instance()->setCategoryDefaults();
167 int count = mView->addCategories();
168 KOPrefs::instance()->mLanguageChanged = false;
169 }
170 processIncidenceSelection( 0 );
171 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
172 SLOT( processIncidenceSelection( Incidence * ) ) );
173 connect( mView, SIGNAL( modifiedChanged( bool ) ),
174 SLOT( slotModifiedChanged( bool ) ) );
175
176
177 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
178 mView->setModified( false );
179 mBlockAtStartup = false;
180 mView->setModified( false );
181 setCentralWidget( mView );
182 globalFlagBlockStartup = 0;
183 mView->show();
184 delete splash;
185 if ( newFile )
186 mView->updateConfig();
187 // qApp->processEvents();
188 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
189 fillSyncMenu();
190 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
191 if ( showWarning ) {
192 KMessageBox::information( this,
193 "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");
194 qApp->processEvents();
195 mView->dialogManager()->showSyncOptions();
196 }
197}
198MainWindow::~MainWindow()
199{
200 //qDebug("MainWindow::~MainWindow() ");
201 //save toolbar location
202
203 delete mCalendar;
204 delete KOPrefs::instance();
205 delete KIncidenceFormatter::instance();
206
207
208}
209void MainWindow::closeEvent( QCloseEvent* ce )
210{
211
212
213
214 if ( ! KOPrefs::instance()->mAskForQuit ) {
215 saveOnClose();
216 ce->accept();
217 return;
218
219 }
220
221 switch( QMessageBox::information( this, "KO/Pi",
222 i18n("Do you really want\nto close KO/Pi?"),
223 i18n("Close"), i18n("No"),
224 0, 0 ) ) {
225 case 0:
226 saveOnClose();
227 ce->accept();
228 break;
229 case 1:
230 ce->ignore();
231 break;
232 case 2:
233
234 default:
235 break;
236 }
237
238
239}
240
241void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
242{
243 QDataStream stream( data, IO_ReadOnly );
244 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
245 //QString datamess;
246 //qDebug("message ");
247 qDebug("KO: QCOP message received: %s ", cmsg.data() );
248 if ( cmsg == "-writeFile" ) {
249 // I made from the "-writeFile" an "-writeAlarm"
250 mView->viewManager()->showWhatsNextView();
251 mCalendar->checkAlarmForIncidence( 0, true);
252 showMaximized();
253 raise();
254 return;
255
256 }
257 if ( cmsg == "-writeFileSilent" ) {
258 // I made from the "-writeFile" an "-writeAlarm"
259 // mView->viewManager()->showWhatsNextView();
260 mCalendar->checkAlarmForIncidence( 0, true);
261 //showMaximized();
262 //raise();
263 hide();
264 return;
265 }
266 if ( cmsg == "-newCountdown" ) {
267 qDebug("newCountdown ");
268
269 }
270 QString msg ;
271 QString allmsg = cmsg;
272 while ( allmsg.length() > 0 ) {
273 int nextC = allmsg.find( "-", 1 );
274 if ( nextC == -1 ) {
275 msg = allmsg;
276 allmsg = "";
277 } else{
278 msg = allmsg.left( nextC );
279 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
280 }
281 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
282 if ( msg == "-newEvent" ) {
283 mView->newEvent();
284 }
285 if ( msg == "-newTodo" ) {
286 mView->newTodo();
287
288 }
289 if ( msg == "-showWN" ) {
290 mView->viewManager()->showWhatsNextView();
291 }
292 if ( msg == "-showTodo" ) {
293 mView->viewManager()->showTodoView();
294 }
295 if ( msg == "-showList" ) {
296 mView->viewManager()->showListView();
297 }
298 else if ( msg == "-showDay" ) {
299 mView->viewManager()->showDayView();
300 }
301 else if ( msg == "-showWWeek" ) {
302 mView->viewManager()->showWorkWeekView();
303 }
304 else if ( msg == "-ringSync" ) {
305 multiSync( false );
306 }
307 else if ( msg == "-showWeek" ) {
308 mView->viewManager()->showWeekView();
309 }
310 else if ( msg == "-showTodo" ) {
311 mView->viewManager()->showTodoView();
312 }
313 else if ( msg == "-showJournal" ) {
314 mView->dateNavigator()->selectDates( 1 );
315 mView->dateNavigator()->selectToday();
316 mView->viewManager()->showJournalView();
317 }
318 else if ( msg == "-showKO" ) {
319 mView->viewManager()->showNextXView();
320 }
321 else if ( msg == "-showWNext" || msg == "nextView()" ) {
322 mView->viewManager()->showWhatsNextView();
323 }
324 else if ( msg == "-showNextXView" ) {
325 mView->viewManager()->showNextXView();
326 }
327
328
329 }
330
331 showMaximized();
332 raise();
333}
334
335QPixmap MainWindow::loadPixmap( QString name )
336{
337 return SmallIcon( name );
338
339}
340void MainWindow::initActions()
341{
342 //KOPrefs::instance()->mShowFullMenu
343 iconToolBar->clear();
344 KOPrefs *p = KOPrefs::instance();
345 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
346
347 QPopupMenu *viewMenu = new QPopupMenu( this );
348 QPopupMenu *actionMenu = new QPopupMenu( this );
349 QPopupMenu *importMenu = new QPopupMenu( this );
350
351 syncMenu = new QPopupMenu( this );
352 configureAgendaMenu = new QPopupMenu( this );
353 configureToolBarMenu = new QPopupMenu( this );
354 QPopupMenu *helpMenu = new QPopupMenu( this );
355 if ( KOPrefs::instance()->mShowFullMenu ) {
356 QMenuBar *menuBar1;
357 menuBar1 = menuBar();
358 menuBar1->insertItem( i18n("File"), importMenu );
359 menuBar1->insertItem( i18n("View"), viewMenu );
360 menuBar1->insertItem( i18n("Actions"), actionMenu );
361 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
362 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
363 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
364 menuBar1->insertItem( i18n("Help"), helpMenu );
365 } else {
366 QPEMenuBar *menuBar1;
367 menuBar1 = new QPEMenuBar( iconToolBar );
368 QPopupMenu *menuBar = new QPopupMenu( this );
369 menuBar1->insertItem( i18n("ME"), menuBar);
370 menuBar->insertItem( i18n("File"), importMenu );
371 menuBar->insertItem( i18n("View"), viewMenu );
372 menuBar->insertItem( i18n("Actions"), actionMenu );
373 menuBar->insertItem( i18n("Synchronize"), syncMenu );
374 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
375 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
376 menuBar->insertItem( i18n("Help"), helpMenu );
377 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
378 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
379 }
380 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
381 // ******************
382 QAction *action;
383 QIconSet icon;
384 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
385 configureToolBarMenu->setCheckable( true );
386
387 QString pathString = "";
388 if ( !p->mToolBarMiniIcons ) {
389 if ( QApplication::desktop()->width() < 480 )
390 pathString += "icons16/";
391 } else
392 pathString += "iconsmini/";
393 configureAgendaMenu->setCheckable( true );
394 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
395 configureAgendaMenu->insertSeparator();
396 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
397 configureAgendaMenu->insertItem(i18n("Small"), 6 );
398 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
399 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
400 configureAgendaMenu->insertItem(i18n("Large"), 12 );
401 configureAgendaMenu->insertItem(i18n("Big"), 14 );
402 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
403 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
404 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
405
406 icon = loadPixmap( pathString + "configure" );
407 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
408 action->addTo( actionMenu );
409 connect( action, SIGNAL( activated() ),
410 mView, SLOT( edit_options() ) );
411 actionMenu->insertSeparator();
412 icon = loadPixmap( pathString + "newevent" );
413 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
414 configureToolBarMenu->insertSeparator();
415 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
416 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
417 ne_action->addTo( actionMenu );
418 connect( ne_action, SIGNAL( activated() ),
419 mView, SLOT( newEvent() ) );
420 icon = loadPixmap( pathString + "newtodo" );
421 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
422 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
423 nt_action->addTo( actionMenu );
424 connect( nt_action, SIGNAL( activated() ),
425 mView, SLOT( newTodo() ) );
426 icon = loadPixmap( pathString + "navi" );
427 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
428 action->addTo( viewMenu );
429 connect( action, SIGNAL( activated() ),
430 mView, SLOT( toggleDateNavigatorWidget() ) );
431 icon = loadPixmap( pathString + "filter" );
432 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
433 action->addTo( viewMenu );
434 connect( action, SIGNAL( activated() ),
435 mView, SLOT( toggleFilter() ) );
436
437
438 viewMenu->insertSeparator();
439 icon = loadPixmap( pathString + "picker" );
440 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
441 action->addTo( viewMenu );
442 connect( action, SIGNAL( activated() ),
443 mView, SLOT( showDatePicker() ) );
444 action->addTo( iconToolBar );
445 viewMenu->insertSeparator();
446 icon = loadPixmap( pathString + "list" );
447 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
448 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
449 showlist_action->addTo( viewMenu );
450 connect( showlist_action, SIGNAL( activated() ),
451 mView->viewManager(), SLOT( showListView() ) );
452
453
454 icon = loadPixmap( pathString + "day" );
455 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
456 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
457 day1_action->addTo( viewMenu );
458 // action->addTo( toolBar );
459 connect( day1_action, SIGNAL( activated() ),
460 mView->viewManager(), SLOT( showDayView() ) );
461
462 icon = loadPixmap( pathString + "workweek" );
463 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
464 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
465 day5_action->addTo( viewMenu );
466 connect( day5_action, SIGNAL( activated() ),
467 mView->viewManager(), SLOT( showWorkWeekView() ) );
468
469 icon = loadPixmap( pathString + "week" );
470 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
471 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
472 day7_action->addTo( viewMenu );
473 connect( day7_action, SIGNAL( activated() ),
474 mView->viewManager(), SLOT( showWeekView() ) );
475
476 icon = loadPixmap( pathString + "month" );
477 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
478 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
479 month_action->addTo( viewMenu );
480 connect( month_action, SIGNAL( activated() ),
481 mView->viewManager(), SLOT( showMonthView() ) );
482
483 icon = loadPixmap( pathString + "todo" );
484 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
485 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
486 todoview_action->addTo( viewMenu );
487 connect( todoview_action, SIGNAL( activated() ),
488 mView->viewManager(), SLOT( showTodoView() ) );
489
490 icon = loadPixmap( pathString + "journal" );
491 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
492 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
493 viewjournal_action->addTo( viewMenu );
494 connect( viewjournal_action, SIGNAL( activated() ),
495 mView->viewManager(), SLOT( showJournalView() ) );
496
497 icon = loadPixmap( pathString + "xdays" );
498 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
499 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
500 xdays_action->addTo( viewMenu );
501 connect( xdays_action, SIGNAL( activated() ),
502 mView->viewManager(), SLOT( showNextXView() ) );
503
504 icon = loadPixmap( pathString + "whatsnext" );
505 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
506 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
507 whatsnext_action->addTo( viewMenu );
508 connect( whatsnext_action, SIGNAL( activated() ),
509 mView->viewManager(), SLOT( showWhatsNextView() ) );
510
511#if 0
512 action = new QAction( "view_timespan", "Time Span", 0, this );
513 action->addTo( viewMenu );
514 connect( action, SIGNAL( activated() ),
515 mView->viewManager(), SLOT( showTimeSpanView() ) );
516#endif
517
518 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
519 this );
520 mNewSubTodoAction->addTo( actionMenu );
521 connect( mNewSubTodoAction, SIGNAL( activated() ),
522 mView, SLOT( newSubTodo() ) );
523
524 actionMenu->insertSeparator();
525
526 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
527 mShowAction->addTo( actionMenu );
528 connect( mShowAction, SIGNAL( activated() ),
529 mView, SLOT( showIncidence() ) );
530
531 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
532 mEditAction->addTo( actionMenu );
533 connect( mEditAction, SIGNAL( activated() ),
534 mView, SLOT( editIncidence() ) );
535
536 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
537 mDeleteAction->addTo( actionMenu );
538 connect( mDeleteAction, SIGNAL( activated() ),
539 mView, SLOT( deleteIncidence() ) );
540
541 actionMenu->insertSeparator();
542
543 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
544 this );
545 action->addTo( actionMenu );
546 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
547
548 icon = loadPixmap( pathString + "search" );
549 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
550 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
551 search_action->addTo( actionMenu );
552 connect( search_action, SIGNAL( activated() ),
553 mView->dialogManager(), SLOT( showSearchDialog() ) );
554
555 icon = loadPixmap( pathString + "today" );
556 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
557 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
558 today_action->addTo( actionMenu );
559 connect( today_action, SIGNAL( activated() ),
560 mView, SLOT( goToday() ) );
561
562 if ( KOPrefs::instance()->mShowFullMenu ) {
563 actionMenu->insertSeparator();
564 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
565
566 }
567 // actionMenu->insertSeparator();
568 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
569 this );
570 action->addTo( importMenu );
571 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
572 action = new QAction( "import_quick", i18n("Import last file"), 0,
573 this );
574 action->addTo( importMenu );
575 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
576 importMenu->insertSeparator();
577 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
578 this );
579 action->addTo( importMenu );
580 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
581#ifndef DESKTOP_VERSION
582 importMenu->insertSeparator();
583 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
584 this );
585 action->addTo( importMenu );
586 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
587#endif
588
589 importMenu->insertSeparator();
590 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
591 this );
592 action->addTo( importMenu );
593 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
594
595 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
596 this );
597 action->addTo( importMenu );
598 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
599
600 importMenu->insertSeparator();
601 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
602 this );
603 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
604 importMenu->insertSeparator();
605 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
606 this );
607 action->addTo( importMenu );
608 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
609#ifndef DESKTOP_VERSION
610 importMenu->insertSeparator();
611 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
612 this );
613 action->addTo( importMenu );
614 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
615
616 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
617 this );
618 action->addTo( importMenu );
619 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
620#else
621 importMenu->insertSeparator();
622 icon = loadPixmap( pathString + "print" );
623 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
624 action->addTo( importMenu );
625 connect( action, SIGNAL( activated() ),
626 this, SLOT( printCal() ) );
627
628 icon = loadPixmap( pathString + "print" );
629 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
630 action->addTo( importMenu );
631 connect( action, SIGNAL( activated() ),
632 this, SLOT( printSel() ) );
633#endif
634 importMenu->insertSeparator();
635 action = new QAction( "beam all", i18n("Save"), 0,
636 this );
637 action->addTo( importMenu );
638 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
639 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
640 this );
641 action->addTo( importMenu );
642 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
643
644 //menuBar->insertItem( "Configure",configureMenu );
645 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
646 icon = loadPixmap( "korganizer/korganizer" );
647 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
648 action->addTo( helpMenu );
649 connect( action, SIGNAL( activated() ),
650 SLOT( keyBindings() ) );
651 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
652 action->addTo( helpMenu );
653 connect( action, SIGNAL( activated() ),
654 SLOT( features() ) );
655 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
656 action->addTo( helpMenu );
657 connect( action, SIGNAL( activated() ),
658 SLOT( aboutAutoSaving() ) );
659 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
660 action->addTo( helpMenu );
661 connect( action, SIGNAL( activated() ),
662 SLOT( aboutKnownBugs() ) );
663 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
664 action->addTo( helpMenu );
665 connect( action, SIGNAL( activated() ),
666 SLOT( usertrans() ) );
667 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
668 action->addTo( helpMenu );
669 connect( action, SIGNAL( activated() ),
670 SLOT( synchowto() ) );
671 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
672 action->addTo( helpMenu );
673 connect( action, SIGNAL( activated() ),
674 SLOT( whatsNew() ) );
675 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
676 action->addTo( helpMenu );
677 connect( action, SIGNAL( activated() ),
678 SLOT( faq() ) );
679
680
681 action = new QAction( "about", i18n("About..."), 0, this );
682 action->addTo( helpMenu );
683 connect( action, SIGNAL( activated() ),
684 SLOT( about() ) );
685 //menuBar->insertSeparator();
686
687 // ******************************************************
688 // menubar icons
689
690
691 iconToolBar->setHorizontalStretchable (true );
692 //menuBar->insertItem( iconToolBar );
693 //xdays_action
694 if (p-> mShowIconNewEvent)
695 ne_action->addTo( iconToolBar );
696 if (p->mShowIconNewTodo )
697 nt_action->addTo( iconToolBar );
698 if (p-> mShowIconSearch)
699 search_action->addTo( iconToolBar );
700 if (p-> mShowIconNext)
701 whatsnext_action->addTo( iconToolBar );
702 if (p-> mShowIconNextDays)
703 xdays_action->addTo( iconToolBar );
704 if (p-> mShowIconList)
705 showlist_action->addTo( iconToolBar );
706 if (p-> mShowIconDay1)
707 day1_action->addTo( iconToolBar );
708 if (p-> mShowIconDay5)
709 day5_action->addTo( iconToolBar );
710 if (p-> mShowIconDay7)
711 day7_action->addTo( iconToolBar );
712 if (p-> mShowIconMonth)
713 month_action->addTo( iconToolBar );
714 if (p-> mShowIconTodoview)
715 todoview_action->addTo( iconToolBar );
716 if (p-> mShowIconJournal)
717 viewjournal_action->addTo( iconToolBar );
718 icon = loadPixmap( pathString + "2leftarrowB" );
719 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
720 if (p-> mShowIconBackFast) {
721 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
722 connect( action, SIGNAL( activated() ),
723 mView, SLOT( goPreviousMonth() ) );
724 action->addTo( iconToolBar );
725 }
726 icon = loadPixmap( pathString + "1leftarrowB" );
727 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
728 if (p-> mShowIconBack) {
729 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
730 connect( action, SIGNAL( activated() ),
731 mView, SLOT( goPrevious() ) );
732 action->addTo( iconToolBar );
733 }
734 if (p-> mShowIconToday)
735 today_action->addTo( iconToolBar );
736 icon = loadPixmap( pathString + "1rightarrowB" );
737 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
738 if (p-> mShowIconForward) {
739 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
740 connect( action, SIGNAL( activated() ),
741 mView, SLOT( goNext() ) );
742 action->addTo( iconToolBar );
743 }
744 icon = loadPixmap( pathString + "2rightarrowB" );
745 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
746 if (p-> mShowIconForwardFast) {
747 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
748 connect( action, SIGNAL( activated() ),
749 mView, SLOT( goNextMonth() ) );
750 action->addTo( iconToolBar );
751 }
752
753
754 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
755
756 if (p-> mShowIconNewEvent)
757 configureToolBarMenu->setItemChecked( 10, true );
758 if (p->mShowIconNewTodo )
759 configureToolBarMenu->setItemChecked( 20, true );
760 if (p-> mShowIconSearch)
761 configureToolBarMenu->setItemChecked( 120, true );
762 if (p-> mShowIconList)
763 configureToolBarMenu->setItemChecked( 30, true );
764 if (p-> mShowIconDay1)
765 configureToolBarMenu->setItemChecked( 40, true );
766 if (p-> mShowIconDay5)
767 configureToolBarMenu->setItemChecked( 50, true );
768 if (p-> mShowIconDay7)
769 configureToolBarMenu->setItemChecked( 60, true );
770 if (p-> mShowIconMonth)
771 configureToolBarMenu->setItemChecked( 70, true );
772 if (p-> mShowIconTodoview)
773 configureToolBarMenu->setItemChecked( 80, true );
774 if (p-> mShowIconBackFast)
775 configureToolBarMenu->setItemChecked( 200, true );
776 if (p-> mShowIconBack)
777 configureToolBarMenu->setItemChecked( 210, true );
778 if (p-> mShowIconToday)
779 configureToolBarMenu->setItemChecked( 130, true );
780 if (p-> mShowIconForward)
781 configureToolBarMenu->setItemChecked( 220, true );
782 if (p-> mShowIconForwardFast)
783 configureToolBarMenu->setItemChecked( 230, true );
784 if (p-> mShowIconNextDays)
785 configureToolBarMenu->setItemChecked( 100, true );
786 if (p-> mShowIconNext)
787 configureToolBarMenu->setItemChecked( 110, true );
788 if (p-> mShowIconJournal)
789 configureToolBarMenu->setItemChecked( 90, true );
790 if (p-> mShowIconWhatsThis)
791 configureToolBarMenu->setItemChecked( 300, true );
792
793 QLabel* dummy = new QLabel( iconToolBar );
794 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
795 if (!p-> mShowIconStretch)
796 iconToolBar->setStretchableWidget ( dummy ) ;
797 else
798 configureToolBarMenu->setItemChecked( 5, true );
799 if (p-> mShowIconWhatsThis)
800 QWhatsThis::whatsThisButton ( iconToolBar );
801 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
802 configureAgenda( p->mHourSize );
803 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
804}
805void MainWindow::fillSyncMenu()
806{
807 syncMenu->clear();
808 syncMenu->insertItem( i18n("Configure..."), 0 );
809 syncMenu->insertSeparator();
810 syncMenu->insertItem( i18n("Multiple sync"), 1 );
811 syncMenu->insertSeparator();
812
813 QStringList prof = KOPrefs::instance()->mSyncProfileNames;
814
815 if ( prof.count() < 3 ) {
816 KConfig *config = KOGlobals::config();
817 prof.clear();
818 prof << i18n("Sharp-DTM");
819 prof << i18n("Local file");
820 prof << i18n("Last file");
821 KSyncProfile* temp = new KSyncProfile ();
822 temp->setName( prof[0] );
823 temp->writeConfig(config);
824 temp->setName( prof[1] );
825 temp->writeConfig(config);
826 temp->setName( prof[2] );
827 temp->writeConfig(config);
828 config->sync();
829 delete temp;
830 KOPrefs::instance()->mSyncProfileNames = prof;
831 }
832
833 int i;
834 for ( i = 0; i < prof.count(); ++i ) {
835
836 syncMenu->insertItem( prof[i], 1000+i );
837 if ( i == 2 )
838 syncMenu->insertSeparator();
839 }
840 QDir app_dir;
841 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
842 syncMenu->setItemEnabled( false , 1000 );
843 }
844}
845
846int MainWindow::ringSync()
847{
848 int syncedProfiles = 0;
849 int i;
850 QTime timer;
851 KConfig *config = KOGlobals::config();
852 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
853 KSyncProfile* temp = new KSyncProfile ();
854 KOPrefs::instance()->mAskForPreferences = false;
855 for ( i = 0; i < syncProfileNames.count(); ++i ) {
856 mCurrentSyncProfile = i;
857 temp->setName(syncProfileNames[mCurrentSyncProfile]);
858 temp->readConfig(config);
859 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
860 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
861 ++syncedProfiles;
862 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
863 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
864 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
865 KOPrefs::instance()->mShowSyncSummary = false;
866 mView->setSyncDevice(syncProfileNames[i] );
867 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
868 if ( i == 0 ) {
869 syncSharp();
870 } else {
871 if ( temp->getIsLocalFileSync() ) {
872 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
873 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
874 } else {
875 syncRemote( temp, false );
876
877 }
878 }
879 timer.start();
880 setCaption(i18n("Multiple sync in progress ... please wait!") );
881 while ( timer.elapsed () < 2000 ) {
882 qApp->processEvents();
883#ifndef _WIN32_
884 sleep (1);
885#endif
886 }
887
888 }
889
890 }
891 delete temp;
892 return syncedProfiles;
893}
894
895void MainWindow::multiSync( bool askforPrefs )
896{
897 if (mBlockSaveFlag)
898 return;
899 mBlockSaveFlag = true;
900 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
901 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
902 question,
903 i18n("Yes"), i18n("No"),
904 0, 0 ) != 0 ) {
905 mBlockSaveFlag = false;
906 setCaption(i18n("Aborted! Nothing synced!"));
907 return;
908 }
909 mView->setSyncDevice(i18n("Multiple profiles") );
910 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
911 if ( askforPrefs ) {
912 mView->edit_sync_options();
913 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
914 }
915 setCaption(i18n("Multiple sync started.") );
916 qApp->processEvents();
917 int num = ringSync() ;
918 if ( num > 1 )
919 ringSync();
920 mBlockSaveFlag = false;
921 if ( num )
922 save();
923 if ( num )
924 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
925 else
926 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
927 return;
928}
929void MainWindow::slotSyncMenu( int action )
930{
931 //qDebug("syncaction %d ", action);
932 if ( action == 0 ) {
933 confSync();
934 return;
935 }
936 if ( action == 1 ) {
937 multiSync( true );
938 return;
939 }
940
941 if (mBlockSaveFlag)
942 return;
943 mBlockSaveFlag = true;
944 mCurrentSyncProfile = action - 1000 ;
945 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
946 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
947 KConfig *config = KOGlobals::config();
948 KSyncProfile* temp = new KSyncProfile ();
949 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
950 temp->readConfig(config);
951 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
952 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
953 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
954 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
955 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
956 if ( action == 1000 ) {
957 syncSharp();
958
959 } else if ( action == 1001 ) {
960 syncLocalFile();
961
962 } else if ( action == 1002 ) {
963 quickSyncLocalFile();
964
965 } else if ( action >= 1003 ) {
966 if ( temp->getIsLocalFileSync() ) {
967 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
968 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
969 } else {
970 syncRemote( temp );
971
972 }
973 }
974 delete temp;
975 mBlockSaveFlag = false;
976}
977void MainWindow::setDefaultPreferences()
978{
979 KOPrefs *p = KOPrefs::instance();
980
981 p->mCompactDialogs = true;
982 p->mConfirm = true;
983 // p->mEnableQuickTodo = false;
984}
985
986QString MainWindow::resourcePath()
987{
988 return KGlobal::iconLoader()->iconPath();
989}
990
991void MainWindow::displayText( QString text ,QString cap )
992{
993 QDialog dia( this, "name", true ); ;
994 dia.setCaption( cap );
995 QVBoxLayout* lay = new QVBoxLayout( &dia );
996 lay->setSpacing( 3 );
997 lay->setMargin( 3 );
998 QTextBrowser tb ( &dia );
999 lay->addWidget( &tb );
1000 tb.setText( text );
1001#ifdef DESKTOP_VERSION
1002 dia.resize( 640, 480);
1003#else
1004 dia.showMaximized();
1005#endif
1006 dia.exec();
1007}
1008void MainWindow::displayFile( QString fn, QString cap )
1009{
1010 QString fileName = resourcePath() + fn;
1011 QString text;
1012 QFile file( fileName );
1013 if (!file.open( IO_ReadOnly ) ) {
1014 return ;
1015
1016 }
1017 QTextStream ts( &file );
1018 text = ts.read();
1019 file.close();
1020 displayText( text, cap);
1021}
1022void MainWindow::features()
1023{
1024
1025 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1026}
1027
1028void MainWindow::usertrans()
1029{
1030
1031 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1032}
1033void MainWindow::synchowto()
1034{
1035
1036 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1037}
1038void MainWindow::faq()
1039{
1040 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1041
1042}
1043void MainWindow::whatsNew()
1044{
1045 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1046
1047}
1048void MainWindow::about()
1049{
1050 QString version;
1051#include <../version>
1052 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1053 i18n("KOrganizer/Platform-independent\n") +
1054 "(KO/Pi) " + version + " - " +
1055
1056#ifdef DESKTOP_VERSION
1057 i18n("Desktop Edition\n") +
1058#else
1059 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1060#endif
1061 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1062}
1063void MainWindow::keyBindings()
1064{
1065 QString cap = i18n("Key bindings KOrganizer/Pi");
1066 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1067 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1068 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1069 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1070 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1071 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1072 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1073 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1074 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1075 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1076 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1077 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1078 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1079 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1080 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1081 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1082 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1083 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1084 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1085 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1086 i18n("<p><h3>In agenda view:</h3></p>\n") +
1087 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1088 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1089 i18n("<p><h3>In todo view:</h3></p>\n") +
1090 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1091 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1092 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1093 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1094 i18n("<p><h3>In list view:</h3></p>\n") +
1095 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1096 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1097 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1098 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1099 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1100 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1101 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1102 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1103 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1104 i18n("<p><b>E</b>: Edit item</p>\n") +
1105 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1106 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1107 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1108 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1109 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1110 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1111 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1112 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1113 i18n("<p><b>White</b>: Item readonly</p>\n");
1114 displayText( text, cap);
1115
1116}
1117void MainWindow::aboutAutoSaving()
1118{
1119 QMessageBox* msg;
1120 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1121 i18n("After changing something, the data is\nautomatically saved to the file\n~/Applications/korganizer/calendar/mycalendar.ics\nafter (configureable) 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"), QMessageBox::NoIcon,
1122 QMessageBox::Ok,
1123 QMessageBox::NoButton,
1124 QMessageBox::NoButton);
1125 msg->exec();
1126 delete msg;
1127
1128
1129}
1130void MainWindow::aboutKnownBugs()
1131{
1132 QMessageBox* msg;
1133 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1134 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")+
1135 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1136 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1137 i18n("\nor report them in the bugtracker on\n") +
1138 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1139 QMessageBox::NoIcon,
1140 QMessageBox::Ok,
1141 QMessageBox::NoButton,
1142 QMessageBox::NoButton);
1143 msg->exec();
1144 delete msg;
1145
1146}
1147
1148QString MainWindow::defaultFileName()
1149{
1150 return locateLocal( "data", "korganizer/mycalendar.ics" );
1151}
1152
1153void MainWindow::processIncidenceSelection( Incidence *incidence )
1154{
1155 if ( !incidence ) {
1156 enableIncidenceActions( false );
1157
1158 mNewSubTodoAction->setEnabled( false );
1159 setCaptionToDates();
1160 return;
1161
1162 }
1163
1164 //KGlobal::locale()->formatDateTime(nextA, true);
1165 QString startString = "";
1166 if ( incidence->type() != "Todo" ) {
1167 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1168 if ( incidence->doesFloat() ) {
1169 startString += ": "+incidence->dtStartDateStr( true );
1170 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1171
1172 } else {
1173 startString = ": "+incidence->dtStartStr(true);
1174 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1175
1176 }
1177
1178 } else {
1179 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1180 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1181 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1182 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1183 }
1184
1185 }
1186 else
1187 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1188 if ( !incidence->location().isEmpty() )
1189 startString += " (" +incidence->location()+")";
1190 setCaption( incidence->summary()+startString);
1191
1192 enableIncidenceActions( true );
1193
1194 if ( incidence->type() == "Event" ) {
1195 mShowAction->setText( i18n("Show Event...") );
1196 mEditAction->setText( i18n("Edit Event...") );
1197 mDeleteAction->setText( i18n("Delete Event...") );
1198
1199 mNewSubTodoAction->setEnabled( false );
1200 } else if ( incidence->type() == "Todo" ) {
1201 mShowAction->setText( i18n("Show Todo...") );
1202 mEditAction->setText( i18n("Edit Todo...") );
1203 mDeleteAction->setText( i18n("Delete Todo...") );
1204
1205 mNewSubTodoAction->setEnabled( true );
1206 } else {
1207 mShowAction->setText( i18n("Show...") );
1208 mShowAction->setText( i18n("Edit...") );
1209 mShowAction->setText( i18n("Delete...") );
1210
1211 mNewSubTodoAction->setEnabled( false );
1212 }
1213}
1214
1215void MainWindow::enableIncidenceActions( bool enabled )
1216{
1217 mShowAction->setEnabled( enabled );
1218 mEditAction->setEnabled( enabled );
1219 mDeleteAction->setEnabled( enabled );
1220}
1221
1222void MainWindow::importBday()
1223{
1224 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1225 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1226 i18n("Import!"), i18n("Cancel"), 0,
1227 0, 1 );
1228 if ( result == 0 ) {
1229 mView->importBday();
1230
1231 }
1232
1233
1234}
1235void MainWindow::importQtopia()
1236{
1237#ifndef DESKTOP_VERSION
1238 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1239 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"),
1240 i18n("Import!"), i18n("Cancel"), 0,
1241 0, 1 );
1242 if ( result == 0 ) {
1243 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1244 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1245 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1246 mView->importQtopia( categories, datebook, todolist );
1247 }
1248#else
1249 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1250 i18n("Not supported \non desktop!\n"),
1251 i18n("Ok"), i18n("Cancel"), 0,
1252 0, 1 );
1253
1254#endif
1255}
1256
1257void MainWindow::saveOnClose()
1258{
1259 KOPrefs *p = KOPrefs::instance();
1260 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1261 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1262 iconToolBar->y() > height()/2;
1263 mView->writeSettings();
1264 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1265 save();
1266}
1267void MainWindow::slotModifiedChanged( bool changed )
1268{
1269 if ( mBlockAtStartup )
1270 return;
1271 int msec;
1272 // we store the changes after 1 minute,
1273 // and for safety reasons after 10 minutes again
1274 if ( !mBlockSaveFlag )
1275 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1276 else
1277 msec = 1000 * 600;
1278 mSaveTimer.start( msec, true ); // 1 minute
1279 qDebug("KO: Saving File in %d secs!", msec/1000);
1280 mCalendarModifiedFlag = true;
1281}
1282#include <qfileinfo.h>
1283void MainWindow::save()
1284{
1285 if ( mBlockSaveFlag )
1286 return;
1287 bool store = mBlockSaveFlag;
1288 mBlockSaveFlag = true;
1289 if ( mView->checkFileVersion( defaultFileName()) ) {
1290
1291 QTime neededSaveTime = QDateTime::currentDateTime().time();
1292 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1293 qDebug("KO: Start saving data to file!");
1294 mView->saveCalendar( defaultFileName() );
1295
1296 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1297 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1298 qDebug("KO: Needed %d ms for saving.",msNeeded );
1299 QString savemes;
1300 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1301 setCaption(savemes);
1302 } else
1303 setCaption(i18n("Saving cancelled!"));
1304 mCalendarModifiedFlag = false;
1305 mBlockSaveFlag = store;
1306}
1307
1308void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1309{
1310 if ( !e->isAutoRepeat() ) {
1311 mFlagKeyPressed = false;
1312 }
1313}
1314void MainWindow::keyPressEvent ( QKeyEvent * e )
1315{
1316 qApp->processEvents();
1317 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1318 e->ignore();
1319 // qDebug(" ignore %d",e->isAutoRepeat() );
1320 return;
1321 }
1322 if (! e->isAutoRepeat() )
1323 mFlagKeyPressed = true;
1324 KOPrefs *p = KOPrefs::instance();
1325 bool showSelectedDates = false;
1326 int size;
1327 int pro = 0;
1328 //qDebug("MainWindow::keyPressEvent ");
1329 switch ( e->key() ) {
1330 case Qt::Key_Right:
1331 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1332 mView->goNextMonth();
1333 else
1334 mView->goNext();
1335 showSelectedDates = true;
1336 break;
1337 case Qt::Key_Left:
1338 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1339 mView->goPreviousMonth();
1340 else
1341 mView->goPrevious();
1342 showSelectedDates = true;
1343 break;
1344 case Qt::Key_Down:
1345 mView->viewManager()->agendaView()->scrollOneHourDown();
1346 break;
1347 case Qt::Key_Up:
1348 mView->viewManager()->agendaView()->scrollOneHourUp();
1349 break;
1350 case Qt::Key_I:
1351 mView->showIncidence();
1352 break;
1353 case Qt::Key_Delete:
1354 case Qt::Key_Backspace:
1355 mView->deleteIncidence();
1356 break;
1357 case Qt::Key_D:
1358 mView->viewManager()->showDayView();
1359 showSelectedDates = true;
1360 break;
1361 case Qt::Key_O:
1362 mView->toggleFilerEnabled( );
1363 break;
1364 case Qt::Key_0:
1365 case Qt::Key_1:
1366 case Qt::Key_2:
1367 case Qt::Key_3:
1368 case Qt::Key_4:
1369 case Qt::Key_5:
1370 case Qt::Key_6:
1371 case Qt::Key_7:
1372 case Qt::Key_8:
1373 case Qt::Key_9:
1374 pro = e->key()-48;
1375 if ( pro == 0 )
1376 pro = 10;
1377 if ( e->state() == Qt::ControlButton)
1378 pro += 10;
1379 break;
1380 case Qt::Key_M:
1381 mView->viewManager()->showMonthView();
1382 showSelectedDates = true;
1383 break;
1384 case Qt::Key_Insert:
1385 mView->newEvent();
1386 break;
1387 case Qt::Key_S :
1388 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1389 mView->newSubTodo();
1390 else
1391 mView->dialogManager()->showSearchDialog();
1392 break;
1393 case Qt::Key_Y :
1394 case Qt::Key_Z :
1395 mView->viewManager()->showWorkWeekView();
1396 showSelectedDates = true;
1397 break;
1398 case Qt::Key_U :
1399 mView->viewManager()->showWeekView();
1400 showSelectedDates = true;
1401 break;
1402 case Qt::Key_H :
1403 keyBindings();
1404 break;
1405 case Qt::Key_W:
1406 mView->viewManager()->showWhatsNextView();
1407 break;
1408 case Qt::Key_L:
1409 mView->viewManager()->showListView();
1410 break;
1411 case Qt::Key_N:
1412 mView->viewManager()->showNextXView();
1413 showSelectedDates = true;
1414 break;
1415 case Qt::Key_V:
1416 mView->viewManager()->showTodoView();
1417 break;
1418 case Qt::Key_C:
1419 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1420 break;
1421 case Qt::Key_P:
1422 mView->showDatePicker( );
1423 break;
1424 case Qt::Key_F:
1425 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1426 mView->editFilters();
1427 else
1428 mView->toggleFilter();
1429 break;
1430 case Qt::Key_X:
1431 mView->toggleDateNavigatorWidget();
1432 break;
1433 case Qt::Key_Space:
1434 mView->toggleExpand();
1435 break;
1436 case Qt::Key_A:
1437 mView->toggleAllDaySize();
1438 break;
1439 case Qt::Key_T:
1440 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1441 mView->newTodo();
1442 else {
1443 mView->goToday();
1444 showSelectedDates = true;
1445 }
1446 break;
1447 case Qt::Key_J:
1448 mView->viewManager()->showJournalView();
1449 break;
1450 case Qt::Key_B:
1451 mView->editIncidenceDescription();;
1452 break;
1453 // case Qt::Key_Return:
1454 case Qt::Key_E:
1455 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1456 mView->newEvent();
1457 else
1458 mView->editIncidence();
1459 break;
1460 case Qt::Key_Plus:
1461 size = p->mHourSize +2;
1462 if ( size <= 18 )
1463 configureAgenda( size );
1464 break;
1465 case Qt::Key_Minus:
1466 size = p->mHourSize - 2;
1467 if ( size >= 4 )
1468 configureAgenda( size );
1469 break;
1470
1471
1472 default:
1473 e->ignore();
1474 }
1475 if ( pro > 0 ) {
1476 mView->selectFilter( pro-1 );
1477 }
1478 if ( showSelectedDates ) {
1479 ;// setCaptionToDates();
1480 }
1481
1482}
1483
1484void MainWindow::configureToolBar( int item )
1485{
1486
1487 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1488 KOPrefs *p = KOPrefs::instance();
1489 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1490 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1491 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1492 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1493 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1494 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1495 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1496 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1497 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1498 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1499 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1500 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1501 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1502 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1503 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1504 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1505 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1506 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1507 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1508 // initActions();
1509}
1510
1511void MainWindow::setCaptionToDates()
1512{
1513 QString selDates;
1514 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1515 if (mView->startDate() < mView->endDate() )
1516 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1517 setCaption( i18n("Dates: ") + selDates );
1518
1519}
1520// parameter item == 0: reinit
1521void MainWindow::configureAgenda( int item )
1522{
1523
1524 KOPrefs *p = KOPrefs::instance();
1525
1526 int i;
1527 if ( item == 1 ) {
1528 mView->toggleAllDaySize();
1529 return;
1530 }
1531 // do not allow 4 for widgets higher than 480
1532 // if ( QApplication::desktop()->height() > 480 ) {
1533// if ( item == 4 )
1534// item = 6;
1535// }
1536 for ( i = 4; i <= 18; i= i+2 )
1537 configureAgendaMenu->setItemChecked( i, false );
1538 configureAgendaMenu->setItemChecked( item, true );
1539 if ( p->mHourSize == item )
1540 return;
1541 p->mHourSize=item;
1542 mView->viewManager()->agendaView()->updateConfig();
1543}
1544
1545void MainWindow::saveCalendar()
1546{
1547 QString fn = KOPrefs::instance()->mLastSaveFile;
1548 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1549
1550 if ( fn == "" )
1551 return;
1552 QFileInfo info;
1553 info.setFile( fn );
1554 QString mes;
1555 bool createbup = true;
1556 if ( info. exists() ) {
1557 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1558 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1559 i18n("Overwrite!"), i18n("Cancel"), 0,
1560 0, 1 );
1561 if ( result != 0 ) {
1562 createbup = false;
1563 }
1564 }
1565 if ( createbup ) {
1566 mView->saveCalendar( fn );
1567 mes = i18n("KO/Pi:Saved %1").arg(fn);
1568 KOPrefs::instance()->mLastSaveFile = fn;
1569 setCaption(mes);
1570 }
1571}
1572void MainWindow::loadCalendar()
1573{
1574
1575 QString fn = KOPrefs::instance()->mLastLoadFile;
1576 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1577
1578 if ( fn == "" )
1579 return;
1580 QFileInfo info;
1581 info.setFile( fn );
1582 QString mess;
1583 bool loadbup = true;
1584 if ( info. exists() ) {
1585 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1586 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1587 mess,
1588 i18n("Load!"), i18n("Cancel"), 0,
1589 0, 1 );
1590 if ( result != 0 ) {
1591 loadbup = false;
1592 }
1593 } else {
1594 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1595 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1596 0, 1 );
1597
1598 return;
1599 }
1600 if ( loadbup ) {
1601 mView->openCalendar( fn );
1602 KOPrefs::instance()->mLastLoadFile = fn;
1603 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1604 setCaption(mess);
1605 }
1606
1607}
1608void MainWindow::quickImportIcal()
1609{
1610 importFile( KOPrefs::instance()->mLastImportFile, false );
1611}
1612void MainWindow::importFile( QString fn, bool quick )
1613{
1614 QFileInfo info;
1615 info.setFile( fn );
1616 QString mess;
1617 bool loadbup = true;
1618 if ( !info. exists() ) {
1619 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1620 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1621 mess );
1622 return;
1623 }
1624 int result = 0;
1625 if ( !quick ) {
1626 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 ));
1627 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1628 mess,
1629 "Import", "Cancel", 0,
1630 0, 1 );
1631 }
1632 if ( result == 0 ) {
1633 if ( mView->openCalendar( fn, true )) {
1634 KOPrefs::instance()->mLastImportFile = fn;
1635 setCaption(i18n("Imported file successfully"));
1636 } else {
1637 setCaption(i18n("Error importing file"));
1638 }
1639 }
1640}
1641
1642void MainWindow::importIcal()
1643{
1644
1645 QString fn =KOPrefs::instance()->mLastImportFile;
1646
1647 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1648 if ( fn == "" )
1649 return;
1650 importFile( fn, true );
1651
1652}
1653
1654void MainWindow::exportVCalendar()
1655{
1656 QString fn = KOPrefs::instance()->mLastVcalFile;
1657 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1658 if ( fn == "" )
1659 return;
1660 QFileInfo info;
1661 info.setFile( fn );
1662 QString mes;
1663 bool createbup = true;
1664 if ( info. exists() ) {
1665 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1666 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1667 i18n("Overwrite!"), i18n("Cancel"), 0,
1668 0, 1 );
1669 if ( result != 0 ) {
1670 createbup = false;
1671 }
1672 }
1673 if ( createbup ) {
1674 if ( mView->exportVCalendar( fn ) ) {
1675 KOPrefs::instance()->mLastVcalFile = fn;
1676 if ( fn.length() > 20 )
1677 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1678 else
1679 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1680 setCaption(mes);
1681 }
1682 }
1683
1684}
1685#include <qpushbutton.h>
1686QString MainWindow::getPassword( )
1687{
1688 QString retfile = "";
1689 QDialog dia ( this, "input-dialog", true );
1690 QLineEdit lab ( &dia );
1691 lab.setEchoMode( QLineEdit::Password );
1692 QVBoxLayout lay( &dia );
1693 lay.setMargin(7);
1694 lay.setSpacing(7);
1695 lay.addWidget( &lab);
1696 dia.setFixedSize( 230,50 );
1697 dia.setCaption( i18n("Enter password") );
1698 QPushButton pb ( "OK", &dia);
1699 lay.addWidget( &pb );
1700 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1701 dia.show();
1702 int res = dia.exec();
1703 if ( res )
1704 retfile = lab.text();
1705 dia.hide();
1706 qApp->processEvents();
1707 return retfile;
1708
1709}
1710
1711void MainWindow::syncLocalFile()
1712{
1713
1714 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1715
1716 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1717 if ( fn == "" )
1718 return;
1719 //mView->setSyncDevice("local-file" );
1720 if ( syncWithFile( fn, false ) ) {
1721 // Event* e = mView->getLastSyncEvent();
1722// e->setReadOnly( false );
1723// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1724// e->setReadOnly( true );
1725 }
1726
1727}
1728
1729bool MainWindow::syncWithFile( QString fn , bool quick )
1730{
1731 bool ret = false;
1732 QFileInfo info;
1733 info.setFile( fn );
1734 QString mess;
1735 bool loadbup = true;
1736 if ( !info. exists() ) {
1737 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1738 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1739 mess );
1740 return ret;
1741 }
1742 int result = 0;
1743 if ( !quick ) {
1744 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1745 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1746 mess,
1747 i18n("Sync"), i18n("Cancel"), 0,
1748 0, 1 );
1749 if ( result )
1750 return false;
1751 }
1752 if ( KOPrefs::instance()->mAskForPreferences )
1753 mView->edit_sync_options();
1754 if ( result == 0 ) {
1755 //qDebug("Now sycing ... ");
1756 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1757 setCaption( i18n("Synchronization successful") );
1758 else
1759 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1760 if ( ! quick )
1761 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1762 slotModifiedChanged( true );
1763 }
1764 return ret;
1765}
1766void MainWindow::quickSyncLocalFile()
1767{
1768 //mView->setSyncDevice("local-file" );
1769 //qDebug("quickSyncLocalFile() ");
1770 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1771 // Event* e = mView->getLastSyncEvent();
1772// e->setReadOnly( false );
1773// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1774// e->setReadOnly( true );
1775
1776 }
1777}
1778
1779void MainWindow::confSync()
1780{
1781 mView->confSync();
1782 fillSyncMenu();
1783 mView->writeSettings();
1784
1785
1786}
1787void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1788{
1789 QString question;
1790 if ( ask ) {
1791 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1792 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1793 question,
1794 i18n("Yes"), i18n("No"),
1795 0, 0 ) != 0 )
1796 return;
1797 }
1798 QString command = prof->getPreSyncCommand();
1799 int fi;
1800 if ( (fi = command.find("$PWD$")) > 0 ) {
1801 QString pwd = getPassword();
1802 command = command.left( fi )+ pwd + command.mid( fi+5 );
1803
1804 }
1805 int maxlen = 30;
1806 if ( QApplication::desktop()->width() > 320 )
1807 maxlen += 25;
1808 setCaption ( i18n( "Copy remote file to local machine..." ) );
1809 int fileSize = 0;
1810 int result = system ( command );
1811 // 0 : okay
1812 // 256: no such file or dir
1813 //
1814 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1815 if ( result != 0 ) {
1816 int len = maxlen;
1817 while ( len < command.length() ) {
1818 command.insert( len , "\n" );
1819 len += maxlen +2;
1820 }
1821 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1822 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1823 question,
1824 i18n("Okay!")) ;
1825 setCaption ("KO/Pi");
1826 return;
1827 }
1828 setCaption ( i18n( "Copying succeed." ) );
1829 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1830 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1831// Event* e = mView->getLastSyncEvent();
1832// e->setReadOnly( false );
1833// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1834// e->setReadOnly( true );
1835 if ( KOPrefs::instance()->mWriteBackFile ) {
1836 command = prof->getPostSyncCommand();
1837 setCaption ( i18n( "Writing back file ..." ) );
1838 result = system ( command );
1839 qDebug("KO: Writing back file result: %d ", result);
1840 if ( result != 0 ) {
1841 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1842 return;
1843 } else {
1844 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1845 }
1846 }
1847 }
1848 return;
1849}
1850void MainWindow::syncSSH()
1851{
1852 // not used anymore
1853 QTime timer;
1854 timer.start();
1855 //qDebug("MainWindow::syncssh() ");
1856 KOPrefs *p = KOPrefs::instance();
1857 QString localFile = p->mLocalTempFile;
1858 QString remoteIP = p->mRemoteIP;
1859 QString remoteUser = p->mRemoteUser;
1860 QString remoteFile = p->mRemoteFile;
1861 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1862 remoteUser += ":" + p->mRemotePassWd;
1863
1864 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1865 i18n("IP: " ) +remoteIP +"\n" +
1866 i18n("User: " ) + remoteUser +"\n" ;
1867 int maxlen = 30;
1868 if ( QApplication::desktop()->width() > 320 )
1869 maxlen += 25;
1870 if ( remoteFile.length() > maxlen )
1871 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
1872 else
1873 question += i18n("Remote file:\n " ) + remoteFile +"\n";
1874 if ( localFile.length() > maxlen )
1875 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
1876 else
1877 question += i18n("Local temp file:\n " ) + localFile +"\n";
1878
1879 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1880 question,
1881 i18n("Yes"), i18n("No"),
1882 0, 0 ) != 0 )
1883 return;
1884 // if ( !p->mUsePassWd ) {
1885 // QString pass = getPassword();
1886 // if ( pass.length() > 0 )
1887 // remoteUser += ":" + pass;
1888 // }
1889 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
1890 setCaption ( i18n( "Copy remote file to local machine..." ) );
1891 int fileSize = 0;
1892 int result = system ( command );
1893 // 0 : okay
1894 // 256: no such file or dir
1895 //
1896 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1897 if ( result != 0 ) {
1898 int len = maxlen;
1899 while ( len < command.length() ) {
1900 command.insert( len , "\n" );
1901 len += maxlen +2;
1902 }
1903 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1904 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1905 question,
1906 i18n("Okay!")) ;
1907 setCaption ("KO/Pi");
1908 return;
1909 }
1910
1911
1912 setCaption ( i18n( "Copying succeed." ) );
1913 //mView->setSyncDevice("ssh-scp" );
1914 if ( syncWithFile(localFile , true ) ) {
1915// Event* e = mView->getLastSyncEvent();
1916// e->setReadOnly( false );
1917// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1918// e->setReadOnly( true );
1919 if ( KOPrefs::instance()->mWriteBackFile ) {
1920 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
1921 setCaption ( i18n( "Writing back file ..." ) );
1922 result = system ( command );
1923 if ( result != 0 ) {
1924 int len = maxlen;
1925 while ( len < command.length() ) {
1926 command.insert( len , "\n" );
1927 len += maxlen +2;
1928 }
1929 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1930 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1931 question,
1932 i18n("Okay!")) ;
1933 setCaption ("KO/Pi");
1934 return;
1935 } else {
1936 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1937 }
1938 }
1939 }
1940 return;
1941#if 0
1942 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
1943 while ( timer.elapsed() < 5000 )
1944 qApp->processEvents();
1945
1946 qDebug("MainWindow::merging) ");
1947 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
1948 while ( mBlockSaveFlag )
1949 qApp->processEvents();
1950 save();
1951 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
1952#endif
1953
1954}
1955
1956
1957void MainWindow::syncSharp()
1958{
1959 if ( mCalendarModifiedFlag )
1960 save();
1961 mView->syncSharp();
1962 slotModifiedChanged( true );
1963
1964}
1965
1966void MainWindow::printSel( )
1967{
1968 mView->viewManager()->agendaView()->agenda()->printSelection();
1969}
1970
1971void MainWindow::printCal()
1972{
1973 mView->print();//mCp->showDialog();
1974}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
new file mode 100644
index 0000000..ee4aaa6
--- a/dev/null
+++ b/korganizer/mainwindow.h
@@ -0,0 +1,115 @@
1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H
3
4#include <qmainwindow.h>
5#include <qtimer.h>
6#include <qdict.h>
7
8#include <libkcal/incidence.h>
9#include "simplealarmclient.h"
10
11class QAction;
12class CalendarView;
13class KSyncProfile;
14#ifdef DESKTOP_VERSION
15
16#define QPEToolBar QToolBar
17#define QPEMenuBar QMenuBar
18#endif
19class QPEToolBar;
20
21namespace KCal {
22class CalendarLocal;
23}
24
25using namespace KCal;
26
27class MainWindow : public QMainWindow
28{
29 Q_OBJECT
30 public:
31 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
32 ~MainWindow();
33 public slots:
34 void configureAgenda( int );
35 void recieve( const QCString& msg, const QByteArray& data );
36 static QString defaultFileName();
37 static QString resourcePath();
38 protected slots:
39 void setCaptionToDates();
40 int ringSync();
41 void multiSync( bool askforPrefs = false );
42 void about();
43 void faq();
44 void usertrans();
45 void features();
46 void synchowto();
47 void whatsNew();
48 void keyBindings();
49 void aboutAutoSaving();;
50 void aboutKnownBugs();
51
52 void processIncidenceSelection( Incidence * );
53
54 void importQtopia();
55 void importBday();
56 void importIcal();
57 void importFile( QString, bool );
58 void quickImportIcal();
59
60 void slotModifiedChanged( bool );
61
62 void save();
63 void configureToolBar( int );
64 void printSel();
65 void printCal();
66 void saveCalendar();
67 void loadCalendar();
68 void exportVCalendar();
69
70 void slotSyncMenu( int );
71 void syncSSH();
72 void confSync();
73 void syncSharp();
74 void syncLocalFile();
75 bool syncWithFile( QString, bool );
76 void quickSyncLocalFile();
77
78
79 protected:
80 void displayText( QString, QString);
81 void displayFile( QString, QString);
82
83 void enableIncidenceActions( bool );
84
85 private:
86 void saveOnClose();
87 int mCurrentSyncProfile;
88 void syncRemote( KSyncProfile* , bool ask = true);
89 void fillSyncMenu();
90 bool mFlagKeyPressed;
91 bool mBlockAtStartup;
92 QPEToolBar *iconToolBar;
93 void initActions();
94 void setDefaultPreferences();
95 void keyPressEvent ( QKeyEvent * ) ;
96 void keyReleaseEvent ( QKeyEvent * ) ;
97 QPopupMenu *configureToolBarMenu;
98 QPopupMenu *configureAgendaMenu, *syncMenu;
99 CalendarLocal *mCalendar;
100 CalendarView *mView;
101 QString getPassword();
102 QAction *mNewSubTodoAction;
103
104 QAction *mShowAction;
105 QAction *mEditAction;
106 QAction *mDeleteAction;
107 void closeEvent( QCloseEvent* ce );
108 SimpleAlarmClient mAlarmClient;
109 QTimer mSaveTimer;
110 bool mBlockSaveFlag;
111 bool mCalendarModifiedFlag;
112 QPixmap loadPixmap( QString );
113};
114
115#endif
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
new file mode 100644
index 0000000..1052a99
--- a/dev/null
+++ b/korganizer/navigatorbar.cpp
@@ -0,0 +1,199 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24
25#include <qstring.h>
26#include <qtooltip.h>
27#include <qpushbutton.h>
28#include <qlayout.h>
29#include <qframe.h>
30#include <qlabel.h>
31#include <qapplication.h>
32
33#include <kdebug.h>
34#include <klocale.h>
35#include <kglobal.h>
36#include <kiconloader.h>
37#include "libkdepim/kdatepicker.h"
38#include <knotifyclient.h>
39#include "kdatetbl.h"
40
41#include "koglobals.h"
42#include "koprefs.h"
43#ifndef KORG_NOPLUGINS
44#include "kocore.h"
45#endif
46
47#include <kcalendarsystem.h>
48
49#include "navigatorbar.h"
50
51NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
52 : QWidget( parent, name )
53{
54 QBoxLayout *topLayout = new QHBoxLayout( this );
55
56 // Set up the control buttons and date label
57 mCtrlFrame = new QFrame( this );
58 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
59 mCtrlFrame->setLineWidth(1);
60
61 topLayout->addWidget( mCtrlFrame );
62
63 QFont tfont = font();
64 if ( QApplication::desktop()->width() >= 480 )
65 tfont.setPointSize(tfont.pointSize()+2);
66 tfont.setBold(true);
67
68 bool isRTL = KOGlobals::self()->reverseLayout();
69#ifndef DESKTOP_VERSION
70 bool isDesktop = false;
71#else
72 bool isDesktop = true;
73#endif
74 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
75 isDesktop = true;
76 // Create backward navigation buttons
77 mPrevYear = new QPushButton( mCtrlFrame );
78 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
79 QToolTip::add( mPrevYear, i18n("Previous Year") );
80
81 mPrevMonth = new QPushButton( mCtrlFrame );
82 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
83 QToolTip::add( mPrevMonth, i18n("Previous Month") );
84
85 // Create forward navigation buttons
86 mNextMonth = new QPushButton( mCtrlFrame );
87 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
88 QToolTip::add( mNextMonth, i18n("Next Month") );
89
90 mNextYear = new QPushButton( mCtrlFrame );
91 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
92 QToolTip::add( mNextYear, i18n("Next Year") );
93 mSelectMonth = new QPushButton( mCtrlFrame );
94 // Create month name label
95 //selectMonth->setFont( tfont );
96 // selectMonth->setAlignment( AlignCenter );
97 //mDateLabel = new QLabel( selectMonth );
98 //mDateLabel->setFont( tfont );
99 //mDateLabel->setAlignment( AlignCenter );
100 if ( QString ( name ) == QString("useBigPixmaps") ) {
101 mNextMonth->setFlat( true);
102 mNextYear->setFlat( true);
103 mSelectMonth->setFlat( true);
104 mPrevYear->setFlat( true);
105 mPrevMonth->setFlat( true);
106 }
107 mSelectMonth->setFont( tfont );
108 // Set minimum width to width of widest month name label
109 int i;
110 int maxwidth = 0;
111 QFontMetrics fm ( mSelectMonth->font() );
112 int width = fm.width("September '00" );
113// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
114// ++i ) {
115// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
116// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
117// int width = fm.width("September 2000" );
118// if ( width > maxwidth ) maxwidth = width;
119// }
120 maxwidth = width+2;
121 int size = fm.height()+2;
122 if ( QApplication::desktop()->width() >= 480 ) {
123 size += 6;
124 maxwidth+= 6;
125 }
126 mSelectMonth->setFixedWidth( maxwidth );
127 mSelectMonth->setFixedHeight( size );
128 mPrevYear->setFixedHeight( size );
129 mPrevMonth->setFixedHeight( size );
130 mNextMonth->setFixedHeight( size );
131 mNextYear->setFixedHeight ( size );
132 // set up control frame layout
133 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
134 ctrlLayout->addWidget( mPrevYear, 3 );
135 ctrlLayout->addWidget( mPrevMonth, 3 );
136 //ctrlLayout->addStretch( 1 );
137 // ctrlLayout->addSpacing( 1 );
138 // ctrlLayout->addWidget( mDateLabel );
139 ctrlLayout->addWidget( mSelectMonth );
140 // ctrlLayout->addSpacing( 1 );
141 // ctrlLayout->addStretch( 1 );
142 ctrlLayout->addWidget( mNextMonth, 3 );
143 ctrlLayout->addWidget( mNextYear, 3 );
144
145 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
146 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
147 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
148 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
149 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
150 mPrevYear->setFocusPolicy(NoFocus);
151 mPrevMonth->setFocusPolicy(NoFocus);
152 mNextMonth->setFocusPolicy(NoFocus);
153 mNextYear->setFocusPolicy(NoFocus);
154 mSelectMonth->setFocusPolicy(NoFocus);
155}
156
157NavigatorBar::~NavigatorBar()
158{
159}
160
161void NavigatorBar::selectMonth()
162{
163
164 int month;
165 KPopupFrame* popup = new KPopupFrame(this);
166 int size = 12;
167 if ( QApplication::desktop()->width() >= 480 )
168 size = 18;
169 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup);
170 // -----
171 picker->resize(picker->sizeHint());
172 popup->setMainWidget(picker);
173 picker->setFocus();
174 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
175 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
176 {
177 month = picker->getResult();
178 emit monthSelected ( month );
179 } else {
180 KNotifyClient::beep();
181 }
182 delete popup;
183}
184void NavigatorBar::selectDates( const KCal::DateList &dateList )
185{
186 if (dateList.count() > 0) {
187 QDate date = dateList.first();
188
189 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
190
191 // compute the label at the top of the navigator
192 QString dtstr = i18n(calSys->monthName( date )) + " '" +
193 QString::number( calSys->year( date ) ).right(2);
194
195 mSelectMonth->setText( dtstr );
196 }
197}
198
199#include "navigatorbar.moc"
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h
new file mode 100644
index 0000000..9c5c0cf
--- a/dev/null
+++ b/korganizer/navigatorbar.h
@@ -0,0 +1,66 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef NAVIGATORBAR_H
25#define NAVIGATORBAR_H
26
27#include <libkcal/incidencebase.h>
28
29#include <qwidget.h>
30
31class QPushButton;
32class QFrame;
33class QLabel;
34
35class NavigatorBar: public QWidget
36{
37 Q_OBJECT
38 public:
39 NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 );
40 ~NavigatorBar();
41
42 public slots:
43 void selectDates( const KCal::DateList & );
44 void selectMonth();
45
46 signals:
47 void goNextMonth();
48 void goPrevMonth();
49 void goNextYear();
50 void goPrevYear();
51 void monthSelected( int );
52
53
54 private:
55 QFrame *mCtrlFrame;
56
57 QPushButton *mPrevYear;
58 QPushButton *mPrevMonth;
59 QPushButton *mNextMonth;
60 QPushButton *mNextYear;
61 QPushButton *mSelectMonth;
62
63 //QLabel *mDateLabel;
64};
65
66#endif
diff --git a/korganizer/navigatorbar.moc b/korganizer/navigatorbar.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/navigatorbar.moc
diff --git a/korganizer/outgoingdialog.cpp b/korganizer/outgoingdialog.cpp
new file mode 100644
index 0000000..4eb64f3
--- a/dev/null
+++ b/korganizer/outgoingdialog.cpp
@@ -0,0 +1,394 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <kdebug.h>
21
22#include <qfile.h>
23#include <qdir.h>
24#include <qtextstream.h>
25
26#include <kglobal.h>
27#include <klocale.h>
28#include <ktempfile.h>
29#include <kstandarddirs.h>
30
31#include <libkcal/event.h>
32#include <libkcal/freebusy.h>
33//#include <libkcal/imipscheduler.h>
34#include <libkcal/dummyscheduler.h>
35#include <libkcal/icalformat.h>
36#include <libkcal/calendar.h>
37
38#ifndef KORG_NOMAIL
39#include "mailscheduler.h"
40#endif
41
42#include "koprefs.h"
43#include "outgoingdialog.h"
44#include "koeventviewerdialog.h"
45#include "docprefs.h"
46
47ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev,
48 Scheduler::Method method,
49 const QString &recipients)
50 : QListViewItem(parent)
51{
52 mIncidence = ev;
53 mMethod = method;
54 mRecipients = recipients;
55
56// kdDebug() << "ScheduleItemOut: setting the summary" << endl;
57 //Set the summary
58 if(ev->type() != "FreeBusy") {
59 Incidence *incidence = static_cast<Incidence *>(ev);
60 setText(0,incidence->summary());
61 } else {
62 setText(0,i18n("Free Busy Object"));
63 }
64
65// kdDebug() << "ScheduleItemOut: checking if the object is an event" << endl;
66 //If the object is an event
67 if(ev->type()=="Event") {
68 Event *event = static_cast<Event *>(ev);
69
70 setText(1,event->dtStartDateStr());
71 if (event->doesFloat()) { //If the event floats set the start and end times to no time
72 setText(2,i18n("no time"));
73 setText(4,i18n("no time"));
74 } else { //If it does not float
75 setText(2,event->dtStartTimeStr());
76 if (event->hasDuration()) {
77 setText(4,event->dtEndTimeStr());
78 } else {
79 setText(4,i18n("no time"));
80 }
81 }
82 if (event->hasEndDate()) {
83 setText(3,event->dtEndDateStr());
84 }
85 else {
86 setText(3,i18n("no time"));
87 }
88 }
89
90 //If the object is an Todo
91 if(ev->type()=="Todo") {
92 Todo *event = static_cast<Todo *>(ev);
93 if (event->hasStartDate()) {
94 setText(1,event->dtStartDateStr());
95 if (!event->doesFloat()) {
96 setText(2,event->dtStartTimeStr());
97 }
98 }
99 if (event->hasDueDate()) {
100 setText(3,event->dtDueDateStr());
101 if (!event->doesFloat()) {
102 setText(4,event->dtDueTimeStr());
103 }
104 }
105 }
106
107// kdDebug() << "ScheduleItemOut: checking if the object is a FreeBusy object" << endl;
108 //If the object is a freebusy object
109 if(ev->type() == "FreeBusy") {
110 FreeBusy *freebusy = static_cast<FreeBusy *>(ev);
111
112 setText(1,freebusy->dtStartDateStr());
113 setText(2,freebusy->dtStartTimeStr());
114 //Must try and get this to the users local settings
115 setText(3,KGlobal::locale()->formatDate( freebusy->dtEnd().date() ) );
116 setText(4,KGlobal::locale()->formatTime( freebusy->dtEnd().time() ) );
117 }
118
119// kdDebug() << "ScheduleItemOut: Setting the method" << endl;
120 //Set the Method
121 setText(5,Scheduler::translatedMethodName(mMethod));
122}
123
124OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent,
125 const char* name,bool modal,
126 WFlags fl)
127 : OutgoingDialog_base(parent,name,modal,fl)
128{
129 mCalendar = calendar;
130
131 mFormat = new ICalFormat;
132
133 if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) {
134 mScheduler = new DummyScheduler(mCalendar);
135 } else {
136#ifndef KORG_NOMAIL
137 mScheduler = new MailScheduler(mCalendar);
138#else
139 mScheduler = new DummyScheduler(mCalendar);
140#endif
141 }
142 mMessageListView->setColumnAlignment(1,AlignHCenter);
143 mMessageListView->setColumnAlignment(2,AlignHCenter);
144 mMessageListView->setColumnAlignment(3,AlignHCenter);
145 mMessageListView->setColumnAlignment(4,AlignHCenter);
146 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)),
147 this,SLOT(showEvent(QListViewItem *)));
148 mDocPrefs = new DocPrefs("groupschedule");
149 loadMessages();
150}
151
152OutgoingDialog::~OutgoingDialog()
153{
154 delete mDocPrefs;
155 delete mFormat;
156}
157
158bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method)
159{
160 kdDebug() << "Outgoing::addMessage" << "Method:" << method << endl;
161 if (method == Scheduler::Publish) return false;
162 if( mDocPrefs ) {
163 if (method != Scheduler::Cancel) {
164 mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true );
165 } else {
166 if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") )
167 return true;
168 }
169 }
170
171 if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) {
172 new ScheduleItemOut(mMessageListView,incidence,method);
173 saveMessage(incidence,method);
174 emit numMessagesChanged(mMessageListView->childCount());
175 }
176 else {
177 mScheduler->performTransaction(incidence,method);
178 }
179 return true;
180}
181
182bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method,
183 const QString &recipients)
184{
185 //if (method != Scheduler::Publish) return false;
186 if( mDocPrefs ) {
187 if (method != Scheduler::Cancel) {
188 mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true );
189 } else {
190 if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") )
191 return true;
192 }
193 }
194 if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) {
195 new ScheduleItemOut(mMessageListView,incidence,method,recipients);
196 saveMessage(incidence,method,recipients);
197 emit numMessagesChanged(mMessageListView->childCount());
198 }
199 else {
200 mScheduler->performTransaction(incidence,method,recipients);
201 }
202 return true;
203}
204
205void OutgoingDialog::send()
206{
207 kdDebug() << "OutgoingDialog::send" << endl;
208 ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild());
209 while(item) {
210 bool success;
211 if (item->method() == Scheduler::Publish) {
212 success = mScheduler->publish(item->event(),item->recipients());
213 } else {
214 success = mScheduler->performTransaction(item->event(),item->method());
215 }
216 ScheduleItemOut *oldItem = item;
217 item = (ScheduleItemOut *)(item->nextSibling());
218 if (success) {
219 deleteMessage(oldItem->event());
220 delete (oldItem->event());
221 delete oldItem;
222 }
223 }
224
225 emit numMessagesChanged(mMessageListView->childCount());
226}
227
228void OutgoingDialog::deleteItem()
229{
230 ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->selectedItem());
231 if(!item)
232 return;
233 deleteMessage(item->event());
234 delete(item->event());
235 mMessageListView->takeItem(item);
236 emit numMessagesChanged(mMessageListView->childCount());
237}
238
239void OutgoingDialog::showEvent(QListViewItem *qitem)
240{
241 ScheduleItemOut *item = (ScheduleItemOut *)qitem;
242 Event *event = 0;
243 Todo *todo = 0;
244 if ( item->event()->type()=="Event" ) {
245 event = static_cast<Event *>(item->event());
246 }
247 if ( item->event()->type()=="Todo" ) {
248 todo = static_cast<Todo *>(item->event());
249 }
250 QString sendText;
251 if (event || todo) {
252 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this);
253 if (event) eventViewer->setEvent(event);
254 if (todo) eventViewer->setTodo(todo);
255 sendText = "<hr><h4>"+i18n("Event will be sent to:")+"</h4>";
256 switch (item->method()) {
257 case Scheduler::Publish: {
258 sendText += item->recipients();
259 break; }
260 case Scheduler::Request: {
261 sendText += i18n("All attendees");
262 break; }
263 case Scheduler::Refresh: {
264 sendText += i18n("All attendees");
265 break; }
266 case Scheduler::Cancel: {
267 sendText += i18n("All attendees");
268 break; }
269 case Scheduler::Add: {
270 sendText += i18n("All attendees");
271 break; }
272 case Scheduler::Reply: {
273 sendText += i18n("The organizer %1").arg(item->event()->organizer());
274 break; }
275 case Scheduler::Counter: {
276 sendText += i18n("The organizer %1").arg(item->event()->organizer());
277 break; }
278 case Scheduler::Declinecounter: {
279 sendText += i18n("All attendees");
280 break; }
281 case Scheduler::NoMethod: {
282 sendText += "";
283 break; }
284 default:
285 sendText = "";
286 }
287 eventViewer->addText(sendText);
288 eventViewer->show();
289 }
290}
291
292bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method,
293 const QString &recipients)
294{
295 KTempFile ktfile(locateLocal("data","korganizer/outgoing/"),"ics");
296 QString messageText = mFormat->createScheduleMessage(incidence,method);
297 QTextStream *qts = ktfile.textStream();
298 *qts << messageText;
299 *qts << "METHOD-BEGIN:" << endl << method << endl << ":METHOD-END" << endl;
300 *qts << "RECIPIENTS-BEGIN:" << endl << recipients << endl << ":RECIPIENTS-END" << endl;
301 mMessageMap[incidence]=ktfile.name();
302
303 return true;
304}
305
306bool OutgoingDialog::deleteMessage(IncidenceBase *incidence)
307{
308 QFile f( mMessageMap[incidence] );
309 mMessageMap.remove(incidence);
310 if ( !f.exists() ) return false;
311 else
312 return f.remove();
313}
314
315void OutgoingDialog::loadMessages()
316{
317 Scheduler::Method method;
318 QString recipients;
319
320 QString outgoingDirName = locateLocal("data","korganizer/outgoing");
321 QDir outgoingDir(outgoingDirName);
322 QStringList outgoing = outgoingDir.entryList(QDir::Files);
323 QStringList::ConstIterator it;
324 for(it = outgoing.begin(); it != outgoing.end(); ++it) {
325 kdDebug() << "-- File: " << (*it) << endl;
326 QFile f(outgoingDirName + "/" + (*it));
327 bool inserted = false;
328 QMap<IncidenceBase*, QString>::Iterator iter;
329 for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) {
330 if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true;
331 }
332 if (!inserted) {
333 if (!f.open(IO_ReadOnly)) {
334 kdDebug() << "OutgoingDialog::loadMessage(): Can't open file'"
335 << (*it) << "'" << endl;
336 } else {
337 QTextStream t(&f);
338 QString messageString = t.read();
339 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar,
340 messageString);
341 int begin_pos = messageString.find("METHOD-BEGIN:");
342 begin_pos = messageString.find('\n',begin_pos)+1;
343 QString meth = messageString.mid(begin_pos,1);
344 switch (meth.toInt()) {
345 case 0:method=Scheduler::Publish; break;
346 case 1:method=Scheduler::Request; break;
347 case 2:method=Scheduler::Refresh; break;
348 case 3:method=Scheduler::Cancel; break;
349 case 4:method=Scheduler::Add; break;
350 case 5:method=Scheduler::Reply; break;
351 case 6:method=Scheduler::Counter; break;
352 case 7:method=Scheduler::Declinecounter; break;
353 default :method=Scheduler::NoMethod; break;
354 }
355 begin_pos = messageString.find("RECIPIENTS-BEGIN:");
356 begin_pos = messageString.find('\n',begin_pos)+1;
357 int end_pos = messageString.find(":RECIPIENTS-END",begin_pos)-1;
358 recipients = messageString.mid(begin_pos, end_pos-begin_pos);
359 kdDebug() << "Outgoing::loadMessage(): Recipients: " << recipients << endl;
360
361 if (message) {
362 bool inserted = false;
363 QMap<IncidenceBase*, QString>::Iterator iter;
364 for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) {
365 if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true;
366 }
367 if (!inserted) {
368 kdDebug() << "OutgoingDialog::loadMessage(): got message '"
369 << (*it) << "'" << endl;
370 IncidenceBase *inc = message->event();
371 new ScheduleItemOut(mMessageListView,inc,method,recipients);
372 mMessageMap[message->event()]=outgoingDirName + "/" + (*it);
373 }
374 } else {
375 QString errorMessage;
376 if (mFormat->exception()) {
377 errorMessage = mFormat->exception()->message();
378 }
379 kdDebug() << "OutgoingDialog::loadMessage(): Error parsing "
380 "message: " << errorMessage << endl;
381 }
382 f.close();
383 }
384 }
385 }
386 emit numMessagesChanged(mMessageListView->childCount());
387}
388
389void OutgoingDialog::setDocumentId( const QString &id )
390{
391 mDocPrefs->setDoc( id );
392}
393
394#include "outgoingdialog.moc"
diff --git a/korganizer/outgoingdialog.h b/korganizer/outgoingdialog.h
new file mode 100644
index 0000000..a3d561a
--- a/dev/null
+++ b/korganizer/outgoingdialog.h
@@ -0,0 +1,88 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef OUTGOINGDIALOG_H
24#define OUTGOINGDIALOG_H
25
26#include <qlistview.h>
27#include <qmap.h>
28#include <qstring.h>
29
30#include <libkcal/scheduler.h>
31
32#include "docprefs.h"
33#include "outgoingdialog_base.h"
34
35using namespace KCal;
36
37class ScheduleItemOut : public QListViewItem
38{
39 public:
40 ScheduleItemOut(QListView *parent,IncidenceBase *ev,
41 Scheduler::Method method, const QString &recipients=QString::null);
42 virtual ~ScheduleItemOut() {}
43
44 IncidenceBase *event() { return mIncidence; }
45 Scheduler::Method method() { return mMethod; }
46 QString recipients() { return mRecipients; }
47
48 private:
49 IncidenceBase *mIncidence;
50 Scheduler::Method mMethod;
51 QString mRecipients;
52};
53
54class OutgoingDialog : public OutgoingDialog_base
55{
56 Q_OBJECT
57 public:
58 OutgoingDialog(Calendar *,QWidget* parent=0,const char* name=0,
59 bool modal=false,WFlags fl=0);
60 ~OutgoingDialog();
61
62 bool addMessage(IncidenceBase *,Scheduler::Method);
63 bool addMessage(IncidenceBase *,Scheduler::Method,const QString &recipients);
64 void setDocumentId( const QString &id );
65
66 public slots:
67 void loadMessages();
68
69 signals:
70 void numMessagesChanged(int);
71
72 protected slots:
73 void send();
74 void deleteItem();
75 void showEvent(QListViewItem *);
76
77 private:
78 bool saveMessage(IncidenceBase *,Scheduler::Method,const QString &recipients=0);
79 bool deleteMessage(IncidenceBase *);
80
81 Calendar *mCalendar;
82 ICalFormat *mFormat;
83 Scheduler *mScheduler;
84 QMap<IncidenceBase*, QString> mMessageMap;
85 DocPrefs *mDocPrefs;
86};
87
88#endif // OUTGOINGDIALOG_H
diff --git a/korganizer/outgoingdialog.moc b/korganizer/outgoingdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/outgoingdialog.moc
diff --git a/korganizer/outgoingdialog_base.cpp b/korganizer/outgoingdialog_base.cpp
new file mode 100644
index 0000000..e5b913a
--- a/dev/null
+++ b/korganizer/outgoingdialog_base.cpp
@@ -0,0 +1,109 @@
1#include <klocale.h>
2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/outgoingdialog_base.ui'
4**
5** Created: Sat Mar 29 22:31:21 2003
6** by: The User Interface Compiler ()
7**
8** WARNING! All changes made in this file will be lost!
9****************************************************************************/
10
11#include "outgoingdialog_base.h"
12
13#include <qvariant.h>
14#include <qheader.h>
15#include <qlistview.h>
16#include <qpushbutton.h>
17#include <qlayout.h>
18#include <qtooltip.h>
19#include <qwhatsthis.h>
20
21/*
22 * Constructs a OutgoingDialog_base as a child of 'parent', with the
23 * name 'name' and widget flags set to 'f'.
24 *
25 * The dialog will by default be modeless, unless you set 'modal' to
26 * TRUE to construct a modal dialog.
27 */
28OutgoingDialog_base::OutgoingDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
29 : QDialog( parent, name, modal, fl )
30
31{
32 if ( !name )
33 setName( "OutgoingDialog_base" );
34 OutgoingDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "OutgoingDialog_baseLayout");
35
36 mMessageListView = new QListView( this, "mMessageListView" );
37 mMessageListView->addColumn( tr2i18n( "Summary" ) );
38 mMessageListView->addColumn( tr2i18n( "Start Date" ) );
39 mMessageListView->addColumn( tr2i18n( "Start Time" ) );
40 mMessageListView->addColumn( tr2i18n( "End Date" ) );
41 mMessageListView->addColumn( tr2i18n( "End Time" ) );
42 mMessageListView->addColumn( tr2i18n( "Method" ) );
43 mMessageListView->setFrameShape( QListView::StyledPanel );
44 mMessageListView->setFrameShadow( QListView::Sunken );
45 mMessageListView->setAllColumnsShowFocus( TRUE );
46
47 OutgoingDialog_baseLayout->addMultiCellWidget( mMessageListView, 0, 3, 0, 0 );
48
49 PushButton5 = new QPushButton( this, "PushButton5" );
50 PushButton5->setDefault( FALSE );
51
52 OutgoingDialog_baseLayout->addWidget( PushButton5, 0, 1 );
53
54 PushButton7 = new QPushButton( this, "PushButton7" );
55
56 OutgoingDialog_baseLayout->addWidget( PushButton7, 1, 1 );
57
58 PushButton6 = new QPushButton( this, "PushButton6" );
59 PushButton6->setDefault( TRUE );
60
61 OutgoingDialog_baseLayout->addWidget( PushButton6, 3, 1 );
62 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
63 OutgoingDialog_baseLayout->addItem( spacer, 2, 1 );
64 languageChange();
65 resize( QSize(582, 274).expandedTo(minimumSizeHint()) );
66
67 // signals and slots connections
68 connect( PushButton6, SIGNAL( clicked() ), this, SLOT( accept() ) );
69 connect( PushButton5, SIGNAL( clicked() ), this, SLOT( send() ) );
70 connect( PushButton7, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
71}
72
73/*
74 * Destroys the object and frees any allocated resources
75 */
76OutgoingDialog_base::~OutgoingDialog_base()
77{
78 // no need to delete child widgets, Qt does it all for us
79}
80
81/*
82 * Sets the strings of the subwidgets using the current
83 * language.
84 */
85void OutgoingDialog_base::languageChange()
86{
87 setCaption( tr2i18n( "Scheduler - Outgoing Messages" ) );
88 mMessageListView->header()->setLabel( 0, tr2i18n( "Summary" ) );
89 mMessageListView->header()->setLabel( 1, tr2i18n( "Start Date" ) );
90 mMessageListView->header()->setLabel( 2, tr2i18n( "Start Time" ) );
91 mMessageListView->header()->setLabel( 3, tr2i18n( "End Date" ) );
92 mMessageListView->header()->setLabel( 4, tr2i18n( "End Time" ) );
93 mMessageListView->header()->setLabel( 5, tr2i18n( "Method" ) );
94 PushButton5->setText( tr2i18n( "&Send Messages" ) );
95 PushButton7->setText( tr2i18n( "&Remove" ) );
96 PushButton6->setText( tr2i18n( "&Close" ) );
97}
98
99void OutgoingDialog_base::send()
100{
101 qWarning( "OutgoingDialog_base::send(): Not implemented yet" );
102}
103
104void OutgoingDialog_base::deleteItem()
105{
106 qWarning( "OutgoingDialog_base::deleteItem(): Not implemented yet" );
107}
108
109#include "outgoingdialog_base.moc"
diff --git a/korganizer/outgoingdialog_base.h b/korganizer/outgoingdialog_base.h
new file mode 100644
index 0000000..af71bb1
--- a/dev/null
+++ b/korganizer/outgoingdialog_base.h
@@ -0,0 +1,47 @@
1/****************************************************************************
2** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/outgoingdialog_base.ui'
3**
4** Created: Sat Mar 29 22:24:26 2003
5** by: The User Interface Compiler ()
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9
10#ifndef OUTGOINGDIALOG_BASE_H
11#define OUTGOINGDIALOG_BASE_H
12
13#include <qvariant.h>
14#include <qdialog.h>
15
16class QVBoxLayout;
17class QHBoxLayout;
18class QGridLayout;
19class QListView;
20class QListViewItem;
21class QPushButton;
22
23class OutgoingDialog_base : public QDialog
24{
25 Q_OBJECT
26
27public:
28 OutgoingDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
29 ~OutgoingDialog_base();
30
31 QListView* mMessageListView;
32 QPushButton* PushButton5;
33 QPushButton* PushButton7;
34 QPushButton* PushButton6;
35
36protected:
37 QGridLayout* OutgoingDialog_baseLayout;
38
39protected slots:
40 virtual void languageChange();
41
42 virtual void send();
43 virtual void deleteItem();
44
45};
46
47#endif // OUTGOINGDIALOG_BASE_H
diff --git a/korganizer/outgoingdialog_base.moc b/korganizer/outgoingdialog_base.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/outgoingdialog_base.moc
diff --git a/korganizer/publishdialog.cpp b/korganizer/publishdialog.cpp
new file mode 100644
index 0000000..176595a
--- a/dev/null
+++ b/korganizer/publishdialog.cpp
@@ -0,0 +1,152 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qlineedit.h>
25#include <kdebug.h>
26
27#include <kglobal.h>
28#include <klocale.h>
29#ifndef KORG_NOKABC
30#include <kabc/addresseedialog.h>
31#endif
32
33#include "koprefs.h"
34#include "publishdialog.h"
35
36PublishDialog::PublishDialog(QWidget* parent, const char* name,
37 bool modal, WFlags fl)
38 : PublishDialog_base(parent,name,modal,fl)
39{
40 setCaption(i18n("Select Addresses"));
41 mNameLineEdit->setEnabled(false);
42 mEmailLineEdit->setEnabled(false);
43 connect(mAddressListView,SIGNAL(selectionChanged(QListViewItem *)),
44 SLOT(updateInput()));
45}
46
47PublishDialog::~PublishDialog()
48{
49}
50
51void PublishDialog::addAttendee(Attendee *attendee)
52{
53 mNameLineEdit->setEnabled(true);
54 mEmailLineEdit->setEnabled(true);
55 QListViewItem *item = new QListViewItem(mAddressListView);
56 item->setText(0,attendee->name());
57 item->setText(1,attendee->email());
58 mAddressListView->insertItem(item);
59}
60
61QString PublishDialog::addresses()
62{
63 QString to = "";
64 QListViewItem *item;
65 int i, count;
66 count = mAddressListView->childCount();
67 for (i=0;i<count;i++) {
68 item = mAddressListView->firstChild();
69 mAddressListView->takeItem(item);
70 to += item->text(1);
71 if (i<count-1) {
72 to += ", ";
73 }
74 }
75 return to;
76}
77
78void PublishDialog::addItem()
79{
80 mNameLineEdit->setEnabled(true);
81 mEmailLineEdit->setEnabled(true);
82 QListViewItem *item = new QListViewItem(mAddressListView);
83 mAddressListView->insertItem(item);
84 mAddressListView->setSelected(item,true);
85 mNameLineEdit->setText(i18n("(EmptyName)"));
86 mEmailLineEdit->setText(i18n("(EmptyEmail)"));
87}
88
89void PublishDialog::removeItem()
90{
91 QListViewItem *item;
92 item = mAddressListView->selectedItem();
93 if (!item) return;
94 mAddressListView->takeItem(item);
95 item = mAddressListView->selectedItem();
96 if (!item) {
97 mNameLineEdit->setText("");
98 mEmailLineEdit->setText("");
99 mNameLineEdit->setEnabled(false);
100 mEmailLineEdit->setEnabled(false);
101 }
102 if (mAddressListView->childCount() == 0) {
103 mNameLineEdit->setEnabled(false);
104 mEmailLineEdit->setEnabled(false);
105 }
106}
107
108void PublishDialog::openAddressbook()
109{
110#ifndef KORG_NOKABC
111 KABC::Addressee::List addressList;
112 addressList = KABC::AddresseeDialog::getAddressees(this);
113 //KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
114 KABC::Addressee a = addressList.first();
115 if (!a.isEmpty()) {
116 uint i;
117 for (i=0;i<addressList.count();i++) {
118 a = addressList[i];
119 mNameLineEdit->setEnabled(true);
120 mEmailLineEdit->setEnabled(true);
121 QListViewItem *item = new QListViewItem(mAddressListView);
122 mAddressListView->setSelected(item,true);
123 mNameLineEdit->setText(a.realName());
124 mEmailLineEdit->setText(a.preferredEmail());
125 mAddressListView->insertItem(item);
126 }
127 }
128#endif
129}
130
131void PublishDialog::updateItem()
132{
133 QListViewItem *item;
134 item = mAddressListView->selectedItem();
135 if (!item) return;
136 item->setText(0,mNameLineEdit->text());
137 item->setText(1,mEmailLineEdit->text());
138}
139
140void PublishDialog::updateInput()
141{
142 QListViewItem *item;
143 item = mAddressListView->selectedItem();
144 if (!item) return;
145 mNameLineEdit->setEnabled(true);
146 mEmailLineEdit->setEnabled(true);
147 QString mail = item->text(1);
148 mNameLineEdit->setText(item->text(0));
149 mEmailLineEdit->setText(mail);
150}
151
152#include "publishdialog.moc"
diff --git a/korganizer/publishdialog.h b/korganizer/publishdialog.h
new file mode 100644
index 0000000..338603c
--- a/dev/null
+++ b/korganizer/publishdialog.h
@@ -0,0 +1,55 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef PUBLISHDIALOG_H
24#define PUBLISHDIALOG_H
25
26#include <qlistview.h>
27#include <libkcal/attendee.h>
28
29#include "publishdialog_base.h"
30
31using namespace KCal;
32
33class PublishDialog : public PublishDialog_base
34{
35 Q_OBJECT
36 public:
37 PublishDialog(QWidget* parent=0,const char* name=0,
38 bool modal=true,WFlags fl=0);
39 ~PublishDialog();
40
41 void addAttendee(Attendee *attendee);
42 QString addresses();
43
44 signals:
45 void numMessagesChanged(int);
46
47 protected slots:
48 void addItem();
49 void removeItem();
50 void openAddressbook();
51 void updateItem();
52 void updateInput();
53};
54
55#endif // OUTGOINGDIALOG_H
diff --git a/korganizer/publishdialog.moc b/korganizer/publishdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/publishdialog.moc
diff --git a/korganizer/publishdialog_base.cpp b/korganizer/publishdialog_base.cpp
new file mode 100644
index 0000000..75e4746
--- a/dev/null
+++ b/korganizer/publishdialog_base.cpp
@@ -0,0 +1,162 @@
1#include <klocale.h>
2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/publishdialog_base.ui'
4**
5** Created: Sat Mar 29 22:31:35 2003
6** by: The User Interface Compiler ()
7**
8** WARNING! All changes made in this file will be lost!
9****************************************************************************/
10
11#include "publishdialog_base.h"
12
13#include <qvariant.h>
14#include <qframe.h>
15#include <qheader.h>
16#include <qlabel.h>
17#include <qlineedit.h>
18#include <qlistview.h>
19#include <qpushbutton.h>
20#include <qlayout.h>
21#include <qtooltip.h>
22#include <qwhatsthis.h>
23
24/*
25 * Constructs a PublishDialog_base as a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'.
27 *
28 * The dialog will by default be modeless, unless you set 'modal' to
29 * TRUE to construct a modal dialog.
30 */
31PublishDialog_base::PublishDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
32 : QDialog( parent, name, modal, fl )
33
34{
35 if ( !name )
36 setName( "PublishDialog_base" );
37 PublishDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "PublishDialog_baseLayout");
38
39 mAddressListView = new QListView( this, "mAddressListView" );
40 mAddressListView->addColumn( tr2i18n( "Name" ) );
41 mAddressListView->addColumn( tr2i18n( "Email" ) );
42
43 PublishDialog_baseLayout->addMultiCellWidget( mAddressListView, 0, 3, 0, 1 );
44
45 TextLabel1 = new QLabel( this, "TextLabel1" );
46
47 PublishDialog_baseLayout->addWidget( TextLabel1, 4, 0 );
48
49 TextLabel2 = new QLabel( this, "TextLabel2" );
50
51 PublishDialog_baseLayout->addWidget( TextLabel2, 5, 0 );
52
53 mEmailLineEdit = new QLineEdit( this, "mEmailLineEdit" );
54
55 PublishDialog_baseLayout->addWidget( mEmailLineEdit, 5, 1 );
56
57 mNameLineEdit = new QLineEdit( this, "mNameLineEdit" );
58
59 PublishDialog_baseLayout->addWidget( mNameLineEdit, 4, 1 );
60
61 PushButton10 = new QPushButton( this, "PushButton10" );
62
63 PublishDialog_baseLayout->addWidget( PushButton10, 0, 2 );
64
65 PushButton12 = new QPushButton( this, "PushButton12" );
66
67 PublishDialog_baseLayout->addWidget( PushButton12, 2, 2 );
68
69 PushButton11 = new QPushButton( this, "PushButton11" );
70
71 PublishDialog_baseLayout->addWidget( PushButton11, 1, 2 );
72 QSpacerItem* spacer = new QSpacerItem( 20, 241, QSizePolicy::Minimum, QSizePolicy::Expanding );
73 PublishDialog_baseLayout->addMultiCell( spacer, 3, 5, 2, 2 );
74
75 Line2 = new QFrame( this, "Line2" );
76 Line2->setFrameShape( QFrame::HLine );
77 Line2->setFrameShadow( QFrame::Sunken );
78 Line2->setFrameShape( QFrame::HLine );
79
80 PublishDialog_baseLayout->addMultiCellWidget( Line2, 6, 6, 0, 2 );
81
82 layout95 = new QHBoxLayout( 0, 0, 6, "layout95");
83 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
84 layout95->addItem( spacer_2 );
85
86 PushButton9 = new QPushButton( this, "PushButton9" );
87 PushButton9->setDefault( TRUE );
88 layout95->addWidget( PushButton9 );
89
90 PushButton8 = new QPushButton( this, "PushButton8" );
91 layout95->addWidget( PushButton8 );
92
93 PublishDialog_baseLayout->addMultiCellLayout( layout95, 7, 7, 0, 2 );
94 languageChange();
95 resize( QSize(420, 379).expandedTo(minimumSizeHint()) );
96
97 // signals and slots connections
98 connect( PushButton10, SIGNAL( clicked() ), this, SLOT( addItem() ) );
99 connect( PushButton11, SIGNAL( clicked() ), this, SLOT( removeItem() ) );
100 connect( PushButton12, SIGNAL( clicked() ), this, SLOT( openAddressbook() ) );
101 connect( PushButton9, SIGNAL( clicked() ), this, SLOT( accept() ) );
102 connect( mNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( updateItem() ) );
103 connect( mEmailLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( updateItem() ) );
104 connect( PushButton8, SIGNAL( clicked() ), this, SLOT( reject() ) );
105
106 // tab order
107 setTabOrder( mAddressListView, mNameLineEdit );
108 setTabOrder( mNameLineEdit, mEmailLineEdit );
109 setTabOrder( mEmailLineEdit, PushButton10 );
110 setTabOrder( PushButton10, PushButton11 );
111 setTabOrder( PushButton11, PushButton12 );
112 setTabOrder( PushButton12, PushButton9 );
113 setTabOrder( PushButton9, PushButton8 );
114}
115
116/*
117 * Destroys the object and frees any allocated resources
118 */
119PublishDialog_base::~PublishDialog_base()
120{
121 // no need to delete child widgets, Qt does it all for us
122}
123
124/*
125 * Sets the strings of the subwidgets using the current
126 * language.
127 */
128void PublishDialog_base::languageChange()
129{
130 setCaption( tr2i18n( "Form1" ) );
131 mAddressListView->header()->setLabel( 0, tr2i18n( "Name" ) );
132 mAddressListView->header()->setLabel( 1, tr2i18n( "Email" ) );
133 TextLabel1->setText( tr2i18n( "Name:" ) );
134 TextLabel2->setText( tr2i18n( "Email:" ) );
135 PushButton10->setText( tr2i18n( "&New" ) );
136 PushButton12->setText( tr2i18n( "&Addressbook" ) );
137 PushButton11->setText( tr2i18n( "&Remove" ) );
138 PushButton9->setText( tr2i18n( "&OK" ) );
139 PushButton8->setText( tr2i18n( "&Cancel" ) );
140}
141
142void PublishDialog_base::addItem()
143{
144 qWarning( "PublishDialog_base::addItem(): Not implemented yet" );
145}
146
147void PublishDialog_base::removeItem()
148{
149 qWarning( "PublishDialog_base::removeItem(): Not implemented yet" );
150}
151
152void PublishDialog_base::openAddressbook()
153{
154 qWarning( "PublishDialog_base::openAddressbook(): Not implemented yet" );
155}
156
157void PublishDialog_base::updateItem()
158{
159 qWarning( "PublishDialog_base::updateItem(): Not implemented yet" );
160}
161
162#include "publishdialog_base.moc"
diff --git a/korganizer/publishdialog_base.h b/korganizer/publishdialog_base.h
new file mode 100644
index 0000000..932474e
--- a/dev/null
+++ b/korganizer/publishdialog_base.h
@@ -0,0 +1,60 @@
1/****************************************************************************
2** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/publishdialog_base.ui'
3**
4** Created: Sat Mar 29 22:24:27 2003
5** by: The User Interface Compiler ()
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9
10#ifndef PUBLISHDIALOG_BASE_H
11#define PUBLISHDIALOG_BASE_H
12
13#include <qvariant.h>
14#include <qdialog.h>
15
16class QVBoxLayout;
17class QHBoxLayout;
18class QGridLayout;
19class QFrame;
20class QLabel;
21class QLineEdit;
22class QListView;
23class QListViewItem;
24class QPushButton;
25
26class PublishDialog_base : public QDialog
27{
28 Q_OBJECT
29
30public:
31 PublishDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
32 ~PublishDialog_base();
33
34 QListView* mAddressListView;
35 QLabel* TextLabel1;
36 QLabel* TextLabel2;
37 QLineEdit* mEmailLineEdit;
38 QLineEdit* mNameLineEdit;
39 QPushButton* PushButton10;
40 QPushButton* PushButton12;
41 QPushButton* PushButton11;
42 QFrame* Line2;
43 QPushButton* PushButton9;
44 QPushButton* PushButton8;
45
46protected:
47 QGridLayout* PublishDialog_baseLayout;
48 QHBoxLayout* layout95;
49
50protected slots:
51 virtual void languageChange();
52
53 virtual void addItem();
54 virtual void removeItem();
55 virtual void openAddressbook();
56 virtual void updateItem();
57
58};
59
60#endif // PUBLISHDIALOG_BASE_H
diff --git a/korganizer/publishdialog_base.moc b/korganizer/publishdialog_base.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/publishdialog_base.moc
diff --git a/korganizer/resourceview.h b/korganizer/resourceview.h
new file mode 100644
index 0000000..0cac495
--- a/dev/null
+++ b/korganizer/resourceview.h
@@ -0,0 +1,8 @@
1#ifndef MICRO_KORG_RESOURCEVIEW_H
2#define MICRO_KORG_RESOURCEVIEW_H
3
4class ResourceView
5{
6};
7
8#endif
diff --git a/korganizer/savetemplatedialog.cpp b/korganizer/savetemplatedialog.cpp
new file mode 100644
index 0000000..0da524f
--- a/dev/null
+++ b/korganizer/savetemplatedialog.cpp
@@ -0,0 +1,76 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include <qlayout.h>
25
26#include <keditlistbox.h>
27#include <klocale.h>
28
29#include "koprefs.h"
30
31#include "savetemplatedialog.h"
32#include "savetemplatedialog.moc"
33
34SaveTemplateDialog::SaveTemplateDialog( IncidenceType type, QWidget *parent )
35 : KDialogBase( Plain, i18n("Save Template"), Ok | Cancel, Ok, parent, 0,
36 true, false ),
37 mType( type )
38{
39 QFrame *topFrame = plainPage();
40 QVBoxLayout *topLayout = new QVBoxLayout( topFrame, 0, spacingHint() );
41
42 mEditListBox = new KEditListBox( i18n("Select Template Name"), topFrame,
43 0, false, KEditListBox::Add |
44 KEditListBox::Remove );
45 topLayout->addWidget( mEditListBox );
46 connect( mEditListBox, SIGNAL( changed() ), SLOT( slotChanged() ) );
47
48 QStringList templates;
49
50 if ( mType == EventType ) {
51 templates = KOPrefs::instance()->mEventTemplates;
52 } else if( mType == TodoType ) {
53 templates = KOPrefs::instance()->mTodoTemplates;
54 }
55
56 mEditListBox->insertStringList( templates );
57}
58
59SaveTemplateDialog::~SaveTemplateDialog()
60{
61}
62
63void SaveTemplateDialog::slotOk()
64{
65 emit templateSelected( mEditListBox->currentText() );
66 accept();
67}
68
69void SaveTemplateDialog::slotChanged()
70{
71 if ( mType == EventType ) {
72 KOPrefs::instance()->mEventTemplates = mEditListBox->items();
73 } else if( mType == TodoType ) {
74 KOPrefs::instance()->mTodoTemplates = mEditListBox->items();
75 }
76}
diff --git a/korganizer/savetemplatedialog.h b/korganizer/savetemplatedialog.h
new file mode 100644
index 0000000..7e54bee
--- a/dev/null
+++ b/korganizer/savetemplatedialog.h
@@ -0,0 +1,53 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef SAVETEMPLATEDIALOG_H
24#define SAVETEMPLATEDIALOG_H
25
26#include <kdialogbase.h>
27
28class KEditListBox;
29
30class SaveTemplateDialog : public KDialogBase
31{
32 Q_OBJECT
33 public:
34 enum IncidenceType { EventType, TodoType };
35
36 SaveTemplateDialog( IncidenceType type, QWidget *parent = 0 );
37 virtual ~SaveTemplateDialog();
38
39 signals:
40 void templateSelected( const QString & );
41
42 protected slots:
43 void slotOk();
44
45 void slotChanged();
46
47 private:
48 IncidenceType mType;
49
50 KEditListBox *mEditListBox;
51};
52
53#endif
diff --git a/korganizer/savetemplatedialog.moc b/korganizer/savetemplatedialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/savetemplatedialog.moc
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
new file mode 100644
index 0000000..74d48b9
--- a/dev/null
+++ b/korganizer/searchdialog.cpp
@@ -0,0 +1,396 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24
25#include <qlayout.h>
26#include <qcheckbox.h>
27#include <qgroupbox.h>
28#include <qlabel.h>
29#include <qlineedit.h>
30#include <qpushbutton.h>
31
32#include <klocale.h>
33#include <kmessagebox.h>
34
35#include <libkdepim/kdateedit.h>
36
37#include "koglobals.h"
38#include "koprefs.h"
39
40#include "calendarview.h"
41#include "koviewmanager.h"
42#include "searchdialog.h"
43#include "searchdialog.moc"
44
45SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
46 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false,
47 i18n("&Find"))
48{
49 mCalendar = calendar;
50 QFrame *topFrame = plainPage();
51 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint());
52
53 // Search expression
54 QHBoxLayout *subLayout = new QHBoxLayout();
55 layout->addLayout(subLayout);
56
57 searchLabel = new QLabel(topFrame);
58 searchLabel->setText(i18n("Search for:"));
59 subLayout->addWidget(searchLabel);
60
61 searchEdit = new QLineEdit(topFrame);
62 subLayout->addWidget(searchEdit);
63 searchEdit->setText("*"); // Find all events by default
64 searchEdit->setFocus();
65 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
66 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
67 // Subjects to search
68 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
69 // topFrame);
70
71
72
73 QHBox *incidenceGroup = new QHBox( topFrame );
74 layout->addWidget(incidenceGroup);
75
76 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
77 mSearchEvent->setChecked(true);
78 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
79 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
80
81 QHBox *subjectGroup = new QHBox( topFrame );
82 layout->addWidget(subjectGroup);
83
84 mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup);
85 mSummaryCheck->setChecked(true);
86 mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup);
87 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
88
89 QHBox *attendeeGroup = new QHBox( topFrame );
90 layout->addWidget(attendeeGroup );
91 new QLabel( i18n("Attendee:"),attendeeGroup );
92 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
93 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
94 // Date range
95 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
96 // topFrame);
97 // layout->addWidget(rangeGroup);
98
99 QWidget *rangeWidget = new QWidget(topFrame);
100 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint());
101
102 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
103 mStartDate = new KDateEdit(rangeWidget);
104 rangeLayout->addWidget(mStartDate);
105 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
106 mEndDate = new KDateEdit(rangeWidget);
107 mEndDate->setDate(QDate::currentDate().addDays(365));
108 rangeLayout->addWidget(mEndDate);
109
110 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame);
111 //mInclusiveCheck->setChecked(false);
112 layout->addWidget(rangeWidget);
113 //layout->addWidget(mInclusiveCheck);
114 // Subjects to search
115
116
117 // Results list view
118 listView = new KOListView(mCalendar,topFrame);
119 //listView->showDates();
120
121
122 layout->addWidget(listView);
123
124 // if ( KOPrefs::instance()->mCompactDialogs ) {
125 // KOGlobals::fitDialogToScreen( this, true );
126 // }
127
128 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
129 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch()));
130 QPushButton *CloseButton = findButton( Close );
131 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear()));
132
133#ifndef DESKTOP_VERSION
134 setCaption(i18n("Click OK to search ->"));
135 hideButtons();
136#endif
137}
138
139SearchDialog::~SearchDialog()
140{
141
142}
143void SearchDialog::accept()
144{
145 doSearch();
146}
147void SearchDialog::updateList()
148{
149 //listView->updateList();
150 if ( isVisible() ) {
151 updateView();
152 //qDebug("SearchDialog::updated ");
153 }
154 else {
155 listView->clear();
156 //qDebug("SearchDialog::cleared ");
157
158 }
159}
160void SearchDialog::searchTextChanged( const QString &_text )
161{
162 enableButton( KDialogBase::User1, !_text.isEmpty() );
163}
164
165void SearchDialog::doSearch()
166{
167 QRegExp re;
168
169 re.setWildcard(true); // most people understand these better.
170 re.setCaseSensitive(false);
171 re.setPattern(searchEdit->text());
172 if (!re.isValid() ) {
173 KMessageBox::sorry(this,
174 i18n("Invalid search expression,\ncannot perform "
175 "the search.\nPlease enter a search expression\n"
176 "using the wildcard characters\n '*' and '?'"
177 "where needed."));
178 return;
179 }
180
181 search(re);
182
183 listView->setStartDate( mStartDate->date() );
184 listView->showEvents(mMatchedEvents);
185 listView->addTodos(mMatchedTodos);
186 listView->addJournals(mMatchedJournals);
187
188 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
189 KMessageBox::information(this,
190 i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed."));
191#ifndef DESKTOP_VERSION
192 setCaption(i18n("Click OK to search ->"));
193#else
194 setCaption(i18n("KO/Pi Find "));
195#endif
196 } else {
197 QString mess;
198 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
199 setCaption( i18n("KO/Pi Find: ") + mess);
200
201 }
202}
203void SearchDialog::updateConfig()
204{
205 listView->updateConfig();
206}
207void SearchDialog::updateView()
208{
209
210 QRegExp re;
211 re.setWildcard(true); // most people understand these better.
212 re.setCaseSensitive(false);
213 re.setPattern(searchEdit->text());
214 if (re.isValid()) {
215 search(re);
216 } else {
217 mMatchedEvents.clear();
218 mMatchedTodos.clear();
219 mMatchedJournals.clear();
220 }
221 listView->setStartDate( mStartDate->date() );
222 listView->showEvents(mMatchedEvents);
223 listView->addTodos(mMatchedTodos);
224 listView->addJournals(mMatchedJournals);
225}
226
227void SearchDialog::search(const QRegExp &re)
228{
229 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
230 mEndDate->date(),
231 false /*mInclusiveCheck->isChecked()*/ );
232
233 mMatchedEvents.clear();
234 if ( mSearchEvent->isChecked() ) {
235 Event *ev;
236 for(ev=events.first();ev;ev=events.next()) {
237 if (mSummaryCheck->isChecked()) {
238#if QT_VERSION >= 300
239 if (re.search(ev->summary()) != -1)
240#else
241 if (re.match(ev->summary()) != -1)
242#endif
243 {
244 mMatchedEvents.append(ev);
245 continue;
246 }
247 }
248 if (mDescriptionCheck->isChecked()) {
249#if QT_VERSION >= 300
250 if (re.search(ev->description()) != -1)
251#else
252 if (re.match(ev->description()) != -1)
253#endif
254 {
255 mMatchedEvents.append(ev);
256 continue;
257 }
258 }
259 if (mCategoryCheck->isChecked()) {
260#if QT_VERSION >= 300
261 if (re.search(ev->categoriesStr()) != -1)
262#else
263 if (re.match(ev->categoriesStr()) != -1)
264#endif
265 {
266 mMatchedEvents.append(ev);
267 continue;
268 }
269 }
270 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
271 QPtrList<Attendee> tmpAList = ev->attendees();
272 Attendee *a;
273 for (a = tmpAList.first(); a; a = tmpAList.next()) {
274 if (mSearchAName->isChecked()) {
275#if QT_VERSION >= 300
276 if (re.search(a->name()) != -1)
277#else
278 if (re.match(a->name()) != -1)
279#endif
280 {
281 mMatchedEvents.append(ev);
282 break;
283 }
284 }
285 if (mSearchAEmail->isChecked()) {
286#if QT_VERSION >= 300
287 if (re.search(a->email()) != -1)
288#else
289 if (re.match(a->email()) != -1)
290#endif
291 {
292 mMatchedEvents.append(ev);
293 break;
294 }
295 }
296 }
297 }
298 }
299 }
300 QPtrList<Todo> todos = mCalendar->todos( );
301 mMatchedTodos.clear();
302 if ( mSearchTodo->isChecked() ) {
303 Todo *tod;
304 for(tod=todos.first();tod;tod=todos.next()) {
305 if (mSummaryCheck->isChecked()) {
306#if QT_VERSION >= 300
307 if (re.search(tod->summary()) != -1)
308#else
309 if (re.match(tod->summary()) != -1)
310#endif
311 {
312 mMatchedTodos.append(tod);
313 continue;
314 }
315 }
316 if (mDescriptionCheck->isChecked()) {
317#if QT_VERSION >= 300
318 if (re.search(tod->description()) != -1)
319#else
320 if (re.match(tod->description()) != -1)
321#endif
322 {
323 mMatchedTodos.append(tod);
324 continue;
325 }
326 }
327 if (mCategoryCheck->isChecked()) {
328#if QT_VERSION >= 300
329 if (re.search(tod->categoriesStr()) != -1)
330#else
331 if (re.match(tod->categoriesStr()) != -1)
332#endif
333 {
334 mMatchedTodos.append(tod);
335 continue;
336 }
337 }
338 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
339 QPtrList<Attendee> tmpAList = tod->attendees();
340 Attendee *a;
341 for (a = tmpAList.first(); a; a = tmpAList.next()) {
342 if (mSearchAName->isChecked()) {
343#if QT_VERSION >= 300
344 if (re.search(a->name()) != -1)
345#else
346 if (re.match(a->name()) != -1)
347#endif
348 {
349 mMatchedTodos.append(tod);
350 break;
351 }
352 }
353 if (mSearchAEmail->isChecked()) {
354#if QT_VERSION >= 300
355 if (re.search(a->email()) != -1)
356#else
357 if (re.match(a->email()) != -1)
358#endif
359 {
360 mMatchedTodos.append(tod);
361 break;
362 }
363 }
364 }
365 }
366 }
367 }
368 mMatchedJournals.clear();
369 if (mSearchJournal->isChecked() ) {
370 QPtrList<Journal> journals = mCalendar->journals( );
371 Journal* journ;
372
373 for(journ=journals.first();journ;journ=journals.next()) {
374 if ( journ->dtStart().date() <= mEndDate->date()
375 &&journ->dtStart().date() >= mStartDate->date()) {
376#if QT_VERSION >= 300
377 if (re.search(journ->description()) != -1)
378#else
379 if (re.match(journ->description()) != -1)
380#endif
381 {
382 mMatchedJournals.append(journ);
383 continue;
384 }
385 }
386 }
387 }
388
389}
390void SearchDialog::keyPressEvent ( QKeyEvent *e)
391{
392
393 e->ignore();
394
395}
396//mMatchedJournals;
diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h
new file mode 100644
index 0000000..a03c586
--- a/dev/null
+++ b/korganizer/searchdialog.h
@@ -0,0 +1,93 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
23*/
24#ifndef SEARCHDIALOG_H
25#define SEARCHDIALOG_H
26
27#include <qregexp.h>
28
29#include <kdialogbase.h>
30
31#include <libkcal/calendar.h>
32
33#include "kolistview.h"
34
35class KDateEdit;
36class QCheckBox;
37class QLineEdit;
38class QLabel;
39class CalendarView;
40
41using namespace KCal;
42
43class SearchDialog : public KDialogBase
44{
45 Q_OBJECT
46 public:
47 SearchDialog(Calendar *calendar,CalendarView *parent=0);
48 virtual ~SearchDialog();
49 KOListView *listview(){ return listView;}
50 void updateView();
51
52 public slots:
53 void changeEventDisplay(Event *, int) { updateView(); }
54 void updateConfig();
55 void updateList();
56 protected slots:
57 void accept();
58 void doSearch();
59 void searchTextChanged( const QString &_text );
60
61 signals:
62 void showEventSignal(Event *);
63 void editEventSignal(Event *);
64 void deleteEventSignal(Event *);
65
66 private:
67 void search(const QRegExp &);
68
69 Calendar *mCalendar;
70
71 QPtrList<Event> mMatchedEvents;
72 QPtrList<Todo> mMatchedTodos;
73 QPtrList<Journal> mMatchedJournals;
74
75 QLabel *searchLabel;
76 QLineEdit *searchEdit;
77 KOListView *listView;
78
79 KDateEdit *mStartDate;
80 KDateEdit *mEndDate;
81 // QCheckBox *mInclusiveCheck;
82 QCheckBox *mSummaryCheck;
83 QCheckBox *mDescriptionCheck;
84 QCheckBox *mCategoryCheck;
85 QCheckBox *mSearchEvent;
86 QCheckBox *mSearchTodo;
87 QCheckBox *mSearchJournal;
88 QCheckBox *mSearchAName;
89 QCheckBox *mSearchAEmail;
90 void keyPressEvent ( QKeyEvent *e) ;
91};
92
93#endif
diff --git a/korganizer/searchdialog.moc b/korganizer/searchdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/searchdialog.moc
diff --git a/korganizer/simplealarmclient.cpp b/korganizer/simplealarmclient.cpp
new file mode 100644
index 0000000..4882a27
--- a/dev/null
+++ b/korganizer/simplealarmclient.cpp
@@ -0,0 +1,111 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002,2003 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include "simplealarmclient.h"
25
26#include <kprocess.h>
27#include <kdebug.h>
28#include <kstandarddirs.h>
29
30#include <qfile.h>
31#include <qtextstream.h>
32
33SimpleAlarmClient::SimpleAlarmClient()
34 : mProcess( 0 )
35{
36 //mCalendarsFile = locateLocal( "data", "simplealarmdaemon/calendars" );
37
38
39}
40
41SimpleAlarmClient::~SimpleAlarmClient()
42{
43 delete mProcess;
44}
45
46void SimpleAlarmClient::startDaemon()
47{
48
49 qDebug("SimpleAlarmClient::startDaemon() ");
50 if ( !mProcess ) {
51 mProcess = new KProcess;
52 *mProcess << "simplealarmdaemon";
53 if ( !mProcess->start() ) {
54 kdDebug() << "Failed to start process." << endl;
55 }
56 }
57}
58
59bool SimpleAlarmClient::setCalendars( const QStringList &calendars )
60{
61
62
63 QFile f( mCalendarsFile );
64 if ( !f.open( IO_WriteOnly ) ) {
65 kdDebug() << "Unable to open file '" << mCalendarsFile << "'" << endl;
66 return false;
67 }
68 QTextStream ts( &f );
69 QStringList::ConstIterator it;
70 for ( it = calendars.begin(); it != calendars.end(); ++it ) {
71 kdDebug() << "CAL: " << *it << endl;
72 ts << *it << "\n";
73 }
74 f.close();
75
76 return true;
77}
78
79bool SimpleAlarmClient::addCalendar( const QString &calendar )
80{
81 QFile f( mCalendarsFile );
82 if ( !f.open( IO_WriteOnly | IO_Append ) ) return false;
83 QTextStream ts( &f );
84 ts << calendar << "\n";
85 f.close();
86
87 return true;
88}
89
90bool SimpleAlarmClient::removeCalendar( const QString &calendar )
91{
92 QStringList calendars;
93
94 QFile f( mCalendarsFile );
95 if ( !f.open( IO_ReadOnly ) ) return false;
96 QTextStream ts( &f );
97 bool found = false;
98 QString line;
99 while ( !( line = ts.readLine() ).isNull() ) {
100 if ( line != calendar ) calendars.append( line );
101 else found = true;
102 }
103
104 if ( found ) return setCalendars( calendars );
105 else return true;
106}
107
108bool SimpleAlarmClient::reloadCalendar( const QString & )
109{
110 return true;
111}
diff --git a/korganizer/simplealarmclient.h b/korganizer/simplealarmclient.h
new file mode 100644
index 0000000..6ad8d52
--- a/dev/null
+++ b/korganizer/simplealarmclient.h
@@ -0,0 +1,57 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef SIMPLEALARMCLIENT_H
24#define SIMPLEALARMCLIENT_H
25
26#include "alarmclient.h"
27
28class KProcess;
29
30/**
31 This class implements the client interface for the SimpleAlarmDaemon.
32*/
33class SimpleAlarmClient : public AlarmClient
34{
35 public:
36 SimpleAlarmClient();
37 virtual ~SimpleAlarmClient();
38
39 /**
40 Start alarm daemon.
41 */
42 void startDaemon();
43
44 bool setCalendars( const QStringList & );
45
46 bool addCalendar( const QString & );
47
48 bool removeCalendar( const QString & );
49
50 bool reloadCalendar( const QString & );
51
52 private:
53 QString mCalendarsFile;
54 KProcess *mProcess;
55};
56
57#endif
diff --git a/korganizer/statusdialog.cpp b/korganizer/statusdialog.cpp
new file mode 100644
index 0000000..78efeb0
--- a/dev/null
+++ b/korganizer/statusdialog.cpp
@@ -0,0 +1,67 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19
20#include <qlabel.h>
21#include <qpushbutton.h>
22#include <qstringlist.h>
23#include <qlayout.h>
24
25#include <kdebug.h>
26#include <klocale.h>
27
28#include "statusdialog.h"
29#include "statusdialog.moc"
30
31StatusDialog::StatusDialog(QWidget* parent, const char* name) :
32 KDialog(parent,name,true)
33{
34 setCaption(i18n("Set Your Status"));
35
36 QBoxLayout *topLayout = new QVBoxLayout( this );
37 topLayout->setSpacing( spacingHint() );
38 topLayout->setMargin( marginHint() );
39
40 QBoxLayout *statusLayout = new QHBoxLayout( topLayout );
41
42 QLabel *text = new QLabel(i18n("Set your status"),this);
43 statusLayout->addWidget( text );
44
45 mStatus = new QComboBox(false,this);
46 mStatus->insertStringList(Attendee::statusList());
47 statusLayout->addWidget( mStatus );
48
49 QBoxLayout *buttonLayout = new QHBoxLayout( topLayout );
50
51 QPushButton *ok = new QPushButton(i18n("&OK"), this);
52 connect ( ok,SIGNAL(clicked()), this,SLOT(accept()) );
53 buttonLayout->addWidget( ok );
54
55 QPushButton *cancel = new QPushButton(i18n("&Cancel"), this);
56 connect ( cancel,SIGNAL(clicked()), this,SLOT(reject()) );
57 buttonLayout->addWidget( cancel );
58}
59
60StatusDialog::~StatusDialog()
61{
62}
63
64Attendee::PartStat StatusDialog::status()
65{
66 return Attendee::PartStat( mStatus->currentItem() ) ;
67}
diff --git a/korganizer/statusdialog.h b/korganizer/statusdialog.h
new file mode 100644
index 0000000..be6b5e8
--- a/dev/null
+++ b/korganizer/statusdialog.h
@@ -0,0 +1,43 @@
1/*
2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/
19#ifndef STATUSDIALOG_H
20#define STATUSDIALOG_H
21
22#include <qcombobox.h>
23
24#include <kdialog.h>
25
26#include <libkcal/attendee.h>
27
28using namespace KCal;
29
30class StatusDialog : public KDialog
31{
32 Q_OBJECT
33 public:
34 StatusDialog(QWidget* parent=0,const char* name=0);
35 ~StatusDialog();
36
37 Attendee::PartStat status();
38
39 private:
40 QComboBox *mStatus;
41};
42
43#endif
diff --git a/korganizer/statusdialog.moc b/korganizer/statusdialog.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/statusdialog.moc
diff --git a/korganizer/timeline.cpp b/korganizer/timeline.cpp
new file mode 100644
index 0000000..6f9c8dd
--- a/dev/null
+++ b/korganizer/timeline.cpp
@@ -0,0 +1,63 @@
1#include <qpainter.h>
2
3#include <kdebug.h>
4
5#include "timeline.h"
6#include "timeline.moc"
7
8TimeLine::TimeLine( QWidget *parent, const char *name ) :
9 QScrollView( parent, name )
10{
11 mPixelWidth = 1000;
12
13 resizeContents( mPixelWidth, 20 );
14
15 viewport()->setBackgroundMode( PaletteBackground );
16
17 setHScrollBarMode(AlwaysOff);
18 setVScrollBarMode(AlwaysOff);
19}
20
21TimeLine::~TimeLine()
22{
23}
24
25void TimeLine::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
26{
27 int spacingX = mDaySpacing;
28 int offsetX = mDayOffset;
29
30 // Draw vertical lines of grid
31// kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl;
32 int cell = int( (cx - ( spacingX - offsetX ) ) / spacingX );
33 int x = cell * spacingX + ( spacingX - offsetX );
34// kdDebug() << " x: " << x << endl;
35 while (x < cx + cw) {
36// kdDebug() << " x: " << x << endl;
37 p->drawLine(x,cy,x,cy+ch);
38 p->drawText( x + 5, 15, QString::number( mStartDate.addDays( cell + 1 ).date().day() ) );
39
40 x += spacingX;
41 cell++;
42 }
43}
44
45void TimeLine::setDateRange( const QDateTime &start, const QDateTime &end )
46{
47 mStartDate = start;
48 mEndDate = end;
49
50 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mPixelWidth;
51
52 mDaySpacing = 60 * 60 * 24 / mSecsPerPixel;
53
54 mDayOffset = QDateTime( mStartDate.date() ).secsTo( mStartDate ) / mSecsPerPixel;
55
56 kdDebug() << "TimeLines::setDateRange(): mDaySpacing: " << mDaySpacing << " mDayOffset: "
57 << mDayOffset << " mSecsPerPixel: " << mSecsPerPixel << endl;
58}
59
60void TimeLine::setContentsPos( int pos )
61{
62 QScrollView::setContentsPos ( pos, 0 );
63}
diff --git a/korganizer/timeline.h b/korganizer/timeline.h
new file mode 100644
index 0000000..ab3e5d3
--- a/dev/null
+++ b/korganizer/timeline.h
@@ -0,0 +1,33 @@
1#ifndef TIMELINE_H
2#define TIMELINE_H
3
4#include <qscrollview.h>
5#include <qdatetime.h>
6
7class TimeLine : public QScrollView
8{
9 Q_OBJECT
10 public:
11 TimeLine( QWidget *parent = 0, const char *name = 0 );
12 virtual ~TimeLine();
13
14 void setDateRange( const QDateTime &start, const QDateTime &end );
15
16 public slots:
17 void setContentsPos( int pos );
18
19 protected:
20 void drawContents(QPainter* p, int cx, int cy, int cw, int ch);
21
22 private:
23 QDateTime mStartDate;
24 QDateTime mEndDate;
25
26 int mPixelWidth;
27 int mDaySpacing;
28 int mDayOffset;
29 int mSecsPerPixel;
30};
31
32#endif
33
diff --git a/korganizer/timeline.moc b/korganizer/timeline.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/timeline.moc
diff --git a/korganizer/timespanview.cpp b/korganizer/timespanview.cpp
new file mode 100644
index 0000000..f8314e7
--- a/dev/null
+++ b/korganizer/timespanview.cpp
@@ -0,0 +1,158 @@
1
2#ifndef DESKTOP_VERSION
3#include <qksplitter.h>
4#else
5#include <qsplitter.h>
6#endif
7#include <qlistview.h>
8#include <qlayout.h>
9#include <qheader.h>
10#include <qpushbutton.h>
11
12#include <klocale.h>
13#include <kdebug.h>
14
15#include "lineview.h"
16#include "timeline.h"
17
18#include "timespanview.h"
19#include "timespanview.moc"
20
21
22TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) :
23 QWidget( parent, name )
24{
25 QBoxLayout *topLayout = new QVBoxLayout( this );
26#ifndef DESKTOP_VERSION
27 mSplitter = new QKSplitter( this );
28#else
29 mSplitter = new QSplitter( this );
30#endif
31 topLayout->addWidget( mSplitter );
32
33 mList = new QListView( mSplitter );
34 mList->addColumn( i18n("Summary") );
35
36 QWidget *rightPane = new QWidget( mSplitter );
37 QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane );
38
39 mTimeLine = new TimeLine( rightPane );
40 mTimeLine->setFixedHeight( mList->header()->height() );
41 rightPaneLayout->addWidget( mTimeLine );
42
43 mLineView = new LineView( rightPane );
44 rightPaneLayout->addWidget( mLineView );
45
46 QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout );
47
48 QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane );
49 connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) );
50 buttonLayout->addWidget( zoomInButton );
51
52 QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane );
53 connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) );
54 buttonLayout->addWidget( zoomOutButton );
55
56 QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane );
57 connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) );
58 buttonLayout->addWidget( centerButton );
59
60 connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)),
61 mTimeLine,SLOT(setContentsPos(int)));
62}
63
64TimeSpanView::~TimeSpanView()
65{
66}
67
68QValueList<int> TimeSpanView::splitterSizes()
69{
70 return mSplitter->sizes();
71}
72
73void TimeSpanView::setSplitterSizes( QValueList<int> sizes )
74{
75 mSplitter->setSizes( sizes );
76}
77
78void TimeSpanView::addItem( KCal::Event *event )
79{
80 new QListViewItem( mList, event->summary() );
81
82 QDateTime startDt = event->dtStart();
83 QDateTime endDt = event->dtEnd();
84
85// kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString()
86// << " end: " << endDt.toString() << endl;
87
88 int startSecs = mStartDate.secsTo( startDt );
89 int durationSecs = startDt.secsTo( endDt );
90
91// kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl;
92
93 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel;
94 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel;
95
96// kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl;
97
98 mLineView->addLine( startX, endX );
99}
100
101void TimeSpanView::clear()
102{
103 mList->clear();
104 mLineView->clear();
105}
106
107void TimeSpanView::updateView()
108{
109#if QT_VERSION >= 300
110 mLineView->updateContents();
111 mTimeLine->updateContents();
112#else
113#endif
114}
115
116void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end )
117{
118 mStartDate = start;
119 mEndDate = end;
120
121 mTimeLine->setDateRange( start, end );
122
123 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth();
124}
125
126QDateTime TimeSpanView::startDateTime()
127{
128 return mStartDate;
129}
130
131QDateTime TimeSpanView::endDateTime()
132{
133 return mEndDate;
134}
135
136void TimeSpanView::zoomIn()
137{
138 int span = mStartDate.daysTo( mEndDate );
139 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) );
140
141 emit dateRangeChanged();
142}
143
144void TimeSpanView::zoomOut()
145{
146 int span = mStartDate.daysTo( mEndDate );
147 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) );
148
149 emit dateRangeChanged();
150}
151
152void TimeSpanView::centerView()
153{
154 QScrollBar *scrollBar = mLineView->horizontalScrollBar();
155 int min = scrollBar->minValue();
156 int max = scrollBar->maxValue();
157 scrollBar->setValue( min + (max-min) / 2 );
158}
diff --git a/korganizer/timespanview.h b/korganizer/timespanview.h
new file mode 100644
index 0000000..34cb1f7
--- a/dev/null
+++ b/korganizer/timespanview.h
@@ -0,0 +1,60 @@
1#ifndef TIMESPANVIEW_H
2#define TIMESPANVIEW_H
3
4#include <qwidget.h>
5
6#include <libkcal/event.h>
7
8//class QSplitter;
9#ifndef DESKTOP_VERSION
10class QKSplitter;
11#else
12class QSplitter;
13#define QKSplitter QSplitter
14#endif
15class QListView;
16class LineView;
17class TimeLine;
18
19
20class TimeSpanView : public QWidget
21{
22 Q_OBJECT
23 public:
24 TimeSpanView( QWidget *parent=0, const char *name=0 );
25 virtual ~TimeSpanView();
26
27 void addItem( KCal::Event * );
28
29 QValueList<int> splitterSizes();
30 void setSplitterSizes( QValueList<int> );
31
32 void clear();
33
34 void setDateRange( const QDateTime &start, const QDateTime &end );
35
36 QDateTime startDateTime();
37 QDateTime endDateTime();
38
39 public slots:
40 void updateView();
41
42 void zoomIn();
43 void zoomOut();
44 void centerView();
45
46 signals:
47 void dateRangeChanged();
48
49 private:
50 QKSplitter *mSplitter;
51 QListView *mList;
52 TimeLine *mTimeLine;
53 LineView *mLineView;
54
55 QDateTime mStartDate;
56 QDateTime mEndDate;
57 int mSecsPerPixel;
58};
59
60#endif
diff --git a/korganizer/timespanview.moc b/korganizer/timespanview.moc
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/korganizer/timespanview.moc
diff --git a/korganizer/version.h b/korganizer/version.h
new file mode 100644
index 0000000..2f47c90
--- a/dev/null
+++ b/korganizer/version.h
@@ -0,0 +1,29 @@
1#ifndef KORG_VERSION_H
2#define KORG_VERSION_H
3
4/*
5 Version scheme: "x.y.z build".
6
7 "x.y.z" follow the kdelibs version KOrganizer is released with.
8
9 If "z" is 0, it the version is "x.y"
10
11 "build" is empty for final versions. For developer version "build" is
12 something like "alpha1", "alpha2", "beta1", "beta2", "rc1", "rc2".
13
14 Examples in chronological order:
15
16 3.0
17 3.0.1
18 3.1 alpha1
19 3.1 beta1
20 3.1 beta2
21 3.1 rc1
22 3.1
23 3.1.1
24 3.2 alpha1
25*/
26
27static const char *korgVersion = "3.1";
28
29#endif
diff --git a/korganizer/wordsgerman.h b/korganizer/wordsgerman.h
new file mode 100644
index 0000000..4b53ecb
--- a/dev/null
+++ b/korganizer/wordsgerman.h
@@ -0,0 +1,840 @@
1{ "10 minutes","10 Minuten", },
2{ "10th","10." },
3{ "11th","11." },
4{ "12 pm Format","12 AM/PM Format" },
5{ "12th","12." },
6{ "13th","13." },
7{ "14th","14." },
8{ "15th","15." },
9{ "16th","16." },
10{ "17th","17." },
11{ "18th","18." },
12{ "19th","19." },
13{ "1 Day","1 Tag" },
14{ "1 h","1 Std" },
15{ "1 (high)","1 (hoch)" },
16{ "5 (low)","5" },
17{ "1st","1." },
18{ "20th","20." },
19{ "21st","21." },
20{ "22nd","22." },
21{ "23rd","23." },
22{ "24:00 Hour Format","24:00 Stunden Format" },
23{ "24th","24." },
24{ "25th","25." },
25{ "26th","26." },
26{ "27th","27." },
27{ "28th","28." },
28{ "29th","29." },
29{ "2nd","2." },
30{ "30 minutes","30 Minuten" },
31{ "30th","30." },
32{ "31st","31." },
33{ "3rd","3." },
34{ "4th","4." },
35{ "5 (lowest)","5 (Niedrigster)" },
36{ "5th","5." },
37{ "6th","6." },
38{ "7th","7." },
39{ "8th","8." },
40{ "9th","9." },
41{ "About...","Über..." },
42{ "&Accept","&Akzeptieren" },
43{ "Accept","Akzeptieren" },
44{ "Accept A&ll","A&lles Akzepieren" },
45{ "Access:","Zugriff:" },
46{ "A corresponding event is missing in your calendar!","Ein zugehöriger Termin fehlt in ihrem Kalender!" },
47{ "Actions","Aktionen" },
48{ "Add Filter","Filter Hinzufügen" },
49{ "&Add","Hinzufügen" },
50{ "Add","Hinzufügen" },
51{ "Additional email addresses:","Zusätzliche E-Mail Adressen:" },
52{ "Additional email address:","Zusätzliche E-Mail Adresse:" },
53{ "&Addressbook","&Adressbuch" },
54{ "Address &Book...","Adress&buch..." },
55{ "Agenda Size","Agende Größe" },
56{ "Agenda Size:","Größe der Agenda:" },
57{ "Agenda view:","Agenda Ansicht:" },
58{ "Agenda view background color:","Hintergrund der Agenda Ansicht:" },
59{ "All attendees","Alle Teilnehmer" },
60{ "AllDayAgenda Height:","Höhe Ganztages Agenda:" },
61{ "Allday","Ganztägig" },
62{ "Anonymous","Anonym" },
63{ "Apply","Anwenden" },
64{ "Apr","Apr" },
65{ "April","April" },
66{"Ask for every entry on conflict","Frage bei Konflikten nach"},
67{ "Ask for preferences before syncing","Vor dem Syncronisieren nachfragen" },
68{ "Ask for quit when closing KO/Pi","Vor dem Beenden von KO/Pi nachfragen" },
69{ "Attendees","Teilnehmer" },
70{ "Aug","Aug" },
71{ "August","August" },
72{ "Auto-Save","Automatisches Abspeichern" },
73{ "Auto save delay in minutes:","Verzög.autom.Speichern in Min" },
74{ "Auto saving...","Automatische Sicherung..." },
75{ "Begin on:","Starte mit:" },
76{ "Begins on: %1","Starte mit: %1" },
77{ "<b>From:</b> %1 <b>To:</b> %2","<b>Vom:</b> %1 <b>Zum:</b> %2" },
78{ "Bigger","Größer" },
79{ "Biggest","Riesig" },
80{ "Big","Groß" },
81{ "<b>On:</b> %1","<b>Am:</b> %1" },
82{ "<b>On:</b> %1 <b>From:S</b> %2 <b>To:</b> %3","<b>Am:</b> %1 <b>Vom:S</b> %2 <b>Zum:</b> %3" },
83{ "<b>Original event:</b><p>","<b>Original Termin:</b><p>" },
84{ " - both are modified after last sync"," - beide wurden nach der letzten Syncronisation verändert" },
85{ "Busy","Belegt" },
86{ "&Cancel","Abbre&chen" },
87{ "Cancel","Abbrechen" },
88{ "Cannot delete To-Do\nwhich has children.","Kann Todo nicht löschen,\n da noch Einträge vorhanden sind" },
89{ "Cannot delete To-Do which has children.","Kann Todo nicht löschen, da noch Einträge vorhanden sind" },
90{ "Can't generate mail:\nNo event selected.","Kann e-Mail nicht erstellen:\nKein Termin ausgewählt." },
91{ "Categories...","Kategorien..." },
92{ "Categories","Kategorien" },
93{ "Category","Kategorie" },
94{ "Center View","Zentriere Ansicht" },
95{ "Change","Ändere" },
96{ "Cinema","Kino" },
97{ "Click to add a new Todo","Hier klicken, um ein neues Todo anzulegen" },
98{ "Clone Item","Klone Eintrag" },
99{ "&Close","S&chließen" },
100{ "Close","Schließen" },
101{ "Close this dialog to abort deletion!","Zum Abbrechen des Löschvorganges Dialog schließen!" },
102{ "Colors","Farben" },
103{ "completed","erledigt" },
104{ "completed on %1","erledigt am %1" },
105{ "Complete","Erledigt" },
106{ "Confidential","Vertraulich" },
107{ "Configure...","Einstellungen..." },
108{ "Confirm &deletes","Löschvogang bestätigen" },
109{ "Couldn't load calendar\n '%1'.","Kann Kalender\n '%1' nicht laden." },
110{ "Counter-event Viewer","Terminzähler Ansicht" },
111{ "Daily ending hour:","Feierabend:" },
112{ "Daily starting hour:","Anfangszeit:" },
113{ "Daily","Täglich" },
114{ "Date Format","Datums Format" },
115{ "Date Format:","Datums Format:" },
116{ "DateNavigator:(nr)","Datums Navigator" },
117{ "Dates: ","Datum: " },
118{ "Date && Time","Datum && Zeit" },
119{ "Day begins at:","Der Tag beginnt um:" },
120{ "Days in Next-X-Days:","Tage in Nächste-X-Tage:" },
121{ "Days in What's Next:","Tage in What's Next:" },
122{ "day(s)","Tag(e)" },
123{ "Days to show in Next-X-Days view:","Welche Tage in Nächste-X-Tagen anzeigen:" },
124{ "day","Tag" },
125{ "Dec","Dez" },
126{ "December","Dezember" },
127{ "Default alarm time:","Standard Alarmzeit:" },
128{ "Default appointment time:","Standard Termin Startzeit:" },
129{ "Default event color:","Standard Terminfarbe:" },
130{ "Default","Standard" },
131{ "Def. duration of new app.:","Standard Termin Länge:" },
132{ "Delete all completed To-Dos?","Alle bereits erledigten Todos löschen?" },
133{ "Delete All","Lösche alles" },
134{ "Delete all selected","Lösche alle Selektierten" },
135{ "Delete Current","Aktuellen löschen" },
136{ "Delete Event...","Lösche Termin..." },
137{ "Delete Event","Lösche Termin" },
138{ "&Delete","Löschen" },
139{ "Delete...","Löschen..." },
140{ "Delete","Löschen" },
141{ "Delete Todo...","Lösche Todo..." },
142{ "Delete To-Do","Lösche Todo" },
143{ "Deleting item %d ...","Lösche Eintrag %d..." },
144{ "Descriptions","Beschreibungen" },
145{ "Deselect All","Deselektiere Alle" },
146{ "Details","Details" },
147{ "Dinner","Abendessen" },
148{ "Do you really want\nto close KO/Pi?","Möchten Sie wirklich\nKO/PI verlassen?" },
149{ "Due Date","Fällig am" },
150{ "Due: ","Fällig: "},
151{ "Due Time","Fällig um" },
152{ "Due:","Fällig:"},
153{ "Duration: ","Dauer: " },
154{ "Edit...","Bearbeite..." },
155{ "Edit","Bearbeite" },
156{ "Edit Event...","Bearbeite Termin..." },
157{ "Edit Event","Bearbeite Termin" },
158{ "Edit exceptions","Bearbeite Ausnahmen" },
159{ "EditorBox:","Editor Fenster:" },
160{ "Edit Recurrence Range","Bearbeite Wiederholung" },
161{ "Edit Todo...","Berabeite Todo..." },
162{ "Edit To-Do","Todo bearbeiten" },
163{ "E&mail address:","E&mail Adresse:" },
164{ "(EmptyEmail)","(KeineEmail)" },
165{ "(EmptyName)","(KeinName)" },
166{ "Enable Recurrence","Wiederholender Termin" },
167{ "End after","Endet nach"},
168{ "End by:","Endet am"},
169{ "End Date","End Datum" },
170{ "End:","Ende:" },
171{ "End Time","End Zeit" },
172{ "English","Englisch" },
173{ "Event","Termin" },
174{ "Event list","Termin Liste" },
175{ "Events","Termine" },
176{ "Event Viewer:","Termin Übersicht:" },
177{ "every","jede" },
178{ "Exceptions...","Ausnahmen..." },
179{ "Exceptions","Ausnahmen" },
180{ "Exclude holidays","Ohne freie Tage" },
181{ "Exclude Saturdays","Ohne Samstage" },
182{ "Feb","Feb" },
183{ "February","Februar" },
184{ "&Find","Suche!" },
185{ "Fonts","Schriftart" },
186{ "Force take local entry always","Erzwinge:Nimm immer lokalen Eintrag" },
187{ "Force take remote entry always","Erzwinge:Nimm immer fernen Eintrag"},
188{ "Free","Frei" },
189{ "Friday","Freitag" },
190{ "Fri","Fr" },
191{ "From:","Vom:" },
192{ "Full &name:","Vor- und &Nachname:" },
193{ "General","Allgemein" },
194{ "German","Deutsch" },
195{ "Gifts","Geschenke" },
196{ "Go to Today","Heute anzeigen" },
197{ "Help","Hilfe" },
198{ "Hide Dates","Daten ausblenden" },
199{ "Highlight color:","Markierungen:" },
200{ "Holiday color:","Freie Tage:" },
201{ "hour(s)","Stunde(n)" },
202{ "In %1 days: ","In %1 Tagen: " },
203{ "Incomplete Todo:","Unerledigte Aufgaben:" },
204{ "Information","Information" },
205{ "Invalid search expression,\ncannot perform ","Kann Suche nicht ausführen" },
206{ "Jan","Jan" },
207{ "January","Januar" },
208{ "JournalView:","Journal Ansicht:" },
209{ "Journals","Journale" },
210{ "Jul","Jul" },
211{ "July","Juli" },
212{ "Jump to date","Springe zum Datum" },
213{ "June","Juni" },
214{ "Jun","Jun" },
215{ "Key Bindings...","Tastenzuordnung..." },
216{ "Kids","Kinder" },
217{ "Known Problems...","Bekannte Probleme..." },
218{ "KO/Pi Find ","KO/Pi Suchdialog " },
219{ "KO/Pi Find: ","KO/Pi Suchen: " },
220{ "KO/Pi is starting ... "," KO/Pi startet ... \n... Zeit für eine Kaffeepause ..." },
221{ "Language:(needs restart)","Sprache (Neustart!)" },
222{ "Language:","Sprache" },
223{ "Large","Etwas mehr" },
224{ "List View:","Listenansicht:" },
225{ "List View","Listenansicht" },
226{ "Load/Save","Laden/Speichern" },
227{ "Load Template","Lade Vorlage" },
228{ "Locale","Localisation" },
229{ "Local temp file:","Lokale temp. Datei:" },
230{ "Location: ","Ort: " },
231{ "Location:","Ort:" },
232{ "Mail client","Mail Programm" },
233{ "Mail Client","Mail Programm" },
234{ "March","März" },
235{ "Mar","Mär" },
236{ "May","Mai" },
237{ "M. Bains line:","M. Bains Linie:" },
238{ "Medium","Medium" },
239{ "Method","Methode" },
240{ "minute(s)","Minute(n)" },
241{ "Monday","Montag" },
242{ "Mon","Mo" },
243{ "Monthly","Monatlich" },
244{ "Month not long enough","Monat ist nicht lang genug" },
245{ "month(s)","Monat(e)" },
246{ "Month view:","Monatsansicht:" },
247{ "Month view uses category colors","Monatsansicht zeigt Kategorie Farben" },
248{ "Todo view uses category colors","To-Do Ansicht zeigt Kategorie Farben" },
249{ "Move &Down","Nach unten verschieben" },
250{ "Move &Up","Nach oben verschieben" },
251{ "Name:","Name:" },
252{ "Name","Name" },
253{ "\nAre you sure you want\nto delete this event?","\nSind Sie sicher, dass Sie\nden Termin löschen möchten?" },
254{ "%n Days","%n Tage" },
255{ "Never","Nie" },
256{ "New event...","Neuer Termin..." },
257{ "New event","Neuer Termin" },
258{ "New Event...","Neuer Termin..." },
259{ "New Events/Todos should","Neue Termine/Todos sollten" },
260{ "&New","&Neu" },
261{ "New","Neu", },
262{ "New Sub-Todo...","Neues Sub-Todo..." },
263{ "New Todo...","Neues Todo..." },
264{ "Next Alarm: ","Nächster Alarm: ", },
265{ "&Next Day","&Nächster Tag", },
266{ "Next days view uses full window","Nächste-X-Tage nutzt Vollbild" },
267{ "Next month","Nächster Monat" },
268{ "&Next Week","&Nächste Woche" },
269{ "Next year","Nächstes Jahr" },
270{ "Next Year","Nächstes Jahr" },
271{ "%n h","%n Std" },
272{ "No ending date","Kein End-Datum", },
273{ "No event, nothing to do.","Kein Termin, nichts zu tun.", },
274{ "No event selected.","Kein Termin selektiert" },
275{ "No","Nein" },
276{ "No program set","Kein Programm ausgewählt", },
277{ "Normal","Normal" },
278{ "[No selection]","Keine Selektion", },
279{ "No sound set","Kein Sound ausgewählt", },
280{ "no time ","keine Zeit ", },
281{ "no time","keine Zeit", },
282{ "No Time","Keine Zeit" },
283{ "November","November" },
284{ "Nov","Nov", },
285{ "\nThis event recurs\nover multiple dates.\n","\nDieser Termin wiederholt sich an mehreren Tagen.\n" },
286{ "occurrence(s)","Vorkommen" },
287{ "October","Oktober" },
288{ "Oct","Okt", },
289{ "O-due!","Ü-fällig! " },
290{ "&OK","&OK" },
291{ "Ok+Show!","Ok+Anzeigen" },
292{ "Organizer: %1","Organisator %1" },
293{ "Organizer","Organisator" },
294{ "Owner: ","Besitzer: " },
295{ "Owner:","Besitzer:" },
296{ "<p><b>Priority:</b> %2</p>","<p><b>Priorität:</b> %2</p>" },
297{ "Pick a date to display","Wähle einen Tag zum anzeigen aus" },
298{ "Please specify a valid due date.","Bitte gültiges Fälligkeitsdatum angeben."},
299{ "Please specify a valid end date, for example '%1'.","Bitte gültiges Enddatum angeben, z.B.'%1'." },
300{ "Please specify a valid start date.","Bitte gültiges Startdatum angeben." },
301{ "Please specify a valid start date, for example '%1'.","Bitte gültiges Startdatum angeben, z.B. '%1'." },
302{ "Please specify a valid start time.","Bitte gültige Startzeit angeben."},
303{ "Please specify a valid start time, for example '%1'.","Bitte gültige Startzeit angeben, z.B. '%1'." },
304{ "Preferences - some settings need a restart (nr)","Einstellungen - teilweise Neustart erforderlich (bn)" },
305{ "&Previous Day","Vorheriger Tag" },
306{ "Previous month","Vorheriger Monat" },
307{ "Previous Month","Vorheriger Monat" },
308{ "&Previous Week","Vorherige Woche" },
309{ "Previous year","Vorheriges Jahr" },
310{ "Previous Year","Vorheriges Jahr" },
311{ "Printing","Drucken" },
312{ "Priority:","Priorität:" },
313{ "Private","Privat" },
314{ "Proceed","Weiter" },
315{ "Public","Öffentlich" },
316{ "Purge","Entferne" },
317{ "Purge Completed","Entferne erledigte ToDos" },
318{ "Purge To-Dos","Todos bereinigen" },
319{ "read-only","schreibgeschützt" },
320{ "Recur every","Wiederh. alle" },
321{ "Recur in the month of","Wiederh. im Monat" },
322{ "Recur on the","Wiederh. am" },
323{ "Recur on this day","Wiederh. am diesen Tag" },
324{ "Recurrence Range...","Wiederholungs Zeitraum..." },
325{ "Recurrence Range","Wiederholungs Zeitraum" },
326{ "Recurrence Rule","Wiederholungs Regel" },
327{ "Recurrence","Wiederholung" },
328{ "Recurs","Wiederholung" },
329{"&Reject","Abweisen"},
330{ "Reminder:","Alarm:" },
331{ "Rem.:","Alarm:" },
332{ "Rem.","Alarm:" },
333{ "Remote file:","Remote Datei:"},
334{ "Remote IP:","Remote (ferne) IP:" },
335{ "Remote syncing (via ssh/scp) network settings ","Remote Sync (via ssh/scp) Netzwerk Einstellungen " },
336{ "Remote user:","Remote Benutzer"},
337{ "&Remove","Entfe&rnen" },
338{ "Remove","Entfernen" },
339{ "Request response","Bemerkung anfordern" },
340{ "Role:","Rolle:" },
341{ "Role","Rolle" },
342{ "Sat","Sa" },
343{ "Saturday","Samstag" },
344{ "Search for:","Suche nach:" },
345{ "Search In","Suche in" },
346{ "Search...","Suche..." },
347{ "Search","Suche" },
348{ "Select Addresses","Wähle Adressen" },
349{ "Select all","Selektiere Alle" },
350{ "Select a month","Wähle Monat" },
351{ "Select a week","Wähle Woche" },
352{ "Select a year","Wähle Jahr" },
353{ "Send directly","Sende direkt" },
354{ "&Send Messages","&Sende Nachrichten", },
355{ "Sep","Sep" },
356{ "September","September" },
357{ "Shopping","Einkaufen" },
358{ "Use short date in (WN/E) view","Kurzdatum in (WN/Termin) Ansicht" },
359{ "Show Dates","Zeige Daten" },
360{ "Show events that recur daily in date nav.","Zeige tägl.wiederh.Term.in Datums Nav." },
361{ "Show Event...","Zeige Termin..." },
362{ "Show ev. that recur weekly in date nav.","Zeige wöch.wiederh.Term.in Datums Nav." },
363{ "Show Marcus Bains line","Zeige Marcus Bains Linie" },
364{ "Show summary after syncing","Zeige Zusammenfassung nach Sync." },
365{ "Show time as:","Zeige Zeit als" },
366{ "Show Todo...","Zeige To-Do" },
367{ "Show topmost todo prios in What's N.:","Anz. höchster Prios in What's N.:"},
368{ "Show topmost todo prios in What's Next:","Anz. höchster Prios in What's Next:"},
369{ "Show vertical screen (Needs restart)","Vertikaler Bildschirm-Layout (Neustart!)" },
370{ "&Show","Zeige" },
371{ "Show...","Zeige..." },
372{ "Show","Zeige" },
373{ "Small","Klein" },
374{ "Sorry","Entschuldigung" },
375{"Sorry, the copy command failed!\nCommand was:\n","Der Kopierbefehl schlug fehl!\nBefehl war:\n"},
376{ "Start:","Start:" },
377{ "Start Date","Start Datum" },
378{ "Start date: %1","Start Datum: %1" },
379{ "Start Time","Start Zeit" },
380{ "Status:","Status:" },
381{ "Status","Status:" },
382{ "Summaries","Titel" },
383{ "Summary:","Titel:" },
384{ "Summary","Titel" },
385{ "Sunday","Sonntag" },
386{ "Sun","So" },
387{ "Sync preferences:","Sync Einstellungen" },
388{ "Sync Prefs","Sync Einstellungen" },
389{ "Syncronize","Daten abgleich" },
390{ "Take local entry on conflict","Nimm lokalen Eintrag beim Konflikt" },
391{ "Take newest entry on conflict","Nimm neuesten Eintrag beim Konflikt" },
392{ "Take remote entry on conflict","Nimm fernen Eintrag beim Konflikt" },
393{ "Template '%1' does not contain a valid Todo.","Template '%1' enthält kein gültiges To-Do" },
394{ "Template does not contain a valid Event.","Template '%1' enthält keinen gültigen Termin" },
395{ "Template...","Vorlage..." },
396{ "This day","Dieser Tag" },
397{ "This is an experimental feature. ","Dieses Feature ist experimentel" },
398{ "This item will be\npermanently deleted.","Dieser Eintrag wird\nkomplett gelöscht." },
399{ "This item will be permanently deleted.", "Dieser Eintrag wird komplett gelöscht." },
400{ "Thu","Do" },
401{ "Thursday","Donnerstag" },
402{ "Time associated","Mit Zeit" },
403{ "Time bar:","Uhrzeit Zeile:" },
404{ "Time && Date","Zeit und Datum" },
405{ "Time Format","Zeit Format" },
406{ "Time Format(nr):","Zeit Format(Neustart!)" },
407{ "Date Labels:","Datumsleiste:" },
408{ "Time: ","Zeit: " },
409{ "Timezone:","Zeitzone:" },
410{ "Tiny","Sehr klein" },
411{ "To: ","Bis: " },
412{ "To:","Bis:" },
413{ "Today: ","Heute: " },
414{ "Todo due today color:","Heute fällige To-Do's" },
415{ "To-do items:","To-Do items:" },
416{ "Todo overdue color:","Überfällige To-Do's" },
417{ "Todo","Todo" },
418{ "To-do view shows completed Todos","To-do Ansicht zeigt erledigte To-dos" },
419{ "ToDoView:","Todo Ansicht:" },
420{ "Toggle Alarm","Wechsle Alarm" },
421{ "Toggle Allday","Umschalten Ganztag" },
422{ "Tomorrow: ","Morgen: " },
423{ "Tue","Di" },
424{ "Tuesday","Dienstag" },
425{ "Two entries are in conflict, if: ","Zwei Einträge haben einen Konflikt, wenn:" },
426{ "Unable to find template '%1'.","Kann Vorlage '%1' nicht finden." },
427{ "Unknown","Unbekannt" },
428{ "Up","Hinauf" },
429{ "Use password (if not, ask when syncing)","Passwort: (sonst jedesmal anfragen)" },
430{ "User defined","Benutzerdefiniert" },
431{ "User long date:","Format langes Datum:" },
432{ "User short date:","Forma kurzes Datum:" },
433{ "View","Ansicht" },
434{ "View Fonts","Schriftarten Ansichten" },
435{ "Views","Ansichten" },
436{ "Wed","Mi" },
437{ "Wednesday","Mittwoch" },
438{ "Week %1","Woche %1" },
439{ "Weekly","Wöchentlich" },
440{ "Week starts on Sunday","Woche beginnt Sonntags" },
441{ "What's Next View:","What's Next Anz." },
442{ "What's next ?","Was kommt als nächstes?(What's Next)" },
443{ "Working Hours","Tägliche Arbeitszeit" },
444{ "Working hours color:","Arbeitszeit in der Agenda Ansicht:" },
445{ "Write back existing entries only","Nur exisitierende Einträge zurückschreiben" },
446{ "Write back synced file","Syncronisierte Datei zurückschreiben" },
447{ "Yearly","Jährlich" },
448{ "year(s)","Jahr(e)" },
449{ "Yes","Ja" },
450{ "You have %d item(s) selected.\n","Sie haben %d Einträge ausgewählt.\n" },
451{ "You have to restart KOrganizer for this setting to take effect.","Sie müssem Korganizer neu starten, damit diese Einstellung aktiviert wird." },
452{ "week(s) on:","Woche(n) am: " },
453{ "Full menu bar(nr)","Volle Menuleiste(bn)" },
454{ "Timezone has daylight saving","Zeitzone hat Sommerzeit" },
455{ "Actual start/end is the\nsunday before this date.","Tatsächlicher Beginn/Ende ist der Sonntag\nvor diesem Datum!" },
456{ "The year in the date is ignored.","Das Jahr vom Datum wird ignoriert." },
457{ "Daylight start:","Sommerzeit Beginn:" },
458{ "Daylight end:","Sommerzeit Ende:" },
459{ "Time Zone","Zeitzone" },
460{ "Monday 19 April 2004: %A %d %B %Y","Montag 19 April 2004: %A %d %B %Y" },
461{ "%A: Monday --- %a: Mon","%A: Montag --- %a: Mon" },
462{ "minutely","minütlich" },
463{ "hourly","stündlich" },
464{ "daily","täglich" },
465{ "weekly","wöchentlich" },
466{ "monthly","monatlich" },
467{ "day-monthly","tag-monatlich" },
468{ "month-yearly","monat-jährlich" },
469{ "day-yearly","tag-jährlich" },
470{ "position-yearly","pos-jährlich" },
471{ "Edit item on doubleclick (if not, show)","Editiere mit Doppelklick(wenn nicht, zeige)" },
472{ "Highlight current day in agenda","Hebe >>heute<< in Agenda hervor" },
473{ "Use light color for highlight current day","Helle Farbe für >>heute<< Hervorhebung" },
474{ "Highlight selection in Time Edit","Hebe Auswahl in Zeit Edit hervor" },
475{ "Hold fullscreen on view change","Behalte Vollbild bei Ansichswechsel" },
476{ "Hold non-fullscreen on view change","Behalte Nicht-Vollbild bei Ansichtsw." },
477{ "Event list view uses full window","Listenansicht nutzt Vollbild" },
478{ "Set agenda to DayBeginsAt on change","Setze Agenda auf TagBeginntUm bei Wechsel" },
479{ "Set agenda to current time on change","Setze Agenda auf gegenw.Zeit bei Wechsel" },
480{ "Listview uses monthly timespan","Listenansicht zeigt monatliche Zeitspanne" },
481{ "ViewChange","Ansichtswechsel" },
482{ "Default alarm *.wav file:","Standard Alarm *.wav Datei:" },
483{ "This setting is useless for 5500 user!","Diese Einst. ist nutzlos für 5500 Nutzer" },
484{ "File","Datei" },
485{ "Clone...","Dupliziere.." },
486{ "Move...","Bewege..." },
487{ "Beam...","Sende via IR..." },
488{ "&Clone...","Dupliziere.." },
489{ "&Move...","Bewege..." },
490{ "&Beam...","Sende via IR..." },
491{ "Show Completed","Zeige erledigte Todos" },
492{ "Show Quick Todo","Zeige Quick Todo" },
493{ "Unparent Todo","Un-sub Todo" },
494{ "Save selected to file...","Speichere Selektierte..." },
495{ "Add Categ. to selected...","Füge zu Selekt. Kateg. hinzu..." },
496{ "Set Categ. for selected...","Setze Kateg. für Selekt." },
497{ "Beam selected via IR","Sende Selekt. via IR..." },
498{ "Search","Suchen" },
499{ "Date Picker","Datum auswählen" },
500{ "Day View","Tagesansicht" },
501{ "Work Week","Arbeitswoche" },
502{ "Week","Wochenansicht" },
503{ "Month","Monatsansicht" },
504{ "Todo View","Todo Liste" },
505{ "Journal","Journal Ansicht" },
506{ "Next days","Nächste Tage" },
507{ "Print agenda selection...","Drucke Agendaselektion..." },
508{ "Toggle DateNavigator","Navigator umschalten" },
509{ "Toggle FilterView","Filteransicht umschalten" },
510{ "Prev. month","Vorheriger Monat" },
511{ "Go backward","Gehe zurück" },
512{ "Go forward","Gehe weiter" },
513{ "Synchronize","Synchronisieren" },
514{ "AgendaSize","Agendagröße" },
515{ "Import (*.ics/*.vcs) file","Importiere (*.ics/*.vcs) Datei" },
516{ "Import last file","Importiere letzte Datei" },
517{ "Import Opie/Qtopia Cal.","Importiere Opie/Qtopia Kal." },
518{ "Load Calendar Backup","Lade Kalender Backup" },
519{ "Save Calendar Backup","Speichere Kalender Backup" },
520{ "Export VCalendar","Exportiere VCalendar" },
521{ "Manage new categories...","Verwalte neue Kategorien..." },
522{ "Beam complete calendar...","Sende kompletten Kalender via IR" },
523{ "Beam filtered calendar...","Sende gefilterten Kalender via IR" },
524{ "Remote via ssh","Über Netzwerk via ssh" },
525{ "With local file","Mit lokaler Datei" },
526{ "With last file","Mit letzter Datei" },
527{ "KO/Pi: Ready for beaming","KO/Pi: Bereit zum Senden" },
528{ "KO/Pi:Beaming done","KO/Pi: Senden erfolgt" },
529{ "Save filename","Speichern: Dateinamen wählen" },
530{ "File already exists!\nOld file from:\n%1\nOverwrite?\n","Dateiname existiert bereits!\nAlte Datei vom:\n%1\nÜberschreiben?\n" },
531{ "KO/Pi: Warning!","KO/Pi: Warnung!" },
532{ "Overwrite!","Überschreibe!" },
533{ "KO/Pi:Saved %1","KO/Pi:Gespeichert %1" },
534{ "All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n","Alle selektierten Einträge werden\nunwiederbringlich gelöscht.\n(Löschen kann auf dem\nPDA einige Zeit dauern)\n" },
535{ "KO/Pi Confirmation","KO/Pi Bestätigung" },
536{ "Close dialog to abort deletion!","Schließe Dialog um das Löschen abzubrechen!" },
537{ "Deleting item %d ...","Lösche Eintrag %d ..." },
538{ "%d items remaining in list.","%d Einträge sind in der Liste verblieben." },
539{ "Size","Größe" },
540{ "Date","Datum" },
541{ "Mime Type","Datei Typ" },
542{ "All Files","Alle Dateien" },
543{ "Files","Dateien" },
544{ "Documents","DoKumente" },
545{ "Select Categories","Selektiere Kategorien" },
546{ " &Deselect All "," Auswahl aufheben " },
547{ "A&dd","Hinzu" },
548{ "&Modify","Ändern" },
549{ "Edit Categories","Editiere Kategorien" },
550{ " &Edit Categories "," &Editiere Kategorien " },
551{ "Beam Options","Beam Einstellungen" },
552{ " With timezone "," Mit Zeitzone " },
553{ " Local time ", " Lokale Zeit " },
554{ "Manage new Categories","Verwalte neue Kategorien" },
555{ "Add to category list","Füge zur Kategorieliste hinzu" },
556{ "Remove from Events/Todos","Entferne von Terminen/Todos" },
557{ "After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n ","Nach dem Importieren/Laden/Syncen\nkann es neue Kategorien in den \nTerminen oder Todos geben, die nicht\nin der Kategorieliste enthalten sind.\nBitte wählen Sie, was passieren soll:\n " },
558{ "New categories not in list:","Kategorien, die nicht in der Liste sind:" },
559{ "File format","Datei Format" },
560{ "Time format","Zeit Format" },
561{ "Delete all\ncompleted To-Dos?","Lösche alle\nerledigten To-Dos?" },
562{ "KO/Pi:Saving Data to File ...","KO/Pi: Speichere Kalender in Datei ..." },
563{ "KO/Pi:File Saved. Needed %d sec, %d ms","KO/Pi: Abgespeichert in %d sec, %d ms" },
564{ "h","Std" },
565{ "min","Min" },
566{ "hou","Std" },
567{ "day","Tag" },
568{ "French(nyi)","Französich (noch nicht implementiert)" },
569{ "Time","Zeit" },
570{ "Event Viewer","Termin Ansicht" },
571{ "Cancel Sync","Sync Abbrechen" },
572{ "Remote","Fern" },
573{ "Local","Lokal" },
574{ "Conflict! Please choose entry","Konflikt! Bitte Eintrag wählen" },
575{ "Local: ","Lokal: " },
576{ "Remote: ","Fern: " },
577{ "Last modified: ","Zuletzt geändert: " },
578{ "Location: ","Ort: " },
579{ "<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>","<p><b>Von:</b> %1 </p><p><b>Bis:</b> %2</p>" },
580{ "<p><b>On:</b> %1</p>","<p><b>Am:</b> %1</p>" },
581{ "<p><b>From:</b> %1</p> ","<p><b>Von:</b> %1</p> " },
582{ "<p><b>To:</b> %1</p>","<p><b>Bis:</b> %1</p>" },
583{ "<p><b>On:</b> %1</p> ","<p><b>Am:</b> %1</p> " },
584{ "<p><b>From:</b> %1 <b>To:</b> %2</p>","<p><b>Von:</b> %1 <b>Bis:</b> %2</p>" },
585{ "This is a %1 recurring event.","Das ist ein %1 wiederholender Termin." },
586{ "<b>Next recurrence is on:</b>","<b>Nächste Wiederholung ist am:</b>" },
587{ "<b>Last recurrence was on:</b>","<b>Letzte Wiederholung war am:</b>" },
588{ "( %1 min before )","( %1 min vorher )" },
589{ "<b>Alarm on: ","<b>Alarm am: " },
590{ "<b>Details: </b>","<b>Details: </b>" },
591{ "<p><b>Priority:</b> %2</p>","<p><b>Priorität:</b> %2</p>" },
592{ "<p><i>%1 % completed</i></p>","<p><i>%1 % erledigt</i></p>" },
593{ "Organizer","Organisator" },
594{ "Save","Speichern" },
595{ "Exit (+save)","Beenden (+ speichern)" },
596{ "Home","Zuhause" },
597{ "Office","Büro" },
598{ "Libary","Bücherei" },
599{ "Doctor","Arzt" },
600{ "Beach","Strand" },
601{ "Conference room","Konferenzraum" },
602{ "Drive Home","Heimfahrt" },
603{ "Watch TV","Tv gucken" },
604{ "Phone call","Telefonanruf" },
605{ "Pay bill","Rechnung bezahlen" },
606{ "Read book","Buch lesen" },
607{ "Watering plants","Pflanzen giessen" },
608{"Appointment","Verabredung" },
609{"Birthday","Geburtstag" },
610{"Business","Geschäft" },
611{"Business Travel","Geschäftsreise" },
612{"Cinema","Kino" },
613{"Customer","Kunde" },
614{"Break","Pause" },
615{"Breakfast","Frühstück" },
616{"Competition","Wettkampf" },
617{"Dinner","Abendessen" },
618{"Education","Erziehung" },
619{"Family","Familie" },
620{"Favorites","Favoriten" },
621{"Festival","Festival" },
622{"Fishing","Angeln" },
623{"Flight","Flug" },
624{"Gifts","Geschenk" },
625{"Holiday","Feiertag" },
626{"Holiday Cards","Ansichtskarten" },
627{"Hot Contacts","Heisse Kontakte" },
628{"Hiking","Wandern" },
629{"Hunting","Jagen" },
630{"Key Customer","Wichtiger Kunde" },
631{"Kids","Kinder" },
632{"Lunch","Mittagessen" },
633{"Meeting","Treffen" },
634{"Miscellaneous","Verschiedenes" },
635{"Partner","Partner" },
636{"Party","Partie" },
637{"Personal","Privat" },
638{"Personal Travel","Privatreise"},
639{"PHB","PHB" },
640{"Phone Calls","Telefonanruf" },
641{"Projects","Projekt" },
642{"Recurring","Wiederholend" },
643{"School","Schule" },
644{"Shopping","Einkaufen" },
645{"Speach","Rede" },
646{"Special Occasion","Spez.Gelegenheit" },
647{"Sports","Sport" },
648{"Talk","Vortrag" },
649{"Travel","Reise" },
650{"TV","TV" },
651{"Germany","Deutschland" },
652{"Sweden","Schweden" },
653{"Forest","Wald" },
654{ "Desert","Wüste" },
655{ "Kitchen","Küche" },
656{ "Lake","See" },
657{"University","Universität"},
658{"Vacation","Urlaub" },
659{"VIP","VIP" },
660{ "Import Sharp Calendar","Importiere Sharp Kalender" },
661{ "This todo has been cancelled!","Dieses Todo wurde gecancelt!" },
662{ "This event has been cancelled!","Dieser Termin wurde gecancelt!" },
663{ "Cancelled","Gecancelt" },
664{ "Multiple sync","Mehrfach Sync" },
665{ "Local file","Lokale Datei" },
666{ "Last file","Letzte Datei" },
667{ "Keys + Colors...","Tasten + Farben..." },
668{ "Mini icons in toolbar(nr)","Mini Icons in ToolBar(bn)" },
669{ "Quick load/save (w/o Unicode)","Schnelles Laden/Speichern (o Unicode)" },
670{ "Choose...","Wähle..." },
671{ "Use colors for application:","Setze Farben für Programm:" },
672{ "Buttons, menus, etc.:","Knöpfe, Menu, etc.:" },
673{ "Frames, labels, etc.:","Rahmen, Label, etc.:" },
674{ "Show parent To-Do's in What's Next view","Zeige Ober-Todo in What's Next Anz." },
675{ "Show location in What's Next view","Zeige Ort in What's Next Anz." },
676{ "Show events that recur ","Zeige Termine, die sich wiederholen:" },
677{ "Show in every cell ","Zeige in jeder Zelle " },
678{ "short month","kurzen Monat" },
679{ "icons","Icons" },
680{ "Show Sat/Sun together","Zeige Sam/Son zusammen" },
681{ "Categorie colors are applied to text","Kategorie Farben färben Text" },
682{ "Month view uses day colors","Monatsansicht zeigt Tagesfarben" },
683{ "Day color odd months","Tagesfarbe ungerade Monate" },
684{ "Day color even months","Tagesfarbe gerade Monate" },
685{ "Color for Sundays + category \"Holiday\"","Farbe für Sonntag + Kateg.\" Feiertag\"" },
686{ "To-do view shows complete as 'xx %'","Zeige Prozent erledigt als 'xx %'" },
687{ "Small To-do view uses smaller font","Kleine To-do Ansicht nutzt kleineren Font" },
688{ "Colors are applied to text","Farben werden auf Text angewendet" },
689{ "Use internal alarm notification","Nutze interne Alarm Benachrichtigung" },
690{ "Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n","Achtung: KO/Pi muß ausgeführt werden damit die Benachrichtigung funktioniert. Empfehlung für Zaurus: Diese Option nicht wählen und KO/Pi Alarm Applet installieren.\n" },
691{ "Play beeps count:","Anzahl der Alarmpiepse: " },
692{ "Beeps interval in sec:","Zeitintervall der Alarmpiepse: " },
693{ "Default suspend time in min:","Standard Supendierungs Zeit: " },
694{ "Auto suspend count:","Anzahl der auto Suspendierungen" },
695{ "Alarm *.wav file for newly created alarm:","Alarm *.wav Datei für neu angelegte Alarme:" },
696{ "New profile","Neues Profil" },
697{ "Clone profile","Klone Profil" },
698{ "Delete profile","Lösche Profil" },
699{ "Profile:","Profil:" },
700{ "Include in multiple sync","Beziehe Profil in mehrfach Sync mit ein" },
701{ "Force: Take local entry always","Erzwinge: Nimm immer lokalen Eintrag" },
702{ "Force: Take remote entry always","Erzwinge: Nimm immer fernen Eintrag" },
703{ "Show summary after sync","Zeige Zusammenfassung nach dem Synchronisieren" },
704{ "Write back file","Schreibe Datei zurück" },
705{ "Remote file (w down/upload command)","Entfernte Datei (via down/upload Kommando)" },
706{ "Pre sync (download) command:","Bevor Sync (download) Kommando:" },
707{ "Local device name:","Name dieses Gerätes:" },
708{ "Ask for preferences before sync","Frage nach Synchronisationseinstellungen vor dem Syncen" },
709{ "Sync preferences","Synchronisations Einstellungen" },
710{ "Profile kind","Profil Art" },
711{ "Local file","Lokale Datei" },
712{ "Local file:","Lokale Datei:" },
713{ "Post sync (upload) command:","Nach Sync (upload) Kommando:" },
714{ "Fill in default values for:","Setze Beispiel Werte ein für:" },
715{ "Hint: Use $PWD$ for placeholder of password!","Hinweis: Benutze $PWD$ als Platzhalter für ein Passwort!" },
716{ "Synchronization Preferences","Einstellungen der Synchronisationsprofile"},
717{ "Device","Gerät:" },
718{ "Sync with file \n...%1\nfrom:\n%2\n","Sync mit Datei \n...%1\nvom:\n%2\n" },
719{ "Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n","Synchronisationsübersicht:\n\n %d items lokal hinzugefügt\n %d items entfernt hinzugefügt\n %d items lokal geändert\n %d items entfernt geändert\n %d items lokal gelöscht\n %d items entfernt gelöscht\n" },
720{ "Synchronization successful","Synchronisation erfolgreich" },
721{ "Sync cancelled or failed. Nothing synced.","Sync abgebrochen oder fehlgeschlagen. Nichts wurde gesynced." },
722{ "Sync file \n...%1\ndoes not exist!\nNothing synced!\n","Sync Datei \n...%1\nexistiert nicht!\nNichts wurde gesynced!\n" },
723{ "Sync filename(*.ics/*.vcs)","Sync Dateiname(*.ics/*.vcs)" },
724{ "Enter password","Passwort eingeben" },
725{ "Do you really want\nto remote sync\nwith profile \n","Wollen Sie wirklich\nmit dem entfernten\nProfil syncen: \n" },
726{ "Copy remote file to local machine...","Kopiere entfernte Datei auf lokalen Rechner..." },
727{ "Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n","Sorry, das Kopierkommando schlug fehl!\nKommando war:\n%1\n \nVersuche Kommando von Kosole um\nDetails für das Fehlschlagen\nzu erfahren.\n" },
728{ "Writing back file result: ","Resultat des Dateizurückschreibens: " },
729{ "Syncronization sucessfully completed","Synchronisation erfolgreich abgeschlossen" },
730{ "Edit Calendar Filters","Editiere Kalendar Filter" },
731{ "Enter filter name:","Neuer Filter Name:" },
732{ "Add Filter","Filter hinzufügen" },
733{ "Question","Frage" },
734{ "Filter position: ","Filter Position: " },
735{ "Month View","Monatsansicht" },
736{ "This profil cannot be deleted!\n","Dieses Profil kann\nnicht gelöscht werden!" },
737{ "KO/Pi config error","KO/Pi Konfig. Fehler" },
738{ "Local device name undefined!\nPlease define device name!","Name dieses Gerätes undefiniert!\nBitte Namen angeben!" },
739{ "Multiple profiles with same name!\nPlease use unique profile names!","Mehrere Profile haben denselben Namen!\nBitte unterschiedliche Namen wählen!" },
740{ "Access: ","Zugriff: " },
741{ "Needs Action","Aktion notwendig" },
742{ "Accepted","Akzeptiert" },
743{ "Declined","Abgelehnt" },
744{ "Tentative","Vorläufig" },
745{ "Delegated","Beauftragt" },
746{ "Completed","Vollständig" },
747{ "In Process","In Bearbeitung" },
748{ "Participant","Teilnehmer" },
749{ "Optional Participant","Möglicher Teilnehmer" },
750{ "Observer","Beobachter" },
751{ "Chair","Vorsitzender" },
752{ "Not supported \non desktop!\n","" },
753{ "Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. ","Es ist nichts selektiert!\nDieses druckt die volle Breite der Agenda View, so wie man sie sieht.\nUm die verticale Auswahl zum Drucken zu bestimmen,\nbitte einen verticalen Zeitraum (mit gedrückter linker Maustaste)\nin einer Spalte auswählen. " },
754{ "Date range: ","Datums Zeitspanne: " },
755{ "Not supported \non PDA!\n","Nicht verfügbar\nauf dem PDA. " },
756{ "Syncing - close to abort!","Syncing-schließe um abzubrechen." },
757{ "Add / remove events","Add./entferne Termine" },
758{ "File does not exist:\n '%1'.","Datei existiert nicht:\n '%1'." },
759{ "Couldn't load calendar\n '%1'.","Kann Kalender nicht laden:\n '%1'." },
760{ "\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n","\nDie gepeicherte Datei wurde verändert!\nDatei Grösse: %1 Bytes.\nZuletzt geändert: %2\nMöchten Sie:\n\n - Speichern und die Datei überschreiben?\n - Mit Datei Synchronisieren, dann speichern?\n - Abbrechen ohne zu speichern? \n" },
761{ "Overwrite","Überschreiben" },
762{ "Sync+save","Syncen+speichern" },
763{ "Default","Standard" },
764{ " Categories added to list! "," Kategorien zur Liste hinzugefügt! " },
765{ " %d items?"," %d Einträge?" },
766{ "\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?","\nDieses ist ein\nwiederholender Termin!.\nSind Sie sicher, dass Sie\ndiesen Termin und alle\nWiederholungen löschen möchten?" },
767{ " ?\n\nDelete:\n"," ?\n\nLösche:\n" },
768{ "Current","Aktuelle" },
769{ "\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n","\nDieses ist ein\nwiederholender Termin!\nMöchten sie alle Wiederholungen\nlöschen, oder nur die aktuelle am:\n" },
770{ "All","Alle" },
771{ "Data Loss Warning","Datenverlust Warnung" },
772{ "Proceed","Weitermachen" },
773{ "The journal entries can not be\nexported to a vCalendar file.","Die Journal Einträge können\nnicht in eine vCalendar\nDatei exportiert werden!" },
774{ "Filter disabled ","Filter abgeschaltet" },
775{ "Filter selected: ","Gewählter Filter: " },
776{ "Toggle Cancel","Gecancelt ändern" },
777{ "&Toggle Cancel","Gecancel&t ändern" },
778{ "Configure Toolbar","Konfiguriere Toolbar" },
779{ "Stretched TB","Gedehnte TB" },
780{ "Import file \n...%1\ndoes not exist!\nNothing imported!\n","Import Datei \n...%1\nexistiert nicht!\nNichts importiert!\n" },
781{ "Import filename(*.ics/*.vcs)","Import Dateiname(*.ics/*.vcs)" },
782{ "When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing","Wenn ein Kalender doppelt importiert\nwird, werden doppelte Einträge ignoriert!\nSie können eine Backup Datei anlegen unter\nDatei - Speichere Kalender Backup\num den Import rückgängig machen zu können.\n" },
783{ "Not supported \non desktop!\n","Nur verfügbar auf PDA!" },
784{ "Imported file successfully","Datei erfolgreich importiert" },
785{ "Error importing file","Fehler beim Importieren der Datei" },
786{ "Export vcal filename(*.vcs)","Export vcal Dateiname(*.vcs)" },
787{ "Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n","Zu speichernde Datei\existiert bereits!\nExist. Datei vom:\n%1\nÜberschreiben?\n" },
788{ "Overwrite!","Überschreiben!" },
789{ "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n","Import Datei \n...%1\nvom:\n%2\nDuplizierte Einträge\nwerden nicht importiert!\n" },
790{ "Load backup filename","Lade Backup Dateiname" },
791{ "Backup file\ndoes not exist!\nNothing loaded!","Backup Datei\nexistiert nicht!\nNichts geladen!" },
792{ "KO/Pi:Loaded %1","KO/Pi:Geladen %1" },
793{ "Save backup filename","Speichere Backup Dateiname" },
794{ "Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n","Backup Datei\nexistiert bereits!\nAlte Backup Datei vom:\n%1\nÜberschreiben?\n" },
795{ "KO/Pi:Saved %1","KO/Pi:Gespeichert %1" },
796{ "Details of attendee","Teilnehmerdetails" },
797{ "Work phone:\n","Telefon Arbeit:\n" },
798{ "Work mobile phone:\n","Mobiltelefon Arbeit:\n" },
799{ "Home phone:\n","Telefon privat:\n" },
800{ "Mobile home phone:\n","Mobiltelefon privat:\n" },
801{ "Email:\n","Email:\n" },
802{ "Alarm disabled","Alarm deaktiviert" },
803{ "Audio.Al.: ","Audio Al.: " },
804{ "Proc.Al.: ","Proc.Al.: " },
805{ "No sound set","Kein Sound definiert" },
806{ "*.wav|Wav Files","*.wav|Wav Dateien" },
807{ "No program set","Kein Programm definiert" },
808{ "Running '%1'","Ausführen '%1'" },
809{ "Playing '%1'","Abspielen '%1'" },
810{ "Show Sync Events in WN/Agenda view","Zeige Sync Events in WN/Agenda Ansicht" },
811{ "User defined (usertranslation.txt)","Benutzerdefiniert (usertranslation.txt)" },
812{ "Load!","Laden!" },
813{ "Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n","Backup Datei vom:\n%1\nDas Laden der Backup Datei\nlöscht die aktuellen Daten!\n" },
814{ "KO/Pi Features and hints","KO/Pi Eigenschaften und Tipps" },
815{ "KO/Pi User translation HowTo","KO/Pi Benutzer-Übersetzung HowTo" },
816{ "KO/Pi Synchronization HowTo","KO/Pi Synchronisation HowTo" },
817{ "Features + hints...","Eigenschaften + Tipps..." },
818{ "User translation...","Benutzer Übersetzung..." },
819{ "Sync HowTo...","Synchronisation HowTo..." },
820{ "Print calendar...","Drucke Kalender..." },
821{ "Anniversary","Jahrestag" },
822{ "When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n","Wenn Geburtstage mehrfach importiert\nwerden, werden doppelte Einträge ignoriert\nwenn sie nicht verändert wurden.\n" },
823{ "Import Birthdays (KA/Pi)","Importiere Geburtstage (KA/Pi)" },
824{ "Next recurrence is on: ","Nächste Wiederholung ist am:" },
825{ "<b>Alarm on: </b>","<b>Alarm am: </b>" },
826{ "<b>Access: </b>","<b>Zugriff: </b>" },
827{ "(%1 min before)","(%1 min vorher)" },
828{ "<b>Categories: </b>","<b>Kategorien: </b>" },
829{ "Save Journal/Description...","Speichere Journal/Details..." },
830{ "This saves the text/details of selected\nJournals and Events/Todos\nto a text file.","Das speichert den Text bzw.\ndie Details von selektierten\nJournalen und Events/Todos\nin eine Textdatei." },
831{ "Continue","Weitermachen" },
832{ " birthdays/anniversaries added!"," Geburts-/Jahrestage hinzugefügt" },
833{ "Attendee:","Teilnehmer:" },
834{ "Click OK to search ->","Klicke zum Suchen auf OK ->" },
835{ "","" },
836{ "","" },
837{ "","" },
838{ "","" },
839{ "","" },
840{ "","" },