From fd7fa49fc3cdf7a27a9f61086570f560c12953cc Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 8 Jan 2009 02:37:18 +0000 Subject: [PATCH] #1668 Groups: filter torrents by evalutating a multivalue property (any tracker and any file) --- Transmission.xcodeproj/project.pbxproj | 6 + macosx/Makefile.am | 2 + macosx/PredicateEditorRowTemplateAny.h | 31 ++ macosx/PredicateEditorRowTemplateAny.m | 42 +++ macosx/Torrent.h | 2 +- macosx/Torrent.m | 13 +- macosx/en.lproj/GroupRules.xib | 460 +++++++++++++++---------- 7 files changed, 370 insertions(+), 186 deletions(-) create mode 100644 macosx/PredicateEditorRowTemplateAny.h create mode 100644 macosx/PredicateEditorRowTemplateAny.m diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index f7cf9f8ba..8ae487975 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -104,6 +104,7 @@ A2385DD40BFE06C800B24EF6 /* DragOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A2385DD20BFE06C800B24EF6 /* DragOverlayWindow.m */; }; A23F4FF20D1D98AD002FCB97 /* PrefsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A23F4FF00D1D98AD002FCB97 /* PrefsWindow.xib */; }; A23F50020D1D99D7002FCB97 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A23F50000D1D99D7002FCB97 /* MainMenu.xib */; }; + A23F526F0F14395900AA02E3 /* PredicateEditorRowTemplateAny.m in Sources */ = {isa = PBXBuildFile; fileRef = A23F526E0F14395900AA02E3 /* PredicateEditorRowTemplateAny.m */; }; A241528B0C0261B8007DD3B4 /* Globe.png in Resources */ = {isa = PBXBuildFile; fileRef = A2FB06950BFF484A0095564D /* Globe.png */; }; A245030C0D6A1FB000B49D00 /* UpArrowGroupTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = A245030B0D6A1FB000B49D00 /* UpArrowGroupTemplate.png */; }; A245030E0D6A1FBC00B49D00 /* DownArrowGroupTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = A245030D0D6A1FBC00B49D00 /* DownArrowGroupTemplate.png */; }; @@ -490,6 +491,8 @@ A233BD680D8CF2C7007EE7B4 /* StatsWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = StatsWindow.xib; path = macosx/StatsWindow.xib; sourceTree = ""; }; A2385DD20BFE06C800B24EF6 /* DragOverlayWindow.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = DragOverlayWindow.m; path = macosx/DragOverlayWindow.m; sourceTree = ""; }; A2385DD30BFE06C800B24EF6 /* DragOverlayWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = DragOverlayWindow.h; path = macosx/DragOverlayWindow.h; sourceTree = ""; }; + A23F526D0F14395900AA02E3 /* PredicateEditorRowTemplateAny.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PredicateEditorRowTemplateAny.h; path = macosx/PredicateEditorRowTemplateAny.h; sourceTree = ""; }; + A23F526E0F14395900AA02E3 /* PredicateEditorRowTemplateAny.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PredicateEditorRowTemplateAny.m; path = macosx/PredicateEditorRowTemplateAny.m; sourceTree = ""; }; A245030B0D6A1FB000B49D00 /* UpArrowGroupTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = UpArrowGroupTemplate.png; path = macosx/Images/UpArrowGroupTemplate.png; sourceTree = ""; }; A245030D0D6A1FBC00B49D00 /* DownArrowGroupTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DownArrowGroupTemplate.png; path = macosx/Images/DownArrowGroupTemplate.png; sourceTree = ""; }; A24621350C769CF400088E81 /* trevent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = trevent.h; path = libtransmission/trevent.h; sourceTree = ""; }; @@ -901,6 +904,8 @@ A22180970D148A71007D09ED /* GroupsPrefsController.m */, A2FB701A0D95CAEA0001F331 /* GroupsController.h */, A2FB701B0D95CAEA0001F331 /* GroupsController.m */, + A23F526D0F14395900AA02E3 /* PredicateEditorRowTemplateAny.h */, + A23F526E0F14395900AA02E3 /* PredicateEditorRowTemplateAny.m */, A2D307A20D9EC6870051FD27 /* BlocklistDownloader.h */, A2D307A30D9EC6870051FD27 /* BlocklistDownloader.m */, A222E9850E6B21D9009FB003 /* BlocklistDownloaderViewController.h */, @@ -1863,6 +1868,7 @@ A222E9870E6B21D9009FB003 /* BlocklistDownloaderViewController.m in Sources */, A222EA7B0E6C32C4009FB003 /* BlocklistScheduler.m in Sources */, A232F07E0EEA034A00041646 /* BonjourController.m in Sources */, + A23F526F0F14395900AA02E3 /* PredicateEditorRowTemplateAny.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macosx/Makefile.am b/macosx/Makefile.am index 825b75867..34cdc3937 100644 --- a/macosx/Makefile.am +++ b/macosx/Makefile.am @@ -90,6 +90,8 @@ EXTRA_DIST = \ PiecesView.m \ PortChecker.h \ PortChecker.m \ + PredicateEditorRowTemplateAny.h \ + PredicateEditorRowTemplateAny.m \ PrefsController.h \ PrefsController.m \ PrefsWindow.h \ diff --git a/macosx/PredicateEditorRowTemplateAny.h b/macosx/PredicateEditorRowTemplateAny.h new file mode 100644 index 000000000..c9e80ffe6 --- /dev/null +++ b/macosx/PredicateEditorRowTemplateAny.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2009 Transmission authors and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#import + +@interface PredicateEditorRowTemplateAny : NSPredicateEditorRowTemplate +{ +} + +@end diff --git a/macosx/PredicateEditorRowTemplateAny.m b/macosx/PredicateEditorRowTemplateAny.m new file mode 100644 index 000000000..c28e9eb0b --- /dev/null +++ b/macosx/PredicateEditorRowTemplateAny.m @@ -0,0 +1,42 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2009 Transmission authors and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#import "PredicateEditorRowTemplateAny.h" + +@implementation PredicateEditorRowTemplateAny + +- (NSPredicate *) predicateWithSubpredicates: (NSArray *) subpredicates +{ + //we only make NSComparisonPredicates + NSComparisonPredicate * predicate = (NSComparisonPredicate *)[super predicateWithSubpredicates: subpredicates]; + + //construct a near-identical predicate + return [NSComparisonPredicate predicateWithLeftExpression: [predicate leftExpression] + rightExpression: [predicate rightExpression] + modifier: NSAnyPredicateModifier + type: [predicate predicateOperatorType] + options: [predicate options]]; +} + +@end diff --git a/macosx/Torrent.h b/macosx/Torrent.h index cc2b0375d..b281dde7c 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -154,7 +154,7 @@ typedef enum - (NSString *) scrapeResponse; - (NSMutableArray *) allTrackers: (BOOL) separators; -- (NSString *) trackerList; +- (NSArray *) allTrackersFlat; - (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers; - (void) updateAllTrackersForRemove: (NSMutableArray *) trackers; - (BOOL) hasAddedTrackers; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 00a5d0a38..b0ecd1f26 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -777,10 +777,9 @@ int trashDataFile(const char * filename) return allTrackers; } -//used by auto group rules -- (NSString *) trackerList +- (NSArray *) allTrackersFlat { - return [[self allTrackers: NO] componentsJoinedByString: @"\n"]; + return [self allTrackers: NO]; } - (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers @@ -1705,13 +1704,13 @@ int trashDataFile(const char * filename) fWaitToStart = waitToStart && [waitToStart boolValue]; fResumeOnWake = NO; - + + [self createFileList]; + fOrderValue = orderValue ? [orderValue intValue] : tr_sessionCountTorrents(lib) - 1; fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self]; - fAddedTrackers = addedTrackers ? [addedTrackers boolValue] : NO; - - [self createFileList]; + fAddedTrackers = addedTrackers ? [addedTrackers boolValue] : NO; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:) name: @"GroupValueRemoved" object: nil]; diff --git a/macosx/en.lproj/GroupRules.xib b/macosx/en.lproj/GroupRules.xib index 9709fed20..246cf8e3f 100644 --- a/macosx/en.lproj/GroupRules.xib +++ b/macosx/en.lproj/GroupRules.xib @@ -8,7 +8,7 @@ 353.00 YES - + YES @@ -114,17 +114,17 @@ 274 YES - + 290 YES - - + + 257 {{399, 4}, {18, 18}} - - + + -1 YES @@ -137,8 +137,8 @@ 16 _addOption: - - + + -2038284033 36 @@ -151,12 +151,12 @@ 75 - - + + -2147483391 {{379, 4}, {18, 18}} - - + + -1 YES @@ -165,8 +165,8 @@ - _deleteOption: - - + + -2038284033 36 @@ -176,10 +176,10 @@ - + 256 {{7, 3}, {58, 19}} - + -1 YES @@ -191,7 +191,7 @@ 1.100000e+01 3100 - + -2038284033 36 @@ -249,11 +249,11 @@ - + 256 {{71, 3}, {167, 19}} - - + + -1 YES @@ -311,7 +311,7 @@ {{71, 3}, {167, 19}} YES - + YES YES @@ -337,7 +337,7 @@ - + YES YES @@ -354,23 +354,23 @@ 2 {{7, 3}, {58, 19}} {{71, 3}, {167, 19}} - - + + 0 0 YES - + 290 YES - - + + 257 {{399, 4}, {18, 18}} - - + + -1 YES @@ -379,8 +379,8 @@ + _addOption: - - + + -2038284033 36 @@ -389,12 +389,12 @@ 75 - - + + 257 {{379, 4}, {18, 18}} - - + + -1 YES @@ -403,8 +403,8 @@ - _deleteOption: - - + + -2038284033 36 @@ -414,10 +414,10 @@ - + 256 {{37, 3}, {76, 19}} - + -1 YES @@ -499,10 +499,10 @@ - + 256 {{119, 3}, {95, 19}} - + -1 YES @@ -546,7 +546,7 @@ _popUpItemAction: - + @@ -558,7 +558,19 @@ _popUpItemAction: - + + + + + + matches + + 1048576 + 2147483647 + + + _popUpItemAction: + @@ -570,7 +582,7 @@ _popUpItemAction: - + @@ -582,11 +594,11 @@ - + 256 {{220, 4}, {61, 18}} - - + + YES 343014976 @@ -635,7 +647,7 @@ {{220, 4}, {61, 18}} YES - + YES YES @@ -662,7 +674,7 @@ - + YES YES @@ -675,7 +687,7 @@ - + YES YES @@ -693,22 +705,22 @@ {{37, 3}, {76, 19}} {{119, 3}, {95, 19}} {{220, 4}, {61, 18}} - - + + 0 0 YES - + 290 YES - - + + 257 {{399, 4}, {18, 18}} - + -1 YES @@ -718,8 +730,8 @@ + _addOption: - - + + -2038284033 36 @@ -728,12 +740,12 @@ 75 - - + + 257 {{379, 4}, {18, 18}} - - + + -1 YES @@ -742,8 +754,8 @@ - _deleteOption: - - + + -2038284033 36 @@ -752,21 +764,21 @@ 75 - - + + 256 {{37, 3}, {79, 19}} - - + + -1 YES - + 67239488 4196352 - + 3 - valueForKey: + valueForKeyPath: 1 @@ -774,20 +786,20 @@ YES 10 - trackerList + fFlatFileList.name - + -2038284033 36 400 75 - - - Tracker + + + Any File 1048576 2147483647 @@ -795,15 +807,40 @@ _popUpItemAction: - - + + YES - + YES - + + + + Any Tracker + + 1048576 + 2147483647 + + + _popUpItemAction: + + 3 + valueForKey: + + 1 + + + YES + + 10 + allTrackersFlat + + + + + 3 @@ -812,28 +849,28 @@ 2 - - + + 256 {{122, 3}, {99, 19}} - - + + -1 YES - + 67239488 4196352 - - + + -2038284033 36 400 75 - - + + contains 1048576 @@ -842,15 +879,51 @@ _popUpItemAction: - - + + YES - + YES - + + + + begins with + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + + ends with + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + + is + + 1048576 + 2147483647 + + + _popUpItemAction: + + + 3 @@ -859,19 +932,19 @@ 2 - - + + 256 {{227, 4}, {150, 18}} - - + + YES 343014976 4326400 - + YES @@ -880,16 +953,16 @@ {{0, 50}, {427, 25}} - + 2 1 YES - - - + + + 3 {{37, 3}, {79, 19}} @@ -897,7 +970,7 @@ {{227, 4}, {150, 18}} YES - + YES YES @@ -907,7 +980,7 @@ YES - + 1 1 0 @@ -915,16 +988,16 @@ 700 YES - - - + + + NO YES - + YES YES @@ -934,10 +1007,10 @@ YES - + - + YES YES @@ -947,7 +1020,7 @@ YES - + @@ -955,16 +1028,16 @@ {{37, 3}, {79, 19}} {{122, 3}, {99, 19}} {{227, 4}, {150, 18}} - - + + 0 0 YES - {{1, 1}, {427, 175}} + {{1, 1}, {427, 164}} - + @@ -974,7 +1047,7 @@ NSRuleEditorItemPBoardType - {429, 177} + {429, 166} YES @@ -1008,8 +1081,8 @@ YES YES - - + + YES @@ -1032,9 +1105,9 @@ YES YES - - - + + + YES @@ -1061,15 +1134,15 @@ YES YES - - - + + + YES - - - + + + @@ -1084,20 +1157,20 @@ YES - - - + + + YES - + - {{1, 1}, {429, 177}} + {{1, 1}, {429, 166}} @@ -1126,7 +1199,7 @@ _doScroller: - {{20, 49}, {431, 179}} + {{20, 60}, {431, 168}} 514 @@ -1231,8 +1304,8 @@ YES - + @@ -1293,7 +1366,7 @@ YES - + @@ -1356,18 +1429,14 @@ YES - + + - - 55 - - - 42 @@ -1404,42 +1473,76 @@ - 104 - + 118 + + + + + 147 + YES - - + + - 109 - + 148 + YES - + + - + - 110 - - - - - 105 - + 152 + YES - + + + + - + - 108 - - + 153 + + + + + 154 + + + + + 155 + + + + + 156 + + + + + 161 + + + + + 162 + + + + + 163 + + @@ -1458,10 +1561,10 @@ 1.windowTemplate.hasMinSize 1.windowTemplate.maxSize 1.windowTemplate.minSize - 105.IBEditorWindowLastContentRect - 109.IBEditorWindowLastContentRect 11.IBPluginDependency 12.IBPluginDependency + 147.CustomClassName + 148.IBEditorWindowLastContentRect 2.IBPluginDependency 3.IBPluginDependency 31.IBPluginDependency @@ -1478,6 +1581,7 @@ 4.IBPluginDependency 40.IBPluginDependency 42.IBPluginDependency + 47.IBEditorWindowLastContentRect 47.IBPluginDependency 48.IBPluginDependency 49.IBPluginDependency @@ -1489,18 +1593,18 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilderKit com.apple.InterfaceBuilderKit - {{433, 376}, {471, 248}} + {{505, 452}, {471, 248}} com.apple.InterfaceBuilder.CocoaPlugin - {{433, 376}, {471, 248}} + {{505, 452}, {471, 248}} {471, 100000} {471, 128} - {{481, 527}, {115, 22}} - {{566, 527}, {121, 22}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + PredicateEditorRowTemplateAny + {{553, 584}, {143, 41}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1511,12 +1615,13 @@ com.apple.InterfaceBuilder.CocoaPlugin {{481, 533}, {129, 41}} com.apple.InterfaceBuilder.CocoaPlugin - {{563, 495}, {140, 79}} + {{635, 552}, {140, 98}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{523, 634}, {91, 41}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1544,7 +1649,7 @@ - 117 + 163 @@ -1584,7 +1689,6 @@ fAutoAssignRulesEnableCheck fCustomLocationEnableCheck fCustomLocationPopUp - fGroupRulesPrefsContainer fGroupRulesSheetWindow fRuleEditor fSelectedColorNameField @@ -1598,7 +1702,6 @@ NSButton NSButton NSPopUpButton - NSView NSWindow NSPredicateEditor NSTextField @@ -1611,13 +1714,6 @@ macosx/GroupsPrefsController.h - - NSApplication - - IBProjectSource - macosx/NSApplicationAdditions.h - - NSObject @@ -1639,6 +1735,14 @@ macosx/UKKQueue/UKMainThreadProxy.h + + PredicateEditorRowTemplateAny + NSPredicateEditorRowTemplate + + IBProjectSource + macosx/PredicateEditorRowTemplateAny.h + + 0