feat(table): vista tabla por tipo de entidad (issue 0004)
- entity_ops: entity_list_rows (bulk pull id/name/type_ref/status/updated_at). - AppState::TableRow + cache + filtros (search substring + show_all toggle). - views_table: tabs por type_ref (alfabetico) o tabla unica con todos los tipos. ImGui::BeginTable con sort + clipper para >10k filas. Click en Selectable selecciona el nodo en el viewport (clear + add via graph_viewport_*). - views_table_refresh_indices: degree + node_idx por user_data hash. - main.cpp: panel "Table" en g_panels; cache build tras load_input y reload_after_mutation.
This commit is contained in:
@@ -772,6 +772,44 @@ bool entity_list_by_tags(const char* db_path,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool entity_list_rows(const char* db_path,
|
||||
std::vector<EntityRowSnapshot>* out)
|
||||
{
|
||||
if (!db_path || !out) return false;
|
||||
out->clear();
|
||||
sqlite3* db = nullptr;
|
||||
if (sqlite3_open_v2(db_path, &db, SQLITE_OPEN_READONLY, nullptr) != SQLITE_OK) {
|
||||
if (db) sqlite3_close(db);
|
||||
return false;
|
||||
}
|
||||
const char* sql =
|
||||
"SELECT id, COALESCE(name,''), COALESCE(type_ref,''), "
|
||||
" COALESCE(status,''), COALESCE(updated_at,'') "
|
||||
"FROM entities ORDER BY type_ref, name";
|
||||
sqlite3_stmt* st = nullptr;
|
||||
if (sqlite3_prepare_v2(db, sql, -1, &st, nullptr) != SQLITE_OK) {
|
||||
sqlite3_close(db);
|
||||
return false;
|
||||
}
|
||||
while (sqlite3_step(st) == SQLITE_ROW) {
|
||||
EntityRowSnapshot r;
|
||||
const unsigned char* a0 = sqlite3_column_text(st, 0);
|
||||
const unsigned char* a1 = sqlite3_column_text(st, 1);
|
||||
const unsigned char* a2 = sqlite3_column_text(st, 2);
|
||||
const unsigned char* a3 = sqlite3_column_text(st, 3);
|
||||
const unsigned char* a4 = sqlite3_column_text(st, 4);
|
||||
r.id = a0 ? (const char*)a0 : "";
|
||||
r.name = a1 ? (const char*)a1 : "";
|
||||
r.type_ref = a2 ? (const char*)a2 : "";
|
||||
r.status = a3 ? (const char*)a3 : "";
|
||||
r.updated_at = a4 ? (const char*)a4 : "";
|
||||
out->push_back(std::move(r));
|
||||
}
|
||||
sqlite3_finalize(st);
|
||||
sqlite3_close(db);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Index user_data -> sql id
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user