Commit eaa388fe1b1de7515b800bc9525bcf3a9e692b23

Authored by 고영탁
1 parent dbfe7c9eac
Exists in master and in 2 other branches fhd, fhd-demo

설정 즐겨찾기 저장 기능 개발

app/gui/oven_control/config.cpp
... ... @@ -30,6 +30,7 @@ Config::Config(QObject *parent) : QObject(parent)
30 30 {
31 31 memcpy(config_format,config_format_kr,MAX_CONFIG_COUNT*64);
32 32 loadConfig();
  33 + loadFavorite();
33 34 // m_setFavorite.insert(2);
34 35 // m_setFavorite.insert(3);
35 36 // m_setFavorite.insert(1);
... ... @@ -253,11 +254,48 @@ QList<uint32_t> Config::getConstSortedFavorite(){
253 254 }
254 255  
255 256 bool Config::loadFavorite(void){
256   -
  257 + bool rst;
  258 + uint32_t itemp;
  259 + QFile file(FAVORITE_FILE_NAME);
  260 + if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
  261 + m_setFavorite.clear();
  262 + while(!file.atEnd()){
  263 + QByteArray line = file.readLine();
  264 + QString strTemp = tr(line);
  265 + itemp = strTemp.toInt(&rst,10);
  266 + if(rst && itemp < (uint32_t)config_invalid) {
  267 + m_setFavorite.insert(itemp);
  268 + qDebug()<< "load favorite index " << itemp;
  269 + }
  270 + }
  271 + file.close();
  272 + qDebug() << "loading Favorite Menu Success";
  273 + }
  274 + else{
  275 + qDebug() << "Favorite File Not Found";
  276 + }
257 277 return false;
258 278 }
259 279  
260 280 bool Config::saveFavorite(void){
  281 + bool rst;
  282 + uint32_t itemp;
  283 + QFile file(FAVORITE_FILE_NAME);
  284 + if(file.open(QIODevice::WriteOnly | QIODevice::Text)){
  285 + QTextStream out(&file);
  286 + QSetIterator<uint32_t> itr(m_setFavorite);
  287 + while(itr.hasNext()){
  288 + itemp = itr.next();
  289 + out << itemp << "\n";
  290 + qDebug() << "save favorite index" << itemp;
  291 + }
  292 + file.close();
  293 + qDebug()<<"saving Favorite menu success";
  294 + return true;
  295 + }
  296 + else{
  297 + qDebug() << "saving favorite fail";
  298 + }
261 299 return false;
262 300 }
263 301  
... ...
app/gui/oven_control/configwindow.cpp
... ... @@ -60,9 +60,11 @@ void ConfigWindow::on_backButton_clicked()
60 60 dlg->exec();
61 61 if(dlg->result() == QDialog::Accepted){
62 62 cfg->saveConfig();
  63 + cfg->saveFavorite();
63 64 }
64 65 else{
65 66 cfg->loadConfig();
  67 + cfg->loadFavorite();
66 68 }
67 69 close();
68 70 }
... ...