2011-03-20 15:16:13 +08:00
//
2016-04-09 23:18:45 +08:00
// FlycutStore.h
// Flycut
2011-03-20 15:16:13 +08:00
//
2016-04-09 23:18:45 +08:00
// Flycut by Gennadiy Potapov and contributors. Based on Jumpcut by Steve Cook.
// Copyright 2011 General Arcade. All rights reserved.
2011-03-20 15:16:13 +08:00
//
2016-04-09 23:18:45 +08:00
// This code is open-source software subject to the MIT License; see the homepage
// at <https://github.com/TermiT/Flycut> for details.
2011-03-20 15:16:13 +08:00
//
# import <Foundation / Foundation.h>
2016-04-09 23:18:45 +08:00
# import "FlycutClipping.h"
2011-03-20 15:16:13 +08:00
2017-09-03 11:13:52 +08:00
@ protocol FlycutStoreDelegate < NSObject >
@ optional
- ( void ) beginUpdates ; // allow multiple insert/delete of rows and sections to be animated simultaneously. Nestable
- ( void ) endUpdates ; // only call insert/delete/reload calls or change the editing state inside an update block. otherwise things like row count, etc. may be invalid.
- ( void ) insertClippingAtIndex : ( int ) index ;
- ( void ) deleteClippingAtIndex : ( int ) index ;
- ( void ) reloadClippingAtIndex : ( int ) index ;
- ( void ) moveClippingAtIndex : ( int ) index toIndex : ( int ) newIndex ;
@ end
2017-10-20 03:41:24 +08:00
@ protocol FlycutStoreDeleteDelegate < NSObject >
@ optional
- ( void ) willDeleteClippingFromStore : ( id ) store AtIndex : ( int ) index ;
@ end
2016-04-09 23:18:45 +08:00
@ interface FlycutStore : NSObject {
2011-03-20 15:16:13 +08:00
// Our various listener-related preferences
int jcRememberNum ; // The max we will allow users to display; 20
int jcDisplayNum ; // How many the user actually wants to display; defaults to 10
int jcDisplayLen ; // How many characters to display in the menu; defaults to 37
2017-10-20 03:20:34 +08:00
// Our status information
bool modifiedSinceLastSaveStore ;
2017-10-20 03:47:38 +08:00
NSUInteger insertionJournalCountLastSave ;
NSUInteger deletionJournalCountLastSave ;
2011-03-20 15:16:13 +08:00
// hash -- key values to clippings
// initially we will use PasteboardCount as the key value, but this will not be guaranteed
// to be unique once we allow for saving. Instead, we should use seconds since day 0 or some such.
// NSMutableDictionary * jcClippings;
// array -- stores key values for the last jcRememberNum text pasteboard items
NSMutableArray * jcList ;
2017-10-20 03:47:38 +08:00
NSMutableArray * insertionJournal ;
NSMutableArray * deletionJournal ;
2011-03-20 15:16:13 +08:00
}
- ( id ) initRemembering : ( int ) nowRemembering
displaying : ( int ) nowDisplaying
withDisplayLength : ( int ) displayLength ;
// Set various values
- ( void ) setRememberNum : ( int ) nowRemembering ;
- ( void ) setDisplayNum : ( int ) nowDisplaying ;
- ( void ) setDisplayLen : ( int ) newDisplayLength ;
2017-10-20 03:20:34 +08:00
- ( void ) clearModifiedSinceLastSaveStore ;
2017-10-20 03:47:38 +08:00
- ( void ) pruneJournals ;
- ( void ) clearInsertionJournalCount : ( NSUInteger ) count ;
- ( void ) clearDeletionJournalCount : ( NSUInteger ) count ;
2011-03-20 15:16:13 +08:00
// Retrieve various values
2015-07-21 11:19:43 +08:00
- ( int ) rememberNum ;
2011-03-20 15:16:13 +08:00
- ( int ) displayLen ;
- ( int ) jcListCount ;
2017-10-20 03:20:34 +08:00
- ( bool ) modifiedSinceLastSaveStore ;
2017-10-20 03:47:38 +08:00
- ( NSArray * ) insertionJournal ;
- ( NSArray * ) deletionJournal ;
2016-04-09 23:18:45 +08:00
- ( FlycutClipping * ) clippingAtPosition : ( int ) index ;
2011-03-20 15:16:13 +08:00
- ( NSString * ) clippingContentsAtPosition : ( int ) index ;
- ( NSString * ) clippingDisplayStringAtPosition : ( int ) index ;
- ( NSString * ) clippingTypeAtPosition : ( int ) index ;
- ( NSArray * ) previousContents : ( int ) howMany ;
- ( NSArray * ) previousDisplayStrings : ( int ) howMany ;
2015-09-03 11:21:25 +08:00
- ( NSArray * ) previousDisplayStrings : ( int ) howMany containing : ( NSString * ) search ;
- ( NSArray * ) previousIndexes : ( int ) howMany containing : ( NSString * ) search ; // This method is in newest-first order.
2017-09-03 11:13:52 +08:00
- ( int ) indexOfClipping : ( FlycutClipping * ) clipping ;
2017-07-28 13:58:44 +08:00
- ( int ) indexOfClipping : ( NSString * ) clipping ofType : ( NSString * ) type fromAppLocalizedName : ( NSString * ) appLocalizedName fromAppBundleURL : ( NSString * ) bundleURL atTimestamp : ( int ) timestamp ;
2017-09-03 11:13:52 +08:00
- ( bool ) removeDuplicates ;
2011-03-20 15:16:13 +08:00
// Add a clipping
2017-07-28 13:58:44 +08:00
- ( bool ) addClipping : ( NSString * ) clipping ofType : ( NSString * ) type fromAppLocalizedName : ( NSString * ) appLocalizedName fromAppBundleURL : ( NSString * ) bundleURL atTimestamp : ( NSInteger ) timestamp ;
2016-04-09 23:18:45 +08:00
- ( void ) addClipping : ( FlycutClipping * ) clipping ;
2017-09-03 11:13:52 +08:00
- ( void ) insertClipping : ( FlycutClipping * ) clipping atIndex : ( int ) index ;
2011-03-20 15:16:13 +08:00
// Delete a clipping
2011-11-21 15:44:58 +08:00
- ( void ) clearItem : ( int ) index ;
2011-03-20 15:16:13 +08:00
// Delete all list clippings
- ( void ) clearList ;
2013-10-26 02:31:37 +08:00
// Merge all list clippings
- ( void ) mergeList ;
2012-07-04 10:54:52 +08:00
// Move the clipping at index to the top
- ( void ) clippingMoveToTop : ( int ) index ;
2017-09-03 11:13:52 +08:00
- ( void ) clippingMoveFrom : ( int ) index To : ( int ) toIndex ;
/** optional delegate (not retained) */
@ property ( nonatomic , nullable , assign ) id < FlycutStoreDelegate > delegate ;
2012-07-04 10:54:52 +08:00
2017-10-20 03:41:24 +08:00
/** optional delegate (not retained) */
@ property ( nonatomic , nullable , assign ) id < FlycutStoreDeleteDelegate > deleteDelegate ;
2011-03-20 15:16:13 +08:00
// Delete all named clippings
@ end