/** * @RDE_HEADER@ * HMI Plugin for ExerciseManangement - Exercise Overview Dialog * $Id$ * $HeadURL$ * $Author$ * Created by Christian Ehrlicher, SLSE, 2016-02-29 */ #include "mrk_dialog.h" #include "ui_mrk_dialog.h" #include "mrk_edit_dialog.h" #include #include #include #include #include #include namespace MarkerManagement { //--------------------------------- // MarkerManagementDialog //--------------------------------- MarkerManagementDialog::MarkerManagementDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent) : LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly) , m_menuGroup(menuGroup) , m_model(nullptr) , m_session(session) , m_ui(new Ui::MarkerManagementDialog) , m_dtc(nullptr) , m_ftc(nullptr) , m_flmFtc(nullptr) , m_avmInterface(nullptr) , m_requestHelper(new LtsUtils::RequestHelper(this)) , m_logger(getLogger("MarkerManagementDialog")) { m_ui->setupUi(this); m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MarkerManagementDialog::onEditMarker); m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MarkerManagementDialog::onRemoveMarker); m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MarkerManagementDialog::onPrint); connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &MarkerManagementDialog::onEditMarker); connect(m_ui->chkOtherMarkers, &QCheckBox::toggled, this, &MarkerManagementDialog::onShowOtherUsersMarkers); setOnlineHelpFilename(QStringLiteral("Situation-Markers")); } MarkerManagementDialog::~MarkerManagementDialog() { delete m_ui; } void MarkerManagementDialog::retranslate() { translate(m_ui, tr("Marker")); } void MarkerManagementDialog::tableColumnOrganiserSetting() { //LtsColumnOrganiser m_ui->widget->setColumnsOrganiserEnabled(identifier(), true); } bool MarkerManagementDialog::init(const std::shared_ptr &dtc, const std::shared_ptr &ftc, const std::shared_ptr &flmFtc, const std::shared_ptr &avmInterface, const std::shared_ptr &flmGui) { if (!dtc || !ftc) return false; if (m_dtc) return true; m_dtc = dtc; m_ftc = ftc; m_flmFtc = flmFtc; m_avmInterface = avmInterface; m_flmGui = flmGui; m_model = new MarkerManagementDialogModel(this); MarkerSortFilterProxyModel *proxyModel = new MarkerSortFilterProxyModel(this); proxyModel->setOperatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId()); proxyModel->setSourceModel(m_model); m_model->initModel(dtc, nullptr, m_flmGui); m_ui->widget->setModel(proxyModel, [this]() { return new CustomViewMarker(this); }); m_ui->widget->hideColumn(MarkerManagementDialogModel::ColImage); m_ui->widget->hideColumn(MarkerManagementDialogModel::ColOperator); m_ui->widget->hideColumn(MarkerManagementDialogModel::ColFileId); m_ui->widget->hideColumn(MarkerManagementDialogModel::ColOffset); #ifndef LTS_DEBUG m_ui->widget->hideColumn(MarkerManagementDialogModel::ColStreams); #endif connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &MarkerManagementDialog::enaDisa); enaDisa(); return true; } void MarkerManagementDialog::enaDisa() { QModelIndexList selectedRows = m_ui->widget->selectedRows(); const int cntSelectedRows = selectedRows.size(); m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (cntSelectedRows == 1)); m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (cntSelectedRows > 0)); } void MarkerManagementDialog::onEditMarker() { const QModelIndex idx = m_ui->widget->currentIndex(); if (!idx.isValid()) return; const MarkerManagement::Marker marker = m_model->getRowData(idx.row()); if (marker.id() <= 0) return; DEBUG_LOG(m_logger) << "current MarkerId: " << marker.id(); AudioVideoManagement::StreamNameMapping *streamNameMapping = nullptr; if (m_avmInterface) streamNameMapping = m_avmInterface->streamNameMapping(); MarkerEditDialog *dialog = new MarkerEditDialog(marker.id(), m_dtc, m_ftc, streamNameMapping); addDialog(dialog, m_menuGroup, QStringLiteral("EditMarker%1").arg(marker.id())); } void MarkerManagementDialog::onRemoveMarker() { const QModelIndex idx = m_ui->widget->currentIndex(); if (!idx.isValid()) return; const MarkerManagement::Marker marker = m_model->getRowData(idx.row()); if (marker.id() <= 0) return; Core::RemoveElementRequest req(marker.id()); m_requestHelper->addRequest([req, this]() { return m_ftc->markerRemoveRequest(req, this); }); if (marker.fileContentId() > 0) { Core::RemoveElementRequest req1(marker.fileContentId()); m_requestHelper->addRequest([req1, this]() { return m_flmFtc->fileContentRemoveRequest(req1, this); }); } m_requestHelper->startRequests(); } void MarkerManagementDialog::onPrint() { LtsPrinting::printView(m_session, this, m_ui->widget->treeView()); } void MarkerManagementDialog::onShowOtherUsersMarkers(bool isChecked) { MarkerSortFilterProxyModel *proxyModel = static_cast(m_ui->widget->proxyModel()); if (!proxyModel) return; proxyModel->setShowOtherUsersMarkers(isChecked); } } // namespace MarkerManagement