Skip to content
Snippets Groups Projects
Commit b6af344c authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

Allow to call actions displayed in the UserActionModel

Refs #66613
parent dfd7b01f
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@
***************************************************************************/
#include "pixmapmanipulationdelegate.h"
#include <useractionmodel.h>
#include <QtCore/QSize>
PixmapManipulationDelegate* PixmapManipulationDelegate::m_spInstance = new PixmapManipulationDelegate();
......@@ -80,3 +82,9 @@ QVariant PixmapManipulationDelegate::profilePhoto(const QByteArray& data)
Q_UNUSED(data)
return QVariant();
}
QVariant PixmapManipulationDelegate::userActionIcon(const UserActionElement& state) const
{
Q_UNUSED(state)
return QVariant();
}
......@@ -24,9 +24,10 @@
#include <QtCore/QModelIndex>
//Ring
class Person ;
class ContactMethod;
class Call ;
class Person ;
class ContactMethod ;
class Call ;
struct UserActionElement;
/**
* Different clients can have multiple way of displaying images. Some may
......@@ -42,14 +43,18 @@ class LIB_EXPORT PixmapManipulationDelegate {
public:
PixmapManipulationDelegate();
virtual ~PixmapManipulationDelegate() {}
virtual QVariant contactPhoto(Person* c, const QSize& size, bool displayPresence = true);
virtual QVariant callPhoto(Call* c, const QSize& size, bool displayPresence = true);
virtual QVariant callPhoto(const ContactMethod* n, const QSize& size, bool displayPresence = true);
virtual QVariant numberCategoryIcon(const QVariant& p, const QSize& size, bool displayPresence = false, bool isPresent = false);
virtual QVariant serurityIssueIcon(const QModelIndex& index);
virtual QVariant contactPhoto(Person* c, const QSize& size, bool displayPresence = true);
virtual QVariant callPhoto(Call* c, const QSize& size, bool displayPresence = true);
virtual QVariant callPhoto(const ContactMethod* n, const QSize& size, bool displayPresence = true);
virtual QVariant numberCategoryIcon(const QVariant& p, const QSize& size, bool displayPresence = false, bool isPresent = false);
virtual QVariant serurityIssueIcon(const QModelIndex& index);
virtual QByteArray toByteArray(const QVariant& pxm);
virtual QVariant profilePhoto(const QByteArray& data);
virtual QVariant profilePhoto(const QByteArray& data);
/**
* Return the icons associated with the action and its state
*/
virtual QVariant userActionIcon(const UserActionElement& state) const;
//Singleton
static PixmapManipulationDelegate* instance();
......
/****************************************************************************
* Copyright (C) 2012-2015 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Lesser 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 USERACTIONS_H
#define USERACTIONS_H
/**
* This code used to be in the KDE client. It doesn't really fit well in well
* in what libringclient is supposed to do, but as it has to be replicated for
* each clients, then UserActionModel will provide an abstract way to call those
* functions.
*/
namespace UserActions {
bool accept(const QList<Call*> calls)
{
bool ret = true;
for (Call* call : calls) {
if(!call) {
qDebug() << "Calling when no item is selected. Opening an item.";
CallModel::instance()->dialingCall();
CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(call), QItemSelectionModel::ClearAndSelect);
}
else {
const Call::State state = call->state();
//TODO port to lifeCycle code
if (state == Call::State::RINGING || state == Call::State::CURRENT || state == Call::State::HOLD
|| state == Call::State::BUSY || state == Call::State::FAILURE || state == Call::State::ERROR) {
qDebug() << "Calling when item currently ringing, current, hold or busy. Opening an item.";
Call* c2 = CallModel::instance()->dialingCall();
CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(c2), QItemSelectionModel::ClearAndSelect);
}
else {
try {
call->performAction(Call::Action::ACCEPT);
}
catch(const char * msg) {
// KMessageBox::error(Ring::app(),i18n(msg));
ret = false;
}
}
}
}
return ret;
} //accept
///Call
bool hangup(const QList<Call*> calls)
{
bool ret = true;
for (Call* call : calls) {
if (call) {
try {
call->performAction(Call::Action::REFUSE);
}
catch(const char * msg) {
// KMessageBox::error(Ring::app(),i18n(msg));
}
}
}
return ret;
} //hangup
///Refuse call
bool refuse(const QList<Call*> calls)
{
bool ret = true;
for (Call* call : calls) {
if(!call) {
qDebug() << "Error : Hanging up when no item selected. Should not happen.";
}
else {
try {
call->performAction(Call::Action::REFUSE);
}
catch(const char * msg) {
// KMessageBox::error(Ring::app(),i18n(msg));
}
}
}
return ret;
}
///Put call on hold
bool hold(const QList<Call*> calls)
{
bool ret = true;
for (Call* call : calls) {
if(!call) {
qDebug() << "Error : Holding when no item selected. Should not happen.";
}
else {
try {
call->performAction(Call::Action::HOLD);
}
catch(const char * msg) {
// KMessageBox::error(Ring::app(),i18n(msg));
}
}
}
return ret;
}
///Remove call from hold
bool unhold(const QList<Call*> calls)
{
bool ret = true;
for (Call* call : calls) {
if(!call) {
qDebug() << "Error : Un-Holding when no item selected. Should not happen.";
}
else {
try {
call->performAction(Call::Action::HOLD);
}
catch(const char * msg) {
// KMessageBox::error(Ring::app(),i18n(msg));
}
}
}
return ret;
}
///Transfer a call
bool transfer(const QList<Call*> calls)
{
bool ret = true;
for (Call* call : calls) {
if(!call) {
qDebug() << "Error : Transferring when no item selected. Should not happen.";
}
else {
try {
call->performAction(Call::Action::TRANSFER);
}
catch(const char * msg) {
// KMessageBox::error(Ring::app(),i18n(msg));
}
}
}
return ret;
}
///Record a call
bool record(const QList<Call*> calls)
{
bool ret = true;
for (Call* call : calls) {
if(!call) {
qDebug() << "Error : Recording when no item selected. Should not happen.";
}
else {
try {
call->performAction(Call::Action::RECORD);
}
catch(const char * msg) {
// KMessageBox::error(Ring::app(),i18n(msg));
}
}
}
return ret;
}
}; //namespace UserActions
#endif
\ No newline at end of file
This diff is collapsed.
......@@ -22,8 +22,11 @@
#include <QtCore/QAbstractItemModel>
#include "typedefs.h"
#include "call.h"
//Qt
class QSortFilterProxyModel;
//Ring
#include "call.h"
class Call;
class CallModel;
class UserActionModelPrivate;
......@@ -70,6 +73,8 @@ public:
};
Q_ENUMS(Action)
Q_PROPERTY(QSortFilterProxyModel* activeActionModel READ activeActionModel);
//Constructor
explicit UserActionModel(Call* parent);
UserActionModel(CallModel* parent);
......@@ -85,6 +90,11 @@ public:
//Getters
Q_INVOKABLE bool isActionEnabled ( UserActionModel::Action action ) const;
Q_INVOKABLE uint relativeIndex ( UserActionModel::Action action ) const;
QSortFilterProxyModel* activeActionModel() const;
//Mutators
bool execute( const Action action ) const;
bool execute( const QModelIndex& idx ) const;
private:
const QScopedPointer<UserActionModelPrivate> d_ptr;
......@@ -96,4 +106,14 @@ Q_SIGNALS:
};
Q_DECLARE_METATYPE(UserActionModel*)
/**
* "Java bean" used to avoid having a 5+ parameter pixmap delegate
*/
struct UserActionElement {
UserActionModel::Action action ;
QList<Call*> calls ;
Qt::CheckState checkState ;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment