not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / libs / taskmanager / abstractsortingstrategy.h
blob9bd4076f16e6cdfb1e088cda82a0273111c5cf61
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 ABSTRACTSORTINGSTRATEGY_H
25 #define ABSTRACTSORTINGSTRATEGY_H
27 #include <QtCore/QObject>
29 #include <taskmanager/abstractgroupableitem.h>
30 #include <taskmanager/groupmanager.h>
31 #include <taskmanager/taskmanager_export.h>
33 namespace TaskManager
36 /**
37 * Base class for strategies which can be used to
38 * automatically sort tasks.
40 class TASKMANAGER_EXPORT AbstractSortingStrategy : public QObject
42 Q_OBJECT
43 public:
44 AbstractSortingStrategy(QObject *parent);
45 virtual ~AbstractSortingStrategy();
47 /** Returns the strategy type */
48 GroupManager::TaskSortingStrategy type() const;
50 /** Adds group under control of sorting strategy. all added subgroups are automatically added to this sortingStrategy*/
51 void handleGroup(TaskGroup *);
53 /** DesktopChanges time to backup any needed data */
54 virtual void desktopChanged(int newDesktop);
56 /** Moves Item to new index*/
57 bool moveItem(AbstractItemPtr, int);
59 protected Q_SLOTS:
60 /** Handles a new item, is typically called after an item was added to a handled group*/
61 virtual void handleItem(AbstractItemPtr);
62 /** Checks if the order has to be updated. Must be connected to a AbstractGroupableItem* */
63 void check(AbstractItemPtr item = 0);
64 void removeGroup(); //FIXME necessary?
66 protected:
67 void setType(GroupManager::TaskSortingStrategy strategy);
69 private:
70 /**
71 * Sorts list of items according to startegy.
72 * Has to be reimplemented by every SortingStrategy.
74 * @param items the items that are to be sorted; the list is passed
75 * in by value and should be in the proprer sorting order when
76 * the method returns.
78 virtual void sortItems(ItemList &ites) = 0;
80 class Private;
81 Private * const d;
84 typedef QHash <AbstractGroupableItem*, int> itemHashTable;
85 typedef QHash <int, itemHashTable*> desktopHashTable;
87 } // TaskManager namespace
88 #endif