コード例 #1
0
string NoteController::getNoteName( unsigned int pos ) const
{
	Note note = _model->getNote( pos );

	if( note.getName() != "" && note.read() != "" )
		return note.getName();
	return "";
}
コード例 #2
0
string NoteController::getNoteText( string name )
{
	Note note = searchNote( name );
	if( note.getName() != "" && note.read() != "" )
		return note.read();
	return "";
}
コード例 #3
0
ファイル: note.cpp プロジェクト: xuyan505/QOwnNotes
/**
 * Stores all notes that were changed to disk
 *
 * @param currentNote will be set by this method if the filename of the current
 * note has changed
 * @param currentNoteChanged true if current note was changed
 * @param noteWasRenamed true if a note was renamed
 * @return amount of notes that were saved
 */
int Note::storeDirtyNotesToDisk(Note &currentNote, bool *currentNoteChanged,
                                bool *noteWasRenamed) {
    QSqlDatabase db = QSqlDatabase::database("memory");
    QSqlQuery query(db);
    ScriptingService* scriptingService = ScriptingService::instance();
    Note note;
//    qDebug() << "storeDirtyNotesToDisk";

    query.prepare("SELECT * FROM note WHERE has_dirty_data = 1");
    if (!query.exec()) {
        qWarning() << __func__ << ": " << query.lastError();
        return 0;
    } else {
        int count = 0;
        for (int r = 0; query.next(); r++) {
            note = noteFromQuery(query);
            QString oldName = note.getName();
            note.storeNoteTextFileToDisk();
            QString newName = note.getName();

            // check if the file name has changed
            if (oldName != newName) {
                // rename the note file names of note tag links
                Tag::renameNoteFileNamesOfLinks(oldName, newName);
                *noteWasRenamed = true;

                // override the current note because the file name has changed
                currentNote = note;
            }

            // emit the signal for the QML that the note was stored
            emit scriptingService->noteStored(
                    QVariant::fromValue(
                            static_cast<QObject*>(NoteApi::fromNote(note))));

            // reassign currentNote if filename of currentNote has changed
            if (note.isSameFile(currentNote)) {
                *currentNoteChanged = true;
            }

            qDebug() << "stored note: " << note;
            count++;
        }

        return count;
    }
}
コード例 #4
0
ファイル: notedialog.cpp プロジェクト: pbek/QOwnNotes
void NoteDialog::setNote(Note note) {
    setWindowTitle(note.getName());

    // show the decrypted text if possible
    QString text = note.hasEncryptedNoteText() && note.canDecryptNoteText() ?
                   note.getDecryptedNoteText() : note.getNoteText();
    ui->textEdit->setPlainText(text);
}
コード例 #5
0
ファイル: note.cpp プロジェクト: guija/QOwnNotes
/**
 * Returns all notes names that are not tagged
 */
QStringList Note::fetchAllNotTaggedNames() {
    QList<Note> noteList = Note::fetchAll();
    QStringList untaggedNoteFileNameList;

    QListIterator<Note> itr(noteList);

    while (itr.hasNext()) {
        Note note = itr.next();
        int tagCount = Tag::countAllOfNote(note);
        if (tagCount == 0) {
            untaggedNoteFileNameList << note.getName();
        }
    }

    return untaggedNoteFileNameList;
}