fileitemfactory.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <qpainter.h>
00013 #include <kdebug.h>
00014
00015 #include "filetreewidget.h"
00016 #include "fileitemfactory.h"
00017
00018 using namespace filetreeview;
00019
00021
00023
00024 FileTreeWidget* FileTreeViewItem::listView() const
00025 {
00026 return static_cast<FileTreeWidget*>( QListViewItem::listView() );
00027 }
00028
00030
00031 void FileTreeViewItem::hideOrShow()
00032 {
00033 kdDebug( 9017 ) << "MyFileTreeViewItem::hideOrShow(): " + path() << endl;
00034 setVisible( listView()->shouldBeShown( this ) );
00035
00036 FileTreeViewItem* item = static_cast<FileTreeViewItem*>( firstChild() );
00037 while (item)
00038 {
00039
00040 item->hideOrShow();
00041 item = static_cast<FileTreeViewItem*>( item->nextSibling() );
00042 }
00043 }
00044
00046
00047 bool FileTreeViewItem::setProjectFile( QString const & path, bool pf )
00048 {
00049 kdDebug( 9017 ) << "FileTreeViewItem::setProjectFile(): " + path << endl;
00050
00051 if ( this->path() == path )
00052 {
00053 m_isProjectFile = pf;
00054 setVisible( listView()->shouldBeShown( this ) );
00055 repaint();
00056 return true;
00057 }
00058
00059 FileTreeViewItem* item = static_cast<FileTreeViewItem*>( firstChild() );
00060 while( item )
00061 {
00062 if ( item->setProjectFile( path, pf ) )
00063 return true;
00064 else
00065 item = static_cast<FileTreeViewItem*>(item->nextSibling());
00066 }
00067 return false;
00068 }
00069
00071
00072 void FileTreeViewItem::paintCell(QPainter *p, const QColorGroup &cg,
00073 int column, int width, int alignment)
00074 {
00075 if ( listView()->showNonProjectFiles() && isProjectFile() )
00076 {
00077 QFont font( p->font() );
00078 font.setBold( true );
00079 p->setFont( font );
00080 }
00081
00082 QListViewItem::paintCell( p, cg, column, width, alignment );
00083 }
00084
00085
00087
00088 int FileTreeViewItem::compare( QListViewItem *i, int col, bool ascending ) const
00089 {
00090 KFileTreeViewItem* rhs = dynamic_cast<KFileTreeViewItem*>( i );
00091 if (rhs)
00092 {
00093 if (rhs->isDir() && !isDir())
00094 return (ascending) ? 1 : -1;
00095 else
00096 if (!rhs->isDir() && isDir())
00097 return (ascending) ? -1 : 1;
00098 }
00099
00100 return QListViewItem::compare( i, col, ascending );
00101 }
00102
00104
This file is part of the documentation for KDevelop Version 3.1.2.