mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-31 17:42:13 +02:00
Revert "started integrating the breadcrumb"
This reverts commit ac576046c9
.
This commit is contained in:
@@ -15,27 +15,6 @@ Rectangle {
|
||||
ListElement { label: "By Year"; image: "image://albumart/foobar"; creatorContent: "year" }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: stationView
|
||||
|
||||
onPagePicked: {
|
||||
switch(createBy) {
|
||||
case StationWidget.CreateByArtist:
|
||||
stationCreator.content = "stations/CreateByArtist.qml";
|
||||
break;
|
||||
case StationWidget.CreateByGenre:
|
||||
stationCreator.content = "stations/CreateByGenre.qml";
|
||||
break;
|
||||
case StationWidget.CreateByYear:
|
||||
stationCreator.content = "stations/CreateByYear.qml";
|
||||
break;
|
||||
}
|
||||
|
||||
print("########", createBy, stationCreator.content)
|
||||
stationListView.currentIndex = page;
|
||||
}
|
||||
}
|
||||
|
||||
VisualItemModel {
|
||||
id: stationVisualModel
|
||||
|
||||
@@ -86,34 +65,34 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
RoundedButton {
|
||||
id: backButton
|
||||
text: "<"
|
||||
height: defaultFontHeight * 4
|
||||
width: height
|
||||
opacity: stationListView.currentIndex == 0 ? 0 : 1
|
||||
source: "../images/back-rest.svg"
|
||||
smooth: true
|
||||
hidden: stationListView.currentIndex == 0
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
margins: defaultFontHeight * 2
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: stationListView.decrementCurrentIndex()
|
||||
}
|
||||
|
||||
onClicked: stationListView.decrementCurrentIndex()
|
||||
}
|
||||
|
||||
Image {
|
||||
RoundedButton {
|
||||
id: nextButton
|
||||
text: stationListView.currentIndex == 2 ? "+" : ">"
|
||||
height: defaultFontHeight * 4
|
||||
opacity: stationListView.currentIndex != 2 ? 0 : 1
|
||||
source: stationListView.currentIndex == 2 ? "../images/list-add.svg" : "../images/skip-rest.svg"
|
||||
smooth: true
|
||||
//hidden: stationListView.currentIndex == 0 || !rootView.configured // This should work once rootView.configured works
|
||||
hidden: stationListView.currentIndex != 2
|
||||
anchors {
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
margins: defaultFontHeight * 2
|
||||
}
|
||||
|
||||
onClicked: stationListView.incrementCurrentIndex()
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,11 +14,9 @@
|
||||
#include "widgets/DeclarativeCoverArtProvider.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "widgets/Breadcrumb.h"
|
||||
|
||||
#include <QUrl>
|
||||
#include <QSize>
|
||||
#include <QVBoxLayout>
|
||||
#include <qdeclarative.h>
|
||||
#include <QDeclarativeContext>
|
||||
|
||||
@@ -26,7 +24,7 @@ namespace Tomahawk
|
||||
{
|
||||
|
||||
DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
: DeclarativeView( parent )
|
||||
, m_playlist( playlist )
|
||||
, m_runningOnDemand( false )
|
||||
, m_activePlaylist( false )
|
||||
@@ -42,30 +40,13 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa
|
||||
m_artistChartsModel = new PlayableModel( this );
|
||||
|
||||
|
||||
QVBoxLayout *vLayout = new QVBoxLayout();
|
||||
setLayout(vLayout);
|
||||
TomahawkUtils::unmarginLayout(vLayout);
|
||||
|
||||
createStationModel();
|
||||
m_breadcrumb = new Breadcrumb();
|
||||
connect(m_breadcrumb, SIGNAL(activateIndex(QModelIndex)), SLOT(breadcrumbChanged(QModelIndex)));
|
||||
m_breadcrumb->setModel(m_createStationModel);
|
||||
m_breadcrumb->setRootIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::Charts, TomahawkUtils::Original ) );
|
||||
vLayout->addWidget(m_breadcrumb);
|
||||
|
||||
DeclarativeView *m_declarativeView = new DeclarativeView();
|
||||
vLayout->addWidget(m_declarativeView);
|
||||
qRegisterMetaType<CreateBy>("CreateBy");
|
||||
|
||||
qmlRegisterUncreatableType<GeneratorInterface>("tomahawk", 1, 0, "Generator", "you cannot create it on your own - should be set in context");
|
||||
qmlRegisterUncreatableType<DynamicQmlWidget>("tomahawk", 1, 0, "StationWidget", "bla");
|
||||
|
||||
m_declarativeView->rootContext()->setContextProperty( "dynamicModel", m_proxyModel );
|
||||
m_declarativeView->rootContext()->setContextProperty( "artistChartsModel", m_artistChartsModel );
|
||||
m_declarativeView->rootContext()->setContextProperty( "generator", m_playlist->generator().data() );
|
||||
m_declarativeView->rootContext()->setContextProperty( "stationView", this );
|
||||
rootContext()->setContextProperty( "dynamicModel", m_proxyModel );
|
||||
rootContext()->setContextProperty( "artistChartsModel", m_artistChartsModel );
|
||||
rootContext()->setContextProperty( "generator", m_playlist->generator().data() );
|
||||
|
||||
m_declarativeView->setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) );
|
||||
setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) );
|
||||
|
||||
connect( m_model, SIGNAL( currentItemChanged(QPersistentModelIndex)), SLOT( currentIndexChanged( QPersistentModelIndex ) ) );
|
||||
connect( m_model, SIGNAL( loadingStarted() ), SIGNAL(loadingChanged() ) );
|
||||
@@ -166,7 +147,7 @@ void DynamicQmlWidget::startStationFromGenre(const QString &genre)
|
||||
void DynamicQmlWidget::currentIndexChanged( const QPersistentModelIndex ¤tIndex )
|
||||
{
|
||||
tDebug() << "current index is" << currentIndex.row();
|
||||
m_declarativeView->rootContext()->setContextProperty( "currentlyPlayedIndex", m_proxyModel->mapFromSource( currentIndex ).row() );
|
||||
rootContext()->setContextProperty( "currentlyPlayedIndex", m_proxyModel->mapFromSource( currentIndex ).row() );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -267,94 +248,5 @@ DynamicQmlWidget::onArtistCharts( const QList< Tomahawk::artist_ptr >& artists )
|
||||
m_artistChartsModel->clear();
|
||||
m_artistChartsModel->appendArtists( artists );
|
||||
|
||||
QStandardItem *byArtistItem = 0;
|
||||
for(int i = 0; i < m_createStationModel->rowCount(); ++i) {
|
||||
QStandardItem *item = m_createStationModel->itemFromIndex(m_createStationModel->index(i, 0));
|
||||
tDebug() << "##" << item->data(Qt::UserRole);
|
||||
if(item->data(RoleCreateBy).toInt() == CreateByArtist) {
|
||||
byArtistItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!byArtistItem) {
|
||||
// huh? no "...by artist selection? Cannot continue...
|
||||
return;
|
||||
}
|
||||
|
||||
QStandardItem *selectArtistItem = new QStandardItem("choose artist...");
|
||||
selectArtistItem->setData(1, RolePage);
|
||||
selectArtistItem->setData(CreateByArtist, RoleCreateBy);
|
||||
byArtistItem->appendRow(selectArtistItem);
|
||||
foreach(const Tomahawk::artist_ptr &artist, artists) {
|
||||
QStandardItem *artistItem = new QStandardItem(artist->name());
|
||||
artistItem->setData(2, RolePage);
|
||||
artistItem->setData(CreateByNone, RoleCreateBy);
|
||||
byArtistItem->appendRow(artistItem);
|
||||
}
|
||||
m_breadcrumb->setModel(m_createStationModel);
|
||||
}
|
||||
|
||||
void DynamicQmlWidget::createStationModel()
|
||||
{
|
||||
m_createStationModel = new QStandardItemModel(this);
|
||||
|
||||
// Create Station by...
|
||||
QStandardItem *selectionItem = new QStandardItem("Start...");
|
||||
selectionItem->setData(0, RolePage);
|
||||
selectionItem->setData(CreateByNone, RoleCreateBy);
|
||||
m_createStationModel->insertRow(0, selectionItem);
|
||||
|
||||
QStandardItem *byArtistItem = new QStandardItem("...by Artist");
|
||||
byArtistItem->setData(1, RolePage);
|
||||
byArtistItem->setData(CreateByArtist, RoleCreateBy);
|
||||
m_createStationModel->insertRow(0, byArtistItem);
|
||||
|
||||
QStandardItem *byGenreItem = new QStandardItem("...by Genre");
|
||||
byArtistItem->setData(1, RolePage);
|
||||
byGenreItem->setData(CreateByGenre, RoleCreateBy);
|
||||
m_createStationModel->insertRow(0, byGenreItem);
|
||||
|
||||
QStandardItem *byYearItem = new QStandardItem("...by Year");
|
||||
byArtistItem->setData(1, RolePage);
|
||||
byYearItem->setData(CreateByYear, RoleCreateBy);
|
||||
m_createStationModel->insertRow(0, byYearItem);
|
||||
|
||||
// Fill in genres (static for now)
|
||||
QStringList genres;
|
||||
genres << "acoustic" << "alternative" << "alternative rock" << "classic" << "folk" << "indie" << "pop" <<
|
||||
"rock" << "hip-hop" << "punk" << "grunge" << "indie" << "electronic" << "country" << "jazz" <<
|
||||
"psychodelic" << "soundtrack" << "reggae" << "house" << "drum and base";
|
||||
|
||||
QStandardItem *selectGenreItem = new QStandardItem("choose genre...");
|
||||
selectGenreItem->setData(1, RolePage);
|
||||
selectGenreItem->setData(CreateByGenre, RoleCreateBy);
|
||||
byGenreItem->appendRow(selectGenreItem);
|
||||
foreach(const QString &genre, genres) {
|
||||
QStandardItem *genreItem = new QStandardItem(genre);
|
||||
genreItem->setData(2, RolePage);
|
||||
genreItem->setData(CreateByNone, RoleCreateBy);
|
||||
byGenreItem->appendRow(genreItem);
|
||||
}
|
||||
|
||||
// Fill in years (static for now)
|
||||
QStringList years;
|
||||
years << "50" << "60" << "70" << "80" << "90";
|
||||
|
||||
QStandardItem *selectYearItem = new QStandardItem("choose year...");
|
||||
selectYearItem->setData(1, RolePage);
|
||||
selectYearItem->setData(CreateByYear, RoleCreateBy);
|
||||
byYearItem->appendRow(selectYearItem);
|
||||
foreach(const QString &year, years) {
|
||||
QStandardItem *yearItem = new QStandardItem(year);
|
||||
yearItem->setData(2, RolePage);
|
||||
yearItem->setData(CreateByNone, RoleCreateBy);
|
||||
byYearItem->appendRow(yearItem);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicQmlWidget::breadcrumbChanged(const QModelIndex &index)
|
||||
{
|
||||
tDebug() << "**************************************" << index.data(RolePage).toInt() << index.data(RoleCreateBy);
|
||||
emit pagePicked(index.data(RolePage).toInt(), index.data(RoleCreateBy).toInt());
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@
|
||||
#include "widgets/DeclarativeView.h"
|
||||
|
||||
#include <QDeclarativeImageProvider>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class PlayableModel;
|
||||
class PlayableProxyModel;
|
||||
@@ -32,26 +31,17 @@ class PlayableProxyModel;
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class Breadcrumb;
|
||||
class DynamicModel;
|
||||
|
||||
class DynamicQmlWidget : public QWidget, public Tomahawk::ViewPage
|
||||
class DynamicQmlWidget : public DeclarativeView, public Tomahawk::ViewPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS(CreateBy)
|
||||
Q_PROPERTY(QString title READ title)
|
||||
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
|
||||
Q_PROPERTY(bool configured READ configured NOTIFY configuredChanged)
|
||||
|
||||
public:
|
||||
enum CreateBy {
|
||||
CreateByNone,
|
||||
CreateByArtist,
|
||||
CreateByGenre,
|
||||
CreateByYear
|
||||
};
|
||||
|
||||
explicit DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0 );
|
||||
virtual ~DynamicQmlWidget();
|
||||
|
||||
@@ -76,7 +66,6 @@ public:
|
||||
signals:
|
||||
void loadingChanged();
|
||||
void configuredChanged();
|
||||
void pagePicked(int page, int createBy);
|
||||
|
||||
public slots:
|
||||
void playItem(int index);
|
||||
@@ -102,29 +91,17 @@ private slots:
|
||||
void loadArtistCharts();
|
||||
void onArtistCharts( const QList< Tomahawk::artist_ptr >& artists );
|
||||
|
||||
void createStationModel();
|
||||
void breadcrumbChanged(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
enum Roles {
|
||||
RolePage = Qt::UserRole,
|
||||
RoleCreateBy,
|
||||
};
|
||||
|
||||
DynamicModel* m_model;
|
||||
PlayableProxyModel* m_proxyModel;
|
||||
dynplaylist_ptr m_playlist;
|
||||
|
||||
PlayableModel* m_artistChartsModel;
|
||||
|
||||
QStandardItemModel *m_createStationModel;
|
||||
Breadcrumb *m_breadcrumb;
|
||||
DeclarativeView *m_declarativeView;
|
||||
|
||||
bool m_runningOnDemand;
|
||||
bool m_activePlaylist;
|
||||
};
|
||||
|
||||
}
|
||||
Q_DECLARE_METATYPE(Tomahawk::DynamicQmlWidget::CreateBy);
|
||||
|
||||
#endif // DYNAMIC_QML_WIDGET_H
|
||||
|
Reference in New Issue
Block a user