Commit 0108d70f authored by Marco Martin's avatar Marco Martin

move the applicationslistmodel to containment c++

the application list is only used in that containment for now: don't
create an extra qml import just for that, but put it into the c++
applet for the homescreen instead to make sure nobody else
uses it at least until we are really sure is needed elsewhere
parent e8ce3679
......@@ -45,10 +45,9 @@ install(DIRECTORY compositor/
PATTERN dummydata EXCLUDE)
kpackage_install_package(phonebook org.kde.phone.phonebook genericqml)
install(FILES phonebook/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.dialer.desktop)
install(FILES phonebook/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.phonebook.desktop)
add_subdirectory(bin)
add_subdirectory(qmlcomponents)
#add_subdirectory(services)
add_subdirectory(settingsmodules)
add_subdirectory(applets)
......
......@@ -12,7 +12,7 @@ target_link_libraries(plasma_applet_quicksettings
KF5::I18n)
install(TARGETS plasma_applet_quicksettings DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/plasmoids)
install(TARGETS plasma_applet_quicksettings DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/applets)
#install(FILES plasma-quicksettings-default.desktop DESTINATION ${SERVICES_INSTALL_DIR})
plasma_install_package(package org.kde.phone.quicksettings)
......
plasma_install_package(homescreen org.kde.phone.homescreen)
plasma_install_package(panel org.kde.phone.panel)
add_subdirectory(homescreen)
set(homescreen_SRCS
homescreen.cpp
applicationlistmodel.cpp
)
add_library(plasma_applet_phone_homescreen MODULE ${homescreen_SRCS})
kcoreaddons_desktop_to_json(plasma_applet_phone_homescreen package/metadata.desktop)
target_link_libraries(plasma_applet_phone_homescreen
Qt5::Gui
KF5::Plasma
Qt5::Qml
KF5::I18n
KF5::Service
)
install(TARGETS plasma_applet_phone_homescreen DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/applets)
plasma_install_package(package org.kde.phone.homescreen)
#! /usr/bin/env bash
$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp
$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.phone.homescreen.pot
rm -f rc.cpp
/***************************************************************************
* Copyright (C) 2015 Marco Martin <mart@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, 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 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 . *
***************************************************************************/
#include "homescreen.h"
#include "applicationlistmodel.h"
#include <QtQml>
#include <QDebug>
HomeScreen::HomeScreen(QObject *parent, const QVariantList &args)
: Plasma::Containment(parent, args)
{
qmlRegisterType<ApplicationListModel>();
m_applicationListModel = new ApplicationListModel(this);
setHasConfigurationInterface(true);
}
HomeScreen::~HomeScreen()
{
}
ApplicationListModel *HomeScreen::applicationListModel()
{
return m_applicationListModel;
}
K_EXPORT_PLASMA_APPLET_WITH_JSON(homescreen, HomeScreen, "metadata.json")
#include "homescreen.moc"
/***************************************************************************
* Copyright (C) 2015 Marco Martin <mart@kde.org> *
*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, 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 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 . *
***************************************************************************/
#ifndef HOMESCREEN_H
#define HOMESCREEN_H
#include <Plasma/Containment>
class ApplicationListModel;
class HomeScreen : public Plasma::Containment
{
Q_OBJECT
Q_PROPERTY(ApplicationListModel *applicationListModel READ applicationListModel CONSTANT)
public:
HomeScreen( QObject *parent, const QVariantList &args );
~HomeScreen();
ApplicationListModel *applicationListModel();
private:
ApplicationListModel *m_applicationListModel;
};
#endif
......@@ -23,7 +23,6 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0
import org.kde.satellite.components 0.1 as SatelliteComponents
import "plasmapackage:/code/LayoutManager.js" as LayoutManager
......@@ -100,14 +99,14 @@ MouseEventListener {
LayoutManager.restore();
applicationsView.contentY = -root.height;
appListModel.appOrder = plasmoid.configuration.AppOrder;
appListModel.loadApplications();
plasmoid.nativeInterface.applicationListModel.appOrder = plasmoid.configuration.AppOrder;
plasmoid.nativeInterface.applicationListModel.loadApplications();
}
SatelliteComponents.ApplicationListModel {
id: appListModel
Connections {
target: plasmoid.nativeInterface.applicationListModel
onAppOrderChanged: {
plasmoid.configuration.AppOrder = appListModel.appOrder;
plasmoid.configuration.AppOrder = plasmoid.nativeInterface.applicationListModel.appOrder;
}
}
......@@ -196,7 +195,7 @@ MouseEventListener {
var newRow = (Math.round(applicationsView.width / applicationsView.cellWidth) * Math.floor(pos.y / applicationsView.cellHeight) + Math.floor(pos.x / applicationsView.cellWidth));
if (applicationsView.dragData.ApplicationOriginalRowRole != newRow) {
appListModel.moveItem(applicationsView.dragData.ApplicationOriginalRowRole, newRow);
plasmoid.nativeInterface.applicationListModel.moveItem(applicationsView.dragData.ApplicationOriginalRowRole, newRow);
applicationsView.dragData.ApplicationOriginalRowRole = newRow;
}
......@@ -254,7 +253,7 @@ MouseEventListener {
return;
}
appListModel.runApplication(item.modelData.ApplicationStorageIdRole)
plasmoid.nativeInterface.applicationListModel.runApplication(item.modelData.ApplicationStorageIdRole)
}
PlasmaCore.ColorScope {
anchors.fill: parent
......@@ -353,7 +352,7 @@ MouseEventListener {
cellWidth: root.buttonHeight
cellHeight: cellWidth
model: appListModel
model: plasmoid.nativeInterface.applicationListModel
snapMode: GridView.SnapToRow
......@@ -481,7 +480,7 @@ MouseEventListener {
cellWidth: root.buttonHeight
cellHeight: cellWidth
model: appListModel
model: plasmoid.nativeInterface.applicationListModel
delegate: HomeLauncher {}
move: Transition {
......
......@@ -6,7 +6,7 @@ Type=Service
X-KDE-ServiceTypes=Plasma/Applet,Plasma/Containment
X-Plasma-API=declarativeappletscript
X-KDE-ParentApp=
X-KDE-Library=plasma_applet_phone_homescreen
X-KDE-PluginInfo-Author=Marco Martin
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Email=mart@kde.org
......
project(satellitecomponents)
set(satellitecomponents_SRCS
satellitecomponentsplugin.cpp
applicationlistmodel.cpp
)
add_library(satellitecomponentsplugin SHARED ${satellitecomponents_SRCS})
target_link_libraries(satellitecomponentsplugin
Qt5::Core
Qt5::Widgets
Qt5::Qml
Qt5::Quick
KF5::Service
KF5::Declarative
KF5::I18n)
install(TARGETS satellitecomponentsplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/satellite/components)
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/satellite/components)
add_subdirectory(modeltest)
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml` -L Java -o $podir/libsatellitecomponentsplugin.pot
rm -f rc.cpp
set(applicationlistmodeltest_SRCS
main.cpp
modeltest.cpp
../applicationlistmodel.cpp
)
add_executable(applicationlistmodeltest ${applicationlistmodeltest_SRCS})
target_link_libraries(applicationlistmodeltest
Qt5::Core
Qt5::Test
Qt5::Widgets
KF5::Service
)
#include <QAction>
#include <QApplication>
#include <QDialog>
#include <QPushButton>
#include <QTreeView>
#include <QVBoxLayout>
#include <QDebug>
#include "../applicationlistmodel.h"
#include "modeltest.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *widget = new QWidget;
QVBoxLayout *layout = new QVBoxLayout(widget);
ApplicationListModel *applicationListModel = new ApplicationListModel(widget);
ModelTest *test = new ModelTest(applicationListModel, widget);
QTreeView *view = new QTreeView(widget);
QPushButton *upButton = new QPushButton(widget);
upButton->setText("Move Up");
QObject::connect(upButton, &QPushButton::clicked, [=](){
QModelIndex idx = view->currentIndex();
if (idx.row() > 0) {
applicationListModel->moveItem(idx.row(), idx.row()-1);
}
});
QPushButton *downButton = new QPushButton(widget);
downButton->setText("Move Down");
QObject::connect(downButton, &QPushButton::clicked, [=](){
QModelIndex idx = view->currentIndex();
if (idx.row() > 0) {
applicationListModel->moveItem(idx.row(), idx.row()+1);
}
});
layout->addWidget(upButton);
layout->addWidget(downButton);
view->setDragDropMode(QAbstractItemView::InternalMove);
view->setModel(applicationListModel);
applicationListModel->loadApplications();
layout->addWidget(view);
QAction *quit = new QAction(widget);
quit->setShortcut(Qt::CTRL + Qt::Key_Q);
QObject::connect(quit, SIGNAL(triggered()), &app, SLOT(quit()));
widget->addAction(quit);
widget->show();
return app.exec();
}
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef MODELTEST_H
#define MODELTEST_H
#include <QtCore/QObject>
#include <QtCore/QAbstractItemModel>
#include <QtCore/QStack>
class ModelTest : public QObject
{
Q_OBJECT
public:
ModelTest( QAbstractItemModel *model, QObject *parent = 0 );
private Q_SLOTS:
void nonDestructiveBasicTest();
void rowCount();
void columnCount();
void hasIndex();
void index();
void parent();
void data();
protected Q_SLOTS:
void runAllTests();
void layoutAboutToBeChanged();
void layoutChanged();
void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end );
void rowsInserted( const QModelIndex & parent, int start, int end );
void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end );
void rowsRemoved( const QModelIndex & parent, int start, int end );
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void headerDataChanged(Qt::Orientation orientation, int start, int end);
private:
void checkChildren( const QModelIndex &parent, int currentDepth = 0 );
QAbstractItemModel *model;
struct Changing {
QModelIndex parent;
int oldSize;
QVariant last;
QVariant next;
};
QStack<Changing> insert;
QStack<Changing> remove;
bool fetchingMore;
QList<QPersistentModelIndex> changing;
};
#endif
module org.kde.satellite.components
plugin satellitecomponentsplugin
\ No newline at end of file
/*
* Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
* Copyright 2010 by Ménard Alexis <menard@kde.org>
* Copyright 2010 by Marco Martin <mart@kde.org>
* 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 Library 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.
*/
#include "satellitecomponentsplugin.h"
#include <QtQml>
#include <QQmlExtensionPlugin>
#include <QQmlEngine>
#include <QQmlContext>
#include <kdeclarative/kdeclarative.h>
#include "applicationlistmodel.h"
void SatelliteComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
QQmlExtensionPlugin::initializeEngine(engine, uri);
if (!engine->rootContext()->contextObject()) {
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine);
kdeclarative.setupBindings();
}
}
void SatelliteComponentsPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.satellite.components"));
qmlRegisterType<ApplicationListModel>(uri, 0, 1, "ApplicationListModel");
}
#include "satellitecomponentsplugin.moc"
/*
* Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
* Copyright 2010 by Ménard Alexis <menard@kde.org>
* Copyright 2010 by Marco Martin <mart@kde.org>
* 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 Library 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.
*/
#ifndef SATELLITECOMPONENTSPLUGIN_H
#define SATELLITECOMPONENTSPLUGIN_H
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
class SatelliteComponentsPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void initializeEngine(QQmlEngine *engine, const char *uri);
void registerTypes(const char *uri);
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment