summaryrefslogtreecommitdiff
path: root/fusion_model.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 /fusion_model.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 'fusion_model.hpp')
-rw-r--r--fusion_model.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/fusion_model.hpp b/fusion_model.hpp
index f40ac33..4ccaa5b 100644
--- a/fusion_model.hpp
+++ b/fusion_model.hpp
@@ -23,6 +23,7 @@ struct FusionModelInterface {
virtual std::string field_name(size_t section) const {throw std::runtime_error("\"field_name(size_t)\" not implemented for this model");}
virtual std::string key(size_t section) const {throw std::runtime_error("\"key(size_t)\" not implemented for this model");}
virtual boost::any get_cell(size_t row, size_t column) const {throw std::runtime_error("\"get_cell(size_t, size_t)\" not implemented for this model");}
+ virtual void set_cell(size_t row, size_t column, boost::any const& value) {throw std::runtime_error("\"set_cell(size_t, size_t, boost::any const&)\" not implemented for this model");}
};
template <typename T>
@@ -57,6 +58,11 @@ struct fusion_model<std::vector<T>> : public FusionModelInterface
{
return get_nth(data[row], column);
}
+
+ virtual void set_cell(size_t row, size_t column, boost::any const& value) override final
+ {
+ set_nth<row_type>(data[row], column, value);
+ }
};
template <typename T>
@@ -100,4 +106,11 @@ struct fusion_model<std::map<std::string, T>> : public FusionModelInterface
std::advance(cit, row);
return get_nth(cit->second, column);
}
+
+ virtual void set_cell(size_t row, size_t column, boost::any const& value) override final
+ {
+ auto it = data.begin();
+ std::advance(it, row);
+ set_nth<row_type>(it->second, column, value);
+ }
}; \ No newline at end of file