#include "dirtylevel.h" #include namespace { QDateTime cookStartTime; qint64 cookingTime; int cookingCount; } void DirtyLevel::cookStart() { cookStartTime = QDateTime::currentDateTime(); cookingCount++; } void DirtyLevel::cookEnd() { cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime()); } int DirtyLevel::dirty() { if (cookingCount < 1) return 0; if (cookingTime < 1 * 3600) return 1; if (cookingTime < 3 * 3600) return 2; if (cookingTime < 5 * 3600) return 3; if (cookingTime < 7 * 3600) return 4; return 5; } int DirtyLevel::state() { if (cookingCount < 1) return 0; if (cookingCount < 4) return 1; if (cookingCount < 7) return 2; if (cookingCount < 10) return 3; if (cookingCount < 13) return 4; return 5; }