summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-25 14:10:34 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-25 14:10:34 (GMT)
commitde03e428157ee60c5d8a13ef121127203f455b3f (patch)
treeee46edb01f6f2cc078bdeab5230cd2e05d3430bb /Swift
parenta6caf0f52dbb24577e3730d9c42415e89e18a99b (diff)
downloadswift-de03e428157ee60c5d8a13ef121127203f455b3f.zip
swift-de03e428157ee60c5d8a13ef121127203f455b3f.tar.bz2
Expand roster groups on a single click.
Resolves: #212
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp10
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.h2
2 files changed, 10 insertions, 2 deletions
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<GroupRosterItem*>(static_cast<RosterItem*>(index.internalPointer()));
+ if (item) {
+ setExpanded(index, !isExpanded(index));
+ }
+}
+
+
void QtTreeWidget::handleItemActivated(const QModelIndex& index) {
RosterItem* item = static_cast<RosterItem*>(index.internalPointer());
ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(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);