/** * Jumps to the correct task list item */ void TodoDialog::jumpToTodoListItem() { // set the current row of the task list to the first row if (ui->todoList->count() > 0) { int row = -1; // let us jump to a specific calendar item if it was set in the // constructor if (!_jumpToCalendarItemUid.isEmpty()) { row = findTodoItemRowByUID(_jumpToCalendarItemUid); if (row != 1) { _jumpToCalendarItemUid = ""; } } // try to find a possible last created calendar item if ((row == -1) && lastCreatedCalendarItem.isFetched()) { row = findTodoItemRowByUID(lastCreatedCalendarItem.getUid()); // clear the last created calendar item if we found it in the list if (row > -1) { lastCreatedCalendarItem = CalendarItem(); } } if (row == -1) { // try to find the currently selected calendar item row = findTodoItemRowByUID(currentCalendarItem.getUid()); } ui->todoList->setCurrentRow(row >= 0 ? row : 0); } else { resetEditFrameControls(); } }
void TodoDialog::resetEditFrameControls() { ui->summaryEdit->setText(""); ui->descriptionEdit->setText(""); ui->prioritySlider->setValue(0); ui->reminderCheckBox->setChecked(false); ui->reminderDateTimeEdit->hide(); ui->saveButton->setEnabled(false); ui->removeButton->setEnabled(false); currentCalendarItem = CalendarItem(); }
/** * @brief Reloads the todo list from the SQLite database */ void TodoDialog::reloadTodoListItems() { QList<CalendarItem> calendarItemList = CalendarItem::fetchAllByCalendar( ui->todoListSelector->currentText()); MetricsService::instance()->sendEvent( "note", "todo list loaded", "", calendarItemList.count()); { const QSignalBlocker blocker(ui->todoList); Q_UNUSED(blocker); ui->todoList->clear(); QListIterator<CalendarItem> itr(calendarItemList); while (itr.hasNext()) { CalendarItem calItem = itr.next(); // skip completed items if the "show completed items" checkbox // is not checked if (!ui->showCompletedItemsCheckBox->checkState()) { if (calItem.isCompleted()) { continue; } } QString uid = calItem.getUid(); // skip items that were not fully loaded yet if (uid == "") { continue; } QListWidgetItem *item = new QListWidgetItem(calItem.getSummary()); item->setWhatsThis(uid); item->setCheckState( calItem.isCompleted() ? Qt::Checked : Qt::Unchecked); item->setFlags( Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable); ui->todoList->addItem(item); } } // set the current row of the todo list to the first row if (ui->todoList->count() > 0) { int row = -1; // try to find a possible last created calendar item if (lastCreatedCalendarItem.isFetched()) { row = findTodoItemRowByUID(lastCreatedCalendarItem.getUid()); // clear the last created calendar item if we found it in the list if (row > -1) { lastCreatedCalendarItem = CalendarItem(); } } if (row == -1) { // try to find the currently selected calendar item row = findTodoItemRowByUID(currentCalendarItem.getUid()); } ui->todoList->setCurrentRow(row >= 0 ? row : 0); } else { resetEditFrameControls(); } }