Files
VX5_KRO_GearPump/scene/ViewModels.cpp
T
2026-04-29 14:10:10 +08:00

57 lines
1.5 KiB
C++

#include "ViewModels.h"
BarcodeViewModel::BarcodeViewModel(QObject *parent)
: QObject(parent)
{
}
void BarcodeViewModel::setContentPattern(const QString &contentPattern)
{
if (m_contentPattern == contentPattern)
return;
m_contentPattern = contentPattern;
emit contentPatternChanged();
}
void BarcodeViewModel::setCounterViewModel(CounterViewModel counterViewModel)
{
m_counterViewModel = std::move(counterViewModel);
emit counterViewModelChanged();
}
void BarcodeViewModel::setDateViewModel(DateItemModel dateViewModel)
{
m_dateViewModel = std::move(dateViewModel);
emit dateViewModelChanged();
}
DateItemModel DateItemModel::createDefaultReplaceModel()
{
DateItemModel model;
model.dataMap << "0" << "1" << "2" << "3" << "4" << "5" << "6" << "7"
<< "8" << "9" << "A" << "B" << "C" << "D" << "E" << "F";
for (int i = 1; i <= 31; ++i) {
model.daysMap.append(QString("%1").arg(i, 2, 10, QChar('0')));
}
for (int i = 1; i <= 12; ++i) {
model.monthsMap.append(QString("%1").arg(i, 2, 10, QChar('0')));
}
int startYear = QDate::currentDate().year();
for (int i = 0; i < 16; ++i) {
model.yearsMap.insert(startYear + i, QString::number(startYear + i));
}
model.weeksMap << "MON" << "TUE" << "WED" << "THU" << "FRI" << "SAT" << "SUN";
for (int i = 0; i <= 23; ++i) {
model.hoursMap.append(QString("%1").arg(i, 2, 10, QChar('0')));
}
return model;
}