示例#1
0
// Delete an item from the tree.  We really just hide it.
void NTagView::deleteRequested() {
    QList<QTreeWidgetItem*> items = selectedItems();

    if (global.confirmDeletes()) {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Question);
        if (items.size() == 1)
            msgBox.setText(tr("Are you sure you want to delete this tag?"));
        else
            msgBox.setText(tr("Are you sure you want to delete all selected tags?"));
        msgBox.setWindowTitle(tr("Verify Delete"));
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::No);
        int ret = msgBox.exec();
        if (ret == QMessageBox::No)
            return;
    }

    for (int i=0; i<items.size(); i++) {
        // Delete from the DB
        qint32 lid = items[i]->data(NAME_POSITION, Qt::UserRole).toInt();
        TagTable table(global.db);
        table.deleteTag(lid);

        // Now remove selected tags
        NTagViewItem *ptr = dataStore.take(items[i]->data(NAME_POSITION, Qt::UserRole).toInt());
        QList<QTreeWidgetItem*> children = ptr->takeChildren();
        ptr->parent()->addChildren(children);
        ptr->parent()->removeChild(ptr);
        emit(tagDeleted(lid, ptr->data(NAME_POSITION, Qt::DisplayRole).toString()));
        delete ptr;
    }
}
示例#2
0
// Delete an item from the tree.  We really just hide it.
void NTagView::deleteRequested() {
    QList<QTreeWidgetItem*> items = selectedItems();

    qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt();
    if (global.confirmDeletes()) {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Question);
        msgBox.setText(tr("Are you sure you want to delete this tag?"));
        msgBox.setWindowTitle(tr("Verify Delete"));
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::No);
        int ret = msgBox.exec();
        if (ret == QMessageBox::No)
            return;
    }
    TagTable table(global.db);
    table.deleteTag(lid);
//    NTagViewItem *ptr = (NTagViewItem*)items[0];
//    ptr->setHidden(true);

    // Now remove it in the datastore
    NTagViewItem *ptr = dataStore.take(items[0]->data(NAME_POSITION, Qt::UserRole).toInt());
    emit(tagDeleted(lid, ptr->data(NAME_POSITION, Qt::DisplayRole).toString()));
    delete ptr;
}
示例#3
0
// Delete an item from the tree.  We really just hide it.
void NTagView::mergeRequested() {
    QList<QTreeWidgetItem*> items = selectedItems();

    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setText(tr("Are you sure you want to merge these tags?"));
    msgBox.setWindowTitle(tr("Verify Merge"));
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    int ret = msgBox.exec();
    if (ret == QMessageBox::No)
        return;

    qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt();
    NoteTable ntable(global.db);
    QList<qint32> notes;
    for (int j=1; j<items.size(); j++) {
        ntable.findNotesByTag(notes, items[j]->data(NAME_POSITION, Qt::UserRole).toInt());
        for (int i=0; i<notes.size(); i++) {
            if (!ntable.hasTag(notes[i], lid)) {
                ntable.addTag(notes[i], lid, true);
                QString tagString = ntable.getNoteListTags(notes[i]);
                emit(updateNoteList(notes[i], NOTE_TABLE_TAGS_POSITION, tagString));
//                qint64 dt = QDateTime::currentMSecsSinceEpoch();
//                ntable.updateDate(notes[i],  dt, NOTE_UPDATED_DATE, true);
//                emit(updateNoteList(notes[i], NOTE_TABLE_DATE_UPDATED_POSITION, dt));
            }
        }
    }

    // Now delete the old tags.
    for (int i=1; i<items.size(); i++) {
        qint32 lid = items[i]->data(NAME_POSITION, Qt::UserRole).toInt();
        TagTable table(global.db);
        table.deleteTag(lid);

        // Now remove it in the datastore
        NTagViewItem *ptr = dataStore.take(items[i]->data(NAME_POSITION, Qt::UserRole).toInt());
        emit(tagDeleted(lid, ptr->data(NAME_POSITION, Qt::DisplayRole).toString()));
        delete ptr;
    }
}
示例#4
0
bool CWizIndexBase::DeleteTagEx(const WIZTAGDATA& data)
{
    qDebug() << "delete tag, name: " << data.strName;

    Q_ASSERT(data.strKbGUID == m_strKbGUID);

    CString strFormat = FormatDeleteSQLFormat(TABLE_NAME_WIZ_TAG, TABLE_KEY_WIZ_TAG);

    CString strSQL;
    strSQL.Format(strFormat,
        STR2SQL(data.strGUID).utf16()
        );

    if (!ExecSQL(strSQL))
        return false;

    if (!m_bUpdating) {
        emit tagDeleted(data);
    }

    return true;
}
示例#5
0
/**
 * \brief    Constructeur d'un éditeur de note
 * \details  Construit les parties permettant d'associer un tag à une note,
 *           editer le titre de la note et sauvegarder la note
 * \param    note         Pointeur sur la note à éditer
 */
