コード例 #1
0
void AbstractItemEditor::resetProperty(QtProperty *property)
{
    if (m_propertyManager->resetFontSubProperty(property))
        return;

    if (m_propertyManager->resetIconSubProperty(property))
        return;

    BoolBlocker block(m_updatingBrowser);

    QtVariantProperty *prop = m_propertyManager->variantProperty(property);
    int role = m_propertyToRole.value(prop);
    if (role == ItemFlagsShadowRole)
        prop->setValue(qVariantFromValue((int)QListWidgetItem().flags()));
    else
        prop->setValue(QVariant(prop->valueType(), (void *)0));
    prop->setModified(false);

    setItemData(role, QVariant());
    if (role == Qt::DecorationPropertyRole)
        setItemData(Qt::DecorationRole, qVariantFromValue(QIcon()));
    if (role == Qt::DisplayPropertyRole)
        setItemData(Qt::EditRole, qVariantFromValue(QString()));
    if (role == Qt::ToolTipPropertyRole)
        setItemData(Qt::ToolTipRole, qVariantFromValue(QString()));
    if (role == Qt::StatusTipPropertyRole)
        setItemData(Qt::StatusTipRole, qVariantFromValue(QString()));
    if (role == Qt::WhatsThisPropertyRole)
        setItemData(Qt::WhatsThisRole, qVariantFromValue(QString()));
}
コード例 #2
0
/**
 * @param parent Parent
 */
Admin_anz::Admin_anz( QWidget* parent ) :
    QDialog( parent )
{
    ui.setupUi( this );
    ui.buttonBox->button( QDialogButtonBox::Cancel )->setText("Abbrechen");

    this->setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );

    passwords.aktualisieren();

    shared_lock lock ( nutzer_verwaltung.read_lock() );
    anz_nutzer.reserve( nutzer_verwaltung.size() ); // Genügend Speicherplatz reservieren

    for ( Nutzer const& currnutzer : nutzer_verwaltung ) {
        std::string name = currnutzer.nutzername + " (" + currnutzer.pc_nutzername + ')';

        if ( currnutzer.x_plum )
            name += " (Plum-Chat)";
        else if ( enthaelt( Chat::std_admins, currnutzer.nutzername ) )
            name += " (Passwort \"" + passwords.getpass( currnutzer.nutzername ) + "\")";

        anz_nutzer.emplace_back( currnutzer.nummer, QListWidgetItem( QString::fromStdString( name ) ) ); // Item erstellen und mit Nummer des Nutzers in anz_nutzer schreiben
        QListWidgetItem& curri = anz_nutzer.back().second; // Referenz auf das Item
        ui.listWidget->addItem( &curri ); // Item hinzufügen
        curri.setFlags( &currnutzer == &nutzer_ich ? Qt::ItemIsUserCheckable : Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); // Sich selbst kann der Oberadmin nicht entmachten
        curri.setCheckState( currnutzer.admin ? Qt::Checked : Qt::Unchecked ); // je nachdem, ob currnutzer ein Admin ist oder nicht, das Item checken
    }

    ui.listWidget->sortItems();

    connect( this, &Admin_anz::accepted, [this] () { schreiben(); } );
}
コード例 #3
0
void AbstractItemEditor::updateBrowser()
{
    BoolBlocker block(m_updatingBrowser);
    foreach (QtVariantProperty *prop, m_properties) {
        int role = m_propertyToRole.value(prop);
        QVariant val = getItemData(role);
        if (!val.isValid()) {
            if (role == ItemFlagsShadowRole)
                val = qVariantFromValue((int)QListWidgetItem().flags());
            else
                val = QVariant((int)prop->value().userType(), (void *)0);
            prop->setModified(false);
        } else {
            prop->setModified(true);
        }
        prop->setValue(val);
    }
コード例 #4
0
void AbstractItemEditor::propertyChanged(QtProperty *property)
{
    if (m_updatingBrowser)
        return;


    BoolBlocker block(m_updatingBrowser);
    QtVariantProperty *prop = m_propertyManager->variantProperty(property);
    int role;
    if ((role = m_propertyToRole.value(prop, -1)) == -1)
        // Subproperty
        return;

    if ((role == ItemFlagsShadowRole && prop->value().toInt() == (int)QListWidgetItem().flags())
            || (role == Qt::DecorationPropertyRole && !qVariantValue<PropertySheetIconValue>(prop->value()).mask())
            || (role == Qt::FontRole && !qVariantValue<QFont>(prop->value()).resolve())) {
        prop->setModified(false);
        setItemData(role, QVariant());
    } else {
        prop->setModified(true);
        setItemData(role, prop->value());
    }

    switch (role) {
    case Qt::DecorationPropertyRole:
        setItemData(Qt::DecorationRole, qVariantFromValue(iconCache()->icon(qVariantValue<PropertySheetIconValue>(prop->value()))));
        break;
    case Qt::DisplayPropertyRole:
        setItemData(Qt::EditRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value()));
        break;
    case Qt::ToolTipPropertyRole:
        setItemData(Qt::ToolTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value()));
        break;
    case Qt::StatusTipPropertyRole:
        setItemData(Qt::StatusTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value()));
        break;
    case Qt::WhatsThisPropertyRole:
        setItemData(Qt::WhatsThisRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value()));
        break;
    default:
        break;
    }

    prop->setValue(getItemData(role));
}