diff options
| author | Kevin Smith <git@kismith.co.uk> | 2009-07-26 16:31:58 (GMT) | 
|---|---|---|
| committer | Kevin Smith <git@kismith.co.uk> | 2009-07-26 16:31:58 (GMT) | 
| commit | 3d6db73e834b745f2abadd04f8309d96f2b41b9c (patch) | |
| tree | bd02aa7ad336ebfa33117d9566791b66fa4cf6c7 /Swift/QtUI/Roster/RosterModel.cpp | |
| parent | a28d92f3458218d6effbfdd9a42bf8fbe8b8aa72 (diff) | |
| download | swift-3d6db73e834b745f2abadd04f8309d96f2b41b9c.zip swift-3d6db73e834b745f2abadd04f8309d96f2b41b9c.tar.bz2 | |
The new roster now renders (badly) the contents.
Diffstat (limited to 'Swift/QtUI/Roster/RosterModel.cpp')
| -rw-r--r-- | Swift/QtUI/Roster/RosterModel.cpp | 33 | 
1 files changed, 20 insertions, 13 deletions
| diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp index 2c9a2cc..4c5954e 100644 --- a/Swift/QtUI/Roster/RosterModel.cpp +++ b/Swift/QtUI/Roster/RosterModel.cpp @@ -2,12 +2,25 @@  namespace Swift { -RosterModel::RosterModel(RosterItem* tree) { -	tree_ = tree; +RosterModel::RosterModel() {  }  RosterModel::~RosterModel() { -	 +	delete tree_; +} + +void RosterModel::setRoot(RosterItem* root) { +	tree_ = root; +	connect(tree_, SIGNAL(changed()), this, SLOT(handleItemChanged())); +} +							   + +void RosterModel::handleItemChanged() { +	//FIXME: This is just a lazy hack to cause the view to refresh until it works. +	// Then I'll replace it with the proper implementation. +	printf("Changed\n"); +	reset(); +	emit layoutChanged();  }  int RosterModel::columnCount(const QModelIndex& parent) const { @@ -16,10 +29,8 @@ int RosterModel::columnCount(const QModelIndex& parent) const {  }  QVariant RosterModel::data(const QModelIndex& index, int role) const { -	if (!index.isValid()) { -		return QVariant(); -	} -	return QVariant("bob"); +	RosterItem* item = index.isValid() ? static_cast<RosterItem*>(index.internalPointer()) : NULL; +	return item ? item->data(role) : QVariant();  }  QModelIndex RosterModel::index(int row, int column, const QModelIndex& parent) const { @@ -38,16 +49,12 @@ QModelIndex RosterModel::parent(const QModelIndex& index) const {  	Q_ASSERT(item);  	RosterItem* parentItem = item->getParentItem(); -	return parentItem == tree_ ? QModelIndex() : createIndex(parentItem->getParentItem()->rowOf(parentItem), 0, parentItem); +	return parentItem == tree_ ? QModelIndex() : createIndex(parentItem->row(), 0, parentItem);  }  int RosterModel::rowCount(const QModelIndex& parent) const { -	if (!parent.isValid()) { -		return 0; -	} -	 -	RosterItem* item = static_cast<RosterItem*>(parent.internalPointer()); +	RosterItem* item = parent.isValid() ? static_cast<RosterItem*>(parent.internalPointer()) : tree_;  	Q_ASSERT(item);  	return item->rowCount(); | 
 Swift
 Swift