diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /kbugbuster/gui/buglvi.cpp | |
download | tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbugbuster/gui/buglvi.cpp')
-rw-r--r-- | kbugbuster/gui/buglvi.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/kbugbuster/gui/buglvi.cpp b/kbugbuster/gui/buglvi.cpp new file mode 100644 index 00000000..be629510 --- /dev/null +++ b/kbugbuster/gui/buglvi.cpp @@ -0,0 +1,109 @@ +/* + buglvi.cpp - Custom QListViewItem that holds a Bug object + + copyright : (c) 2001 by Martijn Klingens + email : klingens@kde.org + + ************************************************************************* + * * + * 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 <qfont.h> +#include <qpainter.h> + +#include <kstringhandler.h> +#include <kdebug.h> + +#include "bugsystem.h" +#include "bugserver.h" + +#include "buglvi.h" + +using namespace KBugBusterMainWindow; + +BugLVI::BugLVI( KListView *parent , const Bug &bug ) +: KListViewItem( parent, bug.number() + " ", + i18n( "1 day", "%n days", bug.age() ), + bug.title(), //KStringHandler::csqueeze( bug.title(), 70 ), + Bug::statusLabel( bug.status() ), + Bug::severityLabel( bug.severity() ), + bug.submitter().fullName() ) +{ + m_bug = bug; + + bool hasCommands = BugSystem::self()->server()->hasCommandsFor( bug ); + mCommandState = hasCommands ? BugCommand::Queued : BugCommand::None; + + if ( bug.age() == 0xFFFFFFFF ) + setText( 1, i18n( "Unknown" ) ); + + Person developer = bug.developerTODO(); + if ( !developer.name.isEmpty() ) + setText( 3, i18n( "%1 (%2)" ).arg( Bug::statusLabel( bug.status() ), developer.name ) ); +} + +BugLVI::~BugLVI() +{ +} + +QString BugLVI::key( int column, bool /* ascending */ ) const +{ + QString key; + + if ( column == 0 ) + { + key = text( 0 ).rightJustify( 10, '0' ); + } + else if ( column == 1 ) + { + if ( m_bug.age() == 0xFFFFFFFF ) + key = "0"; + else + key = QString::number( m_bug.age() ).rightJustify( 10, '0' ); + } + else if ( column == 4 ) + { + key = QString::number( 10 - m_bug.severity() ); + key += m_bug.number().rightJustify( 10, '0' ); + } + else + { + key = text( column ); + } + + return key; +} + +void BugLVI::paintCell(QPainter* p, const QColorGroup& cg, + int column, int width, int align) +{ + QColorGroup newCg = cg; + if ( mCommandState == BugCommand::Queued ) { + QFont font = p->font(); + font.setBold( true ); + p->setFont( font ); + } else if ( mCommandState == BugCommand::Sent ) { + QFont font = p->font(); + font.setItalic( true ); + p->setFont( font ); + } else if ( m_bug.status() == Bug::Closed ) { + // Different color for closed bugs + newCg.setColor( QColorGroup::Text, cg.color( QColorGroup::Dark ) ); + } + + KListViewItem::paintCell( p, newCg, column, width, align ); +} + +void BugLVI::setCommandState( BugCommand::State state) +{ + mCommandState = state; +} + +// vim: set et ts=4 sw=4 sts=4: + |