From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- parts/filelist/filelist_item.cpp | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 parts/filelist/filelist_item.cpp (limited to 'parts/filelist/filelist_item.cpp') diff --git a/parts/filelist/filelist_item.cpp b/parts/filelist/filelist_item.cpp new file mode 100644 index 00000000..d528cc2c --- /dev/null +++ b/parts/filelist/filelist_item.cpp @@ -0,0 +1,104 @@ +/*************************************************************************** + * Copyright (C) 2004 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * 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 +#include +#include + +#include "filelist_item.h" + +#include +#include + +FileListItem * FileListItem::s_activeItem = 0; + +FileListItem::FileListItem( QListView * parent, KURL const & url, DocumentState state ) + : QListViewItem( parent, url.fileName() ), + _url( url ) + +{ + KFileItem fileItem( KFileItem::Unknown, KFileItem::Unknown, _url ); + _icon = fileItem.pixmap(KIcon::SizeSmall); + setState( state ); +} + +KURL FileListItem::url() +{ + return _url; +} + +DocumentState FileListItem::state( ) +{ + return _state; +} + +void FileListItem::setState( DocumentState state ) +{ + _state = state; + + switch( state ) + { + case Clean: + setPixmap( 0, _icon); +// setPixmap( 0, 0L ); + break; + case Modified: + setPixmap( 0, SmallIcon("filesave") ); + break; + case Dirty: + setPixmap( 0, SmallIcon("revert") ); + break; + case DirtyAndModified: + setPixmap( 0, SmallIcon("stop") ); + break; + } +} + +void FileListItem::setHeight( int ) +{ + QListViewItem::setHeight( KIcon::SizeSmall > listView()->fontMetrics().height() ? KIcon::SizeSmall : listView()->fontMetrics().height() ); +} + +void FileListItem::paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align ) +{ + QColorGroup mcg = cg; + + if ( isActive() ) + { + mcg.setColor( QColorGroup::Base, Qt::yellow ); + } + + QListViewItem::paintCell( p, mcg, column, width, align ); +} + +bool FileListItem::isActive( ) +{ + return ( s_activeItem == this ); +} + +//static +void FileListItem::setActive( FileListItem * item ) +{ + s_activeItem = item; +} + +int FileListItem::compare( QListViewItem * i, int col, bool ascending ) const +{ + QFileInfo info1( key( col, ascending ) ); //this + QFileInfo info2( i->key( col, ascending ) ); //that + int fileComp = info1.fileName().compare( info2.fileName() ); + if ( fileComp != 0 ) + return fileComp; + else + return info1.extension().compare( info2.extension() ); +} + +// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off; -- cgit v1.2.1