File indexing completed on 2024-04-28 09:36:47
0001 /* 0002 This file is part of KCachegrind. 0003 0004 SPDX-FileCopyrightText: 2002-2016 Josef Weidendorfer <Josef.Weidendorfer@gmx.de> 0005 0006 SPDX-License-Identifier: GPL-2.0-only 0007 */ 0008 0009 /* 0010 * Global configuration for KCachegrind (only non-GUI options) 0011 */ 0012 0013 #ifndef GLOBALCONFIG_H 0014 #define GLOBALCONFIG_H 0015 0016 #include <QStringList> 0017 #include <QHash> 0018 0019 #include "tracedata.h" 0020 0021 class GlobalConfig; 0022 0023 /** 0024 * Global configuration (only non-GUI options). 0025 * A singleton. 0026 */ 0027 class GlobalConfig 0028 { 0029 friend class ConfigDlg; 0030 0031 public: 0032 GlobalConfig(); 0033 virtual ~GlobalConfig(); 0034 0035 // gets the singleton instance 0036 static GlobalConfig* config(); 0037 0038 virtual void saveOptions(); 0039 virtual void readOptions(); 0040 0041 static QStringList sourceDirs(TraceData*, TraceObject* o = nullptr); 0042 static bool showPercentage(); 0043 static bool showExpanded(); 0044 static bool showCycles(); 0045 static bool hideTemplates(); 0046 0047 // lower percentage limit of cost items filled into lists 0048 static int percentPrecision(); 0049 // max symbol lengths/count in tooltip/popup 0050 static int maxSymbolLength(); 0051 // strip a symbol name according to <maxSymbolLength> 0052 static QString shortenSymbol(const QString&); 0053 static int maxSymbolCount(); 0054 // max. number of items in lists 0055 static int maxListCount(); 0056 0057 // how many lines of context to show before/after annotated source/assembler 0058 static int context(); 0059 // how many lines without cost are still regarded as inside a function 0060 static int noCostInside(); 0061 0062 const QStringList& generalSourceDirs(); 0063 QStringList objectSourceDirs(QString); 0064 void setGeneralSourceDirs(QStringList); 0065 void setObjectSourceDirs(QString, QStringList); 0066 void clearObjectSourceDirs(); 0067 0068 void setPercentPrecision(int); 0069 void setMaxSymbolLength(int); 0070 void setMaxSymbolCount(int); 0071 void setMaxListCount(int); 0072 void setContext(int); 0073 0074 static void setShowPercentage(bool); 0075 static void setShowExpanded(bool); 0076 0077 static void setShowCycles(bool); 0078 0079 static void setHideTemplates(bool); 0080 // upper limit for cutting of a call in cycle detection 0081 static double cycleCut(); 0082 0083 void addDefaultTypes(); 0084 0085 protected: 0086 QStringList knownTypes(); 0087 QString knownFormula(const QString& name); 0088 QString knownLongName(const QString& name); 0089 0090 QStringList _generalSourceDirs; 0091 QHash<QString, QStringList> _objectSourceDirs; 0092 0093 bool _showPercentage, _showExpanded, _showCycles, _hideTemplates; 0094 double _cycleCut; 0095 int _percentPrecision; 0096 int _maxSymbolLength, _maxSymbolCount, _maxListCount; 0097 int _context, _noCostInside; 0098 0099 static GlobalConfig* _config; 0100 }; 0101 0102 #endif // GLOBALCONFIG_H