From 8e27496a68c5a5e775c11199d2dfbaf665bd9843 Mon Sep 17 00:00:00 2001 From: relikd Date: Fri, 3 Aug 2018 00:25:21 +0200 Subject: [PATCH] aaaand, its gone. nothing works, this stupid arrangedObjects is always empty at init. --- baRSS/AppDelegate.h | 1 - baRSS/AppDelegate.m | 6 --- baRSS/Base.lproj/Main.xib | 13 +++--- baRSS/NewsController.m | 90 --------------------------------------- baRSS/Preferences.m | 40 ++++++++--------- 5 files changed, 25 insertions(+), 125 deletions(-) diff --git a/baRSS/AppDelegate.h b/baRSS/AppDelegate.h index a242d42..f02b188 100644 --- a/baRSS/AppDelegate.h +++ b/baRSS/AppDelegate.h @@ -25,6 +25,5 @@ @interface AppDelegate : NSObject @property (readonly, strong) NSPersistentContainer *persistentContainer; -- (IBAction)quitClicked:(id)sender; @end diff --git a/baRSS/AppDelegate.m b/baRSS/AppDelegate.m index 7533236..9657914 100644 --- a/baRSS/AppDelegate.m +++ b/baRSS/AppDelegate.m @@ -30,10 +30,6 @@ @implementation AppDelegate -- (IBAction)quitClicked:(id)sender { - [NSApplication.sharedApplication terminate:self]; -} - - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.statusItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength]; self.statusItem.title = @"me"; @@ -43,8 +39,6 @@ printf("done\n"); } - - - (void)applicationWillTerminate:(NSNotification *)aNotification { [PyHandler shutdown]; } diff --git a/baRSS/Base.lproj/Main.xib b/baRSS/Base.lproj/Main.xib index e0180dd..0b6f211 100644 --- a/baRSS/Base.lproj/Main.xib +++ b/baRSS/Base.lproj/Main.xib @@ -22,10 +22,7 @@ - - - @@ -67,7 +64,7 @@ - + @@ -413,7 +410,6 @@ - @@ -437,6 +433,8 @@ + n + @@ -449,6 +447,9 @@ + +CA + @@ -472,6 +473,8 @@ + g + diff --git a/baRSS/NewsController.m b/baRSS/NewsController.m index 9500dc2..5c62c5e 100644 --- a/baRSS/NewsController.m +++ b/baRSS/NewsController.m @@ -27,12 +27,8 @@ @interface NewsController () @property (weak) IBOutlet NSOutlineView *outlineView; -@property (weak) IBOutlet NSMenuItem *pauseItem; -@property (weak) IBOutlet NSMenuItem *updateAllItem; -@property (weak) IBOutlet NSMenuItem *openUnreadItem; @property (strong) NSArray *currentlyDraggedNodes; -@property (strong) NSMutableSet *expandedItems; @end @implementation NewsController @@ -42,36 +38,11 @@ static NSString *dragNodeType = @"baRSS-feed-type"; - (void)awakeFromNib { [super awakeFromNib]; - self.expandedItems = [NSMutableSet set]; - NSArray *storedExpansions = [[NSUserDefaults standardUserDefaults] arrayForKey:@"pups"]; - NSLog(@"%lu", storedExpansions.count); - for (NSString *str in storedExpansions) { - if (str.length == 0) - continue; - NSIndexPath *path = [NSIndexPath new]; - for (NSString *idx in [str componentsSeparatedByString:@","]) { - path = [path indexPathByAddingIndex:(NSUInteger)[idx integerValue]]; - } - NSLog(@"%@", path); - } - NSLog(@"%@", self.arrangedObjects.childNodes); -// [self.expandedItems bind:NSContentArrayBinding toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:@"values.pups" options:nil]; -// [self.expandedItems addObject:[self indexPathToString:[NSIndexPath indexPathWithIndex:4]]]; -// self.expandedItems = [NSMutableSet set]; -// [self.expandedItems bind:@"values" toObject:[NSUserDefaults standardUserDefaults] -// withKeyPath:@"extensio" options:@{ NSContinuouslyUpdatesValueBindingOption : @YES, -// NSRaisesForNotApplicableKeysBindingOption : @YES -// }]; -// [self.expandedItems addObject:[NSIndexPath indexPathWithIndex:4]]; - - - // Set the outline view to accept the custom drag type AbstractTreeNodeType... [self.outlineView registerForDraggedTypes:[NSArray arrayWithObject:dragNodeType]]; [self setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:YES]]]; } - - (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item { // this delegate method is only here to set owner to null and prohibit repeated awakeFromNib calls return [self.outlineView makeViewWithIdentifier:tableColumn.identifier owner:nil]; @@ -180,67 +151,6 @@ static NSString *dragNodeType = @"baRSS-feed-type"; } } -- (NSString*)indexPathToString:(NSIndexPath*)path { - NSMutableString *mStr = [NSMutableString string]; - for (NSUInteger i = 0; i < path.length; i++) { - [mStr appendFormat:@",%lu", [path indexAtPosition:i]]; - } - if (mStr.length < 1) return mStr; - return [mStr substringFromIndex:1]; -} - -- (NSArray*)indexPathToNumberArray:(NSIndexPath*)path { - NSUInteger *idcs = malloc(sizeof(NSUInteger) * path.length); - [path getIndexes:idcs]; - NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:path.length]; - for (NSUInteger i = 0; i < path.length; i++) { - [arr addObject:[NSNumber numberWithUnsignedInteger:[path indexAtPosition:i]]]; - } - free(idcs); - return arr; -} - -- (id)outlineView:(NSOutlineView *)outlineView itemForPersistentObject:(id)object { - NSIndexPath *path = [NSIndexPath new]; - for (NSNumber *num in object) { - path = [path indexPathByAddingIndex:[num unsignedIntegerValue]]; - } - NSLog(@"%@", [self arrangedObjects]); - [((AppDelegate*)[NSApp delegate]) persistentContainer]; - NSTreeNode *node = [[self arrangedObjects] descendantNodeAtIndexPath:path]; - return node; -} - -- (id)outlineView:(NSOutlineView *)outlineView persistentObjectForItem:(id)item { - NSUInteger len = [item indexPath].length; - NSUInteger *idcs = malloc(sizeof(NSUInteger) * len); - [[item indexPath] getIndexes:idcs]; - NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:len]; - for (NSUInteger i = 0; i < len; i++) { - [arr addObject:[NSNumber numberWithUnsignedInteger:[[item indexPath] indexAtPosition:i]]]; - } - free(idcs); - return arr; -} - -#pragma mark - Store and reload exanded items - -- (void)loadExpandedItems { - -} - -- (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item { - [self.expandedItems addObject:[item indexPath]]; - return YES; -} - -- (BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item { - [self.expandedItems removeObject:[item indexPath]]; -// [self.outlineView isExpandable:] -// [self.outlineView expandItem:] - return YES; -} - #pragma mark - Dragging Support, Data Source Delegate - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard { diff --git a/baRSS/Preferences.m b/baRSS/Preferences.m index ed4b9f4..9bb664a 100644 --- a/baRSS/Preferences.m +++ b/baRSS/Preferences.m @@ -56,31 +56,25 @@ - (void)keyDown:(NSEvent *)event { if (event.modifierFlags & NSEventModifierFlagCommand) { bool holdShift = event.modifierFlags & NSEventModifierFlagShift; - @try { - unichar key = [event.characters characterAtIndex:0]; + unichar key = [event.characters characterAtIndex:0]; + switch (key) { + case 'w': [self close]; break; + case 'q': [NSApplication.sharedApplication terminate:self]; break; + } + if (self.window.contentView == self.viewFeeds) { // these only apply for NSOutlineView switch (key) { - case 'w': [self close]; break; - case 'q': [NSApplication.sharedApplication terminate:self]; break; + case 'z': + if (holdShift) [self.newsController.managedObjectContext.undoManager redo]; + else [self.newsController.managedObjectContext.undoManager undo]; + [self.newsController rearrangeObjects]; // update the ordering + break; + case 'o': break; // open .opml file + case 's': break; // save data or backup .opml file + case 'c': // copy row entry + [self.newsController copyDescriptionOfSelectedItems]; + break; + case 'a': [self.feedsOutline selectAll:nil]; break; } - if (self.window.contentView == self.viewFeeds) { // these only apply for NSOutlineView - switch (key) { - case 'z': - if (holdShift) [self.newsController.managedObjectContext.undoManager redo]; - else [self.newsController.managedObjectContext.undoManager undo]; - [self.newsController rearrangeObjects]; // update the ordering - break; - case 'n': [self.newsController addFeed:nil]; break; - case 'o': break; // open .opml file - case 's': break; // save data or backup .opml file - case 'c': // copy row entry - [self.newsController copyDescriptionOfSelectedItems]; - break; - case 'a': [self.feedsOutline selectAll:nil]; break; - // TODO: delete - } - } - } @catch (NSException *exception) { - NSLog(@"%@", event); } } }