Revision: 18551
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18551&view=rev
Author:   ununnilium
Date:     2012-03-13 22:24:52 +0000 (Tue, 13 Mar 2012)
Log Message:
-----------
Add support for smart and static groups

Modified Paths:
--------------
    trunk/bibdesk_ios/BDSKGroupTableViewController.m
    trunk/bibdesk_ios/BTParse.xcodeproj/project.pbxproj
    trunk/bibdesk_ios/BibDocument.m
    trunk/bibdesk_ios/en.lproj/MainStoryboard_iPad.storyboard
    trunk/bibdesk_ios/en.lproj/MainStoryboard_iPhone.storyboard

Modified: trunk/bibdesk_ios/BDSKGroupTableViewController.m
===================================================================
--- trunk/bibdesk_ios/BDSKGroupTableViewController.m    2012-03-13 06:37:32 UTC 
(rev 18550)
+++ trunk/bibdesk_ios/BDSKGroupTableViewController.m    2012-03-13 22:24:52 UTC 
(rev 18551)
@@ -41,9 +41,14 @@
 #import "BDSKPubTableViewController.h"
 #import "BibDocument.h"
 #import "BDSKPublicationsArray.h"
+#import "BDSKGroupsArray.h"
+#import "BDSKSmartGroup.h"
+#import "BDSKStaticGroup.h"
 
 @interface BDSKGroupTableViewController ()
 
+- (void)updateActivityIndicator;
+
 @end
 
 @implementation BDSKGroupTableViewController
@@ -69,6 +74,7 @@
  
     // Uncomment the following line to display an Edit button in the 
navigation bar for this view controller.
     // self.navigationItem.rightBarButtonItem = self.editButtonItem;
+    [self updateActivityIndicator];
 }
 
 - (void)viewDidUnload
@@ -91,18 +97,30 @@
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {
-    // Return the number of sections.
-    return 1;
+    if (self.document) return 3;
+    
+    return 0;
 }
 
 - (NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section
 {
-    // Return the number of rows in the section.
     if (section == 0) return 1;
+    if (section == 1) return [[[self.document groups] smartGroups] count];
+    if (section == 2) return [[[self.document groups] staticGroups] count];
+    if (section == 3) return [[[self.document groups] categoryGroups] count];
     
     return 0;
 }
 
+- (NSString *)tableView:(UITableView *)tableView 
titleForHeaderInSection:(NSInteger)section
+{
+    if (section == 1 && [[[self.document groups] smartGroups] count]) return 
@"Smart";
+    if (section == 2 && [[[self.document groups] staticGroups] count]) return 
@"Static";
+    if (section == 3 && [[[self.document groups] categoryGroups] count]) 
return @"Keywords";
+    
+    return nil;
+}
+
 - (UITableViewCell *)tableView:(UITableView *)tableView 
cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     static NSString *CellIdentifier = @"Cell";
@@ -117,6 +135,24 @@
         } else {
             cell.detailTextLabel.text = nil;
         }
+    
+    } else if (indexPath.section == 1) {
+    
+        BDSKSmartGroup *group = [[[document groups] smartGroups] 
objectAtIndex:indexPath.row];
+        cell.textLabel.text = [group name];
+        cell.detailTextLabel.text = [NSString stringWithFormat:@"%i", [group 
count]];
+        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+    
+    } else if (indexPath.section == 2) {
+    
+        BDSKStaticGroup *group = [[[document groups] staticGroups] 
objectAtIndex:indexPath.row];
+        cell.textLabel.text = [group name];
+        cell.detailTextLabel.text = [NSString stringWithFormat:@"%i", [group 
count]];
+        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+    
+    } else if (indexPath.section == 3) {
+    
+    
     }
     
     return cell;
@@ -165,9 +201,7 @@
 
 - (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    if (indexPath.section == 0) {
-        [self performSegueWithIdentifier:@"publications" sender:self];
-    }
+    [self performSegueWithIdentifier:@"publications" sender:self];
 }
 
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
@@ -180,6 +214,17 @@
         if (indexPath.section == 0 && indexPath.row == 0) {
             viewController.navigationItem.title = @"Library";
             viewController.bibItems = [NSArray 
arrayWithArray:self.document.publications];
+        } else if (indexPath.section == 1) {
+            BDSKSmartGroup *group = [[[document groups] smartGroups] 
objectAtIndex:indexPath.row];
+            viewController.navigationItem.title = [group name];
+            viewController.bibItems = [group 
filterItems:document.publications];
+        } else if (indexPath.section == 2) {
+            BDSKStaticGroup *group = [[[document groups] staticGroups] 
objectAtIndex:indexPath.row];
+            viewController.navigationItem.title = [group name];
+            viewController.bibItems = [group publications];
+        } else if (indexPath.section == 3) {
+            
+        
         }
     }
 }
@@ -189,13 +234,31 @@
     if (document != newDocument) {
         [document release];
         document = [newDocument retain];
+        NSArray *smartGroups = [[document groups] smartGroups];
+        for (BDSKSmartGroup *group in smartGroups) {
+            [group filterItems:document.publications];
+        }
         [self.tableView reloadData];
+        [self updateActivityIndicator];
     }
