• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libtaskmanager

alphasortingstrategy.cpp

Go to the documentation of this file.
00001 /*****************************************************************
00002 
00003 Copyright 2008 Christian Mollekopf <chrigi_1@hotmail.com>
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00018 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021 
00022 ******************************************************************/
00023 
00024 #include "alphasortingstrategy.h"
00025 
00026 #include <QMap>
00027 #include <QString>
00028 #include <QtAlgorithms>
00029 #include <QList>
00030 
00031 #include <KDebug>
00032 
00033 #include "taskitem.h"
00034 #include "taskgroup.h"
00035 #include "taskmanager.h"
00036 
00037 
00038 namespace TaskManager
00039 {
00040 
00041 AlphaSortingStrategy::AlphaSortingStrategy(QObject *parent)
00042     :AbstractSortingStrategy(parent)
00043 {
00044     setType(GroupManager::AlphaSorting);
00045 }
00046 
00047 void AlphaSortingStrategy::sortItems(ItemList &items)
00048 {
00049     //kDebug();
00050     QMap<QString, AbstractGroupableItem*> map;
00051 
00052     foreach (AbstractGroupableItem *groupable, items) {
00053         if (groupable->isGroupItem()) {
00054             TaskGroup *group = qobject_cast<TaskGroup*>(groupable);
00055             if (!group) {
00056                 continue;
00057             }
00058 
00059             map.insertMulti(group->name().toLower(), groupable);
00060             continue;
00061         }
00062 
00063 
00064         TaskItem *item = qobject_cast<TaskItem*>(groupable);
00065         if (!item)  {
00066             kDebug() << "Wrong object type";
00067             continue;
00068         }
00069 
00070         if (!item->task()) {
00071             kDebug() << "Null Pointer";
00072             continue;
00073         }
00074 
00075         //sort by programname not windowname
00076         //kDebug() << "inserting multi item" <<  item->task()->classClass();
00077         map.insertMulti(item->task()->classClass().toLower(), groupable);
00078     }
00079 
00080     items.clear();
00081     QMapIterator<QString, AbstractGroupableItem *> it(map);
00082     while (it.hasNext()) {
00083         items << it.next().value();
00084     }
00085 }
00086 
00087 } //namespace
00088 
00089 #include "alphasortingstrategy.moc"
00090 

libtaskmanager

Skip menu "libtaskmanager"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal