22 #include <tqfileinfo.h> 25 #include <kstandarddirs.h> 26 #include <tdeconfig.h> 27 #include <tdeio/netaccess.h> 29 Profile::Profile(
Profile *parent,
const TQString &name)
30 :m_parent(parent), m_name(name)
33 m_parent->addChildProfile(
this);
35 TQString profileConfig = locate(
"data",
"tdevelop/profiles" + dirName() +
"/profile.config");
36 TDEConfig config(profileConfig);
38 config.setGroup(
"Information");
39 m_genericName = config.readEntry(
"GenericName");
40 m_description = config.readEntry(
"Description");
42 config.setGroup(
"Properties");
43 m_properties = config.readListEntry(
"List");
45 config.setGroup(
"Enable");
46 m_explicitEnable = config.readListEntry(
"List");
48 config.setGroup(
"Disable");
49 m_explicitDisable = config.readListEntry(
"List");
52 Profile::Profile(
Profile *parent,
const TQString &name,
const TQString &genericName,
const TQString &description)
53 :m_parent(parent), m_name(name), m_genericName(genericName), m_description(description)
56 m_parent->addChildProfile(
this);
62 for (TQValueList<Profile*>::iterator it = m_children.begin(); it != m_children.end(); ++it)
66 void Profile::addChildProfile(
Profile *profile)
68 m_children.append(profile);
71 void Profile::removeChildProfile(
Profile *profile)
73 m_children.remove(profile);
76 TQString Profile::dirName()
const 79 return m_parent->dirName() +
"/" + m_name;
86 TQString profileConfig = locateLocal(
"data",
"tdevelop/profiles" + dirName() +
"/profile.config");
87 TDEConfig config(profileConfig);
89 config.setGroup(
"Information");
90 config.writeEntry(
"GenericName", m_genericName);
91 config.writeEntry(
"Description", m_description);
93 config.setGroup(
"Properties");
94 config.writeEntry(
"List", m_properties);
96 config.setGroup(
"Enable");
97 config.writeEntry(
"List", m_explicitEnable);
99 config.setGroup(
"Disable");
100 config.writeEntry(
"List", m_explicitDisable);
105 Profile::EntryList Profile::list(
List type)
107 EntryList parentList;
109 parentList = m_parent->list(type);
110 EntryList list = parentList;
111 for (EntryList::iterator it = list.begin(); it != list.end(); ++it)
112 (*it).derived =
true;
113 TQStringList &personalList = listByType(type);
114 for (TQStringList::const_iterator it = personalList.begin(); it != personalList.end(); ++it)
115 list.append(Entry(*it,
false));
119 void Profile::addEntry(
List type,
const TQString &value)
121 TQStringList &list = listByType(type);
122 if (!list.contains(value))
126 void Profile::removeEntry(
List type,
const TQString &value)
128 TQStringList &list = listByType(type);
132 void Profile::clearList(
List type )
137 m_properties.clear();
139 m_explicitEnable.clear();
141 m_explicitDisable.clear();
145 TQStringList &Profile::listByType(
List type)
151 return m_explicitEnable;
154 return m_explicitDisable;
158 bool Profile::hasInEntryList(EntryList &list, TQString value)
160 for (EntryList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it)
161 if ((*it).name == value)
166 bool Profile::remove()
168 TQStringList dirs = TDEGlobal::dirs()->findDirs(
"data",
"tdevelop/profiles" + dirName());
169 if ((dirs.count() == 1) && dirs[0].startsWith(TQDir::homeDirPath()))
170 return TDEIO::NetAccess::del(KURL::fromPathOrURL(dirs[0]), 0);
174 void Profile::detachFromParent()
177 m_parent->removeChildProfile(
this);
180 KURL::List Profile::resources(
const TQString &nameFilter)
182 TQStringList resources;
183 TQStringList resourceDirs = TDEGlobal::dirs()->resourceDirs(
"data");
184 for (TQStringList::const_iterator it = resourceDirs.begin(); it != resourceDirs.end(); ++it)
187 dir = dir +
"tdevelop/profiles" + dirName();
190 const TQFileInfoList *infoList = d.entryInfoList(nameFilter, TQDir::Files);
193 for (TQFileInfoList::const_iterator infoIt = infoList->constBegin();
194 infoIt != infoList->constEnd(); ++ infoIt)
195 resources.append((*infoIt)->absFilePath());
198 return KURL::List(resources);
201 void Profile::addResource(
const KURL &url)
203 TQString saveLocation = TDEGlobal::dirs()->saveLocation(
"data",
"tdevelop/profiles"+dirName(),
true);
204 TDEIO::NetAccess::file_copy(url, KURL::fromPathOrURL(saveLocation), -1,
true);
List
Lists which are held by a profile.
X-TDevelop-Properties defined for this profile.
A list of explicitly disabled plugins (names).
A list of explicitly enabled plugins (names).