~ubuntu-branches/ubuntu/quantal/kdepimlibs/quantal-proposed

« back to all changes in this revision

Viewing changes to akonadi/trashjob.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-14 14:37:07 UTC
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: package-import@ubuntu.com-20111214143707-m0qplh3hsd957ukv
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2011 Christian Mollekopf <chrigi_1@fastmail.fm>
 
3
 
 
4
    This library is free software; you can redistribute it and/or modify it
 
5
    under the terms of the GNU Library General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or (at your
 
7
    option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful, but WITHOUT
 
10
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
12
    License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to the
 
16
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
17
    02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef AKONADI_TRASHJOB_H
 
21
#define AKONADI_TRASHJOB_H
 
22
 
 
23
#include "akonadi_export.h"
 
24
 
 
25
#include <akonadi/item.h>
 
26
#include <akonadi/collection.h>
 
27
#include <akonadi/job.h>
 
28
 
 
29
namespace Akonadi
 
30
{
 
31
 
 
32
/**
 
33
 * @short Job that moves items/collection to trash.
 
34
 *
 
35
 * This job marks the given entites as trash and moves them to a given trash collection, if available.
 
36
 *
 
37
 * Priorities of trash collections are the following:
 
38
 * 1. keepTrashInCollection()
 
39
 * 2. setTrashCollection()
 
40
 * 3. configured collection in TrashSettings
 
41
 * 4. keep in collection if nothing is configured
 
42
 *
 
43
 * If the item is already marked as trash, it will be deleted instead
 
44
 * only if deleteIfInTrash() is set.
 
45
 * The entity is marked as trash with the EntityDeletedAttribute.
 
46
 *
 
47
 * The restore collection in the EntityDeletedAttribute is set the following way:
 
48
 * -If entites are not moved to trash -> no restore collection
 
49
 * -If collection is deleted -> also subentites get collection.parentCollection as restore collection
 
50
 * -If multiple items are deleted -> all items get their parentCollection as restore collection
 
51
 *
 
52
 * Example:
 
53
 *
 
54
 * @code
 
55
 *
 
56
 * const Akonadi::Item::List items = ...
 
57
 *
 
58
 * TrashJob *job = new TrashJob( items );
 
59
 * connect( job, SIGNAL( result( KJob* ) ), this, SLOT( deletionResult( KJob* ) ) );
 
60
 *
 
61
 * @endcode
 
62
 *
 
63
 * @author Christian Mollekopf <chrigi_1@fastmail.fm>
 
64
 * @since 4.8
 
65
 */
 
66
class AKONADI_EXPORT TrashJob : public Job
 
67
{
 
68
    Q_OBJECT
 
69
 
 
70
  public:
 
71
 
 
72
    /**
 
73
     * Creates a new trash job that marks @p item as trash, and moves it to the configured trash collection.
 
74
     *
 
75
     * If @p keepTrashInCollection is set, the item will not be moved to the configured trash collection.
 
76
     *
 
77
     * @param item The item to mark as trash.
 
78
     * @param parent The parent object.
 
79
     */
 
80
    explicit TrashJob( const Item &item, QObject *parent = 0 );
 
81
 
 
82
    /**
 
83
     * Creates a new trash job that marks all items in the list
 
84
     * @p items as trash, and moves it to the configured trash collection.
 
85
     * The items can be in different collections/resources and will still be moved to the correct trash colleciton.
 
86
     *
 
87
     * If @p keepTrashInCollection is set, the item will not be moved to the configured trash collection.
 
88
     *
 
89
     * @param items The items to mark as trash.
 
90
     * @param parent The parent object.
 
91
     */
 
92
    explicit TrashJob( const Item::List &items, QObject *parent = 0 );
 
93
 
 
94
    /**
 
95
     * Creates a new trash job that marks @p collection as trash, and moves it to the configured trash collection.
 
96
     * The subentities of the collection are also marked as trash.
 
97
     *
 
98
     * If @p keepTrashInCollection is set, the item will not be moved to the configured trash collection.
 
99
     *
 
100
     * @param collection The collection to mark as trash.
 
101
     * @param parent The parent object.
 
102
     */
 
103
    explicit TrashJob( const Collection &collection, QObject *parent = 0 );
 
104
 
 
105
    ~TrashJob();
 
106
 
 
107
    /**
 
108
     * Ignore configured Trash collections and keep all items local
 
109
     */
 
110
    void keepTrashInCollection( bool enable );
 
111
 
 
112
    /**
 
113
     * Moves all entities to the give collection
 
114
     */
 
115
    void setTrashCollection( const Collection &trashcollection );
 
116
 
 
117
    /**
 
118
     * Delete Items which are already in trash, instead of ignoring them
 
119
     */
 
120
    void deleteIfInTrash( bool enable );
 
121
 
 
122
    Item::List items() const;
 
123
 
 
124
  protected:
 
125
    virtual void doStart();
 
126
 
 
127
  private:
 
128
    //@cond PRIVATE
 
129
    class TrashJobPrivate;
 
130
    Q_DECLARE_PRIVATE( TrashJob )
 
131
    Q_PRIVATE_SLOT( d_func(), void selectResult( KJob* ) )
 
132
    Q_PRIVATE_SLOT( d_func(), void setAttribute( const Akonadi::Collection::List & ) )
 
133
    Q_PRIVATE_SLOT( d_func(), void setAttribute( const Akonadi::Item::List & ) )
 
134
    Q_PRIVATE_SLOT( d_func(), void setAttribute( KJob* ) )
 
135
    Q_PRIVATE_SLOT( d_func(), void collectionsReceived( const Akonadi::Collection::List & ) )
 
136
    Q_PRIVATE_SLOT( d_func(), void itemsReceived( const Akonadi::Item::List & ) )
 
137
    Q_PRIVATE_SLOT( d_func(), void parentCollectionReceived( const Akonadi::Collection::List & ) )
 
138
    //@endcond
 
139
};
 
140
 
 
141
}
 
142
 
 
143
#endif