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

Method collectCodeEditors

MiniZincIDE/mainwindow.cpp:1727–1775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1725}
1726
1727QVector<CodeEditor*> MainWindow::collectCodeEditors(QVector<QStringList>& locs) {
1728 QVector<CodeEditor*> ces;
1729 ces.resize(locs.size());
1730 // Open each file in the path
1731 for (int p = 0; p < locs.size(); p++) {
1732 QStringList& elements = locs[p];
1733
1734 QString filename = elements[0];
1735 QUrl url = QUrl::fromLocalFile(filename);
1736 QFileInfo urlinfo(url.toLocalFile());
1737
1738 bool notOpen = true;
1739 if (filename != "") {
1740 for (int i=0; i<ui->tabWidget->count(); i++) {
1741 CodeEditor* ce = qobject_cast<CodeEditor*>(ui->tabWidget->widget(i));
1742 if (!ce) {
1743 continue;
1744 }
1745
1746 QFileInfo ceinfo(ce->filepath);
1747
1748 if (ceinfo.canonicalFilePath() == urlinfo.canonicalFilePath()) {
1749 ces[p] = ce;
1750 if(p == locs.size()-1) {
1751 ui->tabWidget->setCurrentIndex(i);
1752 }
1753 notOpen = false;
1754 break;
1755 }
1756 }
1757 if (notOpen && filename.size() > 0) {
1758 openFile(url.toLocalFile(), false, false);
1759 CodeEditor* ce = static_cast<CodeEditor*>(ui->tabWidget->widget(ui->tabWidget->count()-1));
1760
1761 QFileInfo ceinfo(ce->filepath);
1762
1763 if (ceinfo.canonicalFilePath() == urlinfo.canonicalFilePath()) {
1764 ces[p] = ce;
1765 } else {
1766 throw InternalError("Code editor file path does not match URL file path");
1767 }
1768 }
1769 } else {
1770 CodeEditor* ce = qobject_cast<CodeEditor*>(ui->tabWidget->widget(ui->tabWidget->currentIndex()));
1771 ces[p] = ce;
1772 }
1773 }
1774 return ces;
1775}
1776
1777void MainWindow::find(bool fwd, bool forceNoWrapAround)
1778{

Callers

nothing calls this directly

Calls 7

InternalErrorClass · 0.85
countMethod · 0.80
setCurrentIndexMethod · 0.80
currentIndexMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
widgetMethod · 0.45

Tested by

no test coverage detected