Действие кнопки "Сохранить в файл" (для всех разделов) (продолжение):
Код:
if(ui->stackedWidget->currentIndex() == 8)
{
if ((ui->edPipNumber_9->text() == "") || (ui->edVipNumber_9->text() == ""))
{
QMessageBox::warning(this, "Ошибка", "Введите номера ВИП и ПИП!");
return;
}
static QList<OneTempCheck> tcl;
static OneTempCheck otc;
static int ang = 0, tem = 0, u1 = 0, u2 = 0, du = 0, ktu = 0, nt = 0, np = 0;
static QString temp = "", pointDate = "";
for(int i = 0; i < 6; i++)
{
ang = 0; tem = 0; u1 = 0; u2 = 0; du = 0; ktu = 0; nt = 0; np = 0;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Что это
temp = ui->tempTableWidget_9->verticalHeaderItem(i)->text();
if(temp != "")
{
int t = temp.indexOf(',');
ang = temp.mid(t-4, 3).toInt();
tem = temp.right(5).left(3).toInt();
}
pointDate = ui->tempTableWidget_9->item(i, 0)->text();
temp = ui->tempTableWidget_9->item(i, 1)->text();
if(temp != "")
u1 = temp.toInt();
temp = ui->tempTableWidget_9->item(i, 2)->text();
if(temp != "")
u2 = temp.toInt();
temp = ui->tempTableWidget_9->item(i, 3)->text();
if(temp != "")
du = temp.toInt();
temp = ui->tempTableWidget_9->item(i, 4)->text();
if(temp != "")
ktu = temp.toInt();
temp = ui->tempTableWidget_9->item(i, 5)->text();
if(temp != "")
nt = temp.toInt();
temp = ui->tempTableWidget_9->item(i, 6)->text();
if(temp != "")
np = temp.toInt();
otc.ReadOneTemperCheck(ang, tem, pointDate, u1, u2, du, ktu, nt, np);
tcl.append(otc);
}
myXml = new XmlMainClass(ui->edPipNumber_9->text(), ui->edVipNumber_9->text(), tcl);
myXml->WriteCheckFile(2);
if(myXml->GetIsFileOk())
{
QString info = "Результаты настройки сохранены в файл:\n" + QDir::currentPath() + "/настройка/X999_ПИП№" + \
ui->edPipNumber_9->text() + "_ВИП№" + \
ui->edVipNumber_9->text() + "_проверка_температура.xml";
QMessageBox::information(this, "Сохранение файла", info.toUtf8().data());
}
else QMessageBox::warning(this, "Ошибка", "Ошибка открытия файла");
tcl.clear();
delete myXml;
}
if(ui->stackedWidget->currentIndex() == 4)
{
if ((ui->edPipNumber->text() == "") || (ui->edVipNumber->text() == ""))
{
QMessageBox::warning(this, "Ошибка", "Введите номера ВИП и ПИП!");
return;
}
QString curDate = QDate::currentDate().toString("ddMMyyyy");
QString curTime = QTime::currentTime().toString("hhmmss");
QString fileName = QDir::currentPath() + "/расчет/X999_ПИП№" + ui->edPipNumber->text() + "_ВИП№" + \
ui->edVipNumber->text() + "_" + curDate + "_" + curTime + "_расчет.xml";
QStringList title, value;
for(int i = 0; i < ui->parametrTableWidget->rowCount(); i++)
{
title.append(ui->parametrTableWidget->verticalHeaderItem(i)->text());
if(ui->parametrTableWidget->item(i, 0) == 0)
{
value.append("");
}
else
{
value.append(ui->parametrTableWidget->item(i, 0)->text());
}
}
myXml = new XmlMainClass(fileName, title, value);
myXml->writeCalcFile(title, value);
if(myXml->GetIsFileOk())
{
QString info = "Результаты настройки сохранены в файл:\n" + fileName;
QMessageBox::information(this, "Сохранение файла", info.toUtf8().data());
}
else QMessageBox::warning(this, "Ошибка", "Ошибка открытия файла");
delete myXml;
//////////////////////////////////////////////////////////////////////////////////////////////////
}
}