~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/taskmanager/abstractgroupingstrategy.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
 
 
3
Copyright 2008 Christian Mollekopf <chrigi_1@hotmail.com>
 
4
 
 
5
Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
of this software and associated documentation files (the "Software"), to deal
 
7
in the Software without restriction, including without limitation the rights
 
8
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
copies of the Software, and to permit persons to whom the Software is
 
10
furnished to do so, subject to the following conditions:
 
11
 
 
12
The above copyright notice and this permission notice shall be included in
 
13
all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
 
 
22
******************************************************************/
 
23
 
 
24
#ifndef ABSTRACTGROUPINGSTRATEGY_H
 
25
#define ABSTRACTGROUPINGSTRATEGY_H
 
26
 
 
27
#include <QtCore/QObject>
 
28
 
 
29
#include "abstractgroupableitem.h"
 
30
#include "groupmanager.h"
 
31
#include "taskgroup.h"
 
32
#include "taskmanager_export.h"
 
33
 
 
34
class QAction;
 
35
 
 
36
namespace TaskManager
 
37
{
 
38
 
 
39
/**
 
40
 * Base class for strategies which can be used to
 
41
 * automatically group tasks.
 
42
 */
 
43
class TASKMANAGER_EXPORT AbstractGroupingStrategy : public QObject
 
44
{
 
45
    Q_OBJECT
 
46
public:
 
47
    AbstractGroupingStrategy(GroupManager *groupManager);
 
48
    virtual ~AbstractGroupingStrategy();
 
49
 
 
50
    void destroy();
 
51
 
 
52
     /** Handles a new item */
 
53
    virtual void handleItem(AbstractGroupableItem *) = 0;
 
54
 
 
55
     /** Returns the strategy type */
 
56
    GroupManager::TaskGroupingStrategy type() const;
 
57
 
 
58
    /** DesktopChanges time to backup any needed data */
 
59
    virtual void desktopChanged(int newDesktop);
 
60
 
 
61
    /**
 
62
    * Returns list of actions that a task can do in this groupingStrategy
 
63
    *  If the visualization supports grouping it has to show these actions.
 
64
    */
 
65
    virtual QList<QAction*> strategyActions(QObject *parent, AbstractGroupableItem *item);
 
66
 
 
67
    /** Returns the root group to use in grouping */
 
68
    GroupPtr rootGroup() const;
 
69
 
 
70
    enum EditableGroupProperties
 
71
    {
 
72
        None = 0,
 
73
        Name = 1,
 
74
        Color = 2,
 
75
        Icon =  4,
 
76
        Members = 8,
 
77
        All = 15
 
78
    };
 
79
    /**
 
80
    * Returns which group properties are editable by the user and which are handled solely by the strategy.
 
81
    * The visualization should create a configuration interface based on this.
 
82
    */
 
83
    virtual EditableGroupProperties editableGroupProperties() = 0;
 
84
 
 
85
    /* The following functions check if a property is editable and sets it on group*/
 
86
 
 
87
    virtual bool setName(const QString &, TaskGroup*);
 
88
    /** Returns a List of unused Names*/
 
89
    virtual QList<QString> nameSuggestions(TaskGroup *);
 
90
 
 
91
    virtual bool setColor(const QColor &, TaskGroup*);
 
92
    /** Returns a list of unused colors*/
 
93
    virtual QList<QColor> colorSuggestions(TaskGroup *);
 
94
 
 
95
    virtual bool setIcon(const QIcon &, TaskGroup*);
 
96
    /** Returns a list of icons*/
 
97
    virtual QList<QIcon> iconSuggestions(TaskGroup *);
 
98
 
 
99
    /** Adds an item to group if EditableGroupProperties::Members is set */
 
100
    bool manualGroupingRequest(AbstractGroupableItem* taskItem, TaskGroup* groupItem);
 
101
    /** 
 
102
    * Creates a new group if EditableGroupProperties::Members is set
 
103
    * Should be called if the user wants to group items manually
 
104
    */
 
105
    bool manualGroupingRequest(ItemList items);
 
106
 
 
107
protected:
 
108
    /** Create a group with items and returns the newly created group */
 
109
    TaskGroup* createGroup(ItemList items);
 
110
 
 
111
Q_SIGNALS:
 
112
    void groupRemoved(TaskGroup*);
 
113
 
 
114
protected Q_SLOTS:
 
115
    /** Adds all group members to the parentgroup of group and removes the group */
 
116
    virtual void closeGroup(TaskGroup *group);
 
117
 
 
118
    /** Checks if the group is still necessary, removes group if empty*/
 
119
    virtual void checkGroup();
 
120
 
 
121
     /** Returns the strategy type */
 
122
    void setType(GroupManager::TaskGroupingStrategy type);
 
123
 
 
124
private:
 
125
    class Private;
 
126
    Private * const d;
 
127
};
 
128
 
 
129
} // TaskManager namespace
 
130
#endif