-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6fdc45
commit 782c94b
Showing
11 changed files
with
883 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
// cdlgmdfregistervalue.cpp | ||
// | ||
// This file is part of the VSCP (https://www.vscp.org) | ||
// | ||
// The MIT License (MIT) | ||
// | ||
// Copyright © 2000-2023 Ake Hedman, Grodans Paradis AB | ||
// <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
|
||
#ifdef WIN32 | ||
#include <pch.h> | ||
#endif | ||
|
||
#include <vscp.h> | ||
#include <vscphelper.h> | ||
|
||
#include <vscpworks.h> | ||
|
||
#include "cdlgmdfregistervalue.h" | ||
#include "ui_cdlgmdfregistervalue.h" | ||
|
||
#include <QColorDialog> | ||
#include <QDate> | ||
#include <QDebug> | ||
#include <QMessageBox> | ||
#include <QShortcut> | ||
|
||
#include <spdlog/async.h> | ||
#include <spdlog/sinks/rotating_file_sink.h> | ||
#include <spdlog/sinks/stdout_color_sinks.h> | ||
#include <spdlog/spdlog.h> | ||
|
||
const char CDlgMdfRegisterValue::pre_str_registerbit[] = "Register value: "; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// CTor | ||
// | ||
|
||
CDlgMdfRegisterValue::CDlgMdfRegisterValue(QWidget* parent) | ||
: QDialog(parent) | ||
, ui(new Ui::CDlgMdfRegisterValue) | ||
{ | ||
ui->setupUi(this); | ||
|
||
// m_type = mdf_type_unknown; | ||
m_pvalue = nullptr; | ||
|
||
vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); | ||
|
||
setInitialFocus(); | ||
this->setFixedSize(this->size()); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// DTor | ||
// | ||
|
||
CDlgMdfRegisterValue::~CDlgMdfRegisterValue() | ||
{ | ||
delete ui; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// initDialogData | ||
// | ||
|
||
void | ||
CDlgMdfRegisterValue::initDialogData(CMDF_Value* pvalue, int index) | ||
{ | ||
QString str; | ||
|
||
if (nullptr == pvalue) { | ||
spdlog::error("MDF register value information - Invalid MDF register value object (initDialogData)"); | ||
return; | ||
} | ||
|
||
m_pvalue = pvalue; | ||
|
||
setName(pvalue->getName().c_str()); | ||
str = pvalue->getValue().c_str(); | ||
setValue(str); | ||
|
||
switch (index) { | ||
case index_name: | ||
ui->editName->setFocus(); | ||
break; | ||
|
||
case index_value: | ||
ui->editValue->setFocus(); | ||
break; | ||
|
||
default: | ||
ui->editName->setFocus(); | ||
break; | ||
} | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// setInitialFocus | ||
// | ||
|
||
void | ||
CDlgMdfRegisterValue::setInitialFocus(void) | ||
{ | ||
// ui->editName->setFocus(); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Getters & Setters | ||
// ---------------------------------------------------------------------------- | ||
|
||
QString | ||
CDlgMdfRegisterValue::getName(void) | ||
{ | ||
return ui->editName->text(); | ||
}; | ||
|
||
void | ||
CDlgMdfRegisterValue::setName(const QString& name) | ||
{ | ||
ui->editName->setText(name); | ||
}; | ||
|
||
// ----------------------------------------------------------------------- | ||
|
||
QString | ||
CDlgMdfRegisterValue::getValue(void) | ||
{ | ||
return ui->editValue->text(); | ||
}; | ||
|
||
void | ||
CDlgMdfRegisterValue::setValue(const QString& name) | ||
{ | ||
ui->editValue->setText(name); | ||
}; | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// accept | ||
// | ||
|
||
void | ||
CDlgMdfRegisterValue::accept() | ||
{ | ||
std::string str; | ||
if (nullptr != m_pvalue) { | ||
m_pvalue->setName(getName().toStdString()); | ||
m_pvalue->setValue(getValue().toStdString()); | ||
} | ||
else { | ||
spdlog::error("MDF module information - Invalid MDF object (accept)"); | ||
} | ||
|
||
QDialog::accept(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// cdlgmdfregistervalue.h | ||
// | ||
// This file is part of the VSCP (https://www.vscp.org) | ||
// | ||
// The MIT License (MIT) | ||
// | ||
// Copyright © 2000-2023 Ake Hedman, Grodans Paradis AB | ||
// <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
|
||
#ifndef CDLGMDFREGISTERVALUE_H | ||
#define CDLGMDFREGISTERVALUE_H | ||
|
||
#include <mdf.h> | ||
#include <vscpworks.h> | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class CDlgMdfRegisterValue; | ||
} | ||
|
||
class CDlgMdfRegisterValue : public QDialog { | ||
Q_OBJECT | ||
|
||
public: | ||
public: | ||
explicit CDlgMdfRegisterValue(QWidget* parent = nullptr); | ||
~CDlgMdfRegisterValue(); | ||
|
||
static const int index_name = 0; | ||
static const int index_value = 1; | ||
|
||
|
||
static const char pre_str_registerbit[]; | ||
|
||
/*! | ||
Set inital focus to description | ||
*/ | ||
void setInitialFocus(void); | ||
|
||
/*! | ||
Init dialog data | ||
@param CMDF *pmdf Pointer to MDF | ||
@param pbit Pointer to MDF bit object | ||
@param index Selected file item | ||
*/ | ||
void initDialogData(CMDF_Value* pvalue, int index = 0); | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Getters & Setters | ||
// ---------------------------------------------------------------------------- | ||
|
||
// name | ||
QString getName(void); | ||
void setName(const QString& name); | ||
|
||
// value | ||
QString getValue(void); | ||
void setValue(const QString& value); | ||
|
||
public slots: | ||
|
||
/*! | ||
Accept dialog data and write to register | ||
*/ | ||
void accept(void); | ||
|
||
private: | ||
Ui::CDlgMdfRegisterValue* ui; | ||
|
||
/// Pointer to MDF | ||
CMDF* m_pmdf; | ||
|
||
/// Pointer to bit information | ||
CMDF_Value* m_pvalue; | ||
}; | ||
|
||
#endif // CDlgMdfRegisterValue_H |
Oops, something went wrong.