예제 #1
0
void NoteHistory::add(Note note, int cursorPosition) {
    if (!note.exists()) {
        return;
    }

    NoteHistoryItem item(&note, cursorPosition);

    if (noteHistory->contains(item)) {
        // decrease current index if we are going to remove an item before it
        if (noteHistory->indexOf(item) < currentIndex) {
            currentIndex--;
        }

        // remove found item
        noteHistory->removeAll(item);
    }

    noteHistory->prepend(item);

    if (currentIndex < lastIndex()) {
        // increase current index
        currentIndex++;
    }

    noteHistory->move(0, currentIndex);
    currentIndex = noteHistory->indexOf(item);

    qDebug() << " added to history: " << item;
}
예제 #2
0
파일: noteapi.cpp 프로젝트: pbek/QOwnNotes
/**
 * Removes a tag from the note
 *
 * @param tagName
 * @return true if the tag was removed from the note
 */
bool NoteApi::removeTag(QString tagName) {
    Tag tag = Tag::fetchByName(tagName);
    if (!tag.exists()) {
        return false;
    }

    Note note = Note::fetch(id);
    if (!note.exists()) {
        return false;
    }

    return tag.removeLinkToNote(note);
}
예제 #3
0
파일: noteapi.cpp 프로젝트: pbek/QOwnNotes
/**
 * Adds a tag to the note
 *
 * @param tagName
 * @return true if the note was tagged
 */
bool NoteApi::addTag(QString tagName) {
    if (tagName.isEmpty()) {
        return false;
    }

    Note note = Note::fetch(id);
    if (!note.exists()) {
        return false;
    }

    // create a new tag if it doesn't exist
    Tag tag = Tag::fetchByName(tagName);
    if (!tag.isFetched()) {
        tag.setName(tagName);
        tag.store();
    }

    return tag.linkToNote(note);
}
예제 #4
0
bool NoteHistoryItem::isNoteValid() {
    Note note = getNote();
    return note.exists();
}