| 737 | } |
| 738 | |
| 739 | void 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("\""); |
nothing calls this directly
no test coverage detected