Skip to content

Commit

Permalink
Add method for checking if a specified model/variant exists in the co…
Browse files Browse the repository at this point in the history
…nfiguration
  • Loading branch information
Bernd Wachter committed Jun 13, 2013
1 parent e866ad3 commit 73b072a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
27 changes: 27 additions & 0 deletions libssu/ssudeviceinfo.cpp
Expand Up @@ -95,6 +95,33 @@ QString SsuDeviceInfo::adaptationVariables(const QString &adaptationName, QHash<
return adaptationName;
}

void SsuDeviceInfo::clearCache(){
cachedFamily = "";
cachedModel = "";
cachedVariant = "";
}

bool SsuDeviceInfo::contains(const QString &model){
QString oldModel = deviceModel();
bool found = false;

if (!model.isEmpty()){
clearCache();
setDeviceModel(model);
}

if (!deviceVariant(false).isEmpty())
found = true;
if (boardMappings->childGroups().contains(deviceModel()))
found = true;

if (!model.isEmpty()){
clearCache();
setDeviceModel(oldModel);
}
return found;
}

QString SsuDeviceInfo::deviceFamily(){
if (!cachedFamily.isEmpty())
return cachedFamily;
Expand Down
12 changes: 11 additions & 1 deletion libssu/ssudeviceinfo.h
Expand Up @@ -37,7 +37,15 @@ class SsuDeviceInfo: public QObject {
*/
QString adaptationVariables(const QString &adaptationName, QHash<QString, QString> *storageHash);
/**
* Try to find the device family for the system this is running on
* Check if a given model is available in the deviceinfo database, either directly,
* or as variant. If no model is provided as argument the autodetected or previously
* set model is used.
*/
bool contains(const QString &model="");
/**
* Try to find the device family for the system this is running on. This function
* temporarily changes the detected model, and therefore should not be used in a
* multithreaded environment, unless you like funny results.
*/
Q_INVOKABLE QString deviceFamily();
/**
Expand Down Expand Up @@ -93,5 +101,7 @@ class SsuDeviceInfo: public QObject {
private:
SsuSettings *boardMappings;
QString cachedFamily, cachedModel, cachedVariant;

void clearCache();
};
#endif

0 comments on commit 73b072a

Please sign in to comment.