Message info
 
To:kde-commits@kde.org From:Shantanu Tushar Subject:[plasma-mediacenter/plain-containment-shantanu] /: Some changes to ItemDelegate logic for Image/Icon Date:Sun, 18 Mar 2012 16:47:52 +0100 (CET)
 

Git commit 6356b64c6e784d022afbc216920190da0a5c2298 by Shantanu Tushar.
Committed on 11/03/2012 at 14:08.
Pushed by shantanu into branch 'plain-containment-shantanu'.

Some changes to ItemDelegate logic for Image/Icon
Dont show label when not required, as its expensive with metadata

M +3 -2 browsingbackends/metadatabackends/abstractmetadatamodel.cpp
M +10 -8 browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
M +6 -1 browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp
M +7 -2 components/mediabrowser/MediaBrowser.qml
M +23 -23 components/mediabrowser/MediaItemDelegate.qml
M +9 -3 components/mediabrowser/MediaItemHighlight.qml
M +0 -1 components/mediainfobar/MediaInfoBar.qml
M +6 -0 components/mediaplayer/MediaPlayer.qml
M +2 -0 libs/mediacenter/mediacenter.cpp
M +4 -2 libs/mediacenter/mediacenter.h
M +7 -7 shells/newshell/package/contents/ui/mediacenter.qml

http://commits.kde.org/plasma-mediacenter/6356b64c6e784d022afbc216920190da0a5c2298

diff --git a/browsingbackends/metadatabackends/abstractmetadatamodel.cpp b/browsingbackends/metadatabackends/abstractmetadatamodel.cpp
index 85a0def..581b05c 100644
--- a/browsingbackends/metadatabackends/abstractmetadatamodel.cpp
+++ b/browsingbackends/metadatabackends/abstractmetadatamodel.cpp
@@ -19,8 +19,9 @@


#include "abstractmetadatamodel.h"
-#include <mediacenter/mediacenter.h>
-#include <mediacenter/abstractbrowsingbackend.h>
+
+#include <libs/mediacenter/mediacenter.h>
+#include <libs/mediacenter/abstractbrowsingbackend.h>

#include <QtGui/QIcon>
#include <QtCore/QEvent>
diff --git a/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp b/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
index 4df94c6..aca5173 100644
--- a/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
+++ b/browsingbackends/metadatabackends/metadatapicturebackend/metadatapicturemodel.cpp
@@ -32,7 +32,7 @@ MetadataPictureModel::MetadataPictureModel (QObject* parent)
resetMetadataModel();
metadataModel()->setProperty("resourceType", "nfo:Image");
metadataModel()->setProperty("mimeType", "");
- metadataModel()->setProperty("limit", 50);
+ metadataModel()->setProperty("limit", 100);
}
else {
kDebug() << "WARNING: Constructor called before metadataModel set :/";
@@ -50,16 +50,18 @@ QVariant MetadataPictureModel::data (const QModelIndex& index, int role) const
return QVariant();
}

- if (role == Qt::DecorationRole) {
- if (!MetadataPictureModel::data(index, MediaCenter::IsExpandableRole).toBool())
+ switch (role) {
+ case Qt::DecorationRole:
+ if (!MetadataPictureModel::data(index, MediaCenter::IsExpandableRole).toBool()) {
return AbstractMetadataModel::data (index, MediaCenter::MediaUrlRole);
- }
- if(role == MediaCenter::MediaTypeRole) {
+ }
+ case MediaCenter::MediaTypeRole:
return "image";
+ case MediaCenter::HideLabelRole:
+ return true;
}
- else {
- return AbstractMetadataModel::data(index, role);
- }
+
+ return AbstractMetadataModel::data(index, role);
}

#include "metadatapicturemodel.moc"
diff --git a/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp b/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp
index 397613c..63301fc 100644
--- a/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp
+++ b/browsingbackends/metadatabackends/metadatavideobackend/metadatavideomodel.cpp
@@ -20,6 +20,7 @@

#include "metadatavideomodel.h"
#include "metadatavideothumbnailprovider.h"
+#include <mediacenter/mediacenter.h>

