summaryrefslogtreecommitdiffstats
path: root/parts/fileview/fileitemfactory.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /parts/fileview/fileitemfactory.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'parts/fileview/fileitemfactory.cpp')
-rw-r--r--parts/fileview/fileitemfactory.cpp145
1 files changed, 145 insertions, 0 deletions
diff --git a/parts/fileview/fileitemfactory.cpp b/parts/fileview/fileitemfactory.cpp
new file mode 100644
index 00000000..614f535c
--- /dev/null
+++ b/parts/fileview/fileitemfactory.cpp
@@ -0,0 +1,145 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Mario Scalas *
+ * mario.scalas@libero.it *
+ * *
+ * 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 <qpainter.h>
+#include <kdebug.h>
+
+#include "filetreewidget.h"
+#include "fileitemfactory.h"
+
+using namespace filetreeview;
+
+///////////////////////////////////////////////////////////////////////////////
+// class FileTreeViewItem
+///////////////////////////////////////////////////////////////////////////////
+
+FileTreeWidget* FileTreeViewItem::listView() const
+{
+ return static_cast<FileTreeWidget*>( QListViewItem::listView() );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void FileTreeViewItem::hideOrShow()
+{
+ kdDebug( 9017 ) << "MyFileTreeViewItem::hideOrShow(): " + path() << endl;
+ setVisible( listView()->shouldBeShown( this ) );
+ FileTreeViewItem* item = static_cast<FileTreeViewItem*>( firstChild() );
+ while (item)
+ {
+ //kdDebug( 9017 ) << "MyFileTreeViewItem::hideOrShow(): " + item->path() << endl;
+ item->hideOrShow();
+ item = static_cast<FileTreeViewItem*>( item->nextSibling() );
+ }
+}
+
+bool FileTreeViewItem::changeActiveDir( const QString& olddir, const QString& newdir, bool foundolddir, bool foundnewdir )
+{
+ kdDebug( 9017 ) << "FileTreeViewItem::changeActiveDir(): " + olddir << " new: " << newdir << " for: " << path() << endl;
+
+ if ( this->path() == olddir && isDir() && m_isActiveDir )
+ {
+ m_isActiveDir = false;
+ setVisible( listView()->shouldBeShown( this ) );
+ foundolddir = true;
+ repaint();
+ }
+
+ if ( this->path() == newdir && isDir() && !m_isActiveDir )
+ {
+ m_isActiveDir = true;
+ setVisible( listView()->shouldBeShown( this ) );
+ foundnewdir = true;
+ repaint();
+ }
+
+ if( foundnewdir && foundolddir )
+ return true;
+
+ FileTreeViewItem* item = static_cast<FileTreeViewItem*>( firstChild() );
+ while( item )
+ {
+ if ( item->changeActiveDir( olddir, newdir, foundnewdir, foundolddir ) )
+ return true;
+ else
+ item = static_cast<FileTreeViewItem*>(item->nextSibling());
+ }
+ return false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+bool FileTreeViewItem::setProjectFile( QString const & path, bool pf )
+{
+
+ if ( this->path() == path && isProjectFile() != pf )
+ {
+ kdDebug( 9017 ) << "FileTreeViewItem::setProjectFile(): " + path << " projectfile: " << pf << endl;
+ m_isProjectFile = pf;
+ setVisible( listView()->shouldBeShown( this ) );
+ repaint();
+ return true;
+ }
+
+ FileTreeViewItem* item = static_cast<FileTreeViewItem*>( firstChild() );
+ while( item )
+ {
+ if ( item->setProjectFile( path, pf ) )
+ return true;
+ else
+ item = static_cast<FileTreeViewItem*>(item->nextSibling());
+ }
+ return false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void FileTreeViewItem::paintCell(QPainter *p, const QColorGroup &cg,
+ int column, int width, int alignment)
+{
+ if ( listView()->showNonProjectFiles() && isProjectFile() )
+ {
+ QFont font( p->font() );
+ font.setBold( true );
+ p->setFont( font );
+ }
+
+ if( isActiveDir() )
+ {
+ QFont font( p->font() );
+ font.setItalic( true );
+ p->setFont( font );
+ }
+
+ QListViewItem::paintCell( p, cg, column, width, alignment );
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+
+int FileTreeViewItem::compare( QListViewItem *i, int col, bool ascending ) const
+{
+ KFileTreeViewItem* rhs = dynamic_cast<KFileTreeViewItem*>( i );
+ if (rhs)
+ {
+ if (rhs->isDir() && !isDir())
+ return (ascending) ? 1 : -1;
+ else
+ if (!rhs->isDir() && isDir())
+ return (ascending) ? -1 : 1;
+ }
+
+ return QListViewItem::compare( i, col, ascending );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// class BranchItemFactory
+///////////////////////////////////////////////////////////////////////////////