| 203 | } |
| 204 | |
| 205 | void MainWindow::saveFile() |
| 206 | { |
| 207 | QString fileName = QFileDialog::getSaveFileName(this, tr("Save file as"), "", "*.cht"); |
| 208 | |
| 209 | if (!fileName.isEmpty()) { |
| 210 | QFile file(fileName); |
| 211 | QTextStream stream(&file); |
| 212 | |
| 213 | if (file.open(QFile::WriteOnly | QFile::Text)) { |
| 214 | for (int row = 0; row < m_model->rowCount(QModelIndex()); ++row) { |
| 215 | |
| 216 | QStringList pieces; |
| 217 | |
| 218 | pieces.append(m_model->data(m_model->index(row, 0, QModelIndex()), |
| 219 | Qt::DisplayRole) |
| 220 | .toString()); |
| 221 | pieces.append(m_model->data(m_model->index(row, 1, QModelIndex()), |
| 222 | Qt::DisplayRole) |
| 223 | .toString()); |
| 224 | pieces.append(m_model->data(m_model->index(row, 2, QModelIndex()), |
| 225 | Qt::DisplayRole) |
| 226 | .toString()); |
| 227 | pieces.append(m_model->data(m_model->index(row, 0, QModelIndex()), |
| 228 | Qt::DecorationRole) |
| 229 | .toString()); |
| 230 | |
| 231 | stream << pieces.join(",") << "\n"; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | file.close(); |
| 236 | statusBar()->showMessage(tr("Saved %1").arg(fileName), 2000); |
| 237 | } |
| 238 | } |
nothing calls this directly
no test coverage detected