From dadc34655c3ab961b0b0b94a10eaaba710f0b5e8 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 4 Jul 2011 22:38:03 +0000 Subject: Added kmymoney git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239792 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmymoney2/widgets/transactionform.h | 223 ++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 kmymoney2/widgets/transactionform.h (limited to 'kmymoney2/widgets/transactionform.h') diff --git a/kmymoney2/widgets/transactionform.h b/kmymoney2/widgets/transactionform.h new file mode 100644 index 0000000..13116da --- /dev/null +++ b/kmymoney2/widgets/transactionform.h @@ -0,0 +1,223 @@ +/*************************************************************************** + transactionform.h + ---------- + begin : Sun May 14 2006 + copyright : (C) 2006 by Thomas Baumgart + email : Thomas Baumgart + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 TRANSACTIONFORM_H +#define TRANSACTIONFORM_H + +// ---------------------------------------------------------------------------- +// QT Includes + +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +// KDE Includes + +// ---------------------------------------------------------------------------- +// Project Includes + +#include +#include +#include + +#include "../kmymoneysettings.h" + +class MyMoneyObjectContainer; + +namespace KMyMoneyTransactionForm { + +/** + * @author Thomas Baumgart + */ +class TabBar : public QTabBar +{ + Q_OBJECT +public: + typedef enum { + SignalNormal = 0, // standard signal behaviour + SignalNever, // don't signal selection of a tab at all + SignalAlways // always signal selection of a tab + } SignalEmissionE; + + TabBar(QWidget* parent = 0, const char* name = 0); + virtual ~TabBar() {} + + SignalEmissionE setSignalEmission(SignalEmissionE type); + + void copyTabs(const TabBar* otabbar); + + void addTab(QTab* tab, int id); + + void setIdentifier(QTab* tab, int newId); + + QTab* tab(int id) const; + + int currentTab(void) const; + +public slots: + /** + * overridden for internal reasons, API not changed + */ + virtual void setCurrentTab( int ); + + /** + * overridden for internal reasons, API not changed + */ + virtual void setCurrentTab( QTab * ); + + /** + * overridden for internal reasons, API not changed + */ + virtual void show(void); + +protected slots: + void slotTabSelected(int id); + +signals: + void tabSelected(int id); + +private: + SignalEmissionE m_signalType; + + /** + * maps our internal action ids to those used by + * qt3. Since it does not seem possible to tell + * qt3 to use our ids everywhere (in QAccel) we + * need to know which is which + */ + QMap m_idMap; + + +}; + +typedef enum { + LabelColumn1 = 0, + ValueColumn1, + LabelColumn2, + ValueColumn2, + // insert new values above this line + MaxColumns +} Column; + +/** + * @author Thomas Baumgart + */ +class TransactionForm : public TransactionEditorContainer +{ + Q_OBJECT +public: + TransactionForm(QWidget *parent = 0, const char *name = 0); + virtual ~TransactionForm() {} + + /** + * Override the QTable member function to avoid display of focus + */ + void paintFocus(QPainter* /*p*/, const QRect& /*cr*/ ) {} + + QSize tableSize(void) const; + QSize sizeHint(void) const; + void adjustColumn(Column col); + void clear(void); + + void paintCell(QPainter* painter, int row, int col, const QRect& r, bool selected, const QColorGroup& cg); + + void resize(int col); + + void arrangeEditWidgets(QMap& editWidgets, KMyMoneyRegister::Transaction* t); + void removeEditWidgets(QMap& editWidgets); + void tabOrder(QWidgetList& tabOrderWidgets, KMyMoneyRegister::Transaction* t) const; + + /** + * reimplemented to prevent normal cell selection behavior + */ + void setCurrentCell(int, int) {} + + TabBar* tabBar(QWidget* parent = 0); + + void setupForm(const MyMoneyAccount& acc); + + void enableTabBar(bool b); + + protected: + /** + * reimplemented to support QWidget::WState_BlockUpdates + */ + void drawContents(QPainter *p, int cx, int cy, int cw, int ch); + + /** + * reimplemented to prevent normal mouse press behavior + */ + void contentsMousePressEvent(QMouseEvent* ev) { ev->ignore(); } + + /** + * reimplemented to prevent normal mouse move behavior + */ + void contentsMouseMoveEvent(QMouseEvent* ev) { ev->ignore(); } + + /** + * reimplemented to prevent normal mouse release behavior + */ + void contentsMouseReleaseEvent(QMouseEvent* ev) { ev->ignore(); } + + /** + * reimplemented to prevent normal mouse double click behavior + */ + void contentsMouseDoubleClickEvent(QMouseEvent* ev) { ev->ignore(); } + + /** + * reimplemented to prevent normal keyboard behavior + */ + void keyPressEvent(QKeyEvent* ev) { ev->ignore(); } + + /** + * Override logic and use standard QFrame behaviour + */ + bool focusNextPrevChild(bool next); + +public slots: + void slotSetTransaction(KMyMoneyRegister::Transaction* item); + +protected slots: + void resize(void); + + /** + * Helper method to convert @a int into @a KMyMoneyRegister::Action + */ + void slotActionSelected(int); + +signals: + /** + * This signal is emitted when a user selects a tab. @a id + * contains the tab's id (e.g. KMyMoneyRegister::ActionDeposit) + */ + void newTransaction(KMyMoneyRegister::Action id); + +protected: + KMyMoneyRegister::Transaction* m_transaction; + QColorGroup m_cellColorGroup; + TabBar* m_tabBar; +}; + + +} // namespace + +#endif +// vim:cin:si:ai:et:ts=2:sw=2: -- cgit v1.2.1