diff options
| author | Kevin Smith <git@kismith.co.uk> | 2010-05-14 22:11:54 (GMT) | 
|---|---|---|
| committer | Kevin Smith <git@kismith.co.uk> | 2010-05-14 22:11:54 (GMT) | 
| commit | 1f48a865bc052b12c3a156426bd1ebdd5955c74e (patch) | |
| tree | 3cf40b78dab6364a4d00f925f66e9a6cbe7b596f /Swift/QtUI/Roster/QtTreeWidget.cpp | |
| parent | e10a0c0902b503bbffdc802aa238c8b6ac4fe210 (diff) | |
| download | swift-contrib-1f48a865bc052b12c3a156426bd1ebdd5955c74e.zip swift-contrib-1f48a865bc052b12c3a156426bd1ebdd5955c74e.tar.bz2  | |
Start roster groups expanded.
Resolves: #343
Diffstat (limited to 'Swift/QtUI/Roster/QtTreeWidget.cpp')
| -rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 61 | 
1 files changed, 31 insertions, 30 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index 97b055b..ba57421 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -8,6 +8,7 @@  #include "Swiften/Base/Platform.h"  #include "Swiften/Roster/ContactRosterItem.h" +#include "Swiften/Roster/GroupRosterItem.h"  #include "Swift/Controllers/UIEvents/UIEventStream.h"  #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" @@ -33,10 +34,10 @@ QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, QWidget* parent) : QTreeV  	setIndentation(0);  	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(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(expanded(const QModelIndex&)), this, SLOT(handleExpanded(const QModelIndex&))); +	connect(this, SIGNAL(collapsed(const QModelIndex&)), this, SLOT(handleCollapsed(const QModelIndex&)));  }  QtTreeWidget::~QtTreeWidget() { @@ -76,33 +77,33 @@ void QtTreeWidget::contextMenuEvent(QContextMenuEvent* event) {  	}  } -//void QtTreeWidget::handleExpanded(const QModelIndex& index) { -//	QtTreeWidgetItem* qtItem = static_cast<QtTreeWidgetItem*>(index.internalPointer()); -//	if (qtItem) { -//		qtItem->setExpanded(true); -//	} -//} - -//void QtTreeWidget::handleCollapsed(const QModelIndex& index) { -//	QtTreeWidgetItem* qtItem = static_cast<QtTreeWidgetItem*>(index.internalPointer()); -//	if (qtItem) { -//		qtItem->setExpanded(false); -//	} -//} - -//void QtTreeWidget::handleModelItemExpanded(const QModelIndex& index, bool shouldExpand) { -//	if (this->isExpanded(index) == shouldExpand) { -//		return; -//	} -//	//setExpanded(index, shouldExpand); -//	if (shouldExpand) { -//		expand(index); -//		emit expanded(index); -//	} else { -//		collapse(index); -//		emit collapsed(index); -//	} -//} +void QtTreeWidget::handleExpanded(const QModelIndex& index) { +	GroupRosterItem* item = dynamic_cast<GroupRosterItem*>(static_cast<RosterItem*>(index.internalPointer())); +	if (item) { +		item->setExpanded(true); +	} +} + +void QtTreeWidget::handleCollapsed(const QModelIndex& index) { +	GroupRosterItem* item = dynamic_cast<GroupRosterItem*>(static_cast<RosterItem*>(index.internalPointer())); +	if (item) { +		item->setExpanded(false); +	} +} + +void QtTreeWidget::handleModelItemExpanded(const QModelIndex& index, bool shouldExpand) { +	if (this->isExpanded(index) == shouldExpand) { +		return; +	} +	//setExpanded(index, shouldExpand); +	if (shouldExpand) { +		expand(index); +		emit expanded(index); +	} else { +		collapse(index); +		emit collapsed(index); +	} +}  // void QtTreeWidget::handleDataChanged(const QModelIndex& topLeft, const QModelIndex& /*bottomRight*/) {  // 	//in our model, this is only thrown with topLeft == bottomRight  | 
 Swift