summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimrecord.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/core/opimrecord.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp141
1 files changed, 101 insertions, 40 deletions
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 72bb372..c603f44 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -26,67 +26,92 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <qarray.h>
+#include "opimrecord.h"
+
+/* OPIE */
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
-#include <opie2/opimrecord.h>
+/* QT */
+#include <qarray.h>
-namespace Opie {
+namespace Opie
+{
Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
OPimRecord::OPimRecord( int uid )
- : Qtopia::Record() {
+ : Qtopia::Record()
+{
m_lastHit = -1;
setUid( uid );
}
-OPimRecord::~OPimRecord() {
-}
+
+
+OPimRecord::~OPimRecord()
+{}
+
+
OPimRecord::OPimRecord( const OPimRecord& rec )
- : Qtopia::Record( rec )
+ : Qtopia::Record( rec )
{
- (*this) = rec;
+ ( *this ) = rec;
}
-OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
- if ( this == &rec ) return *this;
+
+OPimRecord &OPimRecord::operator=( const OPimRecord& rec )
+{
+ if ( this == &rec ) return * this;
Qtopia::Record::operator=( rec );
m_xrefman = rec.m_xrefman;
m_lastHit = rec.m_lastHit;
- return *this;
+ return *this;
}
+
+
/*
* category names
*/
-QStringList OPimRecord::categoryNames( const QString& appname ) const {
+QStringList OPimRecord::categoryNames( const QString& appname ) const
+{
QStringList list;
QArray<int> cats = categories();
Categories catDB;
catDB.load( categoryFileName() );
- for (uint i = 0; i < cats.count(); i++ ) {
- list << catDB.label( appname, cats[i] );
+ for ( uint i = 0; i < cats.count(); i++ )
+ {
+ list << catDB.label( appname, cats[ i ] );
}
return list;
}
-void OPimRecord::setCategoryNames( const QStringList& ) {
+
+void OPimRecord::setCategoryNames( const QStringList& )
+{
}
-void OPimRecord::addCategoryName( const QString& ) {
+
+
+void OPimRecord::addCategoryName( const QString& )
+{
Categories catDB;
catDB.load( categoryFileName() );
}
-bool OPimRecord::isEmpty()const {
+
+
+bool OPimRecord::isEmpty() const
+{
return ( uid() == 0 );
}
+
+
/*QString OPimRecord::crossToString()const {
QString str;
QMap<QString, QArray<int> >::ConstIterator it;
@@ -102,19 +127,29 @@ bool OPimRecord::isEmpty()const {
return str;
}*/
/* if uid = 1 assign a new one */
-void OPimRecord::setUid( int uid ) {
- if ( uid == 1)
+void OPimRecord::setUid( int uid )
+{
+ if ( uid == 1 )
uid = uidGen().generate();
Qtopia::Record::setUid( uid );
};
-Qtopia::UidGen &OPimRecord::uidGen() {
+
+
+Qtopia::UidGen &OPimRecord::uidGen()
+{
return m_uidGen;
}
-OPimXRefManager &OPimRecord::xrefmanager() {
+
+
+OPimXRefManager &OPimRecord::xrefmanager()
+{
return m_xrefman;
}
-int OPimRecord::rtti(){
+
+
+int OPimRecord::rtti()
+{
return 0;
}
@@ -126,17 +161,19 @@ int OPimRecord::rtti(){
* Categories
* XRef
*/
-bool OPimRecord::loadFromStream( QDataStream& stream ) {
+bool OPimRecord::loadFromStream( QDataStream& stream )
+{
int Int;
uint UInt;
stream >> Int;
- setUid(Int);
+ setUid( Int );
/** Categories */
stream >> UInt;
- QArray<int> array(UInt);
- for (uint i = 0; i < UInt; i++ ) {
- stream >> array[i];
+ QArray<int> array( UInt );
+ for ( uint i = 0; i < UInt; i++ )
+ {
+ stream >> array[ i ];
}
setCategories( array );
@@ -145,7 +182,8 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
*/
OPimXRef xref;
stream >> UInt;
- for ( uint i = 0; i < UInt; i++ ) {
+ for ( uint i = 0; i < UInt; i++ )
+ {
xref.setPartner( OPimXRef::One, partner( stream ) );
xref.setPartner( OPimXRef::Two, partner( stream ) );
m_xrefman.add( xref );
@@ -153,15 +191,19 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
return true;
}
-bool OPimRecord::saveToStream( QDataStream& stream )const {
+
+
+bool OPimRecord::saveToStream( QDataStream& stream ) const
+{
/** UIDs */
stream << uid();
/** Categories */
stream << categories().count();
- for ( uint i = 0; i < categories().count(); i++ ) {
- stream << categories()[i];
+ for ( uint i = 0; i < categories().count(); i++ )
+ {
+ stream << categories() [ i ];
}
/*
@@ -170,18 +212,25 @@ bool OPimRecord::saveToStream( QDataStream& stream )const {
*/
stream << m_xrefman.list().count();
for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
- it != m_xrefman.list().end(); ++it ) {
- flush( (*it).partner( OPimXRef::One), stream );
- flush( (*it).partner( OPimXRef::Two), stream );
+ it != m_xrefman.list().end(); ++it )
+ {
+ flush( ( *it ).partner( OPimXRef::One ), stream );
+ flush( ( *it ).partner( OPimXRef::Two ), stream );
}
return true;
}
-void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{
+
+
+void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const
+{
str << par.service();
str << par.uid();
str << par.field();
}
-OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
+
+
+OPimXRefPartner OPimRecord::partner( QDataStream& stream )
+{
OPimXRefPartner par;
QString str;
int i;
@@ -197,16 +246,28 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
return par;
}
-void OPimRecord::setLastHitField( int lastHit )const {
+
+
+void OPimRecord::setLastHitField( int lastHit ) const
+{
m_lastHit = lastHit;
}
-int OPimRecord::lastHitField()const{
+
+
+int OPimRecord::lastHitField() const
+{
return m_lastHit;
}
-QMap<QString, QString> OPimRecord::toExtraMap()const {
+
+
+QMap<QString, QString> OPimRecord::toExtraMap() const
+{
return customMap;
}
-void OPimRecord::setExtraMap( const QMap<QString, QString>& map) {
+
+
+void OPimRecord::setExtraMap( const QMap<QString, QString>& map )
+{
customMap = map;
}