#include <mediacenter/mediacenter.h>
#include <mediacenter/abstractbrowsingbackend.h>
@@ -44,9 +45,9 @@ MetadataVideoModel::MetadataVideoModel(QObject* parent)
if(metadataModel()) {
d->thumbnailKey = metadataModel()->roleNames().key("thumbnail");
resetMetadataModel();
+ metadataModel()->setProperty("thumbnailSize", QSize(600, 600));
metadataModel()->setProperty("resourceType", "nfo:FileDataObject");
metadataModel()->setProperty("mimeType", "video");
- metadataModel()->setProperty("limit", 4);
} else {
kDebug() << "WARNING: Constructor called before metadataModel set :/";
}
@@ -68,6 +69,10 @@ QVariant MetadataVideoModel::data(const QModelIndex& index, int role) const
return "video";
case Qt::DecorationRole:
return AbstractMetadataModel::data(index, d->thumbnailKey);
+ case MediaCenter::DecorationTypeRole:
+ return "qimage";
+ case MediaCenter::HideLabelRole:
+ return true;
default:
return AbstractMetadataModel::data(index, role);
}
diff --git a/components/mediabrowser/MediaBrowser.qml b/components/mediabrowser/MediaBrowser.qml
index ac30769..bca270a 100644
--- a/components/mediabrowser/MediaBrowser.qml
+++ b/components/mediabrowser/MediaBrowser.qml
@@ -25,6 +25,7 @@ Item {
id: mediaBrowser
clip: true
property QtObject currentBrowsingBackend
+ property alias count: mediaBrowserGridView.count

signal playRequested(string url)

@@ -42,8 +43,8 @@ Item {
backend: currentBrowsingBackend
onPlayRequested: mediaBrowser.playRequested(url)
}
- highlight: MediaItemHighlight {}
- //focus: true
+ highlight: MediaItemHighlight { z:1 }
+ focus: true
highlightFollowsCurrentItem: true
flow: GridView.TopToBottom
cacheBuffer: width*10
@@ -53,6 +54,10 @@ Item {
console.log("INIT'ing " + currentBrowsingBackend)
currentBrowsingBackend.metadataModel = metadataModel;
currentBrowsingBackend.init();
+ }
+
+ function loadModel()
+ {
mediaBrowserGridView.model = (function() { return currentBrowsingBackend.backendModel; })
}
}
diff --git a/components/mediabrowser/MediaItemDelegate.qml b/components/mediabrowser/MediaItemDelegate.qml
index b5ff76e..30e1c9c 100644
--- a/components/mediabrowser/MediaItemDelegate.qml
+++ b/components/mediabrowser/MediaItemDelegate.qml
@@ -2,10 +2,12 @@ import QtQuick 1.1
import org.kde.qtextracomponents 0.1 as QtExtraComponents
import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.plasma.core 0.1 as PlasmaCore
+import "MediaItemDelegateLogic.js" as Logic

Item {
id: mediaItemDelegateItem
width: GridView.view.cellWidth; height: GridView.view.cellHeight
+ clip: true

property QtObject backend
signal playRequested(string url)
@@ -15,34 +17,20 @@ Item {
}

Column {
+ id: rootColumn
anchors. fill: parent
+ property variant source

Loader {
id: iconImageLoader
- width: parent.width * 0.95; height: parent.height - itemText.height;
+ width: parent.width * 0.95
+ height: parent.height - (itemText.visible ? itemText.height : 0 );

function checkAndLoad()
{
- console.log("checking for " + typeof(decoration))
- if (typeof(decoration) == "string") {
- console.log("string")
- if (decoration.search('[a-z]+://') == 0) {
- sourceComponent = delegateItemImageComponent;
- if (item) {
- item.source = decoration;
- }
- } else {
- sourceComponent = delegateItemIconComponent;
- item.icon = QIcon(decoration);
- }
- } else if (typeof(decoration) == "object") {
- console.log(decoration)
- sourceComponent = delegateItemIconComponent;
- if (item) {
- item.icon = QIcon(decoration);
- }
- }
+ Logic.checkAndLoad(iconImageLoader);
}
+
Component.onCompleted: checkAndLoad()
}

@@ -53,10 +41,12 @@ Item {
width: parent.width
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
- fillMode: Image.PreserveAspectFit
- sourceSize.width: 128
+ fillMode: Image.PreserveAspectCrop
+ sourceSize.width: width
sourceSize.height: 0
asynchronous: true
+ source: rootColumn.source
+ //cache: false
}
}

@@ -67,12 +57,22 @@ Item {
width: parent.width
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
+ icon: {
+ if (typeof rootColumn.source == "string")
+ QIcon(rootColumn.source);
+ else
+ if (decorationType == "qimage")
+ QIcon(rootColumn.source);
+ else
+ rootColumn.source
+ }
}
}

Text {
id: itemText
- text: display
+ text: hideLabel ? "" : display
+ visible: !hideLabel
font.pointSize: 20
color: theme.textColor
elide: Text.ElideRight
diff --git a/components/mediabrowser/MediaItemHighlight.qml b/components/mediabrowser/MediaItemHighlight.qml
index 067d32b..5d86f08 100644
--- a/components/mediabrowser/MediaItemHighlight.qml
+++ b/components/mediabrowser/MediaItemHighlight.qml
@@ -1,7 +1,13 @@
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore

-PlasmaCore.FrameSvgItem {
- imagePath: "widgets/viewitem"
- prefix: "selected+hover"
+Item {
+ PlasmaCore.FrameSvgItem {
+ anchors.centerIn: parent
+ width: parent.width * 1.2
+ height: parent.height * 1.2
+
+ imagePath: "widgets/viewitem"
+ prefix: "selected+hover"
+ }
}
diff --git a/components/mediainfobar/MediaInfoBar.qml b/components/mediainfobar/MediaInfoBar.qml
index 5af28e9..70278c7 100644
--- a/components/mediainfobar/MediaInfoBar.qml
+++ b/components/mediainfobar/MediaInfoBar.qml
@@ -1,5 +1,4 @@
import QtQuick 1.1

Text {
- text: "hello world"
}
diff --git a/components/mediaplayer/MediaPlayer.qml b/components/mediaplayer/MediaPlayer.qml
index 178fb89..c30af7d 100644
--- a/components/mediaplayer/MediaPlayer.qml
+++ b/components/mediaplayer/MediaPlayer.qml
@@ -6,6 +6,7 @@ Rectangle {
color: "black"

property alias url: video.source
+ signal clicked

Phonon.Media {
id: video
@@ -32,4 +33,9 @@ Rectangle {
{
video.play();
}
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: mediaPlayerRootRect.clicked()
+ }
}
diff --git a/libs/mediacenter/mediacenter.cpp b/libs/mediacenter/mediacenter.cpp
index 9a26bfd..e76c40a 100644
--- a/libs/mediacenter/mediacenter.cpp
+++ b/libs/mediacenter/mediacenter.cpp
@@ -98,6 +98,8 @@ QHash<int, QByteArray> appendAdditionalMediaRoles (const QHash<int, QByteArray>
newRoles[MediaUrlRole] = "mediaUrl";
newRoles[IsExpandableRole] = "isExpandable";
newRoles[MediaTypeRole] = "mediaType";
+ newRoles[DecorationTypeRole] = "decorationType";
+ newRoles[HideLabelRole] = "hideLabel";
return newRoles;
}

diff --git a/libs/mediacenter/mediacenter.h b/libs/mediacenter/mediacenter.h
index 675b436..3b707d4 100644
--- a/libs/mediacenter/mediacenter.h
+++ b/libs/mediacenter/mediacenter.h
@@ -32,8 +32,10 @@ namespace MediaCenter {

enum AdditionalMediaRoles {
MediaUrlRole = Qt::UserRole + 1,
- IsExpandableRole = Qt::UserRole + 2,
- MediaTypeRole = Qt::UserRole + 3
+ IsExpandableRole,
+ MediaTypeRole,
+ DecorationTypeRole,
+ HideLabelRole
};

enum MediaType {
diff --git a/shells/newshell/package/contents/ui/mediacenter.qml b/shells/newshell/package/contents/ui/mediacenter.qml
index c5d7133..c16e96a 100644
--- a/shells/newshell/package/contents/ui/mediacenter.qml
+++ b/shells/newshell/package/contents/ui/mediacenter.qml
@@ -4,15 +4,11 @@ import org.kde.plasma.mediacentercomponents 0.1 as MediaCenterComponents
Rectangle {
id: mediaCenterRootItem

- gradient: Gradient {
- GradientStop { position: 0.0; color: "lightsteelblue" }
- GradientStop { position: 1.0; color: "black" }
- }
-
MediaCenterComponents.MediaPlayer {
id: mediaPlayer
anchors.fill: parent
- z: -1
+
+ onClicked: mediaBrowser.visible = mediaBrowser.visible ? false : true
}

MediaCenterComponents.RuntimeData {
@@ -39,18 +35,22 @@ Rectangle {
}

MediaCenterComponents.MediaBrowser {
+ id: mediaBrowser
width: parent.width
anchors {
left: parent.left; right: parent.right; top: mediaController.top; bottom: mediaInfoBar.top
}
visible: false
+ z: 1

currentBrowsingBackend: runtimeData.currentBrowsingBackend
onCurrentBrowsingBackendChanged: visible = true
+ onVisibleChanged: if (visible) loadModel();
onPlayRequested: {
+ mediaPlayer.visible = true
mediaPlayer.url = url
mediaPlayer.play()
- mediaPlayer.z = 2
+ mediaBrowser.visible = false
}
}