author | zautrix <zautrix> | 2004-10-29 21:05:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 21:05:07 (UTC) |
commit | 3c0edb4b4c4a77b334331749dfde776911c3a3a0 (patch) (side-by-side diff) | |
tree | 89de7078a1a062c19b2f13ededd49f471c362abf | |
parent | a7e2fe5bb10af47a239b8b014a210568cc79287a (diff) | |
download | kdepimpi-3c0edb4b4c4a77b334331749dfde776911c3a3a0.zip kdepimpi-3c0edb4b4c4a77b334331749dfde776911c3a3a0.tar.gz kdepimpi-3c0edb4b4c4a77b334331749dfde776911c3a3a0.tar.bz2 |
KO WN view fix
-rw-r--r-- | kabc/addressee.cpp | 3 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 31 | ||||
-rw-r--r-- | kabc/plugins/ldap/ldapE.pro | 2 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 42 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.h | 2 |
5 files changed, 38 insertions, 42 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 028d3bb..eec0f1f 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -135,385 +135,386 @@ bool Addressee::operator==( const Addressee &a ) const if ( uid() != a.uid() ) return false; if ( mData->name != a.mData->name ) return false; if ( mData->formattedName != a.mData->formattedName ) return false; if ( mData->familyName != a.mData->familyName ) return false; if ( mData->givenName != a.mData->givenName ) return false; if ( mData->additionalName != a.mData->additionalName ) return false; if ( mData->prefix != a.mData->prefix ) return false; if ( mData->suffix != a.mData->suffix ) return false; if ( mData->nickName != a.mData->nickName ) return false; if ( mData->birthday != a.mData->birthday ) return false; if ( mData->mailer != a.mData->mailer ) return false; if ( mData->timeZone != a.mData->timeZone ) return false; if ( mData->geo != a.mData->geo ) return false; if ( mData->title != a.mData->title ) return false; if ( mData->role != a.mData->role ) return false; if ( mData->organization != a.mData->organization ) return false; if ( mData->note != a.mData->note ) return false; if ( mData->productId != a.mData->productId ) return false; //if ( mData->revision != a.mData->revision ) return false; if ( mData->sortString != a.mData->sortString ) return false; if ( mData->secrecy != a.mData->secrecy ) return false; if ( mData->logo != a.mData->logo ) return false; if ( mData->photo != a.mData->photo ) return false; if ( mData->sound != a.mData->sound ) return false; if ( mData->agent != a.mData->agent ) return false; if ( ( mData->url.isValid() || a.mData->url.isValid() ) && ( mData->url != a.mData->url ) ) return false; if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; if ( mData->addresses != a.mData->addresses ) return false; if ( mData->keys != a.mData->keys ) return false; if ( mData->emails != a.mData->emails ) return false; if ( mData->categories != a.mData->categories ) return false; if ( mData->custom != a.mData->custom ) return false; return true; } bool Addressee::operator!=( const Addressee &a ) const { return !( a == *this ); } bool Addressee::isEmpty() const { return mData->empty; } ulong Addressee::getCsum4List( const QStringList & attList) { int max = attList.count(); ulong cSum = 0; int j,k,i; int add; for ( i = 0; i < max ; ++i ) { QString s = attList[i]; if ( ! s.isEmpty() ){ j = s.length(); for ( k = 0; k < j; ++k ) { int mul = k +1; add = s[k].unicode (); if ( k < 16 ) mul = mul * mul; int ii = i+1; add = add * mul *ii*ii*ii; cSum += add; } } } //QString dump = attList.join(","); //qDebug("csum: %d %s", cSum,dump.latin1()); return cSum; } void Addressee::computeCsum(const QString &dev) { QStringList l; //if ( !mData->name.isEmpty() ) l.append(mData->name); //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); if ( !mData->title .isEmpty() ) l.append( mData->title ); if ( !mData->role.isEmpty() ) l.append( mData->role ); if ( !mData->organization.isEmpty() ) l.append( mData->organization ); if ( !mData->note.isEmpty() ) l.append( mData->note ); if ( !mData->productId.isEmpty() ) l.append(mData->productId ); if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); // if ( !mData->logo.isEmpty() ) l.append( ); //if ( !mData->photo.isEmpty() ) l.append( ); //if ( !mData->sound.isEmpty() ) l.append( ); //if ( !mData->agent.isEmpty() ) l.append( ); if ( mData->url.isValid() ) if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); KABC::PhoneNumber::List phoneNumbers; KABC::PhoneNumber::List::Iterator phoneIter; QStringList t; for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); t.sort(); uint iii; for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->emails; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->categories; t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); t = mData->custom; t.sort(); for ( iii = 0; iii < t.count(); ++iii) if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { int find = t[iii].find (':')+1; //qDebug("lennnn %d %d ", find, t[iii].length()); if ( find < t[iii].length()) l.append( t[iii] ); } KABC::Address::List::Iterator addressIter; for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); ++addressIter ) { t = (*addressIter).asList(); t.sort(); for ( iii = 0; iii < t.count(); ++iii) l.append( t[iii] ); } uint cs = getCsum4List(l); #if 0 for ( iii = 0; iii < l.count(); ++iii) qDebug("%d***%s***",iii,l[iii].latin1()); qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); #endif setCsum( dev, QString::number (cs )); } void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) { detach(); if ( mData->name.isEmpty() ) mData->name = ad.mData->name; if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; if ( !mData->birthday.isValid() ) if ( ad.mData->birthday.isValid()) mData->birthday = ad.mData->birthday; if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; QStringList t; QStringList tAD; uint iii; // ********** phone numbers PhoneNumber::List phoneAD = ad.phoneNumbers(); PhoneNumber::List::Iterator phoneItAD; for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { bool found = false; PhoneNumber::List::Iterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { if ( ( *phoneItAD ).contains( (*it) ) ) { found = true; (*it).setType( ( *phoneItAD ).type() ); (*it).setNumber( ( *phoneItAD ).number() ); break; } } - if ( isSubSet && ! found ) + // if ( isSubSet && ! found ) + if ( ! found ) // LR try this one... mData->phoneNumbers.append( *phoneItAD ); } if ( isSubSet ) { // ************* emails; t = mData->emails; tAD = ad.mData->emails; for ( iii = 0; iii < tAD.count(); ++iii) if ( !t.contains(tAD[iii] ) ) mData->emails.append( tAD[iii] ); } // ************* categories; t = mData->categories; tAD = ad.mData->categories; for ( iii = 0; iii < tAD.count(); ++iii) if ( !t.contains(tAD[iii] ) ) mData->categories.append( tAD[iii] ); QStringList::ConstIterator it; for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { QString qualifiedName = (*it).left( (*it).find( ":" )); bool found = false; QStringList::ConstIterator itL; for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { if ( (*itL).startsWith( qualifiedName ) ) { found = true; break; } } if ( ! found ) { mData->custom.append( *it ); } } if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; if ( !mData->sound.isIntern() ) { if ( mData->sound.url().isEmpty() ) { mData->sound = ad.mData->sound; } } if ( !mData->agent.isIntern() ) { if ( mData->agent.url().isEmpty() ) { mData->agent = ad.mData->agent; } } { Key::List::Iterator itA; for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { bool found = false; Key::List::Iterator it; for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { if ( (*it) == (*itA)) { found = true; break; } } if ( ! found ) { mData->keys.append( *itA ); } } } KABC::Address::List::Iterator addressIterA; for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { bool found = false; KABC::Address::List::Iterator addressIter; for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); ++addressIter ) { if ( (*addressIter) == (*addressIterA)) { found = true; (*addressIter).setType( (*addressIterA).type() ); break; } } if ( isSubSet && ! found ) { mData->addresses.append( *addressIterA ); } } //qDebug("merge contact %s ", ad.uid().latin1()); setUid( ad.uid() ); setRevision( ad.revision() ); } bool Addressee::removeVoice() { PhoneNumber::List phoneN = phoneNumbers(); PhoneNumber::List::Iterator phoneIt; bool found = false; for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found if ((*phoneIt).type() - PhoneNumber::Voice ) { (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); insertPhoneNumber( (*phoneIt) ); found = true; } } } return found; } bool Addressee::containsAdr(const Addressee& ad ) { if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; // compare phone numbers PhoneNumber::List phoneN = ad.phoneNumbers(); PhoneNumber::List::Iterator phoneIt; bool found = false; for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { bool found = false; PhoneNumber::List phoneL = ad.phoneNumbers(); PhoneNumber::List::Iterator phoneItL; for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { found = true; break; } } if ( ! found ) return false; } return true; } void Addressee::simplifyAddresses() { Address::List list; Address::List::Iterator it; Address::List::Iterator it2; for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { it2 = it; ++it2; for( ; it2 != mData->addresses.end(); ++it2 ) { if ( (*it) == (*it2) ) { list.append( *it ); break; } } } for( it = list.begin(); it != list.end(); ++it ) { removeAddress( (*it) ); } list.clear(); int max = 2; if ( mData->url.isValid() ) max = 1; if ( mData->addresses.count() <= max ) return ; int count = 0; for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { if ( count >= max ) list.append( *it ); ++count; } for( it = list.begin(); it != list.end(); ++it ) { removeAddress( (*it) ); } } // removes all emails but the first // needed by phone sync void Addressee::simplifyEmails() { if ( mData->emails.count() == 0 ) return ; QString email = mData->emails.first(); detach(); mData->emails.clear(); mData->emails.append( email ); } void Addressee::simplifyPhoneNumbers() { int max = 4; int inList = mData->phoneNumbers.count(); KABC::PhoneNumber::List removeNumbers; KABC::PhoneNumber::List::Iterator phoneIter; if ( inList > max ) { // delete non-preferred numbers for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { if ( inList > max ) { if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { removeNumbers.append( ( *phoneIter ) ); diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 3d82553..abb3b3b 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp @@ -1,245 +1,240 @@ /* This file is part of libkabc. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kapplication.h> #include <klocale.h> #include "phonenumber.h" using namespace KABC; PhoneNumber::PhoneNumber() : mType( Home ) { init(); } PhoneNumber::PhoneNumber( const QString &number, int type ) : mType( type ), mNumber( number ) { init(); } PhoneNumber::~PhoneNumber() { } void PhoneNumber::init() { mId = KApplication::randomString( 8 ); } bool PhoneNumber::operator==( const PhoneNumber &p ) const { if ( mNumber != p.mNumber ) return false; if ( mType != p.mType ) return false; return true; } bool PhoneNumber::operator!=( const PhoneNumber &p ) const { return !( p == *this ); } bool PhoneNumber::simplifyNumber() { QString Number; int i; Number = mNumber.stripWhiteSpace (); mNumber = ""; for ( i = 0; i < Number.length(); ++i) { if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) mNumber += Number.at(i); } return ( mNumber.length() > 0 ); } // make cellphone compatible void PhoneNumber::simplifyType() { if ( mType & Fax ) mType = Fax; else if ( mType & Cell ) mType = Cell; else if ( mType & Work ) mType = Work ; else if ( mType & Home ) mType = Home; else mType = Pref; } bool PhoneNumber::contains( const PhoneNumber &p ) { - QString Number; - QString Num; - uint i; - Number = mNumber.stripWhiteSpace (); - Num = ""; - for ( i = 0; i < Number.length(); ++i) { - if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) - Num += Number.at(i); - } - QString NumberR; - QString NumR; - NumberR = p.mNumber.stripWhiteSpace (); - NumR = ""; - for ( i = 0; i < NumberR.length(); ++i) { - if ( NumberR.at(i).isDigit() || NumberR.at(i) == '+'|| NumberR.at(i) == '*'|| NumberR.at(i) == '#' ) - NumR += NumberR.at(i); - } - return (Num == NumR); + PhoneNumber myself; + PhoneNumber other; + myself = *this; + other = p; + myself.simplifyNumber(); + other.simplifyNumber(); + if ( myself.number() != other.number ()) + return false; + myself.simplifyType(); + other.simplifyType(); + if ( myself.type() == other.type()) + return true; + return false; } void PhoneNumber::setId( const QString &id ) { mId = id; } QString PhoneNumber::id() const { return mId; } void PhoneNumber::setNumber( const QString &number ) { mNumber = number; } QString PhoneNumber::number() const { return mNumber; } void PhoneNumber::setType( int type ) { mType = type; } int PhoneNumber::type() const { return mType; } QString PhoneNumber::typeLabel() const { QString label; bool first = true; TypeList list = typeList(); TypeList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); if ( first ) first = false; } } return label; } QString PhoneNumber::label() const { return typeLabel( type() ); } PhoneNumber::TypeList PhoneNumber::typeList() { TypeList list; list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; return list; } QString PhoneNumber::label( int type ) { return typeLabel( type ); } QString PhoneNumber::typeLabel( int type ) { QString typeString; if ((type & Home) == Home) typeString += i18n("Home"); else if ((type & Work) == Work) typeString += i18n("Work"); if (!typeString.isEmpty()) typeString += " "; if ((type & Cell) == Cell) typeString += i18n("Mobile"); else if ((type & Fax) == Fax) typeString += i18n("Fax"); else if ((type & Msg) == Msg) typeString += i18n("Messenger"); else if ((type & Voice) == Voice) { // add nothing in case of the Voice flag // typeString += i18n("Voice"); } else if ((type & Video) == Video) typeString += i18n("Video"); else if ((type & Bbs) == Bbs) typeString += i18n("Mailbox"); else if ((type & Modem) == Modem) typeString += i18n("Modem"); else if ((type & Car) == Car) typeString += i18n("Car"); else if ((type & Isdn) == Isdn) typeString += i18n("ISDN"); else if ((type & Pcs) == Pcs) typeString += i18n("PCS"); else if ((type & Pager) == Pager) typeString += i18n("Pager"); else if ((type & Sip) == Sip) typeString += i18n("SIP"); // add the prefered flag if (!typeString.isEmpty()) typeString += " "; /* if ((type & Pref) == Pref) typeString += i18n("(p)"); */ //if we still have no match, return "other" if (typeString.isEmpty()) return i18n("Other"); return typeString; } QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) { return s << phone.mId << phone.mType << phone.mNumber; } QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) { s >> phone.mId >> phone.mType >> phone.mNumber; return s; } diff --git a/kabc/plugins/ldap/ldapE.pro b/kabc/plugins/ldap/ldapE.pro index df3c94c..57b6f84 100644 --- a/kabc/plugins/ldap/ldapE.pro +++ b/kabc/plugins/ldap/ldapE.pro @@ -1,21 +1,21 @@ TEMPLATE = lib CONFIG += qt warn_on release #release debug TARGET = microkabc_ldap INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR = $(QPEDIR)/lib -LIBS += -lmicrokde -lkamicrokabc +LIBS += -lmicrokde -lmicrokabc LIBS += -L$(QPEDIR)/lib INTERFACES = \ HEADERS = \ resourceldap.h \ resourceldapconfig.h SOURCES = \ resourceldap.cpp \ resourceldapconfig.cpp diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index aa33588..2f7409d 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -1,706 +1,706 @@ /* 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 <qlayout.h> #include <qtextbrowser.h> #include <qtextcodec.h> #include <qfileinfo.h> #include <qlabel.h> #include <qapplication.h> #include <kglobal.h> #include <klocale.h> #include <kdebug.h> #include <kiconloader.h> #include <kmessagebox.h> #include <libkcal/calendar.h> #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "koglobals.h" #include "koprefs.h" #include "koeventviewerdialog.h" #include <qstylesheet.h> #include "kowhatsnextview.h" using namespace KOrg; void WhatsNextTextBrowser::setSource(const QString& n) { if (n.startsWith("event:")) { emit showIncidence(n); return; } else if (n.startsWith("todo:")) { emit showIncidence(n); return; } else { QTextBrowser::setSource(n); } } KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, const char *name) : KOrg::BaseView(calendar, parent, name) { // mDateLabel = // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); // mDateLabel->setMargin(2); // mDateLabel->setAlignment(AlignCenter); setFont( KOPrefs::instance()->mWhatsNextFont ); mView = new WhatsNextTextBrowser(this); connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); QStyleSheet* stsh = mView->styleSheet(); QStyleSheetItem * style ; - style = stsh->item ("a" ); - if ( style ) { - style->setMargin(QStyleSheetItem::MarginAll,0); - } style = stsh->item ("h2" ); if ( style ) { style->setMargin(QStyleSheetItem::MarginAll,0); } style = stsh->item ("h3" ); if ( style ) { style->setMargin(QStyleSheetItem::MarginAll,0); } - style = stsh->item ("table" ); - if ( style ) { - style->setMargin(QStyleSheetItem::MarginAll,0); - } mEventViewer = 0; QBoxLayout *topLayout = new QVBoxLayout(this); // topLayout->addWidget(mDateLabel); topLayout->addWidget(mView); mTimer = new QTimer( this ); connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); } KOWhatsNextView::~KOWhatsNextView() { } int KOWhatsNextView::maxDatesHint() { return 0; } int KOWhatsNextView::currentDateCount() { return 0; } QPtrList<Incidence> KOWhatsNextView::selectedIncidences() { QPtrList<Incidence> eventList; return eventList; } void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Day, fd, td); #endif } void KOWhatsNextView::updateConfig() { setFont( KOPrefs::instance()->mWhatsNextFont ); updateView(); } void KOWhatsNextView::showEvent ( QShowEvent * e ) { //qDebug("KOWhatsNextView::showEvent "); restartTimer(); QWidget::showEvent ( e ); } void KOWhatsNextView::hideEvent ( QHideEvent * e) { //qDebug(" KOWhatsNextView::hideEvent"); mTimer->stop(); QWidget::hideEvent ( e ); } void KOWhatsNextView::restartTimer() { //qDebug("KOWhatsNextView::restartTimer() "); mTimer->start( 300000 ); //mTimer->start( 5000 ); } void KOWhatsNextView::updateView() { if ( mTimer->isActive() ) restartTimer(); //qDebug("KOWhatsNextView::updateView() "); // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); KIconLoader kil("korganizer"); QString ipath;// = new QString(); // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); //<big><big><strong>" + date + "</strong></big></big>\n"; - mText = "<qt><table width=\"100%\">\n"; + mText = "<table width=\"100%\">\n"; //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; #ifdef DESKTOP_VERSION mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; #else mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; #endif // mText += "<img src=\""; // mText += ipath; // mText += "\">"; mEventDate = QDate::currentDate(); #ifdef DESKTOP_VERSION mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; #else mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; #endif mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; int iii; mTodos.clear(); QPtrList<Event> events; QPtrList<Todo> todos = calendar()->todos(); Todo * todo; //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; int daysToShow = KOPrefs::instance()->mWhatsNextDays ; bool itemAdded = false; for ( iii = 0; iii < daysToShow; ++iii ) { QString date; itemAdded = false; events = calendar()->events( mEventDate, true ); if ( iii == 0 ) { // today !!! todo = todos.first(); while(todo) { if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { if ( ! itemAdded ) { appendDay ( iii, mEventDate ); itemAdded = true; } appendEvent(todo); } todo = todos.next(); } } if (events.count() > 0) { // mText += "<p></p>"; // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); // mText += "<h2>"; //mText += " <img src=\""; //mText += ipath; //mText += "\">"; if ( ! itemAdded ) { appendDay ( iii, mEventDate ); - itemAdded = true; } + // for first day (iii == 0) + // we may have syncevents, or events in the past, which maybe should nor be diaplayed + // for that reason we cannot append <table> in appendDay () for iii == 0 + // we must append it in the first successful call of appendEvent() Event *ev = events.first(); while(ev) { //qDebug("+++++event append %s", ev->summary().latin1()); if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { - appendEvent(ev, false , iii!= 0 ); + if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) + itemAdded = true; } ev = events.next(); } //mText += "</table>\n"; } todo = todos.first(); while(todo) { if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { if ( ! itemAdded ) { appendDay ( iii, mEventDate ); itemAdded = true; } appendEvent(todo); } todo = todos.next(); } - if ( !itemAdded && iii == 0 ) { + if ( !itemAdded && iii == 0 ) { // appendDay ( iii, mEventDate ); //mText += "<table>"; // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; //mText +="</table>"; } - if ( itemAdded ) + if ( itemAdded ) mText += "</table>\n"; mEventDate = mEventDate.addDays( 1 ); } int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; if (todos.count() > 0 && topmostPrios > 0 ) { // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); // mText += "<h2>"; //<img src=\""; // mText += ipath; // mText += "\">"; // mText += i18n("Overdue To-Do:") + "</h2>\n"; //mText += "<ul>\n"; bool gotone = false; int priority = 1; int priosFound = 0; #ifdef DESKTOP_VERSION mText +="<p></p>"; #endif mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; mText += "<ul>\n"; while (!gotone && priority<6) { todo = todos.first(); while(todo) { if (!todo->isCompleted() && (todo->priority() == priority) ) { if ( appendTodo(todo) ) gotone = true; } todo = todos.next(); } if ( gotone ) { gotone = false; ++priosFound; if ( priosFound == topmostPrios ) break; } priority++; // kdDebug() << "adding the todos..." << endl; } mText += "</ul>\n"; } int replys = 0; events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); if (events.count() > 0) { Event *ev = events.first(); while(ev) { Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { if (me->status()==Attendee::NeedsAction && me->RSVP()) { if (replys == 0) { mText += "<p></p>"; // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); //mText += "<h2>"; //<img src=\""; // mText += ipath; // mText += "\">"; //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; mText += "<table>\n"; } replys++; appendEvent(ev,true); } } ev = events.next(); } } todos = calendar()->todos(); if (todos.count() > 0) { Todo *to = todos.first(); while(to) { if ( !to->isCompleted() ){ Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { if (me->status()==Attendee::NeedsAction && me->RSVP()) { if (replys == 0) { mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; mText += "<table>\n"; } replys++; appendEvent(to, true); } } } to = todos.next(); } } if (replys > 0 ) mText += "</table>\n"; - mText += "</td></tr>\n</table></qt>\n"; + mText += "</td></tr>\n</table>\n"; mView->setText(mText); mView->setFocus(); // QPixmap bPix = SmallIcon( "back" ); // qDebug("xxxxxxxxxxxxxxxxxxxxx "); // QWidget* test = new QWidget(); // test->setBackgroundMode(FixedPixmap ); // test->setBackgroundPixmap ( bPix ); // test->resize( 300, 400 ); // test->show(); // mView->setBackgroundMode(FixedPixmap ); // mView->setBackgroundPixmap ( bPix ); - // qDebug("%s ",mText.latin1()); + qDebug("%s ",mText.latin1()); } void KOWhatsNextView::appendDay( int i, QDate eventDate ) { QString date; QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { if ( i == 0 ) { - mText += "<table>\n"; + //mText += "<table>\n"; return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; } else if ( i == 1 ) date = "<em><font color=\"#000080\">" + day + "</font></em>" ; else date = "<em><font color=\"#000080\">" + day + "</font></em>"; mText += "<h2>" + date + "</h2>\n"; //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; mText += "<table>\n"; } else { if ( i == 0 ) { - mText += "<table>\n"; + //mText += "<table>\n"; return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; } #ifdef DESKTOP_VERSION else if ( i == 1 ) { date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; } else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; #else else if ( i == 1 ) { date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; } else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; #endif mText += "<h2>" + date + "</h2>\n"; //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; mText += "<table>\n"; } } void KOWhatsNextView::showDates(const QDate &, const QDate &) { updateView(); } void KOWhatsNextView::showEvents(QPtrList<Event>) { } void KOWhatsNextView::changeEventDisplay(Event *, int action) { switch(action) { case KOGlobals::EVENTADDED: updateView(); break; case KOGlobals::EVENTEDITED: updateView(); break; case KOGlobals::EVENTDELETED: updateView(); break; default: updateView(); kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; } } -void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) +bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) { if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) - return; + return false; QDateTime cdt = QDateTime::currentDateTime(); QDateTime noc; QString tempText; + if ( appendTable && !notRed ) { + tempText = "<table>"; + } bool ok = true; if ( reply ) { noc = ev->getNextOccurence( cdt, &ok ); if (! ok && ev->type() == "Event") - return; + return false; } tempText += "<tr><td><b>"; if (ev->type()=="Event") { if (reply) { if (!ev->doesFloat()) tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; else tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; } else { if (!ev->doesFloat()) { Event *event = static_cast<Event *>(ev); QDateTime st,end; if ( event->recurrence()->doesRecur() ) { QDate recDate= mEventDate; int days = event->dtStart().date().daysTo (event->dtEnd().date() ); while ( ! event->recursOn( recDate ) ) { recDate = recDate.addDays( -1 ); } st = QDateTime ( recDate, event->dtStart().time() ); end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); } else { st = event->dtStart(); end = event->dtEnd(); } QString dateText; // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); if ( st.date() < mEventDate ) dateText = "++:++-"; else dateText = event->dtStartTimeStr() + "-"; if ( end.date() > mEventDate ) dateText += "++:++"; else dateText += event->dtEndTimeStr(); if ( notRed ) tempText += dateText; else { if ( end < cdt ) { if ( !KOPrefs::instance()->mWNViewShowsPast ) - return; + return false; tempText += "<font color=\"#F00000\">" + dateText + "</font>"; } else if ( st < cdt ) tempText += "<font color=\"#008000\">" + dateText + "</font>"; else tempText += dateText; } } else { tempText += i18n("Allday:"); } } } else { mTodos.append( ev ); tempText += i18n("ToDo:"); if (reply) { tempText += " "; if ( noc != cdt ) { tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; } } else { if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; QString dfs = KGlobal::locale()->dateFormatShort(); KGlobal::locale()->setDateFormatShort("%d.%b"); tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; KGlobal::locale()->setDateFormatShort(dfs); } else { if (!ev->doesFloat() ) if( ( (Todo*)ev)->dtDue() < cdt ) { tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; } else tempText +=((Todo*)ev)->dtDueTimeStr(); mTodos.append( ev ); } } } tempText += "</b></td><td>"; bool needClose = false; if ( ev->cancelled() ) { tempText += "<font color=\"#F00000\">[c"; needClose =true; } if ( ev->isAlarmEnabled() ) { if ( !needClose) tempText +="["; tempText += "a"; needClose =true; } if ( ev->description().length() > 0 ) { if ( !needClose) tempText +="["; tempText += "i"; needClose =true; } if ( ev->recurrence()->doesRecur() ) { if ( !needClose) tempText +="["; tempText += "r"; needClose =true; } if ( needClose ) { tempText += "] "; } if ( ev->cancelled() ) tempText += "</font>"; tempText += "<a "; if (ev->type()=="Event") tempText += "href=\"event:"; if (ev->type()=="Todo") tempText += "href=\"todo:"; tempText += ev->uid() + "\">"; if ( ev->summary().length() > 0 ) tempText += ev->summary(); else tempText += i18n("-no summary-"); tempText += "</a>"; if ( KOPrefs::instance()->mWNViewShowLocation ) if ( !ev->location().isEmpty() ) tempText += " ("+ev->location() +")"; if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) tempText += " ["+ev->relatedTo()->summary() +"]"; tempText += "</td></tr>\n"; mText += tempText; + return true; } bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) { if ( mTodos.find( ev ) != mTodos.end() ) return false; mTodos.append( ev ); if ( !isSub ) mText += "<p>"; else mText += "<li>"; mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; mText += ind; bool needClose = false; if ( ev->cancelled() ) { mText += "<font color=\"#F00000\">[c"; needClose =true; } if ( ev->isAlarmEnabled() ) { if ( !needClose) mText +="["; mText += "a"; needClose =true; } if ( ev->description().length() > 0 ) { if ( !needClose) mText +="["; mText += "i"; needClose =true; } // if ( ev->recurrence()->doesRecur() ) { // if ( !needClose) // mText +="("; // mText += "r"; // needClose =true; // } if ( needClose ) mText += "] "; if ( ev->cancelled() ) mText += "</font>"; mText += "<a href=\"todo:" + ev->uid() + "\">"; mText += ev->summary(); mText += "</a>"; if ( ((Todo*)ev)->hasDueDate () ) { QString year = ""; int ye = ((Todo*)ev)->dtDue().date().year(); if ( QDateTime::currentDateTime().date().year() != ye ) year = QString::number( ye ); QString dfs = KGlobal::locale()->dateFormatShort(); KGlobal::locale()->setDateFormatShort("%d.%b"); mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; KGlobal::locale()->setDateFormatShort(dfs); } if ( KOPrefs::instance()->mWNViewShowLocation ) if ( !ev->location().isEmpty() ) mText += " ("+ev->location() +")"; if ( !isSub ) { if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) mText += " ["+ev->relatedTo()->summary() +"]"; mText += "</p>\n"; } else { ind += "-"; mText += "</li>\n"; } QPtrList<Incidence> Relations = ev->relations(); Incidence *to; for (to=Relations.first();to;to=Relations.next()) { if (!((Todo*)to)->isCompleted()) appendTodo( to, ind , true ); } return true; } /* void KOWhatsNextView::createEventViewer() { if (!mEventViewer) { mEventViewer = new KOEventViewerDialog(this); } } */ void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) { mEventViewer = v; } // TODO: Create this function in CalendarView and remove it from here void KOWhatsNextView::showIncidence(const QString &uid) { if ( !mEventViewer ) { qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); return; } //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); if (uid.startsWith("event:")) { #ifdef DESKTOP_VERSION Event *event = calendar()->event(uid.mid(8)); #else Event *event = calendar()->event(uid.mid(6)); #endif //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); if (!event) return; //createEventViewer(); mEventViewer->setEvent(event); } else if (uid.startsWith("todo:")) { #ifdef DESKTOP_VERSION Todo *todo = calendar()->todo(uid.mid(7)); #else Todo *todo = calendar()->todo(uid.mid(5)); #endif if (!todo) return; //createEventViewer(); mEventViewer->setTodo(todo); } else { return; } mEventViewer->showMe(); mEventViewer->raise(); } diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h index 1118bdd..9049268 100644 --- a/korganizer/kowhatsnextview.h +++ b/korganizer/kowhatsnextview.h @@ -1,96 +1,96 @@ /* 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. */ #ifndef KOWHATSNEXTVIEW_H #define KOWHATSNEXTVIEW_H #include <qtextbrowser.h> #include <qtimer.h> #include <korganizer/baseview.h> class QListView; class QLabel; class KOEventViewerDialog; class WhatsNextTextBrowser : public QTextBrowser { Q_OBJECT public: WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {} void setSource(const QString &); signals: void showIncidence(const QString &uid); }; /** This class provides a view of the next events and todos */ class KOWhatsNextView : public KOrg::BaseView { Q_OBJECT public: KOWhatsNextView(Calendar *calendar, QWidget *parent = 0, const char *name = 0); ~KOWhatsNextView(); virtual int maxDatesHint(); virtual int currentDateCount(); void setEventViewer(KOEventViewerDialog* v ); virtual QPtrList<Incidence> selectedIncidences(); DateList selectedDates() {DateList q; return q;} virtual void printPreview(CalPrinter *calPrinter, const QDate &, const QDate &); public slots: virtual void updateView(); virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); void updateConfig(); void changeEventDisplay(Event *, int); protected: - void appendEvent(Incidence *, bool reply=false, bool notRed = true); + bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false); bool appendTodo(Incidence *, QString ind = "", bool isSub = false ); void appendDay( int i, QDate date ); QDate mEventDate; virtual void showEvent ( QShowEvent * ); virtual void hideEvent ( QHideEvent * ); private slots: void showIncidence(const QString &); void restartTimer(); private: //void createEventViewer(); QTimer* mTimer; QTextBrowser *mView; QString mText; // QLabel *mDateLabel; KOEventViewerDialog *mEventViewer; QValueList<Incidence *> mTodos; }; #endif |