15#include "Preference.h"
17#include "IException.h"
28 void Preference::Load(
const QString &file) {
38 QString(
"The preference file %1 was not found or does not exist").arg(file),
44 for(
int i = 0; i < pvl.
groups(); i++) {
45 Isis::PvlGroup &inGroup = pvl.
group(i);
48 for(
int k = 0; k < inGroup.
keywords(); k++) {
49 Isis::PvlKeyword &inKey = inGroup[k];
64 PvlGroup &performance =
findGroup(
"Performance");
65 if (performance.hasKeyword(
"GlobalThreads")) {
66 IString threadsPreference = performance[
"GlobalThreads"][0];
68 if (threadsPreference.DownCase() !=
"optimized") {
70 int threads = threadsPreference.ToQt().toInt();
73 QThreadPool::globalInstance()->setMaxThreadCount(threads);
86 Preference &Preference::Preferences(
bool unitTest) {
93 Isis::FileName setup(
"$HOME/.Isis");
94 if(!setup.fileExists()) {
96 QString dirName(IString(setup.expanded()).ToQt());
108 Isis::FileName userPref(
"$HOME/.Isis/IsisPreferences");
109 if(userPref.fileExists()) {
127 bool Preference::outputErrorAsPvl() {
128 bool usePvlFormat =
false;
130 PvlGroup &errorFacility = this->
findGroup(
"ErrorFacility");
131 if (errorFacility.hasKeyword(
"Format")) {
132 QString format = errorFacility[
"Format"][0];
133 usePvlFormat = (format.toUpper() ==
"PVL");
136 catch (IException &e) {
142 bool Preference::reportFileLine() {
143 bool reportFileLine =
true;
145 if (this->
hasGroup(
"ErrorFacility")) {
146 PvlGroup &errorFacility = this->
findGroup(
"ErrorFacility");
147 if (errorFacility.hasKeyword(
"FileLine")) {
148 QString fileLine = errorFacility[
"FileLine"][0];
149 reportFileLine = (fileLine.toUpper() ==
"ON");
153 return reportFileLine;
156 void Preference::Shutdown() {
File name manipulation and expansion.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Reads user preferences from a data file.
Preference()
Constructs a Preference object.
static Preference * p_preference
Pointer to a Preference object.
static bool p_unitTest
Flag indicating whether the file is a unitTest or not.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
QString name() const
Returns the container name.
void deleteKeyword(const QString &name)
Remove a specified keyword.
Container for cube-like labels.
Pvl()
Constructs an empty Pvl object.
void read(const QString &file)
Loads PVL information from a stream.
QString name() const
Returns the keyword name.
PvlGroup & group(const int index)
Return the group at the specified index.
int groups() const
Returns the number of groups contained.
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.