• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.12
  • kdelibs
  • kdecore
  • config
kconfiggroup.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the KDE libraries
3  Copyright (c) 2006, 2007 Thomas Braxton <kde.braxton@gmail.com>
4  Copyright (c) 1999 Preston Brown <pbrown@kde.org>
5  Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #include "kconfiggroup.h"
24 #include "kconfiggroup_p.h"
25 
26 #include "kconfig.h"
27 #include "kconfig_p.h"
28 #include "ksharedconfig.h"
29 #include "kstringhandler.h"
30 #include "kcomponentdata.h"
31 #include "kconfigdata.h"
32 #include <kdebug.h>
33 
34 #include <QtCore/QDate>
35 #include <QtCore/QSharedData>
36 #include <QtCore/QFile>
37 #include <QtCore/QPoint>
38 #include <QtCore/QRect>
39 #include <QtCore/QString>
40 #include <QtCore/QTextStream>
41 #include <QtCore/QDir>
42 
43 #include <stdlib.h>
44 
45 class KConfigGroupPrivate : public QSharedData
46 {
47  public:
48  KConfigGroupPrivate(KConfig* owner, bool isImmutable, bool isConst, const QByteArray &name)
49  : mOwner(owner), mName(name), bImmutable(isImmutable), bConst(isConst)
50  {
51  }
52 
53  KConfigGroupPrivate(const KSharedConfigPtr &owner, const QByteArray& name)
54  : sOwner(owner), mOwner(sOwner.data()), mName(name),
55  bImmutable(name.isEmpty()? owner->isImmutable(): owner->isGroupImmutable(name)), bConst(false)
56  {
57  }
58 
59  KConfigGroupPrivate(KConfigGroup* parent, bool isImmutable, bool isConst, const QByteArray& name)
60  : sOwner(parent->d->sOwner), mOwner(parent->d->mOwner), mName(name),
61  bImmutable(isImmutable), bConst(isConst)
62  {
63  if (!parent->d->mName.isEmpty())
64  mParent = parent->d;
65  }
66 
67  KConfigGroupPrivate(const KConfigGroupPrivate* other, bool isImmutable, const QByteArray &name)
68  : sOwner(other->sOwner), mOwner(other->mOwner), mName(name),
69  bImmutable(isImmutable), bConst(other->bConst)
70  {
71  if (!other->mName.isEmpty())
72  mParent = const_cast<KConfigGroupPrivate *>(other);
73  }
74 
75  KSharedConfig::Ptr sOwner;
76  KConfig *mOwner;
77  QExplicitlySharedDataPointer<KConfigGroupPrivate> mParent;
78  QByteArray mName;
79 
80  /* bitfield */
81  const bool bImmutable:1; // is this group immutable?
82  const bool bConst:1; // is this group read-only?
83 
84  QByteArray fullName() const
85  {
86  if (!mParent) {
87  return name();
88  }
89  return mParent->fullName(mName);
90  }
91 
92  QByteArray name() const
93  {
94  if (mName.isEmpty())
95  return "<default>";
96  return mName;
97  }
98 
99  QByteArray fullName(const QByteArray& aGroup) const
100  {
101  if (mName.isEmpty())
102  return aGroup;
103  return fullName() + '\x1d' + aGroup;
104  }
105 
106  static QExplicitlySharedDataPointer<KConfigGroupPrivate> create(KConfigBase *master,
107  const QByteArray &name,
108  bool isImmutable,
109  bool isConst)
110  {
111  QExplicitlySharedDataPointer<KConfigGroupPrivate> data;
112  if (dynamic_cast<KConfigGroup*>(master))
113  data = new KConfigGroupPrivate(dynamic_cast<KConfigGroup*>(master), isImmutable, isConst, name);
114  else
115  data = new KConfigGroupPrivate(dynamic_cast<KConfig*>(master), isImmutable, isConst, name);
116  return data;
117  }
118 
119  static QByteArray serializeList(const QList<QByteArray> &list);
120  static QStringList deserializeList(const QString &data);
121 };
122 
123 QByteArray KConfigGroupPrivate::serializeList(const QList<QByteArray> &list)
124 {
125  QByteArray value = "";
126 
127  if (!list.isEmpty()) {
128  QList<QByteArray>::ConstIterator it = list.constBegin();
129  const QList<QByteArray>::ConstIterator end = list.constEnd();
130 
131  value = QByteArray(*it).replace('\\', "\\\\").replace(',', "\\,");
132 
133  while (++it != end) {
134  // In the loop, so it is not done when there is only one element.
135  // Doing it repeatedly is a pretty cheap operation.
136  value.reserve(4096);
137 
138  value += ',';
139  value += QByteArray(*it).replace('\\', "\\\\").replace(',', "\\,");
140  }
141 
142  // To be able to distinguish an empty list from a list with one empty element.
143  if (value.isEmpty())
144  value = "\\0";
145  }
146 
147  return value;
148 }
149 
150 QStringList KConfigGroupPrivate::deserializeList(const QString &data)
151 {
152  if (data.isEmpty())
153  return QStringList();
154  if (data == QLatin1String("\\0"))
155  return QStringList(QString());
156  QStringList value;
157  QString val;
158  val.reserve(data.size());
159  bool quoted = false;
160  for (int p = 0; p < data.length(); p++) {
161  if (quoted) {
162  val += data[p];
163  quoted = false;
164  } else if (data[p].unicode() == '\\') {
165  quoted = true;
166  } else if (data[p].unicode() == ',') {
167  val.squeeze(); // release any unused memory
168  value.append(val);
169  val.clear();
170  val.reserve(data.size() - p);
171  } else {
172  val += data[p];
173  }
174  }
175  value.append(val);
176  return value;
177 }
178 
179 static QList<int> asIntList(const QByteArray& string)
180 {
181  QList<int> list;
182  Q_FOREACH(const QByteArray& s, string.split(','))
183  list << s.toInt();
184  return list;
185 }
186 
187 static QList<qreal> asRealList(const QByteArray& string)
188 {
189  QList<qreal> list;
190  Q_FOREACH(const QByteArray& s, string.split(','))
191  list << s.toDouble();
192  return list;
193 }
194 
195 static QString errString( const char * pKey, const QByteArray & value, const QVariant & aDefault ) {
196  return QString::fromLatin1("\"%1\" - conversion of \"%3\" to %2 failed")
197  .arg(QString::fromLatin1(pKey))
198  .arg(QString::fromLatin1(QVariant::typeToName(aDefault.type())))
199  .arg(QString::fromLatin1(value));
200 }
201 
202 static QString formatError( int expected, int got ) {
203  return QString::fromLatin1(" (wrong format: expected %1 items, got %2)").arg( expected ).arg( got );
204 }
205 
206 QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray& value, const QVariant& aDefault)
207 {
208  // if a type handler is added here you must add a QVConversions definition
209  // to conversion_check.h, or ConversionCheck::to_QVariant will not allow
210  // readEntry<T> to convert to QVariant.
211  switch( aDefault.type() ) {
212  case QVariant::Invalid:
213  return QVariant();
214  case QVariant::String:
215  // this should return the raw string not the dollar expanded string.
216  // imho if processed string is wanted should call
217  // readEntry(key, QString) not readEntry(key, QVariant)
218  return QString::fromUtf8(value);
219  case QVariant::List:
220  case QVariant::StringList:
221  return KConfigGroupPrivate::deserializeList(QString::fromUtf8(value));
222  case QVariant::ByteArray:
223  return value;
224  case QVariant::Bool: {
225  const QByteArray lower(value.toLower());
226  if (lower == "false" || lower == "no" || lower == "off" || lower == "0")
227  return false;
228  return true;
229  }
230  case QVariant::Double:
231  case QMetaType::Float:
232  case QVariant::Int:
233  case QVariant::UInt:
234  case QVariant::LongLong:
235  case QVariant::ULongLong: {
236  QVariant tmp = value;
237  if ( !tmp.convert(aDefault.type()) )
238  tmp = aDefault;
239  return tmp;
240  }
241  case QVariant::Point: {
242  const QList<int> list = asIntList(value);
243 
244  if ( list.count() != 2 ) {
245  kError() << errString( pKey, value, aDefault )
246  << formatError( 2, list.count() );
247  return aDefault;
248  }
249  return QPoint(list.at( 0 ), list.at( 1 ));
250  }
251  case QVariant::PointF: {
252  const QList<qreal> list = asRealList(value);
253 
254  if ( list.count() != 2 ) {
255  kError() << errString( pKey, value, aDefault )
256  << formatError( 2, list.count() );
257  return aDefault;
258  }
259  return QPointF(list.at( 0 ), list.at( 1 ));
260  }
261  case QVariant::Rect: {
262  const QList<int> list = asIntList(value);
263 
264  if ( list.count() != 4 ) {
265  kError() << errString( pKey, value, aDefault )
266  << formatError( 4, list.count() );
267  return aDefault;
268  }
269  const QRect rect(list.at( 0 ), list.at( 1 ), list.at( 2 ), list.at( 3 ));
270  if ( !rect.isValid() ) {
271  kError() << errString( pKey, value, aDefault );
272  return aDefault;
273  }
274  return rect;
275  }
276  case QVariant::RectF: {
277  const QList<qreal> list = asRealList(value);
278 
279  if ( list.count() != 4 ) {
280  kError() << errString( pKey, value, aDefault )
281  << formatError( 4, list.count() );
282  return aDefault;
283  }
284  const QRectF rect(list.at( 0 ), list.at( 1 ), list.at( 2 ), list.at( 3 ));
285  if ( !rect.isValid() ) {
286  kError() << errString( pKey, value, aDefault );
287  return aDefault;
288  }
289  return rect;
290  }
291  case QVariant::Size: {
292  const QList<int> list = asIntList(value);
293 
294  if ( list.count() != 2 ) {
295  kError() << errString( pKey, value, aDefault )
296  << formatError( 2, list.count() );
297  return aDefault;
298  }
299  const QSize size(list.at( 0 ), list.at( 1 ));
300  if ( !size.isValid() ) {
301  kError() << errString( pKey, value, aDefault );
302  return aDefault;
303  }
304  return size;
305  }
306  case QVariant::SizeF: {
307  const QList<qreal> list = asRealList(value);
308 
309  if ( list.count() != 2 ) {
310  kError() << errString( pKey, value, aDefault )
311  << formatError( 2, list.count() );
312  return aDefault;
313  }
314  const QSizeF size(list.at( 0 ), list.at( 1 ));
315  if ( !size.isValid() ) {
316  kError() << errString( pKey, value, aDefault );
317  return aDefault;
318  }
319  return size;
320  }
321  case QVariant::DateTime: {
322  const QList<int> list = asIntList(value);
323  if ( list.count() != 6 ) {
324  kError() << errString( pKey, value, aDefault )
325  << formatError( 6, list.count() );
326  return aDefault;
327  }
328  const QDate date( list.at( 0 ), list.at( 1 ), list.at( 2 ) );
329  const QTime time( list.at( 3 ), list.at( 4 ), list.at( 5 ) );
330  const QDateTime dt( date, time );
331  if ( !dt.isValid() ) {
332  kError() << errString( pKey, value, aDefault );
333  return aDefault;
334  }
335  return dt;
336  }
337  case QVariant::Date: {
338  QList<int> list = asIntList(value);
339  if ( list.count() == 6 )
340  list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime
341  if ( list.count() != 3 ) {
342  kError() << errString( pKey, value, aDefault )
343  << formatError( 3, list.count() );
344  return aDefault;
345  }
346  const QDate date( list.at( 0 ), list.at( 1 ), list.at( 2 ) );
347  if ( !date.isValid() ) {
348  kError() << errString( pKey, value, aDefault );
349  return aDefault;
350  }
351  return date;
352  }
353  case QVariant::Color:
354  case QVariant::Font:
355  kWarning() << "KConfigGroup::readEntry was passed GUI type '"
356  << aDefault.typeName()
357  << "' but kdeui isn't linked! If it is linked to your program, "
358  "this is a platform bug. Please inform the KDE developers";
359  break;
360  case QVariant::Url:
361  return QUrl(QString::fromUtf8(value));
362 
363  default:
364  if( aDefault.canConvert<KUrl>() ) {
365  const KUrl url(QString::fromUtf8(value));
366  return qVariantFromValue<KUrl>( url );
367  }
368  break;
369  }
370 
371  kWarning() << "unhandled type " << aDefault.typeName();
372  return QVariant();
373 }
374 
375 #ifdef Q_WS_WIN
376 # include <QtCore/QDir>
377 #endif
378 
379 static bool cleanHomeDirPath( QString &path, const QString &homeDir )
380 {
381 #ifdef Q_WS_WIN //safer
382  if (!QDir::convertSeparators(path).startsWith(QDir::convertSeparators(homeDir)))
383  return false;
384 #else
385  if (!path.startsWith(homeDir))
386  return false;
387 #endif
388 
389  int len = homeDir.length();
390  // replace by "$HOME" if possible
391  if (len && (path.length() == len || path[len] == QLatin1Char('/'))) {
392  path.replace(0, len, QString::fromLatin1("$HOME"));
393  return true;
394  } else
395  return false;
396 }
397 
398 static QString translatePath( QString path ) // krazy:exclude=passbyvalue
399 {
400  if (path.isEmpty())
401  return path;
402 
403  // only "our" $HOME should be interpreted
404  path.replace(QLatin1Char('$'), QLatin1String("$$"));
405 
406  bool startsWithFile = path.startsWith(QLatin1String("file:"), Qt::CaseInsensitive);
407 
408  // return original path, if it refers to another type of URL (e.g. http:/), or
409  // if the path is already relative to another directory
410  if ((!startsWithFile && QFileInfo(path).isRelative()) ||
411  (startsWithFile && QFileInfo(path.mid(5)).isRelative()))
412  return path;
413 
414  if (startsWithFile)
415  path.remove(0,5); // strip leading "file:/" off the string
416 
417  // keep only one single '/' at the beginning - needed for cleanHomeDirPath()
418  while (path[0] == QLatin1Char('/') && path[1] == QLatin1Char('/'))
419  path.remove(0,1);
420 
421  // we can not use KGlobal::dirs()->relativeLocation("home", path) here,
422  // since it would not recognize paths without a trailing '/'.
423  // All of the 3 following functions to return the user's home directory
424  // can return different paths. We have to test all them.
425  const QString homeDir0 = QFile::decodeName(qgetenv("HOME"));
426  const QString homeDir1 = QDir::homePath();
427  const QString homeDir2 = QDir(homeDir1).canonicalPath();
428  if (cleanHomeDirPath(path, homeDir0) ||
429  cleanHomeDirPath(path, homeDir1) ||
430  cleanHomeDirPath(path, homeDir2) ) {
431  // kDebug() << "Path was replaced\n";
432  }
433 
434  if (startsWithFile)
435  path.prepend(QString::fromLatin1("file://"));
436 
437  return path;
438 }
439 
440 
441 KConfigGroup::KConfigGroup() : d(0)
442 {
443 }
444 
445 bool KConfigGroup::isValid() const
446 {
447  return 0 != d.constData();
448 }
449 
450 KConfigGroupGui _kde_internal_KConfigGroupGui;
451 static inline bool readEntryGui(const QByteArray& data, const char* key, const QVariant &input,
452  QVariant &output)
453 {
454  if (_kde_internal_KConfigGroupGui.readEntryGui)
455  return _kde_internal_KConfigGroupGui.readEntryGui(data, key, input, output);
456  return false;
457 }
458 
459 static inline bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &input,
460  KConfigGroup::WriteConfigFlags flags)
461 {
462  if (_kde_internal_KConfigGroupGui.writeEntryGui)
463  return _kde_internal_KConfigGroupGui.writeEntryGui(cg, key, input, flags);
464  return false;
465 }
466 
467 KConfigGroup::KConfigGroup(KConfigBase *master, const QString &_group)
468  : d(KConfigGroupPrivate::create(master, _group.toUtf8(), master->isGroupImmutable(_group), false))
469 {
470 }
471 
472 KConfigGroup::KConfigGroup(KConfigBase *master, const char *_group)
473  : d(KConfigGroupPrivate::create(master, _group, master->isGroupImmutable(_group), false))
474 {
475 }
476 
477 KConfigGroup::KConfigGroup(const KConfigBase *master, const QString &_group)
478  : d(KConfigGroupPrivate::create(const_cast<KConfigBase*>(master), _group.toUtf8(), master->isGroupImmutable(_group), true))
479 {
480 }
481 
482 KConfigGroup::KConfigGroup(const KConfigBase *master, const char * _group)
483  : d(KConfigGroupPrivate::create(const_cast<KConfigBase*>(master), _group, master->isGroupImmutable(_group), true))
484 {
485 }
486 
487 KConfigGroup::KConfigGroup(const KSharedConfigPtr &master, const QString &_group)
488  : d(new KConfigGroupPrivate(master, _group.toUtf8()))
489 {
490 }
491 
492 KConfigGroup::KConfigGroup(const KSharedConfigPtr &master, const char * _group)
493  : d(new KConfigGroupPrivate(master, _group))
494 {
495 }
496 
497 KConfigGroup &KConfigGroup::operator=(const KConfigGroup &rhs)
498 {
499  d = rhs.d;
500  return *this;
501 }
502 
503 KConfigGroup::KConfigGroup(const KConfigGroup &rhs)
504  : KConfigBase(), d(rhs.d)
505 {
506 }
507 
508 KConfigGroup::~KConfigGroup()
509 {
510  d = 0;
511 }
512 
513 KConfigGroup KConfigGroup::groupImpl(const QByteArray& aGroup)
514 {
515  Q_ASSERT_X(isValid(), "KConfigGroup::groupImpl", "accessing an invalid group");
516  Q_ASSERT_X(!aGroup.isEmpty(), "KConfigGroup::groupImpl", "can not have an unnamed child group");
517 
518  KConfigGroup newGroup;
519 
520  newGroup.d = new KConfigGroupPrivate(this, isGroupImmutableImpl(aGroup), d->bConst, aGroup);
521 
522  return newGroup;
523 }
524 
525 const KConfigGroup KConfigGroup::groupImpl(const QByteArray& aGroup) const
526 {
527  Q_ASSERT_X(isValid(), "KConfigGroup::groupImpl", "accessing an invalid group");
528  Q_ASSERT_X(!aGroup.isEmpty(), "KConfigGroup::groupImpl", "can not have an unnamed child group");
529 
530  KConfigGroup newGroup;
531 
532  newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup*>(this), isGroupImmutableImpl(aGroup),
533  true, aGroup);
534 
535  return newGroup;
536 }
537 
538 KConfigGroup KConfigGroup::parent() const
539 {
540  Q_ASSERT_X(isValid(), "KConfigGroup::parent", "accessing an invalid group");
541 
542  KConfigGroup parentGroup;
543 
544  if (d->mParent) {
545  parentGroup.d = d->mParent;
546  } else {
547  parentGroup.d = new KConfigGroupPrivate(d->mOwner, d->mOwner->isImmutable(), d->bConst, "");
548  // make sure we keep the refcount up on the KConfig object
549  parentGroup.d->sOwner = d->sOwner;
550  }
551 
552  return parentGroup;
553 }
554 
555 void KConfigGroup::deleteGroup(WriteConfigFlags flags)
556 {
557  Q_ASSERT_X(isValid(), "KConfigGroup::deleteGroup", "accessing an invalid group");
558  Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteGroup", "deleting a read-only group");
559 
560  config()->deleteGroup(d->fullName(), flags);
561 }
562 
563 #ifndef KDE_NO_DEPRECATED
564 void KConfigGroup::changeGroup( const QString &group )
565 {
566  Q_ASSERT_X(isValid(), "KConfigGroup::changeGroup", "accessing an invalid group");
567  d.detach();
568  d->mName = group.toUtf8();
569 }
570 #endif
571 
572 #ifndef KDE_NO_DEPRECATED
573 void KConfigGroup::changeGroup( const char *group )
574 {
575  Q_ASSERT_X(isValid(), "KConfigGroup::changeGroup", "accessing an invalid group");
576  d.detach();
577  d->mName = group;
578 }
579 #endif
580 
581 QString KConfigGroup::name() const
582 {
583  Q_ASSERT_X(isValid(), "KConfigGroup::name", "accessing an invalid group");
584 
585  return QString::fromUtf8(d->name());
586 }
587 
588 bool KConfigGroup::exists() const
589 {
590  Q_ASSERT_X(isValid(), "KConfigGroup::exists", "accessing an invalid group");
591 
592  return config()->hasGroup( d->fullName() );
593 }
594 
595 void KConfigGroup::sync()
596 {
597  Q_ASSERT_X(isValid(), "KConfigGroup::sync", "accessing an invalid group");
598 
599  if (!d->bConst)
600  config()->sync();
601 }
602 
603 QMap<QString, QString> KConfigGroup::entryMap() const
604 {
605  Q_ASSERT_X(isValid(), "KConfigGroup::entryMap", "accessing an invalid group");
606 
607  return config()->entryMap(QString::fromUtf8(d->fullName()));
608 }
609 
610 KConfig* KConfigGroup::config()
611 {
612  Q_ASSERT_X(isValid(), "KConfigGroup::config", "accessing an invalid group");
613 
614  return d->mOwner;
615 }
616 
617 const KConfig* KConfigGroup::config() const
618 {
619  Q_ASSERT_X(isValid(), "KConfigGroup::config", "accessing an invalid group");
620 
621  return d->mOwner;
622 }
623 
624 bool KConfigGroup::isEntryImmutable(const char* key) const
625 {
626  Q_ASSERT_X(isValid(), "KConfigGroup::isEntryImmutable", "accessing an invalid group");
627 
628  return (isImmutable() ||
629  !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults()));
630 }
631 
632 bool KConfigGroup::isEntryImmutable(const QString& key) const
633 {
634  return isEntryImmutable(key.toUtf8().constData());
635 }
636 
637 QString KConfigGroup::readEntryUntranslated(const QString& pKey, const QString& aDefault) const
638 {
639  return readEntryUntranslated(pKey.toUtf8().constData(), aDefault);
640 }
641 
642 QString KConfigGroup::readEntryUntranslated(const char *key, const QString& aDefault) const
643 {
644  Q_ASSERT_X(isValid(), "KConfigGroup::readEntryUntranslated", "accessing an invalid group");
645 
646  QString result = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchFlags(), 0);
647  if (result.isNull())
648  return aDefault;
649  return result;
650 }
651 
652 QString KConfigGroup::readEntry(const char *key, const char* aDefault) const
653 {
654  return readEntry(key, QString::fromUtf8(aDefault));
655 }
656 
657 QString KConfigGroup::readEntry(const QString &key, const char* aDefault) const
658 {
659  return readEntry(key.toUtf8().constData(), aDefault);
660 }
661 
662 QString KConfigGroup::readEntry(const char* key, const QString& aDefault) const
663 {
664  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
665 
666  bool expand = false;
667 
668  // read value from the entry map
669  QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized,
670  &expand);
671  if (aValue.isNull())
672  aValue = aDefault;
673 
674  if (expand)
675  return KConfigPrivate::expandString(aValue);
676 
677  return aValue;
678 }
679 
680 QString KConfigGroup::readEntry(const QString &key, const QString& aDefault) const
681 {
682  return readEntry(key.toUtf8().constData(), aDefault);
683 }
684 
685 QStringList KConfigGroup::readEntry(const char* key, const QStringList& aDefault) const
686 {
687  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
688 
689  const QString data = readEntry(key, QString());
690  if (data.isNull())
691  return aDefault;
692 
693  return KConfigGroupPrivate::deserializeList(data);
694 }
695 
696 QStringList KConfigGroup::readEntry( const QString& key, const QStringList& aDefault) const
697 {
698  return readEntry( key.toUtf8().constData(), aDefault );
699 }
700 
701 QVariant KConfigGroup::readEntry( const char* key, const QVariant &aDefault ) const
702 {
703  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
704 
705  const QByteArray data = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized);
706  if (data.isNull())
707  return aDefault;
708 
709  QVariant value;
710  if (!readEntryGui( data, key, aDefault, value ))
711  return convertToQVariant(key, data, aDefault);
712 
713  return value;
714 }
715 
716 QVariant KConfigGroup::readEntry( const QString& key, const QVariant& aDefault) const
717 {
718  return readEntry( key.toUtf8().constData(), aDefault );
719 }
720 
721 QVariantList KConfigGroup::readEntry( const char* key, const QVariantList& aDefault) const
722 {
723  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
724 
725  const QString data = readEntry(key, QString());
726  if (data.isNull())
727  return aDefault;
728 
729  QVariantList value;
730  foreach(const QString& v, KConfigGroupPrivate::deserializeList(data))
731  value << v;
732 
733  return value;
734 }
735 
736 QVariantList KConfigGroup::readEntry( const QString& key, const QVariantList& aDefault) const
737 {
738  return readEntry( key.toUtf8().constData(), aDefault );
739 }
740 
741 QStringList KConfigGroup::readXdgListEntry(const QString& key, const QStringList& aDefault) const
742 {
743  return readXdgListEntry(key.toUtf8().constData(), aDefault);
744 }
745 
746 QStringList KConfigGroup::readXdgListEntry(const char *key, const QStringList& aDefault) const
747 {
748  Q_ASSERT_X(isValid(), "KConfigGroup::readXdgListEntry", "accessing an invalid group");
749 
750  const QString data = readEntry(key, QString());
751  if (data.isNull())
752  return aDefault;
753 
754  QStringList value;
755  QString val;
756  val.reserve(data.size());
757  // XXX List serialization being a separate layer from low-level parsing is
758  // probably a bug. No affected entries are defined, though.
759  bool quoted = false;
760  for (int p = 0; p < data.length(); p++) {
761  if (quoted) {
762  val += data[p];
763  quoted = false;
764  } else if (data[p] == QLatin1Char('\\')) {
765  quoted = true;
766  } else if (data[p] == QLatin1Char(';')) {
767  value.append(val);
768  val.clear();
769  val.reserve(data.size() - p);
770  } else {
771  val += data[p];
772  }
773  }
774  if (!val.isEmpty()) {
775  kWarning() << "List entry" << key << "in" << config()->name() << "is not compliant with XDG standard (missing trailing semicolon).";
776  value.append(val);
777  }
778  return value;
779 }
780 
781 QString KConfigGroup::readPathEntry(const QString& pKey, const QString & aDefault) const
782 {
783  return readPathEntry(pKey.toUtf8().constData(), aDefault);
784 }
785 
786 QString KConfigGroup::readPathEntry(const char *key, const QString & aDefault) const
787 {
788  Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
789 
790  bool expand = false;
791 
792  QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized,
793  &expand);
794  if (aValue.isNull())
795  aValue = aDefault;
796 
797  return KConfigPrivate::expandString(aValue);
798 }
799 
800 QStringList KConfigGroup::readPathEntry(const QString& pKey, const QStringList& aDefault) const
801 {
802  return readPathEntry(pKey.toUtf8().constData(), aDefault);
803 }
804 
805 QStringList KConfigGroup::readPathEntry(const char *key, const QStringList& aDefault) const
806 {
807  Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
808 
809  const QString data = readPathEntry(key, QString());
810  if (data.isNull())
811  return aDefault;
812 
813  return KConfigGroupPrivate::deserializeList(data);
814 }
815 
816 void KConfigGroup::writeEntry( const char* key, const QString& value, WriteConfigFlags flags )
817 {
818  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
819  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
820 
821  writeEntry(key, value.toUtf8(), flags);
822 }
823 
824 void KConfigGroup::writeEntry( const QString& key, const QString& value, WriteConfigFlags flags )
825 {
826  writeEntry(key.toUtf8().constData(), value, flags);
827 }
828 
829 void KConfigGroup::writeEntry(const QString &key, const char *value, WriteConfigFlags pFlags)
830 {
831  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
832  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
833 
834  writeEntry(key.toUtf8().constData(), QVariant(QString::fromLatin1(value)), pFlags);
835 }
836 
837 void KConfigGroup::writeEntry(const char *key, const char *value, WriteConfigFlags pFlags)
838 {
839  writeEntry(key, QVariant(QString::fromLatin1(value)), pFlags);
840 }
841 
842 void KConfigGroup::writeEntry( const char* key, const QByteArray& value,
843  WriteConfigFlags flags )
844 {
845  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
846  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
847 
848  config()->d_func()->putData(d->fullName(), key, value.isNull()? QByteArray(""): value, flags);
849 }
850 
851 void KConfigGroup::writeEntry(const QString& key, const QByteArray& value,
852  WriteConfigFlags pFlags)
853 {
854  writeEntry(key.toUtf8().constData(), value, pFlags);
855 }
856 
857 void KConfigGroup::writeEntry(const char* key, const QStringList &list, WriteConfigFlags flags)
858 {
859  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
860  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
861 
862  QList<QByteArray> balist;
863 
864  foreach(const QString &entry, list)
865  balist.append(entry.toUtf8());
866 
867  writeEntry(key, KConfigGroupPrivate::serializeList(balist), flags);
868 }
869 
870 void KConfigGroup::writeEntry(const QString& key, const QStringList &list, WriteConfigFlags flags)
871 {
872  writeEntry(key.toUtf8().constData(), list, flags);
873 }
874 
875 void KConfigGroup::writeEntry( const char* key, const QVariantList& list, WriteConfigFlags flags )
876 {
877  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
878  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
879 
880  QList<QByteArray> data;
881 
882  foreach(const QVariant& v, list) {
883  if (v.type() == QVariant::ByteArray)
884  data << v.toByteArray();
885  else
886  data << v.toString().toUtf8();
887  }
888 
889  writeEntry(key, KConfigGroupPrivate::serializeList(data), flags);
890 }
891 
892 void KConfigGroup::writeEntry( const char* key, const QVariant &value,
893  WriteConfigFlags flags )
894 {
895  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
896  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
897 
898  if ( writeEntryGui( this, key, value, flags ) )
899  return; // GUI type that was handled
900 
901  QByteArray data;
902  // if a type handler is added here you must add a QVConversions definition
903  // to conversion_check.h, or ConversionCheck::to_QVariant will not allow
904  // writeEntry<T> to convert to QVariant.
905  switch( value.type() ) {
906  case QVariant::Invalid:
907  data = "";
908  break;
909  case QVariant::ByteArray:
910  data = value.toByteArray();
911  break;
912  case QVariant::String:
913  case QVariant::Int:
914  case QVariant::UInt:
915  case QVariant::Double:
916  case QMetaType::Float:
917  case QVariant::Bool:
918  case QVariant::LongLong:
919  case QVariant::ULongLong:
920  data = value.toString().toUtf8();
921  break;
922  case QVariant::List:
923  kError(!value.canConvert(QVariant::StringList))
924  << "not all types in \"" << key << "\" can convert to QString,"
925  " information will be lost";
926  case QVariant::StringList:
927  writeEntry( key, value.toList(), flags );
928  return;
929  case QVariant::Point: {
930  QVariantList list;
931  const QPoint rPoint = value.toPoint();
932  list.insert( 0, rPoint.x() );
933  list.insert( 1, rPoint.y() );
934 
935  writeEntry( key, list, flags );
936  return;
937  }
938  case QVariant::PointF: {
939  QVariantList list;
940  const QPointF point = value.toPointF();
941  list.insert( 0, point.x() );
942  list.insert( 1, point.y() );
943 
944  writeEntry( key, list, flags );
945  return;
946  }
947  case QVariant::Rect:{
948  QVariantList list;
949  const QRect rRect = value.toRect();
950  list.insert( 0, rRect.left() );
951  list.insert( 1, rRect.top() );
952  list.insert( 2, rRect.width() );
953  list.insert( 3, rRect.height() );
954 
955  writeEntry( key, list, flags );
956  return;
957  }
958  case QVariant::RectF:{
959  QVariantList list;
960  const QRectF rRectF = value.toRectF();
961  list.insert(0, rRectF.left());
962  list.insert(1, rRectF.top());
963  list.insert(2, rRectF.width());
964  list.insert(3, rRectF.height());
965 
966  writeEntry(key, list, flags);
967  return;
968  }
969  case QVariant::Size:{
970  QVariantList list;
971  const QSize rSize = value.toSize();
972  list.insert( 0, rSize.width() );
973  list.insert( 1, rSize.height() );
974 
975  writeEntry( key, list, flags );
976  return;
977  }
978  case QVariant::SizeF:{
979  QVariantList list;
980  const QSizeF rSizeF = value.toSizeF();
981  list.insert(0, rSizeF.width());
982  list.insert(1, rSizeF.height());
983 
984  writeEntry(key, list, flags);
985  return;
986  }
987  case QVariant::Date: {
988  QVariantList list;
989  const QDate date = value.toDate();
990 
991  list.insert( 0, date.year() );
992  list.insert( 1, date.month() );
993  list.insert( 2, date.day() );
994 
995  writeEntry( key, list, flags );
996  return;
997  }
998  case QVariant::DateTime: {
999  QVariantList list;
1000  const QDateTime rDateTime = value.toDateTime();
1001 
1002  const QTime time = rDateTime.time();
1003  const QDate date = rDateTime.date();
1004 
1005  list.insert( 0, date.year() );
1006  list.insert( 1, date.month() );
1007  list.insert( 2, date.day() );
1008 
1009  list.insert( 3, time.hour() );
1010  list.insert( 4, time.minute() );
1011  list.insert( 5, time.second() );
1012 
1013  writeEntry( key, list, flags );
1014  return;
1015  }
1016 
1017  case QVariant::Color:
1018  case QVariant::Font:
1019  kWarning() << "KConfigGroup::writeEntry was passed GUI type '"
1020  << value.typeName()
1021  << "' but kdeui isn't linked! If it is linked to your program, this is a platform bug. "
1022  "Please inform the KDE developers";
1023  break;
1024  case QVariant::Url:
1025  data = KUrl(value.toUrl()).url().toUtf8();
1026  break;
1027  default:
1028  if( value.canConvert<KUrl>() ) {
1029  data = qvariant_cast<KUrl>(value).url().toUtf8();
1030  break;
1031  }
1032  kWarning() << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name();
1033  }
1034 
1035  writeEntry(key, data, flags);
1036 }
1037 
1038 void KConfigGroup::writeEntry( const QString& key, const QVariant& value, WriteConfigFlags flags )
1039 {
1040  writeEntry(key.toUtf8().constData(), value, flags);
1041 }
1042 
1043 void KConfigGroup::writeEntry(const QString& key, const QVariantList &list, WriteConfigFlags flags)
1044 {
1045  writeEntry(key.toUtf8().constData(), list, flags);
1046 }
1047 
1048 void KConfigGroup::writeXdgListEntry(const QString& key, const QStringList &value, WriteConfigFlags pFlags)
1049 {
1050  writeXdgListEntry(key.toUtf8().constData(), value, pFlags);
1051 }
1052 
1053 void KConfigGroup::writeXdgListEntry(const char *key, const QStringList &list, WriteConfigFlags flags)
1054 {
1055  Q_ASSERT_X(isValid(), "KConfigGroup::writeXdgListEntry", "accessing an invalid group");
1056  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeXdgListEntry", "writing to a read-only group");
1057 
1058  QString value;
1059  value.reserve(4096);
1060 
1061  // XXX List serialization being a separate layer from low-level escaping is
1062  // probably a bug. No affected entries are defined, though.
1063  QStringList::ConstIterator it = list.constBegin();
1064  const QStringList::ConstIterator end = list.constEnd();
1065  for (; it != end; ++it) {
1066  QString val(*it);
1067  val.replace(QLatin1Char('\\'), QLatin1String("\\\\")).replace(QLatin1Char(';'), QLatin1String("\\;"));
1068  value += val;
1069  value += QLatin1Char(';');
1070  }
1071 
1072  writeEntry(key, value, flags);
1073 }
1074 
1075 void KConfigGroup::writePathEntry(const QString& pKey, const QString & path, WriteConfigFlags pFlags)
1076 {
1077  writePathEntry(pKey.toUtf8().constData(), path, pFlags);
1078 }
1079 
1080 void KConfigGroup::writePathEntry(const char *pKey, const QString & path, WriteConfigFlags pFlags)
1081 {
1082  Q_ASSERT_X(isValid(), "KConfigGroup::writePathEntry", "accessing an invalid group");
1083  Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
1084 
1085  config()->d_func()->putData(d->fullName(), pKey, translatePath(path).toUtf8(), pFlags, true);
1086 }
1087 
1088 void KConfigGroup::writePathEntry(const QString& pKey, const QStringList &value, WriteConfigFlags pFlags)
1089 {
1090  writePathEntry(pKey.toUtf8().constData(), value, pFlags);
1091 }
1092 
1093 void KConfigGroup::writePathEntry(const char *pKey, const QStringList &value, WriteConfigFlags pFlags)
1094 {
1095  Q_ASSERT_X(isValid(), "KConfigGroup::writePathEntry", "accessing an invalid group");
1096  Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
1097 
1098  QList<QByteArray> list;
1099  foreach(const QString& path, value)
1100  list << translatePath(path).toUtf8();
1101 
1102  config()->d_func()->putData(d->fullName(), pKey, KConfigGroupPrivate::serializeList(list), pFlags, true);
1103 }
1104 
1105 void KConfigGroup::deleteEntry( const char *key, WriteConfigFlags flags)
1106 {
1107  Q_ASSERT_X(isValid(), "KConfigGroup::deleteEntry", "accessing an invalid group");
1108  Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteEntry", "deleting from a read-only group");
1109 
1110  config()->d_func()->putData(d->fullName(), key, QByteArray(), flags);
1111 }
1112 
1113 void KConfigGroup::deleteEntry( const QString& key, WriteConfigFlags flags)
1114 {
1115  deleteEntry(key.toUtf8().constData(), flags);
1116 }
1117 
1118 void KConfigGroup::revertToDefault(const char *key)
1119 {
1120  Q_ASSERT_X(isValid(), "KConfigGroup::revertToDefault", "accessing an invalid group");
1121  Q_ASSERT_X(!d->bConst, "KConfigGroup::revertToDefault", "writing to a read-only group");
1122 
1123  config()->d_func()->revertEntry(d->fullName(), key);
1124 }
1125 
1126 void KConfigGroup::revertToDefault(const QString &key)
1127 {
1128  revertToDefault(key.toUtf8().constData());
1129 }
1130 
1131 bool KConfigGroup::hasDefault(const char *key) const
1132 {
1133  Q_ASSERT_X(isValid(), "KConfigGroup::hasDefault", "accessing an invalid group");
1134 
1135  KEntryMap::SearchFlags flags = KEntryMap::SearchDefaults|KEntryMap::SearchLocalized;
1136 
1137  return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
1138 }
1139 
1140 bool KConfigGroup::hasDefault(const QString &key) const
1141 {
1142  return hasDefault(key.toUtf8().constData());
1143 }
1144 
1145 bool KConfigGroup::hasKey(const char *key) const
1146 {
1147  Q_ASSERT_X(isValid(), "KConfigGroup::hasKey", "accessing an invalid group");
1148 
1149  KEntryMap::SearchFlags flags = KEntryMap::SearchLocalized;
1150  if ( config()->readDefaults() )
1151  flags |= KEntryMap::SearchDefaults;
1152 
1153  return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
1154 }
1155 
1156 bool KConfigGroup::hasKey(const QString &key) const
1157 {
1158  return hasKey(key.toUtf8().constData());
1159 }
1160 
1161 bool KConfigGroup::isImmutable() const
1162 {
1163  Q_ASSERT_X(isValid(), "KConfigGroup::isImmutable", "accessing an invalid group");
1164 
1165  return d->bImmutable;
1166 }
1167 
1168 QStringList KConfigGroup::groupList() const
1169 {
1170  Q_ASSERT_X(isValid(), "KConfigGroup::groupList", "accessing an invalid group");
1171 
1172  return config()->d_func()->groupList(d->fullName());
1173 }
1174 
1175 QStringList KConfigGroup::keyList() const
1176 {
1177  Q_ASSERT_X(isValid(), "KConfigGroup::keyList", "accessing an invalid group");
1178 
1179  return entryMap().keys();
1180 }
1181 
1182 void KConfigGroup::markAsClean()
1183 {
1184  Q_ASSERT_X(isValid(), "KConfigGroup::markAsClean", "accessing an invalid group");
1185 
1186  config()->markAsClean();
1187 }
1188 
1189 KConfigGroup::AccessMode KConfigGroup::accessMode() const
1190 {
1191  Q_ASSERT_X(isValid(), "KConfigGroup::accessMode", "accessing an invalid group");
1192 
1193  return config()->accessMode();
1194 }
1195 
1196 bool KConfigGroup::hasGroupImpl(const QByteArray & b) const
1197 {
1198  Q_ASSERT_X(isValid(), "KConfigGroup::hasGroupImpl", "accessing an invalid group");
1199 
1200  return config()->hasGroup(d->fullName(b));
1201 }
1202 
1203 void KConfigGroup::deleteGroupImpl(const QByteArray &b, WriteConfigFlags flags)
1204 {
1205  Q_ASSERT_X(isValid(), "KConfigGroup::deleteGroupImpl", "accessing an invalid group");
1206  Q_ASSERT_X(!d->bConst,"KConfigGroup::deleteGroupImpl", "deleting from a read-only group");
1207 
1208  config()->deleteGroup(d->fullName(b), flags);
1209 }
1210 
1211 bool KConfigGroup::isGroupImmutableImpl(const QByteArray& b) const
1212 {
1213  Q_ASSERT_X(isValid(), "KConfigGroup::isGroupImmutableImpl", "accessing an invalid group");
1214 
1215  if (!hasGroupImpl(b)) // group doesn't exist yet
1216  return d->bImmutable; // child groups are immutable if the parent is immutable.
1217 
1218  return config()->isGroupImmutable(d->fullName(b));
1219 }
1220 
1221 void KConfigGroup::copyTo(KConfigBase* other, WriteConfigFlags pFlags) const
1222 {
1223  Q_ASSERT_X(isValid(), "KConfigGroup::copyTo", "accessing an invalid group");
1224  Q_ASSERT(other != 0);
1225 
1226  if (KConfigGroup *otherGroup = dynamic_cast<KConfigGroup*>(other)) {
1227  config()->d_func()->copyGroup(d->fullName(), otherGroup->d->fullName(), otherGroup, pFlags);
1228  } else if (KConfig* otherConfig = dynamic_cast<KConfig*>(other)) {
1229  KConfigGroup newGroup = otherConfig->group(d->fullName());
1230  otherConfig->d_func()->copyGroup(d->fullName(), d->fullName(), &newGroup, pFlags);
1231  } else {
1232  Q_ASSERT_X(false, "KConfigGroup::copyTo", "unknown type of KConfigBase");
1233  }
1234 }
1235 
1236 void KConfigGroup::reparent(KConfigBase* parent, WriteConfigFlags pFlags)
1237 {
1238  Q_ASSERT_X(isValid(), "KConfigGroup::reparent", "accessing an invalid group");
1239  Q_ASSERT_X(!d->bConst, "KConfigGroup::reparent", "reparenting a read-only group");
1240  Q_ASSERT_X(!d->bImmutable, "KConfigGroup::reparent", "reparenting an immutable group");
1241  Q_ASSERT(parent != 0);
1242 
1243  KConfigGroup oldGroup(*this);
1244 
1245  d = KConfigGroupPrivate::create(parent, d->mName, false, false);
1246  oldGroup.copyTo(this, pFlags);
1247  oldGroup.deleteGroup(); // so that the entries with the old group name are deleted on sync
1248 }
QVariant
KConfigGroupGui::writeEntryGui
kWriteEntryGui writeEntryGui
Definition: kconfiggroup_p.h:37
KConfigGroup::readPathEntry
QString readPathEntry(const QString &pKey, const QString &aDefault) const
Reads a path.
Definition: kconfiggroup.cpp:781
KSharedPtr< KSharedConfig >
KConfig::sync
void sync()
Definition: kconfig.cpp:414
KConfigGroup::groupImpl
KConfigGroup groupImpl(const QByteArray &b)
Definition: kconfiggroup.cpp:513
KConfigGroup::writePathEntry
void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags=Normal)
Writes a file path to the configuration.
Definition: kconfiggroup.cpp:1075
KConfig::name
QString name() const
Returns the filename used to store the configuration.
Definition: kconfig.cpp:529
kdebug.h
errString
static QString errString(const char *pKey, const QByteArray &value, const QVariant &aDefault)
Definition: kconfiggroup.cpp:195
KConfigGroup::accessMode
AccessMode accessMode() const
Definition: kconfiggroup.cpp:1189
KMacroExpander::group
Definition: kmacroexpander_unix.cpp:34
Kuit::Att::Url
Definition: kuitsemantics.cpp:94
KConfigGroup::hasDefault
bool hasDefault(const QString &key) const
Whether a default is specified for an entry in either the system wide configuration file or the globa...
Definition: kconfiggroup.cpp:1140
translatePath
static QString translatePath(QString path)
Definition: kconfiggroup.cpp:398
KConfigGroup::operator=
KConfigGroup & operator=(const KConfigGroup &)
Definition: kconfiggroup.cpp:497
kconfig.h
KConfigGroup::isEntryImmutable
bool isEntryImmutable(const QString &key) const
Checks if it is possible to change the given entry.
Definition: kconfiggroup.cpp:632
KConfigGroup::reparent
void reparent(KConfigBase *parent, WriteConfigFlags pFlags=Normal)
Changes the configuration object that this group belongs to.
Definition: kconfiggroup.cpp:1236
KConfigPrivate::expandString
static QString expandString(const QString &value)
Definition: kconfig.cpp:155
cleanHomeDirPath
static bool cleanHomeDirPath(QString &path, const QString &homeDir)
Definition: kconfiggroup.cpp:379
KConfigGroup::markAsClean
void markAsClean()
Definition: kconfiggroup.cpp:1182
KConfigBase::deleteGroup
void deleteGroup(const QByteArray &group, WriteConfigFlags flags=Normal)
Delete aGroup.
Definition: kconfigbase.cpp:74
kError
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Definition: kdebug.h:187
KConfigGroup::parent
KConfigGroup parent() const
Returns the group that this group belongs to.
Definition: kconfiggroup.cpp:538
KConfigBase::hasGroup
bool hasGroup(const QString &group) const
Returns true if the specified group is known about.
Definition: kconfigbase.cpp:29
KConfigBase::group
KConfigGroup group(const QByteArray &group)
Returns an object for the named subgroup.
Definition: kconfigbase.cpp:44
KConfigGroup::writeEntry
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
Writes a value to the configuration object.
Definition: kconfiggroup.cpp:1038
KConfigGroup::changeGroup
void changeGroup(const QString &group)
Changes the group of the object.
Definition: kconfiggroup.cpp:564
KConfigGroup::isValid
bool isValid() const
Whether the group is valid.
Definition: kconfiggroup.cpp:445
QUrl
QString
KConfigGroup::deleteGroup
void deleteGroup(WriteConfigFlags pFlags=Normal)
Delete all entries in the entire group.
Definition: kconfiggroup.cpp:555
formatError
static QString formatError(int expected, int got)
Definition: kconfiggroup.cpp:202
kconfig_p.h
KUrl
Represents and parses a URL.
Definition: kurl.h:111
KConfigGroupGui::readEntryGui
kReadEntryGui readEntryGui
Definition: kconfiggroup_p.h:36
KConfig::entryMap
QMap< QString, QString > entryMap(const QString &aGroup=QString()) const
Returns a map (tree) of entries in a particular group.
Definition: kconfig.cpp:382
KConfigGroup::deleteEntry
void deleteEntry(const QString &pKey, WriteConfigFlags pFlags=Normal)
Deletes the entry specified by pKey in the current group.
Definition: kconfiggroup.cpp:1113
KConfigGroupGui
Definition: kconfiggroup_p.h:29
KConfigGroup::readEntryUntranslated
QString readEntryUntranslated(const QString &pKey, const QString &aDefault=QString()) const
Reads an untranslated string entry.
Definition: kconfiggroup.cpp:637
KConfigGroup::exists
bool exists() const
Check whether the containing KConfig object acutally contains a group with this name.
Definition: kconfiggroup.cpp:588
KConfig::accessMode
AccessMode accessMode() const
Definition: kconfig.cpp:698
KConfig::groupList
QStringList groupList() const
Definition: kconfig.cpp:291
KConfigGroup::isGroupImmutableImpl
bool isGroupImmutableImpl(const QByteArray &aGroup) const
Definition: kconfiggroup.cpp:1211
QStringList
KConfigGroup::~KConfigGroup
~KConfigGroup()
Definition: kconfiggroup.cpp:508
KConfigGroup::writeXdgListEntry
void writeXdgListEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags=Normal)
Writes a list of strings to the config object, following XDG desktop entry spec separator semantics...
Definition: kconfiggroup.cpp:1048
KConfigGroup::KConfigGroupPrivate
friend class KConfigGroupPrivate
Definition: kconfiggroup.h:646
KConfigGroup::readXdgListEntry
QStringList readXdgListEntry(const QString &pKey, const QStringList &aDefault=QStringList()) const
Reads a list of strings from the config object, following XDG desktop entry spec separator semantics...
Definition: kconfiggroup.cpp:741
ksharedconfig.h
KConfigGroup::copyTo
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
Copies the entries in this group to another configuration object.
Definition: kconfiggroup.cpp:1221
KConfigBase
Definition: kconfigbase.h:38
KConfigGroup::keyList
QStringList keyList() const
Returns a list of keys this group contains.
Definition: kconfiggroup.cpp:1175
kconfigdata.h
KShell::homeDir
QString homeDir(const QString &user)
Definition: kshell.cpp:29
KConfigGroup::name
QString name() const
The name of this group.
Definition: kconfiggroup.cpp:581
kWarning
#define kWarning
Definition: kdebug.h:322
kstringhandler.h
KConfigGroup::hasKey
bool hasKey(const QString &key) const
Checks whether the key has an entry in this group.
Definition: kconfiggroup.cpp:1156
QDateTime
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:53
QSharedData
writeEntryGui
static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags)
Definition: kconfiggroup.cpp:459
asIntList
static QList< int > asIntList(const QByteArray &string)
Definition: kconfiggroup.cpp:179
KConfig
The central class of the KDE configuration data system.
Definition: kconfig.h:70
KConfigGroup::config
KConfig * config()
Return the config object that this group belongs to.
Definition: kconfiggroup.cpp:610
KConfig::markAsClean
void markAsClean()
Definition: kconfig.cpp:484
output
void output(QList< Action > actions, QHash< QString, QString > domain)
Definition: fake/kauth-policy-gen-polkit.cpp:41
KConfigGroup::hasGroupImpl
bool hasGroupImpl(const QByteArray &group) const
Definition: kconfiggroup.cpp:1196
QPoint
asRealList
static QList< qreal > asRealList(const QByteArray &string)
Definition: kconfiggroup.cpp:187
_kde_internal_KConfigGroupGui
KConfigGroupGui _kde_internal_KConfigGroupGui
Definition: kconfiggroup.cpp:450
QRect
kconfiggroup_p.h
KConfigBase::AccessMode
AccessMode
Possible return values for accessMode().
Definition: kconfigbase.h:133
Kuit::Tag::List
Definition: kuitsemantics.cpp:84
KConfigBase::isGroupImmutable
bool isGroupImmutable(const QByteArray &aGroup) const
Can changes be made to the entries in aGroup?
Definition: kconfigbase.cpp:89
readEntryGui
static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output)
Definition: kconfiggroup.cpp:451
QSize
KEntryMap::SearchLocalized
Definition: kconfigdata.h:157
KConfigGroup::sync
void sync()
Definition: kconfiggroup.cpp:595
kcomponentdata.h
KConfigGroup::isImmutable
bool isImmutable() const
Whether this group may be changed.
Definition: kconfiggroup.cpp:1161
KConfigGroup::deleteGroupImpl
void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags)
Definition: kconfiggroup.cpp:1203
KConfigGroup::readEntry
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfiggroup.h:248
KConfigGroup::revertToDefault
void revertToDefault(const QString &key)
Reverts an entry to the default settings.
Definition: kconfiggroup.cpp:1126
KEntryMap::SearchDefaults
Definition: kconfigdata.h:156
KConfigGroup::groupList
QStringList groupList() const
Definition: kconfiggroup.cpp:1168
KConfigGroup::entryMap
QMap< QString, QString > entryMap() const
Returns a map (tree) of entries for all entries in this group.
Definition: kconfiggroup.cpp:603
QMap
kconfiggroup.h
KConfigGroup::KConfigGroup
KConfigGroup()
Constructs an invalid group.
Definition: kconfiggroup.cpp:441
QList< QByteArray >
KConfig::readDefaults
bool readDefaults() const
Definition: kconfig.cpp:747
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal