Skip to content

Commit

Permalink
Added register value edit
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Dec 12, 2023
1 parent a6fdc45 commit 782c94b
Show file tree
Hide file tree
Showing 11 changed files with 883 additions and 138 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
"any": "cpp",
"numbers": "cpp",
"span": "cpp",
"bitset": "cpp"
"bitset": "cpp",
"complex": "cpp",
"format": "cpp"
},
"python.pythonPath": "/usr/bin/python3",
"files.exclude": {
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,16 @@ add_executable(${PROJECT_NAME}
src/cdlgmdfregisterbitlist.cpp
src/cdlgmdfregisterbitlist.h

build/ui_cdlgmdfregistervalue.h
src/cdlgmdfregistervalue.ui
src/cdlgmdfregistervalue.cpp
src/cdlgmdfregistervalue.h

build/ui_cdlgmdfregistervaluelist.h
src/cdlgmdfregistervaluelist.ui
src/cdlgmdfregistervaluelist.cpp
src/cdlgmdfregistervaluelist.h

${VSCP_PATH}/src/vscp/common/version.h
${VSCP_PATH}/src/vscp/common/vscp.h
${VSCP_PATH}/src/vscp/common/vscpremotetcpif.h
Expand Down
2 changes: 1 addition & 1 deletion src/cdlgmdfregisterbit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Register Bit Definition</string>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
Expand Down
175 changes: 175 additions & 0 deletions src/cdlgmdfregistervalue.cpp
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();
}
98 changes: 98 additions & 0 deletions src/cdlgmdfregistervalue.h
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
Loading

0 comments on commit 782c94b

Please sign in to comment.