merge latest from master
This commit is contained in:
commit
0147ea7880
5
list.cpp
5
list.cpp
|
@ -60,6 +60,11 @@ void List::remove(std::size_t row_ndx) {
|
|||
m_link_view->remove(row_ndx);
|
||||
}
|
||||
|
||||
Query List::get_query() {
|
||||
verify_attached();
|
||||
return m_link_view->get_target_table().where(m_link_view);
|
||||
}
|
||||
|
||||
void List::verify_valid_row(std::size_t row_ndx, bool insertion) {
|
||||
size_t size = m_link_view->size();
|
||||
if (row_ndx > size || (!insertion && row_ndx == size)) {
|
||||
|
|
2
list.hpp
2
list.hpp
|
@ -47,6 +47,8 @@ namespace realm {
|
|||
template<typename ValueType, typename ContextType>
|
||||
void set(ContextType ctx, ValueType value, size_t list_ndx);
|
||||
|
||||
Query get_query();
|
||||
|
||||
void verify_valid_row(std::size_t row_ndx, bool insertion = false);
|
||||
void verify_attached();
|
||||
void verify_in_tranaction();
|
||||
|
|
15
results.cpp
15
results.cpp
|
@ -67,6 +67,17 @@ void Results::validate_write() const
|
|||
throw InvalidTransactionException("Must be in a write transaction");
|
||||
}
|
||||
|
||||
void Results::set_live(bool live)
|
||||
{
|
||||
if (!live && m_mode == Mode::Table) {
|
||||
m_query = m_table->where();
|
||||
m_mode = Mode::Query;
|
||||
}
|
||||
|
||||
update_tableview();
|
||||
m_live = live;
|
||||
}
|
||||
|
||||
size_t Results::size()
|
||||
{
|
||||
validate_read();
|
||||
|
@ -94,7 +105,7 @@ RowExpr Results::get(size_t row_ndx)
|
|||
case Mode::TableView:
|
||||
update_tableview();
|
||||
if (row_ndx < m_table_view.size())
|
||||
return m_table_view.get(row_ndx);
|
||||
return (!m_live && !m_table_view.is_row_attached(row_ndx)) ? RowExpr() : m_table_view.get(row_ndx);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -148,7 +159,9 @@ void Results::update_tableview()
|
|||
m_mode = Mode::TableView;
|
||||
break;
|
||||
case Mode::TableView:
|
||||
if (m_live) {
|
||||
m_table_view.sync_if_needed();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,9 @@ public:
|
|||
// Get the object type which will be returned by get()
|
||||
StringData get_object_type() const noexcept { return get_object_schema().name; }
|
||||
|
||||
// Set whether the TableView should sync if needed before accessing results
|
||||
void set_live(bool live);
|
||||
|
||||
// Get the size of this results
|
||||
// Can be either O(1) or O(N) depending on the state of things
|
||||
size_t size();
|
||||
|
@ -168,6 +171,7 @@ private:
|
|||
TableView m_table_view;
|
||||
Table* m_table = nullptr;
|
||||
SortOrder m_sort;
|
||||
bool m_live = true;
|
||||
|
||||
Mode m_mode = Mode::Empty;
|
||||
|
||||
|
|
Loading…
Reference in New Issue