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

Method selectFilesToAnalyze

gui/mainwindow.cpp:750–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750QStringList MainWindow::selectFilesToAnalyze(QFileDialog::FileMode mode)
751{
752 if (mProjectFile) {
753 QMessageBox msgBox(this);
754 msgBox.setWindowTitle(tr("Cppcheck"));
755 const QString msg(tr("You must close the project file before selecting new files or directories!"));
756 msgBox.setText(msg);
757 msgBox.setIcon(QMessageBox::Critical);
758 msgBox.exec();
759 return QStringList();
760 }
761
762 QStringList selected;
763
764 // NOTE: we use QFileDialog::getOpenFileNames() and
765 // QFileDialog::getExistingDirectory() because they show native Windows
766 // selection dialog which is a lot more usable than Qt:s own dialog.
767 if (mode == QFileDialog::ExistingFiles) {
768 QMap<QString,QString> filters;
769 filters[tr("C/C++ Source")] = FileList::getDefaultFilters().join(" ");
770 filters[tr("Compile database")] = compile_commands_json;
771 filters[tr("Visual Studio")] = "*.sln *.slnx *.vcxproj";
772 filters[tr("Borland C++ Builder 6")] = "*.bpr";
773 QString lastFilter = mSettings->value(SETTINGS_LAST_ANALYZE_FILES_FILTER).toString();
774 selected = QFileDialog::getOpenFileNames(this,
775 tr("Select files to analyze"),
776 getPath(SETTINGS_LAST_CHECK_PATH),
777 toFilterString(filters),
778 &lastFilter);
779 mSettings->setValue(SETTINGS_LAST_ANALYZE_FILES_FILTER, lastFilter);
780
781 if (selected.isEmpty())
782 mCurrentDirectory.clear();
783 else {
784 QFileInfo inf(selected[0]);
785 mCurrentDirectory = inf.absolutePath();
786 }
787 formatAndSetTitle();
788 } else if (mode == QFileDialog::Directory) {
789 QString dir = QFileDialog::getExistingDirectory(this,
790 tr("Select directory to analyze"),
791 getPath(SETTINGS_LAST_CHECK_PATH));
792 if (!dir.isEmpty()) {
793 qDebug() << "Setting current directory to: " << dir;
794 mCurrentDirectory = dir;
795 selected.append(dir);
796 dir = QDir::toNativeSeparators(dir);
797 formatAndSetTitle(dir);
798 }
799 }
800 if (!mCurrentDirectory.isEmpty())
801 setPath(SETTINGS_LAST_CHECK_PATH, mCurrentDirectory);
802
803 return selected;
804}
805
806void MainWindow::analyzeFiles()
807{

Callers

nothing calls this directly

Calls 9

getPathFunction · 0.85
toFilterStringFunction · 0.85
setPathFunction · 0.85
isEmptyMethod · 0.80
joinMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45
setValueMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected