void connectControllerAndModel( Controller* controller, CharmDataModel* model ) { QObject::connect( controller, SIGNAL(eventAdded(Event)), model, SLOT(addEvent(Event)) ); QObject::connect( controller, SIGNAL(eventModified(Event)), model, SLOT(modifyEvent(Event)) ); QObject::connect( controller, SIGNAL(eventDeleted(Event)), model, SLOT(deleteEvent(Event)) ); QObject::connect( controller, SIGNAL(allEvents(EventList)), model, SLOT(setAllEvents(EventList)) ); QObject::connect( controller, SIGNAL(definedTasks(TaskList)), model, SLOT(setAllTasks(TaskList)) ); QObject::connect( controller, SIGNAL(taskAdded(Task)), model, SLOT(addTask(Task)) ); QObject::connect( controller, SIGNAL(taskUpdated(Task)), model, SLOT(modifyTask(Task)) ); QObject::connect( controller, SIGNAL(taskDeleted(Task)), model, SLOT(deleteTask(Task)) ); }
static void reviewLoop (const std::vector <std::string>& uuids, unsigned int limit, bool autoClear) { auto width = getWidth (); unsigned int reviewed = 0; // If a limit was specified ('review 10'), then it should override the data // set size, if it is smaller. unsigned int total = uuids.size (); if (limit) total = std::min (total, limit); if (total == 0) { std::cout << reviewNothing (); return; } std::cout << reviewStart (width); unsigned int current = 0; while (current < total && (limit == 0 || reviewed < limit)) { // Run 'info' report for task. auto uuid = uuids[current]; // Display banner for this task. std::string dummy; std::string description; execute ("task", {"_get", uuid + ".description"}, dummy, description); std::string response; bool repeat; do { repeat = false; std::cout << banner (current + 1, total, width, Lexer::trimRight (description, "\n")); // Use 'system' to run the command and show the output. std::string command = "task " + uuid + " information"; system (command.c_str ()); // Display prompt, get input. response = getResponse (menu ()); if (response == "e") { editTask (uuid); } else if (response == "m") { modifyTask (uuid); repeat = true; } else if (response == "s") { std::cout << "Skipped\n\n"; ++current; } else if (response == "c") { completeTask (uuid); ++current; ++reviewed; } else if (response == "d") { deleteTask (uuid); ++current; ++reviewed; } else if (response == "") { reviewTask (uuid); ++current; ++reviewed; } else if (response == "r") { reviewTask (uuid); ++current; ++reviewed; } else if (response == "q") { break; } else { std::cout << format ("Command '{1}' is not recognized.", response) << "\n"; } // Note that just hitting <Enter> yields an empty command, which does // nothing but advance to the next task. if (autoClear) std::cout << "\033[2J\033[0;0H"; } while (repeat); if (response == "q") break; } std::cout << "\n" << format ("End of review. {1} out of {2} tasks reviewed.", reviewed, total) << "\n\n"; }