summaryrefslogtreecommitdiff
path: root/boost_any_to_qvariant.hpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2014-05-03 16:14:48 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2014-05-03 22:38:33 +0200
commit13cfd05f9b2bb3c8d7d1bf47fcef037a745bacf8 (patch)
tree98a325d0e547d5da0b0fd4b0b9ce2054306e87d0 /boost_any_to_qvariant.hpp
parent5bf919190e90b017ff00ab074bce68e90958fa3c (diff)
downloadgeneric-gui-13cfd05f9b2bb3c8d7d1bf47fcef037a745bacf8.tar.gz
generic-gui-13cfd05f9b2bb3c8d7d1bf47fcef037a745bacf8.tar.bz2
generic-gui-13cfd05f9b2bb3c8d7d1bf47fcef037a745bacf8.zip
Adds editing functionality to the models.
no longer able to store QStrings in the model though, But when creating generic guis you should not use any Gui related types anyway.
Diffstat (limited to 'boost_any_to_qvariant.hpp')
-rw-r--r--boost_any_to_qvariant.hpp67
1 files changed, 0 insertions, 67 deletions
diff --git a/boost_any_to_qvariant.hpp b/boost_any_to_qvariant.hpp
deleted file mode 100644
index 6172c09..0000000
--- a/boost_any_to_qvariant.hpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#pragma once
-
-#include "friendly_fusion.hpp"
-#include "index_list.hpp"
-
-#include <QVariant>
-
-#include <boost/any.hpp>
-
-#include <string>
-
-template<typename value_type>
-QVariant convert(boost::any const& x)
-{
- return QVariant::fromValue<value_type>(boost::any_cast<value_type>(x));
-}
-
-template <typename T, int n>
-QVariant convert(boost::any const& x)
-{
- typedef friendly_fusion::result_of::begin<T> begin;
- typedef friendly_fusion::result_of::advance_c<typename begin::type, n> adv_it;
- typedef friendly_fusion::result_of::deref<typename adv_it::type> deref;
- typedef typename std::decay<typename deref::type>::type value_type;
- return convert<value_type>(x);
-}
-
-#if defined( __GNUC__ ) && !defined( __clang__ )
-template <typename T, int index>
-std::function<QVariant(boost::any const&)> convert_lambda()
-{
- return [](boost::any const& any)
- {
- return convert<T, index>(any);
- };
-}
-
-#endif //defined( __GNUC__ ) && !defined( __clang__ )
-
-template<typename T, int... Indices>
-QVariant to_qvariant(boost::any const& any, int index, indices<Indices...>)
-{
- typedef std::function<QVariant(boost::any const&)> element_type;
- static element_type table[] =
- {
-#if defined( __GNUC__ ) && !defined( __clang__ )
- //Workaround for gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47226
- convert_lambda<T, Indices>()
- ...
-#else
- [](boost::any const& any){return convert<T, Indices>(any);}
- ...
-#endif //defined( __GNUC__ ) && !defined( __clang__ )
- };
-
- return table[index](any);
-}
-
-
-template <typename T>
-QVariant to_qvariant(boost::any const& x, int index)
-{
- typedef typename friendly_fusion::result_of::size<T>::type seq_size;
- typedef typename build_indices<seq_size::value>::type indices_type;
-
- return to_qvariant<T>(x, index, indices_type{});
-} \ No newline at end of file