not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / libs / taskmanager / strategies / manualgroupingstrategy.h
blobc740f53de4c58236eda76f6e5722de83666aabb6
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 MANUALGROUPINGSTRATEGY_H
25 #define MANUALGROUPINGSTRATEGY_H
27 #include "abstractgroupingstrategy.h"
28 #include "taskgroup.h"
30 namespace TaskManager
33 class ManualGroupingStrategy;
34 /**
35 * TaskGroup, a container for tasks and subgroups
38 class TaskGroupTemplate : public AbstractGroupableItem
40 Q_OBJECT
41 public:
42 TaskGroupTemplate(ManualGroupingStrategy *parent, TaskGroup *group);
43 ~TaskGroupTemplate();
45 TaskGroup *group();
46 void setGroup(TaskGroup *);
48 ItemList &members() const;
49 QIcon icon() const;
50 QColor color() const;
51 QString name() const;
53 bool isGroupItem() const { return true; }
55 /** only true if item is in this group */
56 bool hasDirectMember(AbstractItemPtr item) const;
57 /** only true if item is in this or any sub group */
58 bool hasMember(AbstractItemPtr item) const;
59 /** Returns Direct Member group if the passed item is in a subgroup */
60 AbstractItemPtr directMember(AbstractItemPtr) const;
62 TaskGroupTemplate *findParentGroup(AbstractItemPtr item) const;
64 TaskGroupTemplate *parentGroup() const;
65 void setParentGroup(TaskGroupTemplate *);
67 void addMimeData(QMimeData *mimeData) const;
69 Q_SIGNALS:
70 /** Unprotects group so it can get closed
72 void unprotectGroup(TaskGroup *);
73 /** used to inform the group that there is still a desktop with this group so it wont
74 * be closed when empty
76 void protectGroup(TaskGroup *);
78 void destroyed(AbstractGroupableItem *);
80 private Q_SLOTS:
81 void itemDestroyed(AbstractGroupableItem *);
84 public Q_SLOTS:
85 /** Needed because we subclass AbstractGroupableItem */
86 void toDesktop(int) {}
87 bool isOnCurrentDesktop() const { return false; }
88 bool isOnAllDesktops() const { return false; }
89 int desktop() const {return 0; }
91 void setShaded(bool) {}
92 void toggleShaded() {}
93 bool isShaded() const {return false; }
95 void setMaximized(bool) {}
96 void toggleMaximized() {}
97 bool isMaximized() const {return false; }
99 void setMinimized(bool) {}
100 void toggleMinimized() {}
101 bool isMinimized() const { return false; }
103 void setFullScreen(bool) {}
104 void toggleFullScreen() {}
105 bool isFullScreen() const { return false; }
107 void setKeptBelowOthers(bool) {}
108 void toggleKeptBelowOthers() {}
109 bool isKeptBelowOthers() const { return false; }
111 void setAlwaysOnTop(bool) {}
112 void toggleAlwaysOnTop() {}
113 bool isAlwaysOnTop() const { return false; }
115 bool isActionSupported(NET::Action) const { return false; }
117 /** close all members of this group */
118 void close() {}
120 /** returns true if at least one member is active */
121 bool isActive() const { return false; }
122 /** returns true if at least one member is demands attention */
123 bool demandsAttention() const { return false; }
125 /** add item to group */
126 void add(AbstractItemPtr);
128 /** remove item from group */
129 void remove(AbstractItemPtr);
131 /** Removes all tasks and groups from this group */
132 void clear();
134 /** remove this group, passes all members to grouping strategy*/
135 void closeGroup();
137 private:
138 class Private;
139 Private * const d;
145 class GroupManager;
147 * Remembers manually grouped tasks
148 * To do this it keeps an exact copy of the rootGroup and all subgroups
149 * for each desktop/screen
151 class ManualGroupingStrategy: public AbstractGroupingStrategy
153 Q_OBJECT
154 public:
155 ManualGroupingStrategy(GroupManager *groupingStrategy);
156 ~ManualGroupingStrategy();
158 /** looks up if this item has been grouped before and groups it accordingly.
159 *otherwise the item goes to the rootGroup
161 void handleItem(AbstractItemPtr);
162 /** Should be called if the user wants to manually add an item to a group */
163 //bool addItemToGroup(AbstractGroupableItem*, TaskGroup*);
164 /** Should be called if the user wants to group items manually */
165 bool groupItems(ItemList items);
167 /** Returns list of actions that a task can do in this groupingStrategy
168 * fore example: remove this Task from this group
170 QList<QAction*> strategyActions(QObject *parent, AbstractGroupableItem *item);
172 EditableGroupProperties editableGroupProperties();
174 void desktopChanged(int newDesktop);
176 private slots:
178 /** Actions which the strategy offers*/
179 /** sender item leaves group*/
180 void leaveGroup();
181 /** Removes all items from the sender group and adds to the parent Group*/
182 void removeGroup();
185 void groupChangedDesktop(int newDesk);
186 /** Protects group from being closed, because the tasks in the group are just temporarily
187 * not available (not on the desktop,...). Every TaskGroupTemplate calls this so the group is
188 * is only closed if it isn't present on any desktop.
190 void protectGroup(TaskGroup *group);
191 /** Unprotects group so it can get closed
193 void unprotectGroup(TaskGroup *group);
194 /** This function makes sure that if the rootGroup template already got deleted nobody tries to access it again*/
195 void resetCurrentTemplate();
197 protected:
198 void closeGroup(TaskGroup*);
200 private:
201 bool manualGrouping(TaskItem* taskItem, TaskGroup* groupItem);
203 /** Create a duplication of a group with all subgroups TaskItems arent duplicated */
204 TaskGroupTemplate *createDuplication(TaskGroup *group);
206 class Private;
207 Private * const d;
215 #endif