filetreeviewwidgetimpl.cpp
Go to the documentation of this file.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 #include <kdeversion.h>
00017
00018 #include <kdevproject.h>
00019
00020 #include "fileviewpart.h"
00021 #include "filetreewidget.h"
00022 #include "fileitemfactory.h"
00023
00024 #include "filetreeviewwidgetimpl.h"
00025
00026 using namespace filetreeview;
00027
00029
00031
00032 FileTreeViewWidgetImpl::FileTreeViewWidgetImpl( FileTreeWidget *parent, const char *name )
00033 : QObject( parent, name ), m_branchItemFactory( 0 ),
00034 m_part( parent->part() ), m_isReloadingTree( false )
00035 {
00036 kdDebug(9017) << "FileTreeViewWidgetImpl::FileTreeViewWidgetImpl()" << endl;
00037
00038
00039 m_actionToggleShowNonProjectFiles = new KToggleAction( i18n("Show Non Project Files"), KShortcut(),
00040 this, SLOT(slotToggleShowNonProjectFiles()), this, "actiontoggleshowshownonprojectfiles" );
00041 #if KDE_IS_VERSION(3,2,90)
00042 m_actionToggleShowNonProjectFiles->setCheckedState(i18n("Hide Non Project Files"));
00043 #endif
00044 m_actionToggleShowNonProjectFiles->setWhatsThis(i18n("<b>Show non project files</b><p>Shows files that do not belong to a project in a file tree."));
00045
00046
00047 QDomDocument &dom = *m_part->projectDom();
00048 m_actionToggleShowNonProjectFiles->setChecked( !DomUtil::readBoolEntry(dom, "/kdevfileview/tree/hidenonprojectfiles") );
00049 }
00050
00052
00053 FileTreeViewWidgetImpl::~FileTreeViewWidgetImpl()
00054 {
00055 kdDebug(9017) << "FileTreeViewWidgetImpl::~FileTreeViewWidgetImpl()" << endl;
00056
00057 delete m_branchItemFactory;
00058
00059 QDomDocument &dom = *m_part->projectDom();
00060 DomUtil::writeBoolEntry( dom, "/kdevfileview/tree/hidenonprojectfiles", !showNonProjectFiles() );
00061 }
00062
00064
00065 FileTreeWidget *FileTreeViewWidgetImpl::fileTree() const
00066 {
00067 return static_cast<FileTreeWidget *>( parent() );
00068 }
00069
00071
00072 QDomDocument &FileTreeViewWidgetImpl::projectDom() const
00073 {
00074 return *part()->projectDom();
00075 }
00076
00078
00079 QString FileTreeViewWidgetImpl::projectDirectory() const
00080 {
00081 return part()->project()->projectDirectory();
00082 }
00083
00085
00086 bool FileTreeViewWidgetImpl::showNonProjectFiles() const
00087 {
00088 return m_actionToggleShowNonProjectFiles->isChecked();
00089 }
00090
00092
00093 void FileTreeViewWidgetImpl::fillPopupMenu( QPopupMenu *popupMenu, QListViewItem *item ) const
00094 {
00095
00096
00097
00098 if (item == fileTree()->firstChild() && canReloadTree())
00099 {
00100 int id = popupMenu->insertItem( i18n( "Reload Tree"), this, SLOT( slotReloadTree() ) );
00101 popupMenu->setWhatsThis( id, i18n("<b>Reload tree</b><p>Reloads the project files tree.") );
00102 }
00103
00104 m_actionToggleShowNonProjectFiles->plug( popupMenu );
00105 }
00106
00108
00109 KURL::List FileTreeViewWidgetImpl::selectedPathUrls()
00110 {
00111 kdDebug(9017) << "FileTreeViewWidgetImpl::selectedPathUrls()" << endl;
00112
00113 KURL::List urlList;
00114
00115 QValueList<QListViewItem*> list = allSelectedItems( fileTree()->firstChild() );
00116 QValueList<QListViewItem*>::Iterator it = list.begin();
00117 while( it != list.end() )
00118 {
00119 KURL url;
00120 url.setPath( static_cast<FileTreeViewItem*>( *it )->path() );
00121 urlList << url;
00122 ++it;
00123 }
00124
00125 return urlList;
00126 }
00127
00129
00130 QValueList<QListViewItem*> FileTreeViewWidgetImpl::allSelectedItems( QListViewItem * item ) const
00131 {
00132 QValueList<QListViewItem*> list;
00133
00134 if ( item )
00135 {
00136 if ( item->isSelected() )
00137 {
00138 list << item;
00139 }
00140
00141 QListViewItem * it = item->firstChild();
00142 while( it )
00143 {
00144 list += allSelectedItems( it );
00145 it = it->nextSibling();
00146 }
00147 }
00148
00149 return list;
00150 }
00151
00153
00154 void FileTreeViewWidgetImpl::slotReloadTree()
00155 {
00156 fileTree()->openDirectory( projectDirectory() );
00157 }
00158
00160
00161 void FileTreeViewWidgetImpl::slotToggleShowNonProjectFiles()
00162 {
00163 fileTree()->hideOrShow();
00164 }
00165
00166 #include "filetreeviewwidgetimpl.moc"
This file is part of the documentation for KDevelop Version 3.1.2.