task.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright 2009 Andrew Stromme <astromme@chatonka.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Library General Public License as
  6. * published by the Free Software Foundation; either version 2, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this program; if not, write to the
  16. * Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef RTM_TASK_H
  20. #define RTM_TASK_H
  21. // Qt Includes
  22. #include <QDate>
  23. #include <QTime>
  24. #include <QDateTime>
  25. #include <QString>
  26. #include <QObject>
  27. // Local Includes
  28. #include "rtm.h"
  29. #include "note.h"
  30. #include <QStringList>
  31. namespace RTM {
  32. class TaskPrivate;
  33. class Session;
  34. class RTM_EXPORT Task : public QObject
  35. {
  36. Q_OBJECT
  37. Q_PROPERTY(QStringList tags READ tags WRITE setTags)
  38. Q_PROPERTY(qulonglong listId READ listId WRITE setList)
  39. Q_PROPERTY(QDateTime completedTime READ completed)
  40. Q_PROPERTY(bool isCompleted READ isCompleted WRITE setCompleted)
  41. Q_PROPERTY(bool isDeleted READ isDeleted WRITE setDeleted)
  42. Q_PROPERTY(QDateTime deletedTime READ deleted)
  43. Q_PROPERTY(int priority READ priority WRITE setPriority)
  44. Q_PROPERTY(QDateTime due READ due WRITE setDue)
  45. Q_PROPERTY(QString name READ name WRITE setName)
  46. Q_PROPERTY(qulonglong seriesId READ seriesId)
  47. Q_PROPERTY(QString estimate READ estimate WRITE setEstimate)
  48. Q_PROPERTY(qulonglong locationId READ locationId WRITE setLocationId)
  49. Q_PROPERTY(QString repeatString READ repeatString WRITE setRepeatString)
  50. Q_PROPERTY(QString url READ url WRITE setUrl)
  51. Q_PROPERTY(qulonglong id READ id)
  52. //Q_PROPERTY(Notes notes READ notes WRITE setNotes)
  53. public:
  54. virtual ~Task();
  55. /** Creates a new task from QString task. Also uploads to RTM::Session session */
  56. static Task* createSyncTaskFromString(RTM::Session* session, const QString& task);
  57. static Task* uninitializedTask(RTM::Session* session);
  58. QStringList tags() const;
  59. RTM::ListId listId() const;
  60. QDateTime completed() const;
  61. bool isCompleted() const;
  62. bool isDeleted() const;
  63. QDateTime deleted() const;
  64. int priority() const;
  65. QDateTime due() const;
  66. QString name() const;
  67. RTM::TaskSeriesId seriesId() const;
  68. QString estimate() const;
  69. LocationId locationId() const;
  70. QString repeatString() const;
  71. QString url() const;
  72. RTM::TaskId id() const;
  73. Notes notes() const;
  74. void setTags(const QStringList &tags);
  75. void setList(ListId listId);
  76. void setCompleted(bool completed);
  77. void setDeleted(bool deleted);
  78. void setPriority(int priority);
  79. void setDue(const QDateTime& dueDate);
  80. void setDue(const QString& date);
  81. void setName(const QString& name);
  82. void setEstimate(const QString& estimate);
  83. void setLocationId(LocationId locationid);
  84. void setRepeatString(const QString& repeatString);
  85. void setUrl(const QString& url);
  86. void setNotes(const Notes& notes);
  87. void addTag(const Tag& tag);
  88. bool removeTag(const Tag& tag);
  89. void removeAllTags();
  90. void addNote(const QString& title, const QString& text);
  91. bool editNote(RTM::NoteId noteid, const QString& newTitle, const QString& newText);
  92. bool removeNote(RTM::NoteId noteid);
  93. void removeAllNotes();
  94. void postpone();
  95. int increasePriority(); // Returns priority
  96. int decreasePriority();
  97. void undoLastAction();
  98. private:
  99. Task(RTM::Session* session);
  100. friend class TasksReader;
  101. friend class TaskPrivate;
  102. TaskPrivate * const d;
  103. };
  104. } // namespace RTM
  105. #endif