11 changed files with 346 additions and 36 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 as version 3 of the License, or //
|
||||
// //
|
||||
// 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 V3 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 "command.h" |
||||
#include "util/simpleserializer.h" |
||||
|
||||
Command::Command() |
||||
{ |
||||
resetToDefaults(); |
||||
} |
||||
|
||||
Command::~Command() |
||||
{} |
||||
|
||||
void Command::resetToDefaults() |
||||
{ |
||||
m_group = "default"; |
||||
m_description = "no name"; |
||||
m_command = ""; |
||||
m_argString = ""; |
||||
m_pressKey = static_cast<Qt::Key>(0); |
||||
m_releaseKey = static_cast<Qt::Key>(0); |
||||
} |
||||
|
||||
QByteArray Command::serialize() const |
||||
{ |
||||
SimpleSerializer s(1); |
||||
|
||||
s.writeString(1, m_group); |
||||
s.writeString(2, m_description); |
||||
s.writeString(3, m_command); |
||||
s.writeString(4, m_argString); |
||||
s.writeS32(5, (int) m_pressKey); |
||||
s.writeS32(6, (int) m_releaseKey); |
||||
|
||||
return s.final(); |
||||
} |
||||
|
||||
|
||||
bool Command::deserialize(const QByteArray& data) |
||||
{ |
||||
SimpleDeserializer d(data); |
||||
|
||||
if (!d.isValid()) |
||||
{ |
||||
resetToDefaults(); |
||||
return false; |
||||
} |
||||
|
||||
if (d.getVersion() == 1) |
||||
{ |
||||
int tmpInt; |
||||
|
||||
d.readString(1, &m_group, "default"); |
||||
d.readString(2, &m_description, "no name"); |
||||
d.readString(3, &m_command, ""); |
||||
d.readString(4, &m_argString, ""); |
||||
d.readS32(5, &tmpInt, 0); |
||||
m_pressKey = static_cast<Qt::Key>(tmpInt); |
||||
d.readS32(6, &tmpInt, 0); |
||||
m_releaseKey = static_cast<Qt::Key>(tmpInt); |
||||
|
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
resetToDefaults(); |
||||
return false; |
||||
} |
||||
} |
||||
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 as version 3 of the License, or //
|
||||
// //
|
||||
// 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 V3 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 SDRBASE_COMMANDS_COMMAND_H_ |
||||
#define SDRBASE_COMMANDS_COMMAND_H_ |
||||
|
||||
#include <Qt> |
||||
#include <QByteArray> |
||||
#include <QString> |
||||
|
||||
class Command |
||||
{ |
||||
public: |
||||
Command(); |
||||
~Command(); |
||||
void resetToDefaults(); |
||||
|
||||
QByteArray serialize() const; |
||||
bool deserialize(const QByteArray& data); |
||||
|
||||
void setCommand(const QString& command) { m_command = command; } |
||||
const QString& getCommand() const { return m_command; } |
||||
void setArgString(const QString& argString) { m_argString = argString; } |
||||
const QString& getArgString() const { return m_argString; } |
||||
void setGroup(const QString& group) { m_group = group; } |
||||
const QString& getGroup() const { return m_group; } |
||||
void setDescription(const QString& description) { m_description = description; } |
||||
const QString& getDescription() const { return m_description; } |
||||
void setPressKey(Qt::Key key) { m_pressKey = key; } |
||||
Qt::Key getPressKey() const { return m_pressKey; } |
||||
void setReleaseKey(Qt::Key key) { m_releaseKey = key; } |
||||
Qt::Key getReleaseKey() const { return m_releaseKey; } |
||||
|
||||
private: |
||||
QString m_command; |
||||
QString m_argString; |
||||
QString m_group; |
||||
QString m_description; |
||||
Qt::Key m_pressKey; |
||||
Qt::Key m_releaseKey; |
||||
}; |
||||
|
||||
|
||||
|
||||
#endif /* SDRBASE_COMMANDS_COMMAND_H_ */ |
||||
|
After Width: | Height: | Size: 398 B |
|
After Width: | Height: | Size: 381 B |
Loading…
Reference in new issue