summaryrefslogtreecommitdiffstats
path: root/kmymoney2/dialogs/keditequityentrydlg.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-04 22:38:03 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-04 22:38:03 +0000
commitdadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (patch)
tree99e72842fe687baea16376a147619b6048d7e441 /kmymoney2/dialogs/keditequityentrydlg.cpp
downloadkmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.tar.gz
kmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.zip
Added kmymoney
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239792 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmymoney2/dialogs/keditequityentrydlg.cpp')
-rw-r--r--kmymoney2/dialogs/keditequityentrydlg.cpp138
1 files changed, 138 insertions, 0 deletions
diff --git a/kmymoney2/dialogs/keditequityentrydlg.cpp b/kmymoney2/dialogs/keditequityentrydlg.cpp
new file mode 100644
index 0000000..854ce9a
--- /dev/null
+++ b/kmymoney2/dialogs/keditequityentrydlg.cpp
@@ -0,0 +1,138 @@
+/***************************************************************************
+ keditequityentrydlg.cpp - description
+ -------------------
+ begin : Sat Mar 6 2004
+ copyright : (C) 2000-2004 by Michael Edwardes
+ Javier Campos Morales <[email protected]>
+ Felix Rodriguez <[email protected]>
+ Thomas Baumgart <[email protected]>
+ Kevin Tambascio <[email protected]>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+// ----------------------------------------------------------------------------
+// QT Includes
+#include <qtimer.h>
+
+// ----------------------------------------------------------------------------
+// KDE Includes
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kpushbutton.h>
+#include <kiconloader.h>
+#include <kcombobox.h>
+
+// ----------------------------------------------------------------------------
+// Project Includes
+
+#include "keditequityentrydlg.h"
+#include "kupdatestockpricedlg.h"
+#include "../widgets/kmymoneypriceview.h"
+
+KEditEquityEntryDlg::KEditEquityEntryDlg(const MyMoneySecurity& selectedSecurity, QWidget *parent, const char *name)
+ : KEditEquityEntryDecl(parent, name, true)
+{
+ m_selectedSecurity = selectedSecurity;
+
+ connect(btnOK, SIGNAL(clicked()), this, SLOT(slotOKClicked()));
+ connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(edtEquityName, SIGNAL(textChanged(const QString &)), this, SLOT(slotDataChanged()));
+ connect(edtMarketSymbol, SIGNAL(textChanged(const QString &)), this, SLOT(slotDataChanged()));
+ connect(edtFraction, SIGNAL(textChanged(const QString&)), this, SLOT(slotDataChanged()));
+ connect(btnAddEntry, SIGNAL(clicked()), kpvPriceHistory, SLOT(slotAddPrice()));
+ connect(btnEditEntry, SIGNAL(clicked()), kpvPriceHistory, SLOT(slotEditPrice()));
+ connect(btnRemoveEntry, SIGNAL(clicked()), kpvPriceHistory, SLOT(slotDeletePrice()));
+ connect(kpvPriceHistory, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(slotSelectionChanged(QListViewItem*)));
+
+ //fill in the fields with what we know.
+ edtEquityName->setText(m_selectedSecurity.name());
+ edtMarketSymbol->setText(m_selectedSecurity.tradingSymbol());
+ edtFraction->setPrecision(0);
+ edtFraction->setCalculatorButtonVisible(false);
+ edtFraction->loadText(QString::number(m_selectedSecurity.smallestAccountFraction()));
+ cmbInvestmentType->setCurrentItem((int)m_selectedSecurity.securityType());
+ // FIXME PRICE
+ // kpvPriceHistory->setHistory(m_selectedSecurity.priceHistory());
+
+ // add icons to buttons
+ KIconLoader *il = KGlobal::iconLoader();
+ btnOK->setGuiItem(KStdGuiItem::ok());
+ btnCancel->setGuiItem(KStdGuiItem::cancel());
+ btnRemoveEntry->setGuiItem(KStdGuiItem::remove());
+ btnAddEntry->setGuiItem(KStdGuiItem::add());
+
+ KGuiItem editButtenItem( i18n( "&Edit" ),
+ QIconSet(il->loadIcon("edit", KIcon::Small, KIcon::SizeSmall)),
+ i18n("Modify the selected entry"),
+ i18n("Change the price information of the selected entry."));
+ btnEditEntry->setGuiItem(editButtenItem);
+
+ slotSelectionChanged(0); // make sure buttons are disabled in the beginning
+ slotDataChanged();
+ m_changes = false;
+
+ // force a resize to optimize the layout of all widgets
+ resize(width()-1, height()-1);
+ QTimer::singleShot(10, this, SLOT(slotTimerDone()));
+}
+
+KEditEquityEntryDlg::~KEditEquityEntryDlg()
+{
+}
+
+void KEditEquityEntryDlg::slotTimerDone(void)
+{
+ // the resize operation does the trick to adjust
+ // all widgets in the view to the size they should
+ // have and show up correctly. Don't ask me, why
+ // this is, but it cured the problem (ipwizard).
+ resize(width()+1, height()+1);
+}
+
+/** No descriptions */
+void KEditEquityEntryDlg::slotOKClicked()
+{
+ if(m_changes /* || kpvPriceHistory->dirty() */)
+ {
+ m_selectedSecurity.setName(edtEquityName->text());
+ m_selectedSecurity.setTradingSymbol(edtMarketSymbol->text());
+ m_selectedSecurity.setSmallestAccountFraction(edtFraction->value().abs());
+ // FIXME PRICE
+ // m_selectedSecurity.setPriceHistory(kpvPriceHistory->history());
+ }
+
+ accept();
+}
+
+void KEditEquityEntryDlg::slotSelectionChanged(QListViewItem* item)
+{
+ btnEditEntry->setEnabled(item != 0);
+ btnRemoveEntry->setEnabled(item != 0);
+}
+
+void KEditEquityEntryDlg::slotDataChanged(void)
+{
+ bool okEnabled = true;
+
+ if(!edtFraction->value().isPositive()
+ || edtMarketSymbol->text().isEmpty()
+ || edtEquityName->text().isEmpty())
+ okEnabled = false;
+
+ btnOK->setEnabled(okEnabled);
+
+ m_changes = true;
+}
+
+#include "keditequityentrydlg.moc"