#include "ticketdevfile.h"ticketdevfile::ticketdevfile(){this->fileName.sprintf("ticket.ini");if(QFile::exists(this->fileName)){this->read();}else{this->reast();this->write();}}//读取设置int ticketdevfile::read(){QFile myfile(fileName);QByteArray buffer;QString str;QStringList strList;QMap<QString,QString> map;//read ticdet.inimyfile.open(QIODevice::ReadOnly);while(1){buffer = myfile.readLine();if(buffer.length() == 0){break;}str = QString(buffer);strList = str.split("=");if(strList.count() >=2){map.insert(strList[0],strList[1]);}}myfile.close();//加载设置comDev[0].com_type = map["com1_dev"].toInt();comDev[0].com_model = map["com1_model"].toInt();comDev[1].com_type = map["com2_dev"].toInt();comDev[1].com_model = map["com2_model"].toInt();comDev[2].com_type = map["com3_dev"].toInt();comDev[2].com_model = map["com3_model"].toInt();comDev[3].com_type = map["com4_dev"].toInt();comDev[3].com_model = map["com4_model"].toInt();for(int i=0;i<4;i++){qDebug() << "com" << i+1<< "_type=" << comDev[i].com_type;qDebug() << "com" << i+1<< "_model=" << comDev[i].com_model;}return -1;}//写入设置int ticketdevfile::write(){QString writeBuf;QFile myfile(fileName);myfile.open(QIODevice::WriteOnly);for(int i=0;i<4;i++){writeBuf.sprintf("com%d_dev=%d\r\n",i+1,comDev[i].com_type);myfile.write(writeBuf.toAscii());writeBuf.sprintf("com%d_model=%d\r\n",i+1,comDev[i].com_model);myfile.write(writeBuf.toAscii());myfile.write("\r\n");}myfile.close();return -1;}//复位设置int ticketdevfile::reast(){comDev[0].com_type = 1;comDev[0].com_model = 1;comDev[1].com_type = 1;comDev[1].com_model = 1;comDev[2].com_type = 0;comDev[2].com_model = 0;comDev[3].com_type = 4;comDev[3].com_model = 1;return -1;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。