aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projectmodels.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/projectexplorer/projectmodels.cpp')
-rw-r--r--src/plugins/projectexplorer/projectmodels.cpp57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp
index 8a47245d1b..d269a059b3 100644
--- a/src/plugins/projectexplorer/projectmodels.cpp
+++ b/src/plugins/projectexplorer/projectmodels.cpp
@@ -214,35 +214,23 @@ bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int rol
// The base name of the file was changed. Go look for other files with the same base name
// and offer to rename them as well.
if (orgFilePath != newFilePath && orgFileInfo.suffix() == newFilePath.toFileInfo().suffix()) {
- ProjectNode *productNode = node->parentProjectNode();
- while (productNode && !productNode->isProduct())
- productNode = productNode->parentProjectNode();
- if (productNode) {
- const auto filter = [&orgFilePath, &orgFileInfo](const Node *n) {
- return n->asFileNode()
- && n->filePath().toFileInfo().dir() == orgFileInfo.dir()
- && n->filePath().toFileInfo().completeBaseName()
- == orgFileInfo.completeBaseName()
- && n->filePath() != orgFilePath;
- };
- const QList<Node *> candidateNodes = productNode->findNodes(filter);
- if (!candidateNodes.isEmpty()) {
- const QMessageBox::StandardButton reply = QMessageBox::question(
- Core::ICore::mainWindow(), tr("Rename More Files?"),
- tr("Would you like to rename these files as well?\n %1")
- .arg(transform<QStringList>(candidateNodes, [](const Node *n) {
- return n->filePath().toFileInfo().fileName();
- }).join("\n ")));
- if (reply == QMessageBox::Yes) {
- for (Node * const n : candidateNodes) {
- QString targetFilePath = orgFileInfo.absolutePath() + '/'
- + newFilePath.toFileInfo().completeBaseName();
- const QString suffix = n->filePath().toFileInfo().suffix();
- if (!suffix.isEmpty())
- targetFilePath.append('.').append(suffix);
- toRename.emplace_back(std::make_tuple(n, n->filePath(),
- FilePath::fromString(targetFilePath)));
- }
+ const QList<Node *> candidateNodes = ProjectTree::siblingsWithSameBaseName(node);
+ if (!candidateNodes.isEmpty()) {
+ const QMessageBox::StandardButton reply = QMessageBox::question(
+ Core::ICore::dialogParent(), tr("Rename More Files?"),
+ tr("Would you like to rename these files as well?\n %1")
+ .arg(transform<QStringList>(candidateNodes, [](const Node *n) {
+ return n->filePath().toFileInfo().fileName();
+ }).join("\n ")));
+ if (reply == QMessageBox::Yes) {
+ for (Node * const n : candidateNodes) {
+ QString targetFilePath = orgFileInfo.absolutePath() + '/'
+ + newFilePath.toFileInfo().completeBaseName();
+ const QString suffix = n->filePath().toFileInfo().suffix();
+ if (!suffix.isEmpty())
+ targetFilePath.append('.').append(suffix);
+ toRename.emplace_back(std::make_tuple(n, n->filePath(),
+ FilePath::fromString(targetFilePath)));
}
}
}
@@ -370,6 +358,7 @@ void FlatModel::handleProjectAdded(Project *project)
this, [this, project]() {
if (nodeForProject(project))
parsingStateChanged(project);
+ emit ProjectTree::instance()->nodeActionsChanged();
});
addOrRebuildProjectModel(project);
}
@@ -515,12 +504,13 @@ public:
targetDirLayout->addWidget(new QLabel(tr("Target directory:"), this));
m_targetDirChooser = new PathChooser(this);
m_targetDirChooser->setExpectedKind(PathChooser::ExistingDirectory);
- m_targetDirChooser->setFileName(defaultTargetDir);
+ m_targetDirChooser->setFilePath(defaultTargetDir);
connect(m_targetDirChooser, &PathChooser::validChanged, this, [this](bool valid) {
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
});
targetDirLayout->addWidget(m_targetDirChooser);
- connect(m_buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, [this] {
+ connect(m_buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
+ this, [this] {
switch (dropAction()) {
case DropAction::CopyWithFiles:
case DropAction::MoveWithFiles:
@@ -548,7 +538,7 @@ public:
DropAction dropAction() const { return static_cast<DropAction>(m_buttonGroup->checkedId()); }
FilePath targetDir() const
{
- return m_targetDirChooser ? m_targetDirChooser->fileName() : FilePath();
+ return m_targetDirChooser ? m_targetDirChooser->filePath() : FilePath();
}
private:
@@ -759,8 +749,7 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
"files. Please check your repository."))
.append("\n ").append(makeUserFileList(failedVcsOp));
}
- QMessageBox::warning(Core::ICore::mainWindow(), tr("Failure Updating Project"),
- message);
+ QMessageBox::warning(Core::ICore::dialogParent(), tr("Failure Updating Project"), message);
}
return true;