MCPcopy Create free account
hub / github.com/KDE/labplot / openProject

Method openProject

src/frontend/MainWin.cpp:1493–1532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1491}
1492
1493void MainWin::openProject() {
1494 bool supportOthers = false;
1495 QString allExtensions = Project::supportedExtensions();
1496 QString extensions = i18n("LabPlot Projects (%1)", allExtensions);
1497 if (m_lastOpenFileFilter.isEmpty())
1498 m_lastOpenFileFilter = extensions;
1499
1500#ifdef HAVE_LIBORIGIN
1501 extensions += QLatin1String(";;") + i18n("Origin Projects (%1)", OriginProjectParser::supportedExtensions());
1502 allExtensions += QLatin1String(" ") + OriginProjectParser::supportedExtensions();
1503 supportOthers = true;
1504#endif
1505
1506#ifdef HAVE_CANTOR_LIBS
1507 extensions += QLatin1String(";;") + i18n("Cantor Projects (*.cws)");
1508 extensions += QLatin1String(";;") + i18n("Jupyter Notebooks (*.ipynb)");
1509 allExtensions += QLatin1String(" *.cws *.ipynb");
1510 supportOthers = true;
1511#endif
1512
1513 // add an entry for "All supported files" if we support more than labplot
1514 if (supportOthers)
1515 extensions = i18n("All supported files (%1)", allExtensions) + QLatin1String(";;") + extensions;
1516
1517 KConfigGroup group = Settings::group(QStringLiteral("MainWin"));
1518 const QString& dir = group.readEntry("LastOpenDir", "");
1519 const QString& path = QFileDialog::getOpenFileName(this, i18nc("@title:window", "Open Project"), dir, extensions, &m_lastOpenFileFilter);
1520 if (path.isEmpty()) // "Cancel" was clicked
1521 return;
1522
1523 this->openProject(path);
1524
1525 // save new "last open directory"
1526 int pos = path.lastIndexOf(QLatin1String("/"));
1527 if (pos != -1) {
1528 const QString& newDir = path.left(pos);
1529 if (newDir != dir)
1530 group.writeEntry("LastOpenDir", newDir);
1531 }
1532}
1533
1534void MainWin::openProject(const QString& fileName) {
1535 if (m_project && fileName == m_project->fileName()) {

Callers 1

openRecentProjectMethod · 0.95

Calls 15

groupFunction · 0.85
existsMethod · 0.80
showMessageMethod · 0.80
loadNotebookMethod · 0.80
dockWidgetsMapMethod · 0.80
suppressDeletionMethod · 0.80
isEmptyMethod · 0.45
fileNameMethod · 0.45
openMethod · 0.45
closeMethod · 0.45
setFileNameMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected