00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qpopupmenu.h>
00013
#include <kdebug.h>
00014
#include <kaction.h>
00015
#include <klocale.h>
00016
00017
#include <kdevproject.h>
00018
00019
#include "fileviewpart.h"
00020
#include "filetreewidget.h"
00021
#include "fileitemfactory.h"
00022
00023
#include "filetreeviewwidgetimpl.h"
00024
00025
using namespace filetreeview;
00026
00028
00030
00031 FileTreeViewWidgetImpl::FileTreeViewWidgetImpl(
FileTreeWidget *parent,
const char *name )
00032 :
QObject( parent, name ), m_branchItemFactory( 0 ),
00033 m_part( parent->part() ), m_isReloadingTree( false )
00034 {
00035
kdDebug(9017) <<
"FileTreeViewWidgetImpl::FileTreeViewWidgetImpl()" <<
endl;
00036
00037
00038
m_actionToggleShowNonProjectFiles =
new KToggleAction( i18n(
"Show Non Project Files"),
KShortcut(),
00039
this, SLOT(
slotToggleShowNonProjectFiles()),
this,
"actiontoggleshowshownonprojectfiles" );
00040
m_actionToggleShowNonProjectFiles->
setWhatsThis(i18n(
"<b>Show non project files</b><p>Shows files that do not belong to a project in a file tree."));
00041
00042
00043
QDomDocument &dom = *
m_part->
projectDom();
00044
m_actionToggleShowNonProjectFiles->
setChecked( !DomUtil::readBoolEntry(dom,
"/kdevfileview/tree/hidenonprojectfiles") );
00045 }
00046
00048
00049 FileTreeViewWidgetImpl::~FileTreeViewWidgetImpl()
00050 {
00051
kdDebug(9017) <<
"FileTreeViewWidgetImpl::~FileTreeViewWidgetImpl()" <<
endl;
00052
00053
delete m_branchItemFactory;
00054
00055
QDomDocument &dom = *
m_part->
projectDom();
00056 DomUtil::writeBoolEntry( dom,
"/kdevfileview/tree/hidenonprojectfiles", !
showNonProjectFiles() );
00057 }
00058
00060
00061 FileTreeWidget *
FileTreeViewWidgetImpl::fileTree()
const
00062
{
00063
return static_cast<FileTreeWidget *>( parent() );
00064 }
00065
00067
00068 QDomDocument &
FileTreeViewWidgetImpl::projectDom()
const
00069
{
00070
return *
part()->
projectDom();
00071 }
00072
00074
00075 QString FileTreeViewWidgetImpl::projectDirectory()
const
00076
{
00077
return part()->
project()->
projectDirectory();
00078 }
00079
00081
00082 bool FileTreeViewWidgetImpl::showNonProjectFiles()
const
00083
{
00084
return m_actionToggleShowNonProjectFiles->
isChecked();
00085 }
00086
00088
00089 void FileTreeViewWidgetImpl::fillPopupMenu(
QPopupMenu *popupMenu,
QListViewItem *item )
const
00090
{
00091
00092
00093
00094
if (item ==
fileTree()->firstChild() &&
canReloadTree())
00095 {
00096
int id = popupMenu->insertItem( i18n(
"Reload Tree"),
this, SLOT(
slotReloadTree() ) );
00097 popupMenu->setWhatsThis(
id, i18n(
"<b>Reload tree</b><p>Reloads the project files tree.") );
00098 }
00099
00100
m_actionToggleShowNonProjectFiles->
plug( popupMenu );
00101 }
00102
00104
00105 KURL::List FileTreeViewWidgetImpl::selectedPathUrls()
00106 {
00107
kdDebug(9017) <<
"FileTreeViewWidgetImpl::selectedPathUrls()" <<
endl;
00108
00109
KURL::List urlList;
00110
00111
QValueList<QListViewItem*> list =
allSelectedItems(
fileTree()->firstChild() );
00112
QValueList<QListViewItem*>::Iterator it = list.begin();
00113
while( it != list.end() )
00114 {
00115
KURL url;
00116 url.
setPath( static_cast<FileTreeViewItem*>( *it )->path() );
00117 urlList << url;
00118 ++it;
00119 }
00120
00121
return urlList;
00122 }
00123
00125
00126 QValueList<QListViewItem*> FileTreeViewWidgetImpl::allSelectedItems(
QListViewItem * item )
const
00127
{
00128
QValueList<QListViewItem*> list;
00129
00130
if ( item )
00131 {
00132
if ( item->isSelected() )
00133 {
00134 list << item;
00135 }
00136
00137
QListViewItem * it = item->firstChild();
00138
while( it )
00139 {
00140 list +=
allSelectedItems( it );
00141 it = it->nextSibling();
00142 }
00143 }
00144
00145
return list;
00146 }
00147
00149
00150 void FileTreeViewWidgetImpl::slotReloadTree()
00151 {
00152
fileTree()->
openDirectory(
projectDirectory() );
00153 }
00154
00156
00157 void FileTreeViewWidgetImpl::slotToggleShowNonProjectFiles()
00158 {
00159
fileTree()->
hideOrShow();
00160 }
00161
00162
#include "filetreeviewwidgetimpl.moc"