| 832 | } |
| 833 | |
| 834 | QString ResultsTree::askFileDir(const QString &file) |
| 835 | { |
| 836 | QString text = tr("Could not find file:") + '\n' + file + '\n'; |
| 837 | QString title; |
| 838 | if (file.indexOf('/')) { |
| 839 | QString folderName = file.mid(0, file.indexOf('/')); |
| 840 | text += tr("Please select the folder '%1'").arg(folderName); |
| 841 | title = tr("Select Directory '%1'").arg(folderName); |
| 842 | } else { |
| 843 | text += tr("Please select the directory where file is located."); |
| 844 | title = tr("Select Directory"); |
| 845 | } |
| 846 | |
| 847 | QMessageBox msgbox(this); |
| 848 | msgbox.setWindowTitle("Cppcheck"); |
| 849 | msgbox.setText(text); |
| 850 | msgbox.setIcon(QMessageBox::Warning); |
| 851 | msgbox.exec(); |
| 852 | |
| 853 | QString dir = QFileDialog::getExistingDirectory(this, title, |
| 854 | getPath(SETTINGS_LAST_SOURCE_PATH), |
| 855 | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); |
| 856 | |
| 857 | if (dir.isEmpty()) |
| 858 | return QString(); |
| 859 | |
| 860 | // User selected root path |
| 861 | if (QFileInfo::exists(dir + '/' + file)) |
| 862 | mCheckPath = dir; |
| 863 | |
| 864 | // user selected checked folder |
| 865 | else if (file.indexOf('/') > 0) { |
| 866 | dir += '/'; |
| 867 | QString folderName = file.mid(0, file.indexOf('/')); |
| 868 | if (dir.indexOf('/' + folderName + '/')) |
| 869 | dir = dir.mid(0, dir.lastIndexOf('/' + folderName + '/')); |
| 870 | if (QFileInfo::exists(dir + '/' + file)) |
| 871 | mCheckPath = dir; |
| 872 | } |
| 873 | |
| 874 | // Otherwise; return |
| 875 | else |
| 876 | return QString(); |
| 877 | |
| 878 | setPath(SETTINGS_LAST_SOURCE_PATH, mCheckPath); |
| 879 | return mCheckPath; |
| 880 | } |
| 881 | |
| 882 | void ResultsTree::copy() |
| 883 | { |