handling of summary after installation
This commit is contained in:
parent
53946457ab
commit
24b83840cd
@ -30,7 +30,7 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, m_worker(worker)
|
||||
, m_width(70)
|
||||
, m_width(60)
|
||||
, m_progressRunning(false)
|
||||
, m_updateStep(UpdateDcEvent::UpdateStep::NONE) {
|
||||
|
||||
@ -44,16 +44,20 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
m_updateSteps[INSTALL_SW_PACKETS] = "Install SW packets ";
|
||||
m_updateSteps[INSTALL_DC_CONFIGURATION] = "Install DC configuration ";
|
||||
m_updateSteps[SYNCHRONIZE_REPOSITORY] = "Synchronize repository/filesystem ";
|
||||
m_updateSteps[UPDATE_DC] = "Update DC";
|
||||
m_updateSteps[UPDATE_DC] = "Update DC ";
|
||||
|
||||
QString text{};
|
||||
for (int i = 0; i < m_updateSteps.size(); ++i) {
|
||||
QString &tmp = m_updateSteps[i];
|
||||
int len = m_showLineLength - tmp.length();
|
||||
while (--len > 0) {
|
||||
tmp += " ";
|
||||
}
|
||||
ui->stepLabel->setText(tmp + "\n");
|
||||
m_updateSteps[i] = tmp;
|
||||
text += m_updateSteps[i];
|
||||
}
|
||||
ui->stepLabel->setTextFormat(Qt::RichText);
|
||||
ui->stepLabel->setText(text);
|
||||
|
||||
this->setStatusBar(new QStatusBar(this));
|
||||
QFont f;
|
||||
@ -73,7 +77,7 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
lst << QString("Update tool version : %1 - %2 %3").arg(APP_VERSION).arg(APP_BUILD_DATE).arg(APP_BUILD_TIME).leftJustified(m_width-3);
|
||||
lst << QString("Machine number : %1 ").arg(m_worker->machineNr()).leftJustified(m_width-3);
|
||||
lst << QString("Customer number : %1 ").arg(m_worker->customerNr()).leftJustified(m_width-3);
|
||||
lst << QString("Zone number : %1 (%2)").arg(m_worker->zoneNr()).arg(Utils::zoneName(m_worker->zoneNr())).leftJustified(m_width-3);
|
||||
lst << QString("Zone number : %1 ").arg(m_worker->zoneNr()).leftJustified(m_width-3);
|
||||
lst << QString("APISM version : %1").arg(m_worker->apismVersion()).leftJustified(m_width-3);
|
||||
lst << QString("").leftJustified(m_width-3, '=');
|
||||
|
||||
@ -109,7 +113,12 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
m_statusTimer->start(1000);
|
||||
}
|
||||
|
||||
connect(m_worker->summaryTimer(), SIGNAL(timeout()), this, SLOT(onSummary()));
|
||||
m_worker->summaryTimer()->setSingleShot(true);
|
||||
m_worker->summaryTimer()->setInterval(5000);
|
||||
|
||||
connect(ui->exit, SIGNAL(clicked()),this,SLOT(onQuit()));
|
||||
connect(m_worker, SIGNAL(summary()),this,SLOT(onSummary()));
|
||||
connect(m_worker, SIGNAL(showSummary(QString)),this,SLOT(onShowSummary(QString)));
|
||||
connect(m_worker, SIGNAL(disableExit()),this,SLOT(onDisableExit()));
|
||||
connect(m_worker, SIGNAL(showDcDownload(QString)),this,SLOT(onShowDcDownload(QString)));
|
||||
@ -142,8 +151,91 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
connect(m_worker, SIGNAL(replaceLast(QStringList,QString)),this, SLOT(onReplaceLast(QStringList,QString)));
|
||||
}
|
||||
|
||||
void MainWindow::onSummary() {
|
||||
QThread::sleep(3);
|
||||
|
||||
QString summary, first, second, line, tmp;
|
||||
QVector<QPair<QString, QString>> vec = Utils::installedPackages();
|
||||
|
||||
if (m_worker) {
|
||||
vec.append(Utils::installedTariffFiles(m_worker, m_worker->customerRepository()));
|
||||
vec.append(Utils::installedJsonFiles(m_worker, m_worker->customerRepository()));
|
||||
}
|
||||
int max_first = 0, max_second = 0;
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
max_first = std::max(max_first, vec[i].first.length());
|
||||
max_second = std::max(max_second, vec[i].second.length());
|
||||
}
|
||||
|
||||
max_first += 5;
|
||||
|
||||
summary = "UPDATE SUMMARY\n\n";
|
||||
|
||||
if (m_worker) {
|
||||
first = QString("%1").arg("start", max_first, QChar(' '));
|
||||
tmp = QString("%1").arg(m_worker->start().toString(Qt::ISODate));
|
||||
second = QString("%1").arg(tmp, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
}
|
||||
|
||||
first = QString("%1").arg("update tool version", max_first, QChar(' '));
|
||||
tmp = QString("%1 - %2 %3").arg(APP_VERSION).arg(APP_BUILD_DATE).arg(APP_BUILD_TIME);
|
||||
second = QString("%1").arg(tmp, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
|
||||
if (m_worker) {
|
||||
first = QString("%1").arg("machine number", max_first, QChar(' '));
|
||||
tmp = QString("%1").arg(m_worker->machineNr());
|
||||
second = QString("%1").arg(tmp, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
|
||||
first = QString("%1").arg("customer number", max_first, QChar(' '));
|
||||
tmp = QString("%1").arg(m_worker->customerNr());
|
||||
second = QString("%1").arg(tmp, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
|
||||
first = QString("%1").arg("zone number", max_first, QChar(' '));
|
||||
tmp = QString("%1").arg(m_worker->zoneNr());
|
||||
second = QString("%1").arg(tmp, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
}
|
||||
|
||||
tmp = targetDcVersion();
|
||||
if (!tmp.isEmpty()) {
|
||||
first = QString("%1").arg("target device controller", max_first, QChar(' '));
|
||||
second = QString("%1").arg(tmp, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
}
|
||||
|
||||
if (m_worker) {
|
||||
first = QString("%1").arg("apism", max_first, QChar(' '));
|
||||
tmp = QString("%1").arg(m_worker->apismVersion());
|
||||
second = QString("%1").arg(tmp, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
}
|
||||
|
||||
for (int i = 0; i < vec.size(); ++i) {
|
||||
first = QString("%1").arg(vec[i].first, max_first, QChar(' '));
|
||||
second = QString("%1").arg(vec[i].second, -max_second, QChar(' '));
|
||||
line = first + ": " + second;
|
||||
summary += line + "\n";
|
||||
}
|
||||
|
||||
if (m_worker) {
|
||||
emit m_worker->showSummary(summary);
|
||||
emit m_worker->enableExit();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShowSummary(QString text) {
|
||||
|
||||
// QString s = ui->updateLabel->text();
|
||||
QString s("\n");
|
||||
|
||||
@ -161,6 +253,9 @@ void MainWindow::onSetDcDownloadProgress(int v) {
|
||||
}
|
||||
|
||||
void MainWindow::onShowTariffUpdate(QString) {
|
||||
return;
|
||||
|
||||
|
||||
ui->exit->setEnabled(false);
|
||||
|
||||
QString s = ui->stepLabel->text();
|
||||
@ -341,13 +436,12 @@ void MainWindow::onShowUpdateDCFirmware(QString status) {
|
||||
|
||||
QString s = m_updateSteps[UPDATE_DC].trimmed();
|
||||
|
||||
if (status.contains(UpdateCommand::UPDATE_DC_FIRMARE_SUCCESS, Qt::CaseInsensitive)) {
|
||||
if (status.contains(internal::UPDATE_DC_FIRMARE_SUCCESS, Qt::CaseInsensitive)) {
|
||||
s += " <font color='Green'>success</font>";
|
||||
} else {
|
||||
s += " <font color='Red'>UNKNOWN STATUS</font>";
|
||||
}
|
||||
|
||||
m_updateSteps[UPDATE_DC] = s;
|
||||
s.clear();
|
||||
for (int i = 0; i < m_updateSteps.size(); ++i) {
|
||||
if (i != UPDATE_DC) {
|
||||
@ -356,6 +450,7 @@ void MainWindow::onShowUpdateDCFirmware(QString status) {
|
||||
s += m_updateSteps[i];
|
||||
}
|
||||
}
|
||||
|
||||
ui->stepLabel->setText(s);
|
||||
}
|
||||
|
||||
@ -440,6 +535,9 @@ void MainWindow::onShowJsonDownload(QString) {
|
||||
}
|
||||
|
||||
void MainWindow::onShowDcDownload(QString version) {
|
||||
return;
|
||||
|
||||
|
||||
m_targetDcVersion = version;
|
||||
ui->exit->setEnabled(false);
|
||||
|
||||
|
@ -68,6 +68,7 @@ public slots:
|
||||
void onShowUpdateDCFirmware(QString);
|
||||
void onSetDcDownloadProgress(int);
|
||||
void onShowSummary(QString);
|
||||
void onSummary();
|
||||
#if EMERGENCY_LEAVE_BL==1
|
||||
void emergencyLeaveBL();
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user