forked from qt-creator/qt-creator
ProjectNodes: Use QVector instead of QList for LocationInfo
Change-Id: I5bad9e1849b9d752de24626013c9102242d11a0a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
@@ -314,7 +314,7 @@ void addBacktraceInformation(FolderNode *node,
|
|||||||
const QDir &sourceDir,
|
const QDir &sourceDir,
|
||||||
int backtraceIndex)
|
int backtraceIndex)
|
||||||
{
|
{
|
||||||
QList<FolderNode::LocationInfo> info;
|
QVector<FolderNode::LocationInfo> info;
|
||||||
// Set up a default target path:
|
// Set up a default target path:
|
||||||
FilePath targetPath = node->filePath().pathAppended("CMakeLists.txt");
|
FilePath targetPath = node->filePath().pathAppended("CMakeLists.txt");
|
||||||
while (backtraceIndex != -1) {
|
while (backtraceIndex != -1) {
|
||||||
|
@@ -800,7 +800,7 @@ void ServerModeReader::addTargets(
|
|||||||
QTC_ASSERT(tNode, qDebug() << "No target node for" << t->sourceDirectory << t->name; continue);
|
QTC_ASSERT(tNode, qDebug() << "No target node for" << t->sourceDirectory << t->name; continue);
|
||||||
tNode->setTargetInformation(t->artifacts, t->type);
|
tNode->setTargetInformation(t->artifacts, t->type);
|
||||||
tNode->setBuildDirectory(t->buildDirectory);
|
tNode->setBuildDirectory(t->buildDirectory);
|
||||||
QList<FolderNode::LocationInfo> info;
|
QVector<FolderNode::LocationInfo> info;
|
||||||
// Set up a default target path:
|
// Set up a default target path:
|
||||||
FilePath targetPath = t->sourceDirectory.pathAppended("CMakeLists.txt");
|
FilePath targetPath = t->sourceDirectory.pathAppended("CMakeLists.txt");
|
||||||
for (CrossReference *cr : qAsConst(t->crossReferences)) {
|
for (CrossReference *cr : qAsConst(t->crossReferences)) {
|
||||||
|
@@ -3389,8 +3389,8 @@ void ProjectExplorerPluginPrivate::updateLocationSubMenus()
|
|||||||
|
|
||||||
const FolderNode *const fn
|
const FolderNode *const fn
|
||||||
= ProjectTree::currentNode() ? ProjectTree::currentNode()->asFolderNode() : nullptr;
|
= ProjectTree::currentNode() ? ProjectTree::currentNode()->asFolderNode() : nullptr;
|
||||||
const QList<FolderNode::LocationInfo> locations
|
const QVector<FolderNode::LocationInfo> locations = fn ? fn->locationInfo()
|
||||||
= fn ? fn->locationInfo() : QList<FolderNode::LocationInfo>();
|
: QVector<FolderNode::LocationInfo>();
|
||||||
|
|
||||||
const bool isVisible = !locations.isEmpty();
|
const bool isVisible = !locations.isEmpty();
|
||||||
projectMenu->menuAction()->setVisible(isVisible);
|
projectMenu->menuAction()->setVisible(isVisible);
|
||||||
@@ -3408,7 +3408,10 @@ void ProjectExplorerPluginPrivate::updateLocationSubMenus()
|
|||||||
}
|
}
|
||||||
const int line = li.line;
|
const int line = li.line;
|
||||||
const Utils::FilePath path = li.path;
|
const Utils::FilePath path = li.path;
|
||||||
auto *action = new QAction(li.displayName, nullptr);
|
QString displayName = fn->filePath() == li.path
|
||||||
|
? li.displayName
|
||||||
|
: tr("%1 in %2").arg(li.displayName).arg(li.path.toUserOutput());
|
||||||
|
auto *action = new QAction(displayName, nullptr);
|
||||||
connect(action, &QAction::triggered, this, [line, path]() {
|
connect(action, &QAction::triggered, this, [line, path]() {
|
||||||
Core::EditorManager::openEditorAt(path.toString(), line);
|
Core::EditorManager::openEditorAt(path.toString(), line);
|
||||||
});
|
});
|
||||||
|
@@ -670,13 +670,13 @@ void FolderNode::setIcon(const QIcon &icon)
|
|||||||
m_icon = icon;
|
m_icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderNode::setLocationInfo(const QList<FolderNode::LocationInfo> &info)
|
void FolderNode::setLocationInfo(const QVector<FolderNode::LocationInfo> &info)
|
||||||
{
|
{
|
||||||
m_locations = info;
|
m_locations = info;
|
||||||
Utils::sort(m_locations, &LocationInfo::priority);
|
Utils::sort(m_locations, &LocationInfo::priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<FolderNode::LocationInfo> FolderNode::locationInfo() const
|
const QVector<FolderNode::LocationInfo> FolderNode::locationInfo() const
|
||||||
{
|
{
|
||||||
return m_locations;
|
return m_locations;
|
||||||
}
|
}
|
||||||
|
@@ -249,6 +249,7 @@ public:
|
|||||||
class LocationInfo
|
class LocationInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
LocationInfo() = default;
|
||||||
LocationInfo(const QString &dn,
|
LocationInfo(const QString &dn,
|
||||||
const Utils::FilePath &p,
|
const Utils::FilePath &p,
|
||||||
const int l = 0,
|
const int l = 0,
|
||||||
@@ -264,8 +265,8 @@ public:
|
|||||||
unsigned int priority = 0;
|
unsigned int priority = 0;
|
||||||
QString displayName;
|
QString displayName;
|
||||||
};
|
};
|
||||||
void setLocationInfo(const QList<LocationInfo> &info);
|
void setLocationInfo(const QVector<LocationInfo> &info);
|
||||||
const QList<LocationInfo> locationInfo() const;
|
const QVector<LocationInfo> locationInfo() const;
|
||||||
|
|
||||||
QString addFileFilter() const;
|
QString addFileFilter() const;
|
||||||
void setAddFileFilter(const QString &filter) { m_addFileFilter = filter; }
|
void setAddFileFilter(const QString &filter) { m_addFileFilter = filter; }
|
||||||
@@ -311,7 +312,7 @@ protected:
|
|||||||
virtual void handleSubTreeChanged(FolderNode *node);
|
virtual void handleSubTreeChanged(FolderNode *node);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Node>> m_nodes;
|
std::vector<std::unique_ptr<Node>> m_nodes;
|
||||||
QList<LocationInfo> m_locations;
|
QVector<LocationInfo> m_locations;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Node> takeNode(Node *node);
|
std::unique_ptr<Node> takeNode(Node *node);
|
||||||
|
Reference in New Issue
Block a user