Commit 3422b775 authored by Allan Anderson's avatar Allan Anderson
Browse files

BUG:289351 - Editing mulitple transactions - cannot change Memo field.

Reinstate previous fix, allow memo field to be empty, and allow date to be edited.
parent 3546eb8c
......@@ -49,7 +49,7 @@ bool Activity::isComplete(QString& reason) const
bool rc = false;
KMyMoneySecurity* security = dynamic_cast<KMyMoneySecurity*>(haveWidget("security"));
if (!security->currentText().isEmpty()) {
rc = security->selector()->contains(security->currentText());
rc = (security->selector()->contains(security->currentText()) || (isMultiSelection() && m_memoChanged));
}
return rc;
}
......
......@@ -56,6 +56,8 @@ public:
virtual void preloadAssetAccount(void);
virtual ~Activity() {}
bool m_memoChanged;
QString m_memoText;
protected:
Activity(InvestTransactionEditor* editor) {
......
......@@ -253,6 +253,11 @@ void InvestTransactionEditor::createEditWidgets(void)
KTextEdit* memo = new KTextEdit;
memo->setTabChangesFocus(true);
m_editWidgets["memo"] = memo;
connect(memo, SIGNAL(textChanged()), this, SLOT(slotUpdateInvestMemoState()));
connect(memo, SIGNAL(textChanged()), this, SLOT(slotUpdateButtonState()));
d->m_activity->m_memoText.clear();
d->m_activity->m_memoChanged = false;
kMyMoneyEdit* value = new kMyMoneyEdit;
value->setClickMessage(i18n("Shares"));
......@@ -622,6 +627,11 @@ void InvestTransactionEditor::loadEditWidgets(KMyMoneyRegister::Action /* action
aSet.clear();
aSet.load(security->selector(), i18n("Security"), m_account.accountList(), true);
// memo
memo->setText(m_split.memo());
d->m_activity->m_memoText = m_split.memo();
d->m_activity->m_memoChanged = false;
if (!isMultiSelection()) {
// date
if (m_transaction.postDate().isValid())
......@@ -658,9 +668,6 @@ void InvestTransactionEditor::loadEditWidgets(KMyMoneyRegister::Action /* action
setupCategoryWidget(fees, m_feeSplits, id, SLOT(slotEditFeeSplits()));
slotUpdateFeeVisibility(fees->currentText());
// memo
memo->setText(m_split.memo());
// shares
// don't set the value if the number of shares is zero so that
// we can see the hint
......@@ -695,7 +702,6 @@ void InvestTransactionEditor::loadEditWidgets(KMyMoneyRegister::Action /* action
} else {
postDate->loadDate(QDate());
reconcile->setState(MyMoneySplit::Unknown);
memo->setText(QString());
// We don't allow to change the activity
activity->setActivity(d->m_activity->type());
......@@ -1035,7 +1041,7 @@ bool InvestTransactionEditor::createTransaction(MyMoneyTransaction& t, const MyM
// by the user
KTextEdit* memo = dynamic_cast<KTextEdit*>(m_editWidgets["memo"]);
if (memo) {
if (!isMultiSelection() || (isMultiSelection() && !memo->toPlainText().isEmpty()))
if (!isMultiSelection() || (isMultiSelection() && d->m_activity->m_memoChanged))
s0.setMemo(memo->toPlainText());
}
......@@ -1156,5 +1162,13 @@ void InvestTransactionEditor::setupFinalWidgets(void)
addFinalWidget(haveWidget("memo"));
}
void InvestTransactionEditor::slotUpdateInvestMemoState(void)
{
KTextEdit* memo = dynamic_cast<KTextEdit*>(m_editWidgets["memo"]);
if(memo) {
d->m_activity->m_memoChanged = (memo->toPlainText() != d->m_activity->m_memoText);
}
}
#include "investtransactioneditor.moc"
......@@ -121,6 +121,7 @@ protected slots:
void slotUpdateFeeVisibility(const QString&);
void slotUpdateTotalAmount(void);
void slotTransactionContainerGeometriesUpdated();
void slotUpdateInvestMemoState(void);
protected:
/**
......@@ -167,8 +168,8 @@ protected:
private:
MyMoneySplit m_assetAccountSplit;
QList<MyMoneySplit> m_interestSplits;
QList<MyMoneySplit> m_feeSplits;
QList<MyMoneySplit> m_interestSplits;
QList<MyMoneySplit> m_feeSplits;
MyMoneySecurity m_security;
MyMoneySecurity m_currency;
MyMoneySplit::investTransactionTypeE m_transactionType;
......
......@@ -272,6 +272,14 @@ void TransactionEditor::slotNumberChanged(const QString& txt)
}
}
void TransactionEditor::slotUpdateMemoState(void)
{
KTextEdit* memo = dynamic_cast<KTextEdit*>(m_editWidgets["memo"]);
if (memo) {
m_memoChanged = (memo->toPlainText() != m_memoText);
}
}
void TransactionEditor::slotUpdateButtonState(void)
{
QString reason;
......@@ -784,7 +792,11 @@ void StdTransactionEditor::createEditWidgets(void)
KTextEdit* memo = new KTextEdit;
memo->setObjectName(QLatin1String("Memo"));
memo->setTabChangesFocus(true);
connect(memo, SIGNAL(textChanged()), this, SLOT(slotUpdateMemoState()));
connect(memo, SIGNAL(textChanged()), this, SLOT(slotUpdateButtonState()));
m_editWidgets["memo"] = memo;
m_memoText.clear();
m_memoChanged = false;
bool showNumberField = true;
switch (m_account.accountType()) {
......@@ -819,6 +831,7 @@ void StdTransactionEditor::createEditWidgets(void)
kMyMoneyDateInput* postDate = new kMyMoneyDateInput;
m_editWidgets["postdate"] = postDate;
postDate->setObjectName(QLatin1String("PostDate"));
connect(postDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotUpdateButtonState()));
postDate->setDate(QDate());
kMyMoneyEdit* value = new kMyMoneyEdit;
......@@ -983,8 +996,13 @@ void StdTransactionEditor::loadEditWidgets(KMyMoneyRegister::Action action)
if (!m_account.id().isEmpty())
category->selector()->removeItem(m_account.id());
// also show memo text if isMultiSelection()
dynamic_cast<KTextEdit*>(m_editWidgets["memo"])->setText(m_split.memo());
// need to know if it changed
m_memoText = m_split.memo();
m_memoChanged = false;
if (!isMultiSelection()) {
dynamic_cast<KTextEdit*>(m_editWidgets["memo"])->setText(m_split.memo());
if (m_transaction.postDate().isValid())
dynamic_cast<kMyMoneyDateInput*>(m_editWidgets["postdate"])->setDate(m_transaction.postDate());
else if (m_lastPostDate.isValid())
......@@ -1765,6 +1783,8 @@ bool StdTransactionEditor::isComplete(QString& reason) const
bool payeeIsPresent = false;
bool categoryIsPresent = false;
bool amountIsPresent = false;
bool memoIsPresent = false;
bool dateIsPresent = false;
for (it_w = m_editWidgets.begin(); it_w != m_editWidgets.end(); ++it_w) {
KMyMoneyPayeeCombo* payee = dynamic_cast<KMyMoneyPayeeCombo*>(*it_w);
......@@ -1804,10 +1824,13 @@ bool StdTransactionEditor::isComplete(QString& reason) const
if (cashflow && cashflow->direction() != KMyMoneyRegister::Unknown)
break;
if (postDate->date().isValid() && (postDate->date() >= m_account.openingDate()))
if (postDate->date().isValid() && (postDate->date() >= m_account.openingDate())) {
dateIsPresent = true;
break;
}
if (memo && !memo->toPlainText().isEmpty()) {
if (memo && m_memoChanged) {
memoIsPresent = true;
break;
}
......@@ -1816,7 +1839,7 @@ bool StdTransactionEditor::isComplete(QString& reason) const
}
}
bool rc = (categoryIsPresent && amountIsPresent); // usual mandatory fields
bool rc1 = (payeeIsPresent || categoryIsPresent || amountIsPresent); // if isMultiSelection(), they are optional
bool rc1 = (payeeIsPresent || categoryIsPresent || amountIsPresent || memoIsPresent) || dateIsPresent; // if isMultiSelection(), these are optional
return (rc || (isMultiSelection() && (it_w != m_editWidgets.end() || rc1)));
}
......@@ -2035,7 +2058,7 @@ bool StdTransactionEditor::createTransaction(MyMoneyTransaction& t, const MyMone
// by the user
KTextEdit* memo = dynamic_cast<KTextEdit*>(m_editWidgets["memo"]);
if (memo) {
if (!isMultiSelection() || (isMultiSelection() && !memo->toPlainText().isEmpty()))
if (!isMultiSelection() || (isMultiSelection() && m_memoChanged))
s0.setMemo(memo->toPlainText());
}
......
......@@ -152,6 +152,8 @@ public:
void addFinalWidget(const QWidget*);
QString m_memoText;
public slots:
void slotReloadEditWidgets(void);
......@@ -184,6 +186,7 @@ protected:
protected slots:
void slotUpdateButtonState(void);
void slotUpdateMemoState(void);
void slotUpdateAccount(void);
void slotNumberChanged(const QString&);
......@@ -306,6 +309,7 @@ protected:
QMap<QString, MyMoneyMoney> m_priceInfo;
KMyMoneyRegister::Action m_initialAction;
bool m_openEditSplits;
bool m_memoChanged;
};
......
Supports Markdown
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