libede: renamed ExplorerFileBranch to FileSystemNode. also renamed all Branch to...
authorRejean Loyer <rejean.loyer@gmail.com>
Wed, 14 Sep 2011 04:53:42 +0000 (00:53 -0400)
committerRejean Loyer <rejean.loyer@gmail.com>
Wed, 14 Sep 2011 22:54:26 +0000 (18:54 -0400)
libede/src/FileSystemBox.ec

index 151df78..741fa74 100644 (file)
@@ -138,7 +138,6 @@ public enum ExplorerFileType
    }
 };
 
-#if 0
 class ExplorerControl : Window
 {
    bool previewPictures;
@@ -155,7 +154,6 @@ class ExplorerControl : Window
       }
    }
 }
-#endif
 
 #if 0
 class ExplorerView : ExplorerControl
@@ -164,7 +162,7 @@ class ExplorerView : ExplorerControl
    hasHorzScroll = false;
    hasVertScroll = false;
 
-   virtual void Load(ExplorerFileBranch parent);
+   virtual void Load(FileSystemNode parent);
    virtual void Refresh();
 
    virtual void LaunchNotifyItemSelect(Window master, ExplorerView view, ExplorerFileItem item, ExplorerFileItemArray selectedItems)
@@ -233,7 +231,7 @@ class ExplorerView : ExplorerControl
 class ExplorerViewList : ExplorerView
 {
 
-   ExplorerFileBranch location;
+   FileSystemNode location;
 
 public:
 
@@ -249,7 +247,7 @@ public:
       Load(location);
    }
 
-   void Load(ExplorerFileBranch location)
+   void Load(FileSystemNode location)
    {
       char path[MAX_LOCATION];
       this.location = location;
@@ -284,7 +282,7 @@ class ExplorerViewDetails : ExplorerView
    list.resizable = true;
    list.sortable = true;
 
-   ExplorerFileBranch location;
+   FileSystemNode location;
 
 public:
 
@@ -304,7 +302,7 @@ public:
       Load(location);
    }
 
