1 /*****************************************************************
3 Copyright 2008 Christian Mollekopf <chrigi_1@hotmail.com>
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:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
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.
22 ******************************************************************/
24 #ifndef ABSTRACTGROUPINGSTRATEGY_H
25 #define ABSTRACTGROUPINGSTRATEGY_H
27 #include <QtCore/QObject>
29 #include <taskmanager/abstractgroupableitem.h>
30 #include <taskmanager/groupmanager.h>
31 #include <taskmanager/taskgroup.h>
32 #include <taskmanager/taskmanager_export.h>
40 * Base class for strategies which can be used to
41 * automatically group tasks.
43 class TASKMANAGER_EXPORT AbstractGroupingStrategy
: public QObject
47 AbstractGroupingStrategy(GroupManager
*groupManager
);
48 virtual ~AbstractGroupingStrategy();
50 /** Handles a new item */
51 virtual void handleItem(AbstractItemPtr
) = 0;
53 /** Returns the strategy type */
54 GroupManager::TaskGroupingStrategy
type() const;
56 /** DesktopChanges time to backup any needed data */
57 virtual void desktopChanged(int newDesktop
);
59 /** Returns list of actions that a task can do in this groupingStrategy
60 * If the visualization supports grouping it has to show these actions.
62 virtual QList
<QAction
*> strategyActions(QObject
*parent
, AbstractGroupableItem
*item
);
64 enum EditableGroupProperties
73 /** Returns which group properties are editable by the user and which are handled solely by the strategy.
74 * The visualization should create a configuration interface based on this.
76 virtual EditableGroupProperties
editableGroupProperties() = 0;
78 /** The following functions check if a property is editable and sets it on group*/
80 /** Adds an item to group if EditableGroupProperties::Members is set*/
81 virtual bool addItemToGroup(AbstractGroupableItem
*, TaskGroup
*);
83 virtual bool setName(const QString
&, TaskGroup
*);
84 /** Returns a List of unused Names*/
85 virtual QList
<QString
> nameSuggestions(TaskGroup
*);
87 virtual bool setColor(const QColor
&, TaskGroup
*);
88 /** Returns a list of unused colors*/
89 virtual QList
<QColor
> colorSuggestions(TaskGroup
*);
91 virtual bool setIcon(const QIcon
&, TaskGroup
*);
92 /** Returns a list of icons*/
93 virtual QList
<QIcon
> iconSuggestions(TaskGroup
*);
96 void groupRemoved(TaskGroup
*);
99 /** Adds all group members to the parentgroup of group and removes the group */
100 virtual void closeGroup(TaskGroup
*group
);
102 /** Checks if the group is still necessary, removes group if empty*/
103 virtual void checkGroup();
105 /** Returns the strategy type */
106 void setType(GroupManager::TaskGroupingStrategy type
);
109 /** Create a group with items and returns the newly created group */
110 TaskGroup
* createGroup(ItemList items
);
117 } // TaskManager namespace