project items reading is working:

This commit is contained in:
Vadim Lopatin 2015-01-13 18:57:06 +03:00
parent 72dfdb74b8
commit 8552d03305
2 changed files with 26 additions and 4 deletions

View File

@ -2,6 +2,7 @@ module dlangide.ui.wspanel;
import dlangui.all;
import dlangide.workspace.workspace;
import dlangide.workspace.project;
class WorkspacePanel : VerticalLayout {
protected Workspace _workspace;
@ -21,6 +22,20 @@ class WorkspacePanel : VerticalLayout {
return _workspace;
}
void addProjectItems(TreeItem root, ProjectItem items) {
for (int i = 0; i < items.childCount; i++) {
ProjectItem child = items.child(i);
if (child.isFolder) {
TreeItem p = root.newChild(child.filename, child.name, "folder");
p.objectParam = child;
addProjectItems(p, child);
} else {
TreeItem p = root.newChild(child.filename, child.name, "text-plain");
p.objectParam = child;
}
}
}
@property void workspace(Workspace w) {
_workspace = w;
_tree.requestLayout();
@ -29,6 +44,7 @@ class WorkspacePanel : VerticalLayout {
TreeItem root = _tree.items.newChild(w.filename, w.name, "project-development");
foreach(project; w.projects) {
TreeItem p = root.newChild(project.filename, project.name, "project-open");
addProjectItems(p, project.items);
}
} else {
_tree.items.newChild("none", "New workspace"d, "project-development");

View File

@ -66,7 +66,7 @@ class ProjectFolder : ProjectItem {
}
@property override bool isFolder() {
return false;
return true;
}
@property override int childCount() {
return _children.count;
@ -78,13 +78,14 @@ class ProjectFolder : ProjectItem {
void addChild(ProjectItem item) {
_children.add(item);
item._parent = this;
item._project = this;
item._project = _project;
}
bool loadDir(string path) {
string src = relativeToAbsolutePath(path);
if (isDir(src) && exists(src)) {
if (exists(src) && isDir(src)) {
ProjectFolder dir = new ProjectFolder(src);
addChild(dir);
Log.d(" added project folder ", src);
dir.loadItems();
return true;
}
@ -92,9 +93,10 @@ class ProjectFolder : ProjectItem {
}
bool loadFile(string path) {
string src = relativeToAbsolutePath(path);
if (isFile(src) && exists(src)) {
if (exists(src) && isFile(src)) {
ProjectSourceFile f = new ProjectSourceFile(src);
addChild(f);
Log.d(" added project file ", src);
return true;
}
return false;
@ -196,6 +198,10 @@ class Project : WorkspaceItem {
return buildNormalizedPath(_dir, path);
}
@property ProjectFolder items() {
return _items;
}
@property Workspace workspace() {
return _workspace;
}