Esempio n. 1
0
void ComboBox::setItemText(int itemIndex, const std::string& text)
{
  ASSERT(itemIndex >= 0 && (size_t)itemIndex < m_items.size());

  ListItem* item = m_items[itemIndex];
  item->setText(text);
}
Esempio n. 2
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;
}
Esempio n. 3
0
void ListWidget::addItem(const std::string &content)
{
	ListItem* item = new ListItem();
	item->setText(content);
	item->setRelativePosition(computeItemPosition(items_.size()));
	item->setSize({this->getSize().x - SCROLLBAR_WIDTH, ITEM_HEIGHT});
	items_.push_back(std::unique_ptr<ListItem>(item));

	// If this is the first item, select it
	if(items_.size() == 1)
		selectItem(*item);
}
Esempio n. 4
0
void MainWindow::noteTitleChange(QString newTitle)
{
    QString guid = ui->noteTitle->objectName();

    if (guid.isEmpty())
        return;

    emit titleChanged(newTitle, guid);

    ListItem *note = ui->NotesList->getNoteWithGuid(guid);
    if (note == NULL)
        return;

    note->setText(newTitle);
}
Esempio n. 5
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();
}
Esempio n. 6
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();
}
Esempio n. 7
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();

}
Esempio n. 8
0
/*****************************************************************************
 * Gets the needed information from the list and redraw
 *****************************************************************************/
void ListGphScene::rredraw()
{
    rclear();

    //Input objects
    ListItem* h1 = new ListItem();
    h1->setAsTitle(true);
    h1->setText("INPUTS");
    h1->setPosY(currY);
    h1->setData(32, QVariant(-1));
    h1->setData(33, QVariant(-1));
    currY += 17;
    this->addItem(h1);

    for (int i = 0; i < inputList.size(); i++)
    {
        GphListItem item = inputList[i];
        ListItem* txt = new ListItem();
        txt->setText(item.getText());
        txt->setPosY(currY);
        txt->setData(32, QVariant(item.getId()));
        txt->setData(33, QVariant(item.getType()));
        this->addItem(txt);
        currY += 17;
    }

    //Output objects
    ListItem* h2 = new ListItem();
    h2->setAsTitle(true);
    h2->setText("OUTPUTS");
    h2->setPosY(currY);
    h2->setData(32, QVariant(-1));
    h2->setData(33, QVariant(-1));
    currY += 17;
    this->addItem(h2);

    for (int i = 0; i < outputList.size(); i++)
    {
        GphListItem item = outputList[i];
        ListItem* txt = new ListItem();
        txt->setText(item.getText());
        txt->setPosY(currY);
        txt->setData(32, QVariant(item.getId()));
        txt->setData(33, QVariant(item.getType()));
        this->addItem(txt);
        currY += 17;
    }

    //Filter objects
    ListItem* h3 = new ListItem();
    h3->setAsTitle(true);
    h3->setText("FILTERS");
    h3->setPos(0,currY);
    h3->setData(32, QVariant(-1));
    h3->setData(33, QVariant(-1));
    currY += 17;
    this->addItem(h3);

    for (int i = 0; i < filterList.size(); i++)
    {
        GphListItem item = filterList[i];
        ListItem* txt = new ListItem();
        txt->setText(item.getText());
        txt->setPosY(currY);
        txt->setData(32, QVariant(item.getId()));
        txt->setData(33, QVariant(item.getType()));
        this->addItem(txt);
        currY += 17;
    }

}