Author: fredkiefer
Date: Sun Mar  8 23:23:06 2015
New Revision: 38387

URL: http://svn.gna.org/viewcvs/gnustep?rev=38387&view=rev
Log:
        * Source/NSCollectionView.m (-tile): Prevent _numberOfColumns
        from being 0.
        * Source/NSArrayController.m: Revert last change and add proper
        handling of arrangeObjects for many cases.
        * Source/NSCollectionViewItem.m: Fix reference counting. Add
        method -view to have something to display.

Modified:
    libs/gui/trunk/ChangeLog
    libs/gui/trunk/Source/NSArrayController.m
    libs/gui/trunk/Source/NSCollectionView.m
    libs/gui/trunk/Source/NSCollectionViewItem.m

Modified: libs/gui/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=38387&r1=38386&r2=38387&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog    (original)
+++ libs/gui/trunk/ChangeLog    Sun Mar  8 23:23:06 2015
@@ -1,3 +1,12 @@
+2015-03-08 Fred Kiefer <fredkie...@gmx.de>
+
+       * Source/NSCollectionView.m (-tile): Prevent _numberOfColumns from
+       being 0.
+       * Source/NSArrayController.m: Revert last change and add proper
+       handling of arrangeObjects for many cases.
+       * Source/NSCollectionViewItem.m: Fix reference counting. Add
+       method -view to have something to display.
+
 2015-03-08  Germán Arias <germanan...@gmx.es>
 
        * Source/NSPrinter.m (-loadPPDAtPath:symbolValues:inclusionSet:):

Modified: libs/gui/trunk/Source/NSArrayController.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSArrayController.m?rev=38387&r1=38386&r2=38387&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSArrayController.m   (original)
+++ libs/gui/trunk/Source/NSArrayController.m   Sun Mar  8 23:23:06 2015
@@ -48,6 +48,8 @@
   if (self == [NSArrayController class])
     {
       [self exposeBinding: NSContentArrayBinding];
+      [self setKeys: [NSArray arrayWithObjects: NSContentBinding, 
NSContentObjectBinding, nil] 
+            triggerChangeNotificationsForDependentKey: @"arrangedObjects"];
     }
 }
 
@@ -55,7 +57,6 @@
 {
   if ((self = [super initWithContent: content]) != nil)
     {
-      [self setAutomaticallyRearrangesObjects: YES];
       [self rearrangeObjects];
       [self setSelectsInsertedObjects: YES];
     }
@@ -83,42 +84,76 @@
 
 - (void) addObject: (id)obj
 {
+  [self willChangeValueForKey: NSContentBinding];
   [_content addObject: obj];
   if ([self automaticallyRearrangesObjects])
     {
       [self rearrangeObjects];
     }
+  else 
+    {
+      // FIXME: Should check whether _arranged_objects is mutable
+      ASSIGN(_arranged_objects, [_arranged_objects arrayByAddingObject: obj]);
+    }
+  if ([self selectsInsertedObjects])
+    {
+      [self addSelectedObjects: [NSArray arrayWithObject: obj]];
+    }
+  [self didChangeValueForKey: NSContentBinding];
 }
 
 - (void) addObjects: (NSArray*)obj
 {
+  [self willChangeValueForKey: NSContentBinding];
   [_content addObjectsFromArray: obj];
   if ([self automaticallyRearrangesObjects])
     {
       [self rearrangeObjects];
     }
+  else 
+    {
+      // FIXME: Should check whether _arranged_objects is mutable
+      ASSIGN(_arranged_objects, [_arranged_objects 
arrayByAddingObjectsFromArray: obj]);
+    }
   if ([self selectsInsertedObjects])
     {
       [self addSelectedObjects: obj];
     }
+  [self didChangeValueForKey: NSContentBinding];
 }
 
 - (void) removeObject: (id)obj
 {
+  [self willChangeValueForKey: NSContentBinding];
   [_content removeObject: obj];
+  [self removeSelectedObjects: [NSArray arrayWithObject: obj]];
   if ([self automaticallyRearrangesObjects])
     {
       [self rearrangeObjects];
     }
+  else 
+    {
+      // FIXME
+      //[_arranged_objects removeObject: obj];
+    }
+  [self didChangeValueForKey: NSContentBinding];
 }
 
 - (void) removeObjects: (NSArray*)obj
 {
+  [self willChangeValueForKey: NSContentBinding];
   [_content removeObjectsInArray: obj];
+  [self removeSelectedObjects: obj];
   if ([self automaticallyRearrangesObjects])
     {
       [self rearrangeObjects];
     }
+  else 
+    {
+      // FIXME
+      //[_arranged_objects removeObjectsInArray: obj];
+    }
+  [self didChangeValueForKey: NSContentBinding];
 }
 
 - (BOOL) canInsert
@@ -136,7 +171,7 @@
 {
   id new = [self newObject];
 
-  [_content addObject: new];
+  [self addObject: new];
   RELEASE(new);
 }
 
@@ -391,10 +426,10 @@
   [self removeObjects: [_arranged_objects objectsAtIndexes: idx]];
 }
 
