~ubuntu-branches/ubuntu/trusty/kdepimlibs/trusty

« back to all changes in this revision

Viewing changes to kcalcore/customproperties.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-11-23 17:36:44 UTC
  • mfrom: (1.1.102)
  • Revision ID: package-import@ubuntu.com-20131123173644-p5ow94192ezsny8g
Tags: 4:4.11.80-0ubuntu1
[ Rohan Garg ]
* New upstream beta release
  - Bump akonadi requirement to 1.10.45
  - Update install files
  - Update symbols

[ Philip Muškovac ]
* kdepimlibs-dev/-dbg breaks/replaces kdepim-runtime/-dbg (<< 4:4.11.80)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "customproperties.h"
33
33
 
34
34
#include <QDataStream>
 
35
#include <KDebug>
35
36
 
36
37
using namespace KCalCore;
37
38
 
44
45
    bool operator==( const Private &other ) const;
45
46
    QMap<QByteArray, QString> mProperties;   // custom calendar properties
46
47
    QMap<QByteArray, QString> mPropertyParameters;
 
48
 
 
49
    // Volatile properties are not written back to the serialized format and are not compared in operator==
 
50
    // They are only used for runtime purposes and are not part of the payload.
 
51
    QMap<QByteArray, QString> mVolatileProperties;
 
52
 
 
53
 
 
54
    bool isVolatileProperty( const QString &name ) const
 
55
    {
 
56
      return name.startsWith( "X-KDE-VOLATILE" );
 
57
    }
47
58
};
48
59
 
49
60
bool CustomProperties::Private::operator==( const CustomProperties::Private &other ) const
50
61
{
51
62
  if ( mProperties.count() != other.mProperties.count() ) {
 
63
    // kDebug() << "Property count is different:" << mProperties << other.mProperties;
52
64
    return false;
53
65
  }
54
66
  for ( QMap<QByteArray, QString>::ConstIterator it = mProperties.begin();
113
125
    return;
114
126
  }
115
127
  customPropertyUpdate();
116
 
  d->mProperties[property] = value;
 
128
 
 
129
  if ( d->isVolatileProperty( property ) )  {
 
130
    d->mVolatileProperties[property] = value;
 
131
  } else {
 
132
    d->mProperties[property] = value;
 
133
  }
 
134
 
117
135
  customPropertyUpdated();
118
136
}
119
137
 
154
172
    d->mProperties.remove( name );
155
173
    d->mPropertyParameters.remove( name );
156
174
    customPropertyUpdated();
 
175
  } else if ( d->mVolatileProperties.contains( name ) ) {
 
176
    customPropertyUpdate();
 
177
    d->mVolatileProperties.remove( name );
 
178
    customPropertyUpdated();
157
179
  }
158
180
}
159
181
 
160
182
QString CustomProperties::nonKDECustomProperty( const QByteArray &name ) const
161
183
{
162
 
  return d->mProperties.value( name );
 
184
  return d->isVolatileProperty( name ) ? d->mVolatileProperties.value( name ) : d->mProperties.value( name );
163
185
}
164
186
 
165
187
QString CustomProperties::nonKDECustomPropertyParameters( const QByteArray &name ) const
174
196
        it != properties.end();  ++it ) {
175
197
    // Validate the property name and convert any null string to empty string
176
198
    if ( checkName( it.key() ) ) {
177
 
      d->mProperties[it.key()] = it.value().isNull() ? QString( "" ) : it.value();
 
199
      if ( d->isVolatileProperty( it.key() ) ) {
 
200
        d->mVolatileProperties[it.key()] = it.value().isNull() ? QLatin1String( "" ) : it.value();
 
201
      } else {
 
202
        d->mProperties[it.key()] = it.value().isNull() ? QLatin1String( "" ) : it.value();
 
203
      }
178
204
      if ( !changed ) {
179
205
        customPropertyUpdate();
180
206
      }
188
214
 
189
215
QMap<QByteArray, QString> CustomProperties::customProperties() const
190
216
{
191
 
  return d->mProperties;
 
217
  QMap<QByteArray, QString> result;
 
218
  result.unite( d->mProperties );
 
219
  result.unite( d->mVolatileProperties );
 
220
 
 
221
  return result;
192
222
}
193
223
 
194
224
void CustomProperties::customPropertyUpdate()
240
270
QDataStream &KCalCore::operator>>( QDataStream &stream,
241
271
                                   KCalCore::CustomProperties &properties )
242
272
{
 
273
  properties.d->mVolatileProperties.clear();
243
274
  return stream >> properties.d->mProperties
244
275
                >> properties.d->mPropertyParameters;
245
276
}