Ivan Vučica avatar Ivan Vučica committed af27f5c

Fixed XML tree in GNUstep not being the same as under Cocoa by explicitly operating just with '<outline>' nodes.

Comments (0)

Files changed (2)

OPML/OPMLDocument.m

     if([_outlineView isItemExpanded:selectedElement])
     {
         // create a child node
-    	newItem = [_outline insertNewChildNodeOf:selectedElement];
+        newItem = [_outline insertNewChildNodeOf:selectedElement];
     }
     else
     {

OPML/OPMLOutline+ViewRelated.m

     if(!item)
     {
         // own child count
-        NSLog(@"Root children %ld", [[self bodyNode] childCount]);
-        return [[self bodyNode] childCount];
+        NSLog(@"Root children %ld", [[[self bodyNode] nodesForXPath:@"./outline" error:nil] count]);
+        return [[[self bodyNode] nodesForXPath:@"./outline" error:nil] count];
     }
     
     if([item isKindOfClass:[OPMLOutlineXMLElement class]])
         OPMLOutlineXMLElement * xmlItem = (OPMLOutlineXMLElement*)item;
         
         NSString * xmlItemType = [[xmlItem attributeForName:@"type"] stringValue];
-        NSLog(@"type %@", xmlItemType);
+
         if([xmlItemType isEqualToString:@"include"])
         {
             if(![[xmlItem attributeForName:@"url"] stringValue])
             {
                 // no url? it's not an inclusion.
                 // just return the number of locally-stored children.
-                return [xmlItem childCount];
+                return [[xmlItem nodesForXPath:@"./outline" error:nil] count];
             }
             // otherwise load the outline, assign it to the
             // node, and return the number of children in included outline.
             else
             {
                 // we have not loaded the outline ok, so return local children
-                return [xmlItem childCount];
+                return [[xmlItem nodesForXPath:@"./outline" error:nil] count];
             }
         }
         else
         {
+        #if !GNUSTEP
             return [xmlItem childCount];
+        #else
+            return [[xmlItem nodesForXPath:@"./outline" error:nil] count];
+        #endif
         }
     }
     
     if(!item)
     {
         // root body node
-        return [[self bodyNode] childAtIndex:index];
+        return [[[self bodyNode] nodesForXPath:@"./outline" error:nil] objectAtIndex:index];
     }
     
     if([item isKindOfClass:[OPMLOutlineXMLElement class]])
         if(includedOutline) // ask outline about its root node's child
             return [includedOutline outlineView:outlineView child:index ofItem:nil];
         
-        return [xmlItem childAtIndex:index];
+        return [[xmlItem nodesForXPath:@"./outline" error:nil] objectAtIndex:index];
     }
     
     return nil;
         
         return [[element attributeForName:@"text"] stringValue];
     }
-    return item;
+    return nil;
 }
 
 - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
 {
     if ([item isKindOfClass:[OPMLOutlineXMLElement class]]) {
         OPMLOutlineXMLElement * element = (OPMLOutlineXMLElement*)item;
+#if !GNUSTEP
         if([element rootDocument] == _xmlDocument)
+#endif
         {
             [[element attributeForName:@"text"] setStringValue:object];
         }
 
 -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
 {
-    if([item isKindOfClass:[NSXMLElement class]])
+    if([item isKindOfClass:[OPMLOutlineXMLElement class]])
     {
+#if !GNUSTEP
         if ([item rootDocument] == _xmlDocument)
+#endif
         {
             return YES;
         }
-        
         return NO;
     }
     return NO;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.