Commit ba67c997 authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

KoProperty

- methods in Set::Iterator are now const
- added propertyValues(const Set& set) utility function

2.0: ported


svn path=/trunk/koffice/; revision=547381
parent c8b72599
......@@ -21,6 +21,7 @@
#include "set.h"
#include "property.h"
#include "utils.h"
#include <qapplication.h>
#include <q3asciidict.h>
......@@ -92,6 +93,7 @@ Set::Iterator::Iterator(const Set &set)
Set::Iterator::~Iterator()
{
delete iterator;
}
void
......@@ -101,13 +103,13 @@ Set::Iterator::operator ++()
}
Property*
Set::Iterator::operator *()
Set::Iterator::operator *() const
{
return current();
}
QByteArray
Set::Iterator::currentKey()
Set::Iterator::currentKey() const
{
if (iterator)
return iterator->currentKey();
......@@ -116,7 +118,7 @@ Set::Iterator::currentKey()
}
Property*
Set::Iterator::current()
Set::Iterator::current() const
{
if(iterator)
return iterator->current();
......@@ -124,7 +126,7 @@ Set::Iterator::current()
return 0;
}
//////////////////////////////////////////////
//////////////////////////////////////////////
Set::Set(QObject *parent, const QString &typeName)
: QObject(parent, typeName.latin1())
......@@ -508,4 +510,15 @@ void Buffer::intersectedReset(KoProperty::Set& set, KoProperty::Property& prop)
}
}
//////////////////////////////////////////////
QMap<QByteArray, QVariant> KoProperty::propertyValues(const Set& set)
{
QMap<QByteArray, QVariant> result;
for (Set::Iterator it(set); it.current(); ++it)
result.insert( it.currentKey(), it.current()->value() );
return result;
}
#include "set.moc"
......@@ -46,10 +46,9 @@ class KOPROPERTY_EXPORT Set : public QObject
Q_OBJECT
public:
/*! \brief A class to iterate over a SetPrivate
It behaves as a QDictIterator. To use it:
\code Set::Iterator it(set);
for(; it.current(); ++it) { .... }
/*! \brief A class to iterate over a Set.
It behaves like a QDictIterator. To use it:
\code for(Set::Iterator it(set); it.current(); ++it) { .... }
\endcode
\author Cedric Pasteur <cedric.pasteur@free.fr>
\author Alexander Dymo <cloudtemple@mskat.net> */
......@@ -59,10 +58,10 @@ class KOPROPERTY_EXPORT Set : public QObject
~Iterator();
void operator ++();
Property* operator *();
Property* operator *() const;
QByteArray currentKey();
Property* current();
QByteArray currentKey() const;
Property* current() const;
private:
Q3AsciiDictIterator<Property> *iterator;
......
......@@ -17,6 +17,9 @@
* Boston, MA 02110-1301, USA.
*/
#include <qmap.h>
#include <qwidget.h>
namespace KoProperty {
//! @short A container widget that can be used to split information into hideable sections
......@@ -36,4 +39,6 @@ class KOPROPERTY_EXPORT GroupContainer : public QWidget
Private *d;
};
KOPROPERTY_EXPORT QMap<QByteArray, QVariant> propertyValues(const Set& set);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment