forked from qt-creator/qt-creator
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: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -62,12 +62,13 @@ using namespace ProjectExplorer;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Node::Node(NodeType nodeType,
|
Node::Node(NodeType nodeType,
|
||||||
const QString &filePath)
|
const QString &filePath, int line)
|
||||||
: QObject(),
|
: QObject(),
|
||||||
m_nodeType(nodeType),
|
m_nodeType(nodeType),
|
||||||
m_projectNode(0),
|
m_projectNode(0),
|
||||||
m_folderNode(0),
|
m_folderNode(0),
|
||||||
m_path(filePath)
|
m_path(filePath),
|
||||||
|
m_line(line)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -105,6 +106,28 @@ void Node::setPath(const QString &path)
|
|||||||
emitNodeUpdated();
|
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
|
NodeType Node::nodeType() const
|
||||||
{
|
{
|
||||||
return m_nodeType;
|
return m_nodeType;
|
||||||
@@ -189,8 +212,8 @@ void Node::setParentFolderNode(FolderNode *parentFolder)
|
|||||||
|
|
||||||
FileNode::FileNode(const QString &filePath,
|
FileNode::FileNode(const QString &filePath,
|
||||||
const FileType fileType,
|
const FileType fileType,
|
||||||
bool generated)
|
bool generated, int line)
|
||||||
: Node(FileNodeType, filePath),
|
: Node(FileNodeType, filePath, line),
|
||||||
m_fileType(fileType),
|
m_fileType(fileType),
|
||||||
m_generated(generated)
|
m_generated(generated)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,16 +83,18 @@ public:
|
|||||||
ProjectNode *projectNode() const; // managing project
|
ProjectNode *projectNode() const; // managing project
|
||||||
FolderNode *parentFolderNode() const; // parent folder or project
|
FolderNode *parentFolderNode() const; // parent folder or project
|
||||||
QString path() const; // file system path
|
QString path() const; // file system path
|
||||||
virtual int line() const;
|
int line() const;
|
||||||
virtual QString displayName() const;
|
virtual QString displayName() const;
|
||||||
virtual QString tooltip() const;
|
virtual QString tooltip() const;
|
||||||
virtual bool isEnabled() const;
|
virtual bool isEnabled() const;
|
||||||
|
|
||||||
void setPath(const QString &path);
|
void setPath(const QString &path);
|
||||||
|
void setLine(int line);
|
||||||
|
void setPathAndLine(const QString &path, int line);
|
||||||
void emitNodeUpdated();
|
void emitNodeUpdated();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Node(NodeType nodeType, const QString &path);
|
Node(NodeType nodeType, const QString &path, int line = -1);
|
||||||
|
|
||||||
void setNodeType(NodeType type);
|
void setNodeType(NodeType type);
|
||||||
void setProjectNode(ProjectNode *project);
|
void setProjectNode(ProjectNode *project);
|
||||||
@@ -106,12 +108,13 @@ private:
|
|||||||
ProjectNode *m_projectNode;
|
ProjectNode *m_projectNode;
|
||||||
FolderNode *m_folderNode;
|
FolderNode *m_folderNode;
|
||||||
QString m_path;
|
QString m_path;
|
||||||
|
int m_line;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT FileNode : public Node {
|
class PROJECTEXPLORER_EXPORT FileNode : public Node {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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;
|
FileType fileType() const;
|
||||||
bool isGenerated() const;
|
bool isGenerated() const;
|
||||||
|
|||||||
@@ -222,18 +222,12 @@ public:
|
|||||||
|
|
||||||
QbsFileNode::QbsFileNode(const QString &filePath, const ProjectExplorer::FileType fileType,
|
QbsFileNode::QbsFileNode(const QString &filePath, const ProjectExplorer::FileType fileType,
|
||||||
bool generated, int line) :
|
bool generated, int line) :
|
||||||
ProjectExplorer::FileNode(filePath, fileType, generated),
|
ProjectExplorer::FileNode(filePath, fileType, generated, line)
|
||||||
m_line(line)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void QbsFileNode::setLine(int l)
|
|
||||||
{
|
|
||||||
m_line = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QbsFileNode::displayName() const
|
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)
|
bool QbsFileNode::update(const qbs::CodeLocation &loc)
|
||||||
@@ -241,8 +235,7 @@ bool QbsFileNode::update(const qbs::CodeLocation &loc)
|
|||||||
const QString oldPath = path();
|
const QString oldPath = path();
|
||||||
const int oldLine = line();
|
const int oldLine = line();
|
||||||
|
|
||||||
setPath(loc.fileName());
|
setPathAndLine(loc.fileName(), loc.line());
|
||||||
setLine(loc.line());
|
|
||||||
return (line() != oldLine || path() != oldPath);
|
return (line() != oldLine || path() != oldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,16 +55,10 @@ class QbsFileNode : public ProjectExplorer::FileNode
|
|||||||
public:
|
public:
|
||||||
QbsFileNode(const QString &filePath, const ProjectExplorer::FileType fileType, bool generated,
|
QbsFileNode(const QString &filePath, const ProjectExplorer::FileType fileType, bool generated,
|
||||||
int line);
|
int line);
|
||||||
int line() const { return m_line; }
|
|
||||||
|
|
||||||
void setLine(int l);
|
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
|
||||||
bool update(const qbs::CodeLocation &loc);
|
bool update(const qbs::CodeLocation &loc);
|
||||||
|
|
||||||
private:
|
|
||||||
int m_line;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user