![]() |
Home · All Namespaces · All Classes |
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 00004 ** All rights reserved. 00005 ** Contact: Nokia Corporation (directui@nokia.com) 00006 ** 00007 ** This file is part of systemui. 00008 ** 00009 ** If you have questions regarding the use of this file, please contact 00010 ** Nokia at directui@nokia.com. 00011 ** 00012 ** This library is free software; you can redistribute it and/or 00013 ** modify it under the terms of the GNU Lesser General Public 00014 ** License version 2.1 as published by the Free Software Foundation 00015 ** and appearing in the file LICENSE.LGPL included in the packaging 00016 ** of this file. 00017 ** 00018 ****************************************************************************/ 00019 00020 #include "sysuid.h" 00021 #include "notificationarea.h" 00022 #include "notificationareasink.h" 00023 #include "notificationmanager.h" 00024 #include <MBanner> 00025 00026 NotificationArea::NotificationArea(MWidget *parent, bool notificationsClickable) : 00027 MWidgetController(new NotificationAreaModel, parent), 00028 notificationAreaSink(new NotificationAreaSink) 00029 { 00030 // Connect notification signals 00031 NotificationManager *notificationManager = &Sysuid::instance()->notificationManager(); 00032 notificationAreaSink->setNotificationsClickable(notificationsClickable); 00033 connect(notificationManager, SIGNAL(groupUpdated(uint, const NotificationParameters &)), notificationAreaSink, SLOT(addGroup(uint, const NotificationParameters &))); 00034 connect(notificationManager, SIGNAL(groupRemoved(uint)), notificationAreaSink, SLOT(removeGroup(uint))); 00035 connect(notificationManager, SIGNAL(notificationRemoved(uint)), notificationAreaSink, SLOT(removeNotification(uint))); 00036 connect(notificationManager, SIGNAL(notificationRestored(const Notification &)), notificationAreaSink, SLOT(addNotification(const Notification &))); 00037 connect(notificationManager, SIGNAL(notificationUpdated(const Notification &)), notificationAreaSink, SLOT(addNotification(const Notification &))); 00038 connect(notificationAreaSink, SIGNAL(addNotification(MBanner &)), this, SLOT(addNotification(MBanner &))); 00039 connect(notificationAreaSink, SIGNAL(removeNotification(MBanner &)), this, SLOT(removeNotification(MBanner &))); 00040 connect(notificationAreaSink, SIGNAL(notificationRemovalRequested(uint)), notificationManager, SLOT(removeNotification(uint))); 00041 connect(notificationAreaSink, SIGNAL(notificationGroupClearingRequested(uint)), notificationManager, SLOT(removeNotificationsInGroup(uint))); 00042 connect(notificationAreaSink, SIGNAL(notificationAddedToGroup(MBanner &)), this, SLOT(moveNotificationToTop(MBanner &))); 00043 connect(notificationAreaSink, SIGNAL(bannerClicked()), this, SIGNAL(bannerClicked())); 00044 connect(this, SIGNAL(notificationRemovalRequested(uint)), notificationAreaSink, SIGNAL(notificationRemovalRequested(uint))); 00045 connect(this, SIGNAL(notificationGroupClearingRequested(uint)), notificationAreaSink, SIGNAL(notificationGroupClearingRequested(uint))); 00046 } 00047 00048 NotificationArea::~NotificationArea() 00049 { 00050 delete notificationAreaSink; 00051 } 00052 00053 void NotificationArea::moveNotificationToTop(MBanner ¬ification) 00054 { 00055 QList<MBanner *> banners(model()->banners()); 00056 if(banners.count() != 0) { 00057 banners.move(banners.indexOf(¬ification), 0); 00058 model()->setBanners(banners); 00059 } 00060 } 00061 00062 void NotificationArea::addNotification(MBanner ¬ification) 00063 { 00064 // Put the notification into the model of the notification area 00065 notification.setParentItem(this); 00066 QList<MBanner *> banners(model()->banners()); 00067 banners.push_front(¬ification); 00068 model()->setBanners(banners); 00069 } 00070 00071 void NotificationArea::removeNotification(MBanner ¬ification) 00072 { 00073 // Remove the notification from the model of the notification area 00074 QList<MBanner *> banners(model()->banners()); 00075 banners.removeOne(¬ification); 00076 model()->setBanners(banners); 00077 notification.setParentItem(NULL); 00078 } 00079 00080 void NotificationArea::removeAllRemovableBanners() 00081 { 00082 foreach(MBanner *banner, model()->banners()) { 00083 // Remove all user removable banners 00084 if (banner->property(WidgetNotificationSink::USER_REMOVABLE_PROPERTY).toBool()) { 00085 // Get the notification ID from the info banner 00086 bool ok = false; 00087 uint notificationId = banner->property(WidgetNotificationSink::NOTIFICATION_ID_PROPERTY).toUInt(&ok); 00088 if (ok) { 00089 // Request notification removal 00090 emit notificationRemovalRequested(notificationId); 00091 } else { 00092 uint groupId = banner->property(WidgetNotificationSink::GROUP_ID_PROPERTY).toUInt(&ok); 00093 if (ok) { 00094 // Request notification group clearing 00095 emit notificationGroupClearingRequested(groupId); 00096 } 00097 } 00098 } 00099 } 00100 } 00101 00102 void NotificationArea::setHonorPrivacySetting(bool honor) 00103 { 00104 notificationAreaSink->setHonorPrivacySetting(honor); 00105 }
| Copyright © 2010 Nokia Corporation | Generated on Wed Nov 10 16:04:52 2010 Doxygen 1.6.1 |
MeeGo Touch |
