Flycut/FlycutEngine/FlycutStore.h

114 lines
4.2 KiB
C
Raw Normal View History

2011-03-20 15:16:13 +08:00
//
// FlycutStore.h
// Flycut
2011-03-20 15:16:13 +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
//
// 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>
#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
@protocol FlycutStoreDeleteDelegate <NSObject>
@optional
- (void)willDeleteClippingFromStore:(id)store AtIndex:(int)index;
@end
@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
// Our status information
bool modifiedSinceLastSaveStore;
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;
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;
-(void) clearModifiedSinceLastSaveStore;
-(void) pruneJournals;
-(void) clearInsertionJournalCount:(NSUInteger)count;
-(void) clearDeletionJournalCount:(NSUInteger)count;
2011-03-20 15:16:13 +08:00
// Retrieve various values
-(int) rememberNum;
2011-03-20 15:16:13 +08:00
-(int) displayLen;
-(int) jcListCount;
-(bool) modifiedSinceLastSaveStore;
-(NSArray *) insertionJournal;
-(NSArray *) deletionJournal;
-(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;
-(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;
-(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
-(bool) addClipping:(NSString *)clipping ofType:(NSString *)type fromAppLocalizedName:(NSString *)appLocalizedName fromAppBundleURL:(NSString *)bundleURL atTimestamp:(NSInteger) timestamp;
-(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
-(void) clearItem:(int)index;
2011-03-20 15:16:13 +08:00
// Delete all list clippings
-(void) clearList;
// 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
/** optional delegate (not retained) */
@property (nonatomic, nullable, assign) id<FlycutStoreDeleteDelegate> deleteDelegate;
2011-03-20 15:16:13 +08:00
// Delete all named clippings
@end