Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mjdescy committed Mar 18, 2016
2 parents 5615937 + 753ab7d commit 3a39095
Show file tree
Hide file tree
Showing 17 changed files with 1,495 additions and 1,038 deletions.
13 changes: 13 additions & 0 deletions TodoTxtMac/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,19 @@ CA
<action selector="openWebSite:" target="7QU-ZR-XSK" id="9Ag-Y1-CGm"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="lRU-6h-IH1"/>
<menuItem title="Plaintext Productivity Web Site" id="9hp-z8-KLG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openPlaintextProductivityWebSite:" target="7QU-ZR-XSK" id="ECP-z5-0Cu"/>
</connections>
</menuItem>
<menuItem title="Todo.txt Tips from Plaintext Productivity" id="MgF-xZ-I3A">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openTodoTxtTipsPlaintextProductivityWebSite:" target="7QU-ZR-XSK" id="tYj-xu-zQ4"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
Expand Down
2 changes: 2 additions & 0 deletions TodoTxtMac/TTMAppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ extern NSString *const TodoFileArgument;
- (IBAction)openPreferencesWindow:(id)sender;
- (IBAction)openFiltersWindow:(id)sender;
- (IBAction)openWebSite:(id)sender;
- (IBAction)openPlaintextProductivityWebSite:(id)sender;
- (IBAction)openTodoTxtTipsPlaintextProductivityWebSite:(id)sender;

#pragma mark - User Defaults-related Methods

Expand Down
18 changes: 16 additions & 2 deletions TodoTxtMac/TTMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
[TTMDocumentStatusBarText defaultFormat], @"statusBarFormat",
@0, @"levelsOfUndo",
@YES, @"allowUndoOfArchiveCommand",
@NO, @"hideFutureTasks",
nil];
}
return dict;
Expand Down Expand Up @@ -150,11 +151,24 @@ - (IBAction)openFiltersWindow:(id)sender {
[self.filtersController showWindow:self];
}

- (void)launchURLFromString:(NSString*)urlString {
NSURL *url = [NSURL URLWithString:urlString];
[[NSWorkspace sharedWorkspace] openURL:url];
}

- (IBAction)openWebSite:(id)sender {
NSURL *helpURL = [NSURL URLWithString:@"http://mjdescy.github.io/TodoTxtMac/"];
[[NSWorkspace sharedWorkspace] openURL:helpURL];
[self launchURLFromString:@"http://mjdescy.github.io/TodoTxtMac/"];
}

- (IBAction)openPlaintextProductivityWebSite:(id)sender {
[self launchURLFromString:@"http://plaintext-productivity.net"];
}

- (IBAction)openTodoTxtTipsPlaintextProductivityWebSite:(id)sender {
[self launchURLFromString:@"http://plaintext-productivity.net/1-00-tasks-introduction.html"];
}


#pragma mark - User Defaults-related Methods

- (void)initializeUserDefaults:(id)sender {
Expand Down
9 changes: 7 additions & 2 deletions TodoTxtMac/TTMDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ - (void)addTasksFromArray:(NSArray*)rawTextStrings
[[self.undoManager prepareWithInvocationTarget:self] removeTasks:newTasks];
}

[self updateTaskListMetadata];
if (removeAllTasksFirst) {
[self visualRefreshOnly:self];
} else {
[self updateTaskListMetadata];
}
}

