Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bookmark

git-svn-id: https://ichm.googlecode.com/svn/trunk@7 e1f60c0e-2a54-0410-99cd-d3f60e83567d
  • Loading branch information...
commit 19c16ed7e4c69ff9ce34116b5b0d18396d3f09c0 1 parent a768321
iamawalrus authored
View
1  .gitignore
@@ -1,2 +1,3 @@
build/
ichm.xcodeproj/splyb.*
+Frameworks/
View
848 Bookmark.xib
@@ -9,6 +9,7 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="21"/>
+ <integer value="82"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -60,7 +61,7 @@
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
- <object class="NSColor" key="NSColor">
+ <object class="NSColor" key="NSColor" id="961896355">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
</object>
@@ -109,7 +110,7 @@
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textBackgroundColor</string>
- <object class="NSColor" key="NSColor">
+ <object class="NSColor" key="NSColor" id="880920733">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
@@ -163,7 +164,7 @@
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="781166857">
- <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Add</string>
<reference key="NSSupport" ref="369980128"/>
@@ -171,7 +172,7 @@
<int key="NSButtonFlags">-2038284033</int>
<int key="NSButtonFlags2">129</int>
<string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
+ <string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
@@ -191,7 +192,7 @@
<int key="NSButtonFlags">-2038284033</int>
<int key="NSButtonFlags2">129</int>
<string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
+ <string type="base64-UTF8" key="NSKeyEquivalent">Gw</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
@@ -203,6 +204,413 @@
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
+ <object class="NSWindowTemplate" id="507922163">
+ <int key="NSWindowStyleMask">287</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{178, 664}, {664, 417}}</string>
+ <int key="NSWTFlags">603979776</int>
+ <string key="NSWindowTitle">Bookmarks</string>
+ <string key="NSWindowClass">NSPanel</string>
+ <nil key="NSViewClass"/>
+ <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <object class="NSView" key="NSWindowView" id="593148486">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSSplitView" id="747467316">
+ <reference key="NSNextResponder" ref="593148486"/>
+ <int key="NSvFlags">274</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomView" id="448607244">
+ <reference key="NSNextResponder" ref="747467316"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSScrollView" id="315083324">
+ <reference key="NSNextResponder" ref="448607244"/>
+ <int key="NSvFlags">274</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSClipView" id="573113634">
+ <reference key="NSNextResponder" ref="315083324"/>
+ <int key="NSvFlags">2304</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSOutlineView" id="429475557">
+ <reference key="NSNextResponder" ref="573113634"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{122, 394}</string>
+ <reference key="NSSuperview" ref="573113634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="_NSCornerView" key="NSCornerView">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{-26, 0}, {16, 17}}</string>
+ </object>
+ <object class="NSMutableArray" key="NSTableColumns">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTableColumn" id="936298404">
+ <double key="NSWidth">1.190000e+02</double>
+ <double key="NSMinWidth">1.600000e+01</double>
+ <double key="NSMaxWidth">1.000000e+03</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628032</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents"/>
+ <object class="NSFont" key="NSSupport" id="26">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.100000e+01</double>
+ <int key="NSfFlags">3100</int>
+ </object>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="969494351">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerTextColor</string>
+ <reference key="NSColor" ref="939875636"/>
+ </object>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="318385583">
+ <int key="NSCellFlags">337772096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="369980128"/>
+ <reference key="NSControlView" ref="429475557"/>
+ <object class="NSColor" key="NSBackgroundColor" id="74281778">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlBackgroundColor</string>
+ <reference key="NSColor" ref="961896355"/>
+ </object>
+ <reference key="NSTextColor" ref="177624219"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <reference key="NSTableView" ref="429475557"/>
+ </object>
+ </object>
+ <double key="NSIntercellSpacingWidth">3.000000e+00</double>
+ <double key="NSIntercellSpacingHeight">2.000000e+00</double>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC44MzkyMTU3IDAuODY2NjY2NjcgMC44NTg4MjM1NCAwLjk5MDAwMDAxAA</bytes>
+ </object>
+ <object class="NSColor" key="NSGridColor" id="643251177">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">gridColor</string>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC41AA</bytes>
+ </object>
+ </object>
+ <double key="NSRowHeight">1.700000e+01</double>
+ <int key="NSTvFlags">-767557632</int>
+ <int key="NSColumnAutoresizingStyle">4</int>
+ <int key="NSDraggingSourceMaskForLocal">15</int>
+ <int key="NSDraggingSourceMaskForNonLocal">0</int>
+ <bool key="NSAllowsTypeSelect">YES</bool>
+ <float key="NSOutlineViewIndentationPerLevelKey">1.000000e+01</float>
+ </object>
+ </object>
+ <string key="NSFrameSize">{122, 394}</string>
+ <reference key="NSSuperview" ref="315083324"/>
+ <reference key="NSNextKeyView" ref="429475557"/>
+ <reference key="NSDocView" ref="429475557"/>
+ <reference key="NSBGColor" ref="74281778"/>
+ <int key="NScvFlags">6</int>
+ </object>
+ <object class="NSScroller" id="522272554">
+ <reference key="NSNextResponder" ref="315083324"/>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{105, 1}, {15, 253}}</string>
+ <reference key="NSSuperview" ref="315083324"/>
+ <reference key="NSTarget" ref="315083324"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">9.962825e-01</double>
+ </object>
+ <object class="NSScroller" id="117432022">
+ <reference key="NSNextResponder" ref="315083324"/>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{-100, -100}, {104, 15}}</string>
+ <reference key="NSSuperview" ref="315083324"/>
+ <int key="NSsFlags">1</int>
+ <reference key="NSTarget" ref="315083324"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">9.916667e-01</double>
+ </object>
+ </object>
+ <string key="NSFrameSize">{122, 394}</string>
+ <reference key="NSSuperview" ref="448607244"/>
+ <reference key="NSNextKeyView" ref="573113634"/>
+ <int key="NSsFlags">528</int>
+ <reference key="NSVScroller" ref="522272554"/>
+ <reference key="NSHScroller" ref="117432022"/>
+ <reference key="NSContentView" ref="573113634"/>
+ <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+ </object>
+ </object>
+ <string key="NSFrameSize">{122, 394}</string>
+ <reference key="NSSuperview" ref="747467316"/>
+ <string key="NSClassName">NSView</string>
+ </object>
+ <object class="NSCustomView" id="430097707">
+ <reference key="NSNextResponder" ref="747467316"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSScrollView" id="101056552">
+ <reference key="NSNextResponder" ref="430097707"/>
+ <int key="NSvFlags">274</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSClipView" id="71725076">
+ <reference key="NSNextResponder" ref="101056552"/>
+ <int key="NSvFlags">2304</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTableView" id="340154077">
+ <reference key="NSNextResponder" ref="71725076"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{598, 377}</string>
+ <reference key="NSSuperview" ref="71725076"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTableHeaderView" key="NSHeaderView" id="1056359488">
+ <reference key="NSNextResponder" ref="460190783"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{598, 17}</string>
+ <reference key="NSSuperview" ref="460190783"/>
+ <reference key="NSTableView" ref="340154077"/>
+ </object>
+ <object class="_NSCornerView" key="NSCornerView" id="84813064">
+ <reference key="NSNextResponder" ref="101056552"/>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{-26, 0}, {16, 17}}</string>
+ <reference key="NSSuperview" ref="101056552"/>
+ </object>
+ <object class="NSMutableArray" key="NSTableColumns">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTableColumn" id="123282893">
+ <double key="NSWidth">1.880000e+02</double>
+ <double key="NSMinWidth">4.000000e+01</double>
+ <double key="NSMaxWidth">1.000000e+03</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628032</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Title</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor" id="169460976">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
+ </object>
+ <reference key="NSTextColor" ref="969494351"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="455703067">
+ <int key="NSCellFlags">337772096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="369980128"/>
+ <reference key="NSControlView" ref="340154077"/>
+ <reference key="NSBackgroundColor" ref="74281778"/>
+ <reference key="NSTextColor" ref="177624219"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="340154077"/>
+ </object>
+ <object class="NSTableColumn" id="779828339">
+ <double key="NSWidth">1.020000e+02</double>
+ <double key="NSMinWidth">4.000000e+01</double>
+ <double key="NSMaxWidth">1.000000e+03</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628032</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Tags</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSBackgroundColor" ref="169460976"/>
+ <reference key="NSTextColor" ref="969494351"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="1065849901">
+ <int key="NSCellFlags">337772096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="369980128"/>
+ <reference key="NSControlView" ref="340154077"/>
+ <reference key="NSBackgroundColor" ref="74281778"/>
+ <reference key="NSTextColor" ref="177624219"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="340154077"/>
+ </object>
+ <object class="NSTableColumn" id="1031918808">
+ <double key="NSWidth">2.990000e+02</double>
+ <double key="NSMinWidth">1.000000e+01</double>
+ <double key="NSMaxWidth">3.402823e+38</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628032</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Document</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerColor</string>
+ <reference key="NSColor" ref="880920733"/>
+ </object>
+ <reference key="NSTextColor" ref="969494351"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="406782229">
+ <int key="NSCellFlags">337772096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="369980128"/>
+ <reference key="NSControlView" ref="340154077"/>
+ <reference key="NSBackgroundColor" ref="74281778"/>
+ <reference key="NSTextColor" ref="177624219"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <reference key="NSTableView" ref="340154077"/>
+ </object>
+ </object>
+ <double key="NSIntercellSpacingWidth">3.000000e+00</double>
+ <double key="NSIntercellSpacingHeight">2.000000e+00</double>
+ <reference key="NSBackgroundColor" ref="880920733"/>
+ <reference key="NSGridColor" ref="643251177"/>
+ <double key="NSRowHeight">1.700000e+01</double>
+ <int key="NSTvFlags">-700448768</int>
+ <int key="NSColumnAutoresizingStyle">4</int>
+ <int key="NSDraggingSourceMaskForLocal">15</int>
+ <int key="NSDraggingSourceMaskForNonLocal">0</int>
+ <bool key="NSAllowsTypeSelect">YES</bool>
+ </object>
+ </object>
+ <string key="NSFrame">{{0, 17}, {598, 377}}</string>
+ <reference key="NSSuperview" ref="101056552"/>
+ <reference key="NSNextKeyView" ref="340154077"/>
+ <reference key="NSDocView" ref="340154077"/>
+ <reference key="NSBGColor" ref="74281778"/>
+ <int key="NScvFlags">6</int>
+ </object>
+ <object class="NSScroller" id="510769802">
+ <reference key="NSNextResponder" ref="101056552"/>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{522, 17}, {15, 340}}</string>
+ <reference key="NSSuperview" ref="101056552"/>
+ <reference key="NSTarget" ref="101056552"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">9.577465e-01</double>
+ </object>
+ <object class="NSScroller" id="1008769278">
+ <reference key="NSNextResponder" ref="101056552"/>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{-100, -100}, {527, 15}}</string>
+ <reference key="NSSuperview" ref="101056552"/>
+ <int key="NSsFlags">1</int>
+ <reference key="NSTarget" ref="101056552"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">9.948007e-01</double>
+ </object>
+ <object class="NSClipView" id="460190783">
+ <reference key="NSNextResponder" ref="101056552"/>
+ <int key="NSvFlags">2304</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="1056359488"/>
+ </object>
+ <string key="NSFrameSize">{598, 17}</string>
+ <reference key="NSSuperview" ref="101056552"/>
+ <reference key="NSNextKeyView" ref="1056359488"/>
+ <reference key="NSDocView" ref="1056359488"/>
+ <reference key="NSBGColor" ref="74281778"/>
+ <int key="NScvFlags">4</int>
+ </object>
+ <reference ref="84813064"/>
+ </object>
+ <string key="NSFrameSize">{598, 394}</string>
+ <reference key="NSSuperview" ref="430097707"/>
+ <reference key="NSNextKeyView" ref="71725076"/>
+ <int key="NSsFlags">560</int>
+ <reference key="NSVScroller" ref="510769802"/>
+ <reference key="NSHScroller" ref="1008769278"/>
+ <reference key="NSContentView" ref="71725076"/>
+ <reference key="NSHeaderClipView" ref="460190783"/>
+ <reference key="NSCornerView" ref="84813064"/>
+ <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+ </object>
+ </object>
+ <string key="NSFrame">{{123, 0}, {541, 394}}</string>
+ <reference key="NSSuperview" ref="747467316"/>
+ <string key="NSClassName">NSView</string>
+ </object>
+ </object>
+ <string key="NSFrame">{{0, 23}, {664, 394}}</string>
+ <reference key="NSSuperview" ref="593148486"/>
+ <bool key="NSIsVertical">YES</bool>
+ <int key="NSDividerStyle">2</int>
+ </object>
+ <object class="NSButton" id="226809430">
+ <reference key="NSNextResponder" ref="593148486"/>
+ <int key="NSvFlags">289</int>
+ <string key="NSFrame">{{623, -1}, {21, 25}}</string>
+ <reference key="NSSuperview" ref="593148486"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="296501519">
+ <int key="NSCellFlags">-2080244224</int>
+ <int key="NSCellFlags2">134348800</int>
+ <string key="NSContents">Round Textured</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="226809430"/>
+ <int key="NSButtonFlags">-2033958657</int>
+ <int key="NSButtonFlags2">163</int>
+ <object class="NSCustomResource" key="NSNormalImage">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSRemoveTemplate</string>
+ </object>
+ <string key="NSAlternateContents"/>
+ <string type="base64-UTF8" key="NSKeyEquivalent">fw</string>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrameSize">{664, 417}</string>
+ <reference key="NSSuperview"/>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <string key="NSFrameAutosaveName">BookmarkPanel</string>
+ </object>
+ <object class="NSArrayController" id="929209826">
+ <object class="NSMutableArray" key="NSDeclaredKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>title</string>
+ <string>tagsToString</string>
+ <string>file.title</string>
+ <string>tags</string>
+ <string>tagsString</string>
+ <string>bm.file.isValid</string>
+ <string>file.isValid</string>
+ </object>
+ <bool key="NSEditable">YES</bool>
+ <object class="_NSManagedProxy" key="_NSManagedProxy">
+ <string key="NSEntityName">Bookmark</string>
+ </object>
+ <bool key="_NSIsUsingManagedProxy">YES</bool>
+ <bool key="NSAvoidsEmptySelection">YES</bool>
+ <bool key="NSPreservesSelection">YES</bool>
+ <bool key="NSSelectsInsertedObjects">YES</bool>
+ <bool key="NSFilterRestrictsInsertion">YES</bool>
+ <bool key="NSClearsFilterPredicateOnInsertion">YES</bool>
+ </object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -247,6 +655,174 @@
</object>
<int key="connectionID">57</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">managedObjectContext: managedObjectContext</string>
+ <reference key="source" ref="929209826"/>
+ <reference key="destination" ref="1001"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="929209826"/>
+ <reference key="NSDestination" ref="1001"/>
+ <string key="NSLabel">managedObjectContext: managedObjectContext</string>
+ <string key="NSBinding">managedObjectContext</string>
+ <string key="NSKeyPath">managedObjectContext</string>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">93</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">value: arrangedObjects.title</string>
+ <reference key="source" ref="123282893"/>
+ <reference key="destination" ref="929209826"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="123282893"/>
+ <reference key="NSDestination" ref="929209826"/>
+ <string key="NSLabel">value: arrangedObjects.title</string>
+ <string key="NSBinding">value</string>
+ <string key="NSKeyPath">arrangedObjects.title</string>
+ <object class="NSDictionary" key="NSOptions">
+ <string key="NS.key.0">NSAllowsEditingMultipleValuesSelection</string>
+ <integer value="0" key="NS.object.0" id="8"/>
+ </object>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">99</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">value: arrangedObjects.file.title</string>
+ <reference key="source" ref="1031918808"/>
+ <reference key="destination" ref="929209826"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="1031918808"/>
+ <reference key="NSDestination" ref="929209826"/>
+ <string key="NSLabel">value: arrangedObjects.file.title</string>
+ <string key="NSBinding">value</string>
+ <string key="NSKeyPath">arrangedObjects.file.title</string>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">102</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">tableController</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="929209826"/>
+ </object>
+ <int key="connectionID">103</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">window</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="507922163"/>
+ </object>
+ <int key="connectionID">106</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dataSource</string>
+ <reference key="source" ref="429475557"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">108</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">tocView</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="429475557"/>
+ </object>
+ <int key="connectionID">109</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">filterBookmarks:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="429475557"/>
+ </object>
+ <int key="connectionID">110</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">initialFirstResponder</string>
+ <reference key="source" ref="109038487"/>
+ <reference key="destination" ref="340154077"/>
+ </object>
+ <int key="connectionID">111</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">nextKeyView</string>
+ <reference key="source" ref="420816584"/>
+ <reference key="destination" ref="810068274"/>
+ </object>
+ <int key="connectionID">113</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">nextKeyView</string>
+ <reference key="source" ref="810068274"/>
+ <reference key="destination" ref="420816584"/>
+ </object>
+ <int key="connectionID">114</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">value: arrangedObjects.tagsString</string>
+ <reference key="source" ref="779828339"/>
+ <reference key="destination" ref="929209826"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="779828339"/>
+ <reference key="NSDestination" ref="929209826"/>
+ <string key="NSLabel">value: arrangedObjects.tagsString</string>
+ <string key="NSBinding">value</string>
+ <string key="NSKeyPath">arrangedObjects.tagsString</string>
+ <object class="NSDictionary" key="NSOptions">
+ <string key="NS.key.0">NSAllowsEditingMultipleValuesSelection</string>
+ <reference key="NS.object.0" ref="8"/>
+ </object>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">116</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="507922163"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">117</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">remove:</string>
+ <reference key="source" ref="929209826"/>
+ <reference key="destination" ref="226809430"/>
+ </object>
+ <int key="connectionID">120</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">enabled: arrangedObjects.file.isValid</string>
+ <reference key="source" ref="1031918808"/>
+ <reference key="destination" ref="929209826"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="1031918808"/>
+ <reference key="NSDestination" ref="929209826"/>
+ <string key="NSLabel">enabled: arrangedObjects.file.isValid</string>
+ <string key="NSBinding">enabled</string>
+ <string key="NSKeyPath">arrangedObjects.file.isValid</string>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">127</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -399,6 +975,196 @@
<reference key="object" ref="1032422399"/>
<reference key="parent" ref="947288821"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">65</int>
+ <reference key="object" ref="507922163"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="593148486"/>
+ </object>
+ <reference key="parent" ref="1002"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">66</int>
+ <reference key="object" ref="593148486"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="747467316"/>
+ <reference ref="226809430"/>
+ </object>
+ <reference key="parent" ref="507922163"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">67</int>
+ <reference key="object" ref="747467316"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="448607244"/>
+ <reference ref="430097707"/>
+ </object>
+ <reference key="parent" ref="593148486"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">68</int>
+ <reference key="object" ref="448607244"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="315083324"/>
+ </object>
+ <reference key="parent" ref="747467316"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">69</int>
+ <reference key="object" ref="430097707"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="101056552"/>
+ </object>
+ <reference key="parent" ref="747467316"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">70</int>
+ <reference key="object" ref="315083324"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="522272554"/>
+ <reference ref="117432022"/>
+ <reference ref="429475557"/>
+ </object>
+ <reference key="parent" ref="448607244"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">71</int>
+ <reference key="object" ref="522272554"/>
+ <reference key="parent" ref="315083324"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">72</int>
+ <reference key="object" ref="117432022"/>
+ <reference key="parent" ref="315083324"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">73</int>
+ <reference key="object" ref="429475557"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="936298404"/>
+ </object>
+ <reference key="parent" ref="315083324"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">75</int>
+ <reference key="object" ref="936298404"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="318385583"/>
+ </object>
+ <reference key="parent" ref="429475557"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">78</int>
+ <reference key="object" ref="318385583"/>
+ <reference key="parent" ref="936298404"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">79</int>
+ <reference key="object" ref="101056552"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="510769802"/>
+ <reference ref="1008769278"/>
+ <reference ref="340154077"/>
+ <reference ref="1056359488"/>
+ </object>
+ <reference key="parent" ref="430097707"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">80</int>
+ <reference key="object" ref="510769802"/>
+ <reference key="parent" ref="101056552"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">81</int>
+ <reference key="object" ref="1008769278"/>
+ <reference key="parent" ref="101056552"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">82</int>
+ <reference key="object" ref="340154077"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="123282893"/>
+ <reference ref="779828339"/>
+ <reference ref="1031918808"/>
+ </object>
+ <reference key="parent" ref="101056552"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">83</int>
+ <reference key="object" ref="1056359488"/>
+ <reference key="parent" ref="101056552"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">84</int>
+ <reference key="object" ref="123282893"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="455703067"/>
+ </object>
+ <reference key="parent" ref="340154077"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">85</int>
+ <reference key="object" ref="779828339"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="1065849901"/>
+ </object>
+ <reference key="parent" ref="340154077"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">86</int>
+ <reference key="object" ref="1065849901"/>
+ <reference key="parent" ref="779828339"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">87</int>
+ <reference key="object" ref="455703067"/>
+ <reference key="parent" ref="123282893"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">88</int>
+ <reference key="object" ref="1031918808"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="406782229"/>
+ </object>
+ <reference key="parent" ref="340154077"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">89</int>
+ <reference key="object" ref="406782229"/>
+ <reference key="parent" ref="1031918808"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">90</int>
+ <reference key="object" ref="929209826"/>
+ <reference key="parent" ref="1002"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">118</int>
+ <reference key="object" ref="226809430"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="296501519"/>
+ </object>
+ <reference key="parent" ref="593148486"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">119</int>
+ <reference key="object" ref="296501519"/>
+ <reference key="parent" ref="226809430"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -408,6 +1174,8 @@
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
+ <string>118.IBPluginDependency</string>
+ <string>119.IBPluginDependency</string>
<string>20.IBEditorWindowLastContentRect</string>
<string>20.IBPluginDependency</string>
<string>20.IBWindowTemplateEditedContentRect</string>
@@ -428,16 +1196,43 @@
<string>33.IBPluginDependency</string>
<string>34.IBPluginDependency</string>
<string>35.IBPluginDependency</string>
+ <string>65.IBEditorWindowLastContentRect</string>
+ <string>65.IBPluginDependency</string>
+ <string>65.IBWindowTemplateEditedContentRect</string>
+ <string>65.NSWindowTemplate.visibleAtLaunch</string>
+ <string>65.windowTemplate.maxSize</string>
+ <string>66.IBPluginDependency</string>
+ <string>67.IBPluginDependency</string>
+ <string>68.IBPluginDependency</string>
+ <string>69.IBPluginDependency</string>
+ <string>70.IBPluginDependency</string>
+ <string>71.IBPluginDependency</string>
+ <string>72.IBPluginDependency</string>
+ <string>73.IBPluginDependency</string>
+ <string>75.IBPluginDependency</string>
+ <string>78.IBPluginDependency</string>
+ <string>79.IBPluginDependency</string>
+ <string>80.IBPluginDependency</string>
+ <string>81.IBPluginDependency</string>
+ <string>82.IBPluginDependency</string>
+ <string>83.IBPluginDependency</string>
+ <string>84.IBPluginDependency</string>
+ <string>85.IBPluginDependency</string>
+ <string>86.IBPluginDependency</string>
+ <string>87.IBPluginDependency</string>
+ <string>90.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{504, 949}, {435, 134}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{504, 949}, {435, 134}}</string>
- <integer value="0"/>
+ <reference ref="8"/>
<string>{3.40282e+38, 3.40282e+38}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -454,6 +1249,31 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{257, 656}, {664, 417}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{257, 656}, {664, 417}}</string>
+ <reference ref="8"/>
+ <string>{3.40282e+38, 3.40282e+38}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -476,7 +1296,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">57</int>
+ <int key="maxID">127</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -489,12 +1309,16 @@
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>endAddBookmark:</string>
+ <string>filterBookmarks:</string>
+ <string>openBookmark:</string>
<string>showAddBookmark:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
+ <string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -502,16 +1326,26 @@
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>addPanel</string>
+ <string>bookmarkMenu</string>
+ <string>groupByFilesMenu</string>
+ <string>groupByTagsMenu</string>
<string>managePanel</string>
+ <string>tableController</string>
<string>tagField</string>
<string>titleField</string>
+ <string>tocView</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSWindow</string>
+ <string>NSMenu</string>
+ <string>NSMenu</string>
+ <string>NSMenu</string>
<string>NSPanel</string>
+ <string>NSArrayController</string>
<string>NSTextField</string>
<string>NSTextField</string>
+ <string>NSOutlineView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
View
10 BookmarkController.h
@@ -8,27 +8,33 @@
#import <Cocoa/Cocoa.h>
@class CHMFile;
+@class CHMBookmark;
+@class FetchRequestItem;
@interface BookmarkController : NSWindowController {
IBOutlet NSWindow* addPanel;
IBOutlet NSTextField* titleField;
IBOutlet NSTextField* tagField;
IBOutlet NSMenu *bookmarkMenu;
+ IBOutlet NSMenu *groupByFilesMenu;
+ IBOutlet NSMenu *groupByTagsMenu;
+ IBOutlet NSOutlineView *tocView;
IBOutlet NSPanel* managePanel;
+ IBOutlet NSArrayController* tableController;
NSManagedObjectModel *managedObjectModel;
NSManagedObjectContext *managedObjectContext;
+ FetchRequestItem* tocSource;
}
- (IBAction)showAddBookmark:(id)sender;
- (IBAction)endAddBookmark:(id)sender;
- (IBAction)openBookmark:(id)sender;
+- (IBAction)filterBookmarks:(id)sender;
- (void)addBookmarkDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (NSManagedObjectModel *)managedObjectModel;
- (NSManagedObjectContext *)managedObjectContext;
-
-- (CHMFile *)fileByPath:(NSString*)path;
@end
View
343 BookmarkController.m
@@ -10,6 +10,70 @@
#import "CHMDocument.h"
#import "CHMFile.h"
#import "CHMBookmark.h"
+#import "CHMTag.h"
+
+@interface BookmarkController (Private)
+- (void)groupByTagsMenuNeedsUpdate:(NSMenu*)menu;
+- (void)groupByFilesMenuNeedsUpdate:(NSMenu*)menu;
+- (NSMenuItem *)createMenuItemForBookmark:(CHMBookmark*)bm;
+- (void)setupDataSource;
+- (void)addEmptyItemToMenu:(NSMenu*)menu;
+@end
+
+@interface FetchRequestItem : NSObject
+{
+ NSFetchRequest *request;
+ NSMutableArray* children;
+ NSString *title;
+}
+
+@property (readwrite, retain) NSFetchRequest* request;
+@property (readwrite, retain) NSString* title;
+
+- (void)addChild:(FetchRequestItem*)child;
+- (FetchRequestItem*)childAtIndex:(int)index;
+- (int)numberOfChildren;
+@end
+
+@implementation FetchRequestItem
+
+@synthesize request;
+@synthesize title;
+
+- (id)init
+{
+ children = [[NSMutableArray alloc] init];
+ request = nil;
+ title = nil;
+ return self;
+}
+
+- (void)dealloc
+{
+ if (request)
+ [request release];
+ if (title)
+ [title release];
+ [children release];
+ [super dealloc];
+}
+
+- (void)addChild:(FetchRequestItem*)child
+{
+ [children addObject:child];
+}
+
+- (FetchRequestItem*)childAtIndex:(int)index
+{
+ return [children objectAtIndex:index];
+}
+
+- (int)numberOfChildren
+{
+ return [children count];
+}
+
+@end
@implementation BookmarkController
@@ -17,12 +81,24 @@ - (id)init
{
if (![super initWithWindowNibName:@"Bookmark"])
return nil;
+
+ tocSource = nil;
+
+ [CHMFile purgeWithContext:[self managedObjectContext]];
+
return self;
}
- (void)windowDidLoad
{
NSLog(@"Nib file is loaded");
+ [tableController fetch:self];
+}
+
+- (IBAction)showWindow:(id)sender
+{
+ [self setupDataSource];
+ [super showWindow:sender];
}
- (IBAction)showAddBookmark:(id)sender
@@ -34,6 +110,12 @@ - (IBAction)showAddBookmark:(id)sender
CHMDocument *doc = (CHMDocument*)sender;
[titleField setStringValue:[doc currentTitle]];
[titleField selectText:self];
+ CHMBookmark* bm = [CHMBookmark bookmarkByURL:[doc currentURL] withContext:[self managedObjectContext]];
+ if( bm && [bm.tags count] > 0 )
+ [tagField setStringValue:[bm tagsString]];
+ else
+ [tagField setStringValue:@""];
+
[NSApp beginSheet:addPanel modalForWindow:[doc windowForSheet] modalDelegate:self didEndSelector:@selector(addBookmarkDidEnd:returnCode:contextInfo:) contextInfo:doc];
}
@@ -55,40 +137,51 @@ - (void)addBookmarkDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextIn
NSError *error = nil;
NSManagedObjectContext *context =[self managedObjectContext];
- CHMFile *chmFile = [self fileByPath:[doc filePath]] ;
+ CHMFile *chmFile = [CHMFile fileByPath:[doc filePath] withContext:context] ;
if (!chmFile)
{
chmFile = [NSEntityDescription
insertNewObjectForEntityForName:@"File"
inManagedObjectContext:context];
[chmFile setPath:[doc filePath]];
+ [chmFile setTitle:[doc docTitle]];
[context save:&error];
if ( ![context save:&error] )
NSLog(@"Can not fetch file info: %d",error );
}
- CHMBookmark *bookmark = [NSEntityDescription
+ CHMBookmark *bookmark = [CHMBookmark bookmarkByURL:[doc currentURL] withContext:[self managedObjectContext]];
+ if ( !bookmark )
+ {
+ bookmark = [NSEntityDescription
insertNewObjectForEntityForName:@"Bookmark"
inManagedObjectContext:context];
- [bookmark setPath:[doc currentURL]];
+ }
+ [bookmark setUrl:[doc currentURL]];
[bookmark setTitle:[titleField stringValue]];
[bookmark setCreatedAt:[NSDate date]];
[bookmark setFile:chmFile];
+ [bookmark setTagsString:[tagField stringValue]];
if ( ![context save:&error] )
{
NSLog(@"Can not fetch file info: %d",error );
return;
}
-
- NSMenuItem *newitem = [[[NSMenuItem alloc] init] autorelease];
- [newitem setTitle:bookmark.title];
- [newitem setTarget:self];
- [newitem setAction:@selector(openBookmark:)];
- [newitem setRepresentedObject:bookmark];
- [newitem setEnabled:YES];
- [bookmarkMenu insertItem:newitem atIndex:3];
}
+- (IBAction)filterBookmarks:(id)sender
+{
+ int selectedRow = [tocView selectedRow];
+ if( selectedRow >= 0 ) {
+ FetchRequestItem *item = [tocView itemAtRow:selectedRow];
+ NSError *error;
+ if ([item request])
+ [tableController fetchWithRequest:[item request] merge:NO error:&error];
+ else
+ [tableController fetch:sender];
+ }
+
+}
#pragma mark CoreData context
- (NSString *)applicationSupportFolder {
@@ -145,47 +238,114 @@ - (NSManagedObjectContext *) managedObjectContext {
return managedObjectContext;
}
-#pragma mark data accessing
-- (CHMFile *)fileByPath:(NSString*)path
+#pragma mark Bookmark Menu
+
+#define BOOKMARK_LIMIT 15
+
+- (NSMenuItem *)createMenuItemForBookmark:(CHMBookmark*)bm
+{
+ NSMenuItem *newitem = [[[NSMenuItem alloc] init] autorelease];
+ [newitem setTitle:bm.title];
+ [newitem setTarget:self];
+ [newitem setAction:@selector(openBookmark:)];
+ [newitem setRepresentedObject:bm];
+ [newitem setEnabled:[bm.file.isValid boolValue] ];
+ return newitem;
+}
+
+- (void)addEmptyItemToMenu:(NSMenu*)menu
{
- if (!path)
- return nil;
+ NSMenuItem *newitem = [[[NSMenuItem alloc] init] autorelease];
+ [newitem setTitle:NSLocalizedString(@"(Empty)", @"(Empty menu)")];
+ [newitem setEnabled:NO];
+ [menu addItem:newitem];
+}
+
+- (void)groupByTagsMenuNeedsUpdate:(NSMenu*)menu
+{
+ NSArray *tags = [CHMTag allTagswithContext:[self managedObjectContext]];
- NSManagedObjectContext *context =[self managedObjectContext];
- NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
- NSEntityDescription *fileEntity = [NSEntityDescription
- entityForName:@"File" inManagedObjectContext:context];
- [request setEntity:fileEntity];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:
- @"path == %@", path];
- [request setPredicate:predicate];
- NSError *error = nil;
- NSArray *array = [context executeFetchRequest:request error:&error];
- if (array == nil)
+ while([menu numberOfItems] != 0)
+ [menu removeItemAtIndex:0];
+
+ if ( !tags || [tags count] == 0)
{
- NSLog(@"Can not fetch file info: %d",error );
- return nil;
+ [self addEmptyItemToMenu:menu];
+ return;
}
- if ([array count] == 0)
+
+ for (CHMTag* tag in tags)
{
- NSLog(@"Can not fetch file with path: %%",path );
- return nil;
+ NSSet * bookmarks = tag.bookmarks;
+ if ( [bookmarks count] == 0 )
+ continue;
+
+
+ NSMenuItem *newitem = [[[NSMenuItem alloc] init] autorelease];
+ [newitem setTitle:tag.tag];
+ [newitem setEnabled:YES];
+ NSMenu *newmenu = [[[NSMenu alloc] init] autorelease];
+ [newmenu setAutoenablesItems:NO];
+ [newitem setSubmenu:newmenu];
+ for (CHMBookmark * bm in bookmarks) {
+ [newmenu addItem:[self createMenuItemForBookmark:bm]];
+ }
+ [menu addItem:newitem];
}
- return [array objectAtIndex:0];
+
+ if ([menu numberOfItems] == 0)
+ [self addEmptyItemToMenu:menu];
}
-#pragma mark Bookmark Menu
-
-#define BOOKMAKR_LIMIT 15
+- (void)groupByFilesMenuNeedsUpdate:(NSMenu*)menu
+{
+ NSArray *files = [CHMFile allFileswithContext:[self managedObjectContext]];
+
+ while([menu numberOfItems] != 0)
+ [menu removeItemAtIndex:0];
+
+ if ( !files || [files count] == 0)
+ {
+ [self addEmptyItemToMenu:menu];
+ return;
+ }
+
+ for (CHMFile* file in files)
+ {
+ NSSet * bookmarks = file.bookmarks;
+ if ( [bookmarks count] == 0 )
+ continue;
+
+
+ NSMenuItem *newitem = [[[NSMenuItem alloc] init] autorelease];
+ [newitem setTitle:file.title];
+ [newitem setEnabled:YES];
+ NSMenu *newmenu = [[[NSMenu alloc] init] autorelease];
+ [newmenu setAutoenablesItems:NO];
+ [newitem setSubmenu:newmenu];
+ for (CHMBookmark * bm in bookmarks) {
+ [newmenu addItem:[self createMenuItemForBookmark:bm]];
+ }
+ [menu addItem:newitem];
+ }
+
+ if ([menu numberOfItems] == 0)
+ [self addEmptyItemToMenu:menu];
+}
- (void)menuNeedsUpdate:(NSMenu *)menu
{
NSDocumentController *controller = [NSDocumentController sharedDocumentController];
[[menu itemWithTag:0] setEnabled:(nil != [controller currentDocument])];
- while ([menu numberOfItems] > 3)
+ if (menu == groupByTagsMenu)
+ return [self groupByTagsMenuNeedsUpdate:groupByTagsMenu];
+ else if (menu == groupByFilesMenu)
+ return [self groupByFilesMenuNeedsUpdate:groupByFilesMenu];
+
+ while ([menu numberOfItems] > 0)
{
- [menu removeItemAtIndex:3];
+ [menu removeItemAtIndex:0];
}
NSManagedObjectContext *context =[self managedObjectContext];
@@ -193,7 +353,7 @@ - (void)menuNeedsUpdate:(NSMenu *)menu
NSEntityDescription *bookmarkEntity = [NSEntityDescription
entityForName:@"Bookmark" inManagedObjectContext:context];
[request setEntity:bookmarkEntity];
- [request setFetchLimit:BOOKMAKR_LIMIT];
+ [request setFetchLimit:BOOKMARK_LIMIT];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
initWithKey:@"createdAt" ascending:NO];
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
@@ -207,14 +367,11 @@ - (void)menuNeedsUpdate:(NSMenu *)menu
return;
}
for (CHMBookmark* bm in array) {
- NSMenuItem *newitem = [[[NSMenuItem alloc] init] autorelease];
- [newitem setTitle:[bm title]];
- [newitem setTarget:self];
- [newitem setAction:@selector(openBookmark:)];
- [newitem setRepresentedObject:bm];
- [newitem setEnabled:YES];
- [menu addItem:newitem];
+ [menu addItem:[self createMenuItemForBookmark:bm]];
}
+
+ if ([menu numberOfItems] == 0)
+ [self addEmptyItemToMenu:menu];
}
- (IBAction)openBookmark:(id)sender
@@ -224,6 +381,100 @@ - (IBAction)openBookmark:(id)sender
CHMBookmark * bm = (CHMBookmark*)[sender representedObject];
NSURL *url = [NSURL fileURLWithPath:bm.file.path];
CHMDocument* doc = [controller openDocumentWithContentsOfURL:url display:YES error:&error];
- [doc loadURL:[NSURL URLWithString:bm.path]];
+ [doc loadURL:[NSURL URLWithString:bm.url]];
+}
+
+# pragma mark NSOutlineView datasource
+- (void)setupDataSource
+{
+ if(tocSource)
+ [tocSource release];
+
+ tocSource = [[FetchRequestItem alloc] init];
+
+ FetchRequestItem * allItem = [[FetchRequestItem alloc] init];
+ [allItem setTitle:NSLocalizedString(@"All", @"All")];
+ [tocSource addChild:allItem];
+
+ NSManagedObjectContext *moc = [self managedObjectContext];
+ NSEntityDescription *bookmarkDescription = [NSEntityDescription
+ entityForName:@"Bookmark"
+ inManagedObjectContext:moc];
+
+ FetchRequestItem * tagsItem = [[FetchRequestItem alloc] init];
+ [tagsItem setTitle:NSLocalizedString(@"Tags", @"Tags")];
+ [tocSource addChild:tagsItem];
+ for (CHMTag* tag in [CHMTag allTagswithContext:moc])
+ {
+ if ([tag.bookmarks count] == 0)
+ continue;
+ FetchRequestItem * tagItem = [[FetchRequestItem alloc] init];
+ [tagItem setTitle:tag.tag];
+ NSFetchRequest * request = [[[NSFetchRequest alloc] init] autorelease];
+ [request setEntity:bookmarkDescription];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:
+ @"(ANY tags.tag == %@)", tag.tag];
+ [request setPredicate:predicate];
+ [tagItem setRequest:request];
+ [tagsItem addChild:tagItem];
+ }
+
+ FetchRequestItem * filesItem = [[FetchRequestItem alloc] init];
+ [filesItem setTitle:NSLocalizedString(@"Files", @"Files")];
+ [tocSource addChild:filesItem];
+ for (CHMFile* file in [CHMFile allFileswithContext:moc])
+ {
+ if ([file.bookmarks count] == 0)
+ continue;
+ FetchRequestItem * fileItem = [[FetchRequestItem alloc] init];
+ [fileItem setTitle:file.title];
+ NSFetchRequest * request = [[[NSFetchRequest alloc] init] autorelease];
+ [request setEntity:bookmarkDescription];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:
+ @"(file == %@)", file];
+ [request setPredicate:predicate];
+ [fileItem setRequest:request];
+ [filesItem addChild:fileItem];
+ }
+ [tocView reloadData];
+}
+
+- (int)outlineView:(NSOutlineView *)outlineView
+numberOfChildrenOfItem:(id)item
+{
+ if(!item)
+ item = tocSource;
+ return [(FetchRequestItem*)item numberOfChildren];
+}
+
+- (BOOL)outlineView:(NSOutlineView *)outlineView
+ isItemExpandable:(id)item
+{
+ return [item numberOfChildren] > 0;
+}
+
+- (id)outlineView:(NSOutlineView *)outlineView
+ child:(int)theIndex
+ ofItem:(id)item
+{
+ if (!item)
+ item = tocSource;
+
+ return [item childAtIndex:theIndex];
+}
+
+- (id)outlineView:(NSOutlineView *)outlineView
+objectValueForTableColumn:(NSTableColumn *)tableColumn
+ byItem:(id)item
+{
+ return [item title];
+}
+
+#pragma mark Bookmark manager window Delegate
+- (void)windowWillClose:(NSNotification *)notification
+{
+ NSError *error;
+ [CHMFile purgeWithContext:[self managedObjectContext]];
+ [[self managedObjectContext] save:&error];
}
@end
View
16 BookmarkView.h
@@ -0,0 +1,16 @@
+//
+// BookmarkView.h
+// ichm
+//
+// Created by Robin Lu on 8/12/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface BookmarkView : NSTableView {
+ IBOutlet NSArrayController* controller;
+}
+
+@end
View
23 BookmarkView.m
@@ -0,0 +1,23 @@
+//
+// BookmarkView.m
+// ichm
+//
+// Created by Robin Lu on 8/12/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "BookmarkView.h"
+
+
+@implementation BookmarkView
+- (void)keyUp:(NSEvent *)theEvent
+{
+ NSLog(@"keycode %d", [theEvent keyCode]);
+ if ([theEvent keyCode] == 51)
+ {
+ [controller remove:self];
+ NSError * error;
+ [[controller managedObjectContext] save:&error];
+ }
+}
+@end
View
5 CHMBookmark.h
@@ -15,12 +15,15 @@
{
}
-@property (retain) NSString * path;
+@property (retain) NSString * url;
@property (retain) NSString * title;
@property (retain) NSDate * createdAt;
@property (retain) CHMFile * file;
@property (retain) NSSet* tags;
+- (NSString*)tagsString;
++ (CHMBookmark *)bookmarkByURL:(NSString*)url withContext:(NSManagedObjectContext*)context;
+- (void)setTagsString:(NSString*)tags;
@end
@interface CHMBookmark (CoreDataGeneratedAccessors)
View
61 CHMBookmark.m
@@ -13,10 +13,69 @@
@implementation CHMBookmark
-@dynamic path;
+@dynamic url;
@dynamic title;
@dynamic createdAt;
@dynamic file;
@dynamic tags;
+- (NSString*)tagsString
+{
+ NSMutableString *str = [[[NSMutableString alloc] initWithString:@""] autorelease];
+ for (CHMTag * tag in self.tags) {
+ [str appendFormat:@"%@, ", tag.tag];
+ }
+ NSRange range = {[str length] - 2, 2};
+ [str deleteCharactersInRange:range];
+ return str;
+}
+
+- (void)setTagsString:(NSString*)tags
+{
+ if (!tags || [tags length] == 0)
+ return;
+ NSManagedObjectContext*context = [self managedObjectContext];
+
+ NSArray* taglist = [tags componentsSeparatedByString:@","];
+ NSMutableSet *set = [[NSMutableSet alloc] init];
+ for (NSString* tag in taglist) {
+ NSString* trimmed = [tag stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ if ( [trimmed length] > 0 )
+ {
+ CHMTag *tag = [CHMTag getTagByString:trimmed OnCreate:YES withContext:context];
+ if ( ![self.tags containsObject:tag] )
+ [set addObject:tag];
+ }
+ }
+ if ([set count] != 0)
+ [self addTags:set];
+ [set release];
+}
+
++ (CHMBookmark *)bookmarkByURL:(NSString*)url withContext:(NSManagedObjectContext*)context
+{
+ if (!url)
+ return nil;
+
+ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
+ NSEntityDescription *bookmarkEntity = [NSEntityDescription
+ entityForName:@"Bookmark" inManagedObjectContext:context];
+ [request setEntity:bookmarkEntity];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:
+ @"url == %@", url];
+ [request setPredicate:predicate];
+ NSError *error = nil;
+ NSArray *array = [context executeFetchRequest:request error:&error];
+ if (array == nil)
+ {
+ NSLog(@"Can not fetch bookmark info: %d",error );
+ return nil;
+ }
+ if ([array count] == 0)
+ {
+ return nil;
+ }
+ return [array objectAtIndex:0];
+}
+
@end
View
5 CHMDocument.h
@@ -42,6 +42,7 @@ struct chmFile;
float sidebarWidth;
CHMTableOfContent *tocSource ;
+ CHMTableOfContent *indexSource ;
CHMSearchResult *searchSource;
SKIndexRef skIndex;
@@ -55,10 +56,12 @@ struct chmFile;
}
@property (readonly) NSString* filePath;
+@property (readonly) NSString* docTitle;
+
- (NSString*)currentURL;
- (NSString*)currentTitle;
-- (BOOL) exist: (const char *)path;
+- (BOOL) exist: (NSString *)path;
- (NSData *)content: (NSString *)path;
- (BOOL)loadMetadata;
View
96 CHMDocument.m
@@ -78,6 +78,7 @@ - (void)setupTOCSource;
@implementation CHMDocument
@synthesize filePath;
+@synthesize docTitle;
- (id)init
{
@@ -338,11 +339,11 @@ static inline unsigned long readLong( NSData *data, unsigned int offset ) {
}
# pragma mark chmlib
-- (BOOL) exist: (const char *)path
+- (BOOL) exist: (NSString *)path
{
struct chmUnitInfo info;
if (chmFileHandle)
- return chm_resolve_object( chmFileHandle, path, &info ) != CHM_RESOLVE_SUCCESS;
+ return chm_resolve_object( chmFileHandle, [path UTF8String], &info ) == CHM_RESOLVE_SUCCESS;
return NO;
}
@@ -362,26 +363,27 @@ - (NSData *)content: (NSString *)path
}
struct chmUnitInfo info;
- if (chm_resolve_object( chmFileHandle, [path UTF8String], &info ) != CHM_RESOLVE_SUCCESS)
+ void *buffer = nil;
+ @synchronized(self)
{
- return nil;
+ if (chm_resolve_object( chmFileHandle, [path UTF8String], &info ) == CHM_RESOLVE_SUCCESS)
+ {
+ buffer = malloc( info.length );
+
+ if( buffer ) {
+ if( !chm_retrieve_object( chmFileHandle, &info, buffer, 0, info.length ) ) {
+ NSLog( @"Failed to load %qu bytes for %@", (long long)info.length, path );
+ free( buffer );
+ buffer = nil;
+ }
+ }
+ }
}
- void *buffer = malloc( info.length );
-
- if( !buffer ) {
- // Allocation failed
- NSLog( @"Failed to allocate %qu bytes for %@", (long long)info.length, path );
- return nil;
- }
-
- if( !chm_retrieve_object( chmFileHandle, &info, buffer, 0, info.length ) ) {
- NSLog( @"Failed to load %qu bytes for %@", (long long)info.length, path );
- free( buffer );
- return nil;
- }
-
- return [NSData dataWithBytesNoCopy:buffer length:info.length];
+ if (buffer)
+ return [NSData dataWithBytesNoCopy:buffer length:info.length];
+
+ return nil;
}
@@ -464,23 +466,22 @@ - (BOOL)loadMetadata {
case 6:
{
const char *data = (const char *)([systemData bytes] + offset + 4);
- char *tmpname = malloc(strlen(data)+5);
+ NSString *prefix = [[NSString alloc] initWithCString:data encoding:nameToEncoding(encodingName)];
if( !tocPath || [tocPath length] == 0 ) {
- sprintf(tmpname, "/%s.hhc", data);
- if ([self exist:tmpname])
+ NSString *path = [NSString stringWithFormat:@"/%@.hhc", prefix];
+ if ([self exist:path])
{
- tocPath = [[NSString alloc] initWithCString:tmpname encoding:nameToEncoding(encodingName)];
+ tocPath = path;
}
}
if ( !indexPath || [indexPath length] == 0 )
{
- sprintf(tmpname, "/%s.hhk", data);
- if ([self exist:tmpname])
+ NSString *path = [NSString stringWithFormat:@"/%@.hhk", prefix];
+ if ([self exist:path])
{
- indexPath = [[NSString alloc] initWithCString:tmpname encoding:nameToEncoding(encodingName)];
+ indexPath = path;
}
}
- free(tmpname);
NSLog( @"SYSTEM Table of contents: %@", tocPath );
}
break;
@@ -524,17 +525,17 @@ - (NSString *)findHomeForPath: (NSString *)basePath
NSString *separator = [basePath hasSuffix:@"/"]? @"" : @"/";
testPath = [NSString stringWithFormat:@"%@%@index.htm", basePath, separator];
- if( [self exist:[testPath UTF8String]] ) {
+ if( [self exist:testPath] ) {
return testPath;
}
testPath = [NSString stringWithFormat:@"%@%@default.html", basePath, separator];
- if( [self exist:[testPath UTF8String]] ) {
+ if( [self exist:testPath] ) {
return testPath;
}
testPath = [NSString stringWithFormat:@"%@%@default.htm", basePath, separator];
- if( [self exist:[testPath UTF8String]] ) {
+ if( [self exist:testPath] ) {
return testPath;
}
@@ -556,8 +557,6 @@ - (void)windowControllerDidLoadNib:(NSWindowController *) aController
[self setupTabBar];
[self addNewTab:self];
- [self goHome:self];
-
[tocView setDataSource:tocSource];
[tocView setAutoresizesOutlineColumn:NO];
if([tocSource rootChildrenCount]==0)
@@ -569,6 +568,8 @@ - (void)windowControllerDidLoadNib:(NSWindowController *) aController
if(curWidth > MinSidebarWidth)
sidebarWidth = curWidth;
+ [self goHome:self];
+
[self prepareSearchIndex];
}
@@ -587,7 +588,8 @@ - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
}
- (void)setupTOCSource{
- if(tocPath){
+ if (tocPath && [tocPath length] > 0)
+ {
NSData * tocData = [self content:tocPath];
CHMTableOfContent* newTOC = [[CHMTableOfContent alloc] initWithData:tocData encodingName:[self currentEncodingName]];
CHMTableOfContent* oldTOC = tocSource;
@@ -596,6 +598,17 @@ - (void)setupTOCSource{
if(oldTOC)
[oldTOC release];
}
+
+ if (indexPath && [indexPath length] > 0)
+ {
+ NSData * tocData = [self content:indexPath];
+ CHMTableOfContent* newTOC = [[CHMTableOfContent alloc] initWithData:tocData encodingName:[self currentEncodingName]];
+ CHMTableOfContent* oldTOC = indexSource;
+ indexSource = newTOC;
+
+ if(oldTOC)
+ [oldTOC release];
+ }
}
- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)docType {
@@ -655,8 +668,8 @@ - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
[self locateTOC:sender];
// set label for tab bar
- NSURL * url = [NSURL URLWithString:[sender mainFrameURL]];
- NSString *path = [url path];
+ NSURL * url = [[[frame dataSource] request] URL];
+ NSString *path = [[url absoluteString] substringFromIndex:11];
LinkItem* item = [tocSource itemForPath:path withStack:nil];
NSTabViewItem *tabItem = [docTabView selectedTabViewItem];
NSString *name = [item name];
@@ -838,7 +851,8 @@ - (IBAction)goHistory:(id)sender
- (IBAction)locateTOC:(id)sender
{
- NSString * path = [[NSURL URLWithString:[curWebView mainFrameURL]] path];
+ NSURL * url = [[[[curWebView mainFrame] dataSource] request] URL];
+ NSString *path = [[url absoluteString] substringFromIndex:11];
NSMutableArray *tocStack = [[NSMutableArray alloc] init];
LinkItem* item = [tocSource itemForPath:path withStack:tocStack];
NSEnumerator *enumerator = [tocStack reverseObjectEnumerator];
@@ -848,6 +862,7 @@ - (IBAction)locateTOC:(id)sender
NSInteger idx = [tocView rowForItem:item];
NSIndexSet *idxSet = [[NSIndexSet alloc] initWithIndex:idx];
[tocView selectRowIndexes:idxSet byExtendingSelection:NO];
+ [tocView scrollRowToVisible:idx];
[tocStack release];
}
@@ -1113,8 +1128,6 @@ static int forEachFile(struct chmFile *h,
- (void)buildSearchIndex
{
- [NSThread sleepForTimeInterval:1];
-
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
chm_enumerate(chmFileHandle, CHM_ENUMERATE_FILES||CHM_ENUMERATE_NORMAL, forEachFile, (void*)self);
[pool release];
@@ -1156,7 +1169,12 @@ - (IBAction)searchInFile:(id)sender
if (searchSource)
[searchSource release];
- searchSource = [[CHMSearchResult alloc] initwithTOC:tocSource];
+ if (indexSource)
+ searchSource = [[CHMSearchResult alloc] initwithTOC:indexSource];
+ else if (tocSource)
+ searchSource = [[CHMSearchResult alloc] initwithTOC:tocSource];
+ else
+ return;
SKSearchOptions options = kSKSearchOptionDefault;
SKIndexFlush(skIndex);
View
5 CHMFile.h
@@ -15,8 +15,13 @@
}
@property (retain) NSString * path;
+@property (retain) NSString * title;
@property (retain) NSSet* bookmarks;
+@property (retain) NSNumber * isValid;
++ (CHMFile *)fileByPath:(NSString*)path withContext:(NSManagedObjectContext*)context;
++ (NSArray*)allFileswithContext:(NSManagedObjectContext*)context;
++ (void)purgeWithContext:(NSManagedObjectContext*)context;
@end
@interface CHMFile (CoreDataGeneratedAccessors)
View
64 CHMFile.m
@@ -14,5 +14,69 @@ @implementation CHMFile
@dynamic path;
@dynamic bookmarks;
+@dynamic title;
+@dynamic isValid;
++ (CHMFile *)fileByPath:(NSString*)path withContext:(NSManagedObjectContext*)context
+{
+ if (!path)
+ return nil;
+
+ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
+ NSEntityDescription *fileEntity = [NSEntityDescription
+ entityForName:@"File" inManagedObjectContext:context];
+ [request setEntity:fileEntity];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:
+ @"path == %@", path];
+ [request setPredicate:predicate];
+ NSError *error = nil;
+ NSArray *array = [context executeFetchRequest:request error:&error];
+ if (array == nil)
+ {
+ NSLog(@"Can not fetch file info: %d",error );
+ return nil;
+ }
+ if ([array count] == 0)
+ {
+ NSLog(@"Can not fetch file with path: %%",path );
+ return nil;
+ }
+ return [array objectAtIndex:0];
+}
+
++ (NSArray*)allFileswithContext:(NSManagedObjectContext*)context
+{
+ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
+ NSEntityDescription *tagEntity = [NSEntityDescription
+ entityForName:@"File" inManagedObjectContext:context];
+ [request setEntity:tagEntity];
+ NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
+ initWithKey:@"title" ascending:YES];
+ [request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
+ [sortDescriptor release];
+ NSError *error = nil;
+ NSArray *array = [context executeFetchRequest:request error:&error];
+ if (array == nil)
+ {
+ NSLog(@"Can not fetch file info: %d",error );
+ }
+ return array;
+}
+
++ (void)purgeWithContext:(NSManagedObjectContext*)context
+{
+ NSArray * files = [CHMFile allFileswithContext:context];
+ for ( CHMFile * file in files )
+ {
+ if ([[file bookmarks] count] == 0)
+ [context deleteObject:file];
+ else
+ {
+ BOOL isDirectory;
+ BOOL isValid = [[NSFileManager defaultManager] fileExistsAtPath:[file path] isDirectory:&isDirectory] && !isDirectory ;
+ NSNumber *number = [[NSNumber alloc] initWithBool:isValid];
+ [file setIsValid:number];
+ }
+ }
+}
@end
View
2  CHMTableOfContent.m
@@ -314,6 +314,8 @@ - (void) dealloc
- (void)addPath:(NSString*)path Score:(float)score
{
LinkItem * item = [tableOfContent itemForPath:path withStack:nil];
+ if (!item)
+ return;
ScoredLinkItem * newitem = [[ScoredLinkItem alloc] initWithName:[item name] Path:[item path] Score:score];
[rootItems appendChild:newitem];
}
View
5 CHMTag.h
@@ -17,6 +17,8 @@
@property (retain) NSString * tag;
@property (retain) NSSet* bookmarks;
++ (CHMTag*)getTagByString:(NSString*)tagstr OnCreate:(BOOL)shouldCreate withContext:(NSManagedObjectContext*)context;
++ (NSArray*)allTagswithContext:(NSManagedObjectContext*)context;
@end
@interface CHMTag (CoreDataGeneratedAccessors)
@@ -25,5 +27,4 @@
- (void)addBookmarks:(NSSet *)value;
- (void)removeBookmarks:(NSSet *)value;
-@end
-
+@end
View
59 CHMTag.m
@@ -15,4 +15,61 @@ @implementation CHMTag
@dynamic tag;
@dynamic bookmarks;
-@end
++ (CHMTag*)getTagByString:(NSString*)tagstr OnCreate:(BOOL)shouldCreate withContext:(NSManagedObjectContext*)context
+{
+ if (!tagstr)
+ return nil;
+
+ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
+ NSEntityDescription *tagEntity = [NSEntityDescription
+ entityForName:@"Tag" inManagedObjectContext:context];
+ [request setEntity:tagEntity];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:
+ @"tag == %@", tagstr];
+ [request setPredicate:predicate];
+ NSError *error = nil;
+ NSArray *array = [context executeFetchRequest:request error:&error];
+ if (array == nil)
+ {
+ NSLog(@"Can not fetch tag info: %d",error );
+ return nil;
+ }
+ if ([array count] != 0)
+ return [array objectAtIndex:0];;
+
+ if (shouldCreate)
+ {
+ CHMTag *tag = [NSEntityDescription
+ insertNewObjectForEntityForName:@"Tag"
+ inManagedObjectContext:context];
+ tag.tag = tagstr;
+ if ( ![context save:&error] )
+ {
+ NSLog(@"Can not create tag: %d",error );
+ return nil;
+ }
+ return tag;
+ }
+ return nil;
+}
+
++ (NSArray*)allTagswithContext:(NSManagedObjectContext*)context
+{
+ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
+ NSEntityDescription *tagEntity = [NSEntityDescription
+ entityForName:@"Tag" inManagedObjectContext:context];
+ [request setEntity:tagEntity];
+ NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
+ initWithKey:@"tag" ascending:YES];
+ [request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
+ [sortDescriptor release];
+ NSError *error = nil;
+ NSArray *array = [context executeFetchRequest:request error:&error];
+ if (array == nil)
+ {
+ NSLog(@"Can not fetch tag info: %d",error );
+ }
+ return array;
+}
+
+@end
View
260 English.lproj/MainMenu.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="527"/>
+ <integer value="57"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -46,7 +46,7 @@
</object>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="110575045">
- <string key="NSTitle">NewApplication</string>
+ <string key="NSTitle">iChm</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="238522557">
@@ -638,6 +638,64 @@
<reference key="NSMixedImage" ref="310636482"/>
<int key="NSTag">2</int>
</object>
+ <object class="NSMenuItem" id="123608967">
+ <reference key="NSMenu" ref="496604764"/>
+ <string key="NSTitle">Group by Files</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="1033313550"/>
+ <reference key="NSMixedImage" ref="310636482"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="558830455">
+ <string key="NSTitle">Group by Files</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <bool key="NSNoAutoenable">YES</bool>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="877211933">
+ <reference key="NSMenu" ref="496604764"/>
+ <string key="NSTitle">Group by Tags</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="1033313550"/>
+ <reference key="NSMixedImage" ref="310636482"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="391550730">
+ <string key="NSTitle">Group by Tags</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <bool key="NSNoAutoenable">YES</bool>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="997093011">
+ <reference key="NSMenu" ref="496604764"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="1033313550"/>
+ <reference key="NSMixedImage" ref="310636482"/>
+ </object>
+ <object class="NSMenuItem" id="703728921">
+ <reference key="NSMenu" ref="496604764"/>
+ <string key="NSTitle">Recent</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference