Commit ae25b72b authored by Thomas Baumgart's avatar Thomas Baumgart
Browse files

Prevent creation of schedules that are not assigned to an account

BUG: 416410
FIXED-IN: 5.0.8
(cherry picked from commit f9bc63cd)
parent d8e96afe
......@@ -263,7 +263,7 @@ TransactionEditor* KEditScheduleDlg::startEdit()
if (editor) {
editor->setScheduleInfo(d->ui->m_nameEdit->text());
connect(editor, &TransactionEditor::transactionDataSufficient, d->ui->buttonBox->button(QDialogButtonBox::Ok), &QWidget::setEnabled);
connect(editor, &TransactionEditor::transactionDataSufficient, d->m_requiredFields, &KMandatoryFieldGroup::setExternalMandatoryState);
connect(editor, &TransactionEditor::escapePressed, d->ui->buttonBox->button(QDialogButtonBox::Cancel), &QAbstractButton::animateClick);
connect(editor, &TransactionEditor::returnPressed, d->ui->buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::animateClick);
......
......@@ -63,15 +63,17 @@ class KMandatoryFieldGroupPrivate
Q_DISABLE_COPY(KMandatoryFieldGroupPrivate)
public:
KMandatoryFieldGroupPrivate() :
m_okButton(0),
m_enabled(true)
KMandatoryFieldGroupPrivate()
: m_okButton(0)
, m_enabled(true)
, m_externalMandatoryState(true)
{
}
QList<QWidget *> m_widgets;
QPushButton* m_okButton;
bool m_enabled;
bool m_externalMandatoryState;
};
KMandatoryFieldGroup::KMandatoryFieldGroup(QObject *parent) :
......@@ -180,10 +182,19 @@ void KMandatoryFieldGroup::setOkButton(QPushButton *button)
changed();
}
void KMandatoryFieldGroup::setExternalMandatoryState(bool state)
{
Q_D(KMandatoryFieldGroup);
if (d->m_externalMandatoryState != state) {
d->m_externalMandatoryState = state;
changed();
}
}
void KMandatoryFieldGroup::changed()
{
Q_D(KMandatoryFieldGroup);
bool enable = true;
bool enable = d->m_externalMandatoryState;
QList<QWidget *>::ConstIterator i;
for (i = d->m_widgets.constBegin(); i != d->m_widgets.constEnd(); ++i) {
QWidget *widget = *i;
......
......@@ -89,6 +89,15 @@ public Q_SLOTS:
*/
void changed();
/**
* Use this slot to set the initial @a state when checking
* for all mandatory data. This can be used to add support
* for widgets that are not directly supported by
* this object. The default @a state when this method
* was never called is @c true.
*/
void setExternalMandatoryState(bool state);
Q_SIGNALS:
void stateChanged();
void stateChanged(bool state);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment