palmtoprecord.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qtopia/private/palmtoprecord.h>
00021 #include <qtopia/stringutil.h>
00022 #include <qstringlist.h>
00023
00034 namespace Qtopia {
00035
00036
00037
00038 Record &Record::operator=( const Record &c )
00039 {
00040 if(this == &c ) return *this;
00041 mUid = c.mUid;
00042 mCats = c.mCats;
00043 customMap = c.customMap;
00044 return *this;
00045 }
00046
00047 void Record::setCategories( int single )
00048 {
00049 if ( single == 0 )
00050 return;
00051 mCats.resize(1);
00052 mCats[0] = single;
00053 }
00054
00055
00056 QString Record::idsToString( const QArray<int> &catsUnsorted )
00057 {
00058 QArray<int> cats = catsUnsorted;
00059 cats.sort();
00060
00061 QString str;
00062 for ( uint i = 0; i < cats.size(); i++ )
00063 if ( i == 0 )
00064 str = QString::number( cats[int(i)] );
00065 else
00066 str += ";" + QString::number( cats[int(i)] );
00067
00068 return str;
00069 }
00070
00071
00072 QArray<int> Record::idsFromString( const QString &str )
00073 {
00074 QStringList catStrs = QStringList::split( ";", str );
00075 QArray<int> cats( catStrs.count() );
00076 uint i = 0;
00077 for ( QStringList::ConstIterator it = catStrs.begin();
00078 it != catStrs.end(); ++it ) {
00079 cats[int(i)] = (*it).toInt();
00080 i++;
00081 }
00082 return cats;
00083 }
00084
00089 QString Record::customField( const QString &key) const
00090 {
00091 if (customMap.contains(key))
00092 return customMap[key];
00093
00094 return QString::null;
00095 }
00096
00100 void Record::setCustomField( const QString &key, const QString &value)
00101 {
00102
00103 if (customMap.contains(key))
00104 customMap.replace(key, value);
00105 else
00106 customMap.insert(key, value);
00107
00108
00109 }
00110
00114 void Record::removeCustomField(const QString &key)
00115 {
00116 customMap.remove(key);
00117 }
00118
00119 QString Record::customToXml() const
00120 {
00121
00122 QString buf(" ");
00123 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
00124 cit != customMap.end(); ++cit) {
00125
00126 buf += cit.key();
00127 buf += "=\"";
00128 buf += escapeString(cit.data());
00129 buf += "\" ";
00130 }
00131 return buf;
00132 }
00133
00134 void Record::dump( const QMap<int, QString> &map )
00135 {
00136 QMap<int, QString>::ConstIterator it;
00137 for( it = map.begin(); it != map.end(); ++it )
00138 qDebug("%d : %s", it.key(), it.data().local8Bit().data() );
00139 }
00140
00141 }
00142
This file is part of the documentation for OPIE Version 1.5.5.