Commit f20b92f9 authored by Tobias Hunger's avatar Tobias Hunger Committed by hjk

ProjectNodes: Add line information and act on it

Also allow for the path to be set. Qbs can move products from one
file to the next, so that is needed there.

Change-Id: Iebaf3be40fdb0e5e462d45b00cf46d58f985a163
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 1fda2111
......@@ -73,6 +73,16 @@ Node::Node(NodeType nodeType,
}
/*!
* \brief The path of the file representing this node.
*
* This method does not emit any signals, that has to be done by the calling class!
*/
void Node::setPath(const QString &path)
{
m_path = path;
}
NodeType Node::nodeType() const
{
return m_nodeType;
......@@ -102,6 +112,11 @@ QString Node::path() const
return m_path;
}
int Node::line() const
{
return -1;
}
QString Node::displayName() const
{
return QFileInfo(path()).fileName();
......@@ -241,6 +256,24 @@ void FolderNode::setIcon(const QIcon &icon)
m_icon = icon;
}
FileNode *FolderNode::findFile(const QString &path)
{
foreach (FileNode *n, fileNodes()) {
if (n->path() == path)
return n;
}
return 0;
}
FolderNode *FolderNode::findSubFolder(const QString &path)
{
foreach (FolderNode *n, subFolderNodes()) {
if (n->path() == path)
return n;
}
return 0;
}
/*!
\class ProjectExplorer::VirtualFolderNode
......
......@@ -85,11 +85,15 @@ public:
ProjectNode *projectNode() const; // managing project
FolderNode *parentFolderNode() const; // parent folder or project
QString path() const; // file system path
virtual int line() const;
virtual QString displayName() const;
virtual QString vcsTopic() const;
virtual QString tooltip() const;
virtual bool isEnabled() const;
void setPath(const QString &path); // this does not call emitNodeUpdated!
void emitNodeUpdated();
protected:
Node(NodeType nodeType, const QString &path);
......@@ -97,8 +101,6 @@ protected:
void setProjectNode(ProjectNode *project);
void setParentFolderNode(FolderNode *parentFolder);
void emitNodeUpdated();
private:
NodeType m_nodeType;
ProjectNode *m_projectNode;
......@@ -140,6 +142,9 @@ public:
void setDisplayName(const QString &name);
void setIcon(const QIcon &icon);
FileNode *findFile(const QString &path);
FolderNode *findSubFolder(const QString &path);
protected:
QList<FolderNode*> m_subFolderNodes;
QList<FileNode*> m_fileNodes;
......@@ -331,7 +336,6 @@ private:
friend class Node;
};
} // namespace ProjectExplorer
// HACK: THERE SHOULD BE ONE PLACE TO MAKE THE FILE ENDING->FILE TYPE ASSOCIATION
......
......@@ -40,6 +40,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icontext.h>
#include <utils/qtcassert.h>
......@@ -374,8 +375,11 @@ void ProjectTreeWidget::initView()
void ProjectTreeWidget::openItem(const QModelIndex &mainIndex)
{
Node *node = m_model->nodeForIndex(mainIndex);
if (node->nodeType() == FileNodeType)
EditorManager::openEditor(node->path(), Id(), EditorManager::ModeSwitch);
if (node->nodeType() != FileNodeType)
return;
IEditor *editor = EditorManager::openEditor(node->path(), Id(), EditorManager::ModeSwitch);
if (node->line() >= 0)
editor->gotoLine(node->line());
}
void ProjectTreeWidget::setProjectFilter(bool filter)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment