/* static */ void UIMachineSettingsNetworkPage::updateGenericProperties(CNetworkAdapter &adapter, const QString &strPropText) { /* Parse new properties: */ QStringList newProps = strPropText.split("\n"); QHash<QString, QString> hash; /* Save new properties: */ for (int i = 0; i < newProps.size(); ++i) { QString strLine = newProps[i]; int iSplitPos = strLine.indexOf("="); if (iSplitPos) { QString strKey = strLine.left(iSplitPos); QString strVal = strLine.mid(iSplitPos+1); adapter.SetProperty(strKey, strVal); hash[strKey] = strVal; } } /* Removing deleted properties: */ QVector<QString> names; QVector<QString> props; props = adapter.GetProperties(QString(), names); for (int i = 0; i < names.size(); ++i) { QString strName = names[i]; QString strValue = props[i]; if (strValue != hash[strName]) adapter.SetProperty(strName, hash[strName]); } }
/* static */ QString UIMachineSettingsNetworkPage::summarizeGenericProperties(const CNetworkAdapter &adapter) { /* Prepare formatted string: */ QVector<QString> names; QVector<QString> props; props = adapter.GetProperties(QString(), names); QString strResult; /* Load generic properties: */ for (int i = 0; i < names.size(); ++i) { strResult += names[i] + "=" + props[i]; if (i < names.size() - 1) strResult += "\n"; } /* Return formatted string: */ return strResult; }