Пример #1
0
void NotesWidget::insertNewNote(QString guid, QString noteBook, QString title)
{
    ListItem* item = new ListItem(this);
    item->setText(title);
    item->setNoteBookGUID(noteBook);
    item->setIcon(QIcon::fromTheme("basket"));
    item->setGUID(guid);

    signalsDisabled = true;
    setCurrentItem(item);
    signalsDisabled = false;
}
Пример #2
0
void NotesWidget::switchNotebook(TreeItem::noteListType type, QStringList id, QString currentNote)
{
    listType = type;
    signalsDisabled = true;
    bool active = true;

    clear();

    QSqlQuery result;
    if (type == TreeItem::allNotes) {
        result.prepare("SELECT title, guid, notebookGuid, created, updated FROM notes WHERE active=:active");
        result.bindValue(":active", true);
    } else if ((type == TreeItem::noteBook) || (type == TreeItem::stack)) {
        result.prepare(QString("SELECT title, guid, notebookGuid, created, updated FROM notes WHERE notebookGuid IN (%1) AND active=:active").arg(AddSQLArray(id.count())));
        BindSQLArray(result, id);
        result.bindValue(":active", true);
    } else if (type == TreeItem::trashBin) {
        result.prepare("SELECT title, guid, notebookGuid, created, updated FROM notes WHERE active=:active");
        result.bindValue(":active", false);
        active = false;
    } else if (type == TreeItem::conflict) {
        result.prepare("SELECT notes.title, conflictingNotes.guid, notes.notebookGuid, notes.created, conflictingNotes.updated FROM conflictingNotes LEFT JOIN notes ON notes.guid = conflictingNotes.guid");
    }
    if (!result.exec())
        LOG_ERROR("SQL: " + result.lastError().text());

    while (result.next()) {
        ListItem* item = new ListItem(this);
        item->setText(result.value(0).toString());
        item->setGUID(result.value(1).toString());
        item->setNoteBookGUID(result.value(2).toString());
        item->setCreated(result.value(3).toLongLong());
        item->setModified(result.value(4).toLongLong());
        item->setIcon(QIcon::fromTheme("basket"));
        item->setActive(active);
        item->setSortType(sortType);
    }

    if (!currentNote.isEmpty())
        selectNoteWithGuid(currentNote);

    sortItems();

    signalsDisabled = false;
    emit reloaded();
}
Пример #3
0
void NotesWidget::switchTag(QStringList id, QString currentNote)
{
    signalsDisabled = true;
    clear();

    if (id.isEmpty()) {
        signalsDisabled = false;
        return;
    }

    QSqlQuery result;

    result.prepare(QString("SELECT notes.title, notes.guid, notes.created, notes.updated FROM notesTags LEFT OUTER JOIN notes ON notesTags.noteGuid = notes.guid WHERE notesTags.guid IN (%1) AND notes.active=:active GROUP BY notesTags.noteGuid").arg(AddSQLArray(id.count())));
    BindSQLArray(result, id);

    result.bindValue(":active", true);
    if (!result.exec())
        LOG_ERROR("SQL: " + result.lastError().text());

    while (result.next()) {
        ListItem* item = new ListItem(this);
        item->setText(result.value(0).toString());
        item->setGUID(result.value(1).toString());
        item->setCreated(result.value(2).toLongLong());
        item->setModified(result.value(3).toLongLong());
        item->setIcon(QIcon::fromTheme("basket"));
        item->setSortType(sortType);
    }

    if (!currentNote.isEmpty())
        selectNoteWithGuid(currentNote);

    sortItems();

    signalsDisabled = false;
    emit reloaded();
}
Пример #4
0
void NotesWidget::switchSearch(QStringList guids, QString currentNote)
{
    signalsDisabled = true;
    clear();

    if (guids.isEmpty()) {
        signalsDisabled = false;
        return;
    }

    QSqlQuery result;
    result.prepare(QString("SELECT title, guid, created, updated FROM notes WHERE guid IN (%1)").arg(AddSQLArray(guids.count())));
    BindSQLArray(result, guids);

    if (!result.exec())
        LOG_ERROR("SQL: " + result.lastError().text());

    while (result.next()) {
        ListItem* item = new ListItem(this);
        item->setText(result.value(0).toString());
        item->setGUID(result.value(1).toString());
        item->setCreated(result.value(2).toLongLong());
        item->setModified(result.value(3).toLongLong());
        item->setIcon(QIcon::fromTheme("basket"));
        item->setSortType(sortType);
    }

    if (!currentNote.isEmpty())
        selectNoteWithGuid(currentNote);

    sortItems();

    signalsDisabled = false;
    emit reloaded();

}