aaaand, its gone.

nothing works, this stupid arrangedObjects is always empty at init.
This commit is contained in:
relikd
2018-08-03 00:25:21 +02:00
parent 963e991fcd
commit 8e27496a68
5 changed files with 25 additions and 125 deletions

View File

@@ -25,6 +25,5 @@
@interface AppDelegate : NSObject <NSApplicationDelegate> @interface AppDelegate : NSObject <NSApplicationDelegate>
@property (readonly, strong) NSPersistentContainer *persistentContainer; @property (readonly, strong) NSPersistentContainer *persistentContainer;
- (IBAction)quitClicked:(id)sender;
@end @end

View File

@@ -30,10 +30,6 @@
@implementation AppDelegate @implementation AppDelegate
- (IBAction)quitClicked:(id)sender {
[NSApplication.sharedApplication terminate:self];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
self.statusItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength]; self.statusItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
self.statusItem.title = @"me"; self.statusItem.title = @"me";
@@ -43,8 +39,6 @@
printf("done\n"); printf("done\n");
} }
- (void)applicationWillTerminate:(NSNotification *)aNotification { - (void)applicationWillTerminate:(NSNotification *)aNotification {
[PyHandler shutdown]; [PyHandler shutdown];
} }

View File

@@ -22,10 +22,7 @@
<treeController mode="entity" entityName="FeedConfig" fetchPredicateFormat="parent == nil" automaticallyPreparesContent="YES" childrenKeyPath="children" leafKeyPath="type" id="1oZ-Uo-mIu" customClass="NewsController"> <treeController mode="entity" entityName="FeedConfig" fetchPredicateFormat="parent == nil" automaticallyPreparesContent="YES" childrenKeyPath="children" leafKeyPath="type" id="1oZ-Uo-mIu" customClass="NewsController">
<connections> <connections>
<binding destination="Voe-Tx-rLC" name="managedObjectContext" keyPath="self.persistentContainer.viewContext" id="Q1f-VN-9qq"/> <binding destination="Voe-Tx-rLC" name="managedObjectContext" keyPath="self.persistentContainer.viewContext" id="Q1f-VN-9qq"/>
<outlet property="openUnreadItem" destination="Qqw-Xj-oA5" id="JN3-Ej-EPc"/>
<outlet property="outlineView" destination="hKk-G1-1po" id="Z4y-uD-Zse"/> <outlet property="outlineView" destination="hKk-G1-1po" id="Z4y-uD-Zse"/>
<outlet property="pauseItem" destination="D7r-Vb-9eO" id="8Cu-bX-0uT"/>
<outlet property="updateAllItem" destination="wgp-fa-8Wj" id="dI0-8A-qaY"/>
</connections> </connections>
</treeController> </treeController>
<customObject id="bgB-po-1IK" customClass="Preferences"> <customObject id="bgB-po-1IK" customClass="Preferences">
@@ -67,7 +64,7 @@
</menuItem> </menuItem>
<menuItem title="Quit" keyEquivalent="q" id="Nb6-yK-a1A"> <menuItem title="Quit" keyEquivalent="q" id="Nb6-yK-a1A">
<connections> <connections>
<action selector="quitClicked:" target="Voe-Tx-rLC" id="itf-Lt-9Yn"/> <action selector="terminate:" target="-1" id="STj-gf-HrE"/>
</connections> </connections>
</menuItem> </menuItem>
</items> </items>
@@ -413,7 +410,6 @@
</tableColumns> </tableColumns>
<connections> <connections>
<outlet property="dataSource" destination="1oZ-Uo-mIu" id="sch-o5-yEm"/> <outlet property="dataSource" destination="1oZ-Uo-mIu" id="sch-o5-yEm"/>
<outlet property="delegate" destination="1oZ-Uo-mIu" id="ZkV-Zy-rDc"/>
</connections> </connections>
</outlineView> </outlineView>
</subviews> </subviews>
@@ -437,6 +433,8 @@
<buttonCell key="cell" type="smallSquare" alternateTitle="Add feed" bezelStyle="smallSquare" image="NSAddTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="WMA-eZ-pOl"> <buttonCell key="cell" type="smallSquare" alternateTitle="Add feed" bezelStyle="smallSquare" image="NSAddTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="WMA-eZ-pOl">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<string key="keyEquivalent">n</string>
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</buttonCell> </buttonCell>
<connections> <connections>
<action selector="add:" target="1oZ-Uo-mIu" id="9rc-sz-RXa"/> <action selector="add:" target="1oZ-Uo-mIu" id="9rc-sz-RXa"/>
@@ -449,6 +447,9 @@
<buttonCell key="cell" type="smallSquare" alternateTitle="Remove Feed" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="d9M-ZD-oma"> <buttonCell key="cell" type="smallSquare" alternateTitle="Remove Feed" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="d9M-ZD-oma">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
CA
</string>
</buttonCell> </buttonCell>
<connections> <connections>
<action selector="remove:" target="1oZ-Uo-mIu" id="mph-g8-8J0"/> <action selector="remove:" target="1oZ-Uo-mIu" id="mph-g8-8J0"/>
@@ -472,6 +473,8 @@
<buttonCell key="cell" type="smallSquare" alternateTitle="Add group" bezelStyle="smallSquare" image="NSPathTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="9m2-U5-xE2"> <buttonCell key="cell" type="smallSquare" alternateTitle="Add group" bezelStyle="smallSquare" image="NSPathTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="9m2-U5-xE2">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<string key="keyEquivalent">g</string>
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</buttonCell> </buttonCell>
<connections> <connections>
<action selector="addGroup:" target="1oZ-Uo-mIu" id="8MO-eQ-XcJ"/> <action selector="addGroup:" target="1oZ-Uo-mIu" id="8MO-eQ-XcJ"/>

