Commit d4ad2693 authored by Daniel Teske's avatar Daniel Teske
Browse files

ProjectExplorer::Node::line should be a property not a virtual function



Changing it must emit the same signals as does setting path, since the
sorting might change.

Change-Id: Iaf29c0775387d623d2e611e202b63ab52e812140
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 23c6a424
......@@ -62,12 +62,13 @@ using namespace ProjectExplorer;
*/
Node::Node(NodeType nodeType,
const QString &filePath)
const QString &filePath, int line)
: QObject(),
m_nodeType(nodeType),
m_projectNode(0),
m_folderNode(0),
m_path(filePath)
m_path(filePath),
m_line(line)
{
}
......@@ -105,6 +106,28 @@ void Node::setPath(const QString &path)
emitNodeUpdated();
}
void Node::setLine(int line)
{
if (m_line == line)
return;
emitNodeSortKeyAboutToChange();
m_line = line;
emitNodeSortKeyChanged();
emitNodeUpdated();
}
void Node::setPathAndLine(const QString &path, int line)
{
if (m_path == path
&& m_line == line)
return;
emitNodeSortKeyAboutToChange();
m_path = path;
m_line = line;
emitNodeSortKeyChanged();
emitNodeUpdated();
}
NodeType Node::nodeType() const
{
return m_nodeType;
......@@ -189,8 +212,8 @@ void Node::setParentFolderNode(FolderNode *parentFolder)
FileNode::FileNode(const QString &filePath,
const FileType fileType,
bool generated)
: Node(FileNodeType, filePath),
bool generated, int line)
: Node(FileNodeType, filePath, line),
m_fileType(fileType),
m_generated(generated)
{
......
......@@ -83,16 +83,18 @@ public:
ProjectNode *projectNode() const; // managing project
FolderNode *parentFolderNode() const; // parent folder or project
QString path() const; // file system path
virtual int line() const;
int line() const;
virtual QString displayName() const;
virtual QString tooltip() const;
virtual bool isEnabled() const;
void setPath(const QString &path);
void setLine(int line);
void setPathAndLine(const QString &path, int line);
void emitNodeUpdated();
protected:
Node(NodeType nodeType, const QString &path);
Node(NodeType nodeType, const QString &path, int line = -1);
void setNodeType(NodeType type);
void setProjectNode(ProjectNode *project);
......@@ -106,12 +108,13 @@ private:
ProjectNode *m_projectNode;
FolderNode *m_folderNode;
QString m_path;
int m_line;
};
class PROJECTEXPLORER_EXPORT FileNode : public Node {
Q_OBJECT
public:
FileNode(const QString &filePath, const FileType fileType, bool generated);
FileNode(const QString &filePath, const FileType fileType, bool generated, int line = -1);
FileType fileType() const;
bool isGenerated() const;
......
......@@ -222,18 +222,12 @@ public:
QbsFileNode::QbsFileNode(const QString &filePath, const ProjectExplorer::FileType fileType,
bool generated, int line) :
ProjectExplorer::FileNode(filePath, fileType, generated),
m_line(line)
ProjectExplorer::FileNode(filePath, fileType, generated, line)
{ }
void QbsFileNode::setLine(int l)
{
m_line = l;
}
QString QbsFileNode::displayName() const
{
return ProjectExplorer::FileNode::displayName() + QLatin1Char(':') + QString::number(m_line);
return ProjectExplorer::FileNode::displayName() + QLatin1Char(':') + QString::number(line());
}
bool QbsFileNode::update(const qbs::CodeLocation &loc)
......@@ -241,8 +235,7 @@ bool QbsFileNode::update(const qbs::CodeLocation &loc)
const QString oldPath = path();
const int oldLine = line();
setPath(loc.fileName());
setLine(loc.line());
setPathAndLine(loc.fileName(), loc.line());
return (line() != oldLine || path() != oldPath);
}
......
......@@ -55,16 +55,10 @@ class QbsFileNode : public ProjectExplorer::FileNode
public:
QbsFileNode(const QString &filePath, const ProjectExplorer::FileType fileType, bool generated,
int line);
int line() const { return m_line; }
void setLine(int l);
QString displayName() const;
bool update(const qbs::CodeLocation &loc);
private:
int m_line;
};
// ---------------------------------------------------------------------------
......
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