-   void Load(ExplorerFileBranch location)
+   void Load(FileSystemNode location)
    {
       char path[MAX_LOCATION];
       this.location = location;
@@ -337,7 +335,7 @@ public:
 class ExplorerViewIcons : ExplorerView
 {
 
-   ExplorerFileBranch location;
+   FileSystemNode location;
 
 public:
 
@@ -353,7 +351,7 @@ public:
       Load(location);
    }
 
-   void Load(ExplorerFileBranch location)
+   void Load(FileSystemNode location)
    {
       char path[MAX_LOCATION];
       this.location = location;
@@ -384,7 +382,7 @@ public:
 class ExplorerViewCards : ExplorerView
 {
 
-   ExplorerFileBranch location;
+   FileSystemNode location;
 
 public:
 
@@ -400,7 +398,7 @@ public:
       Load(location);
    }
 
-   void Load(ExplorerFileBranch location)
+   void Load(FileSystemNode location)
    {
       char path[MAX_LOCATION];
       this.location = location;
@@ -466,7 +464,7 @@ class ExplorerViewShowcase : ExplorerView
    list.anchor = Anchor { left = 0, top = 0, bottom = 0 };
    list.size = Size { w = 200 };
 
-   ExplorerFileBranch location;
+   FileSystemNode location;
 
 public:
 
@@ -564,7 +562,7 @@ public:
       Load(location);
    }
 
-   void Load(ExplorerFileBranch location)
+   void Load(FileSystemNode location)
    {
       char path[MAX_LOCATION];
       this.location = location;
@@ -601,14 +599,14 @@ class ExplorerTree : ExplorerControl
 
 public:
 
-   DataField nameField { dataType = "ExplorerFileBranch", width = 240, userData = this };
+   DataField nameField { dataType = "FileSystemNode", width = 240, userData = this };
 
-   ExplorerFileBranch root;
-   ExplorerFileBranch selection;
+   FileSystemNode root;
+   FileSystemNode selection;
 
-   virtual bool Window::NotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch);
+   virtual bool Window::NotifyNodeSelect(ExplorerTree tree, FileSystemNode node);
    
-   property ExplorerFileBranch branch
+   property FileSystemNode node
    {
       get
       {
@@ -618,28 +616,28 @@ public:
             return null;
          if(!tree.currentRow.tag)
             return null;
-         return (ExplorerFileBranch)tree.currentRow.tag;
+         return (FileSystemNode)tree.currentRow.tag;
       }
    }
 
-   void Select(ExplorerFileBranch branch)
+   void Select(FileSystemNode node)
    {
-      if(branch.row)
+      if(node.row)
       {
-         branch.EnsureVisible(false);
-         tree.SelectRow(branch.row);
+         node.EnsureVisible(false);
+         tree.SelectRow(node.row);
       }
    }
 
-   ExplorerFileBranch Find(const char * name, ExplorerFileBranch parent)
+   FileSystemNode Find(const char * name, FileSystemNode parent)
    {
-      ExplorerFileBranch branch;
-      ExplorerFileBranch start = parent ? parent : root;
+      FileSystemNode node;
+      FileSystemNode start = parent ? parent : root;
       if(!start.loaded || !start.childrenLoaded)
-         BranchLoad(start, tree);
-      for(branch = start.children.first; branch; branch = branch.next)
-         if(branch.name && !strcmpi(branch.name, name))
-            return branch;
+         NodeLoad(start, tree);
+      for(node = start.children.first; node; node = node.next)
+         if(node.name && !strcmpi(node.name, name))
+            return node;
       return null;
    }
 
@@ -651,7 +649,7 @@ public:
       hasHorzScroll = true;
       hasVertScroll = true;
       fullRowSelect = false;
-      treeBranches = true;
+      treeNodees = true;
       collapseControl = true;
       rootCollapseButton = true;
 
@@ -670,25 +668,25 @@ public:
       {
          if(row)
          {
-            ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
-            ExplorerFileBranch child;
+            FileSystemNode node = (FileSystemNode)row.tag;
+            FileSystemNode child;
             if(collapsed)
             {
                /*
-               for(child = branch.children.last; child; child = branch.children.last)
+               for(child = node.children.last; child; child = node.children.last)
                {
                   listBox.DeleteRow(child.row);
                   child.Free();
                   delete child;
                }
-               branch.childrenLoaded = false;
+               node.childrenLoaded = false;
                */
             }
             else
             {
-               if(!branch.loaded || !branch.childrenLoaded)
-                  BranchLoad(branch, tree);
-               for(child = branch.children.first; child && child.next; child = child.next);
+               if(!node.loaded || !node.childrenLoaded)
+                  NodeLoad(node, tree);
+               for(child = node.children.first; child && child.next; child = child.next);
                if(child)
                   child.EnsureVisible(false);
             }
@@ -701,8 +699,8 @@ public:
          DataRow row = listBox.currentRow;
          if(row)
          {
-            ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
-            if(branch)
+            FileSystemNode node = (FileSystemNode)row.tag;
+            if(node)
             {
                PopupMenu popup;
                Menu menu { };
@@ -730,9 +728,9 @@ public:
       {
          if(row)
          {
-            ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
-            NotifyBranchSelect(listBox.parent.master, this, branch);
-            selection = branch;
+            FileSystemNode node = (FileSystemNode)row.tag;
+            NotifyNodeSelect(listBox.parent.master, this, node);
+            selection = node;
          }
          return true;
       }
@@ -741,7 +739,7 @@ public:
       {
          if(row)
          {
-            ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
+            FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -750,7 +748,7 @@ public:
       {
          if(row)
          {
-            ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
+            FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -759,7 +757,7 @@ public:
       {
          if(row)
          {
-            ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
+            FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -822,19 +820,19 @@ public:
 
    void Load()
    {
-      ExplorerFileBranch parent;
-      ExplorerFileBranch branch;
+      FileSystemNode parent;
+      FileSystemNode node;
       FileListing listing { "/" };
 
       tree.Clear();
 
-      root = ExplorerFileBranch { type = computer, loaded = true, childrenLoaded = true };
+      root = FileSystemNode { type = computer, loaded = true, childrenLoaded = true };
    #ifdef __WIN32__
       root.name = rootName;
    #else
       root.name = "/";
    #endif
-      AddBranch(root, true, false, null, tree);
+      AddNode(root, true, false, null, tree);
 
    // How can this make sense for linux? 
    #ifdef __WIN32__
@@ -857,18 +855,18 @@ public:
             info[0] = 0;
          }
 
-         parent = MakeFileBranch(listing.stats, name);
+         parent = MakeFileNode(listing.stats, name);
          if(info[0])
             parent.info = CopyString(info);
          parent.loaded = true;
-         AddBranch(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root, tree);
+         AddNode(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root, tree);
          if(!listing.stats.attribs.isDirectory)
             parent.childrenLoaded = true;
       }
 
-      branch = ExplorerFileBranch { name = msNetwork, type = network };
-      AddBranch(branch, false, true, null, tree);
-      branch.row.collapsed = true;
+      node = FileSystemNode { name = msNetwork, type = network };
+      AddNode(node, false, true, null, tree);
+      node.row.collapsed = true;
       tree.Sort(nameField, 1);
       tree.SelectRow(root.row);
    #endif
@@ -961,12 +959,12 @@ End If
 #endif
 
 #if 0
-public class FileTreeBranchBSArray : ArrayBinarySorted
+public class FileTreeNodeBSArray : ArrayBinarySorted
 {
-   type = class(ExplorerFileBranch);
+   type = class(FileSystemNode);
 public:
-   ExplorerFileBranch * const _;
-   BSloc Add(ExplorerFileBranch item)
+   FileSystemNode * const _;
+   BSloc Add(FileSystemNode item)
    {
       BSloc result = Find(item);
       if(!result.valid)
@@ -976,7 +974,7 @@ public:
       }
       return result;
    }
-   BSloc Remove(ExplorerFileBranch item)
+   BSloc Remove(FileSystemNode item)
    {
       
    }
@@ -984,19 +982,19 @@ public:
 #endif
 
 #if 0
-public class FileTreeBranchArray : RedjArray
+public class FileTreeNodeArray : RedjArray
 {
-   type = class(ExplorerFileBranch);
+   type = class(FileSystemNode);
 public:
-   ExplorerFileBranch * const _;
-   ExplorerFileBranch * Add(ExplorerFileBranch item)
+   FileSystemNode * const _;
+   FileSystemNode * Add(FileSystemNode item)
    {
       uint pos = _count;
       Append(1);
       _[pos] = item;
       return &_[pos];
    }
-   ExplorerFileBranch * AddBefore(uint position, ExplorerFileBranch item)
+   FileSystemNode * AddBefore(uint position, FileSystemNode item)
    {
       Insert(position, 1);
       _[position] = item;
@@ -1215,10 +1213,9 @@ ExplorerFileItem MakeFileItem(const FileAttribs attribs, const char * fileName,
 }
 #endif
 
-#if 0
-public class ExplorerFileBranch : struct
+public class FileSystemNode : struct
 {
-   ExplorerFileBranch prev, next;
+   FileSystemNode prev, next;
 
    bool loaded, childrenLoaded;
    int indent;
@@ -1227,13 +1224,13 @@ public class ExplorerFileBranch : struct
    DataRow row;
    OldList children;
    ExplorerFileType type;
-   ExplorerFileBranch parent;
+   FileSystemNode parent;
 
    FileStats stats;
 
    void GetPath(String outputPath)
    {  
-      ExplorerFileBranch up;
+      FileSystemNode up;
       if(parent)
       {
          strcpy(outputPath, name);
@@ -1254,27 +1251,27 @@ public class ExplorerFileBranch : struct
 
    }
 
-   bool IsChildOf(ExplorerFileBranch branch)
+   bool IsChildOf(FileSystemNode node)
    {
-      ExplorerFileBranch test;
+      FileSystemNode test;
       for(test = parent; test; test = test.parent)
-         if(test == branch)
+         if(test == node)
             return true;
       return false;
    }
 
-   void DuplicateChildren(bool recursive, bool forceExpanded, ExplorerFileBranch addTo, ListBox tree)
+   void DuplicateChildren(bool recursive, bool forceExpanded, FileSystemNode addTo, ListBox tree)
    {
       if(children.first)
       {
-         ExplorerFileBranch child;
+         FileSystemNode child;
          
          for(child = children.first; child; child = child.next)
          {
-            ExplorerFileBranch copy { };
+            FileSystemNode copy { };
             copy.name = CopyString(child.name);
             copy.type = child.type;
-            AddBranch(copy, child.loaded, false, addTo, tree);
+            AddNode(copy, child.loaded, false, addTo, tree);
             if(forceExpanded)
                copy.row.collapsed = false;
             if(recursive)
@@ -1299,7 +1296,7 @@ public class ExplorerFileBranch : struct
 
    void Free()
    {
-      ExplorerFileBranch child;
+      FileSystemNode child;
       for(; (child = children.first); )
       {
          child.Free();
@@ -1398,7 +1395,7 @@ public class ExplorerFileBranch : struct
       }
    }
 
-   int OnCompare(ExplorerFileBranch b)
+   int OnCompare(FileSystemNode b)
    {
       int result;
       if(type == b.type || (type < folder && b.type < folder) || (type >= drive))
@@ -1417,104 +1414,104 @@ public class ExplorerFileBranch : struct
    }
 };
 
-ExplorerFileBranch MakeFileBranch(const FileStats stats, const char * name)
+FileSystemNode MakeFileNode(const FileStats stats, const char * name)
 {
-   ExplorerFileBranch fileTreeBranch { stats = stats };
-   fileTreeBranch.name = CopyString(name);
-   if(!fileTreeBranch.name)
-      fileTreeBranch.name = null;
+   FileSystemNode fileTreeNode { stats = stats };
+   fileTreeNode.name = CopyString(name);
+   if(!fileTreeNode.name)
+      fileTreeNode.name = null;
    if(stats.attribs.isDirectory)
    {
-      fileTreeBranch.type = (stats.attribs.isDrive) ? drive : folder;
-      if(stats.attribs.isServer) fileTreeBranch.type = server;
-      if(stats.attribs.isShare) fileTreeBranch.type = share;
-      if(stats.attribs.isCDROM) fileTreeBranch.type = cdrom;
-      if(stats.attribs.isRemote) fileTreeBranch.type = netDrive;
+      fileTreeNode.type = (stats.attribs.isDrive) ? drive : folder;
+      if(stats.attribs.isServer) fileTreeNode.type = server;
+      if(stats.attribs.isShare) fileTreeNode.type = share;
+      if(stats.attribs.isCDROM) fileTreeNode.type = cdrom;
+      if(stats.attribs.isRemote) fileTreeNode.type = netDrive;
       if(stats.attribs.isRemovable) 
       {
          if(name[0] == 'A' || name[0] == 'B')
-            fileTreeBranch.type = floppy;
+            fileTreeNode.type = floppy;
          else
-            fileTreeBranch.type = removable;
+            fileTreeNode.type = removable;
       }
    }
    else
    {
       char extension[MAX_EXTENSION];
-      GetExtension(fileTreeBranch.name, extension);
-      fileTreeBranch.type = ExplorerFileType::SelectByExtension(extension);
+      GetExtension(fileTreeNode.name, extension);
+      fileTreeNode.type = ExplorerFileType::SelectByExtension(extension);
    }
-   return fileTreeBranch;
+   return fileTreeNode;
 }
 
-void AddBranch(ExplorerFileBranch branch, bool loaded, bool addLoader, ExplorerFileBranch addTo, ListBox tree)
+void AddNode(FileSystemNode node, bool loaded, bool addLoader, FileSystemNode addTo, ListBox tree)
 {
    DataRow row = (addTo && addTo.row) ? addTo.row.AddRow() : tree.AddRow();
    if(addTo)
    {
-      branch.parent = addTo;
-      branch.indent = addTo.indent + 1;
-      addTo.children.Add(branch);
+      node.parent = addTo;
+      node.indent = addTo.indent + 1;
+      addTo.children.Add(node);
    }
-   row.tag = (int)branch;
-   branch.row = row;
-   row.SetData(null, branch);
+   row.tag = (int)node;
+   node.row = row;
+   row.SetData(null, node);
 
-   branch.loaded = loaded;
+   node.loaded = loaded;
    if(addLoader)
-      //AddBranch(ExplorerFileBranch { }, false, false, branch, tree); // why would this create a compile error?
-      AddBranch(ExplorerFileBranch { type = none }, false, false, branch, tree);
+      //AddNode(FileSystemNode { }, false, false, node, tree); // why would this create a compile error?
+      AddNode(FileSystemNode { type = none }, false, false, node, tree);
 
-   if(branch.indent > 0)
+   if(node.indent > 0)
       row.collapsed = true;
-   else if(branch.type == folder)
-      branch.type = folderOpen;
+   else if(node.type == folder)
+      node.type = folderOpen;
 }
 
-void BranchLoad(ExplorerFileBranch branch, ListBox tree)
+void NodeLoad(FileSystemNode node, ListBox tree)
 {
-   if(!branch.loaded)
+   if(!node.loaded)
    {
       char path[MAX_LOCATION];
-      branch.GetPath(path);
+      node.GetPath(path);
       {
          FileListing listing { path };
-         if(branch.children.count == 1)
-         DeleteBranch(branch.children.first, tree);
+         if(node.children.count == 1)
+         DeleteNode(node.children.first, tree);
 
          while(listing.Find())
          {
             if(listing.stats.attribs.isDirectory)
             {
-               ExplorerFileBranch child = MakeFileBranch(listing.stats, listing.name);
-               AddBranch(child, true, false, branch, tree);
-               BranchChildLoad(child, branch, tree);
+               FileSystemNode child = MakeFileNode(listing.stats, listing.name);
+               AddNode(child, true, false, node, tree);
+               NodeChildLoad(child, node, tree);
             }
          }
       }
-      branch.childrenLoaded = true;
-      branch.loaded = true;
-      branch.row.SortSubRows(false);
+      node.childrenLoaded = true;
+      node.loaded = true;
+      node.row.SortSubRows(false);
    }
-   else if(!branch.childrenLoaded)
+   else if(!node.childrenLoaded)
    {
-      ExplorerFileBranch child;
-      if(branch.children.first)
+      FileSystemNode child;
+      if(node.children.first)
       {
-         for(child = branch.children.first; child; child = child.next)
+         for(child = node.children.first; child; child = child.next)
          {
             if(!child.loaded)
-               BranchLoad(child, tree);
+               NodeLoad(child, tree);
             else if(!child.childrenLoaded)
-               BranchChildLoad(child, branch, tree);
+               NodeChildLoad(child, node, tree);
          }
-         branch.childrenLoaded = true;
-         branch.row.SortSubRows(false);
+         node.childrenLoaded = true;
+         node.row.SortSubRows(false);
       }
    }
 }
 
-static void BranchChildLoad(ExplorerFileBranch parent, ExplorerFileBranch branch, ListBox tree)
+static void NodeChildLoad(FileSystemNode parent, FileSystemNode node, ListBox tree)
 {
    char path[MAX_LOCATION];
    parent.GetPath(path);
@@ -1525,8 +1522,8 @@ static void BranchChildLoad(ExplorerFileBranch parent, ExplorerFileBranch branch
       {
          if(listing.stats.attribs.isDirectory)
          {
-            ExplorerFileBranch child = MakeFileBranch(listing.stats, listing.name);
-            AddBranch(child, true, false, parent, tree);
+            FileSystemNode child = MakeFileNode(listing.stats, listing.name);
+            AddNode(child, true, false, parent, tree);
             added = true;
          }
       }
@@ -1536,12 +1533,11 @@ static void BranchChildLoad(ExplorerFileBranch parent, ExplorerFileBranch branch
    //parent.childrenLoaded = true;
 }
 
-void DeleteBranch(ExplorerFileBranch branch, ListBox tree)
+void DeleteNode(FileSystemNode node, ListBox tree)
 {
-   ExplorerFileBranch child;
-   for(; (child = branch.children.first); )
-      DeleteBranch(child, tree);
-   tree.DeleteRow(branch.row);
-   branch.Delete();
+   FileSystemNode child;
+   for(; (child = node.children.first); )
+      DeleteNode(child, tree);
+   tree.DeleteRow(node.row);
+   node.Delete();
 }
-#endif