void repo::gui::RepoDialogUserManager::addUser(const core::RepoUser &user)
{
    QList<QStandardItem *> row;
    //--------------------------------------------------------------------------
    // User object itself
    QVariant var;
    var.setValue(user);

    QStandardItem *item = new QStandardItem();
    item->setData(var);
    item->setEnabled(true);
    item->setCheckable(true);
    item->setCheckState(Qt::Checked);
    item->setTristate(false);
    item->setEditable(false);
    row.append(item);

    // Username
    row.append(createItem(QString::fromStdString(user.getUsername())));

    // First Name
    row.append(createItem(QString::fromStdString(user.getFirstName())));

    // Last Name
    row.append(createItem(QString::fromStdString(user.getLastName())));

    // Email
    row.append(createItem(QString::fromStdString(user.getEmail())));

    // Projects count
    row.append(createItem((qulonglong)(user.getProjectsList().size())));

    // Groups count
    row.append(createItem((qulonglong)(user.getGroupsList().size())));

    // Roles count
    row.append(createItem((qulonglong)(user.getRolesList().size())));

    //--------------------------------------------------------------------------
    model->invisibleRootItem()->appendRow(row);
}
Example #2
0
void FilterModel::registerInstance(Objref_ptr objref)
{
    m_instances.add(objref);

    FirstLevelItem item;
    item.objref = objref;
    FirstLevelItems_t::iterator it = 
        m_items.insert(objref->id(), item);
    
    OperationsMap_t& operations = it.value().operations;

    QStandardItem * ifItem = new QStandardItem(objref->name());
    ifItem->setEditable(false);
    ifItem->setCheckable(true);
    ifItem->setTristate(true);
    ifItem->setCheckState(Qt::Checked);
    item.item = ifItem;

    const unsigned int count = objref->interface()->operation_count();

    for (unsigned int i = 0; i < count; i++) 
    {
        OperationDescriptor_ptr op =
            objref->interface()->get_reflective_by_index(i);

        QStandardItem * opItem = new QStandardItem(op->get_name());
        opItem->setEditable(false);
        opItem->setCheckable(true);
        opItem->setCheckState(Qt::Checked);

        ifItem->appendRow(opItem);

        operations.insert(op->get_tag(), opItem);
    }

    appendRow(ifItem);
    
    emit filterChanged();
}
Example #3
0
void tst_QStandardItem::getSetFlags()
{
    QStandardItem item;
    item.setEnabled(true);
    QVERIFY(item.isEnabled());
    QVERIFY(item.flags() & Qt::ItemIsEnabled);
    item.setEditable(true);
    QVERIFY(item.isEditable());
    QVERIFY(item.flags() & Qt::ItemIsEditable);
    item.setSelectable(true);
    QVERIFY(item.isSelectable());
    QVERIFY(item.flags() & Qt::ItemIsSelectable);
    item.setCheckable(true);
    QVERIFY(item.isCheckable());
    QCOMPARE(item.checkState(), Qt::Unchecked);
    QVERIFY(item.flags() & Qt::ItemIsUserCheckable);
    item.setTristate(true);
    QVERIFY(item.isTristate());
    QVERIFY(item.flags() & Qt::ItemIsTristate);
#ifndef QT_NO_DRAGANDDROP
    item.setDragEnabled(true);
    QVERIFY(item.isDragEnabled());
    QVERIFY(item.flags() & Qt::ItemIsDragEnabled);
    item.setDropEnabled(true);
    QVERIFY(item.isDropEnabled());
    QVERIFY(item.flags() & Qt::ItemIsDropEnabled);
#endif
    
    QVERIFY(item.isEnabled());
    item.setEnabled(false);
    QVERIFY(!item.isEnabled());
    QVERIFY(!(item.flags() & Qt::ItemIsEnabled));
    QVERIFY(item.isEditable());
    item.setEditable(false);
    QVERIFY(!item.isEditable());
    QVERIFY(!(item.flags() & Qt::ItemIsEditable));
    QVERIFY(item.isSelectable());
    item.setSelectable(false);
    QVERIFY(!item.isSelectable());
    QVERIFY(!(item.flags() & Qt::ItemIsSelectable));
    QVERIFY(item.isCheckable());
    item.setCheckable(false);
    QVERIFY(!item.isCheckable());
    QVERIFY(!(item.flags() & Qt::ItemIsUserCheckable));
    QVERIFY(item.isTristate());
    item.setTristate(false);
    QVERIFY(!item.isTristate());
    QVERIFY(!(item.flags() & Qt::ItemIsTristate));
#ifndef QT_NO_DRAGANDDROP
    QVERIFY(item.isDragEnabled());
    item.setDragEnabled(false);
    QVERIFY(!item.isDragEnabled());
    QVERIFY(!(item.flags() & Qt::ItemIsDragEnabled));
    QVERIFY(item.isDropEnabled());
    item.setDropEnabled(false);
    QVERIFY(!item.isDropEnabled());
    QVERIFY(!(item.flags() & Qt::ItemIsDropEnabled));
#endif

    item.setCheckable(false);
    item.setCheckState(Qt::Checked);
    item.setCheckable(true);
    QCOMPARE(item.checkState(), Qt::Checked);
}