From de03e428157ee60c5d8a13ef121127203f455b3f Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Tue, 25 May 2010 15:10:34 +0100 Subject: Expand roster groups on a single click. Resolves: #212 diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index ba57421..997c1f6 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -35,9 +35,9 @@ QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, QWidget* parent) : QTreeV setRootIsDecorated(true); connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleItemActivated(const QModelIndex&))); connect(model_, SIGNAL(itemExpanded(const QModelIndex&, bool)), this, SLOT(handleModelItemExpanded(const QModelIndex&, bool))); -// connect(model_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(handleDataChanged(const QModelIndex&, const QModelIndex&))); connect(this, SIGNAL(expanded(const QModelIndex&)), this, SLOT(handleExpanded(const QModelIndex&))); connect(this, SIGNAL(collapsed(const QModelIndex&)), this, SLOT(handleCollapsed(const QModelIndex&))); + connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(handleClicked(const QModelIndex&))); } QtTreeWidget::~QtTreeWidget() { @@ -58,6 +58,14 @@ QtTreeWidgetItem* QtTreeWidget::getRoot() { return treeRoot_; } +void QtTreeWidget::handleClicked(const QModelIndex& index) { + GroupRosterItem* item = dynamic_cast(static_cast(index.internalPointer())); + if (item) { + setExpanded(index, !isExpanded(index)); + } +} + + void QtTreeWidget::handleItemActivated(const QModelIndex& index) { RosterItem* item = static_cast(index.internalPointer()); ContactRosterItem* contact = dynamic_cast(item); diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h index b45701e..796afed 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.h +++ b/Swift/QtUI/Roster/QtTreeWidget.h @@ -31,7 +31,7 @@ class QtTreeWidget : public QTreeView{ void handleModelItemExpanded(const QModelIndex&, bool expanded); void handleExpanded(const QModelIndex&); void handleCollapsed(const QModelIndex&); -// void handleDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); + void handleClicked(const QModelIndex&); protected: void contextMenuEvent(QContextMenuEvent* event); -- cgit v0.10.2-6-g49f6