NoteEditor::NoteEditor(Note *note, QWidget *parent) : resource(note) {
    setParent(parent);

    // top tag row
    QLabel* tagsLabel = new QLabel("Tags associés : ");
    tags = new QComboBox(this);
    QLabel* deleteTagLabel = new QLabel("Supprimer un tag : ");
    deleteTag = new QComboBox(this);
    for(QMultiMap<QString, QString>::iterator it = TagManager::getInstance().getAssociatedTagsBegin() ; it != TagManager::getInstance().getAssociatedTagsEnd(); ++it){
        if (it.value() == note->getId()) {
            tags->addItem(it.key());
            deleteTag->addItem(it.key());
        }
    }
    deleteTagBtn = new QPushButton(this);
    deleteTagBtn->setIcon(QIcon("supprimer.png"));
    QObject::connect(deleteTagBtn, SIGNAL(clicked()), this, SLOT(deleteAssociatedTag()));
    QLabel* addTagLabel = new QLabel("Associer un tag : ");
    addTag = new QComboBox(this);
    for(QSet<QString>::iterator it = TagManager::getInstance().getTagsBegin() ; it != TagManager::getInstance().getTagsEnd(); ++it){
        addTag->addItem((*it));
    }
    addTagBtn = new QPushButton(this);
    addTagBtn->setIcon(QIcon("ajouter.png"));
    QObject::connect(addTagBtn, SIGNAL(clicked()), this, SLOT(addAssociatedTag()));
    QHBoxLayout* tagRowLayout = new QHBoxLayout;
    tagRowLayout->addWidget(tagsLabel);
    tagRowLayout->addWidget(tags);
    tagRowLayout->addWidget(deleteTagLabel);
    tagRowLayout->addWidget(deleteTag);
    tagRowLayout->addWidget(deleteTagBtn);
    tagRowLayout->addWidget(addTagLabel);
    tagRowLayout->addWidget(addTag);
    tagRowLayout->addWidget(addTagBtn);

    // title and save
    title = new QLineEdit;
    save = new QPushButton;
    save->setIcon(QIcon("sauvegarder.png"));

    title->setText(note->getTitle());
    QObject::connect(title, SIGNAL(textChanged(QString)), this, SLOT(enableSave()));
    QObject::connect(title, SIGNAL(textChanged(QString)), this, SLOT(updateNote()));
    save->setEnabled(false);
    QObject::connect(save, SIGNAL(clicked()), this, SLOT(saveNote()));

    layout = new QVBoxLayout;
    QHBoxLayout* hLayout = new QHBoxLayout;
    hLayout->addWidget(title);
    hLayout->addWidget(save);
    layout->addLayout(tagRowLayout);
    layout->addLayout(hLayout);
    this->setLayout(layout);

    QObject::connect(&TagManager::getInstance(), SIGNAL(onTagAdd(QString)), this, SLOT(tagCreated(QString)));
    QObject::connect(&TagManager::getInstance(), SIGNAL(onTagDelete(QString)), this, SLOT(tagDeleted(QString)));
}