~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to korganizer/views/todoview/kotodomodel.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#ifndef KOTODOMODEL_H
26
26
#define KOTODOMODEL_H
27
27
 
 
28
#include <kcalcore/todo.h>
 
29
 
28
30
#include <QAbstractItemModel>
29
 
#include <QStringList>
30
31
#include <QString>
31
32
#include <QHash>
32
33
 
33
 
namespace KCal {
 
34
#include <Akonadi/Item>
 
35
 
 
36
using namespace KCalCore;
 
37
 
 
38
namespace CalendarSupport {
34
39
  class Calendar;
35
 
  class Incidence;
36
 
  class Todo;
37
 
#ifndef KORG_NODND
38
 
  class DndFactory;
39
 
#endif
40
 
}
41
 
using namespace KCal;
42
 
 
43
 
namespace KOrg {
44
 
  class IncidenceChangerBase;
45
 
}
46
 
using namespace KOrg;
 
40
  class IncidenceChanger;
 
41
}
47
42
 
48
43
/**
49
44
        @author Thomas Thrainer
56
51
    /** This enum defines all columns this model provides */
57
52
    enum {
58
53
      SummaryColumn = 0,
59
 
      RecurColumn = 1,
60
 
      PriorityColumn = 2,
61
 
      PercentColumn = 3,
62
 
      DueDateColumn = 4,
63
 
      CategoriesColumn = 5,
64
 
      DescriptionColumn = 6
 
54
      RecurColumn,
 
55
      PriorityColumn,
 
56
      PercentColumn,
 
57
      DueDateColumn,
 
58
      CategoriesColumn,
 
59
      DescriptionColumn,
 
60
      CalendarColumn,
 
61
      ColumnCount // Just for iteration/column count purposes. Always keep at the end of enum.
65
62
    };
66
63
 
67
64
    /** This enum defines the user defined roles of the items in this model */
71
68
    };
72
69
 
73
70
  public:
74
 
    explicit KOTodoModel( Calendar *cal, QObject *parent = 0 );
 
71
    explicit KOTodoModel( QObject *parent = 0 );
75
72
    virtual ~KOTodoModel();
76
73
 
77
74
    /** Set the calendar */
78
 
    void setCalendar( Calendar *cal );
 
75
    void setCalendar( CalendarSupport::Calendar *cal );
79
76
    /** Resets the model and deletes the whole todo tree */
80
77
    void clearTodos();
81
78
    /** Reloads all todos from the Calendar provided during construction */
82
79
    void reloadTodos();
83
80
    /** Reloads only the specified todo (if the incidence is a todo) */
84
 
    void processChange( Incidence *incidence, int action );
 
81
    void processChange( const Akonadi::Item &incidence, int action );
85
82
 
86
 
    /** Creates a new todo with the given text as summary under the given parent */
87
 
    QModelIndex addTodo( const QString &summary,
88
 
                         const QModelIndex &parent = QModelIndex(),
89
 
                         const QStringList &categories = QStringList() );
90
 
    /** Copy the todo with the given index to the given date */
91
 
    void copyTodo( const QModelIndex &index, const QDate &date );
 
83
    Akonadi::Item todoForIndex( const QModelIndex &idx ) const;
92
84
 
93
85
    /** Sets the incidence changer used to edit incidences (todos)
94
86
     *
95
87
     * @param changer Pointer to the changer to use.
96
88
     */
97
 
    void setIncidenceChanger( IncidenceChangerBase *changer )
 
89
    void setIncidenceChanger( CalendarSupport::IncidenceChanger *changer )
98
90
    { mChanger = changer; }
99
91
 
100
92
    virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
139
131
     * or due today.
140
132
     */
141
133
    void expandIndex( const QModelIndex &index );
142
 
 
 
134
    void flatViewChanged( bool enabled );
143
135
  private:
144
136
    struct TodoTreeNode;
145
137
 
149
141
    /** Move the TodoTreeNode if the relationship of the todo's parent has
150
142
     *  changed and return a model index to the current node.
151
143
     */
152
 
    QModelIndex moveIfParentChanged( TodoTreeNode *curNode, Todo *todo,
 
144
    QModelIndex moveIfParentChanged( TodoTreeNode *curNode, const Akonadi::Item &todo,
153
145
                                     bool addParentIfMissing );
154
146
 
155
 
   /** Recursively find a todo.
156
 
    *
157
 
    * @param todo Pointer to the todo to find.
158
 
    * @return Pointer to the TodoTreeNode node which represents the todo
159
 
    *         searched for or 0 if not found.
160
 
    */
161
 
    TodoTreeNode *findTodo( const Todo *todo ) const;
 
147
    /** Recursively find a todo.
 
148
     *
 
149
     * @param uid uid to the todo to find.
 
150
     * @return Pointer to the TodoTreeNode node which represents the todo
 
151
     *         searched for or 0 if not found.
 
152
     */
 
153
    TodoTreeNode *findTodo( const QString &uid ) const;
162
154
 
163
155
    /**
164
156
     * If the todo is overdue or due today, the expandIndex signal
167
159
     *
168
160
     * @param todo the todo whose parents will be expanded if needed
169
161
     */
170
 
    void expandTodoIfNeeded( const Todo *todo );
 
162
    void expandTodoIfNeeded( const Akonadi::Item &todo );
171
163
 
172
164
    /**
173
165
     * Returns true if there's a loop, e.g.: t1 is parent of
175
167
     *
176
168
     * @param todo the todo that will be checked
177
169
     */
178
 
    bool isInHierarchyLoop( const Todo *todo ) const;
 
170
    bool isInHierarchyLoop( const KCalCore::Todo::Ptr &todo ) const;
179
171
 
180
172
    /** Insert a todo at the right place in the todo tree.
181
173
     *
185
177
     *                     recursively linked todos.
186
178
     * @return Pointer to the newly inserted TodoTreeNode node.
187
179
     */
188
 
    TodoTreeNode *insertTodo( Todo *todo, bool checkRelated = true );
 
180
    TodoTreeNode *insertTodo( const Akonadi::Item &todo, bool checkRelated = true );
189
181
 
190
182
    /** Count of columns each item has */
191
183
    const int mColumnCount;
192
184
 
193
185
    /** Calendar to get data from */
194
 
    Calendar *mCalendar;
 
186
    CalendarSupport::Calendar *mCalendar;
195
187
    /** Root elements of the todo tree. */
196
188
    TodoTreeNode *mRootNode;
197
189
    /** Hash to speed up searching todo by their uid */
198
 
    QHash<QString, TodoTreeNode*> mTodoHash;
199
 
 
200
 
    /** This IncidenceChanger is used to change todos */
201
 
    IncidenceChangerBase *mChanger;
 
190
    QHash<Akonadi::Item::Id, TodoTreeNode*> mTodoHash;
 
191
 
 
192
    QHash<QString, TodoTreeNode*> mTodoUidHash;
 
193
 
 
194
    /** This CalendarSupport::IncidenceChanger is used to change todos */
 
195
    CalendarSupport::IncidenceChanger *mChanger;
202
196
 
203
197
    /** Display the todos without hierarchy? */
204
198
    bool mFlatView;
205
 
 
206
 
#ifndef KORG_NODND
207
 
    DndFactory *mDndFactory;
208
 
#endif
209
199
};
210
200
 
211
201
#endif