summaryrefslogtreecommitdiffstats
path: root/Source/MFCDialog/PropertyList.cpp
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2004-01-02 22:24:19 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2004-01-02 22:24:19 (GMT)
commit0c4bec756312a21c9afaf4fd7f648c242b2da5dd (patch)
tree330547c4d9c9602c15dca50137fc9b68ae9f6d68 /Source/MFCDialog/PropertyList.cpp
parent02d253c59ed0cbcb15f0714148cbe0fbc01a254f (diff)
downloadCMake-0c4bec756312a21c9afaf4fd7f648c242b2da5dd.zip
CMake-0c4bec756312a21c9afaf4fd7f648c242b2da5dd.tar.gz
CMake-0c4bec756312a21c9afaf4fd7f648c242b2da5dd.tar.bz2
ENH: fix bug with advanced items loosing edit and do a better job sorting
Diffstat (limited to 'Source/MFCDialog/PropertyList.cpp')
-rw-r--r--Source/MFCDialog/PropertyList.cpp119
1 files changed, 104 insertions, 15 deletions
diff --git a/Source/MFCDialog/PropertyList.cpp b/Source/MFCDialog/PropertyList.cpp
index bc1c8bc..a0e2755 100644
--- a/Source/MFCDialog/PropertyList.cpp
+++ b/Source/MFCDialog/PropertyList.cpp
@@ -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();
+}
+