34 #include <QtCore/QByteArray>
39 static bool checkName(
const QByteArray &name );
41 class CustomProperties::Private
45 QMap<QByteArray, QString> mProperties;
48 bool CustomProperties::Private::operator==(
const CustomProperties::Private &other )
const
50 if ( mProperties.count() != other.mProperties.count() ) {
53 for ( QMap<QByteArray, QString>::ConstIterator it = mProperties.begin();
54 it != mProperties.end(); ++it ) {
55 QMap<QByteArray, QString>::ConstIterator itOther =
56 other.mProperties.find( it.key() );
57 if ( itOther == other.mProperties.end() || itOther.value() != it.value() ) {
71 : d( new Private( *cp.d ) )
78 if ( &other ==
this ) {
93 return *d == *other.d;
97 const QString &value )
99 if ( value.isNull() || key.isEmpty() || app.isEmpty() ) {
102 QByteArray
property =
"X-KDE-" + app +
'-' + key;
103 if ( !checkName( property ) ) {
106 d->mProperties[property] = value;
122 QByteArray property(
"X-KDE-" + app +
'-' + key );
123 if ( !checkName( property ) ) {
131 if ( value.isNull() || !checkName( name ) ) {
134 d->mProperties[name] = value;
140 if ( d->mProperties.remove( name ) ) {
147 return d->mProperties.value( name );
152 bool changed =
false;
153 for ( QMap<QByteArray, QString>::ConstIterator it = properties.begin();
154 it != properties.end(); ++it ) {
156 if ( checkName( it.key() ) ) {
157 d->mProperties[it.key()] = it.value().isNull() ? QString(
"" ) : it.value();
168 return d->mProperties;
172 bool checkName(
const QByteArray &name )
176 const char *n = name;
177 int len = name.length();
178 if ( len < 2 || n[0] !=
'X' || n[1] !=
'-' ) {
181 for (
int i = 2; i < len; ++i ) {
183 if ( ( ch >=
'A' && ch <=
'Z' ) ||
184 ( ch >=
'a' && ch <=
'z' ) ||
185 ( ch >=
'0' && ch <=
'9' ) ||