Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+123
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-06-08
|
||||
*/
|
||||
|
||||
#include "licenceedit.h"
|
||||
#include "ui_licenceedit.h"
|
||||
|
||||
#include <LtsLicence/lts_licence.h>
|
||||
|
||||
LicenceEdit::LicenceEdit(QWidget *parent)
|
||||
: NGLDialog(parent)
|
||||
, m_ui(new Ui::LicenceEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
clear();
|
||||
|
||||
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onOk,
|
||||
this, &LicenceEdit::onOk);
|
||||
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onCancel,
|
||||
this, &LicenceEdit::onCancel);
|
||||
connect(m_ui->chbIgnoreCount, &QCheckBox::stateChanged,
|
||||
this, &LicenceEdit::enableIgnoreCount);
|
||||
connect(m_ui->chbIgnoreExpiration, &QCheckBox::stateChanged,
|
||||
this, &LicenceEdit::enableIgnoreExpiration);
|
||||
connect(m_ui->leName, &QLineEdit::textChanged,
|
||||
this, &LicenceEdit::onNameChanged);
|
||||
}
|
||||
|
||||
LicenceEdit::~LicenceEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief enables QCheckBox "Ignore Count"
|
||||
* @param checkState
|
||||
*
|
||||
* The function enables or disables the QCheckBox "sbCount"
|
||||
* The parameter @checkState represents the CheckState of the QCheckBox.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void LicenceEdit::enableIgnoreCount(int checkState)
|
||||
{
|
||||
m_ui->lbxCount->setEnabled(checkState == Qt::Unchecked);
|
||||
m_ui->sbMaxCount->setEnabled(checkState == Qt::Unchecked);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief enables QCheckBox "Ignore Expiration"
|
||||
* @param i
|
||||
*
|
||||
* The function enables or disables the QCheckBox "sbExpiration"
|
||||
* The parameter "i" represents the CheckState of the QCheckBox.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void LicenceEdit::enableIgnoreExpiration(int checkState)
|
||||
{
|
||||
m_ui->lbxExpiry->setEnabled(checkState == Qt::Unchecked);
|
||||
m_ui->dateEdit->setEnabled(checkState == Qt::Unchecked);
|
||||
m_ui->timeEdit->setEnabled(checkState == Qt::Unchecked);
|
||||
}
|
||||
|
||||
void LicenceEdit::onNameChanged(const QString &name)
|
||||
{
|
||||
setWindowTitle(name.isEmpty() ? tr("Add Licence") : name);
|
||||
m_ui->nglDialogButtonBox->setEnabled(NGLStandardButton::Ok, !name.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
void LicenceEdit::setLicence(const LtsLicence::Licence &licence)
|
||||
{
|
||||
m_ui->leName->setText(licence.name);
|
||||
m_ui->dateEdit->setDate(licence.expiration.date());
|
||||
m_ui->timeEdit->setTime(licence.expiration.time());
|
||||
m_ui->sbMaxCount->setValue(licence.maxCount);
|
||||
m_ui->chbIgnoreCount->setChecked(licence.ignoreMaxCount);
|
||||
m_ui->chbIgnoreExpiration->setChecked(licence.ignoreExpiration);
|
||||
m_ui->leName->setEnabled(false);
|
||||
}
|
||||
|
||||
void LicenceEdit::clear()
|
||||
{
|
||||
m_ui->leName->clear();
|
||||
m_ui->chbIgnoreCount->setChecked(false);
|
||||
m_ui->chbIgnoreExpiration->setChecked(false);
|
||||
m_ui->dateEdit->setMinimumDate(QDate::currentDate());
|
||||
m_ui->dateEdit->setDate(QDateTime::currentDateTime().date());
|
||||
m_ui->timeEdit->setTime(QDateTime::currentDateTime().time());
|
||||
m_ui->sbMaxCount->setValue(1);
|
||||
m_ui->leName->setEnabled(true);
|
||||
m_ui->leName->setFocus();
|
||||
}
|
||||
|
||||
void LicenceEdit::onOk()
|
||||
{
|
||||
QDateTime dateTime(m_ui->dateEdit->date(), m_ui->timeEdit->time());
|
||||
|
||||
LtsLicence::Licence li;
|
||||
li.name = m_ui->leName->text();
|
||||
li.expiration = dateTime;
|
||||
li.maxCount = m_ui->sbMaxCount->text().toInt();
|
||||
li.ignoreMaxCount = m_ui->chbIgnoreCount->isChecked();
|
||||
li.ignoreExpiration = m_ui->chbIgnoreExpiration->isChecked();
|
||||
|
||||
emit newLicence(li);
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void LicenceEdit::onCancel()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
Reference in new issue
Block a user