author | zautrix <zautrix> | 2004-09-17 00:39:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-17 00:39:46 (UTC) |
commit | 14f8adb33ca434d36e80b3b7e7e262f4ede24d0d (patch) (side-by-side diff) | |
tree | 477f0cbf3c5b4d8e5b1c01c682c5e650f34c2912 | |
parent | 8462751df135b9ad08b1269661d2c7eb18c67976 (diff) | |
download | kdepimpi-14f8adb33ca434d36e80b3b7e7e262f4ede24d0d.zip kdepimpi-14f8adb33ca434d36e80b3b7e7e262f4ede24d0d.tar.gz kdepimpi-14f8adb33ca434d36e80b3b7e7e262f4ede24d0d.tar.bz2 |
More lib changes
-rw-r--r-- | kaddressbook/kaddressbookE.pro | 2 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 10 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 328 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.h | 42 | ||||
-rw-r--r-- | libkcal/libkcalE.pro | 2 | ||||
-rw-r--r-- | libkdepim/libkdepimE.pro | 6 | ||||
-rwxr-xr-x | setZaurus3 | 24 |
7 files changed, 405 insertions, 9 deletions
diff --git a/kaddressbook/kaddressbookE.pro b/kaddressbook/kaddressbookE.pro index c027895..7eb85fd 100644 --- a/kaddressbook/kaddressbookE.pro +++ b/kaddressbook/kaddressbookE.pro @@ -1,161 +1,161 @@ TEMPLATE = app CONFIG += qt warn_on TARGET = kapi OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR=$(QPEDIR)/bin INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include DEFINES += KAB_EMBEDDED KAB_NOSPLITTER #DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOKABC KORG_NOARCHIVE KORG_NOMAIL #DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER #DEFINES += KORG_NOLVALTERNATION -#LIBS += -lmicrokdepim +LIBS += -lmicrokdepim #LIBS += -lmicrokcal LIBS += -lmicrokde LIBS += -lmicroqtcompat LIBS += -lmicrokabc LIBS += -lqpe LIBS += -ljpeg LIBS += $(QTOPIALIB) LIBS += -L$(QPEDIR)/lib LIBS += -Wl,-export-dynamic LIBS += $(GCC3EXTRALIB1) LIBS += $(GCC3EXTRALIB2) INTERFACES = \ # filteredit_base.ui \ # kofilterview_base.ui \ HEADERS = \ features/mergewidget.h \ features/distributionlistwidget.h \ kcmconfigs/addresseewidget.h \ kcmconfigs/extensionconfigdialog.h \ kcmconfigs/kcmkabconfig.h \ kcmconfigs/kabconfigwidget.h \ addresseeeditordialog.h \ addresseeeditorwidget.h \ addresseditwidget.h \ addresseeconfig.h \ addresseeutil.h \ emaileditwidget.h \ filtereditdialog.h \ kaddressbookmain.h \ kabprefs.h \ kabcore.h \ viewmanager.h \ extensionmanager.h \ extensionwidget.h \ kaddressbookview.h \ geowidget.h \ imagewidget.h \ incsearchwidget.h \ jumpbuttonbar.h \ phoneeditwidget.h \ secrecywidget.h \ keywidget.h \ nameeditdialog.h \ filter.h \ addviewdialog.h \ configurewidget.h \ viewconfigurewidget.h \ viewconfigurefieldspage.h \ viewconfigurefilterpage.h \ typecombo.h \ undo.h \ undocmds.h \ xxportmanager.h \ xxportobject.h \ xxportselectdialog.h \ details/detailsviewcontainer.h \ details/look_basic.h \ details/look_html.h \ views/kaddressbookiconview.h \ views/kaddressbooktableview.h \ views/kaddressbookcardview.h \ views/configuretableviewdialog.h \ views/configurecardviewdialog.h \ views/cardview.h \ views/colorlistbox.h \ views/contactlistview.h \ xxport/vcard_xxport.h \ xxport/kde2_xxport.h \ xxport/csv_xxport.h \ xxport/csvimportdialog.h \ xxport/opie_xxport.h \ xxport/qtopia_xxport.h \ xxport/sharpdtm_xxport.h \ #details/look_details.h \ #mainwindoiw.h \ # alarmclient.h \ # calendarview.h \ # customlistviewitem.h \ # datenavigator.h SOURCES = \ addresseeeditordialog.cpp \ addresseeeditorwidget.cpp \ addresseditwidget.cpp \ addresseeconfig.cpp \ addresseeutil.cpp \ extensionmanager.cpp \ features/mergewidget.cpp \ features/distributionlistwidget.cpp \ kcmconfigs/addresseewidget.cpp \ kcmconfigs/extensionconfigdialog.cpp \ kcmconfigs/kcmkabconfig.cpp \ kcmconfigs/kabconfigwidget.cpp \ emaileditwidget.cpp \ filtereditdialog.cpp \ mainembedded.cpp \ kaddressbookmain.cpp \ kabcore.cpp \ kabprefs.cpp \ viewmanager.cpp \ kaddressbookview.cpp \ extensionwidget.cpp \ geowidget.cpp \ imagewidget.cpp \ incsearchwidget.cpp \ jumpbuttonbar.cpp \ phoneeditwidget.cpp \ secrecywidget.cpp \ keywidget.cpp \ nameeditdialog.cpp \ filter.cpp \ addviewdialog.cpp \ configurewidget.cpp \ viewconfigurewidget.cpp \ viewconfigurefieldspage.cpp \ viewconfigurefilterpage.cpp \ undo.cpp \ undocmds.cpp \ xxportmanager.cpp \ xxportobject.cpp \ xxportselectdialog.cpp \ details/detailsviewcontainer.cpp \ details/look_basic.cpp \ details/look_html.cpp \ views/kaddressbookiconview.cpp \ views/kaddressbooktableview.cpp \ views/kaddressbookcardview.cpp \ views/configuretableviewdialog.cpp \ views/configurecardviewdialog.cpp \ views/cardview.cpp \ views/contactlistview.cpp \ views/colorlistbox.cpp \ xxport/vcard_xxport.cpp \ xxport/kde2_xxport.cpp \ xxport/csv_xxport.cpp \ xxport/csvimportdialog.cpp \ xxport/opie_xxport.cpp \ xxport/qtopia_xxport.cpp \ xxport/sharpdtm_xxport.cpp \ #details/look_details.cpp \ #mainwindow.cpp \ # calendarview.cpp \ # timespanview.cpp diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 948047a..e938e4e 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp @@ -1,580 +1,580 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qcstring.h> #include <qwhatsthis.h> #include <qdialog.h> #include <qapplication.h> #include <qlabel.h> #include <qlayout.h> #include <klocale.h> #include <kapplication.h> #include <libkcal/event.h> #include <libkcal/todo.h> #include <kdebug.h> #include <kiconloader.h> #include <krun.h> #include <kglobal.h> #include <kprocess.h> #include "koprefs.h" -#include <libkdepim/addresseeview.h> #include <kabc/stdaddressbook.h> #ifndef KORG_NODCOP #include <dcopclient.h> #include "korganizer.h" #include "koprefs.h" #include "actionmanager.h" #endif #include "koeventviewer.h" -#ifndef KORG_NOKABC -#include <kabc/stdaddressbook.h> -#define size count -#endif +//#ifndef KORG_NOKABC +//#include <kabc/stdaddressbook.h> +//#define size count +//#endif #ifdef DESKTOP_VERSION #include <kabc/addresseedialog.h> +#include <kabc/addresseeview.h> #else //DESKTOP_VERSION #include <externalapphandler.h> #include <qtopia/qcopenvelope_qws.h> #endif //DESKTOP_VERSION KOEventViewer::KOEventViewer(QWidget *parent,const char *name) : QTextBrowser(parent,name) { mSyncMode = false; mColorMode = 0; } KOEventViewer::~KOEventViewer() { } void KOEventViewer::setSource(const QString& n) { if ( n.left(3) == "uid" ) #ifdef DESKTOP_VERSION { KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); KABC::AddressBook::Iterator it; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { // LR I do not understand, why the uid string is different on zaurus and desktop QString uid = "uid://"+(*it).uid(); //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); if (n == uid ) { //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); QDialog dia( this,"dia123", true ); dia.setCaption( i18n("Details of attendee") ); QVBoxLayout lay ( &dia ); KPIM::AddresseeView av ( &dia ); av.setAddressee( (*it) ); lay.addWidget( &av ); if ( QApplication::desktop()->width() < 480 ) dia.resize( 220, 240); else { dia.resize( 400,400); } dia.exec(); break; } } return; } #else { if ( "uid:organizer" == n ) { ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); return; } QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); if (attendees.count()) { Attendee *a; for(a=attendees.first();a;a=attendees.next()) { if ( "uid:"+a->uid() == n ) { bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); return; } } } return; } //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); // the result should now arrive through method insertAttendees //QString uid = "uid:"+(*it).uid(); #endif if ( n.left(6) == "mailto" ) { // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); #ifndef DESKTOP_VERSION QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); e << n.mid(7); #endif } #ifndef KORG_NODCOP kdDebug() << "KOEventViewer::setSource(): " << n << endl; QString tmpStr; if (n.startsWith("mailto:")) { KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); //emit showIncidence(n); return; } else if (n.startsWith("uid:")) { DCOPClient *client = KApplication::kApplication()->dcopClient(); const QByteArray noParamData; const QByteArray paramData; QByteArray replyData; QCString replyTypeStr; #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) bool foundAbbrowser = PING_ABBROWSER; if (foundAbbrowser) { //KAddressbook is already running, so just DCOP to it to bring up the contact editor //client->send("kaddressbook","KAddressBookIface", QDataStream arg(paramData, IO_WriteOnly); arg << n.mid(6); client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); return; } else { /* KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. We start it without its main interface */ KIconLoader* iconLoader = new KIconLoader(); QString iconPath = iconLoader->iconPath("go",KIcon::Small); ActionManager::setStartedKAddressBook(true); tmpStr = "kaddressbook --editor-only --uid "; tmpStr += KProcess::quote(n.mid(6)); KRun::runCommand(tmpStr,"KAddressBook",iconPath); return; } } else { //QTextBrowser::setSource(n); } #endif } void KOEventViewer::addTag(const QString & tag,const QString & text) { int number=text.contains("\n"); QString str = "<" + tag + ">"; QString tmpText=text; QString tmpStr=str; if(number !=-1) { if (number > 0) { int pos=0; QString tmp; for(int i=0;i<=number;i++) { pos=tmpText.find("\n"); tmp=tmpText.left(pos); tmpText=tmpText.right(tmpText.length()-pos-1); tmpStr+=tmp+"<br>"; } } else tmpStr += tmpText; tmpStr+="</" + tag + ">"; mText.append(tmpStr); } else { str += text + "</" + tag + ">"; mText.append(str); } } void KOEventViewer::setColorMode( int m ) { mColorMode = m; } void KOEventViewer::appendEvent(Event *event, int mode ) { mMailSubject = ""; mCurrentIncidence = event; bool shortDate = KOPrefs::instance()->mShortDateInViewer; topLevelWidget()->setCaption(i18n("Event Viewer")); if ( mode == 0 ) { addTag("h2",event->summary()); } else { if ( mColorMode == 1 ) { mText +="<font color=\"#00A000\">"; } if ( mColorMode == 2 ) { mText +="<font color=\"#C00000\">"; } // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; if ( mode == 1 ) { addTag("h2",i18n( "Local: " ) +event->summary()); } else { addTag("h2",i18n( "Remote: " ) +event->summary()); } addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } mMailSubject += i18n( "Meeting " )+ event->summary(); if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This event has been cancelled!")); mText.append("<br>"); mText += "</font>"; mMailSubject += i18n("(cancelled)"); } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(event->location()+"<br>"); mMailSubject += i18n(" at ") + event->location(); } if (event->doesFloat()) { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") .arg(event->dtStartDateStr(shortDate)) .arg(event->dtEndDateStr(shortDate))); } else { mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); } } else { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1</p> ") .arg(event->dtStartStr( shortDate))); mText.append(i18n("<p><b>To:</b> %1</p>") .arg(event->dtEndStr(shortDate))); } else { mText.append(i18n("<p><b>On:</b> %1</p> ") .arg(event->dtStartDateStr( shortDate ))); mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") .arg(event->dtStartTimeStr()) .arg(event->dtEndTimeStr())); } } if (event->recurrence()->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); bool last; QDate start = QDate::currentDate(); QDate next; next = event->recurrence()->getPreviousDate( start , &last ); if ( !last ) { next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); addTag("p",i18n("<b>Next recurrence is on:</b>") ); addTag("p", KGlobal::locale()->formatDate( next, shortDate )); QDateTime nextdt = QDateTime( next, event->dtStart().time()); mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); } else { addTag("p",i18n("<b>Last recurrence was on:</b>") ); addTag("p", KGlobal::locale()->formatDate( next, shortDate )); } } else { mMailSubject += i18n(" - " )+event->dtStartStr( true ); } if (event->isAlarmEnabled()) { Alarm *alarm =event->alarms().first() ; QDateTime t = alarm->time(); int min = t.secsTo( event->dtStart() )/60; QString s =i18n("( %1 min before )").arg( min ); addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p",s); } addTag("b",i18n("Access: ")); mText.append(event->secrecyStr()+"<br>"); if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",event->description()); } formatCategories(event); formatReadOnly(event); formatAttendees(event); setText(mText); //QWhatsThis::add(this,mText); } void KOEventViewer::appendTodo(Todo *event, int mode ) { mMailSubject = ""; mCurrentIncidence = event; topLevelWidget()->setCaption(i18n("Todo Viewer")); bool shortDate = KOPrefs::instance()->mShortDateInViewer; if (mode == 0 ) addTag("h2",event->summary()); else { if ( mColorMode == 1 ) { mText +="<font color=\"#00A000\">"; } if ( mColorMode == 2 ) { mText +="<font color=\"#B00000\">"; } if ( mode == 1 ) { addTag("h2",i18n( "Local: " ) +event->summary()); } else { addTag("h2",i18n( "Remote: " ) +event->summary()); } addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } mMailSubject += i18n( "Todo " )+ event->summary(); if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This todo has been cancelled!")); mText.append("<br>"); mText += "</font>"; mMailSubject += i18n("(cancelled)"); } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(event->location()+"<br>"); mMailSubject += i18n(" at ") + event->location(); } if (event->hasDueDate()) { mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); mMailSubject += i18n(" - " )+event->dtDueStr( true ); } addTag("b",i18n("Access: ")); mText.append(event->secrecyStr()+"<br>"); if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",event->description()); } formatCategories(event); mText.append(i18n("<p><b>Priority:</b> %2</p>") .arg(QString::number(event->priority()))); mText.append(i18n("<p><i>%1 % completed</i></p>") .arg(event->percentComplete())); formatReadOnly(event); formatAttendees(event); setText(mText); } void KOEventViewer::formatCategories(Incidence *event) { if (!event->categoriesStr().isEmpty()) { if (event->categories().count() == 1) { addTag("h3",i18n("Category")); } else { addTag("h3",i18n("Categories")); } addTag("p",event->categoriesStr()); } } void KOEventViewer::formatAttendees(Incidence *event) { QPtrList<Attendee> attendees = event->attendees(); if (attendees.count()) { QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); addTag("h3",i18n("Organizer")); mText.append("<ul><li>"); #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION KABC::AddressBook *add_book = KABC::StdAddressBook::self(); KABC::Addressee::List addressList; addressList = add_book->findByEmail(event->organizer()); KABC::Addressee o = addressList.first(); if (!o.isEmpty() && addressList.size()<2) { mText += "<a href=\"uid:" + o.uid() + "\">"; mText += o.formattedName(); mText += "</a>\n"; } else { mText.append(event->organizer()); } #else //DESKTOP_VERSION mText += "<a href=\"uid:organizer\">"; mText += event->organizer(); mText += "</a>\n"; #endif //DESKTOP_VERSION #else mText.append(event->organizer()); #endif if (iconPath) { mText += " <a href=\"mailto:" + event->organizer() + "\">"; mText += "<IMG src=\"" + iconPath + "\">"; mText += "</a>\n"; } mText.append("</li></ul>"); addTag("h3",i18n("Attendees")); Attendee *a; mText.append("<ul>"); for(a=attendees.first();a;a=attendees.next()) { #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION if (a->name().isEmpty()) { addressList = add_book->findByEmail(a->email()); KABC::Addressee o = addressList.first(); if (!o.isEmpty() && addressList.size()<2) { mText += "<a href=\"uid:" + o.uid() + "\">"; mText += o.formattedName(); mText += "</a>\n"; } else { mText += "<li>"; mText.append(a->email()); mText += "\n"; } } else { mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; } #else //DESKTOP_VERSION mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; #endif //DESKTOP_VERSION #else //qDebug("nokabc "); mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; #endif if (!a->email().isEmpty()) { if (iconPath) { mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; mText += "<IMG src=\"" + iconPath + "\">"; mText += "</a>\n"; } } if (a->status() != Attendee::NeedsAction ) mText +="[" + a->statusStr() + "] "; if (a->role() == Attendee::Chair ) mText +="(" + a->roleStr().left(1) + ".)"; } mText.append("</li></ul>"); } } void KOEventViewer::appendJournal(Journal *jour, int mode ) { bool shortDate = KOPrefs::instance()->mShortDateInViewer; if (mode == 0 ) addTag("h2",i18n("Journal from: ")); else { if ( mode == 1 ) { addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); } else { addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); } addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); } topLevelWidget()->setCaption("Journal Viewer"); mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); if (!jour->description().isEmpty()) { addTag("p",jour->description()); } setText(mText); } void KOEventViewer::formatReadOnly(Incidence *event) { if (event->isReadOnly()) { addTag("p","<em>(" + i18n("read-only") + ")</em>"); } } void KOEventViewer::setSyncMode( bool b ) { mSyncMode = b; } void KOEventViewer::setTodo(Todo *event, bool clearV ) { if ( clearV ) clearEvents(); if ( mSyncMode ) { if ( clearV ) appendTodo(event,1 ); else appendTodo(event,2); } else appendTodo(event); } void KOEventViewer::setJournal(Journal *event, bool clearV ) { if ( clearV ) clearEvents(); if ( mSyncMode ) { if ( clearV ) appendJournal(event, 1); else appendJournal(event, 2); } else appendJournal(event); } void KOEventViewer::setEvent(Event *event) { clearEvents(); if ( mSyncMode ) appendEvent(event, 1); else appendEvent(event); } void KOEventViewer::addEvent(Event *event) { if ( mSyncMode ) appendEvent(event, 2); else appendEvent(event); } void KOEventViewer::clearEvents(bool now) { mText = ""; if (now) setText(mText); } void KOEventViewer::addText(QString text) { mText.append(text); setText(mText); } diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp new file mode 100644 index 0000000..2c45f21 --- a/dev/null +++ b/libkcal/kincidenceformatter.cpp @@ -0,0 +1,328 @@ +#include "kincidenceformatter.h" +#include <kstaticdeleter.h> +#include <kglobal.h> +#include <klocale.h> +#ifdef DEKTOP_VERSION +#include <kabc/stdaddressbook.h> +#define size count +#endif + +KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; +static KStaticDeleter<KIncidenceFormatter> insd; + +QString KIncidenceFormatter::getFormattedText( Incidence * inc ) +{ +// #ifndef QT_NO_INPUTDIALOG +// return QInputDialog::getItem( caption, label, items, current, editable ); +// #else +// return QString::null; +// #endif + mText = ""; + if ( inc->type() == "Event" ) + setEvent((Event *) inc ); + else if ( inc->type() == "Todo" ) + setTodo((Todo *) inc ); + return mText; +} + +KIncidenceFormatter* KIncidenceFormatter::instance() +{ + if (!mInstance) { + mInstance = insd.setObject(new KIncidenceFormatter()); + } + return mInstance; +} +KIncidenceFormatter::~KIncidenceFormatter() +{ + if (mInstance == this) + mInstance = insd.setObject(0); + //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); +} +KIncidenceFormatter::KIncidenceFormatter() +{ + mColorMode = 0; +} +void KIncidenceFormatter::setEvent(Event *event) +{ + int mode = 0; + mCurrentIncidence = event; + bool shortDate = true; + if ( mode == 0 ) { + addTag("h3",event->summary()); + } + else { + if ( mColorMode == 1 ) { + mText +="<font color=\"#00A000\">"; + } + if ( mColorMode == 2 ) { + mText +="<font color=\"#C00000\">"; + } + // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; + if ( mode == 1 ) { + addTag("h2",i18n( "Local: " ) +event->summary()); + } else { + addTag("h2",i18n( "Remote: " ) +event->summary()); + } + addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); + if ( mColorMode ) + mText += "</font>"; + } + if (event->cancelled ()) { + mText +="<font color=\"#B00000\">"; + addTag("i",i18n("This event has been cancelled!")); + mText.append("<br>"); + mText += "</font>"; + } + if (!event->location().isEmpty()) { + addTag("b",i18n("Location: ")); + mText.append(event->location()+"<br>"); + } + if (event->doesFloat()) { + if (event->isMultiDay()) { + mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") + .arg(event->dtStartDateStr(shortDate)) + .arg(event->dtEndDateStr(shortDate))); + } else { + mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); + } + } else { + if (event->isMultiDay()) { + mText.append(i18n("<p><b>From:</b> %1</p> ") + .arg(event->dtStartStr( shortDate))); + mText.append(i18n("<p><b>To:</b> %1</p>") + .arg(event->dtEndStr(shortDate))); + } else { + mText.append(i18n("<p><b>On:</b> %1</p> ") + .arg(event->dtStartDateStr( shortDate ))); + mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") + .arg(event->dtStartTimeStr()) + .arg(event->dtEndTimeStr())); + } + } + + if (event->recurrence()->doesRecur()) { + + QString recurText = event->recurrence()->recurrenceText(); + addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); + bool last; + QDate start = QDate::currentDate(); + QDate next; + next = event->recurrence()->getPreviousDate( start , &last ); + if ( !last ) { + next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); + addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) ); + //addTag("p", KGlobal::locale()->formatDate( next, shortDate )); + } else { + addTag("p",i18n("<b>Last recurrence was on:</b>") ); + addTag("p", KGlobal::locale()->formatDate( next, shortDate )); + } + } + + + if (event->isAlarmEnabled()) { + Alarm *alarm =event->alarms().first() ; + QDateTime t = alarm->time(); + int min = t.secsTo( event->dtStart() )/60; + QString s =i18n("(%1 min before)").arg( min ); + addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); + //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); + //addTag("p",s); + } + + addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); + // mText.append(event->secrecyStr()+"<br>"); + formatCategories(event); + if (!event->description().isEmpty()) { + addTag("p",i18n("<b>Details: </b>")); + addTag("p",event->description()); + } + + + formatReadOnly(event); + formatAttendees(event); + + +} + +void KIncidenceFormatter::setTodo(Todo *event ) +{ + int mode = 0; + mCurrentIncidence = event; + bool shortDate = true; + if (mode == 0 ) + addTag("h3",event->summary()); + else { + if ( mColorMode == 1 ) { + mText +="<font color=\"#00A000\">"; + } + if ( mColorMode == 2 ) { + mText +="<font color=\"#B00000\">"; + } + if ( mode == 1 ) { + addTag("h2",i18n( "Local: " ) +event->summary()); + } else { + addTag("h2",i18n( "Remote: " ) +event->summary()); + } + addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); + if ( mColorMode ) + mText += "</font>"; + } + if (event->cancelled ()) { + mText +="<font color=\"#B00000\">"; + addTag("i",i18n("This todo has been cancelled!")); + mText.append("<br>"); + mText += "</font>"; + } + + if (!event->location().isEmpty()) { + addTag("b",i18n("Location: ")); + mText.append(event->location()+"<br>"); + } + if (event->hasDueDate()) { + mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); + } + mText.append(i18n("<p><b>Priority:</b> %2</p>") + .arg(QString::number(event->priority()))); + + mText.append(i18n("<p><i>%1 % completed</i></p>") + .arg(event->percentComplete())); + addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); + formatCategories(event); + if (!event->description().isEmpty()) { + addTag("p",i18n("<b>Details: </b>")); + addTag("p",event->description()); + } + + + + formatReadOnly(event); + formatAttendees(event); + +} + +void KIncidenceFormatter::setJournal(Journal* ) +{ + +} + +void KIncidenceFormatter::formatCategories(Incidence *event) +{ + if (!event->categoriesStr().isEmpty()) { + addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); + //mText.append(event->categoriesStr()); + } +} +void KIncidenceFormatter::addTag(const QString & tag,const QString & text) +{ + int number=text.contains("\n"); + QString str = "<" + tag + ">"; + QString tmpText=text; + QString tmpStr=str; + if(number !=-1) + { + if (number > 0) { + int pos=0; + QString tmp; + for(int i=0;i<=number;i++) { + pos=tmpText.find("\n"); + tmp=tmpText.left(pos); + tmpText=tmpText.right(tmpText.length()-pos-1); + tmpStr+=tmp+"<br>"; + } + } + else tmpStr += tmpText; + tmpStr+="</" + tag + ">"; + mText.append(tmpStr); + } + else + { + str += text + "</" + tag + ">"; + mText.append(str); + } +} + +void KIncidenceFormatter::formatAttendees(Incidence *event) +{ + QPtrList<Attendee> attendees = event->attendees(); + if (attendees.count()) { + QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); + addTag("h3",i18n("Organizer")); + mText.append("<ul><li>"); +#if 0 + //ndef KORG_NOKABC + + KABC::AddressBook *add_book = KABC::StdAddressBook::self(); + KABC::Addressee::List addressList; + addressList = add_book->findByEmail(event->organizer()); + KABC::Addressee o = addressList.first(); + if (!o.isEmpty() && addressList.size()<2) { + mText += "<a href=\"uid:" + o.uid() + "\">"; + mText += o.formattedName(); + mText += "</a>\n"; + } else { + mText.append(event->organizer()); + } +#else + mText.append(event->organizer()); +#endif + if (iconPath) { + mText += " <a href=\"mailto:" + event->organizer() + "\">"; + mText += "<IMG src=\"" + iconPath + "\">"; + mText += "</a>\n"; + } + mText.append("</li></ul>"); + + addTag("h3",i18n("Attendees")); + Attendee *a; + mText.append("<ul>"); + for(a=attendees.first();a;a=attendees.next()) { +#if 0 +//ndef KORG_NOKABC + if (a->name().isEmpty()) { + addressList = add_book->findByEmail(a->email()); + KABC::Addressee o = addressList.first(); + if (!o.isEmpty() && addressList.size()<2) { + mText += "<a href=\"uid:" + o.uid() + "\">"; + mText += o.formattedName(); + mText += "</a>\n"; + } else { + mText += "<li>"; + mText.append(a->email()); + mText += "\n"; + } + } else { + mText += "<li><a href=\"uid:" + a->uid() + "\">"; + if (!a->name().isEmpty()) mText += a->name(); + else mText += a->email(); + mText += "</a>\n"; + } +#else + //qDebug("nokabc "); + mText += "<li><a href=\"uid:" + a->uid() + "\">"; + if (!a->name().isEmpty()) mText += a->name(); + else mText += a->email(); + mText += "</a>\n"; +#endif + + if (!a->email().isEmpty()) { + if (iconPath) { + mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; + mText += "<IMG src=\"" + iconPath + "\">"; + mText += "</a>\n"; + } + } + if (a->status() != Attendee::NeedsAction ) + mText +="[" + a->statusStr() + "] "; + if (a->role() == Attendee::Chair ) + mText +="(" + a->roleStr().left(1) + ".)"; + } + mText.append("</li></ul>"); + } +} + +void KIncidenceFormatter::formatReadOnly(Incidence *event) +{ + if (event->isReadOnly()) { + addTag("p","<em>(" + i18n("read-only") + ")</em>"); + } +} diff --git a/libkcal/kincidenceformatter.h b/libkcal/kincidenceformatter.h new file mode 100644 index 0000000..6165a9f --- a/dev/null +++ b/libkcal/kincidenceformatter.h @@ -0,0 +1,42 @@ +#ifndef KINCIDENCENFORMATTER_H +#define KINCIDENCENFORMATTER_H + +#include <qstring.h> +#include <qobject.h> + +#include "incidence.h" +#include "event.h" +#include "todo.h" +#include "journal.h" + +using namespace KCal; + +class KIncidenceFormatter : public QObject +{ + public: + static KIncidenceFormatter* instance(); + KIncidenceFormatter(); + ~KIncidenceFormatter(); + QString getFormattedText( Incidence * inc ); + + void setEvent(Event *event); + void setTodo(Todo *event ); + void setJournal(Journal* ); + + protected: + int mColorMode; + void addTag(const QString & tag,const QString & text); + + void formatCategories(Incidence *event); + void formatAttendees(Incidence *event); + void formatReadOnly(Incidence *event); + + private: + bool mSyncMode; + + QString mText; + Incidence* mCurrentIncidence; + static KIncidenceFormatter* mInstance; +}; + +#endif diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro index f5be980..1f5ef78 100644 --- a/libkcal/libkcalE.pro +++ b/libkcal/libkcalE.pro @@ -1,89 +1,91 @@ TEMPLATE = lib CONFIG += qt warn_on TARGET = microkcal INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include INCLUDEPATH += ../libical/src/libical INCLUDEPATH += ../libical/src/libicalss OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR = $(QPEDIR)/lib LIBS += ../libical/lib/$(PLATFORM)/libical.a LIBS += ../libical/lib/$(PLATFORM)/libicalss.a INTERFACES = \ HEADERS = \ alarm.h \ attachment.h \ attendee.h \ calendar.h \ calendarlocal.h \ calfilter.h \ calformat.h \ calstorage.h \ compat.h \ customproperties.h \ dummyscheduler.h \ duration.h \ event.h \ exceptions.h \ filestorage.h \ freebusy.h \ icaldrag.h \ icalformat.h \ icalformatimpl.h \ imipscheduler.h \ incidence.h \ incidencebase.h \ +kincidenceformatter.h \ journal.h \ period.h \ person.h \ qtopiaformat.h \ sharpformat.h \ phoneformat.h \ recurrence.h \ scheduler.h \ todo.h \ vcaldrag.h \ vcalformat.h \ versit/port.h \ versit/vcc.h \ versit/vobject.h \ SOURCES = \ alarm.cpp \ attachment.cpp \ attendee.cpp \ calendar.cpp \ calendarlocal.cpp \ calfilter.cpp \ calformat.cpp \ compat.cpp \ customproperties.cpp \ dummyscheduler.cpp \ duration.cpp \ event.cpp \ exceptions.cpp \ filestorage.cpp \ freebusy.cpp \ icaldrag.cpp \ icalformat.cpp \ icalformatimpl.cpp \ imipscheduler.cpp \ incidence.cpp \ incidencebase.cpp \ + kincidenceformatter.cpp \ journal.cpp \ period.cpp \ person.cpp \ qtopiaformat.cpp \ sharpformat.cpp \ phoneformat.cpp \ recurrence.cpp \ scheduler.cpp \ todo.cpp \ vcaldrag.cpp \ vcalformat.cpp \ versit/vcc.c \ versit/vobject.c \ diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro index 102d827..69980e3 100644 --- a/libkdepim/libkdepimE.pro +++ b/libkdepim/libkdepimE.pro @@ -1,51 +1,51 @@ TEMPLATE = lib CONFIG += qt warn_on TARGET = microkdepim INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include LIBS += -lmicrokde -LIBS += -lmicrokcal +#LIBS += -lmicrokcal LIBS += -L$(QPEDIR)/lib OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR=$(QPEDIR)/lib INTERFACES = \ HEADERS = \ categoryeditdialog.h \ categoryeditdialog_base.h \ categoryselectdialog.h \ categoryselectdialog_base.h \ externalapphandler.h \ kdateedit.h \ kdatepicker.h \ kinputdialog.h \ - kincidenceformatter.h \ kpimprefs.h \ kpimglobalprefs.h \ kprefsdialog.h \ ksyncprofile.h \ ksyncprefsdialog.h \ kcmconfigs/kcmkdepimconfig.h \ kcmconfigs/kdepimconfigwidget.h SOURCES = \ categoryeditdialog.cpp \ categoryeditdialog_base.cpp \ categoryselectdialog.cpp \ categoryselectdialog_base.cpp \ externalapphandler.cpp \ kdateedit.cpp \ kinputdialog.cpp \ kdatepicker.cpp \ - kincidenceformatter.cpp \ kpimprefs.cpp \ kpimglobalprefs.cpp \ kprefsdialog.cpp \ ksyncprofile.cpp \ ksyncprefsdialog.cpp \ kcmconfigs/kcmkdepimconfig.cpp \ kcmconfigs/kdepimconfigwidget.cpp + + diff --git a/setZaurus3 b/setZaurus3 new file mode 100755 index 0000000..2649292 --- a/dev/null +++ b/setZaurus3 @@ -0,0 +1,24 @@ +# Settings to compile KDE-Pim/Pi with gcc 3.3.2 cross compiler for Zaurus +# copy this dir to /opt/Qtopia/examples/ +# Now this file should be in the path /opt/Qtopia/examples/kdepim/setZaurus3 +# add the following line to ~/.bashrc without leading # +# alias cz='source /opt/Qtopia/examples/kdepim/setZaurus3' +# then type in terminal cz3<return> to set the variables +# for cross-compiling +export QPEDIR=/opt/Qtopia/sharp3 +export OPIEDIR=/kde_dev/opie +#export BUILD_NO_OPIE_PLUGIN=1 +export BUILD_NO_QTOPIA_PLUGIN=1 +export BUILD_NO_SHARP_PLUGIN=1 +#export BUILD_NO_GAMMU=1 +export QTDIR=/opt/Qtopia/sharp3 +#insert here path to your gcc 3.3.2 compiler +export PATH=$QTDIR/bin:/opt/cross/bin:$PATH +export TMAKEPATH=/opt/Qtopia/tmake/lib/qws/linux-sharp-g++ +export PLATFORM=zaurus3 +export RELEASE_DEBUG=release +export SHARPDTMSDK=/opt/dtm +#export RELEASE_DEBUG=debug +export GCC3EXTRALIB1=-lpng12 +export GCC3EXTRALIB2=-lz +export KDEPIM_VERSION=1.9.5c
\ No newline at end of file |