summaryrefslogtreecommitdiffstats
path: root/kmymoney2/widgets/kmymoneyforecastlistviewitem.cpp
blob: 6bfd1c2f79a706a020d263a4035850fda4a16eda (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
/***************************************************************************
                          kmymoneylistviewitem  -  description
                             -------------------
    begin                : Sun Nov 25 2007
    copyright            : (C) 2007 by Alvaro Soliverez
    email                : asoliverez@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 <tqpalette.h>
#include <tqpen.h>
#include <tqcolor.h>
#include <tqpainter.h>

// ----------------------------------------------------------------------------
// KDE Includes

// ----------------------------------------------------------------------------
// Project Includes

#include "kmymoneyforecastlistviewitem.h"

#include <kmymoney/kmymoneyglobalsettings.h>

KMyMoneyForecastListViewItem::KMyMoneyForecastListViewItem (TQListView* tqparent, TQListViewItem* after, bool isNegative) :
  KListViewItem(tqparent, after),
  m_negative(isNegative)
{
}

KMyMoneyForecastListViewItem::~KMyMoneyForecastListViewItem()
{
}

void KMyMoneyForecastListViewItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int tqalignment)
{
  TQColorGroup _cg = cg;
  TQColor textColour;
  if(m_negative == true) {
    textColour = KMyMoneyGlobalSettings::listNegativeValueColor(); //if the item is marked is marked as negative, all columns will be painted negative
  } else {
    textColour = m_columnsColor[column]; //otherwise, respect the color for each column
  }
  _cg.setColor(TQColorGroup::Text, textColour); 
  
  KListViewItem::paintCell(p, _cg, column, width, tqalignment);
}

void KMyMoneyForecastListViewItem::setNegative(bool isNegative)
{
  m_negative = isNegative;
}

void KMyMoneyForecastListViewItem::setText( int column, const TQString &text, const bool &negative)
{
  //if negative set the map to negative color according to KMyMoneySettings
  if(negative) {
    m_columnsColor[column] = KMyMoneyGlobalSettings::listNegativeValueColor();
  } else {
    m_columnsColor[column] = TQColorGroup::Text;
  }
  
  KListViewItem::setText(column, text);
}