Esempio n. 1
0
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);
}
Esempio n. 2
0
bool DbNote::updateRow(Note & note)
{
    sqlite3_stmt *statement;
    string stmnt =
        "update NoteTable SET date=?,NoteText=?,NoteTitle=?,NoteRef=?,KatKey=? where NoteKey=?;";
    if (!openDB())
    {
        throw SQLError("Can't open the DB-Connection");
        return false;
    }
    int req = sqlite3_prepare_v2(db, stmnt.c_str(), -1, &statement, 0);
    if (req != SQLITE_OK)
    {
        throw SQLError("Preparing Update-Statement failed");
        return false;
    }
    req = sqlite3_bind_text(statement, 1,
                            (note.getDate().getDateString()).c_str(),
                            (note.getDate().getDateString()).length(), SQLITE_TRANSIENT);

    if (req != SQLITE_OK)
    {
        throw SQLError("Binding Date into update statement failed");
        return false;
    }
    req = sqlite3_bind_text(statement, 2, (note.getNoteText()).c_str(),
                            (note.getNoteText()).length(), SQLITE_TRANSIENT);
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding note text into update statement failed");
        return false;
    }
    req = sqlite3_bind_text(statement, 3, (note.getNotetitle()).c_str(),
                            (note.getNotetitle()).length(), SQLITE_TRANSIENT);
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding note title into update statement failed");
        return false;
    }
    req = sqlite3_bind_int(statement, 4, note.getNoteRef());
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding note ref into update statement failed");
        return false;
    }
    req = sqlite3_bind_int(statement, 5, note.getKatKey());
    if (req != SQLITE_OK)
    {
        throw SQLError(
            "Binding note category key into update statement failed");
        return false;
    }
    req = sqlite3_bind_int(statement, 6, note.getNoteKey());
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding note key into update statement failed");
        return false;
    }
    req = sqlite3_step(statement);
    if (req != SQLITE_DONE)
    {
        throw SQLError("execute of insert statement failed");
        return false;
    }
    sqlite3_finalize(statement);
    sqlite3_close(db);
    return true;
}
Esempio n. 3
0
bool DbNote::insertTable(Note & note)
{
    sqlite3_stmt *statement;
    string stmnt =
        "insert into NoteTable (date,NoteText,NoteTitle,NoteRef,KatKey) values (?,?,?,?,?)";

    if (!openDB())
    {
        throw SQLError("Can't open the DB-Connection");
        return false;
    }
    int req = sqlite3_prepare_v2(db, stmnt.c_str(), stmnt.length(), &statement,
                                 0);
    if (req != SQLITE_OK)
    {
        throw SQLError("Preparing Insert-Statement failed");
        return false;
    }
    req = sqlite3_bind_text(statement, 1,
                            (note.getDate().getDateString()).c_str(),
                            (note.getDate().getDateString()).length(), SQLITE_TRANSIENT);
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding Date into insert statement failed");
        return false;
    }
    req = sqlite3_bind_text(statement, 2, (note.getNoteText()).c_str(),
                            (note.getNoteText()).length(), SQLITE_TRANSIENT);
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding note text into insert statement failed");
        return false;
    }
    req = sqlite3_bind_text(statement, 3, (note.getNotetitle()).c_str(),
                            (note.getNotetitle()).length(), SQLITE_TRANSIENT);
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding note title into insert statement failed");
        return false;
    }
    req = sqlite3_bind_int(statement, 4, note.getNoteRef());
    if (req != SQLITE_OK)
    {
        throw SQLError("Binding note ref into insert statement failed");
        return false;
    }
    req = sqlite3_bind_int(statement, 5, note.getKatKey());
    if (req != SQLITE_OK)
    {
        throw SQLError(
            "Binding note category key into insert statement failed");
        return false;
    }
    req = sqlite3_step(statement);
    if (req != SQLITE_DONE)
    {
        throw SQLError("execute of insert statement failed");
        return false;
    }
    sqlite3_finalize(statement);
    sqlite3_close(db);
    return true;
}