Ballot.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2014-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import <Foundation/Foundation.h>
  21. #import <CoreData/CoreData.h>
  22. @class Contact,BallotChoice, BallotMessage, Conversation;
  23. @interface Ballot : NSManagedObject
  24. @property (nonatomic, retain) NSNumber * assessmentType;
  25. @property (nonatomic, retain) NSNumber * choicesType;
  26. @property (nonatomic, retain) NSDate * createDate;
  27. @property (nonatomic, retain) NSString * creatorId;
  28. @property (nonatomic, retain) NSString * title;
  29. @property (nonatomic, retain) NSData * id;
  30. @property (nonatomic, retain) NSDate * modifyDate;
  31. @property (nonatomic, retain) NSNumber * state;
  32. @property (nonatomic, retain) NSNumber * type;
  33. @property (nonatomic, retain) NSNumber * unreadUpdateCount;
  34. @property (nonatomic, retain) NSSet *choices;
  35. @property (nonatomic, retain) Conversation *conversation;
  36. @property (nonatomic, retain) NSSet *message;
  37. // participants are persisted when the ballot is closed
  38. @property (nonatomic, retain) NSSet *participants;
  39. @end
  40. @interface Ballot (CoreDataGeneratedAccessors)
  41. - (void)addChoicesObject:(BallotChoice *)value;
  42. - (void)removeChoicesObject:(BallotChoice *)value;
  43. - (void)addChoices:(NSSet *)values;
  44. - (void)removeChoices:(NSSet *)values;
  45. - (void)addMessageObject:(BallotMessage *)value;
  46. - (void)removeMessageObject:(BallotMessage *)value;
  47. - (void)addMessage:(NSSet *)values;
  48. - (void)removeMessage:(NSSet *)values;
  49. - (void)addParticipantsObject:(Contact *)value;
  50. - (void)removeParticipantsObject:(Contact *)value;
  51. - (void)addParticipants:(NSSet *)values;
  52. - (void)removeParticipants:(NSSet *)values;
  53. #pragma mark - own definitions & methods
  54. enum {
  55. kBallotStateOpen = 0,
  56. kBallotStateClosed
  57. };
  58. enum {
  59. kBallotTypeClosed = 0,
  60. kBallotTypeIntermediate
  61. };
  62. enum {
  63. kBallotAssessmentTypeSingle = 0,
  64. kBallotAssessmentTypeMultiple
  65. };
  66. - (NSArray *)choicesSortedByOrder;
  67. - (void)setClosed;
  68. - (void)setMultipleChoice:(BOOL)multipleChoice;
  69. - (void)setIntermediate:(BOOL)intermediate;
  70. - (BOOL)isClosed;
  71. - (BOOL)isMultipleChoice;
  72. - (BOOL)isIntermediate;
  73. - (BOOL)displayResult;
  74. - (BOOL)isOwn;
  75. - (BOOL)canEdit;
  76. - (void)incrementUnreadUpdateCount;
  77. - (void)resetUnreadUpdateCount;
  78. - (NSInteger)numberOfReceivedVotes;
  79. - (NSInteger)participantCount;
  80. @end