diff options
-rw-r--r-- | odb/qt/containers/list-traits.hxx | 3 | ||||
-rw-r--r-- | odb/qt/containers/list-traits.txx | 28 |
2 files changed, 31 insertions, 0 deletions
diff --git a/odb/qt/containers/list-traits.hxx b/odb/qt/containers/list-traits.hxx index 17e7765..6541d3f 100644 --- a/odb/qt/containers/list-traits.hxx +++ b/odb/qt/containers/list-traits.hxx @@ -64,6 +64,9 @@ namespace odb c._start (); } + static bool + changed (const container_type&); + static void update (const container_type&, const functions&); diff --git a/odb/qt/containers/list-traits.txx b/odb/qt/containers/list-traits.txx index 2893236..8af5c85 100644 --- a/odb/qt/containers/list-traits.txx +++ b/odb/qt/containers/list-traits.txx @@ -5,6 +5,34 @@ namespace odb { template <typename V> + bool access::container_traits<QOdbList<V> >:: + changed (const container_type& c) + { + // Because modifications can cancel each other (e.g., push and pop), + // it is tricky to keep track of whether there are any changes in + // the container. Instead, we are just going to examine each element + // just like update(). + // + + // We should either be tracking or summarily changed. + // + if (c._tracking ()) + { + const vector_impl& impl (c._impl ()); + + for (std::size_t i (0), n (impl.size ()); i < n; ++i) + { + if (impl.state (i) != vector_impl::state_unchanged) + return true; + } + } + else + return true; + + return false; + } + + template <typename V> void access::container_traits<QOdbList<V> >:: update (const container_type& c, const functions& f) { |