summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--kabc/vcardparser/vcard.cpp2
-rw-r--r--kabc/vcardparser/vcardline.cpp14
-rw-r--r--kabc/vcardparser/vcardline.h7
-rw-r--r--kabc/vcardparser/vcardparser.cpp8
-rw-r--r--kabc/vcardparser/vcardtool.cpp86
-rw-r--r--kaddressbook/views/cardview.cpp9
7 files changed, 67 insertions, 61 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index bc0c62a..97c8154 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,103 +1,105 @@
Info about the changes in new versions of KDE-Pim/Pi
********** VERSION 2.0.26 ************
And again fixed some bugs.
Added two more fields to the KA/Pi view config:
A "Mobile (home)" and a "Mobile (work)" field.
+Fixed utf8 import (e.g. for Japaneese text) in KA/Pi.
+
********** VERSION 2.0.25 ************
And again fixed some bugs.
********** VERSION 2.0.24 ************
Fixed again a lot of small bugs.
Some performance optimizations in date navigator.
Month view displays now multi days events on top of each cell, such that it is more likely that all multi days items of one event are in the same row.
********** VERSION 2.0.23 ************
Fixed again a lot of small and strange bugs, e.g. the missing toolbar of KA/Pi after a new installation.
Fixed the (agenda) layout of KO/Pi on 5500er.
Some usebility enhancements (e.g. reselection the current item of the todo view after some changes).
********** VERSION 2.0.22 ************
KO/Pi:
Fix for creating events/todos via the abgenda context menu.
Added option to split toolbar to 3 toolbars.
(Toolbar moving s disabled for this option due to a bug in Qt somewhere).
Added option to show one small filter-view-toolbar.
Added a print option to the desktop version:
Now you can print out the view of the "Event Viewer".
That means you can print all data of one particular event/todo.
Added scaling options to printout of Event Viewer and What'sNext View.
Fixed some problems in the month view in "week start sunday" mode.
KA/Pi:
Added two more config options.
Fixed resizing problem of address request dialog when orientation was switched.
Cleaned up the menu structure.
Fixed some more problems.
Fixed the annoying problem that scrolling continued after the key was released in KO/Pi Monthview and the KA/Pi views.
And, this is a really cool option (Ben did suggest it):
Now KO/Pi and KA/Pi can be run from a USB stick:
All data is read from and written to the stick.
You can enable this in the global configure option TAB with:
Save using LOCAL storage.
Just put KDE-Pim/Pi on a memory stick and you can access all your PIM data on every computer with Windows XP. It will work with the ME and Linux versions as well. I will put a memory stick version for teh next stable release online.
********** VERSION 2.0.21 ************
Fixed another SMTP problem in OM/Pi.
Some small changed in the new datenavigator in KO/Pi.
Changed default setting for new filter in KA/Pi to "exclude categories".
Changed the default font size for 640x480 display .
Changed popup menu behaviour in agenda and list view.
Fixed some layout problems of the date label size in the month view.
Made month view update faster.
Made first datenavigator repainting faster.
Changed the title of the event/todo edit dialogs.
Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course).
Many small usebility fixes in KO/Pi.
Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi.
The set of possible "next views" are the views you have toolbar buttons for.
Made alarm sound working on Linux.
KO/Pi alarm applet changed:
Made buttons in alarm dialog much bigger.
Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger.
The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings.
And because this version is realeased at Easter, I added an Easter-egg:
With a new undocumented command you can get a message box about the next alarm.
Good luck to find it!
********** VERSION 2.0.20 ************
Two small fixes in OM/Pi.
Better resizing of the new datenavigator in KO/Pi.
********** VERSION 2.0.19 ************
KO/Pi:
Enhancements and bugfixes in the new datenavigator.
Bugfix in this changelog:
The datenavigator was changed in version 2.0.18, not the datepicker.
********** VERSION 2.0.18 ************
KO/Pi:
Fixed some minor problems.
Cleaned up the KO/Pi config dialog.
Fixed problem moving events in aganda view.
Made datepicker scaleable, i.e. if the datenavigator shows now a
datenavigator matrix depending on its size.
Birthdays are now displayed green in the datenavigator.
What'sThis Help in datenavigator shows all events of the day.
OM/Pi:
diff --git a/kabc/vcardparser/vcard.cpp b/kabc/vcardparser/vcard.cpp
index 24fd498..bc9f208 100644
--- a/kabc/vcardparser/vcard.cpp
+++ b/kabc/vcardparser/vcard.cpp
@@ -18,101 +18,101 @@
Boston, MA 02111-1307, USA.
*/
#include "vcard.h"
using namespace KABC;
VCard::VCard()
{
}
VCard::VCard( const VCard& vcard )
{
mLineMap = vcard.mLineMap;
}
VCard::~VCard()
{
}
VCard& VCard::operator=( const VCard& vcard )
{
if ( &vcard == this )
return *this;
mLineMap = vcard.mLineMap;
return *this;
}
void VCard::clear()
{
mLineMap.clear();
}
QStringList VCard::identifiers() const
{
//return mLineMap.keys();
//PP re: US method QMap::keys() not available yet. SO collect the data manually
QStringList result;
QMap<QString, VCardLine::List>::ConstIterator it;
for( it = mLineMap.begin(); it != mLineMap.end(); ++it ) {
result << it.key().latin1();
}
return result;
}
void VCard::addLine( const VCardLine& line )
{
mLineMap[ line.identifier() ].append( line );
}
VCardLine::List VCard::lines( const QString& identifier ) const
{
LineMap::ConstIterator it = mLineMap.find( identifier );
if ( it == mLineMap.end() )
return VCardLine::List();
return *it;
}
VCardLine VCard::line( const QString& identifier ) const
{
LineMap::ConstIterator it = mLineMap.find( identifier );
if ( it == mLineMap.end() )
return VCardLine();
if ( (*it).isEmpty() )
return VCardLine();
else
return (*it).first();
}
void VCard::setVersion( Version version )
{
mLineMap.remove( "VERSION" );
VCardLine line;
line.setIdentifier( "VERSION" );
if ( version == v2_1 )
line.setIdentifier( "2.1" );
else if ( version == v3_0 )
line.setIdentifier( "3.0" );
mLineMap[ "VERSION" ].append( line );
}
VCard::Version VCard::version() const
{
LineMap::ConstIterator versionEntry = mLineMap.find( "VERSION" );
if ( versionEntry == mLineMap.end() )
return v3_0;
VCardLine line = ( *versionEntry )[ 0 ];
- if ( line.value() == "2.1" )
+ if ( line.valueString() == "2.1" )
return v2_1;
else
return v3_0;
}
diff --git a/kabc/vcardparser/vcardline.cpp b/kabc/vcardparser/vcardline.cpp
index 0972a35..8df2d32 100644
--- a/kabc/vcardparser/vcardline.cpp
+++ b/kabc/vcardparser/vcardline.cpp
@@ -1,171 +1,175 @@
/*
This file is part of libkabc.
Copyright (c) 2003 Tobias Koenig <tokoe@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.
*/
#include "vcardline.h"
using namespace KABC;
class VCardLine::VCardLinePrivate
{
public:
QString mGroup;
};
VCardLine::VCardLine()
: d( 0 )
{
}
VCardLine::VCardLine( const QString &identifier )
: d( 0 )
{
mIdentifier = identifier;
}
VCardLine::VCardLine( const QString &identifier, const QString &value )
: d( 0 )
{
mIdentifier = identifier;
mValue.assign( value.data(), value.length() );
}
VCardLine::VCardLine( const VCardLine& line )
: d( 0 )
{
mParamMap = line.mParamMap;
mValue = line.mValue;
mIdentifier = line.mIdentifier;
}
VCardLine::~VCardLine()
{
delete d;
d = 0;
}
VCardLine& VCardLine::operator=( const VCardLine& line )
{
if ( &line == this )
return *this;
mParamMap = line.mParamMap;
mValue = line.mValue;
mIdentifier = line.mIdentifier;
return *this;
}
void VCardLine::setIdentifier( const QString& identifier )
{
mIdentifier = identifier;
}
QString VCardLine::identifier() const
{
return mIdentifier;
}
-void VCardLine::setValue( const QString& value )
+void VCardLine::setValueString( const QString& value )
{
- mValue.duplicate( value.data(), value.length() );
+ setValueCString( value.utf8() );
+}
+void VCardLine::setValueCString( const QCString& value )
+{
+ mValue.duplicate( value.data(), value.length() );
}
-void VCardLine::setValue( const QByteArray& value )
+void VCardLine::setValueBytes( const QByteArray& value )
{
mValue = value;
}
-QVariant VCardLine::value() const
+QString VCardLine::valueString() const
{
- return QVariant( QCString( mValue.data(), mValue.size()+1 ) );
+ return QString::fromUtf8( mValue.data(), mValue.size() );
}
QByteArray VCardLine::valueBytes() const
{
return mValue;
}
void VCardLine::setGroup( const QString& group )
{
if ( !d )
d = new VCardLinePrivate();
d->mGroup = group;
}
QString VCardLine::group() const
{
if ( d )
return d->mGroup;
else
return QString();
}
bool VCardLine::hasGroup() const
{
if ( !d )
return false;
else
return d->mGroup.isEmpty();
}
QStringList VCardLine::parameterList() const
{
//return mParamMap.keys();
//US method QMap::keys() not available yet. SO collect the data manually
//US return mParamMap->keys();
QStringList result;
QMap<QString, QStringList>::ConstIterator it;
for( it = mParamMap.begin(); it != mParamMap.end(); ++it ) {
result << it.key().latin1();
}
return result;
}
void VCardLine::addParameter( const QString& param, const QString& value )
{
QStringList &list = mParamMap[ param ];
if ( list.findIndex( value ) == -1 ) // not included yet
list.append( value );
}
QStringList VCardLine::parameters( const QString& param ) const
{
ParamMap::ConstIterator it = mParamMap.find( param );
if ( it == mParamMap.end() )
return QStringList();
else
return *it;
}
QString VCardLine::parameter( const QString& param ) const
{
ParamMap::ConstIterator it = mParamMap.find( param );
if ( it == mParamMap.end() )
return QString::null;
else {
if ( (*it).isEmpty() )
return QString::null;
else
return (*it).first();
}
}
diff --git a/kabc/vcardparser/vcardline.h b/kabc/vcardparser/vcardline.h
index 6e74b38..8dc9322 100644
--- a/kabc/vcardparser/vcardline.h
+++ b/kabc/vcardparser/vcardline.h
@@ -1,118 +1,119 @@
/*
This file is part of libkabc.
Copyright (c) 2003 Tobias Koenig <tokoe@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.
*/
#ifndef VCARDLINE_H
#define VCARDLINE_H
#include <qstringlist.h>
#include <qvaluelist.h>
#include <qcstring.h>
#include <qvariant.h>
#include <qmap.h>
#include <qstring.h>
namespace KABC {
class VCardLine
{
public:
typedef QValueList<VCardLine> List;
typedef QMap<QString, QStringList> ParamMap;
VCardLine();
VCardLine( const QString &identifier );
VCardLine( const QString &identifier, const QString &value );
VCardLine( const VCardLine& );
~VCardLine();
VCardLine& operator=( const VCardLine& );
/**
* Sets the identifier of this line e.g. UID, FN, CLASS
*/
void setIdentifier( const QString& identifier );
/**
* Returns the identifier of this line.
*/
QString identifier() const;
/**
* Sets the value of of this line.
*/
- void setValue( const QString& value );
- void setValue( const QByteArray& value );
+ void setValueString( const QString& value );
+ void setValueCString( const QCString& value );
+ void setValueBytes( const QByteArray& value );
/**
* Returns the value of this line.
*/
- QVariant value() const;
+ QString valueString() const;
QByteArray valueBytes() const;
/**
* Sets the group the line belongs to.
*/
void setGroup( const QString& group );
/**
* Returns the group the line belongs to.
*/
QString group() const;
/**
* Returns whether the line belongs to a group.
*/
bool hasGroup() const;
/**
* Returns all parameters.
*/
QStringList parameterList() const;
/**
* Add a new parameter to the line.
*/
void addParameter( const QString& param, const QString& value );
/**
* Returns the values of a special parameter.
* You can get a list of all parameters with paramList().
*/
QStringList parameters( const QString& param ) const;
/**
* Returns only the first value of a special parameter.
* You can get a list of all parameters with paramList().
*/
QString parameter( const QString& param ) const;
private:
ParamMap mParamMap;
QString mIdentifier;
QByteArray mValue;
class VCardLinePrivate;
VCardLinePrivate *d;
};
}
#endif
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp
index 7fae011..11622a0 100644
--- a/kabc/vcardparser/vcardparser.cpp
+++ b/kabc/vcardparser/vcardparser.cpp
@@ -33,208 +33,208 @@ VCardParser::VCardParser()
}
VCardParser::~VCardParser()
{
}
VCard::List VCardParser::parseVCards( const QString& text )
{
static QRegExp sep( "[\x0d\x0a]" );
VCard currentVCard;
VCard::List vCardList;
QString currentLine;
const QStringList lines = QStringList::split( sep, text );
QStringList::ConstIterator it;
bool inVCard = false;
QStringList::ConstIterator linesEnd( lines.end() );
for ( it = lines.begin(); it != linesEnd; ++it ) {
if ( (*it).isEmpty() ) // empty line
continue;
if ( (*it)[ 0 ] == ' ' || (*it)[ 0 ] == '\t' ) { // folded line => append to previous
currentLine += QString( *it ).remove( 0, 1 );
continue;
} else {
if ( inVCard && !currentLine.isEmpty() ) { // now parse the line
int colon = currentLine.find( ':' );
if ( colon == -1 ) { // invalid line
currentLine = (*it);
continue;
}
VCardLine vCardLine;
const QString key = currentLine.left( colon ).stripWhiteSpace();
QString value = currentLine.mid( colon + 1 );
QStringList params = QStringList::split( ';', key );
// check for group
if ( params[0].find( '.' ) != -1 ) {
const QStringList groupList = QStringList::split( '.', params[0] );
vCardLine.setGroup( groupList[0] );
vCardLine.setIdentifier( groupList[1] );
} else
vCardLine.setIdentifier( params[0] );
if ( params.count() > 1 ) { // find all parameters
QStringList::ConstIterator paramIt = params.begin();
for ( ++paramIt; paramIt != params.end(); ++paramIt ) {
QStringList pair = QStringList::split( '=', *paramIt );
if ( pair.count() == 1 ) {
// correct the fucking 2.1 'standard'
if ( pair[0].lower() == "quoted-printable" ) {
pair[0] = "encoding";
pair[1] = "quoted-printable";
} else if ( pair[0].lower() == "base64" ) {
pair[0] = "encoding";
pair[1] = "base64";
} else {
pair.prepend( "type" );
}
}
// This is pretty much a faster pair[1].contains( ',' )...
if ( pair[1].find( ',' ) != -1 ) { // parameter in type=x,y,z format
const QStringList args = QStringList::split( ',', pair[ 1 ] );
QStringList::ConstIterator argIt;
for ( argIt = args.begin(); argIt != args.end(); ++argIt )
vCardLine.addParameter( pair[0].lower(), *argIt );
} else
vCardLine.addParameter( pair[0].lower(), pair[1] );
}
}
params = vCardLine.parameterList();
if ( params.findIndex( "encoding" ) != -1 ) { // have to decode the data
QByteArray input, output;
if ( vCardLine.parameter( "encoding" ).lower() == "b" ||
vCardLine.parameter( "encoding" ).lower() == "base64" ) {
input = value.local8Bit();
KCodecs::base64Decode( input, output );
} else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) {
// join any qp-folded lines
while ( value.mid(value.length()-1,1) == "=" && it != linesEnd ) {
value = value.remove( value.length()-1, 1 ) + (*it);
++it;
}
input = value.local8Bit();
KCodecs::quotedPrintableDecode( input, output );
}
//PP our vcards are *supposed* to be in UTF-8
// if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) {
// vCardLine.setValue( QString::fromUtf8( output.data(), output.size() ) );
// } else
- vCardLine.setValue( output );
+ vCardLine.setValueBytes( output );
//PP our vcards are *supposed* to be in UTF-8
// } else if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) {
// vCardLine.setValue( QString::fromUtf8( value.ascii() ) );
} else
- vCardLine.setValue( value.replace( QRegExp("\\\\n"), "\n" ) );
+ vCardLine.setValueString( value.replace( QRegExp("\\\\n"), "\n" ) );
currentVCard.addLine( vCardLine );
}
// we do not save the start and end tag as vcardline
if ( (*it).lower().startsWith( "begin:vcard" ) ) {
inVCard = true;
currentLine = "";
currentVCard.clear(); // flush vcard
continue;
}
if ( (*it).lower().startsWith( "end:vcard" ) ) {
inVCard = false;
vCardList.append( currentVCard );
currentLine = "";
currentVCard.clear(); // flush vcard
continue;
}
currentLine = (*it);
}
}
return vCardList;
}
QString VCardParser::createVCards( const VCard::List& list )
{
QString text;
QString textLine;
QString encodingType;
QStringList idents;
QStringList params;
QStringList values;
QStringList::ConstIterator identIt;
QStringList::Iterator paramIt;
QStringList::ConstIterator valueIt;
VCardLine::List lines;
VCardLine::List::ConstIterator lineIt;
VCard::List::ConstIterator cardIt;
bool hasEncoding;
// iterate over the cards
VCard::List::ConstIterator listEnd( list.end() );
for ( cardIt = list.begin(); cardIt != listEnd; ++cardIt ) {
text.append( "BEGIN:VCARD\r\n" );
idents = (*cardIt).identifiers();
for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) {
lines = (*cardIt).lines( (*identIt) );
// iterate over the lines
for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
- if ( !(*lineIt).value().asString().isEmpty() ) {
+ if ( !(*lineIt).valueString().isEmpty() ) {
if ( (*lineIt).hasGroup() )
textLine = (*lineIt).group() + "." + (*lineIt).identifier();
else
textLine = (*lineIt).identifier();
params = (*lineIt).parameterList();
hasEncoding = false;
if ( params.count() > 0 ) { // we have parameters
for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) {
if ( (*paramIt) == "encoding" ) {
hasEncoding = true;
encodingType = (*lineIt).parameter( "encoding" ).lower();
}
values = (*lineIt).parameters( *paramIt );
for ( valueIt = values.begin(); valueIt != values.end(); ++valueIt ) {
textLine.append( ";" + (*paramIt).upper() );
if ( !(*valueIt).isEmpty() )
textLine.append( "=" + (*valueIt) );
}
}
}
if ( hasEncoding ) { // have to encode the data
QByteArray input, output;
input = (*lineIt).valueBytes();
if ( encodingType == "b" )
KCodecs::base64Encode( input, output );
else if ( encodingType == "quoted-printable" )
KCodecs::quotedPrintableEncode( input, output );
textLine.append( ":" + QString( output ) );
} else
- textLine.append( ":" + (*lineIt).value().asString().replace( QRegExp("\n"), "\\n" ) );
+ textLine.append( ":" + (*lineIt).valueString().replace( QRegExp("\n"), "\\n" ) );
if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line
for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i )
text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" );
} else
text.append( textLine + "\r\n" );
}
}
}
text.append( "END:VCARD\r\n" );
text.append( "\r\n" );
}
return text;
}
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp
index 0cf72c0..c3d92b6 100644
--- a/kabc/vcardparser/vcardtool.cpp
+++ b/kabc/vcardparser/vcardtool.cpp
@@ -274,596 +274,596 @@ QString VCardTool::createVCards( Addressee::List list, VCard::Version version )
VCardLine line( "TEL", (*phoneIt).number() );
QMap<QString, int>::ConstIterator typeIt;
for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) {
if ( typeIt.data() & (*phoneIt).type() )
line.addParameter( "TYPE", typeIt.key() );
}
card.addLine( line );
}
// TITLE
VCardLine titleLine( "TITLE", (*addrIt).title() );
if ( version == VCard::v2_1 ) {
titleLine.addParameter( "CHARSET", "UTF-8" );
titleLine.addParameter( "ENCODING", "8BIT" );
}
card.addLine( titleLine );
// TZ
TimeZone timeZone = (*addrIt).timeZone();
if ( timeZone.isValid() ) {
QString str;
int neg = 1;
if ( timeZone.offset() < 0 )
neg = -1;
str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ),
( timeZone.offset() / 60 ) * neg,
( timeZone.offset() % 60 ) * neg );
card.addLine( VCardLine( "TZ", str ) );
}
// UID
card.addLine( VCardLine( "UID", (*addrIt).uid() ) );
// URL
card.addLine( VCardLine( "URL", (*addrIt).url().url() ) );
// VERSION
if ( version == VCard::v2_1 )
card.addLine( VCardLine( "VERSION", "2.1" ) );
if ( version == VCard::v3_0 )
card.addLine( VCardLine( "VERSION", "3.0" ) );
// X-
const QStringList customs = (*addrIt).customs();
for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) {
QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) );
QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 );
if ( value.isEmpty() )
continue;
VCardLine line( identifier, value );
if ( version == VCard::v2_1 ) {
line.addParameter( "CHARSET", "UTF-8" );
line.addParameter( "ENCODING", "8BIT" );
}
card.addLine( line );
}
vCardList.append( card );
}
return VCardParser::createVCards( vCardList );
}
Addressee::List VCardTool::parseVCards( const QString& vcard )
{
static const QChar semicolonSep( ';' );
static const QChar commaSep( ',' );
QString identifier;
Addressee::List addrList;
const VCard::List vCardList = VCardParser::parseVCards( vcard );
VCard::List::ConstIterator cardIt;
VCard::List::ConstIterator listEnd( vCardList.end() );
for ( cardIt = vCardList.begin(); cardIt != listEnd; ++cardIt ) {
Addressee addr;
const QStringList idents = (*cardIt).identifiers();
QStringList::ConstIterator identIt;
QStringList::ConstIterator identEnd( idents.end() );
for ( identIt = idents.begin(); identIt != identEnd; ++identIt ) {
const VCardLine::List lines = (*cardIt).lines( (*identIt) );
VCardLine::List::ConstIterator lineIt;
// iterate over the lines
for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
identifier = (*lineIt).identifier().lower();
// ADR
if ( identifier == "adr" ) {
Address address;
- const QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() );
+ const QStringList addrParts = splitString( semicolonSep, (*lineIt).valueString() );
if ( addrParts.count() > 0 )
address.setPostOfficeBox( addrParts[ 0 ] );
if ( addrParts.count() > 1 )
address.setExtended( addrParts[ 1 ] );
if ( addrParts.count() > 2 )
address.setStreet( addrParts[ 2 ] );
if ( addrParts.count() > 3 )
address.setLocality( addrParts[ 3 ] );
if ( addrParts.count() > 4 )
address.setRegion( addrParts[ 4 ] );
if ( addrParts.count() > 5 )
address.setPostalCode( addrParts[ 5 ] );
if ( addrParts.count() > 6 )
address.setCountry( addrParts[ 6 ] );
int type = 0;
const QStringList types = (*lineIt).parameters( "type" );
for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it )
type += mAddressTypeMap[ (*it).lower() ];
address.setType( type );
addr.insertAddress( address );
}
// AGENT
else if ( identifier == "agent" )
addr.setAgent( parseAgent( *lineIt ) );
// BDAY
else if ( identifier == "bday" )
- addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) );
+ addr.setBirthday( parseDateTime( (*lineIt).valueString() ) );
// CATEGORIES
else if ( identifier == "categories" ) {
- const QStringList categories = splitString( commaSep, (*lineIt).value().asString() );
+ const QStringList categories = splitString( commaSep, (*lineIt).valueString() );
addr.setCategories( categories );
}
// CLASS
else if ( identifier == "class" )
addr.setSecrecy( parseSecrecy( *lineIt ) );
// EMAIL
else if ( identifier == "email" ) {
const QStringList types = (*lineIt).parameters( "type" );
- addr.insertEmail( (*lineIt).value().asString(), types.findIndex( "PREF" ) != -1 );
+ addr.insertEmail( (*lineIt).valueString(), types.findIndex( "PREF" ) != -1 );
}
// FN
else if ( identifier == "fn" )
- addr.setFormattedName( (*lineIt).value().asString() );
+ addr.setFormattedName( (*lineIt).valueString() );
// GEO
else if ( identifier == "geo" ) {
Geo geo;
- const QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true );
+ const QStringList geoParts = QStringList::split( ';', (*lineIt).valueString(), true );
geo.setLatitude( geoParts[ 0 ].toFloat() );
geo.setLongitude( geoParts[ 1 ].toFloat() );
addr.setGeo( geo );
}
// KEY
else if ( identifier == "key" )
addr.insertKey( parseKey( *lineIt ) );
// LABEL
else if ( identifier == "label" ) {
int type = 0;
const QStringList types = (*lineIt).parameters( "type" );
for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it )
type += mAddressTypeMap[ (*it).lower() ];
bool available = false;
KABC::Address::List addressList = addr.addresses();
KABC::Address::List::Iterator it;
for ( it = addressList.begin(); it != addressList.end(); ++it ) {
if ( (*it).type() == type ) {
- (*it).setLabel( (*lineIt).value().asString() );
+ (*it).setLabel( (*lineIt).valueString() );
addr.insertAddress( *it );
available = true;
break;
}
}
if ( !available ) { // a standalone LABEL tag
KABC::Address address( type );
- address.setLabel( (*lineIt).value().asString() );
+ address.setLabel( (*lineIt).valueString() );
addr.insertAddress( address );
}
}
// LOGO
else if ( identifier == "logo" )
addr.setLogo( parsePicture( *lineIt ) );
// MAILER
else if ( identifier == "mailer" )
- addr.setMailer( (*lineIt).value().asString() );
+ addr.setMailer( (*lineIt).valueString() );
// N
else if ( identifier == "n" ) {
- const QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() );
+ const QStringList nameParts = splitString( semicolonSep, (*lineIt).valueString() );
if ( nameParts.count() > 0 )
addr.setFamilyName( nameParts[ 0 ] );
if ( nameParts.count() > 1 )
addr.setGivenName( nameParts[ 1 ] );
if ( nameParts.count() > 2 )
addr.setAdditionalName( nameParts[ 2 ] );
if ( nameParts.count() > 3 )
addr.setPrefix( nameParts[ 3 ] );
if ( nameParts.count() > 4 )
addr.setSuffix( nameParts[ 4 ] );
}
// NAME
else if ( identifier == "name" )
- addr.setName( (*lineIt).value().asString() );
+ addr.setName( (*lineIt).valueString() );
// NICKNAME
else if ( identifier == "nickname" )
- addr.setNickName( (*lineIt).value().asString() );
+ addr.setNickName( (*lineIt).valueString() );
// NOTE
else if ( identifier == "note" )
- addr.setNote( (*lineIt).value().asString() );
+ addr.setNote( (*lineIt).valueString() );
// ORGANIZATION
else if ( identifier == "org" )
- addr.setOrganization( (*lineIt).value().asString() );
+ addr.setOrganization( (*lineIt).valueString() );
// PHOTO
else if ( identifier == "photo" )
addr.setPhoto( parsePicture( *lineIt ) );
// PROID
else if ( identifier == "prodid" )
- addr.setProductId( (*lineIt).value().asString() );
+ addr.setProductId( (*lineIt).valueString() );
// REV
else if ( identifier == "rev" )
- addr.setRevision( parseDateTime( (*lineIt).value().asString() ) );
+ addr.setRevision( parseDateTime( (*lineIt).valueString() ) );
// ROLE
else if ( identifier == "role" )
- addr.setRole( (*lineIt).value().asString() );
+ addr.setRole( (*lineIt).valueString() );
// SORT-STRING
else if ( identifier == "sort-string" )
- addr.setSortString( (*lineIt).value().asString() );
+ addr.setSortString( (*lineIt).valueString() );
// SOUND
else if ( identifier == "sound" )
addr.setSound( parseSound( *lineIt ) );
// TEL
else if ( identifier == "tel" ) {
PhoneNumber phone;
- phone.setNumber( (*lineIt).value().asString() );
+ phone.setNumber( (*lineIt).valueString() );
int type = 0;
const QStringList types = (*lineIt).parameters( "type" );
for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it )
type += mPhoneTypeMap[(*it).upper()];
phone.setType( type );
addr.insertPhoneNumber( phone );
}
// TITLE
else if ( identifier == "title" )
- addr.setTitle( (*lineIt).value().asString() );
+ addr.setTitle( (*lineIt).valueString() );
// TZ
else if ( identifier == "tz" ) {
TimeZone tz;
- const QString date = (*lineIt).value().asString();
+ const QString date = (*lineIt).valueString();
int hours = date.mid( 1, 2).toInt();
int minutes = date.mid( 4, 2 ).toInt();
int offset = ( hours * 60 ) + minutes;
offset = offset * ( date[ 0 ] == '+' ? 1 : -1 );
tz.setOffset( offset );
addr.setTimeZone( tz );
}
// UID
else if ( identifier == "uid" )
- addr.setUid( (*lineIt).value().asString() );
+ addr.setUid( (*lineIt).valueString() );
// URL
else if ( identifier == "url" )
- addr.setUrl( KURL( (*lineIt).value().asString() ) );
+ addr.setUrl( KURL( (*lineIt).valueString() ) );
// X-
else if ( identifier.startsWith( "x-" ) ) {
const QString key = (*lineIt).identifier().mid( 2 );
int dash = key.find( "-" );
- addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).value().asString() );
+ addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).valueString() );
}
}
}
addrList.append( addr );
}
return addrList;
}
QDateTime VCardTool::parseDateTime( const QString &str )
{
QDateTime dateTime;
if ( str.find( '-' ) == -1 ) { // is base format (yyyymmdd)
dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(),
str.mid( 6, 2 ).toInt() ) );
if ( str.find( 'T' ) ) // has time information yyyymmddThh:mm:ss
dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(),
str.mid( 17, 2 ).toInt() ) );
} else { // is extended format yyyy-mm-dd
dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 5, 2 ).toInt(),
str.mid( 8, 2 ).toInt() ) );
if ( str.find( 'T' ) ) // has time information yyyy-mm-ddThh:mm:ss
dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(),
str.mid( 17, 2 ).toInt() ) );
}
return dateTime;
}
QString VCardTool::createDateTime( const QDateTime &dateTime )
{
QString str;
if ( dateTime.date().isValid() ) {
str.sprintf( "%4d-%02d-%02d", dateTime.date().year(), dateTime.date().month(),
dateTime.date().day() );
if ( dateTime.time().isValid() ) {
QString tmp;
tmp.sprintf( "T%02d:%02d:%02dZ", dateTime.time().hour(), dateTime.time().minute(),
dateTime.time().second() );
str += tmp;
}
}
return str;
}
Picture VCardTool::parsePicture( const VCardLine &line )
{
Picture pic;
const QStringList params = line.parameterList();
if ( params.findIndex( "encoding" ) != -1 ) {
QImage img;
img.loadFromData( line.valueBytes() );
pic.setData( img );
} else if ( params.findIndex( "value" ) != -1 ) {
if ( line.parameter( "value" ).lower() == "uri" )
- pic.setUrl( line.value().asString() );
+ pic.setUrl( line.valueString() );
}
if ( params.findIndex( "type" ) != -1 )
pic.setType( line.parameter( "type" ) );
return pic;
}
VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic )
{
VCardLine line( identifier );
if ( pic.isIntern() ) {
if ( !pic.data().isNull() ) {
QByteArray input;
QDataStream s( input, IO_WriteOnly );
s.setVersion( 4 );
s << pic.data();
- line.setValue( input );
+ line.setValueBytes( input );
line.addParameter( "encoding", "b" );
line.addParameter( "type", "image/png" );
}
} else if ( !pic.url().isEmpty() ) {
QByteArray ba;
- line.setValue( pic.url() );
+ line.setValueString( pic.url() );
line.addParameter( "value", "URI" );
}
return line;
}
Sound VCardTool::parseSound( const VCardLine &line )
{
Sound snd;
const QStringList params = line.parameterList();
if ( params.findIndex( "encoding" ) != -1 )
snd.setData( line.valueBytes() );
else if ( params.findIndex( "value" ) != -1 ) {
if ( line.parameter( "value" ).lower() == "uri" )
- snd.setUrl( line.value().asString() );
+ snd.setUrl( line.valueString() );
}
/* TODO: support sound types
if ( params.contains( "type" ) )
snd.setType( line.parameter( "type" ) );
*/
return snd;
}
VCardLine VCardTool::createSound( const Sound &snd )
{
VCardLine line( "SOUND" );
if ( snd.isIntern() ) {
if ( !snd.data().isEmpty() ) {
- line.setValue( snd.data() );
+ line.setValueBytes( snd.data() );
line.addParameter( "encoding", "b" );
// TODO: need to store sound type!!!
}
} else if ( !snd.url().isEmpty() ) {
- line.setValue( snd.url() );
+ line.setValueString( snd.url() );
line.addParameter( "value", "URI" );
}
return line;
}
Key VCardTool::parseKey( const VCardLine &line )
{
Key key;
const QStringList params = line.parameterList();
if ( params.findIndex( "encoding" ) != -1 )
key.setBinaryData( line.valueBytes() );
else
- key.setTextData( line.value().asString() );
+ key.setTextData( line.valueString() );
if ( params.findIndex( "type" ) != -1 ) {
if ( line.parameter( "type" ).lower() == "x509" )
key.setType( Key::X509 );
else if ( line.parameter( "type" ).lower() == "pgp" )
key.setType( Key::PGP );
else {
key.setType( Key::Custom );
key.setCustomTypeString( line.parameter( "type" ) );
}
}
return key;
}
VCardLine VCardTool::createKey( const Key &key )
{
VCardLine line( "KEY" );
if ( key.isBinary() ) {
if ( !key.binaryData().isEmpty() ) {
- line.setValue( key.binaryData() );
+ line.setValueBytes( key.binaryData() );
line.addParameter( "encoding", "b" );
}
} else if ( !key.textData().isEmpty() )
- line.setValue( key.textData() );
+ line.setValueString( key.textData() );
if ( key.type() == Key::X509 )
line.addParameter( "type", "X509" );
else if ( key.type() == Key::PGP )
line.addParameter( "type", "PGP" );
else if ( key.type() == Key::Custom )
line.addParameter( "type", key.customTypeString() );
return line;
}
Secrecy VCardTool::parseSecrecy( const VCardLine &line )
{
Secrecy secrecy;
- if ( line.value().asString().lower() == "public" )
+ if ( line.valueString().lower() == "public" )
secrecy.setType( Secrecy::Public );
- if ( line.value().asString().lower() == "private" )
+ if ( line.valueString().lower() == "private" )
secrecy.setType( Secrecy::Private );
- if ( line.value().asString().lower() == "confidential" )
+ if ( line.valueString().lower() == "confidential" )
secrecy.setType( Secrecy::Confidential );
return secrecy;
}
VCardLine VCardTool::createSecrecy( const Secrecy &secrecy )
{
VCardLine line( "CLASS" );
int type = secrecy.type();
if ( type == Secrecy::Public )
- line.setValue( "PUBLIC" );
+ line.setValueString( "PUBLIC" );
else if ( type == Secrecy::Private )
- line.setValue( "PRIVATE" );
+ line.setValueString( "PRIVATE" );
else if ( type == Secrecy::Confidential )
- line.setValue( "CONFIDENTIAL" );
+ line.setValueString( "CONFIDENTIAL" );
return line;
}
Agent VCardTool::parseAgent( const VCardLine &line )
{
Agent agent;
const QStringList params = line.parameterList();
if ( params.findIndex( "value" ) != -1 ) {
if ( line.parameter( "value" ).lower() == "uri" )
- agent.setUrl( line.value().asString() );
+ agent.setUrl( line.valueString() );
} else {
- QString str = line.value().asString();
+ QString str = line.valueString();
str.replace( QRegExp("\\\\n"), "\r\n" );
str.replace( QRegExp("\\\\N"), "\r\n" );
str.replace( QRegExp("\\\\;"), ";" );
str.replace( QRegExp("\\\\:"), ":" );
str.replace( QRegExp("\\\\,"), "," );
const Addressee::List list = parseVCards( str );
if ( list.count() > 0 ) {
Addressee *addr = new Addressee;
*addr = list[ 0 ];
agent.setAddressee( addr );
}
}
return agent;
}
VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent )
{
VCardLine line( "AGENT" );
if ( agent.isIntern() ) {
if ( agent.addressee() != 0 ) {
Addressee::List list;
list.append( *agent.addressee() );
QString str = createVCards( list, version );
str.replace( QRegExp("\\r\\n"), "\\n" );
str.replace( QRegExp(";"), "\\;" );
str.replace( QRegExp(":"), "\\:" );
str.replace( QRegExp(","), "\\," );
- line.setValue( str );
+ line.setValueString( str );
}
} else if ( !agent.url().isEmpty() ) {
- line.setValue( agent.url() );
+ line.setValueString( agent.url() );
line.addParameter( "value", "URI" );
}
return line;
}
QStringList VCardTool::splitString( const QChar &sep, const QString &str )
{
QStringList list;
QString value( str );
int start = 0;
int pos = value.find( sep, start );
while ( pos != -1 ) {
if ( value[ pos - 1 ] != '\\' ) {
if ( pos > start && pos <= (int)value.length() )
list << value.mid( start, pos - start );
else
list << QString::null;
start = pos + 1;
pos = value.find( sep, start );
} else {
if ( pos != 0 ) {
value.replace( pos - 1, 2, sep );
pos = value.find( sep, pos );
} else
pos = value.find( sep, pos + 1 );
}
}
int l = value.length() - 1;
if ( value.mid( start, l - start + 1 ).length() > 0 )
list << value.mid( start, l - start + 1 );
else
list << QString::null;
return list;
}
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index 84d3116..b6e053f 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -843,210 +843,209 @@ void CardView::setSelected(CardViewItem *item, bool selected)
item->setSelected(selected);
item->repaintCard();
emit selectionChanged();
emit selectionChanged(item);
}
else
{
emit selectionChanged();
emit selectionChanged(0);
}
}
else if (d->mSelectionMode == CardView::Multi)
{
item->setSelected(selected);
item->repaintCard();
emit selectionChanged();
}
else if (d->mSelectionMode == CardView::Extended)
{
bool b = signalsBlocked();
blockSignals(true);
selectAll(false);
blockSignals(b);
item->setSelected(selected);
item->repaintCard();
emit selectionChanged();
}
}
bool CardView::isSelected(CardViewItem *item) const
{
return (item && item->isSelected());
}
CardViewItem *CardView::selectedItem() const
{
// find the first selected item
QPtrListIterator<CardViewItem> iter(d->mItemList);
for (iter.toFirst(); iter.current(); ++iter)
{
if ((*iter)->isSelected())
return *iter;
}
return 0;
}
CardViewItem *CardView::firstItem() const
{
return d->mItemList.first();
}
int CardView::childCount() const
{
return d->mItemList.count();
}
/*US
CardViewItem *CardView::findItem(const QString &text, const QString &label,
Qt::StringComparisonMode compare)
{
// IF the text is empty, we will return null, since empty text will
// match anything!
if (text.isEmpty())
return 0;
QPtrListIterator<CardViewItem> iter(d->mItemList);
if (compare & Qt::BeginsWith)
{
QString value;
for (iter.toFirst(); iter.current(); ++iter)
{
value = (*iter)->fieldValue(label).upper();
if (value.startsWith(text.upper()))
return *iter;
}
}
else
{
kdDebug(5720) << "CardView::findItem: search method not implemented" << endl;
}
return 0;
}
*/
uint CardView::columnWidth()
{
return d->mDrawSeparators ?
d->mItemWidth + ( 2 * d->mItemSpacing ) + d->mSepWidth :
d->mItemWidth + d->mItemSpacing;
}
void CardView::drawContents(QPainter *p, int clipx, int clipy,
int clipw, int cliph)
{
- QScrollView::drawContents(p, clipx, clipy, clipw, cliph);
-
+ //QScrollView::drawContents(p, clipx, clipy, clipw, cliph);
if (d->mLayoutDirty)
calcLayout();
//kdDebug() << "CardView::drawContents: " << clipx << ", " << clipy
// << ", " << clipw << ", " << cliph << endl;
QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale
-
+ int cX, cY;
+ contentsToViewport ( clipx, clipy, cX, cY );
QRect clipRect(clipx, clipy, clipw, cliph);
QRect cardRect;
QRect sepRect;
CardViewItem *item;
CardViewSeparator *sep;
-
// make sure the viewport is a pure background
- viewport()->erase(clipRect);
+ viewport()->erase( QRect ( cX, cY , clipw, cliph ) );
// Now tell the cards to draw, if they are in the clip region
QPtrListIterator<CardViewItem> iter(d->mItemList);
for (iter.toFirst(); iter.current(); ++iter)
{
item = *iter;
cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() );
if (clipRect.intersects(cardRect) || clipRect.contains(cardRect))
{
//kdDebug() << "\trepainting card at: " << cardRect.x() << ", "
// << cardRect.y() << endl;
// Tell the card to paint
p->save();
p->translate(cardRect.x(), cardRect.y());
item->paintCard(p, cg);
p->restore();
}
}
// Followed by the separators if they are in the clip region
QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
for (sepIter.toFirst(); sepIter.current(); ++sepIter)
{
sep = *sepIter;
sepRect = sep->mRect;
if (clipRect.intersects(sepRect) || clipRect.contains(sepRect))
{
p->save();
p->translate(sepRect.x(), sepRect.y());
sep->paintSeparator(p, cg);
p->restore();
}
}
}
void CardView::resizeEvent(QResizeEvent *e)
{
QScrollView::resizeEvent(e);
setLayoutDirty(true);
}
void CardView::calcLayout()
{
//kdDebug() << "CardView::calcLayout:" << endl;
// Start in the upper left corner and layout all the
// cars using their height and width
int maxWidth = 0;
int maxHeight = 0;
int xPos = 0;
int yPos = 0;
int cardSpacing = d->mItemSpacing;
// delete the old separators
d->mSeparatorList.clear();
QPtrListIterator<CardViewItem> iter(d->mItemList);
CardViewItem *item = 0;
CardViewSeparator *sep = 0;
xPos += cardSpacing;
for (iter.toFirst(); iter.current(); ++iter)
{
item = *iter;
yPos += cardSpacing;
if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height())
{
maxHeight = QMAX(maxHeight, yPos);
// Drawing in this column would be greater than the height
// of the scroll view, so move to next column
yPos = cardSpacing;
xPos += cardSpacing + maxWidth;
if (d->mDrawSeparators)
{
// Create a separator since the user asked
sep = new CardViewSeparator(this);
sep->mRect.moveTopLeft(QPoint(xPos, yPos+d->mItemMargin));
xPos += d->mSepWidth + cardSpacing;
d->mSeparatorList.append(sep);
}
maxWidth = 0;
}
item->d->x = xPos;
item->d->y = yPos;
yPos += item->height();
maxWidth = QMAX(maxWidth, d->mItemWidth);