MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / startApplication

Method startApplication

gui/resultstree.cpp:739–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737}
738
739void ResultsTree::startApplication(const ResultItem *target, int application)
740{
741 //If there are no applications specified, tell the user about it
742 if (mApplications->getApplicationCount() == 0) {
743 QMessageBox msg(QMessageBox::Critical,
744 tr("Cppcheck"),
745 tr("No editor application configured.\n\n"
746 "Configure the editor application for Cppcheck in preferences/Applications."),
747 QMessageBox::Ok,
748 this);
749 msg.exec();
750 return;
751 }
752
753 if (application == -1)
754 application = mApplications->getDefaultApplication();
755
756 if (application == -1) {
757 QMessageBox msg(QMessageBox::Critical,
758 tr("Cppcheck"),
759 tr("No default editor application selected.\n\n"
760 "Please select the default editor application in preferences/Applications."),
761 QMessageBox::Ok,
762 this);
763 msg.exec();
764 return;
765 }
766
767 if (target && application >= 0 && application < mApplications->getApplicationCount() && target->parent()) {
768 const auto& errorPathItem = target->getErrorPathItem();
769
770 //Replace (file) with filename
771 QString file = QDir::toNativeSeparators(errorPathItem.file);
772 qDebug() << "Opening file: " << file;
773
774 const QFileInfo info(file);
775 if (!info.exists()) {
776 if (info.isAbsolute()) {
777 QMessageBox msgbox(this);
778 msgbox.setWindowTitle("Cppcheck");
779 msgbox.setText(tr("Could not find the file!"));
780 msgbox.setIcon(QMessageBox::Critical);
781 msgbox.exec();
782 } else {
783 QDir checkdir(mCheckPath);
784 if (checkdir.isAbsolute() && checkdir.exists()) {
785 file = mCheckPath + "/" + file;
786 } else {
787 QString dir = askFileDir(file);
788 dir += '/';
789 file = dir + file;
790 }
791 }
792 }
793
794 if (file.indexOf(" ") > -1) {
795 file.insert(0, "\"");
796 file.append("\"");

Callers

nothing calls this directly

Calls 9

getDefaultApplicationMethod · 0.80
getErrorPathItemMethod · 0.80
getPathMethod · 0.80
startsWithMethod · 0.80
endsWithMethod · 0.80
getApplicationCountMethod · 0.45
existsMethod · 0.45
isAbsoluteMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected