rendered paste bodydiff --git a/kio/kio/udsentry.cpp b/kio/kio/udsentry.cppindex 4b1b5dc..cb6b665 100644--- a/kio/kio/udsentry.cpp+++ b/kio/kio/udsentry.cpp@@ -18,9 +18,11 @@ Boston, MA 02110-1301, USA. */+#include "udsentry.h"++#include <kdebug.h> #include <kio/global.h> #include <kio/kio_export.h>-#include "udsentry.h" #include <QtCore/QString> #include <QtCore/QHash>@@ -28,15 +30,15 @@ using namespace KIO;--/**+namespace KIO {+ /** * A field inside a UDSEntry, to store information about a file or URL. * Each field is for instance the name, the size, the modification time of the file, etc. * You never need to use this class directly, see UDSEntry for the public API. */-class TraditionalUDSField-{-public:+ class TraditionalUDSField+ {+ public: /// @internal needed by QHash TraditionalUDSField(); /**@@ -66,10 +68,11 @@ public: */ long long toNumber() const;-private:+ private: QString m_str; long long m_long;-};+ };+} /* --------------- TraditionalUDSField ---------------- */@@ -99,10 +102,14 @@ long long TraditionalUDSField::toNumber() const /* ---------- UDSEntry ------------ */-class UDSEntryPrivate : public QSharedData+class KIO::UDSEntryPrivate : public QSharedData {- public:- QHash<uint, TraditionalUDSField> fields;+public:+ typedef QHash<uint, TraditionalUDSField> FieldHash;+ FieldHash fields;++ static void save(QDataStream &, const UDSEntry &);+ static void load(QDataStream &, UDSEntry &); }; UDSEntry::UDSEntry()@@ -110,103 +117,99 @@ UDSEntry::UDSEntry() { }+UDSEntry::UDSEntry(const UDSEntry &other)+ : d(other.d)+{+}+ UDSEntry::~UDSEntry() { }-QString UDSEntry::stringValue( uint field )+UDSEntry &UDSEntry::operator=(const UDSEntry &other) {- return d->fields->value( field ).toString();+ d = other.d;+ return *this; }-long long UDSEntry::numberValue( uint field, long long defaultValue = 0 )+QString UDSEntry::stringValue( uint field ) const {- const_iterator it = fields->find( field );- return it != constEnd() ? it.value().toNumber() : defaultValue;+ return d->fields.value( field ).toString(); }-bool UDSEntry::isDir()+long long UDSEntry::numberValue( uint field, long long defaultValue ) const+{+ UDSEntryPrivate::FieldHash::const_iterator it = d->fields.find( field );+ return it != d->fields.constEnd() ? it.value().toNumber() : defaultValue;+}++bool UDSEntry::isDir() const { return S_ISDIR( numberValue( UDS_FILE_TYPE ) ); }-bool UDSEntry::isLink()+bool UDSEntry::isLink() const { return !stringValue( UDS_LINK_DEST ).isEmpty(); } void UDSEntry::insert(uint field, QString value) {- fields->insert( field, value);+ d->fields.insert( field, value); } void UDSEntry::insert(uint field, long long l) {- fields->insert( field, l);+ d->fields.insert( field, l); }-QList<uint> &UDSEntry::listFields() const+QList<uint> UDSEntry::listFields() const {- fields->keys();+ return d->fields.keys(); } int UDSEntry::count() const {- return fields->count();+ return d->fields.count(); } bool UDSEntry::contains(uint field) const {- return fields->contains (field);+ return d->fields.contains(field); }-bool UDSEntry::remove(uint field) const+bool UDSEntry::remove(uint field) {- return fields->remove(field) > 0;+ return d->fields.remove(field) > 0; } void UDSEntry::clear() {- fields->clear();+ d->fields.clear(); } QDataStream & operator<< ( QDataStream & s, const UDSEntry & a ) {- s << 'T'; /* traditional: QHash<uint, TraditionalUDSField> */- s << a.d->fields;+ UDSEntryPrivate::save(s, a); return s; } QDataStream & operator>> ( QDataStream & s, UDSEntry & a ) {- char entryType;- s >> entryType;- if (entryType=='T')- {- s >> a.d->fields;- }- else- {- kError() << "UDSEntry >> unexpected internal object type!" << entryType << "\n";- Q_ASSERT( 0 );- }+ UDSEntryPrivate::load(s, a); return s; }-/*- moved here from slaveinterface.cpp (and commented out)- TODO: we have to mashal TraditionalUDSField--QDataStream &operator <<(QDataStream &s, const KIO::UDSEntry &e )+void UDSEntryPrivate::save(QDataStream &s, const UDSEntry &a) {- // TODO: that's not really compatible with the new UDSEntry model?!- // (as soon as we have named fields)+ const FieldHash &e = a.d->fields;+ s << e.size();- KIO::UDSEntry::ConstIterator it = e.begin();- const KIO::UDSEntry::ConstIterator end = e.end();+ FieldHash::ConstIterator it = e.begin();+ const FieldHash::ConstIterator end = e.end(); for( ; it != end; ++it ) { const quint32 uds = it.key();@@ -218,13 +221,12 @@ QDataStream &operator <<(QDataStream &s, const KIO::UDSEntry &e ) else Q_ASSERT( 0 ); }- return s; }-QDataStream &operator >>(QDataStream &s, KIO::UDSEntry &e )+void UDSEntryPrivate::load(QDataStream &s, UDSEntry &a) {- // TODO: that's not really compatible with the new UDSEntry model?!- // (as soon as we have named fields)+ FieldHash &e = a.d->fields;+ e.clear(); quint32 size; s >> size;@@ -243,9 +245,8 @@ QDataStream &operator >>(QDataStream &s, KIO::UDSEntry &e ) } else Q_ASSERT( 0 ); }- return s; }-*/+ //////////////diff --git a/kio/kio/udsentry.h b/kio/kio/udsentry.hindex ffc7094..1437e09 100644--- a/kio/kio/udsentry.h+++ b/kio/kio/udsentry.h@@ -124,7 +124,12 @@ public: * remove a field with a certain numeric id * @param field numeric type id */- bool remove(uint field) const;+ bool remove(uint field);++ /**+ * lists all fields+ */+ QList<uint> listFields() const; /** * remove all fields@@ -215,15 +220,12 @@ public: private:-+ friend class UDSEntryPrivate; QSharedDataPointer<UDSEntryPrivate> d; //UDSEntryPrivate *const d; };-KIO_EXPORT QDataStream & operator<< ( QDataStream & s, const UDSEntry & a );-KIO_EXPORT QDataStream & operator>> ( QDataStream & s, UDSEntry & a );- /** * A directory listing is a list of UDSEntry instances.@@ -245,4 +247,7 @@ typedef QList<UDSEntry> UDSEntryList; } // end namespace+KIO_EXPORT QDataStream & operator<< ( QDataStream & s, const KIO::UDSEntry & a );+KIO_EXPORT QDataStream & operator>> ( QDataStream & s, KIO::UDSEntry & a );+ #endif /*UDSENTRY_H*/