[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma
From: Marco Martin <notmart () gmail ! com>
Date: 2010-12-04 19:29:54
Message-ID: 20101204192954.14D96AC8A4 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1203593 by mart:
move the addons applet into examples
M +9 -4 MediaCenterComponents/applets/mediabrowser/CMakeLists.txt
M +9 -5 MediaCenterComponents/applets/mediabrowser/browsingbackends/localfiles/localfilesabstractbackend.cpp \
M +1 -1 MediaCenterComponents/applets/mediabrowser/browsingbackends/localfiles/localfilesabstractbackend.h \
M +38 -40 MediaCenterComponents/applets/mediabrowser/mediabrowser.cpp
M +5 -4 MediaCenterComponents/applets/mediabrowser/mediabrowser.h
M +21 -1 MediaCenterComponents/libs/mediacenter/abstractbrowsingbackend.cpp
M +19 -9 MediaCenterComponents/libs/mediacenter/abstractbrowsingbackend.h
A declarative-applets/examples/addons (directory)
M +2 -1 libs/CMakeLists.txt
M +15 -10 shells/meego/plasmaapp.cpp
M +15 -1 shells/meego/plasmaapp.h
D shells/mobile/applets/addons (directory)
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediabrowser/CMakeLists.txt \
#1203592:1203593 @@ -1,9 +1,9 @@
set(mediabrowser_SRCS
mediabrowser.cpp
-abstractmediaitemview.cpp
-listview.cpp
-gridview.cpp
-fileviewitem.cpp
+#abstractmediaitemview.cpp
+#listview.cpp
+#gridview.cpp
+#fileviewitem.cpp
)
# Now make sure all files get to the right place
@@ -14,6 +14,7 @@
${KDE4_KIO_LIBS}
${KDE4_KFILE_LIBS}
${KDE4_NEPOMUK_LIBS}
+ ${QT_QTDECLARATIVE_LIBRARY}
mediacenterlibs
)
@@ -23,4 +24,8 @@
install(FILES plasma-applet-mediabrowser.desktop
DESTINATION ${SERVICES_INSTALL_DIR})
+install(FILES
+filegrid.qml
+DESTINATION ${DATA_INSTALL_DIR}/plasma-mediacenter/declarative/)
+
add_subdirectory(browsingbackends)
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediabrowser/browsingbackends/localfiles/localfilesabstractbackend.cpp \
#1203592:1203593 @@ -54,11 +54,6 @@
}
-QAbstractItemModel* LocalFilesAbstractBackend::model()
-{
- return m_model;
-}
-
void LocalFilesAbstractBackend::setBackendName(const QString& name)
{
m_backendName = name;
@@ -117,10 +112,19 @@
if (!m_model) {
m_model = new KDirModel(this);
+ connect(m_model->dirLister(), SIGNAL(completed()), SLOT(resetModel()));
+ setModel(m_model);
initModel();
}
}
+void LocalFilesAbstractBackend::resetModel()
+{
+ kDebug() << "Reset the model" << m_model->rowCount();
+ setModel(0);
+ setModel(m_model);
+}
+
void LocalFilesAbstractBackend::getWatchedDirsList()
{
KUrl url = KFileDialog::getExistingDirectoryUrl();
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediabrowser/browsingbackends/localfiles/localfilesabstractbackend.h \
#1203592:1203593 @@ -34,7 +34,6 @@
LocalFilesAbstractBackend(const QString &name, QObject* parent, const \
QVariantList& args); virtual ~LocalFilesAbstractBackend();
- QAbstractItemModel* model();
virtual void createConfigurationInterface(KConfigDialog* parent);
virtual void init();
@@ -45,6 +44,7 @@
void configAccepted();
void getWatchedDirsList();
void removeItem();
+ void resetModel();
private:
void setBackendName(const QString &name);
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediabrowser/mediabrowser.cpp \
#1203592:1203593 @@ -28,6 +28,10 @@
#include <QWidget>
#include <QKeyEvent>
#include <QGraphicsLinearLayout>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeComponent>
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/qdeclarative.h>
#include <KDirModel>
#include <KConfigDialog>
@@ -37,10 +41,12 @@
#include <KDebug>
#include <KDirLister>
+QML_DECLARE_TYPE(MediaCenter::AbstractBrowsingBackend)
+
MediaBrowser::MediaBrowser(QObject *parent, const QVariantList &args)
: MediaCenter::Browser(parent, args),
m_view(0),
- m_model(0),
+ m_backend(0),
m_layout(new QGraphicsLinearLayout(Qt::Vertical))
{
setAspectRatioMode(Plasma::IgnoreAspectRatio);
@@ -48,6 +54,8 @@
setEnableToolbar(true);
toolbar()->setNavigationControls(MediaCenter::NavigationToolbar::BackwardControl \
| MediaCenter::NavigationToolbar::ViewModeControl); +
+ qmlRegisterType<MediaCenter::AbstractBrowsingBackend>("MediaCenter", 0, 1, \
"AbstractBrowsingBackend"); }
MediaBrowser::~MediaBrowser()
@@ -55,16 +63,16 @@
void MediaBrowser::showInstalledBackends()
{
-// delete m_model;
+// delete m_backend->model();
// m_model = new StartupModel(this);
-// m_view->setModel(m_model);
+// m_view->setModel(m_backend->model());
// QmlHomeView *homeView = new QmlHomeView(this);
// QGraphicsLinearLayout *layout = \
static_cast<QGraphicsLinearLayout*>(this->layout()); // \
layout->addItem(homeView);
// homeView->setQmlPath(KStandardDirs::locate("data", \
"plasma-mediacenter/declarative/homeview.qml"));
-// homeView->setModel(m_model);
+// homeView->setModel(m_backend->model());
}
void MediaBrowser::init()
@@ -78,23 +86,14 @@
void MediaBrowser::createView()
{
delete m_view;
- kDebug() << "view deleted";
+ m_view = new Plasma::DeclarativeWidget(this);
- if (m_viewType == "list") {
- m_view = new ListView(this);
- } else {
- m_view = new GridView(this);
- }
+ m_view->setQmlPath(KStandardDirs::locate("data", \
"plasma-mediacenter/declarative/filegrid.qml"));
- m_view->setDrawBlurredText(m_blurred);
- m_view->setFocus(Qt::OtherFocusReason);
-
- if (m_model) {
- m_view->setModel(m_model);
-// m_view->generateItems();
+ if (m_backend) {
+ m_view->engine()->rootContext()->setContextProperty("fileBackend", \
m_backend); }
-
- connect (this, SIGNAL(browseHistoryBackRequest()), m_view, SLOT(goPrevious()));
+ /*connect (this, SIGNAL(browseHistoryBackRequest()), m_view, \
SLOT(goPrevious()));
connect (m_view, SIGNAL(mediasActivated(QList<MediaCenter::Media>)), this, \
SIGNAL(mediasActivated(QList<MediaCenter::Media>)));
connect (m_view, SIGNAL(mediasListChanged(QList<MediaCenter::Media>)), this, \
SIGNAL(mediasListChanged(QList<MediaCenter::Media>)));
connect (m_view, SIGNAL(mediaActivated(const MediaCenter::Media&)), this, \
SIGNAL(mediaActivated(const MediaCenter::Media&))); @@ -102,6 +101,7 @@
connect (m_view, SIGNAL(mediaSelected(MediaCenter::Media)), this, \
SLOT(selectedMediasAdd(MediaCenter::Media)));
connect (m_view, SIGNAL(mediaUnselected(MediaCenter::Media)), this, \
SLOT(selectedMediasRemove(MediaCenter::Media)));
connect (m_view, SIGNAL(directoryChanged()), this, SLOT(clearSelectedMedias()));
+// // */
QGraphicsLinearLayout *layout = \
static_cast<QGraphicsLinearLayout*>(this->layout()); layout->addItem(m_view);
@@ -109,7 +109,7 @@
void MediaBrowser::createConfigurationInterface(KConfigDialog *parent)
{
- QWidget *generalConfig = new QWidget(parent);
+ /*QWidget *generalConfig = new QWidget(parent);
uiGeneral.setupUi(generalConfig);
parent->addPage(generalConfig, i18n("Browser appearance"), \
"preferences-desktop-display"); @@ -119,7 +119,7 @@
uiGeneral.gridRadio->setChecked(true);
}
- uiGeneral.blurredTextCheckBox->setChecked(m_blurred);
+ uiGeneral.blurredTextCheckBox->setChecked(m_blurred);*/
if (currentBrowsingBackend()) {
if (currentBrowsingBackend()->hasConfigurationInterface()) {
@@ -132,15 +132,15 @@
void MediaBrowser::loadConfiguration()
{
- KConfigGroup cf = config();
+ //KConfigGroup cf = config();
- m_viewType = cf.readEntry("ViewType", "list");
- m_blurred = cf.readEntry("BlurredText", true);
+ //m_viewType = cf.readEntry("ViewType", "list");
+ //m_blurred = cf.readEntry("BlurredText", true);
}
void MediaBrowser::configAccepted()
{
- KConfigGroup cf = config();
+ /*KConfigGroup cf = config();
kDebug() << cf.name();
QString type;
@@ -159,9 +159,9 @@
bool blurred = uiGeneral.blurredTextCheckBox->isChecked();
if (blurred != m_blurred) {
m_blurred = blurred;
- m_view->setDrawBlurredText(m_blurred);
+ //m_view->setDrawBlurredText(m_blurred);
cf.writeEntry("BlurredText", m_blurred);
- }
+ }*/
}
@@ -169,25 +169,23 @@
{
kDebug() << "loading browsing backend";
- m_view->setModel( 0 );
- backend->setParent(this);
- backend->init();
- m_model = backend->model();
- m_view->setModel( m_model );
+ m_backend = backend;
- emit browsingModeChanged( backend->requiredMode() );
+ m_backend->setParent(this);
+ m_backend->init();
+ m_view->engine()->rootContext()->setContextProperty("fileBackend", m_backend);
+ //m_view->engine()->rootContext()->setContextProperty("fileModel", \
m_backend->model()); +
+ emit browsingModeChanged( m_backend->requiredMode() );
}
void MediaBrowser::showStartupState()
{
- //Calling directly showInstalledBackends makes PMC crash on startup
- //m_model = new StartupModel(this);
- //m_view->setModel(m_model);
}
KUrl MediaBrowser::currentUrl() const
{
- KDirModel *modeldir = qobject_cast<KDirModel*>(m_model);
+ KDirModel *modeldir = qobject_cast<KDirModel*>(m_backend->model());
if (!modeldir || !modeldir->dirLister()) {
return KUrl();
}
@@ -196,7 +194,7 @@
void MediaBrowser::openUrl(const KUrl &url)
{
- KDirModel *modeldir = qobject_cast<KDirModel*>(m_model);
+ KDirModel *modeldir = qobject_cast<KDirModel*>(m_backend->model());
if (modeldir) {
modeldir->dirLister()->openUrl(url);
}
@@ -204,7 +202,7 @@
void MediaBrowser::listMediaInDirectory()
{
- m_view->listMediaInDirectory();
+ //m_view->listMediaInDirectory();
}
void MediaBrowser::selectedMediasAdd(const MediaCenter::Media &media)
@@ -236,7 +234,7 @@
void MediaBrowser::gestureEvent(MediaCenter::BrowserGesture *bGesture)
{
- if (!bGesture) {
+ /*if (!bGesture) {
return;
}
@@ -255,8 +253,8 @@
} else if (bGesture->activeAction() == \
MediaCenter::BrowserGesture::ActivateAction) {
QKeyEvent keyEvent(QKeyEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
qApp->sendEvent(m_view, &keyEvent);
+ }*/
}
-}
void MediaBrowser::createQmlHomeView()
{}
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediabrowser/mediabrowser.h \
#1203592:1203593 @@ -20,8 +20,9 @@
#define MEDIABROWSER_H
#include <mediacenter/browser.h>
+#include <plasma/widgets/declarativewidget.h>
-#include "ui_general.h"
+//#include "ui_general.h"
class QGraphicsLinearLayout;
class AbstractMediaItemView;
@@ -67,10 +68,10 @@
void pictureDataEngine();
private:
- AbstractMediaItemView *m_view;
- Ui::General uiGeneral;
+ Plasma::DeclarativeWidget * m_view;
+ //Ui::General uiGeneral;
- QAbstractItemModel *m_model;
+ MediaCenter::AbstractBrowsingBackend *m_backend;
bool m_blurred;
QString m_viewType;
--- trunk/playground/base/plasma/MediaCenterComponents/libs/mediacenter/abstractbrowsingbackend.cpp \
#1203592:1203593 @@ -32,7 +32,8 @@
AbstractBrowsingBackendPrivate(KService::Ptr service, AbstractBrowsingBackend \
*q) : backendInfo(service),
q(q),
- cfInterface(false)
+ cfInterface(false),
+ model(0)
{}
AbstractBrowsingBackend *q;
@@ -40,19 +41,38 @@
KPluginInfo backendInfo;
MediaCenter::Mode requiredMode;
BrowsingType browsingType;
+ QAbstractItemModel * model;
};
AbstractBrowsingBackend::AbstractBrowsingBackend(QObject *parent, const QVariantList \
&args) : QObject(parent), d(new \
AbstractBrowsingBackendPrivate(KService::serviceByStorageId(args.count() ? \
args.first().toString() : QString()), this)) {
Q_UNUSED(args);
+ qRegisterMetaType<QAbstractItemModel*>("QAbstractItemModel*");
}
+AbstractBrowsingBackend::AbstractBrowsingBackend(QObject * parent)
+ : QObject(parent),
+ d(new AbstractBrowsingBackendPrivate(KService::serviceByStorageId(QString()), \
this)) +{
+}
+
AbstractBrowsingBackend::~AbstractBrowsingBackend()
{
delete d;
}
+void AbstractBrowsingBackend::setModel(QAbstractItemModel * model)
+{
+ d->model = model;
+ emit modelChanged(d->model);
+}
+
+QObject * AbstractBrowsingBackend::model()
+{
+ return (QObject*)(d->model);
+}
+
bool AbstractBrowsingBackend::hasConfigurationInterface() const
{
return d->cfInterface;
--- trunk/playground/base/plasma/MediaCenterComponents/libs/mediacenter/abstractbrowsingbackend.h \
#1203592:1203593 @@ -49,6 +49,8 @@
class MEDIACENTER_EXPORT AbstractBrowsingBackend : public QObject
{
Q_OBJECT
+ Q_PROPERTY(QObject* backendModel READ model/* WRITE setModel*/ NOTIFY \
modelChanged) +
public:
enum BrowsingType {
LocalBrowsing,
@@ -64,18 +66,13 @@
* The first argument of @param args must be the unique storageID of the \
service.
* */
AbstractBrowsingBackend(QObject *parent, const QVariantList &args);
+ AbstractBrowsingBackend(QObject *parent = 0);
virtual ~AbstractBrowsingBackend();
/**
- * This method must be reimplemented in order to provide the model to be
- * used by the view.
- * @note When LocalBrowsing is set it is highly recommended to use a KDirModel.
- * If the package is set to RemoteBrowsing the model
- * must provide an url that points to the media content for each
- * QModelIndex. It must make use of MediaRole role to accomplish this.
- * @see MediaRole
+ * @returns the model of the browsing backend
*/
- virtual QAbstractItemModel *model() = 0;
+ QObject *model();
/**
* @return the browsing type of the model. Typically a remote browsing type
@@ -127,7 +124,6 @@
*/
static KService::List availableBackends();
-public slots:
/**
* This slot must be reimplemented if browsingType returns
* LocalBrowsing. This method will be used to list the media
@@ -142,8 +138,22 @@
*/
virtual void searchForMedia(const QString &name);
+signals:
+ void modelChanged(QAbstractItemModel * model);
+
protected:
/**
+ * This method must be set in order to provide the model to be
+ * used by the view.
+ * @note When LocalBrowsing is set it is highly recommended to use a KDirModel.
+ * If the package is set to RemoteBrowsing the model
+ * must provide an url that points to the media content for each
+ * QModelIndex. It must make use of MediaRole role to accomplish this.
+ * @see MediaRole
+ */
+ void setModel(QAbstractItemModel * model);
+
+ /**
* As from Plasma::Applet this method should be used in order
* to inform about the availability of a configuration interface for
* the model.
--- trunk/playground/base/plasma/libs/CMakeLists.txt #1203592:1203593
@@ -1,2 +1,3 @@
add_subdirectory(qnotificationareaitem)
-add_subdirectory(jsanimation)
\ No newline at end of file
+add_subdirectory(jsanimation)
+add_subdirectory(storage)
--- trunk/playground/base/plasma/shells/meego/plasmaapp.cpp #1203592:1203593
@@ -39,33 +39,38 @@
#include <Plasma/Wallpaper>
#include <Plasma/WindowEffects>
-#include <meegotouch/MApplicationService>
-
#include "singleview.h"
static MApplication *kapp = 0;
-class KUniqueApplicationService: public MApplicationService
-{
-public:
- KUniqueApplicationService(QObject *parent = 0)
+
+KUniqueApplicationService::KUniqueApplicationService(QObject *parent)
: MApplicationService("org.kde.plasma-meegoapp", parent)
{
}
- void launch()
+void KUniqueApplicationService::launch()
+{;
+ PlasmaApp::self()->newInstance();
+}
+
+void KUniqueApplicationService::launch(const QStringList ¶meters)
{
- // PlasmaApp::self()->newInstance();
+ PlasmaApp::self()->newInstance();
}
- void handleServiceRegistrationFailure()
+void KUniqueApplicationService::handleServiceRegistrationFailure()
{
qDebug() << "KUniqueApplicationService::handleServiceRegistrationFailure()";
incrementAndRegister();
}
-};
+void KUniqueApplicationService::launchAnotherWithQProcess()
+{
+
+}
+
PlasmaApp* PlasmaApp::self(int argc, char **argv)
{
if (!kapp) {
--- trunk/playground/base/plasma/shells/meego/plasmaapp.h #1203592:1203593
@@ -29,8 +29,8 @@
#include <plasma/plasma.h>
#include <meegotouch/MApplication>
+#include <meegotouch/MApplicationService>
-
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <fixx11h.h>
@@ -45,6 +45,20 @@
class SingleView;
+
+class KUniqueApplicationService: public MApplicationService
+{
+ Q_OBJECT
+public:
+ KUniqueApplicationService(QObject *parent = 0);
+
+public Q_SLOTS:
+ void launch();
+ void launch(const QStringList ¶meters);
+ void handleServiceRegistrationFailure();
+ void launchAnotherWithQProcess();
+};
+
class PlasmaApp : public MApplication
{
Q_OBJECT
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic