示例#1
0
文件: note.cpp 项目: guija/QOwnNotes
/**
 * Renames a note
 */
bool Note::renameNoteFile(QString newName) {
    // cleanup not allowed characters characters
    newName = cleanupFileName(newName);

    // add the old file suffix to the name
    QString newFileName = newName + "." + fileNameSuffix();

    // check if name has really changed
    if (name == newName) {
        return false;
    }

    // check if name already exists
    Note existingNote = Note::fetchByName(newName);
    if (existingNote.isFetched() && (existingNote.getId() != id)) {
        return false;
    }

    // get the note file to rename it
    QFile file(getFullNoteFilePathForFile(fileName));

    // store the new note file name
    fileName = newFileName;
    name = newName;
    store();

    // rename the note file name
    return file.rename(getFullNoteFilePathForFile(newFileName));
}
示例#2
0
/**
 * Ajoute une note à la liste des notes gérées
 * par le NotesManager
 * @param type Type de la note
 */
Note* NotesManager::add(QString type)
{
  if (!factories.contains(type)) {
    throw NoteException(QObject::tr("Wrong note type givento NotesManager::add"));
  }
  Note *n = factories[type]->newNote("");
  notes[n->getId()] = n;
  return n;
}
示例#3
0
/**
 * Gets a list of note ids from a note list
 */
QList<int> Note::noteIdListFromNoteList(QList<Note> noteList) {
    QListIterator<Note> itr(noteList);
    QList<int> idList;

    while (itr.hasNext()) {
        Note note = itr.next();
        idList << note.getId();
    }

    return idList;
}
示例#4
0
/**
 * Checks if the notes are the same (by file)
 *
 * @param note
 * @return
 */
bool Note::isSameFile(Note note) {
    return (id == note.getId()) &&
            (noteSubFolderId == note.getNoteSubFolderId());
}