From 52e816794dbfa37518dba979d7089780897690db Mon Sep 17 00:00:00 2001 From: Ake Hedman Date: Tue, 7 Nov 2023 18:11:18 +0100 Subject: [PATCH] File handling in place --- .vscode/settings.json | 3 +- src/cdlgmdffile.cpp | 453 ++++++++++++++++---- src/cdlgmdffile.h | 19 +- src/cdlgmdffilepicture.cpp | 3 +- src/cfrmmdf.cpp | 824 ++++++++++++++++++++++++------------- src/cfrmmdf.h | 74 ++++ 6 files changed, 1013 insertions(+), 363 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 731281dc..7c89d872 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -74,7 +74,8 @@ "regex": "cpp", "any": "cpp", "numbers": "cpp", - "span": "cpp" + "span": "cpp", + "bitset": "cpp" }, "python.pythonPath": "/usr/bin/python3", "files.exclude": { diff --git a/src/cdlgmdffile.cpp b/src/cdlgmdffile.cpp index 34220e2c..1e43dde9 100644 --- a/src/cdlgmdffile.cpp +++ b/src/cdlgmdffile.cpp @@ -35,12 +35,12 @@ #include -#include "cdlgmdffilepicture.h" -#include "cdlgmdffilevideo.h" -#include "cdlgmdffilefirmware.h" #include "cdlgmdffiledriver.h" -#include "cdlgmdffilesetup.h" +#include "cdlgmdffilefirmware.h" #include "cdlgmdffilemanual.h" +#include "cdlgmdffilepicture.h" +#include "cdlgmdffilesetup.h" +#include "cdlgmdffilevideo.h" #include "cdlgmdffile.h" #include "ui_cdlgmdffile.h" @@ -55,6 +55,13 @@ #include #include +const char CDlgMdfFile:: pre_str_picture[] = "Picture: "; +const char CDlgMdfFile:: pre_str_video[] = "Video: "; +const char CDlgMdfFile:: pre_str_firmware[] = "Firmware: "; +const char CDlgMdfFile:: pre_str_driver[] = "Driver: "; +const char CDlgMdfFile:: pre_str_setup[] = "Setup script: "; +const char CDlgMdfFile:: pre_str_manual[] = "Manual: "; + /////////////////////////////////////////////////////////////////////////////// // CTor // @@ -122,7 +129,7 @@ CDlgMdfFile::initDialogData(const CMDF_Object* pmdfobj, mdf_record_type type, in do { pPictureObj = m_pmdf->getPictureObj(index); if (nullptr != pPictureObj) { - ui->listFile->addItem(QString("Picture %1 - ").arg(index) + pPictureObj->getName().c_str()); + ui->listFile->addItem(QString("Picture: - ") + pPictureObj->getName().c_str()); } index++; @@ -149,7 +156,7 @@ CDlgMdfFile::initDialogData(const CMDF_Object* pmdfobj, mdf_record_type type, in do { pVideoObj = m_pmdf->getVideoObj(index); if (nullptr != pVideoObj) { - ui->listFile->addItem(QString("Video %1 - ").arg(index) + pVideoObj->getName().c_str()); + ui->listFile->addItem(QString("Video - ") + pVideoObj->getName().c_str()); } index++; @@ -176,7 +183,7 @@ CDlgMdfFile::initDialogData(const CMDF_Object* pmdfobj, mdf_record_type type, in do { pFirmwareObj = m_pmdf->getFirmwareObj(index); if (nullptr != pFirmwareObj) { - ui->listFile->addItem(QString("Firmware %1 - ").arg(index) + pFirmwareObj->getName().c_str()); + ui->listFile->addItem(QString("Firmware - ") + pFirmwareObj->getName().c_str()); } index++; @@ -203,7 +210,7 @@ CDlgMdfFile::initDialogData(const CMDF_Object* pmdfobj, mdf_record_type type, in do { pDriverObj = m_pmdf->getDriverObj(index); if (nullptr != pDriverObj) { - ui->listFile->addItem(QString("Driver %1 - ").arg(index) + pDriverObj->getName().c_str()); + ui->listFile->addItem(QString("Driver - ") + pDriverObj->getName().c_str()); } index++; @@ -230,7 +237,7 @@ CDlgMdfFile::initDialogData(const CMDF_Object* pmdfobj, mdf_record_type type, in do { pSetupObj = m_pmdf->getSetupObj(index); if (nullptr != pSetupObj) { - ui->listFile->addItem(QString("Setup %1 - ").arg(index) + pSetupObj->getName().c_str()); + ui->listFile->addItem(QString("Setup - ") + pSetupObj->getName().c_str()); } index++; @@ -257,7 +264,7 @@ CDlgMdfFile::initDialogData(const CMDF_Object* pmdfobj, mdf_record_type type, in do { pManualObj = m_pmdf->getManualObj(index); if (nullptr != pManualObj) { - ui->listFile->addItem(QString("Manual %1 - ").arg(index) + pManualObj->getName().c_str()); + ui->listFile->addItem(QString("Manual - ") + pManualObj->getName().c_str()); } index++; @@ -327,7 +334,7 @@ CDlgMdfFile::initDialogData(const CMDF_Object* pmdfobj, mdf_record_type type, in void CDlgMdfFile::setInitialFocus(void) { - // ui->editGuid->setFocus(); + //ui->editName->setFocus(); } /////////////////////////////////////////////////////////////////////////////// @@ -340,66 +347,119 @@ CDlgMdfFile::addFileItem(void) switch (m_type) { case mdf_type_picture: { - CMDF_Picture *pobj = m_pmdf->getPictureObj(ui->listFile->currentRow()); + + CMDF_Picture* pobjnew = new CMDF_Picture(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + CDlgMdfFilePicture dlg(this); - dlg.initDialogData(pobj /*, &selstr*/); + dlg.initDialogData(pobjnew); if (QDialog::Accepted == dlg.exec()) { - // ui->listDescription->clear(); - // fillDescription(); + m_pmdf->getPictureObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_picture) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; } } break; case mdf_type_video: { - CMDF_Video *pobj = m_pmdf->getVideoObj(ui->listFile->currentRow()); + + CMDF_Video* pobjnew = new CMDF_Video(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + + CMDF_Video* pobj = m_pmdf->getVideoObj(ui->listFile->currentRow()); CDlgMdfFileVideo dlg(this); - dlg.initDialogData(pobj /*, &selstr*/); + dlg.initDialogData(pobjnew); if (QDialog::Accepted == dlg.exec()) { - // ui->listDescription->clear(); - // fillDescription(); + m_pmdf->getVideoObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_video) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; } } break; case mdf_type_firmware: { - CMDF_Firmware *pobj = m_pmdf->getFirmwareObj(ui->listFile->currentRow()); + + CMDF_Firmware* pobjnew = new CMDF_Firmware(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + CDlgMdfFileFirmware dlg(this); - dlg.initDialogData(pobj /*, &selstr*/); + dlg.initDialogData(pobjnew); if (QDialog::Accepted == dlg.exec()) { - // ui->listDescription->clear(); - // fillDescription(); + m_pmdf->getFirmwareObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_firmware) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; } } break; - case mdf_type_driver: { - CMDF_Driver *pobj = m_pmdf->getDriverObj(ui->listFile->currentRow()); + + CMDF_Driver* pobjnew = new CMDF_Driver(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + CDlgMdfFileDriver dlg(this); - dlg.initDialogData(pobj /*, &selstr*/); + dlg.initDialogData(pobjnew); if (QDialog::Accepted == dlg.exec()) { - // ui->listDescription->clear(); - // fillDescription(); + m_pmdf->getDriverObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_driver) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; } } break; case mdf_type_setup: { - CMDF_Setup *pobj = m_pmdf->getSetupObj(ui->listFile->currentRow()); + + CMDF_Setup* pobjnew = new CMDF_Setup(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + CDlgMdfFileSetup dlg(this); - dlg.initDialogData(pobj /*, &selstr*/); + dlg.initDialogData(pobjnew); if (QDialog::Accepted == dlg.exec()) { - // ui->listDescription->clear(); - // fillDescription(); + m_pmdf->getSetupObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_setup) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; } } break; case mdf_type_manual: { - CMDF_Manual *pobj = m_pmdf->getManualObj(ui->listFile->currentRow()); + + CMDF_Manual* pobjnew = new CMDF_Manual(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + CDlgMdfFileManual dlg(this); - dlg.initDialogData(pobj /*, &selstr*/); + dlg.initDialogData(pobjnew); if (QDialog::Accepted == dlg.exec()) { - // ui->listDescription->clear(); - // fillDescription(); + m_pmdf->getManualObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_manual) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; } } break; - } } @@ -410,25 +470,72 @@ CDlgMdfFile::addFileItem(void) void CDlgMdfFile::editFileItem(void) { - // if (-1 != ui->listDescription->currentRow()) { + if (-1 != ui->listFile->currentRow()) { - // // Save the row - // int idx = ui->listDescription->currentRow(); + // Save the row + int idx = ui->listFile->currentRow(); - // QListWidgetItem* pitem = ui->listDescription->currentItem(); - // QString selstr = pitem->text().split('_').first().left(2); + switch (m_type) { - // CDlgMdfDescription dlg(this); - // dlg.initDialogData(m_pitemobj->getMapDescription(), &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); - // } + case mdf_type_picture: { + CMDF_Picture* pobj = m_pmdf->getPictureObj(ui->listFile->currentRow()); + CDlgMdfFilePicture dlg(this); + dlg.initDialogData(pobj /*, &selstr*/); + if (QDialog::Accepted == dlg.exec()) { + ui->listFile->currentItem()->setText(QString(pre_str_picture) + QString("- ") + pobj->getName().c_str()); + } + } break; + + case mdf_type_video: { + CMDF_Video* pobj = m_pmdf->getVideoObj(ui->listFile->currentRow()); + CDlgMdfFileVideo dlg(this); + dlg.initDialogData(pobj /*, &selstr*/); + if (QDialog::Accepted == dlg.exec()) { + ui->listFile->currentItem()->setText(QString(pre_str_video) + QString(" ") + pobj->getName().c_str()); + } + } break; + + case mdf_type_firmware: { + CMDF_Firmware* pobj = m_pmdf->getFirmwareObj(ui->listFile->currentRow()); + CDlgMdfFileFirmware dlg(this); + dlg.initDialogData(pobj /*, &selstr*/); + if (QDialog::Accepted == dlg.exec()) { + ui->listFile->currentItem()->setText(QString(pre_str_firmware) + QString(" ") + pobj->getName().c_str()); + } + } break; + + case mdf_type_driver: { + CMDF_Driver* pobj = m_pmdf->getDriverObj(ui->listFile->currentRow()); + CDlgMdfFileDriver dlg(this); + dlg.initDialogData(pobj /*, &selstr*/); + if (QDialog::Accepted == dlg.exec()) { + ui->listFile->currentItem()->setText(QString(pre_str_driver) + QString(" ") + pobj->getName().c_str()); + } + } break; + + case mdf_type_setup: { + CMDF_Setup* pobj = m_pmdf->getSetupObj(ui->listFile->currentRow()); + CDlgMdfFileSetup dlg(this); + dlg.initDialogData(pobj /*, &selstr*/); + if (QDialog::Accepted == dlg.exec()) { + // ui->listDescription->clear(); + // fillDescription(); + } + } break; + + case mdf_type_manual: { + CMDF_Manual* pobj = m_pmdf->getManualObj(ui->listFile->currentRow()); + CDlgMdfFileManual dlg(this); + dlg.initDialogData(pobj /*, &selstr*/); + if (QDialog::Accepted == dlg.exec()) { + ui->listFile->currentItem()->setText(QString(pre_str_manual) + QString(" ") + pobj->getName().c_str()); + } + } break; + } + } + else { + QMessageBox::warning(this, tr(APPNAME), tr("An item must be selected"), QMessageBox::Ok); + } } /////////////////////////////////////////////////////////////////////////////// @@ -438,17 +545,175 @@ CDlgMdfFile::editFileItem(void) void CDlgMdfFile::dupFileItem(void) { - // if (-1 != ui->listDescription->currentRow()) { - // CDlgMdfDescription dlg(this); - // dlg.initDialogData(m_pitemobj->getMapDescription()); - // if (QDialog::Accepted == dlg.exec()) { - // ui->listDescription->clear(); - // fillDescription(); - // } - // } - // else { - // QMessageBox::warning(this, tr("vscpworks+"), tr("An item must be selected"), QMessageBox::Ok); - // } + if (-1 != ui->listFile->currentRow()) { + + // Save the row + int idx = ui->listFile->currentRow(); + + switch (m_type) { + + case mdf_type_picture: { + + CMDF_Picture* pobj = m_pmdf->getPictureObj(ui->listFile->currentRow()); + if (nullptr == pobj) { + QMessageBox::warning(this, tr(APPNAME), tr("Invalid object"), QMessageBox::Ok); + return; + } + + CMDF_Picture* pobjnew = new CMDF_Picture(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + + *pobjnew = *pobj; + + CDlgMdfFilePicture dlg(this); + dlg.initDialogData(pobjnew); + if (QDialog::Accepted == dlg.exec()) { + m_pmdf->getPictureObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_picture) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; + } + + } break; + + case mdf_type_video: { + CMDF_Video* pobj = m_pmdf->getVideoObj(ui->listFile->currentRow()); + if (nullptr == pobj) { + QMessageBox::warning(this, tr(APPNAME), tr("Invalid object"), QMessageBox::Ok); + return; + } + + CMDF_Video* pobjnew = new CMDF_Video(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + + *pobjnew = *pobj; + + CDlgMdfFileVideo dlg(this); + dlg.initDialogData(pobjnew); + if (QDialog::Accepted == dlg.exec()) { + m_pmdf->getVideoObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_video) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; + } + } break; + + case mdf_type_firmware: { + CMDF_Firmware* pobj = m_pmdf->getFirmwareObj(ui->listFile->currentRow()); + if (nullptr == pobj) { + QMessageBox::warning(this, tr(APPNAME), tr("Invalid object"), QMessageBox::Ok); + return; + } + + CMDF_Firmware* pobjnew = new CMDF_Firmware(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + + *pobjnew = *pobj; + + CDlgMdfFileFirmware dlg(this); + dlg.initDialogData(pobjnew); + if (QDialog::Accepted == dlg.exec()) { + m_pmdf->getFirmwareObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_firmware) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; + } + } break; + + case mdf_type_driver: { + CMDF_Driver* pobj = m_pmdf->getDriverObj(ui->listFile->currentRow()); + if (nullptr == pobj) { + QMessageBox::warning(this, tr(APPNAME), tr("Invalid object"), QMessageBox::Ok); + return; + } + + CMDF_Driver* pobjnew = new CMDF_Driver(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + + *pobjnew = *pobj; + + CDlgMdfFileDriver dlg(this); + dlg.initDialogData(pobjnew); + if (QDialog::Accepted == dlg.exec()) { + m_pmdf->getDriverObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_driver) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; + } + } break; + + case mdf_type_setup: { + CMDF_Setup* pobj = m_pmdf->getSetupObj(ui->listFile->currentRow()); + if (nullptr == pobj) { + QMessageBox::warning(this, tr(APPNAME), tr("Invalid object"), QMessageBox::Ok); + return; + } + + CMDF_Setup* pobjnew = new CMDF_Setup(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + + *pobjnew = *pobj; + + CDlgMdfFileSetup dlg(this); + dlg.initDialogData(pobjnew); + if (QDialog::Accepted == dlg.exec()) { + m_pmdf->getSetupObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_setup) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; + } + } break; + + case mdf_type_manual: { + CMDF_Manual* pobj = m_pmdf->getManualObj(ui->listFile->currentRow()); + if (nullptr == pobj) { + QMessageBox::warning(this, tr(APPNAME), tr("Invalid object"), QMessageBox::Ok); + return; + } + + CMDF_Manual* pobjnew = new CMDF_Manual(); + if (nullptr == pobjnew) { + QMessageBox::warning(this, tr("APPNAME"), tr("Out of memory problem"), QMessageBox::Ok); + return; + } + + *pobjnew = *pobj; + + CDlgMdfFileManual dlg(this); + dlg.initDialogData(pobjnew); + if (QDialog::Accepted == dlg.exec()) { + m_pmdf->getManualObjList()->push_back(pobjnew); + ui->listFile->addItem(QString(pre_str_manual) + QString(" ") + pobjnew->getName().c_str()); + } + else { + delete pobjnew; + } + } break; + } + } + else { + QMessageBox::warning(this, tr(APPNAME), tr("An item must be selected"), QMessageBox::Ok); + } } /////////////////////////////////////////////////////////////////////////////// @@ -458,18 +723,54 @@ CDlgMdfFile::dupFileItem(void) void CDlgMdfFile::deleteFileItem(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_pitemobj->getMapDescription()->erase(selstr.toStdString()); - // ui->listDescription->clear(); - // fillDescription(); - // } + if (-1 != ui->listFile->currentRow()) { + + // Save the row + int idx = ui->listFile->currentRow(); + + switch (m_type) { + + case mdf_type_picture: { + std::deque* pPictureList = m_pmdf->getPictureObjList(); + pPictureList->erase(pPictureList->begin() + idx); + ui->listFile->takeItem(idx); + } break; + + case mdf_type_video: { + std::deque* pVideoList = m_pmdf->getVideoObjList(); + pVideoList->erase(pVideoList->begin() + idx); + ui->listFile->takeItem(idx); + + } break; + + case mdf_type_firmware: { + std::deque* pFirmwareList = m_pmdf->getFirmwareObjList(); + pFirmwareList->erase(pFirmwareList->begin() + idx); + ui->listFile->takeItem(idx); + } break; + + case mdf_type_driver: { + std::deque* pDriverList = m_pmdf->getDriverObjList(); + pDriverList->erase(pDriverList->begin() + idx); + ui->listFile->takeItem(idx); + } break; + + case mdf_type_setup: { + std::deque* pSetupList = m_pmdf->getSetupObjList(); + pSetupList->erase(pSetupList->begin() + idx); + ui->listFile->takeItem(idx); + } break; + + case mdf_type_manual: { + std::deque* pManualList = m_pmdf->getManualObjList(); + pManualList->erase(pManualList->begin() + idx); + ui->listFile->takeItem(idx); + } break; + } + } + else { + QMessageBox::warning(this, tr(APPNAME), tr("An item must be selected"), QMessageBox::Ok); + } } // ---------------------------------------------------------------------------- diff --git a/src/cdlgmdffile.h b/src/cdlgmdffile.h index c432ade1..774bf6cb 100644 --- a/src/cdlgmdffile.h +++ b/src/cdlgmdffile.h @@ -48,12 +48,19 @@ class CDlgMdfFile : public QDialog { explicit CDlgMdfFile(QWidget* parent = nullptr); ~CDlgMdfFile(); - const int index_picture = 0; - const int index_video = 1; - const int index_firmware = 2; - const int index_driver = 3; - const int index_setup = 4; - const int index_manual = 5; + static const int index_picture = 0; + static const int index_video = 1; + static const int index_firmware = 2; + static const int index_driver = 3; + static const int index_setup = 4; + static const int index_manual = 5; + + static const char pre_str_picture[]; + static const char pre_str_video[]; + static const char pre_str_firmware[]; + static const char pre_str_driver[]; + static const char pre_str_setup[]; + static const char pre_str_manual[]; /*! Set inital focus to description diff --git a/src/cdlgmdffilepicture.cpp b/src/cdlgmdffilepicture.cpp index 9d783b7a..cb57d094 100644 --- a/src/cdlgmdffilepicture.cpp +++ b/src/cdlgmdffilepicture.cpp @@ -105,6 +105,7 @@ CDlgMdfFilePicture::initDialogData(const CMDF_Object* pmdfobj, mdf_file_picture_ ui->date->setDate(dd); switch (index) { + case index_file_picture_url: ui->editUrl->setFocus(); break; @@ -241,7 +242,7 @@ CDlgMdfFilePicture::accept() m_ppicture->setFormat(str); QDate dd = ui->date->date(); - m_ppicture->setDate(dd.toString("YY-MM-DD").toStdString()); + m_ppicture->setDate(dd.toString("yyyy-MM-dd").toStdString()); } else { spdlog::error("MDF module information - Invalid MDF object (accept)"); diff --git a/src/cfrmmdf.cpp b/src/cfrmmdf.cpp index 3ee16148..5ce61da1 100644 --- a/src/cfrmmdf.cpp +++ b/src/cfrmmdf.cpp @@ -52,15 +52,15 @@ #include "cdlgmdfcontact.h" #include "cdlgmdfcontactlist.h" #include "cdlgmdfdescription.h" -#include "cdlgmdfmanufacturer.h" -#include "cdlgmdfmodule.h" #include "cdlgmdffile.h" -#include "cdlgmdffilepicture.h" -#include "cdlgmdffilevideo.h" -#include "cdlgmdffilemanual.h" #include "cdlgmdffiledriver.h" #include "cdlgmdffilefirmware.h" +#include "cdlgmdffilemanual.h" +#include "cdlgmdffilepicture.h" #include "cdlgmdffilesetup.h" +#include "cdlgmdffilevideo.h" +#include "cdlgmdfmanufacturer.h" +#include "cdlgmdfmodule.h" #include #include @@ -456,7 +456,11 @@ CFrmMdf::showMdfContextMenu(const QPoint& pos) break; case mdf_type_picture_item: - menu->addAction(QString(tr("Edit picture items")), this, SLOT(editFile())); + menu->addAction(QString(tr("Edit picture item")), this, SLOT(editFile())); + break; + + case mdf_type_picture_sub_item: + menu->addAction(QString(tr("Edit picture item")), this, SLOT(editFile())); break; case mdf_type_video: @@ -1147,48 +1151,72 @@ CFrmMdf::renderPictureItems(QMdfTreeWidgetItem* pItemPicture, uint16_t selectedI do { pPictureObj = m_mdf.getPictureObj(index); if (nullptr != pPictureObj) { - QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemPicture, &m_mdf, mdf_type_picture_item, index); - str = QString("Picture %1 - ").arg(index) + pPictureObj->getName().c_str(); + + QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemPicture, pPictureObj, mdf_type_picture_item, index); + str = QString(CDlgMdfFile::pre_str_picture) + QString(" ") + pPictureObj->getName().c_str(); pItem->setText(0, str); pItemPicture->addChild(pItem); - QMdfTreeWidgetItem* pSubItem; + renderPictureSubItems(pItem, pPictureObj, selectedIndex); - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Name: ") + pPictureObj->getName().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); + if (index == selectedIndex) { + pItem->setSelected(true); + pItem->parent()->setSelected(false); } + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_url); - if (nullptr != pSubItem) { - str = QString("URL: ") + pPictureObj->getUrl().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + index++; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Format: ") + pPictureObj->getFormat().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + } while (nullptr != pPictureObj); +} - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_date); - if (nullptr != pSubItem) { - str = QString("Date: %1").arg(pPictureObj->getDate().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +/////////////////////////////////////////////////////////////////////////////// +// renderPictureSubItems +// - fillDescriptionItems(pItem, pPictureObj, pPictureObj->getMapDescription()); - fillInfoUrlItems(pItem, pPictureObj, pPictureObj->getMapInfoUrl()); - } +void +CFrmMdf::renderPictureSubItems(QMdfTreeWidgetItem* pPictureItem, CMDF_Picture* pPictureObj, uint16_t selectedIndex) +{ + QString str; + QMdfTreeWidgetItem* pSubItem; - index++; + if ((nullptr == pPictureObj) && (nullptr == pPictureItem)) { + return; + } - } while (nullptr != pPictureObj); + str = QString(CDlgMdfFile::pre_str_picture) + QString(" ") + pPictureObj->getName().c_str(); + pPictureItem->setText(0, str); + + pSubItem = new QMdfTreeWidgetItem(pPictureItem, pPictureObj, mdf_type_picture_sub_item, 0); + if (nullptr != pSubItem) { + str = QString("Name: ") + pPictureObj->getName().c_str(); + pSubItem->setText(0, str); + pPictureItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pPictureItem, pPictureObj, mdf_type_picture_sub_item, 1); + if (nullptr != pSubItem) { + str = QString("URL: ") + pPictureObj->getUrl().c_str(); + pSubItem->setText(0, str); + pPictureItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pPictureItem, pPictureObj, mdf_type_picture_sub_item, 2); + if (nullptr != pSubItem) { + str = QString("Format: ") + pPictureObj->getFormat().c_str(); + pSubItem->setText(0, str); + pPictureItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pPictureItem, pPictureObj, mdf_type_picture_sub_item, 3); + if (nullptr != pSubItem) { + str = QString("Date: %1").arg(pPictureObj->getDate().c_str()); + pSubItem->setText(0, str); + pPictureItem->addChild(pSubItem); + } + + fillDescriptionItems(pPictureItem, pPictureObj, pPictureObj->getMapDescription()); + fillInfoUrlItems(pPictureItem, pPictureObj, pPictureObj->getMapInfoUrl()); } /////////////////////////////////////////////////////////////////////////////// @@ -1210,48 +1238,68 @@ CFrmMdf::renderVideoItems(QMdfTreeWidgetItem* pItemVideo, uint16_t selectedIndex do { pVideoObj = m_mdf.getVideoObj(index); if (nullptr != pVideoObj) { - QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemVideo, &m_mdf, mdf_type_video_item, index); - str = QString("Video %1 - ").arg(index) + pVideoObj->getName().c_str(); + QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemVideo, pVideoObj, mdf_type_video_item, index); + str = QString(CDlgMdfFile::pre_str_video) + QString(" ") + pVideoObj->getName().c_str(); pItem->setText(0, str); pItemVideo->addChild(pItem); - QMdfTreeWidgetItem* pSubItem; + renderVideoSubItems(pItem, pVideoObj, selectedIndex); - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Name: ") + pVideoObj->getName().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); + if (index == selectedIndex) { + pItem->setSelected(true); + pItem->parent()->setSelected(false); } + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_url); - if (nullptr != pSubItem) { - str = QString("URL: ") + pVideoObj->getUrl().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + index++; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Format: ") + pVideoObj->getFormat().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + } while (nullptr != pVideoObj); +} - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_date); - if (nullptr != pSubItem) { - str = QString("Date: %1").arg(pVideoObj->getDate().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +/////////////////////////////////////////////////////////////////////////////// +// renderVideoSubItems +// - fillDescriptionItems(pItem, pVideoObj, pVideoObj->getMapDescription()); - fillInfoUrlItems(pItem, pVideoObj, pVideoObj->getMapInfoUrl()); - } +void +CFrmMdf::renderVideoSubItems(QMdfTreeWidgetItem* pVideoItem, CMDF_Video* pVideoObj, uint16_t selectedIndex) +{ + QString str; + QMdfTreeWidgetItem* pSubItem; - index++; + if ((nullptr == pVideoObj) && (nullptr == pVideoItem)) { + return; + } - } while (nullptr != pVideoObj); + pSubItem = new QMdfTreeWidgetItem(pVideoItem, mdf_type_video_sub_item); + if (nullptr != pSubItem) { + str = QString("Name: ") + pVideoObj->getName().c_str(); + pSubItem->setText(0, str); + pVideoItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pVideoItem, mdf_type_video_sub_item); + if (nullptr != pSubItem) { + str = QString("URL: ") + pVideoObj->getUrl().c_str(); + pSubItem->setText(0, str); + pVideoItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pVideoItem, mdf_type_video_sub_item); + if (nullptr != pSubItem) { + str = QString("Format: ") + pVideoObj->getFormat().c_str(); + pSubItem->setText(0, str); + pVideoItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pVideoItem, mdf_type_video_sub_item); + if (nullptr != pSubItem) { + str = QString("Date: %1").arg(pVideoObj->getDate().c_str()); + pSubItem->setText(0, str); + pVideoItem->addChild(pSubItem); + } + + fillDescriptionItems(pVideoItem, pVideoObj, pVideoObj->getMapDescription()); + fillInfoUrlItems(pVideoItem, pVideoObj, pVideoObj->getMapInfoUrl()); } /////////////////////////////////////////////////////////////////////////////// @@ -1273,48 +1321,63 @@ CFrmMdf::renderManualItems(QMdfTreeWidgetItem* pItemManual, uint16_t selectedInd do { pManualObj = m_mdf.getManualObj(index); if (nullptr != pManualObj) { - QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemManual, &m_mdf, mdf_type_manual_item, index); - str = QString("Manual %1 - %2").arg(index).arg(pManualObj->getName().c_str()); + QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemManual, pManualObj, mdf_type_manual_item, index); + str = QString(CDlgMdfFile::pre_str_manual) + QString(" ") + pManualObj->getName().c_str(); pItem->setText(0, str); pItemManual->addChild(pItem); - QMdfTreeWidgetItem* pSubItem; + renderManualSubItems(pItem, pManualObj, selectedIndex); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Name: %1").arg(pManualObj->getName().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + index++; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_url); - if (nullptr != pSubItem) { - str = QString("URL: ") + pManualObj->getUrl().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + } while (nullptr != pManualObj); +} - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Format: ") + pManualObj->getFormat().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +/////////////////////////////////////////////////////////////////////////////// +// renderManualSubItems +// - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_date); - if (nullptr != pSubItem) { - str = QString("Date: %1").arg(pManualObj->getDate().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +void +CFrmMdf::renderManualSubItems(QMdfTreeWidgetItem* pManualItem, CMDF_Manual* pManualObj, uint16_t selectedIndex) +{ + QString str; + QMdfTreeWidgetItem* pSubItem; - fillDescriptionItems(pItem, pManualObj, pManualObj->getMapDescription()); - fillInfoUrlItems(pItem, pManualObj, pManualObj->getMapInfoUrl()); - } + if ((nullptr == pManualObj) && (nullptr == pManualItem)) { + return; + } - index++; + pSubItem = new QMdfTreeWidgetItem(pManualItem, mdf_type_manual_sub_item); + if (nullptr != pSubItem) { + str = QString("Name: %1").arg(pManualObj->getName().c_str()); + pSubItem->setText(0, str); + pManualItem->addChild(pSubItem); + } - } while (nullptr != pManualObj); + pSubItem = new QMdfTreeWidgetItem(pManualItem, mdf_type_manual_sub_item); + if (nullptr != pSubItem) { + str = QString("URL: ") + pManualObj->getUrl().c_str(); + pSubItem->setText(0, str); + pManualItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pManualItem, mdf_type_manual_sub_item); + if (nullptr != pSubItem) { + str = QString("Format: ") + pManualObj->getFormat().c_str(); + pSubItem->setText(0, str); + pManualItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pManualItem, mdf_type_manual_sub_item); + if (nullptr != pSubItem) { + str = QString("Date: %1").arg(pManualObj->getDate().c_str()); + pSubItem->setText(0, str); + pManualItem->addChild(pSubItem); + } + + fillDescriptionItems(pManualItem, pManualObj, pManualObj->getMapDescription()); + fillInfoUrlItems(pManualItem, pManualObj, pManualObj->getMapInfoUrl()); } /////////////////////////////////////////////////////////////////////////////// @@ -1336,83 +1399,98 @@ CFrmMdf::renderDriverItems(QMdfTreeWidgetItem* pItemDriver, uint16_t selectedInd do { pDriverObj = m_mdf.getDriverObj(index); if (nullptr != pDriverObj) { - QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemDriver, &m_mdf, mdf_type_driver_item, index); - str = QString("Driver %1 - %2 %3").arg(index).arg(pDriverObj->getName().c_str()).arg(pDriverObj->getDate().c_str()); + QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemDriver, pDriverObj, mdf_type_driver_item, index); + str = QString(CDlgMdfFile::pre_str_driver) + QString(" %1 %2").arg(pDriverObj->getName().c_str()).arg(pDriverObj->getDate().c_str()); pItem->setText(0, str); pItemDriver->addChild(pItem); - QMdfTreeWidgetItem* pSubItem; + renderDriverSubItems(pItem, pDriverObj, selectedIndex); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Name: %1").arg(pDriverObj->getName().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + index++; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Version: %1.%2.%3").arg(pDriverObj->getVersionMajor()).arg(pDriverObj->getVersionMinor()).arg(pDriverObj->getVersionPatch()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + } while (nullptr != pDriverObj); +} - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_date); - if (nullptr != pSubItem) { - str = QString("Date: ") + pDriverObj->getDate().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +/////////////////////////////////////////////////////////////////////////////// +// renderDriverSubItems +// - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_url); - if (nullptr != pSubItem) { - str = QString("URL: ") + pDriverObj->getUrl().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +void +CFrmMdf::renderDriverSubItems(QMdfTreeWidgetItem* pDriverItem, CMDF_Driver* pDriverObj, uint16_t selectedIndex) +{ + QString str; + QMdfTreeWidgetItem* pSubItem; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Type: ") + pDriverObj->getType().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + if ((nullptr == pDriverObj) && (nullptr == pDriverItem)) { + return; + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Architecture: ") + pDriverObj->getFormat().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("Name: %1").arg(pDriverObj->getName().c_str()); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("OS: ") + pDriverObj->getOS().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("Version: %1.%2.%3").arg(pDriverObj->getVersionMajor()).arg(pDriverObj->getVersionMinor()).arg(pDriverObj->getVersionPatch()); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("OS Version: ") + pDriverObj->getOSVer().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("Date: ") + pDriverObj->getDate().c_str(); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("MD5 Checksum: ") + pDriverObj->getMd5().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("URL: ") + pDriverObj->getUrl().c_str(); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } - fillDescriptionItems(pItem, pDriverObj, pDriverObj->getMapDescription()); - fillInfoUrlItems(pItem, pDriverObj, pDriverObj->getMapInfoUrl()); - } + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("Type: ") + pDriverObj->getType().c_str(); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } - index++; + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("Architecture: ") + pDriverObj->getFormat().c_str(); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } - } while (nullptr != pDriverObj); + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("OS: ") + pDriverObj->getOS().c_str(); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("OS Version: ") + pDriverObj->getOSVer().c_str(); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pDriverItem, mdf_type_driver_sub_item); + if (nullptr != pSubItem) { + str = QString("MD5 Checksum: ") + pDriverObj->getMd5().c_str(); + pSubItem->setText(0, str); + pDriverItem->addChild(pSubItem); + } + + fillDescriptionItems(pDriverItem, pDriverObj, pDriverObj->getMapDescription()); + fillInfoUrlItems(pDriverItem, pDriverObj, pDriverObj->getMapInfoUrl()); } /////////////////////////////////////////////////////////////////////////////// @@ -1432,52 +1510,69 @@ CFrmMdf::renderSetupItems(QMdfTreeWidgetItem* pItemSetup, uint16_t selectedIndex } do { + pSetupObj = m_mdf.getSetupObj(index); if (nullptr != pSetupObj) { - QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemSetup, &m_mdf, mdf_type_setup_item, index); - str = QString("Script %1 - %2").arg(index).arg(pSetupObj->getName().c_str()); + + QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemSetup, pSetupObj, mdf_type_setup_item, index); + str = QString(CDlgMdfFile::pre_str_setup) + QString(" %1").arg(pSetupObj->getName().c_str()); pItem->setText(0, str); pItemSetup->addChild(pItem); - QMdfTreeWidgetItem* pSubItem; + renderSetupSubItems(pItem, pSetupObj, selectedIndex); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Name: %1").arg(pSetupObj->getName().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + index++; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_url); - if (nullptr != pSubItem) { - str = QString("URL: ") + pSetupObj->getUrl().c_str(); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + } while (nullptr != pSetupObj); +} - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Format: ") + pSetupObj->getFormat().c_str(); - // pSubItem->setFont(0, fontTopItem); - // pSubItem->setForeground(0, greenBrush); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +/////////////////////////////////////////////////////////////////////////////// +// renderSetupSubItems +// - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_date); - if (nullptr != pSubItem) { - str = QString("Date: %1").arg(pSetupObj->getDate().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +void +CFrmMdf::renderSetupSubItems(QMdfTreeWidgetItem* pSetupItem, CMDF_Setup* pSetupObj, uint16_t selectedIndex) +{ + QString str; + QMdfTreeWidgetItem* pSubItem; - fillDescriptionItems(pItem, pSetupObj, pSetupObj->getMapDescription()); - fillInfoUrlItems(pItem, pSetupObj, pSetupObj->getMapInfoUrl()); - } + if ((nullptr == pSetupObj) && (nullptr == pSetupItem)) { + return; + } - index++; + pSubItem = new QMdfTreeWidgetItem(pSetupItem, mdf_type_setup_sub_item); + if (nullptr != pSubItem) { + str = QString("Name: %1").arg(pSetupObj->getName().c_str()); + pSubItem->setText(0, str); + pSetupItem->addChild(pSubItem); + } - } while (nullptr != pSetupObj); + pSubItem = new QMdfTreeWidgetItem(pSetupItem, mdf_type_setup_sub_item); + if (nullptr != pSubItem) { + str = QString("URL: ") + pSetupObj->getUrl().c_str(); + pSubItem->setText(0, str); + pSetupItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pSetupItem, mdf_type_setup_sub_item); + if (nullptr != pSubItem) { + str = QString("Format: ") + pSetupObj->getFormat().c_str(); + // pSubItem->setFont(0, fontTopItem); + // pSubItem->setForeground(0, greenBrush); + pSubItem->setText(0, str); + pSetupItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pSetupItem, mdf_type_setup_sub_item); + if (nullptr != pSubItem) { + str = QString("Date: %1").arg(pSetupObj->getDate().c_str()); + pSubItem->setText(0, str); + pSetupItem->addChild(pSubItem); + } + + fillDescriptionItems(pSetupItem, pSetupObj, pSetupObj->getMapDescription()); + fillInfoUrlItems(pSetupItem, pSetupObj, pSetupObj->getMapInfoUrl()); } /////////////////////////////////////////////////////////////////////////////// @@ -1499,83 +1594,98 @@ CFrmMdf::renderFirmwareItems(QMdfTreeWidgetItem* pItemFirmware, uint16_t selecte do { pFirmwareObj = m_mdf.getFirmwareObj(index); if (nullptr != pFirmwareObj) { - QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemFirmware, &m_mdf, mdf_type_firmware_item, index); - str = QString("Firmware %1 - %2 %3").arg(index).arg(pFirmwareObj->getDate().c_str()).arg(pFirmwareObj->getName().c_str()); + QMdfTreeWidgetItem* pItem = new QMdfTreeWidgetItem(pItemFirmware, pFirmwareObj, mdf_type_firmware_item, index); + str = QString(CDlgMdfFile::pre_str_firmware) + QString(" %1 %2").arg(pFirmwareObj->getDate().c_str()).arg(pFirmwareObj->getName().c_str()); pItem->setText(0, str); pItemFirmware->addChild(pItem); - QMdfTreeWidgetItem* pSubItem; + renderFirmwareSubItems(pItem, pFirmwareObj, selectedIndex); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Name: %1").arg(pFirmwareObj->getName().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + index++; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Version: %1.%2.%3").arg(pFirmwareObj->getVersionMajor()).arg(pFirmwareObj->getVersionMinor()).arg(pFirmwareObj->getVersionPatch()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + } while (nullptr != pFirmwareObj); +} - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_url); - if (nullptr != pSubItem) { - str = QString("URL: %1").arg(pFirmwareObj->getUrl().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +/////////////////////////////////////////////////////////////////////////////// +// renderFirmwareSubItems +// - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_date); - if (nullptr != pSubItem) { - str = QString("Date: %1").arg(pFirmwareObj->getDate().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } +void +CFrmMdf::renderFirmwareSubItems(QMdfTreeWidgetItem* pFirmwareItem, CMDF_Firmware* pFirmwareObj, uint16_t selectedIndex) +{ + QString str; + QMdfTreeWidgetItem* pSubItem; - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_number); - if (nullptr != pSubItem) { - str = QString("Target Code: %1").arg(pFirmwareObj->getTargetCode()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + if ((nullptr == pFirmwareObj) && (nullptr == pFirmwareItem)) { + return; + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Target: %1").arg(pFirmwareObj->getTarget().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_string); + if (nullptr != pSubItem) { + str = QString("Name: %1").arg(pFirmwareObj->getName().c_str()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("Format: %1").arg(pFirmwareObj->getFormat().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_string); + if (nullptr != pSubItem) { + str = QString("Version: %1.%2.%3").arg(pFirmwareObj->getVersionMajor()).arg(pFirmwareObj->getVersionMinor()).arg(pFirmwareObj->getVersionPatch()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_number); - if (nullptr != pSubItem) { - str = QString("Size: %1").arg(pFirmwareObj->getSize()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_url); + if (nullptr != pSubItem) { + str = QString("URL: %1").arg(pFirmwareObj->getUrl().c_str()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } - pSubItem = new QMdfTreeWidgetItem(pItem, mdf_type_generic_string); - if (nullptr != pSubItem) { - str = QString("MD5 Checksum: %1").arg(pFirmwareObj->getMd5().c_str()); - pSubItem->setText(0, str); - pItem->addChild(pSubItem); - } + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_date); + if (nullptr != pSubItem) { + str = QString("Date: %1").arg(pFirmwareObj->getDate().c_str()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } - fillDescriptionItems(pItem, pFirmwareObj, pFirmwareObj->getMapDescription()); - fillInfoUrlItems(pItem, pFirmwareObj, pFirmwareObj->getMapInfoUrl()); - } + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_number); + if (nullptr != pSubItem) { + str = QString("Target Code: %1").arg(pFirmwareObj->getTargetCode()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } - index++; + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_string); + if (nullptr != pSubItem) { + str = QString("Target: %1").arg(pFirmwareObj->getTarget().c_str()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } - } while (nullptr != pFirmwareObj); + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_string); + if (nullptr != pSubItem) { + str = QString("Format: %1").arg(pFirmwareObj->getFormat().c_str()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_number); + if (nullptr != pSubItem) { + str = QString("Size: %1").arg(pFirmwareObj->getSize()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } + + pSubItem = new QMdfTreeWidgetItem(pFirmwareItem, mdf_type_generic_string); + if (nullptr != pSubItem) { + str = QString("MD5 Checksum: %1").arg(pFirmwareObj->getMd5().c_str()); + pSubItem->setText(0, str); + pFirmwareItem->addChild(pSubItem); + } + + fillDescriptionItems(pFirmwareItem, pFirmwareObj, pFirmwareObj->getMapDescription()); + fillInfoUrlItems(pFirmwareItem, pFirmwareObj, pFirmwareObj->getMapInfoUrl()); } /////////////////////////////////////////////////////////////////////////////// @@ -1635,6 +1745,7 @@ CFrmMdf::loadMdf(void) // Module QMdfTreeWidgetItem* pItemModule = new QMdfTreeWidgetItem(&m_mdf, mdf_type_mdf); + m_headModule = pItemModule; pItemModule->setObject(&m_mdf); pItemModule->setFont(0, fontTopItem); pItemModule->setForeground(0, blueBrush); @@ -1686,6 +1797,7 @@ CFrmMdf::loadMdf(void) QMdfTreeWidgetItem* pItemManufacturer = new QMdfTreeWidgetItem(pItemModule, m_mdf.getManufacturer(), mdf_type_manufacturer); + m_headManufacturer = pItemManufacturer; pItemManufacturer->setFont(0, fontTopItem); pItemManufacturer->setForeground(0, greenBrush); pItemManufacturer->setText(0, tr("Manufacturer")); @@ -1820,6 +1932,7 @@ CFrmMdf::loadMdf(void) m_mdf.getBootLoaderObj(), mdf_type_bootloader, static_cast(index_bootloader_algorithm)); + m_headBootLoader = pItemBoot; pItemBoot->setFont(0, fontTopItem); pItemBoot->setForeground(0, greenBrush); pItemBoot->setText(0, tr("Boot")); @@ -1830,42 +1943,46 @@ CFrmMdf::loadMdf(void) // * * * Files * * * QMdfTreeWidgetItem* pItemFiles = new QMdfTreeWidgetItem(pItemModule, &m_mdf, mdf_type_file); + m_headFile = pItemFiles; pItemFiles->setFont(0, fontTopItem); pItemFiles->setForeground(0, greenBrush); pItemFiles->setText(0, tr("Files")); ui->treeMDF->addTopLevelItem(pItemFiles); - // Picture file(s) QMdfTreeWidgetItem* pItemPicture = new QMdfTreeWidgetItem(pItemFiles, &m_mdf, mdf_type_picture); + m_headFilePicture = m_headFilePicture; pItemPicture->setFont(0, fontTopItem); pItemPicture->setText(0, tr("Pictures")); pItemFiles->addChild(pItemPicture); renderPictureItems(pItemPicture); - // Manuals - - QMdfTreeWidgetItem* pItemManual = new QMdfTreeWidgetItem(pItemFiles, &m_mdf, mdf_type_manual); - pItemManual->setFont(0, fontTopItem); - pItemManual->setText(0, tr("Manuals")); - pItemFiles->addChild(pItemManual); - - renderManualItems(pItemManual); - // Video file(s) QMdfTreeWidgetItem* pItemVideo = new QMdfTreeWidgetItem(pItemFiles, &m_mdf, mdf_type_video); + m_headFileVideo = m_headFileVideo; pItemVideo->setFont(0, fontTopItem); pItemVideo->setText(0, tr("Videos")); pItemFiles->addChild(pItemVideo); renderVideoItems(pItemVideo); + // Manuals + + QMdfTreeWidgetItem* pItemManual = new QMdfTreeWidgetItem(pItemFiles, &m_mdf, mdf_type_manual); + m_headFileManual = m_headFileManual; + pItemManual->setFont(0, fontTopItem); + pItemManual->setText(0, tr("Manuals")); + pItemFiles->addChild(pItemManual); + + renderManualItems(pItemManual); + // Firmware file(s) QMdfTreeWidgetItem* pItemFirmware = new QMdfTreeWidgetItem(pItemFiles, &m_mdf, mdf_type_firmware); + m_headFileFirmware = m_headFileFirmware; pItemFirmware->setFont(0, fontTopItem); pItemFirmware->setText(0, tr("Firmware")); pItemFiles->addChild(pItemFirmware); @@ -1875,6 +1992,7 @@ CFrmMdf::loadMdf(void) // Drivers QMdfTreeWidgetItem* pItemDriver = new QMdfTreeWidgetItem(pItemFiles, &m_mdf, mdf_type_driver); + m_headFileDriver = m_headFileDriver; pItemDriver->setFont(0, fontTopItem); pItemDriver->setText(0, tr("Drivers")); pItemFiles->addChild(pItemDriver); @@ -1884,10 +2002,11 @@ CFrmMdf::loadMdf(void) // Setup script QMdfTreeWidgetItem* pItemSetup = new QMdfTreeWidgetItem(pItemFiles, &m_mdf, mdf_type_setup); + m_headFileSetupScript = pItemSetup; pItemSetup->setFont(0, fontTopItem); // pItemSetup->setForeground(0, greenBrush); - pItemSetup->setText(0, tr("Setup scripts")); - pItemFiles->addChild(pItemSetup); + m_headFileSetupScript->setText(0, tr("Setup scripts")); + pItemFiles->addChild(m_headFileSetupScript); renderSetupItems(pItemSetup); @@ -1898,6 +2017,7 @@ CFrmMdf::loadMdf(void) QMdfTreeWidgetItem* pSubItem; QMdfTreeWidgetItem* pItemRegister = new QMdfTreeWidgetItem(pItemModule, mdf_type_register); + m_headRegister = pItemRegister; pItemRegister->setFont(0, fontTopItem); pItemRegister->setForeground(0, greenBrush); pItemRegister->setText(0, tr("Registers")); @@ -1943,6 +2063,7 @@ CFrmMdf::loadMdf(void) // * * * Remote variables * * * QMdfTreeWidgetItem* pItemRemoteVar = new QMdfTreeWidgetItem(pItemModule, mdf_type_remotevar); + m_headRemoteVariabel = pItemRemoteVar; pItemRemoteVar->setFont(0, fontTopItem); pItemRemoteVar->setForeground(0, greenBrush); pItemRemoteVar->setText(0, tr("Remote Variables")); @@ -2058,6 +2179,7 @@ CFrmMdf::loadMdf(void) // * * * Alarm * * * QMdfTreeWidgetItem* pItemAlarm = new QMdfTreeWidgetItem(pItemModule, mdf_type_alarm); + m_headAlarm = pItemAlarm; pItemAlarm->setFont(0, fontTopItem); pItemAlarm->setForeground(0, greenBrush); pItemAlarm->setText(0, tr("Alarm")); @@ -2071,6 +2193,7 @@ CFrmMdf::loadMdf(void) // * * * Decision Matrix * * * QMdfTreeWidgetItem* pItemDM = new QMdfTreeWidgetItem(pItemModule, mdf_type_decision_matrix); + m_headDecisionMatrix = pItemDM; pItemDM->setFont(0, fontTopItem); pItemDM->setForeground(0, greenBrush); pItemDM->setText(0, tr("Decision Matrix")); @@ -2222,6 +2345,7 @@ CFrmMdf::loadMdf(void) // * * * Events * * * QMdfTreeWidgetItem* pItemEvent = new QMdfTreeWidgetItem(pItemModule, mdf_type_event); + pItemEvent = pItemEvent; pItemEvent->setFont(0, fontTopItem); pItemEvent->setForeground(0, greenBrush); pItemEvent->setText(0, tr("Events")); @@ -3132,11 +3256,19 @@ CFrmMdf::editDescription(void) pmap = m_mdf.getManufacturer()->getMapDescription(); break; + // Contact items case mdf_type_phone_item: case mdf_type_fax_item: case mdf_type_email_item: case mdf_type_web_item: - case mdf_type_social_item: { + case mdf_type_social_item: + // File items + case mdf_type_picture_item: + case mdf_type_video_item: + case mdf_type_manual_item: + case mdf_type_firmware_item: + case mdf_type_driver_item: + case mdf_type_setup_item: { qDebug() << pParentToItemDescription->getObjectType() << pItem->getObjectType() << pItem->text(0) << pParentToItemDescription->text(0) << pParentToItemDescription->parent()->text(0); @@ -3241,11 +3373,19 @@ CFrmMdf::editInfoUrl(void) pmap = m_mdf.getManufacturer()->getMapInfoUrl(); break; + // Contact items case mdf_type_phone_item: case mdf_type_fax_item: case mdf_type_email_item: case mdf_type_web_item: - case mdf_type_social_item: { + case mdf_type_social_item: + // File items + case mdf_type_picture_item: + case mdf_type_video_item: + case mdf_type_manual_item: + case mdf_type_firmware_item: + case mdf_type_driver_item: + case mdf_type_setup_item: { qDebug() << pParentToItemInfoUrl->getObjectType() << pItem->getObjectType() << pItem->text(0) << pParentToItemInfoUrl->text(0) << pParentToItemInfoUrl->parent()->text(0); @@ -3675,7 +3815,6 @@ CFrmMdf::editBootLoader(void) } } - /////////////////////////////////////////////////////////////////////////////// // editFileList // @@ -3684,7 +3823,7 @@ void CFrmMdf::editFileList(void) { QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); - QMdfTreeWidgetItem* pFileHeadItem = nullptr; + QMdfTreeWidgetItem* pFileHeadItem = (QMdfTreeWidgetItem*)pItem->parent(); uint16_t selectedIndex = pItem->getElementIndex(); // Item must be selected @@ -3703,11 +3842,81 @@ CFrmMdf::editFileList(void) CDlgMdfFile dlg(this); dlg.initDialogData(pItem->getObject(), pItem->getObjectType()); if (QDialog::Accepted == dlg.exec()) { - + + // Expand to make traversion possible + pItem->setExpanded(true); + + switch (pItem->getObjectType()) { + + case mdf_type_picture: { + QMdfTreeWidgetItem* piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + while ((nullptr != piter) && (mdf_type_picture_item == piter->getObjectType())) { + pItem->removeChild(piter); + delete piter; + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + } + + renderPictureItems(pItem, selectedIndex); + } break; + + case mdf_type_video: { + QMdfTreeWidgetItem* piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + while (mdf_type_video_item == piter->getObjectType()) { + pItem->removeChild(piter); + delete piter; + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + } + + renderVideoItems(pItem, selectedIndex); + } break; + + case mdf_type_firmware: { + QMdfTreeWidgetItem* piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + while (mdf_type_firmware_item == piter->getObjectType()) { + pItem->removeChild(piter); + delete piter; + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + } + + renderFirmwareItems(pItem, selectedIndex); + } break; + + case mdf_type_driver: { + QMdfTreeWidgetItem* piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + while (mdf_type_driver_item == piter->getObjectType()) { + pItem->removeChild(piter); + delete piter; + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + } + + renderDriverItems(pItem, selectedIndex); + } break; + + case mdf_type_setup: { + QMdfTreeWidgetItem* piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + while ((nullptr != piter) && (mdf_type_picture_item == piter->getObjectType())) { + pItem->removeChild(piter); + delete piter; + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + } + + renderPictureItems(pItem, selectedIndex); + } break; + + case mdf_type_manual: { + QMdfTreeWidgetItem* piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + while (mdf_type_manual_item == piter->getObjectType()) { + pItem->removeChild(piter); + delete piter; + piter = (QMdfTreeWidgetItem*)ui->treeMDF->itemBelow(pItem); + } + + renderManualItems(pItem, selectedIndex); + } break; + } } } - /////////////////////////////////////////////////////////////////////////////// // editFile // @@ -3715,9 +3924,9 @@ CFrmMdf::editFileList(void) void CFrmMdf::editFile(void) { - QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); - QMdfTreeWidgetItem* pBootHeadItem = nullptr; - uint16_t selectedIndex = pItem->getElementIndex(); + QMdfTreeWidgetItem* pItem = (QMdfTreeWidgetItem*)ui->treeMDF->currentItem(); + QMdfTreeWidgetItem* pItemHead = (QMdfTreeWidgetItem*)pItem->parent(); + uint16_t selectedIndex = pItem->getElementIndex(); // Item must be selected if (nullptr == pItem) { @@ -3731,4 +3940,61 @@ CFrmMdf::editFile(void) spdlog::error("MDF bootloader edit - object has nullptr"); return; } + + switch (pItem->getObjectType()) { + + case mdf_type_picture_item: { + CMDF_Picture* pobj = (CMDF_Picture*)pItem->getObject(); + CDlgMdfFilePicture dlg(this); + dlg.initDialogData(pobj); + if (QDialog::Accepted == dlg.exec()) { + qDebug() << "Item = " << pItem->text(0) << ((CMDF_Picture*)pItem->getObject())->getName().c_str() << " type = " << ((CMDF_Picture*)pItem->getObject())->getMdfObjectType(); + + QList childrenList = pItem->takeChildren(); + // qDebug() << "Header = " << pItemHead->text(0) << ((CMDF_Picture*)pItemHead->getObject())->getName().c_str() << " type = " << ((CMDF_Picture*)pItemHead->getObject())->getMdfObjectType(); + // qDebug() << "Take children: size = " << childrenList.size(); + + // Remove children + for (qsizetype i = 0; i < childrenList.size(); ++i) { + QMdfTreeWidgetItem* item = (QMdfTreeWidgetItem*)childrenList.at(i); + // qDebug() << item->text(0); + delete item; + } + childrenList.clear(); + + renderPictureSubItems(pItem, pobj); + + // Expand to make items visible + pItem->setExpanded(true); + } + } break; + + case mdf_type_picture_sub_item: { + CMDF_Picture* pobj = (CMDF_Picture*)pItemHead->getObject(); + if (nullptr == pobj) { + int ret = QMessageBox::critical(this, tr("APPNAME"), tr("Internal error: Invalid picture object")); + spdlog::error("MDF picture edit - object has nullptr"); + return; + } + CDlgMdfFilePicture dlg(this); + dlg.initDialogData(pobj, static_cast(pItem->getElementIndex())); + if (QDialog::Accepted == dlg.exec()) { + + QList childrenList = pItemHead->takeChildren(); + // qDebug() << "Header = " << pItemHead->text(0) << ((CMDF_Picture*)pItemHead->getObject())->getName().c_str() << " type = " << ((CMDF_Picture*)pItemHead->getObject())->getMdfObjectType(); + // qDebug() << "Take children: size = " << childrenList.size(); + + // Remove children + for (qsizetype i = 0; i < childrenList.size(); ++i) { + QMdfTreeWidgetItem* item = (QMdfTreeWidgetItem*)childrenList.at(i); + // qDebug() << item->text(0); + delete item; + } + childrenList.clear(); + + selectedIndex = pItem->getElementIndex(); + renderPictureSubItems(pItemHead, pobj); + } + } break; + } } \ No newline at end of file diff --git a/src/cfrmmdf.h b/src/cfrmmdf.h index 0febfb6b..8acb035e 100644 --- a/src/cfrmmdf.h +++ b/src/cfrmmdf.h @@ -338,6 +338,15 @@ public slots: void renderPictureItems(QMdfTreeWidgetItem* pItemPicture, uint16_t selectedIndex = 0); + /*! + Render picture subitems + @param pItemPicture Pointer to picture item to render + @param pPictureObj Pointer to picture object + @param selectedIndex Item that should be selected + */ + void + renderPictureSubItems(QMdfTreeWidgetItem* pItemPicture, CMDF_Picture* pPictureObj, uint16_t selectedIndex = 0); + /*! Render video items @param pItemVideo Pointer to header item in tree for sub items @@ -346,6 +355,15 @@ public slots: void renderVideoItems(QMdfTreeWidgetItem* pItemVideo, uint16_t selectedIndex = 0); + /*! + Render video subitems + @param pItemVideo Pointer to picture item to render + @param pVideoObj Pointer to picture object + @param selectedIndex Item that should be selected + */ + void + renderVideoSubItems(QMdfTreeWidgetItem* pItemVideo, CMDF_Video* pVideoObj, uint16_t selectedIndex = 0); + /*! Render manual items @param pItemManual Pointer to header item in tree for sub items @@ -354,6 +372,15 @@ public slots: void renderManualItems(QMdfTreeWidgetItem* pItemManual, uint16_t selectedIndex = 0); + /*! + Render manual subitems + @param pItemManual Pointer to manual item to render + @param pManualObj Pointer to manaul object + @param selectedIndex Item that should be selected + */ + void + renderManualSubItems(QMdfTreeWidgetItem* pItemManual, CMDF_Manual* pManualObj, uint16_t selectedIndex = 0); + /*! Render driver items @param pItemDriver Pointer to header item in tree for sub items @@ -362,6 +389,15 @@ public slots: void renderDriverItems(QMdfTreeWidgetItem* pItemDriver, uint16_t selectedIndex = 0); + /*! + Render driver subitems + @param pItemDriver Pointer to driver item to render + @param pDriverObj Pointer to driver object + @param selectedIndex Item that should be selected + */ + void + renderDriverSubItems(QMdfTreeWidgetItem* pItemDriver, CMDF_Driver* pDriverObj, uint16_t selectedIndex = 0); + /*! Render setup items @param pItemSetup Pointer to header item in tree for sub items @@ -370,6 +406,15 @@ public slots: void renderSetupItems(QMdfTreeWidgetItem* pItemSetup, uint16_t selectedIndex = 0); + /*! + Render setup subitems + @param pItemSetup Pointer to setup item to render + @param pSetupObj Pointer to setup object + @param selectedIndex Item that should be selected + */ + void + renderSetupSubItems(QMdfTreeWidgetItem* pItemSetup, CMDF_Setup* pSetupObj, uint16_t selectedIndex = 0); + /*! Render firmware items @param pItemFirmware Pointer to header item in tree for sub items @@ -378,6 +423,15 @@ public slots: void renderFirmwareItems(QMdfTreeWidgetItem* pItemFirmware, uint16_t selectedIndex = 0); + /*! + Render firmware subitems + @param pItemFirmware Pointer to firmware item to render + @param pFirmwareObj Pointer to firmware object + @param selectedIndex Item that should be selected + */ + void + renderFirmwareSubItems(QMdfTreeWidgetItem* pItemFirmware, CMDF_Firmware* pFirmwareObj, uint16_t selectedIndex = 0); + /// Do the new operation void newMdf(void); @@ -416,6 +470,26 @@ public slots: // The statusbar QStatusBar* m_bar; + + /*! + Headers in the tree that are used as reference for updates. + The following pointers are always valid and set. + */ + QMdfTreeWidgetItem* m_headModule; + QMdfTreeWidgetItem* m_headManufacturer; + QMdfTreeWidgetItem* m_headBootLoader; + QMdfTreeWidgetItem* m_headFile; + QMdfTreeWidgetItem* m_headFilePicture; + QMdfTreeWidgetItem* m_headFileVideo; + QMdfTreeWidgetItem* m_headFileManual; + QMdfTreeWidgetItem* m_headFileFirmware; + QMdfTreeWidgetItem* m_headFileDriver; + QMdfTreeWidgetItem* m_headFileSetupScript; + QMdfTreeWidgetItem* m_headRegister; + QMdfTreeWidgetItem* m_headRemoteVariabel; + QMdfTreeWidgetItem* m_headAlarm; + QMdfTreeWidgetItem* m_headDecisionMatrix; + QMdfTreeWidgetItem* m_headEvent; }; #endif // CFrmMdf_H