author | zautrix <zautrix> | 2005-01-14 11:37:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-14 11:37:40 (UTC) |
commit | 61c95ce0295f1397db6499c5b468a9fb3d32a0f4 (patch) (side-by-side diff) | |
tree | 2bceecc46d42a572adfad7d8e5000d1534642cbd /kabc | |
parent | a46ecf5ed81460ec9a4e457798e1bf0fb74c5624 (diff) | |
download | kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.zip kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.tar.gz kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.tar.bz2 |
made kapi saving faster
-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kabc/picture.cpp | 38 | ||||
-rw-r--r-- | kabc/vcard/ContentLine.cpp | 30 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 77 |
4 files changed, 99 insertions, 48 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3ce733d..568dfc4 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -1684,4 +1684,5 @@ void Addressee::dump() const { return; +#if 0 kdDebug(5700) << "Addressee {" << endl; @@ -1747,4 +1748,5 @@ void Addressee::dump() const kdDebug(5700) << "}" << endl; +#endif } diff --git a/kabc/picture.cpp b/kabc/picture.cpp index 6a34b98..57aa297 100644 --- a/kabc/picture.cpp +++ b/kabc/picture.cpp @@ -54,14 +54,40 @@ Picture::~Picture() bool Picture::operator==( const Picture &p ) const { - if ( mIntern != p.mIntern ) return false; - + //qDebug("compare PIC "); + if ( mUndefined && p.mUndefined ) { + //qDebug("compare PIC true 1 "); + return true; + } + if ( mUndefined || p.mUndefined ) { + //qDebug("compare PIC false 1"); + return false; + } + // now we should deal with two defined pics! + if ( mIntern != p.mIntern ) { + //qDebug("compare PIC false 2"); + return false; + } if ( mIntern ) { - if ( mData != p.mData ) + //qDebug("mIntern "); + if ( mData.isNull() && p.mData.isNull() ) { + //qDebug("compare PIC true 2 "); + return true; + } + if ( mData.isNull() || p.mData.isNull() ){ + //qDebug("compare PIC false 3-1"); + + return false; + } + if ( mData != p.mData ) { + //qDebug("compare PIC false 3"); return false; + } } else { - if ( mUrl != p.mUrl ) - return false; + if ( mUrl != p.mUrl ) { + //qDebug("compare PIC false 4"); + return false; + } } - + //qDebug("compare PIC true "); return true; } diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index c368172..2f88cde 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp @@ -274,4 +274,31 @@ ContentLine::_parse() ContentLine::_assemble() { + //strRep_.truncate(0); + QString line; + if (!group_.isEmpty()) + line = group_ + '.'; + line += name_; + ParamListIterator it(paramList_); + for (; it.current(); ++it) + line += ";" + it.current()->asString(); + + if (value_ != 0) + line += ":" + value_->asString(); + + line = line.replace( QRegExp( "\n" ), "\\n" ); + + // Fold lines longer than 72 chars + const int maxLen = 72; + uint cursor = 0; + QString cut; + while( line.length() > ( cursor + 1 ) * maxLen ) { + cut += line.mid( cursor * maxLen, maxLen ); + cut += "\r\n "; + ++cursor; + } + cut += line.mid( cursor * maxLen ); + strRep_ = cut.latin1(); + //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); +#if 0 vDebug("Assemble (argl) - my name is \"" + name_ + "\""); strRep_.truncate(0); @@ -308,5 +335,6 @@ ContentLine::_assemble() } strRep_ += line.mid( cursor * maxLen ); - //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); + qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); +#endif } diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index bc80707..49bfe43 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp @@ -24,4 +24,7 @@ #include <qcstring.h> #include <qstrlist.h> +#include <qstringlist.h> +#include <qstring.h> +#include <qvaluelist.h> #include <VCardEntity.h> @@ -97,28 +100,27 @@ VCard::~VCard() VCard::_parse() { - vDebug("parse() called"); - QStrList l; + + QStringList l; + QStrList sl; - RTokenise(strRep_, "\r\n", l); + RTokenise(strRep_, "\r\n", sl); - if (l.count() < 3) { // Invalid VCARD ! - vDebug("Invalid vcard"); + if (sl.count() < 3) { // Invalid VCARD ! + //qDebug("invalid vcard "); return; } - + l = QStringList::fromStrList( sl ); // Get the first line - QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); - - vDebug("Begin line == \"" + beginLine + "\""); + QString beginLine = l[0].stripWhiteSpace(); // Remove extra blank lines - while (QCString(l.last()).isEmpty()) + while (l.last().isEmpty()) l.remove(l.last()); // Now we know this is the last line - QCString endLine = l.last(); + QString endLine = l.last(); // Trash the first and last lines as we have seen them. - l.remove(0u); + l.remove(l.first()); l.remove(l.last()); @@ -133,6 +135,6 @@ VCard::_parse() } - QCString firstPart(beginLine.left(split)); - QCString valuePart(beginLine.mid(split + 1)); + QString firstPart(beginLine.left(split)); + QString valuePart(beginLine.mid(split + 1)); split = firstPart.find('.'); @@ -143,11 +145,11 @@ VCard::_parse() } - if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! - vDebug("No BEGIN"); + if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! + qDebug("no BEGIN in vcard "); return; } - if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! - vDebug("No VCARD"); + if (valuePart.left(5) != "VCARD") { // Not a vcard ! + qDebug("not a VCARD "); return; } @@ -160,40 +162,28 @@ VCard::_parse() // Handle folded lines. - QStrList refolded; - - QStrListIterator it(l); + QStringList refolded; - QCString cur; - for (; it.current(); ++it) { + QStringList::Iterator it = l.begin(); - cur = it.current(); + QString cur; + for (; it != l.end(); ++it) { + cur = (*it); ++it; - - while ( - it.current() && - it.current()[0] == ' ' && - strlen(it.current()) != 1) - { - cur += it.current() + 1; + while ( it!= l.end() && (*it).at(0) == ' ' && (*it).length()!= 1) { + cur += (*it) ; ++it; } - --it; - refolded.append(cur); } - - QStrListIterator it2(refolded); - - for (; it2.current(); ++it2) { - vDebug("New contentline using \"" + QCString(it2.current()) + "\""); - ContentLine * cl = new ContentLine(it2.current()); - + QStringList::Iterator it2 = refolded.begin(); + for (; it2 != refolded.end(); ++it2) { + ContentLine * cl = new ContentLine(QCString((*it2).latin1())); cl->parse(); if (cl->value() == 0) { - qDebug("Content line could not be parsed. Discarded: %s", it2.current()); + qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); delete cl; } @@ -205,4 +195,8 @@ VCard::_parse() // LAST LINE + + // LR: sorry, but the remaining code in this method makes no sense + +#if 0 split = endLine.find(':'); @@ -225,4 +219,5 @@ VCard::_parse() if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! return; +#endif } |