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

kcachegrind

  • sources
  • kde-4.12
  • kdesdk
  • kcachegrind
  • kcachegrind
kdeconfig.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2002, 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
3 
4  KCachegrind is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, version 2.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 /*
20  * Configuration for KCachegrind
21  */
22 
23 #include "kdeconfig.h"
24 
25 #include <kconfig.h>
26 #include <klocale.h>
27 #include <kdebug.h>
28 #include <kconfiggroup.h>
29 
30 #include "tracedata.h"
31 #include "traceitemview.h"
32 #include "ui_configdlgbase.h"
33 
34 //
35 // KDEConfigGroup
36 //
37 
38 KDEConfigGroup::KDEConfigGroup(KConfigGroup* group, bool readOnly)
39 {
40  _kgroup = group;
41  _readOnly = readOnly;
42 }
43 
44 KDEConfigGroup::~KDEConfigGroup()
45 {
46  delete _kgroup;
47 }
48 
49 void KDEConfigGroup::setValue(const QString& key, const QVariant& value,
50  const QVariant& defaultValue)
51 {
52  if ((_kgroup == 0) || _readOnly) return;
53 
54  if (value == defaultValue) {
55  _kgroup->deleteEntry(key);
56  return;
57  }
58 
59  switch(value.type()) {
60  case QVariant::Bool:
61  _kgroup->writeEntry(key, value.toBool());
62  break;
63  case QVariant::Int:
64  _kgroup->writeEntry(key, value.toInt());
65  break;
66  case QVariant::Double:
67  _kgroup->writeEntry(key, value.toDouble());
68  break;
69  case QVariant::String:
70  _kgroup->writeEntry(key, value.toString());
71  break;
72  case QVariant::StringList:
73  _kgroup->writeEntry(key, value.toStringList());
74  break;
75  case QVariant::Color:
76  _kgroup->writeEntry(key, value.value<QColor>());
77  break;
78  default:
79  qFatal("KDEConfigGroup::setValue - QVariant type %s not supported",
80  value.typeName());
81  }
82 }
83 
84 QVariant KDEConfigGroup::value(const QString& key,
85  const QVariant& defaultValue) const
86 {
87  if (_kgroup == 0) return defaultValue;
88 
89  switch(defaultValue.type()) {
90  case QVariant::Bool:
91  return QVariant(_kgroup->readEntry(key,
92  defaultValue.toBool()));
93  case QVariant::Int:
94  return QVariant(_kgroup->readEntry(key,
95  defaultValue.toInt()));
96  case QVariant::Double:
97  return QVariant(_kgroup->readEntry(key,
98  defaultValue.toDouble()));
99  case QVariant::String:
100  return QVariant(_kgroup->readEntry(key,
101  defaultValue.toString()));
102  case QVariant::StringList:
103  return QVariant(_kgroup->readEntry(key,
104  defaultValue.toStringList()));
105  case QVariant::Color:
106  return QVariant(_kgroup->readEntry(key,
107  defaultValue.value<QColor>()));
108  default:
109  qFatal("KDEConfigGroup::value - QVariant type %s not supported",
110  defaultValue.typeName());
111  }
112  return defaultValue;
113 }
114 
115 
116 
117 //
118 // KDEConfigStorage
119 //
120 
121 KDEConfigStorage::KDEConfigStorage(KConfig* kconfig)
122 {
123  _kconfig = kconfig;
124 }
125 
126 ConfigGroup* KDEConfigStorage::getGroup(const QString& group,
127  const QString& optSuffix)
128 {
129  KConfigGroup* g;
130  bool readOnly;
131 
132  if (!optSuffix.isEmpty()) {
133  readOnly = true;
134  QStringList gList = _kconfig->groupList();
135  if (gList.contains(group+optSuffix))
136  g = new KConfigGroup(_kconfig, group+optSuffix);
137  else if (gList.contains(group))
138  g = new KConfigGroup(_kconfig, group);
139  else
140  g = 0;
141  }
142  else {
143  readOnly = false;
144  g = new KConfigGroup(_kconfig, group);
145  }
146 
147  return new KDEConfigGroup(g, readOnly);
148 }
KDEConfigStorage::KDEConfigStorage
KDEConfigStorage(KConfig *)
Definition: kdeconfig.cpp:121
KDEConfigGroup::value
QVariant value(const QString &key, const QVariant &defaultValue) const
Definition: kdeconfig.cpp:84
traceitemview.h
tracedata.h
KDEConfigGroup::~KDEConfigGroup
~KDEConfigGroup()
Definition: kdeconfig.cpp:44
ConfigGroup
A group of configuration settings.
Definition: config.h:35
KDEConfigGroup
Definition: kdeconfig.h:32
KDEConfigGroup::setValue
void setValue(const QString &key, const QVariant &value, const QVariant &defaultValue=QVariant())
Definition: kdeconfig.cpp:49
kdeconfig.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcachegrind

Skip menu "kcachegrind"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

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