aboutsummaryrefslogtreecommitdiff
path: root/QSThingsPlugin
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-09-11 17:13:17 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-09-11 17:13:17 +0200
commit5870e5cf03ceaff7080174b573618631a413110e (patch)
tree1bbd9d0c441a7316bcd1e7997b917a17ab5de978 /QSThingsPlugin
parentce8b86a7522bda8896115ca7d0118c9d574f3a3f (diff)
Add tags and sections
Diffstat (limited to 'QSThingsPlugin')
-rw-r--r--QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h4
-rw-r--r--QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m52
-rw-r--r--QSThingsPlugin/Parsers/QSThingsTagsParser.h4
-rw-r--r--QSThingsPlugin/Parsers/QSThingsTagsParser.m33
-rw-r--r--QSThingsPlugin/Types/Constants.h10
-rw-r--r--QSThingsPlugin/Types/Constants.m9
6 files changed, 112 insertions, 0 deletions
diff --git a/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h
new file mode 100644
index 0000000..e81f8db
--- /dev/null
+++ b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.h
@@ -0,0 +1,4 @@
+@interface QSThingsAppSectionsParser : QSParser
+{
+}
+@end
diff --git a/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m
new file mode 100644
index 0000000..70a37ae
--- /dev/null
+++ b/QSThingsPlugin/Parsers/QSThingsAppSectionsParser.m
@@ -0,0 +1,52 @@
+#import "Constants.h"
+#import "QSThingsAppSectionsParser.h"
+#import "SQLHelper.h"
+
+@implementation QSThingsAppSectionsParser
+- (BOOL)validParserForPath:(NSString *)path {
+ return [[path lastPathComponent] isEqualToString:@"main.sqlite"];
+}
+
+// This is not really a parser, but having the sqlite helps us
+// confirm that this makes sense.
+- (NSArray *)objectsFromPath:(NSString *)path withSettings:(NSDictionary *)settings {
+ NSMutableArray *objects = [NSMutableArray array];
+
+ // Inbox
+ QSObject *inbox = [QSObject
+ makeObjectWithIdentifier: ThingsAppSectionKeyInbox];
+ [inbox setName:@"Inbox"];
+ [inbox setPrimaryType:kAppSectionType];
+ [objects addObject:inbox];
+
+ // Today
+ QSObject *today = [QSObject
+ makeObjectWithIdentifier: ThingsAppSectionKeyToday];
+ [today setName:@"Today"];
+ [today setPrimaryType:kAppSectionType];
+ [objects addObject:today];
+
+ // Upcoming
+ QSObject *upcoming = [QSObject
+ makeObjectWithIdentifier: ThingsAppSectionKeyUpcoming];
+ [upcoming setName:@"Upcoming"];
+ [upcoming setPrimaryType:kAppSectionType];
+ [objects addObject:upcoming];
+
+ // Anytime
+ QSObject *anytime = [QSObject
+ makeObjectWithIdentifier: ThingsAppSectionKeyAnytime];
+ [anytime setName:@"Anytime"];
+ [anytime setPrimaryType:kAppSectionType];
+ [objects addObject:anytime];
+
+ // Anytime
+ QSObject *someday = [QSObject
+ makeObjectWithIdentifier: ThingsAppSectionKeySomeday];
+ [someday setName:@"Someday"];
+ [someday setPrimaryType:kAppSectionType];
+ [objects addObject:someday];
+
+ return objects;
+}
+@end
diff --git a/QSThingsPlugin/Parsers/QSThingsTagsParser.h b/QSThingsPlugin/Parsers/QSThingsTagsParser.h
new file mode 100644
index 0000000..d57aac1
--- /dev/null
+++ b/QSThingsPlugin/Parsers/QSThingsTagsParser.h
@@ -0,0 +1,4 @@
+@interface QSThingsTagsParser : QSParser
+{
+}
+@end
diff --git a/QSThingsPlugin/Parsers/QSThingsTagsParser.m b/QSThingsPlugin/Parsers/QSThingsTagsParser.m
new file mode 100644
index 0000000..4a81de3
--- /dev/null
+++ b/QSThingsPlugin/Parsers/QSThingsTagsParser.m
@@ -0,0 +1,33 @@
+#import "Constants.h"
+#import "QSThingsTagsParser.h"
+#import "SQLHelper.h"
+
+@implementation QSThingsTagsParser
+- (BOOL)validParserForPath:(NSString *)path {
+ return [[path lastPathComponent] isEqualToString:@"main.sqlite"];
+}
+
+- (NSArray *)objectsFromPath:(NSString *)path withSettings:(NSDictionary *)settings {
+ NSString *query = @"SELECT "
+ "uuid, "
+ "title "
+ "FROM TMTag "
+ "ORDER BY title;";
+
+ NSArray *results = [SQLHelper executeSql:query onFile:path];
+
+ NSMutableArray *objects = [NSMutableArray array];
+ [results enumerateObjectsUsingBlock:^(NSDictionary *dictionary, NSUInteger i, BOOL *stop) {
+
+ QSObject *newObject = [QSObject
+ makeObjectWithIdentifier:[dictionary objectForKey:@"uuid"]];
+ [newObject setObject:dictionary forType:kTagType];
+ [newObject setName:[dictionary objectForKey:@"title"]];
+ [newObject setPrimaryType:kTagType];
+
+ [objects addObject:newObject];
+ }];
+
+ return objects;
+}
+@end
diff --git a/QSThingsPlugin/Types/Constants.h b/QSThingsPlugin/Types/Constants.h
index 044dcde..b94fd7a 100644
--- a/QSThingsPlugin/Types/Constants.h
+++ b/QSThingsPlugin/Types/Constants.h
@@ -9,3 +9,13 @@ extern NSString *const kTaskType;
#pragma mark - Keychain
extern NSString *const kKeychainService;
extern NSString *const kAuthenticationKeyKeychainKey;
+
+#pragma mark - App Section Keys
+typedef NSString* ThingsAppSectionKey NS_STRING_ENUM;
+
+extern ThingsAppSectionKey const ThingsAppSectionKeyInbox;
+extern ThingsAppSectionKey const ThingsAppSectionKeyToday;
+extern ThingsAppSectionKey const ThingsAppSectionKeyUpcoming;
+extern ThingsAppSectionKey const ThingsAppSectionKeyAnytime;
+extern ThingsAppSectionKey const ThingsAppSectionKeySomeday;
+extern ThingsAppSectionKey const ThingsURLRouteAdd;
diff --git a/QSThingsPlugin/Types/Constants.m b/QSThingsPlugin/Types/Constants.m
index e6158a2..d92d007 100644
--- a/QSThingsPlugin/Types/Constants.m
+++ b/QSThingsPlugin/Types/Constants.m
@@ -9,3 +9,12 @@ NSString *const kTaskType = @"things.task";
#pragma mark - Keychain
NSString *const kKeychainService = @"QSThingsPlugin";
NSString *const kAuthenticationKeyKeychainKey = @"authenticationKey";
+
+#pragma mark - App Section Keys
+typedef NSString* ThingsAppSectionKey NS_STRING_ENUM;
+
+ThingsAppSectionKey const ThingsAppSectionKeyInbox = @"things-app-section-inbox";
+ThingsAppSectionKey const ThingsAppSectionKeyToday = @"things-app-section-today";
+ThingsAppSectionKey const ThingsAppSectionKeyUpcoming = @"things-app-section-upcoming";
+ThingsAppSectionKey const ThingsAppSectionKeyAnytime = @"things-app-section-anytime";
+ThingsAppSectionKey const ThingsAppSectionKeySomeday = @"things-app-section-someday";