diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 22:38:03 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 22:38:03 +0000 |
commit | dadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (patch) | |
tree | 99e72842fe687baea16376a147619b6048d7e441 /kmymoney2/widgets/registeritem.cpp | |
download | kmymoney-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/widgets/registeritem.cpp')
-rw-r--r-- | kmymoney2/widgets/registeritem.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/kmymoney2/widgets/registeritem.cpp b/kmymoney2/widgets/registeritem.cpp new file mode 100644 index 0000000..6ef082f --- /dev/null +++ b/kmymoney2/widgets/registeritem.cpp @@ -0,0 +1,116 @@ +/*************************************************************************** + registeritem.cpp - description + ------------------- + begin : Tue Jun 13 2006 + copyright : (C) 2000-2006 by Thomas Baumgart + email : Thomas Baumgart <[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 + +// ---------------------------------------------------------------------------- +// KDE Includes + +// ---------------------------------------------------------------------------- +// Project Includes + +#include <kmymoney/registeritem.h> +#include <kmymoney/register.h> + +#include "../kmymoneyglobalsettings.h" + +using namespace KMyMoneyRegister; + +QDate RegisterItem::nullDate; +MyMoneyMoney RegisterItem::nullValue; + +RegisterItem::RegisterItem() : + m_parent(0), + m_prev(0), + m_next(0) +{ + init(); +} + +RegisterItem::RegisterItem(Register* parent) : + m_parent(parent), + m_prev(0), + m_next(0) +{ + init(); + parent->addItem(this); +} + +void RegisterItem::init(void) +{ + m_startRow = 0; + m_rowsRegister = 1; + m_rowsForm = 1; + m_visible = true; +} + +RegisterItem::~RegisterItem() +{ + m_parent->removeItem(this); +} + +void RegisterItem::setParent(Register* parent) +{ + m_parent = parent; +} + +void RegisterItem::setNumRowsRegister(int rows) +{ + if(rows != m_rowsRegister) { + m_rowsRegister = rows; + if(m_parent) + m_parent->forceUpdateLists(); + } +} + +bool RegisterItem::markVisible(bool visible) +{ + if(m_visible == visible) + return false; + m_visible = visible; + return true; +} + +void RegisterItem::setVisible(bool visible) +{ + if(markVisible(visible) && m_parent) { + if(visible) { + for(int i = startRow(); i < startRow() + numRowsRegister(); ++i) { + m_parent->showRow(i); + m_parent->setRowHeight(i, rowHeightHint()); + } + } else { + for(int i = startRow(); i < startRow() + numRowsRegister(); ++i) { + m_parent->hideRow(i); + } + } + } +} + +int RegisterItem::rowHeightHint(void) const +{ + if(!m_visible) + return 0; + + if(m_parent) { + return m_parent->rowHeightHint(); + } + + QFontMetrics fm( KMyMoneyGlobalSettings::listCellFont() ); + return fm.lineSpacing()+6; +} |