-    
-    if (document) {
-        self.tableView.allowsSelection = YES;
+}
+
+- (void)updateActivityIndicator
+{
+    if (self.document) {
+        self.navigationItem.rightBarButtonItem = nil;
     } else {
-        self.tableView.allowsSelection = NO;
+
+        UIActivityIndicatorViewStyle activityIndicatorViewStyle = 
UIActivityIndicatorViewStyleGray;
+        
+        // barStyle is 3 (undocumented) when in a popover controller
+        if (self.navigationController.navigationBar.barStyle > 2) 
activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
+        UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView 
alloc] initWithActivityIndicatorStyle:activityIndicatorViewStyle];
+        UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] 
initWithCustomView:activityIndicator];
+        self.navigationItem.rightBarButtonItem = refreshButton;
+        [activityIndicator startAnimating];
+        [refreshButton release];
+        [activityIndicator release];
     }
 }
 

Modified: trunk/bibdesk_ios/BTParse.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk_ios/BTParse.xcodeproj/project.pbxproj 2012-03-13 06:37:32 UTC 
(rev 18550)
+++ trunk/bibdesk_ios/BTParse.xcodeproj/project.pbxproj 2012-03-13 22:24:52 UTC 
(rev 18551)
@@ -322,7 +322,7 @@
                                GCC_DYNAMIC_NO_PIC = NO;
                                GCC_OPTIMIZATION_LEVEL = 0;
                                GCC_PREPROCESSOR_DEFINITIONS = (
-                                       "DEBUG=1",
+                                       "DEBUG=0",
                                        "$(inherited)",
                                );
                                GCC_SYMBOLS_PRIVATE_EXTERN = NO;

Modified: trunk/bibdesk_ios/BibDocument.m
===================================================================
--- trunk/bibdesk_ios/BibDocument.m     2012-03-13 06:37:32 UTC (rev 18550)
+++ trunk/bibdesk_ios/BibDocument.m     2012-03-13 22:24:52 UTC (rev 18551)
@@ -50,6 +50,7 @@
     if ((self = [super initWithFileURL:url])) {
     
         publications = [[BDSKPublicationsArray alloc] init];
+        groups = [[BDSKGroupsArray alloc] initWithDocument:self];
         macroResolver = [[BDSKMacroResolver alloc] initWithOwner:self];
         documentInfo = nil;
         wasLoaded = NO;

Modified: trunk/bibdesk_ios/en.lproj/MainStoryboard_iPad.storyboard
===================================================================
--- trunk/bibdesk_ios/en.lproj/MainStoryboard_iPad.storyboard   2012-03-13 
06:37:32 UTC (rev 18550)
+++ trunk/bibdesk_ios/en.lproj/MainStoryboard_iPad.storyboard   2012-03-13 
22:24:52 UTC (rev 18551)
@@ -160,7 +160,7 @@
             <objects>
                 <placeholder placeholderIdentifier="IBFirstResponder" 
id="NX7-64-Fbp" userLabel="First Responder" sceneMemberID="firstResponder"/>
                 <tableViewController id="V4M-S5-o2H" 
customClass="BDSKGroupTableViewController" sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" 
contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" 
style="plain" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="22" 
sectionFooterHeight="22" id="Gk4-mY-4HF">
+                    <tableView key="view" clipsSubviews="YES" 
contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" 
style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" 
id="Gk4-mY-4HF">
                         <rect key="frame" x="0.0" y="64" width="320" 
height="704"/>
                         <autoresizingMask key="autoresizingMask" 
widthSizable="YES" heightSizable="YES"/>
                         <color key="backgroundColor" white="1" alpha="1" 
colorSpace="calibratedWhite"/>

Modified: trunk/bibdesk_ios/en.lproj/MainStoryboard_iPhone.storyboard
===================================================================
--- trunk/bibdesk_ios/en.lproj/MainStoryboard_iPhone.storyboard 2012-03-13 
06:37:32 UTC (rev 18550)
+++ trunk/bibdesk_ios/en.lproj/MainStoryboard_iPhone.storyboard 2012-03-13 
22:24:52 UTC (rev 18551)
@@ -100,7 +100,7 @@
             <objects>
                 <placeholder placeholderIdentifier="IBFirstResponder" 
id="93w-rt-CRO" userLabel="First Responder" sceneMemberID="firstResponder"/>
                 <tableViewController id="Dmr-c8-l4c" 
customClass="BDSKGroupTableViewController" sceneMemberID="viewController">
-                    <tableView key="view" opaque="NO" clipsSubviews="YES" 
clearsContextBeforeDrawing="NO" contentMode="scaleToFill" 
alwaysBounceVertical="YES" dataMode="prototypes" style="plain" 
allowsSelection="NO" rowHeight="44" sectionHeaderHeight="22" 
sectionFooterHeight="22" id="8QT-bf-2O6">
+                    <tableView key="view" opaque="NO" clipsSubviews="YES" 
clearsContextBeforeDrawing="NO" contentMode="scaleToFill" 
alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" 
sectionHeaderHeight="22" sectionFooterHeight="22" id="8QT-bf-2O6">
                         <rect key="frame" x="0.0" y="64" width="320" 
height="416"/>
                         <autoresizingMask key="autoresizingMask" 
widthSizable="YES" heightSizable="YES"/>
                         <color key="backgroundColor" white="1" alpha="1" 
colorSpace="calibratedWhite"/>

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


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to