Message info
 
To:kde-commits@kde.org From:Shantanu Tushar Subject:[plasma-mediacenter/plain-containment-shantanu] /: Make the browser functional Date:Sun, 18 Mar 2012 16:47:52 +0100 (CET)
 

Git commit 9d70a94833a2cdb3a121eb630b4d8b4b85ba49a9 by Shantanu Tushar.
Committed on 10/03/2012 at 18:37.
Pushed by shantanu into branch 'plain-containment-shantanu'.

Make the browser functional

M +0 -4 browsingbackends/metadatabackends/abstractmetadatamodel.cpp
M +1 -2 browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
M +1 -0 components/CMakeLists.txt
M +8 -0 components/backendsmodel/backendsmodel.cpp
M +3 -0 components/backendsmodel/backendsmodel.h
M +50 -2 components/mediabrowser/MediaBrowser.qml
M +2 -3 components/mediawelcome/MediaWelcome.qml
M +1 -0 components/qmldir
M +35 -14 shells/newshell/package/contents/ui/mediacenter.qml

http://commits.kde.org/plasma-mediacenter/9d70a94833a2cdb3a121eb630b4d8b4b85ba49a9

diff --git a/browsingbackends/metadatabackends/abstractmetadatamodel.cpp b/browsingbackends/metadatabackends/abstractmetadatamodel.cpp
index 579d514..67e3b2d 100644
--- a/browsingbackends/metadatabackends/abstractmetadatamodel.cpp
+++ b/browsingbackends/metadatabackends/abstractmetadatamodel.cpp
@@ -132,16 +132,12 @@ QVariant AbstractMetadataModel::data (const QModelIndex& index, int role) const
switch (role) {
case Qt::DisplayRole:
return metadataModel()->data(index, d->labelKey);
- break;
case Qt::DecorationRole:
return metadataModel()->data(index, d->iconKey);
- break;
case MediaCenter::MediaUrlRole:
return metadataModel()->data(index, d->urlKey);
- break;
case MediaCenter::IsExpandableRole:
return false;
- break;
}

return QVariant();
diff --git a/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp b/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
index 4128af2..75284d2 100644
--- a/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
+++ b/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
@@ -25,7 +25,6 @@
#include <QtGui/QIcon>
#include <QEvent>

-
MetadataPictureModel::MetadataPictureModel (QObject* parent)
: AbstractMetadataModel (parent)
{
@@ -51,7 +50,7 @@ QVariant MetadataPictureModel::data (const QModelIndex& index, int role) const
return QVariant();
}

- if (role == Qt::DecorationRole) {
+ if (role == Qt::DecorationRole) {
if (!MetadataPictureModel::data(index, MediaCenter::IsExpandableRole).toBool())
return AbstractMetadataModel::data (index, MediaCenter::MediaUrlRole);
}
diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt
index 9aae83b..4a88415 100644
--- a/components/CMakeLists.txt
+++ b/components/CMakeLists.txt
@@ -6,3 +6,4 @@ install(DIRECTORY mediacontroller DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/pla
install(DIRECTORY mediainfobar DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents)
install(DIRECTORY mediaplayer DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents)
install(DIRECTORY mediawelcome DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents)
+install(DIRECTORY runtimedata DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/mediacentercomponents)
diff --git a/components/backendsmodel/backendsmodel.cpp b/components/backendsmodel/backendsmodel.cpp
index b2d07e0..fc8ad5b 100644
--- a/components/backendsmodel/backendsmodel.cpp
+++ b/components/backendsmodel/backendsmodel.cpp
@@ -16,6 +16,10 @@ BackendsModel::BackendsModel (QObject* parent) : QAbstractListModel (parent)
backend = service->createInstance<MediaCenter::AbstractBrowsingBackend>(0, QVariantList() << service->storageId());
loadBrowsingBackend(backend);
}
+
+ QHash<int, QByteArray> roles = roleNames();
+ roles[ModelObjectRole] = "modelObject";
+ setRoleNames(roles);
}

bool BackendsModel::loadBrowsingBackend(MediaCenter::AbstractBrowsingBackend *backend)
@@ -40,6 +44,10 @@ QVariant BackendsModel::data (const QModelIndex& index, int role) const
return backends.at(index.row())->name();
case Qt::DecorationRole:
return backends.at(index.row())->icon();
+ case ModelObjectRole:
+ QVariant ptr;
+ ptr.setValue(qobject_cast<QObject*>(backends.at(index.row())));
+ return ptr;
}

return QVariant();
diff --git a/components/backendsmodel/backendsmodel.h b/components/backendsmodel/backendsmodel.h
index 8f4050c..5d06188 100644
--- a/components/backendsmodel/backendsmodel.h
+++ b/components/backendsmodel/backendsmodel.h
@@ -11,6 +11,9 @@ class BackendsModel : public QAbstractListModel
{
Q_OBJECT
public:
+ enum Roles {
+ ModelObjectRole = Qt::UserRole + 1
+ };
explicit BackendsModel (QObject* parent = 0);
virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
virtual int rowCount (const QModelIndex& parent = QModelIndex()) const;
diff --git a/components/mediabrowser/MediaBrowser.qml b/components/mediabrowser/MediaBrowser.qml
index 5af28e9..ad59f33 100644
--- a/components/mediabrowser/MediaBrowser.qml
+++ b/components/mediabrowser/MediaBrowser.qml
@@ -1,5 +1,53 @@
+/*
+ * Copyright 2011 Sinny Kumari <ksinny@gmail.com>
+ * Copyright 2010 Lukas Appelhans <l.appelhans@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
import QtQuick 1.1
+import org.kde.metadatamodels 0.1 as MetadataModels
+
+Item {
+ id: mediaBrowser
+ clip: true
+ property QtObject currentBrowsingBackend
+
+ MetadataModels.MetadataModel
+ {
+ id: metadataModel
+ }
+
+ GridView {
+ id: mediaBrowserGridView
+ anchors.fill: parent
+ cellWidth: width / 5
+ cellHeight: width / 6
+ delegate: MediaItemDelegate {}
+ highlight: MediaItemHighlight {}
+ focus: true
+ highlightFollowsCurrentItem: true
+ flow: GridView.TopToBottom
+ cacheBuffer: width*10
+ }

-Text {
- text: "hello world"
+ onCurrentBrowsingBackendChanged: {
+ console.log("INIT'ing " + currentBrowsingBackend)
+ currentBrowsingBackend.metadataModel = metadataModel;
+ currentBrowsingBackend.init();
+ mediaBrowserGridView.model = (function() { return currentBrowsingBackend.backendModel; })
+ }
}
diff --git a/components/mediawelcome/MediaWelcome.qml b/components/mediawelcome/MediaWelcome.qml
index 4184388..5cee49b 100644
--- a/components/mediawelcome/MediaWelcome.qml
+++ b/components/mediawelcome/MediaWelcome.qml
@@ -29,7 +29,7 @@ PathView {
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5

- signal clicked
+ signal backendSelected(variant selectedBackend)

delegate: Component {
Item {
@@ -60,8 +60,7 @@ PathView {

MouseArea {
anchors.fill: parent
- onClicked: {
- }
+ onClicked: view.backendSelected(modelObject)
}
}
}
diff --git a/components/qmldir b/components/qmldir
index aa9dd4c..646927b 100644
--- a/components/qmldir
+++ b/components/qmldir
@@ -3,4 +3,5 @@ MediaController 0.1 mediacontroller/MediaController.qml
MediaInfoBar 0.1 mediainfobar/MediaInfoBar.qml
MediaPlayer 0.1 mediaplayer/MediaPlayer.qml
MediaWelcome 0.1 mediawelcome/MediaWelcome.qml
+RuntimeData 0.1 runtimedata/RuntimeData.qml
plugin backendsmodelplugin backendsmodelplugin/
diff --git a/shells/newshell/package/contents/ui/mediacenter.qml b/shells/newshell/package/contents/ui/mediacenter.qml
index 5fa6a70..8d102c8 100644
--- a/shells/newshell/package/contents/ui/mediacenter.qml
+++ b/shells/newshell/package/contents/ui/mediacenter.qml
@@ -11,32 +11,53 @@ Rectangle {

MediaCenterComponents.MediaPlayer {
anchors.fill: parent
+ z: -1
}

MediaCenterComponents.BackendsModel {
id: backendsModel
}

- Column {
- anchors.fill: parent
+ MediaCenterComponents.RuntimeData {
+ id: runtimeData
+ }

- MediaCenterComponents.MediaController {
- id: mediaController
- height: parent.height*0.1
- width: parent.width
+ MediaCenterComponents.MediaController {
+ id: mediaController
+ height: parent.height*0.1
+ width: parent.width
+ anchors {
+ left: parent.left; right: parent.left; top: parent.top
}
+ }

- MediaCenterComponents.MediaWelcome {
- height: parent.height - mediaController.height - mediaInfoBar.height
- model: backendsModel
+ MediaCenterComponents.MediaWelcome {
+ width: parent.width
+ model: backendsModel
+ anchors {
+ left: parent.left; right: parent.right; top: mediaController.top; bottom: mediaInfoBar.top
}

- MediaCenterComponents.MediaInfoBar {
- id: mediaInfoBar
- height: parent.height * 0.1
- width: parent.width
+ onBackendSelected: { runtimeData.currentBrowsingBackend = selectedBackend; visible = false }
+ }
+
+ MediaCenterComponents.MediaBrowser {
+ width: parent.width
+ anchors {
+ left: parent.left; right: parent.right; top: mediaController.top; bottom: mediaInfoBar.top
}
+ visible: false
+
+ currentBrowsingBackend: runtimeData.currentBrowsingBackend
+ onCurrentBrowsingBackendChanged: visible = true
+ }

- z: 1
+ MediaCenterComponents.MediaInfoBar {
+ id: mediaInfoBar
+ height: parent.height * 0.1
+ width: parent.width
+ anchors {
+ left: parent.left; right: parent.left; bottom: parent.bottom
+ }
}
}