From aabce76d60614eabf54246a340498ce6103edf0d Mon Sep 17 00:00:00 2001 From: randomdan Date: Sat, 28 Apr 2012 15:02:14 +0000 Subject: Render subviews in the order they're defined Add viewGroup for creating arbitrary nesting Don't error when a previously referenced script file no longer exists, just return not current --- project2/common/rowView.h | 2 +- project2/common/viewGroup.cpp | 27 +++++++++++++++++++++++++++ project2/xml/xmlScriptParser.cpp | 8 +++++++- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 project2/common/viewGroup.cpp diff --git a/project2/common/rowView.h b/project2/common/rowView.h index 9ba4699..534a06f 100644 --- a/project2/common/rowView.h +++ b/project2/common/rowView.h @@ -26,7 +26,7 @@ class RowView : public View, public RowProcessor { Columns viewColumns; void executeChildren() const; - typedef ANONSTORAGEOF(View) SubViews; + typedef ANONORDEREDSTORAGEOF(View) SubViews; SubViews subViews; typedef ANONSTORAGEOF(ValueAggregate) ValueAggregates; ValueAggregates valueAggregates; diff --git a/project2/common/viewGroup.cpp b/project2/common/viewGroup.cpp new file mode 100644 index 0000000..b01f6c8 --- /dev/null +++ b/project2/common/viewGroup.cpp @@ -0,0 +1,27 @@ +#include "view.h" +#include +#include "presenter.h" + +class ViewGroup : public View { + public: + ViewGroup(ScriptNodePtr s) : + SourceObject(s), + View(s) + { + s->script->loader.addLoadTarget(s, Storer::into(&subViews)); + } + + void execute(const MultiRowSetPresenter * presenter) const + { + presenter->addNewRowSet(name); + BOOST_FOREACH(const SubViews::value_type & sq, subViews) { + sq->execute(presenter); + } + presenter->finishRowSet(); + } + + typedef ANONORDEREDSTORAGEOF(View) SubViews; + SubViews subViews; +}; + +DECLARE_LOADER("viewgroup", ViewGroup); diff --git a/project2/xml/xmlScriptParser.cpp b/project2/xml/xmlScriptParser.cpp index ece6701..71c4bb5 100644 --- a/project2/xml/xmlScriptParser.cpp +++ b/project2/xml/xmlScriptParser.cpp @@ -76,7 +76,13 @@ bool XmlScriptParser::isCurrent() const { BOOST_FOREACH(const Files::value_type & f, files) { - if (boost::filesystem::last_write_time(f.first) != f.second) { + try { + if (boost::filesystem::last_write_time(f.first) != f.second) { + _root.reset(); + return false; + } + } + catch (const boost::filesystem::filesystem_error &) { _root.reset(); return false; } -- cgit v1.2.3