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

KDECore

  • sources
  • kde-4.14
  • 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  value.append(val);
776  }
777  return value;
778 }
779 
780 QString KConfigGroup::readPathEntry(const QString& pKey, const QString & aDefault) const
781 {
782  return readPathEntry(pKey.toUtf8().constData(), aDefault);
783 }
784 
785 QString KConfigGroup::readPathEntry(const char *key, const QString & aDefault) const
786 {
787  Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
788 
789  bool expand = false;
790 
791  QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized,
792  &expand);
793  if (aValue.isNull())
794  aValue = aDefault;
795 
796  return KConfigPrivate::expandString(aValue);
797 }
798 
799 QStringList KConfigGroup::readPathEntry(const QString& pKey, const QStringList& aDefault) const
800 {
801  return readPathEntry(pKey.toUtf8().constData(), aDefault);
802 }
803 
804 QStringList KConfigGroup::readPathEntry(const char *key, const QStringList& aDefault) const
805 {
806  Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
807 
808  const QString data = readPathEntry(key, QString());
809  if (data.isNull())
810  return aDefault;
811 
812  return KConfigGroupPrivate::deserializeList(data);
813 }
814 
815 void KConfigGroup::writeEntry( const char* key, const QString& value, WriteConfigFlags flags )
816 {
817  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
818  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
819 
820  writeEntry(key, value.toUtf8(), flags);
821 }
822 
823 void KConfigGroup::writeEntry( const QString& key, const QString& value, WriteConfigFlags flags )
824 {
825  writeEntry(key.toUtf8().constData(), value, flags);
826 }
827 
828 void KConfigGroup::writeEntry(const QString &key, const char *value, WriteConfigFlags pFlags)
829 {
830  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
831  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
832 
833  writeEntry(key.toUtf8().constData(), QVariant(QString::fromLatin1(value)), pFlags);
834 }
835 
836 void KConfigGroup::writeEntry(const char *key, const char *value, WriteConfigFlags pFlags)
837 {
838  writeEntry(key, QVariant(QString::fromLatin1(value)), pFlags);
839 }
840 
841 void KConfigGroup::writeEntry( const char* key, const QByteArray& value,
842  WriteConfigFlags flags )
843 {
844  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
845  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
846 
847  config()->d_func()->putData(d->fullName(), key, value.isNull()? QByteArray(""): value, flags);
848 }
849 
850 void KConfigGroup::writeEntry(const QString& key, const QByteArray& value,
851  WriteConfigFlags pFlags)
852 {
853  writeEntry(key.toUtf8().constData(), value, pFlags);
854 }
855 
856 void KConfigGroup::writeEntry(const char* key, const QStringList &list, WriteConfigFlags flags)
857 {
858  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
859  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
860 
861  QList<QByteArray> balist;
862 
863  foreach(const QString &entry, list)
864  balist.append(entry.toUtf8());
865 
866  writeEntry(key, KConfigGroupPrivate::serializeList(balist), flags);
867 }
868 
869 void KConfigGroup::writeEntry(const QString& key, const QStringList &list, WriteConfigFlags flags)
870 {
871  writeEntry(key.toUtf8().constData(), list, flags);
872 }
873 
874 void KConfigGroup::writeEntry( const char* key, const QVariantList& list, WriteConfigFlags flags )
875 {
876  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
877  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
878 
879  QList<QByteArray> data;
880 
881  foreach(const QVariant& v, list) {
882  if (v.type() == QVariant::ByteArray)
883  data << v.toByteArray();
884  else
885  data << v.toString().toUtf8();
886  }
887 
888  writeEntry(key, KConfigGroupPrivate::serializeList(data), flags);
889 }
890 
891 void KConfigGroup::writeEntry( const char* key, const QVariant &value,
892  WriteConfigFlags flags )
893 {
894  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
895  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
896 
897  if ( writeEntryGui( this, key, value, flags ) )
898  return; // GUI type that was handled
899 
900  QByteArray data;
901  // if a type handler is added here you must add a QVConversions definition
902  // to conversion_check.h, or ConversionCheck::to_QVariant will not allow
903  // writeEntry<T> to convert to QVariant.
904  switch( value.type() ) {
905  case QVariant::Invalid:
906  data = "";
907  break;
908  case QVariant::ByteArray:
909  data = value.toByteArray();
910  break;
911  case QVariant::String:
912  case QVariant::Int:
913  case QVariant::UInt:
914  case QVariant::Double:
915  case QMetaType::Float:
916  case QVariant::Bool:
917  case QVariant::LongLong:
918  case QVariant::ULongLong:
919  data = value.toString().toUtf8();
920  break;
921  case QVariant::List:
922  kError(!value.canConvert(QVariant::StringList))
923  << "not all types in \"" << key << "\" can convert to QString,"
924  " information will be lost";
925  case QVariant::StringList:
926  writeEntry( key, value.toList(), flags );
927  return;
928  case QVariant::Point: {
929  QVariantList list;
930  const QPoint rPoint = value.toPoint();
931  list.insert( 0, rPoint.x() );
932  list.insert( 1, rPoint.y() );
933 
934  writeEntry( key, list, flags );
935  return;
936  }
937  case QVariant::PointF: {
938  QVariantList list;
939  const QPointF point = value.toPointF();
940  list.insert( 0, point.x() );
941  list.insert( 1, point.y() );
942 
943  writeEntry( key, list, flags );
944  return;
945  }
946  case QVariant::Rect:{
947  QVariantList list;
948  const QRect rRect = value.toRect();
949  list.insert( 0, rRect.left() );
950  list.insert( 1, rRect.top() );
951  list.insert( 2, rRect.width() );
952  list.insert( 3, rRect.height() );
953 
954  writeEntry( key, list, flags );
955  return;
956  }
957  case QVariant::RectF:{
958  QVariantList list;
959  const QRectF rRectF = value.toRectF();
960  list.insert(0, rRectF.left());
961  list.insert(1, rRectF.top());
962  list.insert(2, rRectF.width());
963  list.insert(3, rRectF.height());
964 
965  writeEntry(key, list, flags);
966  return;
967  }
968  case QVariant::Size:{
969  QVariantList list;
970  const QSize rSize = value.toSize();
971  list.insert( 0, rSize.width() );
972  list.insert( 1, rSize.height() );
973 
974  writeEntry( key, list, flags );
975  return;
976  }
977  case QVariant::SizeF:{
978  QVariantList list;
979  const QSizeF rSizeF = value.toSizeF();
980  list.insert(0, rSizeF.width());
981  list.insert(1, rSizeF.height());
982 
983  writeEntry(key, list, flags);
984  return;
985  }
986  case QVariant::Date: {
987  QVariantList list;
988  const QDate date = value.toDate();
989 
990  list.insert( 0, date.year() );
991  list.insert( 1, date.month() );
992  list.insert( 2, date.day() );
993 
994  writeEntry( key, list, flags );
995  return;
996  }
997  case QVariant::DateTime: {
998  QVariantList list;
999  const QDateTime rDateTime = value.toDateTime();
1000 
1001  const QTime time = rDateTime.time();
1002  const QDate date = rDateTime.date();
1003 
1004  list.insert( 0, date.year() );
1005  list.insert( 1, date.month() );
1006  list.insert( 2, date.day() );
1007 
1008  list.insert( 3, time.hour() );
1009  list.insert( 4, time.minute() );
1010  list.insert( 5, time.second() );
1011 
1012  writeEntry( key, list, flags );
1013  return;
1014  }
1015 
1016  case QVariant::Color:
1017  case QVariant::Font:
1018  kWarning() << "KConfigGroup::writeEntry was passed GUI type '"
1019  << value.typeName()
1020  << "' but kdeui isn't linked! If it is linked to your program, this is a platform bug. "
1021  "Please inform the KDE developers";
1022  break;
1023  case QVariant::Url:
1024  data = KUrl(value.toUrl()).url().toUtf8();
1025  break;
1026  default:
1027  if( value.canConvert<KUrl>() ) {
1028  data = qvariant_cast<KUrl>(value).url().toUtf8();
1029  break;
1030  }
1031  kWarning() << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name();
1032  }
1033 
1034  writeEntry(key, data, flags);
1035 }
1036 
1037 void KConfigGroup::writeEntry( const QString& key, const QVariant& value, WriteConfigFlags flags )
1038 {
1039  writeEntry(key.toUtf8().constData(), value, flags);
1040 }
1041 
1042 void KConfigGroup::writeEntry(const QString& key, const QVariantList &list, WriteConfigFlags flags)
1043 {
1044  writeEntry(key.toUtf8().constData(), list, flags);
1045 }
1046 
1047 void KConfigGroup::writeXdgListEntry(const QString& key, const QStringList &value, WriteConfigFlags pFlags)
1048 {
1049  writeXdgListEntry(key.toUtf8().constData(), value, pFlags);
1050 }
1051 
1052 void KConfigGroup::writeXdgListEntry(const char *key, const QStringList &list, WriteConfigFlags flags)
1053 {
1054  Q_ASSERT_X(isValid(), "KConfigGroup::writeXdgListEntry", "accessing an invalid group");
1055  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeXdgListEntry", "writing to a read-only group");
1056 
1057  QString value;
1058  value.reserve(4096);
1059 
1060  // XXX List serialization being a separate layer from low-level escaping is
1061  // probably a bug. No affected entries are defined, though.
1062  QStringList::ConstIterator it = list.constBegin();
1063  const QStringList::ConstIterator end = list.constEnd();
1064  for (; it != end; ++it) {
1065  QString val(*it);
1066  val.replace(QLatin1Char('\\'), QLatin1String("\\\\")).replace(QLatin1Char(';'), QLatin1String("\\;"));
1067  value += val;
1068  value += QLatin1Char(';');
1069  }
1070 
1071  writeEntry(key, value, flags);
1072 }
1073 
1074 void KConfigGroup::writePathEntry(const QString& pKey, const QString & path, WriteConfigFlags pFlags)
1075 {
1076  writePathEntry(pKey.toUtf8().constData(), path, pFlags);
1077 }
1078 
1079 void KConfigGroup::writePathEntry(const char *pKey, const QString & path, WriteConfigFlags pFlags)
1080 {
1081  Q_ASSERT_X(isValid(), "KConfigGroup::writePathEntry", "accessing an invalid group");
1082  Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
1083 
1084  config()->d_func()->putData(d->fullName(), pKey, translatePath(path).toUtf8(), pFlags, true);
1085 }
1086 
1087 void KConfigGroup::writePathEntry(const QString& pKey, const QStringList &value, WriteConfigFlags pFlags)
1088 {
1089  writePathEntry(pKey.toUtf8().constData(), value, pFlags);
1090 }
1091 
1092 void KConfigGroup::writePathEntry(const char *pKey, const QStringList &value, WriteConfigFlags pFlags)
1093 {
1094  Q_ASSERT_X(isValid(), "KConfigGroup::writePathEntry", "accessing an invalid group");
1095  Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
1096 
1097  QList<QByteArray> list;
1098  foreach(const QString& path, value)
1099  list << translatePath(path).toUtf8();
1100 
1101  config()->d_func()->putData(d->fullName(), pKey, KConfigGroupPrivate::serializeList(list), pFlags, true);
1102 }
1103 
1104 void KConfigGroup::deleteEntry( const char *key, WriteConfigFlags flags)
1105 {
1106  Q_ASSERT_X(isValid(), "KConfigGroup::deleteEntry", "accessing an invalid group");
1107  Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteEntry", "deleting from a read-only group");
1108 
1109  config()->d_func()->putData(d->fullName(), key, QByteArray(), flags);
1110 }
1111 
1112 void KConfigGroup::deleteEntry( const QString& key, WriteConfigFlags flags)
1113 {
1114  deleteEntry(key.toUtf8().constData(), flags);
1115 }
1116 
1117 void KConfigGroup::revertToDefault(const char *key)
1118 {
1119  Q_ASSERT_X(isValid(), "KConfigGroup::revertToDefault", "accessing an invalid group");
1120  Q_ASSERT_X(!d->bConst, "KConfigGroup::revertToDefault", "writing to a read-only group");
1121 
1122  config()->d_func()->revertEntry(d->fullName(), key);
1123 }
1124 
1125 void KConfigGroup::revertToDefault(const QString &key)
1126 {
1127  revertToDefault(key.toUtf8().constData());
1128 }
1129 
1130 bool KConfigGroup::hasDefault(const char *key) const
1131 {
1132  Q_ASSERT_X(isValid(), "KConfigGroup::hasDefault", "accessing an invalid group");
1133 
1134  KEntryMap::SearchFlags flags = KEntryMap::SearchDefaults|KEntryMap::SearchLocalized;
1135 
1136  return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
1137 }
1138 
1139 bool KConfigGroup::hasDefault(const QString &key) const
1140 {
1141  return hasDefault(key.toUtf8().constData());
1142 }
1143 
1144 bool KConfigGroup::hasKey(const char *key) const
1145 {
1146  Q_ASSERT_X(isValid(), "KConfigGroup::hasKey", "accessing an invalid group");
1147 
1148  KEntryMap::SearchFlags flags = KEntryMap::SearchLocalized;
1149  if ( config()->readDefaults() )
1150  flags |= KEntryMap::SearchDefaults;
1151 
1152  return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
1153 }
1154 
1155 bool KConfigGroup::hasKey(const QString &key) const
1156 {
1157  return hasKey(key.toUtf8().constData());
1158 }
1159 
1160 bool KConfigGroup::isImmutable() const
1161 {
1162  Q_ASSERT_X(isValid(), "KConfigGroup::isImmutable", "accessing an invalid group");
1163 
1164  return d->bImmutable;
1165 }
1166 
1167 QStringList KConfigGroup::groupList() const
1168 {
1169  Q_ASSERT_X(isValid(), "KConfigGroup::groupList", "accessing an invalid group");
1170 
1171  return config()->d_func()->groupList(d->fullName());
1172 }
1173 
1174 QStringList KConfigGroup::keyList() const
1175 {
1176  Q_ASSERT_X(isValid(), "KConfigGroup::keyList", "accessing an invalid group");
1177 
1178  return entryMap().keys();
1179 }
1180 
1181 void KConfigGroup::markAsClean()
1182 {
1183  Q_ASSERT_X(isValid(), "KConfigGroup::markAsClean", "accessing an invalid group");
1184 
1185  config()->markAsClean();
1186 }
1187 
1188 KConfigGroup::AccessMode KConfigGroup::accessMode() const
1189 {
1190  Q_ASSERT_X(isValid(), "KConfigGroup::accessMode", "accessing an invalid group");
1191 
1192  return config()->accessMode();
1193 }
1194 
1195 bool KConfigGroup::hasGroupImpl(const QByteArray & b) const
1196 {
1197  Q_ASSERT_X(isValid(), "KConfigGroup::hasGroupImpl", "accessing an invalid group");
1198 
1199  return config()->hasGroup(d->fullName(b));
1200 }
1201 
1202 void KConfigGroup::deleteGroupImpl(const QByteArray &b, WriteConfigFlags flags)
1203 {
1204  Q_ASSERT_X(isValid(), "KConfigGroup::deleteGroupImpl", "accessing an invalid group");
1205  Q_ASSERT_X(!d->bConst,"KConfigGroup::deleteGroupImpl", "deleting from a read-only group");
1206 
1207  config()->deleteGroup(d->fullName(b), flags);
1208 }
1209 
1210 bool KConfigGroup::isGroupImmutableImpl(const QByteArray& b) const
1211 {
1212  Q_ASSERT_X(isValid(), "KConfigGroup::isGroupImmutableImpl", "accessing an invalid group");
1213 
1214  if (!hasGroupImpl(b)) // group doesn't exist yet
1215  return d->bImmutable; // child groups are immutable if the parent is immutable.
1216 
1217  return config()->isGroupImmutable(d->fullName(b));
1218 }
1219 
1220 void KConfigGroup::copyTo(KConfigBase* other, WriteConfigFlags pFlags) const
1221 {
1222  Q_ASSERT_X(isValid(), "KConfigGroup::copyTo", "accessing an invalid group");
1223  Q_ASSERT(other != 0);
1224 
1225  if (KConfigGroup *otherGroup = dynamic_cast<KConfigGroup*>(other)) {
1226  config()->d_func()->copyGroup(d->fullName(), otherGroup->d->fullName(), otherGroup, pFlags);
1227  } else if (KConfig* otherConfig = dynamic_cast<KConfig*>(other)) {
1228  KConfigGroup newGroup = otherConfig->group(d->fullName());
1229  otherConfig->d_func()->copyGroup(d->fullName(), d->fullName(), &newGroup, pFlags);
1230  } else {
1231  Q_ASSERT_X(false, "KConfigGroup::copyTo", "unknown type of KConfigBase");
1232  }
1233 }
1234 
1235 void KConfigGroup::reparent(KConfigBase* parent, WriteConfigFlags pFlags)
1236 {
1237  Q_ASSERT_X(isValid(), "KConfigGroup::reparent", "accessing an invalid group");
1238  Q_ASSERT_X(!d->bConst, "KConfigGroup::reparent", "reparenting a read-only group");
1239  Q_ASSERT_X(!d->bImmutable, "KConfigGroup::reparent", "reparenting an immutable group");
1240  Q_ASSERT(parent != 0);
1241 
1242  KConfigGroup oldGroup(*this);
1243 
1244  d = KConfigGroupPrivate::create(parent, d->mName, false, false);
1245  oldGroup.copyTo(this, pFlags);
1246  oldGroup.deleteGroup(); // so that the entries with the old group name are deleted on sync
1247 }
KConfigGroupGui::writeEntryGui
kWriteEntryGui writeEntryGui
Definition: kconfiggroup_p.h:37
QVariant::canConvert
bool canConvert(Type t) const
QVariant::toUrl
QUrl toUrl() const
KConfigGroup::readPathEntry
QString readPathEntry(const QString &pKey, const QString &aDefault) const
Reads a path.
Definition: kconfiggroup.cpp:780
QVariant::toByteArray
QByteArray toByteArray() const
QTime::minute
int minute() const
KSharedPtr< KSharedConfig >
KConfig::sync
void sync()
Definition: kconfig.cpp:388
KConfigGroup::groupImpl
KConfigGroup groupImpl(const QByteArray &b)
Definition: kconfiggroup.cpp:513
QExplicitlySharedDataPointer::detach
void detach()
QSize::width
int width() const
QVariant::toPointF
QPointF toPointF() const
KConfigGroup::writePathEntry
void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags=Normal)
Writes a file path to the configuration.
Definition: kconfiggroup.cpp:1074
kdebug.h
errString
static QString errString(const char *pKey, const QByteArray &value, const QVariant &aDefault)
Definition: kconfiggroup.cpp:195
QByteArray::toInt
int toInt(bool *ok, int base) const
KConfigGroup::accessMode
AccessMode accessMode() const
Definition: kconfiggroup.cpp:1188
QByteArray::toLower
QByteArray toLower() const
QByteArray::toDouble
double toDouble(bool *ok) const
QByteArray::reserve
void reserve(int size)
QByteArray
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:1139
QVariant::toList
QList< QVariant > toList() const
QExplicitlySharedDataPointer::constData
const T * constData() const
QVariant::toDateTime
QDateTime toDateTime() const
translatePath
static QString translatePath(QString path)
Definition: kconfiggroup.cpp:398
QString::prepend
QString & prepend(QChar ch)
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
QDir::convertSeparators
QString convertSeparators(const QString &pathName)
QList::at
const T & at(int i) const
QMap
QByteArray::isNull
bool isNull() const
QString::size
int size() const
KConfigGroup::reparent
void reparent(KConfigBase *parent, WriteConfigFlags pFlags=Normal)
Changes the configuration object that this group belongs to.
Definition: kconfiggroup.cpp:1235
QByteArray::isEmpty
bool isEmpty() const
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:1181
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
QDateTime::time
QTime time() const
QRectF::top
qreal top() const
KConfigGroup::writeEntry
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
Writes a value to the configuration object.
Definition: kconfiggroup.cpp:1037
QRect::height
int height() const
KConfigGroup::changeGroup
void changeGroup(const QString &group)
Changes the group of the object.
Definition: kconfiggroup.cpp:564
QPoint
KConfigGroup::isValid
bool isValid() const
Whether the group is valid.
Definition: kconfiggroup.cpp:445
QString::remove
QString & remove(int position, int n)
QDate::month
int month() const
KConfigGroup::deleteGroup
void deleteGroup(WriteConfigFlags pFlags=Normal)
Delete all entries in the entire group.
Definition: kconfiggroup.cpp:555
QDir::homePath
QString homePath()
QTime
formatError
static QString formatError(int expected, int got)
Definition: kconfiggroup.cpp:202
QRectF::left
qreal left() const
kconfig_p.h
KUrl
Represents and parses a URL.
Definition: kurl.h:111
QTime::second
int second() const
QPoint::x
int x() const
QPoint::y
int y() const
KConfigGroupGui::readEntryGui
kReadEntryGui readEntryGui
Definition: kconfiggroup_p.h:36
QString::isNull
bool isNull() const
QPointF
QString::clear
void clear()
KConfig::entryMap
QMap< QString, QString > entryMap(const QString &aGroup=QString()) const
Returns a map (tree) of entries in a particular group.
Definition: kconfig.cpp:356
KConfigGroup::deleteEntry
void deleteEntry(const QString &pKey, WriteConfigFlags pFlags=Normal)
Deletes the entry specified by pKey in the current group.
Definition: kconfiggroup.cpp:1112
KConfigGroupGui
Definition: kconfiggroup_p.h:29
QRect
QSharedData
QList::count
int count(const T &value) const
QPointF::x
qreal x() const
QPointF::y
qreal y() const
QList::append
void append(const T &value)
QString::fromUtf8
QString fromUtf8(const char *str, int size)
KConfigGroup::readEntryUntranslated
QString readEntryUntranslated(const QString &pKey, const QString &aDefault=QString()) const
Reads an untranslated string entry.
Definition: kconfiggroup.cpp:637
QRect::top
int top() const
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:672
QRect::left
int left() const
KConfig::groupList
QStringList groupList() const
Definition: kconfig.cpp:261
QList::isEmpty
bool isEmpty() const
KConfigGroup::isGroupImmutableImpl
bool isGroupImmutableImpl(const QByteArray &aGroup) const
Definition: kconfiggroup.cpp:1210
QString::isEmpty
bool isEmpty() const
QDate::day
int day() const
KConfigGroup::~KConfigGroup
~KConfigGroup()
Definition: kconfiggroup.cpp:508
QByteArray::constData
const char * constData() const
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QByteArray::replace
QByteArray & replace(int pos, int len, const char *after)
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:1047
QVariant::toSizeF
QSizeF toSizeF() const
QDate
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
QDate::year
int year() const
QString
KConfigGroup::copyTo
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
Copies the entries in this group to another configuration object.
Definition: kconfiggroup.cpp:1220
QList< QByteArray >
KConfigBase
Definition: kconfigbase.h:38
QStringList
KConfigGroup::keyList
QStringList keyList() const
Returns a list of keys this group contains.
Definition: kconfiggroup.cpp:1174
kconfigdata.h
QVariant::toSize
QSize toSize() const
QTime::hour
int hour() const
QFileInfo
QSize
QUrl
QLatin1Char
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:1155
QVariant::typeToName
const char * typeToName(Type typ)
QDir
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:53
QVariant::toDate
QDate toDate() const
QString::replace
QString & replace(int position, int n, QChar after)
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
QRect::width
int width() const
QRectF::width
qreal width() const
QString::mid
QString mid(int position, int n) const
QDateTime::date
QDate date() const
KConfig::markAsClean
void markAsClean()
Definition: kconfig.cpp:458
output
void output(QList< Action > actions, QHash< QString, QString > domain)
Definition: fake/kauth-policy-gen-polkit.cpp:41
QSizeF
KConfigGroup::hasGroupImpl
bool hasGroupImpl(const QByteArray &group) const
Definition: kconfiggroup.cpp:1195
QLatin1String
asRealList
static QList< qreal > asRealList(const QByteArray &string)
Definition: kconfiggroup.cpp:187
QRectF
_kde_internal_KConfigGroupGui
KConfigGroupGui _kde_internal_KConfigGroupGui
Definition: kconfiggroup.cpp:450
QVariant::typeName
const char * typeName() const
kconfiggroup_p.h
QList::ConstIterator
typedef ConstIterator
QSize::height
int height() const
QList::mid
QList< T > mid(int pos, int length) const
KConfigBase::AccessMode
AccessMode
Possible return values for accessMode().
Definition: kconfigbase.h:133
QString::length
int length() const
QString::reserve
void reserve(int size)
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
QString::fromLatin1
QString fromLatin1(const char *str, int size)
readEntryGui
static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output)
Definition: kconfiggroup.cpp:451
QVariant::toPoint
QPoint toPoint() const
QRectF::height
qreal height() const
QDir::canonicalPath
QString canonicalPath() const
KEntryMap::SearchLocalized
Definition: kconfigdata.h:157
KConfigGroup::sync
void sync()
Definition: kconfiggroup.cpp:595
QVariant::toRect
QRect toRect() const
QList::constEnd
const_iterator constEnd() const
QList::constBegin
const_iterator constBegin() const
QVariant::type
Type type() const
kcomponentdata.h
QSizeF::height
qreal height() const
QVariant::toRectF
QRectF toRectF() const
KConfigGroup::isImmutable
bool isImmutable() const
Whether this group may be changed.
Definition: kconfiggroup.cpp:1160
QExplicitlySharedDataPointer< KConfigGroupPrivate >
QVariant::convert
bool convert(Type t)
KConfigGroup::deleteGroupImpl
void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags)
Definition: kconfiggroup.cpp:1202
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QVariant::toString
QString toString() const
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:1125
QString::squeeze
void squeeze()
KEntryMap::SearchDefaults
Definition: kconfigdata.h:156
QSizeF::width
qreal width() const
KConfigGroup::groupList
QStringList groupList() const
Definition: kconfiggroup.cpp:1167
KConfigGroup::entryMap
QMap< QString, QString > entryMap() const
Returns a map (tree) of entries for all entries in this group.
Definition: kconfiggroup.cpp:603
QFile::decodeName
QString decodeName(const QByteArray &localFileName)
kconfiggroup.h
QDateTime
KConfigGroup::KConfigGroup
KConfigGroup()
Constructs an invalid group.
Definition: kconfiggroup.cpp:441
KConfig::readDefaults
bool readDefaults() const
Definition: kconfig.cpp:721
QVariant
QString::toUtf8
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • 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