Revision: 12538
          http://sourceforge.net/p/skim-app/code/12538
Author:   hofman
Date:     2021-11-08 16:53:10 +0000 (Mon, 08 Nov 2021)
Log Message:
-----------
Tool tip for grouped search results

Modified Paths:
--------------
    trunk/LeftSideView.xib
    trunk/SKGroupedSearchResult.h
    trunk/SKGroupedSearchResult.m
    trunk/SKImageToolTipContext.m

Modified: trunk/LeftSideView.xib
===================================================================
--- trunk/LeftSideView.xib      2021-11-08 16:05:55 UTC (rev 12537)
+++ trunk/LeftSideView.xib      2021-11-08 16:53:10 UTC (rev 12538)
@@ -478,6 +478,7 @@
                                                 <connections>
                                                     <binding 
destination="9a8-cx-9oD" name="value" keyPath="objectValue.count" 
previousBinding="kWL-Vz-uBg" id="68o-25-wdJ"/>
                                                     <binding 
destination="9a8-cx-9oD" name="maxValue" keyPath="objectValue.maxCount" 
id="kWL-Vz-uBg"/>
+                                                    <binding 
destination="9a8-cx-9oD" name="toolTip" keyPath="objectValue.label" 
id="bi6-PT-g2z"/>
                                                 </connections>
                                             </levelIndicator>
                                         </subviews>

Modified: trunk/SKGroupedSearchResult.h
===================================================================
--- trunk/SKGroupedSearchResult.h       2021-11-08 16:05:55 UTC (rev 12537)
+++ trunk/SKGroupedSearchResult.h       2021-11-08 16:53:10 UTC (rev 12538)
@@ -51,6 +51,7 @@
 @property (nonatomic, readonly) NSUInteger pageIndex;
 @property (nonatomic, readonly) NSUInteger count;
 @property (nonatomic) NSUInteger maxCount;
+@property (nonatomic, readonly) NSString *label;
 @property (nonatomic, readonly) NSArray *matches;
 
 + (id)groupedSearchResultWithPage:(PDFPage *)aPage 
maxCount:(NSUInteger)aMaxCount;

Modified: trunk/SKGroupedSearchResult.m
===================================================================
--- trunk/SKGroupedSearchResult.m       2021-11-08 16:05:55 UTC (rev 12537)
+++ trunk/SKGroupedSearchResult.m       2021-11-08 16:53:10 UTC (rev 12538)
@@ -46,8 +46,15 @@
 @implementation SKGroupedSearchResult
 
 @synthesize page, maxCount, matches;
-@dynamic pageIndex, count;
+@dynamic pageIndex, count, label;
 
++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
+    NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
+    if ([key isEqualToString:@"label"])
+        keyPaths = [keyPaths setByAddingObjectsFromSet:[NSSet 
setWithObjects:SKGroupedSearchResultCountKey, nil]];
+    return keyPaths;
+}
+
 + (id)groupedSearchResultWithPage:(PDFPage *)aPage 
maxCount:(NSUInteger)aMaxCount {
     return [[[self alloc] initWithPage:aPage maxCount:aMaxCount] autorelease];
 }
@@ -76,6 +83,10 @@
     return [matches count];
 }
 
+- (NSString *)label {
+    return [self count] == 1 ? NSLocalizedString(@"1 Result", @"") : [NSString 
stringWithFormat:NSLocalizedString(@"%ld Results", @""), (long)[self count]];
+}
+
 - (void)addMatch:(PDFSelection *)match {
     [self willChangeValueForKey:SKGroupedSearchResultCountKey];
     CGFloat order = [match boundsOrderForPage:page];

Modified: trunk/SKImageToolTipContext.m
===================================================================
--- trunk/SKImageToolTipContext.m       2021-11-08 16:05:55 UTC (rev 12537)
+++ trunk/SKImageToolTipContext.m       2021-11-08 16:53:10 UTC (rev 12538)
@@ -204,8 +204,7 @@
 #pragma clang diagnostic ignored "-Wpartial-availability"
     [selections setValue:[NSColor findHighlightColor] forKey:@"color"];
 #pragma clang diagnostic pop
-    NSString *label = [self count] == 1 ? NSLocalizedString(@"1 Result", @"") 
: [NSString stringWithFormat:NSLocalizedString(@"%ld Results", @""), 
(long)[self count]];
-    return [[[selections firstObject] destination] 
toolTipImageWithOffset:NSMakePoint(-50.0, 20.0) scale:scale 
selections:selections label:label];
+    return [[[selections firstObject] destination] 
toolTipImageWithOffset:NSMakePoint(-50.0, 20.0) scale:scale 
selections:selections label:[self label]];
 }
 
 @end

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to