blob: 1652877047d34d0d0f8647cfa8dde44a0dae3736 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/***************************************************************************
registeritem.cpp - description
-------------------
begin : Tue Jun 13 2006
copyright : (C) 2000-2006 by Thomas Baumgart
email : Thomas Baumgart <ipwizard@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. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// ----------------------------------------------------------------------------
// QT Includes
// ----------------------------------------------------------------------------
// KDE Includes
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoney/registeritem.h>
#include <kmymoney/register.h>
#include "../kmymoneyglobalsettings.h"
using namespace KMyMoneyRegister;
TQDate 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();
}
TQFontMetrics fm( KMyMoneyGlobalSettings::listCellFont() );
return fm.lineSpacing()+6;
}
|