Files
RRJClient/Widgets/updatefileslot.cpp
2026-03-11 15:53:08 +03:00

88 lines
1.8 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "updatefileslot.h"
#include "ui_updatefileslot.h"
#include <QDateTime>
UpdateFileSlot::UpdateFileSlot(QWidget *parent) :
QWidget(parent),
ui(new Ui::UpdateFileSlot),
needUpdate(false)
{
ui->setupUi(this);
}
void UpdateFileSlot::fill(QString itemName, FileData serverData, FileData localData)
{
ui->Path->setText(itemName);
local = localData;
bool haveData = serverData.lastUpdate != "нет";
QString result = " Сервер: ";
QDateTime serverFileTime;
if (haveData)
{
serverFileTime = QDateTime::fromString(serverData.lastUpdate,"dd.MM.yyyy hh:mm:ss");
result.append(serverFileTime.toString("dd.MM.yyyy"));
}
else
{
result.append("НЕТ");
}
QDateTime localFileTime = QDateTime::fromString(localData.lastUpdate,"dd.MM.yyyy hh:mm:ss");
result.append(" Локально: ");
result.append(localFileTime.toString("dd.MM.yyyy"));
ui->Dates->setText(result);
bool newest = localFileTime > serverFileTime;
ui->UpdateCheckBox->setChecked(newest);
QPixmap pixmap;
if (newest)
{
pixmap.load(":/resource/Icons/new.png");
}
else
{
pixmap.load(nullptr);
}
QPixmap scaled = pixmap.scaled(ui->Image->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->Image->setPixmap(scaled);
}
UpdateFileSlot::~UpdateFileSlot()
{
delete ui;
}
FileData UpdateFileSlot::getLocal() const
{
return local;
}
bool UpdateFileSlot::getNeedUpdate() const
{
return needUpdate;
}
void UpdateFileSlot::setNeedUpdate(bool value)
{
needUpdate = value;
}
void UpdateFileSlot::on_UpdateCheckBox_stateChanged(int arg1)
{
if (ui->UpdateCheckBox->checkState() == Qt::Checked)
{
needUpdate = true;
}
else if (ui->UpdateCheckBox->checkState() == Qt::Unchecked)
{
needUpdate = false;
}
}