void
PlaydarTagCloudModel::startGetTags(const QString& rql)
{
    m_hosts.clear();
    m_tagListBuffer.clear();
    m_tagList.clear();

    m_maxWeight = 0;
    m_maxLogCount = FLT_MIN;
    m_minLogCount = FLT_MAX;
    m_maxTrackCount = 0;
    m_totalTracks = 0;
    m_totalDuration = 0;

    BoffinTagRequest* req = m_playdar->boffinTagcloud(rql);
    connect(req, SIGNAL(tagItem(BoffinTagItem)), SLOT(onTag(BoffinTagItem)));
    connect(req, SIGNAL(tagItem(BoffinTagItem)), SIGNAL(tagItem(BoffinTagItem)));
    connect(req, SIGNAL(error()), this, SLOT(onTagError()));
    if( m_loadingTimer )
    {
    	delete( m_loadingTimer );
    	m_loadingTimer = 0;
    }
    qDebug() << "Fetching rql: " << rql;
}
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);
}