From f4f894f09b255438d822baa02caaa0cf23d2b40a Mon Sep 17 00:00:00 2001
From: victor <taehoon@falinux.com>
Date: Mon, 22 May 2017 20:54:52 +0900
Subject: [PATCH] =?UTF-8?q?=EC=B2=AD=EA=B2=B0/=EA=B4=80=EB=A6=AC=20?=
 =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=A0=80=EC=9E=A5=20=EA=B0=92=20Getter/Se?=
 =?UTF-8?q?tter=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/gui/oven_control/dirtylevel.cpp | 60 ++++++++++++++++++++++++++-----------
 app/gui/oven_control/dirtylevel.h   |  6 ++++
 2 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/app/gui/oven_control/dirtylevel.cpp b/app/gui/oven_control/dirtylevel.cpp
index 4285c05..fd052f2 100644
--- a/app/gui/oven_control/dirtylevel.cpp
+++ b/app/gui/oven_control/dirtylevel.cpp
@@ -4,6 +4,7 @@
 
 namespace {
 QDateTime cookStartTime;
+bool cookStarted = false;
 qint64 cookingTime;
 int cookingCount;
 
@@ -38,13 +39,18 @@ void decountState(int level)
 
 void DirtyLevel::cookStart()
 {
+    cookStarted = true;
     cookStartTime = QDateTime::currentDateTime();
-    cookingCount++;
+    ::cookingCount++;
 }
 
 void DirtyLevel::cookEnd()
 {
-    cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime());
+    if (cookStarted)
+    {
+        cookStarted = true;
+        ::cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime());
+    }
 }
 
 void DirtyLevel::wash(int type)
@@ -52,23 +58,23 @@ void DirtyLevel::wash(int type)
     switch (type)
     {
     case 1:
-        cookingTime = qMax(cookingTime - 2 * 3600, 0);
+        ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0);
         decountState(1);
         break;
     case 2:
-        cookingTime = qMax(cookingTime - 3 * 3600, 0);
+        ::cookingTime = qMax(::cookingTime - 3 * 3600, (qint64) 0);
         decountState(1);
         break;
     case 3:
-        cookingTime = qMax(cookingTime - 4 * 3600, 0);
+        ::cookingTime = qMax(::cookingTime - 4 * 3600, (qint64) 0);
         decountState(2);
         break;
     case 4:
-        cookingTime = qMax(cookingTime - 10 * 3600, 0);
+        ::cookingTime = qMax(::cookingTime - 10 * 3600, (qint64) 0);
         decountState(2);
         break;
     case 5:
-        cookingTime = qMax(cookingTime - 2 * 3600, 0);
+        ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0);
         decountState(1);
         break;
     }
@@ -76,30 +82,50 @@ void DirtyLevel::wash(int type)
 
 int DirtyLevel::dirty()
 {
-    if (cookingCount < 1)
+    if (::cookingCount < 1)
         return 0;
-    if (cookingTime < 1 * 3600)
+    if (::cookingTime < 1 * 3600)
         return 1;
-    if (cookingTime < 3 * 3600)
+    if (::cookingTime < 3 * 3600)
         return 2;
-    if (cookingTime < 5 * 3600)
+    if (::cookingTime < 5 * 3600)
         return 3;
-    if (cookingTime < 7 * 3600)
+    if (::cookingTime < 7 * 3600)
         return 4;
     return 5;
 }
 
 int DirtyLevel::state()
 {
-    if (cookingCount < 1)
+    if (::cookingCount < 1)
         return 0;
-    if (cookingCount <= 5)
+    if (::cookingCount <= 5)
         return 1;
-    if (cookingCount <= 10)
+    if (::cookingCount <= 10)
         return 2;
-    if (cookingCount <= 15)
+    if (::cookingCount <= 15)
         return 3;
-    if (cookingCount <= 20)
+    if (::cookingCount <= 20)
         return 4;
     return 5;
 }
+
+void DirtyLevel::setCookingTime(qint64 secs)
+{
+    ::cookingTime = secs;
+}
+
+int DirtyLevel::cookingTime()
+{
+    return ::cookingTime;
+}
+
+int DirtyLevel::cookingCount()
+{
+    return ::cookingCount;
+}
+
+void DirtyLevel::setCookingCount(int count)
+{
+    ::cookingCount = count;
+}
diff --git a/app/gui/oven_control/dirtylevel.h b/app/gui/oven_control/dirtylevel.h
index efa487e..43d1383 100644
--- a/app/gui/oven_control/dirtylevel.h
+++ b/app/gui/oven_control/dirtylevel.h
@@ -1,6 +1,7 @@
 #ifndef DIRTYLEVEL_H
 #define DIRTYLEVEL_H
 
+#include <QtCore>
 
 namespace DirtyLevel {
 void cookStart();
@@ -9,6 +10,11 @@ void wash(int type);
 
 int dirty();
 int state();
+
+int cookingTime();
+void setCookingTime(qint64 secs);
+int cookingCount();
+void setCookingCount(int count);
 }
 
 #endif // DIRTYLEVEL_H
-- 
2.1.4