Skip to content

Commit

Permalink
GUI: Fix how the tree model handles opening a file
Browse files Browse the repository at this point in the history
We only want to add a top level item if we're opening a directory, not a file.
  • Loading branch information
fdde authored and DrMcCoy committed Dec 29, 2017
1 parent 52c8ebb commit ed452bb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/gui/resourcetree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ ResourceTree::~ResourceTree() {

void ResourceTree::setRootPath(const QString &path) {
_mainWindow->status()->push("Populating resource tree...");
ResourceTreeItem *top = new ResourceTreeItem(QFileInfo(path).canonicalFilePath(), _root);
_root->appendChild(top);

ResourceTreeItem *top = _root;
// If the root path is a directory, add a top level item
// with its name
auto info = QFileInfo(path);
if (info.isDir()) {
top = new ResourceTreeItem(info.canonicalFilePath(), _root);
_root->appendChild(top);
}

populate(path, top);

_mainWindow->status()->pop();
}

Expand Down

0 comments on commit ed452bb

Please sign in to comment.