add more spacing
[personal-kdebase.git] / workspace / libs / taskmanager / groupmanager.h
blob8704d97ce08d453d47b19ca9fb9611a216911e24
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 GROUPMANAGER_H
25 #define GROUPMANAGER_H
27 #include <QtCore/QObject>
29 #include <taskmanager/abstractgroupableitem.h>
30 #include <taskmanager/task.h>
31 #include <taskmanager/taskitem.h>
32 #include <taskmanager/taskmanager_export.h>
34 namespace TaskManager
37 class AbstractSortingStrategy;
38 class AbstractGroupingStrategy;
39 class GroupManagerPrivate;
41 /**
42 * Manages the grouping stuff. It doesn't know anything about grouping and sorting itself, this is done in the grouping and sorting strategies.
44 class TASKMANAGER_EXPORT GroupManager: public QObject
47 Q_OBJECT
48 public:
49 GroupManager(QObject *parent);
50 ~GroupManager();
52 /**
53 * Returns a group which contains all items and subgroups.
54 * Visualizations should be based on this.
56 GroupPtr rootGroup() const;
58 /**
59 * Strategy used to Group new items
61 enum TaskGroupingStrategy
63 NoGrouping = 0,
64 ManualGrouping = 1, //Allow manual grouping
65 ProgramGrouping = 2 //Group automatically same programs
68 TaskGroupingStrategy groupingStrategy() const;
69 void setGroupingStrategy(TaskGroupingStrategy);
70 AbstractGroupingStrategy* taskGrouper() const;
73 /**
74 * How the task are ordered
76 enum TaskSortingStrategy
78 NoSorting = 0,
79 ManualSorting = 1,
80 AlphaSorting = 2,
81 DesktopSorting = 3
84 TaskSortingStrategy sortingStrategy() const;
85 void setSortingStrategy(TaskSortingStrategy);
86 AbstractSortingStrategy* taskSorter() const;
88 bool showOnlyCurrentScreen() const;
89 void setShowOnlyCurrentScreen(bool);
91 bool showOnlyCurrentDesktop() const;
92 void setShowOnlyCurrentDesktop(bool);
94 bool showOnlyMinimized() const;
95 void setShowOnlyMinimized(bool);
97 bool onlyGroupWhenFull() const;
98 /**
99 * Only apply the grouping startegy when the taskbar is full according to
100 * setFullLimit(int). This is currently limited to ProgramGrouping.
102 void setOnlyGroupWhenFull(bool state);
104 * Set the limit when the taskbar is considered as full
106 void setFullLimit(int limit);
109 * Functions to call if the user wants to do something manually, the strategy allows or refuses the request
111 bool manualGroupingRequest(AbstractGroupableItem* taskItem, TaskGroup* groupItem);
112 bool manualGroupingRequest(ItemList items);
114 bool manualSortingRequest(AbstractGroupableItem* taskItem, int newIndex);
117 * The Visualization is responsible to update the screen number the visualization is currently on.
119 void setScreen(int screen);
121 Q_SIGNALS:
122 /** Signal that the rootGroup has to be reloaded in the visualization */
123 void reload();
124 /** Signal that the item is no longer available */
125 void itemRemoved(AbstractGroupableItem*);
126 /** Signal that a group was removed */
127 void groupRemoved(TaskGroup*);
129 public Q_SLOTS:
131 * Slots for newly added tasks from TaskManager
133 bool add(TaskPtr);
134 void remove(TaskPtr);
136 void add(StartupPtr);
137 void remove(StartupPtr);
140 * listen to the relevant signals of taskmanager
142 void reconnect();
144 private:
145 Q_PRIVATE_SLOT(d, void currentDesktopChanged(int))
146 Q_PRIVATE_SLOT(d, void taskChanged(TaskPtr, ::TaskManager::TaskChanges))
147 Q_PRIVATE_SLOT(d, void checkScreenChange())
148 Q_PRIVATE_SLOT(d, void itemDestroyed())
149 Q_PRIVATE_SLOT(d, void checkIfFull())
151 friend class GroupManagerPrivate;
152 GroupManagerPrivate * const d;
155 #endif