Menus with unread count: mark, unmark, open all unread
This commit is contained in:
@@ -22,15 +22,28 @@
|
||||
|
||||
#import "FeedConfig+CoreDataClass.h"
|
||||
|
||||
@class FeedItem;
|
||||
|
||||
@interface FeedConfig (Ext)
|
||||
/// Enum type to distinguish different @c FeedConfig types
|
||||
typedef enum int16_t {
|
||||
GROUP = 0,
|
||||
FEED = 1,
|
||||
SEPARATOR = 2
|
||||
} FeedConfigType;
|
||||
/**
|
||||
Iteration block for descendants of @c FeedItem.
|
||||
|
||||
@param parent The parent @c FeedConfig where this @c FeedItem belongs to.
|
||||
@param item Currently processed @c FeedItem.
|
||||
@return Return @c YES to continue processing. Return @c NO to stop processing and exit early.
|
||||
*/
|
||||
typedef BOOL (^FeedConfigRecursiveItemsBlock) (FeedConfig *parent, FeedItem *item);
|
||||
|
||||
@property (getter=typ, setter=setTyp:) FeedConfigType typ;
|
||||
@property (readonly) NSArray<FeedConfig*> *sortedChildren;
|
||||
|
||||
- (BOOL)descendantFeedItems:(FeedConfigRecursiveItemsBlock)block;
|
||||
- (NSString*)readableRefreshString;
|
||||
- (NSString*)readableDescription;
|
||||
@end
|
||||
|
||||
@@ -21,27 +21,52 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#import "FeedConfig+Ext.h"
|
||||
#import "Feed+CoreDataClass.h"
|
||||
|
||||
@implementation FeedConfig (Ext)
|
||||
/// Enum tpye getter see @c FeedConfigType
|
||||
- (FeedConfigType)typ { return (FeedConfigType)self.type; }
|
||||
/// Enum type setter see @c FeedConfigType
|
||||
- (void)setTyp:(FeedConfigType)typ { self.type = typ; }
|
||||
|
||||
- (FeedConfigType)typ {
|
||||
return (FeedConfigType)self.type;
|
||||
}
|
||||
|
||||
- (void)setTyp:(FeedConfigType)typ {
|
||||
self.type = typ;
|
||||
}
|
||||
/**
|
||||
Sorted children array based on sort order provided in feed settings.
|
||||
|
||||
@return Sorted array of @c FeedConfig items.
|
||||
*/
|
||||
- (NSArray<FeedConfig *> *)sortedChildren {
|
||||
if (self.children.count == 0)
|
||||
return nil;
|
||||
return [self.children sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"sortIndex" ascending:YES]]];
|
||||
}
|
||||
|
||||
/**
|
||||
Iterate over all descendant @c FeedItems in sub groups
|
||||
|
||||
@param block Will yield the current parent config and feed item. Return @c NO to cancel iteration.
|
||||
@return Returns @c NO if the iteration was canceled early. Otherwise @c YES.
|
||||
*/
|
||||
- (BOOL)descendantFeedItems:(FeedConfigRecursiveItemsBlock)block {
|
||||
if (self.children.count > 0) {
|
||||
for (FeedConfig *config in self.children) {
|
||||
if ([config descendantFeedItems:block] == NO)
|
||||
return NO;
|
||||
}
|
||||
} else if (self.feed.items.count > 0) {
|
||||
for (FeedItem* item in self.feed.items) {
|
||||
if (block(self, item) == NO)
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
/// @return Formatted string for update interval ( e.g., @c 30m or @c 12h )
|
||||
- (NSString*)readableRefreshString {
|
||||
return [NSString stringWithFormat:@"%d%c", self.refreshNum, [@"smhdw" characterAtIndex:self.refreshUnit % 5]];
|
||||
}
|
||||
|
||||
/// @return Simplified description of the feed object.
|
||||
- (NSString*)readableDescription {
|
||||
switch (self.typ) {
|
||||
case SEPARATOR: return @"-------------";
|
||||
|
||||
@@ -191,8 +191,8 @@
|
||||
}
|
||||
}
|
||||
- (void)loadView {
|
||||
NSTextField *tf = [NSTextField textFieldWithString:@"New Group"];
|
||||
tf.placeholderString = @"New Group";
|
||||
NSTextField *tf = [NSTextField textFieldWithString:NSLocalizedString(@"New Group", nil)];
|
||||
tf.placeholderString = NSLocalizedString(@"New Group", nil);
|
||||
tf.autoresizingMask = NSViewWidthSizable | NSViewMinYMargin;
|
||||
self.view = tf;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,6 @@
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:selectedIndex forKey:@"preferencesTab"];
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"baRSSPreferencesClosed" object:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<window title="baRSS Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="prefWindow" animationBehavior="default" tabbingMode="disallowed" id="XQ4-ia-CCO" userLabel="Window" customClass="NonRespondingWindow">
|
||||
<window title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="prefWindow" animationBehavior="default" tabbingMode="disallowed" id="XQ4-ia-CCO" userLabel="Window" customClass="NonRespondingWindow">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
|
||||
<rect key="contentRect" x="948" y="431" width="320" height="327"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
|
||||
Reference in New Issue
Block a user