26#include <tqapplication.h>
27#include <tqasciidict.h>
33typedef TQMap<TQCString, TQValueList<TQCString> > StringListMap;
34typedef TQMapIterator<TQCString, TQStringList> StringListMapIterator;
48 informAboutClearing(0)
57 StringListMap propertiesOfGroup;
58 TQValueList<TQCString> groupNames;
59 TQMap<TQCString, TQString> groupDescriptions;
60 TQMap<TQCString, TQString> groupIcons;
62 TQMap<Property*, TQCString> groupForProperty;
67 TQCString prevSelection;
72 bool* informAboutClearing;
80 kopropertywarn <<
"Set::property(): PROPERTY \"" <<
name <<
"\" NOT FOUND" << endl;
81 return Set_nonConstNull;
90Set::Iterator::Iterator(
const Set &set)
92 iterator =
new Property::DictIterator(set.d->dict);
95Set::Iterator::~Iterator()
101Set::Iterator::operator ++()
107Set::Iterator::operator *()
const
113Set::Iterator::currentKey()
const
116 return iterator->currentKey();
122Set::Iterator::current()
const
125 return iterator->current();
132Set::Set(TQObject *parent,
const TQString &
typeName)
133: TQObject(parent,
typeName.latin1())
135 d =
new SetPrivate();
136 d->ownProperty =
true;
137 d->groupDescriptions.insert(
"common", i18n(
"General properties",
"General"));
138 d->typeName = typeName;
143 : TQObject(0 , set.name())
145 d =
new SetPrivate();
149Set::Set(
bool propertyOwner)
152 d =
new SetPrivate();
153 d->ownProperty = propertyOwner;
154 d->groupDescriptions.insert(
"common", i18n(
"General properties",
"General"));
173 kopropertywarn <<
"Set::addProperty(): property == 0" << endl;
177 kopropertywarn <<
"Set::addProperty(): COULD NOT ADD NULL PROPERTY" << endl;
190 property->addSet(
this);
191 if (updateSortingKey)
192 property->setSortingKey( d->dict.count() );
228 if (d->informAboutClearing)
229 *d->informAboutClearing =
true;
230 d->informAboutClearing = 0;
232 d->propertiesOfGroup.clear();
233 d->groupNames.clear();
234 d->groupForProperty.clear();
235 d->groupDescriptions.clear();
236 d->groupIcons.clear();
237 Property::DictIterator it(d->dict);
243Set::informAboutClearing(
bool& cleared)
246 d->informAboutClearing = &cleared;
258 if(d->groupForProperty.contains(
property) && (d->groupForProperty[
property] == group))
261 if(!d->propertiesOfGroup.contains(group)) {
262 TQValueList<TQCString> l;
264 d->propertiesOfGroup.insert(group, l);
265 d->groupNames.append(group);
270 d->groupForProperty.insert(
property, group);
278 TQCString group = d->groupForProperty[
property];
280 if (d->propertiesOfGroup[group].isEmpty()) {
282 d->propertiesOfGroup.remove(group);
283 TQValueListIterator<TQCString> it = d->groupNames.find(group);
284 if (it != d->groupNames.end()) {
285 d->groupNames.remove(it);
288 d->groupForProperty.remove(
property);
291const TQValueList<TQCString>&
294 return d->groupNames;
297const TQValueList<TQCString>&
300 return d->propertiesOfGroup[group];
306 d->groupDescriptions[group] = desc;
312 if(d->groupDescriptions.contains(group))
313 return d->groupDescriptions[group];
320 d->groupIcons[group] = icon;
326 return d->groupIcons[group];
334 return d->dict.count();
340 return d->dict.isEmpty();
352 d->readOnly = readOnly;
358 return d->dict.find(name);
364 return d->property(name);
370 return d->property(name);
381 d->ownProperty = set.d->ownProperty;
382 d->prevSelection = set.d->prevSelection;
383 d->groupDescriptions = set.d->groupDescriptions;
386 for(Property::DictIterator it(set.d->dict); it.current(); ++it) {
409 if(d->dict.isEmpty()) {
410 kopropertydbg <<
"<EMPTY>" << endl;
413 kopropertydbg << d->dict.count() <<
" properties:" << endl;
415 for(Property::DictIterator it(d->dict); it.current(); ++it)
416 it.current()->debug();
422 return d->prevSelection;
426Set::setPrevSelection(
const TQCString &prevSelection)
449Buffer::Buffer(
const Set *set)
461void Buffer::initialSet(
const Set *set)
464 for(Property::DictIterator it(set->d->dict); it.current(); ++it) {
466 TQCString group = set->d->groupForProperty[it.current()];
467 TQString groupDesc = set->d->groupDescriptions[ group ];
476 if ( d->dict.isEmpty() )
482 for(Property::DictIterator it(d->dict); it.current(); ++it) {
483 const char* key = it.current()->name();
486 blockSignals(
true );
487 it.current()->resetValue();
488 it.current()->addRelatedProperty(
property );
489 blockSignals(
false );
499 TQCString propertyName = prop.
name();
503 const TQValueList<Property*> *props = prop.
related();
504 TQValueList<Property*>::const_iterator it = props->begin();
505 for ( ; it != props->end(); ++it ) {
506 ( *it )->setValue( prop.
value(),
false );
513 TQCString propertyName = prop.
name();
517 const TQValueList<Property*> *props = prop.
related();
518 TQValueList<Property*>::const_iterator it = props->begin();
519 for ( ; it != props->end(); ++it ) {
520 ( *it )->setValue( prop.
value(),
false );
526TQMap<TQCString, TQVariant> KoProperty::propertyValues(
const Set& set)
528 TQMap<TQCString, TQVariant> result;
530 result.insert( it.currentKey(), it.current()->value() );
virtual void intersect(const Set *set)
The base class representing a single property.
void addRelatedProperty(Property *property)
void setName(const TQCString &name)
void setValue(const TQVariant &value, bool rememberOldValue=true, bool useCustomProperty=true)
const TQValueList< Property * > * related() const
A class to iterate over a Set. It behaves like a TQDictIterator. To use it:
Lists holding properties in groups.
void setReadOnly(bool readOnly)
void addToGroup(const TQCString &group, Property *property)
TQString groupDescription(const TQCString &group) const
const Set & operator=(const Set &set)
void removeFromGroup(Property *property)
void removeProperty(Property *property)
Property & operator[](const TQCString &name) const
void propertyChanged(KoProperty::Set &set, KoProperty::Property &property)
Property & property(const TQCString &name) const
TQString typeName() const
TQCString prevSelection() const
void propertyReset(KoProperty::Set &set, KoProperty::Property &property)
void setGroupIcon(const TQCString &group, const TQString &icon)
bool contains(const TQCString &name) const
void setGroupDescription(const TQCString &group, const TQString &desc)
void addProperty(Property *property, TQCString group="common")
void changeProperty(const TQCString &property, const TQVariant &value)
void addPropertyInternal(Property *property, TQCString group, bool updateSortingKey)
void aboutToDeleteProperty(KoProperty::Set &set, KoProperty::Property &property)
const TQValueList< TQCString > & groupNames() const
const TQValueList< TQCString > & propertyNamesForGroup(const TQCString &group) const
TQString groupIcon(const TQCString &group) const
const char * name(StdAction id)
Namespace for a set of classes implementing generic properties framework.