ENH: fix bug with advanced items loosing edit and do a better job sorting
This commit is contained in:
parent
02d253c59e
commit
0c4bec7563
|
@ -76,7 +76,7 @@ IDR_MAINFRAME ICON DISCARDABLE "res\\CMakeSetupDialog.ico"
|
|||
IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About CMakeSetup"
|
||||
FONT 8, "MS Sans Serif"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
|
||||
LTEXT "CMakeSetup\nwww.cmake.org",IDC_STATIC,40,18,119,16
|
||||
|
@ -108,7 +108,7 @@ BEGIN
|
|||
PUSHBUTTON "OK",IDC_OK,166,219,51,15
|
||||
PUSHBUTTON "Cancel",IDCANCEL,222,219,51,15
|
||||
PUSHBUTTON "Help",IDC_HELP_BUTTON,278,219,51,15
|
||||
LISTBOX IDC_LIST2,15,53,419,126,LBS_OWNERDRAWVARIABLE |
|
||||
LISTBOX IDC_LIST2,15,53,419,126,LBS_SORT | LBS_OWNERDRAWVARIABLE |
|
||||
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
|
||||
WS_HSCROLL
|
||||
GROUPBOX "Cache Values",IDC_FRAME,10,44,432,140
|
||||
|
|
|
@ -768,14 +768,9 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
{
|
||||
cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
|
||||
size_t size = m_CacheEntriesList.GetItems().size();
|
||||
bool reverseOrder = false;
|
||||
// if there are already entries in the cache, then
|
||||
// put the new ones in the top, so they show up first
|
||||
if(size)
|
||||
{
|
||||
reverseOrder = true;
|
||||
}
|
||||
|
||||
bool reverseOrder = false;
|
||||
// all the current values are not new any more
|
||||
std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
|
||||
for(std::set<CPropertyItem*>::iterator i = items.begin();
|
||||
|
@ -798,15 +793,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
{
|
||||
value = '\'' + value + '\'';
|
||||
}
|
||||
|
||||
if(!m_AdvancedValues)
|
||||
{
|
||||
if(i.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
m_CacheEntriesList.RemoveProperty(key);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
bool advanced = i.GetPropertyAsBool("ADVANCED");
|
||||
switch(i.GetType() )
|
||||
{
|
||||
case cmCacheManager::BOOL:
|
||||
|
@ -816,7 +803,8 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
"ON",
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::COMBO,"ON|OFF",
|
||||
reverseOrder
|
||||
reverseOrder,
|
||||
advanced
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -825,7 +813,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
"OFF",
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::COMBO,"ON|OFF",
|
||||
reverseOrder
|
||||
reverseOrder, advanced
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
@ -834,7 +822,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
value.c_str(),
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::PATH,"",
|
||||
reverseOrder
|
||||
reverseOrder, advanced
|
||||
);
|
||||
break;
|
||||
case cmCacheManager::FILEPATH:
|
||||
|
@ -842,7 +830,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
value.c_str(),
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::FILE,"",
|
||||
reverseOrder
|
||||
reverseOrder, advanced
|
||||
);
|
||||
break;
|
||||
case cmCacheManager::STRING:
|
||||
|
@ -850,7 +838,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
value.c_str(),
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::EDIT,"",
|
||||
reverseOrder
|
||||
reverseOrder, advanced
|
||||
);
|
||||
break;
|
||||
case cmCacheManager::INTERNAL:
|
||||
|
@ -858,6 +846,15 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(m_CacheEntriesList.GetShowAdvanced())
|
||||
{
|
||||
m_CacheEntriesList.ShowAdvanced();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CacheEntriesList.HideAdvanced();
|
||||
}
|
||||
|
||||
m_OKButton.EnableWindow(false);
|
||||
if(cachem->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
|
||||
{
|
||||
|
@ -867,11 +864,22 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
|||
i != items.end(); ++i)
|
||||
{
|
||||
CPropertyItem* item = *i;
|
||||
if(item->m_NewValue)
|
||||
if(item->m_Advanced )
|
||||
{
|
||||
// if one new value then disable to OK button
|
||||
enable = false;
|
||||
break;
|
||||
if(item->m_NewValue && m_CacheEntriesList.GetShowAdvanced())
|
||||
{
|
||||
enable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(item->m_NewValue)
|
||||
{
|
||||
// if one new value then disable to OK button
|
||||
enable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(enable)
|
||||
|
@ -1274,83 +1282,15 @@ void CMakeSetupDialog::OnHelpButton()
|
|||
|
||||
void CMakeSetupDialog::ShowAdvancedValues()
|
||||
{
|
||||
cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
|
||||
for(cmCacheManager::CacheIterator i = cachem->NewIterator();
|
||||
!i.IsAtEnd(); i.Next())
|
||||
{
|
||||
const char* key = i.GetName();
|
||||
if(!i.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch(i.GetType() )
|
||||
{
|
||||
case cmCacheManager::BOOL:
|
||||
if(cmSystemTools::IsOn(i.GetValue()))
|
||||
{
|
||||
m_CacheEntriesList.AddProperty(key,
|
||||
"ON",
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::COMBO,"ON|OFF",
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CacheEntriesList.AddProperty(key,
|
||||
"OFF",
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::COMBO,"ON|OFF",
|
||||
true
|
||||
);
|
||||
}
|
||||
break;
|
||||
case cmCacheManager::PATH:
|
||||
m_CacheEntriesList.AddProperty(key,
|
||||
i.GetValue(),
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::PATH,"",
|
||||
true
|
||||
);
|
||||
break;
|
||||
case cmCacheManager::FILEPATH:
|
||||
m_CacheEntriesList.AddProperty(key,
|
||||
i.GetValue(),
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::FILE,"",
|
||||
true
|
||||
);
|
||||
break;
|
||||
case cmCacheManager::STRING:
|
||||
m_CacheEntriesList.AddProperty(key,
|
||||
i.GetValue(),
|
||||
i.GetProperty("HELPSTRING"),
|
||||
CPropertyList::EDIT,"",
|
||||
true
|
||||
);
|
||||
break;
|
||||
case cmCacheManager::INTERNAL:
|
||||
m_CacheEntriesList.RemoveProperty(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_CacheEntriesList.ShowAdvanced();
|
||||
}
|
||||
|
||||
void CMakeSetupDialog::RemoveAdvancedValues()
|
||||
{
|
||||
cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
|
||||
|
||||
for(cmCacheManager::CacheIterator i = cachem->NewIterator();
|
||||
!i.IsAtEnd(); i.Next())
|
||||
{
|
||||
const char* key = i.GetName();
|
||||
if(i.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
m_CacheEntriesList.RemoveProperty(key);
|
||||
}
|
||||
}
|
||||
m_CacheEntriesList.HideAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void CMakeSetupDialog::OnAdvancedValues()
|
||||
{
|
||||
this->UpdateData();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
CPropertyList::CPropertyList()
|
||||
{
|
||||
m_Dirty = false;
|
||||
m_ShowAdvanced = false;
|
||||
m_curSel = -1;
|
||||
}
|
||||
|
||||
|
@ -129,34 +130,52 @@ int CPropertyList::AddItem(CString txt)
|
|||
int nIndex = AddString(txt);
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
int CPropertyList::AddPropItem(CPropertyItem* pItem, bool reverseOrder)
|
||||
// order = 0 sorted
|
||||
// order = 1 add to top
|
||||
// order = 2 add to bottom
|
||||
int CPropertyList::AddPropItem(CPropertyItem* pItem, int order)
|
||||
{
|
||||
if(pItem->m_Advanced && ! m_ShowAdvanced)
|
||||
{
|
||||
m_PropertyItems.insert(pItem);
|
||||
return 0;
|
||||
}
|
||||
this->HideControls();
|
||||
int nIndex;
|
||||
if(reverseOrder)
|
||||
if(order)
|
||||
{
|
||||
nIndex = InsertString(0, _T(""));
|
||||
if(order == 1)
|
||||
{
|
||||
order = 0;
|
||||
}
|
||||
if(order == 2)
|
||||
{
|
||||
order = -1;
|
||||
}
|
||||
nIndex = InsertString(order, _T(""));
|
||||
}
|
||||
else
|
||||
{
|
||||
nIndex = AddString(_T(""));
|
||||
nIndex = AddString(pItem->m_propName);
|
||||
}
|
||||
SetItemDataPtr(nIndex,pItem);
|
||||
m_PropertyItems.insert(pItem);
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
int CPropertyList::AddProperty(const char* name,
|
||||
const char* value,
|
||||
const char* helpString,
|
||||
int type,
|
||||
const char* comboItems, bool reverseOrder)
|
||||
void CPropertyList::AddProperty(const char* name,
|
||||
const char* value,
|
||||
const char* helpString,
|
||||
int type,
|
||||
const char* comboItems,
|
||||
bool reverseOrder,
|
||||
bool advanced)
|
||||
{
|
||||
CPropertyItem* pItem = 0;
|
||||
for(int i =0; i < this->GetCount(); ++i)
|
||||
CPropertyItem* pItem = 0;
|
||||
for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
|
||||
i != m_PropertyItems.end(); ++i)
|
||||
{
|
||||
CPropertyItem* item = this->GetItem(i);
|
||||
CPropertyItem* item = *i;
|
||||
if(item->m_propName == name)
|
||||
{
|
||||
pItem = item;
|
||||
|
@ -166,7 +185,7 @@ int CPropertyList::AddProperty(const char* name,
|
|||
pItem->m_HelpString = helpString;
|
||||
InvalidateList();
|
||||
}
|
||||
return i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if it is not found, then create a new one
|
||||
|
@ -175,7 +194,14 @@ int CPropertyList::AddProperty(const char* name,
|
|||
pItem = new CPropertyItem(name, value, helpString, type, comboItems);
|
||||
pItem->m_NewValue = true;
|
||||
}
|
||||
return this->AddPropItem(pItem, reverseOrder);
|
||||
pItem->m_Advanced = advanced;
|
||||
int order = 0;
|
||||
if(reverseOrder)
|
||||
{
|
||||
order = 1;
|
||||
}
|
||||
this->AddPropItem(pItem, order);
|
||||
return;
|
||||
}
|
||||
|
||||
int CPropertyList::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
|
@ -707,3 +733,66 @@ void CPropertyList::InvalidateList()
|
|||
m_Dirty = true;
|
||||
}
|
||||
|
||||
void CPropertyList::ShowAdvanced()
|
||||
{
|
||||
this->ResetContent();
|
||||
m_ShowAdvanced = true;
|
||||
std::map<std::string, CPropertyItem*> sortProps;
|
||||
for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
|
||||
i != m_PropertyItems.end(); ++i)
|
||||
{
|
||||
sortProps[(const char*)(*i)->m_propName] = *i;
|
||||
}
|
||||
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
|
||||
i != sortProps.end(); ++i)
|
||||
{
|
||||
CPropertyItem* item = i->second;
|
||||
if(item->m_NewValue)
|
||||
{
|
||||
this->AddPropItem(item, 2);
|
||||
}
|
||||
}
|
||||
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
|
||||
i != sortProps.end(); ++i)
|
||||
{
|
||||
CPropertyItem* item = i->second;
|
||||
if(!item->m_NewValue)
|
||||
{
|
||||
this->AddPropItem(item, 2);
|
||||
}
|
||||
}
|
||||
this->InvalidateList();
|
||||
}
|
||||
|
||||
|
||||
void CPropertyList::HideAdvanced()
|
||||
{
|
||||
this->ResetContent();
|
||||
m_ShowAdvanced = false;
|
||||
std::map<std::string, CPropertyItem*> sortProps;
|
||||
for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
|
||||
i != m_PropertyItems.end(); ++i)
|
||||
{
|
||||
sortProps[(const char*)(*i)->m_propName] = *i;
|
||||
}
|
||||
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
|
||||
i != sortProps.end(); ++i)
|
||||
{
|
||||
CPropertyItem* item = i->second;
|
||||
if(item->m_NewValue && !item->m_Advanced)
|
||||
{
|
||||
this->AddPropItem(item, 2);
|
||||
}
|
||||
}
|
||||
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
|
||||
i != sortProps.end(); ++i)
|
||||
{
|
||||
CPropertyItem* item = i->second;
|
||||
if(!item->m_Advanced && !item->m_NewValue)
|
||||
{
|
||||
this->AddPropItem(item, 2);
|
||||
}
|
||||
}
|
||||
this->InvalidateList();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
CString m_cmbItems;
|
||||
bool m_NewValue;
|
||||
bool m_Removed;
|
||||
bool m_Advanced;
|
||||
|
||||
public:
|
||||
CPropertyItem(CString propName, CString curValue,
|
||||
|
@ -48,6 +49,7 @@ public:
|
|||
m_curValue = curValue;
|
||||
m_nItemType = nItemType;
|
||||
m_cmbItems = cmbItems;
|
||||
m_Advanced = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -76,18 +78,22 @@ public:
|
|||
|
||||
// Operations
|
||||
public:
|
||||
bool GetShowAdvanced() {return m_ShowAdvanced;}
|
||||
bool IsDirty() { return m_Dirty; }
|
||||
void ClearDirty() { m_Dirty = false; }
|
||||
|
||||
int AddItem(CString txt);
|
||||
int AddProperty(const char* name,
|
||||
void AddProperty(const char* name,
|
||||
const char* value,
|
||||
const char* helpString,
|
||||
int type,
|
||||
const char* comboItems,
|
||||
bool reverseOrder);
|
||||
bool reverseOrder,
|
||||
bool advanced);
|
||||
void RemoveProperty(const char* name);
|
||||
void HideControls();
|
||||
void ShowAdvanced();
|
||||
void HideAdvanced();
|
||||
std::set<CPropertyItem*> GetItems()
|
||||
{
|
||||
return m_PropertyItems;
|
||||
|
@ -136,7 +142,10 @@ protected:
|
|||
|
||||
void InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo);
|
||||
void DisplayButton(CRect region);
|
||||
int AddPropItem(CPropertyItem* pItem, bool top);
|
||||
// order = 0 sorted
|
||||
// order = 1 add to top
|
||||
// order = 2 add to bottom
|
||||
int AddPropItem(CPropertyItem* pItem, int order);
|
||||
void InvalidateList();
|
||||
|
||||
CComboBox m_cmbBox;
|
||||
|
@ -158,6 +167,7 @@ protected:
|
|||
BOOL m_bDivIsSet;
|
||||
HCURSOR m_hCursorArrow;
|
||||
HCURSOR m_hCursorSize;
|
||||
bool m_ShowAdvanced;
|
||||
std::set<CPropertyItem*> m_PropertyItems;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue