summaryrefslogtreecommitdiffstats
path: root/kmymoney2/dialogs/kmymoneysplittable.h
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/kmymoneysplittable.h
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/kmymoneysplittable.h')
-rw-r--r--kmymoney2/dialogs/kmymoneysplittable.h264
1 files changed, 264 insertions, 0 deletions
diff --git a/kmymoney2/dialogs/kmymoneysplittable.h b/kmymoney2/dialogs/kmymoneysplittable.h
new file mode 100644
index 0000000..023660f
--- /dev/null
+++ b/kmymoney2/dialogs/kmymoneysplittable.h
@@ -0,0 +1,264 @@
+/***************************************************************************
+ kmymoneysplittable.h - description
+ -------------------
+ begin : Thu Jan 10 2002
+ copyright : (C) 2000-2002 by Michael Edwardes
+ email : mte@users.sourceforge.net
+ Javier Campos Morales <javi_c@users.sourceforge.net>
+ Felix Rodriguez <frodriguez@users.sourceforge.net>
+ John C <thetacoturtle@users.sourceforge.net>
+ Thomas Baumgart <ipwizard@users.sourceforge.net>
+ Kevin Tambascio <ktambascio@users.sourceforge.net>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KMYMONEYSPLITTABLE_H
+#define KMYMONEYSPLITTABLE_H
+
+// ----------------------------------------------------------------------------
+// QT Includes
+
+#include <qwidget.h>
+#include <qtable.h>
+#include <qwidgetlist.h>
+#include <qguardedptr.h>
+
+// ----------------------------------------------------------------------------
+// KDE Includes
+
+class KPopupMenu;
+class KPushButton;
+
+// ----------------------------------------------------------------------------
+// Project Includes
+
+#include "../mymoney/mymoneytransaction.h"
+#include "../mymoney/mymoneyaccount.h"
+
+class KMyMoneyCategory;
+class kMyMoneyLineEdit;
+class kMyMoneyEdit;
+
+/**
+ * @author Thomas Baumgart
+ */
+class kMyMoneySplitTable : public QTable
+{
+ Q_OBJECT
+public:
+ kMyMoneySplitTable(QWidget *parent=0, const char *name=0);
+ virtual ~kMyMoneySplitTable();
+
+ void paintCell(QPainter *p, int row, int col, const QRect& r, bool /*selected*/);
+ void paintFocus(QPainter *p, const QRect &cr);
+
+ /**
+ * This method is used to load the widget with the information about
+ * the transaction @p t. The split referencing the account @p acc is
+ * not shown in the widget.
+ *
+ * @param t reference to transaction to be shown/modified
+ * @param s reference to split that is to be hidden
+ * @param acc reference to account
+ */
+ void setTransaction(const MyMoneyTransaction& t, const MyMoneySplit& s, const MyMoneyAccount& acc);
+
+ /**
+ * This method is used to retrieve the transaction from the widget.
+ */
+ const MyMoneyTransaction& transaction(void) const { return m_transaction; }
+
+ /**
+ * Returns a list of MyMoneySplit objects. It contains all but the one
+ * referencing the account passed in setTransaction().
+ *
+ * @param t reference to transaction
+ * @return list of splits
+ */
+ const QValueList<MyMoneySplit> getSplits(const MyMoneyTransaction& t) const;
+
+ void setup(const QMap<QString, MyMoneyMoney>& priceInfo);
+
+protected:
+ void contentsMousePressEvent( QMouseEvent* e );
+ void contentsMouseReleaseEvent( QMouseEvent* e );
+ void contentsMouseDoubleClickEvent( QMouseEvent* e );
+ bool eventFilter(QObject *o, QEvent *e);
+ void endEdit(int row, int col, bool accept, bool replace );
+
+ void resizeEvent(QResizeEvent*);
+ QWidget* createEditWidgets(void);
+ void destroyEditWidgets(void);
+
+ /**
+ * This method handles the focus of the keyboard. When in edit mode
+ * (m_editCategory widget is visible) the keyboard focus is handled
+ * according to the widgets that are referenced in m_tabOrderWidgets.
+ * If not in edit mode, the base class functionality is provided.
+ *
+ * @param next true if forward-tab, false if backward-tab was
+ * pressed by the user
+ */
+ virtual bool focusNextPrevChild(bool next);
+ void addToTabOrder(QWidget* w);
+
+ /**
+ * convenience function for setCurrentCell(int row, int col)
+ */
+ void setCurrentCell(int row) { setCurrentCell(row, 0); }
+
+ void updateTransactionTableSize(void);
+
+ /**
+ * This method returns the current state of the inline editing mode
+ *
+ * @return true if inline edit mode is on, false otherwise
+ */
+ bool isEditMode(void) const;
+
+ /**
+ * This method retuns the background color for a given @p row.
+ *
+ * @param row the row in question
+ * @return the color as QColor object
+ */
+ const QColor rowBackgroundColor(const int row) const;
+
+ void endEdit(bool keyboardDriven);
+
+public slots:
+ /** No descriptions */
+ virtual void setCurrentCell(int row, int col);
+
+ virtual void setNumRows(int r);
+
+ QWidget* slotStartEdit(void);
+ void slotEndEdit(void);
+ void slotEndEditKeyboard(void);
+ void slotDeleteSplit(void);
+ void slotCancelEdit(void);
+ void slotDuplicateSplit(void);
+
+protected slots:
+ virtual void columnWidthChanged(int col);
+
+ /// move the focus to the selected @p row.
+ void slotSetFocus(int row, int col = 0, int button = Qt::LeftButton, const QPoint & mousePos = QPoint(0, 0));
+
+ /**
+ * Calling this slot refills the widget with the data
+ * passed in the argument @p t.
+ *
+ * @param t reference to transaction data
+ */
+ void slotUpdateData(const MyMoneyTransaction& t);
+
+ void slotLoadEditWidgets(void);
+
+signals:
+ /**
+ * This signal is emitted whenever the return key is pressed
+ * and the widget is not in edit mode.
+ */
+ void escapePressed(void);
+
+ /**
+ * This signal is emitted whenever the return key is pressed
+ * and the widget is not in edit mode.
+ */
+ void returnPressed(void);
+
+ /**
+ * This signal is emitted whenever the transaction data has been changed
+ *
+ * @param t modified transaction data
+ */
+ void transactionChanged(const MyMoneyTransaction& t);
+
+ /**
+ * This signal is sent out, when a new category needs to be created
+ * @sa KMyMoneyCombo::createItem()
+ *
+ * @param txt The name of the category to be created
+ * @param id A connected slot should store the id of the created object in this variable
+ */
+ void createCategory(const QString& txt, QString& id);
+
+ /**
+ * Signal is emitted, if any of the widgets enters (@a state equals @a true)
+ * or leaves (@a state equals @a false) object creation mode.
+ *
+ * @param state Enter (@a true) or leave (@a false) object creation
+ */
+ void objectCreation(bool state);
+
+private:
+ /// the currently selected row (will be printed as selected)
+ int m_currentRow;
+
+ /// the number of rows filled with data
+ int m_maxRows;
+
+ /// indication if inline editing mode is on or not
+ bool m_editMode;
+
+ MyMoneyTransaction m_transaction;
+ MyMoneyAccount m_account;
+ MyMoneySplit m_split;
+ MyMoneySplit m_hiddenSplit;
+
+ unsigned m_amountWidth;
+
+ /**
+ * This member keeps a pointer to the context menu
+ */
+ KPopupMenu* m_contextMenu;
+
+ /// keeps the id of the delete entry in the context menu
+ int m_contextMenuDelete;
+
+ /// keeps the id of the duplicate entry in the context menu
+ int m_contextMenuDuplicate;
+
+ /**
+ * This member contains a pointer to the input widget for the category.
+ * The widget will be created and destroyed dynamically in createInputWidgets()
+ * and destroyInputWidgets().
+ */
+ QGuardedPtr<KMyMoneyCategory> m_editCategory;
+
+ /**
+ * This member contains a pointer to the input widget for the memo.
+ * The widget will be created and destroyed dynamically in createInputWidgets()
+ * and destroyInputWidgets().
+ */
+ QGuardedPtr<kMyMoneyLineEdit> m_editMemo;
+
+ /**
+ * This member contains a pointer to the input widget for the amount.
+ * The widget will be created and destroyed dynamically in createInputWidgets()
+ * and destroyInputWidgets().
+ */
+ QGuardedPtr<kMyMoneyEdit> m_editAmount;
+
+ /**
+ * This member keeps the tab order for the above widgets
+ */
+ QWidgetList m_tabOrderWidgets;
+
+ QGuardedPtr<QFrame> m_registerButtonFrame;
+ QGuardedPtr<KPushButton> m_registerEnterButton;
+ QGuardedPtr<KPushButton> m_registerCancelButton;
+
+ QMap<QString, MyMoneyMoney> m_priceInfo;
+};
+
+#endif