void UIMachineWindow::updateAppearanceOf(int iElement) { /* Update window title: */ if (iElement & UIVisualElement_WindowTitle) { /* Get machine state: */ KMachineState state = uisession()->machineState(); /* Prepare full name: */ QString strSnapshotName; if (machine().GetSnapshotCount() > 0) { CSnapshot snapshot = machine().GetCurrentSnapshot(); strSnapshotName = " (" + snapshot.GetName() + ")"; } QString strMachineName = machineName() + strSnapshotName; if (state != KMachineState_Null) strMachineName += " [" + gpConverter->toString(state) + "]"; /* Unusual on the Mac. */ #ifndef VBOX_WS_MAC const QString strUserProductName = uisession()->machineWindowNamePostfix(); strMachineName += " - " + (strUserProductName.isEmpty() ? defaultWindowTitle() : strUserProductName); #endif /* !VBOX_WS_MAC */ if (machine().GetMonitorCount() > 1) strMachineName += QString(" : %1").arg(m_uScreenId + 1); setWindowTitle(strMachineName); } }
void QgsAttributeTypeDialog::setIndex( int index, int editTypeInt ) { mIndex = index; //need to set index for combobox QgsVectorLayer::EditType editType; if ( editTypeInt > -1 ) { editType = QgsVectorLayer::EditType( editTypeInt ); } else { editType = mLayer->editType( index ); } setWindowTitle( defaultWindowTitle() + " \"" + mLayer->pendingFields()[index].name() + "\"" ); QgsAttributeList attributeList = QgsAttributeList(); attributeList.append( index ); mLayer->select( attributeList, QgsRectangle(), false ); QgsFeature f; QString text; //calculate min and max for range for this field if ( mLayer->pendingFields()[index].type() == QVariant::Int ) { rangeWidget->clear(); rangeWidget->addItems( QStringList() << tr( "Editable" ) << tr( "Slider" ) << tr( "Dial" ) ); int min = INT_MIN; int max = INT_MAX; while ( mLayer->nextFeature( f ) ) { QVariant val = f.attributeMap()[index]; if ( val.isValid() && !val.isNull() ) { int valInt = val.toInt(); if ( min > valInt ) min = valInt; if ( max < valInt ) max = valInt; } text = tr( "Current minimum for this value is %1 and current maximum is %2." ).arg( min ).arg( max ); } } else if ( mLayer->pendingFields()[index].type() == QVariant::Double ) { double dMin = -DBL_MAX; double dMax = DBL_MAX; rangeWidget->clear(); rangeWidget->addItems( QStringList() << tr( "Editable" ) << tr( "Slider" ) ); while ( mLayer->nextFeature( f ) ) { QVariant val = f.attributeMap()[index]; if ( val.isValid() && !val.isNull() ) { double dVal = val.toDouble(); if ( dMin > dVal ) dMin = dVal; if ( dMax < dVal ) dMax = dVal; } text = tr( "Current minimum for this value is %1 and current maximum is %2." ).arg( dMin ).arg( dMax ); } } else { text = tr( "Attribute has no integer or real type, therefore range is not usable." ); } valuesLabel->setText( text ); //setPageForIndex( index ); setPageForEditType( editType ); switch ( editType ) { case QgsVectorLayer::ValueMap: { tableWidget->clearContents(); for ( int i = tableWidget->rowCount() - 1; i > 0; i-- ) { tableWidget->removeRow( i ); } // if some value map already present use it QMap<QString, QVariant> map; if ( !mValueMap.empty() ) { map = mValueMap; } else { map = mLayer->valueMap( index ); } int row = 0; for ( QMap<QString, QVariant>::iterator mit = map.begin(); mit != map.end(); mit++, row++ ) { tableWidget->insertRow( row ); if ( mit.value().isNull() ) { tableWidget->setItem( row, 0, new QTableWidgetItem( mit.key() ) ); } else { tableWidget->setItem( row, 0, new QTableWidgetItem( mit.value().toString() ) ); tableWidget->setItem( row, 1, new QTableWidgetItem( mit.key() ) ); } } } break; case QgsVectorLayer::EditRange: case QgsVectorLayer::SliderRange: case QgsVectorLayer::DialRange: { if ( mLayer->pendingFields()[mIndex].type() != QVariant::Int ) { minimumSpinBox->setValue( mLayer->range( index ).mMin.toInt() ); maximumSpinBox->setValue( mLayer->range( index ).mMax.toInt() ); stepSpinBox->setValue( mLayer->range( index ).mStep.toInt() ); } else if ( mLayer->pendingFields()[mIndex].type() == QVariant::Double ) { minimumDoubleSpinBox->setValue( mLayer->range( index ).mMin.toDouble() ); maximumDoubleSpinBox->setValue( mLayer->range( index ).mMax.toDouble() ); stepDoubleSpinBox->setValue( mLayer->range( index ).mStep.toDouble() ); } if ( editType == QgsVectorLayer::EditRange ) { rangeWidget->setCurrentIndex( 0 ); } else if ( editType == QgsVectorLayer::SliderRange ) { rangeWidget->setCurrentIndex( 1 ); } else { rangeWidget->setCurrentIndex( 2 ); } } break; case QgsVectorLayer::UniqueValuesEditable: editableUniqueValues->setChecked( editType == QgsVectorLayer::UniqueValuesEditable ); break; default: break; } }