Add source's name next to each task

This commit is contained in:
Vyn 2025-02-02 11:42:28 +01:00
parent e2cd994026
commit a03e71890c
4 changed files with 20 additions and 2 deletions

View file

@ -98,6 +98,13 @@ void AppWindow::setupCallbacks()
assert(source);
return source->id;
});
models().on_get_source_name_from_id([&](int sourceId) {
auto source = miraiInstance_->getSourceById(sourceId);
assert(source);
return slint::SharedString(source->name());
});
miraiInstance_->onSourceAdded([&](mirai::Source *source) {
refreshModels();
});
@ -338,6 +345,8 @@ void AppWindow::reloadTasks()
unscheduledTasks_->clear();
for (int taskIndex = 0; taskIndex < unscheduledTasksView.size(); ++taskIndex) {
auto &task = unscheduledTasksView.at(taskIndex);
const auto &source = miraiInstance_->getSourceById(task.sourceId());
std::println("request name for source id {} : {}", task.sourceId(), source->name());
unscheduledTasks_->push_back({
.sourceId = task.sourceId(),
.eventId = -1,