- (IBAction)addNewTask:(id)sender {
Expand Down Expand Up @@ -476,6 +480,7 @@ - (void)refreshTaskListWithSave:(BOOL)saveToFile {

- (IBAction)visualRefreshOnly:(id)sender {
[self setTaskListFont];
[self reapplyActiveFilterPredicate];
[self.tableView reloadData];
[self updateTaskListMetadata];
}
Expand Down Expand Up @@ -1299,7 +1304,7 @@ - (IBAction)showTasklistMetadata:(id)sender {
}

- (IBAction)hideTasklistMetadata:(id)sender {
[NSApp endSheet:self.tasklistMetadataSheet];
[self.windowForSheet endSheet:self.tasklistMetadataSheet];
[self.tasklistMetadataSheet close];
self.tasklistMetadataSheet = nil;
}
Expand Down
1 change: 1 addition & 0 deletions TodoTxtMac/TTMDocumentStatusBarText.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ extern NSString* const TTMActiveFilterNumber;
extern NSString* const TTMActiveSortNumber;
extern NSString* const TTMActiveSortName;
extern NSString* const TTMSelectedTaskCount;
extern NSString* const TTMHideFutureTasks;

@property (nonatomic, retain) TTMDocument *document;
@property (nonatomic) NSString *format;
Expand Down
19 changes: 15 additions & 4 deletions TodoTxtMac/TTMDocumentStatusBarText.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ @implementation TTMDocumentStatusBarText
NSString* const TTMActiveSortNumber = @"{Sort Preset}";
NSString* const TTMActiveSortName = @"{Sort Name}";
NSString* const TTMSelectedTaskCount = @"{Selected}";
NSString* const TTMHideFutureTasks = @"{Hide Future Tasks}";

#pragma mark - Init Method

Expand All @@ -98,7 +99,7 @@ - (NSDictionary*)documentMetadata {
@(TTMSortThresholdDate) : @"Threshold Date",
@(TTMSortAlphabetical) : @"Alphabetical"
};

return @{TTMAllStatusBarAllTaskCountTag : @(self.document.tasklistMetadata.allTaskCount),
TTMAllCompletedTaskCount : @(self.document.tasklistMetadata.completedTaskCount),
TTMAllIncompleteTaskCount : @(self.document.tasklistMetadata.incompleteTaskCount),
Expand All @@ -120,10 +121,19 @@ - (NSDictionary*)documentMetadata {
TTMActiveFilterNumber : @(self.document.activeFilterPredicateNumber),
TTMActiveSortNumber : @(self.document.activeSortType),
TTMActiveSortName : [sortNames objectForKey:@(self.document.activeSortType)],
TTMSelectedTaskCount : @(self.document.arrayController.selectionIndexes.count)
TTMSelectedTaskCount : @(self.document.arrayController.selectionIndexes.count),
TTMHideFutureTasks : [self hideFutureTasks]
};
}

- (NSString*)hideFutureTasks {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"hideFutureTasks"]) {
return NSLocalizedString(@"Yes", "");
} else {
return NSLocalizedString(@"No", "");
}
}

#pragma mark - Output/Property Methods

- (NSString*)statusBarText {
Expand Down Expand Up @@ -161,12 +171,13 @@ + (NSArray*)availableTags {
TTMActiveFilterNumber,
TTMActiveSortNumber,
TTMActiveSortName,
TTMSelectedTaskCount
TTMSelectedTaskCount,
TTMHideFutureTasks
];
}

+ (NSString*)defaultFormat {
return @"Filter #: {Filter Preset} | Sort: {Sort Name} | Tasks: {Shown Tasks} of {All Tasks} | Incomplete: {Shown Incomplete} | Due Today: {Shown Due Today} | Overdue: {Shown Overdue}";
return @"Filter #: {Filter Preset} | Sort: {Sort Name} | Tasks: {Shown Tasks} of {All Tasks} | Incomplete: {Shown Incomplete} | Due Today: {Shown Due Today} | Overdue: {Shown Overdue} | Hide Future Tasks: {Hide Future Tasks}";
}

@end
13 changes: 13 additions & 0 deletions TodoTxtMac/TTMFilterPredicates.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@
*/
+ (NSData*)defaultFilterPredicateData;

/*!
* @method hideFutureTasksFilterPredicate:
* @abstract This method returns a filter predicate for use with the "hide future tasks" option.
*/
+ (NSPredicate*)hideFutureTasksFilterPredicate;

/*!
* @method hideFutureTasksFilterSubPredicate:
* @abstract This method returns a filter predicate for use with the "hide future tasks" option.
*/
+ (NSPredicate*)hideFutureTasksFilterSubPredicate;


/*!
* @method noFilterPredicate:
* @abstract This method returns a filter predicate for use when the filter is disabled.
Expand Down
44 changes: 40 additions & 4 deletions TodoTxtMac/TTMFilterPredicates.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
*/

#import "TTMFilterPredicates.h"
#import "TTMTask.h"

@implementation TTMFilterPredicates

Expand Down Expand Up @@ -80,7 +81,27 @@ + (NSData*)defaultFilterPredicateData {
}

+ (NSPredicate*)noFilterPredicate {
return nil;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"hideFutureTasks"]) {
return [self hideFutureTasksFilterPredicate];
} else {
return nil;
}
}

+ (NSPredicate*)hideFutureTasksFilterPredicate {
static NSPredicate *defaultPredicate = nil;
if (defaultPredicate == nil) {
NSPredicate *defaultSubPredicate = [self hideFutureTasksFilterSubPredicate];

NSArray *subPredicates = @[defaultSubPredicate];
defaultPredicate = [NSCompoundPredicate
andPredicateWithSubpredicates:subPredicates];
}
return defaultPredicate;
}

+ (NSPredicate*)hideFutureTasksFilterSubPredicate {
return [NSPredicate predicateWithFormat:@"thresholdState != %d", (int)ThresholdAfterToday];
}

#pragma mark - Set Filter Predicate Methods
Expand Down Expand Up @@ -110,9 +131,17 @@ + (NSPredicate*)getFilterPredicateFromPresetNumber:(NSUInteger)presetNumber {
return [self noFilterPredicate];
}
if (presetNumber > 9) {
return nil;
return [self noFilterPredicate];
}

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"hideFutureTasks"]) {
NSPredicate *filterPresetSubPredicate = [self getFilterPredicateFromUserDefaultsKey:[self keyFromPresetNumber:presetNumber]];
NSPredicate *hideFutureTasksSubPredicate = [self hideFutureTasksFilterSubPredicate];
NSArray *subPredicates = @[filterPresetSubPredicate, hideFutureTasksSubPredicate];
return [NSCompoundPredicate andPredicateWithSubpredicates:subPredicates];
} else {
return [self getFilterPredicateFromUserDefaultsKey:[self keyFromPresetNumber:presetNumber]];
}
return [self getFilterPredicateFromUserDefaultsKey:[self keyFromPresetNumber:presetNumber]];
}

+ (NSString*)keyFromPresetNumber:(NSUInteger)presetNumber {
Expand All @@ -123,7 +152,14 @@ + (NSString*)keyFromPresetNumber:(NSUInteger)presetNumber {
}

+ (NSPredicate*)activeFilterPredicate {
return [self getFilterPredicateFromUserDefaultsKey:@"activeFilterPredicate"];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"hideFutureTasks"]) {
NSPredicate *filterPresetSubPredicate = [self getFilterPredicateFromUserDefaultsKey:@"activeFilterPredicate"];
NSPredicate *hideFutureTasksSubPredicate = [self hideFutureTasksFilterSubPredicate];
NSArray *subPredicates = @[filterPresetSubPredicate, hideFutureTasksSubPredicate];
return [NSCompoundPredicate andPredicateWithSubpredicates:subPredicates];
} else {
return [self getFilterPredicateFromUserDefaultsKey:@"activeFilterPredicate"];
}
}

+ (void)setActiveFilterPredicatePresetNumber:(NSUInteger)presetNumber {
Expand Down
24 changes: 12 additions & 12 deletions TodoTxtMac/TTMFilters.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="TTMFiltersController">
Expand All @@ -28,7 +28,7 @@
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="573" height="406"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="x3A-pX-TrY">
<rect key="frame" x="18" y="369" width="449" height="17"/>
Expand Down Expand Up @@ -524,7 +524,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="tcy-Zc-P6i">
<rect key="frame" x="477" y="1" width="15" height="245"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -1016,7 +1016,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="vAx-J9-pQC">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -1508,7 +1508,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="ues-cY-hv0">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -2000,7 +2000,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="Dn2-oy-WkD">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -2492,7 +2492,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="Xch-za-6Nr">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -2984,7 +2984,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="2bq-D6-2te">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -3476,7 +3476,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="JkQ-8M-KaS">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -3968,7 +3968,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="h5H-Ye-21u">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -4460,7 +4460,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="uW2-e6-tfL">
<rect key="frame" x="475" y="1" width="15" height="249"/>
<rect key="frame" x="477" y="1" width="15" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down
Loading

0 comments on commit 3a39095

Please sign in to comment.