1
/****************************************************************************
2
* Copyright (C) 2013-2014 by Savoir-Faire Linux *
3
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
5
* This library is free software; you can redistribute it and/or *
6
* modify it under the terms of the GNU Lesser General Public *
7
* License as published by the Free Software Foundation; either *
8
* version 2.1 of the License, or (at your option) any later version. *
10
* This library is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13
* Lesser General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17
***************************************************************************/
21
#include <QtCore/QTimer>
29
#include "../lib/dbus/callmanager.h"
31
Macro::Macro(QObject* parent) : QObject(parent),m_Position(0),m_Delay(0),m_pCat(nullptr),m_pPointer(nullptr),
32
m_Action(nullptr),m_pModel(nullptr)
36
Macro::Macro(const Macro* macro) :
37
QObject(0) , m_Position(macro->m_Position), m_Name(macro->m_Name) ,
38
m_Description(macro->m_Description), m_Sequence(macro->m_Sequence), m_Escaped(macro->m_Escaped) ,
39
m_Id(macro->m_Id) , m_Delay(macro->m_Delay) , m_Category(macro->m_Category),
40
m_Action(macro->m_Action) , m_pCat(macro->m_pCat) , m_pModel(macro->m_pModel) ,
41
m_pPointer(macro->m_pPointer)
44
void Macro::execute() {
45
m_Escaped = m_Sequence;
46
while (m_Escaped.indexOf("\\n") != -1) {
47
m_Escaped = m_Escaped.replace("\\n","\n");
52
void Macro::nextStep()
54
if (m_Position < m_Escaped.size()) {
55
if (!MacroModel::instance()->m_lListeners.size())
56
Q_NOREPLY DBus::CallManager::instance().playDTMF(QString(m_Escaped[m_Position]));
58
foreach(MacroListener* l,MacroModel::instance()->m_lListeners) {
59
l->addDTMF(QString(m_Escaped[m_Position]));
63
QTimer::singleShot(m_Delay?m_Delay:100,this,SLOT(nextStep()));
70
QModelIndex Macro::index()
72
QModelIndex parent = m_pModel->index(m_pModel->m_lCategories.indexOf(m_pCat),0,QModelIndex());
73
return m_pModel->index(m_pCat->m_lContent.indexOf(this),0,parent);
76
void Macro::setName(const QString &value)
80
m_Action->setText(m_Name);
83
void Macro::setDescription(const QString &value)
85
m_Description = value;emit changed(this);
87
void Macro::setSequence(const QString &value)
89
m_Sequence = value;emit changed(this);
92
void Macro::setEscaped(const QString &value)
94
m_Escaped = value;emit changed(this);
97
void Macro::setId(const QString &value)
99
m_Id = value;emit changed(this);
102
void Macro::setDelay(int value)
104
m_Delay = value;emit changed(this);
107
void Macro::setCategory(const QString &value)
109
m_Category = value;emit changed(this);
112
QString Macro::name() const
117
QString Macro::description() const
119
return m_Description;
122
QString Macro::sequence() const
127
QString Macro::escaped() const
132
QString Macro::id() const
137
int Macro::delay() const
142
QString Macro::category() const
147
KAction* Macro::action()