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

Method askFileDir

gui/resultstree.cpp:834–880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832}
833
834QString 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
882void ResultsTree::copy()
883{

Callers

nothing calls this directly

Calls 4

getPathFunction · 0.85
setPathFunction · 0.85
isEmptyMethod · 0.80
QStringClass · 0.70

Tested by

no test coverage detected