summaryrefslogtreecommitdiff
path: root/noncore/apps/zsafe/shadedlistitem.cpp
blob: 72c62610d49785c6d322452c2d9fd8ca6eac7158 (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
/*
 * shadedlistitem.cpp
 *
 * (c) 2003 by Jeremy Bowman <jmbowman@alum.mit.edu>
 *
 * 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.
 */

#include "zsafe.h"
#include "shadedlistitem.h"


ShadedListItem::ShadedListItem(int index, QListViewItem *parent)
    : QListViewItem(parent)
{
    oddRow = (index % 2 != 0);
}

ShadedListItem::ShadedListItem(int index, QListView *parent)
    : QListViewItem(parent), lv(parent)
{
    oddRow = (index % 2 != 0);
}

ShadedListItem::ShadedListItem(int index, QListView *parent, QListViewItem *after)
    : QListViewItem(parent, after), lv(parent)
{
    oddRow = (index % 2 != 0);
}

ShadedListItem::ShadedListItem(int index, QListView *parent, QString label1, QString label2, QString label3)
    : QListViewItem(parent, label1, label2, label3), lv(parent)
{
    oddRow = (index % 2 != 0);
}

ShadedListItem::ShadedListItem(int index, QListView *parent, QListViewItem *after, QString label1, QString label2, QString label3)
    : QListViewItem(parent, after, label1, label2, label3), lv(parent)
{
    oddRow = (index % 2 != 0);
}

ShadedListItem::~ShadedListItem()
{

}


void ShadedListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
{
    QColorGroup colors(cg);
#if QT_VERSION >=300
    const QColorGroup::ColorRole crole = QColorGroup::Base;
    // const QWidget::BackgroundMode bgmode = lv->viewport()->backgroundMode();
    // const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode(bgmode);
#else
    const QColorGroup::ColorRole crole = QColorGroup::Base;
#endif
    if (oddRow) {
        colors.setColor(crole, *ZSafe::oddRowColor);
    }
    else {
        colors.setColor(crole, *ZSafe::evenRowColor);
    }
    QListViewItem::paintCell(p, colors, column, width, alignment);
}