summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-16 22:19:12 (UTC)
committer zautrix <zautrix>2005-01-16 22:19:12 (UTC)
commit507b362d42d5eed6277ad17422b6ba61acca636e (patch) (unidiff)
treed3d29451d37649b102c3e171e2927437925f8ce8 /korganizer
parenta704468d5fd02d30cf962c8b2d6815c7e9208e5d (diff)
downloadkdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.zip
kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.gz
kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.bz2
print AB
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp2
-rw-r--r--korganizer/kowhatsnextview.cpp42
-rw-r--r--korganizer/kowhatsnextview.h5
3 files changed, 33 insertions, 16 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index cee0466..5de667e 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,218 +1,218 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#else //DESKTOP_VERSION 56#else //DESKTOP_VERSION
57#include <externalapphandler.h> 57#include <externalapphandler.h>
58#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
59#endif //DESKTOP_VERSION 59#endif //DESKTOP_VERSION
60 60
61KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
62 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
63{ 63{
64 mSyncMode = false; 64 mSyncMode = false;
65 mColorMode = 0; 65 mColorMode = 0;
66} 66}
67 67
68KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
69{ 69{
70} 70}
71 71
72void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
73{ 73{
74 74
75 if ( n.left(3) == "uid" ) 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 { 77 {
78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
79 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
81 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
82 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
83 83
84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
85 if (n == uid ) { 85 if (n == uid ) {
86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
87 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
88 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
89 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
90 KPIM::AddresseeView av ( &dia ); 90 KABC::AddresseeView av ( &dia );
91 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
92 lay.addWidget( &av ); 92 lay.addWidget( &av );
93 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
94 dia.resize( 220, 240); 94 dia.resize( 220, 240);
95 else { 95 else {
96 dia.resize( 400,400); 96 dia.resize( 400,400);
97 } 97 }
98 dia.exec(); 98 dia.exec();
99 break; 99 break;
100 } 100 }
101 } 101 }
102 return; 102 return;
103 } 103 }
104#else 104#else
105 { 105 {
106 if ( "uid:organizer" == n ) { 106 if ( "uid:organizer" == n ) {
107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
108 return; 108 return;
109 } 109 }
110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
111 if (attendees.count()) { 111 if (attendees.count()) {
112 Attendee *a; 112 Attendee *a;
113 for(a=attendees.first();a;a=attendees.next()) { 113 for(a=attendees.first();a;a=attendees.next()) {
114 if ( "uid:"+a->uid() == n ) { 114 if ( "uid:"+a->uid() == n ) {
115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
116 return; 116 return;
117 } 117 }
118 } 118 }
119 } 119 }
120 return; 120 return;
121 } 121 }
122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
123 // the result should now arrive through method insertAttendees 123 // the result should now arrive through method insertAttendees
124 //QString uid = "uid:"+(*it).uid(); 124 //QString uid = "uid:"+(*it).uid();
125#endif 125#endif
126 if ( n.left(6) == "mailto" ) { 126 if ( n.left(6) == "mailto" ) {
127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
128#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
130 e << n.mid(7); 130 e << n.mid(7);
131#endif 131#endif
132 132
133 } 133 }
134 134
135 135
136#ifndef KORG_NODCOP 136#ifndef KORG_NODCOP
137 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 137 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
138 QString tmpStr; 138 QString tmpStr;
139 if (n.startsWith("mailto:")) { 139 if (n.startsWith("mailto:")) {
140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
141 //emit showIncidence(n); 141 //emit showIncidence(n);
142 return; 142 return;
143 } else if (n.startsWith("uid:")) { 143 } else if (n.startsWith("uid:")) {
144 DCOPClient *client = KApplication::kApplication()->dcopClient(); 144 DCOPClient *client = KApplication::kApplication()->dcopClient();
145 const QByteArray noParamData; 145 const QByteArray noParamData;
146 const QByteArray paramData; 146 const QByteArray paramData;
147 QByteArray replyData; 147 QByteArray replyData;
148 QCString replyTypeStr; 148 QCString replyTypeStr;
149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
150 bool foundAbbrowser = PING_ABBROWSER; 150 bool foundAbbrowser = PING_ABBROWSER;
151 151
152 if (foundAbbrowser) { 152 if (foundAbbrowser) {
153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
154 //client->send("kaddressbook","KAddressBookIface", 154 //client->send("kaddressbook","KAddressBookIface",
155 QDataStream arg(paramData, IO_WriteOnly); 155 QDataStream arg(paramData, IO_WriteOnly);
156 arg << n.mid(6); 156 arg << n.mid(6);
157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
158 return; 158 return;
159 } else { 159 } else {
160 /* 160 /*
161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
162 We start it without its main interface 162 We start it without its main interface
163 */ 163 */
164 KIconLoader* iconLoader = new KIconLoader(); 164 KIconLoader* iconLoader = new KIconLoader();
165 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 165 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
166 ActionManager::setStartedKAddressBook(true); 166 ActionManager::setStartedKAddressBook(true);
167 tmpStr = "kaddressbook --editor-only --uid "; 167 tmpStr = "kaddressbook --editor-only --uid ";
168 tmpStr += KProcess::quote(n.mid(6)); 168 tmpStr += KProcess::quote(n.mid(6));
169 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 169 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
170 return; 170 return;
171 } 171 }
172 } else { 172 } else {
173 //QTextBrowser::setSource(n); 173 //QTextBrowser::setSource(n);
174 } 174 }
175#endif 175#endif
176} 176}
177 177
178void KOEventViewer::addTag(const QString & tag,const QString & text) 178void KOEventViewer::addTag(const QString & tag,const QString & text)
179{ 179{
180 int number=text.contains("\n"); 180 int number=text.contains("\n");
181 QString str = "<" + tag + ">"; 181 QString str = "<" + tag + ">";
182 QString tmpText=text; 182 QString tmpText=text;
183 QString tmpStr=str; 183 QString tmpStr=str;
184 if(number !=-1) 184 if(number !=-1)
185 { 185 {
186 if (number > 0) { 186 if (number > 0) {
187 int pos=0; 187 int pos=0;
188 QString tmp; 188 QString tmp;
189 for(int i=0;i<=number;i++) { 189 for(int i=0;i<=number;i++) {
190 pos=tmpText.find("\n"); 190 pos=tmpText.find("\n");
191 tmp=tmpText.left(pos); 191 tmp=tmpText.left(pos);
192 tmpText=tmpText.right(tmpText.length()-pos-1); 192 tmpText=tmpText.right(tmpText.length()-pos-1);
193 tmpStr+=tmp+"<br>"; 193 tmpStr+=tmp+"<br>";
194 } 194 }
195 } 195 }
196 else tmpStr += tmpText; 196 else tmpStr += tmpText;
197 tmpStr+="</" + tag + ">"; 197 tmpStr+="</" + tag + ">";
198 mText.append(tmpStr); 198 mText.append(tmpStr);
199 } 199 }
200 else 200 else
201 { 201 {
202 str += text + "</" + tag + ">"; 202 str += text + "</" + tag + ">";
203 mText.append(str); 203 mText.append(str);
204 } 204 }
205} 205}
206 206
207void KOEventViewer::setColorMode( int m ) 207void KOEventViewer::setColorMode( int m )
208{ 208{
209 mColorMode = m; 209 mColorMode = m;
210} 210}
211void KOEventViewer::appendEvent(Event *event, int mode ) 211void KOEventViewer::appendEvent(Event *event, int mode )
212{ 212{
213 mMailSubject = ""; 213 mMailSubject = "";
214 mCurrentIncidence = event; 214 mCurrentIncidence = event;
215 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 215 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
216 topLevelWidget()->setCaption(i18n("Event Viewer")); 216 topLevelWidget()->setCaption(i18n("Event Viewer"));
217 if ( mode == 0 ) { 217 if ( mode == 0 ) {
218 addTag("h2",event->summary()); 218 addTag("h2",event->summary());
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 219f7c3..7166a01 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,256 +1,272 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27 27#ifdef DESKTOP_VERSION
28#include <qpaintdevicemetrics.h>
29#endif
28#include <kglobal.h> 30#include <kglobal.h>
29#include <klocale.h> 31#include <klocale.h>
30#include <kdebug.h> 32#include <kdebug.h>
31#include <kiconloader.h> 33#include <kiconloader.h>
32#include <kmessagebox.h> 34#include <kmessagebox.h>
33 35
34#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
35 37
36#ifndef KORG_NOPRINTER 38#ifndef KORG_NOPRINTER
37#include "calprinter.h" 39#include "calprinter.h"
38#endif 40#endif
39#include "koglobals.h" 41#include "koglobals.h"
40#include "koprefs.h" 42#include "koprefs.h"
41#include "koeventviewerdialog.h" 43#include "koeventviewerdialog.h"
42#include <qstylesheet.h> 44#include <qstylesheet.h>
43#include "kowhatsnextview.h" 45#include "kowhatsnextview.h"
44using namespace KOrg; 46using namespace KOrg;
45 47
46void WhatsNextTextBrowser::setSource(const QString& n) 48void WhatsNextTextBrowser::setSource(const QString& n)
47{ 49{
48 50
49 if (n.startsWith("event:")) { 51 if (n.startsWith("event:")) {
50 emit showIncidence(n); 52 emit showIncidence(n);
51 return; 53 return;
52 } else if (n.startsWith("todo:")) { 54 } else if (n.startsWith("todo:")) {
53 emit showIncidence(n); 55 emit showIncidence(n);
54 return; 56 return;
55 } else { 57 } else {
56 QTextBrowser::setSource(n); 58 QTextBrowser::setSource(n);
57 } 59 }
58} 60}
61void WhatsNextTextBrowser::printMe()
62{
63#ifdef DESKTOP_VERSION
64 QPrinter printer;
65 if (!printer.setup() )
66 return;
67 QPainter p;
68 p.begin ( &printer );
69 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
70 float dx, dy;
71 int wid = (m.width() * 9)/10;
72 dx = (float) wid/(float)contentsWidth ();
73 dy = (float)(m.height()) / (float)contentsHeight ();
74 float scale;
75 // scale to fit the width or height of the paper
76 if ( dx < dy )
77 scale = dx;
78 else
79 scale = dy;
80 p.translate( m.width()/10,0 );
81 p.scale( scale, scale );
82 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
83 p.end();
84#endif
85}
59 86
60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 87KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
61 const char *name) 88 const char *name)
62 : KOrg::BaseView(calendar, parent, name) 89 : KOrg::BaseView(calendar, parent, name)
63{ 90{
64 // mDateLabel = 91 // mDateLabel =
65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 92 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
66 // mDateLabel->setMargin(2); 93 // mDateLabel->setMargin(2);
67 // mDateLabel->setAlignment(AlignCenter); 94 // mDateLabel->setAlignment(AlignCenter);
68 setFont( KOPrefs::instance()->mWhatsNextFont ); 95 setFont( KOPrefs::instance()->mWhatsNextFont );
69 mView = new WhatsNextTextBrowser(this); 96 mView = new WhatsNextTextBrowser(this);
70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 97 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
71 QStyleSheet* stsh = mView->styleSheet(); 98 QStyleSheet* stsh = mView->styleSheet();
72 QStyleSheetItem * style ; 99 QStyleSheetItem * style ;
73 style = stsh->item ("h2" ); 100 style = stsh->item ("h2" );
74 if ( style ) { 101 if ( style ) {
75 style->setMargin(QStyleSheetItem::MarginAll,0); 102 style->setMargin(QStyleSheetItem::MarginAll,0);
76 } 103 }
77 style = stsh->item ("h3" ); 104 style = stsh->item ("h3" );
78 if ( style ) { 105 if ( style ) {
79 style->setMargin(QStyleSheetItem::MarginAll,0); 106 style->setMargin(QStyleSheetItem::MarginAll,0);
80 } 107 }
81 mEventViewer = 0; 108 mEventViewer = 0;
82 109
83 QBoxLayout *topLayout = new QVBoxLayout(this); 110 QBoxLayout *topLayout = new QVBoxLayout(this);
84 // topLayout->addWidget(mDateLabel); 111 // topLayout->addWidget(mDateLabel);
85 topLayout->addWidget(mView); 112 topLayout->addWidget(mView);
86 mTimer = new QTimer( this ); 113 mTimer = new QTimer( this );
87 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 114 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
88 115
89 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 116 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
90 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 117 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
91} 118}
92 119
93KOWhatsNextView::~KOWhatsNextView() 120KOWhatsNextView::~KOWhatsNextView()
94{ 121{
95} 122}
96 123
97int KOWhatsNextView::maxDatesHint() 124int KOWhatsNextView::maxDatesHint()
98{ 125{
99 return 0; 126 return 0;
100} 127}
101 128
102int KOWhatsNextView::currentDateCount() 129int KOWhatsNextView::currentDateCount()
103{ 130{
104 return 0; 131 return 0;
105} 132}
106 133
107QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 134QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
108{ 135{
109 QPtrList<Incidence> eventList; 136 QPtrList<Incidence> eventList;
110 137
111 return eventList; 138 return eventList;
112} 139}
113 140
114void KOWhatsNextView::printMe() 141void KOWhatsNextView::printMe()
115{ 142{
116#ifdef DESKTOP_VERSION 143#ifdef DESKTOP_VERSION
117 QPrinter printer; 144 mView->printMe();
118 if (!printer.setup() )
119 return;
120 QTextBrowser tb;
121 tb.setFixedSize( 600, 4000 );
122 QPainter::redirect ( tb.viewport(), &printer );
123 updateView();
124 tb.setText( mText );
125 tb.show();
126 tb.repaint();
127 tb.hide();
128 KMessageBox::information( this, i18n("Printing What's Next View!\n\nPlease close after\nprinting is finished."));
129#endif 145#endif
130} 146}
131void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 147void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
132 const QDate &td) 148 const QDate &td)
133{ 149{
134#ifndef KORG_NOPRINTER 150#ifndef KORG_NOPRINTER
135 calPrinter->preview(CalPrinter::Day, fd, td); 151 calPrinter->preview(CalPrinter::Day, fd, td);
136#endif 152#endif
137} 153}
138void KOWhatsNextView::updateConfig() 154void KOWhatsNextView::updateConfig()
139{ 155{
140 setFont( KOPrefs::instance()->mWhatsNextFont ); 156 setFont( KOPrefs::instance()->mWhatsNextFont );
141 updateView(); 157 updateView();
142 158
143} 159}
144void KOWhatsNextView::showEvent ( QShowEvent * e ) 160void KOWhatsNextView::showEvent ( QShowEvent * e )
145{ 161{
146 //qDebug("KOWhatsNextView::showEvent "); 162 //qDebug("KOWhatsNextView::showEvent ");
147 restartTimer(); 163 restartTimer();
148 QWidget::showEvent ( e ); 164 QWidget::showEvent ( e );
149} 165}
150void KOWhatsNextView::hideEvent ( QHideEvent * e) 166void KOWhatsNextView::hideEvent ( QHideEvent * e)
151{ 167{
152 //qDebug(" KOWhatsNextView::hideEvent"); 168 //qDebug(" KOWhatsNextView::hideEvent");
153 mTimer->stop(); 169 mTimer->stop();
154 QWidget::hideEvent ( e ); 170 QWidget::hideEvent ( e );
155} 171}
156void KOWhatsNextView::restartTimer() 172void KOWhatsNextView::restartTimer()
157{ 173{
158 //qDebug("KOWhatsNextView::restartTimer() "); 174 //qDebug("KOWhatsNextView::restartTimer() ");
159 mTimer->start( 300000 ); 175 mTimer->start( 300000 );
160 //mTimer->start( 5000 ); 176 //mTimer->start( 5000 );
161} 177}
162void KOWhatsNextView::updateView() 178void KOWhatsNextView::updateView()
163{ 179{
164 if ( mTimer->isActive() ) 180 if ( mTimer->isActive() )
165 restartTimer(); 181 restartTimer();
166 //qDebug("KOWhatsNextView::updateView() "); 182 //qDebug("KOWhatsNextView::updateView() ");
167 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 183 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
168 KIconLoader kil("korganizer"); 184 KIconLoader kil("korganizer");
169 QString ipath;// = new QString(); 185 QString ipath;// = new QString();
170 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 186 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
171 //<big><big><strong>" + date + "</strong></big></big>\n"; 187 //<big><big><strong>" + date + "</strong></big></big>\n";
172 mText = "<table width=\"100%\">\n"; 188 mText = "<table width=\"100%\">\n";
173 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 189 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
174#ifdef DESKTOP_VERSION 190#ifdef DESKTOP_VERSION
175 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 191 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
176#else 192#else
177 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 193 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
178#endif 194#endif
179 // mText += "<img src=\""; 195 // mText += "<img src=\"";
180 // mText += ipath; 196 // mText += ipath;
181 // mText += "\">"; 197 // mText += "\">";
182 mEventDate = QDate::currentDate(); 198 mEventDate = QDate::currentDate();
183#ifdef DESKTOP_VERSION 199#ifdef DESKTOP_VERSION
184 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 200 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
185#else 201#else
186 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 202 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
187#endif 203#endif
188 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 204 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
189 int iii; 205 int iii;
190 mTodos.clear(); 206 mTodos.clear();
191 QPtrList<Event> events; 207 QPtrList<Event> events;
192 QPtrList<Todo> todos = calendar()->todos(); 208 QPtrList<Todo> todos = calendar()->todos();
193 Todo * todo; 209 Todo * todo;
194 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 210 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
195 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 211 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
196 bool itemAdded = false; 212 bool itemAdded = false;
197 for ( iii = 0; iii < daysToShow; ++iii ) { 213 for ( iii = 0; iii < daysToShow; ++iii ) {
198 QString date; 214 QString date;
199 itemAdded = false; 215 itemAdded = false;
200 events = calendar()->events( mEventDate, true ); 216 events = calendar()->events( mEventDate, true );
201 217
202 if ( iii == 0 ) { // today !!! 218 if ( iii == 0 ) { // today !!!
203 todo = todos.first(); 219 todo = todos.first();
204 while(todo) { 220 while(todo) {
205 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 221 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
206 if ( ! itemAdded ) { 222 if ( ! itemAdded ) {
207 appendDay ( iii, mEventDate ); 223 appendDay ( iii, mEventDate );
208 //itemAdded = true; 224 //itemAdded = true;
209 225
210 } //bool reply=false, bool notRed = true, bool appendTable = false); 226 } //bool reply=false, bool notRed = true, bool appendTable = false);
211 appendEvent(todo, false, false, !itemAdded ); 227 appendEvent(todo, false, false, !itemAdded );
212 itemAdded = true; 228 itemAdded = true;
213 } 229 }
214 todo = todos.next(); 230 todo = todos.next();
215 } 231 }
216 } 232 }
217 233
218 234
219 if (events.count() > 0) { 235 if (events.count() > 0) {
220 // mText += "<p></p>"; 236 // mText += "<p></p>";
221 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 237 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
222 // mText += "<h2>"; 238 // mText += "<h2>";
223 //mText += " <img src=\""; 239 //mText += " <img src=\"";
224 //mText += ipath; 240 //mText += ipath;
225 //mText += "\">"; 241 //mText += "\">";
226 if ( ! itemAdded ) { 242 if ( ! itemAdded ) {
227 appendDay ( iii, mEventDate ); 243 appendDay ( iii, mEventDate );
228 244
229 } 245 }
230 // for first day (iii == 0) 246 // for first day (iii == 0)
231 // we may have syncevents, or events in the past, which maybe should not be diaplayed 247 // we may have syncevents, or events in the past, which maybe should not be diaplayed
232 // for that reason we cannot append <table> in appendDay () for iii == 0 248 // for that reason we cannot append <table> in appendDay () for iii == 0
233 // we must append it in the first successful call of appendEvent() 249 // we must append it in the first successful call of appendEvent()
234 Event *ev = events.first(); 250 Event *ev = events.first();
235 while(ev) { 251 while(ev) {
236 //qDebug("+++++event append %s", ev->summary().latin1()); 252 //qDebug("+++++event append %s", ev->summary().latin1());
237 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 253 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
238 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) 254 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) )
239 itemAdded = true; 255 itemAdded = true;
240 } 256 }
241 ev = events.next(); 257 ev = events.next();
242 } 258 }
243 259
244 //mText += "</table>\n"; 260 //mText += "</table>\n";
245 } 261 }
246 262
247 todo = todos.first(); 263 todo = todos.first();
248 while(todo) { 264 while(todo) {
249 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 265 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
250 if ( ! itemAdded ) { 266 if ( ! itemAdded ) {
251 appendDay ( iii, mEventDate ); 267 appendDay ( iii, mEventDate );
252 //itemAdded = true; 268 //itemAdded = true;
253 } 269 }
254 appendEvent(todo, false , iii!= 0,!itemAdded); 270 appendEvent(todo, false , iii!= 0,!itemAdded);
255 itemAdded = true; 271 itemAdded = true;
256 } 272 }
diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h
index 0231cf2..715037f 100644
--- a/korganizer/kowhatsnextview.h
+++ b/korganizer/kowhatsnextview.h
@@ -1,99 +1,100 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOWHATSNEXTVIEW_H 19#ifndef KOWHATSNEXTVIEW_H
20#define KOWHATSNEXTVIEW_H 20#define KOWHATSNEXTVIEW_H
21 21
22#include <qtextbrowser.h> 22#include <qtextbrowser.h>
23#include <qtimer.h> 23#include <qtimer.h>
24 24
25#include <korganizer/baseview.h> 25#include <korganizer/baseview.h>
26 26
27class QListView; 27class QListView;
28class QLabel; 28class QLabel;
29 29
30class KOEventViewerDialog; 30class KOEventViewerDialog;
31 31
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qwidget.h> 33#include <qwidget.h>
34class WhatsNextTextBrowser : public QTextBrowser { 34class WhatsNextTextBrowser : public QTextBrowser {
35 Q_OBJECT 35 Q_OBJECT
36 public: 36 public:
37 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {} 37 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {};
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void printMe();
40 41
41 signals: 42 signals:
42 void showIncidence(const QString &uid); 43 void showIncidence(const QString &uid);
43}; 44};
44 45
45 46
46/** 47/**
47 This class provides a view of the next events and todos 48 This class provides a view of the next events and todos
48*/ 49*/
49class KOWhatsNextView : public KOrg::BaseView 50class KOWhatsNextView : public KOrg::BaseView
50{ 51{
51 Q_OBJECT 52 Q_OBJECT
52 public: 53 public:
53 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0, 54 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0,
54 const char *name = 0); 55 const char *name = 0);
55 ~KOWhatsNextView(); 56 ~KOWhatsNextView();
56 57
57 virtual int maxDatesHint(); 58 virtual int maxDatesHint();
58 virtual int currentDateCount(); 59 virtual int currentDateCount();
59 void setEventViewer(KOEventViewerDialog* v ); 60 void setEventViewer(KOEventViewerDialog* v );
60 virtual QPtrList<Incidence> selectedIncidences(); 61 virtual QPtrList<Incidence> selectedIncidences();
61 DateList selectedDates() 62 DateList selectedDates()
62 {DateList q; 63 {DateList q;
63 return q;} 64 return q;}
64 virtual void printPreview(CalPrinter *calPrinter, 65 virtual void printPreview(CalPrinter *calPrinter,
65 const QDate &, const QDate &); 66 const QDate &, const QDate &);
66 67
67 public slots: 68 public slots:
68 virtual void updateView(); 69 virtual void updateView();
69 void printMe(); 70 void printMe();
70 virtual void showDates(const QDate &start, const QDate &end); 71 virtual void showDates(const QDate &start, const QDate &end);
71 virtual void showEvents(QPtrList<Event> eventList); 72 virtual void showEvents(QPtrList<Event> eventList);
72 void updateConfig(); 73 void updateConfig();
73 void changeEventDisplay(Event *, int); 74 void changeEventDisplay(Event *, int);
74 75
75 protected: 76 protected:
76 bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false); 77 bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false);
77 bool appendTodo(Incidence *, QString ind = "", bool isSub = false ); 78 bool appendTodo(Incidence *, QString ind = "", bool isSub = false );
78 void appendDay( int i, QDate date ); 79 void appendDay( int i, QDate date );
79 QDate mEventDate; 80 QDate mEventDate;
80 virtual void showEvent ( QShowEvent * ); 81 virtual void showEvent ( QShowEvent * );
81 virtual void hideEvent ( QHideEvent * ); 82 virtual void hideEvent ( QHideEvent * );
82 83
83 private slots: 84 private slots:
84 void showIncidence(const QString &); 85 void showIncidence(const QString &);
85 void restartTimer(); 86 void restartTimer();
86 87
87 88
88 private: 89 private:
89 //void createEventViewer(); 90 //void createEventViewer();
90 QTimer* mTimer; 91 QTimer* mTimer;
91 QTextBrowser *mView; 92 WhatsNextTextBrowser *mView;
92 QString mText; 93 QString mText;
93 // QLabel *mDateLabel; 94 // QLabel *mDateLabel;
94 KOEventViewerDialog *mEventViewer; 95 KOEventViewerDialog *mEventViewer;
95 96
96 QValueList<Incidence *> mTodos; 97 QValueList<Incidence *> mTodos;
97}; 98};
98 99
99#endif 100#endif