diff --git a/CMakeLists.txt b/CMakeLists.txt index 16d3768c..0fe005f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,10 +252,12 @@ qt5_wrap_ui(UI src/mainwindow.ui src/cdlgmdfremotevar.ui src/cdlgmdfdescription.ui src/cdlgmdfinfourl.ui - src/cdlgmdffilefirmware.ui - src/cdlgmdffilevideo.ui + src/cdlgmdffilefirmware.ui + src/cdlgmdffilevideo.ui src/cdlgmdfvaluelist.ui src/cdlgeditmap.ui + src/cdlgmdfmanufacturer.ui + src/cdlgmdfcontact.ui ) add_executable(${PROJECT_NAME} @@ -501,6 +503,16 @@ add_executable(${PROJECT_NAME} src/cdlgeditmap.cpp src/cdlgeditmap.h + build/ui_cdlgmdfmanufacturer.h + src/cdlgmdfmanufacturer.ui + src/cdlgmdfmanufacturer.cpp + src/cdlgmdfmanufacturer.h + + build/ui_cdlgmdfcontact.h + src/cdlgmdfcontact.ui + src/cdlgmdfcontact.cpp + src/cdlgmdfcontact.h + ${VSCP_PATH}/src/vscp/common/version.h ${VSCP_PATH}/src/vscp/common/vscp.h ${VSCP_PATH}/src/vscp/common/vscpremotetcpif.h diff --git a/src/cdlgmdfcontact.cpp b/src/cdlgmdfcontact.cpp new file mode 100644 index 00000000..7376cd16 --- /dev/null +++ b/src/cdlgmdfcontact.cpp @@ -0,0 +1,230 @@ +// cdlgmdfcontact.cpp +// +// This file is part of the VSCP (https://www.vscp.org) +// +// The MIT License (MIT) +// +// Copyright © 2000-2023 Ake Hedman, Grodans Paradis AB +// +// +// 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 +#endif + +#include +#include + +#include + +#include "cdlgmdfcontact.h" +#include "ui_cdlgmdfcontact.h" + +#include +#include +#include + +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +// CTor +// + +CDlgMdfContact::CDlgMdfContact(QWidget* parent) + : QDialog(parent) + , ui(new Ui::CDlgMdfContact) +{ + ui->setupUi(this); + + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + + // QShortcut* shortcut = new QShortcut(QKeySequence(tr("Ctrl+E", "Edit")), ui->editDate); + // connect(shortcut, &QShortcut::activated, this, &CDlgMdfContact::editDesc); + + setInitialFocus(); +} + +/////////////////////////////////////////////////////////////////////////////// +// DTor +// + +CDlgMdfContact::~CDlgMdfContact() +{ + delete ui; +} + +/////////////////////////////////////////////////////////////////////////////// +// initDialogData +// + +void +CDlgMdfContact::initDialogData(const CMDF_Object* pmdfobj) +{ + QString str; + + if (nullptr == pmdfobj) { + spdlog::error("MDF module information - Invalid MDF object (initDialogData)"); + return; + } + + m_pmdf = (CMDF*)pmdfobj; + + // ui->editName->setText(m_pmdf->getModuleName().c_str()); + // ui->editModel->setText(m_pmdf->getModuleModel().c_str()); + // ui->comboModuleLevel->setCurrentIndex(m_pmdf->getModuleLevel()); + // ui->editVersion->setText(m_pmdf->getModuleVersion().c_str()); + // str = m_pmdf->getModuleChangeDate().c_str(); + // ui->editDate->setDate(QDate::fromString(str, Qt::ISODate)); + // ui->editBufferSize->setValue(m_pmdf->getModuleBufferSize()); + // ui->editCopyright->setText(m_pmdf->getModuleCopyright().c_str()); + + // switch (index) { + // case index_module_model: + // ui->editModel->setFocus(); + // break; + + // case index_module_version: + // ui->editVersion->setFocus(); + // break; + + // case index_module_level: + // ui->comboModuleLevel->setFocus(); + // break; + + // case index_module_change_date: + // ui->editDate->setFocus(); + // break; + + // case index_module_buffer_size: + // ui->editBufferSize->setFocus(); + // break; + + // case index_module_copyright: + // ui->editCopyright->setFocus(); + // break; + + // case index_module_name: + // default: + // ui->editName->setFocus(); + // break; + // } + + // Fill in descriptions + //fillDescription(); + + // std::map* pmapDescription = m_pmdf->getModuleDescriptionMap(); + // std::map::iterator itDesc = pmapDescription->begin(); + // while (itDesc != pmapDescription->end()) { + // std::string lang = itDesc->first; // key + // std::string description = itDesc->second; + // str = lang.c_str() + tr(" - ") + description.c_str(); + // ui->listDescription->addItem(str); + // itDesc++; + // } + + // Fill in help URL's + //fillInfoUrl(); + // std::map* pmapHelpUrl = m_pmdf->getModuleHelpUrlMap(); + // std::map::iterator itInfo = pmapHelpUrl->begin(); + // while (itInfo != pmapHelpUrl->end()) { + // std::string lang = itInfo->first; // key + // std::string info = itInfo->second; + // str = lang.c_str() + tr(" - ") + info.c_str(); + // ui->listInfo->addItem(str); + // itInfo++; + // } +} + + +/////////////////////////////////////////////////////////////////////////////// +// setInitialFocus +// + +void +CDlgMdfContact::setInitialFocus(void) +{ + // ui->editGuid->setFocus(); +} + + +// ---------------------------------------------------------------------------- +// Getters & Setters +// ---------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// getName +// + +QString +CDlgMdfContact::getName(void) +{ + return (ui->editValue->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setName +// + +void +CDlgMdfContact::setName(const QString& str) +{ + ui->editValue->setText(str); +} + + +/////////////////////////////////////////////////////////////////////////////// +// accept +// + +void +CDlgMdfContact::accept() +{ + std::string str; + if (nullptr != m_pmdf) { + + // str = ui->editName->text().toStdString(); + // m_pmdf->setModuleName(str); + + // str = ui->editModel->text().toStdString(); + // m_pmdf->setModuleModel(str); + + // m_pmdf->setModuleLevel(ui->comboModuleLevel->currentIndex()); + + // str = ui->editVersion->text().toStdString(); + // m_pmdf->setModuleVersion(str); + + // str = ui->editDate->text().toStdString(); + // m_pmdf->setModuleChangeDate(str); + + // m_pmdf->setModuleBufferSize(ui->editBufferSize->value()); + + // str = ui->editCopyright->text().toStdString(); + // m_pmdf->setModuleCopyright(str); + } + else { + spdlog::error("MDF module information - Invalid MDF object (accept)"); + } + + QDialog::accept(); +} diff --git a/src/cdlgmdfcontact.h b/src/cdlgmdfcontact.h new file mode 100644 index 00000000..69a60130 --- /dev/null +++ b/src/cdlgmdfcontact.h @@ -0,0 +1,123 @@ +// cdlgmdfcontact.h +// +// This file is part of the VSCP (https://www.vscp.org) +// +// The MIT License (MIT) +// +// Copyright © 2000-2023 Ake Hedman, Grodans Paradis AB +// +// +// 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 CDLGMDFCONTACT_H +#define CDLGMDFCONTACT_H + +#include +#include + +#include + + +namespace Ui { +class CDlgMdfContact; +} + +class CDlgMdfContact : public QDialog { + Q_OBJECT + +public: +public: + explicit CDlgMdfContact(QWidget* parent = nullptr); + ~CDlgMdfContact(); + + /*! + Set inital focus to description + */ + void setInitialFocus(void); + + /*! + Set edit mode. + GUID will be READ ONLY + */ + void setEditMode(); + + /*! + Init dialog data + @param pmdfobject Pointer to MDF object + @param index The index for the field that will get focus + */ + void initDialogData(const CMDF_Object* pmdfobj); + + + // ---------------------------------------------------------------------------- + // Getters & Setters + // ---------------------------------------------------------------------------- + + /*! + Name getter/setters + */ + void setName(const QString& name); + QString getName(void); + + /*! + GUID getter/setters + */ + void setModel(const QString& guid); + QString getModel(void); + + /*! + GUID getter/setters + */ + void setVersion(const QString& guid); + QString getVersion(void); + + /*! + GUID getter/setters + */ + void setChangeDate(const QString& guid); + QString getChangeDate(void); + + /*! + GUID getter/setters + */ + void setBufferSize(int size); + int getBufferSize(void); + + /*! + GUID getter/setters + */ + void setCopyright(const QString& guid); + QString getCopyright(void); + + /*! + GUID getter/setters + */ + void setDescription(const QString& guid); + QString getDescription(void); + +public slots: + void accept(void); + +private: + Ui::CDlgMdfContact* ui; + CMDF* m_pmdf; +}; + +#endif // CDLGMDFCONTACT_H diff --git a/src/cdlgmdfcontact.ui b/src/cdlgmdfcontact.ui new file mode 100644 index 00000000..ee003b1e --- /dev/null +++ b/src/cdlgmdfcontact.ui @@ -0,0 +1,96 @@ + + + CDlgMdfContact + + + + 0 + 0 + 487 + 128 + + + + Dialog + + + + + 10 + 90 + 471 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + false + + + + + + 9 + 9 + 471 + 71 + + + + + + + Type + + + + + + + + Email + + + + + Phone + + + + + Fax + + + + + Web + + + + + Social + + + + + + + + Type + + + + + + + + + + + + diff --git a/src/cdlgmdfmanufacturer.cpp b/src/cdlgmdfmanufacturer.cpp new file mode 100644 index 00000000..bc20b24c --- /dev/null +++ b/src/cdlgmdfmanufacturer.cpp @@ -0,0 +1,474 @@ +// cdlgmdfmmanufacturer.cpp +// +// This file is part of the VSCP (https://www.vscp.org) +// +// The MIT License (MIT) +// +// Copyright © 2000-2023 Ake Hedman, Grodans Paradis AB +// +// +// 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 +#endif + +#include +#include + +#include + +#include "cdlgmdfmanufacturer.h" +#include "ui_cdlgmdfmanufacturer.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +// CTor +// + +CDlgMdfManufacturer::CDlgMdfManufacturer(QWidget* parent) + : QDialog(parent) + , ui(new Ui::CDlgMdfManufacturer) +{ + ui->setupUi(this); + + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + + // QShortcut* shortcut = new QShortcut(QKeySequence(tr("Ctrl+E", "Edit")), ui->editDate); + // connect(shortcut, &QShortcut::activated, this, &CDlgMdfManufacturer::editDesc); + + // // connect(ui->btnSetDummyGuid, &QPushButton::clicked, this, &cdlgmdfmodule::setDummyGuid); + + // connect(ui->btnAddDesc, &QToolButton::clicked, this, &CDlgMdfManufacturer::addDesc); + // connect(ui->btnEditDesc, &QToolButton::clicked, this, &CDlgMdfManufacturer::editDesc); + // connect(ui->btnDupDesc, &QToolButton::clicked, this, &CDlgMdfManufacturer::dupDesc); + // connect(ui->btnDelDesc, &QToolButton::clicked, this, &CDlgMdfManufacturer::deleteDesc); + + // connect(ui->btnAddInfo, &QToolButton::clicked, this, &CDlgMdfManufacturer::addInfo); + // connect(ui->btnEditInfo, &QToolButton::clicked, this, &CDlgMdfManufacturer::editInfo); + // connect(ui->btnDupInfo, &QToolButton::clicked, this, &CDlgMdfManufacturer::dupInfo); + // connect(ui->btnDelInfo, &QToolButton::clicked, this, &CDlgMdfManufacturer::deleteInfo); + + setInitialFocus(); +} + +/////////////////////////////////////////////////////////////////////////////// +// DTor +// + +CDlgMdfManufacturer::~CDlgMdfManufacturer() +{ + delete ui; +} + +/////////////////////////////////////////////////////////////////////////////// +// initDialogData +// + +void +CDlgMdfManufacturer::initDialogData(const CMDF_Object* pmdfobj, mdf_manufacturer_index index) +{ + QString str; + + if (nullptr == pmdfobj) { + spdlog::error("MDF module information - Invalid MDF object (initDialogData)"); + return; + } + + m_pmanufacturer = (CMDF_Manufacturer*)pmdfobj; + + ui->editName->setText(m_pmanufacturer->getName().c_str()); + ui->editStreet->setText(m_pmanufacturer->getAddressObj()->getStreet().c_str()); + ui->editCity->setText(m_pmanufacturer->getAddressObj()->getCity().c_str()); + ui->editTown->setText(m_pmanufacturer->getAddressObj()->getTown().c_str()); + ui->editPostCode->setText(m_pmanufacturer->getAddressObj()->getPostCode().c_str()); + ui->editRegion->setText(m_pmanufacturer->getAddressObj()->getRegion().c_str()); + ui->editState->setText(m_pmanufacturer->getAddressObj()->getState().c_str()); + ui->editCountry->setText(m_pmanufacturer->getAddressObj()->getCountry().c_str()); + + switch (index) { + case index_manufacturer_street: + ui->editStreet->setFocus(); + break; + + case index_manufacturer_city: + ui->editCity->setFocus(); + break; + + case index_manufacturer_town: + ui->editTown->setFocus(); + break; + + case index_manufacturer_post_code: + ui->editPostCode->setFocus(); + break; + + case index_manufacturer_region: + ui->editRegion->setFocus(); + break; + + case index_manufacturer_state: + ui->editState->setFocus(); + break; + + case index_manufacturer_country: + ui->editCountry->setFocus(); + break; + + case index_manufacturer_name: + default: + ui->editName->setFocus(); + break; + } + + // Fill in descriptions + //fillDescription(); + + // std::map* pmapDescription = m_pmdf->getModuleDescriptionMap(); + // std::map::iterator itDesc = pmapDescription->begin(); + // while (itDesc != pmapDescription->end()) { + // std::string lang = itDesc->first; // key + // std::string description = itDesc->second; + // str = lang.c_str() + tr(" - ") + description.c_str(); + // ui->listDescription->addItem(str); + // itDesc++; + // } + + // Fill in help URL's + //fillInfoUrl(); + // std::map* pmapHelpUrl = m_pmdf->getModuleHelpUrlMap(); + // std::map::iterator itInfo = pmapHelpUrl->begin(); + // while (itInfo != pmapHelpUrl->end()) { + // std::string lang = itInfo->first; // key + // std::string info = itInfo->second; + // str = lang.c_str() + tr(" - ") + info.c_str(); + // ui->listInfo->addItem(str); + // itInfo++; + // } +} + + +/////////////////////////////////////////////////////////////////////////////// +// setInitialFocus +// + +void +CDlgMdfManufacturer::setInitialFocus(void) +{ + // ui->editGuid->setFocus(); +} + + + +// ---------------------------------------------------------------------------- +// Getters & Setters +// ---------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// getName +// + +QString +CDlgMdfManufacturer::getName(void) +{ + return (ui->editName->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setName +// + +void +CDlgMdfManufacturer::setName(const QString& str) +{ + ui->editName->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// getStreet +// + +QString +CDlgMdfManufacturer::getStreet(void) +{ + return (ui->editStreet->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setStreet +// + +void +CDlgMdfManufacturer::setStreet(const QString& str) +{ + ui->editStreet->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// getCity +// + +QString +CDlgMdfManufacturer::getCity(void) +{ + return (ui->editCity->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setCity +// + +void +CDlgMdfManufacturer::setCity(const QString& str) +{ + ui->editCity->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// getTown +// + +QString +CDlgMdfManufacturer::getTown(void) +{ + return (ui->editTown->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setTown +// + +void +CDlgMdfManufacturer::setTown(const QString& str) +{ + ui->editTown->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// getPostCode +// + +QString +CDlgMdfManufacturer::getPostCode(void) +{ + return (ui->editPostCode->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setPostCode +// + +void +CDlgMdfManufacturer::setPostCode(const QString& str) +{ + ui->editPostCode->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// getRegion +// + +QString +CDlgMdfManufacturer::getRegion(void) +{ + return (ui->editRegion->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setPostCode +// + +void +CDlgMdfManufacturer::setRegion(const QString& str) +{ + ui->editRegion->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// getState +// + +QString +CDlgMdfManufacturer::getState(void) +{ + return (ui->editState->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setState +// + +void +CDlgMdfManufacturer::setState(const QString& str) +{ + ui->editState->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// getCountry +// + +QString +CDlgMdfManufacturer::getCountry(void) +{ + return (ui->editCountry->text()); +} + +/////////////////////////////////////////////////////////////////////////////// +// setCountry +// + +void +CDlgMdfManufacturer::setCountry(const QString& str) +{ + ui->editCountry->setText(str); +} + +/////////////////////////////////////////////////////////////////////////////// +// accept +// + +void +CDlgMdfManufacturer::accept() +{ + std::string str; + if (nullptr != m_pmanufacturer) { + + str = ui->editName->text().toStdString(); + //m_pmdf->setModuleName(str); + + // str = ui->editModel->text().toStdString(); + // m_pmdf->setModuleModel(str); + + // m_pmdf->setModuleLevel(ui->comboModuleLevel->currentIndex()); + + // str = ui->editVersion->text().toStdString(); + // m_pmdf->setModuleVersion(str); + + // str = ui->editDate->text().toStdString(); + // m_pmdf->setModuleChangeDate(str); + + // m_pmdf->setModuleBufferSize(ui->editBufferSize->value()); + + // str = ui->editCopyright->text().toStdString(); + // m_pmdf->setModuleCopyright(str); + } + else { + spdlog::error("MDF module information - Invalid MDF object (accept)"); + } + + QDialog::accept(); +} + +/////////////////////////////////////////////////////////////////////////////// +// addDesc +// + +void +CDlgMdfManufacturer::addContact(void) +{ + // QString selstr = "en"; // Default language + + // CDlgMdfDescription dlg(this); + // dlg.initDialogData(m_pmdf->getModuleDescriptionMap()/*, &selstr*/); + // if (QDialog::Accepted == dlg.exec()) { + // ui->listDescription->clear(); + // fillDescription(); + // } +} + +/////////////////////////////////////////////////////////////////////////////// +// editDesc +// + +void +CDlgMdfManufacturer::editContact(void) +{ + // if (-1 != ui->listDescription->currentRow()) { + + // // Save the row + // int idx = ui->listDescription->currentRow(); + + // QListWidgetItem* pitem = ui->listDescription->currentItem(); + // QString selstr = pitem->text().split('_').first().left(2); + + // CDlgMdfDescription dlg(this); + // dlg.initDialogData(m_pmdf->getModuleDescriptionMap(), &selstr); + // if (QDialog::Accepted == dlg.exec()) { + // ui->listDescription->clear(); + // fillDescription(); + // ui->listDescription->setCurrentRow(idx); + // } + // } + // else { + // QMessageBox::warning(this, tr("vscpworks+"), tr("An item must be selected"), QMessageBox::Ok); + // } +} + +/////////////////////////////////////////////////////////////////////////////// +// dupDesc +// + +void +CDlgMdfManufacturer::dupContact(void) +{ + // if (-1 != ui->listDescription->currentRow()) { + // CDlgMdfDescription dlg(this); + // dlg.initDialogData(m_pmdf->getModuleDescriptionMap()); + // if (QDialog::Accepted == dlg.exec()) { + // ui->listDescription->clear(); + // fillDescription(); + // } + // } + // else { + // QMessageBox::warning(this, tr("vscpworks+"), tr("An item must be selected"), QMessageBox::Ok); + // } +} + +/////////////////////////////////////////////////////////////////////////////// +// deleteDesc +// + +void +CDlgMdfManufacturer::deleteContact(void) +{ + // if (-1 != ui->listDescription->currentRow()) { + + // // Save the row + // int idx = ui->listDescription->currentRow(); + + // QListWidgetItem* pitem = ui->listDescription->currentItem(); + // QString selstr = pitem->text().split('_').first().left(2); + + // m_pmdf->getModuleDescriptionMap()->erase(selstr.toStdString()); + // ui->listDescription->clear(); + // fillDescription(); + + // } +} diff --git a/src/cdlgmdfmanufacturer.h b/src/cdlgmdfmanufacturer.h new file mode 100644 index 00000000..8905a879 --- /dev/null +++ b/src/cdlgmdfmanufacturer.h @@ -0,0 +1,174 @@ +// cdlgmdfmanufacturer.h +// +// This file is part of the VSCP (https://www.vscp.org) +// +// The MIT License (MIT) +// +// Copyright © 2000-2023 Ake Hedman, Grodans Paradis AB +// +// +// 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 CDLGMDFMANUFACTURER_H +#define CDLGMDFMANUFACTURER_H + +#include +#include + +#include + +// Id for fields to identify them in the UI. +// Use to set focus on edit and to write changed values +// in correct position among other things. +typedef enum mdf_manufacturer_index { + index_manufacturer_name = 0, + index_manufacturer_street, + index_manufacturer_city, + index_manufacturer_town, + index_manufacturer_post_code, + index_manufacturer_region, + index_manufacturer_state, + index_manufacturer_country, + index_manufacturer_phone, + index_manufacturer_fax, + index_manufacturer_email, + index_manufacturer_web, + index_manufacturer_social, +} mdf_manufacturer_index; + +// Tree prefixes (Text before value in tree table) +#define PREFIX_MDF_MANUFACTURER_NAME tr("Name : ") +#define PREFIX_MDF_MANUFACTURER_STREET tr("Street: ") +#define PREFIX_MDF_MANUFACTURER_CITY tr("City: ") +#define PREFIX_MDF_MANUFACTURER_TOWN tr("Town: ") +#define PREFIX_MDF_MANUFACTURER_POST_CODE tr("Post Code: ") +#define PREFIX_MDF_MANUFACTURER_REGION tr("Region: ") +#define PREFIX_MDF_MANUFACTURER_STATE tr("State: ") +#define PREFIX_MDF_MANUFACTURER_COUNTRY tr("Country: ") +#define PREFIX_MDF_MANUFACTURER_PHONE tr("phone: ") +#define PREFIX_MDF_MANUFACTURER_FAX tr("fax: ") +#define PREFIX_MDF_MANUFACTURER_EMAIL tr("email: ") +#define PREFIX_MDF_MANUFACTURER_WEB tr("web: ") +#define PREFIX_MDF_MANUFACTURER_SOCIAL tr("social: ") + +namespace Ui { +class CDlgMdfManufacturer; +} + +class CDlgMdfManufacturer : public QDialog { + Q_OBJECT + +public: +public: + explicit CDlgMdfManufacturer(QWidget* parent = nullptr); + ~CDlgMdfManufacturer(); + + /*! + Set inital focus to description + */ + void setInitialFocus(void); + + /*! + Set edit mode. + GUID will be READ ONLY + */ + void setEditMode(); + + /*! + Init dialog data + @param pmdfobject Pointer to MDF object + @param index The index for the field that will get focus + */ + void initDialogData(const CMDF_Object* pmdfobj, mdf_manufacturer_index index = index_manufacturer_name); + + /*! + Fill in contact items + */ + void fillContactItems(void); + + + // ---------------------------------------------------------------------------- + // Getters & Setters + // ---------------------------------------------------------------------------- + + /*! + Name getter/setters + */ + void setName(const QString& str); + QString getName(void); + + /*! + Street getter/setters + */ + void setStreet(const QString& str); + QString getStreet(void); + + /*! + City getter/setters + */ + void setCity(const QString& str); + QString getCity(void); + + /*! + Town getter/setters + */ + void setTown(const QString& str); + QString getTown(void); + + /*! + Post code getter/setters + */ + void setPostCode(const QString& str); + QString getPostCode(void); + + /*! + Region getter/setters + */ + void setRegion(const QString& str); + QString getRegion(void); + + /*! + State getter/setters + */ + void setState(const QString& str); + QString getState(void); + + /*! + Country getter/setters + */ + void setCountry(const QString& str); + QString getCountry(void); + +public slots: + void accept(void); + + // Contact buttons + void addContact(void); + void editContact(void); + void dupContact(void); + void deleteContact(void); + + +private: + Ui::CDlgMdfManufacturer* ui; + CMDF_Manufacturer* m_pmanufacturer; +}; + +#endif // CDLGMDFMMANUFACTURER_H diff --git a/src/cdlgmdfmanufacturer.ui b/src/cdlgmdfmanufacturer.ui new file mode 100644 index 00000000..b0392b3b --- /dev/null +++ b/src/cdlgmdfmanufacturer.ui @@ -0,0 +1,268 @@ + + + CDlgMdfManufacturer + + + + 0 + 0 + 660 + 591 + + + + Dialog + + + + + 10 + 550 + 631 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + false + + + + + + 9 + 9 + 641 + 531 + + + + + + + Name + + + + + + + + + + Street + + + + + + + + + + City + + + + + + + + + + Town + + + + + + + + + + Post Code + + + + + + + + + + Region + + + + + + + + + + State + + + + + + + + + + Country + + + + + + + + + + Contact + + + + + + + + + + + + + + + + Add description item + + + ... + + + + :/add.png:/add.png + + + Ctrl+A + + + + + + + Edit description item + + + ... + + + + :/pencil.svg:/pencil.svg + + + Ctrl+E + + + + + + + Duplicate description item + + + ... + + + + :/images/svg/copy.svg:/images/svg/copy.svg + + + Ctrl+D + + + + + + + Delete Description item + + + ... + + + + :/remove.png:/remove.png + + + Ctrl+X + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + + + buttonBox + accepted() + CDlgMdfManufacturer + accept() + + + 325 + 565 + + + 329 + 295 + + + + + buttonBox + rejected() + CDlgMdfManufacturer + reject() + + + 325 + 565 + + + 329 + 295 + + + + + diff --git a/src/cfrmmdf.cpp b/src/cfrmmdf.cpp index b2eb5b10..1c180d03 100644 --- a/src/cfrmmdf.cpp +++ b/src/cfrmmdf.cpp @@ -48,6 +48,8 @@ #include "ui_cfrmmdf.h" #include "cdlgeditmap.h" +#include "cdlgmdfcontact.h" +#include "cdlgmdfmanufacturer.h" #include "cdlgmdfmodule.h" #include @@ -138,7 +140,7 @@ CFrmMdf::CFrmMdf(QWidget* parent, const char* path) ui->treeMDF->setEditTriggers(QAbstractItemView::NoEditTriggers); vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - spdlog::debug(std::string(tr("Node configuration module opended").toStdString())); + spdlog::debug(std::string(tr("Node configuration module opened").toStdString())); if (nullptr == path) { // spdlog::trace(std::string(tr("path is null").toStdString())); @@ -172,7 +174,7 @@ CFrmMdf::CFrmMdf(QWidget* parent, const char* path) connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openMdf())); // Open has been selected in the menu - Edit Module info - connect(ui->actionEdit_item, SIGNAL(triggered()), this, SLOT(editModuleData())); + connect(ui->actionEdit_item, SIGNAL(triggered()), this, SLOT(editData())); // Register row has been clicked. connect(ui->treeMDF, @@ -380,7 +382,13 @@ CFrmMdf::showMdfContextMenu(const QPoint& pos) break; case mdf_type_manufacturer: - menu->addAction(QString(tr("Manufacturer")), this, SLOT(loadSelectedMdf())); + // menu->addAction(QString(tr("Manufacturer")), this, SLOT(loadSelectedMdf())); + menu->addAction(QString(tr("Edit")), this, SLOT(editManufacturerData())); + break; + + case mdf_type_manufacturer_item: + // menu->addAction(QString(tr("Manufacturer")), this, SLOT(loadSelectedMdf())); + menu->addAction(QString(tr("Edit")), this, SLOT(editManufacturerData())); break; case mdf_type_file: @@ -904,6 +912,13 @@ CFrmMdf::loadMdf(void) QBrush greenBrush(QColor("green")); QBrush blueBrush(QColor("blue")); + QBrush redBrush(QColor("red")); + QBrush yellowBrush(QColor("yellow")); + QBrush cyanBrush(QColor("cyan")); + QBrush magentaBrush(QColor("magenta")); + QBrush greyBrush(QColor("grey")); + QBrush darkGreyBrush(QColor("darkGrey")); + QBrush darkMagentaBrush(QColor("darkMagenta")); QFont fontTopItem; fontTopItem.setBold(true); @@ -963,7 +978,9 @@ CFrmMdf::loadMdf(void) // * * * Manufacturer info * * * - QMdfTreeWidgetItem* pItemManufacturer = new QMdfTreeWidgetItem(pItemModule, mdf_type_manufacturer); + QMdfTreeWidgetItem* pItemManufacturer = new QMdfTreeWidgetItem(pItemModule, + m_mdf.getManufacturer(), + mdf_type_manufacturer); pItemManufacturer->setFont(0, fontTopItem); pItemManufacturer->setForeground(0, greenBrush); pItemManufacturer->setText(0, tr("Manufacturer")); @@ -973,115 +990,197 @@ CFrmMdf::loadMdf(void) if (nullptr != pManufacturer) { str = QString("Name: ") + m_mdf.getManufacturerName().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_name); pItem->setText(0, str); pItemModule->addChild(pItem); str = QString("Street: ") + m_mdf.getManufacturerStreetAddress().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_street); pItem->setText(0, str); pItemModule->addChild(pItem); str = QString("City: ") + m_mdf.getManufacturerCityAddress().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_city); pItem->setText(0, str); pItemModule->addChild(pItem); str = QString("Town: ") + m_mdf.getManufacturerTownAddress().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_town); pItem->setText(0, str); pItemModule->addChild(pItem); str = QString("Post Code: ") + m_mdf.getManufacturerPostCodeAddress().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_post_code); pItem->setText(0, str); pItemModule->addChild(pItem); str = QString("Region: ") + m_mdf.getManufacturerRegionAddress().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_region); pItem->setText(0, str); pItemModule->addChild(pItem); str = QString("State: ") + m_mdf.getManufacturerStateAddress().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_state); pItem->setText(0, str); pItemModule->addChild(pItem); str = QString("Country: ") + m_mdf.getManufacturerCountryAddress().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_generic_string); + pItem = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_manufacturer_item, + index_manufacturer_country); pItem->setText(0, str); pItemModule->addChild(pItem); + // * * * Manufacturer - email * * * + + QMdfTreeWidgetItem* pItemEmailHead = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_email); + // pItemEmailHead->setFont(0, fontTopItem); + // pItemEmailHead->setForeground(0, darkMagentaBrush); + pItemEmailHead->setText(0, tr("Email")); + pItemModule->addChild(pItemEmailHead); + index = 0; CMDF_Item* pItemEmail; do { pItemEmail = pManufacturer->getEmailObj(index++); if (nullptr != pItemEmail) { - str = QString("Email ") + QString::number(index) + ": " + pItemEmail->getName().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_email); - pItem->setText(0, str); - pItemModule->addChild(pItem); - fillDescriptionItems(pItem, pManufacturer->getEmailObj(), pManufacturer->getEmailObj()->getDescriptionMap()); - fillHelpUrlItems(pItem, pManufacturer->getEmailObj(), pManufacturer->getEmailObj()->getInfoUrlMap()); + // str = QString("Email ") + QString::number(index) + ": " + pItemEmail->getName().c_str(); + pItem = new QMdfTreeWidgetItem(pItemEmailHead, mdf_type_email_item); + pItem->setText(0, pItemEmail->getName().c_str()); + pItemEmailHead->addChild(pItem); + fillDescriptionItems(pItem, + pManufacturer->getEmailObj(), + pManufacturer->getEmailObj()->getDescriptionMap()); + fillHelpUrlItems(pItem, + pManufacturer->getEmailObj(), + pManufacturer->getEmailObj()->getInfoUrlMap()); } } while (nullptr != pItemEmail); + QMdfTreeWidgetItem* pItemPhoneHead = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_phone); + // pItemPhoneHead->setFont(0, fontTopItem); + // pItemEmailHead->setForeground(0, darkMagentaBrush); + pItemPhoneHead->setText(0, tr("Phone")); + pItemModule->addChild(pItemPhoneHead); + CMDF_Item* pItemPhone; index = 0; do { pItemPhone = pManufacturer->getPhoneObj(index++); if (nullptr != pItemPhone) { - str = QString("Phone ") + QString::number(index) + ": " + pItemPhone->getName().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_phone); - pItem->setText(0, str); - pItemModule->addChild(pItem); - fillDescriptionItems(pItem, pManufacturer->getPhoneObj(), pManufacturer->getPhoneObj()->getDescriptionMap()); - fillHelpUrlItems(pItem, pManufacturer->getPhoneObj(), pManufacturer->getPhoneObj()->getInfoUrlMap()); + // str = QString("Phone ") + QString::number(index) + ": " + pItemPhone->getName().c_str(); + pItem = new QMdfTreeWidgetItem(pItemPhoneHead, mdf_type_phone_item); + pItem->setText(0, pItemPhone->getName().c_str()); + pItemPhoneHead->addChild(pItem); + fillDescriptionItems(pItem, + pManufacturer->getPhoneObj(), + pManufacturer->getPhoneObj()->getDescriptionMap()); + fillHelpUrlItems(pItem, + pManufacturer->getPhoneObj(), + pManufacturer->getPhoneObj()->getInfoUrlMap()); } } while (nullptr != pItemPhone); + QMdfTreeWidgetItem* pItemFaxHead = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_fax); + // pItemFaxHead->setFont(0, fontTopItem); + // pItemEmailHead->setForeground(0, darkMagentaBrush); + pItemFaxHead->setText(0, tr("Fax")); + pItemModule->addChild(pItemFaxHead); + CMDF_Item* pItemFax; index = 0; do { pItemFax = pManufacturer->getFaxObj(index++); if (nullptr != pItemFax) { - str = QString("Fax ") + QString::number(index) + ": " + pItemFax->getName().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_fax); - pItem->setText(0, str); - pItemModule->addChild(pItem); - fillDescriptionItems(pItem, pManufacturer->getFaxObj(), pManufacturer->getFaxObj()->getDescriptionMap()); - fillHelpUrlItems(pItem, pManufacturer->getFaxObj(), pManufacturer->getFaxObj()->getInfoUrlMap()); + // str = QString("Fax ") + QString::number(index) + ": " + pItemFax->getName().c_str(); + pItem = new QMdfTreeWidgetItem(pItemFaxHead, mdf_type_fax_item); + pItem->setText(0, pItemFax->getName().c_str()); + pItemFaxHead->addChild(pItem); + fillDescriptionItems(pItem, + pManufacturer->getFaxObj(), + pManufacturer->getFaxObj()->getDescriptionMap()); + fillHelpUrlItems(pItem, + pManufacturer->getFaxObj(), + pManufacturer->getFaxObj()->getInfoUrlMap()); } } while (nullptr != pItemFax); + QMdfTreeWidgetItem* pItemWebHead = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_web); + // pItemWebHead->setFont(0, fontTopItem); + // pItemEmailHead->setForeground(0, darkMagentaBrush); + pItemWebHead->setText(0, tr("Web")); + pItemModule->addChild(pItemWebHead); + CMDF_Item* pItemWeb; index = 0; do { pItemWeb = pManufacturer->getWebObj(index++); if (nullptr != pItemWeb) { - str = QString("Web ") + QString::number(index) + ": " + pItemWeb->getName().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_web); - pItem->setText(0, str); - pItemModule->addChild(pItem); - fillDescriptionItems(pItem, pManufacturer->getWebObj(), pManufacturer->getWebObj()->getDescriptionMap()); - fillHelpUrlItems(pItem, pManufacturer->getWebObj(), pManufacturer->getWebObj()->getInfoUrlMap()); + // str = QString("Web ") + QString::number(index) + ": " + pItemWeb->getName().c_str(); + pItem = new QMdfTreeWidgetItem(pItemWebHead, mdf_type_web); + pItem->setText(0, pItemWeb->getName().c_str()); + pItemWebHead->addChild(pItem); + fillDescriptionItems(pItem, + pManufacturer->getWebObj(), + pManufacturer->getWebObj()->getDescriptionMap()); + fillHelpUrlItems(pItem, + pManufacturer->getWebObj(), + pManufacturer->getWebObj()->getInfoUrlMap()); } } while (nullptr != pItemWeb); + QMdfTreeWidgetItem* pItemSocialHead = new QMdfTreeWidgetItem(pItemManufacturer, + m_mdf.getManufacturer(), + mdf_type_social); + // pItemSocialHead->setFont(0, fontTopItem); + // pItemEmailHead->setForeground(0, darkMagentaBrush); + pItemSocialHead->setText(0, tr("Social")); + pItemModule->addChild(pItemSocialHead); + CMDF_Item* pItemSocial; index = 0; do { pItemSocial = pManufacturer->getSocialObj(index++); if (nullptr != pItemSocial) { - str = QString("Social ") + QString::number(index) + ": " + pItemSocial->getName().c_str(); - pItem = new QMdfTreeWidgetItem(pItemManufacturer, mdf_type_social); - pItem->setText(0, str); - pItemModule->addChild(pItem); + // str = QString("Social ") + QString::number(index) + ": " + pItemSocial->getName().c_str(); + pItem = new QMdfTreeWidgetItem(pItemSocialHead, mdf_type_social_item); + pItem->setText(0, pItemSocial->getName().c_str()); + pItemSocialHead->addChild(pItem); fillDescriptionItems(pItem, pManufacturer->getSocialObj(), pManufacturer->getSocialObj()->getDescriptionMap()); fillHelpUrlItems(pItem, pManufacturer->getSocialObj(), pManufacturer->getSocialObj()->getInfoUrlMap()); } @@ -2344,6 +2443,186 @@ CFrmMdf::deleteMdfWidgetChildItems(QMdfTreeWidgetItem* pItem, mdf_record_type ty return cnt; } +/////////////////////////////////////////////////////////////////////////////// +// editData +// + +void +CFrmMdf::editData() +{ + QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); + + switch (pItem->getObjectType() /*pItem->type() - QTreeWidgetItem::UserType*/) { + case mdf_type_unknown: + + break; + + case mdf_type_redirection: + + break; + + case mdf_type_mdf: + editModuleData(); + break; + + case mdf_type_mdf_item: + editModuleData(); + break; + + case mdf_type_value: + break; + + case mdf_type_bit: + break; + + case mdf_type_bit_item: + break; + + case mdf_type_register_page: + break; + + case mdf_type_register: + break; + + case mdf_type_register_item: + break; + + case mdf_type_remotevar: + break; + + case mdf_type_remotevar_item: + break; + + case mdf_type_action_param: + break; + + case mdf_type_action: + break; + + case mdf_type_action_item: + break; + + case mdf_type_decision_matrix: + break; + + case mdf_type_event_data: + break; + + case mdf_type_event_data_item: + break; + + case mdf_type_event: + break; + + case mdf_type_event_item: + break; + + case mdf_type_value_item: + break; + + case mdf_type_bootloader: + break; + + case mdf_type_alarm: + break; + + case mdf_type_address: + break; + + case mdf_type_manufacturer: + editManufacturerData(); + break; + + case mdf_type_manufacturer_item: + editManufacturerData(); + break; + + case mdf_type_file: + break; + + case mdf_type_picture: + break; + + case mdf_type_picture_item: + break; + + case mdf_type_video: + break; + + case mdf_type_video_item: + break; + + case mdf_type_firmware: + break; + + case mdf_type_firmware_item: + break; + + case mdf_type_driver: + break; + + case mdf_type_driver_item: + break; + + case mdf_type_setup: + break; + + case mdf_type_setup_item: + break; + + case mdf_type_manual: + break; + + case mdf_type_manual_item: + break; + + case mdf_type_email: + break; + + case mdf_type_phone: + break; + + case mdf_type_fax: + break; + + case mdf_type_web: + break; + + case mdf_type_social: + break; + + case mdf_type_generic_string: + break; + + case mdf_type_generic_number: + break; + + case mdf_type_generic_url: + break; + + case mdf_type_generic_date: + break; + + case mdf_type_generic_access: + break; + + case mdf_type_generic_description: + break; + + case mdf_type_generic_description_item: + break; + + case mdf_type_generic_help_url: + break; + + case mdf_type_generic_help_url_item: + break; + + default: + break; + } +} + /////////////////////////////////////////////////////////////////////////////// // editModuleData // @@ -2490,13 +2769,13 @@ CFrmMdf::editModuleData() } while (mdf_type_mdf_item == piter->getObjectType()); // Find module descriptions - int n = piter->childCount(); - if (mdf_type_generic_description == piter->getObjectType()) { - piter->setExpanded(false); - n = ui->treeMDF->indexOfTopLevelItem(piter); - n = ui->treeMDF->topLevelItemCount(); - n = n + 1; - } + // int n = piter->childCount(); + // if (mdf_type_generic_description == piter->getObjectType()) { + // piter->setExpanded(false); + // n = ui->treeMDF->indexOfTopLevelItem(piter); + // n = ui->treeMDF->topLevelItemCount(); + // n = n + 1; + // } deleteMdfWidgetChildItems(pItemDescription, mdf_type_generic_description_item); fillDescriptionItems(pItemDescription, &m_mdf, m_mdf.getModuleDescriptionMap(), true); @@ -2514,9 +2793,9 @@ CFrmMdf::editModuleData() void CFrmMdf::editDescription() { - QString selstr = ""; + QString selstr = ""; QMdfTreeWidgetItem* pItemDescription = nullptr; // Pointer to description top item - QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); + QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); // Item must be selected if (nullptr == pItem) { @@ -2548,7 +2827,7 @@ CFrmMdf::editDescription() } else if (mdf_type_generic_description_item == pItem->getObjectType()) { pItemDescription = (QMdfTreeWidgetItem*)pItem->parent(); - selstr = pItem->text(0).split('_').first().left(2); + selstr = pItem->text(0).split('_').first().left(2); } else { int ret = QMessageBox::critical(this, tr("MDF module edit"), tr("Invalid module top item object type")); @@ -2568,7 +2847,6 @@ CFrmMdf::editDescription() fillDescriptionItems(pItemDescription, &m_mdf, m_mdf.getModuleDescriptionMap(), true); QMdfTreeWidgetItem* piter = nullptr; - } } @@ -2579,9 +2857,9 @@ CFrmMdf::editDescription() void CFrmMdf::editInfoUrl() { - QString selstr = ""; + QString selstr = ""; QMdfTreeWidgetItem* pItemInfoUrl = nullptr; // Pointer to info url top item - QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); + QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); // Item must be selected if (nullptr == pItem) { @@ -2597,14 +2875,14 @@ CFrmMdf::editInfoUrl() } // Must be correct object type - if ((mdf_type_generic_help_url!= pItem->getObjectType()) && (mdf_type_generic_help_url_item != pItem->getObjectType())) { + if ((mdf_type_generic_help_url != pItem->getObjectType()) && (mdf_type_generic_help_url_item != pItem->getObjectType())) { int ret = QMessageBox::critical(this, tr("MDF module edit"), tr("This is not a module help url item")); spdlog::error("MDF module edit - Not a module item"); return; } // Set pointer to module top item - if (mdf_type_generic_help_url== pItem->getObjectType()) { + if (mdf_type_generic_help_url == pItem->getObjectType()) { pItemInfoUrl = pItem; @@ -2613,7 +2891,7 @@ CFrmMdf::editInfoUrl() } else if (mdf_type_generic_help_url_item == pItem->getObjectType()) { pItemInfoUrl = (QMdfTreeWidgetItem*)pItem->parent(); - selstr = pItem->text(0).split('_').first().left(2); + selstr = pItem->text(0).split('_').first().left(2); } else { int ret = QMessageBox::critical(this, tr("MDF module edit"), tr("Invalid module top item object type")); @@ -2632,8 +2910,118 @@ CFrmMdf::editInfoUrl() // Update Module items deleteMdfWidgetChildItems(pItemInfoUrl, mdf_type_generic_help_url_item); fillHelpUrlItems(pItemInfoUrl, &m_mdf, m_mdf.getModuleHelpUrlMap(), true); + + QMdfTreeWidgetItem* piter = nullptr; + } +} + +/////////////////////////////////////////////////////////////////////////////// +// editManufacturerData +// + +void +CFrmMdf::editManufacturerData() +{ + QMdfTreeWidgetItem* pItemManufacturer = nullptr; // Pointer to module top item + QMdfTreeWidgetItem* pItemEmail = nullptr; // Pointer to description top item + QMdfTreeWidgetItem* pItemWeb = nullptr; // Pointer to info URL top item + QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); + + // Item must be selected + if (nullptr == pItem) { + int ret = QMessageBox::critical(this, tr("MDF module edit"), tr("No MDF module item selected")); + return; + } + + // Must have an object + if (nullptr == pItem->getObject()) { + int ret = QMessageBox::critical(this, tr("MDF module edit"), tr("Internal error: Invalid module object")); + spdlog::error("MDF module edit - object has nullptr"); + return; + } + + // Must be correct object type + if ((mdf_type_manufacturer != pItem->getObjectType()) && (mdf_type_manufacturer_item != pItem->getObjectType())) { + int ret = QMessageBox::critical(this, tr("MDF manufacturer edit"), tr("This is not a manufacturer item")); + spdlog::error("MDF manufacturer edit - Not a manufacturer item"); + return; + } + + // Set pointer to module top item + if (mdf_type_manufacturer == pItem->getObjectType()) { + + pItemManufacturer = pItem; + + // Make sure it is expanded + pItem->setExpanded(true); + } + else if (mdf_type_manufacturer_item == pItem->getObjectType()) { + pItemManufacturer = (QMdfTreeWidgetItem*)pItem->parent(); + } + else { + int ret = QMessageBox::critical(this, tr("MDF manufacturer edit"), tr("Invalid manufacturer top item object type")); + spdlog::error("MDF manufacturer edit - Invalid manufacturer top item object type"); + return; + } + + CDlgMdfManufacturer dlg(this); + dlg.initDialogData(pItem->getObject(), static_cast(pItem->getElementIndex())); + + if (QDialog::Accepted == dlg.exec()) { + + // Update Module items + CMDF_Manufacturer *pmanufacturer = (CMDF_Manufacturer*)pItem->getObject(); + pmanufacturer->setName(dlg.getName().toStdString()); + pmanufacturer->getAddressObj()->setStreet(dlg.getStreet().toStdString()); + pmanufacturer->getAddressObj()->setTown(dlg.getTown().toStdString()); + pmanufacturer->getAddressObj()->setCity(dlg.getCity().toStdString()); + pmanufacturer->getAddressObj()->setPostCode(dlg.getPostCode().toStdString()); + pmanufacturer->getAddressObj()->setState(dlg.getState().toStdString()); + pmanufacturer->getAddressObj()->setRegion(dlg.getRegion().toStdString()); + pmanufacturer->getAddressObj()->setCountry(dlg.getCountry().toStdString()); + QMdfTreeWidgetItem* piter = nullptr; + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItemManufacturer); + do { + + switch (piter->getElementIndex()) { + + case index_manufacturer_name: + piter->setText(0, PREFIX_MDF_MANUFACTURER_NAME + pmanufacturer->getName().c_str()); + break; + + case index_manufacturer_street: + piter->setText(0, PREFIX_MDF_MANUFACTURER_STREET + pmanufacturer->getAddressObj()->getStreet().c_str()); + break; + + case index_manufacturer_town: + piter->setText(0, PREFIX_MDF_MANUFACTURER_TOWN + pmanufacturer->getAddressObj()->getTown().c_str()); + break; + case index_manufacturer_city: + piter->setText(0, PREFIX_MDF_MANUFACTURER_CITY + pmanufacturer->getAddressObj()->getCity().c_str()); + break; + + case index_manufacturer_post_code: + piter->setText(0, PREFIX_MDF_MANUFACTURER_POST_CODE + pmanufacturer->getAddressObj()->getPostCode().c_str()); + break; + + case index_manufacturer_state: + piter->setText(0, PREFIX_MDF_MANUFACTURER_STATE + pmanufacturer->getAddressObj()->getState().c_str()); + break; + + case index_manufacturer_region: + piter->setText(0, PREFIX_MDF_MANUFACTURER_REGION + pmanufacturer->getAddressObj()->getRegion().c_str()); + break; + + case index_manufacturer_country: + piter->setText(0, PREFIX_MDF_MANUFACTURER_COUNTRY + pmanufacturer->getAddressObj()->getCountry().c_str()); + break; + } + + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(piter); + + } while (mdf_type_manufacturer_item == piter->getObjectType()); } } \ No newline at end of file diff --git a/src/cfrmmdf.h b/src/cfrmmdf.h index d5eec576..279f790a 100644 --- a/src/cfrmmdf.h +++ b/src/cfrmmdf.h @@ -181,6 +181,9 @@ public slots: /// Item has been double clicked void onItemDoubleClicked(QTreeWidgetItem* item, int column); + /// Edit MDF data + void editData(void); + /// Edit MDF module data void editModuleData(void); @@ -190,6 +193,9 @@ public slots: /// Edit MDF info URL's void editInfoUrl(void); + /// Edit MDF manufacturer data + void editManufacturerData(void); + /*! Fill in data from info map as children to parent item diff --git a/src/qdarkstyle/theme/style.qrc.depends b/src/qdarkstyle/theme/style.qrc.depends new file mode 100644 index 00000000..d74dee00 --- /dev/null +++ b/src/qdarkstyle/theme/style.qrc.depends @@ -0,0 +1,217 @@ + + + + rc/.keep + rc/arrow_down.png + rc/arrow_down@2x.png + rc/arrow_down_disabled.png + rc/arrow_down_disabled@2x.png + rc/arrow_down_focus.png + rc/arrow_down_focus@2x.png + rc/arrow_down_pressed.png + rc/arrow_down_pressed@2x.png + rc/arrow_left.png + rc/arrow_left@2x.png + rc/arrow_left_disabled.png + rc/arrow_left_disabled@2x.png + rc/arrow_left_focus.png + rc/arrow_left_focus@2x.png + rc/arrow_left_pressed.png + rc/arrow_left_pressed@2x.png + rc/arrow_right.png + rc/arrow_right@2x.png + rc/arrow_right_disabled.png + rc/arrow_right_disabled@2x.png + rc/arrow_right_focus.png + rc/arrow_right_focus@2x.png + rc/arrow_right_pressed.png + rc/arrow_right_pressed@2x.png + rc/arrow_up.png + rc/arrow_up@2x.png + rc/arrow_up_disabled.png + rc/arrow_up_disabled@2x.png + rc/arrow_up_focus.png + rc/arrow_up_focus@2x.png + rc/arrow_up_pressed.png + rc/arrow_up_pressed@2x.png + rc/base_icon.png + rc/base_icon@2x.png + rc/base_icon_disabled.png + rc/base_icon_disabled@2x.png + rc/base_icon_focus.png + rc/base_icon_focus@2x.png + rc/base_icon_pressed.png + rc/base_icon_pressed@2x.png + rc/branch_closed.png + rc/branch_closed@2x.png + rc/branch_closed_disabled.png + rc/branch_closed_disabled@2x.png + rc/branch_closed_focus.png + rc/branch_closed_focus@2x.png + rc/branch_closed_pressed.png + rc/branch_closed_pressed@2x.png + rc/branch_end.png + rc/branch_end@2x.png + rc/branch_end_disabled.png + rc/branch_end_disabled@2x.png + rc/branch_end_focus.png + rc/branch_end_focus@2x.png + rc/branch_end_pressed.png + rc/branch_end_pressed@2x.png + rc/branch_line.png + rc/branch_line@2x.png + rc/branch_line_disabled.png + rc/branch_line_disabled@2x.png + rc/branch_line_focus.png + rc/branch_line_focus@2x.png + rc/branch_line_pressed.png + rc/branch_line_pressed@2x.png + rc/branch_more.png + rc/branch_more@2x.png + rc/branch_more_disabled.png + rc/branch_more_disabled@2x.png + rc/branch_more_focus.png + rc/branch_more_focus@2x.png + rc/branch_more_pressed.png + rc/branch_more_pressed@2x.png + rc/branch_open.png + rc/branch_open@2x.png + rc/branch_open_disabled.png + rc/branch_open_disabled@2x.png + rc/branch_open_focus.png + rc/branch_open_focus@2x.png + rc/branch_open_pressed.png + rc/branch_open_pressed@2x.png + rc/checkbox_checked.png + rc/checkbox_checked@2x.png + rc/checkbox_checked_disabled.png + rc/checkbox_checked_disabled@2x.png + rc/checkbox_checked_focus.png + rc/checkbox_checked_focus@2x.png + rc/checkbox_checked_pressed.png + rc/checkbox_checked_pressed@2x.png + rc/checkbox_indeterminate.png + rc/checkbox_indeterminate@2x.png + rc/checkbox_indeterminate_disabled.png + rc/checkbox_indeterminate_disabled@2x.png + rc/checkbox_indeterminate_focus.png + rc/checkbox_indeterminate_focus@2x.png + rc/checkbox_indeterminate_pressed.png + rc/checkbox_indeterminate_pressed@2x.png + rc/checkbox_unchecked.png + rc/checkbox_unchecked@2x.png + rc/checkbox_unchecked_disabled.png + rc/checkbox_unchecked_disabled@2x.png + rc/checkbox_unchecked_focus.png + rc/checkbox_unchecked_focus@2x.png + rc/checkbox_unchecked_pressed.png + rc/checkbox_unchecked_pressed@2x.png + rc/line_horizontal.png + rc/line_horizontal@2x.png + rc/line_horizontal_disabled.png + rc/line_horizontal_disabled@2x.png + rc/line_horizontal_focus.png + rc/line_horizontal_focus@2x.png + rc/line_horizontal_pressed.png + rc/line_horizontal_pressed@2x.png + rc/line_vertical.png + rc/line_vertical@2x.png + rc/line_vertical_disabled.png + rc/line_vertical_disabled@2x.png + rc/line_vertical_focus.png + rc/line_vertical_focus@2x.png + rc/line_vertical_pressed.png + rc/line_vertical_pressed@2x.png + rc/radio_checked.png + rc/radio_checked@2x.png + rc/radio_checked_disabled.png + rc/radio_checked_disabled@2x.png + rc/radio_checked_focus.png + rc/radio_checked_focus@2x.png + rc/radio_checked_pressed.png + rc/radio_checked_pressed@2x.png + rc/radio_unchecked.png + rc/radio_unchecked@2x.png + rc/radio_unchecked_disabled.png + rc/radio_unchecked_disabled@2x.png + rc/radio_unchecked_focus.png + rc/radio_unchecked_focus@2x.png + rc/radio_unchecked_pressed.png + rc/radio_unchecked_pressed@2x.png + rc/toolbar_move_horizontal.png + rc/toolbar_move_horizontal@2x.png + rc/toolbar_move_horizontal_disabled.png + rc/toolbar_move_horizontal_disabled@2x.png + rc/toolbar_move_horizontal_focus.png + rc/toolbar_move_horizontal_focus@2x.png + rc/toolbar_move_horizontal_pressed.png + rc/toolbar_move_horizontal_pressed@2x.png + rc/toolbar_move_vertical.png + rc/toolbar_move_vertical@2x.png + rc/toolbar_move_vertical_disabled.png + rc/toolbar_move_vertical_disabled@2x.png + rc/toolbar_move_vertical_focus.png + rc/toolbar_move_vertical_focus@2x.png + rc/toolbar_move_vertical_pressed.png + rc/toolbar_move_vertical_pressed@2x.png + rc/toolbar_separator_horizontal.png + rc/toolbar_separator_horizontal@2x.png + rc/toolbar_separator_horizontal_disabled.png + rc/toolbar_separator_horizontal_disabled@2x.png + rc/toolbar_separator_horizontal_focus.png + rc/toolbar_separator_horizontal_focus@2x.png + rc/toolbar_separator_horizontal_pressed.png + rc/toolbar_separator_horizontal_pressed@2x.png + rc/toolbar_separator_vertical.png + rc/toolbar_separator_vertical@2x.png + rc/toolbar_separator_vertical_disabled.png + rc/toolbar_separator_vertical_disabled@2x.png + rc/toolbar_separator_vertical_focus.png + rc/toolbar_separator_vertical_focus@2x.png + rc/toolbar_separator_vertical_pressed.png + rc/toolbar_separator_vertical_pressed@2x.png + rc/transparent.png + rc/transparent@2x.png + rc/transparent_disabled.png + rc/transparent_disabled@2x.png + rc/transparent_focus.png + rc/transparent_focus@2x.png + rc/transparent_pressed.png + rc/transparent_pressed@2x.png + rc/window_close.png + rc/window_close@2x.png + rc/window_close_disabled.png + rc/window_close_disabled@2x.png + rc/window_close_focus.png + rc/window_close_focus@2x.png + rc/window_close_pressed.png + rc/window_close_pressed@2x.png + rc/window_grip.png + rc/window_grip@2x.png + rc/window_grip_disabled.png + rc/window_grip_disabled@2x.png + rc/window_grip_focus.png + rc/window_grip_focus@2x.png + rc/window_grip_pressed.png + rc/window_grip_pressed@2x.png + rc/window_minimize.png + rc/window_minimize@2x.png + rc/window_minimize_disabled.png + rc/window_minimize_disabled@2x.png + rc/window_minimize_focus.png + rc/window_minimize_focus@2x.png + rc/window_minimize_pressed.png + rc/window_minimize_pressed@2x.png + rc/window_undock.png + rc/window_undock@2x.png + rc/window_undock_disabled.png + rc/window_undock_disabled@2x.png + rc/window_undock_focus.png + rc/window_undock_focus@2x.png + rc/window_undock_pressed.png + rc/window_undock_pressed@2x.png + + + style.qss + +