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

kcachegrind

  • sources
  • kde-4.14
  • kdesdk
  • kcachegrind
  • qcachegrind
qcgconfig.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 QCachegrind
21  */
22 
23 #include "qcgconfig.h"
24 
25 #include <QSettings>
26 
27 #include "tracedata.h"
28 #include "traceitemview.h"
29 
30 //
31 // QCGConfigGroup
32 //
33 
34 QCGConfigGroup::QCGConfigGroup(QSettings* settings, QString prefix,
35  bool readOnly)
36 {
37  _settings = settings;
38  _prefix = prefix;
39  _readOnly = readOnly;
40 }
41 
42 QCGConfigGroup::~QCGConfigGroup()
43 {}
44 
45 void QCGConfigGroup::setValue(const QString& key, const QVariant& value,
46  const QVariant& defaultValue)
47 {
48  if ((_settings == 0) || _readOnly) return;
49 
50  QString fullKey = QString("%1/%2").arg(_prefix).arg(key);
51  if (value == defaultValue)
52  _settings->remove(fullKey);
53  else
54  _settings->setValue(fullKey, value);
55 }
56 
57 QVariant QCGConfigGroup::value(const QString& key,
58  const QVariant& defaultValue) const
59 {
60  if (_settings == 0) return defaultValue;
61 
62  QString fullKey = QString("%1/%2").arg(_prefix).arg(key);
63  return _settings->value(fullKey, defaultValue);
64 }
65 
66 
67 
68 //
69 // QCGConfigStorage
70 //
71 
72 QCGConfigStorage::QCGConfigStorage()
73 {
74  _settings = new QSettings;
75 }
76 
77 QCGConfigStorage::~QCGConfigStorage()
78 {
79  delete _settings;
80 }
81 
82 ConfigGroup* QCGConfigStorage::getGroup(const QString& group,
83  const QString& optSuffix)
84 {
85  // for writing
86  if (optSuffix.isEmpty())
87  return new QCGConfigGroup(_settings, group, false);
88 
89  // for reading
90  QStringList gList = _settings->childGroups();
91  if (gList.contains(group+optSuffix))
92  return new QCGConfigGroup(_settings, group + optSuffix, true);
93  else if (gList.contains(group))
94  return new QCGConfigGroup(_settings, group, true);
95 
96  // requested group does not exist, return only default values
97  return new QCGConfigGroup(0, QString::null, true);
98 }
QCGConfigGroup::~QCGConfigGroup
~QCGConfigGroup()
Definition: qcgconfig.cpp:42
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QCGConfigStorage::QCGConfigStorage
QCGConfigStorage()
Definition: qcgconfig.cpp:72
traceitemview.h
QSettings::setValue
void setValue(const QString &key, const QVariant &value)
QCGConfigStorage::~QCGConfigStorage
~QCGConfigStorage()
Definition: qcgconfig.cpp:77
tracedata.h
QString::isEmpty
bool isEmpty() const
QSettings::childGroups
QStringList childGroups() const
QString
ConfigGroup
A group of configuration settings.
Definition: config.h:35
QStringList
QSettings
QSettings::remove
void remove(const QString &key)
QSettings::value
QVariant value(const QString &key, const QVariant &defaultValue) const
QCGConfigGroup
Definition: qcgconfig.h:31
QCGConfigGroup::setValue
void setValue(const QString &key, const QVariant &value, const QVariant &defaultValue=QVariant())
Definition: qcgconfig.cpp:45
QCGConfigGroup::value
QVariant value(const QString &key, const QVariant &defaultValue) const
Definition: qcgconfig.cpp:57
qcgconfig.h
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:39:50 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
  • 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