From 80f96f761c949c24266a8f96d5e7d8ba83cb69eb Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 14 Jan 2012 21:31:02 +0000 Subject: [PATCH] In NotificationWindow, have AppGroupViews get deleted upon expiry. I.e. once there are no more notifications in the AppGroupView, we get the NotificationWindow to delete it. As a result of this change, we no longer need the AppGroupView.cpp _ResizeViews() method. --- src/servers/notification/AppGroupView.cpp | 45 +++++++---------------- src/servers/notification/AppGroupView.h | 2 - 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 5029808350..e1f36da458 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -203,17 +203,22 @@ AppGroupView::MessageReceived(BMessage* msg) return; infoview_t::iterator vIt = find(fInfo.begin(), fInfo.end(), view); + if (vIt == fInfo.end()) + break; - if (vIt != fInfo.end()) { - fInfo.erase(vIt); - GetLayout()->RemoveView(view); - delete view; + fInfo.erase(vIt); + GetLayout()->RemoveView(view); + delete view; + + fParent->PostMessage(msg); + + if (!this->HasChildren()) { + Hide(); + BMessage removeSelfMessage(kRemoveGroupView); + removeSelfMessage.AddPointer("view", this); + fParent->PostMessage(&removeSelfMessage); } - - _ResizeViews(); - - if (Window() != NULL) - Window()->PostMessage(msg); + break; } default: @@ -263,28 +268,6 @@ AppGroupView::Group() const } -void -AppGroupView::_ResizeViews() -{ - int32 children = fInfo.size(); - - if (!fCollapsed) { - for (int32 i = 0; i < children; i++) { - if (fInfo[i]->IsHidden()) - fInfo[i]->Show(); - } - } else { - for (int32 i = 0; i < children; i++) - if (!fInfo[i]->IsHidden()) - fInfo[i]->Hide(); - } - - if (!IsHidden() && !HasChildren()) - Hide(); - fParent->Layout(true); -} - - bool AppGroupView::HasChildren() { diff --git a/src/servers/notification/AppGroupView.h b/src/servers/notification/AppGroupView.h index deb9d09c87..0c1406d56d 100644 --- a/src/servers/notification/AppGroupView.h +++ b/src/servers/notification/AppGroupView.h @@ -35,8 +35,6 @@ public: const BString& Group() const; private: - void _ResizeViews(); - BString fLabel; NotificationWindow* fParent; infoview_t fInfo;