kate Library API Documentation

kateprojectdirview.cpp

00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> 00004 Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #include "kateprojectdirview.h" 00022 #include "kateprojectdirview.moc" 00023 00024 #include <kdialogbase.h> 00025 #include <kicontheme.h> 00026 #include <klocale.h> 00027 00028 class KateProjectDirViewDialog : public KDialogBase 00029 { 00030 public: 00031 KateProjectDirViewDialog (Kate::Project *project, const QString &dir, QWidget *parent); 00032 ~KateProjectDirViewDialog (); 00033 00034 int exec(); 00035 00036 private: 00037 Kate::Project *m_project; 00038 QString m_dir; 00039 KateProjectDirView *m_view; 00040 }; 00041 00042 KateProjectDirView::KateProjectDirView (Kate::Project *project, const QString &dir, QWidget *parent) : KFileIconView (parent, "projectdirview") 00043 { 00044 m_project = project; 00045 m_relDir = dir; 00046 m_dir = KURL (m_project->dir() + QString ("/") + m_relDir); 00047 m_dirs = m_project->dirs (dir); 00048 m_files = m_project->files (dir); 00049 00050 setSelectionMode (KFile::Extended); 00051 setIconSize( KIcon::SizeMedium ); 00052 00053 m_listJob = KIO::listDir (m_dir, false, true); 00054 connect (m_listJob, SIGNAL(entries( KIO::Job *, const KIO::UDSEntryList&)), this, SLOT(entries( KIO::Job *, const KIO::UDSEntryList&))); 00055 } 00056 00057 KateProjectDirView::~KateProjectDirView () 00058 { 00059 } 00060 00061 void KateProjectDirView::entries( KIO::Job *, const KIO::UDSEntryList& list) 00062 { 00063 for (uint z=0; z < list.count(); z++) 00064 { 00065 KFileItem *item = new KFileItem (list[z], m_dir, true, true); 00066 00067 if (item->isDir()) 00068 { 00069 if ((item->name() != QString (".")) && (item->name() != QString ("..")) && (m_dirs.findIndex (item->name()) == -1)) 00070 insertItem (item); 00071 } 00072 else 00073 { 00074 if (m_files.findIndex (item->name()) == -1) 00075 insertItem (item); 00076 } 00077 } 00078 } 00079 00080 void KateProjectDirView::addDialog (Kate::Project *project, const QString &dir, QWidget *parent) 00081 { 00082 KateProjectDirViewDialog* dlg = new KateProjectDirViewDialog (project, dir, parent); 00083 dlg->exec(); 00084 delete dlg; 00085 } 00086 00087 KateProjectDirViewDialog::KateProjectDirViewDialog (Kate::Project *project, const QString &dir, QWidget *parent) : KDialogBase (parent, "dirviewdialog", true, i18n ("Add Directories/Files to Project"), KDialogBase::Ok|KDialogBase::Cancel) 00088 { 00089 m_project = project; 00090 m_dir = dir; 00091 m_view = new KateProjectDirView (project, dir, this); 00092 setMainWidget(m_view); 00093 } 00094 00095 KateProjectDirViewDialog::~KateProjectDirViewDialog () 00096 { 00097 } 00098 00099 int KateProjectDirViewDialog::exec() 00100 { 00101 int n = 0; 00102 00103 if ((n = KDialogBase::exec())) 00104 { 00105 QStringList dirs, files; 00106 for (KFileItem *item = m_view->firstFileItem(); item != 0; item = m_view->nextItem (item)) 00107 { 00108 if (m_view->isSelected (item)) 00109 { 00110 if (item->isDir()) 00111 dirs.push_back (item->name()); 00112 else 00113 files.push_back (item->name()); 00114 } 00115 } 00116 00117 m_project->addDirs (m_dir, dirs); 00118 m_project->addFiles (m_dir, files); 00119 } 00120 00121 return n; 00122 }
KDE Logo
This file is part of the documentation for kate Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 13 21:47:01 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003