From eaa388fe1b1de7515b800bc9525bcf3a9e692b23 Mon Sep 17 00:00:00 2001 From: byloveletter Date: Thu, 18 May 2017 19:02:03 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=A6=90=EA=B2=A8?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0=20=EC=A0=80=EC=9E=A5=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui/oven_control/config.cpp | 40 ++++++++++++++++++++++++++++++++++- app/gui/oven_control/configwindow.cpp | 2 ++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/gui/oven_control/config.cpp b/app/gui/oven_control/config.cpp index 8b79997..15aace2 100644 --- a/app/gui/oven_control/config.cpp +++ b/app/gui/oven_control/config.cpp @@ -30,6 +30,7 @@ Config::Config(QObject *parent) : QObject(parent) { memcpy(config_format,config_format_kr,MAX_CONFIG_COUNT*64); loadConfig(); + loadFavorite(); // m_setFavorite.insert(2); // m_setFavorite.insert(3); // m_setFavorite.insert(1); @@ -253,11 +254,48 @@ QList Config::getConstSortedFavorite(){ } bool Config::loadFavorite(void){ - + bool rst; + uint32_t itemp; + QFile file(FAVORITE_FILE_NAME); + if(file.open(QIODevice::ReadOnly | QIODevice::Text)){ + m_setFavorite.clear(); + while(!file.atEnd()){ + QByteArray line = file.readLine(); + QString strTemp = tr(line); + itemp = strTemp.toInt(&rst,10); + if(rst && itemp < (uint32_t)config_invalid) { + m_setFavorite.insert(itemp); + qDebug()<< "load favorite index " << itemp; + } + } + file.close(); + qDebug() << "loading Favorite Menu Success"; + } + else{ + qDebug() << "Favorite File Not Found"; + } return false; } bool Config::saveFavorite(void){ + bool rst; + uint32_t itemp; + QFile file(FAVORITE_FILE_NAME); + if(file.open(QIODevice::WriteOnly | QIODevice::Text)){ + QTextStream out(&file); + QSetIterator itr(m_setFavorite); + while(itr.hasNext()){ + itemp = itr.next(); + out << itemp << "\n"; + qDebug() << "save favorite index" << itemp; + } + file.close(); + qDebug()<<"saving Favorite menu success"; + return true; + } + else{ + qDebug() << "saving favorite fail"; + } return false; } diff --git a/app/gui/oven_control/configwindow.cpp b/app/gui/oven_control/configwindow.cpp index 04c50d6..8c1e924 100644 --- a/app/gui/oven_control/configwindow.cpp +++ b/app/gui/oven_control/configwindow.cpp @@ -60,9 +60,11 @@ void ConfigWindow::on_backButton_clicked() dlg->exec(); if(dlg->result() == QDialog::Accepted){ cfg->saveConfig(); + cfg->saveFavorite(); } else{ cfg->loadConfig(); + cfg->loadFavorite(); } close(); } -- 2.1.4