void FileParser::openFile(const QString &fileName) { intoData = false; intoRule = false; wordRule.clear(); KeyCode.clear(); Length.clear(); Pinyin.clear(); PinyinLength.clear(); Prompt.clear(); ConstructPhrase.clear(); InvalidChar.clear(); keymap.clear(); wordList.clear(); //validKey.clear(); //FIXME: May be qt4.8.3 BUG if (fileName.isEmpty()) return; QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&file); in.setCodec("UTF-8"); QString line; emit setProgressRange(0, file.size() - 1); while (!in.atEnd()) { line = in.readLine(); if (line.isEmpty()) continue; processLine(line); if (keymap.size() % 400 == 1) emit setProgressValue(file.pos()); } file.close(); saveWordList(); emit setProgressValue(file.size()); }
void MainWindow::closeEvent(QCloseEvent *) { saveWordList(); }