Files
qt5-legatus-legacy/Lts/Plugins/InfrastructureManagement/Gui/ResourceManagement/PlanChooser/new_plan_dialog.cpp
T
2026-08-13 18:33:10 +02:00

69 lines
1.9 KiB
C++
Executable File

/**
* @RDE_HEADER@
* PlanChooser - New Plan Dialog - Asks for Plan name
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2017-04-20
*/
#include "new_plan_dialog.h"
#include "ui_new_plan_dialog.h"
#include <LtsSession/lts_session.h>
#include <QDateTime>
namespace InfrastructureManagement
{
NewPlanDialog::NewPlanDialog(LtsSession::LtsSession *session, QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::NewPlanDialog)
, m_session(session)
, m_logger(getLogger("NewPlanDialog"))
{
setWindowTitle(tr("Create New Plan"));
m_ui->setupUi(this);
connect(m_ui->pbCreate, &QPushButton::clicked, this, &NewPlanDialog::accept);
connect(m_ui->pbCancel, &QPushButton::clicked, this, &NewPlanDialog::reject);
Qt::WindowFlags wf = Qt::FramelessWindowHint; // make frameless, shadow replaces the border / frame
//setModal(true);
wf |= Qt::Dialog;
wf |= Qt::WindowStaysOnTopHint;
setWindowFlags(wf);
m_ui->dteBegin->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
m_ui->dteEnd->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
//m_ui->dteBegin->setMsecsSinceEpoch(QDateTime::currentMSecsSinceEpoch());
//m_ui->dteEnd->setMsecsSinceEpoch(QDateTime::currentMSecsSinceEpoch());
}
NewPlanDialog::~NewPlanDialog()
{
delete m_ui;
}
void NewPlanDialog::init(const std::shared_ptr<ForeignGuiComboboxInterface> &ismCbx)
{
ismCbx->fillScheduleStatusComboBox(m_ui->cbStatus);
m_ui->cbStatus->setCurrentIndex(m_ui->cbStatus->findData(ScheduleStatus::Inactive));
}
bool NewPlanDialog::getData(QString &name, qint64 &begin, qint64 &end, int &status)
{
if (exec() != QDialog::Accepted)
return false;
name = m_ui->lePlanName->text();
begin = m_ui->dteBegin->msecsSinceEpoch();
end = m_ui->dteEnd->msecsSinceEpoch();
status = static_cast<ScheduleStatus::type>(m_ui->cbStatus->currentData().toInt());
return true;
}
} // namespace InfrastructureManagement