2
buglvi.cpp - Custom QListViewItem that holds a Bug object
4
copyright : (c) 2001 by Martijn Klingens
5
email : klingens@kde.org
7
*************************************************************************
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
14
*************************************************************************
21
#include <kstringhandler.h>
24
#include "bugsystem.h"
25
#include "bugserver.h"
27
using namespace KBugBusterMainWindow;
29
BugLVI::BugLVI( K3ListView *parent , const Bug &bug )
30
: K3ListViewItem( parent, bug.number() + " ",
31
i18np( "1 day", "%1 days", bug.age() ),
32
bug.title(), //KStringHandler::csqueeze( bug.title(), 70 ),
33
Bug::statusLabel( bug.status() ),
34
Bug::severityLabel( bug.severity() ),
35
bug.submitter().fullName() )
39
bool hasCommands = BugSystem::self()->server()->hasCommandsFor( bug );
40
mCommandState = hasCommands ? BugCommand::Queued : BugCommand::None;
42
if ( bug.age() == 0xFFFFFFFF )
43
setText( 1, i18n( "Unknown" ) );
45
Person developer = bug.developerTODO();
46
if ( !developer.name.isEmpty() )
47
setText( 3, i18n( "%1 (%2)", Bug::statusLabel( bug.status() ), developer.name ) );
54
QString BugLVI::key( int column, bool /* ascending */ ) const
60
key = text( 0 ).rightJustified( 10, '0' );
62
else if ( column == 1 )
64
if ( m_bug.age() == 0xFFFFFFFF )
67
key = QString::number( m_bug.age() ).rightJustified( 10, '0' );
69
else if ( column == 4 )
71
key = QString::number( 10 - m_bug.severity() );
72
key += m_bug.number().rightJustified( 10, '0' );
82
void BugLVI::paintCell(QPainter* p, const QColorGroup& cg,
83
int column, int width, int align)
85
QColorGroup newCg = cg;
86
if ( mCommandState == BugCommand::Queued ) {
87
QFont font = p->font();
90
} else if ( mCommandState == BugCommand::Sent ) {
91
QFont font = p->font();
92
font.setItalic( true );
94
} else if ( m_bug.status() == Bug::Closed ) {
95
// Different color for closed bugs
96
newCg.setColor( QPalette::Text, cg.color( QPalette::Dark ) );
99
K3ListViewItem::paintCell( p, newCg, column, width, align );
102
void BugLVI::setCommandState( BugCommand::State state)
104
mCommandState = state;
107
// vim: set et ts=4 sw=4 sts=4: