• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kremotecontrol

  • sources
  • kde-4.12
  • kdeutils
  • kremotecontrol
  • libkremotecontrol
mode.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Michael Zanetti <michael_zanetti@gmx.net>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 
18 */
19 
20 #include "mode.h"
21 #include "action.h"
22 
23 #include <KDebug>
24 
25 Mode::Mode(const QString &name, const QString &iconName): m_name(name), m_iconName(iconName) {
26 }
27 
28 Mode::~Mode() {
29  while(!m_actionList.isEmpty()){
30  Action *action = m_actionList.first();
31  m_actionList.remove(0);
32  delete action;
33  }
34 }
35 
36 QString Mode::name() const {
37  return m_name;
38 }
39 
40 QString Mode::iconName() const {
41  return m_iconName;
42 }
43 
44 QString Mode::button() const {
45  return m_button;
46 }
47 
48 void Mode::setName(const QString& name) {
49  m_name = name;
50 }
51 
52 void Mode::setIconName(const QString& iconName) {
53  m_iconName = iconName;
54 }
55 
56 void Mode::setButton(const QString& button) {
57  m_button = button;
58 }
59 
60 bool Mode::operator==(const Mode& mode) const {
61  return m_name == mode.name() && m_iconName == mode.iconName() && m_button == mode.button();
62 }
63 
64 void Mode::addAction(Action* action) {
65  m_actionList.append(action);
66 }
67 
68 void Mode::removeAction(Action* action) {
69  m_actionList.remove(m_actionList.indexOf(action));
70  delete action;
71 }
72 
73 void Mode::moveActionUp(Action* action) {
74  int oldIndex = m_actionList.indexOf(action);
75  if(oldIndex > 0) {
76  m_actionList.remove(oldIndex);
77  m_actionList.insert(oldIndex - 1, action);
78  }
79 }
80 
81 void Mode::moveActionDown(Action* action) {
82  int oldIndex = m_actionList.indexOf(action);
83  if(oldIndex < (m_actionList.count() - 1)) {
84  m_actionList.remove(oldIndex);
85  m_actionList.insert(oldIndex + 1, action);
86  }
87 }
88 
89 QVector<Action* > Mode::actions() const {
90  return m_actionList;
91 }
92 
93 QVector<Action*> Mode::actionsForButton(const QString &button) const {
94  QVector<Action*> retList;
95  foreach(Action *action, m_actionList){
96  kDebug() << "checking action:" << action->name() << action->button();
97  if(action->button() == button){
98  kDebug() << "Found action for button:" << action->name();
99  retList.append(action);
100  }
101  }
102  return retList;
103 }
104 
105 bool Mode::doAfter(){
106  return m_doAfter;
107 }
Mode::~Mode
~Mode()
Definition: mode.cpp:28
Mode::Mode
Mode(const QString &name=QString(), const QString &iconName=QLatin1String("infrared-remote"))
Definition: mode.cpp:25
Mode::setButton
void setButton(const QString &button)
Definition: mode.cpp:56
Mode::actions
QVector< Action * > actions() const
Definition: mode.cpp:89
Mode
Definition: mode.h:31
Mode::m_name
QString m_name
Definition: mode.h:64
Action::button
QString button() const
Definition: action.cpp:37
Mode::moveActionUp
void moveActionUp(Action *action)
Definition: mode.cpp:73
Mode::removeAction
void removeAction(Action *action)
Remove the given action from this mode and delete it.
Definition: mode.cpp:68
Mode::moveActionDown
void moveActionDown(Action *action)
Definition: mode.cpp:81
QVector
Mode::m_button
QString m_button
Definition: mode.h:66
Action
Definition: action.h:30
Mode::button
QString button() const
Definition: mode.cpp:44
Mode::actionsForButton
QVector< Action * > actionsForButton(const QString &button) const
Definition: mode.cpp:93
Mode::setIconName
void setIconName(const QString &iconName)
Definition: mode.cpp:52
Action::name
virtual QString name() const =0
action.h
Mode::m_actionList
QVector< Action * > m_actionList
Definition: mode.h:67
Mode::doAfter
bool doAfter()
Definition: mode.cpp:105
Mode::setName
void setName(const QString &name)
Definition: mode.cpp:48
Mode::m_doAfter
bool m_doAfter
Definition: mode.h:68
Mode::addAction
void addAction(Action *action)
Add the given Action to the Mode.
Definition: mode.cpp:64
Mode::operator==
bool operator==(const Mode &mode) const
Definition: mode.cpp:60
Mode::m_iconName
QString m_iconName
Definition: mode.h:65
mode.h
Mode::name
QString name() const
Definition: mode.cpp:36
Mode::iconName
QString iconName() const
Definition: mode.cpp:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:43 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kremotecontrol

Skip menu "kremotecontrol"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal