mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Implement the data model for the breadcrumb in the whatshot widget.
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
#include "ui_whatshotwidget.h"
|
#include "ui_whatshotwidget.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QStandardItem>
|
||||||
|
|
||||||
#include "viewmanager.h"
|
#include "viewmanager.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
@@ -31,6 +33,7 @@
|
|||||||
#include "playlist/treeproxymodel.h"
|
#include "playlist/treeproxymodel.h"
|
||||||
#include "widgets/overlaywidget.h"
|
#include "widgets/overlaywidget.h"
|
||||||
#include "widgets/siblingcrumbbutton.h"
|
#include "widgets/siblingcrumbbutton.h"
|
||||||
|
#include "widgets/kbreadcrumbselectionmodel.h"
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include <dynamic/GeneratorInterface.h>
|
#include <dynamic/GeneratorInterface.h>
|
||||||
@@ -53,13 +56,22 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
|
|||||||
TomahawkUtils::unmarginLayout( ui->verticalLayout->layout() );
|
TomahawkUtils::unmarginLayout( ui->verticalLayout->layout() );
|
||||||
TomahawkUtils::unmarginLayout( ui->verticalLayout_2->layout() );
|
TomahawkUtils::unmarginLayout( ui->verticalLayout_2->layout() );
|
||||||
|
|
||||||
|
|
||||||
|
//set crumb widgets
|
||||||
SiblingCrumbButtonFactory * crumbFactory = new SiblingCrumbButtonFactory;
|
SiblingCrumbButtonFactory * crumbFactory = new SiblingCrumbButtonFactory;
|
||||||
|
|
||||||
|
m_crumbModelLeft = new QStandardItemModel(this);
|
||||||
|
|
||||||
ui->breadCrumbLeft->setButtonFactory(crumbFactory);
|
ui->breadCrumbLeft->setButtonFactory(crumbFactory);
|
||||||
|
ui->breadCrumbLeft->setModel(m_crumbModelLeft);
|
||||||
ui->breadCrumbLeft->setRootIcon(QIcon( RESPATH "images/charts.png" ));
|
ui->breadCrumbLeft->setRootIcon(QIcon( RESPATH "images/charts.png" ));
|
||||||
|
//ui->breadCrumbLeft->setSelectionModel(selectionModelLeft);
|
||||||
|
ui->breadCrumbLeft->setUseAnimation(true);
|
||||||
|
|
||||||
ui->breadCrumbRight->setButtonFactory(crumbFactory);
|
ui->breadCrumbRight->setButtonFactory(crumbFactory);
|
||||||
ui->breadCrumbRight->setRootIcon(QIcon( RESPATH "images/charts.png" ));
|
ui->breadCrumbRight->setRootIcon(QIcon( RESPATH "images/charts.png" ));
|
||||||
|
ui->breadCrumbRight->setModel(m_crumbModelLeft);
|
||||||
|
ui->breadCrumbRight->setUseAnimation(true);
|
||||||
|
|
||||||
|
|
||||||
m_tracksModel = new PlaylistModel( ui->tracksView );
|
m_tracksModel = new PlaylistModel( ui->tracksView );
|
||||||
@@ -122,11 +134,15 @@ WhatsHotWidget::fetchData()
|
|||||||
requestData.customData = QVariantMap();
|
requestData.customData = QVariantMap();
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo );
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo );
|
||||||
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoChartArtists;
|
requestData.type = Tomahawk::InfoSystem::InfoChartCapabilities;
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
|
||||||
|
/*requestData.type = Tomahawk::InfoSystem::InfoChartArtists;
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoChartTracks;
|
requestData.type = Tomahawk::InfoSystem::InfoChartTracks;
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
*/
|
||||||
tDebug() << "WhatsHot: requested InfoChartArtists+Tracks";
|
tDebug() << "WhatsHot: requested InfoChartArtists+Tracks";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,9 +165,26 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
tDebug() << "WhatsHot: got something...";
|
tDebug() << "WhatsHot: got something...";
|
||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
QVariantMap returnedData = output.toMap();
|
||||||
switch ( requestData.type )
|
switch ( requestData.type )
|
||||||
{
|
{
|
||||||
|
case InfoSystem::InfoChartCapabilities:
|
||||||
|
{
|
||||||
|
tDebug() << "WhatsHot:: info chart capabilities";
|
||||||
|
QStandardItem *rootItem= m_crumbModelLeft->invisibleRootItem();
|
||||||
|
tDebug() << "WhatsHot:: " << returnedData.keys();
|
||||||
|
|
||||||
|
foreach(const QString label, returnedData.keys()) {
|
||||||
|
tDebug() << "WhatsHot:: parsing " << label;
|
||||||
|
QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] );
|
||||||
|
tDebug() << "WhatsHot:: appending" << childItem->text();
|
||||||
|
rootItem->appendRow(childItem);
|
||||||
|
}
|
||||||
|
KBreadcrumbSelectionModel *selectionModelLeft = new KBreadcrumbSelectionModel(new QItemSelectionModel(m_crumbModelLeft, this), this);
|
||||||
|
ui->breadCrumbLeft->setSelectionModel(selectionModelLeft);
|
||||||
|
ui->breadCrumbRight->setSelectionModel(selectionModelLeft);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case InfoSystem::InfoChartArtists:
|
case InfoSystem::InfoChartArtists:
|
||||||
{
|
{
|
||||||
const QStringList artists = returnedData["artists"].toStringList();
|
const QStringList artists = returnedData["artists"].toStringList();
|
||||||
@@ -203,3 +236,28 @@ WhatsHotWidget::changeEvent( QEvent* e )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStandardItem*
|
||||||
|
WhatsHotWidget::parseNode(QStandardItem* parentItem, const QString &label, const QVariant &data)
|
||||||
|
{
|
||||||
|
tDebug() << "WhatsHot:: parsing " << label;
|
||||||
|
QStandardItem *sourceItem = new QStandardItem(label);
|
||||||
|
|
||||||
|
if( data.canConvert<QVariantMap>() ) {
|
||||||
|
QVariantMap dataMap = data.toMap();
|
||||||
|
foreach(const QString childLabel,dataMap.keys()) {
|
||||||
|
QStandardItem *childItem = parseNode( sourceItem, childLabel, dataMap[childLabel] );
|
||||||
|
sourceItem->appendRow(childItem);
|
||||||
|
}
|
||||||
|
} else if ( data.canConvert<QVariantList>() ) {
|
||||||
|
QVariantList dataList = data.toList();
|
||||||
|
|
||||||
|
foreach(const QVariant value, dataList) {
|
||||||
|
QStandardItem *childItem= new QStandardItem(value.toString());
|
||||||
|
sourceItem->appendRow(childItem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QStandardItem *childItem= new QStandardItem(data.toString());
|
||||||
|
sourceItem->appendRow(childItem);
|
||||||
|
}
|
||||||
|
return sourceItem;
|
||||||
|
}
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class QStandardItemModel;
|
||||||
|
class QStandardItem;
|
||||||
class TreeModel;
|
class TreeModel;
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
class OverlayWidget;
|
class OverlayWidget;
|
||||||
@@ -81,11 +83,13 @@ private slots:
|
|||||||
void infoSystemFinished( QString target );
|
void infoSystemFinished( QString target );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QStandardItem* parseNode(QStandardItem* parentItem, const QString &label, const QVariant &data);
|
||||||
Ui::WhatsHotWidget *ui;
|
Ui::WhatsHotWidget *ui;
|
||||||
|
|
||||||
PlaylistModel* m_tracksModel;
|
PlaylistModel* m_tracksModel;
|
||||||
TreeModel* m_artistsModel;
|
TreeModel* m_artistsModel;
|
||||||
TreeProxyModel* m_artistsProxy;
|
TreeProxyModel* m_artistsProxy;
|
||||||
|
QStandardItemModel* m_crumbModelLeft;
|
||||||
|
|
||||||
QTimer* m_timer;
|
QTimer* m_timer;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user