void Widget::save(VXml xml) { { VXml coordXml = xml.gotoChild("coord"); QRect rect = geometry(); coordXml.setInt("left", rect.left()); coordXml.setInt("top", rect.top()); coordXml.setInt("width", rect.width()); coordXml.setInt("height", rect.height()); } xml.setInt("showHexa", (int)ui->chkShowHexa->checkState()); xml.setInt("sendHexa", (int)ui->chkSendHexa->checkState()); xml.setInt("echo", (int)ui->chkEcho->checkState()); xml.setInt("echoBroadcast", (int)ui->chkEchoBroadcast->checkState()); xml.setInt("currentIndex", ui->tabOption->currentIndex()); xml.setStr("tcpPort", ui->leTcpPort->text()); xml.setStr("udpPort", ui->leUdpPort->text()); xml.setStr("sslPort", ui->leSslPort->text()); xml.setStr("sendText", ui->pteSend->toPlainText()); { VXml sizesXml = xml.gotoChild("sizes"); QList<int> sizes = ui->splitter->sizes(); QString strList; strList.clear(); foreach (int size, sizes) strList += QString::number(size) + ","; strList = strList.left(strList.count() - 1); sizesXml.setStr("splitter", strList); } tcpServer.save(xml.gotoChilds("netClient/tcpServer")); udpServer.save(xml.gotoChilds("netClient/udpServer")); sslServer.save(xml.gotoChilds("netClient/sslServer")); }
void Widget::load(VXml xml) { { VXml coordXml = xml.findChild("coord"); if (!coordXml.isNull()) { QRect rect = geometry(); rect.setLeft ((coordXml.getInt("left", 0))); rect.setTop ((coordXml.getInt("top", 0))); rect.setWidth ((coordXml.getInt("width", 640))); rect.setHeight((coordXml.getInt("height", 480))); setGeometry(rect); } } ui->chkShowHexa->setCheckState((Qt::CheckState)xml.getInt("showHexa", (int)ui->chkShowHexa->checkState())); ui->chkSendHexa->setCheckState((Qt::CheckState)xml.getInt("sendHexa", (int)ui->chkSendHexa->checkState())); ui->chkEcho->setCheckState((Qt::CheckState)xml.getInt("echo", (int)ui->chkEcho->checkState())); ui->chkEchoBroadcast->setCheckState((Qt::CheckState)xml.getInt("echoBroadcast", (int)ui->chkEchoBroadcast->checkState())); ui->tabOption->setCurrentIndex(xml.getInt("currentIndex", 0)); ui->leTcpPort->setText(xml.getStr("tcpPort", ui->leTcpPort->text())); ui->leUdpPort->setText(xml.getStr("udpPort", ui->leUdpPort->text())); ui->leSslPort->setText(xml.getStr("sslPort", ui->leSslPort->text())); ui->pteSend->insertPlainText(xml.getStr("sendText", ui->pteSend->toPlainText())); { VXml sizesXml = xml.findChild("sizes"); QList<int> sizes; if (!sizesXml.isNull()) { QStringList strList = sizesXml.getStr("splitter").split(","); foreach (QString s, strList) sizes << s.toInt(); ui->splitter->setSizes(sizes); } } tcpServer.load(xml.gotoChilds("netClient/tcpServer")); udpServer.load(xml.gotoChilds("netClient/udpServer")); sslServer.load(xml.gotoChilds("netClient/sslServer")); }