|
@@ -98,15 +98,6 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
var selectTypeArray: NSMutableArray?
|
|
|
var selectColorArray: NSMutableArray?
|
|
|
var selectAuthorArray: NSMutableArray?
|
|
|
-
|
|
|
- /*
|
|
|
- @property (nonatomic, retain) NSArray *notesArray;
|
|
|
-
|
|
|
- @property (nonatomic,copy) void (^applyFilterCallback) (NSArray *authorArr, NSArray *colorArr, NSArray *typeArr, BOOL isEmpty);
|
|
|
-
|
|
|
- @property (nonatomic,copy) void (^cancelCallback) (BOOL isCancel);
|
|
|
-
|
|
|
- */
|
|
|
|
|
|
@IBOutlet weak var typeLabel: NSTextField!
|
|
|
@IBOutlet weak var filterButtonView: NSView!
|
|
@@ -134,6 +125,13 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
private var _authorMutableArray: NSMutableArray?
|
|
|
private var _colorMutableArray: NSMutableArray?
|
|
|
|
|
|
+ var applyFilterCallback: ((_ authorArr: NSArray, _ colorArr: NSArray, _ typeArr: NSArray, _ isEmpty: Bool)->Void)?
|
|
|
+ var cancelCallback: ((_ isCancel: Bool)->Void)?
|
|
|
+
|
|
|
+ private let KMNoteOutlineFilterSelectArray_Type = "KMNoteOutlineFilterSelectArray_Type"
|
|
|
+ private let KMNoteOutlineFilterSelectArray_Author = "KMNoteOutlineFilterSelectArray_Author"
|
|
|
+ private let KMNoteOutlineFilterSelectArray_Color = "KMNoteOutlineFilterSelectArray_Color"
|
|
|
+
|
|
|
deinit {
|
|
|
KMPrint("KMNoteOutlineFilterViewController deinit.")
|
|
|
|
|
@@ -208,6 +206,51 @@ class KMNoteOutlineFilterViewController: NSViewController {
|
|
|
self._updateViewColor()
|
|
|
}
|
|
|
|
|
|
+ @IBAction func clearButtonAction(_ sender: NSButton) {
|
|
|
+ self.selectAuthorArray?.removeAllObjects()
|
|
|
+ self.selectColorArray?.removeAllObjects()
|
|
|
+ self.selectTypeArray?.removeAllObjects()
|
|
|
+
|
|
|
+ self.authorCollectionView.reloadData()
|
|
|
+ self.colorCollectionView.reloadData()
|
|
|
+ self.typeCollectionView.reloadData()
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func cancelButtonAction(_ sender: NSButton) {
|
|
|
+ if (self.cancelCallback != nil) {
|
|
|
+ self.cancelCallback!(true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func applyButtonAction(_ sender: NSButton) {
|
|
|
+ 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 sud = UserDefaults.standard
|
|
|
+ sud.set(data1, forKey: KMNoteOutlineFilterSelectArray_Type)
|
|
|
+ sud.set(data2, forKey: KMNoteOutlineFilterSelectArray_Color)
|
|
|
+ sud.set(data3, forKey: KMNoteOutlineFilterSelectArray_Author)
|
|
|
+ sud.synchronize()
|
|
|
+
|
|
|
+ var isEmpty = false
|
|
|
+ if (self.selectTypeArray!.count == 0 && self.selectColorArray!.count == 0 && self.selectAuthorArray!.count == 0) {
|
|
|
+ isEmpty = true
|
|
|
+ }
|
|
|
+ if (self.selectTypeArray!.count == 0) {
|
|
|
+ self.selectTypeArray = self._typeMutableArray
|
|
|
+ }
|
|
|
+ if (self.selectColorArray!.count == 0) {
|
|
|
+ self.selectColorArray = self._colorMutableArray
|
|
|
+ }
|
|
|
+ if (self.selectAuthorArray!.count == 0) {
|
|
|
+ self.selectAuthorArray = self._authorMutableArray
|
|
|
+ }
|
|
|
+ if (self.applyFilterCallback != nil) {
|
|
|
+ self.applyFilterCallback!(NSArray(array: self.selectTypeArray!), NSArray(array: self.selectColorArray!), NSArray(array: self.selectAuthorArray!), isEmpty)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// MARK: - Private Methods
|