Commit 27a24174 authored by dt's avatar dt
Browse files

Fix currentNode beeing invalid. The ProjecTreeWidget takes care of that.

parent 738ef0b1
......@@ -119,6 +119,13 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent)
m_autoSync(false)
{
m_model = new FlatModel(m_explorer->session()->sessionNode(), this);
NodesWatcher *watcher = new NodesWatcher(this);
m_explorer->session()->sessionNode()->registerWatcher(watcher);
connect(watcher, SIGNAL(foldersAboutToBeRemoved(FolderNode *, const QList<FolderNode*> &)),
this, SLOT(foldersAboutToBeRemoved(FolderNode *, const QList<FolderNode*> &)));
connect(watcher, SIGNAL(filesAboutToBeRemoved(FolderNode *, const QList<FileNode*> &)),
this, SLOT(filesAboutToBeRemoved(FolderNode *, const QList<FileNode*> &)));
m_view = new ProjectTreeView;
m_view->setModel(m_model);
......@@ -165,6 +172,29 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent)
setAutoSynchronization(true);
}
void ProjectTreeWidget::foldersAboutToBeRemoved(FolderNode *, const QList<FolderNode*> &list)
{
Node *n = m_explorer->currentNode();
while(n) {
if (FolderNode *fn = qobject_cast<FolderNode *>(n)) {
if (list.contains(fn)) {
m_explorer->setCurrentNode(n->projectNode());
break;
}
}
n = n->parentFolderNode();
}
}
void ProjectTreeWidget::filesAboutToBeRemoved(FolderNode *, const QList<FileNode*> &list)
{
if (FileNode *fileNode = qobject_cast<FileNode *>(m_explorer->currentNode())) {
if (list.contains(fileNode)) {
m_explorer->setCurrentNode(fileNode->projectNode());
}
}
}
QToolButton *ProjectTreeWidget::toggleSync()
{
return m_toggleSync;
......
......@@ -40,6 +40,8 @@ namespace ProjectExplorer {
class ProjectExplorerPlugin;
class Project;
class Node;
class FolderNode;
class FileNode;
namespace Internal {
......@@ -73,6 +75,9 @@ private slots:
void startupProjectChanged(ProjectExplorer::Project *project);
void initView();
void foldersAboutToBeRemoved(FolderNode *, const QList<FolderNode*> &);
void filesAboutToBeRemoved(FolderNode *, const QList<FileNode*> &);
private:
ProjectExplorerPlugin *m_explorer;
QTreeView *m_view;
......
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