summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Roster/GroupRosterItem.h')
-rw-r--r--Swiften/Roster/GroupRosterItem.h69
1 files changed, 16 insertions, 53 deletions
diff --git a/Swiften/Roster/GroupRosterItem.h b/Swiften/Roster/GroupRosterItem.h
index 83128a5..5e16b2b 100644
--- a/Swiften/Roster/GroupRosterItem.h
+++ b/Swiften/Roster/GroupRosterItem.h
@@ -1,74 +1,37 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_GroupRosterItem_H
-#define SWIFTEN_GroupRosterItem_H
+#pragma once
#include "Swiften/Roster/RosterItem.h"
#include "Swiften/Base/String.h"
-#include "Swiften/Roster/TreeWidget.h"
-#include "Swiften/Roster/TreeWidgetFactory.h"
-#include "Swiften/Roster/TreeWidgetItem.h"
#include "Swiften/Roster/ContactRosterItem.h"
-#include <list>
+#include <vector>
namespace Swift {
class GroupRosterItem : public RosterItem {
public:
- GroupRosterItem(const String& name, TreeWidget* tree, TreeWidgetFactory* factory) : name_(name) {
- widget_ = factory->createTreeWidgetItem(tree);
- widget_->setExpanded(true);
- widget_->setText(name);
- }
-
- ~GroupRosterItem() {
- delete widget_;
- }
-
- const String& getName() const {
- return name_;
- }
-
- TreeWidgetItem* getWidget() const {
- return widget_;
- }
-
- const std::list<RosterItem*>& getChildren() const {
- return children_;
- }
-
- void addChild(RosterItem* item) {
- children_.push_back(item);
- }
-
- void removeChild(const JID& jid) {
- std::list<RosterItem*>::iterator it = children_.begin();
- while (it != children_.end()) {
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(*it);
- if (contact && contact->getJID() == jid) {
- delete contact;
- it = children_.erase(it);
- continue;
- }
- GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(*it);
- if (group) {
- group->removeChild(jid);
- }
- it++;
- }
- }
-
+ GroupRosterItem(const String& name, GroupRosterItem* parent);
+ virtual ~GroupRosterItem();
+ const std::vector<RosterItem*>& getChildren() const;
+ const std::vector<RosterItem*>& getDisplayedChildren() const;
+ void addChild(RosterItem* item);
+ ContactRosterItem* removeChild(const JID& jid);
+ void setDisplayed(RosterItem* item, bool displayed);
+ boost::signal<void ()> onChildrenChanged;
+ static bool itemLessThan(const RosterItem* left, const RosterItem* right);
private:
+ void handleChildrenChanged(GroupRosterItem* group);
+ void sortDisplayed();
String name_;
- TreeWidgetItem* widget_;
- std::list<RosterItem*> children_;
+ std::vector<RosterItem*> children_;
+ std::vector<RosterItem*> displayedChildren_;
};
}
-#endif