-- (void)bind: (NSString *)binding 
-    toObject: (id)anObject
- withKeyPath: (NSString *)keyPath
-     options: (NSDictionary *)options
+- (void) bind: (NSString *)binding 
+     toObject: (id)anObject
+  withKeyPath: (NSString *)keyPath
+      options: (NSDictionary *)options
 {
   if ([binding isEqual: NSContentArrayBinding])
     {
@@ -441,6 +476,7 @@
       [coder encodeBool: [self selectsInsertedObjects] forKey: 
@"NSSelectsInsertedObjects"];
       [coder encodeBool: [self clearsFilterPredicateOnInsertion] forKey:
                @"NSClearsFilterPredicateOnInsertion"];
+      [coder encodeBool: [self automaticallyRearrangesObjects] forKey: 
@"NSAutomaticallyRearrangesObjects"];
     }
   else
     {
@@ -476,6 +512,11 @@
           [self setClearsFilterPredicateOnInsertion: 
                 [coder decodeBoolForKey: 
@"NSClearsFilterPredicateOnInsertion"]];
         }
+      if ([coder containsValueForKey: @"NSAutomaticallyRearrangesObjects"])
+        {
+          [self setAutomaticallyRearrangesObjects: 
+                [coder decodeBoolForKey: @"NSAutomaticallyRearrangesObjects"]];
+        }
     }
   else
     {

Modified: libs/gui/trunk/Source/NSCollectionView.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSCollectionView.m?rev=38387&r1=38386&r2=38387&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSCollectionView.m    (original)
+++ libs/gui/trunk/Source/NSCollectionView.m    Sun Mar  8 23:23:06 2015
@@ -522,10 +522,15 @@
   NSSize itemSize = NSMakeSize(_minItemSize.width, _minItemSize.height);
   
   _numberOfColumns = MAX(1.0, floor(width / itemSize.width));
-  
+
   if (_maxNumberOfColumns > 0)
     {
       _numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);
+    }
+
+  if (_numberOfColumns == 0)
+    {
+      _numberOfColumns = 1;
     }
   
   CGFloat remaining = width - _numberOfColumns * itemSize.width;

Modified: libs/gui/trunk/Source/NSCollectionViewItem.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSCollectionViewItem.m?rev=38387&r1=38386&r2=38387&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSCollectionViewItem.m        (original)
+++ libs/gui/trunk/Source/NSCollectionViewItem.m        Sun Mar  8 23:23:06 2015
@@ -88,10 +88,7 @@
 
 - (void) setTextField: (NSTextField *)aTextField
 {
-  if (textField != aTextField)
-    {
-      textField = aTextField;
-    }
+  ASSIGN(textField, aTextField);
 }
 
 - (NSImageView *) imageView
@@ -101,10 +98,14 @@
 
 - (void) setImageView: (NSImageView *)anImageView
 {
-  if (imageView != anImageView)
-    {
-      imageView = anImageView;
-    }
+  ASSIGN(imageView, anImageView);
+}
+
+- (NSView *) view
+{
+  // FIXME
+  [[self textField] setStringValue: [self representedObject]];
+  return [self textField];
 }
 
 - (id) initWithCoder: (NSCoder *)aCoder
@@ -114,13 +115,27 @@
     {
       if (YES == [aCoder allowsKeyedCoding])
        {
-         textField = [aCoder decodeObjectForKey: @"textField"];
-         imageView = [aCoder decodeObjectForKey: @"imageView"];
+          if ([aCoder containsValueForKey: @"textField"])
+            {
+              [self setTextField: [aCoder decodeObjectForKey: @"textField"]];
+            }
+          else
+            {
+              textField = [[NSTextField alloc] initWithFrame: NSMakeRect(0.0, 
0.0, 100.0, 20.0)];
+            }
+          if ([aCoder containsValueForKey: @"imageView"])
+            {
+              [self setImageView: [aCoder decodeObjectForKey: @"imageView"]];
+            }
+          else
+            {
+              imageView = [[NSImageView alloc] initWithFrame: NSMakeRect(0.0, 
0.0, 100.0, 100.0)];
+            }
        }
       else
        {
-         textField = [aCoder decodeObject];
-         imageView = [aCoder decodeObject];
+         [self setTextField: [aCoder decodeObject]];
+         [self setImageView: [aCoder decodeObject]];
        }
     }
   return self;


_______________________________________________
Gnustep-cvs mailing list
Gnustep-cvs@gna.org
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to