View File

@@ -27,12 +27,8 @@
@interface NewsController () @interface NewsController ()
@property (weak) IBOutlet NSOutlineView *outlineView; @property (weak) IBOutlet NSOutlineView *outlineView;
@property (weak) IBOutlet NSMenuItem *pauseItem;
@property (weak) IBOutlet NSMenuItem *updateAllItem;
@property (weak) IBOutlet NSMenuItem *openUnreadItem;
@property (strong) NSArray<NSTreeNode*> *currentlyDraggedNodes; @property (strong) NSArray<NSTreeNode*> *currentlyDraggedNodes;
@property (strong) NSMutableSet<NSIndexPath*> *expandedItems;
@end @end
@implementation NewsController @implementation NewsController
@@ -42,36 +38,11 @@ static NSString *dragNodeType = @"baRSS-feed-type";
- (void)awakeFromNib { - (void)awakeFromNib {
[super 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... // Set the outline view to accept the custom drag type AbstractTreeNodeType...
[self.outlineView registerForDraggedTypes:[NSArray arrayWithObject:dragNodeType]]; [self.outlineView registerForDraggedTypes:[NSArray arrayWithObject:dragNodeType]];
[self setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:YES]]]; [self setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:YES]]];
} }
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item { - (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 // this delegate method is only here to set owner to null and prohibit repeated awakeFromNib calls
return [self.outlineView makeViewWithIdentifier:tableColumn.identifier owner:nil]; 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 #pragma mark - Dragging Support, Data Source Delegate
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard { - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard {

View File

@@ -56,7 +56,6 @@
- (void)keyDown:(NSEvent *)event { - (void)keyDown:(NSEvent *)event {
if (event.modifierFlags & NSEventModifierFlagCommand) { if (event.modifierFlags & NSEventModifierFlagCommand) {
bool holdShift = event.modifierFlags & NSEventModifierFlagShift; bool holdShift = event.modifierFlags & NSEventModifierFlagShift;
@try {
unichar key = [event.characters characterAtIndex:0]; unichar key = [event.characters characterAtIndex:0];
switch (key) { switch (key) {
case 'w': [self close]; break; case 'w': [self close]; break;
@@ -69,19 +68,14 @@
else [self.newsController.managedObjectContext.undoManager undo]; else [self.newsController.managedObjectContext.undoManager undo];
[self.newsController rearrangeObjects]; // update the ordering [self.newsController rearrangeObjects]; // update the ordering
break; break;
case 'n': [self.newsController addFeed:nil]; break;
case 'o': break; // open .opml file case 'o': break; // open .opml file
case 's': break; // save data or backup .opml file case 's': break; // save data or backup .opml file
case 'c': // copy row entry case 'c': // copy row entry
[self.newsController copyDescriptionOfSelectedItems]; [self.newsController copyDescriptionOfSelectedItems];
break; break;
case 'a': [self.feedsOutline selectAll:nil]; break; case 'a': [self.feedsOutline selectAll:nil]; break;
// TODO: delete
} }
} }
} @catch (NSException *exception) {
NSLog(@"%@", event);
}
} }
} }