Merge remote-tracking branch 'origin/13.0'

Change-Id: I0892d8e54930bb5a65dc51117b8ca7d70ce300a3
This commit is contained in:
Eike Ziller
2024-04-17 12:48:28 +02:00
16 changed files with 130 additions and 66 deletions

View File

@@ -353,7 +353,9 @@ void DiagramSceneModel::selectAllElements()
void DiagramSceneModel::selectElement(DElement *element) void DiagramSceneModel::selectElement(DElement *element)
{ {
QGraphicsItem *selectItem = m_elementToItemMap.value(element); QGraphicsItem *selectItem = m_elementToItemMap.value(element);
for (QGraphicsItem *item : std::as_const(m_selectedItems)) { // We have to create a copy since "setSelected" may modify m_selectedItems
const QSet<QGraphicsItem *> copy = m_selectedItems;
for (QGraphicsItem *item : copy) {
if (item != selectItem) if (item != selectItem)
item->setSelected(false); item->setSelected(false);
} }

View File

@@ -48,7 +48,8 @@ public:
uint ownerId(FileOwner) const override; uint ownerId(FileOwner) const override;
QString owner(FileOwner) const override; QString owner(FileOwner) const override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) // The FileTime change in QAbstractFileEngine, in qtbase, is in since Qt 6.7.1
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 1)
using FileTime = QFile::FileTime; using FileTime = QFile::FileTime;
#endif #endif
bool setFileTime(const QDateTime &newDate, FileTime time) override; bool setFileTime(const QDateTime &newDate, FileTime time) override;

View File

@@ -132,7 +132,7 @@ void ActivationSequenceContextProcessor::processComment()
void ActivationSequenceContextProcessor::processInclude() void ActivationSequenceContextProcessor::processInclude()
{ {
if (m_token.isLiteral() && !isCompletionKindStringLiteralOrSlash()) if (m_token.isStringLiteral() && !isCompletionKindStringLiteralOrSlash())
m_completionKind = CPlusPlus::T_EOF_SYMBOL; m_completionKind = CPlusPlus::T_EOF_SYMBOL;
} }

View File

