|
@@ -11,6 +11,7 @@ extension KMNoteOutlineFilterViewController {
|
|
|
static let filterSelectTypeKey = "KMNoteOutlineFilterSelectArray_Type"
|
|
|
static let filterSelectAuthorKey = "KMNoteOutlineFilterSelectArray_Author"
|
|
|
static let filterSelectColorKey = "KMNoteOutlineFilterSelectArray_Color"
|
|
|
+ static let filterSelectStateKey = "KMNoteOutlineFilterSelectArray_State"
|
|
|
}
|
|
|
|
|
|
typealias NoteFilterVC = KMNoteOutlineFilterViewController
|
|
@@ -161,6 +162,7 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
var selectTypeArray: NSMutableArray?
|
|
|
var selectColorArray: NSMutableArray?
|
|
|
var selectAuthorArray: NSMutableArray?
|
|
|
+ var selectStateArray: NSMutableArray?
|
|
|
|
|
|
@IBOutlet weak var typeLabel: NSTextField!
|
|
|
@IBOutlet weak var filterButtonView: NSView!
|
|
@@ -316,6 +318,16 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
self.selectAuthorArray = NSMutableArray()
|
|
|
}
|
|
|
|
|
|
+ if let data = sud.object(forKey: Self.filterSelectStateKey + (self.listView?.document?.documentURL.path ?? "")) as? NSData {
|
|
|
+ if let array = NSKeyedUnarchiver.unarchiveObject(with: data as Data) as? NSArray {
|
|
|
+ self.selectAuthorArray = NSMutableArray(array: array)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if self.selectStateArray == nil {
|
|
|
+ self.selectStateArray = NSMutableArray()
|
|
|
+ }
|
|
|
+
|
|
|
self.mainScrollView.documentView?.addSubview(self.stateLabel)
|
|
|
self.stateLabel.mas_makeConstraints { make in
|
|
|
make?.leading.equalTo()(16)
|
|
@@ -355,10 +367,12 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
self.selectAuthorArray?.removeAllObjects()
|
|
|
self.selectColorArray?.removeAllObjects()
|
|
|
self.selectTypeArray?.removeAllObjects()
|
|
|
+ self.selectStateArray?.removeAllObjects()
|
|
|
|
|
|
self.authorCollectionView.reloadData()
|
|
|
self.colorCollectionView.reloadData()
|
|
|
self.typeCollectionView.reloadData()
|
|
|
+ self.collectionView.reloadData()
|
|
|
}
|
|
|
|
|
|
@IBAction func cancelButtonAction(_ sender: NSButton) {
|
|
@@ -371,11 +385,13 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
let data1 = NSKeyedArchiver.archivedData(withRootObject: NSArray(array: self.selectTypeArray!))
|
|
|
let data2 = NSKeyedArchiver.archivedData(withRootObject: NSArray(array: self.selectColorArray!))
|
|
|
let data3 = NSKeyedArchiver.archivedData(withRootObject: NSArray(array: self.selectAuthorArray!))
|
|
|
+ let data4 = NSKeyedArchiver.archivedData(withRootObject: NSArray(array: self.selectStateArray!))
|
|
|
|
|
|
let sud = UserDefaults.standard
|
|
|
sud.set(data1, forKey: Self.filterSelectTypeKey + (self.listView?.document?.documentURL.path ?? ""))
|
|
|
sud.set(data2, forKey: Self.filterSelectColorKey + (self.listView?.document?.documentURL.path ?? ""))
|
|
|
sud.set(data3, forKey: Self.filterSelectAuthorKey + (self.listView?.document?.documentURL.path ?? ""))
|
|
|
+ sud.set(data4, forKey: Self.filterSelectStateKey + (self.listView?.document?.documentURL.path ?? ""))
|
|
|
sud.synchronize()
|
|
|
|
|
|
var isEmpty = false
|
|
@@ -391,6 +407,11 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
if (self.selectAuthorArray!.count == 0) {
|
|
|
self.selectAuthorArray = self._authorMutableArray
|
|
|
}
|
|
|
+ if (self.selectStateArray!.count == 0) {
|
|
|
+ for state in stateArray_ {
|
|
|
+ self.selectStateArray?.add(NSNumber(value: state.rawValue))
|
|
|
+ }
|
|
|
+ }
|
|
|
if (self.applyFilterCallback != nil) {
|
|
|
self.applyFilterCallback!(NSArray(array: self.selectTypeArray!), NSArray(array: self.selectColorArray!), NSArray(array: self.selectAuthorArray!), isEmpty)
|
|
|
}
|
|
@@ -537,21 +558,26 @@ extension KMNoteOutlineFilterViewController: NSCollectionViewDelegate, NSCollect
|
|
|
return item
|
|
|
} else if collectionView.isEqual(to: self.collectionView) {
|
|
|
let item = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMNoteFilterStateCollevtionViewItem"), for: indexPath) as! KMNoteFilterStateCollevtionViewItem
|
|
|
-// let author = self._authorMutableArray![indexPath.item]
|
|
|
-// if let data = self.selectAuthorArray?.contains(author), data {
|
|
|
-// item.selectAuthor(author as! String, isSelect: true)
|
|
|
-// } else {
|
|
|
-// item.selectAuthor(author as! String, isSelect: false)
|
|
|
-// }
|
|
|
|
|
|
-// item.authorClickCallback = { [weak self] author in
|
|
|
-// if let data = self?.selectAuthorArray?.contains(author), data {
|
|
|
-// self?.selectAuthorArray?.remove(author)
|
|
|
-// } else {
|
|
|
-// self?.selectAuthorArray?.add(author)
|
|
|
-// }
|
|
|
-// }
|
|
|
let state = self.stateArray_[indexPath.item]
|
|
|
+ if let con = self.selectStateArray?.contains(NSNumber(value: state.rawValue)), con {
|
|
|
+ item.isSelected = true
|
|
|
+ } else {
|
|
|
+ item.isSelected = false
|
|
|
+ }
|
|
|
+ item.selectCallback = { [weak self] isSelect in
|
|
|
+ guard let state = self?.stateArray_[indexPath.item] else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let data = NSNumber(value: state.rawValue)
|
|
|
+ KMPrint("kkkkkkkkkkkkkkkkkkkkk")
|
|
|
+ if let con = self?.selectStateArray?.contains(data), con {
|
|
|
+ self?.selectStateArray?.remove(data)
|
|
|
+ } else {
|
|
|
+ self?.selectStateArray?.add(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+// let state = self.stateArray_[indexPath.item]
|
|
|
item.label.stringValue = KMPDFAnnotationStateGetString(state: state) ?? ""
|
|
|
if let data = KMPDFAnnotationStateGetIcon(state: state) {
|
|
|
item.iv.image = NSImage(named: data)
|