[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:26:38 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=1f536de
The following commit has been merged in the master branch:
commit 1f536de7e9e8a3d0d994624b0d1c20e76b3a980e
Author: Albert Vaca <albertvaka at gmail.com>
Date: Thu Jun 27 02:13:16 2013 +0200
Started wizzard implementation
---
kcm/CMakeLists.txt | 5 +-
.../devicelink.cpp => kcm/daemondbusinterface.cpp | 10 +-
kcm/{wizard.h => daemondbusinterface.h} | 22 ++--
kcm/devicesmodel.cpp | 138 +++++++++++++++++++++
kcm/devicesmodel.h | 64 ++++++++++
kcm/kcm.cpp | 36 ++----
kcm/kcm.h | 13 +-
kcm/wizard.cpp | 46 ++++++-
kcm/wizard.h | 19 ++-
9 files changed, 293 insertions(+), 60 deletions(-)
diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt
index 58c02c6..aebe739 100644
--- a/kcm/CMakeLists.txt
+++ b/kcm/CMakeLists.txt
@@ -1,13 +1,14 @@
-set(kcm_SRCS
+set(kcm_SRCS devicesmodel.cpp
kcm.cpp
wizard.cpp
+ daemondbusinterface.cpp
)
qt4_add_dbus_interface(
kcm_SRCS
${CMAKE_BINARY_DIR}/daemon/org.kde.kdeconnect.xml
- daemoninterface
+ org_kde_kdeconnect_interface
)
kde4_add_ui_files(kcm_SRCS kcm.ui wizard.ui)
diff --git a/daemon/devicelinks/devicelink.cpp b/kcm/daemondbusinterface.cpp
similarity index 80%
copy from daemon/devicelinks/devicelink.cpp
copy to kcm/daemondbusinterface.cpp
index f48ac03..c2d49e0 100644
--- a/daemon/devicelinks/devicelink.cpp
+++ b/kcm/daemondbusinterface.cpp
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2013 Albert Vaca <albertvaka at gmail.com>
*
* This program is free software; you can redistribute it and/or
@@ -18,10 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "devicelink.h"
+#include "daemondbusinterface.h"
-DeviceLink::DeviceLink(Device* d)
- : mDevice(d)
+DaemonDbusInterface::DaemonDbusInterface(QObject* parent)
+ : OrgKdeKdeconnectInterface("org.kde.kdeconnect", "/modules/androidshine", QDBusConnection::sessionBus(), parent)
{
- //gcc complains if we don't add something to compile on a class with virtual functions
+
}
\ No newline at end of file
diff --git a/kcm/wizard.h b/kcm/daemondbusinterface.h
similarity index 78%
copy from kcm/wizard.h
copy to kcm/daemondbusinterface.h
index ccd44aa..2bb384c 100644
--- a/kcm/wizard.h
+++ b/kcm/daemondbusinterface.h
@@ -18,22 +18,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef WIZARD_H
-#define WIZARD_H
+#include "org_kde_kdeconnect_interface.h"
-#include <QWizard>
+#ifndef DaemonDbusInterface_H_
+#define DaemonDbusInterface_H_
-namespace Ui {
- class Wizard;
-}
-
-class AddDeviceWizard : public QWizard
-{
+class DaemonDbusInterface : public OrgKdeKdeconnectInterface {
+ Q_OBJECT
public:
- AddDeviceWizard(QWidget* parent);
- ~AddDeviceWizard();
-private:
- Ui::Wizard* m_wizard;
+ DaemonDbusInterface(QObject* parent);
+
};
-#endif // WIZARD_H
+#endif
\ No newline at end of file
diff --git a/kcm/devicesmodel.cpp b/kcm/devicesmodel.cpp
new file mode 100644
index 0000000..9bf3375
--- /dev/null
+++ b/kcm/devicesmodel.cpp
@@ -0,0 +1,138 @@
+/*
+ * <one line to give the library's name and an idea of what it does.>
+ * Copyright 2013 <copyright holder> <email>
+ *
+ * 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) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "devicesmodel.h"
+
+
+DevicesModel::DevicesModel(QObject *parent)
+ : QAbstractItemModel(parent)
+{
+}
+
+DevicesModel::~DevicesModel()
+{
+}
+
+int DevicesModel::columnCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+
+ return 1;
+}
+
+QVariant DevicesModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() < 0 || index.row() >= m_deviceList.count()) {
+ return QVariant();
+ }
+ switch (role) {
+ case IconModelRole:
+ //return m_deviceList[index.row()].m_icon;
+ case NameModelRole:
+ //return m_deviceList[index.row()].m_device->name();
+ case AliasModelRole:
+ //return m_deviceList[index.row()].m_device->alias();
+ case DeviceTypeModelRole:
+ //return m_deviceList[index.row()].m_deviceType;
+ case DeviceModelRole:
+ //return QVariant::fromValue<void*>(m_deviceList[index.row()].m_device);
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!index.isValid() || index.row() < 0 || index.row() >= m_deviceList.count()) {
+ return false;
+ }
+ switch (role) {
+ case IconModelRole:
+ //m_deviceList[index.row()].m_icon = value.value<QPixmap>();
+ break;
+ case DeviceTypeModelRole:
+ //m_deviceList[index.row()].m_deviceType = value.toString();
+ break;
+ case DeviceModelRole: {
+ //Device *const device = static_cast<Device*>(value.value<void*>());
+ //m_deviceList[index.row()].m_device = device;
+ //connect(device, SIGNAL(propertyChanged(QString,QVariant)),this, SIGNAL(layoutChanged()));
+ }
+ break;
+ default:
+ return false;
+ }
+ emit dataChanged(index, index);
+ return true;
+}
+
+QModelIndex DevicesModel::index(int row, int column, const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+
+ if (row < 0 || row >= m_deviceList.count() || column != 0) {
+ return QModelIndex();
+ }
+
+ return createIndex(row, column);
+}
+
+QModelIndex DevicesModel::parent(const QModelIndex &index) const
+{
+ Q_UNUSED(index);
+
+ return QModelIndex();
+}
+
+int DevicesModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+
+ return m_deviceList.count();
+}
+
+bool DevicesModel::insertRows(int row, int count, const QModelIndex &parent)
+{
+ if (row < 0 || row > m_deviceList.count() || count < 1) {
+ return false;
+ }
+ beginInsertRows(parent, row, row + count - 1);
+ for (int i = row; i < row + count; ++i) {
+ m_deviceList.insert(i, Device());
+ }
+ endInsertRows();
+ return true;
+}
+
+bool DevicesModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ if (row < 0 || row > m_deviceList.count() || count < 1) {
+ return false;
+ }
+ beginRemoveRows(parent, row, row + count - 1);
+ for (int i = row; i < row + count; ++i) {
+ m_deviceList.removeAt(row);
+ }
+ endRemoveRows();
+ return true;
+}
\ No newline at end of file
diff --git a/kcm/devicesmodel.h b/kcm/devicesmodel.h
new file mode 100644
index 0000000..6fdb600
--- /dev/null
+++ b/kcm/devicesmodel.h
@@ -0,0 +1,64 @@
+/*
+ * <one line to give the library's name and an idea of what it does.>
+ * Copyright 2013 <copyright holder> <email>
+ *
+ * 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) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DEVICESMODEL_H
+#define DEVICESMODEL_H
+
+
+#include <QAbstractItemModel>
+#include <QPixmap>
+#include <QList>
+
+class DevicesModel
+ : public QAbstractItemModel
+{
+public:
+ enum ModelRoles {
+ IconModelRole = 0,
+ NameModelRole,
+ AliasModelRole,
+ DeviceTypeModelRole,
+ DeviceModelRole,
+ LastModelRole
+ };
+
+ DevicesModel(QObject *parent = 0);
+ virtual ~DevicesModel();
+
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
+ virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex parent(const QModelIndex &index) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+
+private:
+ struct Device {
+ QString id;
+ QString name;
+ };
+ QList<Device> m_deviceList;
+};
+
+#endif // DEVICESMODEL_H
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index 3931070..f155584 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -40,24 +40,19 @@ K_EXPORT_PLUGIN(KdeConnectKcmFactory("kdeconnect-kcm", "kdeconnect-kcm"))
KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
: KCModule(KdeConnectKcmFactory::componentData(), parent)
- , dbusInterface("org.kde.kdeconnect", "/modules/androidshine", QDBusConnection::sessionBus(), this)
- , wizard(this)
+ , kcmUi(new Ui::KdeConnectKcmUi())
+ , dbusInterface(this)
+ , pairedDevicesList(this)
+ , addDeviceWizard(this)
{
- m_ui = new Ui::KdeConnectKcmUi();
- m_ui->setupUi(this);
+ kcmUi->setupUi(this);
- m_model = new QStandardItemModel(this);
- m_ui->deviceList->setIconSize(QSize(32,32));
- m_ui->deviceList->setModel(m_model);
+ kcmUi->deviceList->setIconSize(QSize(32,32));
+ kcmUi->deviceList->setModel(&pairedDevicesList);
-// dbusInterface.pairDevice("holalala");
-
- connect(&dbusInterface, SIGNAL(deviceAdded(QString, QString)), this, SLOT(deviceAdded(QString, QString)));
- connect(&dbusInterface, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString)));
-
- connect(m_ui->removeButton, SIGNAL(clicked(bool)), this, SLOT(removeButtonClicked()));
- connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(addButtonClicked()));
+ connect(kcmUi->addButton, SIGNAL(clicked(bool)), this, SLOT(addButtonClicked()));
+ connect(kcmUi->removeButton, SIGNAL(clicked(bool)), this, SLOT(removeButtonClicked()));
}
@@ -68,7 +63,7 @@ KdeConnectKcm::~KdeConnectKcm()
void KdeConnectKcm::addButtonClicked()
{
-
+ addDeviceWizard.show();
}
void KdeConnectKcm::removeButtonClicked()
@@ -81,16 +76,5 @@ void KdeConnectKcm::currentChanged(const QModelIndex& current, const QModelIndex
}
-void KdeConnectKcm::deviceAdded(QString id, QString name) //TODO: Rebre mes coses...
-{
- //m_model->appendRow(new QStandardItem(id));
- wizard.show();
-}
-
-void KdeConnectKcm::deviceRemoved(QString id)
-{
-
-}
-
#include "kcm.moc"
diff --git a/kcm/kcm.h b/kcm/kcm.h
index 85818b4..5ca1368 100644
--- a/kcm/kcm.h
+++ b/kcm/kcm.h
@@ -27,7 +27,6 @@
#include <kcmodule.h>
#include "wizard.h"
-#include "daemoninterface.h"
class Create;
class QModelIndex;
@@ -43,7 +42,7 @@ namespace Ui {
class KdeConnectKcm : public KCModule
{
-Q_OBJECT
+ Q_OBJECT
public:
KdeConnectKcm(QWidget *parent, const QVariantList&);
virtual ~KdeConnectKcm();
@@ -53,14 +52,12 @@ private Q_SLOTS:
void removeButtonClicked();
void currentChanged(const QModelIndex& current, const QModelIndex& previous);
- void deviceAdded(QString id, QString name);
- void deviceRemoved(QString id);
private:
- OrgKdeKdeconnectInterface dbusInterface;
- Ui::KdeConnectKcmUi* m_ui;
- QStandardItemModel* m_model;
- AddDeviceWizard wizard;
+ Ui::KdeConnectKcmUi* kcmUi;
+ DaemonDbusInterface dbusInterface;
+ QStandardItemModel pairedDevicesList;
+ AddDeviceWizard addDeviceWizard;
};
diff --git a/kcm/wizard.cpp b/kcm/wizard.cpp
index ef222c9..f4c530c 100644
--- a/kcm/wizard.cpp
+++ b/kcm/wizard.cpp
@@ -21,20 +21,58 @@
#include "wizard.h"
#include <QDebug>
+#include <QStandardItemModel>
#include "ui_wizard.h"
AddDeviceWizard::AddDeviceWizard(QWidget* parent)
: QWizard(parent)
+ , wizardUi(new Ui::Wizard())
+ , dbusInterface(new DaemonDbusInterface(this))
+ , discoveredDevicesList(new QStandardItemModel(this))
{
- qDebug() << "HA";
- m_wizard = new Ui::Wizard();
- m_wizard->setupUi(this);
+ wizardUi->setupUi(this);
+
+ wizardUi->listView->setModel(discoveredDevicesList);
+
+ connect(this,SIGNAL(currentIdChanged(int)),this,SLOT(pageChanged(int)));
+
+ connect(dbusInterface, SIGNAL(deviceAdded(QString, QString)), this, SLOT(deviceDiscovered(QString,QString)));
+ connect(dbusInterface, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceLost(QString)));
+
+}
+
+void AddDeviceWizard::pageChanged(int id)
+{
+ qDebug() << id;
+ //QWizardPage* p = page(id);
+ if (id == 1) {
+ //Show "scanning"
+ }
+}
+
+void AddDeviceWizard::deviceDiscovered(QString id, QString name)
+{
+ QStandardItem* item = new QStandardItem(name);
+ item->setData(id);
+
+ discoveredDevicesList->appendRow(item);
+}
+
+void AddDeviceWizard::deviceLost(QString id)
+{
+ //discoveredDevicesList->removeRow();
+}
+
+void AddDeviceWizard::discoveryFinished(bool success)
+{
}
AddDeviceWizard::~AddDeviceWizard()
{
- delete m_wizard;
+ delete wizardUi;
+ delete dbusInterface;
+ delete discoveredDevicesList;
}
diff --git a/kcm/wizard.h b/kcm/wizard.h
index ccd44aa..741a051 100644
--- a/kcm/wizard.h
+++ b/kcm/wizard.h
@@ -22,18 +22,35 @@
#define WIZARD_H
#include <QWizard>
+#include <QObject>
+
+#include "daemondbusinterface.h"
namespace Ui {
class Wizard;
}
+class QStandardItemModel;
+
class AddDeviceWizard : public QWizard
{
+ Q_OBJECT
+
public:
AddDeviceWizard(QWidget* parent);
~AddDeviceWizard();
+
+private Q_SLOTS:
+ void pageChanged(int id);
+
+ void deviceDiscovered(QString id, QString name);
+ void deviceLost(QString id);
+ void discoveryFinished(bool success);
+
private:
- Ui::Wizard* m_wizard;
+ Ui::Wizard* wizardUi;
+ DaemonDbusInterface* dbusInterface;
+ QStandardItemModel* discoveredDevicesList;
};
#endif // WIZARD_H
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list