19 #include "profileengine.h" 25 #include <tdeglobal.h> 26 #include <kstandarddirs.h> 28 #include <kdevplugin.h> 30 ProfileEngine::ProfileEngine()
32 TQStringList dirs = TDEGlobal::dirs()->findDirs(
"data",
"tdevelop/profiles");
34 m_rootProfile =
new Profile(0,
"KDevelop");
36 TQString currPath =
"/";
37 TQMap<TQString, Profile*> passedPaths;
39 for (TQStringList::const_iterator it = dirs.constBegin(); it != dirs.constEnd(); ++it)
40 processDir(*it, currPath, passedPaths, m_rootProfile);
43 ProfileEngine::~ProfileEngine()
48 void ProfileEngine::processDir(
const TQString &dir,
const TQString &currPath, TQMap<TQString, Profile*> &passedPaths,
Profile *root)
53 TQStringList entryList = qDir.entryList(TQDir::Dirs);
54 for (TQStringList::const_iterator eit = entryList.constBegin(); eit != entryList.constEnd(); ++eit)
56 if ((*eit !=
"..") && (*eit !=
"."))
58 TQString dirName = *eit;
60 if (passedPaths.contains(currPath + dirName))
61 profile = passedPaths[currPath + dirName];
64 profile =
new Profile(root, dirName);
65 passedPaths[currPath + dirName] = profile;
67 processDir(dir + *eit +
"/", currPath + dirName, passedPaths, profile);
79 return TDETrader::OfferList();
81 TQString constraint = TQString::fromLatin1(
"[X-TDevelop-Version] == %1").arg(TDEVELOP_PLUGIN_VERSION);
84 constraint += TQString::fromLatin1(
" and [X-TDevelop-Scope] == 'Global'");
87 constraint += TQString::fromLatin1(
" and [X-TDevelop-Scope] == 'Project'");
90 constraint += TQString::fromLatin1(
" and [X-TDevelop-Scope] == 'Core'");
93 TQString constraint_add =
"";
96 for (Profile::EntryList::const_iterator it = properties.begin(); it != properties.end(); ++it)
97 constraint_add += TQString::fromLatin1(
" %1 '%2' in [X-TDevelop-Properties]").
98 arg((i++)==0?
"":
"or").arg((*it).name);
99 if (!constraint_add.isEmpty())
100 constraint +=
" and ( " + constraint_add +
" ) ";
109 TDETrader::OfferList list = TDETrader::self()->query(TQString::fromLatin1(
"TDevelop/Plugin"), constraint);
128 for (Profile::EntryList::const_iterator it = enableList.begin(); it != enableList.end(); ++it)
130 if (names.contains((*it).name))
132 TQString constraint = TQString::fromLatin1(
"[X-TDevelop-Version] == %1").arg(TDEVELOP_PLUGIN_VERSION);
133 constraint += TQString::fromLatin1(
"and [Name] == '%1'").arg((*it).name);
134 TDETrader::OfferList enable = TDETrader::self()->query(TQString::fromLatin1(
"TDevelop/Plugin"), constraint);
152 TQString constraint = TQString::fromLatin1(
"[X-TDevelop-Version] == %1").arg(TDEVELOP_PLUGIN_VERSION);
155 constraint += TQString::fromLatin1(
" and [X-TDevelop-Scope] == 'Global'");
158 constraint += TQString::fromLatin1(
" and [X-TDevelop-Scope] == 'Project'");
161 constraint += TQString::fromLatin1(
" and [X-TDevelop-Scope] == 'Core'");
164 return TDETrader::self()->query(TQString::fromLatin1(
"TDevelop/Plugin"), constraint);
168 const TQString &profileName)
170 if (profileName ==
"KDevelop")
171 *profile = m_rootProfile;
174 walkProfiles<ProfileListing>(listing, m_rootProfile);
175 *profile = listing.profiles[profileName];
193 return profile->resources(nameFilter);
201 KURL::List
resources = profile->resources(nameFilter);
204 walkProfiles<ProfileListingEx>(listingEx, profile);
206 resources += listingEx.resourceList;
211 const TQString &profile2, TQStringList &unload, TDETrader::OfferList &load)
213 TDETrader::OfferList offers1 =
offers(profile1, offerType);
214 TDETrader::OfferList offers2 =
offers(profile2, offerType);
216 TQStringList offers1List;
217 for (TDETrader::OfferList::const_iterator it = offers1.constBegin();
218 it != offers1.constEnd(); ++it)
219 offers1List.append((*it)->desktopEntryName());
220 TQMap<TQString, KService::Ptr> offers2List;
221 for (TDETrader::OfferList::const_iterator it = offers2.constBegin();
222 it != offers2.constEnd(); ++it)
223 offers2List[(*it)->desktopEntryName()] = *it;
228 for (TQStringList::const_iterator it = offers1List.constBegin();
229 it != offers1List.constEnd(); ++it)
232 if (offers2List.contains(*it))
235 offers2.remove(offers2List[*it]);
263 profile->addResource(url);
Profile resource listing operation.
TDETrader::OfferList offers(const TQString &profileName, OfferType offerType)
KURL::List resources(const TQString &profileName, const TQString &nameFilter)
X-TDevelop-Properties defined for this profile.
KURL::List resourcesRecursive(const TQString &profileName, const TQString &nameFilter)
A list of explicitly enabled plugins (names).
TDETrader::OfferList allOffers(OfferType offerType)
Profile listing operation.
OfferType
Type of the plugin offer.
void getProfileWithListing(ProfileListing &listing, Profile **profile, const TQString &profileName)
Gets a complete listing of available profiles and looks for a profile.
void addResource(const TQString &profileName, const KURL &url)
Adds a resource for the profile.
Profile * findProfile(const TQString &profileName)
Finds a profile with given name.
void diffProfiles(OfferType offerType, const TQString &profile1, const TQString &profile2, TQStringList &unload, TDETrader::OfferList &load)
Gets the difference between profile1 and profile2.