From d49ce2f242a3679f03760597a4fe1e3ad9743d7d Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 7 Sep 2011 07:23:46 +0200 Subject: [PATCH] Allow changing current view from qml --- src/active/tomahawktouchwindow.cpp | 11 +++++++++++ src/active/tomahawktouchwindow.h | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/active/tomahawktouchwindow.cpp b/src/active/tomahawktouchwindow.cpp index 1c6d55da8..183081f5d 100644 --- a/src/active/tomahawktouchwindow.cpp +++ b/src/active/tomahawktouchwindow.cpp @@ -22,6 +22,7 @@ #include "audio/audioengine.h" #include "globalactionmanager.h" #include "sourcesmodel.h" +#include "items/sourcetreeitem.h" #include @@ -55,6 +56,15 @@ void TomahawkTouchWindow::play(const QModelIndex& index) } +void TomahawkTouchWindow::activateItem(const QModelIndex& index) +{ + tLog() << Q_FUNC_INFO << index; + SourceTreeItem* item = qobject_cast< SourceTreeItem* >( s_sourcesModel->data( index, SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() ); + item->activate(); +} + + + void TomahawkTouchWindow::loadQml() { @@ -76,6 +86,7 @@ TomahawkTouchWindow::loadQml() QDeclarativeContext* context = m_view->rootContext(); tLog()<< Q_FUNC_INFO << "make objects accessible from qml"; + context->setContextProperty( "touchWindow", this ); context->setContextProperty( "audioEngine", AudioEngine::instance() ); context->setContextProperty( "globalActionManager", GlobalActionManager::instance() ); context->setContextProperty( "sourcesModel", s_sourcesModel ); diff --git a/src/active/tomahawktouchwindow.h b/src/active/tomahawktouchwindow.h index 723c1dc67..77563c04c 100644 --- a/src/active/tomahawktouchwindow.h +++ b/src/active/tomahawktouchwindow.h @@ -34,8 +34,9 @@ public: TomahawkTouchWindow(); ~TomahawkTouchWindow(); -public slots: - void play( const QModelIndex& index ); + + Q_INVOKABLE void play( const QModelIndex& index ); + Q_INVOKABLE void activateItem( const QModelIndex& index ); private slots: void loadQml();