Commit eaa388fe1b1de7515b800bc9525bcf3a9e692b23
1 parent
dbfe7c9eac
Exists in
master
and in
2 other branches
설정 즐겨찾기 저장 기능 개발
Showing
2 changed files
with
41 additions
and
1 deletions
Show diff stats
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