aaaand, its gone.
nothing works, this stupid arrangedObjects is always empty at init.
This commit is contained in:
@@ -25,6 +25,5 @@
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
@property (readonly, strong) NSPersistentContainer *persistentContainer;
|
||||
- (IBAction)quitClicked:(id)sender;
|
||||
@end
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@
|
||||
<treeController mode="entity" entityName="FeedConfig" fetchPredicateFormat="parent == nil" automaticallyPreparesContent="YES" childrenKeyPath="children" leafKeyPath="type" id="1oZ-Uo-mIu" customClass="NewsController">
|
||||
<connections>
|
||||
<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="pauseItem" destination="D7r-Vb-9eO" id="8Cu-bX-0uT"/>
|
||||
<outlet property="updateAllItem" destination="wgp-fa-8Wj" id="dI0-8A-qaY"/>
|
||||
</connections>
|
||||
</treeController>
|
||||
<customObject id="bgB-po-1IK" customClass="Preferences">
|
||||
@@ -67,7 +64,7 @@
|
||||
</menuItem>
|
||||
<menuItem title="Quit" keyEquivalent="q" id="Nb6-yK-a1A">
|
||||
<connections>
|
||||
<action selector="quitClicked:" target="Voe-Tx-rLC" id="itf-Lt-9Yn"/>
|
||||
<action selector="terminate:" target="-1" id="STj-gf-HrE"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
@@ -413,7 +410,6 @@
|
||||
</tableColumns>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="1oZ-Uo-mIu" id="sch-o5-yEm"/>
|
||||
<outlet property="delegate" destination="1oZ-Uo-mIu" id="ZkV-Zy-rDc"/>
|
||||
</connections>
|
||||
</outlineView>
|
||||
</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">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent">n</string>
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<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">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
CA
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<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">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent">g</string>
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="addGroup:" target="1oZ-Uo-mIu" id="8MO-eQ-XcJ"/>
|
||||
|
||||
@@ -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<NSTreeNode*> *currentlyDraggedNodes;
|
||||
@property (strong) NSMutableSet<NSIndexPath*> *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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user