MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / loadFile

Method loadFile

MiniZincIDE/ide.cpp:521–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519}
520
521QPair<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
552void IDE::loadLargeFile(const QString &path, QWidget* parent)
553{

Callers 1

createEditorMethod · 0.80

Calls 5

findMethod · 0.80
setModifiedMethod · 0.80
endMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected