Skip to content

Commit

Permalink
Bit editing partial added
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Nov 16, 2023
1 parent f539bfe commit e1d1519
Show file tree
Hide file tree
Showing 15 changed files with 1,696 additions and 232 deletions.
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ qt5_wrap_ui(UI src/mainwindow.ui

src/cdlgmdfregister.ui
src/cdlgmdfregisterlist.ui
src/cdlgmdfregisterbitlist.ui
src/cdlgmdfregisterbit.ui
src/cdlgmdfregistervaluelist.ui
src/cdlgmdfregisterbitlist.ui
src/cdlgmdfregistervalue.ui

src/cdlgmdfregistervaluelist.ui

src/cdlgmdfregistermapping.ui

src/cdlgmdfremotevar.ui
Expand Down Expand Up @@ -583,6 +583,16 @@ add_executable(${PROJECT_NAME}
src/cdlgmdfregisterlist.cpp
src/cdlgmdfregisterlist.h

build/ui_cdlgmdfregisterbit.h
src/cdlgmdfregisterbit.ui
src/cdlgmdfregisterbit.cpp
src/cdlgmdfregisterbit.h

build/ui_cdlgmdfregisterbitlist.h
src/cdlgmdfregisterbitlist.ui
src/cdlgmdfregisterbitlist.cpp
src/cdlgmdfregisterbitlist.h

${VSCP_PATH}/src/vscp/common/version.h
${VSCP_PATH}/src/vscp/common/vscp.h
${VSCP_PATH}/src/vscp/common/vscpremotetcpif.h
Expand Down
14 changes: 14 additions & 0 deletions src/cdlgmdfregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ CDlgMdfRegister::CDlgMdfRegister(QWidget* parent)
vscpworks* pworks = (vscpworks*)QCoreApplication::instance();

setInitialFocus();
this->setFixedSize(this->size());
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -201,6 +202,19 @@ CDlgMdfRegister::initDialogData(CMDF* pmdf, CMDF_Register* preg, int index)
ui->editName->setFocus();
break;
}

this->setFixedSize(this->size());
}

///////////////////////////////////////////////////////////////////////////////
// setReadOnly
//

void
CDlgMdfRegister::setReadOnly(void)
{
ui->comboPage->setEnabled(false);
ui->editOffset->setEnabled(false);
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions src/cdlgmdfregister.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ class CDlgMdfRegister : public QDialog {
*/
void initDialogData(CMDF *pmdf, CMDF_Register* preg, int index = 0);

/*!
Prevent page and offset from being edited
*/
void setReadOnly(void);



// ----------------------------------------------------------------------------
// Getters & Setters
Expand Down
3 changes: 3 additions & 0 deletions src/cdlgmdfregister.ui
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="sizeConstraint">
Expand Down
286 changes: 286 additions & 0 deletions src/cdlgmdfregisterbit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
// cdlgmdfregisterbit.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 "cdlgmdfregisterbit.h"
#include "ui_cdlgmdfregisterbit.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 CDlgMdfRegisterBit::pre_str_registerbit[] = "Register bit: ";

///////////////////////////////////////////////////////////////////////////////
// CTor
//

CDlgMdfRegisterBit::CDlgMdfRegisterBit(QWidget* parent)
: QDialog(parent)
, ui(new Ui::CDlgMdfRegisterBit)
{
ui->setupUi(this);

// m_type = mdf_type_unknown;
m_pbit = nullptr;

vscpworks* pworks = (vscpworks*)QCoreApplication::instance();

setInitialFocus();
this->setFixedSize(this->size());
}

///////////////////////////////////////////////////////////////////////////////
// DTor
//

CDlgMdfRegisterBit::~CDlgMdfRegisterBit()
{
delete ui;
}

///////////////////////////////////////////////////////////////////////////////
// initDialogData
//

void
CDlgMdfRegisterBit::initDialogData(CMDF* pmdf, CMDF_Bit* pbit, int index)
{
QString str;

if (nullptr == pmdf) {
spdlog::error("MDF register bit information - Invalid MDF object (initDialogData)");
return;
}

m_pmdf = pmdf;

if (nullptr == pbit) {
spdlog::error("MDF register bit information - Invalid MDF register bit object (initDialogData)");
return;
}

m_pbit = pbit;

setName(pbit->getName().c_str());
setPos(pbit->getPos());
setWidth(pbit->getWidth());
setDefault(pbit->getDefault());
setMin(pbit->getMin());
setMax(pbit->getMax());
setAccess(pbit->getAccess());

switch (index) {
case index_name:
ui->editName->setFocus();
break;

case index_pos:
ui->spinPos->setFocus();
break;

case index_width:
ui->spinWidth->setFocus();
break;

case index_default:
ui->spinDefault->setFocus();
break;

case index_min:
ui->spinMin->setFocus();
break;

case index_max:
ui->spinMax->setFocus();
break;

case index_access:
ui->spinMin->setFocus();
break;

default:
ui->editName->setFocus();
break;
}
}

///////////////////////////////////////////////////////////////////////////////
// setInitialFocus
//

void
CDlgMdfRegisterBit::setInitialFocus(void)
{
// ui->editName->setFocus();
}

// ----------------------------------------------------------------------------
// Getters & Setters
// ----------------------------------------------------------------------------

QString
CDlgMdfRegisterBit::getName(void)
{
return ui->editName->text();
};

void
CDlgMdfRegisterBit::setName(const QString& name)
{
ui->editName->setText(name);
};

// -----------------------------------------------------------------------

uint8_t
CDlgMdfRegisterBit::getPos(void)
{
return ui->spinPos->value();
}

void
CDlgMdfRegisterBit::setPos(uint8_t span)
{
ui->spinPos->setValue(span);
}


// -----------------------------------------------------------------------

uint8_t
CDlgMdfRegisterBit::getWidth(void)
{
return ui->spinWidth->value();
}

void
CDlgMdfRegisterBit::setWidth(uint8_t span)
{
ui->spinWidth->setValue(span);
}

// -----------------------------------------------------------------------

uint8_t
CDlgMdfRegisterBit::getDefault(void)
{
return ui->spinDefault->value();
}

void
CDlgMdfRegisterBit::setDefault(uint8_t span)
{
ui->spinDefault->setValue(span);
}

// -----------------------------------------------------------------------

uint8_t
CDlgMdfRegisterBit::getMin(void)
{
return ui->spinMin->value();
}

void
CDlgMdfRegisterBit::setMin(uint8_t min)
{
ui->spinMin->setValue(min);
}

// -----------------------------------------------------------------------

uint8_t
CDlgMdfRegisterBit::getMax(void)
{
return ui->spinMax->value();
}

void
CDlgMdfRegisterBit::setMax(uint8_t span)
{
ui->spinMax->setValue(span);
}

// -----------------------------------------------------------------------

mdf_access_mode
CDlgMdfRegisterBit::getAccess(void)
{
return static_cast<mdf_access_mode>(ui->comboAccess->currentIndex());
}

void
CDlgMdfRegisterBit::setAccess(uint8_t access)
{
if (access <= MDF_REG_ACCESS_READ_WRITE) {
ui->comboAccess->setCurrentIndex(access);
}
}



///////////////////////////////////////////////////////////////////////////////
// accept
//

void
CDlgMdfRegisterBit::accept()
{
std::string str;
if (nullptr != m_pbit) {
m_pbit->setName(getName().toStdString());
m_pbit->setName(getName().toStdString().c_str());
m_pbit->setPos(getPos());
m_pbit->setWidth(getWidth());
m_pbit->setMin(getMin());
m_pbit->setMax(getMax());
m_pbit->setAccess(getAccess());
m_pbit->setDefault(getDefault());
}
else {
spdlog::error("MDF module information - Invalid MDF object (accept)");
}

QDialog::accept();
}
Loading

0 comments on commit e1d1519

Please sign in to comment.