Port QtDialog to non-iterator cache API.

This commit is contained in:
Stephen Kelly 2015-04-06 12:14:40 +02:00
parent 3e6a76e48b
commit f3922a9a5b
1 changed files with 40 additions and 32 deletions

View File

@ -110,17 +110,18 @@ void QCMake::setBinaryDirectory(const QString& _dir)
QCMakePropertyList props = this->properties(); QCMakePropertyList props = this->properties();
emit this->propertiesChanged(props); emit this->propertiesChanged(props);
cmCacheManager::CacheIterator itm = cachem->NewIterator(); const char* homeDir = cachem->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
if ( itm.Find("CMAKE_HOME_DIRECTORY")) if (homeDir)
{ {
setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str())); setSourceDirectory(QString::fromLocal8Bit(homeDir));
} }
if ( itm.Find("CMAKE_GENERATOR")) const char* gen = cachem->GetCacheEntryValue("CMAKE_GENERATOR");
if (gen)
{ {
const char* extraGen = cachem const char* extraGen = cachem
->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); ->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
std::string curGen = cmExternalMakefileProjectGenerator:: std::string curGen = cmExternalMakefileProjectGenerator::
CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : ""); CreateFullGeneratorName(gen, extraGen? extraGen : "");
this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
} }
} }
@ -195,33 +196,35 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// set the value of properties // set the value of properties
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
for(cmCacheManager::CacheIterator i = cachem->NewIterator(); std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
!i.IsAtEnd(); i.Next()) for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it)
{ {
cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*it);
if(i.GetType() == cmCacheManager::INTERNAL || if(t == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC) t == cmCacheManager::STATIC)
{ {
continue; continue;
} }
QCMakeProperty prop; QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); prop.Key = QString::fromLocal8Bit(it->c_str());
int idx = props.indexOf(prop); int idx = props.indexOf(prop);
if(idx == -1) if(idx == -1)
{ {
toremove.append(QString::fromLocal8Bit(i.GetName().c_str())); toremove.append(QString::fromLocal8Bit(it->c_str()));
} }
else else
{ {
prop = props[idx]; prop = props[idx];
if(prop.Value.type() == QVariant::Bool) if(prop.Value.type() == QVariant::Bool)
{ {
i.SetValue(prop.Value.toBool() ? "ON" : "OFF"); cachem->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
} }
else else
{ {
i.SetValue(prop.Value.toString().toLocal8Bit().data()); cachem->SetCacheEntryValue(*it,
prop.Value.toString().toLocal8Bit().data());
} }
props.removeAt(idx); props.removeAt(idx);
} }
@ -279,42 +282,47 @@ QCMakePropertyList QCMake::properties() const
QCMakePropertyList ret; QCMakePropertyList ret;
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
for(cmCacheManager::CacheIterator i = cachem->NewIterator(); std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
!i.IsAtEnd(); i.Next()) for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
i != cacheKeys.end(); ++i)
{ {
cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*i);
if(i.GetType() == cmCacheManager::INTERNAL || if(t == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC || t == cmCacheManager::STATIC ||
i.GetType() == cmCacheManager::UNINITIALIZED) t == cmCacheManager::UNINITIALIZED)
{ {
continue; continue;
} }
QCMakeProperty prop; const char* cachedValue = cachem->GetCacheEntryValue(*i);
prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING"));
prop.Value = QString::fromLocal8Bit(i.GetValue().c_str());
prop.Advanced = i.GetPropertyAsBool("ADVANCED");
if(i.GetType() == cmCacheManager::BOOL) QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(i->c_str());
prop.Help = QString::fromLocal8Bit(
cachem->GetCacheEntryProperty(*i, "HELPSTRING"));
prop.Value = QString::fromLocal8Bit(cachedValue);
prop.Advanced = cachem->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
if(t == cmCacheManager::BOOL)
{ {
prop.Type = QCMakeProperty::BOOL; prop.Type = QCMakeProperty::BOOL;
prop.Value = cmSystemTools::IsOn(i.GetValue().c_str()); prop.Value = cmSystemTools::IsOn(cachedValue);
} }
else if(i.GetType() == cmCacheManager::PATH) else if(t == cmCacheManager::PATH)
{ {
prop.Type = QCMakeProperty::PATH; prop.Type = QCMakeProperty::PATH;
} }
else if(i.GetType() == cmCacheManager::FILEPATH) else if(t == cmCacheManager::FILEPATH)
{ {
prop.Type = QCMakeProperty::FILEPATH; prop.Type = QCMakeProperty::FILEPATH;
} }
else if(i.GetType() == cmCacheManager::STRING) else if(t == cmCacheManager::STRING)
{ {
prop.Type = QCMakeProperty::STRING; prop.Type = QCMakeProperty::STRING;
if (i.PropertyExists("STRINGS")) const char* stringsProperty =
cachem->GetCacheEntryProperty(*i, "STRINGS");
if (stringsProperty)
{ {
prop.Strings = QString::fromLocal8Bit(i.GetProperty("STRINGS")).split(";"); prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
} }
} }