void QgsSettingsTree::refresh() { if ( !settings ) return; disconnect( this, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ), this, SLOT( updateSetting( QTreeWidgetItem* ) ) ); settings->sync(); // add any settings not in QSettings object, so it will show up in the tree view if ( settings ) { QMap<QString, QStringList>::const_iterator it = settingsMap.constBegin(); while ( it != settingsMap.constEnd() ) { if ( ! settings->contains( it.key() ) ) { settings->setValue( it.key(), it.value().at( 3 ) ); } ++it; } } updateChildItems( 0 ); connect( this, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ), this, SLOT( updateSetting( QTreeWidgetItem* ) ) ); }
void QgsSettingsTree::refresh() { if ( !settings ) return; disconnect( this, &QTreeWidget::itemChanged, this, &QgsSettingsTree::updateSetting ); settings->sync(); // add any settings not in QgsSettings object, so it will show up in the tree view QMap<QString, QStringList>::const_iterator it = settingsMap.constBegin(); while ( it != settingsMap.constEnd() ) { if ( ! settings->contains( it.key() ) ) { settings->setValue( it.key(), it.value().at( 3 ) ); } ++it; } updateChildItems( nullptr ); connect( this, &QTreeWidget::itemChanged, this, &QgsSettingsTree::updateSetting ); }
/*! Sets model \a index where this Abstract view item should retrieve it's content. */ void HbAbstractViewItem::setModelIndex(const QModelIndex &index) { Q_D( HbAbstractViewItem ); if (d->mIndex != index) { d->mIndex = index; updateChildItems(); } }
/*! \reimp Invalidates parent layout when ItemTransformHasChanged is received. */ QVariant HbAbstractViewItem::itemChange(GraphicsItemChange change, const QVariant &value) { switch (change) { case ItemTransformHasChanged: { QGraphicsLayoutItem *parentLayoutItem = this->parentLayoutItem(); if (parentLayoutItem && parentLayoutItem->isLayout()) { QGraphicsLayout *parentLayout = static_cast<QGraphicsLayout *>(parentLayoutItem); parentLayout->invalidate(); } break; } case ItemEnabledHasChanged: { updateChildItems(); break; } default: break; } return HbWidget::itemChange(change, value); }
void QgsSettingsTree::updateChildItems( QTreeWidgetItem *parent ) { int dividerIndex = 0; Q_FOREACH ( const QString& group, settings->childGroups() ) { QTreeWidgetItem *child; int childIndex = findChild( parent, group, dividerIndex ); if ( childIndex != -1 ) { child = childAt( parent, childIndex ); child->setText( 1, "" ); child->setText( 2, "" ); child->setData( 2, Qt::UserRole, QVariant() ); moveItemForward( parent, childIndex, dividerIndex ); } else { child = createItem( group, parent, dividerIndex ); } child->setIcon( 0, groupIcon ); ++dividerIndex; settings->beginGroup( group ); updateChildItems( child ); settings->endGroup(); } Q_FOREACH ( const QString& key, settings->childKeys() ) { QTreeWidgetItem *child; int childIndex = findChild( parent, key, 0 ); if ( childIndex == -1 || childIndex >= dividerIndex ) { if ( childIndex != -1 ) { child = childAt( parent, childIndex ); for ( int i = 0; i < child->childCount(); ++i ) delete childAt( child, i ); moveItemForward( parent, childIndex, dividerIndex ); } else { child = createItem( key, parent, dividerIndex ); } child->setIcon( 0, keyIcon ); ++dividerIndex; } else { child = childAt( parent, childIndex ); } QVariant value = settings->value( key ); if ( value.type() == QVariant::Invalid ) { child->setText( 1, "Invalid" ); } else { child->setText( 1, QVariant::typeToName( QgsVariantDelegate::type( value ) ) ); } child->setText( 2, QgsVariantDelegate::displayText( value ) ); child->setData( 2, Qt::UserRole, value ); } while ( dividerIndex < childCount( parent ) ) delete childAt( parent, dividerIndex ); }