libtaskmanager
abstractgroupableitem.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 // Ownm_preferredInsertIndex 00025 #include "abstractgroupableitem.h" 00026 #include "taskgroup.h" 00027 #include "taskmanager.h" 00028 00029 00030 // KDE 00031 #include <KDebug> 00032 00033 00034 00035 namespace TaskManager 00036 { 00037 00038 00039 class AbstractGroupableItem::Private 00040 { 00041 public: 00042 Private() 00043 :m_parentGroup(0) 00044 { 00045 } 00046 00047 GroupPtr m_parentGroup; 00048 }; 00049 00050 00051 AbstractGroupableItem::AbstractGroupableItem(QObject *parent) 00052 : QObject(parent), 00053 d(new Private) 00054 { 00055 00056 } 00057 00058 00059 AbstractGroupableItem::~AbstractGroupableItem() 00060 { 00061 //kDebug(); 00062 emit destroyed(this); 00063 /*if (parentGroup()) { 00064 kDebug() << "Error: item gets destroyed but still has a parent group"; 00065 }*/ 00066 delete d; 00067 } 00068 00069 00070 bool AbstractGroupableItem::isGrouped() const 00071 { 00072 return parentGroup() && parentGroup()->parentGroup(); 00073 } 00074 00075 QIcon AbstractGroupableItem::icon() const 00076 { 00077 return QIcon(); 00078 } 00079 00080 QString AbstractGroupableItem::name() const 00081 { 00082 return QString(); 00083 } 00084 00085 GroupPtr AbstractGroupableItem::parentGroup() const 00086 { 00087 //kDebug(); 00088 return d->m_parentGroup; 00089 } 00090 00091 00092 void AbstractGroupableItem::setParentGroup(const GroupPtr group) 00093 { 00094 d->m_parentGroup = group; 00095 } 00096 00097 00098 //Item is member of group 00099 bool AbstractGroupableItem::isGroupMember(const GroupPtr group) const 00100 { 00101 //kDebug(); 00102 if (!group) { 00103 //kDebug() << "Null Group Pointer"; 00104 return false; 00105 } 00106 00107 if (!parentGroup()) { 00108 return false; 00109 } 00110 00111 return group->members().contains(const_cast<AbstractGroupableItem*>(this)); 00112 } 00113 00114 00115 } // TaskManager namespace 00116 00117 #include "abstractgroupableitem.moc" 00118