Пример #1
0
//! [1]
void NoteViewer::updateNote()
{
    // Store previous values
    const QString oldTitle = m_title;
    const QString oldDescription = m_description;
    const QDateTime oldDueDateTime = m_dueDateTime;
    const NotebookEntryStatus::Type oldStatus = m_status;

    // Fetch new values from persistent storage
    const NotebookEntry note = m_notebookService->notebookEntry(m_noteId);

    m_title = note.title();
    m_description = note.description().plainText();
    m_dueDateTime = note.dueDateTime();
    m_status = note.status();

    // Check whether values have changed
    if (oldTitle != m_title)
        emit titleChanged();

    if (oldDescription != m_description)
        emit descriptionChanged();

    if (oldDueDateTime != m_dueDateTime)
        emit dueDateTimeChanged();

    if (oldStatus != m_status)
        emit statusChanged();
}
Пример #2
0
//! [2]
void FormEditor::loadNote(const NotebookEntryId &noteId)
{
    m_noteId = noteId;

    // Load the note from the persistent storage
    const NotebookEntry note = m_notebookService->notebookEntry(m_noteId);

    // Update the properties with the data from the note
    m_title = note.title();
    m_description = note.description();
    m_dueDateTime = note.dueDateTime();
    m_completed = (note.status() == NotebookEntryStatus::Completed);

    // Emit the change notifications
    emit titleChanged();
    emit descriptionChanged();
    emit dueDateTimeChanged();
    emit completedChanged();
}