1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added some free functions to help make XML parsing less verbose: parseXML()

This commit is contained in:
jules 2018-10-15 16:08:25 +01:00
parent 97c100b9c1
commit 768139a298
23 changed files with 116 additions and 94 deletions

View file

@ -436,40 +436,42 @@ String TableHeaderComponent::toString() const
void TableHeaderComponent::restoreFromString (const String& storedVersion)
{
std::unique_ptr<XmlElement> storedXml (XmlDocument::parse (storedVersion));
int index = 0;
if (storedXml != nullptr && storedXml->hasTagName ("TABLELAYOUT"))
if (auto storedXML = parseXML (storedVersion))
{
forEachXmlChildElement (*storedXml, col)
if (storedXML->hasTagName ("TABLELAYOUT"))
{
auto tabId = col->getIntAttribute ("id");
int index = 0;
if (auto* ci = getInfoForId (tabId))
forEachXmlChildElement (*storedXML, col)
{
columns.move (columns.indexOf (ci), index);
ci->width = col->getIntAttribute ("width");
setColumnVisible (tabId, col->getBoolAttribute ("visible"));
auto tabId = col->getIntAttribute ("id");
if (auto* ci = getInfoForId (tabId))
{
columns.move (columns.indexOf (ci), index);
ci->width = col->getIntAttribute ("width");
setColumnVisible (tabId, col->getBoolAttribute ("visible"));
}
++index;
}
++index;
columnsResized = true;
sendColumnsChanged();
setSortColumnId (storedXML->getIntAttribute ("sortedCol"),
storedXML->getBoolAttribute ("sortForwards", true));
}
columnsResized = true;
sendColumnsChanged();
setSortColumnId (storedXml->getIntAttribute ("sortedCol"),
storedXml->getBoolAttribute ("sortForwards", true));
}
}
//==============================================================================
void TableHeaderComponent::addListener (Listener* const newListener)
void TableHeaderComponent::addListener (Listener* newListener)
{
listeners.addIfNotAlreadyThere (newListener);
}
void TableHeaderComponent::removeListener (Listener* const listenerToRemove)
void TableHeaderComponent::removeListener (Listener* listenerToRemove)
{
listeners.removeFirstMatchingValue (listenerToRemove);
}