Add a toolbar item for the chapter search.

This commit is contained in:
Damiano Galassi committed 2015-11-25 17:04:40 +01:00
1 parent 7c0aec17a5
commit 4cf14d86ef
6 files changed
+48 -31

No files matched your search

+2 -2
View File
@@ -16,9 +16,9 @@
@implementation SBChapterDB
- (NSArray<SBChapterResult *> *)searchTitle:(NSString *)aTitle duration:(NSUInteger)duration
- (NSArray<SBChapterResult *> *)searchTitle:(NSString *)title language:(nullable NSString *)language duration:(NSUInteger)duration
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.chapterdb.org/chapters/search?title=%@", [SBMetadataHelper urlEncoded:aTitle]]];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.chapterdb.org/chapters/search?title=%@", [SBMetadataHelper urlEncoded:title]]];
NSDictionary *headerOptions = @{@"ApiKey" : API_KEY};
NSData *xmlData = xmlData = [SBMetadataHelper dataFromUrl:url withHTTPMethod:@"GET" headerOptions:headerOptions error:nil];
@@ -20,13 +20,13 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)defaultProvider;
+ (instancetype)importerForProvider:(NSString *)aProviderName;
- (void) searchTitle:(NSString *)title duration:(NSUInteger)duration completionHandler:(void(^)(NSArray<SBChapterResult *> * _Nullable results))handler;
+ (instancetype)importerForProvider:(NSString *)providerName;
- (void) searchTitle:(NSString *)title language:(nullable NSString *)language duration:(NSUInteger)duration completionHandler:(void(^)(NSArray<SBChapterResult *> * _Nullable results))handler;
- (void) cancel;
#pragma mark Methods to be overridden
- (NSArray<SBChapterResult *> *)searchTitle:(NSString *)title duration:(NSUInteger)duration;
- (NSArray<SBChapterResult *> *)searchTitle:(NSString *)title language:(nullable NSString *)language duration:(NSUInteger)duration;
@end
+1
View File
@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
IBOutlet NSToolbarItem *addTracks;
IBOutlet NSToolbarItem *deleteTrack;
IBOutlet NSToolbarItem *searchMetadata;
IBOutlet NSToolbarItem *searchChapters;
IBOutlet NSToolbarItem *sendToQueue;
NSArray<NSString *> *languages;
+17 -5
View File
@@ -417,6 +417,10 @@
return YES;
}
if (toolbarItem == searchChapters) {
return YES;
}
if (toolbarItem == sendToQueue) {
return YES;
}
@@ -643,15 +647,18 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
#pragma mark - Metadata search
- (IBAction)searchMetadata:(id)sender
{
NSString *filename = nil;
- (NSString *)sourceFilename {
for (MP42Track *track in self.mp4.tracks) {
if (track.sourceURL) {
filename = track.sourceURL.lastPathComponent;
break;
return track.sourceURL.lastPathComponent;
}
}
return nil;
}
- (IBAction)searchMetadata:(id)sender
{
NSString *filename = [self sourceFilename];
if (!filename) {
filename = self.fileURL.lastPathComponent;
@@ -692,6 +699,11 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
- (IBAction)searchChapters:(id)sender
{
NSString *title = self.mp4.metadata[@"Name"];
if (title.length == 0) {
title = [self sourceFilename];
}
NSUInteger duration = self.mp4.duration;
_sheet = [[SBChapterSearchController alloc] initWithDelegate:self searchTitle:title andDuration:duration];
+8 -21
View File
@@ -13,7 +13,6 @@
<outlet property="progressText" destination="bkZ-I4-AOn" id="DoB-DJ-QrL"/>
<outlet property="resultsTable" destination="4Q0-U2-W6V" id="CQn-uV-G1f"/>
<outlet property="searchButton" destination="cCz-52-sHg" id="fLu-y9-7QM"/>
<outlet property="searchDuration" destination="lDD-CV-XEt" id="19l-fh-A6J"/>
<outlet property="searchTitle" destination="PZG-F6-4dQ" id="2L8-qm-FDY"/>
<outlet property="window" destination="QvC-M9-y7g" id="vD9-Oz-kVE"/>
</connections>
@@ -76,7 +75,7 @@ Gw
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="title" width="265.8203125" minWidth="40" maxWidth="1000" id="htV-Xa-Z7y">
<tableColumn identifier="title" width="243" minWidth="40" maxWidth="1000" id="htV-Xa-Z7y">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Title">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -89,8 +88,8 @@ Gw
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="chaptercount" editable="NO" width="50" minWidth="10" maxWidth="3.4028234663852886e+38" id="lfp-EW-qOv">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Chapter">
<tableColumn identifier="chaptercount" editable="NO" width="67" minWidth="10" maxWidth="3.4028234663852886e+38" id="lfp-EW-qOv">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Chapters">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
@@ -101,7 +100,7 @@ Gw
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</tableColumn>
<tableColumn identifier="duration" editable="NO" width="100" minWidth="10" maxWidth="3.4028234663852886e+38" id="wqo-sz-7xt">
<tableColumn identifier="duration" editable="NO" width="90" minWidth="10" maxWidth="3.4028234663852886e+38" id="wqo-sz-7xt">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Duration">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -113,17 +112,15 @@ Gw
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</tableColumn>
<tableColumn identifier="confirmations" editable="NO" width="80" minWidth="10" maxWidth="3.4028234663852886e+38" id="rAU-DM-LSF">
<tableColumn identifier="confirmations" editable="NO" width="96" minWidth="10" maxWidth="3.4028234663852886e+38" id="rAU-DM-LSF">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Confirmations">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tableHeaderCell>
<textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="STa-3L-ysZ">
<levelIndicatorCell key="dataCell" controlSize="small" state="on" alignment="left" doubleValue="3" maxValue="100" warningValue="3" criticalValue="3" levelIndicatorStyle="relevancy" id="b5O-HU-XVA">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</levelIndicatorCell>
<tableColumnResizingMask key="resizingMask" userResizable="YES"/>
</tableColumn>
</tableColumns>
@@ -256,7 +253,7 @@ Gw
</connections>
</button>
<textField verticalHuggingPriority="750" id="PZG-F6-4dQ">
<rect key="frame" x="59" y="427" width="277" height="22"/>
<rect key="frame" x="59" y="427" width="375" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="yrS-im-Pbr">
@@ -278,16 +275,6 @@ Gw
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="lDD-CV-XEt">
<rect key="frame" x="348" y="430" width="88" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" placeholderString="Duration" id="c4C-yO-p4R">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<animations/>
</view>
+17
View File
@@ -21,6 +21,7 @@
<outlet property="saveOperationName" destination="100177" id="100186"/>
<outlet property="saveView" destination="100187" id="100192"/>
<outlet property="savingWindow" destination="100175" id="100180"/>
<outlet property="searchChapters" destination="3A7-gZ-0ev" id="ntV-rn-nkt"/>
<outlet property="searchMetadata" destination="100302" id="100310"/>
<outlet property="sendToQueue" destination="100312" id="100316"/>
<outlet property="splitView" destination="100127" id="100262"/>
@@ -330,6 +331,22 @@
<action selector="searchMetadata:" target="-2" id="100309"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="B480C798-26BB-4FE2-B30D-57764B1305E0" label="Search Chapters" paletteLabel="Search Chapters" toolTip="Search metadata online" image="NSRevealFreestandingTemplate" id="3A7-gZ-0ev" customClass="ButtonToolbarItem">
<size key="minSize" width="34" height="25"/>
<size key="maxSize" width="34" height="25"/>
<button key="view" verticalHuggingPriority="750" id="SCB-YC-HmR">
<rect key="frame" x="31" y="14" width="34" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSRevealFreestandingTemplate" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hiJ-Cq-2gk">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<connections>
<action selector="searchChapters:" target="-2" id="ygs-Xb-wHQ"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="864986A8-F5EB-412B-A345-094EA449A2EA" label="Send to Queue" paletteLabel="Send to Queue" toolTip="Send the current document to the queue" image="ToolbarActionTemplate" id="100312" customClass="ButtonToolbarItem">
<size key="minSize" width="34" height="25"/>
<size key="maxSize" width="34" height="25"/>