@@ -749,14 +749,17 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
&& func.Arguments().size() > 1 && func.Arguments().front().Value == target_name; && func.Arguments().size() > 1 && func.Arguments().front().Value == target_name;
}); });
for (const auto &func : {function, targetSourcesFunc, addQmlModuleFunc}) { auto setSourceFilePropFunc = findFunction(*cmakeListFile, [](const auto &func) {
return func.LowerCaseName() == "set_source_files_properties";
});
for (const auto &func : {function, targetSourcesFunc, addQmlModuleFunc, setSourceFilePropFunc}) {
if (!func.has_value()) if (!func.has_value())
continue; continue;
auto filePathArgument = Utils::findOrDefault(func->Arguments(), auto filePathArgument = Utils::findOrDefault(
[file_name = fileName.toStdString()]( func->Arguments(), [file_name = fileName.toStdString()](const auto &arg) {
const auto &arg) { return arg.Value == file_name;
return arg.Value == file_name; });
});
if (!filePathArgument.Value.empty()) { if (!filePathArgument.Value.empty()) {
return ProjectFileArgumentPosition{filePathArgument, targetCMakeFile, fileName}; return ProjectFileArgumentPosition{filePathArgument, targetCMakeFile, fileName};
@@ -925,48 +928,59 @@ bool CMakeBuildSystem::renameFile(Node *context,
{ {
if (auto n = dynamic_cast<CMakeTargetNode *>(context)) { if (auto n = dynamic_cast<CMakeTargetNode *>(context)) {
const FilePath projDir = n->filePath().canonicalPath(); const FilePath projDir = n->filePath().canonicalPath();
const QString newRelPathName const FilePath newRelPath = newFilePath.canonicalPath().relativePathFrom(projDir).cleanPath();
= newFilePath.canonicalPath().relativePathFrom(projDir).cleanPath().toString(); const QString newRelPathName = newRelPath.toString();
// FilePath needs the file to exist on disk, the old file has already been renamed
const QString oldRelPathName
= newRelPath.parentDir().pathAppended(oldFilePath.fileName()).cleanPath().toString();
const QString targetName = n->buildKey(); const QString targetName = n->buildKey();
const QString key const QString key
= QStringList{projDir.path(), targetName, oldFilePath.path(), newFilePath.path()}.join( = QStringList{projDir.path(), targetName, oldFilePath.path(), newFilePath.path()}.join(
";"); ";");
auto fileToRename = m_filesToBeRenamed.take(key); std::optional<CMakeBuildSystem::ProjectFileArgumentPosition> fileToRename
if (!fileToRename.cmakeFile.exists()) { = m_filesToBeRenamed.take(key);
if (!fileToRename->cmakeFile.exists()) {
qCCritical(cmakeBuildSystemLog).noquote() qCCritical(cmakeBuildSystemLog).noquote()
<< "File" << fileToRename.cmakeFile.path() << "does not exist."; << "File" << fileToRename->cmakeFile.path() << "does not exist.";
return false; return false;
} }
BaseTextEditor *editor = qobject_cast<BaseTextEditor *>( do {
Core::EditorManager::openEditorAt({fileToRename.cmakeFile, BaseTextEditor *editor = qobject_cast<BaseTextEditor *>(
static_cast<int>(fileToRename.argumentPosition.Line), Core::EditorManager::openEditorAt(
static_cast<int>(fileToRename.argumentPosition.Column {fileToRename->cmakeFile,
- 1)}, static_cast<int>(fileToRename->argumentPosition.Line),
Constants::CMAKE_EDITOR_ID, static_cast<int>(fileToRename->argumentPosition.Column - 1)},
Core::EditorManager::DoNotMakeVisible)); Constants::CMAKE_EDITOR_ID,
if (!editor) { Core::EditorManager::DoNotMakeVisible));
qCCritical(cmakeBuildSystemLog).noquote() if (!editor) {
<< "BaseTextEditor cannot be obtained for" << fileToRename.cmakeFile.path() qCCritical(cmakeBuildSystemLog).noquote()
<< fileToRename.argumentPosition.Line << int(fileToRename.argumentPosition.Column); << "BaseTextEditor cannot be obtained for" << fileToRename->cmakeFile.path()
return false; << fileToRename->argumentPosition.Line
} << int(fileToRename->argumentPosition.Column);
return false;
}
// If quotes were used for the source file, skip the starting quote // If quotes were used for the source file, skip the starting quote
if (fileToRename.argumentPosition.Delim == cmListFileArgument::Quoted) if (fileToRename->argumentPosition.Delim == cmListFileArgument::Quoted)
editor->setCursorPosition(editor->position() + 1); editor->setCursorPosition(editor->position() + 1);
if (!fileToRename.fromGlobbing) if (!fileToRename->fromGlobbing)
editor->replace(fileToRename.relativeFileName.length(), newRelPathName); editor->replace(fileToRename->relativeFileName.length(), newRelPathName);
editor->editorWidget()->autoIndent(); editor->editorWidget()->autoIndent();
if (!Core::DocumentManager::saveDocument(editor->document())) { if (!Core::DocumentManager::saveDocument(editor->document())) {
qCCritical(cmakeBuildSystemLog).noquote() qCCritical(cmakeBuildSystemLog).noquote()
<< "Changes to" << fileToRename.cmakeFile.path() << "could not be saved."; << "Changes to" << fileToRename->cmakeFile.path() << "could not be saved.";
return false; return false;
} }
// Try the next occurrence. This can happen if set_source_file_properties is used
fileToRename = projectFileArgumentPosition(targetName, oldRelPathName);
} while (fileToRename);
return true; return true;
} }

View File

@@ -633,7 +633,7 @@ static FolderNode *createSourceGroupNode(const QString &sourceGroupName,
FolderNode *existingNode = currentNode->findChildFolderNode( FolderNode *existingNode = currentNode->findChildFolderNode(
[&p](const FolderNode *fn) { return fn->displayName() == p; }); [&p](const FolderNode *fn) { return fn->displayName() == p; });
if (!existingNode) { if (!existingNode) {
auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p, true); auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p);
node->setListInProject(false); node->setListInProject(false);
node->setIcon([] { return Icon::fromTheme("edit-copy"); }); node->setIcon([] { return Icon::fromTheme("edit-copy"); });
@@ -654,7 +654,6 @@ static void addCompileGroups(ProjectNode *targetRoot,
const FilePath &buildDirectory, const FilePath &buildDirectory,
const TargetDetails &td) const TargetDetails &td)
{ {
const bool showSourceFolders = settings().showSourceSubFolders();
const bool inSourceBuild = (sourceDirectory == buildDirectory); const bool inSourceBuild = (sourceDirectory == buildDirectory);
QSet<FilePath> alreadyListed; QSet<FilePath> alreadyListed;
@@ -685,6 +684,9 @@ static void addCompileGroups(ProjectNode *targetRoot,
if (isPchFile(buildDirectory, sourcePath) || isUnityFile(buildDirectory, sourcePath)) if (isPchFile(buildDirectory, sourcePath) || isUnityFile(buildDirectory, sourcePath))
node->setIsGenerated(true); node->setIsGenerated(true);
const bool showSourceFolders = settings().showSourceSubFolders()
&& sourcesOrHeadersFolder(td.sourceGroups[si.sourceGroup]);
// Where does the file node need to go? // Where does the file node need to go?
if (showSourceFolders && sourcePath.isChildOf(buildDirectory) && !inSourceBuild) { if (showSourceFolders && sourcePath.isChildOf(buildDirectory) && !inSourceBuild) {
buildFileNodes.emplace_back(std::move(node)); buildFileNodes.emplace_back(std::move(node));
@@ -696,6 +698,9 @@ static void addCompileGroups(ProjectNode *targetRoot,
} }
for (size_t i = 0; i < sourceGroupFileNodes.size(); ++i) { for (size_t i = 0; i < sourceGroupFileNodes.size(); ++i) {
const bool showSourceFolders = settings().showSourceSubFolders()
&& sourcesOrHeadersFolder(td.sourceGroups[i]);
std::vector<std::unique_ptr<FileNode>> &current = sourceGroupFileNodes[i]; std::vector<std::unique_ptr<FileNode>> &current = sourceGroupFileNodes[i];
FolderNode *insertNode = td.sourceGroups[i] == "TREE" FolderNode *insertNode = td.sourceGroups[i] == "TREE"
? targetRoot ? targetRoot

View File

@@ -18,15 +18,19 @@ using namespace ProjectExplorer;
namespace CMakeProjectManager::Internal { namespace CMakeProjectManager::Internal {
bool sourcesOrHeadersFolder(const QString &displayName)
{
return displayName == "Source Files" || displayName == "Header Files";
}
std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath, std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
int priority, int priority,
const QString &displayName, const QString &displayName)
bool sourcesOrHeaders)
{ {
auto newFolder = std::make_unique<VirtualFolderNode>(basePath); auto newFolder = std::make_unique<VirtualFolderNode>(basePath);
newFolder->setPriority(priority); newFolder->setPriority(priority);
newFolder->setDisplayName(displayName); newFolder->setDisplayName(displayName);
newFolder->setIsSourcesOrHeaders(sourcesOrHeaders); newFolder->setIsSourcesOrHeaders(sourcesOrHeadersFolder(displayName));
return newFolder; return newFolder;
} }
@@ -35,14 +39,13 @@ void addCMakeVFolder(FolderNode *base,
int priority, int priority,
const QString &displayName, const QString &displayName,
std::vector<std::unique_ptr<FileNode>> &&files, std::vector<std::unique_ptr<FileNode>> &&files,
bool sourcesOrHeaders,
bool listInProject) bool listInProject)
{ {
if (files.size() == 0) if (files.size() == 0)
return; return;
FolderNode *folder = base; FolderNode *folder = base;
if (!displayName.isEmpty()) { if (!displayName.isEmpty()) {
auto newFolder = createCMakeVFolder(basePath, priority, displayName, sourcesOrHeaders); auto newFolder = createCMakeVFolder(basePath, priority, displayName);
folder = newFolder.get(); folder = newFolder.get();
base->addNode(std::move(newFolder)); base->addNode(std::move(newFolder));
} }
@@ -90,7 +93,6 @@ void addCMakeInputs(FolderNode *root,
10, 10,
Tr::tr("<Other Locations>"), Tr::tr("<Other Locations>"),
removeKnownNodes(knownFiles, std::move(rootInputs)), removeKnownNodes(knownFiles, std::move(rootInputs)),
/*sourcesOrHeaders=*/false,
/*listInProject=*/false); /*listInProject=*/false);
root->addNode(std::move(cmakeVFolder)); root->addNode(std::move(cmakeVFolder));

View File

@@ -11,17 +11,17 @@
namespace CMakeProjectManager::Internal { namespace CMakeProjectManager::Internal {
bool sourcesOrHeadersFolder(const QString &displayName);
std::unique_ptr<ProjectExplorer::FolderNode> createCMakeVFolder(const Utils::FilePath &basePath, std::unique_ptr<ProjectExplorer::FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
int priority, int priority,
const QString &displayName, const QString &displayName);
bool sourcesOrHeaders);
void addCMakeVFolder(ProjectExplorer::FolderNode *base, void addCMakeVFolder(ProjectExplorer::FolderNode *base,
const Utils::FilePath &basePath, const Utils::FilePath &basePath,
int priority, int priority,
const QString &displayName, const QString &displayName,
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&files, std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&files,
bool sourcesOrHeaders = false,
bool listInProject = true); bool listInProject = true);
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&removeKnownNodes( std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&removeKnownNodes(

View File

@@ -999,6 +999,7 @@ bool FakeVimUserCommandsModel::setData(const QModelIndex &index,
return true; return true;
} }
#ifdef WITH_TESTS
static void setupTest(QString *title, FakeVimHandler **handler, QWidget **edit) static void setupTest(QString *title, FakeVimHandler **handler, QWidget **edit)
{ {
*title = QString::fromLatin1("test.cpp"); *title = QString::fromLatin1("test.cpp");
@@ -1040,7 +1041,6 @@ static void setupTest(QString *title, FakeVimHandler **handler, QWidget **edit)
(*handler)->handleCommand("set iskeyword=@,48-57,_,192-255,a-z,A-Z"); (*handler)->handleCommand("set iskeyword=@,48-57,_,192-255,a-z,A-Z");
} }
#ifdef WITH_TESTS
QObject *createFakeVimTester( void (*setupTest)(QString *, FakeVimHandler **, QWidget **) ); // in fakevim_test.cpp QObject *createFakeVimTester( void (*setupTest)(QString *, FakeVimHandler **, QWidget **) ); // in fakevim_test.cpp
#endif #endif

View File

@@ -60,18 +60,29 @@ using namespace Tasking;
namespace Ios::Internal { namespace Ios::Internal {
static QString identifierForRunControl(RunControl *runControl)
{
const IosDeviceTypeAspect::Data *data = runControl->aspectData<IosDeviceTypeAspect>();
return data ? data->deviceType.identifier : QString();
}
static void stopRunningRunControl(RunControl *runControl) static void stopRunningRunControl(RunControl *runControl)
{ {
static QMap<Id, QPointer<RunControl>> activeRunControls; static QMap<Id, QPointer<RunControl>> activeRunControls;
// clean up deleted
Utils::erase(activeRunControls, [](const QPointer<RunControl> &rc) { return !rc; });
Target *target = runControl->target(); Target *target = runControl->target();
Id devId = DeviceKitAspect::deviceId(target->kit()); const Id devId = DeviceKitAspect::deviceId(target->kit());
const QString identifier = identifierForRunControl(runControl);
// The device can only run an application at a time, if an app is running stop it. // The device can only run an application at a time, if an app is running stop it.
if (activeRunControls.contains(devId)) { if (QPointer<RunControl> activeRunControl = activeRunControls[devId]) {
if (QPointer<RunControl> activeRunControl = activeRunControls[devId]) if (identifierForRunControl(activeRunControl) == identifier) {
activeRunControl->initiateStop(); activeRunControl->initiateStop();
activeRunControls.remove(devId); activeRunControls.remove(devId);
}
} }
if (devId.isValid()) if (devId.isValid())

View File

@@ -391,14 +391,14 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
const CommandLine thisCommand = rc->commandLine(); const CommandLine thisCommand = rc->commandLine();
const FilePath thisWorkingDirectory = rc->workingDirectory(); const FilePath thisWorkingDirectory = rc->workingDirectory();
const Environment thisEnvironment = rc->environment(); const Environment thisEnvironment = rc->environment();
const auto tab = std::find_if(m_runControlTabs.begin(), m_runControlTabs.end(), const auto tab = std::find_if(
[&](const RunControlTab &tab) { m_runControlTabs.begin(), m_runControlTabs.end(), [&](const RunControlTab &tab) {
if (!tab.runControl || tab.runControl->isRunning() || tab.runControl->isStarting()) if (!tab.runControl || !tab.runControl->isStopped())
return false; return false;
return thisCommand == tab.runControl->commandLine() return thisCommand == tab.runControl->commandLine()
&& thisWorkingDirectory == tab.runControl->workingDirectory() && thisWorkingDirectory == tab.runControl->workingDirectory()
&& thisEnvironment == tab.runControl->environment(); && thisEnvironment == tab.runControl->environment();
}); });
if (tab != m_runControlTabs.end()) { if (tab != m_runControlTabs.end()) {
// Reuse this tab // Reuse this tab
if (tab->runControl) if (tab->runControl)

View File

@@ -617,7 +617,15 @@ FilePath BuildConfiguration::buildDirectoryFromTemplate(const FilePath &projectD
[buildType] { return buildTypeName(buildType); }); [buildType] { return buildTypeName(buildType); });
exp.registerSubProvider([kit] { return kit->macroExpander(); }); exp.registerSubProvider([kit] { return kit->macroExpander(); });
FilePath buildDir = FilePath::fromUserInput(buildPropertiesSettings().buildDirectoryTemplate()); auto project = ProjectManager::projectWithProjectFilePath(mainFilePath);
auto environment = Environment::systemEnvironment();
// This adds the environment variables from the <project>.shared file
if (project)
environment.modify(project->additionalEnvironment());
FilePath buildDir = FilePath::fromUserInput(environment.value_or(
Constants::QTC_DEFAULT_BUILD_DIRECTORY_TEMPLATE,
buildPropertiesSettings().buildDirectoryTemplate()));
qCDebug(bcLog) << "build dir template:" << buildDir.toUserOutput(); qCDebug(bcLog) << "build dir template:" << buildDir.toUserOutput();
buildDir = exp.expand(buildDir); buildDir = exp.expand(buildDir);
qCDebug(bcLog) << "expanded build:" << buildDir.toUserOutput(); qCDebug(bcLog) << "expanded build:" << buildDir.toUserOutput();

View File

@@ -8,6 +8,7 @@
#include <coreplugin/dialogs/ioptionspage.h> #include <coreplugin/dialogs/ioptionspage.h>
#include <utils/environment.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
using namespace Utils; using namespace Utils;
@@ -16,7 +17,9 @@ namespace ProjectExplorer {
static QString defaultBuildDirectoryTemplate() static QString defaultBuildDirectoryTemplate()
{ {
return "./build/%{Asciify:%{Kit:FileSystemName}-%{BuildConfig:Name}}"; return qtcEnvironmentVariable(
Constants::QTC_DEFAULT_BUILD_DIRECTORY_TEMPLATE,
"./build/%{Asciify:%{Kit:FileSystemName}-%{BuildConfig:Name}}");
} }
BuildPropertiesSettings &buildPropertiesSettings() BuildPropertiesSettings &buildPropertiesSettings()

View File

@@ -145,6 +145,8 @@ const char CUSTOM_TOOLCHAIN_TYPEID[] = "ProjectExplorer.ToolChain.Custom";
const char DEFAULT_WORKING_DIR[] = "%{buildDir}"; const char DEFAULT_WORKING_DIR[] = "%{buildDir}";
const char DEFAULT_WORKING_DIR_ALTERNATE[] = "%{sourceDir}"; const char DEFAULT_WORKING_DIR_ALTERNATE[] = "%{sourceDir}";
const char QTC_DEFAULT_BUILD_DIRECTORY_TEMPLATE[] = "QTC_DEFAULT_BUILD_DIRECTORY_TEMPLATE";
// Desktop Device related ids: // Desktop Device related ids:
const char DESKTOP_DEVICE_ID[] = "Desktop Device"; const char DESKTOP_DEVICE_ID[] = "Desktop Device";
const char DESKTOP_DEVICE_TYPE[] = "Desktop"; const char DESKTOP_DEVICE_TYPE[] = "Desktop";

View File

@@ -24,6 +24,21 @@
" <sub-class-of type='text/plain'/>", " <sub-class-of type='text/plain'/>",
" <glob pattern='*.dts' weight='80'/>", " <glob pattern='*.dts' weight='80'/>",
" </mime-type>", " </mime-type>",
" <mime-type type='text/x-yacc'>",
" <comment>Yacc/Bison source files</comment>",
" <sub-class-of type='text/plain'/>",
" <glob pattern='*.y'/>",
" <glob pattern='*.yy'/>",
" <glob pattern='*.ypp'/>",
" <glob pattern='*.y++'/>",
" </mime-type>",
" <mime-type type='text/x-lex'>",
" <comment>Lex/Flex source files</comment>",
" <sub-class-of type='text/plain'/>",
" <glob pattern='*.l'/>",
" <glob pattern='*.lex'/>",
" <glob pattern='*.flex'/>",
" </mime-type>",
"</mime-info>" "</mime-info>"
] ]
} }

View File

@@ -524,7 +524,7 @@ def __getSupportedPlatforms__(text, templateName, getAsStrings=False, ignoreVali
version = res.group("version") version = res.group("version")
else: else:
version = None version = None
if templateName == "Qt Quick Application": if templateName in ("Qt Quick 2 Extension Plugin", "Qt Quick Application"):
result = set([Targets.DESKTOP_6_2_4]) result = set([Targets.DESKTOP_6_2_4])
elif 'Supported Platforms' in text: elif 'Supported Platforms' in text:
supports = text[text.find('Supported Platforms'):].split(":")[1].strip().split("\n") supports = text[text.find('Supported Platforms'):].split(":")[1].strip().split("\n")

View File

@@ -82,7 +82,8 @@ def __clickCommit__(count):
test.verify(waitFor('str(fileName.currentText) == expected', 5000), test.verify(waitFor('str(fileName.currentText) == expected', 5000),
"Verifying editor switches to Git Show.") "Verifying editor switches to Git Show.")
description = waitForObject(":Qt Creator_DiffEditor::Internal::DescriptionEditorWidget") description = waitForObject(":Qt Creator_DiffEditor::Internal::DescriptionEditorWidget")
waitFor('len(str(description.plainText)) != 0', 5000) waitFor('len(str(description.plainText)) != 0 '
'and str(description.plainText) != "Waiting for data..."', 5000)
show = str(description.plainText) show = str(description.plainText)
id = "Nobody <nobody@nowhere\.com>" id = "Nobody <nobody@nowhere\.com>"
time = "\w{3} \w{3} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}.* seconds ago\)" time = "\w{3} \w{3} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}.* seconds ago\)"