KDevelop API Documentation

filelist_item.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Jens Dagerbo                                    *
00003  *   jens.dagerbo@swipnet.se                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include <kiconloader.h>
00013 #include <qfontmetrics.h>
00014          
00015 #include "filelist_item.h"
00016 
00017 FileListItem * FileListItem::s_activeItem = 0;
00018 
00019 FileListItem::FileListItem( QListView * parent, KURL const & url, DocumentState state )
00020     : QListViewItem( parent, QString(" ") + url.fileName() ), 
00021     _url( url )
00022 {
00023     setState( state );
00024 }
00025     
00026 KURL FileListItem::url()
00027 {
00028     return _url;
00029 }
00030 
00031 DocumentState FileListItem::state( )
00032 {
00033     return _state;
00034 }
00035 
00036 void FileListItem::setState( DocumentState state )
00037 {
00038     _state = state;
00039     
00040     switch( state )
00041     {
00042         case Clean:
00043             setPixmap( 0, 0L );
00044             break;
00045         case Modified:
00046             setPixmap( 0, SmallIcon("filesave") );
00047             break;
00048         case Dirty:
00049             setPixmap( 0, SmallIcon("revert") );
00050             break;
00051         case DirtyAndModified:
00052             setPixmap( 0, SmallIcon("stop") );
00053             break;                  
00054     }
00055 }
00056 
00057 void FileListItem::setHeight( int )
00058 {
00059     QListViewItem::setHeight( KIcon::SizeSmall > listView()->fontMetrics().height() ? KIcon::SizeSmall : listView()->fontMetrics().height() );
00060 }
00061 
00062 void FileListItem::paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align )
00063 {
00064     QColorGroup mcg = cg;
00065     
00066     if ( isActive() )
00067     {
00068         mcg.setColor( QColorGroup::Base, Qt::yellow );
00069     }
00070     
00071     QListViewItem::paintCell( p, mcg, column, width, align );
00072 }
00073 
00074 bool FileListItem::isActive( )
00075 {
00076     return ( s_activeItem == this );
00077 }
00078 
00079 //static
00080 void FileListItem::setActive( FileListItem * item )
00081 {
00082     s_activeItem = item;
00083 }
00084 
00085 
00086 // kate: space-indent off; indent-width 4; tab-width 4; show-tabs off;
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:40 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003