diff options
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r-- | Source/CursesDialog/cmCursesCacheEntryComposite.cxx | 15 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesCacheEntryComposite.h | 2 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 86 |
3 files changed, 57 insertions, 46 deletions
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 8c11aee..8804a03 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -34,7 +34,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key, } cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( - const char* key, const cmCacheManager::CacheEntry& value, bool isNew, + const char* key, const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth) : m_Key(key), m_LabelWidth(labelwidth), m_EntryWidth(entrywidth) { @@ -49,11 +49,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } m_Entry = 0; - switch ( value.m_Type ) + switch ( it.GetType() ) { case cmCacheManager::BOOL: m_Entry = new cmCursesBoolWidget(m_EntryWidth, 1, 1, 1); - if (cmSystemTools::IsOn(value.m_Value.c_str())) + if (cmSystemTools::IsOn(it.GetValue())) { static_cast<cmCursesBoolWidget*>(m_Entry)->SetValueAsBool(true); } @@ -65,17 +65,20 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( case cmCacheManager::PATH: m_Entry = new cmCursesPathWidget(m_EntryWidth, 1, 1, 1); static_cast<cmCursesPathWidget*>(m_Entry)->SetString( - value.m_Value.c_str()); + it.GetValue()); break; case cmCacheManager::FILEPATH: m_Entry = new cmCursesFilePathWidget(m_EntryWidth, 1, 1, 1); static_cast<cmCursesFilePathWidget*>(m_Entry)->SetString( - value.m_Value.c_str()); + it.GetValue()); break; case cmCacheManager::STRING: m_Entry = new cmCursesStringWidget(m_EntryWidth, 1, 1, 1); static_cast<cmCursesStringWidget*>(m_Entry)->SetString( - value.m_Value.c_str()); + it.GetValue()); + break; + case cmCacheManager::UNINITIALIZED: + cmSystemTools::Error("Found an undefined variable: ", it.GetName()); break; default: // TODO : put warning message here diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 2145d1c..4eac85e 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -25,7 +25,7 @@ class cmCursesCacheEntryComposite public: cmCursesCacheEntryComposite(const char* key, int labelwidth, int entrywidth); cmCursesCacheEntryComposite(const char* key, - const cmCacheManager::CacheEntry& value, + const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth); ~cmCursesCacheEntryComposite(); const char* GetValue(); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index cd4aff2..c004cba 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -117,9 +117,9 @@ void cmCursesMainForm::InitializeUI() this->m_CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { - const cmCacheManager::CacheEntry& value = i.GetEntry(); - if ( value.m_Type != cmCacheManager::INTERNAL && - value.m_Type != cmCacheManager::STATIC ) + if ( i.GetType() != cmCacheManager::INTERNAL && + i.GetType() != cmCacheManager::STATIC && + i.GetType() != cmCacheManager::UNINITIALIZED) { ++count; } @@ -146,16 +146,16 @@ void cmCursesMainForm::InitializeUI() !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - const cmCacheManager::CacheEntry& value = i.GetEntry(); - if ( value.m_Type == cmCacheManager::INTERNAL || - value.m_Type == cmCacheManager::STATIC ) + if ( i.GetType() == cmCacheManager::INTERNAL || + i.GetType() == cmCacheManager::STATIC || + i.GetType() == cmCacheManager::UNINITIALIZED ) { continue; } if (!this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite(key, value, + newEntries->push_back(new cmCursesCacheEntryComposite(key, i, true, 30, entrywidth)); m_OkToGenerate = false; @@ -168,16 +168,16 @@ void cmCursesMainForm::InitializeUI() !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - const cmCacheManager::CacheEntry& value = i.GetEntry(); - if ( value.m_Type == cmCacheManager::INTERNAL || - value.m_Type == cmCacheManager::STATIC ) + if ( i.GetType() == cmCacheManager::INTERNAL || + i.GetType() == cmCacheManager::STATIC || + i.GetType() == cmCacheManager::UNINITIALIZED ) { continue; } if (this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite(key, value, + newEntries->push_back(new cmCursesCacheEntryComposite(key, i, false, 30, entrywidth)); } @@ -224,9 +224,9 @@ void cmCursesMainForm::RePost() std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && - this->m_CMakeInstance->GetCacheManager()->IsAdvanced( - (*it)->GetValue())) + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) { continue; } @@ -243,8 +243,9 @@ void cmCursesMainForm::RePost() std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && - this->m_CMakeInstance->GetCacheManager()->IsAdvanced((*it)->GetValue())) + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) { continue; } @@ -302,9 +303,10 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && this->m_CMakeInstance->GetCacheManager()->IsAdvanced( - (*it)->GetValue())) - { + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) + { continue; } m_NumberOfVisibleEntries++; @@ -318,8 +320,9 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = m_Entries->begin(); it != m_Entries->end(); ++it) { - if (!m_AdvancedMode && this->m_CMakeInstance->GetCacheManager()->IsAdvanced( - (*it)->GetValue())) + cmCacheManager::CacheIterator mit = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED")) { continue; } @@ -453,14 +456,20 @@ void cmCursesMainForm::UpdateStatusBar() // Get the help string of the current entry // and add it to the help string char help[128]; - const char* helpString; - cmCacheManager::CacheEntry *entry = - this->m_CMakeInstance->GetCacheManager()->GetCacheEntry(curField); - if (entry) + cmCacheManager::CacheIterator it = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator(curField); + if (!it.IsAtEnd()) { - helpString = entry->m_HelpString.c_str(); - strncpy(help, helpString, 127); - help[127] = '\0'; + const char* hs = it.GetProperty("HELPSTRING"); + if ( hs ) + { + strncpy(help, hs, 127); + help[127] = '\0'; + } + else + { + help[0] = 0; + } } else { @@ -686,23 +695,22 @@ void cmCursesMainForm::FillCacheManagerFromUI() int size = m_Entries->size(); for(int i=0; i < size; i++) { - cmCacheManager::CacheEntry *entry = - this->m_CMakeInstance->GetCacheManager()->GetCacheEntry( + cmCacheManager::CacheIterator it = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator( (*m_Entries)[i]->m_Key.c_str()); - if (entry) + if (!it.IsAtEnd()) { tmpString = (*m_Entries)[i]->m_Entry->GetValue(); // Remove trailing spaces, convert path to unix slashes std::string tmpSubString = tmpString.substr(0,tmpString.find_last_not_of(" ")+1); - if ( entry->m_Type == cmCacheManager::PATH || - entry->m_Type == cmCacheManager::FILEPATH ) + if ( it.GetType() == cmCacheManager::PATH || + it.GetType() == cmCacheManager::FILEPATH ) { cmSystemTools::ConvertToUnixSlashes(tmpSubString); } - entry->m_Value = tmpSubString; - + it.SetValue(tmpSubString.c_str()); } } } @@ -842,11 +850,11 @@ void cmCursesMainForm::HandleInput() m_Fields[index-2])); const char* curField = lbl->GetValue(); const char* helpString=0; - cmCacheManager::CacheEntry *entry = - this->m_CMakeInstance->GetCacheManager()->GetCacheEntry(curField); - if (entry) + cmCacheManager::CacheIterator it = + this->m_CMakeInstance->GetCacheManager()->GetCacheIterator(curField); + if (!it.IsAtEnd()) { - helpString = entry->m_HelpString.c_str(); + helpString = it.GetProperty("HELPSTRING"); } if (helpString) { |