void
PlaydarTagCloudModel::onFetchedTags()
{
	m_loadingTimer->deleteLater();
	m_loadingTimer = 0;
//	beginInsertRows( QModelIndex(), m_tagList.size(), m_tagListBuffer.size() );
		m_tagList = m_tagListBuffer;
		qSort( m_tagList.begin(), m_tagList.end(), qGreater<BoffinTagItem >() );
//	endInsertRows();
    reset();
	emit fetchedTags();
}
TagBrowserWidget::TagBrowserWidget(PlaydarConnection* playdar, QWidget* parent) :
	QWidget(parent), 
    m_playdar(playdar) 
{
	m_tagCloudModel = new PlaydarTagCloudModel(playdar);
    m_filter = new RelevanceFilter();
    m_filter->setSourceModel(m_tagCloudModel);

	QVBoxLayout* vlayout = new QVBoxLayout(this);
	m_history = new HistoryWidget();
	m_history->newItem("all");
	connect(m_history, SIGNAL(clicked(int, QString)),
			SLOT(onHistoryClicked(int, QString)));
    QPushButton* button = new QPushButton("filter irrelevant tags");
    connect(button, SIGNAL(clicked()), SLOT(onFilterClicked()));
    vlayout->addWidget(button);
	vlayout->addWidget(m_history);

	QWidget* w = new QWidget(this);

	m_view = new TagCloudView(w);
	m_view->setModel(m_filter);

    connect(m_tagCloudModel, SIGNAL(tagItem(BoffinTagItem)), m_view, SLOT(onTag(BoffinTagItem)));
    connect(m_tagCloudModel, SIGNAL(fetchedTags()), m_view, SLOT(onFetchedTags()));

	m_view->setItemDelegate(new TagDelegate);
	connect(m_view->selectionModel(),
			SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
			SLOT(onSelectionChanged(QItemSelection, QItemSelection)));
	vlayout->addWidget(m_view);

// not interested in the playlist widget right now:
//	m_playlistModel = new PlaylistModel(this);
//	m_playlistWidget = new PlaylistWidget(m_playdar, this);
//	m_playlistWidget->setModel(m_playlistModel);
//	vlayout->addWidget(m_playlistWidget);

	m_tagCloudModel->startGetTags();

	this->setLayout(vlayout);
}