| 519 | } |
| 520 | |
| 521 | QPair<QTextDocument*,bool> IDE::loadFile(const QString& path, QWidget* parent) |
| 522 | { |
| 523 | DMap::iterator it = documents.find(path); |
| 524 | if (it==documents.end()) { |
| 525 | QFile file(path); |
| 526 | if (file.open(QFile::ReadOnly | QFile::Text)) { |
| 527 | Doc* d = new Doc; |
| 528 | if ( (path.endsWith(".dzn") || path.endsWith(".fzn") || path.endsWith(".json")) && file.size() > 5*1024*1024) { |
| 529 | d->large = true; |
| 530 | } else { |
| 531 | d->td.setPlainText(file.readAll()); |
| 532 | d->large = false; |
| 533 | } |
| 534 | d->td.setModified(false); |
| 535 | documents.insert(path,d); |
| 536 | if (!d->large) |
| 537 | fsWatch.addPath(path); |
| 538 | return qMakePair(&d->td,d->large); |
| 539 | } else { |
| 540 | QMessageBox::warning(parent, "MiniZinc IDE", |
| 541 | "Could not open file "+path, |
| 542 | QMessageBox::Ok); |
| 543 | QTextDocument* nd = nullptr; |
| 544 | return qMakePair(nd,false); |
| 545 | } |
| 546 | |
| 547 | } else { |
| 548 | return qMakePair(&it.value()->td,it.value()->large); |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | void IDE::loadLargeFile(const QString &path, QWidget* parent) |
| 553 | { |
no test coverage detected